a
    Df                     @  s   d dl mZ d dlmZmZmZmZ d dlZddlm	Z	 ddl
mZmZmZ ddlmZ dd	lmZ dd
lmZmZ G dd deZG dd deeZG dd deeeZdS )    )annotations)CallableClassVarListMappingN   )CDN_DIST)
ButtonIcon
ToggleIcon_ClickableIcon   )TooltipMixin)Widget)ButtonClick_ClickButtonc                      s   e Zd ZU ejdddZejdddZejdddZejdd	dZ	e
Zi ejd
diZded< ddiZded< e dgZded<  fddZejddddddd Z  ZS )r    zy
        The name of the icon to display when toggled from
        [tabler-icons.io](https://tabler-icons.io)/ or an SVG.defaultdocZheartzl
        The name of the icon to display from
        [tabler-icons.io](https://tabler-icons.io)/ or an SVG.NzO
        An explicit size specified as a CSS font-size, e.g. '1.5em' or '20px'.Fz/
        Whether the icon is toggled on or off.nametitle"ClassVar[Mapping[str, str | None]]_renamedescription_source_transformszcss/icon.csszClassVar[List[str]]_stylesheetsc                   s   t  jf i | d S )N)super__init__)selfparams	__class__ _/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/panel/widgets/icon.pyr   /   s    z_ClickableIcon.__init__iconactive_iconT)watchZon_initc                 C  s0   | j std| j d}|r,| js,tdd S )Nz%The icon parameter must not be empty.z<svgz>The active_icon parameter must not be empty if icon is an SVG.)r$   
ValueError
startswithr%   )r   Zicon_is_svgr"   r"   r#   _update_icon2   s    
z_ClickableIcon._update_icon)__name__
__module____qualname__paramStringr%   r$   sizeBooleanvalue_PnClickableIcon_widget_typer   r   __annotations__r   r   r   r   dependsr)   __classcell__r"   r"   r    r#   r      s    
r   c                   @  s   e Zd ZdZeZdS )r
   a  
    The `ToggleIcon` widget allows toggling a single condition between True/False states. This
    widget is interchangeable with the `Checkbox` and `Toggle` widget.

    This widget incorporates a `value` attribute, which alternates between `False` and `True`.

    Reference: https://panel.holoviz.org/reference/widgets/ToggleIcon.html

    :Example:

    >>> pn.widgets.ToggleIcon(
    ...     icon="thumb-up", active_icon="thumb-down", size="4em", description="Like"
    ... )
    N)r*   r+   r,   __doc___PnToggleIconr3   r"   r"   r"   r#   r
   >   s   r
   c                      s   e Zd ZU dZejdddZejdddZejdddZ	e
Zi ejd	d
dZded< dd
iZded<  fddZdddddZdddddZ  ZS )r	   a{  
    The `ButtonIcon` widget facilitates event triggering upon button clicks.

    This widget displays a default `icon` initially. Upon being clicked, an `active_icon` appears
    for a specified `toggle_duration`.

    For instance, the `ButtonIcon` can be effectively utilized to implement a feature akin to
    ChatGPT's copy-to-clipboard button.

    The button incorporates a `value` attribute, which alternates between `False` and `True` as the
    click event is processed.

    Furthermore, it includes an `clicks` attribute, enabling subscription to click events for
    further actions or monitoring.

    Reference: https://panel.holoviz.org/reference/widgets/ButtonIcon.html

    :Example:

    >>> button_icon = pn.widgets.ButtonIcon(
    ...     icon='clipboard',
    ...     active_icon='check',
    ...     description='Copy',
    ...     toggle_duration=2000
    ... )
    r   z9
        The number of times the button has been clicked.r   K   z
        The number of milliseconds the active_icon should be shown for
        and how long the button should be disabled for.FzG
        Toggles from False to True while the event is being processed.r   N)r   clicksr   r   zevent:button_click_target_transformsc                   s0   | dd }t jf i | |r,| | d S )Non_click)popr   r   r<   )r   r   Zclick_handlerr    r"   r#   r      s    zButtonIcon.__init__z+Callable[[param.parameterized.Event], None]zparam.parameterized.Watcher)callbackreturnc                 C  s   | j j|dddS )a  
        Register a callback to be executed when the button is clicked.

        The callback is given an `Event` argument declaring the number of clicks.

        Arguments
        ---------
        callback: (Callable[[param.parameterized.Event], None])
            The function to run on click events. Must accept a positional `Event` argument

        Returns
        -------
        watcher: param.Parameterized.Watcher
          A `Watcher` that executes the callback when the MenuButton is clicked.
        r:   F)Zonlychanged)r-   r&   )r   r>   r"   r"   r#   r<      s    zButtonIcon.on_clickr   None)eventr?   c                 C  s   | j d |  jd7  _dS )z/
        Process a button click event.
        r1   r   N)r-   triggerr:   )r   rA   r"   r"   r#   _process_event   s    zButtonIcon._process_event)r*   r+   r,   r7   r-   ZIntegerr:   Ztoggle_durationr0   r1   _PnButtonIconr3   r   r   r4   r;   r   r<   rC   r6   r"   r"   r    r#   r	   Q   s   
r	   )
__future__r   typingr   r   r   r   r-   Zio.resourcesr   modelsr	   rD   r
   r8   r   r2   Z_mixinr   baser   buttonr   r   r"   r"   r"   r#   <module>   s   +