@getcortexlabs/mavis-core 0.1.0-alpha.8 → 0.1.0-rc.11.1
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/capabilities.d.ts +7 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +30 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/chart.d.ts +43 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +105 -0
- package/dist/chart.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/contracts.d.ts +20 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -1
- 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/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/experimental-regions.d.ts +10 -0
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +23 -0
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental.d.ts +5 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +29 -0
- package/dist/experimental.js.map +1 -1
- 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/index.d.ts +17 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js.map +1 -1
- package/dist/interactive.d.ts +36 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +61 -0
- package/dist/interactive.js.map +1 -0
- package/dist/link.d.ts +24 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +41 -0
- package/dist/link.js.map +1 -1
- package/dist/motion.d.ts +8 -0
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +11 -0
- package/dist/motion.js.map +1 -1
- 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/number-flow-format.d.ts +16 -0
- package/dist/number-flow-format.d.ts.map +1 -0
- package/dist/number-flow-format.js +49 -0
- package/dist/number-flow-format.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/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/sheet.d.ts +7 -0
- package/dist/sheet.d.ts.map +1 -1
- 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/vue/carousel.d.ts +13 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +136 -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 +245 -0
- package/dist/vue/chart.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 +190 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-motion.d.ts +17 -0
- package/dist/vue/component-motion.d.ts.map +1 -0
- package/dist/vue/component-motion.js +83 -0
- package/dist/vue/component-motion.js.map +1 -0
- package/dist/vue/component-props.d.ts +1505 -402
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +28 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/configurator-props.d.ts +21 -0
- package/dist/vue/configurator-props.d.ts.map +1 -1
- package/dist/vue/configurator-props.js +6 -0
- package/dist/vue/configurator-props.js.map +1 -1
- package/dist/vue/configurator.d.ts +3 -3
- package/dist/vue/configurator.d.ts.map +1 -1
- package/dist/vue/configurator.js +3 -1
- package/dist/vue/configurator.js.map +1 -1
- 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 +2 -0
- package/dist/vue/date-calendar.d.ts.map +1 -1
- package/dist/vue/date-calendar.js +20 -1
- package/dist/vue/date-calendar.js.map +1 -1
- package/dist/vue/date-picker.d.ts +48 -13
- package/dist/vue/date-picker.d.ts.map +1 -1
- package/dist/vue/date-picker.js +67 -74
- package/dist/vue/date-picker.js.map +1 -1
- package/dist/vue/date-props.d.ts +15 -0
- package/dist/vue/date-props.d.ts.map +1 -1
- package/dist/vue/date-props.js +4 -0
- package/dist/vue/date-props.js.map +1 -1
- 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 +185 -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/global-components.d.ts +134 -2
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +27 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +23 -1
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/interactive-components.d.ts +31 -0
- package/dist/vue/interactive-components.d.ts.map +1 -0
- package/dist/vue/interactive-components.js +2 -0
- package/dist/vue/interactive-components.js.map +1 -0
- package/dist/vue/interactive-props.d.ts +254 -0
- package/dist/vue/interactive-props.d.ts.map +1 -0
- package/dist/vue/interactive-props.js +85 -0
- package/dist/vue/interactive-props.js.map +1 -0
- 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/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 +125 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +130 -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/number-flow.d.ts +75 -0
- package/dist/vue/number-flow.d.ts.map +1 -0
- package/dist/vue/number-flow.js +57 -0
- package/dist/vue/number-flow.js.map +1 -0
- package/dist/vue/partition.d.ts +15 -0
- package/dist/vue/partition.d.ts.map +1 -0
- package/dist/vue/partition.js +42 -0
- package/dist/vue/partition.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 +233 -36
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +15 -1
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/sortable-list.d.ts +24 -0
- package/dist/vue/sortable-list.d.ts.map +1 -0
- package/dist/vue/sortable-list.js +251 -0
- package/dist/vue/sortable-list.js.map +1 -0
- package/dist/vue/swipe-actions.d.ts +96 -0
- package/dist/vue/swipe-actions.d.ts.map +1 -0
- package/dist/vue/swipe-actions.js +174 -0
- package/dist/vue/swipe-actions.js.map +1 -0
- 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/tree-view.d.ts +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +204 -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 +199 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +330 -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/workflows.d.ts +2 -2
- package/dist/vue/workflows.d.ts.map +1 -1
- package/dist/vue/workflows.js +17 -4
- package/dist/vue/workflows.js.map +1 -1
- 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 +2 -2
- package/src/capabilities.ts +31 -4
- package/src/chart.ts +151 -0
- package/src/collections.ts +87 -0
- package/src/contracts.ts +2 -0
- package/src/date-input.ts +87 -0
- package/src/date-time.ts +37 -0
- package/src/discovery.ts +139 -0
- package/src/experimental-regions.ts +29 -0
- package/src/experimental.ts +40 -0
- package/src/grid.ts +19 -0
- package/src/index.ts +24 -3
- package/src/input.ts +5 -0
- package/src/interactive.ts +91 -0
- package/src/link.ts +63 -0
- package/src/motion.ts +14 -0
- package/src/navigation-transition.ts +14 -0
- package/src/number-flow-format.ts +68 -0
- package/src/popover.ts +38 -0
- package/src/section-scroll.ts +46 -0
- package/src/sheet.ts +11 -0
- package/src/time.ts +83 -0
- package/src/vue/carousel.ts +198 -0
- package/src/vue/chart.ts +337 -0
- package/src/vue/command-palette.ts +235 -0
- package/src/vue/component-motion.ts +109 -0
- package/src/vue/component-props.ts +57 -0
- package/src/vue/configurator-props.ts +6 -0
- package/src/vue/configurator.ts +3 -1
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +30 -1
- package/src/vue/date-picker.ts +81 -85
- package/src/vue/date-props.ts +5 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +241 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/global-components.ts +124 -2
- package/src/vue/index.ts +46 -0
- package/src/vue/interactive-components.ts +29 -0
- package/src/vue/interactive-props.ts +90 -0
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +159 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/navigation.ts +16 -0
- package/src/vue/number-flow.ts +83 -0
- package/src/vue/partition.ts +49 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +16 -1
- package/src/vue/sortable-list.ts +308 -0
- package/src/vue/swipe-actions.ts +226 -0
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/tree-view.ts +259 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +430 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflows.ts +17 -4
- package/src/wayfinding.ts +85 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useComponentSelection, useComponentLayout } from './component-motion.js'
|
|
2
|
+
import { defineComponent, h, inject, mergeProps, type Component } from '@vue/runtime-core'
|
|
3
|
+
import { choiceKey } from '../choice.js'
|
|
4
|
+
import { validateNavigation } from '../collections.js'
|
|
5
|
+
import { appBarProps, tabBarProps } from './navigation-props.js'
|
|
6
|
+
import { navigationKey } from './navigation.js'
|
|
7
|
+
import { useMavisTheme } from './theme.js'
|
|
8
|
+
|
|
9
|
+
export function createNavigationControls(
|
|
10
|
+
ui: {
|
|
11
|
+
Box: Component
|
|
12
|
+
Row: Component
|
|
13
|
+
Column: Component
|
|
14
|
+
Text: Component
|
|
15
|
+
Button: Component
|
|
16
|
+
Badge: Component
|
|
17
|
+
},
|
|
18
|
+
platform: 'web' | 'native',
|
|
19
|
+
) {
|
|
20
|
+
const MAppBar = defineComponent({
|
|
21
|
+
name: 'MAppBar',
|
|
22
|
+
inheritAttrs: false,
|
|
23
|
+
props: appBarProps,
|
|
24
|
+
emits: { back: () => true, error: (_error: unknown) => true },
|
|
25
|
+
setup(props, { attrs, slots, emit }) {
|
|
26
|
+
const navigation = inject(navigationKey, undefined)
|
|
27
|
+
const { theme } = useMavisTheme()
|
|
28
|
+
async function back() {
|
|
29
|
+
try {
|
|
30
|
+
const navigate = props.navigateBack ?? navigation?.back
|
|
31
|
+
if (!navigate) throw new Error('MAppBar back requires navigation or navigateBack.')
|
|
32
|
+
await navigate()
|
|
33
|
+
emit('back')
|
|
34
|
+
} catch (error) {
|
|
35
|
+
emit('error', error)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
if (!props.title.trim()) throw new TypeError('App bars require a title.')
|
|
40
|
+
return h(
|
|
41
|
+
ui.Row,
|
|
42
|
+
mergeProps(
|
|
43
|
+
{
|
|
44
|
+
id: props.id,
|
|
45
|
+
padding: 'md',
|
|
46
|
+
gap: 'md',
|
|
47
|
+
shrink: 0,
|
|
48
|
+
backgroundColor: theme.value.colors.surface,
|
|
49
|
+
},
|
|
50
|
+
attrs,
|
|
51
|
+
platform === 'web'
|
|
52
|
+
? { role: 'group', 'aria-label': props.title, class: 'm-app-bar' }
|
|
53
|
+
: {},
|
|
54
|
+
),
|
|
55
|
+
() => [
|
|
56
|
+
props.back
|
|
57
|
+
? h(ui.Button, {
|
|
58
|
+
icon: 'arrow-left',
|
|
59
|
+
accessibilityLabel: props.backLabel,
|
|
60
|
+
variant: 'ghost',
|
|
61
|
+
onClick: back,
|
|
62
|
+
})
|
|
63
|
+
: null,
|
|
64
|
+
slots.leading?.(),
|
|
65
|
+
h(ui.Column, { grow: 1, shrink: 1, gap: 'xs' }, () => [
|
|
66
|
+
h(ui.Text, { text: props.title, variant: 'heading', as: 'h1' }),
|
|
67
|
+
props.subtitle
|
|
68
|
+
? h(ui.Text, { text: props.subtitle, variant: 'caption', tone: 'muted' })
|
|
69
|
+
: null,
|
|
70
|
+
]),
|
|
71
|
+
slots.actions?.(),
|
|
72
|
+
],
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
const MTabBar = defineComponent({
|
|
78
|
+
name: 'MTabBar',
|
|
79
|
+
inheritAttrs: false,
|
|
80
|
+
props: tabBarProps,
|
|
81
|
+
emits: { error: (_error: unknown) => true },
|
|
82
|
+
setup(props, { attrs, emit }) {
|
|
83
|
+
const { theme } = useMavisTheme()
|
|
84
|
+
const selection = useComponentSelection(() => props.modelValue)
|
|
85
|
+
return () => {
|
|
86
|
+
validateNavigation(props.items)
|
|
87
|
+
if (!props.label.trim()) throw new TypeError('Tab bars require a navigation label.')
|
|
88
|
+
return h(
|
|
89
|
+
ui.Row,
|
|
90
|
+
mergeProps(
|
|
91
|
+
{
|
|
92
|
+
id: props.id,
|
|
93
|
+
motionRegion: selection.region,
|
|
94
|
+
gap: 'xs',
|
|
95
|
+
padding: 'sm',
|
|
96
|
+
shrink: 0,
|
|
97
|
+
backgroundColor: theme.value.colors.surface,
|
|
98
|
+
},
|
|
99
|
+
attrs,
|
|
100
|
+
platform === 'web'
|
|
101
|
+
? {
|
|
102
|
+
role: 'navigation',
|
|
103
|
+
'aria-label': props.label,
|
|
104
|
+
class: 'm-tab-bar',
|
|
105
|
+
style: props.safeArea
|
|
106
|
+
? {
|
|
107
|
+
paddingBottom:
|
|
108
|
+
'max(var(--m-tab-padding, 8px), env(safe-area-inset-bottom))',
|
|
109
|
+
}
|
|
110
|
+
: undefined,
|
|
111
|
+
}
|
|
112
|
+
: { accessibilityLabel: props.label },
|
|
113
|
+
),
|
|
114
|
+
() =>
|
|
115
|
+
props.items.map((item) => {
|
|
116
|
+
const current = item.value === props.modelValue
|
|
117
|
+
return h(
|
|
118
|
+
ui.Button,
|
|
119
|
+
{
|
|
120
|
+
key: choiceKey(item.value),
|
|
121
|
+
grow: 1,
|
|
122
|
+
shrink: 1,
|
|
123
|
+
text: item.label,
|
|
124
|
+
icon: item.icon,
|
|
125
|
+
href: item.href,
|
|
126
|
+
navigate: item.navigate,
|
|
127
|
+
disabled: props.disabled || item.disabled,
|
|
128
|
+
variant: current ? 'primary' : 'ghost',
|
|
129
|
+
accessibilityLabel: `${item.label}${item.badge !== undefined ? ` ${item.badge}` : ''}${current && platform === 'native' ? `. ${props.currentLabel}` : ''}`,
|
|
130
|
+
...(platform === 'web' ? { 'aria-current': current ? 'page' : undefined } : {}),
|
|
131
|
+
onError: (error: unknown) => emit('error', error),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
trailing: () =>
|
|
135
|
+
h(ui.Row, { gap: 'xs' }, () => [
|
|
136
|
+
platform === 'web' && item.badge !== undefined ? ' ' : null,
|
|
137
|
+
current
|
|
138
|
+
? h(ui.Box, {
|
|
139
|
+
width: 5,
|
|
140
|
+
height: 5,
|
|
141
|
+
radius: 'full',
|
|
142
|
+
backgroundColor: theme.value.colors.onPrimary,
|
|
143
|
+
motionSurface: selection.marker,
|
|
144
|
+
accessibilityHidden: true,
|
|
145
|
+
})
|
|
146
|
+
: null,
|
|
147
|
+
item.badge !== undefined
|
|
148
|
+
? h(ui.Badge, { text: String(item.badge), accessibilityHidden: true })
|
|
149
|
+
: null,
|
|
150
|
+
]),
|
|
151
|
+
},
|
|
152
|
+
)
|
|
153
|
+
}),
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
return { MAppBar, MTabBar }
|
|
159
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { ChoiceValue } from '../choice.js'
|
|
3
|
+
import type { MenuItem, NavigationItem, VirtualItemKey } from '../collections.js'
|
|
4
|
+
import type { PopoverPlacement } from '../popover.js'
|
|
5
|
+
import type { HourCycle, LocalTime, TimeLocale } from '../time.js'
|
|
6
|
+
import { buttonProps, inputProps, spacingProp } from './props.js'
|
|
7
|
+
|
|
8
|
+
export const popoverProps = {
|
|
9
|
+
id: inputProps.id,
|
|
10
|
+
open: Boolean,
|
|
11
|
+
label: { type: String, required: true as const },
|
|
12
|
+
triggerLabel: { type: String, required: true as const },
|
|
13
|
+
icon: buttonProps.icon,
|
|
14
|
+
variant: { ...buttonProps.variant, default: 'secondary' },
|
|
15
|
+
disabled: Boolean,
|
|
16
|
+
placement: { type: String as PropType<PopoverPlacement>, default: 'bottom-start' },
|
|
17
|
+
width: { type: Number, default: 280 },
|
|
18
|
+
padding: { ...spacingProp, default: 'md' },
|
|
19
|
+
/** Menu owns its keyboard behavior; ordinary popovers contain arbitrary controls. */
|
|
20
|
+
role: { type: String as PropType<'dialog' | 'menu'>, default: 'dialog' },
|
|
21
|
+
}
|
|
22
|
+
export const menuProps = {
|
|
23
|
+
...popoverProps,
|
|
24
|
+
items: { type: Array as PropType<readonly MenuItem[]>, required: true as const },
|
|
25
|
+
}
|
|
26
|
+
export const appBarProps = {
|
|
27
|
+
id: inputProps.id,
|
|
28
|
+
title: { type: String, required: true as const },
|
|
29
|
+
subtitle: String,
|
|
30
|
+
back: Boolean,
|
|
31
|
+
backLabel: { type: String, default: 'Back' },
|
|
32
|
+
/** Optional app-owned callback; otherwise uses the installed navigation service. */
|
|
33
|
+
navigateBack: Function as PropType<() => void | Promise<unknown>>,
|
|
34
|
+
}
|
|
35
|
+
export const tabBarProps = {
|
|
36
|
+
id: inputProps.id,
|
|
37
|
+
label: { type: String, required: true as const },
|
|
38
|
+
modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
|
|
39
|
+
items: { type: Array as PropType<readonly NavigationItem[]>, required: true as const },
|
|
40
|
+
disabled: Boolean,
|
|
41
|
+
currentLabel: { type: String, default: 'Current page' },
|
|
42
|
+
/** Web viewport inset; native MScreen already owns the safe area. */
|
|
43
|
+
safeArea: { type: Boolean, default: false },
|
|
44
|
+
}
|
|
45
|
+
export const timePickerProps = {
|
|
46
|
+
id: inputProps.id,
|
|
47
|
+
label: inputProps.label,
|
|
48
|
+
width: inputProps.width,
|
|
49
|
+
grow: inputProps.grow,
|
|
50
|
+
shrink: inputProps.shrink,
|
|
51
|
+
modelValue: { type: String as PropType<LocalTime | null>, default: null },
|
|
52
|
+
draft: { type: String, default: undefined },
|
|
53
|
+
min: String,
|
|
54
|
+
max: String,
|
|
55
|
+
minuteStep: { type: Number, default: 1 },
|
|
56
|
+
locale: { type: String as PropType<TimeLocale>, default: 'en-US' },
|
|
57
|
+
hourCycle: String as PropType<HourCycle>,
|
|
58
|
+
name: inputProps.name,
|
|
59
|
+
disabled: Boolean,
|
|
60
|
+
readonly: Boolean,
|
|
61
|
+
required: Boolean,
|
|
62
|
+
helperText: inputProps.helperText,
|
|
63
|
+
error: inputProps.error,
|
|
64
|
+
placeholder: { type: String, default: undefined },
|
|
65
|
+
chooseLabel: { type: String, default: 'Choose time' },
|
|
66
|
+
confirmLabel: { type: String, default: 'Apply' },
|
|
67
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
68
|
+
clearLabel: { type: String, default: 'Clear time' },
|
|
69
|
+
hourLabel: { type: String, default: 'Hour' },
|
|
70
|
+
minuteLabel: { type: String, default: 'Minute' },
|
|
71
|
+
periodLabel: { type: String, default: 'Period' },
|
|
72
|
+
invalidLabel: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: 'Enter a valid time within the allowed range and interval.',
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
export const virtualListProps = {
|
|
78
|
+
id: inputProps.id,
|
|
79
|
+
label: { type: String, required: true as const },
|
|
80
|
+
items: { type: Array as PropType<readonly unknown[]>, required: true as const },
|
|
81
|
+
itemKey: { type: [String, Function] as PropType<VirtualItemKey>, default: 'id' },
|
|
82
|
+
rowHeight: { type: Number, required: true as const },
|
|
83
|
+
height: { type: Number, required: true as const },
|
|
84
|
+
overscan: { type: Number, default: 3 },
|
|
85
|
+
initialIndex: { type: Number, default: 0 },
|
|
86
|
+
emptyLabel: { type: String, default: 'No items' },
|
|
87
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from '@vue/runtime-core'
|
|
2
|
+
import { resolveNavigation, type MavisNavigation, type NavigationOptions } from '../link.js'
|
|
3
|
+
|
|
4
|
+
export const navigationKey: InjectionKey<MavisNavigation | undefined> = Symbol('mavis-navigation')
|
|
5
|
+
|
|
6
|
+
export function useMavisNavigation(): MavisNavigation {
|
|
7
|
+
const navigation = inject(navigationKey, undefined)
|
|
8
|
+
if (!navigation) throw new Error('Provide navigation when installing Mavis in this app.')
|
|
9
|
+
return navigation
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Renderer helper; read reactive component props at render/activation time. */
|
|
13
|
+
export function useNavigationOptions(options: NavigationOptions) {
|
|
14
|
+
const navigation = inject(navigationKey, undefined)
|
|
15
|
+
return () => resolveNavigation(options, navigation)
|
|
16
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
markRaw,
|
|
6
|
+
mergeProps,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
watch,
|
|
9
|
+
type Component,
|
|
10
|
+
} from '@vue/runtime-core'
|
|
11
|
+
import { createMotionSurface, type MotionPlayback } from '../experimental.js'
|
|
12
|
+
import { resolveNumberFlowFormat, type NumberFlowFormat } from '../number-flow-format.js'
|
|
13
|
+
import { numberFlowProps } from './interactive-props.js'
|
|
14
|
+
|
|
15
|
+
export function createNumberFlow(
|
|
16
|
+
Text: Component,
|
|
17
|
+
platform: 'web' | 'native',
|
|
18
|
+
formatter: (locale: string, options: NumberFlowFormat) => (value: number) => string = (
|
|
19
|
+
locale,
|
|
20
|
+
options,
|
|
21
|
+
) => new Intl.NumberFormat(locale, options).format,
|
|
22
|
+
) {
|
|
23
|
+
return defineComponent({
|
|
24
|
+
name: 'MNumberFlow',
|
|
25
|
+
inheritAttrs: false,
|
|
26
|
+
props: numberFlowProps,
|
|
27
|
+
setup(props, { attrs }) {
|
|
28
|
+
const surface = markRaw(createMotionSurface())
|
|
29
|
+
const format = computed(
|
|
30
|
+
() => props.formatValue ?? formatter(props.locale, resolveNumberFlowFormat(props.format)),
|
|
31
|
+
)
|
|
32
|
+
const text = computed(() => {
|
|
33
|
+
if (!Number.isFinite(props.duration) || props.duration <= 0)
|
|
34
|
+
throw new RangeError('MNumberFlow duration must be positive.')
|
|
35
|
+
if (!Number.isFinite(props.value)) throw new RangeError('MNumberFlow value must be finite.')
|
|
36
|
+
return format.value(props.value)
|
|
37
|
+
})
|
|
38
|
+
let playback: MotionPlayback | undefined
|
|
39
|
+
watch(
|
|
40
|
+
() => [props.value, format.value] as const,
|
|
41
|
+
() => {
|
|
42
|
+
if (!props.animated) playback?.stop()
|
|
43
|
+
if (surface.available && props.animated)
|
|
44
|
+
playback = surface.rollTo(props.value, {
|
|
45
|
+
format: format.value,
|
|
46
|
+
duration: props.duration,
|
|
47
|
+
stagger: 24,
|
|
48
|
+
tabular: true,
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
{ flush: 'pre' },
|
|
52
|
+
)
|
|
53
|
+
watch(
|
|
54
|
+
() => props.animated,
|
|
55
|
+
() => {
|
|
56
|
+
if (!props.animated) playback?.stop()
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
onScopeDispose(() => playback?.stop())
|
|
60
|
+
return () =>
|
|
61
|
+
h(
|
|
62
|
+
Text,
|
|
63
|
+
mergeProps(attrs, {
|
|
64
|
+
id: props.id,
|
|
65
|
+
text: text.value,
|
|
66
|
+
variant: props.variant,
|
|
67
|
+
tone: props.tone,
|
|
68
|
+
motionSurface: surface,
|
|
69
|
+
accessibilityLabel: props.label ? `${props.label}: ${text.value}` : text.value,
|
|
70
|
+
...(platform === 'web'
|
|
71
|
+
? {
|
|
72
|
+
class: 'm-number-flow',
|
|
73
|
+
role: props.announce ? 'status' : undefined,
|
|
74
|
+
'aria-live': props.announce ? 'polite' : 'off',
|
|
75
|
+
'aria-atomic': 'true',
|
|
76
|
+
style: { fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap' },
|
|
77
|
+
}
|
|
78
|
+
: { accessibilityLiveRegion: props.announce ? 'polite' : 'none' }),
|
|
79
|
+
}),
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { computed, onScopeDispose, ref, watch } from '@vue/runtime-core'
|
|
2
|
+
import { finiteRange, positiveSize } from '../interactive.js'
|
|
3
|
+
|
|
4
|
+
/** Shared transaction: dragging follows input; cancellation restores the owner's starting value. */
|
|
5
|
+
export function usePartition(
|
|
6
|
+
read: () => number,
|
|
7
|
+
options: () => { min: number; max: number; step: number; disabled: boolean },
|
|
8
|
+
emit: (value: number) => void,
|
|
9
|
+
) {
|
|
10
|
+
const dragging = ref(false)
|
|
11
|
+
const canonical = computed(() => finiteRange(read(), options().min, options().max))
|
|
12
|
+
let origin = 0
|
|
13
|
+
function update(value: number) {
|
|
14
|
+
const config = options()
|
|
15
|
+
if (config.disabled) return
|
|
16
|
+
const step = positiveSize(config.step, 'step')
|
|
17
|
+
const next = finiteRange(
|
|
18
|
+
config.min + Math.round((value - config.min) / step) * step,
|
|
19
|
+
config.min,
|
|
20
|
+
config.max,
|
|
21
|
+
)
|
|
22
|
+
if (next !== canonical.value) emit(Number(next.toFixed(8)))
|
|
23
|
+
}
|
|
24
|
+
function begin() {
|
|
25
|
+
if (options().disabled) return false
|
|
26
|
+
origin = canonical.value
|
|
27
|
+
dragging.value = true
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
function end() {
|
|
31
|
+
dragging.value = false
|
|
32
|
+
}
|
|
33
|
+
function cancel() {
|
|
34
|
+
if (dragging.value) {
|
|
35
|
+
dragging.value = false
|
|
36
|
+
emit(origin)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
watch(
|
|
40
|
+
() => options().disabled,
|
|
41
|
+
(disabled) => {
|
|
42
|
+
if (disabled) cancel()
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
onScopeDispose(() => {
|
|
46
|
+
dragging.value = false
|
|
47
|
+
})
|
|
48
|
+
return { canonical, dragging, update, begin, end, cancel }
|
|
49
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
inject,
|
|
4
|
+
type InjectionKey,
|
|
5
|
+
type PropType,
|
|
6
|
+
type SlotsType,
|
|
7
|
+
} from '@vue/runtime-core'
|
|
8
|
+
|
|
9
|
+
export type MavisPlatform = 'web' | 'ios' | 'android'
|
|
10
|
+
export type MavisPlatformTarget = MavisPlatform | 'native'
|
|
11
|
+
export type MavisPlatformContext = Readonly<{
|
|
12
|
+
platform: MavisPlatform
|
|
13
|
+
isWeb: boolean
|
|
14
|
+
isNative: boolean
|
|
15
|
+
isIOS: boolean
|
|
16
|
+
isAndroid: boolean
|
|
17
|
+
}>
|
|
18
|
+
|
|
19
|
+
/** @internal Supplied by the renderer, including services-only installation. */
|
|
20
|
+
export const platformKey: InjectionKey<MavisPlatformContext> = Symbol('mavis-platform')
|
|
21
|
+
|
|
22
|
+
/** @internal No browser globals, viewport detection or mutable process-wide state. */
|
|
23
|
+
export function createPlatformContext(platform: MavisPlatform): MavisPlatformContext {
|
|
24
|
+
if (!['web', 'ios', 'android'].includes(platform)) throw new RangeError('Unknown Mavis platform.')
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
platform,
|
|
27
|
+
isWeb: platform === 'web',
|
|
28
|
+
isNative: platform !== 'web',
|
|
29
|
+
isIOS: platform === 'ios',
|
|
30
|
+
isAndroid: platform === 'android',
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function useMavisPlatform(): MavisPlatformContext {
|
|
35
|
+
const platform = inject(platformKey, undefined)
|
|
36
|
+
if (!platform)
|
|
37
|
+
throw new Error(
|
|
38
|
+
'Install createMavis() or createMavisServices() in this app before using Mavis platform APIs.',
|
|
39
|
+
)
|
|
40
|
+
return platform
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const platformProps = {
|
|
44
|
+
only: {
|
|
45
|
+
type: [String, Array] as PropType<MavisPlatformTarget | readonly MavisPlatformTarget[]>,
|
|
46
|
+
required: true as const,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Only the selected slot is evaluated; excluded children never run setup or mount. */
|
|
51
|
+
export const MPlatform = defineComponent({
|
|
52
|
+
name: 'MPlatform',
|
|
53
|
+
inheritAttrs: false,
|
|
54
|
+
props: platformProps,
|
|
55
|
+
slots: Object as SlotsType<{ default: () => unknown; fallback: () => unknown }>,
|
|
56
|
+
setup(props, { slots }) {
|
|
57
|
+
const platform = useMavisPlatform()
|
|
58
|
+
return () => {
|
|
59
|
+
const targets = Array.isArray(props.only) ? props.only : [props.only]
|
|
60
|
+
if (
|
|
61
|
+
!targets.length ||
|
|
62
|
+
targets.some((target) => !['web', 'native', 'ios', 'android'].includes(target))
|
|
63
|
+
)
|
|
64
|
+
throw new RangeError(
|
|
65
|
+
'MPlatform.only requires web, native, ios, android, or a non-empty array of these targets.',
|
|
66
|
+
)
|
|
67
|
+
const matches = targets.some(
|
|
68
|
+
(target) => target === platform.platform || (target === 'native' && platform.isNative),
|
|
69
|
+
)
|
|
70
|
+
return matches ? slots.default?.() : slots.fallback?.()
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
})
|
package/src/vue/props.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SheetReturnFocus } from '../sheet.js'
|
|
1
2
|
import {
|
|
2
3
|
viewContract,
|
|
3
4
|
flexContract,
|
|
@@ -170,6 +171,14 @@ export const skeletonProps = {
|
|
|
170
171
|
}
|
|
171
172
|
export const rowProps = vueProps(rowContract)
|
|
172
173
|
export const columnProps = vueProps(columnContract)
|
|
174
|
+
const { motionRegion: _columnMotionRegion, ...columnLayoutProps } = columnProps
|
|
175
|
+
export const gridProps = {
|
|
176
|
+
...boxProps,
|
|
177
|
+
motionRegion: columnProps.motionRegion,
|
|
178
|
+
columns: { type: Number, default: undefined },
|
|
179
|
+
minColumnWidth: { type: Number, default: undefined },
|
|
180
|
+
gap: spacingProp,
|
|
181
|
+
}
|
|
173
182
|
export const stackProps = {
|
|
174
183
|
...columnProps,
|
|
175
184
|
direction: choice(['row', 'column'] as const, 'column'),
|
|
@@ -343,8 +352,13 @@ export const screenProps = {
|
|
|
343
352
|
/** Puts the software keyboard away on a tap outside the editor and, with `scroll`, on a drag towards it. */
|
|
344
353
|
dismissKeyboard: { type: Boolean, default: true },
|
|
345
354
|
}
|
|
346
|
-
export const revealProps = { ...
|
|
355
|
+
export const revealProps = { ...columnLayoutProps, show: Boolean }
|
|
347
356
|
export const sheetProps = {
|
|
357
|
+
/** Web only. Omit to restore the captured opener; return null to leave focus to the application. */
|
|
358
|
+
returnFocus: {
|
|
359
|
+
type: [String, Boolean, Function] as PropType<SheetReturnFocus>,
|
|
360
|
+
default: undefined,
|
|
361
|
+
},
|
|
348
362
|
id: viewProps.id,
|
|
349
363
|
accessibilityLabel: viewProps.accessibilityLabel,
|
|
350
364
|
open: Boolean,
|
|
@@ -371,6 +385,7 @@ export const componentProps = {
|
|
|
371
385
|
MRow: rowProps,
|
|
372
386
|
MColumn: columnProps,
|
|
373
387
|
MStack: stackProps,
|
|
388
|
+
MGrid: gridProps,
|
|
374
389
|
MLink: linkProps,
|
|
375
390
|
MBox: motionBoxProps,
|
|
376
391
|
MCard: cardProps,
|