U
    /e]6                     @  s  d Z ddlmZ ddlZeeZddlmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd	lmZ d
dl m!Z! dZ"e
G dd de!Z#G dd de!Z$G dd de#Z%G dd de%Z&G dd de#Z'G dd de'Z(G dd de'Z)G dd de(Z*G dd de(Z+G dd  d e#Z,G d!d" d"e#Z-G d#d$ d$e#Z.G d%d& d&e#Z/G d'd( d(e#Z0dS ))z4 Various kinds of input widgets and form controls.

    )annotationsN   )CalendarPosition)abstract)BoolColorHexDateDictEitherEnumFloatInstanceIntIntervalListNullNullableOverridePositiveIntReadonlyStringTuple   )TickFormatter   )Widget)AutocompleteInputColorPicker
DatePicker	FileInputInputWidgetMultiChoiceMultiSelectNumericInputPasswordInputSelectSpinner	TextInputTextAreaInputc                   @  s(   e Zd ZdZedddZedd ZdS )r    z- Abstract base class for input widgets.

     z
    Widget's label.
    defaulthelpc                 C  sH   |  d}t|trt|S t|tr.t|S t|tr@t|S |S d S )Nvalue)lookup
isinstancer   floatr   intr   str)clsvalZprop_obj r5   ?/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/models/widgets/inputs.pycoerce_valueT   s    



