instaui 0.1.4__py3-none-any.whl → 0.1.6__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 (198) hide show
  1. instaui/arco/__init__.py +191 -0
  2. instaui/arco/_settings.py +25 -0
  3. instaui/arco/_use_tools/locale.py +50 -0
  4. instaui/arco/component_types.py +1019 -0
  5. instaui/arco/components/_utils.py +22 -0
  6. instaui/arco/components/affix.py +29 -0
  7. instaui/arco/components/alert.py +42 -0
  8. instaui/arco/components/anchor.py +42 -0
  9. instaui/arco/components/auto_complete.py +96 -0
  10. instaui/arco/components/avatar.py +55 -0
  11. instaui/arco/components/back_top.py +14 -0
  12. instaui/arco/components/badge.py +14 -0
  13. instaui/arco/components/breadcrumb.py +14 -0
  14. instaui/arco/components/button.py +43 -0
  15. instaui/arco/components/calendar.py +47 -0
  16. instaui/arco/components/card.py +14 -0
  17. instaui/arco/components/carousel.py +33 -0
  18. instaui/arco/components/cascader.py +111 -0
  19. instaui/arco/components/checkbox.py +32 -0
  20. instaui/arco/components/collapse.py +31 -0
  21. instaui/arco/components/color_picker.py +45 -0
  22. instaui/arco/components/comment.py +14 -0
  23. instaui/arco/components/config_provider.py +13 -0
  24. instaui/arco/components/date_picker.py +111 -0
  25. instaui/arco/components/descriptions.py +14 -0
  26. instaui/arco/components/divider.py +13 -0
  27. instaui/arco/components/drawer.py +98 -0
  28. instaui/arco/components/dropdown.py +45 -0
  29. instaui/arco/components/empty.py +14 -0
  30. instaui/arco/components/form.py +55 -0
  31. instaui/arco/components/icon.py +17 -0
  32. instaui/arco/components/image.py +33 -0
  33. instaui/arco/components/input.py +102 -0
  34. instaui/arco/components/input_number.py +97 -0
  35. instaui/arco/components/input_password.py +38 -0
  36. instaui/arco/components/input_search.py +37 -0
  37. instaui/arco/components/input_tag.py +110 -0
  38. instaui/arco/components/layout.py +13 -0
  39. instaui/arco/components/layout_content.py +6 -0
  40. instaui/arco/components/layout_footer.py +6 -0
  41. instaui/arco/components/layout_header.py +6 -0
  42. instaui/arco/components/layout_sider.py +53 -0
  43. instaui/arco/components/link.py +36 -0
  44. instaui/arco/components/list.py +68 -0
  45. instaui/arco/components/mention.py +97 -0
  46. instaui/arco/components/menu.py +88 -0
  47. instaui/arco/components/modal.py +97 -0
  48. instaui/arco/components/overflow_list.py +29 -0
  49. instaui/arco/components/page_header.py +29 -0
  50. instaui/arco/components/pagination.py +45 -0
  51. instaui/arco/components/pop_confirm.py +58 -0
  52. instaui/arco/components/popover.py +32 -0
  53. instaui/arco/components/progress.py +14 -0
  54. instaui/arco/components/radio.py +40 -0
  55. instaui/arco/components/radio_group.py +42 -0
  56. instaui/arco/components/rate.py +45 -0
  57. instaui/arco/components/resize_box.py +62 -0
  58. instaui/arco/components/result.py +14 -0
  59. instaui/arco/components/select.py +179 -0
  60. instaui/arco/components/skeleton.py +14 -0
  61. instaui/arco/components/slider.py +38 -0
  62. instaui/arco/components/space.py +14 -0
  63. instaui/arco/components/spin.py +14 -0
  64. instaui/arco/components/split.py +76 -0
  65. instaui/arco/components/statistic.py +14 -0
  66. instaui/arco/components/steps.py +32 -0
  67. instaui/arco/components/switch.py +57 -0
  68. instaui/arco/components/tab_pane.py +12 -0
  69. instaui/arco/components/table.py +276 -0
  70. instaui/arco/components/tabs.py +101 -0
  71. instaui/arco/components/tag.py +42 -0
  72. instaui/arco/components/textarea.py +84 -0
  73. instaui/arco/components/time_picker.py +76 -0
  74. instaui/arco/components/timeline.py +14 -0
  75. instaui/arco/components/tooltip.py +29 -0
  76. instaui/arco/components/transfer.py +58 -0
  77. instaui/arco/components/tree.py +120 -0
  78. instaui/arco/components/tree_select.py +86 -0
  79. instaui/arco/components/trigger.py +58 -0
  80. instaui/arco/components/typography.py +142 -0
  81. instaui/arco/components/upload.py +71 -0
  82. instaui/arco/components/verification_code.py +58 -0
  83. instaui/arco/components/watermark.py +14 -0
  84. instaui/arco/locales/__init__.py +4 -0
  85. instaui/arco/locales/_index.py +31 -0
  86. instaui/arco/locales/en_us.py +227 -0
  87. instaui/arco/locales/zh_cn.py +224 -0
  88. instaui/arco/setup.py +36 -0
  89. instaui/arco/static/instaui-arco.css +1 -0
  90. instaui/arco/static/instaui-arco.js +55771 -0
  91. instaui/arco/types.py +24 -0
  92. instaui/components/column.py +10 -2
  93. instaui/components/echarts/echarts.js +128 -0
  94. instaui/components/echarts/echarts.py +194 -0
  95. instaui/components/echarts/static/echarts.esm.min.js +45 -0
  96. instaui/components/element.py +50 -6
  97. instaui/components/grid.py +81 -0
  98. instaui/components/html/__init__.py +30 -19
  99. instaui/components/html/_preset.py +4 -0
  100. instaui/components/html/heading.py +51 -0
  101. instaui/components/html/range.py +3 -0
  102. instaui/components/html/select.py +13 -31
  103. instaui/components/html/table.py +36 -0
  104. instaui/components/markdown/static/github-markdown.css +1 -1
  105. instaui/components/markdown/static/marked.esm.js +0 -1
  106. instaui/components/row.py +8 -7
  107. instaui/components/shiki_code/shiki_code.js +126 -0
  108. instaui/components/shiki_code/shiki_code.py +99 -0
  109. instaui/components/shiki_code/static/langs/css.mjs +5 -0
  110. instaui/components/shiki_code/static/langs/markdown.mjs +5 -0
  111. instaui/components/shiki_code/static/langs/python.mjs +5 -0
  112. instaui/components/shiki_code/static/langs/shell.mjs +2 -0
  113. instaui/components/shiki_code/static/langs/shellscript.mjs +5 -0
  114. instaui/components/shiki_code/static/shiki-core.js +5784 -0
  115. instaui/components/shiki_code/static/shiki-style.css +179 -0
  116. instaui/components/shiki_code/static/shiki-transformers.js +461 -0
  117. instaui/components/shiki_code/static/themes/vitesse-dark.mjs +2 -0
  118. instaui/components/shiki_code/static/themes/vitesse-light.mjs +2 -0
  119. instaui/components/value_element.py +7 -3
  120. instaui/consts.py +2 -1
  121. instaui/event/js_event.py +1 -0
  122. instaui/event/web_event.py +6 -7
  123. instaui/experimental/link_sql/__init__.py +3 -0
  124. instaui/experimental/link_sql/_base.py +23 -0
  125. instaui/experimental/link_sql/_duckdb.py +221 -0
  126. instaui/experimental/link_sql/_types.py +15 -0
  127. instaui/experimental/link_sql/data_source.js +50 -0
  128. instaui/fastapi_server/debug_mode_router.py +1 -1
  129. instaui/fastapi_server/server.py +4 -12
  130. instaui/handlers/event_handler.py +3 -1
  131. instaui/handlers/watch_handler.py +4 -0
  132. instaui/html_tools.py +41 -4
  133. instaui/runtime/_app.py +37 -3
  134. instaui/runtime/_link_manager.py +89 -0
  135. instaui/runtime/resource.py +19 -9
  136. instaui/runtime/scope.py +28 -7
  137. instaui/shadcn_classless/_index.py +42 -0
  138. instaui/shadcn_classless/static/shadcn-classless.css +403 -0
  139. instaui/static/insta-ui.css +1 -1
  140. instaui/static/insta-ui.esm-browser.prod.js +3663 -3658
  141. instaui/static/insta-ui.js.map +1 -1
  142. instaui/static/instaui-tools-browser.js +511 -0
  143. instaui/static/templates/debug/sse.html +1 -1
  144. instaui/static/templates/webview.html +78 -0
  145. instaui/tailwind/__init__.py +6 -0
  146. instaui/tailwind/_index.py +24 -0
  147. instaui/{static/tailwindcss.min.js → tailwind/static/tailwindcss-v3.min.js} +62 -62
  148. instaui/tailwind/static/tailwindcss-v4.min.js +8 -0
  149. instaui/template/_utils.py +23 -0
  150. instaui/template/webview_template.py +50 -0
  151. instaui/ui/__init__.py +8 -2
  152. instaui/ui/__init__.pyi +7 -1
  153. instaui/ui_functions/ui_page.py +1 -1
  154. instaui/vars/data.py +7 -7
  155. instaui/vars/element_ref.py +2 -4
  156. instaui/vars/event_context.py +4 -0
  157. instaui/vars/js_computed.py +6 -8
  158. instaui/vars/ref.py +6 -6
  159. instaui/vars/vue_computed.py +6 -7
  160. instaui/vars/web_computed.py +31 -32
  161. instaui/watch/vue_watch.py +23 -7
  162. instaui/watch/web_watch.py +5 -6
  163. instaui/webview/__init__.py +1 -0
  164. instaui/webview/_utils.py +8 -0
  165. instaui/webview/api.py +72 -0
  166. instaui/webview/func.py +114 -0
  167. instaui/webview/index.py +162 -0
  168. instaui/webview/resource.py +172 -0
  169. instaui/zero/func.py +19 -12
  170. instaui/zero/scope.py +29 -28
  171. {instaui-0.1.4.dist-info → instaui-0.1.6.dist-info}/METADATA +6 -2
  172. instaui-0.1.6.dist-info/RECORD +286 -0
  173. instaui/components/highlight_code/code.js +0 -63
  174. instaui/components/highlight_code/code.py +0 -117
  175. instaui/components/highlight_code/static/core.min.js +0 -307
  176. instaui/components/highlight_code/static/languages/css.min.js +0 -31
  177. instaui/components/highlight_code/static/languages/javascript.min.js +0 -81
  178. instaui/components/highlight_code/static/languages/json.min.js +0 -8
  179. instaui/components/highlight_code/static/languages/python-repl.min.js +0 -5
  180. instaui/components/highlight_code/static/languages/python.min.js +0 -42
  181. instaui/components/highlight_code/static/languages/shell.min.js +0 -5
  182. instaui/components/highlight_code/static/styles/default.min.css +0 -9
  183. instaui/components/highlight_code/static/styles/github-dark-dimmed.min.css +0 -9
  184. instaui/components/highlight_code/static/styles/github-dark.min.css +0 -10
  185. instaui/components/highlight_code/static/styles/github.min.css +0 -10
  186. instaui/daisyui/__init__.py +0 -20
  187. instaui/daisyui/_index.py +0 -15
  188. instaui/daisyui/button.py +0 -38
  189. instaui/daisyui/checkbox.py +0 -17
  190. instaui/daisyui/static/daisyui.css +0 -1
  191. instaui/daisyui/static/themes.css +0 -1
  192. instaui/handlers/computed_handler.py +0 -42
  193. instaui/handlers/config_handler.py +0 -13
  194. instaui/ui/__build_init.py +0 -73
  195. instaui/vars/_utils.py +0 -12
  196. instaui-0.1.4.dist-info/RECORD +0 -179
  197. {instaui-0.1.4.dist-info → instaui-0.1.6.dist-info}/LICENSE +0 -0
  198. {instaui-0.1.4.dist-info → instaui-0.1.6.dist-info}/WHEEL +0 -0
