U
    ARd                      @   s   d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ er|d d	lmZ G d
d deZeeeed f  ZG dd dZdS )    )Enum)TYPE_CHECKINGOptionalUnioncast)Literal)StreamlitAPIException)Heading)gather_metrics)
clean_text)SupportsStr)DeltaGeneratorc                   @   s   e Zd ZdZdZdZdS )HeadingProtoTagh1h2h3N)__name__
__module____qualname__	TITLE_TAG
HEADER_TAGSUBHEADER_TAG r   r   >/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/elements/heading.pyr      s   r   Fc                   @   s   e Zd Zeddddeeee ddddZeddddeeee ddd	d
Z	eddddeeee ddddZ
eddddZedeeeee edddZdS )HeadingMixinheaderN)helpr   )bodyanchorr   returnc             	   C   s   | j dtjtj|||dS )a  Display text in header formatting.

        Parameters
        ----------
        body : str
            The text to display as Github-flavored Markdown. Syntax
            information can be found at: https://github.github.com/gfm.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet.

        anchor : str or False
            The anchor name of the header that can be accessed with #anchor
            in the URL. If omitted, it generates an anchor using the body.
            If False, the anchor is not shown in the UI.

        help : str
            An optional tooltip that gets displayed next to the header.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> st.header('This is a header')
        >>> st.header('A header with _italics_ :blue[colors] and emojis :sunglasses:')

        headingtagr   r   r   )dg_enqueuer   _create_heading_protor   r   selfr   r   r   r   r   r   r   (   s    .   zHeadingMixin.header	subheaderc             	   C   s   | j dtjtj|||dS )a  Display text in subheader formatting.

        Parameters
        ----------
        body : str
            The text to display as Github-flavored Markdown. Syntax
            information can be found at: https://github.github.com/gfm.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet.

        anchor : str or False
            The anchor name of the header that can be accessed with #anchor
            in the URL. If omitted, it generates an anchor using the body.
            If False, the anchor is not shown in the UI.

        help : str
            An optional tooltip that gets displayed next to the subheader.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> st.subheader('This is a subheader')
        >>> st.subheader('A subheader with _italics_ :blue[colors] and emojis :sunglasses:')

        r    r!   )r#   r$   r   r%   r   r   r&   r   r   r   r(   ]   s    .   zHeadingMixin.subheadertitlec             	   C   s   | j dtjtj|||dS )a   Display text in title formatting.

        Each document should have a single `st.title()`, although this is not
        enforced.

        Parameters
        ----------
        body : str
            The text to display as Github-flavored Markdown. Syntax
            information can be found at: https://github.github.com/gfm.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet.

        anchor : str or False
            The anchor name of the header that can be accessed with #anchor
            in the URL. If omitted, it generates an anchor using the body.
            If False, the anchor is not shown in the UI.

        help : str
            An optional tooltip that gets displayed next to the title.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> st.title('This is a title')
        >>> st.title('A title with _italics_ :blue[colors] and emojis :sunglasses:')

        r    r!   )r#   r$   r   r%   r   r   r&   r   r   r   r)      s    1   zHeadingMixin.title)r   c                 C   s
   t d| S )zGet our DeltaGenerator.r   )r   )r'   r   r   r   r#      s    zHeadingMixin.dg)r"   r   r   r   r   c                 C   sx   t  }| j|_t||_|d k	rj|dkr0d|_n:t|trB||_n(|dkrXt	d| nt	dt
|j |rt||_|S )NFTzSAnchor parameter has invalid value: %s. Supported values: None, any string or FalsezRAnchor parameter has invalid type: %s. Supported values: None, any string or False)HeadingProtovaluer"   r   r   Zhide_anchor
isinstancestrr   r   typer   r   )r"   r   r   r   protor   r   r   r%      s,    

z"HeadingMixin._create_heading_proto)N)N)N)NN)r   r   r   r
   r   Anchorr   r-   r   r(   r)   propertyr#   staticmethodr   r*   r%   r   r   r   r   r   '   sT    4 4 7  r   N)enumr   typingr   r   r   r   Ztyping_extensionsr   Zstreamlit.errorsr   Zstreamlit.proto.Heading_pb2r	   r*   Zstreamlit.runtime.metrics_utilr
   Zstreamlit.string_utilr   Zstreamlit.type_utilr   Zstreamlit.delta_generatorr   r   r-   r0   r   r   r   r   r   <module>   s   