
    -egA                       d Z ddlmZ ddlZ ej        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mZmZm Z  dd	l!m"Z" dd
l#m$Z$ ddl%m&Z& dZ'e
 G d de&                      Z( G d de(          Z) G d de(          Z* G d de*          Z+e
 G d de&                      Z, G d de,          Z- G d de,          Z. G d de(          Z/ G d de/          Z0 G d  d!e/          Z1 G d" d#e0          Z2 G d$ d%e0          Z3 G d& d'e(          Z4 G d( d)e(          Z5 G d* d+e(          Z6 G d, d-e(          Z7 G d. d/e(          Z8dS )0z4 Various kinds of input widgets and form controls.

    )annotationsN)inf   )abstract)BoolColorColorHexDictEitherEnumFloatInstanceIntIntervalListNonNegativeNullNullableOverridePositiveReadonlyRequiredSeqStringTuple   )TickFormatter)Tooltip   )Widget)AutocompleteInputCheckboxColorMapColorPicker	FileInputInputWidgetMultiChoiceMultiSelectNumericInputPasswordInputSelectSpinnerSwitchTextAreaInput	TextInputc                       e Zd ZdZd fdZ edd          Z e ee e	e
                    dd	          Zed
             Z xZS )r&   z- Abstract base class for input widgets.

    returnNonec                :     t                      j        |i | d S Nsuper__init__selfargskwargs	__class__s      ;lib/python3.11/site-packages/bokeh/models/widgets/inputs.pyr7   zInputWidget.__init__Y   %    $)&)))))     z
    Widget's label.
    defaulthelpNzg
    Either a plain text or a tooltip with a rich HTML description of the function of this widget.
    c                   |                      d          }t          |t                    rt          |          S t          |t                    rt          |          S t          |t                    rt          |          S |S )Nvalue)lookup
isinstancer   floatr   intr   str)clsvalprop_objs      r=   coerce_valuezInputWidget.coerce_valued   sp    ::g&&h&& 	::#&& 	s88O&)) 	s88OJr?   r1   r2   )__name__
__module____qualname____doc__r7   r   titler   r   r   r   descriptionclassmethodrN   __classcell__r<   s   @r=   r&   r&   R   s         
* * * * * * F2 % 	 	 	E (66&((7*;*;<<d R 	 	 	K 	 	 [	 	 	 	 	r?   r&   c                  .    e Zd ZdZd fdZ e ee ee                    d          Z	 e ee ee                    d          Z
 e ee ee                    d          Z ee ee          d	d
          Z edd          Z xZS )r%   z_ Present a file-chooser dialog to users and return the contents of the
    selected files.
    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zFileInput.__init__z   r>   r?   a  
    The base64-enconded contents of the file or files that were loaded.

    If `multiple` 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)
    rC   a  
    The mime-type of the file or files that were loaded.

    If `multiple` 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)
    a8  
    The name(s) of the file or files that were loaded.

    If `multiple` 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.
    r@   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.
    rA   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.
    rO   )rP   rQ   rR   rS   r7   r   r   r   r   rE   	mime_typefilenameacceptr   multiplerW   rX   s   @r=   r%   r%   t   s        
* * * * * * HVVFDDLL11 
9 
	 
	 
	E V55 
= 
	 
	 
	I xvttF||44 < 	 	 	H  VFDDLL" < 	 	 	F< tE ) 	 	 	HHHHHr?   r%   c                       e Zd ZdZd fdZ eeeed          Z	 eeeed          Z
 eeeed          Z ed	d
          Z eddd          Z eee ee          d          Z xZS )r)   z Numeric input widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zNumericInput.__init__   r>   r?   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.
    rA   rI   rH   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
    
    rO   )rP   rQ   rR   rS   r7   r   r   r   r   rE   lowhighr   placeholderr   moder   r   formatrW   rX   s   @r=   r)   r)      s        
* * * * * * F4 + 	 	 	E &uc ) 	 	 	C 6$s * 	 	 	D & + 	 	 	K 4w & 	 	 	D VD&((="9"9 A 	 	 	FFFFFr?   r)   c                       e Zd ZdZd fdZ e eeee	          d          Z
 ed          Z eed	ed
d          Z eededd          Z ee	edd          Z xZS )r,   z$ Numeric Spinner input widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zSpinner.__init__   r>   r?   z4
    Value reported at the end of interactions.
    r[   rH   rB   gؗҜ<r   z<
    The step added or subtracted to the current value.
    )startendrB   rC   r   
   zp
    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.
    rA   rO   )rP   rQ   rR   rS   r7   r   r   r   r   r   value_throttledr   rg   r   r   steppage_step_multiplier