instaui/runtime/_app.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set
4
+ from typing_extensions import Unpack, TypedDict
4
5
  from instaui.common.jsonable import Jsonable
5
6
  from .resource import HtmlResource
6
7
  from instaui.consts import _T_App_Mode
@@ -20,14 +21,16 @@ if TYPE_CHECKING:
20
21
 
21
22
  class App(Jsonable):
22
23
  _default_app_slot: ClassVar[Optional[App]] = None
24
+ _web_server_info: ClassVar[Optional[Dict]] = None
23
25
 
24
- def __init__(self, *, mode: _T_App_Mode) -> None:
26
+ def __init__(self, *, mode: _T_App_Mode, meta: Optional[Dict] = None) -> None:
25
27
  super().__init__()
26
28
  self._scope_id_counter = 0
27
29
  self._vfor_id_counter = 0
28
30
  self._slot_id_counter = 0
29
31
  self.mode: _T_App_Mode = mode
30
32
  self.items: List[Component] = []
33
+ self.meta = meta
31
34
  self._slots_stacks: List[Slot] = []
32
35
 
33
36
  defalut_scope = self.create_scope()
@@ -35,6 +38,7 @@ class App(Jsonable):
35
38
  self._scopes: List[Scope] = [defalut_scope]
36
39
  self._html_resource = HtmlResource()
