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.
- instaui/__init__.py +9 -0
- instaui/_helper/observable_helper.py +45 -0
- instaui/arco/__init__.py +191 -0
- instaui/arco/_settings.py +25 -0
- instaui/arco/_use_tools/locale.py +50 -0
- instaui/arco/component_types.py +1019 -0
- instaui/arco/components/_utils.py +22 -0
- instaui/arco/components/affix.py +29 -0
- instaui/arco/components/alert.py +42 -0
- instaui/arco/components/anchor.py +42 -0
- instaui/arco/components/auto_complete.py +96 -0
- instaui/arco/components/avatar.py +55 -0
- instaui/arco/components/back_top.py +14 -0
- instaui/arco/components/badge.py +14 -0
- instaui/arco/components/breadcrumb.py +14 -0
- instaui/arco/components/button.py +43 -0
- instaui/arco/components/calendar.py +47 -0
- instaui/arco/components/card.py +14 -0
- instaui/arco/components/carousel.py +33 -0
- instaui/arco/components/cascader.py +111 -0
- instaui/arco/components/checkbox.py +32 -0
- instaui/arco/components/collapse.py +31 -0
- instaui/arco/components/color_picker.py +45 -0
- instaui/arco/components/comment.py +14 -0
- instaui/arco/components/config_provider.py +13 -0
- instaui/arco/components/date_picker.py +111 -0
- instaui/arco/components/descriptions.py +14 -0
- instaui/arco/components/divider.py +13 -0
- instaui/arco/components/drawer.py +98 -0
- instaui/arco/components/dropdown.py +45 -0
- instaui/arco/components/empty.py +14 -0
- instaui/arco/components/form.py +55 -0
- instaui/arco/components/icon.py +17 -0
- instaui/arco/components/image.py +33 -0
- instaui/arco/components/input.py +102 -0
- instaui/arco/components/input_number.py +97 -0
- instaui/arco/components/input_password.py +38 -0
- instaui/arco/components/input_search.py +37 -0
- instaui/arco/components/input_tag.py +110 -0
- instaui/arco/components/layout.py +13 -0
- instaui/arco/components/layout_content.py +6 -0
- instaui/arco/components/layout_footer.py +6 -0
- instaui/arco/components/layout_header.py +6 -0
- instaui/arco/components/layout_sider.py +53 -0
- instaui/arco/components/link.py +36 -0
- instaui/arco/components/list.py +68 -0
- instaui/arco/components/mention.py +97 -0
- instaui/arco/components/menu.py +88 -0
- instaui/arco/components/modal.py +97 -0
- instaui/arco/components/overflow_list.py +29 -0
- instaui/arco/components/page_header.py +29 -0
- instaui/arco/components/pagination.py +45 -0
- instaui/arco/components/pop_confirm.py +58 -0
- instaui/arco/components/popover.py +32 -0
- instaui/arco/components/progress.py +14 -0
- instaui/arco/components/radio.py +40 -0
- instaui/arco/components/radio_group.py +42 -0
- instaui/arco/components/rate.py +45 -0
- instaui/arco/components/resize_box.py +62 -0
- instaui/arco/components/result.py +14 -0
- instaui/arco/components/select.py +182 -0
- instaui/arco/components/skeleton.py +14 -0
- instaui/arco/components/slider.py +38 -0
- instaui/arco/components/space.py +14 -0
- instaui/arco/components/spin.py +14 -0
- instaui/arco/components/split.py +76 -0
- instaui/arco/components/statistic.py +14 -0
- instaui/arco/components/steps.py +32 -0
- instaui/arco/components/switch.py +57 -0
- instaui/arco/components/tab_pane.py +12 -0
- instaui/arco/components/table.py +276 -0
- instaui/arco/components/tabs.py +101 -0
- instaui/arco/components/tag.py +42 -0
- instaui/arco/components/textarea.py +84 -0
- instaui/arco/components/time_picker.py +76 -0
- instaui/arco/components/timeline.py +14 -0
- instaui/arco/components/tooltip.py +29 -0
- instaui/arco/components/transfer.py +58 -0
- instaui/arco/components/tree.py +120 -0
- instaui/arco/components/tree_select.py +86 -0
- instaui/arco/components/trigger.py +58 -0
- instaui/arco/components/typography.py +142 -0
- instaui/arco/components/upload.py +71 -0
- instaui/arco/components/verification_code.py +58 -0
- instaui/arco/components/watermark.py +14 -0
- instaui/arco/locales/__init__.py +4 -0
- instaui/arco/locales/_index.py +31 -0
- instaui/arco/locales/en_us.py +227 -0
- instaui/arco/locales/zh_cn.py +224 -0
- instaui/arco/setup.py +36 -0
- instaui/arco/static/instaui-arco.css +1 -0
- instaui/arco/static/instaui-arco.js +55771 -0
- instaui/arco/types.py +24 -0
- instaui/boot_info.py +43 -0
- instaui/common/jsonable.py +37 -0
- instaui/components/__init__.py +0 -0
- instaui/components/column.py +26 -0
- instaui/components/component.py +47 -0
- instaui/components/content.py +34 -0
- instaui/components/directive.py +55 -0
- instaui/components/element.py +573 -0
- instaui/components/grid.py +213 -0
- instaui/components/html/__init__.py +49 -0
- instaui/components/html/_mixins.py +34 -0
- instaui/components/html/_preset.py +4 -0
- instaui/components/html/button.py +38 -0
- instaui/components/html/checkbox.py +35 -0
- instaui/components/html/date.py +28 -0
- instaui/components/html/div.py +7 -0
- instaui/components/html/form.py +7 -0
- instaui/components/html/heading.py +51 -0
- instaui/components/html/input.py +28 -0
- instaui/components/html/label.py +21 -0
- instaui/components/html/li.py +17 -0
- instaui/components/html/link.py +31 -0
- instaui/components/html/number.py +34 -0
- instaui/components/html/paragraph.py +29 -0
- instaui/components/html/range.py +48 -0
- instaui/components/html/select.py +69 -0
- instaui/components/html/span.py +19 -0
- instaui/components/html/table.py +36 -0
- instaui/components/html/textarea.py +28 -0
- instaui/components/html/ul.py +20 -0
- instaui/components/label.py +5 -0
- instaui/components/markdown/markdown.js +33 -0
- instaui/components/markdown/markdown.py +41 -0
- instaui/components/markdown/static/github-markdown.css +12 -0
- instaui/components/markdown/static/marked.esm.js +2579 -0
- instaui/components/match.py +108 -0
- instaui/components/row.py +17 -0
- instaui/components/shiki_code/shiki_code.js +126 -0
- instaui/components/shiki_code/shiki_code.py +99 -0
- instaui/components/shiki_code/static/langs/css.mjs +5 -0
- instaui/components/shiki_code/static/langs/markdown.mjs +5 -0
- instaui/components/shiki_code/static/langs/python.mjs +5 -0
- instaui/components/shiki_code/static/langs/shell.mjs +2 -0
- instaui/components/shiki_code/static/langs/shellscript.mjs +5 -0
- instaui/components/shiki_code/static/shiki-core.js +5784 -0
- instaui/components/shiki_code/static/shiki-style.css +179 -0
- instaui/components/shiki_code/static/shiki-transformers.js +461 -0
- instaui/components/shiki_code/static/themes/vitesse-dark.mjs +2 -0
- instaui/components/shiki_code/static/themes/vitesse-light.mjs +2 -0
- instaui/components/slot.py +81 -0
- instaui/components/transition_group.py +9 -0
- instaui/components/value_element.py +52 -0
- instaui/components/vfor.py +142 -0
- instaui/components/vif.py +42 -0
- instaui/consts.py +23 -0
- instaui/dependencies/component_dependency.py +22 -0
- instaui/dependencies/plugin_dependency.py +28 -0
- instaui/event/event_mixin.py +12 -0
- instaui/event/js_event.py +82 -0
- instaui/event/vue_event.py +66 -0
- instaui/event/web_event.py +123 -0
- instaui/experimental/__init__.py +3 -0
- instaui/experimental/debug.py +48 -0
- instaui/extra_libs/_echarts.py +3 -0
- instaui/extra_libs/_import_error.py +9 -0
- instaui/extra_libs/_mermaid.py +3 -0
- instaui/extra_libs/_shiki_code.py +3 -0
- instaui/fastapi_server/_utils.py +42 -0
- instaui/fastapi_server/_uvicorn.py +37 -0
- instaui/fastapi_server/debug_mode_router.py +60 -0
- instaui/fastapi_server/dependency_router.py +28 -0
- instaui/fastapi_server/event_router.py +58 -0
- instaui/fastapi_server/middlewares.py +19 -0
- instaui/fastapi_server/request_context.py +19 -0
- instaui/fastapi_server/resource.py +30 -0
- instaui/fastapi_server/server.py +308 -0
- instaui/fastapi_server/watch_router.py +53 -0
- instaui/handlers/_utils.py +88 -0
- instaui/handlers/event_handler.py +60 -0
- instaui/handlers/watch_handler.py +61 -0
- instaui/html_tools.py +94 -0
- instaui/inject.py +33 -0
- instaui/js/__init__.py +4 -0
- instaui/js/js_output.py +15 -0
- instaui/js/lambda_func.py +35 -0
- instaui/launch_collector.py +52 -0
- instaui/page_info.py +13 -0
- instaui/runtime/__init__.py +29 -0
- instaui/runtime/_app.py +234 -0
- instaui/runtime/_inner_helper.py +9 -0
- instaui/runtime/_link_manager.py +89 -0
- instaui/runtime/context.py +47 -0
- instaui/runtime/dataclass.py +30 -0
- instaui/runtime/resource.py +65 -0
- instaui/runtime/scope.py +133 -0
- instaui/runtime/ui_state_scope.py +15 -0
- instaui/settings/__init__.py +4 -0
- instaui/settings/__settings.py +13 -0
- instaui/shadcn_classless/_index.py +42 -0
- instaui/shadcn_classless/static/shadcn-classless.css +403 -0
- instaui/skip.py +12 -0
- instaui/spa_router/__init__.py +26 -0
- instaui/spa_router/_components.py +35 -0
- instaui/spa_router/_file_base_utils.py +273 -0
- instaui/spa_router/_functions.py +122 -0
- instaui/spa_router/_install.py +11 -0
- instaui/spa_router/_route_model.py +117 -0
- instaui/spa_router/_router_box.py +40 -0
- instaui/spa_router/_router_output.py +22 -0
- instaui/spa_router/_router_param_var.py +51 -0
- instaui/spa_router/_types.py +4 -0
- instaui/spa_router/templates/page_routes +60 -0
- instaui/static/insta-ui.css +1 -0
- instaui/static/insta-ui.esm-browser.prod.js +3717 -0
- instaui/static/insta-ui.ico +0 -0
- instaui/static/insta-ui.js.map +1 -0
- instaui/static/instaui-tools-browser.js +511 -0
- instaui/static/templates/debug/sse.html +117 -0
- instaui/static/templates/web.html +74 -0
- instaui/static/templates/webview.html +78 -0
- instaui/static/templates/zero.html +71 -0
- instaui/static/vue.esm-browser.prod.js +9 -0
- instaui/static/vue.global.prod.js +9 -0
- instaui/static/vue.runtime.esm-browser.prod.js +5 -0
- instaui/systems/file_system.py +6 -0
- instaui/systems/func_system.py +119 -0
- instaui/systems/js_system.py +22 -0
- instaui/systems/module_system.py +46 -0
- instaui/systems/pydantic_system.py +27 -0
- instaui/systems/string_system.py +10 -0
- instaui/tailwind/__init__.py +6 -0
- instaui/tailwind/_index.py +24 -0
- instaui/tailwind/static/tailwindcss-v3.min.js +62 -0
- instaui/tailwind/static/tailwindcss-v4.min.js +8 -0
- instaui/template/__init__.py +4 -0
- instaui/template/_utils.py +23 -0
- instaui/template/env.py +7 -0
- instaui/template/web_template.py +49 -0
- instaui/template/webview_template.py +48 -0
- instaui/template/zero_template.py +105 -0
- instaui/ui/__init__.py +144 -0
- instaui/ui/__init__.pyi +149 -0
- instaui/ui/events.py +25 -0
- instaui/ui_functions/input_slient_data.py +16 -0
- instaui/ui_functions/server.py +15 -0
- instaui/ui_functions/str_format.py +36 -0
- instaui/ui_functions/ui_page.py +16 -0
- instaui/ui_functions/ui_types.py +13 -0
- instaui/ui_functions/url_location.py +33 -0
- instaui/vars/_types.py +8 -0
- instaui/vars/data.py +68 -0
- instaui/vars/element_ref.py +40 -0
- instaui/vars/event_context.py +49 -0
- instaui/vars/event_extend.py +0 -0
- instaui/vars/js_computed.py +117 -0
- instaui/vars/mixin_types/common_type.py +5 -0
- instaui/vars/mixin_types/element_binding.py +16 -0
- instaui/vars/mixin_types/observable.py +7 -0
- instaui/vars/mixin_types/pathable.py +14 -0
- instaui/vars/mixin_types/py_binding.py +13 -0
- instaui/vars/mixin_types/str_format_binding.py +8 -0
- instaui/vars/mixin_types/var_type.py +5 -0
- instaui/vars/path_var.py +90 -0
- instaui/vars/ref.py +103 -0
- instaui/vars/slot_prop.py +46 -0
- instaui/vars/state.py +97 -0
- instaui/vars/types.py +24 -0
- instaui/vars/vfor_item.py +204 -0
- instaui/vars/vue_computed.py +81 -0
- instaui/vars/web_computed.py +209 -0
- instaui/vars/web_view_computed.py +1 -0
- instaui/version.py +3 -0
- instaui/watch/_types.py +4 -0
- instaui/watch/_utils.py +3 -0
- instaui/watch/js_watch.py +110 -0
- instaui/watch/vue_watch.py +77 -0
- instaui/watch/web_watch.py +181 -0
- instaui/webview/__init__.py +2 -0
- instaui/webview/_utils.py +8 -0
- instaui/webview/api.py +72 -0
- instaui/webview/func.py +114 -0
- instaui/webview/index.py +161 -0
- instaui/webview/resource.py +172 -0
- instaui/zero/__init__.py +3 -0
- instaui/zero/func.py +123 -0
- instaui/zero/scope.py +109 -0
- instaui-0.1.15.dist-info/METADATA +152 -0
- instaui-0.1.15.dist-info/RECORD +283 -0
- instaui-0.1.15.dist-info/WHEEL +5 -0
- instaui-0.1.15.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,213 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Literal,
|
4
|
+
Optional,
|
5
|
+
TypeVar,
|
6
|
+
Union,
|
7
|
+
)
|
8
|
+
from instaui.vars.types import TMaybeRef
|
9
|
+
from instaui.vars.js_computed import JsComputed
|
10
|
+
from instaui.components.element import Element
|
11
|
+
from instaui.vars.mixin_types.observable import ObservableMixin
|
12
|
+
|
13
|
+
_T = TypeVar("_T")
|
14
|
+
|
15
|
+
|
16
|
+
class Grid(Element):
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
*,
|
20
|
+
rows: Optional[TMaybeRef[Union[int, str]]] = None,
|
21
|
+
columns: Optional[TMaybeRef[Union[int, str]]] = None,
|
22
|
+
template: Optional[TMaybeRef[str]] = None,
|
23
|
+
):
|
24
|
+
'''Grid component
|
25
|
+
|
26
|
+
Args:
|
27
|
+
rows (Optional[TMaybeRef[Union[int, str]]], optional): Number of rows or template for rows. Defaults to None.
|
28
|
+
columns (Optional[TMaybeRef[Union[int, str]]], optional): Number of columns or template for columns. Defaults to None.
|
29
|
+
template (Optional[TMaybeRef[str]], optional): Template for grid. Defaults to None.
|
30
|
+
|
31
|
+
# Example:
|
32
|
+
columns example:
|
33
|
+
.. code-block:: python
|
34
|
+
border = "border-2 border-gray-200"
|
35
|
+
|
36
|
+
with ui.grid(columns=2).classes("h-[200px]").classes(border) as g:
|
37
|
+
|
38
|
+
# a in the first row and first column
|
39
|
+
html.paragraph("a value").classes(border)
|
40
|
+
# b in the first row and second column
|
41
|
+
html.paragraph("b value").classes(border)
|
42
|
+
|
43
|
+
# c in the second row and span over 2 columns
|
44
|
+
html.paragraph("c value").use(
|
45
|
+
g.mark_area_position(column_span=2)
|
46
|
+
).classes(border)
|
47
|
+
|
48
|
+
template areas example:
|
49
|
+
.. code-block:: python
|
50
|
+
border = "border-2 border-gray-200"
|
51
|
+
|
52
|
+
template = r"""
|
53
|
+
"a b c" 1fr
|
54
|
+
"a b ." 2fr / 1fr 1fr 2fr
|
55
|
+
"""
|
56
|
+
|
57
|
+
with ui.grid(template=template).classes("h-[200px]").classes(border) as g:
|
58
|
+
html.paragraph("a value").use(g.mark_area("a")).classes(border)
|
59
|
+
html.paragraph("b value").use(g.mark_area("b")).classes(border)
|
60
|
+
html.paragraph("c value").use(g.mark_area("c")).classes(border)
|
61
|
+
'''
|
62
|
+
|
63
|
+
super().__init__("div")
|
64
|
+
self.style("display: grid;")
|
65
|
+
|
66
|
+
if rows is not None:
|
67
|
+
if isinstance(rows, int):
|
68
|
+
rows = f"repeat({rows}, 1fr)"
|
69
|
+
|
70
|
+
if isinstance(rows, ObservableMixin):
|
71
|
+
rows = _convert_to_repeat_computed(rows)
|
72
|
+
|
73
|
+
self.style({"grid-template-rows": rows})
|
74
|
+
|
75
|
+
if columns is not None:
|
76
|
+
if isinstance(columns, int):
|
77
|
+
columns = f"repeat({columns}, 1fr)"
|
78
|
+
|
79
|
+
if isinstance(columns, ObservableMixin):
|
80
|
+
columns = _convert_to_repeat_computed(columns)
|
81
|
+
|
82
|
+
self.style({"grid-template-columns": columns})
|
83
|
+
|
84
|
+
if template is not None:
|
85
|
+
self.style({"grid-template": template})
|
86
|
+
|
87
|
+
def mark_area(self, area: TMaybeRef[str]):
|
88
|
+
"""Marks an area in the grid
|
89
|
+
|
90
|
+
Args:
|
91
|
+
area (TMaybeRef[str]): Area name
|
92
|
+
|
93
|
+
"""
|
94
|
+
|
95
|
+
def use_fn(element: Element):
|
96
|
+
element.style({"grid-area": area})
|
97
|
+
|
98
|
+
return use_fn
|
99
|
+
|
100
|
+
def mark_area_position(
|
101
|
+
self,
|
102
|
+
*,
|
103
|
+
row: Optional[int] = None,
|
104
|
+
column: Optional[int] = None,
|
105
|
+
row_span: Optional[int] = None,
|
106
|
+
column_span: Optional[int] = None,
|
107
|
+
):
|
108
|
+
"""Marks an area in the grid with position
|
109
|
+
|
110
|
+
Args:
|
111
|
+
row (Optional[int], optional): Start position of row, 1-based. Defaults to None.
|
112
|
+
column (Optional[int], optional): Start position of column, 1-based. Defaults to None.
|
113
|
+
row_span (Optional[int], optional): The span value at the end of the row. Defaults to None.
|
114
|
+
column_span (Optional[int], optional): The span value at the end of the column. Defaults to None.
|
115
|
+
"""
|
116
|
+
real_row = "auto" if row is None else row
|
117
|
+
real_column = "auto" if column is None else column
|
118
|
+
real_row_span = "auto" if row_span is None else f"span {row_span}"
|
119
|
+
real_column_span = "auto" if column_span is None else f"span {column_span}"
|
120
|
+
|
121
|
+
area = f"{real_row} / {real_column} / {real_row_span} / {real_column_span}"
|
122
|
+
return self.mark_area(area)
|
123
|
+
|
124
|
+
@staticmethod
|
125
|
+
def auto_columns(
|
126
|
+
*,
|
127
|
+
min_width: TMaybeRef[str],
|
128
|
+
mode: TMaybeRef[Literal["auto-fill", "auto-fit"]] = "auto-fit",
|
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
|
+
"""
|
186
|
+
|
187
|
+
template = JsComputed(
|
188
|
+
inputs=[min_height, mode],
|
189
|
+
code=r"(min_height, mode)=> `repeat(${mode}, minmax(min(${min_height},100%), 1fr))`",
|
190
|
+
)
|
191
|
+
|
192
|
+
return template
|
193
|
+
|
194
|
+
def row_gap(self, gap: TMaybeRef[str]) -> Grid:
|
195
|
+
return self.style({"row-gap": gap})
|
196
|
+
|
197
|
+
def column_gap(self, gap: TMaybeRef[str]) -> Grid:
|
198
|
+
return self.style({"column-gap": gap})
|
199
|
+
|
200
|
+
def gap(self, gap: TMaybeRef[str]) -> Grid:
|
201
|
+
return self.row_gap(gap).column_gap(gap)
|
202
|
+
|
203
|
+
|
204
|
+
def _convert_to_repeat_computed(value: ObservableMixin):
|
205
|
+
return JsComputed(
|
206
|
+
inputs=[value],
|
207
|
+
code=r"""(value)=> {
|
208
|
+
if (typeof value === "number"){
|
209
|
+
return `repeat(${value}, 1fr)`
|
210
|
+
}
|
211
|
+
return value
|
212
|
+
}""",
|
213
|
+
)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
__all__ = [
|
2
|
+
"span",
|
3
|
+
"label",
|
4
|
+
"paragraph",
|
5
|
+
"input",
|
6
|
+
"number",
|
7
|
+
"button",
|
8
|
+
"checkbox",
|
9
|
+
"form",
|
10
|
+
"select",
|
11
|
+
"option",
|
12
|
+
"ul",
|
13
|
+
"li",
|
14
|
+
"div",
|
15
|
+
"range",
|
16
|
+
"date",
|
17
|
+
"link",
|
18
|
+
"textarea",
|
19
|
+
"table",
|
20
|
+
"h1",
|
21
|
+
"h2",
|
22
|
+
"h3",
|
23
|
+
"h4",
|
24
|
+
"h5",
|
25
|
+
"h6",
|
26
|
+
]
|
27
|
+
|
28
|
+
from .span import Span as span
|
29
|
+
from .label import Label as label
|
30
|
+
from .paragraph import Paragraph as paragraph
|
31
|
+
from .input import Input as input
|
32
|
+
from .number import Number as number
|
33
|
+
from .button import Button as button
|
34
|
+
from .checkbox import Checkbox as checkbox
|
35
|
+
from .form import Form as form
|
36
|
+
from .select import Select as select
|
37
|
+
from .ul import Ul as ul
|
38
|
+
from .li import Li as li
|
39
|
+
from .div import Div as div
|
40
|
+
from .range import Range as range
|
41
|
+
from .date import Date as date
|
42
|
+
from .link import Link as link
|
43
|
+
from .textarea import Textarea as textarea
|
44
|
+
from .table import Table as table
|
45
|
+
from .heading import H1 as h1, H2 as h2, H3 as h3, H4 as h4, H5 as h5, H6 as h6
|
46
|
+
|
47
|
+
option = select.Option
|
48
|
+
|
49
|
+
from . import _preset # noqa: E402, F401
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
import abc
|
3
|
+
from typing import TYPE_CHECKING, List, Optional
|
4
|
+
from instaui.event.event_mixin import EventMixin
|
5
|
+
|
6
|
+
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from instaui.components.element import Element
|
9
|
+
|
10
|
+
|
11
|
+
class InputEventMixin:
|
12
|
+
@abc.abstractmethod
|
13
|
+
def _input_event_mixin_element(self) -> Element:
|
14
|
+
pass
|
15
|
+
|
16
|
+
def on_change(
|
17
|
+
self,
|
18
|
+
handler: EventMixin,
|
19
|
+
*,
|
20
|
+
extends: Optional[List] = None,
|
21
|
+
key: Optional[str] = None,
|
22
|
+
):
|
23
|
+
self._input_event_mixin_element().on("change", handler, extends=extends)
|
24
|
+
return self
|
25
|
+
|
26
|
+
def on_input(
|
27
|
+
self,
|
28
|
+
handler: EventMixin,
|
29
|
+
*,
|
30
|
+
extends: Optional[List] = None,
|
31
|
+
key: Optional[str] = None,
|
32
|
+
):
|
33
|
+
self._input_event_mixin_element().on("input", handler, extends=extends)
|
34
|
+
return self
|
@@ -0,0 +1,38 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
TYPE_CHECKING,
|
4
|
+
List,
|
5
|
+
Optional,
|
6
|
+
)
|
7
|
+
from instaui.components.element import Element
|
8
|
+
|
9
|
+
from instaui.event.event_mixin import EventMixin
|
10
|
+
from instaui.vars.types import TMaybeRef
|
11
|
+
|
12
|
+
if TYPE_CHECKING:
|
13
|
+
pass
|
14
|
+
|
15
|
+
|
16
|
+
class Button(Element):
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
text: Optional[TMaybeRef[str]] = None,
|
20
|
+
):
|
21
|
+
super().__init__("button")
|
22
|
+
|
23
|
+
if text is not None:
|
24
|
+
self.props(
|
25
|
+
{
|
26
|
+
"innerText": text,
|
27
|
+
}
|
28
|
+
)
|
29
|
+
|
30
|
+
def on_click(
|
31
|
+
self,
|
32
|
+
handler: EventMixin,
|
33
|
+
*,
|
34
|
+
extends: Optional[List] = None,
|
35
|
+
key: Optional[str] = None,
|
36
|
+
):
|
37
|
+
self.on("click", handler, extends=extends)
|
38
|
+
return self
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Any,
|
4
|
+
Optional,
|
5
|
+
Union,
|
6
|
+
)
|
7
|
+
|
8
|
+
from instaui.components.element import Element
|
9
|
+
from instaui.components.value_element import ValueElement
|
10
|
+
|
11
|
+
|
12
|
+
from instaui.vars.types import TMaybeRef
|
13
|
+
from ._mixins import InputEventMixin
|
14
|
+
|
15
|
+
|
16
|
+
class Checkbox(InputEventMixin, ValueElement[Union[bool, str]]):
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
value: Union[Union[bool, str], TMaybeRef[Union[bool, str]], None] = None,
|
20
|
+
*,
|
21
|
+
model_value: Optional[TMaybeRef[Union[bool, str]]] = None,
|
22
|
+
checked: Optional[TMaybeRef[bool]] = None,
|
23
|
+
id: Optional[Any] = None,
|
24
|
+
):
|
25
|
+
super().__init__("input", value, is_html_component=True)
|
26
|
+
self.props({"type": "checkbox"})
|
27
|
+
if id is not None:
|
28
|
+
self.props({"id": id})
|
29
|
+
if checked is not None:
|
30
|
+
self.props({"checked": checked})
|
31
|
+
if model_value is not None:
|
32
|
+
self.props({"value": model_value})
|
33
|
+
|
34
|
+
def _input_event_mixin_element(self) -> Element:
|
35
|
+
return self
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Union
|
3
|
+
|
4
|
+
from instaui.components.value_element import ValueElement
|
5
|
+
from ._mixins import InputEventMixin
|
6
|
+
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from instaui.vars.types import TMaybeRef
|
9
|
+
from instaui.components.element import Element
|
10
|
+
|
11
|
+
_T_value = str
|
12
|
+
|
13
|
+
|
14
|
+
class Date(InputEventMixin, ValueElement[_T_value]):
|
15
|
+
def __init__(
|
16
|
+
self,
|
17
|
+
value: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
18
|
+
*,
|
19
|
+
model_value: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
20
|
+
):
|
21
|
+
super().__init__("input", value, is_html_component=True)
|
22
|
+
self.props({"type": "date"})
|
23
|
+
|
24
|
+
if model_value is not None:
|
25
|
+
self.props({"value": model_value})
|
26
|
+
|
27
|
+
def _input_event_mixin_element(self) -> Element:
|
28
|
+
return self
|
@@ -0,0 +1,51 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Any, Literal, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
9
|
+
class Heading(Element):
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
text: Union[str, TMaybeRef[Any]],
|
13
|
+
*,
|
14
|
+
level: Literal[1, 2, 3, 4, 5, 6] = 1,
|
15
|
+
):
|
16
|
+
super().__init__(f"h{level}")
|
17
|
+
self.props(
|
18
|
+
{
|
19
|
+
"innerText": text,
|
20
|
+
}
|
21
|
+
)
|
22
|
+
|
23
|
+
|
24
|
+
class H1(Heading):
|
25
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
26
|
+
super().__init__(text, level=1)
|
27
|
+
|
28
|
+
|
29
|
+
class H2(Heading):
|
30
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
31
|
+
super().__init__(text, level=2)
|
32
|
+
|
33
|
+
|
34
|
+
class H3(Heading):
|
35
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
36
|
+
super().__init__(text, level=3)
|
37
|
+
|
38
|
+
|
39
|
+
class H4(Heading):
|
40
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
41
|
+
super().__init__(text, level=4)
|
42
|
+
|
43
|
+
|
44
|
+
class H5(Heading):
|
45
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
46
|
+
super().__init__(text, level=5)
|
47
|
+
|
48
|
+
|
49
|
+
class H6(Heading):
|
50
|
+
def __init__(self, text: Union[str, TMaybeRef[Any]]):
|
51
|
+
super().__init__(text, level=6)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Optional, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
from instaui.components.value_element import ValueElement
|
5
|
+
|
6
|
+
from ._mixins import InputEventMixin
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from instaui.vars.types import TMaybeRef
|
10
|
+
|
11
|
+
|
12
|
+
class Input(InputEventMixin, ValueElement[str]):
|
13
|
+
def __init__(
|
14
|
+
self,
|
15
|
+
value: Union[str, TMaybeRef[str], None] = None,
|
16
|
+
*,
|
17
|
+
model_value: Union[str, TMaybeRef[str], None] = None,
|
18
|
+
disabled: Optional[TMaybeRef[bool]] = None,
|
19
|
+
):
|
20
|
+
super().__init__("input", value, is_html_component=True)
|
21
|
+
|
22
|
+
if disabled is not None:
|
23
|
+
self.props({"disabled": disabled})
|
24
|
+
if model_value is not None:
|
25
|
+
self.props({"value": model_value})
|
26
|
+
|
27
|
+
def _input_event_mixin_element(self) -> Element:
|
28
|
+
return self
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Any, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
9
|
+
class Label(Element):
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
text: Union[Any, TMaybeRef[Any], None] = None,
|
13
|
+
):
|
14
|
+
super().__init__("label")
|
15
|
+
|
16
|
+
if text is not None:
|
17
|
+
self.props(
|
18
|
+
{
|
19
|
+
"innerText": text,
|
20
|
+
}
|
21
|
+
)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Any, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
9
|
+
class Li(Element):
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
text: Union[Any, TMaybeRef[Any], None] = None,
|
13
|
+
):
|
14
|
+
super().__init__("li")
|
15
|
+
|
16
|
+
if text:
|
17
|
+
self.props({"innerText": text})
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Optional,
|
4
|
+
)
|
5
|
+
from instaui.components.element import Element
|
6
|
+
|
7
|
+
from instaui.vars.types import TMaybeRef
|
8
|
+
|
9
|
+
|
10
|
+
class Link(Element):
|
11
|
+
def __init__(
|
12
|
+
self,
|
13
|
+
href: Optional[TMaybeRef[str]] = None,
|
14
|
+
*,
|
15
|
+
text: Optional[TMaybeRef[str]] = None,
|
16
|
+
):
|
17
|
+
super().__init__("a")
|
18
|
+
|
19
|
+
if text is not None:
|
20
|
+
self.props(
|
21
|
+
{
|
22
|
+
"innerText": text,
|
23
|
+
}
|
24
|
+
)
|
25
|
+
|
26
|
+
if href is not None:
|
27
|
+
self.props(
|
28
|
+
{
|
29
|
+
"href": href,
|
30
|
+
}
|
31
|
+
)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Optional, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
from instaui.components.value_element import ValueElement
|
5
|
+
from ._mixins import InputEventMixin
|
6
|
+
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from instaui.vars.types import TMaybeRef
|
9
|
+
|
10
|
+
|
11
|
+
_T_value = Union[int, float]
|
12
|
+
|
13
|
+
|
14
|
+
class Number(InputEventMixin, ValueElement[_T_value]):
|
15
|
+
def __init__(
|
16
|
+
self,
|
17
|
+
value: Optional[TMaybeRef[_T_value]] = None,
|
18
|
+
*,
|
19
|
+
model_value: Optional[TMaybeRef[_T_value]] = None,
|
20
|
+
min: Optional[TMaybeRef[_T_value]] = None,
|
21
|
+
max: Optional[TMaybeRef[_T_value]] = None,
|
22
|
+
):
|
23
|
+
super().__init__("input", value, is_html_component=True)
|
24
|
+
self.props({"type": "number"})
|
25
|
+
|
26
|
+
if min is not None:
|
27
|
+
self.props({"min": min})
|
28
|
+
if max is not None:
|
29
|
+
self.props({"max": max})
|
30
|
+
if model_value is not None:
|
31
|
+
self.props({"value": model_value})
|
32
|
+
|
33
|
+
def _input_event_mixin_element(self) -> Element:
|
34
|
+
return self
|
@@ -0,0 +1,29 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Any, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
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
|
+
|
20
|
+
def __init__(
|
21
|
+
self,
|
22
|
+
text: Union[str, TMaybeRef[Any]],
|
23
|
+
):
|
24
|
+
super().__init__("p")
|
25
|
+
self.props(
|
26
|
+
{
|
27
|
+
"innerText": text,
|
28
|
+
}
|
29
|
+
)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import List, Union
|
3
|
+
from instaui.components.element import Element
|
4
|
+
from instaui.components.value_element import ValueElement
|
5
|
+
from instaui import consts
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
8
|
+
from ._mixins import InputEventMixin
|
9
|
+
|
10
|
+
_T_value = Union[int, float]
|
11
|
+
|
12
|
+
|
13
|
+
class Range(InputEventMixin, ValueElement[_T_value]):
|
14
|
+
def __init__(
|
15
|
+
self,
|
16
|
+
value: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
17
|
+
*,
|
18
|
+
min: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
19
|
+
max: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
20
|
+
step: Union[_T_value, TMaybeRef[_T_value], None] = None,
|
21
|
+
):
|
22
|
+
super().__init__("input", value, is_html_component=True)
|
23
|
+
self.props({"type": "range"})
|
24
|
+
|
25
|
+
if min is not None:
|
26
|
+
self.props({"min": min})
|
27
|
+
if max is not None:
|
28
|
+
self.props({"max": max})
|
29
|
+
if step is not None:
|
30
|
+
self.props({"step": step})
|
31
|
+
|
32
|
+
def vmodel(
|
33
|
+
self,
|
34
|
+
value: ElementBindingMixin,
|
35
|
+
modifiers: Union[consts.TModifier, List[consts.TModifier], None] = None,
|
36
|
+
*,
|
37
|
+
prop_name: str = "value",
|
38
|
+
):
|
39
|
+
modifiers = modifiers or []
|
40
|
+
if isinstance(modifiers, str):
|
41
|
+
modifiers = [modifiers]
|
42
|
+
|
43
|
+
modifiers_with_number = list(set([*modifiers, "number"]))
|
44
|
+
|
45
|
+
return super().vmodel(value, modifiers_with_number, prop_name=prop_name) # type: ignore
|
46
|
+
|
47
|
+
def _input_event_mixin_element(self) -> Element:
|
48
|
+
return self
|