@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type ScrollEdge = 'start' | 'center' | 'end'
|
|
2
|
+
export interface SectionScrollOptions {
|
|
3
|
+
/** [section edge, viewport edge]. Default: ['start', 'end']. */
|
|
4
|
+
start?: readonly [ScrollEdge, ScrollEdge]
|
|
5
|
+
/** [section edge, viewport edge]. Default: ['end', 'start']. */
|
|
6
|
+
end?: readonly [ScrollEdge, ScrollEdge]
|
|
7
|
+
}
|
|
8
|
+
const edge = { start: 0, center: 0.5, end: 1 } as const
|
|
9
|
+
export function validateSectionScroll(options: SectionScrollOptions) {
|
|
10
|
+
for (const value of [options.start, options.end])
|
|
11
|
+
if (
|
|
12
|
+
value !== undefined &&
|
|
13
|
+
(!Array.isArray(value) ||
|
|
14
|
+
value.length !== 2 ||
|
|
15
|
+
value.some((part) => !Object.hasOwn(edge, part)))
|
|
16
|
+
)
|
|
17
|
+
throw new TypeError(
|
|
18
|
+
'Section points must pair start, center or end for the section and viewport.',
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
/** Renderer geometry only; Jolt owns interpolation, scheduling and reduced motion. */
|
|
22
|
+
export function sectionScrollRange(
|
|
23
|
+
top: number,
|
|
24
|
+
height: number,
|
|
25
|
+
viewport: number,
|
|
26
|
+
maximum: number,
|
|
27
|
+
options: SectionScrollOptions,
|
|
28
|
+
) {
|
|
29
|
+
validateSectionScroll(options)
|
|
30
|
+
if (
|
|
31
|
+
![top, height, viewport, maximum].every(Number.isFinite) ||
|
|
32
|
+
height < 0 ||
|
|
33
|
+
viewport < 0 ||
|
|
34
|
+
maximum < 0
|
|
35
|
+
)
|
|
36
|
+
throw new RangeError('Section geometry must be finite.')
|
|
37
|
+
const position = ([section, screen]: readonly [ScrollEdge, ScrollEdge]) =>
|
|
38
|
+
top + height * edge[section] - viewport * edge[screen]
|
|
39
|
+
const start = position(options.start ?? ['start', 'end'])
|
|
40
|
+
const end = position(options.end ?? ['end', 'start'])
|
|
41
|
+
if (end < start) throw new RangeError('Section end must follow its start.')
|
|
42
|
+
const clamp = (value: number) => Math.max(0, Math.min(maximum, value))
|
|
43
|
+
const range = [clamp(start), clamp(end)] as const
|
|
44
|
+
// A section with no traversable range settles; never divide by zero or add a clock.
|
|
45
|
+
return { range: range[1] > range[0] ? range : ([0, 1] as const), settled: range[1] <= range[0] }
|
|
46
|
+
}
|
package/src/segmented.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { validateChoices, type ChoiceOption, type ChoiceValue } from './choice.js'
|
|
2
|
+
|
|
3
|
+
export type SegmentedOption = Pick<ChoiceOption, 'value' | 'label' | 'disabled'>
|
|
4
|
+
export const segmentedMotion = Object.freeze({
|
|
5
|
+
duration: 180,
|
|
6
|
+
ease: 'easeOut',
|
|
7
|
+
cssEase: 'ease-out',
|
|
8
|
+
} as const)
|
|
9
|
+
|
|
10
|
+
export function validateSegments(
|
|
11
|
+
options: readonly SegmentedOption[],
|
|
12
|
+
value: ChoiceValue | null,
|
|
13
|
+
label: string,
|
|
14
|
+
) {
|
|
15
|
+
validateChoices(options, value)
|
|
16
|
+
if (typeof label !== 'string' || !label.trim())
|
|
17
|
+
throw new TypeError('SegmentedControl needs a non-empty label.')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A segmented choice follows radio behavior: arrows both focus and request selection. */
|
|
21
|
+
export function segmentedFocusTarget(
|
|
22
|
+
options: readonly SegmentedOption[],
|
|
23
|
+
value: ChoiceValue,
|
|
24
|
+
key: string,
|
|
25
|
+
rtl = false,
|
|
26
|
+
): SegmentedOption | undefined {
|
|
27
|
+
const enabled = options.filter((option) => !option.disabled)
|
|
28
|
+
if (key === 'Home') return enabled[0]
|
|
29
|
+
if (key === 'End') return enabled[enabled.length - 1]
|
|
30
|
+
const direction = {
|
|
31
|
+
ArrowRight: rtl ? -1 : 1,
|
|
32
|
+
ArrowLeft: rtl ? 1 : -1,
|
|
33
|
+
ArrowDown: 1,
|
|
34
|
+
ArrowUp: -1,
|
|
35
|
+
}[key]
|
|
36
|
+
if (!direction) return
|
|
37
|
+
const index = enabled.findIndex((option) => option.value === value)
|
|
38
|
+
return enabled[(index + direction + enabled.length) % enabled.length]
|
|
39
|
+
}
|
package/src/sheet.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Why a sheet closed: the component's own control, a platform dismissal, or `open` set to false. */
|
|
2
|
+
export type SheetCloseReason = 'button' | 'backdrop' | 'escape' | 'back' | 'swipe' | 'program'
|
|
3
|
+
|
|
4
|
+
export type SheetName =
|
|
5
|
+
{ title: string; accessibilityLabel?: string } | { title?: string; accessibilityLabel: string }
|
|
6
|
+
|
|
7
|
+
export const sheetCloseReasons: readonly SheetCloseReason[] = [
|
|
8
|
+
'button',
|
|
9
|
+
'backdrop',
|
|
10
|
+
'escape',
|
|
11
|
+
'back',
|
|
12
|
+
'swipe',
|
|
13
|
+
'program',
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export function checkSheetName(title: string | undefined, label: string | undefined) {
|
|
17
|
+
const name = title?.trim() || label?.trim()
|
|
18
|
+
if (!name) throw new RangeError('A sheet needs a nonempty title or accessibilityLabel')
|
|
19
|
+
return name
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Web focus destination, resolved after the native dialog close event. A string is an element ID. */
|
|
23
|
+
export type SheetReturnFocus =
|
|
24
|
+
| string
|
|
25
|
+
| false
|
|
26
|
+
| ((
|
|
27
|
+
reason: SheetCloseReason,
|
|
28
|
+
) =>
|
|
29
|
+
| { readonly isConnected: boolean; focus(options?: { preventScroll?: boolean }): unknown }
|
|
30
|
+
| null
|
|
31
|
+
| undefined)
|
package/src/tabs.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { validateChoices, type ChoiceOption, type ChoiceValue } from './choice.js'
|
|
2
|
+
|
|
3
|
+
export type TabOption = Pick<ChoiceOption, 'value' | 'label' | 'disabled'>
|
|
4
|
+
export interface TabPanelProps {
|
|
5
|
+
value: ChoiceValue
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function validateTabs(tabs: readonly TabOption[], value: ChoiceValue | null, label: string) {
|
|
9
|
+
validateChoices(tabs, value)
|
|
10
|
+
if (typeof label !== 'string' || !label.trim())
|
|
11
|
+
throw new TypeError('Tabs need a non-empty label.')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Keyboard navigation moves focus; activation remains an explicit action. */
|
|
15
|
+
export function tabFocusTarget(
|
|
16
|
+
tabs: readonly TabOption[],
|
|
17
|
+
value: ChoiceValue,
|
|
18
|
+
key: string,
|
|
19
|
+
rtl = false,
|
|
20
|
+
): TabOption | undefined {
|
|
21
|
+
const enabled = tabs.filter((tab) => !tab.disabled)
|
|
22
|
+
if (key === 'Home') return enabled[0]
|
|
23
|
+
if (key === 'End') return enabled[enabled.length - 1]
|
|
24
|
+
if (key !== 'ArrowLeft' && key !== 'ArrowRight') return
|
|
25
|
+
const step = (key === 'ArrowRight' ? 1 : -1) * (rtl ? -1 : 1)
|
|
26
|
+
const index = enabled.findIndex((tab) => tab.value === value)
|
|
27
|
+
return enabled[(index + step + enabled.length) % enabled.length]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Reveal the nearest edge without changing a surrounding vertical scroll view. */
|
|
31
|
+
export function tabScrollOffset(left: number, width: number, offset: number, viewport: number) {
|
|
32
|
+
if (left < offset || width >= viewport) return Math.max(0, left)
|
|
33
|
+
if (left + width > offset + viewport) return Math.max(0, left + width - viewport)
|
|
34
|
+
return offset
|
|
35
|
+
}
|
package/src/theme/themes.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { MavisTheme, ThemeOptions } from './types.js'
|
|
2
|
+
import {
|
|
3
|
+
validateTypography,
|
|
4
|
+
validateComponentTheme,
|
|
5
|
+
validateShadow,
|
|
6
|
+
freezeFamily,
|
|
7
|
+
} from './typography.js'
|
|
8
|
+
import { defaultMotion, validateMotion } from '../motion.js'
|
|
2
9
|
|
|
3
10
|
const foundation: MavisTheme = {
|
|
4
11
|
name: 'mavis',
|
|
@@ -16,40 +23,105 @@ const foundation: MavisTheme = {
|
|
|
16
23
|
onAccent: '#FFFFFF',
|
|
17
24
|
accentSoft: '#E8EEFF',
|
|
18
25
|
border: '#EAE3ED',
|
|
26
|
+
warning: '#9A5A10',
|
|
19
27
|
success: '#237354',
|
|
20
28
|
danger: '#B33545',
|
|
21
29
|
},
|
|
22
30
|
space: { none: 0, xs: 4, sm: 8, md: 16, lg: 24, xl: 32, '2xl': 48 },
|
|
23
31
|
radius: { none: 0, sm: 10, md: 16, lg: 24, full: 999 },
|
|
24
32
|
typography: {
|
|
25
|
-
display: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
display: {
|
|
34
|
+
fontSize: 56,
|
|
35
|
+
fontWeight: '600',
|
|
36
|
+
letterSpacing: -0.04,
|
|
37
|
+
fontFamily: 'system',
|
|
38
|
+
lineHeight: 1.3,
|
|
39
|
+
},
|
|
40
|
+
title: {
|
|
41
|
+
fontSize: 34,
|
|
42
|
+
fontWeight: '600',
|
|
43
|
+
letterSpacing: -0.035,
|
|
44
|
+
fontFamily: 'system',
|
|
45
|
+
lineHeight: 1.3,
|
|
46
|
+
},
|
|
47
|
+
heading: {
|
|
48
|
+
fontSize: 20,
|
|
49
|
+
fontWeight: '600',
|
|
50
|
+
letterSpacing: -0.02,
|
|
51
|
+
fontFamily: 'system',
|
|
52
|
+
lineHeight: 1.3,
|
|
53
|
+
},
|
|
54
|
+
body: {
|
|
55
|
+
fontSize: 16,
|
|
56
|
+
fontWeight: 'normal',
|
|
57
|
+
letterSpacing: 0,
|
|
58
|
+
fontFamily: 'system',
|
|
59
|
+
lineHeight: 1.3,
|
|
60
|
+
},
|
|
61
|
+
caption: {
|
|
62
|
+
fontSize: 13,
|
|
63
|
+
fontWeight: 'normal',
|
|
64
|
+
letterSpacing: 0,
|
|
65
|
+
fontFamily: 'system',
|
|
66
|
+
lineHeight: 1.3,
|
|
67
|
+
},
|
|
68
|
+
overline: {
|
|
69
|
+
fontSize: 11,
|
|
70
|
+
fontWeight: '600',
|
|
71
|
+
letterSpacing: 0.12,
|
|
72
|
+
fontFamily: 'system',
|
|
73
|
+
lineHeight: 1.3,
|
|
74
|
+
},
|
|
31
75
|
},
|
|
32
76
|
control: {
|
|
33
77
|
sm: { height: 44, fontSize: 14, padding: 16 },
|
|
34
78
|
md: { height: 52, fontSize: 16, padding: 20 },
|
|
35
79
|
lg: { height: 60, fontSize: 17, padding: 24 },
|
|
36
80
|
},
|
|
37
|
-
|
|
81
|
+
elevation: {
|
|
82
|
+
none: { x: 0, y: 0, blur: 0, spread: 0, color: 'transparent' },
|
|
83
|
+
sm: { x: 0, y: 2, blur: 6, spread: 0, color: 'rgba(37, 30, 50, 0.10)' },
|
|
84
|
+
md: { x: 0, y: 8, blur: 24, spread: 0, color: 'rgba(37, 30, 50, 0.14)' },
|
|
85
|
+
lg: { x: 0, y: 16, blur: 40, spread: 0, color: 'rgba(37, 30, 50, 0.20)' },
|
|
86
|
+
},
|
|
87
|
+
components: {
|
|
88
|
+
button: { fontWeight: '600', lineHeight: 1.3, paddingY: 12, radius: 'md', elevation: 'none' },
|
|
89
|
+
input: { fontWeight: 'normal', lineHeight: 1.5, paddingX: 16, paddingY: 14, radius: 'md' },
|
|
90
|
+
card: { padding: 'lg', radius: 'lg', elevation: 'none' },
|
|
91
|
+
},
|
|
92
|
+
motion: defaultMotion,
|
|
38
93
|
}
|
|
39
94
|
|
|
40
95
|
/** Derive a complete theme without changing the original. */
|
|
41
96
|
export function defineTheme(options: ThemeOptions, base: MavisTheme = foundation): MavisTheme {
|
|
42
97
|
const typography = { ...base.typography }
|
|
43
98
|
for (const variant of Object.keys(typography) as (keyof typeof typography)[]) {
|
|
44
|
-
|
|
99
|
+
const type = {
|
|
45
100
|
...typography[variant],
|
|
46
101
|
...options.typography?.[variant],
|
|
47
|
-
}
|
|
102
|
+
}
|
|
103
|
+
validateTypography(type)
|
|
104
|
+
typography[variant] = Object.freeze({ ...type, fontFamily: freezeFamily(type.fontFamily) })
|
|
48
105
|
}
|
|
49
106
|
const control = { ...base.control }
|
|
50
107
|
for (const size of Object.keys(control) as (keyof typeof control)[]) {
|
|
51
108
|
control[size] = Object.freeze({ ...control[size], ...options.control?.[size] })
|
|
52
109
|
}
|
|
110
|
+
const elevation = { ...base.elevation }
|
|
111
|
+
for (const level of Object.keys(elevation) as (keyof typeof elevation)[]) {
|
|
112
|
+
const shadow = { ...elevation[level], ...options.elevation?.[level] }
|
|
113
|
+
validateShadow(shadow)
|
|
114
|
+
elevation[level] = Object.freeze(shadow)
|
|
115
|
+
}
|
|
116
|
+
const components = {
|
|
117
|
+
button: { ...base.components.button, ...options.components?.button },
|
|
118
|
+
input: { ...base.components.input, ...options.components?.input },
|
|
119
|
+
card: { ...base.components.card, ...options.components?.card },
|
|
120
|
+
}
|
|
121
|
+
validateComponentTheme(components)
|
|
122
|
+
for (const component of [components.button, components.input]) {
|
|
123
|
+
if (component.fontFamily) component.fontFamily = freezeFamily(component.fontFamily)
|
|
124
|
+
}
|
|
53
125
|
const theme: MavisTheme = {
|
|
54
126
|
name: options.name,
|
|
55
127
|
appearance: options.appearance ?? base.appearance,
|
|
@@ -58,14 +130,18 @@ export function defineTheme(options: ThemeOptions, base: MavisTheme = foundation
|
|
|
58
130
|
radius: Object.freeze({ ...base.radius, ...options.radius }),
|
|
59
131
|
typography: Object.freeze(typography),
|
|
60
132
|
control: Object.freeze(control),
|
|
133
|
+
elevation: Object.freeze(elevation),
|
|
134
|
+
components: Object.freeze({
|
|
135
|
+
button: Object.freeze(components.button),
|
|
136
|
+
input: Object.freeze(components.input),
|
|
137
|
+
card: Object.freeze(components.card),
|
|
138
|
+
}),
|
|
61
139
|
motion: Object.freeze({ ...base.motion, ...options.motion }),
|
|
62
140
|
}
|
|
63
141
|
for (const [key, value] of [...Object.entries(theme.space), ...Object.entries(theme.radius)]) {
|
|
64
142
|
if (!Number.isFinite(value) || value < 0) throw new RangeError(`Invalid theme token: ${key}`)
|
|
65
143
|
}
|
|
66
|
-
|
|
67
|
-
throw new RangeError('pressScale must be greater than 0 and at most 1')
|
|
68
|
-
}
|
|
144
|
+
validateMotion(theme.motion)
|
|
69
145
|
return Object.freeze(theme)
|
|
70
146
|
}
|
|
71
147
|
|
|
@@ -87,6 +163,7 @@ export const midnight = defineTheme({
|
|
|
87
163
|
onAccent: '#172247',
|
|
88
164
|
accentSoft: '#242E4A',
|
|
89
165
|
border: '#3C3046',
|
|
166
|
+
warning: '#F4C579',
|
|
90
167
|
success: '#9FD5BE',
|
|
91
168
|
danger: '#FFA8A8',
|
|
92
169
|
},
|
package/src/theme/types.ts
CHANGED
|
@@ -18,16 +18,65 @@ export interface Palette {
|
|
|
18
18
|
onAccent: string
|
|
19
19
|
accentSoft: string
|
|
20
20
|
border: string
|
|
21
|
+
warning: string
|
|
21
22
|
success: string
|
|
22
23
|
danger: string
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
export type FontWeight =
|
|
27
|
+
'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
|
|
28
|
+
/** A shared installed family, or explicit platform names/stacks. Empty native names use the system font. */
|
|
29
|
+
export type FontFamily = string | Readonly<{ web: string; ios: string; android: string }>
|
|
30
|
+
export type Elevation = 'none' | 'sm' | 'md' | 'lg'
|
|
31
|
+
export interface Shadow {
|
|
32
|
+
x: number
|
|
33
|
+
y: number
|
|
34
|
+
blur: number
|
|
35
|
+
spread: number
|
|
36
|
+
color: string
|
|
37
|
+
}
|
|
38
|
+
export interface ComponentTheme {
|
|
39
|
+
button: {
|
|
40
|
+
fontFamily?: FontFamily
|
|
41
|
+
fontWeight: FontWeight
|
|
42
|
+
lineHeight: number
|
|
43
|
+
paddingY: number
|
|
44
|
+
radius: Radius | number
|
|
45
|
+
elevation: Elevation
|
|
46
|
+
}
|
|
47
|
+
input: {
|
|
48
|
+
fontFamily?: FontFamily
|
|
49
|
+
fontSize?: number
|
|
50
|
+
fontWeight: FontWeight
|
|
51
|
+
lineHeight: number
|
|
52
|
+
paddingX: number
|
|
53
|
+
paddingY: number
|
|
54
|
+
radius: Radius | number
|
|
55
|
+
}
|
|
56
|
+
card: { padding: Spacing; radius: Radius | number; elevation: Elevation }
|
|
57
|
+
}
|
|
58
|
+
|
|
25
59
|
export interface Typography {
|
|
26
60
|
fontSize: number
|
|
27
|
-
fontWeight:
|
|
61
|
+
fontWeight: FontWeight
|
|
62
|
+
fontFamily: FontFamily
|
|
63
|
+
/** Unitless line rhythm, at least 1; native renderers add leading to font metrics. */
|
|
64
|
+
lineHeight: number
|
|
28
65
|
letterSpacing: number
|
|
29
66
|
}
|
|
30
67
|
|
|
68
|
+
export type MotionEase = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'
|
|
69
|
+
export interface MotionTheme {
|
|
70
|
+
pressScale: number
|
|
71
|
+
pressDuration: number
|
|
72
|
+
releaseDuration: number
|
|
73
|
+
releaseBounce: number
|
|
74
|
+
enterDuration: number
|
|
75
|
+
exitDuration: number
|
|
76
|
+
enterOffset: number
|
|
77
|
+
ease: MotionEase
|
|
78
|
+
}
|
|
79
|
+
|
|
31
80
|
export interface MavisTheme {
|
|
32
81
|
readonly name: string
|
|
33
82
|
readonly appearance: 'light' | 'dark'
|
|
@@ -38,7 +87,9 @@ export interface MavisTheme {
|
|
|
38
87
|
readonly control: Readonly<
|
|
39
88
|
Record<Size, Readonly<{ height: number; fontSize: number; padding: number }>>
|
|
40
89
|
>
|
|
41
|
-
readonly
|
|
90
|
+
readonly elevation: Readonly<Record<Elevation, Readonly<Shadow>>>
|
|
91
|
+
readonly components: { readonly [K in keyof ComponentTheme]: Readonly<ComponentTheme[K]> }
|
|
92
|
+
readonly motion: Readonly<MotionTheme>
|
|
42
93
|
}
|
|
43
94
|
|
|
44
95
|
export interface ThemeOptions {
|
|
@@ -49,5 +100,7 @@ export interface ThemeOptions {
|
|
|
49
100
|
radius?: Partial<MavisTheme['radius']>
|
|
50
101
|
typography?: Partial<Record<TextVariant, Partial<Typography>>>
|
|
51
102
|
control?: Partial<Record<Size, Partial<MavisTheme['control'][Size]>>>
|
|
103
|
+
elevation?: Partial<Record<Elevation, Partial<Shadow>>>
|
|
104
|
+
components?: { [K in keyof ComponentTheme]?: Partial<ComponentTheme[K]> }
|
|
52
105
|
motion?: Partial<MavisTheme['motion']>
|
|
53
106
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ComponentTheme, FontFamily, FontWeight, Shadow, Typography } from './types.js'
|
|
2
|
+
|
|
3
|
+
export const fontWeights: readonly FontWeight[] = [
|
|
4
|
+
'normal',
|
|
5
|
+
'bold',
|
|
6
|
+
'100',
|
|
7
|
+
'200',
|
|
8
|
+
'300',
|
|
9
|
+
'400',
|
|
10
|
+
'500',
|
|
11
|
+
'600',
|
|
12
|
+
'700',
|
|
13
|
+
'800',
|
|
14
|
+
'900',
|
|
15
|
+
]
|
|
16
|
+
export function validateWeight(value: FontWeight) {
|
|
17
|
+
if (!fontWeights.includes(value)) throw new RangeError(`Invalid font weight: ${String(value)}`)
|
|
18
|
+
return value
|
|
19
|
+
}
|
|
20
|
+
export function freezeFamily(value: FontFamily): FontFamily {
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
if (!value.trim()) throw new RangeError('A font family must not be blank')
|
|
23
|
+
return value
|
|
24
|
+
}
|
|
25
|
+
if (
|
|
26
|
+
!value ||
|
|
27
|
+
typeof value.web !== 'string' ||
|
|
28
|
+
!value.web.trim() ||
|
|
29
|
+
typeof value.ios !== 'string' ||
|
|
30
|
+
typeof value.android !== 'string'
|
|
31
|
+
) {
|
|
32
|
+
throw new TypeError('A font family needs web, ios and android names')
|
|
33
|
+
}
|
|
34
|
+
return Object.freeze({ ...value })
|
|
35
|
+
}
|
|
36
|
+
export function fontFamily(value: FontFamily, platform: 'web' | 'ios' | 'android') {
|
|
37
|
+
if (value === 'system')
|
|
38
|
+
return platform === 'web'
|
|
39
|
+
? 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
|
|
40
|
+
: ''
|
|
41
|
+
return typeof value === 'string' ? value : value[platform]
|
|
42
|
+
}
|
|
43
|
+
function finite(value: number, name: string, minimum = 0) {
|
|
44
|
+
if (!Number.isFinite(value) || value < minimum) throw new RangeError(`Invalid ${name}: ${value}`)
|
|
45
|
+
}
|
|
46
|
+
export function validateTypography(value: Typography) {
|
|
47
|
+
finite(value.fontSize, 'fontSize', Number.EPSILON)
|
|
48
|
+
finite(value.lineHeight, 'lineHeight', 1)
|
|
49
|
+
if (!Number.isFinite(value.letterSpacing)) throw new RangeError('Invalid letterSpacing')
|
|
50
|
+
validateWeight(value.fontWeight)
|
|
51
|
+
freezeFamily(value.fontFamily)
|
|
52
|
+
}
|
|
53
|
+
export function validateShadow(value: Shadow) {
|
|
54
|
+
for (const key of ['x', 'y', 'spread'] as const) finite(value[key], `shadow ${key}`, -Infinity)
|
|
55
|
+
finite(value.blur, 'shadow blur')
|
|
56
|
+
if (typeof value.color !== 'string' || !value.color.trim())
|
|
57
|
+
throw new RangeError('A shadow needs a color')
|
|
58
|
+
}
|
|
59
|
+
export function validateComponentTheme(value: ComponentTheme) {
|
|
60
|
+
for (const component of [value.button, value.input]) {
|
|
61
|
+
validateWeight(component.fontWeight)
|
|
62
|
+
finite(component.lineHeight, 'lineHeight', 1)
|
|
63
|
+
finite(component.paddingY, 'paddingY')
|
|
64
|
+
if (component.fontFamily !== undefined) freezeFamily(component.fontFamily)
|
|
65
|
+
}
|
|
66
|
+
finite(value.input.paddingX, 'paddingX')
|
|
67
|
+
if (value.input.fontSize !== undefined) finite(value.input.fontSize, 'fontSize', Number.EPSILON)
|
|
68
|
+
for (const component of [value.button, value.input, value.card]) {
|
|
69
|
+
if (typeof component.radius === 'number') finite(component.radius, 'radius')
|
|
70
|
+
else if (!['none', 'sm', 'md', 'lg', 'full'].includes(component.radius))
|
|
71
|
+
throw new RangeError('Invalid component radius')
|
|
72
|
+
}
|
|
73
|
+
for (const component of [value.button, value.card]) {
|
|
74
|
+
if (!['none', 'sm', 'md', 'lg'].includes(component.elevation))
|
|
75
|
+
throw new RangeError('Invalid elevation')
|
|
76
|
+
}
|
|
77
|
+
if (typeof value.card.padding === 'number') finite(value.card.padding, 'padding')
|
|
78
|
+
else if (!['none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'].includes(value.card.padding))
|
|
79
|
+
throw new RangeError('Invalid card padding')
|
|
80
|
+
}
|
|
81
|
+
export function shadowStyle(value: Shadow, platform: 'web' | 'native' = 'web') {
|
|
82
|
+
const unit = platform === 'web' ? 'px' : 'dip'
|
|
83
|
+
return `${value.x}${unit} ${value.y}${unit} ${value.blur}${unit} ${value.spread}${unit} ${value.color}`
|
|
84
|
+
}
|
package/src/time.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** A wall-clock time, independent of date, timezone and daylight-saving transitions. */
|
|
2
|
+
export type LocalTime = string
|
|
3
|
+
export type TimeLocale = 'en-US' | 'pt-BR'
|
|
4
|
+
export type HourCycle = 'h12' | 'h23'
|
|
5
|
+
export interface TimeOptions {
|
|
6
|
+
locale?: TimeLocale
|
|
7
|
+
hourCycle?: HourCycle
|
|
8
|
+
min?: LocalTime
|
|
9
|
+
max?: LocalTime
|
|
10
|
+
minuteStep?: number
|
|
11
|
+
}
|
|
12
|
+
export type TimeValidation =
|
|
13
|
+
| { status: 'empty'; value: null }
|
|
14
|
+
| { status: 'valid'; value: LocalTime }
|
|
15
|
+
| { status: 'incomplete' | 'invalid' | 'range' | 'step'; value: null }
|
|
16
|
+
|
|
17
|
+
export function timeMinutes(value: LocalTime): number {
|
|
18
|
+
if (!/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value))
|
|
19
|
+
throw new RangeError('Time must use HH:mm between 00:00 and 23:59.')
|
|
20
|
+
return Number(value.slice(0, 2)) * 60 + Number(value.slice(3))
|
|
21
|
+
}
|
|
22
|
+
export function localTime(minutes: number): LocalTime {
|
|
23
|
+
if (!Number.isInteger(minutes) || minutes < 0 || minutes >= 1440)
|
|
24
|
+
throw new RangeError('Time requires an integer minute within one day.')
|
|
25
|
+
return `${String(Math.floor(minutes / 60)).padStart(2, '0')}:${String(minutes % 60).padStart(2, '0')}`
|
|
26
|
+
}
|
|
27
|
+
export function timeOptions(options: TimeOptions = {}) {
|
|
28
|
+
const min = options.min === undefined ? 0 : timeMinutes(options.min)
|
|
29
|
+
const max = options.max === undefined ? 1439 : timeMinutes(options.max)
|
|
30
|
+
const step = options.minuteStep ?? 1
|
|
31
|
+
if (min > max)
|
|
32
|
+
throw new RangeError('Time min must not exceed max; overnight ranges are not supported.')
|
|
33
|
+
if (!Number.isInteger(step) || step < 1 || step > 30 || 60 % step)
|
|
34
|
+
throw new RangeError('minuteStep must be a divisor of 60 between 1 and 30.')
|
|
35
|
+
if (Math.ceil(min / step) * step > max)
|
|
36
|
+
throw new RangeError('Time bounds contain no selectable time.')
|
|
37
|
+
const locale = options.locale ?? 'en-US'
|
|
38
|
+
const cycle = options.hourCycle ?? (locale === 'pt-BR' ? 'h23' : 'h12')
|
|
39
|
+
if (!['en-US', 'pt-BR'].includes(locale) || !['h12', 'h23'].includes(cycle))
|
|
40
|
+
throw new RangeError('Unsupported time locale or hour cycle.')
|
|
41
|
+
return { min, max, step, cycle }
|
|
42
|
+
}
|
|
43
|
+
export function validateTime(value: LocalTime | null, options: TimeOptions = {}): TimeValidation {
|
|
44
|
+
const { min, max, step } = timeOptions(options)
|
|
45
|
+
if (value === null) return { status: 'empty', value: null }
|
|
46
|
+
let minutes: number
|
|
47
|
+
try {
|
|
48
|
+
minutes = timeMinutes(value)
|
|
49
|
+
} catch {
|
|
50
|
+
return { status: 'invalid', value: null }
|
|
51
|
+
}
|
|
52
|
+
if (minutes < min || minutes > max) return { status: 'range', value: null }
|
|
53
|
+
if (minutes % step) return { status: 'step', value: null }
|
|
54
|
+
return { status: 'valid', value }
|
|
55
|
+
}
|
|
56
|
+
/** Deterministic during SSR and on native runtimes without Intl. Never constructs a Date. */
|
|
57
|
+
export function formatTime(value: LocalTime | null, options: TimeOptions = {}): string {
|
|
58
|
+
const { cycle } = timeOptions(options)
|
|
59
|
+
if (value === null) return ''
|
|
60
|
+
const minutes = timeMinutes(value)
|
|
61
|
+
if (cycle === 'h23') return value
|
|
62
|
+
const hour = Math.floor(minutes / 60)
|
|
63
|
+
return `${hour % 12 || 12}:${value.slice(3)} ${hour < 12 ? 'AM' : 'PM'}`
|
|
64
|
+
}
|
|
65
|
+
export function parseTime(draft: string, options: TimeOptions = {}): TimeValidation {
|
|
66
|
+
const { cycle } = timeOptions(options)
|
|
67
|
+
const text = draft.trim()
|
|
68
|
+
if (!text) return { status: 'empty', value: null }
|
|
69
|
+
const match =
|
|
70
|
+
cycle === 'h23' ? /^(\d{1,2}):(\d{2})$/.exec(text) : /^(\d{1,2}):(\d{2})\s*(AM|PM)$/i.exec(text)
|
|
71
|
+
if (!match)
|
|
72
|
+
return {
|
|
73
|
+
status: /^\d{0,2}(?::\d{0,2})?\s*[apm]{0,2}$/i.test(text) ? 'incomplete' : 'invalid',
|
|
74
|
+
value: null,
|
|
75
|
+
}
|
|
76
|
+
let hour = Number(match[1])
|
|
77
|
+
if (Number(match[2]) > 59) return { status: 'invalid', value: null }
|
|
78
|
+
if (cycle === 'h12') {
|
|
79
|
+
if (hour < 1 || hour > 12) return { status: 'invalid', value: null }
|
|
80
|
+
hour = (hour % 12) + (match[3]!.toUpperCase() === 'PM' ? 12 : 0)
|
|
81
|
+
} else if (hour > 23) return { status: 'invalid', value: null }
|
|
82
|
+
return validateTime(localTime(hour * 60 + Number(match[2])), options)
|
|
83
|
+
}
|