37
40
  self._component_dependencies: Set[ComponentDependencyInfo] = set()
41
+ self._temp_component_dependencies: Dict[str, ComponentDependencyInfo] = {}
38
42
  self._plugin_dependencies: Set[PluginDependencyInfo] = set()
39
43
 
40
44
  self._page_path: Optional[str] = None
@@ -71,6 +75,17 @@ class App(Jsonable):
71
75
  def reset_html_resource(self):
72
76
  self._html_resource = HtmlResource()
73
77
 
78
+ def add_temp_component_dependency(self, dependency: ComponentDependencyInfo):
79
+ self._temp_component_dependencies[dependency.tag_name] = dependency
80
+
81
+ def get_temp_component_dependency(
82
+ self, tag_name: str, default: ComponentDependencyInfo
83
+ ) -> ComponentDependencyInfo:
84
+ return self._temp_component_dependencies.get(tag_name, default)
85
+
86
+ def has_temp_component_dependency(self, tag_name: str):
87
+ return tag_name in self._temp_component_dependencies
88
+
74
89
  def use_component_dependency(
75
90
  self, dependency: ComponentDependencyInfo, *, replace=False
76
91
  ) -> None:
@@ -109,6 +124,9 @@ class App(Jsonable):
109
124
  exclude_defaults=True, by_alias=True
