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,2 @@
|
|
1
|
+
/* Theme: vitesse-light */
|
2
|
+
export default Object.freeze(JSON.parse("{\"colors\":{\"activityBar.activeBorder\":\"#1c6b48\",\"activityBar.background\":\"#ffffff\",\"activityBar.border\":\"#f0f0f0\",\"activityBar.foreground\":\"#393a34\",\"activityBar.inactiveForeground\":\"#393a3450\",\"activityBarBadge.background\":\"#4e4f47\",\"activityBarBadge.foreground\":\"#ffffff\",\"badge.background\":\"#393a3490\",\"badge.foreground\":\"#ffffff\",\"breadcrumb.activeSelectionForeground\":\"#22222218\",\"breadcrumb.background\":\"#f7f7f7\",\"breadcrumb.focusForeground\":\"#393a34\",\"breadcrumb.foreground\":\"#6a737d\",\"breadcrumbPicker.background\":\"#ffffff\",\"button.background\":\"#1c6b48\",\"button.foreground\":\"#ffffff\",\"button.hoverBackground\":\"#1c6b48\",\"checkbox.background\":\"#f7f7f7\",\"checkbox.border\":\"#d1d5da\",\"debugToolBar.background\":\"#ffffff\",\"descriptionForeground\":\"#393a3490\",\"diffEditor.insertedTextBackground\":\"#1c6b4830\",\"diffEditor.removedTextBackground\":\"#ab595940\",\"dropdown.background\":\"#ffffff\",\"dropdown.border\":\"#f0f0f0\",\"dropdown.foreground\":\"#393a34\",\"dropdown.listBackground\":\"#f7f7f7\",\"editor.background\":\"#ffffff\",\"editor.findMatchBackground\":\"#e6cc7744\",\"editor.findMatchHighlightBackground\":\"#e6cc7766\",\"editor.focusedStackFrameHighlightBackground\":\"#fff5b1\",\"editor.foldBackground\":\"#22222210\",\"editor.foreground\":\"#393a34\",\"editor.inactiveSelectionBackground\":\"#22222210\",\"editor.lineHighlightBackground\":\"#f7f7f7\",\"editor.selectionBackground\":\"#22222218\",\"editor.selectionHighlightBackground\":\"#22222210\",\"editor.stackFrameHighlightBackground\":\"#fffbdd\",\"editor.wordHighlightBackground\":\"#1c6b4805\",\"editor.wordHighlightStrongBackground\":\"#1c6b4810\",\"editorBracketHighlight.foreground1\":\"#2993a3\",\"editorBracketHighlight.foreground2\":\"#1e754f\",\"editorBracketHighlight.foreground3\":\"#a65e2b\",\"editorBracketHighlight.foreground4\":\"#a13865\",\"editorBracketHighlight.foreground5\":\"#bda437\",\"editorBracketHighlight.foreground6\":\"#296aa3\",\"editorBracketMatch.background\":\"#1c6b4820\",\"editorError.foreground\":\"#ab5959\",\"editorGroup.border\":\"#f0f0f0\",\"editorGroupHeader.tabsBackground\":\"#ffffff\",\"editorGroupHeader.tabsBorder\":\"#f0f0f0\",\"editorGutter.addedBackground\":\"#1e754f\",\"editorGutter.commentRangeForeground\":\"#393a3450\",\"editorGutter.deletedBackground\":\"#ab5959\",\"editorGutter.foldingControlForeground\":\"#393a3490\",\"editorGutter.modifiedBackground\":\"#296aa3\",\"editorHint.foreground\":\"#1e754f\",\"editorIndentGuide.activeBackground\":\"#00000030\",\"editorIndentGuide.background\":\"#00000015\",\"editorInfo.foreground\":\"#296aa3\",\"editorInlayHint.background\":\"#f7f7f7\",\"editorInlayHint.foreground\":\"#999999\",\"editorLineNumber.activeForeground\":\"#4e4f47\",\"editorLineNumber.foreground\":\"#393a3450\",\"editorOverviewRuler.border\":\"#fff\",\"editorStickyScroll.background\":\"#f7f7f7\",\"editorStickyScrollHover.background\":\"#f7f7f7\",\"editorWarning.foreground\":\"#a65e2b\",\"editorWhitespace.foreground\":\"#00000015\",\"editorWidget.background\":\"#ffffff\",\"errorForeground\":\"#ab5959\",\"focusBorder\":\"#00000000\",\"foreground\":\"#393a34\",\"gitDecoration.addedResourceForeground\":\"#1e754f\",\"gitDecoration.conflictingResourceForeground\":\"#a65e2b\",\"gitDecoration.deletedResourceForeground\":\"#ab5959\",\"gitDecoration.ignoredResourceForeground\":\"#393a3450\",\"gitDecoration.modifiedResourceForeground\":\"#296aa3\",\"gitDecoration.submoduleResourceForeground\":\"#393a3490\",\"gitDecoration.untrackedResourceForeground\":\"#2993a3\",\"input.background\":\"#f7f7f7\",\"input.border\":\"#f0f0f0\",\"input.foreground\":\"#393a34\",\"input.placeholderForeground\":\"#393a3490\",\"inputOption.activeBackground\":\"#393a3450\",\"list.activeSelectionBackground\":\"#f7f7f7\",\"list.activeSelectionForeground\":\"#393a34\",\"list.focusBackground\":\"#f7f7f7\",\"list.highlightForeground\":\"#1c6b48\",\"list.hoverBackground\":\"#f7f7f7\",\"list.hoverForeground\":\"#393a34\",\"list.inactiveFocusBackground\":\"#ffffff\",\"list.inactiveSelectionBackground\":\"#f7f7f7\",\"list.inactiveSelectionForeground\":\"#393a34\",\"menu.separatorBackground\":\"#f0f0f0\",\"notificationCenterHeader.background\":\"#ffffff\",\"notificationCenterHeader.foreground\":\"#6a737d\",\"notifications.background\":\"#ffffff\",\"notifications.border\":\"#f0f0f0\",\"notifications.foreground\":\"#393a34\",\"notificationsErrorIcon.foreground\":\"#ab5959\",\"notificationsInfoIcon.foreground\":\"#296aa3\",\"notificationsWarningIcon.foreground\":\"#a65e2b\",\"panel.background\":\"#ffffff\",\"panel.border\":\"#f0f0f0\",\"panelInput.border\":\"#e1e4e8\",\"panelTitle.activeBorder\":\"#1c6b48\",\"panelTitle.activeForeground\":\"#393a34\",\"panelTitle.inactiveForeground\":\"#6a737d\",\"peekViewEditor.background\":\"#ffffff\",\"peekViewResult.background\":\"#ffffff\",\"pickerGroup.border\":\"#f0f0f0\",\"pickerGroup.foreground\":\"#393a34\",\"problemsErrorIcon.foreground\":\"#ab5959\",\"problemsInfoIcon.foreground\":\"#296aa3\",\"problemsWarningIcon.foreground\":\"#a65e2b\",\"progressBar.background\":\"#1c6b48\",\"quickInput.background\":\"#ffffff\",\"quickInput.foreground\":\"#393a34\",\"quickInputList.focusBackground\":\"#f7f7f7\",\"scrollbar.shadow\":\"#6a737d33\",\"scrollbarSlider.activeBackground\":\"#393a3450\",\"scrollbarSlider.background\":\"#393a3410\",\"scrollbarSlider.hoverBackground\":\"#393a3450\",\"settings.headerForeground\":\"#393a34\",\"settings.modifiedItemIndicator\":\"#1c6b48\",\"sideBar.background\":\"#ffffff\",\"sideBar.border\":\"#f0f0f0\",\"sideBar.foreground\":\"#4e4f47\",\"sideBarSectionHeader.background\":\"#ffffff\",\"sideBarSectionHeader.border\":\"#f0f0f0\",\"sideBarSectionHeader.foreground\":\"#393a34\",\"sideBarTitle.foreground\":\"#393a34\",\"statusBar.background\":\"#ffffff\",\"statusBar.border\":\"#f0f0f0\",\"statusBar.debuggingBackground\":\"#f7f7f7\",\"statusBar.debuggingForeground\":\"#4e4f47\",\"statusBar.foreground\":\"#4e4f47\",\"statusBar.noFolderBackground\":\"#ffffff\",\"statusBarItem.prominentBackground\":\"#f7f7f7\",\"tab.activeBackground\":\"#ffffff\",\"tab.activeBorder\":\"#f0f0f0\",\"tab.activeBorderTop\":\"#393a3490\",\"tab.activeForeground\":\"#393a34\",\"tab.border\":\"#f0f0f0\",\"tab.hoverBackground\":\"#f7f7f7\",\"tab.inactiveBackground\":\"#ffffff\",\"tab.inactiveForeground\":\"#6a737d\",\"tab.unfocusedActiveBorder\":\"#f0f0f0\",\"tab.unfocusedActiveBorderTop\":\"#f0f0f0\",\"tab.unfocusedHoverBackground\":\"#ffffff\",\"terminal.ansiBlack\":\"#121212\",\"terminal.ansiBlue\":\"#296aa3\",\"terminal.ansiBrightBlack\":\"#aaaaaa\",\"terminal.ansiBrightBlue\":\"#296aa3\",\"terminal.ansiBrightCyan\":\"#2993a3\",\"terminal.ansiBrightGreen\":\"#1e754f\",\"terminal.ansiBrightMagenta\":\"#a13865\",\"terminal.ansiBrightRed\":\"#ab5959\",\"terminal.ansiBrightWhite\":\"#dddddd\",\"terminal.ansiBrightYellow\":\"#bda437\",\"terminal.ansiCyan\":\"#2993a3\",\"terminal.ansiGreen\":\"#1e754f\",\"terminal.ansiMagenta\":\"#a13865\",\"terminal.ansiRed\":\"#ab5959\",\"terminal.ansiWhite\":\"#dbd7ca\",\"terminal.ansiYellow\":\"#bda437\",\"terminal.foreground\":\"#393a34\",\"terminal.selectionBackground\":\"#22222218\",\"textBlockQuote.background\":\"#ffffff\",\"textBlockQuote.border\":\"#f0f0f0\",\"textCodeBlock.background\":\"#ffffff\",\"textLink.activeForeground\":\"#1c6b48\",\"textLink.foreground\":\"#1c6b48\",\"textPreformat.foreground\":\"#586069\",\"textSeparator.foreground\":\"#d1d5da\",\"titleBar.activeBackground\":\"#ffffff\",\"titleBar.activeForeground\":\"#4e4f47\",\"titleBar.border\":\"#f7f7f7\",\"titleBar.inactiveBackground\":\"#ffffff\",\"titleBar.inactiveForeground\":\"#6a737d\",\"tree.indentGuidesStroke\":\"#e1e4e8\",\"welcomePage.buttonBackground\":\"#f6f8fa\",\"welcomePage.buttonHoverBackground\":\"#e1e4e8\"},\"displayName\":\"Vitesse Light\",\"name\":\"vitesse-light\",\"semanticHighlighting\":true,\"semanticTokenColors\":{\"class\":\"#5a6aa6\",\"interface\":\"#2e808f\",\"namespace\":\"#b05a78\",\"property\":\"#998418\",\"type\":\"#2e808f\"},\"tokenColors\":[{\"scope\":[\"comment\",\"punctuation.definition.comment\",\"string.comment\"],\"settings\":{\"foreground\":\"#a0ada0\"}},{\"scope\":[\"delimiter.bracket\",\"delimiter\",\"invalid.illegal.character-not-allowed-here.html\",\"keyword.operator.rest\",\"keyword.operator.spread\",\"keyword.operator.type.annotation\",\"keyword.operator.relational\",\"keyword.operator.assignment\",\"keyword.operator.type\",\"meta.brace\",\"meta.tag.block.any.html\",\"meta.tag.inline.any.html\",\"meta.tag.structure.input.void.html\",\"meta.type.annotation\",\"meta.embedded.block.github-actions-expression\",\"storage.type.function.arrow\",\"meta.objectliteral.ts\",\"punctuation\",\"punctuation.definition.string.begin.html.vue\",\"punctuation.definition.string.end.html.vue\"],\"settings\":{\"foreground\":\"#999999\"}},{\"scope\":[\"constant\",\"entity.name.constant\",\"variable.language\",\"meta.definition.variable\"],\"settings\":{\"foreground\":\"#a65e2b\"}},{\"scope\":[\"entity\",\"entity.name\"],\"settings\":{\"foreground\":\"#59873a\"}},{\"scope\":\"variable.parameter.function\",\"settings\":{\"foreground\":\"#393a34\"}},{\"scope\":[\"entity.name.tag\",\"tag.html\"],\"settings\":{\"foreground\":\"#1e754f\"}},{\"scope\":\"entity.name.function\",\"settings\":{\"foreground\":\"#59873a\"}},{\"scope\":[\"keyword\",\"storage.type.class.jsdoc\",\"punctuation.definition.template-expression\"],\"settings\":{\"foreground\":\"#1e754f\"}},{\"scope\":[\"storage\",\"storage.type\",\"support.type.builtin\",\"constant.language.undefined\",\"constant.language.null\",\"constant.language.import-export-all.ts\"],\"settings\":{\"foreground\":\"#ab5959\"}},{\"scope\":[\"text.html.derivative\",\"storage.modifier.package\",\"storage.modifier.import\",\"storage.type.java\"],\"settings\":{\"foreground\":\"#393a34\"}},{\"scope\":[\"string\",\"string punctuation.section.embedded source\",\"attribute.value\"],\"settings\":{\"foreground\":\"#b56959\"}},{\"scope\":[\"punctuation.definition.string\"],\"settings\":{\"foreground\":\"#b5695977\"}},{\"scope\":[\"punctuation.support.type.property-name\"],\"settings\":{\"foreground\":\"#99841877\"}},{\"scope\":\"support\",\"settings\":{\"foreground\":\"#998418\"}},{\"scope\":[\"property\",\"meta.property-name\",\"meta.object-literal.key\",\"entity.name.tag.yaml\",\"attribute.name\"],\"settings\":{\"foreground\":\"#998418\"}},{\"scope\":[\"entity.other.attribute-name\",\"invalid.deprecated.entity.other.attribute-name.html\"],\"settings\":{\"foreground\":\"#b07d48\"}},{\"scope\":[\"variable\",\"identifier\"],\"settings\":{\"foreground\":\"#b07d48\"}},{\"scope\":[\"support.type.primitive\",\"entity.name.type\"],\"settings\":{\"foreground\":\"#2e8f82\"}},{\"scope\":\"namespace\",\"settings\":{\"foreground\":\"#b05a78\"}},{\"scope\":[\"keyword.operator\",\"keyword.operator.assignment.compound\",\"meta.var.expr.ts\"],\"settings\":{\"foreground\":\"#ab5959\"}},{\"scope\":\"invalid.broken\",\"settings\":{\"fontStyle\":\"italic\",\"foreground\":\"#b31d28\"}},{\"scope\":\"invalid.deprecated\",\"settings\":{\"fontStyle\":\"italic\",\"foreground\":\"#b31d28\"}},{\"scope\":\"invalid.illegal\",\"settings\":{\"fontStyle\":\"italic\",\"foreground\":\"#b31d28\"}},{\"scope\":\"invalid.unimplemented\",\"settings\":{\"fontStyle\":\"italic\",\"foreground\":\"#b31d28\"}},{\"scope\":\"carriage-return\",\"settings\":{\"background\":\"#d73a49\",\"content\":\"^M\",\"fontStyle\":\"italic underline\",\"foreground\":\"#fafbfc\"}},{\"scope\":\"message.error\",\"settings\":{\"foreground\":\"#b31d28\"}},{\"scope\":\"string variable\",\"settings\":{\"foreground\":\"#b56959\"}},{\"scope\":[\"source.regexp\",\"string.regexp\"],\"settings\":{\"foreground\":\"#ab5e3f\"}},{\"scope\":[\"string.regexp.character-class\",\"string.regexp constant.character.escape\",\"string.regexp source.ruby.embedded\",\"string.regexp string.regexp.arbitrary-repitition\"],\"settings\":{\"foreground\":\"#b56959\"}},{\"scope\":\"string.regexp constant.character.escape\",\"settings\":{\"foreground\":\"#bda437\"}},{\"scope\":[\"support.constant\"],\"settings\":{\"foreground\":\"#a65e2b\"}},{\"scope\":[\"keyword.operator.quantifier.regexp\",\"constant.numeric\",\"number\"],\"settings\":{\"foreground\":\"#2f798a\"}},{\"scope\":[\"keyword.other.unit\"],\"settings\":{\"foreground\":\"#ab5959\"}},{\"scope\":[\"constant.language.boolean\",\"constant.language\"],\"settings\":{\"foreground\":\"#1e754f\"}},{\"scope\":\"meta.module-reference\",\"settings\":{\"foreground\":\"#1c6b48\"}},{\"scope\":\"punctuation.definition.list.begin.markdown\",\"settings\":{\"foreground\":\"#a65e2b\"}},{\"scope\":[\"markup.heading\",\"markup.heading entity.name\"],\"settings\":{\"fontStyle\":\"bold\",\"foreground\":\"#1c6b48\"}},{\"scope\":\"markup.quote\",\"settings\":{\"foreground\":\"#2e808f\"}},{\"scope\":\"markup.italic\",\"settings\":{\"fontStyle\":\"italic\",\"foreground\":\"#393a34\"}},{\"scope\":\"markup.bold\",\"settings\":{\"fontStyle\":\"bold\",\"foreground\":\"#393a34\"}},{\"scope\":\"markup.raw\",\"settings\":{\"foreground\":\"#1c6b48\"}},{\"scope\":[\"markup.deleted\",\"meta.diff.header.from-file\",\"punctuation.definition.deleted\"],\"settings\":{\"background\":\"#ffeef0\",\"foreground\":\"#b31d28\"}},{\"scope\":[\"markup.inserted\",\"meta.diff.header.to-file\",\"punctuation.definition.inserted\"],\"settings\":{\"background\":\"#f0fff4\",\"foreground\":\"#22863a\"}},{\"scope\":[\"markup.changed\",\"punctuation.definition.changed\"],\"settings\":{\"background\":\"#ffebda\",\"foreground\":\"#e36209\"}},{\"scope\":[\"markup.ignored\",\"markup.untracked\"],\"settings\":{\"background\":\"#005cc5\",\"foreground\":\"#f6f8fa\"}},{\"scope\":\"meta.diff.range\",\"settings\":{\"fontStyle\":\"bold\",\"foreground\":\"#6f42c1\"}},{\"scope\":\"meta.diff.header\",\"settings\":{\"foreground\":\"#005cc5\"}},{\"scope\":\"meta.separator\",\"settings\":{\"fontStyle\":\"bold\",\"foreground\":\"#005cc5\"}},{\"scope\":\"meta.output\",\"settings\":{\"foreground\":\"#005cc5\"}},{\"scope\":[\"brackethighlighter.tag\",\"brackethighlighter.curly\",\"brackethighlighter.round\",\"brackethighlighter.square\",\"brackethighlighter.angle\",\"brackethighlighter.quote\"],\"settings\":{\"foreground\":\"#586069\"}},{\"scope\":\"brackethighlighter.unmatched\",\"settings\":{\"foreground\":\"#b31d28\"}},{\"scope\":[\"constant.other.reference.link\",\"string.other.link\",\"punctuation.definition.string.begin.markdown\",\"punctuation.definition.string.end.markdown\"],\"settings\":{\"foreground\":\"#b56959\"}},{\"scope\":[\"markup.underline.link.markdown\",\"markup.underline.link.image.markdown\"],\"settings\":{\"fontStyle\":\"underline\",\"foreground\":\"#393a3490\"}},{\"scope\":[\"type.identifier\",\"constant.other.character-class.regexp\"],\"settings\":{\"foreground\":\"#5a6aa6\"}},{\"scope\":[\"entity.other.attribute-name.html.vue\"],\"settings\":{\"foreground\":\"#59873a\"}},{\"scope\":[\"invalid.illegal.unrecognized-tag.html\"],\"settings\":{\"fontStyle\":\"normal\"}}],\"type\":\"light\"}"))
|
@@ -0,0 +1,81 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING, Dict, List, Optional, Set
|
4
|
+
from instaui.common.jsonable import Jsonable
|
5
|
+
from instaui.runtime import get_slot_stacks, pop_slot
|
6
|
+
from instaui.runtime._app import get_app_slot
|
7
|
+
from instaui.vars.slot_prop import BindingSlotPropItem
|
8
|
+
|
9
|
+
if TYPE_CHECKING:
|
10
|
+
from instaui.components.component import Component
|
11
|
+
|
12
|
+
_DEFAULT_SLOT_NAME = ":"
|
13
|
+
|
14
|
+
|
15
|
+
class SlotManager(Jsonable):
|
16
|
+
def __init__(self) -> None:
|
17
|
+
super().__init__()
|
18
|
+
self._slots: Dict[str, Slot] = {}
|
19
|
+
|
20
|
+
def get_slot(self, name: str) -> Slot:
|
21
|
+
name = _DEFAULT_SLOT_NAME if name == "default" else name
|
22
|
+
|
23
|
+
if name not in self._slots:
|
24
|
+
self._slots[name] = Slot(name)
|
25
|
+
|
26
|
+
return self._slots[name]
|
27
|
+
|
28
|
+
@property
|
29
|
+
def default(self):
|
30
|
+
return self.get_slot(_DEFAULT_SLOT_NAME)
|
31
|
+
|
32
|
+
def _to_json_dict(self):
|
33
|
+
if (
|
34
|
+
len(self._slots) == 1
|
35
|
+
and _DEFAULT_SLOT_NAME in self._slots
|
36
|
+
and (not self._slots[_DEFAULT_SLOT_NAME]._has_props_use())
|
37
|
+
):
|
38
|
+
return self._slots[_DEFAULT_SLOT_NAME]._children
|
39
|
+
|
40
|
+
return {name: slot._to_json_dict() for name, slot in self._slots.items()}
|
41
|
+
|
42
|
+
def has_slot(self) -> bool:
|
43
|
+
return len(self._slots) > 0
|
44
|
+
|
45
|
+
|
46
|
+
class Slot(Jsonable):
|
47
|
+
def __init__(self, name: str) -> None:
|
48
|
+
super().__init__()
|
49
|
+
|
50
|
+
self._id: Optional[str] = None
|
51
|
+
self._name = name
|
52
|
+
self._children: List[Component] = []
|
53
|
+
self._props_use_name: Set[str] = set()
|
54
|
+
|
55
|
+
def _has_props_use(self):
|
56
|
+
return len(self._props_use_name) > 0
|
57
|
+
|
58
|
+
def props(self, name: str):
|
59
|
+
if self._id is None:
|
60
|
+
self._id = get_app_slot().generate_slot_id()
|
61
|
+
|
62
|
+
self._props_use_name.add(name)
|
63
|
+
return BindingSlotPropItem(self._id, name)
|
64
|
+
|
65
|
+
def __enter__(self):
|
66
|
+
get_slot_stacks().append(self)
|
67
|
+
return self
|
68
|
+
|
69
|
+
def __exit__(self, *_):
|
70
|
+
pop_slot()
|
71
|
+
|
72
|
+
def _to_json_dict(self):
|
73
|
+
data = super()._to_json_dict()
|
74
|
+
|
75
|
+
if self._children:
|
76
|
+
data["items"] = self._children
|
77
|
+
|
78
|
+
if self._props_use_name:
|
79
|
+
data["props"] = {"id": self._id, "use": list(self._props_use_name)}
|
80
|
+
|
81
|
+
return data
|
@@ -0,0 +1,52 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Generic,
|
4
|
+
List,
|
5
|
+
Optional,
|
6
|
+
Union,
|
7
|
+
TypeVar,
|
8
|
+
)
|
9
|
+
from instaui.components.element import Element
|
10
|
+
from instaui import consts
|
11
|
+
|
12
|
+
from instaui.vars.types import TMaybeRef
|
13
|
+
from instaui.vars.web_computed import WebComputed
|
14
|
+
from instaui.ui_functions.ui_types import is_bindable
|
15
|
+
|
16
|
+
|
17
|
+
_T = TypeVar("_T")
|
18
|
+
|
19
|
+
|
20
|
+
class ValueElement(Element, Generic[_T]):
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
tag: Optional[str] = None,
|
24
|
+
value: Union[_T, TMaybeRef[_T], None] = None,
|
25
|
+
is_html_component: bool = False,
|
26
|
+
value_name: str = "value",
|
27
|
+
):
|
28
|
+
super().__init__(tag)
|
29
|
+
self.__is_html_component = is_html_component
|
30
|
+
|
31
|
+
if value is not None:
|
32
|
+
if is_bindable(value):
|
33
|
+
if isinstance(value, WebComputed):
|
34
|
+
self.props({value_name: value})
|
35
|
+
else:
|
36
|
+
self.vmodel(value, prop_name=value_name)
|
37
|
+
else:
|
38
|
+
self.props({value_name: value})
|
39
|
+
|
40
|
+
def vmodel(
|
41
|
+
self,
|
42
|
+
value,
|
43
|
+
modifiers: Union[consts.TModifier, List[consts.TModifier], None] = None,
|
44
|
+
*,
|
45
|
+
prop_name: str = "value",
|
46
|
+
):
|
47
|
+
return super().vmodel(
|
48
|
+
value,
|
49
|
+
modifiers,
|
50
|
+
prop_name=prop_name,
|
51
|
+
is_html_component=self.__is_html_component,
|
52
|
+
)
|
@@ -0,0 +1,142 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Dict,
|
4
|
+
List,
|
5
|
+
Literal,
|
6
|
+
Mapping,
|
7
|
+
Optional,
|
8
|
+
Union,
|
9
|
+
Sequence,
|
10
|
+
Generic,
|
11
|
+
TypeVar,
|
12
|
+
overload,
|
13
|
+
)
|
14
|
+
import pydantic
|
15
|
+
|
16
|
+
from instaui.components.component import Component
|
17
|
+
from instaui.vars.vfor_item import VForItem, VForDict, VForWithIndex
|
18
|
+
from instaui.runtime._app import get_app_slot, new_scope
|
19
|
+
|
20
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
21
|
+
|
22
|
+
_T = TypeVar("_T")
|
23
|
+
|
24
|
+
|
25
|
+
class VFor(Component, Generic[_T]):
|
26
|
+
def __init__(
|
27
|
+
self,
|
28
|
+
data: Union[Sequence[_T], ElementBindingMixin[List[_T]]],
|
29
|
+
*,
|
30
|
+
key: Union[Literal["item", "index"], str] = "index",
|
31
|
+
):
|
32
|
+
"""for loop component.
|
33
|
+
|
34
|
+
Args:
|
35
|
+
data (Union[Sequence[_T], ElementBindingMixin[List[_T]]]): data source.
|
36
|
+
key (Union[Literal["item", "index"], str]]): key for each item. Defaults to 'index'.
|
37
|
+
|
38
|
+
Examples:
|
39
|
+
.. code-block:: python
|
40
|
+
items = ui.state([1,2,3])
|
41
|
+
|
42
|
+
with ui.vfor(items) as item:
|
43
|
+
html.span(item)
|
44
|
+
|
45
|
+
# object key
|
46
|
+
items = ui.state([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 30}])
|
47
|
+
with ui.vfor(items, key=":item=>item.name") as item:
|
48
|
+
html.span(item.name)
|
49
|
+
"""
|
50
|
+
|
51
|
+
super().__init__("vfor")
|
52
|
+
self._data = data
|
53
|
+
if isinstance(self._data, ElementBindingMixin):
|
54
|
+
self._data._mark_used()
|
55
|
+
self._key = key
|
56
|
+
self._fid = get_app_slot().generate_vfor_id()
|
57
|
+
self.__scope_manager = new_scope(append_to_app=False)
|
58
|
+
self.__scope = None
|
59
|
+
self._num = None
|
60
|
+
self._transition_group_setting = None
|
61
|
+
|
62
|
+
def __enter__(self) -> _T:
|
63
|
+
self.__scope = self.__scope_manager.__enter__()
|
64
|
+
super().__enter__()
|
65
|
+
return VForItem(self).proxy # type: ignore
|
66
|
+
|
67
|
+
def __exit__(self, *_) -> None:
|
68
|
+
self.__scope_manager.__exit__(*_)
|
69
|
+
return super().__exit__(*_)
|
70
|
+
|
71
|
+
def _set_num(self, num):
|
72
|
+
self._num = num
|
73
|
+
|
74
|
+
def transition_group(self, name="fade", tag: Optional[str] = None):
|
75
|
+
self._transition_group_setting = {"name": name, "tag": tag}
|
76
|
+
return self
|
77
|
+
|
78
|
+
@property
|
79
|
+
def current(self):
|
80
|
+
return VForItem(self)
|
81
|
+
|
82
|
+
def with_index(self):
|
83
|
+
return VForWithIndex(self)
|
84
|
+
|
85
|
+
def _to_json_dict(self):
|
86
|
+
data = super()._to_json_dict()
|
87
|
+
data["props"] = {"fid": self._fid}
|
88
|
+
|
89
|
+
props: Dict = data["props"]
|
90
|
+
if self._key is not None and self._key != "index":
|
91
|
+
props["fkey"] = self._key
|
92
|
+
|
93
|
+
if self._data is not None:
|
94
|
+
if isinstance(self._data, ElementBindingMixin):
|
95
|
+
props["bArray"] = self._data._to_element_binding_config()
|
96
|
+
else:
|
97
|
+
props["array"] = self._data
|
98
|
+
|
99
|
+
if self._num is not None:
|
100
|
+
props["num"] = self._num
|
101
|
+
|
102
|
+
if self._transition_group_setting is not None:
|
103
|
+
props["tsGroup"] = {
|
104
|
+
k: v for k, v in self._transition_group_setting.items() if v is not None
|
105
|
+
}
|
106
|
+
|
107
|
+
props["scope"] = self.__scope
|
108
|
+
|
109
|
+
if self._slot_manager.has_slot():
|
110
|
+
props["items"] = self._slot_manager
|
111
|
+
|
112
|
+
data.pop("slots", None)
|
113
|
+
|
114
|
+
return data
|
115
|
+
|
116
|
+
@overload
|
117
|
+
@classmethod
|
118
|
+
def range(cls, end: int) -> VFor[int]: ...
|
119
|
+
|
120
|
+
@overload
|
121
|
+
@classmethod
|
122
|
+
def range(cls, end: ElementBindingMixin[int]) -> VFor[int]: ...
|
123
|
+
|
124
|
+
@classmethod
|
125
|
+
def range(cls, end: Union[int, ElementBindingMixin[int]]) -> VFor[int]:
|
126
|
+
obj = cls(None) # type: ignore
|
127
|
+
|
128
|
+
num = ( # type: ignore
|
129
|
+
end._to_element_binding_config()
|
130
|
+
if isinstance(end, ElementBindingMixin)
|
131
|
+
else end
|
132
|
+
)
|
133
|
+
|
134
|
+
obj._set_num(num)
|
135
|
+
|
136
|
+
return obj # type: ignore
|
137
|
+
|
138
|
+
@classmethod
|
139
|
+
def from_dict(
|
140
|
+
cls, data: Union[Mapping, pydantic.BaseModel, ElementBindingMixin[Dict]]
|
141
|
+
):
|
142
|
+
return VForDict(VFor(data)) # type: ignore
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import Dict, cast
|
3
|
+
from instaui.components.component import Component
|
4
|
+
from instaui.runtime._app import new_scope
|
5
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
9
|
+
class VIf(Component):
|
10
|
+
def __init__(self, on: TMaybeRef[bool]):
|
11
|
+
super().__init__("vif")
|
12
|
+
self._on = cast(ElementBindingMixin, on)
|
13
|
+
if isinstance(on, ElementBindingMixin):
|
14
|
+
on._mark_used()
|
15
|
+
self.__scope_manager = new_scope(append_to_app=False)
|
16
|
+
self.__scope = None
|
17
|
+
|
18
|
+
def __enter__(self):
|
19
|
+
self.__scope = self.__scope_manager.__enter__()
|
20
|
+
return super().__enter__()
|
21
|
+
|
22
|
+
def __exit__(self, *_) -> None:
|
23
|
+
self.__scope_manager.__exit__(*_)
|
24
|
+
return super().__exit__(*_)
|
25
|
+
|
26
|
+
def _to_json_dict(self):
|
27
|
+
data = super()._to_json_dict()
|
28
|
+
data["props"] = {
|
29
|
+
"on": self._on
|
30
|
+
if isinstance(self._on, bool)
|
31
|
+
else self._on._to_element_binding_config(),
|
32
|
+
}
|
33
|
+
props: Dict = data["props"]
|
34
|
+
|
35
|
+
props["scope"] = self.__scope
|
36
|
+
|
37
|
+
if self._slot_manager.has_slot():
|
38
|
+
props["items"] = self._slot_manager
|
39
|
+
|
40
|
+
data.pop("slots", None)
|
41
|
+
|
42
|
+
return data
|
instaui/consts.py
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Literal
|
3
|
+
|
4
|
+
_THIS_DIR = Path(__file__).parent
|
5
|
+
_TEMPLATES_DIR = _THIS_DIR.joinpath("templates")
|
6
|
+
_STATIC_DIR = _THIS_DIR.joinpath("static")
|
7
|
+
|
8
|
+
INDEX_TEMPLATE_PATH = _TEMPLATES_DIR.joinpath("index.html")
|
9
|
+
APP_IIFE_JS_PATH = _STATIC_DIR.joinpath("insta-ui.iife.js")
|
10
|
+
APP_ES_JS_PATH = _STATIC_DIR.joinpath("insta-ui.esm-browser.prod.js")
|
11
|
+
APP_ES_JS_MAP_PATH = _STATIC_DIR.joinpath("insta-ui.js.map")
|
12
|
+
APP_CSS_PATH = _STATIC_DIR.joinpath("insta-ui.css")
|
13
|
+
VUE_IIFE_JS_PATH = _STATIC_DIR.joinpath("vue.global.prod.js")
|
14
|
+
VUE_ES_JS_PATH = _STATIC_DIR.joinpath("vue.esm-browser.prod.js")
|
15
|
+
VUE_ES_RUNTIME_JS_PATH = _STATIC_DIR.joinpath("vue.runtime.esm-browser.prod.js")
|
16
|
+
FAVICON_PATH = _STATIC_DIR.joinpath("insta-ui.ico")
|
17
|
+
# tools
|
18
|
+
TOOLS_BROWSER_JS_PATH = _STATIC_DIR.joinpath("instaui-tools-browser.js")
|
19
|
+
|
20
|
+
PAGE_TITLE = "insta-ui"
|
21
|
+
|
22
|
+
_T_App_Mode = Literal["zero", "web", "webview"]
|
23
|
+
TModifier = Literal["trim", "number", "lazy"]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from dataclasses import dataclass, field
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Dict, Set
|
5
|
+
|
6
|
+
_TTagName = str
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass(frozen=True)
|
10
|
+
class ComponentDependencyInfo:
|
11
|
+
tag_name: _TTagName = field(hash=True)
|
12
|
+
esm: Path = field(hash=False)
|
13
|
+
externals: Dict[str, Path] = field(default_factory=dict, compare=False, hash=False)
|
14
|
+
css: Set[Path] = field(default_factory=set, compare=False, hash=False)
|
15
|
+
|
16
|
+
def copy(self):
|
17
|
+
return ComponentDependencyInfo(
|
18
|
+
tag_name=self.tag_name,
|
19
|
+
esm=self.esm,
|
20
|
+
externals={**self.externals},
|
21
|
+
css=set(self.css),
|
22
|
+
)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from dataclasses import dataclass, field
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import List, Optional
|
5
|
+
from instaui.runtime._app import get_app_slot
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass(frozen=True)
|
9
|
+
class PluginDependencyInfo:
|
10
|
+
name: str = field(hash=True)
|
11
|
+
esm: Path = field(hash=False)
|
12
|
+
externals: Optional[List[Path]] = field(
|
13
|
+
default_factory=list, compare=False, hash=False
|
14
|
+
)
|
15
|
+
css: List[Path] = field(default_factory=list, compare=False, hash=False)
|
16
|
+
|
17
|
+
|
18
|
+
def register_plugin(
|
19
|
+
name: str,
|
20
|
+
esm: Path,
|
21
|
+
*,
|
22
|
+
externals: Optional[List[Path]] = None,
|
23
|
+
css: Optional[List[Path]] = None,
|
24
|
+
):
|
25
|
+
info = PluginDependencyInfo(f"plugin/{name}", esm, externals or [], css or [])
|
26
|
+
|
27
|
+
get_app_slot().use_plugin_dependency(info)
|
28
|
+
return info
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
import typing
|
3
|
+
|
4
|
+
|
5
|
+
class EventMixin(ABC):
|
6
|
+
@abstractmethod
|
7
|
+
def copy_with_extends(self, extends: typing.Sequence) -> "EventMixin":
|
8
|
+
pass
|
9
|
+
|
10
|
+
@abstractmethod
|
11
|
+
def event_type(self) -> typing.Literal["web", "js"]:
|
12
|
+
pass
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import typing
|
2
|
+
from instaui.vars.mixin_types.py_binding import CanInputMixin, CanOutputMixin
|
3
|
+
from instaui.common.jsonable import Jsonable
|
4
|
+
from .event_mixin import EventMixin
|
5
|
+
|
6
|
+
|
7
|
+
class JsEvent(Jsonable, EventMixin):
|
8
|
+
def __init__(
|
9
|
+
self,
|
10
|
+
code: str,
|
11
|
+
inputs: typing.Optional[typing.Sequence[CanInputMixin]] = None,
|
12
|
+
outputs: typing.Optional[typing.Sequence[CanOutputMixin]] = None,
|
13
|
+
):
|
14
|
+
self._is_const_data = [
|
15
|
+
int(not isinstance(input, CanInputMixin)) for input in inputs or []
|
16
|
+
]
|
17
|
+
self._org_inputs = list(inputs or [])
|
18
|
+
self._org_outputs = list(outputs or [])
|
19
|
+
self._inputs = [
|
20
|
+
input._to_input_config() if isinstance(input, CanInputMixin) else input
|
21
|
+
for input in inputs or []
|
22
|
+
]
|
23
|
+
self._outputs = [output._to_output_config() for output in outputs or []]
|
24
|
+
self.code = code
|
25
|
+
|
26
|
+
def _to_json_dict(self):
|
27
|
+
data = super()._to_json_dict()
|
28
|
+
data["type"] = self.event_type()
|
29
|
+
|
30
|
+
if self._inputs:
|
31
|
+
data["inputs"] = self._inputs
|
32
|
+
|
33
|
+
if self._outputs:
|
34
|
+
data["set"] = self._outputs
|
35
|
+
|
36
|
+
if sum(self._is_const_data) > 0:
|
37
|
+
data["data"] = self._is_const_data
|
38
|
+
|
39
|
+
return data
|
40
|
+
|
41
|
+
def copy_with_extends(self, extends: typing.Sequence):
|
42
|
+
return js_event(
|
43
|
+
code=self.code,
|
44
|
+
inputs=self._org_inputs + list(extends),
|
45
|
+
outputs=self._org_outputs,
|
46
|
+
)
|
47
|
+
|
48
|
+
def event_type(self):
|
49
|
+
return "js"
|
50
|
+
|
51
|
+
|
52
|
+
def js_event(
|
53
|
+
*,
|
54
|
+
inputs: typing.Optional[typing.Sequence] = None,
|
55
|
+
outputs: typing.Optional[typing.Sequence] = None,
|
56
|
+
code: str,
|
57
|
+
):
|
58
|
+
"""
|
59
|
+
Creates a client-side event handler decorator for binding JavaScript logic to UI component events.
|
60
|
+
|
61
|
+
Args:
|
62
|
+
inputs (typing.Optional[typing.Sequence], optional):Reactive sources (state variables, computed values)
|
63
|
+
that should be passed to the event handler. These values
|
64
|
+
will be available in the JavaScript context through the `args` array.
|
65
|
+
outputs (typing.Optional[typing.Sequence], optional): Targets (state variables, UI elements) that should
|
66
|
+
update when this handler executes. Used for coordinating
|
67
|
+
interface updates after the event is processed.
|
68
|
+
code (str): JavaScript code to execute when the event is triggered.
|
69
|
+
|
70
|
+
# Example:
|
71
|
+
.. code-block:: python
|
72
|
+
from instaui import ui, html
|
73
|
+
|
74
|
+
a = ui.state(0)
|
75
|
+
|
76
|
+
plus_one = ui.js_event(inputs=[a], outputs=[a], code="a =>a + 1")
|
77
|
+
|
78
|
+
html.button("click me").on_click(plus_one)
|
79
|
+
html.paragraph(a)
|
80
|
+
|
81
|
+
"""
|
82
|
+
return JsEvent(inputs=inputs, outputs=outputs, code=code)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import typing
|
2
|
+
from instaui.common.jsonable import Jsonable
|
3
|
+
from instaui.vars.mixin_types.observable import ObservableMixin
|
4
|
+
from .event_mixin import EventMixin
|
5
|
+
|
6
|
+
|
7
|
+
class VueEvent(Jsonable, EventMixin):
|
8
|
+
"""
|
9
|
+
Create an event object that can be bound to a UI component's event listener.
|
10
|
+
|
11
|
+
This function generates a callable event handler with optional contextual bindings.
|
12
|
+
The event logic is defined via a code string, which can reference bound variables.
|
13
|
+
|
14
|
+
Args:
|
15
|
+
code (str): A string containing the executable logic for the event handler.
|
16
|
+
Typically contains a function body or expression that utilizes bound variables.
|
17
|
+
bindings (typing.Optional[typing.Dict[str, typing.Any]], optional): A dictionary mapping variable names to values that should be available in the
|
18
|
+
event handler's context. If None, no additional bindings are created.. Defaults to None.
|
19
|
+
|
20
|
+
Example:
|
21
|
+
.. code-block:: python
|
22
|
+
a = ui.state(1)
|
23
|
+
|
24
|
+
event = ui.vue_event(bindings={"a": a}, code=r'''()=> { a.value +=1}''')
|
25
|
+
|
26
|
+
html.span(a)
|
27
|
+
html.button("plus").on("click", event)
|
28
|
+
"""
|
29
|
+
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
*,
|
33
|
+
code: str,
|
34
|
+
bindings: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
35
|
+
):
|
36
|
+
self.code = code
|
37
|
+
self._bindings = bindings
|
38
|
+
|
39
|
+
if bindings:
|
40
|
+
bindData = [
|
41
|
+
int(not isinstance(v, ObservableMixin)) for v in bindings.values()
|
42
|
+
]
|
43
|
+
|
44
|
+
if sum(bindData) > 0:
|
45
|
+
self.bindData = bindData
|
46
|
+
|
47
|
+
self.bind = {
|
48
|
+
k: typing.cast(ObservableMixin, v)._to_observable_config()
|
49
|
+
if isinstance(v, ObservableMixin)
|
50
|
+
else v
|
51
|
+
for k, v in bindings.items()
|
52
|
+
}
|
53
|
+
|
54
|
+
def copy_with_extends(self, extends: typing.Dict):
|
55
|
+
raise NotImplementedError("VueEvent does not support extends")
|
56
|
+
|
57
|
+
def event_type(self):
|
58
|
+
return "vue"
|
59
|
+
|
60
|
+
def _to_json_dict(self):
|
61
|
+
data = super()._to_json_dict()
|
62
|
+
data["type"] = self.event_type()
|
63
|
+
return data
|
64
|
+
|
65
|
+
|
66
|
+
vue_event = VueEvent
|