
    pj?                     B   d dl mZ d dlmZ g dZ G d de      Z G d de      Z G d d	e      Z G d
 de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)    )AbstractElement)module)ClientStateChangeClientTriggersCursorLifeCycleMonitor	MouseTrapSizeObserver	FloatCardListBrowserGitTree
XaiHeatMapXaiImageLineSeedc                         e Zd Zd fd	Z xZS )HtmlElementc                     t        |   ||fi | | j                  r | j                  j                  t               y y N)super__init__serverenable_moduler   )self
_elem_namechildrenkwargs	__class__s       K/DATA/.local/lib/python3.12/site-packages/trame_components/widgets/trame.pyr   zHtmlElement.__init__   s5    X88;;KK%%f-     r   __name__
__module____qualname__r   __classcell__r   s   @r   r   r      s    . .r   r   c                   $     e Zd ZdZd fd	Z xZS )r   a  
    Allow the client side to trigger an event when a state element changes.

    :param value: Name of the state variable to monitor
    :type value: str
    :param immediate: Trigger change right away rather than at nextTick (default: False)
    :type immediate: bool
    :param trigger_on_create: If set to true, the change event will be triggered when the client start. (default: False)
    :type trigger_on_create: bool
    :param change: Event triggered when state[value] change
    :type change: Function or JS expression (event)
    c                     t        |   d|fi | | xj                  g dz  c_        | xj                  dgz  c_        y )Nztc-client-state-change))valuez:value	immediate)trigger_on_createtriggerChangeOnCreatechanger   r   _attr_names_event_namesr   r   r   r   s      r   r   zClientStateChange.__init__-   sC    18FvF 
 	

 	hZ'r   r   r!   r"   r#   __doc__r   r$   r%   s   @r   r   r      s    ( (r   r   c                   *     e Zd ZdZd fd	Zd Z xZS )r   z
    Allow to trigger an event on the client side

    :param ref: Identifier for the client side DOM elem
    :param **kwargs: List of events to registers with their callbacks
    c                     || _         t        |   dd |d| | xj                  dgz  c_        | xj                  t        |j                               z  c_        y )N)r   refr5   )ztc-client-triggers)_ClientTriggers__namer   r   r.   r/   listkeys)r   r5   r   r   r   s       r   r   zClientTriggers.__init__B   sP    P#PPUG#T&++-00r   c                 V     | j                   j                  | j                  d|g|  y)zt
        Perform the call on the client

        :param method: Key used in the kwargs at construction time
        emitN)r   js_callr6   )r   methodargss      r   callzClientTriggers.callH   s%     	DKK?$?r   )trame_triggersN)r!   r"   r#   r2   r   r>   r$   r%   s   @r   r   r   :   s    1@r   r   c                   "     e Zd ZdZ fdZ xZS )r   zAllow to define the cursor of the parent component based on an active index and the list of css cursor names.

    :param active: index to selection the current cursor
    :param cursors: Array of available cursor to chose from
    c                 R    t        |   di | | xj                  ddgz  c_        y )Nactivecursors)z	tc-cursorr   r   r.   r   r   r   s     r   r   zCursor.__init__[   s)    //Xy11r   r1   r%   s   @r   r   r   T   s    2 2r   r   c                   $     e Zd ZdZd fd	Z xZS )r   ax  
    LifeCycleMonitor is a debug purpose tool to validate a sub-tree get the proper
    expected life cycle event.

    This component allow to print into the client side console when any of the
    monitored event happen.

    :param name: User specific text to easily identify which component the event
                was coming from.
    :param type: console[type](...) so you can use 'log', 'error', 'info', 'warn'
    :param value: Another value that is printed when an event occur
    :param events: List of events to monitor such as created, beforeMount,
        mounted, beforeUpdate, updated, beforeDestroy, destroyed
    c                     t        |   d|fi | | xj                  g dz  c_        | xj                  g dz  c_        y )Nztc-life-cycle-monitor)nametyper(   events)created)before_mountbeforeMountmounted)before_updatebeforeUpdateupdated)before_destroybeforeDestroy	destroyedr-   r0   s      r   r   zLifeCycleMonitor.__init__s   sF    0(EfE 
 	
 	 
 	
r   r   r1   r%   s   @r   r   r   c   s    
 
r   r   c                   0     e Zd ZdZ fdZddZd Z xZS )r	   a  
    MouseTrap allow to capture client side event and bind them
    to server side trigger.

    :param **kwargs: The keys are meant to be assigned to events.

    .. code-block::

        widget = MouseTrap(Save=save_fn, Open=open_fn, Edit=edit_fn, Escape=exit_fn)

        widget.bind(["ctrl+s", "mod+s"], "Save", stop_propagation=True)
        widget.bind(["ctrl+o", "mod+o"], "Open", stop_propagation=True)
        widget.bind("mod+e", "Edit")
        widget.bind("esc", "Escape")

    c                     t        |   di | d| j                  d<   | xj                  g |j	                         z  c_        y )Nz:mapping="trame__mousetrap"_trame_mapping)ztc-mouse-trap)r   r   _attributesr/   r8   rE   s     r   r   zMouseTrap.__init__   sA    3F3-J)*-v{{}--r   c                     | xj                   |gz  c_         ||d}|rd|d<   |r||d<   | j                  j                  j                  j	                  |       y)z>
        Create binding for key stroke to event name.
        )r8   event   stoplistenN)r/   r   statetrame__mousetrapappend)r   r8   