110
125
  )
111
126
 
127
+ if self._web_server_info is not None:
128
+ data["webInfo"] = self._web_server_info
129
+
112
130
  return data
113
131
 
114
132
  @classmethod
@@ -181,8 +199,8 @@ def pop_slot():
181
199
  get_slot_stacks().pop()
182
200
 
183
201
 
184
- def new_app_slot(mode: _T_App_Mode):
185
- return _app_var.set(App(mode=mode))
202
+ def new_app_slot(mode: _T_App_Mode, app_meta: Optional[Dict] = None):
203
+ return _app_var.set(App(mode=mode, meta=app_meta))
186
204
 
187
205
 
188
206
  def reset_app_slot(token: Token[App]):
@@ -198,3 +216,19 @@ def check_default_app_slot_or_error(
198
216
  ):
199
217
  if isinstance(get_app_slot(), DefaultApp):
200
218
  raise ValueError(error_message)
219
+
220
+
221
+ class TWebServerInfo(TypedDict, total=False):
222
+ watch_url: Optional[str]
223
+ watch_async_url: Optional[str]
224
+ event_url: Optional[str]
225
+ event_async_url: Optional[str]
226
+
227
+
228
+ def update_web_server_info(**kwargs: Unpack[TWebServerInfo]):
229
+ if App._web_server_info is None:
230
+ App._web_server_info = {}
231
+
232
+ data = {k: v for k, v in kwargs.items() if v is not None}
233
+
234
+ App._web_server_info.update(data)
@@ -0,0 +1,89 @@
1
+ from __future__ import annotations
2
+ from typing import (
3
+ Callable,
4
+ Dict,
5
+ Generic,
6
+ List,
7
+ Literal,
8
+ Optional,
9
+ Tuple,
10
+ TypeVar,
11
+ Hashable,
12
+ )
13
+
14
+ _TLinkActionObj = TypeVar("_TLinkActionObj")
15
+
16
+ _DEFAULT_KEY_FN = lambda x: x # noqa: E731
17
+
18
+
19
+ class LinkManager(Generic[_TLinkActionObj]):
20
+ def __init__(
21
+ self, key_fn: Optional[Callable[[_TLinkActionObj], Hashable]] = None
22
+ ) -> None:
23
+ self._key_fn = key_fn or _DEFAULT_KEY_FN
24
+ self._actions_map: Dict[
25
+ Tuple[Literal["add", "remove"], Hashable], _TLinkActionObj
26
+ ] = {}
27
+
28
+ def add_link(
29
+ self,
30
+ obj: _TLinkActionObj,
31
+ ):
32
+ key = ("add", self._key_fn(obj))
33
+ self._actions_map[key] = obj
34
+
35
+ def remove_link(
36
+ self,
37
+ obj: _TLinkActionObj,
38
+ ):
39
+ key = ("remove", self._key_fn(obj))
40
+ self._actions_map[key] = obj
41
+
42
+ def get_valid_links(
43
+ self, secondary_manager: Optional[LinkManager] = None
44
+ ) -> List[_TLinkActionObj]:
45
+ secondary_maps = secondary_manager._actions_map if secondary_manager else {}
46
+ merger_map = {**secondary_maps, **self._actions_map}
47
+
48
+ result = {}
49
+
50
+ for (action, key), obj in merger_map.items():
51
+ if action == "add":
52
+ result[key] = obj
53
+ continue
54
+
55
+ if key in result:
56
+ del result[key]
57
+
58
+ return list(result.values())
59
+
60
+
61
+ if __name__ == "__main__":
62
+
63
+ def test_baes():
64
+ manager: LinkManager[str] = LinkManager()
65
+ manager.add_link("a")
66
+ manager.add_link("b")
67
+ manager.add_link("c")
68
+ manager.remove_link("b")
69
+
70
+ assert manager.get_valid_links() == ["a", "c"]
71
+
72
+ test_baes()
73
+
74
+ def test_with_other():
75
+ other: LinkManager[str] = LinkManager()
76
+ other.add_link("a")
77
+ other.add_link("b")
78
+ other.add_link("c")
79
+
80
+ manager1: LinkManager[str] = LinkManager()
81
+ manager1.add_link("b")
82
+ manager1.add_link("d")
83
+ manager1.add_link("e")
84
+ manager1.remove_link("a")
85
+ manager1.remove_link("b")
86
+
87
+ assert manager1.get_valid_links(other) == ["c", "d", "e"]
88
+
89
+ test_with_other()
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
  from pathlib import Path
