instaui 0.1.15__py2.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 (283) hide show
  1. instaui/__init__.py +9 -0
  2. instaui/_helper/observable_helper.py +45 -0
  3. instaui/arco/__init__.py +191 -0
  4. instaui/arco/_settings.py +25 -0
  5. instaui/arco/_use_tools/locale.py +50 -0
  6. instaui/arco/component_types.py +1019 -0
  7. instaui/arco/components/_utils.py +22 -0
  8. instaui/arco/components/affix.py +29 -0
  9. instaui/arco/components/alert.py +42 -0
  10. instaui/arco/components/anchor.py +42 -0
  11. instaui/arco/components/auto_complete.py +96 -0
  12. instaui/arco/components/avatar.py +55 -0
  13. instaui/arco/components/back_top.py +14 -0
  14. instaui/arco/components/badge.py +14 -0
  15. instaui/arco/components/breadcrumb.py +14 -0
  16. instaui/arco/components/button.py +43 -0
  17. instaui/arco/components/calendar.py +47 -0
  18. instaui/arco/components/card.py +14 -0
  19. instaui/arco/components/carousel.py +33 -0
  20. instaui/arco/components/cascader.py +111 -0
  21. instaui/arco/components/checkbox.py +32 -0
  22. instaui/arco/components/collapse.py +31 -0
  23. instaui/arco/components/color_picker.py +45 -0
  24. instaui/arco/components/comment.py +14 -0
  25. instaui/arco/components/config_provider.py +13 -0
  26. instaui/arco/components/date_picker.py +111 -0
  27. instaui/arco/components/descriptions.py +14 -0
  28. instaui/arco/components/divider.py +13 -0
  29. instaui/arco/components/drawer.py +98 -0
  30. instaui/arco/components/dropdown.py +45 -0
  31. instaui/arco/components/empty.py +14 -0
  32. instaui/arco/components/form.py +55 -0
  33. instaui/arco/components/icon.py +17 -0
  34. instaui/arco/components/image.py +33 -0
  35. instaui/arco/components/input.py +102 -0
  36. instaui/arco/components/input_number.py +97 -0
  37. instaui/arco/components/input_password.py +38 -0
  38. instaui/arco/components/input_search.py +37 -0
  39. instaui/arco/components/input_tag.py +110 -0
  40. instaui/arco/components/layout.py +13 -0
  41. instaui/arco/components/layout_content.py +6 -0
  42. instaui/arco/components/layout_footer.py +6 -0
  43. instaui/arco/components/layout_header.py +6 -0
  44. instaui/arco/components/layout_sider.py +53 -0
  45. instaui/arco/components/link.py +36 -0
  46. instaui/arco/components/list.py +68 -0
  47. instaui/arco/components/mention.py +97 -0
  48. instaui/arco/components/menu.py +88 -0
  49. instaui/arco/components/modal.py +97 -0
  50. instaui/arco/components/overflow_list.py +29 -0
  51. instaui/arco/components/page_header.py +29 -0
  52. instaui/arco/components/pagination.py +45 -0
  53. instaui/arco/components/pop_confirm.py +58 -0
  54. instaui/arco/components/popover.py +32 -0
  55. instaui/arco/components/progress.py +14 -0
  56. instaui/arco/components/radio.py +40 -0
  57. instaui/arco/components/radio_group.py +42 -0
  58. instaui/arco/components/rate.py +45 -0
  59. instaui/arco/components/resize_box.py +62 -0
  60. instaui/arco/components/result.py +14 -0
  61. instaui/arco/components/select.py +182 -0
  62. instaui/arco/components/skeleton.py +14 -0
  63. instaui/arco/components/slider.py +38 -0
  64. instaui/arco/components/space.py +14 -0
  65. instaui/arco/components/spin.py +14 -0
  66. instaui/arco/components/split.py +76 -0
  67. instaui/arco/components/statistic.py +14 -0
  68. instaui/arco/components/steps.py +32 -0
  69. instaui/arco/components/switch.py +57 -0
  70. instaui/arco/components/tab_pane.py +12 -0
  71. instaui/arco/components/table.py +276 -0
  72. instaui/arco/components/tabs.py +101 -0
  73. instaui/arco/components/tag.py +42 -0
  74. instaui/arco/components/textarea.py +84 -0
  75. instaui/arco/components/time_picker.py +76 -0
  76. instaui/arco/components/timeline.py +14 -0
  77. instaui/arco/components/tooltip.py +29 -0
  78. instaui/arco/components/transfer.py +58 -0
  79. instaui/arco/components/tree.py +120 -0
  80. instaui/arco/components/tree_select.py +86 -0
  81. instaui/arco/components/trigger.py +58 -0
  82. instaui/arco/components/typography.py +142 -0
  83. instaui/arco/components/upload.py +71 -0
  84. instaui/arco/components/verification_code.py +58 -0
  85. instaui/arco/components/watermark.py +14 -0
  86. instaui/arco/locales/__init__.py +4 -0
  87. instaui/arco/locales/_index.py +31 -0
  88. instaui/arco/locales/en_us.py +227 -0
  89. instaui/arco/locales/zh_cn.py +224 -0
  90. instaui/arco/setup.py +36 -0
  91. instaui/arco/static/instaui-arco.css +1 -0
  92. instaui/arco/static/instaui-arco.js +55771 -0
  93. instaui/arco/types.py +24 -0
  94. instaui/boot_info.py +43 -0
  95. instaui/common/jsonable.py +37 -0
  96. instaui/components/__init__.py +0 -0
  97. instaui/components/column.py +26 -0
  98. instaui/components/component.py +47 -0
  99. instaui/components/content.py +34 -0
  100. instaui/components/directive.py +55 -0
  101. instaui/components/element.py +573 -0
  102. instaui/components/grid.py +213 -0
  103. instaui/components/html/__init__.py +49 -0
  104. instaui/components/html/_mixins.py +34 -0
  105. instaui/components/html/_preset.py +4 -0
  106. instaui/components/html/button.py +38 -0
  107. instaui/components/html/checkbox.py +35 -0
  108. instaui/components/html/date.py +28 -0
  109. instaui/components/html/div.py +7 -0
  110. instaui/components/html/form.py +7 -0
  111. instaui/components/html/heading.py +51 -0
  112. instaui/components/html/input.py +28 -0
  113. instaui/components/html/label.py +21 -0
  114. instaui/components/html/li.py +17 -0
  115. instaui/components/html/link.py +31 -0
  116. instaui/components/html/number.py +34 -0
  117. instaui/components/html/paragraph.py +29 -0
  118. instaui/components/html/range.py +48 -0
  119. instaui/components/html/select.py +69 -0
  120. instaui/components/html/span.py +19 -0
  121. instaui/components/html/table.py +36 -0
  122. instaui/components/html/textarea.py +28 -0
  123. instaui/components/html/ul.py +20 -0
  124. instaui/components/label.py +5 -0
  125. instaui/components/markdown/markdown.js +33 -0
  126. instaui/components/markdown/markdown.py +41 -0
  127. instaui/components/markdown/static/github-markdown.css +12 -0
  128. instaui/components/markdown/static/marked.esm.js +2579 -0
  129. instaui/components/match.py +108 -0
  130. instaui/components/row.py +17 -0
  131. instaui/components/shiki_code/shiki_code.js +126 -0
  132. instaui/components/shiki_code/shiki_code.py +99 -0
  133. instaui/components/shiki_code/static/langs/css.mjs +5 -0
  134. instaui/components/shiki_code/static/langs/markdown.mjs +5 -0
  135. instaui/components/shiki_code/static/langs/python.mjs +5 -0
  136. instaui/components/shiki_code/static/langs/shell.mjs +2 -0
  137. instaui/components/shiki_code/static/langs/shellscript.mjs +5 -0
  138. instaui/components/shiki_code/static/shiki-core.js +5784 -0
  139. instaui/components/shiki_code/static/shiki-style.css +179 -0
  140. instaui/components/shiki_code/static/shiki-transformers.js +461 -0
  141. instaui/components/shiki_code/static/themes/vitesse-dark.mjs +2 -0
  142. instaui/components/shiki_code/static/themes/vitesse-light.mjs +2 -0
  143. instaui/components/slot.py +81 -0
  144. instaui/components/transition_group.py +9 -0
  145. instaui/components/value_element.py +52 -0
  146. instaui/components/vfor.py +142 -0
  147. instaui/components/vif.py +42 -0
  148. instaui/consts.py +23 -0
  149. instaui/dependencies/component_dependency.py +22 -0
  150. instaui/dependencies/plugin_dependency.py +28 -0
  151. instaui/event/event_mixin.py +12 -0
  152. instaui/event/js_event.py +82 -0
  153. instaui/event/vue_event.py +66 -0
  154. instaui/event/web_event.py +123 -0
  155. instaui/experimental/__init__.py +3 -0
  156. instaui/experimental/debug.py +48 -0
  157. instaui/extra_libs/_echarts.py +3 -0
  158. instaui/extra_libs/_import_error.py +9 -0
  159. instaui/extra_libs/_mermaid.py +3 -0
  160. instaui/extra_libs/_shiki_code.py +3 -0
  161. instaui/fastapi_server/_utils.py +42 -0
  162. instaui/fastapi_server/_uvicorn.py +37 -0
  163. instaui/fastapi_server/debug_mode_router.py +60 -0
  164. instaui/fastapi_server/dependency_router.py +28 -0
  165. instaui/fastapi_server/event_router.py +58 -0
  166. instaui/fastapi_server/middlewares.py +19 -0
  167. instaui/fastapi_server/request_context.py +19 -0
  168. instaui/fastapi_server/resource.py +30 -0
  169. instaui/fastapi_server/server.py +308 -0
  170. instaui/fastapi_server/watch_router.py +53 -0
  171. instaui/handlers/_utils.py +88 -0
  172. instaui/handlers/event_handler.py +60 -0
  173. instaui/handlers/watch_handler.py +61 -0
  174. instaui/html_tools.py +94 -0
  175. instaui/inject.py +33 -0
  176. instaui/js/__init__.py +4 -0
  177. instaui/js/js_output.py +15 -0
  178. instaui/js/lambda_func.py +35 -0
  179. instaui/launch_collector.py +52 -0
  180. instaui/page_info.py +13 -0
  181. instaui/runtime/__init__.py +29 -0
  182. instaui/runtime/_app.py +234 -0
  183. instaui/runtime/_inner_helper.py +9 -0
  184. instaui/runtime/_link_manager.py +89 -0
  185. instaui/runtime/context.py +47 -0
  186. instaui/runtime/dataclass.py +30 -0
  187. instaui/runtime/resource.py +65 -0
  188. instaui/runtime/scope.py +133 -0
  189. instaui/runtime/ui_state_scope.py +15 -0
  190. instaui/settings/__init__.py +4 -0
  191. instaui/settings/__settings.py +13 -0
  192. instaui/shadcn_classless/_index.py +42 -0
  193. instaui/shadcn_classless/static/shadcn-classless.css +403 -0
  194. instaui/skip.py +12 -0
  195. instaui/spa_router/__init__.py +26 -0
  196. instaui/spa_router/_components.py +35 -0
  197. instaui/spa_router/_file_base_utils.py +273 -0
  198. instaui/spa_router/_functions.py +122 -0
  199. instaui/spa_router/_install.py +11 -0
  200. instaui/spa_router/_route_model.py +117 -0
  201. instaui/spa_router/_router_box.py +40 -0
  202. instaui/spa_router/_router_output.py +22 -0
  203. instaui/spa_router/_router_param_var.py +51 -0
  204. instaui/spa_router/_types.py +4 -0
  205. instaui/spa_router/templates/page_routes +60 -0
  206. instaui/static/insta-ui.css +1 -0
  207. instaui/static/insta-ui.esm-browser.prod.js +3717 -0
  208. instaui/static/insta-ui.ico +0 -0
  209. instaui/static/insta-ui.js.map +1 -0
  210. instaui/static/instaui-tools-browser.js +511 -0
  211. instaui/static/templates/debug/sse.html +117 -0
  212. instaui/static/templates/web.html +74 -0
  213. instaui/static/templates/webview.html +78 -0
  214. instaui/static/templates/zero.html +71 -0
  215. instaui/static/vue.esm-browser.prod.js +9 -0
  216. instaui/static/vue.global.prod.js +9 -0
  217. instaui/static/vue.runtime.esm-browser.prod.js +5 -0
  218. instaui/systems/file_system.py +6 -0
  219. instaui/systems/func_system.py +119 -0
  220. instaui/systems/js_system.py +22 -0
  221. instaui/systems/module_system.py +46 -0
  222. instaui/systems/pydantic_system.py +27 -0
  223. instaui/systems/string_system.py +10 -0
  224. instaui/tailwind/__init__.py +6 -0
  225. instaui/tailwind/_index.py +24 -0
  226. instaui/tailwind/static/tailwindcss-v3.min.js +62 -0
  227. instaui/tailwind/static/tailwindcss-v4.min.js +8 -0
  228. instaui/template/__init__.py +4 -0
  229. instaui/template/_utils.py +23 -0
  230. instaui/template/env.py +7 -0
  231. instaui/template/web_template.py +49 -0
  232. instaui/template/webview_template.py +48 -0
  233. instaui/template/zero_template.py +105 -0
  234. instaui/ui/__init__.py +144 -0
  235. instaui/ui/__init__.pyi +149 -0
  236. instaui/ui/events.py +25 -0
  237. instaui/ui_functions/input_slient_data.py +16 -0
  238. instaui/ui_functions/server.py +15 -0
  239. instaui/ui_functions/str_format.py +36 -0
  240. instaui/ui_functions/ui_page.py +16 -0
  241. instaui/ui_functions/ui_types.py +13 -0
  242. instaui/ui_functions/url_location.py +33 -0
  243. instaui/vars/_types.py +8 -0
  244. instaui/vars/data.py +68 -0
  245. instaui/vars/element_ref.py +40 -0
  246. instaui/vars/event_context.py +49 -0
  247. instaui/vars/event_extend.py +0 -0
  248. instaui/vars/js_computed.py +117 -0
  249. instaui/vars/mixin_types/common_type.py +5 -0
  250. instaui/vars/mixin_types/element_binding.py +16 -0
  251. instaui/vars/mixin_types/observable.py +7 -0
  252. instaui/vars/mixin_types/pathable.py +14 -0
  253. instaui/vars/mixin_types/py_binding.py +13 -0
  254. instaui/vars/mixin_types/str_format_binding.py +8 -0
  255. instaui/vars/mixin_types/var_type.py +5 -0
  256. instaui/vars/path_var.py +90 -0
  257. instaui/vars/ref.py +103 -0
  258. instaui/vars/slot_prop.py +46 -0
  259. instaui/vars/state.py +97 -0
  260. instaui/vars/types.py +24 -0
  261. instaui/vars/vfor_item.py +204 -0
  262. instaui/vars/vue_computed.py +81 -0
  263. instaui/vars/web_computed.py +209 -0
  264. instaui/vars/web_view_computed.py +1 -0
  265. instaui/version.py +3 -0
  266. instaui/watch/_types.py +4 -0
  267. instaui/watch/_utils.py +3 -0
  268. instaui/watch/js_watch.py +110 -0
  269. instaui/watch/vue_watch.py +77 -0
  270. instaui/watch/web_watch.py +181 -0
  271. instaui/webview/__init__.py +2 -0
  272. instaui/webview/_utils.py +8 -0
  273. instaui/webview/api.py +72 -0
  274. instaui/webview/func.py +114 -0
  275. instaui/webview/index.py +161 -0
  276. instaui/webview/resource.py +172 -0
  277. instaui/zero/__init__.py +3 -0
  278. instaui/zero/func.py +123 -0
  279. instaui/zero/scope.py +109 -0
  280. instaui-0.1.15.dist-info/METADATA +152 -0
  281. instaui-0.1.15.dist-info/RECORD +283 -0
  282. instaui-0.1.15.dist-info/WHEEL +5 -0
  283. instaui-0.1.15.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,133 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, List
