instaui 0.1.4__py3-none-any.whl → 0.1.5__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/components/echarts/echarts.js +128 -0
- instaui/components/echarts/echarts.py +194 -0
- instaui/components/echarts/static/echarts.esm.min.js +45 -0
- instaui/components/element.py +50 -4
- instaui/components/html/__init__.py +30 -19
- instaui/components/html/_preset.py +4 -0
- instaui/components/html/heading.py +51 -0
- instaui/components/html/range.py +3 -0
- instaui/components/html/select.py +13 -31
- instaui/components/html/table.py +36 -0
- instaui/components/markdown/static/marked.esm.js +0 -1
- 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 +175 -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/value_element.py +7 -3
- instaui/consts.py +2 -1
- instaui/daisyui/__init__.py +8 -2
- instaui/daisyui/_index.py +5 -0
- instaui/daisyui/table.py +35 -0
- instaui/event/js_event.py +1 -0
- instaui/event/web_event.py +6 -7
- instaui/fastapi_server/server.py +4 -12
- instaui/handlers/event_handler.py +3 -1
- instaui/handlers/watch_handler.py +4 -0
- instaui/html_tools.py +40 -2
- instaui/runtime/_app.py +37 -3
- instaui/runtime/_link_manager.py +89 -0
- instaui/runtime/resource.py +19 -9
- instaui/shadcn_classless/_index.py +42 -0
- instaui/shadcn_classless/static/shadcn-classless.css +403 -0
- instaui/static/insta-ui.css +1 -1
- instaui/static/insta-ui.esm-browser.prod.js +1314 -1253
- instaui/static/insta-ui.js.map +1 -1
- instaui/static/instaui-tools-browser.js +511 -0
- instaui/static/templates/webview.html +78 -0
- instaui/tailwind/__init__.py +6 -0
- instaui/tailwind/_index.py +24 -0
- instaui/{static/tailwindcss.min.js → tailwind/static/tailwindcss-v3.min.js} +62 -62
- instaui/tailwind/static/tailwindcss-v4.min.js +8 -0
- instaui/template/_utils.py +23 -0
- instaui/template/webview_template.py +50 -0
- instaui/ui/__init__.py +8 -2
- instaui/ui/__init__.pyi +7 -1
- instaui/vars/event_context.py +4 -0
- instaui/vars/web_computed.py +30 -30
- instaui/watch/web_watch.py +5 -6
- instaui/webview/__init__.py +1 -0
- instaui/webview/_utils.py +8 -0
- instaui/webview/api.py +72 -0
- instaui/webview/func.py +114 -0
- instaui/webview/index.py +162 -0
- instaui/webview/resource.py +172 -0
- instaui/zero/func.py +19 -12
- instaui/zero/scope.py +46 -28
- {instaui-0.1.4.dist-info → instaui-0.1.5.dist-info}/METADATA +4 -1
- {instaui-0.1.4.dist-info → instaui-0.1.5.dist-info}/RECORD +67 -47
- instaui/components/highlight_code/code.js +0 -63
- instaui/components/highlight_code/code.py +0 -117
- instaui/components/highlight_code/static/core.min.js +0 -307
- instaui/components/highlight_code/static/languages/css.min.js +0 -31
- instaui/components/highlight_code/static/languages/javascript.min.js +0 -81
- instaui/components/highlight_code/static/languages/json.min.js +0 -8
- instaui/components/highlight_code/static/languages/python-repl.min.js +0 -5
- instaui/components/highlight_code/static/languages/python.min.js +0 -42
- instaui/components/highlight_code/static/languages/shell.min.js +0 -5
- instaui/components/highlight_code/static/styles/default.min.css +0 -9
- instaui/components/highlight_code/static/styles/github-dark-dimmed.min.css +0 -9
- instaui/components/highlight_code/static/styles/github-dark.min.css +0 -10
- instaui/components/highlight_code/static/styles/github.min.css +0 -10
- instaui/handlers/computed_handler.py +0 -42
- instaui/handlers/config_handler.py +0 -13
- {instaui-0.1.4.dist-info → instaui-0.1.5.dist-info}/LICENSE +0 -0
- {instaui-0.1.4.dist-info → instaui-0.1.5.dist-info}/WHEEL +0 -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\"}"))
|
@@ -11,6 +11,7 @@ from instaui import consts
|
|
11
11
|
|
12
12
|
from instaui.vars.types import TMaybeRef
|
13
13
|
from instaui.vars.web_computed import WebComputed
|
14
|
+
from instaui.ui_functions.ui_types import is_bindable
|
14
15
|
|
15
16
|
|
16
17
|
_T = TypeVar("_T")
|
@@ -28,10 +29,13 @@ class ValueElement(Element, Generic[_T]):
|
|
28
29
|
self.__is_html_component = is_html_component
|
29
30
|
|
30
31
|
if value is not None:
|
31
|
-
if
|
32
|
-
|
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)
|
33
37
|
else:
|
34
|
-
self.
|
38
|
+
self.props({value_name: value})
|
35
39
|
|
36
40
|
def vmodel(
|
37
41
|
self,
|
instaui/consts.py
CHANGED
@@ -13,8 +13,9 @@ APP_CSS_PATH = _STATIC_DIR.joinpath("insta-ui.css")
|
|
13
13
|
VUE_IIFE_JS_PATH = _STATIC_DIR.joinpath("vue.global.prod.js")
|
14
14
|
VUE_ES_JS_PATH = _STATIC_DIR.joinpath("vue.esm-browser.prod.js")
|
15
15
|
VUE_ES_RUNTIME_JS_PATH = _STATIC_DIR.joinpath("vue.runtime.esm-browser.prod.js")
|
16
|
-
TAILWIND_JS_PATH = _STATIC_DIR.joinpath("tailwindcss.min.js")
|
17
16
|
FAVICON_PATH = _STATIC_DIR.joinpath("insta-ui.ico")
|
17
|
+
# tools
|
18
|
+
TOOLS_BROWSER_JS_PATH = _STATIC_DIR.joinpath("instaui-tools-browser.js")
|
18
19
|
|
19
20
|
PAGE_TITLE = "insta-ui"
|
20
21
|
|
instaui/daisyui/__init__.py
CHANGED
@@ -12,9 +12,15 @@ Example usage:
|
|
12
12
|
dsui.checkbox(checked=True)
|
13
13
|
"""
|
14
14
|
|
15
|
-
__all__ = [
|
15
|
+
__all__ = [
|
16
|
+
"use",
|
17
|
+
"checkbox",
|
18
|
+
"button",
|
19
|
+
"table",
|
20
|
+
]
|
16
21
|
|
17
22
|
|
23
|
+
from ._index import use_daisyui as use
|
18
24
|
from .checkbox import Checkbox as checkbox
|
19
25
|
from .button import Button as button
|
20
|
-
from .
|
26
|
+
from .table import Table as table
|
instaui/daisyui/_index.py
CHANGED
@@ -7,6 +7,11 @@ _THEME_CSS = _STATIC_DIR / "themes.css"
|
|
7
7
|
|
8
8
|
|
9
9
|
def use_daisyui(value=True):
|
10
|
+
"""Enable or disable DaisyUI.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
value (bool, optional): Whether to enable or disable DaisyUI. Defaults to True.
|
14
|
+
"""
|
10
15
|
if value:
|
11
16
|
ui.add_css_link(_DAISYUI_CSS)
|
12
17
|
ui.add_css_link(_THEME_CSS)
|
instaui/daisyui/table.py
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
from typing import Any, List, Union
|
2
|
+
from instaui.components.element import Element
|
3
|
+
from instaui.components.element import Element
|
4
|
+
from instaui.components.content import Content
|
5
|
+
from instaui.components.vfor import VFor
|
6
|
+
from instaui.vars.types import TMaybeRef
|
7
|
+
|
8
|
+
|
9
|
+
class Table(Element):
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
columns: Union[List[str], TMaybeRef[List[str]], None] = None,
|
13
|
+
rows: Union[List[List[Any]], TMaybeRef[List[List[Any]]], None] = None,
|
14
|
+
):
|
15
|
+
"""Create a table element.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
columns (Union[List[str], ui_vars.TMaybeRef[List[str]], None], optional): A list of column headers or a reactive reference to such a list. Defaults to None.
|
19
|
+
rows (Union[List[List[Any]], ui_vars.TMaybeRef[List[List[Any]]], None], optional): A list of row data, where each row is a list of cell values, or a reactive reference to such a list. Defaults to None.
|
20
|
+
"""
|
21
|
+
super().__init__("table")
|
22
|
+
self.classes("table")
|
23
|
+
|
24
|
+
with self:
|
25
|
+
with Element("thead"), Element("tr"):
|
26
|
+
with VFor(columns) as col: # type: ignore
|
27
|
+
with Element("th"):
|
28
|
+
Content(col)
|
29
|
+
|
30
|
+
with Element("tbody"):
|
31
|
+
with VFor(rows) as row: # type: ignore
|
32
|
+
with Element("tr"):
|
33
|
+
with VFor(row) as cell: # type: ignore
|
34
|
+
with Element("td"):
|
35
|
+
Content(cell)
|
instaui/event/js_event.py
CHANGED
instaui/event/web_event.py
CHANGED
@@ -7,6 +7,8 @@ from instaui.vars.mixin_types.py_binding import CanInputMixin, CanOutputMixin
|
|
7
7
|
from instaui.handlers import event_handler
|
8
8
|
from .event_mixin import EventMixin
|
9
9
|
|
10
|
+
_SYNC_TYPE = "sync"
|
11
|
+
_ASYNC_TYPE = "async"
|
10
12
|
|
11
13
|
P = ParamSpec("P")
|
12
14
|
R = typing.TypeVar("R")
|
@@ -48,18 +50,15 @@ class WebEvent(Jsonable, EventMixin, typing.Generic[P, R]):
|
|
48
50
|
page_path=app.page_path, handler=self._fn
|
49
51
|
)
|
50
52
|
|
51
|
-
handler_path = (
|
52
|
-
event_handler.ASYNC_URL
|
53
|
-
if inspect.iscoroutinefunction(self._fn)
|
54
|
-
else event_handler.SYNC_URL
|
55
|
-
)
|
56
|
-
|
57
53
|
event_handler.register_event_handler(
|
58
54
|
hkey, self._fn, self._outputs, self._inputs
|
59
55
|
)
|
60
56
|
|
61
57
|
data = {}
|
62
|
-
data["
|
58
|
+
data["type"] = self.event_type()
|
59
|
+
data["fType"] = (
|
60
|
+
_ASYNC_TYPE if inspect.iscoroutinefunction(self._fn) else _SYNC_TYPE
|
61
|
+
)
|
63
62
|
data["hKey"] = hkey
|
64
63
|
data["sid"] = self._sid
|
65
64
|
|
instaui/fastapi_server/server.py
CHANGED
@@ -43,7 +43,6 @@ INSTAUI_STATIC_URL = f"/_instaui_{_INSTA_VERSION}/static"
|
|
43
43
|
VUE_JS_HASH_LINK = f"{INSTAUI_STATIC_URL}/{consts.VUE_ES_JS_PATH.name}"
|
44
44
|
INSTAUI_JS_HASH_LINK = f"{INSTAUI_STATIC_URL}/{consts.APP_ES_JS_PATH.name}"
|
45
45
|
APP_CSS_LINK = f"{INSTAUI_STATIC_URL}/{consts.APP_CSS_PATH.name}"
|
46
|
-
TAILWIND_JS_HASH_LINK = f"{INSTAUI_STATIC_URL}/{consts.TAILWIND_JS_PATH.name}"
|
47
46
|
FAVICON_LINK = f"{INSTAUI_STATIC_URL}/{consts.FAVICON_PATH.name}"
|
48
47
|
|
49
48
|
|
@@ -143,13 +142,6 @@ class Server:
|
|
143
142
|
or consts.PAGE_TITLE,
|
144
143
|
)
|
145
144
|
|
146
|
-
if html_resource.use_tailwind is None:
|
147
|
-
if default_html_resource.use_tailwind:
|
148
|
-
model.js_links.append(JsLink(TAILWIND_JS_HASH_LINK))
|
149
|
-
else:
|
150
|
-
if html_resource.use_tailwind:
|
151
|
-
model.js_links.append(JsLink(TAILWIND_JS_HASH_LINK))
|
152
|
-
|
153
145
|
# register custom components
|
154
146
|
for component in system_slot._component_dependencies:
|
155
147
|
if not component.esm:
|
@@ -192,8 +184,8 @@ class Server:
|
|
192
184
|
model.css_links.append(resource.record_resource(css_link))
|
193
185
|
|
194
186
|
# css file link to web static link
|
195
|
-
for link
|
196
|
-
|
187
|
+
for link in html_resource.get_valid_css_links(
|
188
|
+
default_html_resource._css_links_manager
|
197
189
|
):
|
198
190
|
if isinstance(link, Path):
|
199
191
|
model.css_links.append(resource.record_resource(link))
|
@@ -201,8 +193,8 @@ class Server:
|
|
201
193
|
model.css_links.append(link)
|
202
194
|
|
203
195
|
# js file link to web static link
|
204
|
-
for info in
|
205
|
-
|
196
|
+
for info in html_resource.get_valid_js_links(
|
197
|
+
default_html_resource._js_links_manager
|
206
198
|
):
|
207
199
|
link = (
|
208
200
|
resource.record_resource(info.link)
|
@@ -1,15 +1,17 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
import threading
|
3
3
|
from typing import Callable, Dict, Optional, Sequence, TYPE_CHECKING
|
4
|
-
from . import _utils
|
5
4
|
import ast
|
5
|
+
from . import _utils
|
6
6
|
from instaui.vars.event_context import DatasetEventContext
|
7
|
+
from instaui.runtime._app import update_web_server_info
|
7
8
|
|
8
9
|
if TYPE_CHECKING:
|
9
10
|
from instaui.vars.mixin_types.py_binding import CanOutputMixin, CanInputMixin
|
10
11
|
|
11
12
|
ASYNC_URL = "/instaui/event/async"
|
12
13
|
SYNC_URL = "/instaui/event/sync"
|
14
|
+
update_web_server_info(event_url=SYNC_URL, event_async_url=ASYNC_URL)
|
13
15
|
_event_handlers: Dict[str, _utils.HandlerInfo] = {}
|
14
16
|
dict_lock = threading.Lock()
|
15
17
|
|
@@ -9,12 +9,16 @@ from typing import (
|
|
9
9
|
from dataclasses import dataclass
|
10
10
|
|
11
11
|
from instaui.runtime.context import get_context
|
12
|
+
from instaui.runtime._app import update_web_server_info
|
12
13
|
from instaui.systems import func_system
|
13
14
|
from . import _utils
|
14
15
|
|
15
16
|
|
16
17
|
ASYNC_URL = "/instaui/watch/async"
|
17
18
|
SYNC_URL = "/instaui/watch/sync"
|
19
|
+
|
20
|
+
update_web_server_info(watch_url=SYNC_URL, watch_async_url=ASYNC_URL)
|
21
|
+
|
18
22
|
_watch_handlers: Dict[str, _utils.HandlerInfo] = {}
|
19
23
|
dict_lock = threading.Lock()
|
20
24
|
|
instaui/html_tools.py
CHANGED
@@ -3,13 +3,24 @@ from pathlib import Path
|
|
3
3
|
from typing import Any, Dict, Literal, Optional, Union
|
4
4
|
from instaui.common.jsonable import dumps, dumps2dict
|
5
5
|
from instaui.runtime._app import get_app_slot
|
6
|
+
from instaui.tailwind._index import use_tailwind
|
6
7
|
|
7
8
|
|
8
9
|
def add_css_link(href: Union[str, Path]):
|
10
|
+
"""Add a link to a CSS file to the HTML document.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
href (Union[str, Path]): The path to the CSS file.
|
14
|
+
"""
|
9
15
|
get_app_slot()._html_resource.add_css_link(href)
|
10
16
|
|
11
17
|
|
12
18
|
def remove_css_link(href: Union[str, Path]):
|
19
|
+
"""Remove a link to a CSS file from the HTML document.
|
20
|
+
|
21
|
+
Args:
|
22
|
+
href (Union[str, Path]): The path to the CSS file.
|
23
|
+
"""
|
13
24
|
get_app_slot()._html_resource.remove_css_link(href)
|
14
25
|
|
15
26
|
|
@@ -18,6 +29,13 @@ def add_js_link(
|
|
18
29
|
*,
|
19
30
|
type: Optional[Literal["module"]] = None,
|
20
31
|
):
|
32
|
+
"""Add a link to a JavaScript file to the HTML document.
|
33
|
+
|
34
|
+
Args:
|
35
|
+
link (Union[str, Path]): The path to the JavaScript file.
|
36
|
+
type (Optional[Literal["module"]], optional): The type of the JavaScript file. Defaults to None.
|
37
|
+
"""
|
38
|
+
|
21
39
|
attrs = {
|
22
40
|
"type": type,
|
23
41
|
}
|
@@ -26,22 +44,42 @@ def add_js_link(
|
|
26
44
|
|
27
45
|
|
28
46
|
def add_style(content: str):
|
47
|
+
"""Add a style tag to the HTML document.
|
48
|
+
|
49
|
+
Args:
|
50
|
+
content (str): The content of the style tag.
|
51
|
+
"""
|
29
52
|
get_app_slot()._html_resource.add_style_tag(content)
|
30
53
|
|
31
54
|
|
32
|
-
|
33
|
-
get_app_slot()._html_resource.use_tailwind = value
|
55
|
+
use_tailwind = use_tailwind
|
34
56
|
|
35
57
|
|
36
58
|
def use_page_title(title: str):
|
59
|
+
"""Set the title of the HTML document.
|
60
|
+
|
61
|
+
Args:
|
62
|
+
title (str): The title of the HTML document.
|
63
|
+
"""
|
37
64
|
get_app_slot()._html_resource.title = title
|
38
65
|
|
39
66
|
|
40
67
|
def use_favicon(favicon: Path):
|
68
|
+
"""Set the favicon of the HTML document.
|
69
|
+
|
70
|
+
Args:
|
71
|
+
favicon (Path): The path to the favicon.
|
72
|
+
"""
|
41
73
|
get_app_slot()._html_resource.favicon = favicon
|
42
74
|
|
43
75
|
|
44
76
|
def add_js_code(code: str, *, script_attrs: Optional[Dict[str, Any]] = None):
|
77
|
+
"""Add a script tag to the HTML document with the given JavaScript code.
|
78
|
+
|
79
|
+
Args:
|
80
|
+
code (str): The JavaScript code.
|
81
|
+
script_attrs (Optional[Dict[str, Any]], optional): The attributes of the script tag. Defaults to None.
|
82
|
+
"""
|
45
83
|
get_app_slot()._html_resource.add_script_tag(code, script_attrs=script_attrs)
|
46
84
|
|
47
85
|
|
instaui/runtime/_app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set
|
4
|
+
from typing_extensions import Unpack, TypedDict
|
4
5
|
from instaui.common.jsonable import Jsonable
|
5
6
|
from .resource import HtmlResource
|
6
7
|
from instaui.consts import _T_App_Mode
|
@@ -20,14 +21,16 @@ if TYPE_CHECKING:
|
|
20
21
|
|
21
22
|
class App(Jsonable):
|
22
23
|
_default_app_slot: ClassVar[Optional[App]] = None
|
24
|
+
_web_server_info: ClassVar[Optional[Dict]] = None
|
23
25
|
|
24
|
-
def __init__(self, *, mode: _T_App_Mode) -> None:
|
26
|
+
def __init__(self, *, mode: _T_App_Mode, meta: Optional[Dict] = None) -> None:
|
25
27
|
super().__init__()
|
26
28
|
self._scope_id_counter = 0
|
27
29
|
self._vfor_id_counter = 0
|
28
30
|
self._slot_id_counter = 0
|
29
31
|
self.mode: _T_App_Mode = mode
|
30
32
|
self.items: List[Component] = []
|
33
|
+
self.meta = meta
|
31
34
|
self._slots_stacks: List[Slot] = []
|
32
35
|
|
33
36
|
defalut_scope = self.create_scope()
|
@@ -35,6 +38,7 @@ class App(Jsonable):
|
|
35
38
|
self._scopes: List[Scope] = [defalut_scope]
|
36
39
|
self._html_resource = HtmlResource()
|
37
40
|
self._component_dependencies: Set[ComponentDependencyInfo] = set()
|
41
|
+
self._temp_component_dependencies: Dict[str, ComponentDependencyInfo] = {}
|
38
42
|
self._plugin_dependencies: Set[PluginDependencyInfo] = set()
|
39
43
|
|
40
44
|
self._page_path: Optional[str] = None
|
@@ -71,6 +75,17 @@ class App(Jsonable):
|
|
71
75
|
def reset_html_resource(self):
|
72
76
|
self._html_resource = HtmlResource()
|
73
77
|
|
78
|
+
def add_temp_component_dependency(self, dependency: ComponentDependencyInfo):
|
79
|
+
self._temp_component_dependencies[dependency.tag_name] = dependency
|
80
|
+
|
81
|
+
def get_temp_component_dependency(
|
82
|
+
self, tag_name: str, default: ComponentDependencyInfo
|
83
|
+
) -> ComponentDependencyInfo:
|
84
|
+
return self._temp_component_dependencies.get(tag_name, default)
|
85
|
+
|
86
|
+
def has_temp_component_dependency(self, tag_name: str):
|
87
|
+
return tag_name in self._temp_component_dependencies
|
88
|
+
|
74
89
|
def use_component_dependency(
|
75
90
|
self, dependency: ComponentDependencyInfo, *, replace=False
|
76
91
|
) -> None:
|
@@ -109,6 +124,9 @@ class App(Jsonable):
|
|
109
124
|
exclude_defaults=True, by_alias=True
|
110
125
|
)
|
111
126
|
|
127
|
+
if self._web_server_info is not None:
|
128
|
+
data["webInfo"] = self._web_server_info
|
129
|
+
|
112
130
|
return data
|
113
131
|
|
114
132
|
@classmethod
|
@@ -181,8 +199,8 @@ def pop_slot():
|
|
181
199
|
get_slot_stacks().pop()
|
182
200
|
|
183
201
|
|
184
|
-
def new_app_slot(mode: _T_App_Mode):
|
185
|
-
return _app_var.set(App(mode=mode))
|
202
|
+
def new_app_slot(mode: _T_App_Mode, app_meta: Optional[Dict] = None):
|
203
|
+
return _app_var.set(App(mode=mode, meta=app_meta))
|
186
204
|
|
187
205
|
|
188
206
|
def reset_app_slot(token: Token[App]):
|
@@ -198,3 +216,19 @@ def check_default_app_slot_or_error(
|
|
198
216
|
):
|
199
217
|
if isinstance(get_app_slot(), DefaultApp):
|
200
218
|
raise ValueError(error_message)
|
219
|
+
|
220
|
+
|
221
|
+
class TWebServerInfo(TypedDict, total=False):
|
222
|
+
watch_url: Optional[str]
|
223
|
+
watch_async_url: Optional[str]
|
224
|
+
event_url: Optional[str]
|
225
|
+
event_async_url: Optional[str]
|
226
|
+
|
227
|
+
|
228
|
+
def update_web_server_info(**kwargs: Unpack[TWebServerInfo]):
|
229
|
+
if App._web_server_info is None:
|
230
|
+
App._web_server_info = {}
|
231
|
+
|
232
|
+
data = {k: v for k, v in kwargs.items() if v is not None}
|
233
|
+
|
234
|
+
App._web_server_info.update(data)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import (
|
3
|
+
Callable,
|
4
|
+
Dict,
|
5
|
+
Generic,
|
6
|
+
List,
|
7
|
+
Literal,
|
8
|
+
Optional,
|
9
|
+
Tuple,
|
10
|
+
TypeVar,
|
11
|
+
Hashable,
|
12
|
+
)
|
13
|
+
|
14
|
+
_TLinkActionObj = TypeVar("_TLinkActionObj")
|
15
|
+
|
16
|
+
_DEFAULT_KEY_FN = lambda x: x # noqa: E731
|
17
|
+
|
18
|
+
|
19
|
+
class LinkManager(Generic[_TLinkActionObj]):
|
20
|
+
def __init__(
|
21
|
+
self, key_fn: Optional[Callable[[_TLinkActionObj], Hashable]] = None
|
22
|
+
) -> None:
|
23
|
+
self._key_fn = key_fn or _DEFAULT_KEY_FN
|
24
|
+
self._actions_map: Dict[
|
25
|
+
Tuple[Literal["add", "remove"], Hashable], _TLinkActionObj
|
26
|
+
] = {}
|
27
|
+
|
28
|
+
def add_link(
|
29
|
+
self,
|
30
|
+
obj: _TLinkActionObj,
|
31
|
+
):
|
32
|
+
key = ("add", self._key_fn(obj))
|
33
|
+
self._actions_map[key] = obj
|
34
|
+
|
35
|
+
def remove_link(
|
36
|
+
self,
|
37
|
+
obj: _TLinkActionObj,
|
38
|
+
):
|
39
|
+
key = ("remove", self._key_fn(obj))
|
40
|
+
self._actions_map[key] = obj
|
41
|
+
|
42
|
+
def get_valid_links(
|
43
|
+
self, secondary_manager: Optional[LinkManager] = None
|
44
|
+
) -> List[_TLinkActionObj]:
|
45
|
+
secondary_maps = secondary_manager._actions_map if secondary_manager else {}
|
46
|
+
merger_map = {**secondary_maps, **self._actions_map}
|
47
|
+
|
48
|
+
result = {}
|
49
|
+
|
50
|
+
for (action, key), obj in merger_map.items():
|
51
|
+
if action == "add":
|
52
|
+
result[key] = obj
|
53
|
+
continue
|
54
|
+
|
55
|
+
if key in result:
|
56
|
+
del result[key]
|
57
|
+
|
58
|
+
return list(result.values())
|
59
|
+
|
60
|
+
|
61
|
+
if __name__ == "__main__":
|
62
|
+
|
63
|
+
def test_baes():
|
64
|
+
manager: LinkManager[str] = LinkManager()
|
65
|
+
manager.add_link("a")
|
66
|
+
manager.add_link("b")
|
67
|
+
manager.add_link("c")
|
68
|
+
manager.remove_link("b")
|
69
|
+
|
70
|
+
assert manager.get_valid_links() == ["a", "c"]
|
71
|
+
|
72
|
+
test_baes()
|
73
|
+
|
74
|
+
def test_with_other():
|
75
|
+
other: LinkManager[str] = LinkManager()
|
76
|
+
other.add_link("a")
|
77
|
+
other.add_link("b")
|
78
|
+
other.add_link("c")
|
79
|
+
|
80
|
+
manager1: LinkManager[str] = LinkManager()
|
81
|
+
manager1.add_link("b")
|
82
|
+
manager1.add_link("d")
|
83
|
+
manager1.add_link("e")
|
84
|
+
manager1.remove_link("a")
|
85
|
+
manager1.remove_link("b")
|
86
|
+
|
87
|
+
assert manager1.get_valid_links(other) == ["c", "d", "e"]
|
88
|
+
|
89
|
+
test_with_other()
|
instaui/runtime/resource.py
CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
from pathlib import Path
|
3
3
|
from typing import Any, Dict, List, Optional, Set, Union
|
4
4
|
from .dataclass import JsLink, VueAppUse, VueAppComponent
|
5
|
+
from ._link_manager import LinkManager
|
5
6
|
|
6
7
|
|
7
8
|
class HtmlResource:
|
@@ -10,9 +11,11 @@ class HtmlResource:
|
|
10
11
|
favicon: Optional[Path] = None
|
11
12
|
|
12
13
|
def __init__(self) -> None:
|
13
|
-
self.
|
14
|
+
self._css_links_manager: LinkManager[Union[str, Path]] = LinkManager()
|
14
15
|
self._style_tags: List[str] = []
|
15
|
-
self.
|
16
|
+
self._js_links_manager: LinkManager[JsLink] = LinkManager(
|
17
|
+
key_fn=lambda js_link: js_link.link
|
18
|
+
)
|
16
19
|
self._script_tags: List[str] = []
|
17
20
|
self._vue_app_use: Set[VueAppUse] = set()
|
18
21
|
self._vue_app_components: Set[VueAppComponent] = set()
|
@@ -20,10 +23,10 @@ class HtmlResource:
|
|
20
23
|
self._appConfig = "{}"
|
21
24
|
|
22
25
|
def add_css_link(self, link: Union[str, Path]):
|
23
|
-
self.
|
26
|
+
self._css_links_manager.add_link(link)
|
24
27
|
|
25
28
|
def remove_css_link(self, link: Union[str, Path]):
|
26
|
-
self.
|
29
|
+
self._css_links_manager.remove_link(link)
|
27
30
|
|
28
31
|
def add_style_tag(self, content: str):
|
29
32
|
self._style_tags.append(content)
|
@@ -33,12 +36,19 @@ class HtmlResource:
|
|
33
36
|
link: Union[str, Path],
|
34
37
|
*,
|
35
38
|
attrs: Optional[Dict[str, Any]] = None,
|
36
|
-
insert_before: int = -1,
|
37
39
|
):
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
self.
|
40
|
+
self._js_links_manager.add_link(JsLink(link, attrs or {}))
|
41
|
+
|
42
|
+
def remove_js_link(self, link: Union[str, Path]):
|
43
|
+
self._js_links_manager.remove_link(JsLink(link))
|
44
|
+
|
45
|
+
def get_valid_js_links(self, default_js_links_manager: LinkManager) -> List[JsLink]:
|
46
|
+
return self._js_links_manager.get_valid_links(default_js_links_manager)
|
47
|
+
|
48
|
+
def get_valid_css_links(
|
49
|
+
self, default_css_links_manager: LinkManager[Union[str, Path]]
|
50
|
+
) -> List[Union[str, Path]]:
|
51
|
+
return self._css_links_manager.get_valid_links(default_css_links_manager)
|
42
52
|
|
43
53
|
def add_script_tag(
|
44
54
|
self, content: str, script_attrs: Optional[Dict[str, Any]] = None
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from instaui.runtime._app import get_app_slot
|
3
|
+
|
4
|
+
|
5
|
+
_STATIC_DIR = Path(__file__).parent / "static"
|
6
|
+
_CSS_FILE = _STATIC_DIR / "shadcn-classless.css"
|
7
|
+
|
8
|
+
|
9
|
+
def use_shadcn_classless(value=True):
|
10
|
+
"""Use shadcn-classless.css or not.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
value (bool, optional): Whether to use shadcn-classless.css or not. Defaults to True.
|
14
|
+
|
15
|
+
Example:
|
16
|
+
|
17
|
+
App default use shadcn-classless.css:
|
18
|
+
.. code-block:: python
|
19
|
+
|
20
|
+
@ui.page('/')
|
21
|
+
def index():
|
22
|
+
|
23
|
+
# Create a container with shadcn-classless class
|
24
|
+
with html.div().classes("shadcn-classless"):
|
25
|
+
html.h1("Hello, world!")
|
26
|
+
|
27
|
+
with html.form():
|
28
|
+
html.input()
|
29
|
+
html.button("Submit")
|
30
|
+
|
31
|
+
Can be disabled:
|
32
|
+
.. code-block:: python
|
33
|
+
# App does not use shadcn-classless
|
34
|
+
ui.use_shadcn_classless(False)
|
35
|
+
|
36
|
+
"""
|
37
|
+
|
38
|
+
if value:
|
39
|
+
get_app_slot()._html_resource.add_css_link(_CSS_FILE)
|
40
|
+
|
41
|
+
else:
|
42
|
+
get_app_slot()._html_resource.remove_css_link(_CSS_FILE)
|