3
3
  from typing import Any, Dict, List, Optional, Set, Union
4
4
  from .dataclass import JsLink, VueAppUse, VueAppComponent
5
+ from ._link_manager import LinkManager
5
6
 
6
7
 
7
8
  class HtmlResource:
@@ -10,9 +11,11 @@ class HtmlResource:
10
11
  favicon: Optional[Path] = None
11
12
 
12
13
  def __init__(self) -> None:
13
- self._css_links: Dict[Union[str, Path], Any] = {}
14
+ self._css_links_manager: LinkManager[Union[str, Path]] = LinkManager()
14
15
  self._style_tags: List[str] = []
15
- self._js_links: List[JsLink] = []
16
+ self._js_links_manager: LinkManager[JsLink] = LinkManager(
17
+ key_fn=lambda js_link: js_link.link
18
+ )
16
19
  self._script_tags: List[str] = []
17
20
  self._vue_app_use: Set[VueAppUse] = set()
18
21
  self._vue_app_components: Set[VueAppComponent] = set()
@@ -20,10 +23,10 @@ class HtmlResource:
20
23
  self._appConfig = "{}"
21
24
 
22
25
  def add_css_link(self, link: Union[str, Path]):
23
- self._css_links[link] = None
26
+ self._css_links_manager.add_link(link)
24
27
 
