instaui 0.1.8__py3-none-any.whl → 0.1.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. instaui/_helper/observable_helper.py +11 -1
  2. instaui/arco/components/select.py +4 -1
  3. instaui/arco/static/instaui-arco.css +1 -1
  4. instaui/arco/static/instaui-arco.js +55771 -55771
  5. instaui/components/echarts/echarts.js +7 -5
  6. instaui/components/echarts/echarts.py +1 -1
  7. instaui/components/element.py +12 -22
  8. instaui/components/grid.py +63 -11
  9. instaui/components/html/paragraph.py +10 -0
  10. instaui/components/html/select.py +0 -5
  11. instaui/components/html/table.py +1 -1
  12. instaui/components/label.py +5 -0
  13. instaui/components/row.py +0 -3
  14. instaui/components/shiki_code/static/shiki-style.css +179 -179
  15. instaui/event/js_event.py +24 -0
  16. instaui/event/vue_event.py +66 -0
  17. instaui/event/web_event.py +36 -25
  18. instaui/experimental/__init__.py +1 -2
  19. instaui/handlers/_utils.py +27 -5
  20. instaui/shadcn_classless/static/shadcn-classless.css +403 -403
  21. instaui/spa_router/_file_base_utils.py +20 -16
  22. instaui/static/insta-ui.css +1 -1
  23. instaui/static/insta-ui.esm-browser.prod.js +3683 -3663
  24. instaui/static/insta-ui.js.map +1 -1
  25. instaui/systems/func_system.py +15 -0
  26. instaui/template/webview_template.py +0 -2
  27. instaui/ui/__init__.py +5 -1
  28. instaui/ui/__init__.pyi +5 -1
  29. instaui/ui_functions/ui_page.py +3 -3
  30. instaui/vars/js_computed.py +25 -1
  31. instaui/vars/state.py +15 -0
  32. instaui/vars/web_computed.py +42 -0
  33. instaui/watch/js_watch.py +37 -1
  34. instaui/watch/web_watch.py +53 -0
  35. instaui/webview/__init__.py +1 -0
  36. instaui/webview/index.py +0 -1
  37. instaui-0.1.10.dist-info/METADATA +153 -0
  38. {instaui-0.1.8.dist-info → instaui-0.1.10.dist-info}/RECORD +70 -73
  39. {instaui-0.1.8.dist-info → instaui-0.1.10.dist-info}/WHEEL +1 -1
  40. instaui/experimental/link_sql/__init__.py +0 -3
  41. instaui/experimental/link_sql/_base.py +0 -23
  42. instaui/experimental/link_sql/_duckdb.py +0 -221
  43. instaui/experimental/link_sql/_types.py +0 -15
  44. instaui/experimental/link_sql/data_source.js +0 -50
  45. instaui-0.1.8.dist-info/METADATA +0 -160
  46. {instaui-0.1.8.dist-info → instaui-0.1.10.dist-info/licenses}/LICENSE +0 -0