zInputWidget.coerce_valueN)__name__
__module____qualname____doc__r   titleclassmethodr7   r5   r5   r5   r6   r    J   s   r    c                   @  sp   e Zd ZdZeeeeedddZeeeeedddZ	eeeeedddZ
edddZedd	dZd
S )r   z_ Present a file-chooser dialog to users and return the contents of the
    selected files.
    r)   a  
    The base64-enconded contents of the file or files that were loaded.

    If `mulitiple` is set to False (default), this value is a single string with the contents
    of the single file that was chosen.

    If `multiple` is True, this value is a list of strings, each containing the contents of
    one of the multiple files that were chosen.

    The sequence of files is given by the list of filenames (see below)
    r*   a  
    The mime-type of the file or files that were loaded.

    If `mulitiple` is set to False (default), this value is a single string with the
    mime-type of the single file that was chosen.

    If `multiple` is True, this value is a list of strings, each containing the
    mime-type of one of the multiple files that were chosen.

    The sequence of files is given by the list of filename (see below)
    a9  
    The name(s) of the file or files that were loaded.

    If `mulitiple` is set to False (default), this value is a single string with the
    name of the single file that was chosen.

    If `multiple` is True, this value is a list of strings, each containing the
    name of one of the multiple files that were chosen.

    This list provides the sequence of files for the respective lists in value and mime-type

    .. note::
        The full file path is not included since browsers will not provide
        access to that information for security reasons.
    a  
    Comma-separated list of standard HTML file input filters that restrict what
    files the user can pick from. Values can be:

    `<file extension>`:
        Specific file extension(s) (e.g: .gif, .jpg, .png, .doc) are pickable

    `audio/*`:
        all sound files are pickable

    `video/*`:
        all video files are pickable

    `image/*`:
        all image files are pickable

    `<media type>`:
        A valid `IANA Media Type`_, with no parameters.

    .. _IANA Media Type: https://www.iana.org/assignments/media-types/media-types.xhtml

    .. note::
        A bug in some versions of Chrome on macOS Big Sur may limit
        how you can set a file input filter for those users. In those cases,
        it is impossible to limit the user's selection to specific file
        extensions - instead, the browser will limit users to predefined sets of
        file types, such as ``Text/*`` or ``Image/*``. See :bokeh-issue:`10888`
        for more information.
    Fz
    set multiple=False (default) for single file selection, set multiple=True if
    selection of more than one file at a time should be possible.
    N)r8   r9   r:   r;   r   r
   r   r   r-   Z	mime_typefilenameacceptr   multipler5   r5   r5   r6   r   d   s   r   c                   @  sn   e Zd ZdZeeeeddZeeeeddZ	eeeeddZ
edddZed	d
ddZeeeeeddZdS )r#   z Numeric input widget.

    za
    Initial or entered value.

    Change events are triggered whenever <enter> is pressed.
    r,   z*
    Optional lowest allowable value.
    z+
    Optional highest allowable value.
    r)   ,
    Placeholder for empty input field.
    r*   r1   r0   z
    Define the type of number which can be enter in the input

    example
    mode int: 1, -1, 156
    mode float: 1, -1.2, 1.1e-25
    z
    N)r8   r9   r:   r;   r
   r   r   r   r-   lowhighr   placeholderr   moder   r   formatr5   r5   r5   r6   r#      s   r#   c                      s   e Zd ZdZdd fddZeeeee	ddZ
edd	Zeed
eddddZeededdddZee	edddZ  ZS )r&   z$ Numeric Spinner input widget.

    None)returnc                   s.   d|krd|kr|d |d< t  jf | d S )Nr-   value_throttled)super__init__)selfkwargs	__class__r5   r6   rL      s    zSpinner.__init__z3
    value reported at the end of interactions
    rA   r0   r+   gؗҜ<infr   z;
    The step added or subtracted to the current value
    )startendr+   r,   r   
   zo
    Defines the multiplication factor applied to step when the page up and page
    down keys are pressed
    d   z
    Defines the debounce time in ms before updating `value_throttled` when the
    mouse wheel is used to change the input
    r*   )r8   r9   r:   r;   rL   r   r
   r   r   r   rJ   r   rF   r   r0   stepZpage_step_multiplierZ
wheel_wait__classcell__r5   r5   rO   r6   r&      s   
r&   c                   @  s@   e Zd ZdZedddZedddZedddZee	ddZ
d	S )
TextLikeInputz. Base class for text-like input widgets.

    r)   zf
    Initial or entered text value.

    Change events are triggered whenever <enter> is pressed.
    r*   z}
    Initial or current value.

    Change events are triggered whenever any update happens, i.e. on every
    keypress.
    rB   z*
    Max count of characters in field
    rA   N)r8   r9   r:   r;   r   r-   Zvalue_inputrE   r   r   
max_lengthr5   r5   r5   r6   rY      s
   rY   c                   @  s   e Zd ZdZdS )r'   z  Single-line input widget.

    Nr8   r9   r:   r;   r5   r5   r5   r6   r'     s   r'   c                   @  s2   e Zd ZdZedddZedddZeddZd	S )
r(   z Multi-line input widget.

       zX
    Specifies the width of the text area (in average character width). Default: 20
    r*   r   zF
    Specifies the height of the text area (in lines). Default: 2
    i  rQ   N)	r8   r9   r:   r;   r   colsZrowsr   rZ   r5   r5   r5   r6   r(     s   r(   c                   @  s   e Zd ZdZdS )r$   a#   Single-line password input widget.

    This widget hides the input value so that it is not visible in the browser.

    .. warning::
        Secure transmission of the password to Bokeh server application code
        requires configuring the server for SSL (i.e. HTTPS) termination.

    Nr[   r5   r5   r5   r6   r$   '  s   r$   c                   @  s@   e Zd ZdZeeddZedddZe	dddZ
e	dd	dZd
S )r   z5 Single-line input widget with auto-completion.

    z}
    A list of completion strings. This will be used to guide the
    user upon typing the beginning of a desired value.
    rA   r   zU
    The number of characters a user must type before completions are presented.
    r*   Tz"Enable or disable case sensitivityzs
    Set to False in order to allow users to enter text that is not present in the list of completion strings.
    N)r8   r9   r:   r;   r   r   Zcompletionsr   Zmin_charactersr   Zcase_sensitiveZrestrictr5   r5   r5   r6   r   3  s
   r   c                
   @  sr   e Zd ZdZeeeeeeeeeeeeeeedd	eee
edd Zeddd	e
d	d Zd
S )r%   z Single-select widget.

    a  
    Available selection options. Options may be provided either as a list of
    possible string values, or as a list of tuples, each of the form
    ``(value, label)``. In the latter case, the visible widget text for each
    value will be corresponding given label. Option groupings can be provided
    by supplying a dictionary object whose values are in the aforementioned
    list format
    rA   c                 C  s   dd | D S )Nc                 S  s   g | ]}|d krdn|qS Nr)   r5   ).0itemr5   r5   r6   
<listcomp>T  s     z#Select.<lambda>.<locals>.<listcomp>r5   )vr5   r5   r6   <lambda>T      zSelect.<lambda>r)   z$
    Initial or selected value.
    r*   c                 C  s   dS r^   r5   )_r5   r5   r6   rc   X  rd   N)r8   r9   r:   r;   r
   r   r   r   r	   Zacceptsr   optionsr-   r5   r5   r5   r6   r%   H  s     
 r%   c                   @  s@   e Zd ZdZeeeeeeddZeeddZ	e
dddZdS )	r"   z Multi-select widget.

      
    Available selection options. Options may be provided either as a list of
    possible string values, or as a list of tuples, each of the form
    ``(value, label)``. In the latter case, the visible widget text for each
    value will be corresponding given label.
    rA   %
    Initial or selected values.
       z
    The number of visible options in the dropdown list. (This uses the
    ``select`` HTML element's ``size`` attribute. Some browsers might not
    show less than 3 options.)
    r*   N)r8   r9   r:   r;   r   r
   r   r   rf   r-   r   sizer5   r5   r5   r6   r"   Z  s   r"   c                   @  s|   e Zd ZdZeeeeeeddZeeddZ	e
dddZeeddZeed	dZeed
dZeeddZe
dddZdS )r!   z MultiChoice widget.

    rg   rA   rh   Tz>
    Whether to add a button to remove a selected option.
    r*   z;
    The maximum number of items that can be selected.
    zF
    The number of choices that will be rendered in the dropdown.
    zh
    The number of choices that will be rendered in the dropdown
    when search string is entered.
    z:
    A string that is displayed if not item is added.
    z:
    Specify whether the choices should be solidly filled.N)r8   r9   r:   r;   r   r
   r   r   rf   r-   r   Zdelete_buttonr   r   Z	max_itemsZoption_limitZsearch_option_limitrE   Zsolidr5   r5   r5   r6   r!   q  s   r!   c                   @  s   e Zd ZdZeddZeeddZeeddZe	e
eeeeg ddZe	e
eeeeg ddZeed	d
dZedddZdS )r   z) Calendar-based date picker widget.

    z%
    The initial or picked date.
    rA   z+
    Optional earliest allowable date.
    z)
    Optional latest allowable date.
    z
    A list of dates of ``(start, end)`` date ranges to make unavailable for
    selection. All other dates will be avalable.

    .. note::
        Only one of ``disabled_dates`` and ``enabled_dates`` should be specified.
    r*   z
    A list of dates of ``(start, end)`` date ranges to make available for
    selection. All other dates will be unavailable.

    .. note::
        Only one of ``disabled_dates`` and ``enabled_dates`` should be specified.
    autozX
    Where the calendar is rendered relative to the input when ``inline`` is False.
    Fz:
    Whether the calendar sholud be displayed inline.
    N)r8   r9   r:   r;   r   r-   r   Zmin_dateZmax_dater   r
   r   Zdisabled_datesZenabled_datesr   r   positionr   inliner5   r5   r5   r6   r     s   
r   c                   @  s   e Zd ZdZedddZdS )r   z Color picker widget

    .. warning::
        This widget as a limited support on *Internet Explorer* (it will be displayed
        as a simple text input).

    z#000000zF
    The initial color of the picked color (named or hexadecimal)
    r*   N)r8   r9   r:   r;   r   colorr5   r5   r5   r6   r     s   r   )1r;   
__future__r   logging	getLoggerr8   logZ
core.enumsr   Zcore.has_propsr   Zcore.propertiesr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   
formattersr   Zwidgetr   __all__r    r   r#   r&   rY   r'   r(   r$   r   r%   r"   r!   r   r   r5   r5   r5   r6   <module>   s0   
PQ#))