wheel_waitrW   rX   s   @r=   r,   r,      s         
* * * * * * hvvdE377 ? 	 	 	O 8G$$$D8EC B 	 	 	D $8ER O 	 	 	
 UC 7 	 	 	JJJJJr?   r,   c                  >     e Zd ZdZd fdZ edd          Z xZS )	ToggleInputz4 Base class for toggleable (boolean) input widgets. r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zToggleInput.__init__  r>   r?   Fz"
    The state of the widget.
    rA   rO   )rP   rQ   rR   rS   r7   r   activerW   rX   s   @r=   ru   ru     sV        >>* * * * * * T% ' 	 	 	FFFFFr?   ru   c                  >     e Zd ZdZd fdZ edd          Z xZS )	r"   z A checkbox widget. r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zCheckbox.__init__  r>   r?   r@   z)
    The label next to the checkbox.
    rA   rO   )rP   rQ   rR   rS   r7   r   labelrW   rX   s   @r=   r"   r"     sV        * * * * * * F2 % 	 	 	EEEEEr?   r"   c                  <     e Zd ZdZd fdZ ed          Z xZS )r-   z A checkbox-like widget. r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zSwitch.__init__(  r>   r?       rk   rO   )rP   rQ   rR   rS   r7   r   widthrW   rX   s   @r=   r-   r-   $  sK        ##* * * * * * HR   EEEEEr?   r-   c                       e Zd ZdZd fdZ edd          Z edd          Z edd	          Z e	e
d
          Z xZS )TextLikeInputz. Base class for text-like input widgets.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zTextLikeInput.__init__3  r>   r?   r@   zf
    Initial or entered text value.

    Change events are triggered whenever <enter> is pressed.
    rA   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
    r[   rO   )rP   rQ   rR   rS   r7   r   rE   value_inputrf   r   r   
max_lengthrW   rX   s   @r=   r   r   -  s         
* * * * * * F2 % 	 	 	E & + 	 	 	K & + 	 	 	K # % 	 	 	JJJJJr?   r   c                  X     e Zd ZdZd fdZ eed          Z eed          Z xZ	S )	r/   z  Single-line input widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zTextInput.__init__Q  r>   r?   z
    An optional string prefix to display before the input. This is useful to
    indicate e.g. a variable the entered value will be assigned to.
    r[   z
    An optional string suffix to display after the input. This is useful to
    indicate e.g. the units of measurement of the entered value.
    rO   )
rP   rQ   rR   rS   r7   r   r   prefixsuffixrW   rX   s   @r=   r/   r/   K  sy         
* * * * * * Xf $ 	 	 	F
 Xf $ 	 	 	FFFFFr?   r/   c                  p     e Zd ZdZd fdZ edd          Z edd	          Z ed
          Z	 xZ
S )r.   z Multi-line input widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zTextAreaInput.__init__d  r>   r?      zX
    Specifies the width of the text area (in average character width). Default: 20
    rA   r   zF
    Specifies the height of the text area (in lines). Default: 2
    i  rk   rO   )rP   rQ   rR   rS   r7   r   colsrowsr   r   rW   rX   s   @r=   r.   r.   ^  s         
* * * * * * 3r ! 	 	 	D 3q   	 	 	D #&&&JJJJJr?   r.   c                  $     e Zd ZdZd fdZ xZ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.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zPasswordInput.__init__~  r>   r?   rO   )rP   rQ   rR   rS   r7   rW   rX   s   @r=   r*   r*   r  sG         * * * * * * * * * *r?   r*   c                       e Zd ZdZd fdZ eed          Z e e	e
          d          Z ee
dd	
          Z edd
          Z edd
          Z eddd          Z xZS )r!   z5 Single-line input widget with auto-completion.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zAutocompleteInput.__init__  r>   r?   z}
    A list of completion strings. This will be used to guide the
    user upon typing the beginning of a desired value.
    r[   z;
    Optional maximum number of completions displayed.
    r   zU
    The number of characters a user must type before completions are presented.
    rA   Tz-
    Enable or disable case sensitivity.
    zs
    Set to False in order to allow users to enter text that is not present in the list of completion strings.
    starts_withincludesa  
    Define how to search the list of completion strings. The default option
    ``"starts_with"`` means that the user's text must match the start of a
    completion string. Using ``"includes"`` means that the user's text can
    match any substring of a completion string.
    rO   )rP   rQ   rR   rS   r7   r   r   completionsr   r   r   max_completionsr   min_charactersr   case_sensitiverestrictr   search_strategyrW   rX   s   @r=   r!   r!     s        
