
    >Tf$                         d dl mZ dZ G d dej                  Z G d dej                  Z G d dej                  Z G d	 d
ej                  Z	 G d dej                  Z
 G d dej                  ZdS )    )forms)ArrayWidgetChoicesWidgetClearableFileInputMarkdownWidgetNumberWithOptions
SlugWidgetc                       e Zd ZdZdZdS )r   zL
    Override Django's stock ClearableFileInput with a custom template.
    z!widgets/clearable_file_input.htmlN__name__
__module____qualname____doc__template_name     A/var/www/html/netbox-4.1.3/netbox/utilities/forms/widgets/misc.pyr   r      s          8MMMr   r   c                   (     e Zd ZdZdZd fd	Z xZS )r   z@
    Provide a live preview for Markdown-formatted content.
    zwidgets/markdown_input.htmlNc                     ddi}|r|                     |           t                                          |           d S )Nclasszfont-monospace)updatesuper__init__)selfattrsdefault_attrs	__class__s      r   r   zMarkdownWidget.__init__   sN     %
  	(  ''''''''r   N)r   r   r   r   r   r   __classcell__r   s   @r   r   r      sN          2M( ( ( ( ( ( ( ( ( (r   r   c                   2     e Zd ZdZdZd fd	Z fdZ xZS )r   zX
    Number field with a dropdown pre-populated with common values for convenience.
    z widgets/number_with_options.htmlNc                 X    || _         t                                          |           d S r   )optionsr   r   )r   r#   r   r   s      r   r   zNumberWithOptions.__init__+   s(    r   c                 n    t                                          |||          }| j        |d         d<   |S )Nwidgetr#   )r   get_contextr#   )r   namevaluer   contextr   s        r   r&   zNumberWithOptions.get_context/   s4    ''%%dE599'+|)$r   r   )r   r   r   r   r   r   r&   r   r    s   @r   r   r   %   sg          7M                   r   r   c                       e Zd ZdZdZdS )r	   zW
    Subclass TextInput and add a slug regeneration button next to the form field.
    zwidgets/sluginput.htmlNr   r   r   r   r	   r	   5   s          -MMMr   r	   c                       e Zd ZdZd ZdS )r   zX
    Render each item of an array on a new line within a textarea for easy editing/
    c                 R    |t          |          sd S d                    |          S )N
)lenjoinr   r(   s     r   format_valuezArrayWidget.format_value@   s(    =E

=4yyr   Nr   r   r   r   r1   r   r   r   r   r   <   s-                  r   r   c                       e Zd ZdZd ZdS )r   zf
    Render each key-value pair of a dictionary on a new line within a textarea for easy editing.
    c                 x    |sd S t          |          t          u rd                    d |D                       S |S )Nr-   c                 "    g | ]\  }}| d | S ):r   ).0kvs      r   
<listcomp>z.ChoicesWidget.format_value.<locals>.<listcomp>N   s&    ;;;TQjjQjj;;;r   )typelistr/   r0   s     r   r1   zChoicesWidget.format_valueJ   sF     	4;;$99;;U;;;<<<r   Nr2   r   r   r   r   r   F   s-             r   r   N)djangor   __all__r   Textarear   NumberInputr   	TextInputr	   r   r   r   r   r   <module>rB      s2        8 8 8 8 81 8 8 8( ( ( ( (U^ ( ( ("    )    - - - - - - - -         %.      	 	 	 	 	EN 	 	 	 	 	r   