@@ -74,8 +74,8 @@ function autoResize(root, chartIns, props) {
74
74
  if (!isInitialResize) {
75
75
  isInitialResize = true;
76
76
  if (
77
- root.offsetWidth === offsetWidth &&
78
- root.offsetHeight === offsetHeight
77
+ root.value.offsetWidth === offsetWidth &&
78
+ root.value.offsetHeight === offsetHeight
79
79
  ) {
80
80
  return;
81
81
  }
@@ -105,9 +105,11 @@ function setChartEvents(root, chartIns, emit, props) {
105
105
  if (chartEvents) {
106
106
  chartEvents.forEach(event => {
107
107
  chartIns.value.on(event, (...args) => {
108
- const eventArgs = args[0]
109
- delete eventArgs['event']
110
- delete eventArgs['$vars']
108
+ if (args.length > 0) {
109
+ const eventArgs = args[0]
110
+ delete eventArgs['event']
111
+ delete eventArgs['$vars']
112
+ }
111
113
 
112
114
  emit(`chart:${event}`, ...args)
113
115
  });
@@ -153,7 +153,7 @@ class ECharts(
153
153
  self._zr_events: Set[str] = set()
154
154
  self.props({"option": option})
155
155
 
156
- if init_options:
156
+ if init_options is not None:
157
157
  self.props({"initOptions": init_options})
158
158
 
159
159
  if update_options:
@@ -96,8 +96,11 @@ class Element(Component):
96
96
  self._props.update(self._default_props)
97
97
  self._proxy_props: List[ElementBindingMixin] = []
98
98
 
99
- self._js_events: defaultdict[str, List[EventMixin]] = defaultdict(list)
100
- self._web_events: defaultdict[str, List[EventMixin]] = defaultdict(list)
99
+ self._events: defaultdict[str, List[EventMixin]] = defaultdict(list)
100
+
101
+ # self._js_events: defaultdict[str, List[EventMixin]] = defaultdict(list)
102
+ # self._web_events: defaultdict[str, List[EventMixin]] = defaultdict(list)
103
+ # self._vue_events: defaultdict[str, List[EventMixin]] = defaultdict(list)
101
104
  self._directives: Dict[Directive, None] = {}
102
105
 
103
106
  self._slot_manager = SlotManager()
@@ -328,11 +331,7 @@ class Element(Component):
328
331
  if extends:
329
332
  handler = handler.copy_with_extends(extends)
330
333
 
331
- if handler.event_type() == "js":
332
- self._js_events[event_name].append(handler)
333
-
334
- if handler.event_type() == "web":
335
- self._web_events[event_name].append(handler)
334
+ self._events[event_name].append(handler)
336
335
 
337
336
  return self
338
337
 
@@ -452,8 +451,8 @@ class Element(Component):
452
451
  v._to_element_binding_config() for v in self._proxy_props
453
452
  ]
454
453
 
455
- if self._js_events or self._web_events:
456
- data["events"] = _normalize_events(self._js_events, self._web_events)
454
+ if self._events:
455
+ data["events"] = _normalize_events(self._events)
457
456
 
458
457
  if self._slot_manager.has_slot():
459
458
  data["slots"] = self._slot_manager
@@ -477,20 +476,11 @@ class Element(Component):
477
476
 
478
477
 
479
478
  def _normalize_events(
480
- js_events: defaultdict[str, List[EventMixin]],
481
- web_events: defaultdict[str, List[EventMixin]],
479
+ events: defaultdict[str, List[EventMixin]],
482
480
  ):
483
- merged: defaultdict[str, List[EventMixin]] = defaultdict(list)
484
-
485
- for name, events in js_events.items():
486
- name = _normalize_event_name(name)
487
- merged[name].extend(events)
488
-
489
- for name, events in web_events.items():
490
- name = _normalize_event_name(name)
491
- merged[name].extend(events)
492
-
493
- return dict(merged)
481
+ return {
482
+ _normalize_event_name(name): event_list for name, event_list in events.items()
483
+ }
494
484
 
495
485
 
496
486
  def _normalize_event_name(event_name: str):
@@ -121,23 +121,75 @@ class Grid(Element):
121
121
  area = f"{real_row} / {real_column} / {real_row_span} / {real_column_span}"
122
122
  return self.mark_area(area)
123
123
 
124
- @classmethod
124
+ @staticmethod
125
125
  def auto_columns(
126
- cls,
127
126
  *,
128
127
  min_width: TMaybeRef[str],
129
128
  mode: TMaybeRef[Literal["auto-fill", "auto-fit"]] = "auto-fit",
130
- ) -> Grid:
131
- if isinstance(min_width, ObservableMixin) or isinstance(mode, ObservableMixin):
132
- template = JsComputed(
133
- inputs=[min_width, mode],
134
- code=r"(min_width, mode)=> `repeat(${mode}, minmax(min(${min_width},100%), 1fr))`",
135
- )
129
+ ):
130
+ """
131
+ Generate a dynamic grid column configuration for responsive layout systems.
132
+
133
+ Creates a computed layout specification that calculates column dimensions
134
+ based on minimum width requirements and auto-sizing behavior. Retu
135
+
136
+ Args:
137
+ min_width (TMaybeRef[str]):
138
+ Minimum width constraint for columns as a CSS length string (e.g., "300px").
139
+ Accepts reactive references for dynamic updates.
140
+ mode (TMaybeRef[Literal["auto, optional):
141
+ Auto-sizing behavior strategy:
142
+ - "auto-fill": Preserves container space by creating additional columns
143
+ - "auto-fit": Adjusts columns to fit available space.
144
+ Defaults to "auto-fit".
145
+
146
+ Example:
147
+ .. code-block:: python
148
+
149
+ with ui.grid(columns=ui.grid.auto_columns(min_width="300px")):
150
+ ...
151
+ """
152
+ template = JsComputed(
153
+ inputs=[min_width, mode],
154
+ code=r"(min_width, mode)=> `repeat(${mode}, minmax(min(${min_width},100%), 1fr))`",
155
+ )
156
+
157
+ return template
158
+
159
+ @staticmethod
160
+ def auto_rows(
161
+ *,
162
+ min_height: TMaybeRef[str],
163
+ mode: TMaybeRef[Literal["auto-fill", "auto-fit"]] = "auto-fit",
164
+ ):
165
+ """
166
+ Generate a dynamic grid row configuration for responsive layout systems.
167
+
168
+ Creates a computed layout specification that calculates row dimensions
169
+ based on minimum height requirements and auto-sizing behavior.
170
+
171
+ Args:
172
+ min_height (TMaybeRef[str]):
173
+ Minimum height constraint for rows as a CSS length string (e.g., "300px").
174
+ mode (TMaybeRef[Literal["auto, optional):
175
+ Auto-sizing behavior strategy:
176
+ - "auto-fill": Preserves container space by creating additional rows
177
+ - "auto-fit": Adjusts rows to fit available space.
178
+ Defaults to "auto-fit".
179
+
180
+ Example:
181
+ .. code-block:: python
182
+
183
+ with ui.grid(rows=ui.grid.auto_rows(min_height="300px")):
184
+ ...
185
+ """
136
186
 
137
- else:
138
- template = f"repeat({mode}, minmax(min({min_width},100%), 1fr))"
187
+ template = JsComputed(
188
+ inputs=[min_height, mode],
189
+ code=r"(min_height, mode)=> `repeat(${mode}, minmax(min(${min_height},100%), 1fr))`",
190
+ )
139
191
 
140
- return cls(columns=template)
192
+ return template
141
193
 
142
194
  def row_gap(self, gap: TMaybeRef[str]) -> Grid:
143
195
  return self.style({"row-gap": gap})
@@ -7,6 +7,16 @@ if TYPE_CHECKING:
7
7
 
8
8
 
9
9
  class Paragraph(Element):
10
+ """
11
+ A component class representing an HTML `<p>` (paragraph) element.
12
+
13
+ Args:
14
+ text (Union[str, TMaybeRef[Any]]):The text content of the paragraph.
15
+ - If a string is provided, the content is static.
16
+ - If a `TMaybeRef` object is provided, the content
17
+ will reactively update when the referenced value changes.
18
+ """
19
+
10
20
  def __init__(
11
21
  self,
12
22
  text: Union[str, TMaybeRef[Any]],
@@ -1,14 +1,9 @@
1
1
  from __future__ import annotations
2
2
  from typing import (
3
- TYPE_CHECKING,
4
- Callable,
5
- Dict,
6
3
  List,
7
4
  Optional,
8
5
  Union,
9
- overload,
10
6
  )
11
- from typing_extensions import Self
12
7
  from instaui.components.value_element import ValueElement
13
8
  from instaui.components.element import Element
14
9
  from instaui.event.event_mixin import EventMixin
@@ -1,5 +1,5 @@
1
1
  from __future__ import annotations
2
- from typing import TYPE_CHECKING, Any, List, Optional, Union
2
+ from typing import TYPE_CHECKING, Any, List, Union
3
3
  from instaui.components.element import Element
4
4
  from instaui.components.content import Content
5
5
  from instaui.components.vfor import VFor
@@ -0,0 +1,5 @@
1
+ from instaui.components.html.span import Span
2
+
3
+
4
+ label = Span
5
+ """ A label element. Equivalent to `html.span`. """
instaui/components/row.py CHANGED
@@ -1,7 +1,4 @@
1
1
  from __future__ import annotations
2
- from typing import (
3
- TypeVar,
4
- )
5
2
  from instaui.components.element import Element
6
3
  from instaui.vars.types import TMaybeRef
7
4
  from instaui.vars.js_computed import JsComputed
@@ -1,179 +1,179 @@
1
- :root {
2
- --shiki-font-family-mono: ui-monospace, "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
3
- --shiki-code-line-height: 1.5;
4
- --shiki-code-font-size: 0.875em;
5
- --shiki-code-block-color: #67676c;
6
- --shiki-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(128,128,128,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E");
7
- --shiki-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(128,128,128,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E");
8
- --shiki-code-copy-code-border-color: #e2e2e3;
9
- --shiki-code-copy-code-bg: #f6f6f7;
10
- --shiki-code-copy-code-hover-border-color: #e2e2e3;
11
- --shiki-code-copy-code-hover-bg: #ffffff;
12
- --shiki-code-copy-code-active-text: #67676c;
13
- --shiki-code-copy-copied-text-content: "Copied";
14
- --shiki-code-lang-color: #929295;
15
- }
16
- @media (min-width: 640px) {
17
- .shiki-code[class*=language-] {
18
- border-radius: 8px;
19
- margin: 15px 0;
20
- }
21
- }
22
- .shiki-code[class*=language-] {
23
- position: relative;
24
- margin: 16px 0;
25
- background-color: #f9f9f9;
26
- overflow-x: auto;
27
- transition: background-color 0.5s;
28
- /* line numbers */
29
- }
30
- .shiki-code[class*=language-] pre,
31
- .shiki-code[class*=language-] code {
32
- font-family: var(--shiki-font-family-mono);
33
- }
34
- .shiki-code[class*=language-] pre {
35
- position: relative;
36
- z-index: 1;
37
- margin: 0;
38
- padding: 20px 0;
39
- background: transparent;
40
- overflow-x: auto;
41
- }
42
- .shiki-code[class*=language-] code {
43
- display: block;
44
- padding: 0 24px 0 0;
45
- width: fit-content;
46
- min-width: 100%;
47
- line-height: var(--shiki-code-line-height);
48
- font-size: var(--shiki-code-font-size);
49
- color: var(--shiki-code-block-color);
50
- transition: color 0.5s;
51
- }
52
- .shiki-code[class*=language-] code > .line:before {
53
- content: ' ';
54
- padding: 0 5px;
55
- }
56
- .shiki-code[class*=language-] > button.copy {
57
- direction: ltr;
58
- position: absolute;
59
- top: 12px;
60
- right: 12px;
61
- z-index: 3;
62
- border: 1px solid var(--shiki-code-copy-code-border-color);
63
- border-radius: 4px;
64
- width: 40px;
65
- height: 40px;
66
- background-color: var(--shiki-code-copy-code-bg);
67
- opacity: 0;
68
- cursor: pointer;
69
- background-image: var(--shiki-icon-copy);
70
- background-position: 50%;
71
- background-size: 20px;
72
- background-repeat: no-repeat;
73
- transition: border-color 0.25s, background-color 0.25s, opacity 0.25s;
74
- }
75
- .shiki-code[class*=language-]:hover > button.copy,
76
- .shiki-code[class*=language-] > button.copy:focus {
77
- opacity: 1;
78
- }
79
- .shiki-code[class*=language-] > button.copy:hover,
80
- .shiki-code[class*=language-] > button.copy.copied {
81
- border-color: var(--shiki-code-copy-code-hover-border-color);
82
- background-color: var(--shiki-code-copy-code-hover-bg);
83
- }
84
- .shiki-code[class*=language-] > button.copy.copied,
85
- .shiki-code[class*=language-] > button.copy:hover.copied {
86
- border-radius: 0 4px 4px 0;
87
- background-color: var(--shiki-code-copy-code-hover-bg);
88
- background-image: var(--shiki-icon-copied);
89
- }
90
- .shiki-code[class*=language-] > button.copy.copied:before,
91
- .shiki-code[class*=language-] > button.copy:hover.copied:before {
92
- position: relative;
93
- top: -1px;
94
- display: flex;
95
- justify-content: center;
96
- align-items: center;
97
- border: 1px solid var(--shiki-code-copy-code-hover-border-color);
98
- border-right: 0;
99
- border-radius: 4px 0 0 4px;
100
- padding: 0 10px;
101
- width: fit-content;
102
- height: 40px;
103
- text-align: center;
104
- font-size: 12px;
105
- font-weight: 500;
106
- color: var(--shiki-code-copy-code-active-text);
107
- background-color: var(--shiki-code-copy-code-hover-bg);
108
- white-space: nowrap;
109
- content: var(--shiki-code-copy-copied-text-content);
110
- transform: translate(calc(-100% - 1px));
111
- }
112
- .shiki-code[class*=language-] > span.lang {
113
- position: absolute;
114
- top: 2px;
115
- right: 8px;
116
- z-index: 2;
117
- font-size: 12px;
118
- font-weight: 500;
119
- -webkit-user-select: none;
120
- user-select: none;
121
- color: var(--shiki-code-lang-color);
122
- transition: color 0.4s, opacity 0.4s;
123
- }
124
- .shiki-code[class*=language-]:hover > button.copy + span.lang,
125
- .shiki-code[class*=language-] > button.copy:focus + span.lang {
126
- opacity: 0;
127
- }
128
- .shiki-code[class*=language-].theme-dark {
129
- --shiki-code-line-diff-add-color: #3dd68c;
130
- --shiki-code-line-diff-add-symbol-color: #3dd68c;
131
- --shiki-code-line-diff-remove-color: hsla(349.72, 89.16%, 60.2%, 0.16);
132
- --shiki-code-line-diff-remove-symbol-color: hsl(357.62, 39.92%, 50.39%);
133
- --shiki-code-line-line-number-color: hsla(198.18, 13.36%, 80%, 0.7);
134
- }
135
- .shiki-code[class*=language-] pre.shiki .diff {
136
- all: unset;
137
- }
138
- .shiki-code[class*=language-] pre.shiki code .diff.remove {
139
- background-color: var(--shiki-code-line-diff-remove-color, rgba(244, 63, 94, 0.14));
140
- opacity: 0.7;
141
- }
142
- .shiki-code[class*=language-] pre.shiki code .diff.add {
143
- background-color: rgba(16, 185, 129, 0.14);
144
- }
145
- .shiki-code[class*=language-] pre.shiki code .diff.add:before {
146
- content: "+";
147
- color: var(--shiki-code-line-diff-add-symbol-color, #18794e);
148
- }
149
- .shiki-code[class*=language-] pre.shiki code .diff.remove:before {
150
- content: "-";
151
- color: var(--shiki-code-line-diff-remove-symbol-color, hsl(357.62, 39.92%, 50.39%));
152
- }
153
- .shiki-code[class*=language-] pre.shiki code .diff:before {
154
- width: 2.5em;
155
- text-align: left;
156
- padding-left: 10px;
157
- }
158
- .shiki-code[class*=language-] pre.shiki code .diff {
159
- box-sizing: border-box;
160
- transition: background-color 0.5s;
161
- margin: 0 -24px;
162
- padding: 0 24px;
163
- width: calc(100% + 48px);
164
- display: inline-block;
165
- }
166
- .shiki-code[class*=language-].line-numbers code {
167
- counter-reset: step;
168
- counter-increment: step 0;
169
- }
170
- .shiki-code[class*=language-].line-numbers code .line::before {
171
- content: counter(step);
172
- counter-increment: step;
173
- display: inline-block;
174
- text-align: right;
175
- color: var(--shiki-code-line-line-number-color, hsla(198.18, 13.36%, 51.57%, 0.7));
176
- width: 2.5em;
177
- text-align: left;
178
- padding-left: 10px;
179
- }
1
+ :root {
2
+ --shiki-font-family-mono: ui-monospace, "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
3
+ --shiki-code-line-height: 1.5;
4
+ --shiki-code-font-size: 0.875em;
5
+ --shiki-code-block-color: #67676c;
6
+ --shiki-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(128,128,128,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E");
7
+ --shiki-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(128,128,128,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E");
8
+ --shiki-code-copy-code-border-color: #e2e2e3;
9
+ --shiki-code-copy-code-bg: #f6f6f7;
10
+ --shiki-code-copy-code-hover-border-color: #e2e2e3;
11
+ --shiki-code-copy-code-hover-bg: #ffffff;
12
+ --shiki-code-copy-code-active-text: #67676c;
13
+ --shiki-code-copy-copied-text-content: "Copied";
14
+ --shiki-code-lang-color: #929295;
15
+ }
16
+ @media (min-width: 640px) {
17
+ .shiki-code[class*=language-] {
18
+ border-radius: 8px;
19
+ margin: 15px 0;
20
+ }
21
+ }
22
+ .shiki-code[class*=language-] {
23
+ position: relative;
24
+ margin: 16px 0;
25
+ background-color: #f9f9f9;
26
+ overflow-x: auto;
27
+ transition: background-color 0.5s;
28
+ /* line numbers */
29
+ }
30
+ .shiki-code[class*=language-] pre,
31
+ .shiki-code[class*=language-] code {
32
+ font-family: var(--shiki-font-family-mono);
33
+ }
34
+ .shiki-code[class*=language-] pre {
35
+ position: relative;
36
+ z-index: 1;
37
+ margin: 0;
38
+ padding: 20px 0;
39
+ background: transparent;
40
+ overflow-x: auto;
41
+ }
42
+ .shiki-code[class*=language-] code {
43
+ display: block;
44
+ padding: 0 24px 0 0;
45
+ width: fit-content;
46
+ min-width: 100%;
47
+ line-height: var(--shiki-code-line-height);
48
+ font-size: var(--shiki-code-font-size);
49
+ color: var(--shiki-code-block-color);
50
+ transition: color 0.5s;
51
+ }
52
+ .shiki-code[class*=language-] code > .line:before {
53
+ content: ' ';
54
+ padding: 0 5px;
55
+ }
56
+ .shiki-code[class*=language-] > button.copy {
57
+ direction: ltr;
58
+ position: absolute;
59
+ top: 12px;
60
+ right: 12px;
61
+ z-index: 3;
62
+ border: 1px solid var(--shiki-code-copy-code-border-color);
63
+ border-radius: 4px;
64
+ width: 40px;
65
+ height: 40px;
66
+ background-color: var(--shiki-code-copy-code-bg);
67
+ opacity: 0;
68
+ cursor: pointer;
69
+ background-image: var(--shiki-icon-copy);
70
+ background-position: 50%;
71
+ background-size: 20px;
72
+ background-repeat: no-repeat;
73
+ transition: border-color 0.25s, background-color 0.25s, opacity 0.25s;
74
+ }
75
+ .shiki-code[class*=language-]:hover > button.copy,
76
+ .shiki-code[class*=language-] > button.copy:focus {
77
+ opacity: 1;
78
+ }
79
+ .shiki-code[class*=language-] > button.copy:hover,
80
+ .shiki-code[class*=language-] > button.copy.copied {
81
+ border-color: var(--shiki-code-copy-code-hover-border-color);
82
+ background-color: var(--shiki-code-copy-code-hover-bg);
83
+ }
84
+ .shiki-code[class*=language-] > button.copy.copied,
85
+ .shiki-code[class*=language-] > button.copy:hover.copied {
86
+ border-radius: 0 4px 4px 0;
87
+ background-color: var(--shiki-code-copy-code-hover-bg);
88
+ background-image: var(--shiki-icon-copied);
89
+ }
90
+ .shiki-code[class*=language-] > button.copy.copied:before,
91
+ .shiki-code[class*=language-] > button.copy:hover.copied:before {
92
+ position: relative;
93
+ top: -1px;
94
+ display: flex;
95
+ justify-content: center;
96
+ align-items: center;
97
+ border: 1px solid var(--shiki-code-copy-code-hover-border-color);
98
+ border-right: 0;
99
+ border-radius: 4px 0 0 4px;
100
+ padding: 0 10px;
101
+ width: fit-content;
102
+ height: 40px;
103
+ text-align: center;
104
+ font-size: 12px;
105
+ font-weight: 500;
106
+ color: var(--shiki-code-copy-code-active-text);
107
+ background-color: var(--shiki-code-copy-code-hover-bg);
108
+ white-space: nowrap;
109
+ content: var(--shiki-code-copy-copied-text-content);
110
+ transform: translate(calc(-100% - 1px));
111
+ }
112
+ .shiki-code[class*=language-] > span.lang {
113
+ position: absolute;
114
+ top: 2px;
115
+ right: 8px;
116
+ z-index: 2;
117
+ font-size: 12px;
118
+ font-weight: 500;
119
+ -webkit-user-select: none;
120
+ user-select: none;
121
+ color: var(--shiki-code-lang-color);
122
+ transition: color 0.4s, opacity 0.4s;
123
+ }
124
+ .shiki-code[class*=language-]:hover > button.copy + span.lang,
125
+ .shiki-code[class*=language-] > button.copy:focus + span.lang {
126
+ opacity: 0;
127
+ }
128
+ .shiki-code[class*=language-].theme-dark {
129
+ --shiki-code-line-diff-add-color: #3dd68c;
130
+ --shiki-code-line-diff-add-symbol-color: #3dd68c;
131
+ --shiki-code-line-diff-remove-color: hsla(349.72, 89.16%, 60.2%, 0.16);
132
+ --shiki-code-line-diff-remove-symbol-color: hsl(357.62, 39.92%, 50.39%);
133
+ --shiki-code-line-line-number-color: hsla(198.18, 13.36%, 80%, 0.7);
134
+ }
135
+ .shiki-code[class*=language-] pre.shiki .diff {
136
+ all: unset;
137
+ }
138
+ .shiki-code[class*=language-] pre.shiki code .diff.remove {
139
+ background-color: var(--shiki-code-line-diff-remove-color, rgba(244, 63, 94, 0.14));
140
+ opacity: 0.7;
141
+ }
142
+ .shiki-code[class*=language-] pre.shiki code .diff.add {
143
+ background-color: rgba(16, 185, 129, 0.14);
144
+ }
145
+ .shiki-code[class*=language-] pre.shiki code .diff.add:before {
146
+ content: "+";
147
+ color: var(--shiki-code-line-diff-add-symbol-color, #18794e);
148
+ }
149
+ .shiki-code[class*=language-] pre.shiki code .diff.remove:before {
150
+ content: "-";
151
+ color: var(--shiki-code-line-diff-remove-symbol-color, hsl(357.62, 39.92%, 50.39%));
152
+ }
153
+ .shiki-code[class*=language-] pre.shiki code .diff:before {
154
+ width: 2.5em;
155
+ text-align: left;
156
+ padding-left: 10px;
157
+ }
158
+ .shiki-code[class*=language-] pre.shiki code .diff {
159
+ box-sizing: border-box;
160
+ transition: background-color 0.5s;
161
+ margin: 0 -24px;
162
+ padding: 0 24px;
163
+ width: calc(100% + 48px);
164
+ display: inline-block;
165
+ }
166
+ .shiki-code[class*=language-].line-numbers code {
167
+ counter-reset: step;
168
+ counter-increment: step 0;
169
+ }
170
+ .shiki-code[class*=language-].line-numbers code .line::before {
171
+ content: counter(step);
172
+ counter-increment: step;
173
+ display: inline-block;
174
+ text-align: right;
175
+ color: var(--shiki-code-line-line-number-color, hsla(198.18, 13.36%, 51.57%, 0.7));
176
+ width: 2.5em;
177
+ text-align: left;
178
+ padding-left: 10px;
179
+ }
instaui/event/js_event.py CHANGED
@@ -55,4 +55,28 @@ def js_event(
55
55
  outputs: typing.Optional[typing.Sequence] = None,
56
56
  code: str,
57
57
  ):
58
+ """
59
+ Creates a client-side event handler decorator for binding JavaScript logic to UI component events.
60
+
61
+ Args:
62
+ inputs (typing.Optional[typing.Sequence], optional):Reactive sources (state variables, computed values)
63
+ that should be passed to the event handler. These values
64
+ will be available in the JavaScript context through the `args` array.
65
+ outputs (typing.Optional[typing.Sequence], optional): Targets (state variables, UI elements) that should
66
+ update when this handler executes. Used for coordinating
67
+ interface updates after the event is processed.
68
+ code (str): JavaScript code to execute when the event is triggered.
69
+
70
+ # Example:
71
+ .. code-block:: python
72
+ from instaui import ui, html
73
+
74
+ a = ui.state(0)
75
+
76
+ plus_one = ui.js_event(inputs=[a], outputs=[a], code="a =>a + 1")
77
+
78
+ html.button("click me").on_click(plus_one)
79
+ html.paragraph(a)
80
+
81
+ """
58
82
  return JsEvent(inputs=inputs, outputs=outputs, code=code)