4
+ from instaui.common.jsonable import Jsonable
5
+
6
+
7
+ if TYPE_CHECKING:
8
+ from instaui.vars.mixin_types.var_type import VarMixin
9
+ from instaui.vars.mixin_types.py_binding import CanInputMixin
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
14
+ from instaui.watch.web_watch import WebWatch
15
+ from instaui.watch.js_watch import JsWatch
16
+ from instaui.watch.vue_watch import VueWatch
17
+ from instaui.vars.element_ref import ElementRef
18
+
19
+
20
+ class Scope(Jsonable):
21
+ def __init__(self, id: str) -> None:
22
+ super().__init__()
23
+ self.id = id
24
+ self._vars_id_counter = 0
25
+ self._element_ref_id_counter = 0
26
+ self._refs: List[VarMixin] = []
27
+ self._const_data: List[ConstData] = []
28
+ self._js_computeds: List[JsComputed] = []
29
+ self._vue_computeds: List[VueComputed] = []
30
+ self._web_computeds: List[WebComputed] = []
31
+ self._element_refs: List[ElementRef] = []
32
+ self._run_method_records: List = []
33
+ self._web_watchs: List[WebWatch] = []
34
+ self._js_watchs: List[JsWatch] = []
35
+ self._vue_watchs: List[VueWatch] = []
36
+ self._query = {}
37
+
38
+ def set_run_method_record(
39
+ self, scope_id: str, element_ref_id: str, method_name: str, args
40
+ ):
41
+ self._run_method_records.append((scope_id, element_ref_id, method_name, args))
42
+
43
+ def generate_vars_id(self) -> str:
44
+ self._vars_id_counter += 1
45
+ return str(self._vars_id_counter)
46
+
47
+ def generate_element_ref_id(self) -> str:
48
+ self._element_ref_id_counter += 1
49
+ return str(self._element_ref_id_counter)
50
+
51
+ def register_element_ref(self, ref: ElementRef):
52
+ self._element_refs.append(ref)
53
+
54
+ def set_query(self, url: str, key: str, on: List[CanInputMixin]) -> None:
55
+ self._query = {
56
+ "url": url,
57
+ "key": key,
58
+ "on": [v._to_input_config() for v in on],
59
+ }
60
+
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)
72
+
73
+ def register_web_computed(self, computed: WebComputed) -> None:
74
+ self._web_computeds.append(computed)
75
+
76
+ def register_web_watch(self, watch: WebWatch) -> None:
77
+ self._web_watchs.append(watch)
78
+
79
+ def register_js_watch(self, watch: JsWatch) -> None:
80
+ self._js_watchs.append(watch)
81
+
82
+ def register_vue_watch(self, watch: VueWatch) -> None:
83
+ self._vue_watchs.append(watch)
84
+
85
+ def _to_json_dict(self):
86
+ data = super()._to_json_dict()
87
+ if self._refs:
88
+ data["refs"] = self._refs
89
+ if self._query:
90
+ data["query"] = self._query
91
+ if self._web_watchs:
92
+ data["py_watch"] = self._web_watchs
93
+ if self._js_watchs:
94
+ data["js_watch"] = self._js_watchs
95
+ if self._vue_watchs:
96
+ data["vue_watch"] = self._vue_watchs
97
+ if self._element_refs:
98
+ data["eRefs"] = self._element_refs
99
+
100
+ _web_computeds = [
101
+ computed for computed in self._web_computeds if computed._is_used()
102
+ ]
103
+
104
+ if _web_computeds:
105
+ data["web_computed"] = _web_computeds
106
+ if self._js_computeds:
107
+ data["js_computed"] = self._js_computeds
108
+ if self._vue_computeds:
109
+ data["vue_computed"] = self._vue_computeds
110
+ if self._const_data:
111
+ data["data"] = self._const_data
112
+
113
+ return data
114
+
115
+
116
+ class GlobalScope(Scope):
117
+ def __init__(self, id: str) -> None:
118
+ super().__init__(id)
119
+
120
+ def register_ref(self, var: VarMixin) -> None:
121
+ raise ValueError("Can not register ref in global scope")
122
+
123
+ def register_web_computed(self, computed: WebComputed) -> None:
124
+ raise ValueError("Can not register web_computeds in global scope")
125
+
126
+ def register_web_watch(self, watch: WebWatch) -> None:
127
+ raise ValueError("Can not register web_watchs in global scope")
128
+
129
+ def register_js_watch(self, watch: JsWatch) -> None:
130
+ raise ValueError("Can not register js_watchs in global scope")
131
+
132
+ def register_vue_watch(self, watch: VueWatch) -> None:
133
+ raise ValueError("Can not register vue_watchs in global scope")
@@ -0,0 +1,15 @@
1
+ import contextvars
2
+ from typing import Dict
3
+
4
+
5
+ _scope_var: contextvars.ContextVar[Dict[type, object]] = contextvars.ContextVar(
6
+ "_scope_var", default={}
7
+ )
8
+
9
+
10
+ def save_state(key, obj: object) -> None:
11
+ _scope_var.get()[key] = obj
12
+
13
+
14
+ def load_state(key) -> object:
15
+ return _scope_var.get()[key]
@@ -0,0 +1,4 @@
1
+ from .__settings import use_tailwind
2
+
3
+
4
+ __all__ = ["use_tailwind"]
@@ -0,0 +1,13 @@
1
+ from instaui.runtime import in_default_app_slot, HtmlResource
2
+
3
+
4
+ def use_tailwind(value=True):
5
+ """Use Tailwind CSS framework.
6
+
7
+ Args:
8
+ value (bool, optional): whether to use Tailwind CSS. Defaults to True.
9
+ """
10
+
11
+ if not in_default_app_slot():
12
+ raise ValueError("Cannot set use_tailwind outside of ui.page")
13
+ HtmlResource.use_tailwind = value
@@ -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)
@@ -0,0 +1,403 @@
1
+ .shadcn-classless {
2
+ color-scheme: light dark;
3
+ font-family: ui-monospace, "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
4
+ background-color: var(--background);
5
+ color: var(--foreground);
6
+ line-height: 1.5;
7
+ padding: 1rem;
8
+ --radius: 0.5rem;
9
+ --background: oklch(1 0 0);
10
+ --foreground: oklch(0.141 0.005 285.823);
11
+ --card: oklch(1 0 0);
12
+ --card-foreground: oklch(0.141 0.005 285.823);
13
+ --popover: oklch(1 0 0);
14
+ --popover-foreground: oklch(0.141 0.005 285.823);
15
+ --primary: oklch(0.21 0.006 285.885);
16
+ --primary-foreground: oklch(0.985 0 0);
17
+ --secondary: oklch(0.967 0.001 286.375);
18
+ --secondary-foreground: oklch(0.21 0.006 285.885);
19
+ --muted: oklch(0.967 0.001 286.375);
20
+ --muted-foreground: oklch(0.552 0.016 285.938);
21
+ --accent: oklch(0.967 0.001 286.375);
22
+ --accent-foreground: oklch(0.21 0.006 285.885);
23
+ --destructive: oklch(0.577 0.245 27.325);
24
+ --border: oklch(0.92 0.004 286.32);
25
+ --input: oklch(0.92 0.004 286.32);
26
+ --ring: oklch(0.705 0.015 286.067);
27
+ --chart-1: oklch(0.646 0.222 41.116);
28
+ --chart-2: oklch(0.6 0.118 184.704);
29
+ --chart-3: oklch(0.398 0.07 227.392);
30
+ --chart-4: oklch(0.828 0.189 84.429);
31
+ --chart-5: oklch(0.769 0.188 70.08);
32
+ --sidebar: oklch(0.985 0 0);
33
+ --sidebar-foreground: oklch(0.141 0.005 285.823);
34
+ --sidebar-primary: oklch(0.21 0.006 285.885);
35
+ --sidebar-primary-foreground: oklch(0.985 0 0);
36
+ --sidebar-accent: oklch(0.967 0.001 286.375);
37
+ --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
38
+ --sidebar-border: oklch(0.92 0.004 286.32);
39
+ --sidebar-ring: oklch(0.705 0.015 286.067);
40
+ }
41
+ .shadcn-classless.dark-mode {
42
+ --background: oklch(0.141 0.005 285.823);
43
+ --foreground: oklch(0.985 0 0);
44
+ --card: oklch(0.21 0.006 285.885);
45
+ --card-foreground: oklch(0.985 0 0);
46
+ --popover: oklch(0.21 0.006 285.885);
47
+ --popover-foreground: oklch(0.985 0 0);
48
+ --primary: oklch(0.92 0.004 286.32);
49
+ --primary-foreground: oklch(0.21 0.006 285.885);
50
+ --secondary: oklch(0.274 0.006 286.033);
51
+ --secondary-foreground: oklch(0.985 0 0);
52
+ --muted: oklch(0.274 0.006 286.033);
53
+ --muted-foreground: oklch(0.705 0.015 286.067);
54
+ --accent: oklch(0.274 0.006 286.033);
55
+ --accent-foreground: oklch(0.985 0 0);
56
+ --destructive: oklch(0.704 0.191 22.216);
57
+ --border: oklch(1 0 0 / 10%);
58
+ --input: oklch(1 0 0 / 15%);
59
+ --ring: oklch(0.552 0.016 285.938);
60
+ --chart-1: oklch(0.488 0.243 264.376);
61
+ --chart-2: oklch(0.696 0.17 162.48);
62
+ --chart-3: oklch(0.769 0.188 70.08);
63
+ --chart-4: oklch(0.627 0.265 303.9);
64
+ --chart-5: oklch(0.645 0.246 16.439);
65
+ --sidebar: oklch(0.21 0.006 285.885);
66
+ --sidebar-foreground: oklch(0.985 0 0);
67
+ --sidebar-primary: oklch(0.488 0.243 264.376);
68
+ --sidebar-primary-foreground: oklch(0.985 0 0);
69
+ --sidebar-accent: oklch(0.274 0.006 286.033);
70
+ --sidebar-accent-foreground: oklch(0.985 0 0);
71
+ --sidebar-border: oklch(1 0 0 / 10%);
72
+ --sidebar-ring: oklch(0.552 0.016 285.938);
73
+ }
74
+ .shadcn-classless *,
75
+ .shadcn-classless ::after,
76
+ .shadcn-classless ::before {
77
+ box-sizing: border-box;
78
+ }
79
+ .shadcn-classless * {
80
+ margin: 0;
81
+ padding: 0;
82
+ }
83
+ .shadcn-classless h1,
84
+ .shadcn-classless h2,
85
+ .shadcn-classless h3,
86
+ .shadcn-classless h4,
87
+ .shadcn-classless h5,
88
+ .shadcn-classless h6 {
89
+ margin-bottom: 0.5em;
90
+ font-weight: 700;
91
+ }
92
+ .shadcn-classless h1 {
93
+ letter-spacing: -0.025em;
94
+ font-weight: 700;
95
+ font-size: 1.875rem;
96
+ line-height: 2.25rem;
97
+ }
98
+ .shadcn-classless h2 {
99
+ letter-spacing: -0.025em;
100
+ font-weight: 600;
101
+ font-size: 1.25rem;
102
+ line-height: 1.75rem;
103
+ }
104
+ .shadcn-classless h3 {
105
+ letter-spacing: -0.025em;
106
+ font-weight: 600;
107
+ font-size: 1.125rem;
108
+ line-height: 1.75rem;
109
+ }
110
+ .shadcn-classless h4 {
111
+ letter-spacing: -0.025em;
112
+ font-weight: 600;
113
+ font-size: 16px;
114
+ line-height: 1.75rem;
115
+ }
116
+ .shadcn-classless h5 {
117
+ font-size: 15px;
118
+ }
119
+ .shadcn-classless h6 {
120
+ font-size: 14px;
121
+ }
122
+ .shadcn-classless p {
123
+ margin-bottom: 1em;
124
+ }
125
+ .shadcn-classless a {
126
+ color: var(--primary);
127
+ text-decoration: none;
128
+ }
129
+ .shadcn-classless a:hover {
130
+ text-decoration: underline;
131
+ }
132
+ .shadcn-classless ul,
133
+ .shadcn-classless ol {
134
+ margin-bottom: 1em;
135
+ padding-left: 1.5em;
136
+ }
137
+ .shadcn-classless header,
138
+ .shadcn-classless main {
139
+ max-width: 800px;
140
+ margin: 0 auto;
141
+ }
142
+ .shadcn-classless header {
143
+ margin-bottom: 2rem;
144
+ }
145
+ .shadcn-classless header h1 {
146
+ font-size: 2rem;
147
+ }
148
+ .shadcn-classless nav ul {
149
+ list-style: none;
150
+ padding: 0;
151
+ display: flex;
152
+ gap: 1rem;
153
+ }
154
+ .shadcn-classless section {
155
+ margin-bottom: 2rem;
156
+ }
157
+ .shadcn-classless form {
158
+ display: flex;
159
+ flex-direction: column;
160
+ gap: 1rem;
161
+ }
162
+ .shadcn-classless input,
163
+ .shadcn-classless select,
164
+ .shadcn-classless textarea {
165
+ font-weight: 500;
166
+ font: inherit;
167
+ padding: 0.5rem 0.75rem;
168
+ border: 1px solid var(--border);
169
+ border-radius: var(--radius);
170
+ background-color: var(--background);
171
+ color: var(--foreground);
172
+ font-size: 0.875rem;
173
+ }
174
+ .shadcn-classless select {
175
+ appearance: none;
176
+ -webkit-appearance: none;
177
+ -moz-appearance: none;
178
+ background: transparent;
179
+ background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>');
180
+ background-repeat: no-repeat;
181
+ background-position-x: calc(100% - 0.75rem);
182
+ background-position-y: 50%;
183
+ }
184
+ .shadcn-classless input[type='submit'],
185
+ .shadcn-classless button {
186
+ font: inherit;
187
+ cursor: pointer;
188
+ font-size: 0.875rem;
189
+ font-weight: 500;
190
+ padding: 0.5rem 1rem;
191
+ background-color: var(--primary);
192
+ color: var(--primary-foreground);
193
+ border: none;
194
+ border-radius: var(--radius);
195
+ transition: background-color 0.2s ease-in-out;
196
+ }
197
+ .shadcn-classless input[type='submit']:hover,
198
+ .shadcn-classless button:hover {
199
+ background-color: color-mix(in srgb, var(--primary) 90%, transparent);
200
+ }
201
+ .shadcn-classless fieldset {
202
+ border: 1px solid var(--border);
203
+ border-radius: var(--radius);
204
+ padding: 1rem;
205
+ }
206
+ .shadcn-classless legend {
207
+ padding: 0 0.5rem;
208
+ }
209
+ .shadcn-classless label {
210
+ display: block;
211
+ }
212
+ .shadcn-classless small {
213
+ color: var(--muted-foreground);
214
+ }
215
+ .shadcn-classless figure {
216
+ margin-bottom: 1rem;
217
+ overflow: hidden;
218
+ }
219
+ .shadcn-classless img {
220
+ max-width: 100%;
221
+ height: auto;
222
+ border-radius: var(--radius);
223
+ }
224
+ .shadcn-classless figcaption {
225
+ font-size: 0.875rem;
226
+ margin-top: 0.5rem;
227
+ color: var(--muted-foreground);
228
+ }
229
+ .shadcn-classless blockquote {
230
+ border-left: 4px solid var(--border);
231
+ padding-left: 1rem;
232
+ font-style: italic;
233
+ }
234
+ .shadcn-classless [type='checkbox'],
235
+ .shadcn-classless [type='radio'] {
236
+ margin-right: 0.5rem;
237
+ }
238
+ .shadcn-classless progress {
239
+ width: 100%;
240
+ }
241
+ .shadcn-classless dialog {
242
+ background-color: var(--background);
243
+ color: var(--foreground);
244
+ border: 1px solid var(--border);
245
+ border-radius: var(--radius);
246
+ padding: 24px;
247
+ margin: auto;
248
+ }
249
+ .shadcn-classless dialog::backdrop {
250
+ background-color: rgba(0, 0, 0, 0.8);
251
+ }
252
+ .shadcn-classless details {
253
+ border: 1px solid var(--border);
254
+ border-radius: var(--radius);
255
+ padding: 0.5rem;
256
+ margin-bottom: 1rem;
257
+ }
258
+ .shadcn-classless summary {
259
+ cursor: pointer;
260
+ font-weight: bold;
261
+ }
262
+ .shadcn-classless article {
263
+ border: 1px solid var(--border);
264
+ border-radius: var(--radius);
265
+ padding: 1rem;
266
+ margin-bottom: 1rem;
267
+ }
268
+ .shadcn-classless footer {
269
+ margin-top: 2rem;
270
+ text-align: center;
271
+ color: var(--muted-foreground);
272
+ }
273
+ .shadcn-classless [aria-busy='true'] {
274
+ opacity: 0.7;
275
+ cursor: progress;
276
+ }
277
+ @media (max-width: 600px) {
278
+ .shadcn-classless body {
279
+ padding: 0.5rem;
280
+ }
281
+ .shadcn-classless nav ul {
282
+ flex-direction: column;
283
+ }
284
+ }
285
+ .shadcn-classless input[type='file']::file-selector-button {
286
+ border: none;
287
+ background-color: var(--background);
288
+ font-weight: 600;
289
+ }
290
+ .shadcn-classless *:disabled {
291
+ cursor: not-allowed;
292
+ }
293
+ .shadcn-classless input[type='radio'],
294
+ .shadcn-classless input[type='checkbox'],
295
+ .shadcn-classless input[type='range'] {
296
+ accent-color: var(--primary);
297
+ background-color: var(--background);
298
+ }
299
+ .shadcn-classless kbd {
300
+ padding: 0.125rem 0.625rem;
301
+ background-color: var(--primary);
302
+ color: var(--primary-foreground);
303
+ border-radius: var(--radius);
304
+ }
305
+ .shadcn-classless table {
306
+ caption-side: bottom;
307
+ border-collapse: collapse;
308
+ }
309
+ .shadcn-classless table caption {
310
+ color: var(--muted-foreground);
311
+ margin-top: 1rem;
312
+ }
313
+ .shadcn-classless table th {
314
+ color: var(--muted-foreground);
315
+ }
316
+ .shadcn-classless table tr {
317
+ border-bottom: 1px solid var(--border);
318
+ }
319
+ .shadcn-classless table tr:hover {
320
+ background-color: hsl(var(--muted) / 0.5);
321
+ }
322
+ .shadcn-classless table td,
323
+ .shadcn-classless table th {
324
+ vertical-align: middle;
325
+ padding: 0.5rem;
326
+ text-align: start;
327
+ }
328
+ .shadcn-classless table tfoot {
329
+ background-color: var(--muted);
330
+ }
331
+ .shadcn-classless dialog[drawer] {
332
+ border-bottom-right-radius: 0;
333
+ border-bottom-left-radius: 0;
334
+ top: auto;
335
+ bottom: 0;
336
+ width: 100vw;
337
+ max-height: 50vh;
338
+ }
339
+ .shadcn-classless dialog[drawer][open] {
340
+ animation: slideup 0.2s ease-in forwards;
341
+ }
342
+ .shadcn-classless dialog > header {
343
+ margin: 0;
344
+ }
345
+ @keyframes slideup {
346
+ 0% {
347
+ transform: translateY(100%);
348
+ }
349
+ 100% {
350
+ transform: translateY(0);
351
+ }
352
+ }
353
+ .shadcn-classless progress {
354
+ -webkit-appearance: none;
355
+ -moz-appearance: none;
356
+ appearance: none;
357
+ height: 0.5rem;
358
+ border-radius: 9999px;
359
+ background-color: var(--muted);
360
+ border: 0;
361
+ }
362
+ .shadcn-classless progress[value]::-webkit-progress-value {
363
+ border-radius: 9999px;
364
+ background-color: var(--primary);
365
+ }
366
+ .shadcn-classless ::-webkit-progress-bar {
367
+ border-radius: 9999px;
368
+ background-color: var(--muted);
369
+ }
370
+ .shadcn-classless ::-moz-progress-bar {
371
+ border-radius: 9999px;
372
+ background-color: var(--primary);
373
+ }
374
+ .shadcn-classless progress:indeterminate {
375
+ background: var(--muted) linear-gradient(to right, var(--primary) 35%, var(--muted) 35%) top left / 150% 150% no-repeat;
376
+ animation: progress-indeterminate 1.5s linear infinite;
377
+ }
378
+ .shadcn-classless progress:indeterminate::-webkit-progress-bar {
379
+ background-color: transparent;
380
+ }
381
+ .shadcn-classless progress:indeterminate::-moz-progress-bar {
382
+ background-color: transparent;
383
+ }
384
+ @keyframes progress-indeterminate {
385
+ 0% {
386
+ background-position: 200% 0;
387
+ }
388
+ 100% {
389
+ background-position: -200% 0;
390
+ }
391
+ }
392
+ .shadcn-classless hr {
393
+ border: 0;
394
+ height: 1px;
395
+ margin: 1rem 0;
396
+ background-color: var(--border);
397
+ flex-shrink: 0;
398
+ }
399
+ .shadcn-classless hr[vertical] {
400
+ width: 1px;
401
+ height: 1.25rem;
402
+ margin: 0 1rem;
403
+ }
instaui/skip.py ADDED
@@ -0,0 +1,12 @@
1
+ from typing import Any
2
+
3
+
4
+ class _Skip:
5
+ pass
6
+
7
+
8
+ skip_output = _Skip()
9
+
10
+
11
+ def is_skip_output(value: Any):
12
+ return value is skip_output
@@ -0,0 +1,26 @@
1
+ from ._components import RouterLink as link, RouterView as view
2
+ from ._functions import (
3
+ add_route,
4
+ config_router,
5
+ get_params,
6
+ get_full_path,
7
+ get_path,
8
+ push,
9
+ output,
10
+ )
11
+ from ._route_model import RouteItem
12
+ from ._file_base_utils import build_routes_from_files
13
+
14
+ __all__ = [
15
+ "add_route",
16
+ "config_router",
17
+ "link",
18
+ "view",
19
+ "get_params",
20
+ "get_full_path",
21
+ "get_path",
22
+ "push",
23
+ "output",
24
+ "RouteItem",
25
+ "build_routes_from_files",
26
+ ]
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+ import typing
3
+ from instaui import html
4
+ from instaui.components.element import Element
5
+ from instaui.vars.types import TMaybeRef
6
+
7
+
8
+ class RouterLink(Element):
9
+ def __init__(self, text: TMaybeRef[str], *, to: str):
10
+ super().__init__("router-link")
11
+
12
+ self.props({"to": to})
13
+
14
+ if text is not None:
15
+ with self.add_slot("default"):
16
+ html.span(text)
17
+
18
+ @classmethod
19
+ def by_name(
20
+ cls,
21
+ text: TMaybeRef[str],
22
+ *,
23
+ name: str,
24
+ params: typing.Optional[typing.Dict[str, typing.Any]] = None,
25
+ ) -> RouterLink:
26
+ to: typing.Dict = {"name": name}
27
+ if params:
28
+ to["params"] = params
29
+
30
+ return cls(text, to=to) # type: ignore
31
+
32
+
33
+ class RouterView(Element):
34
+ def __init__(self):
35
+ super().__init__("router-view")