* * * * * * $v % 	 	 	K
 hxx}} 4 	 	 	O ![a 7 	 	 	N T$ . 	 	 	N tD ( 	 	 	H d=* < 	 	 	OOOOOr?   r!   c                  \    e Zd ZdZd fdZ e e ee eee                               e	e e ee eee                                        d          
                     e eee                    d           Z edd	
          
                    ed           Z xZS )r+   z Single-select widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zSelect.__init__  r>   r?   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
    r[   c                    d | D             S )Nc                    g | ]}|dn|	S Nr@    ).0items     r=   
<listcomp>z#Select.<lambda>.<locals>.<listcomp>  s"    7e7e7eZ^t|QU7e7e7er?   r   )vs    r=   <lambda>zSelect.<lambda>  s    7e7ebc7e7e7e r?   r@   z$
    Initial or selected value.
    rA   c                    dS r   r   )_s    r=   r   zSelect.<lambda>  s     r?   rO   )rP   rQ   rR   rS   r7   r   r   r   r   r
   acceptsr   optionsrE   rW   rX   s   @r=   r+   r+     s        
* * * * * * fTT&&vv)>)>??@@VTT&&vv)>)>??@@AA I	 	 	 
ffT6**++-e-e	f	f  F2 % 	 	 		||	$	$ 
EEEEr?   r+   c            	           e Zd ZdZd fdZ e ee eee                    d          Z	 eed          Z
 edd	
          Z xZS )r(   z Multi-select widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zMultiSelect.__init__  r>   r?     
    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.
    r[   %
    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.)
    rA   rO   )rP   rQ   rR   rS   r7   r   r   r   r   r   rE   r   sizerW   rX   s   @r=   r(   r(     s         
* * * * * * d66&%%"7"788 @ 	 	 	G D  	 	 	E 3q   	 	 	DDDDDr?   r(   c            	          e Zd ZdZd fdZ e ee eee                    d          Z	 eed          Z
 edd	
          Z eed          Z eed          Z eed          Z eed          Z edd
          Z xZS )r'   z MultiChoice widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zMultiChoice.__init__  r>   r?   r   r[   r   Tz>
    Whether to add a button to remove a selected option.
    rA   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.rO   )rP   rQ   rR   rS   r7   r   r   r   r   r   rE   r   delete_buttonr   r   	max_itemsoption_limitsearch_option_limitrf   solidrW   rX   s   @r=   r'   r'     sM        
* * * * * * d66&%%"7"788 @ 	 	 	G D  	 	 	E D - 	 	 	M  $ 	 	 	I 8C ' 	 	 	L #(3 . 	 	 	
 (6 ) 	 	 	K D %= > > >EEEEEr?   r'   c                  >     e Zd ZdZd fdZ edd          Z xZS )	r$   z Color picker widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zColorPicker.__init__  r>   r?   z#000000zF
    The initial color of the picked color (named or hexadecimal)
    rA   rO   )rP   rQ   rR   rS   r7   r	   colorrW   rX   s   @r=   r$   r$     sZ         
* * * * * * HY . 	 	 	EEEEEr?   r$   c            
           e Zd ZdZd fdZ eed          Z e e e	e ee
                              d          Z eedd          Z eed	d          Z eed
d          Z xZS )r#   z Color map picker widget.

    r1   r2   c                :     t                      j        |i | d S r4   r5   r8   s      r=   r7   zColorMap.__init__  r>   r?   rc   r[   ro   rA   r   r   rO   )rP   rQ   rR   rS   r7   r   r   rE   r   r   r   itemsr   r   swatch_widthswatch_heightr   ncolsrW   rX   s   @r=   r#   r#     s         
* * * * * * HV # 	 	 	E HSSvss5zz2233 ; 	 	 	E ;sC 7 	 	 	L  KR 7 	 	 	M HS! + 	 	 	EEEEEr?   r#   )9rS   
__future__r   logging	getLoggerrP   logmathr   core.has_propsr   core.propertiesr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
formattersr   uir   widgetr    __all__r&   r%   r)   r,   ru   r"   r-   r   r/   r.   r*   r!   r+   r(   r'   r$   r#   r   r?   r=   <module>r      s    # " " " " " g!!       ' & & & & &                                             . ' & & & & &            . 
    &   
BR	 R	 R	 R	 R	 R	 R	 R	j$	 $	 $	 $	 $	; $	 $	 $	N	 	 	 	 	l 	 	 	: 
		 		 		 		 		& 		 		 
				 		 		 		 		{ 		 		 		! ! ! ! ![ ! ! !	 	 	 	 	K 	 	 	<	 	 	 	 	 	 	 	&' ' ' ' 'M ' ' '(* * * * *I * * * #	 #	 #	 #	 #		 #	 #	 #	L% % % % %[ % % %.	 	 	 	 	+ 	 	 	6*> *> *> *> *>+ *> *> *>X	 	 	 	 	+ 	 	 		 	 	 	 	{ 	 	 	 	 	r?   