25
28
  def remove_css_link(self, link: Union[str, Path]):
26
- self._css_links.pop(link, None)
29
+ self._css_links_manager.remove_link(link)
27
30
 
28
31
  def add_style_tag(self, content: str):
29
32
  self._style_tags.append(content)
@@ -33,12 +36,19 @@ class HtmlResource:
33
36
  link: Union[str, Path],
34
37
  *,
35
38
  attrs: Optional[Dict[str, Any]] = None,
36
- insert_before: int = -1,
37
39
  ):
38
- if insert_before == -1:
39
- self._js_links.append(JsLink(link, attrs or {}))
40
- return
41
- self._js_links.insert(insert_before, JsLink(link, attrs or {}))
40
+ self._js_links_manager.add_link(JsLink(link, attrs or {}))
41
+
42
+ def remove_js_link(self, link: Union[str, Path]):
43
+ self._js_links_manager.remove_link(JsLink(link))
44
+
45
+ def get_valid_js_links(self, default_js_links_manager: LinkManager) -> List[JsLink]:
46
+ return self._js_links_manager.get_valid_links(default_js_links_manager)
47
+
48
+ def get_valid_css_links(
49
+ self, default_css_links_manager: LinkManager[Union[str, Path]]
50
+ ) -> List[Union[str, Path]]:
51
+ return self._css_links_manager.get_valid_links(default_css_links_manager)
42
52
 
43
53
  def add_script_tag(
44
54
  self, content: str, script_attrs: Optional[Dict[str, Any]] = None
instaui/runtime/scope.py CHANGED
@@ -8,6 +8,9 @@ if TYPE_CHECKING:
8
8
  from instaui.vars.mixin_types.var_type import VarMixin
9
9
  from instaui.vars.mixin_types.py_binding import CanInputMixin
10
10
  from instaui.vars.web_computed import WebComputed
11
+ from instaui.vars.js_computed import JsComputed
12
+ from instaui.vars.vue_computed import VueComputed
13
+ from instaui.vars.data import ConstData
11
14
  from instaui.watch.web_watch import WebWatch
12
15
  from instaui.watch.js_watch import JsWatch
13
16
  from instaui.watch.vue_watch import VueWatch
@@ -20,7 +23,10 @@ class Scope(Jsonable):
20
23
  self.id = id
21
24
  self._vars_id_counter = 0
22
25
  self._element_ref_id_counter = 0
23
- self._vars: List[VarMixin] = []
26
+ self._refs: List[VarMixin] = []
27
+ self._const_data: List[ConstData] = []
28
+ self._js_computeds: List[JsComputed] = []
29
+ self._vue_computeds: List[VueComputed] = []
24
30
  self._web_computeds: List[WebComputed] = []
25
31
  self._element_refs: List[ElementRef] = []
26
32
  self._run_method_records: List = []
@@ -52,8 +58,17 @@ class Scope(Jsonable):
52
58
  "on": [v._to_input_config() for v in on],
53
59
  }
