@getcortexlabs/mavis-core 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +168 -0
- package/dist/capabilities.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/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 +56 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -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/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/component-props.d.ts +2853 -0
- package/dist/vue/component-props.d.ts.map +1 -0
- package/dist/vue/component-props.js +29 -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/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 +272 -0
- package/dist/vue/date-props.d.ts.map +1 -0
- package/dist/vue/date-props.js +78 -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/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 +198 -3
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +44 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +36 -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/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/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/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 +171 -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/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 +88 -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/combobox.ts +238 -0
- package/src/vue/component-props.ts +42 -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/date-calendar.ts +76 -0
- package/src/vue/date-picker.ts +410 -0
- package/src/vue/date-props.ts +86 -0
- package/src/vue/dialog.ts +63 -0
- package/src/vue/files.ts +53 -0
- package/src/vue/forms.ts +20 -0
- package/src/vue/global-components.ts +182 -4
- package/src/vue/index.ts +84 -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/virtual-list.ts +28 -0
- package/src/vue/workflow-props.ts +41 -0
- package/src/vue/workflows.ts +257 -0
package/src/index.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export { defineTheme, mavis, midnight } from './theme/themes.js'
|
|
2
2
|
export { resolveSpace } from './theme/resolve.js'
|
|
3
|
+
export { pressMotion, revealMotion, motionRecipe } from './motion.js'
|
|
3
4
|
export type {
|
|
5
|
+
FontFamily,
|
|
6
|
+
MotionTheme,
|
|
7
|
+
MotionEase,
|
|
8
|
+
FontWeight,
|
|
9
|
+
Elevation,
|
|
10
|
+
Shadow,
|
|
11
|
+
ComponentTheme,
|
|
4
12
|
MavisTheme,
|
|
5
13
|
ThemeOptions,
|
|
6
14
|
Palette,
|
|
@@ -12,8 +20,86 @@ export type {
|
|
|
12
20
|
ButtonVariant,
|
|
13
21
|
Size,
|
|
14
22
|
} from './theme/types.js'
|
|
23
|
+
export { listItemLabel } from './list-item.js'
|
|
24
|
+
export { avatarSizes, avatarInitials } from './avatar.js'
|
|
25
|
+
export type { AvatarSize } from './avatar.js'
|
|
26
|
+
export { badgeColors } from './badge.js'
|
|
27
|
+
export type { BadgeTone } from './badge.js'
|
|
15
28
|
export { sliderScale } from './slider.js'
|
|
16
29
|
export { resolveDimension, resolveRadius, nonNegative } from './layout.js'
|
|
17
30
|
export type { Dimension } from './layout.js'
|
|
18
|
-
export { validateInput } from './input.js'
|
|
19
|
-
export
|
|
31
|
+
export { validateInput, inputActionSize } from './input.js'
|
|
32
|
+
export { icons, iconFontVersion } from './icons.js'
|
|
33
|
+
export { iconGlyph, iconFontFamily, iconSizes, resolveIconSize, checkIconOnly } from './icon.js'
|
|
34
|
+
export type { IconName, IconSize } from './icon.js'
|
|
35
|
+
export type { InputHandle, InputActionHandle, InputAction } from './input.js'
|
|
36
|
+
export { checkSheetName, sheetCloseReasons } from './sheet.js'
|
|
37
|
+
export type { SheetCloseReason, SheetName, SheetReturnFocus } from './sheet.js'
|
|
38
|
+
export { isChoiceValue, choiceKey, validateChoices, canChoose } from './choice.js'
|
|
39
|
+
export type { ChoiceValue, ChoiceOption } from './choice.js'
|
|
40
|
+
|
|
41
|
+
export { createToastController, connectToast, disposeToast } from './toast.js'
|
|
42
|
+
export type {
|
|
43
|
+
ToastTone,
|
|
44
|
+
ToastOptions,
|
|
45
|
+
ToastMessage,
|
|
46
|
+
ToastController,
|
|
47
|
+
ToastSnapshot,
|
|
48
|
+
ToastConnection,
|
|
49
|
+
} from './toast.js'
|
|
50
|
+
|
|
51
|
+
export { checkDialogLabels, dialogCloseReasons } from './dialog.js'
|
|
52
|
+
export type { DialogCloseReason } from './dialog.js'
|
|
53
|
+
|
|
54
|
+
export { validateTabs, tabFocusTarget, tabScrollOffset } from './tabs.js'
|
|
55
|
+
export type { TabOption, TabPanelProps } from './tabs.js'
|
|
56
|
+
|
|
57
|
+
export { progressSizes, progressMotion, progressState, checkProgressLabels } from './progress.js'
|
|
58
|
+
export type { ProgressSize, ProgressTone } from './progress.js'
|
|
59
|
+
export { alertAppearance, checkAlertLabels } from './alert.js'
|
|
60
|
+
export type { AlertTone } from './alert.js'
|
|
61
|
+
|
|
62
|
+
export { validateAccordion, toggleAccordion, accordionFocusTarget } from './accordion.js'
|
|
63
|
+
export type { AccordionItem, AccordionPanelProps } from './accordion.js'
|
|
64
|
+
export { validateSegments, segmentedFocusTarget, segmentedMotion } from './segmented.js'
|
|
65
|
+
export type { SegmentedOption } from './segmented.js'
|
|
66
|
+
|
|
67
|
+
export { checkChipLabels, chipColors, type ChipTone } from './chip.js'
|
|
68
|
+
export { checkEmptyStateTitle } from './empty-state.js'
|
|
69
|
+
|
|
70
|
+
export { fontFamily, shadowStyle, validateWeight } from './theme/typography.js'
|
|
71
|
+
|
|
72
|
+
export { componentContracts, describeContract } from './contracts.js'
|
|
73
|
+
export type {
|
|
74
|
+
ContractProps,
|
|
75
|
+
PropertyValue,
|
|
76
|
+
InputEvents,
|
|
77
|
+
ButtonEvents,
|
|
78
|
+
TextInputHandle,
|
|
79
|
+
} from './contracts.js'
|
|
80
|
+
export { targetCapabilities, componentNames, themeContract } from './capabilities.js'
|
|
81
|
+
export type { ComponentName, CapabilityStatus } from './capabilities.js'
|
|
82
|
+
|
|
83
|
+
export * from './date.js'
|
|
84
|
+
export * from './date-input.js'
|
|
85
|
+
export * from './date-time.js'
|
|
86
|
+
export * from './combobox.js'
|
|
87
|
+
export * from './files.js'
|
|
88
|
+
export * from './form.js'
|
|
89
|
+
export * from './navigation.js'
|
|
90
|
+
export * from './link.js'
|
|
91
|
+
export * from './responsive.js'
|
|
92
|
+
export * from './app-icons.js'
|
|
93
|
+
|
|
94
|
+
export * from './number-input.js'
|
|
95
|
+
export * from './multi-select.js'
|
|
96
|
+
export * from './choice-motion.js'
|
|
97
|
+
|
|
98
|
+
export { gridColumns } from './grid.js'
|
|
99
|
+
|
|
100
|
+
export * from './time.js'
|
|
101
|
+
export * from './popover.js'
|
|
102
|
+
export * from './collections.js'
|
|
103
|
+
|
|
104
|
+
export { defineNavigationTransition } from './navigation-transition.js'
|
|
105
|
+
export type { NavigationTransition } from './navigation-transition.js'
|
package/src/input.ts
CHANGED
|
@@ -1,15 +1,42 @@
|
|
|
1
|
+
import { iconGlyph, type IconName } from './icon.js'
|
|
2
|
+
|
|
3
|
+
export interface InputAction {
|
|
4
|
+
icon: IconName
|
|
5
|
+
label: string
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Icon-only actions have a fixed touch target, independent of the accessible label length. */
|
|
10
|
+
export const inputActionSize = 48
|
|
11
|
+
|
|
1
12
|
export interface InputHandle {
|
|
2
13
|
focus(): void
|
|
3
14
|
blur(): void
|
|
4
15
|
}
|
|
5
16
|
|
|
17
|
+
/** Text input action focus never opens the editing keyboard. */
|
|
18
|
+
export interface InputActionHandle extends InputHandle {
|
|
19
|
+
focusAction(): void
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
/** Editing limits constrain user input; they never rewrite application state. */
|
|
7
23
|
export function validateInput(options: {
|
|
8
24
|
multiline: boolean
|
|
9
25
|
type: string
|
|
10
26
|
rows: number
|
|
11
27
|
maxLength?: number
|
|
28
|
+
trailingIcon?: IconName
|
|
29
|
+
trailingAction?: InputAction
|
|
12
30
|
}) {
|
|
31
|
+
if (options.trailingAction) {
|
|
32
|
+
iconGlyph(options.trailingAction.icon)
|
|
33
|
+
if (typeof options.trailingAction.label !== 'string' || !options.trailingAction.label.trim()) {
|
|
34
|
+
throw new RangeError('An input action needs a nonempty label')
|
|
35
|
+
}
|
|
36
|
+
if (options.trailingIcon) {
|
|
37
|
+
throw new RangeError('Use either trailingIcon or trailingAction on an input')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
13
40
|
if (!Number.isSafeInteger(options.rows) || options.rows < 1) {
|
|
14
41
|
throw new RangeError('rows must be a positive integer')
|
|
15
42
|
}
|
package/src/link.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type LinkTarget = '_self' | '_blank'
|
|
2
|
+
export type LinkNavigate = (href: string) => void | Promise<unknown>
|
|
3
|
+
export interface NavigationOptions {
|
|
4
|
+
href?: string
|
|
5
|
+
navigate?: LinkNavigate
|
|
6
|
+
target?: LinkTarget
|
|
7
|
+
rel?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** App-owned navigation. Instances belong to one app (and one SSR request). */
|
|
11
|
+
export interface MavisNavigation {
|
|
12
|
+
/** Releases host hooks when the application unmounts. */
|
|
13
|
+
dispose?(): void
|
|
14
|
+
resolve(href: string): string
|
|
15
|
+
push: LinkNavigate
|
|
16
|
+
replace: LinkNavigate
|
|
17
|
+
back(): void | Promise<unknown>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The common string-route subset of Vue Router, Nuxt's router and vue-router-ns. */
|
|
21
|
+
export interface MavisRouter {
|
|
22
|
+
resolve(href: string): { href?: string; fullPath?: string }
|
|
23
|
+
push(href: string): unknown
|
|
24
|
+
replace(href: string): unknown
|
|
25
|
+
back(): unknown
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isAppDestination(href: string): boolean {
|
|
29
|
+
return !/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href) && !href.includes('\\')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Retains router guards/history and Web base/hash URLs; does not install a router. */
|
|
33
|
+
export function createRouterNavigation(router: MavisRouter): MavisNavigation {
|
|
34
|
+
const internal = (href: string) => {
|
|
35
|
+
const value = linkDestination(href)
|
|
36
|
+
if (!isAppDestination(value))
|
|
37
|
+
throw new TypeError('Router navigation requires an in-app destination.')
|
|
38
|
+
return value
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
resolve(href) {
|
|
42
|
+
const value = internal(href)
|
|
43
|
+
const resolved = router.resolve(value)
|
|
44
|
+
return linkDestination(resolved.href ?? resolved.fullPath ?? value)
|
|
45
|
+
},
|
|
46
|
+
async push(href) {
|
|
47
|
+
return router.push(internal(href))
|
|
48
|
+
},
|
|
49
|
+
async replace(href) {
|
|
50
|
+
return router.replace(internal(href))
|
|
51
|
+
},
|
|
52
|
+
async back() {
|
|
53
|
+
return router.back()
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An explicit callback takes precedence. External links keep the platform default. */
|
|
59
|
+
export function resolveNavigation(
|
|
60
|
+
options: NavigationOptions,
|
|
61
|
+
navigation?: MavisNavigation,
|
|
62
|
+
): NavigationOptions {
|
|
63
|
+
if (options.href === undefined) return options
|
|
64
|
+
const href = linkDestination(options.href)
|
|
65
|
+
if (options.navigate || !navigation || !isAppDestination(href)) return { ...options, href }
|
|
66
|
+
return {
|
|
67
|
+
...options,
|
|
68
|
+
href: linkDestination(navigation.resolve(href)),
|
|
69
|
+
navigate: () => navigation.push(href),
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Navigation belongs to the host; the shared contract only validates its destination. */
|
|
74
|
+
export function linkDestination(href: string): string {
|
|
75
|
+
const value = href.trim()
|
|
76
|
+
if (!value || /[\u0000-\u001f\u007f]/.test(value))
|
|
77
|
+
throw new TypeError('MLink requires a nonempty destination without control characters.')
|
|
78
|
+
if (/^(?:javascript|data|vbscript):/i.test(value))
|
|
79
|
+
throw new TypeError('MLink does not accept executable destinations.')
|
|
80
|
+
return value
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function linkRel(target: LinkTarget, rel = ''): string | undefined {
|
|
84
|
+
const tokens = new Set(rel.split(/\s+/).filter(Boolean))
|
|
85
|
+
if (target === '_blank') {
|
|
86
|
+
tokens.delete('opener')
|
|
87
|
+
tokens.add('noopener')
|
|
88
|
+
tokens.add('noreferrer')
|
|
89
|
+
}
|
|
90
|
+
return [...tokens].join(' ') || undefined
|
|
91
|
+
}
|
package/src/list-item.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Slot content needs an explicit label when it adds meaning to an interactive row. */
|
|
2
|
+
export function listItemLabel(title: string, description: string, label?: string): string {
|
|
3
|
+
if (!title?.trim()) throw new RangeError('ListItem requires a non-empty title.')
|
|
4
|
+
return label?.trim() || [title.trim(), description.trim()].filter(Boolean).join('. ')
|
|
5
|
+
}
|
package/src/motion.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Theme input shared by recipes and theme validation. */
|
|
2
|
+
export function resolvePressScale(scale: number): number {
|
|
3
|
+
if (!Number.isFinite(scale) || scale <= 0 || scale > 1) {
|
|
4
|
+
throw new RangeError('pressScale must be a finite number greater than 0 and at most 1')
|
|
5
|
+
}
|
|
6
|
+
return scale
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Recipes describe motion, not input or lifecycle. Adapters own reduced-motion detection:
|
|
10
|
+
// native follows Jolt configuration; Web follows prefers-reduced-motion. See guide/motion.
|
|
11
|
+
export function pressMotion(value: number | Readonly<MotionTheme>) {
|
|
12
|
+
if (value === null || (typeof value !== 'number' && typeof value !== 'object'))
|
|
13
|
+
throw new RangeError('Press motion needs a valid scale or motion theme')
|
|
14
|
+
const motion = typeof value === 'number' ? { ...defaultMotion, pressScale: value } : value
|
|
15
|
+
validateMotion(motion)
|
|
16
|
+
return {
|
|
17
|
+
composition: 'multiply',
|
|
18
|
+
pressed: [
|
|
19
|
+
{ scale: motion.pressScale },
|
|
20
|
+
{ type: 'spring', duration: motion.pressDuration, bounce: 0 },
|
|
21
|
+
],
|
|
22
|
+
released: [
|
|
23
|
+
{ scale: 1 },
|
|
24
|
+
{ type: 'spring', duration: motion.releaseDuration, bounce: motion.releaseBounce },
|
|
25
|
+
],
|
|
26
|
+
} as const
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Platform-neutral recipe. The host supplies the target and owns the Jolt playback. */
|
|
30
|
+
export function motionRecipe(theme: MavisTheme, name: 'enter' | 'exit') {
|
|
31
|
+
const motion = theme.motion
|
|
32
|
+
validateMotion(motion)
|
|
33
|
+
return name === 'enter'
|
|
34
|
+
? {
|
|
35
|
+
keyframes: { opacity: [0, 1], y: [motion.enterOffset, 0] },
|
|
36
|
+
transition: { type: 'tween' as const, duration: motion.enterDuration, ease: motion.ease },
|
|
37
|
+
}
|
|
38
|
+
: {
|
|
39
|
+
keyframes: { opacity: [1, 0] },
|
|
40
|
+
transition: { type: 'tween' as const, duration: motion.exitDuration, ease: motion.ease },
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const revealMotion = {
|
|
45
|
+
enter: [{ opacity: [0, 1], y: [8, 0] }, { duration: 180 }],
|
|
46
|
+
leave: [{ opacity: 0 }, { duration: 120 }],
|
|
47
|
+
} as const
|
|
48
|
+
import type { MotionTheme, MavisTheme } from './theme/types.js'
|
|
49
|
+
|
|
50
|
+
export const defaultMotion: Readonly<MotionTheme> = Object.freeze({
|
|
51
|
+
pressScale: 0.97,
|
|
52
|
+
pressDuration: 200,
|
|
53
|
+
releaseDuration: 450,
|
|
54
|
+
releaseBounce: 0.35,
|
|
55
|
+
enterDuration: 180,
|
|
56
|
+
exitDuration: 120,
|
|
57
|
+
enterOffset: 8,
|
|
58
|
+
ease: 'easeOut',
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export function validateMotion(motion: Readonly<MotionTheme>) {
|
|
62
|
+
resolvePressScale(motion.pressScale)
|
|
63
|
+
for (const key of [
|
|
64
|
+
'pressDuration',
|
|
65
|
+
'releaseDuration',
|
|
66
|
+
'enterDuration',
|
|
67
|
+
'exitDuration',
|
|
68
|
+
'enterOffset',
|
|
69
|
+
] as const)
|
|
70
|
+
if (!Number.isFinite(motion[key]) || motion[key] < 0)
|
|
71
|
+
throw new RangeError(`${key} must be a finite nonnegative number`)
|
|
72
|
+
if (
|
|
73
|
+
!Number.isFinite(motion.releaseBounce) ||
|
|
74
|
+
motion.releaseBounce < 0 ||
|
|
75
|
+
motion.releaseBounce > 1
|
|
76
|
+
)
|
|
77
|
+
throw new RangeError('releaseBounce must be between 0 and 1')
|
|
78
|
+
if (!['linear', 'easeIn', 'easeOut', 'easeInOut'].includes(motion.ease))
|
|
79
|
+
throw new RangeError('Unknown motion easing')
|
|
80
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { choiceKey, validateChoices, type ChoiceOption, type ChoiceValue } from './choice.js'
|
|
2
|
+
|
|
3
|
+
export function validateMultiSelection(
|
|
4
|
+
options: readonly ChoiceOption[],
|
|
5
|
+
values: readonly ChoiceValue[],
|
|
6
|
+
max?: number,
|
|
7
|
+
) {
|
|
8
|
+
validateChoices(options, null)
|
|
9
|
+
if (max !== undefined && (!Number.isInteger(max) || max < 1))
|
|
10
|
+
throw new RangeError('maxSelected must be a positive integer.')
|
|
11
|
+
const keys = values.map(choiceKey)
|
|
12
|
+
if (new Set(keys).size !== keys.length) throw new RangeError('Selected values must be unique.')
|
|
13
|
+
if (values.some((value) => !options.some((option) => option.value === value)))
|
|
14
|
+
throw new RangeError('Each selected value needs a matching option.')
|
|
15
|
+
if (max !== undefined && values.length > max)
|
|
16
|
+
throw new RangeError('Selection exceeds maxSelected.')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function toggleMultiSelection(
|
|
20
|
+
options: readonly ChoiceOption[],
|
|
21
|
+
values: readonly ChoiceValue[],
|
|
22
|
+
value: ChoiceValue,
|
|
23
|
+
max?: number,
|
|
24
|
+
) {
|
|
25
|
+
validateMultiSelection(options, values, max)
|
|
26
|
+
const option = options.find((item) => item.value === value)
|
|
27
|
+
if (!option || option.disabled) return null
|
|
28
|
+
if (values.includes(value)) return values.filter((item) => item !== value)
|
|
29
|
+
return max !== undefined && values.length >= max ? null : [...values, value]
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface NavigationTransition {
|
|
2
|
+
name?: 'fade' | 'slide' | 'none'
|
|
3
|
+
duration?: number
|
|
4
|
+
}
|
|
5
|
+
/** Shared policy; routers retain guard, history, cancellation and native-back ownership. */
|
|
6
|
+
export function defineNavigationTransition(options: NavigationTransition = {}) {
|
|
7
|
+
const name = options.name ?? 'fade',
|
|
8
|
+
duration = options.duration ?? 220
|
|
9
|
+
if (!['fade', 'slide', 'none'].includes(name))
|
|
10
|
+
throw new TypeError('Navigation transition must be fade, slide or none.')
|
|
11
|
+
if (!Number.isFinite(duration) || duration < 0 || duration > 10000)
|
|
12
|
+
throw new RangeError('Navigation duration must be between 0 and 10000ms.')
|
|
13
|
+
return Object.freeze({ name, duration })
|
|
14
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { validateChoices, type ChoiceOption, type ChoiceValue } from './choice.js'
|
|
2
|
+
|
|
3
|
+
export interface StepOption extends ChoiceOption {
|
|
4
|
+
status?: 'pending' | 'complete' | 'error'
|
|
5
|
+
}
|
|
6
|
+
export function validateSteps(steps: readonly StepOption[], current: ChoiceValue | null) {
|
|
7
|
+
validateChoices(steps, current)
|
|
8
|
+
if (!steps.length) throw new RangeError('Steps require at least one item.')
|
|
9
|
+
if (current !== null && !steps.some((step) => step.value === current))
|
|
10
|
+
throw new RangeError('The current step must exist in steps.')
|
|
11
|
+
for (const step of steps)
|
|
12
|
+
if (step.status && !['pending', 'complete', 'error'].includes(step.status))
|
|
13
|
+
throw new RangeError(`Unknown step status: ${step.status}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PaginationItem = { kind: 'page'; page: number } | { kind: 'gap'; key: string }
|
|
17
|
+
export function pageCount(total: number, pageSize: number) {
|
|
18
|
+
if (!Number.isSafeInteger(total) || total < 0)
|
|
19
|
+
throw new RangeError('total must be a non-negative safe integer.')
|
|
20
|
+
if (!Number.isSafeInteger(pageSize) || pageSize < 1)
|
|
21
|
+
throw new RangeError('pageSize must be a positive safe integer.')
|
|
22
|
+
return Math.ceil(total / pageSize)
|
|
23
|
+
}
|
|
24
|
+
/** 1-based pages. Empty results retain page 1 without inventing a result page. */
|
|
25
|
+
export function pagination(total: number, pageSize: number, page: number, siblingCount = 1) {
|
|
26
|
+
const count = pageCount(total, pageSize)
|
|
27
|
+
if (!Number.isSafeInteger(page) || page < 1)
|
|
28
|
+
throw new RangeError('page must be a positive safe integer.')
|
|
29
|
+
if (!Number.isInteger(siblingCount) || siblingCount < 0 || siblingCount > 2)
|
|
30
|
+
throw new RangeError('siblingCount must be 0, 1 or 2.')
|
|
31
|
+
// A changed total can temporarily make the parent's page stale. Report it without mutation.
|
|
32
|
+
const outOfRange = page > Math.max(1, count)
|
|
33
|
+
const pages = new Set<number>()
|
|
34
|
+
if (count > 0) {
|
|
35
|
+
pages.add(1)
|
|
36
|
+
pages.add(count)
|
|
37
|
+
}
|
|
38
|
+
const anchor = Math.min(page, count)
|
|
39
|
+
for (
|
|
40
|
+
let value = Math.max(1, anchor - siblingCount);
|
|
41
|
+
value <= Math.min(count, anchor + siblingCount);
|
|
42
|
+
value++
|
|
43
|
+
)
|
|
44
|
+
pages.add(value)
|
|
45
|
+
const items: PaginationItem[] = []
|
|
46
|
+
let previous = 0
|
|
47
|
+
for (const value of [...pages].sort((a, b) => a - b)) {
|
|
48
|
+
if (previous && value - previous === 2) items.push({ kind: 'page', page: previous + 1 })
|
|
49
|
+
else if (previous && value - previous > 2)
|
|
50
|
+
items.push({ kind: 'gap', key: `${previous}-${value}` })
|
|
51
|
+
items.push({ kind: 'page', page: value })
|
|
52
|
+
previous = value
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
count,
|
|
56
|
+
items,
|
|
57
|
+
outOfRange,
|
|
58
|
+
previous: count > 0 && page > 1 ? Math.min(page - 1, count) : null,
|
|
59
|
+
next: page < count ? page + 1 : null,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type NumberLocale = 'en-US' | 'pt-BR'
|
|
2
|
+
export type NumberDraft =
|
|
3
|
+
| { status: 'valid'; value: number }
|
|
4
|
+
| { status: 'empty'; value: null }
|
|
5
|
+
| { status: 'incomplete' | 'invalid' | 'range'; value: null }
|
|
6
|
+
|
|
7
|
+
export interface NumberConstraints {
|
|
8
|
+
min?: number
|
|
9
|
+
max?: number
|
|
10
|
+
step: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateNumberConstraints({ min, max, step }: NumberConstraints) {
|
|
14
|
+
if (!Number.isFinite(step) || step <= 0) throw new RangeError('step must be finite and positive.')
|
|
15
|
+
if ([min, max].some((value) => value !== undefined && !Number.isFinite(value)))
|
|
16
|
+
throw new RangeError('Numeric bounds must be finite.')
|
|
17
|
+
if (min !== undefined && max !== undefined && min > max)
|
|
18
|
+
throw new RangeError('min must not exceed max.')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function formatNumber(value: number | null, locale: NumberLocale) {
|
|
22
|
+
if (value === null) return ''
|
|
23
|
+
if (!Number.isFinite(value)) throw new RangeError('NumberInput requires a finite number or null.')
|
|
24
|
+
const [coefficient, exponent] = String(value).split('e')
|
|
25
|
+
let text = coefficient!
|
|
26
|
+
if (exponent) {
|
|
27
|
+
const negative = text.startsWith('-')
|
|
28
|
+
const [whole, fraction = ''] = text.replace('-', '').split('.')
|
|
29
|
+
const digits = whole! + fraction
|
|
30
|
+
const point = whole!.length + Number(exponent)
|
|
31
|
+
text =
|
|
32
|
+
point <= 0
|
|
33
|
+
? `0.${'0'.repeat(-point)}${digits}`
|
|
34
|
+
: point >= digits.length
|
|
35
|
+
? digits + '0'.repeat(point - digits.length)
|
|
36
|
+
: `${digits.slice(0, point)}.${digits.slice(point)}`
|
|
37
|
+
if (negative) text = `-${text}`
|
|
38
|
+
}
|
|
39
|
+
return locale === 'pt-BR' ? text.replace('.', ',') : text
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function parseNumberDraft(
|
|
43
|
+
text: string,
|
|
44
|
+
locale: NumberLocale,
|
|
45
|
+
bounds: NumberConstraints,
|
|
46
|
+
): NumberDraft {
|
|
47
|
+
const value = text.trim()
|
|
48
|
+
if (!value) return { status: 'empty', value: null }
|
|
49
|
+
const normalized = locale === 'pt-BR' ? value.replace(',', '.') : value
|
|
50
|
+
if (/^[+-]?$/.test(normalized) || /^[+-]?(?:\d+)?\.$/.test(normalized))
|
|
51
|
+
return { status: 'incomplete', value: null }
|
|
52
|
+
if (!/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(normalized)) return { status: 'invalid', value: null }
|
|
53
|
+
const number = Number(normalized)
|
|
54
|
+
if (!Number.isFinite(number)) return { status: 'invalid', value: null }
|
|
55
|
+
if (
|
|
56
|
+
(bounds.min !== undefined && number < bounds.min) ||
|
|
57
|
+
(bounds.max !== undefined && number > bounds.max)
|
|
58
|
+
)
|
|
59
|
+
return { status: 'range', value: null }
|
|
60
|
+
return { status: 'valid', value: number }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function stepNumber(value: number | null, direction: -1 | 1, bounds: NumberConstraints) {
|
|
64
|
+
validateNumberConstraints(bounds)
|
|
65
|
+
const base = value ?? Math.max(bounds.min ?? 0, Math.min(0, bounds.max ?? 0))
|
|
66
|
+
// Scale ordinary decimal steps only while the integer arithmetic remains exact.
|
|
67
|
+
// Large or very small values retain JavaScript number precision without rounding to 15 digits.
|
|
68
|
+
const decimals = (number: number) => formatNumber(number, 'en-US').split('.')[1]?.length ?? 0
|
|
69
|
+
const factor = 10 ** Math.max(decimals(base), decimals(bounds.step))
|
|
70
|
+
const scaledBase = Math.round(base * factor),
|
|
71
|
+
scaledStep = Math.round(bounds.step * factor)
|
|
72
|
+
const scaledNext = scaledBase + direction * scaledStep
|
|
73
|
+
const next = [scaledBase, scaledStep, scaledNext].every(Number.isSafeInteger)
|
|
74
|
+
? scaledNext / factor
|
|
75
|
+
: base + direction * bounds.step
|
|
76
|
+
return Math.max(
|
|
77
|
+
bounds.min ?? -Infinity,
|
|
78
|
+
Math.min(bounds.max ?? Infinity, Number.isFinite(next) ? next : base),
|
|
79
|
+
)
|
|
80
|
+
}
|
package/src/popover.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type PopoverPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end'
|
|
2
|
+
export type PopoverCloseReason = 'trigger' | 'outside' | 'escape' | 'back' | 'select' | 'program'
|
|
3
|
+
export interface PopoverRect {
|
|
4
|
+
x: number
|
|
5
|
+
y: number
|
|
6
|
+
width: number
|
|
7
|
+
height: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Coordinates share one CSS-pixel/DIP space. Flip vertically, then clamp to the viewport. */
|
|
11
|
+
export function placePopover(
|
|
12
|
+
anchor: PopoverRect,
|
|
13
|
+
panel: { width: number; height: number },
|
|
14
|
+
viewport: PopoverRect,
|
|
15
|
+
placement: PopoverPlacement,
|
|
16
|
+
rtl = false,
|
|
17
|
+
gap = 8,
|
|
18
|
+
margin = 8,
|
|
19
|
+
) {
|
|
20
|
+
const bottom = anchor.y + anchor.height + gap
|
|
21
|
+
const top = anchor.y - gap - panel.height
|
|
22
|
+
const lower = viewport.y + viewport.height - margin
|
|
23
|
+
const upper = viewport.y + margin
|
|
24
|
+
let above = placement.startsWith('top')
|
|
25
|
+
if (above && top < upper && bottom + panel.height <= lower) above = false
|
|
26
|
+
else if (!above && bottom + panel.height > lower && top >= upper) above = true
|
|
27
|
+
const end = placement.endsWith('end') !== rtl
|
|
28
|
+
const clamp = (value: number, min: number, max: number) =>
|
|
29
|
+
Math.max(min, Math.min(value, Math.max(min, max)))
|
|
30
|
+
return {
|
|
31
|
+
x: clamp(
|
|
32
|
+
end ? anchor.x + anchor.width - panel.width : anchor.x,
|
|
33
|
+
viewport.x + margin,
|
|
34
|
+
viewport.x + viewport.width - panel.width - margin,
|
|
35
|
+
),
|
|
36
|
+
y: clamp(above ? top : bottom, upper, lower - panel.height),
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/progress.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const progressSizes = { sm: 4, md: 8, lg: 12 } as const
|
|
2
|
+
export type ProgressSize = keyof typeof progressSizes
|
|
3
|
+
export type ProgressTone = 'primary' | 'accent' | 'success' | 'warning' | 'danger'
|
|
4
|
+
|
|
5
|
+
export const progressMotion = Object.freeze({ segment: 0.32, duration: 1600 })
|
|
6
|
+
|
|
7
|
+
/** A bounded reading; task ownership and completion stay with the application. */
|
|
8
|
+
export function progressState(value: number, max: number) {
|
|
9
|
+
if (!Number.isFinite(max) || max <= 0)
|
|
10
|
+
throw new RangeError('Progress max must be positive and finite')
|
|
11
|
+
if (!Number.isFinite(value)) throw new RangeError('Progress value must be finite')
|
|
12
|
+
const current = Math.min(max, Math.max(0, value))
|
|
13
|
+
const ratio = current / max
|
|
14
|
+
return { value: current, ratio, text: `${Number((ratio * 100).toFixed(1))}%` }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function checkProgressLabels(label: string, indeterminateLabel: string) {
|
|
18
|
+
if (typeof label !== 'string' || !label.trim())
|
|
19
|
+
throw new TypeError('Progress label must be a non-empty string')
|
|
20
|
+
if (typeof indeterminateLabel !== 'string' || !indeterminateLabel.trim())
|
|
21
|
+
throw new TypeError('Progress indeterminateLabel must be a non-empty string')
|
|
22
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Spacing } from './theme/types.js'
|
|
2
|
+
|
|
3
|
+
export type StackDirection = 'row' | 'column'
|
|
4
|
+
export interface StackLayout {
|
|
5
|
+
direction?: StackDirection
|
|
6
|
+
gap?: Spacing
|
|
7
|
+
align?: 'start' | 'end' | 'center' | 'stretch'
|
|
8
|
+
justify?: 'start' | 'end' | 'center' | 'between' | 'around'
|
|
9
|
+
wrap?: boolean
|
|
10
|
+
}
|
|
11
|
+
export interface StackBreakpoint extends StackLayout {
|
|
12
|
+
/** Content width in CSS pixels on Web and DIPs on NativeScript. */
|
|
13
|
+
at: number
|
|
14
|
+
}
|
|
15
|
+
export type StackResponsive = StackBreakpoint | readonly StackBreakpoint[]
|
|
16
|
+
|
|
17
|
+
/** Sorted min-width overrides; the input order never changes the resulting layout. */
|
|
18
|
+
export function stackLayout(
|
|
19
|
+
base: StackLayout,
|
|
20
|
+
responsive: StackResponsive | undefined,
|
|
21
|
+
width?: number,
|
|
22
|
+
): StackLayout {
|
|
23
|
+
const points =
|
|
24
|
+
responsive === undefined
|
|
25
|
+
? []
|
|
26
|
+
: Array.isArray(responsive)
|
|
27
|
+
? [...responsive]
|
|
28
|
+
: [responsive as StackBreakpoint]
|
|
29
|
+
const seen = new Set<number>()
|
|
30
|
+
const result = { ...base }
|
|
31
|
+
for (const point of points.sort((a, b) => a.at - b.at)) {
|
|
32
|
+
if (!Number.isFinite(point.at) || point.at <= 0 || seen.has(point.at))
|
|
33
|
+
throw new RangeError('Stack breakpoints must be distinct positive content widths.')
|
|
34
|
+
seen.add(point.at)
|
|
35
|
+
if (point.direction !== undefined && !['row', 'column'].includes(point.direction))
|
|
36
|
+
throw new TypeError('Unknown responsive stack direction.')
|
|
37
|
+
if (point.align !== undefined && !['start', 'end', 'center', 'stretch'].includes(point.align))
|
|
38
|
+
throw new TypeError('Unknown responsive alignment.')
|
|
39
|
+
if (
|
|
40
|
+
point.justify !== undefined &&
|
|
41
|
+
!['start', 'end', 'center', 'between', 'around'].includes(point.justify)
|
|
42
|
+
)
|
|
43
|
+
throw new TypeError('Unknown responsive distribution.')
|
|
44
|
+
if (point.wrap !== undefined && typeof point.wrap !== 'boolean')
|
|
45
|
+
throw new TypeError('wrap must be boolean.')
|
|
46
|
+
if (width !== undefined && width >= point.at) {
|
|
47
|
+
const { at, ...override } = point
|
|
48
|
+
Object.assign(result, override)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function stackDirection(
|
|
55
|
+
base: StackDirection,
|
|
56
|
+
responsive: StackResponsive | undefined,
|
|
57
|
+
width?: number,
|
|
58
|
+
): StackDirection {
|
|
59
|
+
if (!['row', 'column'].includes(base)) throw new TypeError('Unknown stack direction.')
|
|
60
|
+
return stackLayout({ direction: base }, responsive, width).direction ?? base
|
|
61
|
+
}
|