event_namestop_propagation	listen_toentrys         r   bindzMouseTrap.bind   s\     	j\)
 E&M'E(O**11%8r   c                 :    g | j                   j                  _        y r   )r   r^   r_   )r   s    r   resetzMouseTrap.reset   s    -/*r   )FN)r!   r"   r#   r2   r   re   rg   r$   r%   s   @r   r	   r	      s    ".
9 0r   r	   c                   "     e Zd ZdZ fdZ xZS )r
   z
    SizeObserver allow to monitor the space available in the UI and bind that
    information onto a state variable.

    :param _name: Name of the state variable to bound the component size to
    c                     t        |   di | | xj                  dgz  c_        d | j                  j                  |<   | j                  j
                  j                  |      | _        y )NrH   )ztc-size-observer)r   r   r.   r   r^   
translatortranslate_keyrH   )r   _namer   r   s      r   r   zSizeObserver.__init__   s^    6v6
 	
 $(% KK**88?	r   r1   r%   s   @r   r
   r
      s    @ @r   r
   c                   $     e Zd ZdZd fd	Z xZS )r   a  
    A |floatcard_vuetify_link| which floats above the application and can be moved freely from a handle

    .. |floatcard_vuetify_link| raw:: html

        <a href="https://vuetifyjs.com/api/v-card" target="_blank">vuetify VCard container</a>


    :param handle_color:
    :param handle_position:
    :param handle_size:
    :param location:

    Vuetify VCard attributes

    :param color:
    :param dark:
    :param flat:
    :param height:
    :param elevation:
    :param hover:
    :param img:
    :param light:
    :param loader_height:
    :param loading:
    :param max_height:
    :param max_width:
    :param min_height:
    :param min_width:
    :param outlined:
    :param raised:
    :param rounded:
    :param shaped:
    :param tile:
    :param width:
    c                 V    t        |   d|fi | | xj                  g dz  c_        y )Nztc-float-card)handle_colorhandle_positionhandle_sizelocationcolordarkflatheight	elevationhoverimglightloader_heightloading
max_height	max_width
min_height	min_widthoutlinedraisedroundedshapedtilewidthrD   r0   s      r   r   zFloatCard.__init__   s-    (=f= 
 	
r   r   r1   r%   s   @r   r   r      s    #J
 
r   r   c                   $     e Zd ZdZd fd	Z xZS )r   a  
    A component that list items that be used for browsing directories or simple item picking

    :param list: List stored in state
    :param filter: Function to filter list
    :param path_separator: The icon to use for the slash between folders
    :param show_path_with_icon: Shows the path with the icon
    :param hide_icon: Hide the folder icons in the navigation bar
    :param sticky_header: Freezes the navigation bar while scrolling
    :param path_icon:
    :param path_selected_icon:
    :param filter_icon:
    :param path:
    c                 V    t        |   d|fi | | xj                  g dz  c_        y )Nztc-list-browser)	path_iconpath_selected_iconpath_separator	hide_iconshow_path_with_iconfilter_iconsticky_headerfilterpathr7   )queryfilterQueryrD   r0   s      r   r   zListBrowser.__init__&  s.    *H?? 
 	
r   r   r1   r%   s   @r   r   r     s    
 
r   r   c                   $     e Zd ZdZd fd	Z xZS )r   a  
    A component to present a Tree the same way Git does it (Like a subway map)

    :param sources: All of the elements of the tree
    :param actives: Any active elements of the tree

    Vuetify styling attributes

    :param active_background:
    :param delta_x:
    :param delta_y:
    :param font_size:
    :param margin:
    :param multiselect:
    :param offset:
    :param palette:
    :param radius:
    :param root_id:
    :param stroke:
    :param width:
    :param active_circle_stroke_color:
    :param not_visible_circle_fill_color:
    :param text_color:
    :param text_weight:
    :param action_map:
    :param action_size:

    Events

    :param actives_change:
    :param visibility_change:
    :param action:

    c                     t        |   d|fi | | xj                  g dz  c_        | xj                  g dz  c_        y )Nztc-git-tree)sourcesactivesactive_backgrounddelta_xdelta_y	font_sizemarginmultiselectoffsetpaletteradiusroot_idstroker   active_circle_stroke_colornot_visible_circle_fill_color
