instaui 0.1.5__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 (132) 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/element.py +0 -2
  94. instaui/components/grid.py +81 -0
  95. instaui/components/markdown/static/github-markdown.css +1 -1
  96. instaui/components/row.py +8 -7
  97. instaui/components/shiki_code/static/shiki-style.css +179 -175
  98. instaui/experimental/link_sql/__init__.py +3 -0
  99. instaui/experimental/link_sql/_base.py +23 -0
  100. instaui/experimental/link_sql/_duckdb.py +221 -0
  101. instaui/experimental/link_sql/_types.py +15 -0
  102. instaui/experimental/link_sql/data_source.js +50 -0
  103. instaui/fastapi_server/debug_mode_router.py +1 -1
  104. instaui/html_tools.py +2 -3
  105. instaui/runtime/scope.py +28 -7
  106. instaui/static/insta-ui.css +1 -1
  107. instaui/static/insta-ui.esm-browser.prod.js +3663 -3719
  108. instaui/static/insta-ui.js.map +1 -1
  109. instaui/static/templates/debug/sse.html +1 -1
  110. instaui/tailwind/_index.py +2 -2
  111. instaui/ui_functions/ui_page.py +1 -1
  112. instaui/vars/data.py +7 -7
  113. instaui/vars/element_ref.py +2 -4
  114. instaui/vars/js_computed.py +6 -8
  115. instaui/vars/ref.py +6 -6
  116. instaui/vars/vue_computed.py +6 -7
  117. instaui/vars/web_computed.py +2 -3
  118. instaui/watch/vue_watch.py +23 -7
  119. instaui/zero/scope.py +3 -20
  120. {instaui-0.1.5.dist-info → instaui-0.1.6.dist-info}/METADATA +5 -4
  121. {instaui-0.1.5.dist-info → instaui-0.1.6.dist-info}/RECORD +123 -36
  122. instaui/daisyui/__init__.py +0 -26
  123. instaui/daisyui/_index.py +0 -20
  124. instaui/daisyui/button.py +0 -38
  125. instaui/daisyui/checkbox.py +0 -17
  126. instaui/daisyui/static/daisyui.css +0 -1
  127. instaui/daisyui/static/themes.css +0 -1
  128. instaui/daisyui/table.py +0 -35
  129. instaui/ui/__build_init.py +0 -73
  130. instaui/vars/_utils.py +0 -12
  131. {instaui-0.1.5.dist-info → instaui-0.1.6.dist-info}/LICENSE +0 -0
  132. {instaui-0.1.5.dist-info → instaui-0.1.6.dist-info}/WHEEL +0 -0
@@ -91,7 +91,7 @@
91
91
  toggleMessageBox(false)
92
92
  console.log('debug-sse connection opened');
93
93
  if (retryCount > 0) {
94
- location.reload(true);
94
+ window.location.reload(true);
95
95
  }
96
96
  }
97
97
 
@@ -8,12 +8,12 @@ _V3_JS = _STATIC_DIR / "tailwindcss-v3.min.js"
8
8
  _V4_JS = _STATIC_DIR / "tailwindcss-v4.min.js"
9
9
 
10
10
 
11
- def use_tailwind(value=True, *, version: Literal["v3", "v4"] = "v4"):
11
+ def use_tailwind(value=True, *, version: Literal["v3", "v4"] = "v3"):
12
12
  """Enable or disable Tailwind CSS.
13
13
 
14
14
  Args:
15
15
  value (bool, optional): Whether to enable or disable Tailwind CSS. Defaults to True.
16
- version (Literal["v3", "v4"], optional): The version of Tailwind CSS to use. Defaults to "v4".
16
+ version (Literal["v3", "v4"], optional): The version of Tailwind CSS to use. Defaults to "v3".
17
17
  """
18
18
  js_file = _V3_JS if version == "v3" else _V4_JS
19
19
 
@@ -2,7 +2,7 @@ from typing import Callable
2
2
  from instaui.launch_collector import get_launch_collector, PageInfo
3
3
 
4
4
 