54
60
 
55
- def register_var(self, var: VarMixin) -> None:
56
- self._vars.append(var)
61
+ def register_ref(self, var: VarMixin) -> None:
62
+ self._refs.append(var)
63
+
64
+ def register_data(self, data: ConstData) -> None:
65
+ self._const_data.append(data)
66
+
67
+ def register_js_computed(self, computed: JsComputed) -> None:
68
+ self._js_computeds.append(computed)
69
+
70
+ def register_vue_computed(self, computed: VueComputed) -> None:
71
+ self._vue_computeds.append(computed)
57
72
 
58
73
  def register_web_computed(self, computed: WebComputed) -> None:
59
74
  self._web_computeds.append(computed)
@@ -69,8 +84,8 @@ class Scope(Jsonable):
69
84
 
70
85
  def _to_json_dict(self):
71
86
  data = super()._to_json_dict()
72
- if self._vars:
73
- data["vars"] = self._vars
87
+ if self._refs:
88
+ data["refs"] = self._refs
74
89
  if self._query:
75
90
  data["query"] = self._query
76
91
  if self._web_watchs:
@@ -83,6 +98,12 @@ class Scope(Jsonable):
83
98
  data["eRefs"] = self._element_refs
84
99
  if self._web_computeds:
85
100
  data["web_computed"] = self._web_computeds
101
+ if self._js_computeds:
102
+ data["js_computed"] = self._js_computeds
103
+ if self._vue_computeds:
104
+ data["vue_computed"] = self._vue_computeds
105
+ if self._const_data:
106
+ data["data"] = self._const_data
86
107
 
87
108
  return data
88
109
 
@@ -91,8 +112,8 @@ class GlobalScope(Scope):
91
112
  def __init__(self, id: str) -> None:
92
113
  super().__init__(id)
93
114
 
94
- def register_var(self, var: VarMixin) -> None:
95
- raise ValueError("Can not register vars in global scope")
115
+ def register_ref(self, var: VarMixin) -> None:
116
+ raise ValueError("Can not register ref in global scope")
96
117
 
97
118
  def register_web_computed(self, computed: WebComputed) -> None:
98
119
  raise ValueError("Can not register web_computeds in global scope")
@@ -0,0 +1,42 @@
1
+ from pathlib import Path
2
+ from instaui.runtime._app import get_app_slot
3
+
4
+
5
+ _STATIC_DIR = Path(__file__).parent / "static"
6
+ _CSS_FILE = _STATIC_DIR / "shadcn-classless.css"
7
+
8
+
9
+ def use_shadcn_classless(value=True):
10
+ """Use shadcn-classless.css or not.
11
+
12
+ Args:
13
+ value (bool, optional): Whether to use shadcn-classless.css or not. Defaults to True.
14
+
15
+ Example:
16
+
17
+ App default use shadcn-classless.css:
18
+ .. code-block:: python
19
+
20
+ @ui.page('/')
21
+ def index():
22
+
23
+ # Create a container with shadcn-classless class
24
+ with html.div().classes("shadcn-classless"):
25
+ html.h1("Hello, world!")
26
+
27
+ with html.form():
28
+ html.input()
29
+ html.button("Submit")
30
+
31
+ Can be disabled:
32
+ .. code-block:: python
33
+ # App does not use shadcn-classless
34
+ ui.use_shadcn_classless(False)
35
+
36
+ """
37
+
38
+ if value:
39
+ get_app_slot()._html_resource.add_css_link(_CSS_FILE)
40
+
41
+ else:
42
+ get_app_slot()._html_resource.remove_css_link(_CSS_FILE)