@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,334 @@
|
|
|
1
|
+
import { DEFAULT_SYSTEM } from "../plan.js";
|
|
2
|
+
import { Facts, SkillFactError, all, commands, either } from "./facts.js";
|
|
3
|
+
//#region ../cli/src/skills/screen-charts.ts
|
|
4
|
+
/** The tier the chart members are in, as the registry names it. */
|
|
5
|
+
var TIER = "charts";
|
|
6
|
+
/** The vocabulary package the chart grammar's types are imported from in React. */
|
|
7
|
+
var VOCABULARY = "@polymorph/react-ui";
|
|
8
|
+
/**
|
|
9
|
+
* The question each chart member answers, in the words a person asks it. A
|
|
10
|
+
* member of the tier this list lacks is described by its purpose, so a new
|
|
11
|
+
* chart member reaches the table with no edit here. A member this list names
|
|
12
|
+
* that the tier lacks stops the texts being written.
|
|
13
|
+
*/
|
|
14
|
+
var QUESTIONS = [
|
|
15
|
+
["BarChart", "Compare amounts across named categories: which is bigger, grouped, stacked or signed"],
|
|
16
|
+
["LineChart", "A trend over time, or change along any ordered or measured x"],
|
|
17
|
+
["AreaChart", "What a total is made of, and how that changes over time"],
|
|
18
|
+
["DonutChart", "Part of a whole, at most six parts, read roughly"],
|
|
19
|
+
["Treemap", "Part of a whole with many parts, or a hierarchy of two levels sized by value"],
|
|
20
|
+
["Histogram", "How one sample of numbers is spread (a distribution)"],
|
|
21
|
+
["ScatterChart", "Whether two measures move together, one mark per observation"],
|
|
22
|
+
["Heatmap", "One measure over a grid of two categories (a matrix), such as weekday by hour"],
|
|
23
|
+
["RadarChart", "A profile over three to six axes that share one unit"],
|
|
24
|
+
["FunnelChart", "Loss between the ordered stages of a process"],
|
|
25
|
+
["Sparkline", "A small inline trend beside a number, with no axes"]
|
|
26
|
+
];
|
|
27
|
+
/** The data each family of chart members takes, and the props that carry it. */
|
|
28
|
+
var FAMILIES = [
|
|
29
|
+
{
|
|
30
|
+
members: [
|
|
31
|
+
"BarChart",
|
|
32
|
+
"LineChart",
|
|
33
|
+
"AreaChart",
|
|
34
|
+
"ScatterChart"
|
|
35
|
+
],
|
|
36
|
+
props: [
|
|
37
|
+
"data",
|
|
38
|
+
"series",
|
|
39
|
+
"x"
|
|
40
|
+
],
|
|
41
|
+
shape: "rows; one series per value field; `x` names the row field along the x axis"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
members: ["Heatmap"],
|
|
45
|
+
props: [
|
|
46
|
+
"data",
|
|
47
|
+
"x",
|
|
48
|
+
"y",
|
|
49
|
+
"value"
|
|
50
|
+
],
|
|
51
|
+
shape: "one row per cell; `x` and `y` name the two category fields, `value` the measure"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
members: ["RadarChart"],
|
|
55
|
+
props: [
|
|
56
|
+
"axes",
|
|
57
|
+
"data",
|
|
58
|
+
"series"
|
|
59
|
+
],
|
|
60
|
+
shape: "one row per axis, in the axes' order, with one field per series"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
members: ["Histogram", "Sparkline"],
|
|
64
|
+
props: ["data"],
|
|
65
|
+
shape: "plain numbers: the raw sample, or the trend in order"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
members: [
|
|
69
|
+
"DonutChart",
|
|
70
|
+
"FunnelChart",
|
|
71
|
+
"Treemap"
|
|
72
|
+
],
|
|
73
|
+
props: [],
|
|
74
|
+
shape: "a list of parts, each `{ key, label, value }`"
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
/**
|
|
78
|
+
* How a model in a consumer's app draws data: which chart member answers which
|
|
79
|
+
* question, the data each takes, the props the members share, what the theme
|
|
80
|
+
* decides that no prop can, and what to do for a chart no member draws. The
|
|
81
|
+
* screen skill sends a model here for any chart.
|
|
82
|
+
*/
|
|
83
|
+
function chartsReference(registry, run) {
|
|
84
|
+
const f = new Facts(registry);
|
|
85
|
+
const tier = f.tier(TIER);
|
|
86
|
+
if (tier.length === 0) throw new SkillFactError(`no member is in the ${TIER} tier`);
|
|
87
|
+
const inTier = (name) => {
|
|
88
|
+
if (!tier.includes(name)) throw new SkillFactError(`${name} is not in the ${TIER} tier`);
|
|
89
|
+
return f.m(name);
|
|
90
|
+
};
|
|
91
|
+
const named = new Set(QUESTIONS.map(([member]) => member));
|
|
92
|
+
const questions = [...QUESTIONS.map(([member, question]) => `| ${question} | ${inTier(member)} |`), ...tier.filter((member) => !named.has(member)).map((member) => `| ${f.purpose(member)} | ${f.m(member)} |`)];
|
|
93
|
+
const families = FAMILIES.map(({ members, props, shape }) => {
|
|
94
|
+
for (const member of members) for (const prop of props) f.p(member, prop);
|
|
95
|
+
return `| ${all(members.map(inTier))} | ${shape} |`;
|
|
96
|
+
});
|
|
97
|
+
const having = (prop) => {
|
|
98
|
+
const found = tier.filter((member) => registry.components.some((entry) => entry.name === member && entry.props.some((each) => each.name === prop)));
|
|
99
|
+
if (found.length === 0) throw new SkillFactError(`no chart member takes ${prop}`);
|
|
100
|
+
const without = tier.filter((member) => !found.includes(member));
|
|
101
|
+
if (without.length === 0) return "every chart";
|
|
102
|
+
if (without.length <= 2) return `every chart but ${all(without.map((name) => f.m(name)))}`;
|
|
103
|
+
return all(found.map((name) => f.m(name)));
|
|
104
|
+
};
|
|
105
|
+
const series = (field) => f.field("ChartSeries", field);
|
|
106
|
+
const styles = either(f.fieldValues("ValueFormat", "style").map((value) => `\`${value}\``));
|
|
107
|
+
const tones = either(f.fieldValues("ChartSeries", "tone").map((value) => `\`${value}\``));
|
|
108
|
+
const datum = f.x("ChartDatum", VOCABULARY);
|
|
109
|
+
const catalog = f.x("DEFAULT_CHART_MESSAGES", VOCABULARY);
|
|
110
|
+
return `
|
|
111
|
+
# Charts
|
|
112
|
+
|
|
113
|
+
A chart is a member of the \`${TIER}\` tier. The app passes it data and literal settings, and the
|
|
114
|
+
theme decides every colour, font and motion.
|
|
115
|
+
|
|
116
|
+
${commands(run, `search --tier ${TIER} --framework <framework>`, "component LineChart --framework <framework>")}
|
|
117
|
+
|
|
118
|
+
The examples are React. Vue, Svelte, Solid and Angular members take the same props and the same
|
|
119
|
+
data. A callback such as ${f.p("BarChart", "onSelect")} is the event \`@select\` in Vue and the
|
|
120
|
+
output \`(select)\` in Angular.
|
|
121
|
+
|
|
122
|
+
## 1. Choose the member
|
|
123
|
+
|
|
124
|
+
| The data answers | Member |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
${questions.join("\n")}
|
|
127
|
+
| One key number and its change, with its trend | ${f.m("Stat")} with ${f.p("Stat", "spark")} |
|
|
128
|
+
| One value against a target or a known range | ${f.m("Meter")}; how much of a task is done, ${f.m("Progress")} |
|
|
129
|
+
| Exact values to look up, sort or copy | ${f.m("Table")} or ${f.m("DataTable")} |
|
|
130
|
+
| A hierarchy to browse, not to size | ${f.m("Tree")} |
|
|
131
|
+
| Events in the order they happened | ${f.m("Timeline")} |
|
|
132
|
+
|
|
133
|
+
No member draws two value axes, a pie or a gauge. A second series in the bars' own unit (a moving
|
|
134
|
+
average, last period) is ${f.m("BarChart")}'s ${f.p("BarChart", "lines")}. A second measure in
|
|
135
|
+
another unit is a second chart over the same rows and \`x\`: a ${f.m("BarChart")} above a
|
|
136
|
+
${f.m("LineChart")} in one panel.
|
|
137
|
+
|
|
138
|
+
## 2. Give it data
|
|
139
|
+
|
|
140
|
+
| Members | What they take |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
${families.join("\n")}
|
|
143
|
+
|
|
144
|
+
A row is a ${datum}: an object of strings, numbers and \`null\`. \`null\` is a gap: a line breaks
|
|
145
|
+
and a bar is absent. It is never drawn as zero. Rows draw in the order given, so sort them in the
|
|
146
|
+
app. A ${f.m("Heatmap")} sorts nothing either: its columns and its rows, from the top, are the
|
|
147
|
+
\`x\` and \`y\` values in the order each first appears in the rows. A pair the rows lack draws as
|
|
148
|
+
the surface, and a second row for a pair is ignored. A time is an ISO 8601 string, and a date-only
|
|
149
|
+
string (\`2026-07-01\`) never shifts by time zone. Values are numbers: the chart formats them with a
|
|
150
|
+
\`format\`. Only ${f.m("DonutChart")}'s ${f.p("DonutChart", "center")} is a string the app formats.
|
|
151
|
+
\`component <Name>\` prints the fields of each data type the member's props take.
|
|
152
|
+
|
|
153
|
+
\`\`\`tsx
|
|
154
|
+
import { DonutChart, Heatmap, Histogram, LineChart } from '${VOCABULARY}'
|
|
155
|
+
|
|
156
|
+
<LineChart
|
|
157
|
+
data={[
|
|
158
|
+
{ day: '2026-07-01', opened: 28, resolved: 25 },
|
|
159
|
+
{ day: '2026-07-02', opened: 35, resolved: 31 },
|
|
160
|
+
]}
|
|
161
|
+
series={[
|
|
162
|
+
{ key: 'opened', label: 'Opened' },
|
|
163
|
+
{ key: 'resolved', label: 'Resolved' },
|
|
164
|
+
]}
|
|
165
|
+
x={{ key: 'day', scale: 'time', label: 'Day' }}
|
|
166
|
+
y={{ label: 'Tickets' }}
|
|
167
|
+
label="Tickets opened and resolved by day"
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
<Heatmap
|
|
171
|
+
data={[
|
|
172
|
+
{ day: 'Mon', band: '08–12', tickets: 34 },
|
|
173
|
+
{ day: 'Mon', band: '12–16', tickets: 38 },
|
|
174
|
+
]}
|
|
175
|
+
x={{ key: 'band', label: 'Hour' }}
|
|
176
|
+
y={{ key: 'day', label: 'Day' }}
|
|
177
|
+
value={{ key: 'tickets' }}
|
|
178
|
+
label="Ticket volume by weekday and hour"
|
|
179
|
+
/>
|
|
180
|
+
|
|
181
|
+
<Histogram data={firstResponseMinutes} x={{ label: 'Minutes to first response' }} label="First response time, this week" />
|
|
182
|
+
|
|
183
|
+
<DonutChart
|
|
184
|
+
segments={[
|
|
185
|
+
{ key: 'email', label: 'Email', value: 214 },
|
|
186
|
+
{ key: 'chat', label: 'Chat', value: 96 },
|
|
187
|
+
]}
|
|
188
|
+
center={{ value: '310', label: 'Open tickets' }}
|
|
189
|
+
label="Open tickets by channel"
|
|
190
|
+
/>
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
- \`x.scale\` is \`band\` (named categories, the default), \`time\` or \`linear\`.
|
|
194
|
+
${f.m("LineChart")} takes all three, ${f.m("AreaChart")} \`band\` or \`time\`,
|
|
195
|
+
${f.m("ScatterChart")} \`linear\` (its default) or \`time\`, and ${f.m("BarChart")} \`band\`
|
|
196
|
+
only. In a ${f.m("ScatterChart")} each series is a y field of the same rows.
|
|
197
|
+
- ${f.m("RadarChart")} takes ${f.p("RadarChart", "axes")} and one row per axis. ${f.m("FunnelChart")} takes ${f.p("FunnelChart", "stages")}, first to last.
|
|
198
|
+
${f.m("Treemap")} takes ${f.p("Treemap", "items")}, where an item with
|
|
199
|
+
${f.field("TreemapItem", "children")} is a group.
|
|
200
|
+
|
|
201
|
+
In a screen spec, data is bound to an input, and every plain object, a nested one included, is an
|
|
202
|
+
\`$object\`. Import the row type through \`types\`:
|
|
203
|
+
|
|
204
|
+
\`\`\`json
|
|
205
|
+
{
|
|
206
|
+
"spec": "polymorph-screen/1",
|
|
207
|
+
"name": "TicketsByChannel",
|
|
208
|
+
"purpose": "Tickets by channel, with a way to open one channel's tickets.",
|
|
209
|
+
"inputs": [
|
|
210
|
+
{ "name": "byChannel", "type": "ChartDatum[]" },
|
|
211
|
+
{ "name": "onOpenChannel", "type": "(selection: { index: number; key: string; datum: ChartDatum }) => void" }
|
|
212
|
+
],
|
|
213
|
+
"types": { "@polymorph/react-ui": ["ChartDatum"] },
|
|
214
|
+
"root": {
|
|
215
|
+
"component": "BarChart",
|
|
216
|
+
"props": {
|
|
217
|
+
"label": "Tickets by channel",
|
|
218
|
+
"data": { "$": "byChannel" },
|
|
219
|
+
"series": [{ "$object": { "key": "tickets", "label": "Tickets" } }],
|
|
220
|
+
"x": { "$object": { "key": "channel", "label": "Channel" } },
|
|
221
|
+
"y": { "$object": { "format": { "$object": { "style": "compact" } } } },
|
|
222
|
+
"onSelect": { "$": "onOpenChannel" }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
\`\`\`
|
|
227
|
+
|
|
228
|
+
\`render\` draws a spec's chart only with rows. Pass them with \`--data\`: a JSON file of sample
|
|
229
|
+
rows beside the spec, an object whose keys are the spec's data inputs, such as
|
|
230
|
+
\`{ "byChannel": [ … ] }\`. The pictures are then \`populated-phone.png\` and
|
|
231
|
+
\`populated-desktop.png\`. Sampled inputs draw the empty state.
|
|
232
|
+
|
|
233
|
+
${commands(run, `render src/screens/tickets.json --system ${DEFAULT_SYSTEM} --data src/screens/tickets.data.json`)}
|
|
234
|
+
|
|
235
|
+
In a page with no build, data is a JSON attribute, the callback is the event \`poly-select\`, and
|
|
236
|
+
${f.p("BarChart", "messages")} is set as a property from script:
|
|
237
|
+
|
|
238
|
+
\`\`\`html
|
|
239
|
+
<poly-bar-chart label="Tickets by channel" data='[{"channel":"Email","tickets":214},{"channel":"Chat","tickets":96}]' series='[{"key":"tickets","label":"Tickets"}]' x='{"key":"channel","label":"Channel"}'></poly-bar-chart>
|
|
240
|
+
\`\`\`
|
|
241
|
+
|
|
242
|
+
## 3. The props charts share
|
|
243
|
+
|
|
244
|
+
| Prop | What it does | Taken by |
|
|
245
|
+
| --- | --- | --- |
|
|
246
|
+
| ${f.p("BarChart", "label")} | Required. The chart's accessible name and the start of its summary sentence. It is not drawn: the panel's title names the chart on screen. | ${having("label")} |
|
|
247
|
+
| ${f.p("BarChart", "size")} | The height, \`sm\`, \`md\` or \`lg\`. The width is always the container's. | ${having("size")} |
|
|
248
|
+
| ${f.p("BarChart", "x")}, ${f.p("LineChart", "y")} | No axis title is drawn, so a label is read as words. \`x.label\` heads the first column of the chart's table of values (a ${f.m("Heatmap")}'s is \`y.label\`). \`y.label\` names the measure the values are in, such as "Requests" or "Latency (ms)": the summary sentence says it once, and the tooltip and the table name each value by its series. A ${f.m("ScatterChart")}'s summary says its \`x.label\` too, and a ${f.m("Histogram")}'s \`y.label\` heads its count column. \`format\` is ${styles}: \`percent\` takes ratios, and \`currency\` takes a \`currency\` code. \`y.domain: 'zero'\` anchors a line at zero. | ${having("x")} |
|
|
249
|
+
| ${f.p("BarChart", "series")} | A ${series("key")} and a ${series("label")} for each series; ${series("slot")} and ${series("tone")} set its colour (section 4). Two or more series draw a legend, whose keys hide and show a series. The legend is not a prop. | ${having("series")} |
|
|
250
|
+
| ${f.p("BarChart", "tooltip")} | How the reading's tooltip looks. \`false\` removes it for print and keeps the keyboard reading and the table. | ${having("tooltip")} |
|
|
251
|
+
| ${f.p("BarChart", "onSelect")} | Called on Enter, Space or a click at the reading position, with what is there: \`{ index, key, datum }\` on a bar. \`component\` prints each member's payload. | ${having("onSelect")} |
|
|
252
|
+
| ${f.p("LineChart", "onBrushEnd")} | A range a person selected with Shift and the arrows or the pointer: ISO strings on a \`time\` x, numbers on a \`linear\` one. It does not filter the chart: put the range in app state. | ${having("onBrushEnd")} |
|
|
253
|
+
| ${f.p("LineChart", "syncId")} | The same string on sibling charts moves their reading together, by x value. | ${having("syncId")} |
|
|
254
|
+
| ${f.p("BarChart", "annotations")} | Marks over the plot, by \`kind\`: a \`line\` for a target, a \`band\` for a window, a \`point\` for an event. | ${having("annotations")} |
|
|
255
|
+
| ${f.p("BarChart", "baseline")} | One target line. | ${having("baseline")} |
|
|
256
|
+
| ${f.p("BarChart", "emphasis")} | A series' \`key\`. That series keeps its colour, and every other series turns grey unless it has a ${series("tone")}. | ${having("emphasis")} |
|
|
257
|
+
| ${f.p("BarChart", "loading")} | A skeleton on the first load, and the previous frame dimmed on a refetch. It wins over the empty state, so pass it with \`data={[]}\` until the rows arrive. An error is not a chart state: show an ${f.m("Alert")} beside the chart. \`data={[]}\` alone draws the empty state with its own sentence. | ${having("loading")} |
|
|
258
|
+
| ${f.p("BarChart", "messages")}, ${f.p("BarChart", "locale")} | Every sentence a chart says, for another language. Pass every key, and the same object to every chart: spread ${catalog} and replace keys, \`{ ...DEFAULT_CHART_MESSAGES, empty: 'Nothing this week' }\`. | ${having("messages")} |
|
|
259
|
+
|
|
260
|
+
A series takes the next of eight colours in the order it is declared, so filtering the data never
|
|
261
|
+
recolours the series that stay. A ninth series and every one after it draws in grey, with a warning
|
|
262
|
+
in development: fold the tail into one "Other" series in the data. ${f.m("ScatterChart")} and
|
|
263
|
+
${f.m("RadarChart")} hold fewer, the palette's cap, which \`theme validate\` prints; above it they
|
|
264
|
+
warn and still draw. ${f.m("DonutChart")} takes at most six segments.
|
|
265
|
+
|
|
266
|
+
Put a chart in a ${f.part("Dashboard", "Panel")} or a ${f.m("Card")} whose \`title\` names it. A
|
|
267
|
+
chart draws no title, no surface and no scroll region of its own, and takes its column's width.
|
|
268
|
+
|
|
269
|
+
## 4. What the theme decides
|
|
270
|
+
|
|
271
|
+
A chart takes from the theme its eight series colours, a sequential ramp for magnitude
|
|
272
|
+
(${f.m("Heatmap")}), a diverging pair for signed values (signed ${f.m("Heatmap")} cells, one signed
|
|
273
|
+
${f.m("BarChart")} series, ${f.v("BarChart", "mode", "diverging")}), its grid and axis lines, its
|
|
274
|
+
fonts and its motion. None of these is a prop, and another palette recolours every chart.
|
|
275
|
+
|
|
276
|
+
| Asked for | Answer |
|
|
277
|
+
| --- | --- |
|
|
278
|
+
| Another colour for this series | ${series("slot")}, 1 to 8: the palette's colour at that place, not a value. Two series never share one. ${f.m("DonutChart")}'s segments take ${f.field("DonutSegment", "slot")} too. |
|
|
279
|
+
| This series means good or bad | ${series("tone")}: ${tones}. It takes the status colour, and is not set with ${series("slot")}. |
|
|
280
|
+
| Make one series stand out | ${f.p("LineChart", "emphasis")} with its key. Every other series without a ${series("tone")} turns grey. |
|
|
281
|
+
|
|
282
|
+
**An exact colour for one series**, such as "opened in our brand orange #FF6A00", is not available:
|
|
283
|
+
no prop and no theme field takes a colour value for a series. Tell the developer so, then offer
|
|
284
|
+
what exists. Slot 1, which the first series takes, follows the palette's accent hue; in a palette
|
|
285
|
+
with no hue (\`chromaBudget\` \`none\` or \`ink\`, as \`neutral\` is) it is orange. \`render\` shows
|
|
286
|
+
it. ${f.p("LineChart", "emphasis")} greys every other series: "make resolved stand out" with it
|
|
287
|
+
turns opened grey, so ask which of the two matters more before you set it. In a palette with a hue,
|
|
288
|
+
moving its \`accentHue\` to the brand's hue moves slot 1 there, turns the other seven slots with
|
|
289
|
+
it, and changes every accent colour in the app, not only the charts. That is the owner's decision
|
|
290
|
+
about the whole app: offer it, and make it only when asked, with the \`polymorph-theme\` skill.
|
|
291
|
+
|
|
292
|
+
## 5. Keyboard and screen readers
|
|
293
|
+
|
|
294
|
+
The plot is one tab stop named by ${f.p("BarChart", "label")}: the arrow keys move a reading
|
|
295
|
+
position that the tooltip shows and a live region announces, Enter and Space call
|
|
296
|
+
${f.p("BarChart", "onSelect")}, and Escape clears. Every chart but ${f.m("Sparkline")} has a summary
|
|
297
|
+
sentence and a table of every value behind a button. Do not wrap a chart in a link, a button or a
|
|
298
|
+
handler of its own, and write ${f.p("Sparkline", "label")} as the reading itself ("First response,
|
|
299
|
+
trending down").
|
|
300
|
+
|
|
301
|
+
## 6. A chart no member draws
|
|
302
|
+
|
|
303
|
+
\`polymorph/no-external-dataviz\` refuses an import of a chart library or of d3 in application
|
|
304
|
+
code. It is answered by rung 1, a chart member, or rung 4, a declared zone: a ${f.m("ThirdParty")}
|
|
305
|
+
boundary around a library that draws the chart itself, or a ${f.m("Bespoke")} zone whose file draws
|
|
306
|
+
SVG by hand, d3's maths included. Give either one the theme's colours (\`var(--pm-chart-1)\` …
|
|
307
|
+
\`var(--pm-chart-8)\`, or ${f.x("useThemeValues", "@polymorph/react")} for a library that takes
|
|
308
|
+
values). The \`polymorph-rules\` skill has each rung.
|
|
309
|
+
|
|
310
|
+
\`\`\`tsx
|
|
311
|
+
import { area } from 'd3-shape'
|
|
312
|
+
import { Bespoke } from '${VOCABULARY}'
|
|
313
|
+
|
|
314
|
+
const ridge = area<number>().x((_, index) => index * 10).y0(40).y1((value) => 40 - value)
|
|
315
|
+
|
|
316
|
+
<Bespoke reason="Hourly load as a ridgeline: no chart member draws one.">
|
|
317
|
+
<svg viewBox="0 0 240 40" role="img" aria-label="Hourly load">
|
|
318
|
+
<path d={ridge(values) ?? ''} style={{ fill: 'var(--pm-chart-1)' }} />
|
|
319
|
+
</svg>
|
|
320
|
+
</Bespoke>
|
|
321
|
+
\`\`\`
|
|
322
|
+
|
|
323
|
+
## 7. On iOS and Android
|
|
324
|
+
|
|
325
|
+
A phone platform draws a chart member natively, adapts it, or has it absent and names a substitute.
|
|
326
|
+
The card's Platforms section lists each platform's absent members with their substitutes, and
|
|
327
|
+
\`component <Name>\` says where one member renders. The \`polymorph-native\` skill covers a SwiftUI
|
|
328
|
+
or Compose screen.
|
|
329
|
+
|
|
330
|
+
${commands(run, "card --platform ios --framework <framework>")}
|
|
331
|
+
`.trimStart();
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
export { chartsReference };
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Facts, all } from "./facts.js";
|
|
2
|
+
//#region ../cli/src/skills/screen-chat.ts
|
|
3
|
+
/**
|
|
4
|
+
* The conversation screen: the members of the `ai` tier, the page that holds
|
|
5
|
+
* them, and what the container owns. The screen skill sends a model here when
|
|
6
|
+
* the screen holds a conversation with a model. The member table is read from
|
|
7
|
+
* the registry, so a member added to the tier is listed without an edit.
|
|
8
|
+
*/
|
|
9
|
+
function chatReference(registry) {
|
|
10
|
+
const f = new Facts(registry);
|
|
11
|
+
const members = f.tier("ai").map((name) => `| ${f.m(name)} | ${f.purpose(name)} |`).join("\n");
|
|
12
|
+
const turn = all(f.values("ChatMessage", "status").map((value) => `\`${value}\``));
|
|
13
|
+
const tool = all(f.values("ToolCall", "status").map((value) => `\`${value}\``));
|
|
14
|
+
const step = all(f.fieldValues("PlanStep", "status").map((value) => `\`${value}\``));
|
|
15
|
+
const attachment = all(f.fieldValues("PromptAttachment", "status").map((value) => `\`${value}\``));
|
|
16
|
+
return `
|
|
17
|
+
# A conversation with a model
|
|
18
|
+
|
|
19
|
+
A screen where a person talks with a model, turn by turn, is built from the conversation members.
|
|
20
|
+
They draw what the container tells them. The container owns the model, the transport and the
|
|
21
|
+
messages.
|
|
22
|
+
|
|
23
|
+
People who write to each other on a record, such as a ticket's messages or a document's comments,
|
|
24
|
+
are not in a conversation with a model. That is ${f.m("CommentThread")}, with
|
|
25
|
+
${f.part("CommentThread", "Comment")} for each comment, read from the top of the page.
|
|
26
|
+
|
|
27
|
+
## 1. The members
|
|
28
|
+
|
|
29
|
+
| Member | What it is |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
${members}
|
|
32
|
+
|
|
33
|
+
\`component <Name>\` prints each one's props and, under \`## Types\`, the fields of the data types
|
|
34
|
+
those props take, such as a trigger, an attachment or a source. Do not build any of these from other
|
|
35
|
+
members, and do not bring in a chat library's components.
|
|
36
|
+
|
|
37
|
+
## 2. The page
|
|
38
|
+
|
|
39
|
+
${f.m("ConversationPage")} is the page archetype. Its ${f.p("ConversationPage", "thread")} takes the
|
|
40
|
+
${f.m("ChatThread")}, its ${f.p("ConversationPage", "composer")} the ${f.m("PromptInput")}, and its
|
|
41
|
+
${f.p("ConversationPage", "aside")} an ${f.m("ArtifactPane")}, named by
|
|
42
|
+
${f.p("ConversationPage", "asideLabel")}. Use it and no other layout. The thread is the one region
|
|
43
|
+
that scrolls, and it needs a bounded box that application code cannot draw. The page itself does not
|
|
44
|
+
scroll, so the composer stays in view.
|
|
45
|
+
|
|
46
|
+
Write this screen in code. A screen spec repeats nothing, and a thread has one
|
|
47
|
+
${f.m("ChatMessage")} for each turn. The app's router or root mounts the page as it mounts any
|
|
48
|
+
other ([app.md](app.md)).
|
|
49
|
+
|
|
50
|
+
## 3. The container
|
|
51
|
+
|
|
52
|
+
\`\`\`tsx
|
|
53
|
+
import { useState } from 'react'
|
|
54
|
+
import { ChatMessage, ChatThread, ConversationPage, Markdown, PromptInput } from '@polymorph/react-ui'
|
|
55
|
+
|
|
56
|
+
import { streamReply } from './model'
|
|
57
|
+
|
|
58
|
+
interface Turn {
|
|
59
|
+
id: string
|
|
60
|
+
role: 'user' | 'assistant'
|
|
61
|
+
text: string
|
|
62
|
+
status?: 'streaming' | 'complete' | 'stopped' | 'error'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function AssistantPage() {
|
|
66
|
+
const [turns, setTurns] = useState<Turn[]>([])
|
|
67
|
+
const [request, setRequest] = useState<AbortController>()
|
|
68
|
+
const streaming = request !== undefined
|
|
69
|
+
|
|
70
|
+
async function send(text: string) {
|
|
71
|
+
const id = crypto.randomUUID()
|
|
72
|
+
const controller = new AbortController()
|
|
73
|
+
const change = (next: Partial<Turn>) =>
|
|
74
|
+
setTurns((all) => all.map((turn) => (turn.id === id ? { ...turn, ...next } : turn)))
|
|
75
|
+
setRequest(controller)
|
|
76
|
+
setTurns((all) => [
|
|
77
|
+
...all,
|
|
78
|
+
{ id: \`\${id}-asked\`, role: 'user', text },
|
|
79
|
+
{ id, role: 'assistant', text: '', status: 'streaming' },
|
|
80
|
+
])
|
|
81
|
+
try {
|
|
82
|
+
let reply = ''
|
|
83
|
+
for await (const piece of streamReply(text, controller.signal)) {
|
|
84
|
+
reply += piece
|
|
85
|
+
change({ text: reply })
|
|
86
|
+
}
|
|
87
|
+
change({ status: 'complete' })
|
|
88
|
+
} catch {
|
|
89
|
+
change({ status: controller.signal.aborted ? 'stopped' : 'error' })
|
|
90
|
+
} finally {
|
|
91
|
+
setRequest(undefined)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<ConversationPage
|
|
97
|
+
title="Assistant"
|
|
98
|
+
thread={
|
|
99
|
+
<ChatThread label="Conversation" streaming={streaming}>
|
|
100
|
+
{turns.map((turn) => (
|
|
101
|
+
<ChatMessage key={turn.id} role={turn.role} author={turn.role === 'user' ? 'You' : 'Assistant'} status={turn.status}>
|
|
102
|
+
{turn.role === 'user' ? turn.text : <Markdown streaming={turn.status === 'streaming'}>{turn.text}</Markdown>}
|
|
103
|
+
</ChatMessage>
|
|
104
|
+
))}
|
|
105
|
+
</ChatThread>
|
|
106
|
+
}
|
|
107
|
+
composer={<PromptInput label="Message" streaming={streaming} onSubmit={(text) => void send(text)} onStop={() => request?.abort()} />}
|
|
108
|
+
/>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
\`\`\`
|
|
112
|
+
|
|
113
|
+
\`streamReply\` stands for the app's own client: an async iterator of the pieces of a reply. A
|
|
114
|
+
client that also reports a tool request or a reply's sources yields events of several kinds, and
|
|
115
|
+
the container keeps what each one says in the turn. The ${f.m("PromptInput")} here holds its own
|
|
116
|
+
text and empties itself when it sends. One given a ${f.p("PromptInput", "value")} is the app's to
|
|
117
|
+
empty.
|
|
118
|
+
|
|
119
|
+
In Vue,
|
|
120
|
+
Svelte, Solid and Angular the members and props have the same names, and a prop that takes content
|
|
121
|
+
(${f.p("ConversationPage", "thread")}, ${f.p("ConversationPage", "composer")},
|
|
122
|
+
${f.p("ConversationPage", "aside")}, ${f.p("ChatMessage", "actions")}) is the framework's own slot,
|
|
123
|
+
as [code.md](code.md) writes one.
|
|
124
|
+
|
|
125
|
+
## 4. What the container must do
|
|
126
|
+
|
|
127
|
+
- **Own the network.** No member fetches, uploads, retries or stores. A member draws what its props
|
|
128
|
+
say and asks through its handlers: ${f.p("PromptInput", "onSubmit")},
|
|
129
|
+
${f.p("PromptInput", "onStop")}, ${f.p("PromptInput", "onAttach")},
|
|
130
|
+
${f.p("PromptInput", "onReject")}, ${f.p("ApprovalCard", "onApprove")} and
|
|
131
|
+
${f.p("ApprovalCard", "onDeny")}.
|
|
132
|
+
- **Stream by rendering again.** ${f.p("Markdown", "streaming")} means more is coming. Pass the
|
|
133
|
+
longer string each time a piece arrives. Set it on the ${f.m("Markdown")} or
|
|
134
|
+
${f.m("StreamingText")} that is growing, on the ${f.m("ChatThread")} and on the
|
|
135
|
+
${f.m("PromptInput")}, whose send control becomes a stop control. Do not animate arriving text and
|
|
136
|
+
do not add a typing indicator: the members show the one pending signal.
|
|
137
|
+
- **Say how each turn ended.** ${f.m("ChatMessage")}'s ${f.p("ChatMessage", "status")} is ${turn},
|
|
138
|
+
with the reason in ${f.p("ChatMessage", "statusMessage")}. A reply the person stopped keeps the
|
|
139
|
+
text that arrived.
|
|
140
|
+
- **Show a model's text as ${f.m("Markdown")}.** It draws headings, lists, code and links through
|
|
141
|
+
the vocabulary, tolerates text that is half written, shows raw HTML as literal text and drops a
|
|
142
|
+
link whose target is unsafe. Use ${f.m("StreamingText")} only for text with no structure. Do not
|
|
143
|
+
render a model's text any other way.
|
|
144
|
+
- **Cite with numbers.** Give ${f.m("Markdown")} the reply's ${f.p("Markdown", "sources")}, each
|
|
145
|
+
with ${f.field("CitationSource", "title")} and ${f.field("CitationSource", "href")}. A \`[1]\` in
|
|
146
|
+
the text becomes a ${f.m("Citation")} of the first one. Put a ${f.m("SourceList")} of the same
|
|
147
|
+
sources under the reply.
|
|
148
|
+
- **Show work as members.** A tool that ran is a ${f.m("ToolCall")}, its
|
|
149
|
+
${f.p("ToolCall", "status")} one of ${tool}. The steps of a run are a ${f.m("Plan")}, each
|
|
150
|
+
${f.field("PlanStep", "status")} one of ${step}. Thinking is a ${f.m("ReasoningDisclosure")}. A
|
|
151
|
+
document the reply produced goes in the ${f.m("ArtifactPane")}.
|
|
152
|
+
- **Ask before a tool acts with ${f.m("ApprovalCard")}** (step 5). It stores no answer.
|
|
153
|
+
- **Hold attachments as data.** ${f.m("PromptInput")}'s ${f.p("PromptInput", "attachments")} is a
|
|
154
|
+
list with ${f.field("PromptAttachment", "id")}, ${f.field("PromptAttachment", "name")} and
|
|
155
|
+
${f.field("PromptAttachment", "status")}, one of ${attachment}. The app uploads a file when
|
|
156
|
+
${f.p("PromptInput", "onAttach")} gives it, and removes one on
|
|
157
|
+
${f.p("PromptInput", "onRemoveAttachment")}. ${f.p("PromptInput", "onReject")} gives each file
|
|
158
|
+
the composer refused with the reason, which the app says in a ${f.m("Toast")}. The app sends the
|
|
159
|
+
ids of the uploaded files with the message.
|
|
160
|
+
- **Offer mentions and commands through ${f.p("PromptInput", "triggers")}.** Each has a
|
|
161
|
+
${f.field("PromptTrigger", "char")} such as \`@\` or \`/\`, a ${f.field("PromptTrigger", "label")}
|
|
162
|
+
and the app's ${f.field("PromptTrigger", "options")}. A pick writes text into the prompt and calls
|
|
163
|
+
${f.field("PromptTrigger", "onSelect")} with the option. The prompt holds text and no ids, so the
|
|
164
|
+
app keeps the picked options and, when the prompt is sent, sends the ids of those whose text is
|
|
165
|
+
still in it. ${f.m("RichTextInput")} differs: its mention is an entity the document stores, and
|
|
166
|
+
it names the character ${f.field("RichTextEntitySource", "trigger")}
|
|
167
|
+
([rich-text.md](rich-text.md)). For
|
|
168
|
+
options the app searches for, set ${f.field("PromptTrigger", "filter")} to \`false\`, read the
|
|
169
|
+
query from ${f.field("PromptTrigger", "onQueryChange")} and set
|
|
170
|
+
${f.field("PromptTrigger", "loading")} until they arrive.
|
|
171
|
+
- **Take voice with ${f.m("RecordButton")}** in ${f.m("PromptInput")}'s
|
|
172
|
+
${f.p("PromptInput", "trailing")}. The app records, and passes
|
|
173
|
+
${f.p("RecordButton", "elapsed")} and ${f.p("RecordButton", "level")} back. An
|
|
174
|
+
${f.m("AudioPlayer")} in a turn plays the recording.
|
|
175
|
+
- **Pass the words.** Every label and status a member shows or announces is a prop, in the app's
|
|
176
|
+
language: ${f.p("ChatThread", "label")} and ${f.p("ChatThread", "messages")},
|
|
177
|
+
${f.p("PromptInput", "label")}, ${f.p("ApprovalCard", "approveLabel")} and
|
|
178
|
+
${f.p("ApprovalCard", "denyLabel")}, ${f.p("ReasoningDisclosure", "label")}. The app formats a
|
|
179
|
+
duration ("Thought for 12 seconds"). No member counts time.
|
|
180
|
+
|
|
181
|
+
The thread announces each turn once to a screen reader when it is added. Do not add a live region
|
|
182
|
+
of your own, and do not put the thread inside another scrolling box.
|
|
183
|
+
|
|
184
|
+
## 5. A tool that asks first
|
|
185
|
+
|
|
186
|
+
\`\`\`tsx
|
|
187
|
+
import { ApprovalCard, ChatMessage, ToolCall } from '@polymorph/react-ui'
|
|
188
|
+
|
|
189
|
+
type Answer = 'approved' | 'denied'
|
|
190
|
+
|
|
191
|
+
interface Call {
|
|
192
|
+
id: string
|
|
193
|
+
name: string
|
|
194
|
+
summary: string
|
|
195
|
+
input: unknown
|
|
196
|
+
/** The answer on its way to the server. */
|
|
197
|
+
sending?: Answer
|
|
198
|
+
/** The answer the server has. */
|
|
199
|
+
decision?: Answer
|
|
200
|
+
/** How the run stands once it is approved. */
|
|
201
|
+
run: 'running' | 'done' | 'error'
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function ToolTurn({ call, onAnswer }: { call: Call; onAnswer: (id: string, answer: Answer) => void }) {
|
|
205
|
+
const status = call.decision === undefined ? 'approval' : call.decision === 'denied' ? 'denied' : call.run
|
|
206
|
+
return (
|
|
207
|
+
<ChatMessage role="assistant" author="Assistant">
|
|
208
|
+
<ToolCall name={call.name} summary={call.summary} input={call.input} status={status} />
|
|
209
|
+
<ApprovalCard
|
|
210
|
+
title={\`Run \${call.name}?\`}
|
|
211
|
+
description={call.summary}
|
|
212
|
+
pending={call.sending}
|
|
213
|
+
decision={call.decision}
|
|
214
|
+
onApprove={() => onAnswer(call.id, 'approved')}
|
|
215
|
+
onDeny={() => onAnswer(call.id, 'denied')}
|
|
216
|
+
/>
|
|
217
|
+
</ChatMessage>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
\`\`\`
|
|
221
|
+
|
|
222
|
+
- The model's client reports the request, and the container adds the call to the turn of the reply
|
|
223
|
+
that asked. The ${f.m("ToolCall")} and the ${f.m("ApprovalCard")} sit side by side in that turn's
|
|
224
|
+
${f.m("ChatMessage")}.
|
|
225
|
+
- On an answer the container sets ${f.p("ApprovalCard", "pending")} and sends the answer to its
|
|
226
|
+
server. When the server has it, the container sets ${f.p("ApprovalCard", "decision")}.
|
|
227
|
+
- Both stay in the turn. The ${f.m("ToolCall")}'s ${f.p("ToolCall", "status")} goes from
|
|
228
|
+
\`approval\` to \`running\` and then \`done\` or \`error\`, or to \`denied\`. The card with a
|
|
229
|
+
${f.p("ApprovalCard", "decision")} is the record of who allowed what, so do not remove it.
|
|
230
|
+
- Write ${f.p("ApprovalCard", "title")} as a question the person can answer, from the app's own
|
|
231
|
+
data: the order's number and the amount, not the model's sentence. Set
|
|
232
|
+
${f.p("ApprovalCard", "tone")} to \`danger\` for what cannot be undone.
|
|
233
|
+
- The tool runs on the server, and only after the server has the approval. A page that runs the
|
|
234
|
+
tool because its own state says "approved" has asked nobody.
|
|
235
|
+
|
|
236
|
+
## 6. What the members do not do
|
|
237
|
+
|
|
238
|
+
- They hold no model client, no stream reader and no message store. Those are the app's.
|
|
239
|
+
- A code block is not coloured by token.
|
|
240
|
+
- Editing, branching and regenerating a turn are the app's ${f.m("Button")}s in
|
|
241
|
+
${f.m("ChatMessage")}'s ${f.p("ChatMessage", "actions")}.
|
|
242
|
+
- A turn that holds a screen the model wrote, such as a form to fill, is the
|
|
243
|
+
\`polymorph-runtime-screen\` skill's.
|
|
244
|
+
`.trimStart();
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
export { chatReference };
|