instaui 0.1.0__tar.gz
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-0.1.0/LICENSE +21 -0
- instaui-0.1.0/PKG-INFO +154 -0
- instaui-0.1.0/README.md +127 -0
- instaui-0.1.0/instaui/__init__.py +9 -0
- instaui-0.1.0/instaui/_helper/observable_helper.py +35 -0
- instaui-0.1.0/instaui/boot_info.py +43 -0
- instaui-0.1.0/instaui/common/jsonable.py +37 -0
- instaui-0.1.0/instaui/components/__init__.py +0 -0
- instaui-0.1.0/instaui/components/column.py +18 -0
- instaui-0.1.0/instaui/components/component.py +47 -0
- instaui-0.1.0/instaui/components/content.py +34 -0
- instaui-0.1.0/instaui/components/directive.py +55 -0
- instaui-0.1.0/instaui/components/element.py +462 -0
- instaui-0.1.0/instaui/components/grid.py +80 -0
- instaui-0.1.0/instaui/components/html/__init__.py +36 -0
- instaui-0.1.0/instaui/components/html/_mixins.py +34 -0
- instaui-0.1.0/instaui/components/html/button.py +38 -0
- instaui-0.1.0/instaui/components/html/checkbox.py +42 -0
- instaui-0.1.0/instaui/components/html/date.py +28 -0
- instaui-0.1.0/instaui/components/html/div.py +7 -0
- instaui-0.1.0/instaui/components/html/form.py +7 -0
- instaui-0.1.0/instaui/components/html/input.py +28 -0
- instaui-0.1.0/instaui/components/html/label.py +21 -0
- instaui-0.1.0/instaui/components/html/li.py +17 -0
- instaui-0.1.0/instaui/components/html/link.py +31 -0
- instaui-0.1.0/instaui/components/html/number.py +34 -0
- instaui-0.1.0/instaui/components/html/paragraph.py +19 -0
- instaui-0.1.0/instaui/components/html/range.py +45 -0
- instaui-0.1.0/instaui/components/html/select.py +93 -0
- instaui-0.1.0/instaui/components/html/span.py +19 -0
- instaui-0.1.0/instaui/components/html/ul.py +20 -0
- instaui-0.1.0/instaui/components/match.py +106 -0
- instaui-0.1.0/instaui/components/row.py +19 -0
- instaui-0.1.0/instaui/components/slot.py +82 -0
- instaui-0.1.0/instaui/components/transition_group.py +9 -0
- instaui-0.1.0/instaui/components/value_element.py +48 -0
- instaui-0.1.0/instaui/components/vfor.py +140 -0
- instaui-0.1.0/instaui/components/vif.py +38 -0
- instaui-0.1.0/instaui/consts.py +18 -0
- instaui-0.1.0/instaui/dependencies/__init__.py +15 -0
- instaui-0.1.0/instaui/dependencies/component_registrar.py +82 -0
- instaui-0.1.0/instaui/dependencies/installer.py +5 -0
- instaui-0.1.0/instaui/event/event_mixin.py +12 -0
- instaui-0.1.0/instaui/event/js_event.py +57 -0
- instaui-0.1.0/instaui/event/web_event.py +108 -0
- instaui-0.1.0/instaui/experimental/__init__.py +4 -0
- instaui-0.1.0/instaui/experimental/debug.py +48 -0
- instaui-0.1.0/instaui/fastapi_server/_utils.py +42 -0
- instaui-0.1.0/instaui/fastapi_server/_uvicorn.py +37 -0
- instaui-0.1.0/instaui/fastapi_server/config_router.py +60 -0
- instaui-0.1.0/instaui/fastapi_server/debug_mode_router.py +61 -0
- instaui-0.1.0/instaui/fastapi_server/event_router.py +58 -0
- instaui-0.1.0/instaui/fastapi_server/middlewares.py +19 -0
- instaui-0.1.0/instaui/fastapi_server/request_context.py +19 -0
- instaui-0.1.0/instaui/fastapi_server/server.py +246 -0
- instaui-0.1.0/instaui/fastapi_server/watch_router.py +53 -0
- instaui-0.1.0/instaui/handlers/_utils.py +66 -0
- instaui-0.1.0/instaui/handlers/computed_handler.py +42 -0
- instaui-0.1.0/instaui/handlers/config_handler.py +13 -0
- instaui-0.1.0/instaui/handlers/event_handler.py +58 -0
- instaui-0.1.0/instaui/handlers/watch_handler.py +57 -0
- instaui-0.1.0/instaui/html_tools.py +139 -0
- instaui-0.1.0/instaui/inject.py +33 -0
- instaui-0.1.0/instaui/js/__init__.py +4 -0
- instaui-0.1.0/instaui/js/js_output.py +15 -0
- instaui-0.1.0/instaui/js/lambda_func.py +35 -0
- instaui-0.1.0/instaui/launch_collector.py +52 -0
- instaui-0.1.0/instaui/page_info.py +23 -0
- instaui-0.1.0/instaui/runtime/__init__.py +29 -0
- instaui-0.1.0/instaui/runtime/_app.py +206 -0
- instaui-0.1.0/instaui/runtime/_inner_helper.py +9 -0
- instaui-0.1.0/instaui/runtime/context.py +47 -0
- instaui-0.1.0/instaui/runtime/dataclass.py +30 -0
- instaui-0.1.0/instaui/runtime/resource.py +87 -0
- instaui-0.1.0/instaui/runtime/scope.py +107 -0
- instaui-0.1.0/instaui/runtime/ui_state_scope.py +15 -0
- instaui-0.1.0/instaui/settings/__init__.py +4 -0
- instaui-0.1.0/instaui/settings/__settings.py +13 -0
- instaui-0.1.0/instaui/skip.py +12 -0
- instaui-0.1.0/instaui/spa_router/__init__.py +26 -0
- instaui-0.1.0/instaui/spa_router/_components.py +35 -0
- instaui-0.1.0/instaui/spa_router/_file_base_utils.py +264 -0
- instaui-0.1.0/instaui/spa_router/_functions.py +122 -0
- instaui-0.1.0/instaui/spa_router/_install.py +11 -0
- instaui-0.1.0/instaui/spa_router/_route_model.py +139 -0
- instaui-0.1.0/instaui/spa_router/_router_box.py +40 -0
- instaui-0.1.0/instaui/spa_router/_router_output.py +22 -0
- instaui-0.1.0/instaui/spa_router/_router_param_var.py +51 -0
- instaui-0.1.0/instaui/spa_router/_types.py +4 -0
- instaui-0.1.0/instaui/spa_router/templates/page_routes +59 -0
- instaui-0.1.0/instaui/static/insta-ui.css +1 -0
- instaui-0.1.0/instaui/static/insta-ui.esm-browser.prod.js +3663 -0
- instaui-0.1.0/instaui/static/insta-ui.iife.js +29 -0
- instaui-0.1.0/instaui/static/insta-ui.iife.js.map +1 -0
- instaui-0.1.0/instaui/static/insta-ui.js.map +1 -0
- instaui-0.1.0/instaui/static/tailwindcss.min.js +62 -0
- instaui-0.1.0/instaui/static/templates/debug/sse.html +117 -0
- instaui-0.1.0/instaui/static/templates/web.html +118 -0
- instaui-0.1.0/instaui/static/templates/zero.html +55 -0
- instaui-0.1.0/instaui/static/vue.esm-browser.prod.js +9 -0
- instaui-0.1.0/instaui/static/vue.global.prod.js +9 -0
- instaui-0.1.0/instaui/static/vue.runtime.esm-browser.prod.js +5 -0
- instaui-0.1.0/instaui/systems/file_system.py +17 -0
- instaui-0.1.0/instaui/systems/func_system.py +104 -0
- instaui-0.1.0/instaui/systems/js_system.py +22 -0
- instaui-0.1.0/instaui/systems/pydantic_system.py +27 -0
- instaui-0.1.0/instaui/systems/string_system.py +10 -0
- instaui-0.1.0/instaui/template/__init__.py +4 -0
- instaui-0.1.0/instaui/template/env.py +7 -0
- instaui-0.1.0/instaui/template/web_template.py +55 -0
- instaui-0.1.0/instaui/template/zero_template.py +24 -0
- instaui-0.1.0/instaui/ui/__init__.py +121 -0
- instaui-0.1.0/instaui/ui/events.py +25 -0
- instaui-0.1.0/instaui/ui_functions/input_slient_data.py +16 -0
- instaui-0.1.0/instaui/ui_functions/server.py +13 -0
- instaui-0.1.0/instaui/ui_functions/str_format.py +36 -0
- instaui-0.1.0/instaui/ui_functions/ui_page.py +31 -0
- instaui-0.1.0/instaui/ui_functions/ui_types.py +13 -0
- instaui-0.1.0/instaui/ui_functions/url_location.py +33 -0
- instaui-0.1.0/instaui/vars/__init__.py +13 -0
- instaui-0.1.0/instaui/vars/_types.py +8 -0
- instaui-0.1.0/instaui/vars/_utils.py +12 -0
- instaui-0.1.0/instaui/vars/data.py +68 -0
- instaui-0.1.0/instaui/vars/element_ref.py +42 -0
- instaui-0.1.0/instaui/vars/event_context.py +45 -0
- instaui-0.1.0/instaui/vars/event_extend.py +0 -0
- instaui-0.1.0/instaui/vars/js_computed.py +95 -0
- instaui-0.1.0/instaui/vars/mixin_types/common_type.py +5 -0
- instaui-0.1.0/instaui/vars/mixin_types/element_binding.py +10 -0
- instaui-0.1.0/instaui/vars/mixin_types/observable.py +7 -0
- instaui-0.1.0/instaui/vars/mixin_types/pathable.py +14 -0
- instaui-0.1.0/instaui/vars/mixin_types/py_binding.py +13 -0
- instaui-0.1.0/instaui/vars/mixin_types/str_format_binding.py +8 -0
- instaui-0.1.0/instaui/vars/mixin_types/var_type.py +5 -0
- instaui-0.1.0/instaui/vars/path_var.py +89 -0
- instaui-0.1.0/instaui/vars/ref.py +103 -0
- instaui-0.1.0/instaui/vars/slot_prop.py +46 -0
- instaui-0.1.0/instaui/vars/state.py +82 -0
- instaui-0.1.0/instaui/vars/types.py +24 -0
- instaui-0.1.0/instaui/vars/vfor_item.py +204 -0
- instaui-0.1.0/instaui/vars/vue_computed.py +82 -0
- instaui-0.1.0/instaui/vars/web_computed.py +157 -0
- instaui-0.1.0/instaui/vars/web_view_computed.py +1 -0
- instaui-0.1.0/instaui/version.py +3 -0
- instaui-0.1.0/instaui/watch/_types.py +4 -0
- instaui-0.1.0/instaui/watch/_utils.py +3 -0
- instaui-0.1.0/instaui/watch/js_watch.py +74 -0
- instaui-0.1.0/instaui/watch/vue_watch.py +61 -0
- instaui-0.1.0/instaui/watch/web_watch.py +123 -0
- instaui-0.1.0/instaui/zero/__init__.py +3 -0
- instaui-0.1.0/instaui/zero/scope.py +9 -0
- instaui-0.1.0/pyproject.toml +39 -0
instaui-0.1.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 CrystalWindSnake
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
instaui-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: instaui
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: insta-ui is a Python-based UI library for rapidly building user interfaces.
|
5
|
+
License: MIT
|
6
|
+
Author: CrystalWindSnake
|
7
|
+
Author-email: 568166495@qq.com
|
8
|
+
Requires-Python: >=3.8,<3.13
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
16
|
+
Provides-Extra: web
|
17
|
+
Provides-Extra: webview
|
18
|
+
Requires-Dist: fastapi ; extra == "web"
|
19
|
+
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
|
20
|
+
Requires-Dist: orjson (>=3.10.15,<4.0.0)
|
21
|
+
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
22
|
+
Requires-Dist: pywebview ; extra == "webview"
|
23
|
+
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
|
24
|
+
Requires-Dist: uvicorn ; extra == "web"
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
|
27
|
+
# insta-ui
|
28
|
+
|
29
|
+
<div align="center">
|
30
|
+
|
31
|
+
English| [简体中文](./README.md)
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
|
36
|
+
## 📖 Introduction
|
37
|
+
insta-ui is a Python-based UI library for rapidly building user interfaces.
|
38
|
+
|
39
|
+
|
40
|
+
## ⚙️ Features
|
41
|
+
|
42
|
+
Three modes are provided:
|
43
|
+
|
44
|
+
- Zero mode: Generates pure HTML files, requiring no dependencies. Simply open in a browser to run.
|
45
|
+
- Web mode: Generates web applications.
|
46
|
+
- Web view mode: Generates web view applications that can be packaged into local applications (without needing to start a web server).
|
47
|
+
|
48
|
+
|
49
|
+
## 📦 Installation
|
50
|
+
|
51
|
+
For zero mode:
|
52
|
+
|
53
|
+
```
|
54
|
+
pip install instaui -U
|
55
|
+
```
|
56
|
+
|
57
|
+
For web mode:
|
58
|
+
|
59
|
+
```
|
60
|
+
pip install instaui[web] -U
|
61
|
+
```
|
62
|
+
|
63
|
+
For web view mode:
|
64
|
+
```
|
65
|
+
pip install instaui[webview] -U
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## 🖥️ Quick Start
|
71
|
+
|
72
|
+
Here's a Counter example where clicking the button will display the current count value on the button text.
|
73
|
+
|
74
|
+
zore mode:
|
75
|
+
|
76
|
+
```python
|
77
|
+
from instaui import ui, html, zero
|
78
|
+
|
79
|
+
with zero():
|
80
|
+
count = ui.ref(0)
|
81
|
+
text = ui.str_format("Count: {}", count)
|
82
|
+
|
83
|
+
html.button(text).on_click(
|
84
|
+
"()=> count.value++", bindings={"count": count}
|
85
|
+
)
|
86
|
+
|
87
|
+
ui.to_html("./test.html")
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
Running the above code will generate a test.html file, which you can open in a browser to see the effect.
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
Web mode:
|
96
|
+
|
97
|
+
```python
|
98
|
+
from instaui import ui, html
|
99
|
+
|
100
|
+
@ui.page("/")
|
101
|
+
def counter():
|
102
|
+
count = ui.ref(0)
|
103
|
+
text = ui.str_format("Count: {}", count)
|
104
|
+
|
105
|
+
html.button(text).on_click("()=> count.value++", bindings={"count": count})
|
106
|
+
|
107
|
+
|
108
|
+
ui.server().run()
|
109
|
+
```
|
110
|
+
|
111
|
+
In web mode, we can define interaction functions for complex computations.
|
112
|
+
|
113
|
+
```python
|
114
|
+
from instaui import ui, html
|
115
|
+
|
116
|
+
@ui.page("/")
|
117
|
+
def counter():
|
118
|
+
count = ui.ref(0)
|
119
|
+
# text = ui.str_format("Count: {}", count)
|
120
|
+
|
121
|
+
@ui.computed(inputs=[count])
|
122
|
+
def text(count: int):
|
123
|
+
# Any Python operation
|
124
|
+
return f"Current Count: {count}"
|
125
|
+
|
126
|
+
|
127
|
+
html.button(text).on_click("()=> count.value++", bindings={"count": count})
|
128
|
+
|
129
|
+
|
130
|
+
ui.server().run()
|
131
|
+
```
|
132
|
+
|
133
|
+
- The computation of `text` will generate network requests.
|
134
|
+
- Button clicks, due to using JS binding, do not require network requests.
|
135
|
+
|
136
|
+
You can choose to handle any computation with either Python or JavaScript. Below is an example of handling the button click event using Python.
|
137
|
+
|
138
|
+
```python
|
139
|
+
@ui.page("/")
|
140
|
+
def counter():
|
141
|
+
count = ui.ref(0)
|
142
|
+
|
143
|
+
@ui.computed(inputs=[count])
|
144
|
+
def text(count: int):
|
145
|
+
return f"Current Count: {count}"
|
146
|
+
|
147
|
+
@ui.event(inputs=[count], outputs=[count])
|
148
|
+
def add_count(count: int):
|
149
|
+
return count + 1
|
150
|
+
|
151
|
+
html.button(text).on_click(add_count)
|
152
|
+
|
153
|
+
```
|
154
|
+
|
instaui-0.1.0/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# insta-ui
|
2
|
+
|
3
|
+
<div align="center">
|
4
|
+
|
5
|
+
English| [简体中文](./README.md)
|
6
|
+
|
7
|
+
</div>
|
8
|
+
|
9
|
+
|
10
|
+
## 📖 Introduction
|
11
|
+
insta-ui is a Python-based UI library for rapidly building user interfaces.
|
12
|
+
|
13
|
+
|
14
|
+
## ⚙️ Features
|
15
|
+
|
16
|
+
Three modes are provided:
|
17
|
+
|
18
|
+
- Zero mode: Generates pure HTML files, requiring no dependencies. Simply open in a browser to run.
|
19
|
+
- Web mode: Generates web applications.
|
20
|
+
- Web view mode: Generates web view applications that can be packaged into local applications (without needing to start a web server).
|
21
|
+
|
22
|
+
|
23
|
+
## 📦 Installation
|
24
|
+
|
25
|
+
For zero mode:
|
26
|
+
|
27
|
+
```
|
28
|
+
pip install instaui -U
|
29
|
+
```
|
30
|
+
|
31
|
+
For web mode:
|
32
|
+
|
33
|
+
```
|
34
|
+
pip install instaui[web] -U
|
35
|
+
```
|
36
|
+
|
37
|
+
For web view mode:
|
38
|
+
```
|
39
|
+
pip install instaui[webview] -U
|
40
|
+
```
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
## 🖥️ Quick Start
|
45
|
+
|
46
|
+
Here's a Counter example where clicking the button will display the current count value on the button text.
|
47
|
+
|
48
|
+
zore mode:
|
49
|
+
|
50
|
+
```python
|
51
|
+
from instaui import ui, html, zero
|
52
|
+
|
53
|
+
with zero():
|
54
|
+
count = ui.ref(0)
|
55
|
+
text = ui.str_format("Count: {}", count)
|
56
|
+
|
57
|
+
html.button(text).on_click(
|
58
|
+
"()=> count.value++", bindings={"count": count}
|
59
|
+
)
|
60
|
+
|
61
|
+
ui.to_html("./test.html")
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
Running the above code will generate a test.html file, which you can open in a browser to see the effect.
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
Web mode:
|
70
|
+
|
71
|
+
```python
|
72
|
+
from instaui import ui, html
|
73
|
+
|
74
|
+
@ui.page("/")
|
75
|
+
def counter():
|
76
|
+
count = ui.ref(0)
|
77
|
+
text = ui.str_format("Count: {}", count)
|
78
|
+
|
79
|
+
html.button(text).on_click("()=> count.value++", bindings={"count": count})
|
80
|
+
|
81
|
+
|
82
|
+
ui.server().run()
|
83
|
+
```
|
84
|
+
|
85
|
+
In web mode, we can define interaction functions for complex computations.
|
86
|
+
|
87
|
+
```python
|
88
|
+
from instaui import ui, html
|
89
|
+
|
90
|
+
@ui.page("/")
|
91
|
+
def counter():
|
92
|
+
count = ui.ref(0)
|
93
|
+
# text = ui.str_format("Count: {}", count)
|
94
|
+
|
95
|
+
@ui.computed(inputs=[count])
|
96
|
+
def text(count: int):
|
97
|
+
# Any Python operation
|
98
|
+
return f"Current Count: {count}"
|
99
|
+
|
100
|
+
|
101
|
+
html.button(text).on_click("()=> count.value++", bindings={"count": count})
|
102
|
+
|
103
|
+
|
104
|
+
ui.server().run()
|
105
|
+
```
|
106
|
+
|
107
|
+
- The computation of `text` will generate network requests.
|
108
|
+
- Button clicks, due to using JS binding, do not require network requests.
|
109
|
+
|
110
|
+
You can choose to handle any computation with either Python or JavaScript. Below is an example of handling the button click event using Python.
|
111
|
+
|
112
|
+
```python
|
113
|
+
@ui.page("/")
|
114
|
+
def counter():
|
115
|
+
count = ui.ref(0)
|
116
|
+
|
117
|
+
@ui.computed(inputs=[count])
|
118
|
+
def text(count: int):
|
119
|
+
return f"Current Count: {count}"
|
120
|
+
|
121
|
+
@ui.event(inputs=[count], outputs=[count])
|
122
|
+
def add_count(count: int):
|
123
|
+
return count + 1
|
124
|
+
|
125
|
+
html.button(text).on_click(add_count)
|
126
|
+
|
127
|
+
```
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import typing
|
2
|
+
from instaui.vars.mixin_types.observable import ObservableMixin
|
3
|
+
from instaui.vars.mixin_types.py_binding import CanInputMixin
|
4
|
+
from instaui.ui_functions.input_slient_data import InputSilentData
|
5
|
+
|
6
|
+
from instaui.vars.mixin_types.common_type import TObservableInput
|
7
|
+
|
8
|
+
|
9
|
+
def analyze_observable_inputs(inputs: typing.List[TObservableInput]):
|
10
|
+
"""
|
11
|
+
Returns:
|
12
|
+
inputs, slients, datas
|
13
|
+
"""
|
14
|
+
|
15
|
+
slients: typing.List[int] = [0] * len(inputs)
|
16
|
+
datas: typing.List[int] = [0] * len(inputs)
|
17
|
+
result_inputs = []
|
18
|
+
|
19
|
+
for idx, input in enumerate(inputs):
|
20
|
+
if isinstance(input, ObservableMixin):
|
21
|
+
result_inputs.append(input._to_observable_config())
|
22
|
+
continue
|
23
|
+
|
24
|
+
if isinstance(input, CanInputMixin):
|
25
|
+
slients[idx] = 1
|
26
|
+
result_inputs.append(input._to_input_config())
|
27
|
+
|
28
|
+
if isinstance(input, InputSilentData) and input.is_const_value():
|
29
|
+
datas[idx] = 1
|
30
|
+
|
31
|
+
else:
|
32
|
+
datas[idx] = 1
|
33
|
+
result_inputs.append(input)
|
34
|
+
|
35
|
+
return result_inputs, slients, datas
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Literal
|
3
|
+
from instaui.version import __version__
|
4
|
+
|
5
|
+
_colors = {
|
6
|
+
"red": "\033[31m",
|
7
|
+
"green": "\033[32m",
|
8
|
+
"yellow": "\033[33m",
|
9
|
+
"blue": "\033[34m",
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
def zero_boot_info(file: Path):
|
14
|
+
message = f"""{_app_message('zero')}
|
15
|
+
{_arrow_right()}file: {_with_color(str(file))}
|
16
|
+
"""
|
17
|
+
print(message)
|
18
|
+
|
19
|
+
|
20
|
+
def web_boot_info(ip: str):
|
21
|
+
message = f"""{_app_message('web')}
|
22
|
+
{_arrow_right()}Local: {_with_color(str(ip), "blue")}
|
23
|
+
"""
|
24
|
+
print(message)
|
25
|
+
|
26
|
+
|
27
|
+
def webview_boot_info():
|
28
|
+
pass
|
29
|
+
|
30
|
+
|
31
|
+
def _app_message(mode: str) -> str:
|
32
|
+
return f"""{_with_color(f"InstaUI {__version__}")}
|
33
|
+
mode: {_with_color(mode)}"""
|
34
|
+
|
35
|
+
|
36
|
+
def _with_color(
|
37
|
+
text: str, color: Literal["red", "green", "yellow", "blue"] = "green"
|
38
|
+
) -> str:
|
39
|
+
return f"{_colors[color]}{text}\033[0m"
|
40
|
+
|
41
|
+
|
42
|
+
def _arrow_right() -> str:
|
43
|
+
return _with_color("➜ ")
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import orjson as json
|
2
|
+
import datetime
|
3
|
+
from enum import Enum
|
4
|
+
|
5
|
+
|
6
|
+
class Jsonable:
|
7
|
+
def _to_json_dict(self):
|
8
|
+
data = {k: v for k, v in self.__dict__.items() if k[:1] != "_"}
|
9
|
+
|
10
|
+
return data
|
11
|
+
|
12
|
+
|
13
|
+
def json_default(obj):
|
14
|
+
if isinstance(obj, float):
|
15
|
+
return None
|
16
|
+
if isinstance(obj, (datetime.date, datetime.datetime)):
|
17
|
+
return obj.isoformat()
|
18
|
+
if isinstance(obj, Enum):
|
19
|
+
return obj.value
|
20
|
+
if isinstance(obj, Jsonable):
|
21
|
+
return obj._to_json_dict()
|
22
|
+
|
23
|
+
|
24
|
+
def dumps(obj, indent=False):
|
25
|
+
def json_default_wrapper(obj):
|
26
|
+
for fn in [json_default]:
|
27
|
+
res = fn(obj)
|
28
|
+
if res is not None:
|
29
|
+
return res
|
30
|
+
|
31
|
+
return json.dumps(
|
32
|
+
obj, default=json_default_wrapper, option=json.OPT_INDENT_2 if indent else 0
|
33
|
+
).decode("utf-8")
|
34
|
+
|
35
|
+
|
36
|
+
def dumps2dict(obj):
|
37
|
+
return json.loads(dumps(obj))
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import Literal
|
3
|
+
from instaui.components.element import Element
|
4
|
+
from instaui.vars.types import TMaybeRef
|
5
|
+
|
6
|
+
|
7
|
+
class Column(Element):
|
8
|
+
def __init__(self):
|
9
|
+
super().__init__("div")
|
10
|
+
self.style("display: flex; flex-direction: column;gap:var(--insta-column-gap)")
|
11
|
+
|
12
|
+
def gap(self, value: TMaybeRef[str]) -> Column:
|
13
|
+
return self.style({"gap": value})
|
14
|
+
|
15
|
+
def align_items(
|
16
|
+
self, value: TMaybeRef[Literal["start", "end", "center", "stretch", "revert"]]
|
17
|
+
) -> Column:
|
18
|
+
return self.style({"align-items": value})
|
@@ -0,0 +1,47 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import (
|
4
|
+
Dict,
|
5
|
+
Optional,
|
6
|
+
Union,
|
7
|
+
)
|
8
|
+
from instaui.common.jsonable import Jsonable
|
9
|
+
from instaui.runtime import (
|
10
|
+
get_app_slot,
|
11
|
+
check_default_app_slot_or_error,
|
12
|
+
)
|
13
|
+
from instaui.components.slot import SlotManager
|
14
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
15
|
+
|
16
|
+
|
17
|
+
class Component(Jsonable):
|
18
|
+
def __init__(self, tag: Optional[Union[str, ElementBindingMixin]] = None):
|
19
|
+
check_default_app_slot_or_error(
|
20
|
+
"Not allowed to create element outside of ui.page"
|
21
|
+
)
|
22
|
+
|
23
|
+
self.tag = (
|
24
|
+
"div"
|
25
|
+
if tag is None
|
26
|
+
else (
|
27
|
+
tag._to_element_binding_config()
|
28
|
+
if isinstance(tag, ElementBindingMixin)
|
29
|
+
else str(tag)
|
30
|
+
)
|
31
|
+
)
|
32
|
+
self._slot_manager = SlotManager()
|
33
|
+
|
34
|
+
get_app_slot().append_component_to_container(self)
|
35
|
+
|
36
|
+
def __enter__(self):
|
37
|
+
self._slot_manager.default.__enter__()
|
38
|
+
return self
|
39
|
+
|
40
|
+
def __exit__(self, *_) -> None:
|
41
|
+
self._slot_manager.default.__exit__(*_)
|
42
|
+
|
43
|
+
def _to_json_dict(self) -> Dict:
|
44
|
+
data = super()._to_json_dict()
|
45
|
+
data["tag"] = self.tag
|
46
|
+
|
47
|
+
return data
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import Dict
|
3
|
+
from instaui.components.component import Component
|
4
|
+
from instaui.vars.types import TMaybeRef
|
5
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
6
|
+
|
7
|
+
|
8
|
+
class Content(Component):
|
9
|
+
def __init__(self, content: TMaybeRef[str]):
|
10
|
+
"""Content to be displayed on the page, typically used for pure text content within slots.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
content (TMaybeRef[str]): The textual content to display.
|
14
|
+
|
15
|
+
Example:
|
16
|
+
.. code-block:: python
|
17
|
+
with html.div():
|
18
|
+
ui.content("Hello, world!")
|
19
|
+
"""
|
20
|
+
super().__init__("content")
|
21
|
+
self._content = content
|
22
|
+
|
23
|
+
def _to_json_dict(self) -> Dict:
|
24
|
+
data = super()._to_json_dict()
|
25
|
+
props = {}
|
26
|
+
data["props"] = props
|
27
|
+
|
28
|
+
if isinstance(self._content, ElementBindingMixin):
|
29
|
+
props["content"] = self._content._to_element_binding_config()
|
30
|
+
props["r"] = 1
|
31
|
+
else:
|
32
|
+
props["content"] = self._content
|
33
|
+
|
34
|
+
return data
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import (
|
4
|
+
Any,
|
5
|
+
List,
|
6
|
+
Optional,
|
7
|
+
)
|
8
|
+
from instaui.common.jsonable import Jsonable
|
9
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
10
|
+
|
11
|
+
|
12
|
+
class Directive(Jsonable):
|
13
|
+
def __init__(
|
14
|
+
self,
|
15
|
+
*,
|
16
|
+
is_sys: bool,
|
17
|
+
name: str,
|
18
|
+
arg: Optional[str] = None,
|
19
|
+
modifiers: Optional[List[Any]] = None,
|
20
|
+
value: Optional[Any] = None,
|
21
|
+
) -> None:
|
22
|
+
super().__init__()
|
23
|
+
self.name = name
|
24
|
+
self._arg = arg
|
25
|
+
self._is_sys = is_sys
|
26
|
+
self._modifiers = modifiers
|
27
|
+
self._value = value
|
28
|
+
|
29
|
+
def __hash__(self) -> int:
|
30
|
+
return hash(self.name)
|
31
|
+
|
32
|
+
def __eq__(self, other: object) -> bool:
|
33
|
+
if not isinstance(other, Directive):
|
34
|
+
return False
|
35
|
+
return self.name == other.name
|
36
|
+
|
37
|
+
def _to_json_dict(self):
|
38
|
+
data = super()._to_json_dict()
|
39
|
+
|
40
|
+
if self._arg:
|
41
|
+
data["arg"] = self._arg
|
42
|
+
|
43
|
+
if self._value:
|
44
|
+
data["value"] = (
|
45
|
+
self._value._to_element_binding_config()
|
46
|
+
if isinstance(self._value, ElementBindingMixin)
|
47
|
+
else self._value
|
48
|
+
)
|
49
|
+
|
50
|
+
if self._modifiers:
|
51
|
+
data["mf"] = list(dict.fromkeys(self._modifiers).keys())
|
52
|
+
|
53
|
+
data["sys"] = int(self._is_sys)
|
54
|
+
|
55
|
+
return data
|