11"""Main module."""
2+
3+ import air
4+
5+ from typing import TYPE_CHECKING , Literal , override
6+
7+ from air .tags .utils import locals_cleanup
8+
9+
10+ class PlotSource (air .UnSafeTag ):
11+ """Provides the plotly dependency"""
12+
13+ @override
14+ def __init__ (
15+ self ,
16+ / ,
17+ * ,
18+ version : str = '3.4.0' ,
19+ library : str = 'plotly' ,
20+ ** custom_attributes ,
21+ ):
22+ self .version = version
23+ super ().__init__ ('' , ** custom_attributes | locals_cleanup (locals ()))
24+
25+ @override
26+ def _render (self ) -> str :
27+ """Wraps the comment text with HTML comment delimiters.
28+
29+ Returns:
30+ The serialized comment node.
31+ """
32+ return f'<script charset="utf-8" src="https://cdn.plot.ly/plotly-{ self .version } .min.js"></script>'
33+
34+
35+
36+ class BaseAirPlotTag (air .UnSafeTag ):
37+ """Defines a client-side script.
38+ Warning: Script tag does not protect against code injection.
39+
40+ Args:
41+ text_child: Inline script code. Use an empty string when providing ``src``.
42+ src: URI of the external script.
43+ type_: Script type. Examples: ``module``, ``importmap``, ``speculationrules``,
44+ a JavaScript MIME type (e.g. ``text/javascript``), or empty for classic scripts.
45+ async_: Fetch in parallel and execute as soon as ready; order is not guaranteed.
46+ defer: Execute after parsing (classic scripts only; modules defer by default).
47+ nomodule: Do not execute on browsers that support ES modules.
48+ crossorigin: CORS mode. One of ``"anonymous"`` or ``"use-credentials"``.
49+ integrity: Subresource Integrity hash (e.g. ``"sha384-..."``).
50+ referrerpolicy: Which referrer to send. One of:
51+ ``"no-referrer"``, ``"no-referrer-when-downgrade"``, ``"origin"``,
52+ ``"origin-when-cross-origin"``, ``"same-origin"``, ``"strict-origin"``,
53+ ``"strict-origin-when-cross-origin"``, ``"unsafe-url"``.
54+ fetchpriority: Network priority hint. One of ``"high"``, ``"low"``, ``"auto"``.
55+ blocking: Space-separated tokens that block operations; currently ``"render"``.
56+ attributionsrc: Space-separated URLs for Attribution Reporting (experimental).
57+ nonce: CSP nonce (meaning: one-time token) to allow this inline script.
58+ class_: Substituted as the DOM ``class`` attribute.
59+ id_: DOM ``id`` attribute.
60+ style: Inline style attribute.
61+ custom_attributes: Keyword arguments transformed into tag attributes.
62+ """
63+
64+ class Line (air .UnSafeTag ):
65+ """Provides the plotly dependency"""
66+
67+ @override
68+ def __init__ (
69+ self ,
70+ / ,
71+ * ,
72+ version : str = '3.4.0' ,
73+ library : str = 'plotly' ,
74+ ** custom_attributes ,
75+ ):
76+ self .version = version
77+ super ().__init__ (** custom_attributes | locals_cleanup (locals ()))
0 commit comments