5
- def page(url: str):
5
+ def page(url: str = "/"):
6
6
  """Register a page route.
7
7
 
8
8
  Args:
instaui/vars/data.py CHANGED
@@ -5,6 +5,7 @@ from typing import (
5
5
  )
6
6
 
7
7
  from instaui.common.jsonable import Jsonable
8
+ from instaui.runtime._app import get_current_scope
8
9
  from instaui.vars.path_var import PathVar
9
10
 
10
11
  from .mixin_types.var_type import VarMixin
@@ -12,7 +13,6 @@ from .mixin_types.py_binding import CanInputMixin, CanOutputMixin
12
13
  from .mixin_types.element_binding import ElementBindingMixin
13
14
  from .mixin_types.pathable import CanPathPropMixin
14
15
  from .mixin_types.str_format_binding import StrFormatBindingMixin
15
- from . import _utils
16
16
 
17
17
 
18
18
  class ConstData(
@@ -25,18 +25,19 @@ class ConstData(
25
25
  StrFormatBindingMixin,
26
26
  ElementBindingMixin,
27
27
  ):
28
- VAR_TYPE = "data"
28
+ BIND_TYPE = "var"
29
29
 
30
30
  def __init__(self, value: Any = None) -> None:
31
31
  self.value = value # type: ignore
32
32
 
33
- sid, id = _utils.register_var(self)
34
- self._sid = sid
35
- self._id = id
33
+ scope = get_current_scope()
34
+ scope.register_data(self)
35
+ self._sid = scope.id
36
+ self._id = scope.generate_vars_id()
36
37
 
37
38
  def __to_binding_config(self):
38
39
  return {
39
- "type": self.VAR_TYPE,
40
+ "type": self.BIND_TYPE,
40
41
  "id": self._id,
41
42
  "sid": self._sid,
42
43
  }
@@ -60,7 +61,6 @@ class ConstData(
60
61
  data = super()._to_json_dict()
61
62
  data["sid"] = self._sid
62
63
  data["id"] = self._id
63
- data["type"] = self.VAR_TYPE
64
64
 
65
65
  return data
66
66
 
@@ -6,12 +6,10 @@ from instaui.vars.mixin_types.py_binding import CanOutputMixin
6
6
 
7
7
  class ElementRef(Jsonable, CanOutputMixin):
8
8
  def __init__(self) -> None:
9
- self._id = None
9
+ scope = get_current_scope()
10
+ self._id = scope.generate_element_ref_id()
10
11
  self.__sid = get_current_scope().id
11
12
 
12
- def _set_id(self, id: str):
13
- self._id = id
14
-
15
13
  def __to_binding_config(
16
14
  self,
17
15
  ):
@@ -3,6 +3,7 @@ import typing
3
3
 
4
4
  from instaui.common.jsonable import Jsonable
5
5
 
6
+ from instaui.runtime._app import get_current_scope
6
7
  from instaui.vars.path_var import PathVar
7
8
  from instaui.vars.mixin_types.var_type import VarMixin
8
9
  from instaui.vars.mixin_types.element_binding import ElementBindingMixin
@@ -13,8 +14,6 @@ from instaui.vars.mixin_types.observable import ObservableMixin
13
14
  from instaui.vars.mixin_types.common_type import TObservableInput
14
15
  from instaui._helper import observable_helper
15
16
 
16
- from . import _utils
17
-
18
17
 
19
18
  class JsComputed(
20
19
  Jsonable,
@@ -26,8 +25,7 @@ class JsComputed(
26
25
  StrFormatBindingMixin,
27
26
  ElementBindingMixin,
28
27
  ):
29
- VAR_TYPE = "jsComputed"
30
- BIND_TYPE = "computed"
28
+ BIND_TYPE = "var"
31
29
 
32
30
  def __init__(
33
31
  self,
@@ -38,9 +36,10 @@ class JsComputed(
38
36
  ) -> None:
39
37
  self.code = code
40
38
 
41
- sid, id = _utils.register_var(self)
42
- self._sid = sid
43
- self._id = id
39
+ scope = get_current_scope()
40
+ scope.register_js_computed(self)
41
+ self._sid = scope.id
42
+ self._id = scope.generate_vars_id()
44
43
 
45
44
  self._inputs, self._is_slient_inputs, self._is_data = (
46
45
  observable_helper.analyze_observable_inputs(list(inputs or []))
@@ -75,7 +74,6 @@ class JsComputed(
75
74
 
76
75
  data["sid"] = self._sid
77
76
  data["id"] = self._id
78
- data["type"] = self.VAR_TYPE
79
77
 
80
78
  if self._inputs:
81
79
  data["inputs"] = self._inputs
instaui/vars/ref.py CHANGED
@@ -9,6 +9,7 @@ from typing import (
9
9
  )
10
10
 
11
11
  from instaui.common.jsonable import Jsonable
12
+ from instaui.runtime._app import get_current_scope
12
13
  from instaui.vars.path_var import PathVar
13
14
 
14
15
  from .mixin_types.var_type import VarMixin
@@ -17,7 +18,6 @@ from .mixin_types.observable import ObservableMixin
17
18
  from .mixin_types.element_binding import ElementBindingMixin
18
19
  from .mixin_types.pathable import CanPathPropMixin
19
20
  from .mixin_types.str_format_binding import StrFormatBindingMixin
20
- from . import _utils
21
21
 
22
22
 
23
23
  _T_Value = TypeVar("_T_Value")
@@ -35,14 +35,15 @@ class Ref(
35
35
  ElementBindingMixin[_T_Value],
36
36
  Generic[_T_Value],
37
37
  ):
38
- VAR_TYPE = "ref"
38
+ VAR_TYPE = "var"
39
39
 
40
40
  def __init__(self, value: Optional[_T_Value] = None) -> None:
41
41
  self.value = value # type: ignore
42
+ scope = get_current_scope()
43
+ scope.register_ref(self)
42
44
 
43
- sid, id = _utils.register_var(self)
44
- self._sid = sid
45
- self._id = id
45
+ self._sid = scope.id
46
+ self._id = scope.generate_vars_id()
46
47
  self._debounced = None
47
48
 
48
49
  def debounced(self, secounds: float):
@@ -78,7 +79,6 @@ class Ref(
78
79
  data = super()._to_json_dict()
79
80
  data["sid"] = self._sid
80
81
  data["id"] = self._id
81
- data["type"] = self.VAR_TYPE
82
82
 
83
83
  if self._debounced is not None:
84
84
  data["debounced"] = self._debounced
@@ -3,6 +3,7 @@ from typing import Any, Dict, Mapping, Optional, Union
3
3
 
4
4
  from instaui.common.jsonable import Jsonable
5
5
 
6
+ from instaui.runtime._app import get_current_scope
6
7
  from instaui.vars.path_var import PathVar
7
8
  from instaui.vars.mixin_types.var_type import VarMixin
8
9
  from instaui.vars.mixin_types.element_binding import ElementBindingMixin
@@ -10,7 +11,6 @@ from instaui.vars.mixin_types.py_binding import CanInputMixin
10
11
  from instaui.vars.mixin_types.pathable import CanPathPropMixin
11
12
  from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
12
13
  from instaui.vars.mixin_types.observable import ObservableMixin
13
- from . import _utils
14
14
 
15
15
 
16
16
  class VueComputed(
@@ -23,8 +23,7 @@ class VueComputed(
23
23
  StrFormatBindingMixin,
24
24
  ElementBindingMixin,
25
25
  ):
26
- VAR_TYPE = "vComputed"
27
- BIND_TYPE = "computed"
26
+ BIND_TYPE = "var"
28
27
 
29
28
  def __init__(
30
29
  self,
@@ -32,10 +31,11 @@ class VueComputed(
32
31
  bindings: Optional[Mapping[str, Union[ElementBindingMixin, Any]]] = None,
33
32
  ) -> None:
34
33
  self.code = fn_code
34
+ scope = get_current_scope()
35
+ scope.register_vue_computed(self)
35
36
 
36
- sid, id = _utils.register_var(self)
37
- self._sid = sid
38
- self._id = id
37
+ self._sid = scope.id
38
+ self._id = scope.generate_vars_id()
39
39
 
40
40
  if bindings:
41
41
  const_bind = []
@@ -75,7 +75,6 @@ class VueComputed(
75
75
  data = super()._to_json_dict()
76
76
  data["sid"] = self._sid
77
77
  data["id"] = self._id
78
- data["type"] = self.VAR_TYPE
79
78
  return data
80
79
 
81
80
 
@@ -41,7 +41,7 @@ class WebComputed(
41
41
  ElementBindingMixin[R],
42
42
  Generic[P, R],
43
43
  ):
44
- VAR_TYPE = "webComputed"
44
+ BIND_TYPE = "var"
45
45
 
46
46
  def __init__(
47
47
  self,
@@ -84,7 +84,6 @@ class WebComputed(
84
84
 
85
85
  data["id"] = self._id
86
86
  data["sid"] = self._sid
87
- data["type"] = self.VAR_TYPE
88
87
 
89
88
  if self._inputs:
90
89
  data["inputs"] = self._inputs
@@ -114,7 +113,7 @@ class WebComputed(
114
113
 
115
114
  def __to_binding_config(self):
116
115
  return {
117
- "type": self.VAR_TYPE,
116
+ "type": self.BIND_TYPE,
118
117
  "id": self._id,
119
118
  "sid": self._sid,
120
119
  }
@@ -33,17 +33,33 @@ class VueWatch(Jsonable):
33
33
 
34
34
  self.code = callback
35
35
 
36
- if isinstance(sources, Sequence):
37
- self.on = [
38
- cast(ObservableMixin, varObj)._to_observable_config()
39
- for varObj in sources
40
- ]
41
- else:
42
- self.on = cast(ObservableMixin, sources)._to_observable_config()
36
+ if not isinstance(sources, Sequence):
37
+ sources = [sources]
38
+
39
+ onData = [int(not isinstance(varObj, ObservableMixin)) for varObj in sources]
40
+
41
+ if sum(onData) > 0:
42
+ self.onData = onData
43
+
44
+ self.on = [
45
+ cast(ObservableMixin, varObj)._to_observable_config()
46
+ if isinstance(varObj, ObservableMixin)
47
+ else varObj
48
+ for varObj in sources
49
+ ]
43
50
 
44
51
  if bindings:
52
+ bindData = [
53
+ int(not isinstance(v, ObservableMixin)) for v in bindings.values()
54
+ ]
55
+
56
+ if sum(bindData) > 0:
57
+ self.bindData = bindData
58
+
45
59
  self.bind = {
46
60
  k: cast(ObservableMixin, v)._to_observable_config()
61
+ if isinstance(v, ObservableMixin)
62
+ else v
47
63
  for k, v in bindings.items()
48
64
  }
49
65
 
instaui/zero/scope.py CHANGED
@@ -45,7 +45,7 @@ class Wrapper:
45
45
 
46
46
 
47
47
  def _create_debug_report(model: ZeroTemplateModel, result_html_str: str):
48
- from instaui import ui, html, daisyui as daisy
48
+ from instaui import ui, html, arco
49
49
 
50
50
  no_exists_path_class = "ex-no-exists-path"
51
51
 
@@ -53,7 +53,7 @@ def _create_debug_report(model: ZeroTemplateModel, result_html_str: str):
53
53
  return "" if path.exists() else no_exists_path_class
54
54
 
55
55
  ui.use_tailwind()
56
- daisy.use()
56
+
57
57
  ui.add_style(rf".{no_exists_path_class} {{background-color: red;color: white;}}")
58
58
 
59
59
  html_size = len(result_html_str.encode("utf-8")) / 1024 / 1024
@@ -78,24 +78,7 @@ def _create_debug_report(model: ZeroTemplateModel, result_html_str: str):
78
78
  if isinstance(url, Path) and url.is_file():
79
79
  rows.append([name, str(url)])
80
80
 
81
- daisy.table(columns=["name", "path"], rows=rows)
82
-
83
- # with ui.grid(columns="auto 1fr").classes(box_style):
84
- # html.span("name")
85
- # html.span("path")
86
-
87
- # html.span("vue")
88
- # html.span(str(model.vue_js_code))
89
-
90
- # html.span("instaui")
91
- # html.span(str(model.instaui_js_code))
92
-
93
- # for name, url in model.extra_import_maps.items():
94
- # if isinstance(url, Path) and url.is_file():
95
- # html.span(name)
96
- # html.span(str(url.resolve().absolute())).classes(
97
- # _path_exists_class(url)
98
- # )
81
+ arco.table(columns=["name", "path"], data=rows)
99
82
 
100
83
  # css links
101
84
  html.paragraph("css links")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: instaui
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: insta-ui is a Python-based UI library for rapidly building user interfaces.
5
5
  License: MIT
6
6
  Author: CrystalWindSnake
@@ -16,15 +16,16 @@ Classifier: Programming Language :: Python :: 3.12
16
16
  Provides-Extra: all
17
17
  Provides-Extra: web
18
18
  Provides-Extra: webview
19
- Requires-Dist: fastapi ; extra == "web"
19
+ Requires-Dist: fastapi[standard] ; extra == "all"
20
+ Requires-Dist: fastapi[standard] ; extra == "web"
20
21
  Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
21
22
  Requires-Dist: orjson (>=3.10.15,<4.0.0)
22
23
  Requires-Dist: pydantic (>=2.10.6,<3.0.0)
24
+ Requires-Dist: pywebview ; extra == "all"
23
25
  Requires-Dist: pywebview ; extra == "webview"
24
26
  Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
27
+ Requires-Dist: uvicorn ; extra == "all"
25
28
  Requires-Dist: uvicorn ; extra == "web"
26
- Requires-Dist: web ; extra == "all"
27
- Requires-Dist: webview ; extra == "all"
28
29
  Description-Content-Type: text/markdown
29
30
 
30
31
  # insta-ui