@getcortexlabs/mavis-core 0.1.0-alpha.1 → 0.1.0-alpha.11
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/README.md +2 -2
- package/dist/accordion.d.ts +17 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +42 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert.d.ts +21 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +13 -0
- package/dist/alert.js.map +1 -0
- package/dist/app-icons.d.ts +27 -0
- package/dist/app-icons.d.ts.map +1 -0
- package/dist/app-icons.js +42 -0
- package/dist/app-icons.js.map +1 -0
- package/dist/avatar.d.ts +10 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +11 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +7 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +11 -0
- package/dist/badge.js.map +1 -0
- package/dist/capabilities.d.ts +132 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +180 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chart.d.ts +40 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +73 -0
- package/dist/chart.js.map +1 -0
- package/dist/chip.d.ts +9 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +16 -0
- package/dist/chip.js.map +1 -0
- package/dist/choice-motion.d.ts +14 -0
- package/dist/choice-motion.d.ts.map +1 -0
- package/dist/choice-motion.js +5 -0
- package/dist/choice-motion.js.map +1 -0
- package/dist/choice.d.ts +15 -0
- package/dist/choice.d.ts.map +1 -0
- package/dist/choice.js +27 -0
- package/dist/choice.js.map +1 -0
- package/dist/collections.d.ts +46 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +48 -0
- package/dist/collections.js.map +1 -0
- package/dist/combobox.d.ts +42 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +159 -0
- package/dist/combobox.js.map +1 -0
- package/dist/contracts.d.ts +1321 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +268 -0
- package/dist/contracts.js.map +1 -0
- package/dist/date-input.d.ts +10 -0
- package/dist/date-input.d.ts.map +1 -0
- package/dist/date-input.js +58 -0
- package/dist/date-input.js.map +1 -0
- package/dist/date-time.d.ts +19 -0
- package/dist/date-time.d.ts.map +1 -0
- package/dist/date-time.js +27 -0
- package/dist/date-time.js.map +1 -0
- package/dist/date.d.ts +96 -0
- package/dist/date.d.ts.map +1 -0
- package/dist/date.js +235 -0
- package/dist/date.js.map +1 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +21 -0
- package/dist/dialog.js.map +1 -0
- package/dist/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +80 -0
- package/dist/discovery.js.map +1 -0
- package/dist/empty-state.d.ts +2 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +5 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/experimental-collections.d.ts +82 -0
- package/dist/experimental-collections.d.ts.map +1 -0
- package/dist/experimental-collections.js +8 -0
- package/dist/experimental-collections.js.map +1 -0
- package/dist/experimental-effects.d.ts +107 -0
- package/dist/experimental-effects.d.ts.map +1 -0
- package/dist/experimental-effects.js +24 -0
- package/dist/experimental-effects.js.map +1 -0
- package/dist/experimental-platforms.d.ts +94 -0
- package/dist/experimental-platforms.d.ts.map +1 -0
- package/dist/experimental-platforms.js +2 -0
- package/dist/experimental-platforms.js.map +1 -0
- package/dist/experimental-playback.d.ts +63 -0
- package/dist/experimental-playback.d.ts.map +1 -0
- package/dist/experimental-playback.js +46 -0
- package/dist/experimental-playback.js.map +1 -0
- package/dist/experimental-regions.d.ts +179 -0
- package/dist/experimental-regions.d.ts.map +1 -0
- package/dist/experimental-regions.js +554 -0
- package/dist/experimental-regions.js.map +1 -0
- package/dist/experimental-sensors.d.ts +42 -0
- package/dist/experimental-sensors.d.ts.map +1 -0
- package/dist/experimental-sensors.js +2 -0
- package/dist/experimental-sensors.js.map +1 -0
- package/dist/experimental-surfaces.d.ts +127 -0
- package/dist/experimental-surfaces.d.ts.map +1 -0
- package/dist/experimental-surfaces.js +2 -0
- package/dist/experimental-surfaces.js.map +1 -0
- package/dist/experimental.d.ts +197 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +855 -0
- package/dist/experimental.js.map +1 -0
- package/dist/files.d.ts +87 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +328 -0
- package/dist/files.js.map +1 -0
- package/dist/form.d.ts +39 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +170 -0
- package/dist/form.js.map +1 -0
- package/dist/grid.d.ts +3 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +16 -0
- package/dist/grid.js.map +1 -0
- package/dist/icon.d.ts +15 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +28 -0
- package/dist/icon.js.map +1 -0
- package/dist/icons.d.ts +2002 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +2003 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +59 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +14 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +12 -0
- package/dist/input.js.map +1 -1
- package/dist/link.d.ts +36 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +60 -0
- package/dist/link.js.map +1 -0
- package/dist/list-item.d.ts +3 -0
- package/dist/list-item.d.ts.map +1 -0
- package/dist/list-item.js +7 -0
- package/dist/list-item.js.map +1 -0
- package/dist/motion.d.ts +58 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +73 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.d.ts +4 -0
- package/dist/multi-select.d.ts.map +1 -0
- package/dist/multi-select.js +23 -0
- package/dist/multi-select.js.map +1 -0
- package/dist/navigation-transition.d.ts +10 -0
- package/dist/navigation-transition.d.ts.map +1 -0
- package/dist/navigation-transition.js +10 -0
- package/dist/navigation-transition.js.map +1 -0
- package/dist/navigation.d.ts +22 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +54 -0
- package/dist/navigation.js.map +1 -0
- package/dist/number-input.d.ts +21 -0
- package/dist/number-input.d.ts.map +1 -0
- package/dist/number-input.js +63 -0
- package/dist/number-input.js.map +1 -0
- package/dist/popover.d.ts +17 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +19 -0
- package/dist/popover.js.map +1 -0
- package/dist/progress.d.ts +19 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +19 -0
- package/dist/progress.js.map +1 -0
- package/dist/responsive.d.ts +18 -0
- package/dist/responsive.d.ts.map +1 -0
- package/dist/responsive.js +35 -0
- package/dist/responsive.js.map +1 -0
- package/dist/section-scroll.d.ts +14 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +28 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/segmented.d.ts +11 -0
- package/dist/segmented.d.ts.map +1 -0
- package/dist/segmented.js +30 -0
- package/dist/segmented.js.map +1 -0
- package/dist/sheet.d.ts +19 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +15 -0
- package/dist/sheet.js.map +1 -0
- package/dist/tabs.d.ts +11 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +28 -0
- package/dist/tabs.js.map +1 -0
- package/dist/theme/themes.d.ts.map +1 -1
- package/dist/theme/themes.js +85 -12
- package/dist/theme/themes.js.map +1 -1
- package/dist/theme/types.d.ts +64 -4
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/typography.d.ts +10 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +90 -0
- package/dist/theme/typography.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +78 -0
- package/dist/time.js.map +1 -0
- package/dist/toast.d.ts +43 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +228 -0
- package/dist/toast.js.map +1 -0
- package/dist/vue/button-content.d.ts +10 -0
- package/dist/vue/button-content.d.ts.map +1 -0
- package/dist/vue/button-content.js +54 -0
- package/dist/vue/button-content.js.map +1 -0
- package/dist/vue/cached-activity.d.ts +3 -0
- package/dist/vue/cached-activity.d.ts.map +1 -0
- package/dist/vue/cached-activity.js +13 -0
- package/dist/vue/cached-activity.js.map +1 -0
- package/dist/vue/carousel.d.ts +11 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +115 -0
- package/dist/vue/carousel.js.map +1 -0
- package/dist/vue/chart.d.ts +194 -0
- package/dist/vue/chart.d.ts.map +1 -0
- package/dist/vue/chart.js +246 -0
- package/dist/vue/chart.js.map +1 -0
- package/dist/vue/combobox.d.ts +155 -0
- package/dist/vue/combobox.d.ts.map +1 -0
- package/dist/vue/combobox.js +195 -0
- package/dist/vue/combobox.js.map +1 -0
- package/dist/vue/command-palette.d.ts +129 -0
- package/dist/vue/command-palette.d.ts.map +1 -0
- package/dist/vue/command-palette.js +187 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-props.d.ts +3310 -0
- package/dist/vue/component-props.d.ts.map +1 -0
- package/dist/vue/component-props.js +43 -0
- package/dist/vue/component-props.js.map +1 -0
- package/dist/vue/configurator-props.d.ts +277 -0
- package/dist/vue/configurator-props.d.ts.map +1 -0
- package/dist/vue/configurator-props.js +63 -0
- package/dist/vue/configurator-props.js.map +1 -0
- package/dist/vue/configurator.d.ts +403 -0
- package/dist/vue/configurator.d.ts.map +1 -0
- package/dist/vue/configurator.js +287 -0
- package/dist/vue/configurator.js.map +1 -0
- package/dist/vue/contracts.d.ts +18 -0
- package/dist/vue/contracts.d.ts.map +1 -0
- package/dist/vue/contracts.js +24 -0
- package/dist/vue/contracts.js.map +1 -0
- package/dist/vue/data-table.d.ts +17 -0
- package/dist/vue/data-table.d.ts.map +1 -0
- package/dist/vue/data-table.js +133 -0
- package/dist/vue/data-table.js.map +1 -0
- package/dist/vue/date-calendar.d.ts +64 -0
- package/dist/vue/date-calendar.d.ts.map +1 -0
- package/dist/vue/date-calendar.js +65 -0
- package/dist/vue/date-calendar.js.map +1 -0
- package/dist/vue/date-picker.d.ts +1000 -0
- package/dist/vue/date-picker.d.ts.map +1 -0
- package/dist/vue/date-picker.js +334 -0
- package/dist/vue/date-picker.js.map +1 -0
- package/dist/vue/date-props.d.ts +278 -0
- package/dist/vue/date-props.d.ts.map +1 -0
- package/dist/vue/date-props.js +81 -0
- package/dist/vue/date-props.js.map +1 -0
- package/dist/vue/dialog.d.ts +21 -0
- package/dist/vue/dialog.d.ts.map +1 -0
- package/dist/vue/dialog.js +58 -0
- package/dist/vue/dialog.js.map +1 -0
- package/dist/vue/discovery-components.d.ts +50 -0
- package/dist/vue/discovery-components.d.ts.map +1 -0
- package/dist/vue/discovery-components.js +2 -0
- package/dist/vue/discovery-components.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +197 -0
- package/dist/vue/discovery-controls.d.ts.map +1 -0
- package/dist/vue/discovery-controls.js +166 -0
- package/dist/vue/discovery-controls.js.map +1 -0
- package/dist/vue/discovery-props.d.ts +249 -0
- package/dist/vue/discovery-props.d.ts.map +1 -0
- package/dist/vue/discovery-props.js +87 -0
- package/dist/vue/discovery-props.js.map +1 -0
- package/dist/vue/files.d.ts +53 -0
- package/dist/vue/files.d.ts.map +1 -0
- package/dist/vue/files.js +40 -0
- package/dist/vue/files.js.map +1 -0
- package/dist/vue/forms.d.ts +4 -0
- package/dist/vue/forms.d.ts.map +1 -0
- package/dist/vue/forms.js +15 -0
- package/dist/vue/forms.js.map +1 -0
- package/dist/vue/global-components.d.ts +259 -3
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +54 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +45 -2
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/inline-content.d.ts +54 -0
- package/dist/vue/inline-content.d.ts.map +1 -0
- package/dist/vue/inline-content.js +64 -0
- package/dist/vue/inline-content.js.map +1 -0
- package/dist/vue/layout-context.d.ts +4 -2
- package/dist/vue/layout-context.d.ts.map +1 -1
- package/dist/vue/layout-context.js +7 -2
- package/dist/vue/layout-context.js.map +1 -1
- package/dist/vue/list-motion.d.ts +7 -0
- package/dist/vue/list-motion.d.ts.map +1 -0
- package/dist/vue/list-motion.js +28 -0
- package/dist/vue/list-motion.js.map +1 -0
- package/dist/vue/loading-effect.d.ts +7 -0
- package/dist/vue/loading-effect.d.ts.map +1 -0
- package/dist/vue/loading-effect.js +32 -0
- package/dist/vue/loading-effect.js.map +1 -0
- package/dist/vue/menu.d.ts +122 -0
- package/dist/vue/menu.d.ts.map +1 -0
- package/dist/vue/menu.js +79 -0
- package/dist/vue/menu.js.map +1 -0
- package/dist/vue/navigation-controls.d.ts +124 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +117 -0
- package/dist/vue/navigation-controls.js.map +1 -0
- package/dist/vue/navigation-props.d.ts +283 -0
- package/dist/vue/navigation-props.d.ts.map +1 -0
- package/dist/vue/navigation-props.js +82 -0
- package/dist/vue/navigation-props.js.map +1 -0
- package/dist/vue/navigation.d.ts +7 -0
- package/dist/vue/navigation.d.ts.map +1 -0
- package/dist/vue/navigation.js +15 -0
- package/dist/vue/navigation.js.map +1 -0
- package/dist/vue/platform.d.ts +37 -0
- package/dist/vue/platform.d.ts.map +1 -0
- package/dist/vue/platform.js +46 -0
- package/dist/vue/platform.js.map +1 -0
- package/dist/vue/props.d.ts +3326 -510
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +314 -83
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/reveal-state.d.ts +18 -0
- package/dist/vue/reveal-state.d.ts.map +1 -0
- package/dist/vue/reveal-state.js +76 -0
- package/dist/vue/reveal-state.js.map +1 -0
- package/dist/vue/theme-provider.d.ts +58 -0
- package/dist/vue/theme-provider.d.ts.map +1 -0
- package/dist/vue/theme-provider.js +69 -0
- package/dist/vue/theme-provider.js.map +1 -0
- package/dist/vue/theme.d.ts +1029 -19
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +47 -2
- package/dist/vue/theme.js.map +1 -1
- package/dist/vue/time-picker.d.ts +488 -0
- package/dist/vue/time-picker.d.ts.map +1 -0
- package/dist/vue/time-picker.js +190 -0
- package/dist/vue/time-picker.js.map +1 -0
- package/dist/vue/toast.d.ts +29 -0
- package/dist/vue/toast.d.ts.map +1 -0
- package/dist/vue/toast.js +79 -0
- package/dist/vue/toast.js.map +1 -0
- package/dist/vue/tree-view.d.ts +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +180 -0
- package/dist/vue/tree-view.js.map +1 -0
- package/dist/vue/virtual-list.d.ts +26 -0
- package/dist/vue/virtual-list.d.ts.map +1 -0
- package/dist/vue/virtual-list.js +2 -0
- package/dist/vue/virtual-list.js.map +1 -0
- package/dist/vue/wayfinding-controls.d.ts +198 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +310 -0
- package/dist/vue/wayfinding-controls.js.map +1 -0
- package/dist/vue/wayfinding-props.d.ts +221 -0
- package/dist/vue/wayfinding-props.d.ts.map +1 -0
- package/dist/vue/wayfinding-props.js +86 -0
- package/dist/vue/wayfinding-props.js.map +1 -0
- package/dist/vue/workflow-props.d.ts +110 -0
- package/dist/vue/workflow-props.d.ts.map +1 -0
- package/dist/vue/workflow-props.js +37 -0
- package/dist/vue/workflow-props.js.map +1 -0
- package/dist/vue/workflows.d.ts +267 -0
- package/dist/vue/workflows.d.ts.map +1 -0
- package/dist/vue/workflows.js +200 -0
- package/dist/vue/workflows.js.map +1 -0
- package/dist/wayfinding.d.ts +50 -0
- package/dist/wayfinding.d.ts.map +1 -0
- package/dist/wayfinding.js +54 -0
- package/dist/wayfinding.js.map +1 -0
- package/package.json +5 -1
- package/src/accordion.ts +66 -0
- package/src/alert.ts +16 -0
- package/src/app-icons.ts +57 -0
- package/src/avatar.ts +11 -0
- package/src/badge.ts +11 -0
- package/src/capabilities.ts +183 -0
- package/src/chart.ts +112 -0
- package/src/chip.ts +20 -0
- package/src/choice-motion.ts +12 -0
- package/src/choice.ts +41 -0
- package/src/collections.ts +87 -0
- package/src/combobox.ts +198 -0
- package/src/contracts.ts +324 -0
- package/src/date-input.ts +87 -0
- package/src/date-time.ts +37 -0
- package/src/date.ts +280 -0
- package/src/dialog.ts +22 -0
- package/src/discovery.ts +139 -0
- package/src/empty-state.ts +4 -0
- package/src/experimental-collections.ts +87 -0
- package/src/experimental-effects.ts +146 -0
- package/src/experimental-platforms.ts +96 -0
- package/src/experimental-playback.ts +115 -0
- package/src/experimental-regions.ts +777 -0
- package/src/experimental-sensors.ts +50 -0
- package/src/experimental-surfaces.ts +124 -0
- package/src/experimental.ts +1102 -0
- package/src/files.ts +408 -0
- package/src/form.ts +190 -0
- package/src/grid.ts +19 -0
- package/src/icon.ts +30 -0
- package/src/icons.ts +2002 -0
- package/src/index.ts +93 -2
- package/src/input.ts +27 -0
- package/src/link.ts +91 -0
- package/src/list-item.ts +5 -0
- package/src/motion.ts +80 -0
- package/src/multi-select.ts +30 -0
- package/src/navigation-transition.ts +14 -0
- package/src/navigation.ts +61 -0
- package/src/number-input.ts +80 -0
- package/src/popover.ts +38 -0
- package/src/progress.ts +22 -0
- package/src/responsive.ts +61 -0
- package/src/section-scroll.ts +46 -0
- package/src/segmented.ts +39 -0
- package/src/sheet.ts +31 -0
- package/src/tabs.ts +35 -0
- package/src/theme/themes.ts +89 -12
- package/src/theme/types.ts +55 -2
- package/src/theme/typography.ts +84 -0
- package/src/time.ts +83 -0
- package/src/toast.ts +249 -0
- package/src/vue/button-content.ts +60 -0
- package/src/vue/cached-activity.ts +13 -0
- package/src/vue/carousel.ts +173 -0
- package/src/vue/chart.ts +338 -0
- package/src/vue/combobox.ts +238 -0
- package/src/vue/command-palette.ts +232 -0
- package/src/vue/component-props.ts +70 -0
- package/src/vue/configurator-props.ts +67 -0
- package/src/vue/configurator.ts +350 -0
- package/src/vue/contracts.ts +39 -0
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +76 -0
- package/src/vue/date-picker.ts +410 -0
- package/src/vue/date-props.ts +89 -0
- package/src/vue/dialog.ts +63 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +218 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/files.ts +53 -0
- package/src/vue/forms.ts +20 -0
- package/src/vue/global-components.ts +248 -4
- package/src/vue/index.ts +97 -4
- package/src/vue/inline-content.ts +71 -0
- package/src/vue/layout-context.ts +10 -3
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/loading-effect.ts +44 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +138 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/navigation.ts +16 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +348 -96
- package/src/vue/reveal-state.ts +83 -0
- package/src/vue/theme-provider.ts +74 -0
- package/src/vue/theme.ts +65 -3
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/toast.ts +99 -0
- package/src/vue/tree-view.ts +220 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +412 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflow-props.ts +41 -0
- package/src/vue/workflows.ts +257 -0
- package/src/wayfinding.ts +85 -0
package/src/accordion.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isChoiceValue, type ChoiceValue } from './choice.js'
|
|
2
|
+
import type { IconName } from './icon.js'
|
|
3
|
+
|
|
4
|
+
export interface AccordionItem {
|
|
5
|
+
value: ChoiceValue
|
|
6
|
+
title: string
|
|
7
|
+
description?: string
|
|
8
|
+
icon?: IconName
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
}
|
|
11
|
+
export interface AccordionPanelProps {
|
|
12
|
+
item: AccordionItem
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function validateAccordion(
|
|
16
|
+
items: readonly AccordionItem[],
|
|
17
|
+
expanded: readonly ChoiceValue[],
|
|
18
|
+
multiple: boolean,
|
|
19
|
+
label: string,
|
|
20
|
+
expandedLabel: string,
|
|
21
|
+
collapsedLabel: string,
|
|
22
|
+
) {
|
|
23
|
+
for (const [name, text] of Object.entries({ label, expandedLabel, collapsedLabel })) {
|
|
24
|
+
if (typeof text !== 'string' || !text.trim())
|
|
25
|
+
throw new TypeError(`Accordion ${name} must be a non-empty string.`)
|
|
26
|
+
}
|
|
27
|
+
const seen = new Set<ChoiceValue>()
|
|
28
|
+
for (const item of items) {
|
|
29
|
+
if (!item || !isChoiceValue(item.value) || typeof item.title !== 'string' || !item.title.trim())
|
|
30
|
+
throw new TypeError('Each accordion item needs a string/finite number value and a title.')
|
|
31
|
+
if (seen.has(item.value)) throw new RangeError(`Duplicate accordion item: ${item.value}`)
|
|
32
|
+
seen.add(item.value)
|
|
33
|
+
}
|
|
34
|
+
if (!Array.isArray(expanded) || expanded.some((value) => !isChoiceValue(value)))
|
|
35
|
+
throw new TypeError('Accordion modelValue must be an array of string/finite number values.')
|
|
36
|
+
if (new Set(expanded).size !== expanded.length)
|
|
37
|
+
throw new RangeError('Accordion expanded values must be unique.')
|
|
38
|
+
if (!multiple && expanded.length > 1)
|
|
39
|
+
throw new RangeError('Accordion allows at most one expanded value unless multiple is true.')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The caller applies the returned array; the input is never mutated. */
|
|
43
|
+
export function toggleAccordion(
|
|
44
|
+
item: AccordionItem,
|
|
45
|
+
expanded: readonly ChoiceValue[],
|
|
46
|
+
multiple: boolean,
|
|
47
|
+
disabled = false,
|
|
48
|
+
): ChoiceValue[] | undefined {
|
|
49
|
+
if (disabled || item.disabled) return
|
|
50
|
+
if (expanded.includes(item.value)) return expanded.filter((value) => value !== item.value)
|
|
51
|
+
return multiple ? [...expanded, item.value] : [item.value]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function accordionFocusTarget(
|
|
55
|
+
items: readonly AccordionItem[],
|
|
56
|
+
value: ChoiceValue,
|
|
57
|
+
key: string,
|
|
58
|
+
): AccordionItem | undefined {
|
|
59
|
+
const enabled = items.filter((item) => !item.disabled)
|
|
60
|
+
if (key === 'Home') return enabled[0]
|
|
61
|
+
if (key === 'End') return enabled[enabled.length - 1]
|
|
62
|
+
if (key !== 'ArrowDown' && key !== 'ArrowUp') return
|
|
63
|
+
const index = enabled.findIndex((item) => item.value === value)
|
|
64
|
+
const step = key === 'ArrowDown' ? 1 : -1
|
|
65
|
+
return enabled[(index + step + enabled.length) % enabled.length]
|
|
66
|
+
}
|
package/src/alert.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IconName } from './icon.js'
|
|
2
|
+
|
|
3
|
+
export type AlertTone = 'info' | 'success' | 'warning' | 'error'
|
|
4
|
+
export const alertAppearance = {
|
|
5
|
+
info: { icon: 'info', tone: 'accent' },
|
|
6
|
+
success: { icon: 'circle-check', tone: 'success' },
|
|
7
|
+
warning: { icon: 'triangle-alert', tone: 'warning' },
|
|
8
|
+
error: { icon: 'circle-alert', tone: 'danger' },
|
|
9
|
+
} as const satisfies Record<AlertTone, { icon: IconName; tone: string }>
|
|
10
|
+
|
|
11
|
+
export function checkAlertLabels(title: string, dismissible: boolean, closeLabel: string) {
|
|
12
|
+
if (typeof title !== 'string' || !title.trim())
|
|
13
|
+
throw new TypeError('Alert title must be a non-empty string')
|
|
14
|
+
if (dismissible && (typeof closeLabel !== 'string' || !closeLabel.trim()))
|
|
15
|
+
throw new TypeError('A dismissible Alert needs a non-empty closeLabel')
|
|
16
|
+
}
|
package/src/app-icons.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface AppIconChoice {
|
|
2
|
+
id: string
|
|
3
|
+
label: string
|
|
4
|
+
}
|
|
5
|
+
export interface AppIconAdapter {
|
|
6
|
+
supported(): boolean
|
|
7
|
+
current(): string | undefined
|
|
8
|
+
select(id: string): Promise<void>
|
|
9
|
+
}
|
|
10
|
+
export class AppIconError extends Error {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly code: 'unsupported' | 'configuration' | 'unknown-icon' | 'platform',
|
|
13
|
+
message: string,
|
|
14
|
+
options?: ErrorOptions,
|
|
15
|
+
) {
|
|
16
|
+
super(message, options)
|
|
17
|
+
this.name = 'AppIconError'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The OS stores selection. Requests are serialized; a rejected request does not block later ones. */
|
|
22
|
+
export function createAppIconController(
|
|
23
|
+
choices: readonly AppIconChoice[],
|
|
24
|
+
primary: string,
|
|
25
|
+
adapter: AppIconAdapter,
|
|
26
|
+
) {
|
|
27
|
+
const ids = new Set<string>()
|
|
28
|
+
for (const choice of choices) {
|
|
29
|
+
if (!choice.id.trim() || !choice.label.trim() || ids.has(choice.id))
|
|
30
|
+
throw new AppIconError('configuration', 'App icons need unique IDs and visible labels.')
|
|
31
|
+
ids.add(choice.id)
|
|
32
|
+
}
|
|
33
|
+
if (!ids.has(primary))
|
|
34
|
+
throw new AppIconError('configuration', 'The primary icon must be configured.')
|
|
35
|
+
let pending = Promise.resolve()
|
|
36
|
+
const select = (id: string): Promise<void> => {
|
|
37
|
+
if (!ids.has(id))
|
|
38
|
+
return Promise.reject(new AppIconError('unknown-icon', `Unknown app icon: ${id}`))
|
|
39
|
+
const task = pending.then(async () => {
|
|
40
|
+
if (!adapter.supported())
|
|
41
|
+
throw new AppIconError('unsupported', 'This runtime cannot change its launcher icon.')
|
|
42
|
+
if (adapter.current() === id) return
|
|
43
|
+
await adapter.select(id)
|
|
44
|
+
})
|
|
45
|
+
pending = task.catch(() => {})
|
|
46
|
+
return task
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
choices: Object.freeze(choices.map((choice) => Object.freeze({ ...choice }))),
|
|
50
|
+
primary,
|
|
51
|
+
supported: () => adapter.supported(),
|
|
52
|
+
current: () => adapter.current(),
|
|
53
|
+
select,
|
|
54
|
+
reset: () => select(primary),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export type AppIconController = ReturnType<typeof createAppIconController>
|
package/src/avatar.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const avatarSizes = { sm: 32, md: 48, lg: 64, xl: 96 } as const
|
|
2
|
+
export type AvatarSize = keyof typeof avatarSizes
|
|
3
|
+
|
|
4
|
+
/** First and last words, normalized before extracting Unicode code points. */
|
|
5
|
+
export function avatarInitials(name: string): string {
|
|
6
|
+
const words = name.trim().normalize('NFC').split(/\s+/).filter(Boolean)
|
|
7
|
+
if (!words.length) return ''
|
|
8
|
+
const first = Array.from(words[0]!)[0]!
|
|
9
|
+
const last = words.length > 1 ? Array.from(words.at(-1)!)[0]! : ''
|
|
10
|
+
return (first + last).toUpperCase()
|
|
11
|
+
}
|
package/src/badge.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Palette } from './theme/types.js'
|
|
2
|
+
export type BadgeTone = 'neutral' | 'primary' | 'accent' | 'success' | 'warning' | 'danger'
|
|
3
|
+
|
|
4
|
+
export function badgeColors(colors: Readonly<Palette>, tone: BadgeTone) {
|
|
5
|
+
if (tone === 'primary') return { color: colors.primary, backgroundColor: colors.primarySoft }
|
|
6
|
+
if (tone === 'accent') return { color: colors.accent, backgroundColor: colors.accentSoft }
|
|
7
|
+
return {
|
|
8
|
+
color: tone === 'neutral' ? colors.text : colors[tone],
|
|
9
|
+
backgroundColor: colors.elevated,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/** Source capabilities, not a promise that every feature is in the last npm release. */
|
|
2
|
+
export const componentNames = [
|
|
3
|
+
'MScreen',
|
|
4
|
+
'MRow',
|
|
5
|
+
'MColumn',
|
|
6
|
+
'MStack',
|
|
7
|
+
'MGrid',
|
|
8
|
+
'MLink',
|
|
9
|
+
'MBox',
|
|
10
|
+
'MCard',
|
|
11
|
+
'MText',
|
|
12
|
+
'MSpan',
|
|
13
|
+
'MThemeProvider',
|
|
14
|
+
'MPlatform',
|
|
15
|
+
'MIcon',
|
|
16
|
+
'MButton',
|
|
17
|
+
'MInput',
|
|
18
|
+
'MSlider',
|
|
19
|
+
'MSwitch',
|
|
20
|
+
'MCheckbox',
|
|
21
|
+
'MRadioGroup',
|
|
22
|
+
'MSelect',
|
|
23
|
+
'MSheet',
|
|
24
|
+
'MDialog',
|
|
25
|
+
'MToast',
|
|
26
|
+
'MTabs',
|
|
27
|
+
'MChip',
|
|
28
|
+
'MEmptyState',
|
|
29
|
+
'MAccordion',
|
|
30
|
+
'MSegmentedControl',
|
|
31
|
+
'MSkeleton',
|
|
32
|
+
'MProgress',
|
|
33
|
+
'MAlert',
|
|
34
|
+
'MAvatar',
|
|
35
|
+
'MBadge',
|
|
36
|
+
'MListItem',
|
|
37
|
+
'MSeparator',
|
|
38
|
+
'MReveal',
|
|
39
|
+
'MDatePicker',
|
|
40
|
+
'MDateRangePicker',
|
|
41
|
+
'MNumberInput',
|
|
42
|
+
'MMultiSelect',
|
|
43
|
+
'MImage',
|
|
44
|
+
'MCombobox',
|
|
45
|
+
'MFilePicker',
|
|
46
|
+
'MFormGroup',
|
|
47
|
+
'MFormErrors',
|
|
48
|
+
'MSteps',
|
|
49
|
+
'MPagination',
|
|
50
|
+
'MPopover',
|
|
51
|
+
'MMenu',
|
|
52
|
+
'MAppBar',
|
|
53
|
+
'MTabBar',
|
|
54
|
+
'MTimePicker',
|
|
55
|
+
'MVirtualList',
|
|
56
|
+
'MDataTable',
|
|
57
|
+
'MCarousel',
|
|
58
|
+
'MRangeSlider',
|
|
59
|
+
'MCalendar',
|
|
60
|
+
'MRating',
|
|
61
|
+
'MTreeView',
|
|
62
|
+
'MCommandPalette',
|
|
63
|
+
'MNavigationRail',
|
|
64
|
+
'MBreadcrumb',
|
|
65
|
+
'MTooltip',
|
|
66
|
+
'MTimeline',
|
|
67
|
+
'MChart',
|
|
68
|
+
] as const
|
|
69
|
+
export type ComponentName = (typeof componentNames)[number]
|
|
70
|
+
export type CapabilityStatus = 'experimental' | 'planned' | 'unsupported' | 'unverified'
|
|
71
|
+
|
|
72
|
+
export const targetCapabilities = {
|
|
73
|
+
version: 1,
|
|
74
|
+
source: 'repository',
|
|
75
|
+
publishedBaseline: '0.1.0-alpha.11',
|
|
76
|
+
developmentMotion: {
|
|
77
|
+
availability: 'published',
|
|
78
|
+
joltCommit: null,
|
|
79
|
+
publishedJoltRelease: '0.1.0-rc.11',
|
|
80
|
+
features: {
|
|
81
|
+
gradient: ['web', 'ios', 'android'],
|
|
82
|
+
loadingEffects: ['web', 'ios'],
|
|
83
|
+
textEffects: ['web', 'ios', 'android'],
|
|
84
|
+
circularVisibility: ['web', 'ios'],
|
|
85
|
+
retainedScrollHeader: ['web', 'ios', 'android'],
|
|
86
|
+
retainedReorder: ['web', 'ios', 'android'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
targets: [
|
|
90
|
+
{
|
|
91
|
+
id: 'vue-web',
|
|
92
|
+
framework: 'vue',
|
|
93
|
+
renderer: 'dom',
|
|
94
|
+
status: 'experimental',
|
|
95
|
+
components: componentNames,
|
|
96
|
+
rendering: {
|
|
97
|
+
client: 'experimental',
|
|
98
|
+
serverImport: 'experimental',
|
|
99
|
+
serverHTML: 'experimental',
|
|
100
|
+
hydration: 'experimental',
|
|
101
|
+
ssg: 'experimental',
|
|
102
|
+
streaming: 'unverified',
|
|
103
|
+
rsc: 'unsupported',
|
|
104
|
+
},
|
|
105
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'client-mount' },
|
|
106
|
+
ssr: {
|
|
107
|
+
availability: '0.1.0-alpha.5',
|
|
108
|
+
host: 'nuxt',
|
|
109
|
+
hostVersion: '4.6.3',
|
|
110
|
+
vueVersion: '3.5.44',
|
|
111
|
+
nodeVersion: '22.23.3',
|
|
112
|
+
preset: 'node-server',
|
|
113
|
+
deferred: [
|
|
114
|
+
'sheet-dialog-presentation',
|
|
115
|
+
'select-popup',
|
|
116
|
+
'date-calendar',
|
|
117
|
+
'combobox-results',
|
|
118
|
+
'file-selection',
|
|
119
|
+
'toast-presentation',
|
|
120
|
+
'motion-measurement',
|
|
121
|
+
],
|
|
122
|
+
preHydrationEditors: [
|
|
123
|
+
'MInput',
|
|
124
|
+
'MCheckbox',
|
|
125
|
+
'MRadioGroup',
|
|
126
|
+
'MSlider',
|
|
127
|
+
'MDatePicker',
|
|
128
|
+
'MDateRangePicker',
|
|
129
|
+
'MCombobox',
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'vue-nativescript',
|
|
135
|
+
framework: 'vue',
|
|
136
|
+
renderer: 'nativescript',
|
|
137
|
+
status: 'experimental',
|
|
138
|
+
components: componentNames,
|
|
139
|
+
rendering: {
|
|
140
|
+
client: 'experimental',
|
|
141
|
+
serverImport: 'unsupported',
|
|
142
|
+
serverHTML: 'unsupported',
|
|
143
|
+
hydration: 'unsupported',
|
|
144
|
+
ssg: 'unsupported',
|
|
145
|
+
streaming: 'unsupported',
|
|
146
|
+
rsc: 'unsupported',
|
|
147
|
+
},
|
|
148
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'native-loaded' },
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
planned: [
|
|
152
|
+
{ id: 'react-web', issue: 145 },
|
|
153
|
+
{ id: 'next', issue: 159 },
|
|
154
|
+
{ id: 'angular-web', issue: 152 },
|
|
155
|
+
{ id: 'svelte-web', issue: 153 },
|
|
156
|
+
{ id: 'solid-web', issue: 154 },
|
|
157
|
+
{ id: 'react-nativescript', issue: 35 },
|
|
158
|
+
{ id: 'angular-nativescript', issue: 36 },
|
|
159
|
+
{ id: 'svelte-nativescript', issue: 37 },
|
|
160
|
+
{ id: 'solid-nativescript', issue: 38 },
|
|
161
|
+
{ id: 'typescript-nativescript', issue: 39 },
|
|
162
|
+
],
|
|
163
|
+
research: [
|
|
164
|
+
{ id: 'react-native', issue: 40 },
|
|
165
|
+
{ id: 'flutter', issue: 41 },
|
|
166
|
+
{ id: 'swiftui-compose', issue: 42 },
|
|
167
|
+
],
|
|
168
|
+
} as const
|
|
169
|
+
|
|
170
|
+
export const themeContract = {
|
|
171
|
+
version: 1,
|
|
172
|
+
units: {
|
|
173
|
+
layout: { web: 'css-px', nativescript: 'dip' },
|
|
174
|
+
dimension: ['layout-number', 'percent', 'auto'],
|
|
175
|
+
fontSize: 'layout',
|
|
176
|
+
lineHeight: 'ratio',
|
|
177
|
+
letterSpacing: 'em',
|
|
178
|
+
pressScale: 'multiplier',
|
|
179
|
+
},
|
|
180
|
+
tokens: ['colors', 'space', 'radius', 'typography', 'components', 'elevation', 'motion'],
|
|
181
|
+
fontFamily: ['system', 'shared-family-name', 'platform-family-record'],
|
|
182
|
+
ownership: 'application-or-controlled-scope',
|
|
183
|
+
} as const
|
package/src/chart.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { collectionKeys } from './discovery.js'
|
|
2
|
+
import type { ChoiceValue } from './choice.js'
|
|
3
|
+
|
|
4
|
+
export interface ChartCategory {
|
|
5
|
+
key: ChoiceValue
|
|
6
|
+
label: string
|
|
7
|
+
}
|
|
8
|
+
export interface ChartSeries {
|
|
9
|
+
key: ChoiceValue
|
|
10
|
+
label: string
|
|
11
|
+
values: readonly (number | null)[]
|
|
12
|
+
/** A shared CSS/native hex color; the theme supplies defaults. */
|
|
13
|
+
color?: string
|
|
14
|
+
}
|
|
15
|
+
export interface ChartSelection {
|
|
16
|
+
category: ChoiceValue
|
|
17
|
+
series: ChoiceValue
|
|
18
|
+
}
|
|
19
|
+
export interface ChartPoint {
|
|
20
|
+
x: number
|
|
21
|
+
y: number
|
|
22
|
+
value: number
|
|
23
|
+
index: number
|
|
24
|
+
}
|
|
25
|
+
export interface ChartGeometry {
|
|
26
|
+
min: number
|
|
27
|
+
max: number
|
|
28
|
+
zero: number
|
|
29
|
+
ticks: readonly number[]
|
|
30
|
+
series: readonly { key: ChoiceValue; points: readonly (ChartPoint | null)[] }[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Hit testing uses normalized plot coordinates, independent of DOM/native geometry. */
|
|
34
|
+
export function chartHitTest(geometry: ChartGeometry, type: 'line' | 'bar', x: number, y: number) {
|
|
35
|
+
const count = geometry.series[0]?.points.length ?? 0
|
|
36
|
+
if (!count || !Number.isFinite(x) || !Number.isFinite(y)) return null
|
|
37
|
+
const category = Math.max(0, Math.min(count - 1, Math.floor(x * count)))
|
|
38
|
+
if (type === 'bar') {
|
|
39
|
+
const within = x * count - category
|
|
40
|
+
const series = Math.max(
|
|
41
|
+
0,
|
|
42
|
+
Math.min(
|
|
43
|
+
geometry.series.length - 1,
|
|
44
|
+
Math.floor(((within - 0.15) / 0.7) * geometry.series.length),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
return geometry.series[series]?.points[category] ? { category, series } : null
|
|
48
|
+
}
|
|
49
|
+
let nearest = -1,
|
|
50
|
+
distance = Infinity
|
|
51
|
+
geometry.series.forEach((series, index) => {
|
|
52
|
+
const point = series.points[category]
|
|
53
|
+
if (point && Math.abs(point.y - y) < distance) {
|
|
54
|
+
nearest = index
|
|
55
|
+
distance = Math.abs(point.y - y)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
return nearest < 0 ? null : { category, series: nearest }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Category positions and values normalized to [0,1], identical in both renderers. */
|
|
62
|
+
export function chartGeometry(
|
|
63
|
+
categories: readonly ChartCategory[],
|
|
64
|
+
series: readonly ChartSeries[],
|
|
65
|
+
domain?: readonly [number, number],
|
|
66
|
+
): ChartGeometry {
|
|
67
|
+
collectionKeys(categories, 'key')
|
|
68
|
+
collectionKeys(series, 'key')
|
|
69
|
+
// This first renderer targets small product charts, not unbounded telemetry streams.
|
|
70
|
+
if (categories.length > 100 || series.length > 8)
|
|
71
|
+
throw new RangeError('Chart supports up to 100 categories and 8 series.')
|
|
72
|
+
for (const category of categories)
|
|
73
|
+
if (!category.label.trim()) throw new TypeError('Chart categories require labels.')
|
|
74
|
+
const values: number[] = []
|
|
75
|
+
for (const item of series) {
|
|
76
|
+
if (!item.label.trim() || item.values.length !== categories.length)
|
|
77
|
+
throw new TypeError('Chart series require labels and one value per category.')
|
|
78
|
+
if (item.color && !/^#[\da-f]{6}$/i.test(item.color))
|
|
79
|
+
throw new TypeError('Chart colors must be six digit hex values.')
|
|
80
|
+
for (const value of item.values) {
|
|
81
|
+
if (value !== null && !Number.isFinite(value))
|
|
82
|
+
throw new RangeError('Chart values must be finite numbers or null.')
|
|
83
|
+
if (value !== null) values.push(value)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let min = Math.min(0, ...values),
|
|
87
|
+
max = Math.max(0, ...values)
|
|
88
|
+
if (domain) {
|
|
89
|
+
if (domain.length !== 2 || !domain.every(Number.isFinite) || domain[0] >= domain[1])
|
|
90
|
+
throw new RangeError('Chart domain requires two increasing finite values.')
|
|
91
|
+
;[min, max] = domain
|
|
92
|
+
if (values.some((value) => value < min || value > max))
|
|
93
|
+
throw new RangeError('Chart domain must contain every value.')
|
|
94
|
+
} else if (min === max) max = min + 1
|
|
95
|
+
const span = max - min
|
|
96
|
+
if (!Number.isFinite(span)) throw new RangeError('Chart domain span must be finite.')
|
|
97
|
+
const y = (value: number) => 1 - (value - min) / span
|
|
98
|
+
return {
|
|
99
|
+
min,
|
|
100
|
+
max,
|
|
101
|
+
zero: y(Math.max(min, Math.min(max, 0))),
|
|
102
|
+
ticks: Array.from({ length: 5 }, (_, i) => min + span * (i / 4)),
|
|
103
|
+
series: series.map((item) => ({
|
|
104
|
+
key: item.key,
|
|
105
|
+
points: item.values.map((value, index) =>
|
|
106
|
+
value === null
|
|
107
|
+
? null
|
|
108
|
+
: { value, index, x: (index + 0.5) / Math.max(1, categories.length), y: y(value) },
|
|
109
|
+
),
|
|
110
|
+
})),
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/chip.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Palette } from './theme/types.js'
|
|
2
|
+
|
|
3
|
+
export type ChipTone = 'primary' | 'accent'
|
|
4
|
+
|
|
5
|
+
export function checkChipLabels(label: string, removable: boolean, removeLabel?: string) {
|
|
6
|
+
if (typeof label !== 'string' || !label.trim())
|
|
7
|
+
throw new TypeError('Chip needs a non-empty label.')
|
|
8
|
+
if (removable && (typeof removeLabel !== 'string' || !removeLabel.trim()))
|
|
9
|
+
throw new TypeError('A removable Chip needs a contextual removeLabel.')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function chipColors(colors: Readonly<Palette>, tone: ChipTone, selected: boolean) {
|
|
13
|
+
return {
|
|
14
|
+
color: selected ? colors[tone] : colors.text,
|
|
15
|
+
backgroundColor: selected
|
|
16
|
+
? colors[tone === 'primary' ? 'primarySoft' : 'accentSoft']
|
|
17
|
+
: colors.surface,
|
|
18
|
+
borderColor: selected ? colors[tone] : colors.border,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MavisTheme } from './theme/types.js'
|
|
2
|
+
|
|
3
|
+
/** Paint uses the theme's interaction timing; adapters own surfaces and disposal. */
|
|
4
|
+
export function choiceMotion(theme: Readonly<MavisTheme>) {
|
|
5
|
+
return { type: 'tween' as const, duration: theme.motion.enterDuration, ease: theme.motion.ease }
|
|
6
|
+
}
|
|
7
|
+
export interface ChoicePaint {
|
|
8
|
+
backgroundColor?: string
|
|
9
|
+
borderColor?: string
|
|
10
|
+
color?: string
|
|
11
|
+
borderRadius?: number
|
|
12
|
+
}
|
package/src/choice.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Labels can change with the language; values identify the choices. */
|
|
2
|
+
export type ChoiceValue = string | number
|
|
3
|
+
export interface ChoiceOption {
|
|
4
|
+
value: ChoiceValue
|
|
5
|
+
label: string
|
|
6
|
+
helperText?: string
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isChoiceValue(value: unknown): value is ChoiceValue {
|
|
11
|
+
return typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** A typed key keeps the number 1 distinct from the string "1". */
|
|
15
|
+
export function choiceKey(value: ChoiceValue): string {
|
|
16
|
+
return `${typeof value === 'number' ? 'n' : 's'}:${value}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function validateChoices(options: readonly ChoiceOption[], value: ChoiceValue | null) {
|
|
20
|
+
if (value !== null && !isChoiceValue(value))
|
|
21
|
+
throw new TypeError('Choice values must be strings, finite numbers or null for no selection.')
|
|
22
|
+
const seen = new Set<ChoiceValue>()
|
|
23
|
+
for (const option of options) {
|
|
24
|
+
if (
|
|
25
|
+
!option ||
|
|
26
|
+
!isChoiceValue(option.value) ||
|
|
27
|
+
typeof option.label !== 'string' ||
|
|
28
|
+
!option.label.trim()
|
|
29
|
+
)
|
|
30
|
+
throw new TypeError(
|
|
31
|
+
'Each choice needs a string or finite number value and a non-empty label.',
|
|
32
|
+
)
|
|
33
|
+
if (seen.has(option.value)) throw new RangeError(`Duplicate choice value: ${option.value}`)
|
|
34
|
+
seen.add(option.value)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Disabled and repeated activations leave the controlled value alone. */
|
|
39
|
+
export function canChoose(option: ChoiceOption, value: ChoiceValue | null, disabled = false) {
|
|
40
|
+
return !disabled && !option.disabled && option.value !== value
|
|
41
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { choiceKey, type ChoiceValue } from './choice.js'
|
|
2
|
+
import type { IconName } from './icon.js'
|
|
3
|
+
import { linkDestination, type LinkNavigate } from './link.js'
|
|
4
|
+
|
|
5
|
+
export interface MenuAction {
|
|
6
|
+
value: ChoiceValue
|
|
7
|
+
label: string
|
|
8
|
+
icon?: IconName
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
destructive?: boolean
|
|
11
|
+
}
|
|
12
|
+
export type MenuItem =
|
|
13
|
+
MenuAction | { type: 'separator'; key: string } | { type: 'group'; key: string; label: string }
|
|
14
|
+
export interface NavigationItem {
|
|
15
|
+
value: ChoiceValue
|
|
16
|
+
label: string
|
|
17
|
+
href: string
|
|
18
|
+
icon?: IconName
|
|
19
|
+
badge?: string | number
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
navigate?: LinkNavigate
|
|
22
|
+
}
|
|
23
|
+
export function validateMenu(items: readonly MenuItem[]) {
|
|
24
|
+
const keys = new Set<string>()
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
const key = 'type' in item ? `decoration:${item.key}` : choiceKey(item.value)
|
|
27
|
+
if (keys.has(key)) throw new RangeError('Menu items require unique keys.')
|
|
28
|
+
keys.add(key)
|
|
29
|
+
if ((!('type' in item) || item.type === 'group') && !item.label.trim())
|
|
30
|
+
throw new TypeError('Menu actions and groups require labels.')
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function validateNavigation(items: readonly NavigationItem[]) {
|
|
34
|
+
validateMenu(items)
|
|
35
|
+
items.forEach((item) => linkDestination(item.href))
|
|
36
|
+
}
|
|
37
|
+
export type VirtualItemKey<T = unknown> = string | ((item: T) => ChoiceValue)
|
|
38
|
+
export interface VirtualItemSlot<T = unknown> {
|
|
39
|
+
item: T
|
|
40
|
+
index: number
|
|
41
|
+
itemKey: ChoiceValue
|
|
42
|
+
}
|
|
43
|
+
export interface VirtualListHandle {
|
|
44
|
+
scrollToIndex(index: number): void
|
|
45
|
+
}
|
|
46
|
+
export function virtualKeys<T>(items: readonly T[], itemKey: VirtualItemKey<T>): ChoiceValue[] {
|
|
47
|
+
const seen = new Set<string>()
|
|
48
|
+
return items.map((item) => {
|
|
49
|
+
const key =
|
|
50
|
+
typeof itemKey === 'function' ? itemKey(item) : (item as Record<string, unknown>)?.[itemKey]
|
|
51
|
+
if (
|
|
52
|
+
(typeof key !== 'string' && typeof key !== 'number') ||
|
|
53
|
+
(typeof key === 'number' && !Number.isFinite(key))
|
|
54
|
+
)
|
|
55
|
+
throw new TypeError('Virtual list items require finite number or string keys.')
|
|
56
|
+
const id = choiceKey(key)
|
|
57
|
+
if (seen.has(id)) throw new RangeError('Virtual list keys must be unique.')
|
|
58
|
+
seen.add(id)
|
|
59
|
+
return key
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
export function virtualWindow(
|
|
63
|
+
count: number,
|
|
64
|
+
rowHeight: number,
|
|
65
|
+
height: number,
|
|
66
|
+
offset: number,
|
|
67
|
+
overscan = 3,
|
|
68
|
+
) {
|
|
69
|
+
if (
|
|
70
|
+
!Number.isInteger(count) ||
|
|
71
|
+
count < 0 ||
|
|
72
|
+
!Number.isFinite(rowHeight) ||
|
|
73
|
+
rowHeight <= 0 ||
|
|
74
|
+
!Number.isFinite(height) ||
|
|
75
|
+
height <= 0 ||
|
|
76
|
+
!Number.isInteger(overscan) ||
|
|
77
|
+
overscan < 0 ||
|
|
78
|
+
!Number.isFinite(offset)
|
|
79
|
+
)
|
|
80
|
+
throw new RangeError(
|
|
81
|
+
'Virtual list requires positive finite dimensions and nonnegative integer overscan.',
|
|
82
|
+
)
|
|
83
|
+
const scrollTop = Math.max(0, Math.min(offset, Math.max(0, count * rowHeight - height)))
|
|
84
|
+
const start = Math.max(0, Math.floor(scrollTop / rowHeight) - overscan)
|
|
85
|
+
const end = Math.min(count, Math.ceil((scrollTop + height) / rowHeight) + overscan)
|
|
86
|
+
return { start, end, scrollTop, totalHeight: count * rowHeight }
|
|
87
|
+
}
|