@metamorph-labs/polymorph 1.0.18 → 1.0.19
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.
- package/CHANGELOG.md +242 -0
- package/dist/design/systems/desktop.json +1 -1
- package/dist/design/systems/dew.json +1 -1
- package/dist/design/systems/flint.json +1 -1
- package/dist/design/systems/glassmorphic.json +1 -1
- package/dist/design/systems/harbor.json +1 -1
- package/dist/design/systems/journal.json +1 -1
- package/dist/design/systems/pastel.json +1 -1
- package/dist/design/systems/pebble.json +1 -1
- package/dist/design/systems/plain.json +1 -1
- package/dist/design/systems/pop.json +1 -1
- package/dist/design/systems/press.json +1 -1
- package/dist/packages/angular-ui/src/ai/ArtifactPane.ts +15 -4
- package/dist/packages/angular-ui/src/ai/PromptInput.ts +3 -1
- package/dist/packages/angular-ui/src/archetypes/Dashboard.ts +38 -20
- package/dist/packages/angular-ui/src/archetypes/dashboard.states.ts +52 -0
- package/dist/packages/angular-ui/src/controls/ColorInput.ts +62 -34
- package/dist/packages/angular-ui/src/controls/Combobox.ts +28 -7
- package/dist/packages/angular-ui/src/controls/DatePicker.ts +12 -11
- package/dist/packages/angular-ui/src/controls/DateRangePicker.ts +22 -17
- package/dist/packages/angular-ui/src/controls/DateRangePickerRangeCalendar.ts +3 -2
- package/dist/packages/angular-ui/src/controls/FileUpload.ts +18 -12
- package/dist/packages/angular-ui/src/controls/FileUploadRow.ts +24 -4
- package/dist/packages/angular-ui/src/controls/MultiSelect.ts +49 -12
- package/dist/packages/angular-ui/src/controls/NumberInput.ts +27 -3
- package/dist/packages/angular-ui/src/controls/PhoneInput.ts +9 -5
- package/dist/packages/angular-ui/src/controls/Select.ts +36 -7
- package/dist/packages/angular-ui/src/controls/TagInput.ts +61 -7
- package/dist/packages/angular-ui/src/controls/TimeInput.ts +15 -1
- package/dist/packages/angular-ui/src/controls/select.states.ts +79 -58
- package/dist/packages/angular-ui/src/overlays/Command.ts +50 -13
- package/dist/packages/angular-ui/src/overlays/CommandPanel.ts +11 -7
- package/dist/packages/angular-ui/src/overlays/ToastViewport.ts +1 -1
- package/dist/packages/angular-ui/src/structure/CodeBlock.ts +18 -4
- package/dist/packages/angular-ui/src/structure/Stat.ts +295 -84
- package/dist/packages/angular-ui/src/structure/stat.states.ts +116 -0
- package/dist/packages/cli/src/agents.js +4 -3
- package/dist/packages/cli/src/apply.js +43 -18
- package/dist/packages/cli/src/check.js +4 -0
- package/dist/packages/cli/src/cli.js +6 -2
- package/dist/packages/cli/src/elements.js +12 -2
- package/dist/packages/cli/src/emit.js +43 -8
- package/dist/packages/cli/src/readings.js +29 -3
- package/dist/packages/cli/src/skills/bridge.js +1197 -0
- package/dist/packages/cli/src/skills/facts.js +190 -0
- package/dist/packages/cli/src/skills/native.js +1580 -0
- package/dist/packages/cli/src/skills/rules.js +199 -0
- package/dist/packages/cli/src/skills/runtime.js +1020 -0
- package/dist/packages/cli/src/skills/screen-charts.js +334 -0
- package/dist/packages/cli/src/skills/screen-chat.js +247 -0
- package/dist/packages/cli/src/skills/screen-code.js +565 -0
- package/dist/packages/cli/src/skills/screen-rich-text.js +305 -0
- package/dist/packages/cli/src/skills/screen.js +378 -0
- package/dist/packages/cli/src/skills/setup-packages.js +307 -0
- package/dist/packages/cli/src/skills/setup.js +125 -0
- package/dist/packages/cli/src/skills/theme-documents.js +351 -0
- package/dist/packages/cli/src/skills/theme.js +208 -0
- package/dist/packages/cli/src/skills.js +13 -794
- package/dist/packages/cli/src/theme.js +42 -1
- package/dist/packages/cli/src/tool-verbs.js +19 -4
- package/dist/packages/cli/src/verbs.js +28 -2
- package/dist/packages/elements-ui/dist/cdn/chunks/{AppShellUserCard-0eCCnnN_.js → AppShellUserCard-XT4br4fr.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AreaChart-DftfzLG0.js → AreaChart-CXNFfbJ8.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-Pr9_K2uM.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcdMgxgY.js → Avatar-3WXoBPLv.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcuvZwe7.js → Avatar-BKqjM8qW.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarButton-D5XKVduu.js → AvatarButton-BasMQCSM.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarGroup-DgFwJUNO.js → AvatarGroup-COch2-O0.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{BarChart-myuR0aHc.js → BarChart-ugae8zfr.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ChatMessage-CgQ1h_JP.js → ChatMessage-Bx4yrF2x.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-B_e5ma3K.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-Fgtr48Vb.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-CD7rsWRp.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-CUw7z6TS.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Combobox-DB2FT7so.js → Combobox-hWIFU9X_.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Command-BXgqRd3I.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{ConfirmDialog-BtQOAHY2.js → ConfirmDialog-CAaBRKxl.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Dashboard-ChMPH4_Q.js → Dashboard-DwNw5Wnd.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-DjqtswQR.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-LsXFHOzm.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{DonutChart-BEK89BeL.js → DonutChart-DYXx6eTe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-3gbZTSSx.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-PlLLDKqc.js → FormField-Bvw4cLBc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-C6L3vYp4.js → FormField-DzhcinED.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{FunnelChart-DVQz_gad.js → FunnelChart-D24XhrGw.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-fAcu6Vrw.js → Heading-Cvfyu8pc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-CgzEi9OQ.js → Heading-XDJzlwt9.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Heatmap-BRwR-n-V.js → Heatmap-BQoUS6gY.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Hero-CV2YWeb4.js → Hero-CXuuFceS.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Histogram-CCYwlinB.js → Histogram-DW_ZPHpR.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{LineChart-BH6Pq1P1.js → LineChart-kf-zlNWe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Markdown-DmZEch4i.js → Markdown-C3rjhIbt.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-DQ86CK9h.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-DbSx9QtV.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-B4ZZOGLl.js +7 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-BsMfbNi6.js +210 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-l_-zAXSZ.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{RadarChart-Coje7Sb0.js → RadarChart-CwJAWRki.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextContent-CufjptHF.js → RichTextContent-D51UfuWk.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextInput-Dz7yBFUA.js → RichTextInput-B32fN_p9.js} +3 -3
- package/dist/packages/elements-ui/dist/cdn/chunks/{ScatterChart-Do5tQTC5.js → ScatterChart-Mps7l5-i.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Select-CpsRP0NR.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-CXR6bP7X.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-DGcx2ZZq.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-BhkLU4gE.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-r2jNTOLN.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{Toast-CAYGbn7g.js → Toast-BTfcZn0I.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ToastViewport-CFslglYc.js → ToastViewport-BBQMRCQT.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{ToolCall-DUCoKsoE.js → ToolCall-DNU5kk9_.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{Treemap-Bh3ruYGJ.js → Treemap-BV8TlZHB.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/agent-DfOqpL9c.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/api-DJBiUXxK.js +4 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-D4YdFevY.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/cap-DA71oFHt.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/{cartesian-I5uPfyqv.js → cartesian-CEn2lJCc.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/{chart-annotations.module-xUExw4pu.js → chart-annotations.module-hA_KO_Pe.js} +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-C_8txUW5.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-BpfyTQ9R.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/check-CHvc4yHL.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/css-vars-DeZ4TCna.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/draw-BiQ3Of6N.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/drawing-nhJNBahV.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/field-labels-Df5HuYC5.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/frame-CtTY4oCn.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/on-call-YKLF3-FH.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/runtime-QRQ3CjZg.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/series-uUg6_JtL.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/src-XnWjGSDr.js +67 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/toast-pwGvxH2T.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/urls-Qks0KJ_p.js +6 -0
- package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-Dro53ATH.js +1 -0
- package/dist/packages/elements-ui/dist/cdn/polymorph-all.js +52 -50
- package/dist/packages/elements-ui/dist/cdn/polymorph.css +1 -1
- package/dist/packages/elements-ui/dist/cdn/polymorph.js +1 -1
- package/dist/packages/elements-ui/dist/cdn/prepaint.js +1 -1
- package/dist/packages/elements-ui/dist/cdn/themes/desktop.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/dew.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/flint.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/glassmorphic.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/harbor.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/journal.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pastel.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pebble.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/plain.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/pop.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/press.css +5 -4
- package/dist/packages/elements-ui/dist/cdn/themes/terminal.css +5 -4
- package/dist/packages/elements-ui/src/ai/ArtifactPane.ts +2 -0
- package/dist/packages/elements-ui/src/archetypes/dashboard.states.ts +9 -0
- package/dist/packages/elements-ui/src/controls/ColorInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/NumberInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/TagInput.ts +4 -0
- package/dist/packages/elements-ui/src/controls/TimeInput.ts +2 -0
- package/dist/packages/elements-ui/src/controls/select.states.ts +10 -0
- package/dist/packages/elements-ui/src/overlays/Command.ts +2 -0
- package/dist/packages/elements-ui/src/structure/CodeBlock.ts +5 -2
- package/dist/packages/elements-ui/src/structure/Stat.ts +6 -0
- package/dist/packages/elements-ui/src/structure/stat.states.ts +33 -0
- package/dist/packages/mcp/src/propose.js +92 -15
- package/dist/packages/mcp/src/server.js +19 -8
- package/dist/packages/mcp/src/tools.js +80 -5
- package/dist/packages/mcp/src/write.js +95 -13
- package/dist/packages/react-ui/src/ai/ArtifactPane.tsx +5 -2
- package/dist/packages/react-ui/src/ai/PromptInput.tsx +5 -2
- package/dist/packages/react-ui/src/archetypes/dashboard.states.tsx +28 -0
- package/dist/packages/react-ui/src/controls/ColorInput.tsx +69 -13
- package/dist/packages/react-ui/src/controls/Combobox.tsx +13 -5
- package/dist/packages/react-ui/src/controls/DatePicker.tsx +3 -0
- package/dist/packages/react-ui/src/controls/DateRangePicker.tsx +22 -5
- package/dist/packages/react-ui/src/controls/FileUpload.tsx +2 -0
- package/dist/packages/react-ui/src/controls/MultiSelect.tsx +30 -6
- package/dist/packages/react-ui/src/controls/NumberInput.tsx +19 -1
- package/dist/packages/react-ui/src/controls/PhoneInput.tsx +3 -3
- package/dist/packages/react-ui/src/controls/Select.tsx +59 -23
- package/dist/packages/react-ui/src/controls/TagInput.tsx +43 -10
- package/dist/packages/react-ui/src/controls/TimeInput.tsx +10 -0
- package/dist/packages/react-ui/src/controls/date-segments.tsx +16 -0
- package/dist/packages/react-ui/src/controls/select.states.tsx +13 -0
- package/dist/packages/react-ui/src/overlays/Command.tsx +23 -2
- package/dist/packages/react-ui/src/overlays/Toaster.tsx +2 -2
- package/dist/packages/react-ui/src/structure/CodeBlock.tsx +7 -3
- package/dist/packages/react-ui/src/structure/Stat.tsx +90 -13
- package/dist/packages/react-ui/src/structure/stat.states.tsx +68 -0
- package/dist/packages/recipes/src/ai/artifact-pane.module.css +4 -4
- package/dist/packages/recipes/src/controls/rich-text-input.module.css +1 -1
- package/dist/packages/recipes/src/structure/avatar.module.css +3 -1
- package/dist/packages/recipes/src/structure/heading.module.css +5 -4
- package/dist/packages/recipes/src/structure/hero.module.css +3 -1
- package/dist/packages/recipes/src/structure/stat.module.css +7 -0
- package/dist/packages/registry/src/card.js +4 -3
- package/dist/packages/registry/src/frameworks.js +28 -1
- package/dist/packages/registry/src/runtime-card.js +300 -0
- package/dist/packages/registry/src/runtime-members.js +176 -0
- package/dist/packages/registry/src/screen-table.js +166 -0
- package/dist/packages/rules/package.js +1 -1
- package/dist/packages/solid-ui/src/ai/ArtifactPane.tsx +11 -3
- package/dist/packages/solid-ui/src/ai/PromptInput.tsx +3 -1
- package/dist/packages/solid-ui/src/archetypes/Dashboard.tsx +3 -0
- package/dist/packages/solid-ui/src/archetypes/dashboard.states.tsx +39 -0
- package/dist/packages/solid-ui/src/controls/ColorInput.tsx +38 -17
- package/dist/packages/solid-ui/src/controls/Combobox.tsx +27 -6
- package/dist/packages/solid-ui/src/controls/DatePicker.tsx +12 -11
- package/dist/packages/solid-ui/src/controls/DateRangePicker.tsx +21 -16
- package/dist/packages/solid-ui/src/controls/DateRangePickerRangeCalendar.tsx +3 -4
- package/dist/packages/solid-ui/src/controls/FileUpload.tsx +1 -0
- package/dist/packages/solid-ui/src/controls/FileUploadRow.tsx +6 -0
- package/dist/packages/solid-ui/src/controls/MultiSelect.tsx +51 -11
- package/dist/packages/solid-ui/src/controls/NumberInput.tsx +21 -2
- package/dist/packages/solid-ui/src/controls/PhoneInput.tsx +8 -4
- package/dist/packages/solid-ui/src/controls/Select.tsx +37 -6
- package/dist/packages/solid-ui/src/controls/TagInput.tsx +26 -5
- package/dist/packages/solid-ui/src/controls/TimeInput.tsx +10 -1
- package/dist/packages/solid-ui/src/controls/select.states.tsx +18 -0
- package/dist/packages/solid-ui/src/overlays/Command.tsx +15 -2
- package/dist/packages/solid-ui/src/overlays/CommandPanel.tsx +7 -7
- package/dist/packages/solid-ui/src/overlays/ToastViewport.tsx +1 -1
- package/dist/packages/solid-ui/src/structure/CodeBlock.tsx +9 -5
- package/dist/packages/solid-ui/src/structure/Stat.tsx +86 -25
- package/dist/packages/solid-ui/src/structure/stat.states.tsx +73 -0
- package/dist/packages/svelte-ui/src/ai/ArtifactPane.svelte +8 -2
- package/dist/packages/svelte-ui/src/ai/PromptInput.svelte +3 -1
- package/dist/packages/svelte-ui/src/archetypes/Dashboard.svelte +3 -0
- package/dist/packages/svelte-ui/src/archetypes/dashboard.states.svelte +2 -0
- package/dist/packages/svelte-ui/src/controls/ColorInput.svelte +29 -8
- package/dist/packages/svelte-ui/src/controls/Combobox.svelte +26 -5
- package/dist/packages/svelte-ui/src/controls/DatePicker.svelte +7 -5
- package/dist/packages/svelte-ui/src/controls/DateRangePicker.svelte +15 -9
- package/dist/packages/svelte-ui/src/controls/DateRangePickerRangeCalendar.svelte +3 -2
- package/dist/packages/svelte-ui/src/controls/FileUpload.svelte +1 -0
- package/dist/packages/svelte-ui/src/controls/FileUploadRow.svelte +8 -1
- package/dist/packages/svelte-ui/src/controls/MultiSelect.svelte +36 -10
- package/dist/packages/svelte-ui/src/controls/NumberInput.svelte +14 -1
- package/dist/packages/svelte-ui/src/controls/PhoneInput.svelte +3 -3
- package/dist/packages/svelte-ui/src/controls/Select.svelte +20 -6
- package/dist/packages/svelte-ui/src/controls/TagInput.svelte +21 -3
- package/dist/packages/svelte-ui/src/controls/TimeInput.svelte +11 -1
- package/dist/packages/svelte-ui/src/controls/select.states.svelte +26 -24
- package/dist/packages/svelte-ui/src/overlays/Command.svelte +13 -1
- package/dist/packages/svelte-ui/src/overlays/CommandPanel.svelte +11 -6
- package/dist/packages/svelte-ui/src/overlays/ToastViewport.svelte +1 -1
- package/dist/packages/svelte-ui/src/structure/CodeBlock.svelte +7 -2
- package/dist/packages/svelte-ui/src/structure/Stat.svelte +70 -17
- package/dist/packages/svelte-ui/src/structure/stat.states.svelte +27 -0
- package/dist/packages/theme/src/admit.js +6 -3
- package/dist/packages/theme/src/color/resolve.js +19 -2
- package/dist/packages/theme/src/derive.js +13 -6
- package/dist/packages/theme/src/emit.js +1 -1
- package/dist/packages/theme/src/runtime.js +58 -0
- package/dist/packages/theme/src/seeds.js +30 -4
- package/dist/packages/theme/src/systems.js +1 -1
- package/dist/packages/theme/src/tokens.js +15 -6
- package/dist/packages/vue-ui/src/ai/ArtifactPane.vue +11 -2
- package/dist/packages/vue-ui/src/ai/PromptInput.vue +3 -1
- package/dist/packages/vue-ui/src/archetypes/Dashboard.vue +3 -0
- package/dist/packages/vue-ui/src/archetypes/dashboard.states.ts +49 -0
- package/dist/packages/vue-ui/src/controls/ColorInput.vue +33 -12
- package/dist/packages/vue-ui/src/controls/Combobox.vue +26 -5
- package/dist/packages/vue-ui/src/controls/DatePicker.vue +12 -11
- package/dist/packages/vue-ui/src/controls/DateRangePicker.vue +20 -15
- package/dist/packages/vue-ui/src/controls/DateRangePickerRangeCalendar.vue +3 -4
- package/dist/packages/vue-ui/src/controls/FileUpload.vue +1 -0
- package/dist/packages/vue-ui/src/controls/FileUploadRow.vue +6 -0
- package/dist/packages/vue-ui/src/controls/MultiSelect.vue +37 -10
- package/dist/packages/vue-ui/src/controls/NumberInput.vue +17 -1
- package/dist/packages/vue-ui/src/controls/PhoneInput.vue +7 -3
- package/dist/packages/vue-ui/src/controls/Select.vue +22 -7
- package/dist/packages/vue-ui/src/controls/TagInput.vue +21 -3
- package/dist/packages/vue-ui/src/controls/TimeInput.vue +10 -1
- package/dist/packages/vue-ui/src/controls/select.states.ts +17 -0
- package/dist/packages/vue-ui/src/overlays/Command.vue +13 -1
- package/dist/packages/vue-ui/src/overlays/CommandPanel.vue +7 -7
- package/dist/packages/vue-ui/src/overlays/ToastViewport.vue +1 -1
- package/dist/packages/vue-ui/src/structure/CodeBlock.vue +7 -2
- package/dist/packages/vue-ui/src/structure/Stat.vue +71 -18
- package/dist/packages/vue-ui/src/structure/stat.states.ts +67 -0
- package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Contracts.kt +144 -33
- package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Members.kt +17 -7
- package/dist/platforms/ios/Sources/PolymorphUI/Generated/Contracts.swift +204 -31
- package/dist/registry/registry.json +371 -75
- package/dist/screen/assets/{screen-CuQbskb8.css → screen-B22PTPwF.css} +1 -1
- package/dist/screen/assets/screen-Cpbh7XMb.js +372 -0
- package/dist/screen/screen.html +3 -3
- package/package.json +1 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-DsmRlr6d.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-BqP8HZKM.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-D8VARz0a.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-BrzZOVeL.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-BiUq0h-w.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Command-hmxVRdFg.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-C8prGbJ2.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-CO1ioqwN.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-HPQe-ttb.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-CerqbGv3.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-CQq7jPgI.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-Dre9GwBy.js +0 -7
- package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-D6_J6Es_.js +0 -210
- package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-BXcsUQ5W.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Select-DxGQgv2q.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-FsMUWigK.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/Stat-WS8v6BQv.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-D-uIQEGS.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-Dho571vA.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/agent-DBDk4wLH.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/api-B9sGZiYn.js +0 -4
- package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-CQwnWhWo.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/cap-Ct4k7zNC.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-DycBfben.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-Cks7VwS5.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/check-dOfCSYFA.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/draw-DclRgiWM.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/drawing-DjkZr0z8.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/frame-BSvl4y47.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/on-call-Jk1sYJc_.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/receivers-BpRfF6dV.js +0 -4
- package/dist/packages/elements-ui/dist/cdn/chunks/series-C_1TNd2n.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/src-Bub3C9YP.js +0 -67
- package/dist/packages/elements-ui/dist/cdn/chunks/toast-AarMGYJn.js +0 -1
- package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-eEPzSqph.js +0 -1
- package/dist/screen/assets/screen-Clj2u6_s.js +0 -372
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { Facts, all, commands } from "./facts.js";
|
|
2
|
+
//#region ../cli/src/skills/screen-code.ts
|
|
3
|
+
/**
|
|
4
|
+
* Two references of the screen skill, for a model that writes a screen in a framework's own code
|
|
5
|
+
* in a consumer's app.
|
|
6
|
+
*
|
|
7
|
+
* `code.md` is the procedure for the file itself: the import line in each framework and route,
|
|
8
|
+
* one screen in React and what differs in Vue, Svelte, Solid, Angular and an elements page, and
|
|
9
|
+
* the container that renders an emitted spec. `app.md` is what surrounds the screen: what the
|
|
10
|
+
* app's root mounts, forms, feedback and overlays, and navigation.
|
|
11
|
+
*
|
|
12
|
+
* The laws hold the names in these texts, not the code. Each example compiles against the
|
|
13
|
+
* vocabulary with its framework's own checker (`tsc`, `vue-tsc`, `svelte-check`, `ngc` with strict
|
|
14
|
+
* templates) and passes `validate`, and the React ones run in a browser; no suite runs them again,
|
|
15
|
+
* so an example changed here is checked again by hand. The elements markup follows the elements'
|
|
16
|
+
* states fixtures and the page the static-page check loads.
|
|
17
|
+
*/
|
|
18
|
+
function codeReference(registry, run) {
|
|
19
|
+
const f = new Facts(registry);
|
|
20
|
+
return `
|
|
21
|
+
# A screen in code, and the container of an emitted one
|
|
22
|
+
|
|
23
|
+
A screen written in code imports members, holds the screen's state and binds content to the
|
|
24
|
+
members' props. A container is such a file around a component \`emit\` wrote from a spec. The
|
|
25
|
+
examples are React, then what differs elsewhere. Read every member you use first:
|
|
26
|
+
|
|
27
|
+
${commands(run, "component DataTable --framework <framework>")}
|
|
28
|
+
|
|
29
|
+
## 1. Import the members
|
|
30
|
+
|
|
31
|
+
| Framework | An app that installs the packages | An app that vendors the members |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| \`react\` | \`import { Button } from '@polymorph/react-ui'\` | \`import { Button } from './polymorph/controls/Button'\` |
|
|
34
|
+
| \`vue\` | \`import { Button } from '@polymorph/vue-ui'\` | \`import Button from './polymorph/controls/Button.vue'\` |
|
|
35
|
+
| \`svelte\` | \`import { Button } from '@polymorph/svelte-ui'\` | \`import Button from './polymorph/controls/Button.svelte'\` |
|
|
36
|
+
| \`solid\` | \`import { Button } from '@polymorph/solid-ui'\` | \`import Button from './polymorph/controls/Button'\` |
|
|
37
|
+
| \`angular\` | \`import { Button } from '@polymorph/angular-ui'\`, the class in the component's \`imports\` | \`import { Button } from './polymorph/controls/Button'\`, the same |
|
|
38
|
+
|
|
39
|
+
- A vendored member is \`<dir>/<tier>/<Member>\` with the framework's extension, under the \`dir\`
|
|
40
|
+
\`polymorph.json\` names (\`src/polymorph/\` by default), imported by a path relative to your file.
|
|
41
|
+
In Vue, Svelte and Solid a vendored part is a file of its own (\`TabsContent.vue\`), written by
|
|
42
|
+
that name: only the package's index makes it ${f.part("Tabs", "Content")}.
|
|
43
|
+
- ${f.m("Icon")} is in every vocabulary package. A project that vendors imports it from the
|
|
44
|
+
foundation: \`@polymorph/react\`, \`@polymorph/vue\` and so on.
|
|
45
|
+
- A member the project has not vendored is added, never written by hand:
|
|
46
|
+
|
|
47
|
+
${commands(run, "add tabs --framework <framework>")}
|
|
48
|
+
|
|
49
|
+
## 2. A screen in React
|
|
50
|
+
|
|
51
|
+
\`\`\`tsx
|
|
52
|
+
import { DataTable, Link, ListPage, SearchInput } from '@polymorph/react-ui'
|
|
53
|
+
import { useState } from 'react'
|
|
54
|
+
|
|
55
|
+
import type { Invoice } from './invoices'
|
|
56
|
+
|
|
57
|
+
export function InvoicesPage(props: {
|
|
58
|
+
invoices: Invoice[]
|
|
59
|
+
navigate: (href: string) => void
|
|
60
|
+
onOpen: (invoice: Invoice) => void
|
|
61
|
+
}) {
|
|
62
|
+
const [query, setQuery] = useState('')
|
|
63
|
+
const shown = props.invoices.filter((invoice) =>
|
|
64
|
+
invoice.customer.toLowerCase().includes(query.toLowerCase()),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<ListPage
|
|
69
|
+
title="Invoices"
|
|
70
|
+
actions={
|
|
71
|
+
<Link href="/invoices/new" variant="button" buttonVariant="solid" onNavigate={props.navigate}>
|
|
72
|
+
New invoice
|
|
73
|
+
</Link>
|
|
74
|
+
}
|
|
75
|
+
filters={
|
|
76
|
+
<SearchInput aria-label="Search invoices" size="sm" value={query} onChange={setQuery} />
|
|
77
|
+
}
|
|
78
|
+
empty={props.invoices.length === 0}
|
|
79
|
+
emptyState={{ title: 'No invoices yet', description: 'An invoice shows here once it is sent.' }}
|
|
80
|
+
>
|
|
81
|
+
<DataTable
|
|
82
|
+
label="Invoices"
|
|
83
|
+
columns={[
|
|
84
|
+
{ key: 'customer', header: 'Customer' },
|
|
85
|
+
{ key: 'status', header: 'Status' },
|
|
86
|
+
{ key: 'total', header: 'Total', numeric: true },
|
|
87
|
+
]}
|
|
88
|
+
data={shown}
|
|
89
|
+
getRowId={(invoice) => invoice.id}
|
|
90
|
+
onRowClick={props.onOpen}
|
|
91
|
+
emptyState={{ icon: 'search', title: 'No invoice matches the search' }}
|
|
92
|
+
/>
|
|
93
|
+
</ListPage>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
- ${f.m("ListPage")} draws its ${f.p("ListPage", "emptyState")} in the table's place while
|
|
99
|
+
${f.p("ListPage", "empty")} is true (no invoice exists). ${f.m("DataTable")} draws its own
|
|
100
|
+
${f.p("DataTable", "emptyState")} when ${f.p("DataTable", "data")} is empty (the search matched
|
|
101
|
+
nothing).
|
|
102
|
+
- The screen holds its state (\`query\`) and derives what it shows (\`shown\`) as it renders.
|
|
103
|
+
Polymorph has no data layer: data arrives as props or from the app's own fetching.
|
|
104
|
+
- The page's one main action is solid and accent. Here it goes to another page, so it is a
|
|
105
|
+
${f.m("Link")} with ${f.v("Link", "variant", "button")} and
|
|
106
|
+
${f.v("Link", "buttonVariant", "solid")}. An action that does the work in place is a
|
|
107
|
+
${f.m("Button")} with no ${f.p("Button", "variant")}. Every other Button there is
|
|
108
|
+
${f.v("Button", "variant", "outline")} or ${f.v("Button", "variant", "ghost")}. [app.md](app.md)
|
|
109
|
+
has the rule for navigation.
|
|
110
|
+
|
|
111
|
+
## 3. The same screen in another framework
|
|
112
|
+
|
|
113
|
+
Members, props, values and parts keep their React names. What differs:
|
|
114
|
+
|
|
115
|
+
| | Vue | Svelte | Solid | Angular |
|
|
116
|
+
| --- | --- | --- | --- | --- |
|
|
117
|
+
| A member | \`<Button>\` | \`<Button>\` | \`<Button>\` | \`<pm-button>\`, its class in \`imports\` |
|
|
118
|
+
| A value | \`:gap="5"\`, \`label="Save"\` | \`gap={5}\` | \`gap={5}\` | \`[gap]="5"\`, \`label="Save"\`; a boolean always bound, \`[iconOnly]="true"\` |
|
|
119
|
+
| A callback ${f.p("DataTable", "onRowClick")} | \`@rowClick="open"\` | \`onRowClick={open}\` | \`onRowClick={open}\` | \`(rowClick)="open($event)"\`, the first argument only |
|
|
120
|
+
| A node prop ${f.p("ListPage", "actions")} | \`<template #actions>\` | \`{#snippet actions()}\` inside the tags | \`actions={<Button … />}\` | the child marked \`slot="actions"\` |
|
|
121
|
+
| A part | \`<Table.Row>\` | \`<Table.Row>\` | \`<Table.Row>\` | \`<tr pmTableRow>\`, \`<li pmListItem>\`; another part is a tag, \`<pm-tabs-content>\` |
|
|
122
|
+
|
|
123
|
+
No member takes two-way binding (\`v-model\`, \`bind:value\`, \`[(value)]\`): pass the value and
|
|
124
|
+
handle its change event. A Solid component reads \`props.foo\` and never destructures its props.
|
|
125
|
+
|
|
126
|
+
\`\`\`ts
|
|
127
|
+
@Component({
|
|
128
|
+
selector: 'app-invoices-page',
|
|
129
|
+
imports: [DataTable, Link, ListPage, SearchInput],
|
|
130
|
+
template: \`
|
|
131
|
+
<pm-list-page title="Invoices" [empty]="invoices().length === 0" [emptyState]="none">
|
|
132
|
+
<pm-link slot="actions" href="/invoices/new" variant="button" buttonVariant="solid"
|
|
133
|
+
(navigate)="navigate.emit($event)">New invoice</pm-link>
|
|
134
|
+
<pm-search-input slot="filters" aria-label="Search invoices" size="sm"
|
|
135
|
+
[value]="query()" (change)="query.set($event)" />
|
|
136
|
+
<pm-data-table label="Invoices" [columns]="columns" [data]="shown()" [getRowId]="rowId"
|
|
137
|
+
(rowClick)="open.emit($event)" [emptyState]="{ icon: 'search', title: 'No match' }" />
|
|
138
|
+
</pm-list-page>
|
|
139
|
+
\`,
|
|
140
|
+
})
|
|
141
|
+
export class InvoicesPage {
|
|
142
|
+
readonly invoices = input.required<Invoice[]>()
|
|
143
|
+
readonly navigate = output<string>()
|
|
144
|
+
readonly open = output<Invoice>()
|
|
145
|
+
protected readonly columns = [{ key: 'customer', header: 'Customer' }]
|
|
146
|
+
protected readonly none = { title: 'No invoices yet' }
|
|
147
|
+
protected readonly query = signal('')
|
|
148
|
+
protected readonly shown = computed(() => this.invoices().filter((i) => i.customer.includes(this.query())))
|
|
149
|
+
protected readonly rowId = (invoice: Invoice) => invoice.id
|
|
150
|
+
}
|
|
151
|
+
\`\`\`
|
|
152
|
+
|
|
153
|
+
## 4. A page with no build: the elements
|
|
154
|
+
|
|
155
|
+
\`\`\`html
|
|
156
|
+
<poly-list-page title="Invoices" empty-state='{"title":"No invoices yet"}'>
|
|
157
|
+
<poly-link slot="actions" href="/invoices/new" variant="button" button-variant="solid">New invoice</poly-link>
|
|
158
|
+
<poly-data-table label="Invoices"
|
|
159
|
+
columns='[{"key":"customer","header":"Customer"},{"key":"total","header":"Total","numeric":true}]'
|
|
160
|
+
empty-state='{"icon":"search","title":"No invoice matches the search"}'></poly-data-table>
|
|
161
|
+
</poly-list-page>
|
|
162
|
+
<script type="module">
|
|
163
|
+
const table = document.querySelector('poly-data-table')
|
|
164
|
+
table.getRowId = (invoice) => invoice.id
|
|
165
|
+
table.data = await (await fetch('/api/invoices')).json()
|
|
166
|
+
table.addEventListener('poly-row-click', (event) => location.assign(\`/invoices/\${event.detail.id}\`))
|
|
167
|
+
<\/script>
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
- A prop is an attribute in kebab case (\`empty-state\`), or the property in camel case. Data is
|
|
171
|
+
JSON. A boolean attribute present is true, and \`"false"\` is false.
|
|
172
|
+
- A node prop is a child with \`slot="<prop>"\` in kebab case, or the dotted name for a node inside
|
|
173
|
+
an object prop: \`slot="empty-state.action"\`.
|
|
174
|
+
- A callback is the event \`poly-<name>\` in kebab case, its first argument as \`detail\`:
|
|
175
|
+
${f.p("DataTable", "onRowClick")} is \`poly-row-click\`. \`click\` on \`<poly-button>\` is the
|
|
176
|
+
native click, and \`poly-click\` is the member's.
|
|
177
|
+
- A function or a render prop is a property a script sets, such as ${f.p("DataTable", "getRowId")}.
|
|
178
|
+
- A part is an element of its own (\`<poly-table-row>\`). Never write a member inside \`<table>\`
|
|
179
|
+
or \`<p>\`.
|
|
180
|
+
- The red rules do not read HTML: \`validate\` and \`check\` leave a page unread. Write no \`class\`
|
|
181
|
+
or \`style\` on an element and no raw \`<button>\` or \`<input>\`. Read each element against
|
|
182
|
+
\`${run} card --framework elements\`, then serve the page and read the console, where an element
|
|
183
|
+
reports each attribute it could not read.
|
|
184
|
+
|
|
185
|
+
## 5. The container of an emitted spec
|
|
186
|
+
|
|
187
|
+
The emitted component holds no state. The container imports it, holds the state, computes every
|
|
188
|
+
derived value, and passes each of the spec's \`inputs\`: data as values, callbacks as functions.
|
|
189
|
+
|
|
190
|
+
\`\`\`tsx
|
|
191
|
+
import { useState } from 'react'
|
|
192
|
+
|
|
193
|
+
import type { Invoice } from './screens/invoices'
|
|
194
|
+
import { InvoicesView } from './screens/InvoicesView'
|
|
195
|
+
|
|
196
|
+
export function Invoices(props: { invoices: Invoice[]; navigate: (href: string) => void }) {
|
|
197
|
+
const [query, setQuery] = useState('')
|
|
198
|
+
const shown = props.invoices.filter((invoice) =>
|
|
199
|
+
invoice.customer.toLowerCase().includes(query.toLowerCase()),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<InvoicesView
|
|
204
|
+
invoices={shown}
|
|
205
|
+
isEmpty={props.invoices.length === 0}
|
|
206
|
+
query={query}
|
|
207
|
+
onQueryChange={setQuery}
|
|
208
|
+
getRowId={(invoice) => invoice.id}
|
|
209
|
+
onOpen={(invoice) => props.navigate(\`/invoices/\${invoice.id}\`)}
|
|
210
|
+
onNavigate={props.navigate}
|
|
211
|
+
/>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
\`\`\`
|
|
215
|
+
|
|
216
|
+
| Framework | What differs |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| \`vue\` | \`import InvoicesView from './screens/InvoicesView.vue'\`; state in a \`ref\`, a derived value in a \`computed\`; a callback input is an event, \`@queryChange="(value: string) => (query = value)"\` |
|
|
219
|
+
| \`svelte\` | \`let query = $state('')\`, \`const shown = $derived(…)\`; callbacks are props, \`onQueryChange={(value) => (query = value)}\` |
|
|
220
|
+
| \`solid\` | \`const [query, setQuery] = createSignal('')\`; a derived value is a function, \`invoices={shown()}\` |
|
|
221
|
+
| \`angular\` | the class in \`imports\`, written \`<app-invoices-view>\`; callbacks are inputs, \`[onQueryChange]="setQuery"\`, each an arrow-function property so it keeps \`this\`: \`protected readonly setQuery = (value: string) => this.query.set(value)\` |
|
|
222
|
+
|
|
223
|
+
While the data has not arrived, the container passes \`true\` to each chart's
|
|
224
|
+
${f.p("LineChart", "loading")} and to ${f.m("DataTable")}'s ${f.p("DataTable", "loading")}, with
|
|
225
|
+
empty rows: a chart draws a skeleton on the first load and dims its last frame on a refetch.
|
|
226
|
+
Empty rows without \`loading\` draw the chart's empty sentence, its \`messages.empty\`. A failed
|
|
227
|
+
load is no member's state: the screen shows an ${f.m("Alert")} with
|
|
228
|
+
${f.v("Alert", "tone", "danger")}, a ${f.p("Alert", "title")} and a retry
|
|
229
|
+
${f.p("Alert", "action")} in the chart's panel. An Alert with no title and no children draws
|
|
230
|
+
nothing, its action included, so a spec binds its title to an input the container leaves empty
|
|
231
|
+
until a load fails. A ${f.m("Stat")} whose number has not arrived takes
|
|
232
|
+
${f.p("Stat", "loading")}, in each entry of ${f.p("Dashboard", "stats")} or on its own: its label
|
|
233
|
+
row stays, and its value and each part it is passed (${f.p("Stat", "delta")},
|
|
234
|
+
${f.p("Stat", "trend")}, ${f.p("Stat", "spark")}, ${f.p("Stat", "footer")}) draw a placeholder of
|
|
235
|
+
that part's size, so the card keeps its height when the number arrives. Pass
|
|
236
|
+
${f.p("Stat", "value")} as the container has it, \`''\` on the first load, and the parts the loaded
|
|
237
|
+
card will have; nothing a loading Stat is passed about its number is drawn or read. A screen
|
|
238
|
+
reader hears ${f.p("Stat", "loadingLabel")}, "Loading" by default, in the value's place. The stat
|
|
239
|
+
row draws nothing while ${f.p("Dashboard", "stats")} is empty.
|
|
240
|
+
|
|
241
|
+
- Never edit the emitted file. Change the spec and emit it again.
|
|
242
|
+
- An emitted screen imports its members from \`@polymorph/<framework>-ui\`. In a project that vendors
|
|
243
|
+
and does not install that package it does not build, and \`emit\` says so in a note: write that
|
|
244
|
+
screen in code with the vendored imports.
|
|
245
|
+
- \`emit\` writes no elements page. There, the page's own script is the container.
|
|
246
|
+
|
|
247
|
+
The root, forms, toasts, dialogs and navigation are in [app.md](app.md).
|
|
248
|
+
`.trimStart();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* What surrounds a screen in a consumer's app: the root's theme module and the members mounted
|
|
252
|
+
* once, the mode and the language, forms, feedback and overlays, and navigation. The skill links
|
|
253
|
+
* it as `references/app.md`, beside `code.md`.
|
|
254
|
+
*/
|
|
255
|
+
function appReference(registry, run) {
|
|
256
|
+
const f = new Facts(registry);
|
|
257
|
+
const toastHost = f.x("ToastHost", "@polymorph/react-ui");
|
|
258
|
+
const tooltipProvider = f.x("TooltipProvider", "@polymorph/react-ui");
|
|
259
|
+
const links = all([
|
|
260
|
+
f.m("Link"),
|
|
261
|
+
f.part("AppShell", "NavItem"),
|
|
262
|
+
f.m("Breadcrumbs"),
|
|
263
|
+
f.m("SectionNav"),
|
|
264
|
+
f.part("List", "Item"),
|
|
265
|
+
f.m("Card")
|
|
266
|
+
]);
|
|
267
|
+
return `
|
|
268
|
+
# The app around a screen: root, forms, feedback and navigation
|
|
269
|
+
|
|
270
|
+
The examples are React, and each section says what differs elsewhere. An app \`init\` wrote has the
|
|
271
|
+
root below. In another app, check each line.
|
|
272
|
+
|
|
273
|
+
## 1. The root
|
|
274
|
+
|
|
275
|
+
- The entry imports the theme module first: \`import 'virtual:polymorph/theme'\`. It brings the
|
|
276
|
+
theme's stylesheet, the fonts its system names and the reader's stored choice. An Angular entry
|
|
277
|
+
imports \`@polymorph/angular-ui/base.css\` next. The Vite plugin writes \`data-system\`,
|
|
278
|
+
\`data-palette\` and the pre-paint script into \`index.html\`: never write them, and never select on
|
|
279
|
+
them in CSS.
|
|
280
|
+
- The toast viewport is mounted once, outside the routes and outside any error boundary.
|
|
281
|
+
- In React a ${f.m("Tooltip")} needs ${tooltipProvider} above it. ${f.m("AppShell")} brings its own;
|
|
282
|
+
a root without AppShell wraps the app in one.
|
|
283
|
+
- Polymorph has no router and no data layer. The router is the app's own dependency, which the app
|
|
284
|
+
installs: a package outside \`@polymorph\` is allowed for routing and for data, and the red rules
|
|
285
|
+
pass a router's imports and components. Its provider goes inside the two above, around the
|
|
286
|
+
routes. This root uses React Router.
|
|
287
|
+
|
|
288
|
+
\`\`\`tsx
|
|
289
|
+
import 'virtual:polymorph/theme'
|
|
290
|
+
|
|
291
|
+
import { ToastHost, TooltipProvider } from '@polymorph/react-ui'
|
|
292
|
+
import { StrictMode } from 'react'
|
|
293
|
+
import { createRoot } from 'react-dom/client'
|
|
294
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
295
|
+
|
|
296
|
+
import { App } from './App'
|
|
297
|
+
|
|
298
|
+
const TOASTS = { dismiss: 'Dismiss', notification: 'Notification', viewport: 'Notifications (F8)' }
|
|
299
|
+
|
|
300
|
+
createRoot(document.getElementById('root')!).render(
|
|
301
|
+
<StrictMode>
|
|
302
|
+
<ToastHost messages={TOASTS}>
|
|
303
|
+
<TooltipProvider>
|
|
304
|
+
<BrowserRouter>
|
|
305
|
+
<App />
|
|
306
|
+
</BrowserRouter>
|
|
307
|
+
</TooltipProvider>
|
|
308
|
+
</ToastHost>
|
|
309
|
+
</StrictMode>,
|
|
310
|
+
)
|
|
311
|
+
\`\`\`
|
|
312
|
+
|
|
313
|
+
\`\`\`html
|
|
314
|
+
<!-- Vue, Svelte, Solid: once, in the root component -->
|
|
315
|
+
<Toast.Viewport />
|
|
316
|
+
<!-- Angular: ToastViewport in the root's imports -->
|
|
317
|
+
<pm-toast-viewport />
|
|
318
|
+
<!-- elements: once, in <body> -->
|
|
319
|
+
<poly-toast-viewport></poly-toast-viewport>
|
|
320
|
+
\`\`\`
|
|
321
|
+
|
|
322
|
+
A new page is mounted by the app's router, or by the root in an app without one. \`init\` wrote a
|
|
323
|
+
placeholder screen, Welcome, from \`src/screens/welcome.json\`, and its root component
|
|
324
|
+
(\`src/App.tsx\`, \`src/App.vue\`, \`src/App.svelte\` or \`src/app.ts\`) renders it. Replace what
|
|
325
|
+
the root component renders with the app's routes, one page per route, and delete the Welcome spec
|
|
326
|
+
and the file emitted from it once nothing renders them.
|
|
327
|
+
|
|
328
|
+
- **Mode.** ${f.m("ModeSwitch")} with a ${f.p("ModeSwitch", "label")} and no
|
|
329
|
+
${f.p("ModeSwitch", "value")} shows the reader's choice of light, dark or system and applies it.
|
|
330
|
+
A Menu or command entry calls ${f.x("setMode", "@polymorph/engine/runtime")} with \`'light'\`,
|
|
331
|
+
\`'dark'\` or \`'system'\`, and reads the choice from ${f.x("useMode", "@polymorph/react")}, which
|
|
332
|
+
every foundation exports. The palette holds both modes: write no \`dark\` class, no
|
|
333
|
+
\`prefers-color-scheme\` rule and no second stylesheet.
|
|
334
|
+
- **Language.** \`lang\` on \`<html>\`, and \`dir="rtl"\` for a right-to-left language: every member
|
|
335
|
+
follows it. No provider sets a locale or words for the whole app. A member that formats dates or
|
|
336
|
+
numbers takes \`locale\`, and a member with words of its own takes \`messages\` or a prop for its
|
|
337
|
+
words, such as ${f.m("Stat")}'s ${f.p("Stat", "deltaLabel")}, ${f.m("TagInput")}'s
|
|
338
|
+
${f.p("TagInput", "countLabel")}, ${f.m("Command")}'s ${f.p("Command", "spoken")} or
|
|
339
|
+
${f.m("CodeBlock")}'s ${f.p("CodeBlock", "copiedLabel")}, English when left out. Pass the app's
|
|
340
|
+
translations to each, as ${toastHost} takes its three words.
|
|
341
|
+
|
|
342
|
+
## 2. Forms
|
|
343
|
+
|
|
344
|
+
${commands(run, "component FormField --framework <framework>")}
|
|
345
|
+
|
|
346
|
+
\`\`\`tsx
|
|
347
|
+
import {
|
|
348
|
+
Button,
|
|
349
|
+
Card,
|
|
350
|
+
FormField,
|
|
351
|
+
FormPage,
|
|
352
|
+
Input,
|
|
353
|
+
Select,
|
|
354
|
+
Stack,
|
|
355
|
+
Textarea,
|
|
356
|
+
toast,
|
|
357
|
+
} from '@polymorph/react-ui'
|
|
358
|
+
import { useState } from 'react'
|
|
359
|
+
|
|
360
|
+
const CHANNELS = [
|
|
361
|
+
{ value: 'email', label: 'Email' },
|
|
362
|
+
{ value: 'chat', label: 'Chat' },
|
|
363
|
+
{ value: 'phone', label: 'Phone' },
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
export interface TicketDraft {
|
|
367
|
+
subject: string
|
|
368
|
+
channel: string
|
|
369
|
+
details: string
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export function NewTicketPage(props: {
|
|
373
|
+
save: (draft: TicketDraft) => Promise<void>
|
|
374
|
+
onDone: () => void
|
|
375
|
+
}) {
|
|
376
|
+
const [subject, setSubject] = useState('')
|
|
377
|
+
const [channel, setChannel] = useState<string | null>(null)
|
|
378
|
+
const [details, setDetails] = useState('')
|
|
379
|
+
const [submitted, setSubmitted] = useState(false)
|
|
380
|
+
const [saving, setSaving] = useState(false)
|
|
381
|
+
const subjectError = submitted && subject.trim() === '' ? 'Give the ticket a subject.' : undefined
|
|
382
|
+
const channelError = submitted && channel === null ? 'Choose a channel.' : undefined
|
|
383
|
+
|
|
384
|
+
async function submit() {
|
|
385
|
+
setSubmitted(true)
|
|
386
|
+
if (subject.trim() === '' || channel === null) return
|
|
387
|
+
setSaving(true)
|
|
388
|
+
try {
|
|
389
|
+
await props.save({ subject, channel, details })
|
|
390
|
+
toast.success('Ticket created')
|
|
391
|
+
props.onDone()
|
|
392
|
+
} catch {
|
|
393
|
+
toast.danger('The ticket was not saved', { description: 'Try again in a moment.' })
|
|
394
|
+
} finally {
|
|
395
|
+
setSaving(false)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<FormPage
|
|
401
|
+
title="New ticket"
|
|
402
|
+
onSubmit={submit}
|
|
403
|
+
actions={<Button type="submit" label="Create ticket" loading={saving} />}
|
|
404
|
+
>
|
|
405
|
+
<Card>
|
|
406
|
+
<Stack gap={5}>
|
|
407
|
+
<FormField label="Subject" required error={subjectError}>
|
|
408
|
+
<Input value={subject} onChange={setSubject} />
|
|
409
|
+
</FormField>
|
|
410
|
+
<FormField label="Channel" required error={channelError}>
|
|
411
|
+
<Select
|
|
412
|
+
options={CHANNELS}
|
|
413
|
+
placeholder="Choose a channel"
|
|
414
|
+
value={channel}
|
|
415
|
+
onChange={setChannel}
|
|
416
|
+
/>
|
|
417
|
+
</FormField>
|
|
418
|
+
<FormField label="Details">
|
|
419
|
+
<Textarea rows={5} value={details} onChange={setDetails} />
|
|
420
|
+
</FormField>
|
|
421
|
+
</Stack>
|
|
422
|
+
</Card>
|
|
423
|
+
</FormPage>
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
\`\`\`
|
|
427
|
+
|
|
428
|
+
The route that mounts the page passes the router's navigation as \`onDone\`: in React Router,
|
|
429
|
+
\`onDone={() => navigate('/tickets')}\`, with \`navigate\` from \`useNavigate()\`.
|
|
430
|
+
|
|
431
|
+
- ${f.m("FormPage")} with ${f.p("FormPage", "onSubmit")} renders a real \`<form>\`: Enter submits
|
|
432
|
+
from any field, and a failed submit moves focus to the first invalid field. Its
|
|
433
|
+
${f.p("FormPage", "actions")} hold one submit Button, solid accent by default, and quiet ones. A
|
|
434
|
+
destructive action goes in ${f.p("FormPage", "leadingAction")}, behind a ${f.m("ConfirmDialog")}.
|
|
435
|
+
- ${f.m("FormField")} wraps one control and wires its label, ${f.p("FormField", "description")},
|
|
436
|
+
${f.p("FormField", "required")} and ${f.p("FormField", "error")}. A non-empty error marks the
|
|
437
|
+
control invalid and links the message; never set the control's ${f.p("Input", "invalid")} as
|
|
438
|
+
well. Two fields side by side are a ${f.m("Grid")} with ${f.p("Grid", "columns")} of 2.
|
|
439
|
+
- Errors are computed from the values and a \`submitted\` flag, so none shows before the first
|
|
440
|
+
submit. A server's error for a field goes in that field's error.
|
|
441
|
+
- ${f.m("Input")}'s and ${f.m("Textarea")}'s ${f.p("Input", "onChange")} hand over the text as a
|
|
442
|
+
\`string\`, then the change event, so \`onChange={setSubject}\` stores it.
|
|
443
|
+
${f.m("Select")}'s hands over \`string | null\`.
|
|
444
|
+
- A ${f.m("Select")}'s ${f.p("Select", "value")} is \`string | null\`, and \`null\` is nothing chosen:
|
|
445
|
+
the trigger shows its ${f.p("Select", "placeholder")}. Start it at \`null\`, store what
|
|
446
|
+
${f.p("Select", "onChange")} hands over as it is, and set \`null\` to clear the choice, as a form
|
|
447
|
+
does when it resets after a save. With ${f.p("Select", "emptyOption")}, \`null\` is that choice,
|
|
448
|
+
such as a filter's "All". Never \`undefined\`: a Select given \`undefined\` holds the choice
|
|
449
|
+
itself, as one given no ${f.p("Select", "value")} does, and stops following the form's state.
|
|
450
|
+
Never \`''\`: no option has it.
|
|
451
|
+
- While the request runs, the submit Button takes ${f.p("Button", "loading")}, and a click does
|
|
452
|
+
nothing.
|
|
453
|
+
- A long form also lists its errors above the fields in ${f.m("ErrorSummary")}, whose
|
|
454
|
+
${f.p("ErrorSummary", "errors")} is \`{ label, fieldId }[]\`, each \`fieldId\` the
|
|
455
|
+
${f.p("FormField", "id")} of its FormField.
|
|
456
|
+
- Vue writes \`@submit\` and \`<template #actions>\`, Angular \`(submit)\`. On a page with no build, a
|
|
457
|
+
\`<form>\` around the elements posts each member's value under its \`name\`.
|
|
458
|
+
|
|
459
|
+
## 3. Feedback and overlays
|
|
460
|
+
|
|
461
|
+
| The screen needs | Use |
|
|
462
|
+
| --- | --- |
|
|
463
|
+
| The outcome of an action | \`toast.success(title)\`, \`toast.danger\`, \`toast.warning\`, \`toast.info\`, or \`toast.promise(promise, { loading, success, error })\` for one card through the wait |
|
|
464
|
+
| A failure that stays until the screen resolves it | ${f.x("ToastNotice", "@polymorph/react-ui")} in React, \`<Toast>\` in a template elsewhere: shown while it is rendered |
|
|
465
|
+
| A region that is loading | ${f.m("Skeleton")} in the content's place, ${f.p("DataTable", "loading")} on a DataTable, ${f.m("Spinner")} for a wait of unknown length |
|
|
466
|
+
| An action that is running | the Button's ${f.p("Button", "loading")}; a ConfirmDialog whose ${f.p("ConfirmDialog", "onConfirm")} returns a promise stays pending until it settles |
|
|
467
|
+
| Nothing to show | ${f.m("EmptyState")}, or the archetype's \`emptyState\`; a failed load is one with \`icon="error"\` and a retry action |
|
|
468
|
+
| A status inside the page | ${f.m("Alert")} with a ${f.p("Alert", "tone")} |
|
|
469
|
+
| A notice for the whole app until its cause ends | ${f.m("Banner")} in AppShell's ${f.p("AppShell", "banner")} |
|
|
470
|
+
| To confirm a destructive action | ${f.m("ConfirmDialog")}: a question, its consequence and a verb |
|
|
471
|
+
| A task over the page | ${f.m("Dialog")} with a ${f.p("Dialog", "title")} and a ${f.p("Dialog", "footer")}, or ${f.m("Drawer")} at the side |
|
|
472
|
+
|
|
473
|
+
\`\`\`tsx
|
|
474
|
+
import { Alert, Button, ConfirmDialog } from '@polymorph/react-ui'
|
|
475
|
+
|
|
476
|
+
export function DeleteInvoice(props: { remove: () => Promise<void> }) {
|
|
477
|
+
return (
|
|
478
|
+
<ConfirmDialog
|
|
479
|
+
title="Delete this invoice?"
|
|
480
|
+
description="The customer keeps the copy they were sent."
|
|
481
|
+
confirmLabel="Delete invoice"
|
|
482
|
+
trigger={<Button variant="ghost" tone="danger" icon="delete" label="Delete" />}
|
|
483
|
+
onConfirm={props.remove}
|
|
484
|
+
/>
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export function LoadFailed(props: { retry: () => void }) {
|
|
489
|
+
return (
|
|
490
|
+
<Alert
|
|
491
|
+
tone="danger"
|
|
492
|
+
title="The invoices did not load"
|
|
493
|
+
action={<Button variant="ghost" size="sm" label="Try again" onClick={props.retry} />}
|
|
494
|
+
/>
|
|
495
|
+
)
|
|
496
|
+
}
|
|
497
|
+
\`\`\`
|
|
498
|
+
|
|
499
|
+
- \`toast\` comes from \`@polymorph/react-ui\` in React, from the foundation (\`@polymorph/vue\` and
|
|
500
|
+
so on) elsewhere, and from \`polymorph.js\` on a page with no build. With no viewport mounted, a
|
|
501
|
+
toast draws nowhere.
|
|
502
|
+
- A danger or warning toast, and one with an \`action\`, stays until it is dismissed. A success or
|
|
503
|
+
info toast leaves on its own.
|
|
504
|
+
- An Angular ConfirmDialog closes when it is confirmed: hold ${f.p("ConfirmDialog", "open")} in the
|
|
505
|
+
component to keep it open while saving. On a page with no build, the \`poly-confirm\` listener
|
|
506
|
+
calls \`event.waitUntil(promise)\`.
|
|
507
|
+
|
|
508
|
+
## 4. Navigation
|
|
509
|
+
|
|
510
|
+
${links} with an \`href\` draw a real \`<a href>\`. Without ${f.p("Link", "onNavigate")} the
|
|
511
|
+
browser loads the address. With it, a plain click calls \`onNavigate(href)\` instead. A click with a
|
|
512
|
+
modifier key or another button, or on an ${f.p("Link", "external")} Link, stays the browser's.
|
|
513
|
+
|
|
514
|
+
\`\`\`tsx
|
|
515
|
+
import { AppShell } from '@polymorph/react-ui'
|
|
516
|
+
import type { ReactNode } from 'react'
|
|
517
|
+
|
|
518
|
+
export function Shell(props: { path: string; navigate: (href: string) => void; children: ReactNode }) {
|
|
519
|
+
return (
|
|
520
|
+
<AppShell
|
|
521
|
+
sidebar={
|
|
522
|
+
<AppShell.NavItem
|
|
523
|
+
icon="inbox"
|
|
524
|
+
label="Invoices"
|
|
525
|
+
href="/invoices"
|
|
526
|
+
current={props.path.startsWith('/invoices')}
|
|
527
|
+
onNavigate={props.navigate}
|
|
528
|
+
/>
|
|
529
|
+
}
|
|
530
|
+
transitionKey={props.path}
|
|
531
|
+
>
|
|
532
|
+
{props.children}
|
|
533
|
+
</AppShell>
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
\`\`\`
|
|
537
|
+
|
|
538
|
+
| Framework | The router, passed to \`onNavigate\` |
|
|
539
|
+
| --- | --- |
|
|
540
|
+
| \`react\` | React Router: \`(href) => navigate(href)\`, \`navigate\` from \`useNavigate()\`. TanStack Router: \`(href) => navigate({ href })\`. Next.js: \`(href) => router.push(href)\` |
|
|
541
|
+
| \`vue\` | \`@navigate="(href) => router.push(href)"\` |
|
|
542
|
+
| \`svelte\` | \`onNavigate={goto}\` in SvelteKit |
|
|
543
|
+
| \`solid\` | \`onNavigate={navigate}\`, \`navigate\` from \`useNavigate()\` of \`@solidjs/router\` |
|
|
544
|
+
| \`angular\` | \`(navigate)="router.navigateByUrl($event)"\` |
|
|
545
|
+
| \`elements\` | a \`poly-navigate\` listener on the element, or \`listens="navigate"\` on it for a listener by delegation; without either, the link follows its \`href\` |
|
|
546
|
+
|
|
547
|
+
- ${f.m("AppShell")} renders once, at the root route, and each route renders one page archetype
|
|
548
|
+
inside it. The app sets ${f.p("AppShell", "transitionKey")} to the path,
|
|
549
|
+
${f.p("AppShell", "pending")} while the router loads, and \`current\` on each item: which paths a
|
|
550
|
+
section holds is the router's knowledge.
|
|
551
|
+
- A pager takes addresses too: ${f.m("Pagination")}'s ${f.p("Pagination", "getPageHref")} beside
|
|
552
|
+
${f.p("Pagination", "onPageChange")}, ${f.m("CursorPagination")}'s
|
|
553
|
+
${f.p("CursorPagination", "previousHref")} and ${f.p("CursorPagination", "nextHref")}.
|
|
554
|
+
- An \`onClick\` on an \`<a>\` is a red-rule violation. A link that routes is a Link with
|
|
555
|
+
\`onNavigate\`, and work that changes data is a Button.
|
|
556
|
+
- An action that goes to another page, such as a page's "New ticket", is a ${f.m("Link")} with
|
|
557
|
+
${f.v("Link", "variant", "button")}, never a ${f.m("Button")} whose handler calls the router. It
|
|
558
|
+
stays an \`<a href>\`, so it opens in a new tab and copies as an address, and it takes a
|
|
559
|
+
Button's look. Its ${f.p("Link", "buttonVariant")} is \`soft\` unless set: set
|
|
560
|
+
${f.v("Link", "buttonVariant", "solid")} when it is the page's one main action. It has no icon,
|
|
561
|
+
no loading and no disabled state.
|
|
562
|
+
`.trimStart();
|
|
563
|
+
}
|
|
564
|
+
//#endregion
|
|
565
|
+
export { appReference, codeReference };
|