text_colortext_weight
action_mapaction_size))actives_changeactivesChange)visibility_changevisibilityChangeactionr-   r0   s      r   r   zGitTree.__init__`  sE    ;F; 
 	
, 	 
 	
r   r   r1   r%   s   @r   r   r   <  s    !F
 
r   r   c                   $     e Zd ZdZd fd	Z xZS )r   aK  
    XaiHeatMap create a visual representation of a numerical array
    representing a 2D image.

    :param heatmap: Array to display
    :param shape: expect [width, height]
    :param color_mode: full, maxSym, minSym, positive, negative, custom (default: full)
    :param color_range: Range to be used when `color_mode="custom"`
    :param color_preset: Preset name from `vtk.js <https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.json>`_

    Events:

    :param hover: event triggered when moving over the map
    :param enter: event triggered when entring the map area
    :param exit: event triggered when exiting the map area
    :param color_range_change: event triggered when color range used has changed
    :param full_range_change: event triggered when full range has changed
    c                     t        |   d|fi | | xj                  g dz  c_        | xj                  g dz  c_        y )Nztc-xai-heat-map)heatmapshape
color_modecolor_rangecolor_preset)rx   enterexitcolor_range_change
colorRangefull_range_change	fullRanger-   r0   s      r   r   zXaiHeatMap.__init__  sF    *H?? 
 	
 	 
 	
r   r   r1   r%   s   @r   r   r     s    &
 
r   r   c                   $     e Zd ZdZd fd	Z xZS )r   a  
    XaiImage show an image with a XaiHeatMap as overlay

    :param src: URL to the image to display
    :param max_height: Limit the size of the image vertically
    :param max_width: Limit the size of the image horizontally
    :param width: If present use as style.width = "..."
    :param colors: Palette to use for areas
    :param areas: (optional) Array containing bounding box info
    :param area_key: (optional) Key in the area[i][key] that id the area
    :param area_style: (optional) css style to apply (default: { stroke-width: 3, rx: 10 })
    :param area_selected: (optional) Array of area ids
    :param area_selected_opacity: Opacity to use for selected areas 0-1
    :param area_opacity: Opacity to use for all areas 0-1
    :param heatmaps: Dict of arrays
    :param heatmap_opacity: Opacity of the heatmap overlay
    :param heatmap_color_preset: Preset name from `vtk.js <https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.json>`_
    :param heatmap_color_range: Range to be used when `heatmap_color_mode="custom"`
    :param heatmap_active: Key in heatmaps to select
    :param heatmap_color_mode: full, maxSym, minSym, positive, negative, custom (default: full)

    Events:

    :param area_selection_change: event triggered when requested area selection change
    :param hover: event triggered when moving over the map
    :param enter: event triggered when entring the map area
    :param exit: event triggered when exiting the map area
    :param color_range_change: event triggered when color range used has changed
    :param full_range_change: event triggered when full range has changed
    c                     t        |   d|fi | | xj                  g dz  c_        | xj                  g dz  c_        y )Nztc-xai-image)srcr}   r~   r   colorsareasarea_key
area_stylearea_selectedarea_selected_opacityarea_opacityheatmapsheatmap_opacityheatmap_color_presetheatmap_color_rangeheatmap_activeheatmap_color_mode))area_selection_changeareaSelectionChangerx   r   r   r   r   r-   r0   s      r   r   zXaiImage.__init__  sE    <V< 
 	
& 	 
 	
r   r   r1   r%   s   @r   r   r     s    >
 
r   r   c                         e Zd Zd fd	Z xZS )r   c                     t        |   d|fi | | xj                  g dz  c_        | xj                  dgz  c_        y )Nztc-line-seed))point_1point1)point_2point2)n_stepsnumberOfSteps)	n_sliders	nbSlidersboundsimage)update_seedzupdate-seedr-   r0   s      r   r   zLineSeed.__init__  sH    <V< 
 	
 	*
 	
r   r   r    r%   s   @r   r   r     s    
 
r   r   N)trame_client.widgets.corer   trame_componentsr   __all__r   r   r   r   r   r	   r
   r   r   r   r   r   r    r   r   <module>r      s    5 # ./ .( (6@[ @4	2[ 	2 
{  
L(0 (0\@; @,A
 A
R
+ 
L@
k @
P#
 #
V<
{ <
H
{ 
r   