@getcortexlabs/mavis-core 0.1.0-alpha.9 → 0.1.0-rc.12
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 +48 -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/creative-controls.d.ts +47 -0
- package/dist/creative-controls.d.ts.map +1 -0
- package/dist/creative-controls.js +112 -0
- package/dist/creative-controls.js.map +1 -0
- package/dist/dashboard.d.ts +72 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +115 -0
- package/dist/dashboard.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/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.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 +2 -0
- package/dist/link.d.ts.map +1 -1
- 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/screen-components.d.ts +45 -0
- package/dist/screen-components.d.ts.map +1 -0
- package/dist/screen-components.js +23 -0
- package/dist/screen-components.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/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/animated-text.d.ts +101 -0
- package/dist/vue/animated-text.d.ts.map +1 -0
- package/dist/vue/animated-text.js +56 -0
- package/dist/vue/animated-text.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 +1708 -21
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +50 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +159 -0
- package/dist/vue/composer.d.ts.map +1 -0
- package/dist/vue/composer.js +142 -0
- package/dist/vue/composer.js.map +1 -0
- package/dist/vue/configurator.d.ts +2 -2
- 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/creative-controls.d.ts +328 -0
- package/dist/vue/creative-controls.d.ts.map +1 -0
- package/dist/vue/creative-controls.js +396 -0
- package/dist/vue/creative-controls.js.map +1 -0
- package/dist/vue/creative-props.d.ts +260 -0
- package/dist/vue/creative-props.d.ts.map +1 -0
- package/dist/vue/creative-props.js +92 -0
- package/dist/vue/creative-props.js.map +1 -0
- package/dist/vue/dashboard-charts.d.ts +240 -0
- package/dist/vue/dashboard-charts.d.ts.map +1 -0
- package/dist/vue/dashboard-charts.js +263 -0
- package/dist/vue/dashboard-charts.js.map +1 -0
- package/dist/vue/dashboard-effects.d.ts +211 -0
- package/dist/vue/dashboard-effects.d.ts.map +1 -0
- package/dist/vue/dashboard-effects.js +235 -0
- package/dist/vue/dashboard-effects.js.map +1 -0
- package/dist/vue/dashboard-props.d.ts +244 -0
- package/dist/vue/dashboard-props.d.ts.map +1 -0
- package/dist/vue/dashboard-props.js +94 -0
- package/dist/vue/dashboard-props.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 +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 +8 -8
- package/dist/vue/date-props.d.ts +6 -0
- package/dist/vue/date-props.d.ts.map +1 -1
- package/dist/vue/date-props.js +3 -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 +237 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +41 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +37 -0
- 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/kanban.d.ts +150 -0
- package/dist/vue/kanban.d.ts.map +1 -0
- package/dist/vue/kanban.js +267 -0
- package/dist/vue/kanban.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/marquee.d.ts +96 -0
- package/dist/vue/marquee.d.ts.map +1 -0
- package/dist/vue/marquee.js +186 -0
- package/dist/vue/marquee.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/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/pin-cell.d.ts +14 -0
- package/dist/vue/pin-cell.d.ts.map +1 -0
- package/dist/vue/pin-cell.js +19 -0
- package/dist/vue/pin-cell.js.map +1 -0
- package/dist/vue/pin-input.d.ts +14 -0
- package/dist/vue/pin-input.d.ts.map +1 -0
- package/dist/vue/pin-input.js +23 -0
- package/dist/vue/pin-input.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 +82 -42
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +3 -1
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/screen-component-props.d.ts +236 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -0
- package/dist/vue/screen-component-props.js +90 -0
- package/dist/vue/screen-component-props.js.map +1 -0
- package/dist/vue/scroll-frame.d.ts +223 -0
- package/dist/vue/scroll-frame.d.ts.map +1 -0
- package/dist/vue/scroll-frame.js +346 -0
- package/dist/vue/scroll-frame.js.map +1 -0
- 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/speed-dial.d.ts +73 -0
- package/dist/vue/speed-dial.d.ts.map +1 -0
- package/dist/vue/speed-dial.js +78 -0
- package/dist/vue/speed-dial.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/swipe-deck.d.ts +120 -0
- package/dist/vue/swipe-deck.d.ts.map +1 -0
- package/dist/vue/swipe-deck.js +229 -0
- package/dist/vue/swipe-deck.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/tour.d.ts +120 -0
- package/dist/vue/tour.d.ts.map +1 -0
- package/dist/vue/tour.js +165 -0
- package/dist/vue/tour.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 +50 -4
- package/src/chart.ts +151 -0
- package/src/collections.ts +87 -0
- package/src/contracts.ts +2 -0
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/discovery.ts +139 -0
- package/src/experimental-regions.ts +29 -0
- package/src/experimental.ts +40 -0
- package/src/index.ts +23 -1
- package/src/interactive.ts +91 -0
- package/src/link.ts +2 -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/screen-components.ts +59 -0
- package/src/section-scroll.ts +46 -0
- package/src/time.ts +83 -0
- package/src/vue/animated-text.ts +72 -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 +104 -0
- package/src/vue/composer.ts +192 -0
- package/src/vue/configurator.ts +3 -1
- package/src/vue/creative-controls.ts +524 -0
- package/src/vue/creative-props.ts +94 -0
- package/src/vue/dashboard-charts.ts +346 -0
- package/src/vue/dashboard-effects.ts +304 -0
- package/src/vue/dashboard-props.ts +95 -0
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +30 -1
- package/src/vue/date-props.ts +3 -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 +237 -0
- package/src/vue/index.ts +64 -0
- package/src/vue/interactive-components.ts +29 -0
- package/src/vue/interactive-props.ts +90 -0
- package/src/vue/kanban.ts +360 -0
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/marquee.ts +248 -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/number-flow.ts +83 -0
- package/src/vue/partition.ts +49 -0
- package/src/vue/pin-cell.ts +26 -0
- package/src/vue/pin-input.ts +31 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +3 -1
- package/src/vue/screen-component-props.ts +92 -0
- package/src/vue/scroll-frame.ts +429 -0
- package/src/vue/sortable-list.ts +308 -0
- package/src/vue/speed-dial.ts +108 -0
- package/src/vue/swipe-actions.ts +226 -0
- package/src/vue/swipe-deck.ts +277 -0
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/tour.ts +239 -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
package/src/vue/menu.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineComponent, h, type Component } from '@vue/runtime-core'
|
|
2
|
+
import { choiceKey, type ChoiceValue } from '../choice.js'
|
|
3
|
+
import { validateMenu, type MenuAction } from '../collections.js'
|
|
4
|
+
import type { PopoverCloseReason } from '../popover.js'
|
|
5
|
+
import { menuProps } from './navigation-props.js'
|
|
6
|
+
import { MThemeProvider } from './theme-provider.js'
|
|
7
|
+
import { useMavisTheme } from './theme.js'
|
|
8
|
+
|
|
9
|
+
export function createMenu(
|
|
10
|
+
ui: {
|
|
11
|
+
Popover: Component
|
|
12
|
+
Column: Component
|
|
13
|
+
Text: Component
|
|
14
|
+
Button: Component
|
|
15
|
+
Separator: Component
|
|
16
|
+
},
|
|
17
|
+
keyboard?: (event: unknown) => void,
|
|
18
|
+
) {
|
|
19
|
+
return defineComponent({
|
|
20
|
+
name: 'MMenu',
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
props: menuProps,
|
|
23
|
+
emits: {
|
|
24
|
+
'update:open': (_open: boolean) => true,
|
|
25
|
+
select: (_value: ChoiceValue, _item: MenuAction) => true,
|
|
26
|
+
close: (_reason: PopoverCloseReason) => true,
|
|
27
|
+
},
|
|
28
|
+
setup(props, { attrs, emit }) {
|
|
29
|
+
const { theme } = useMavisTheme()
|
|
30
|
+
return () => {
|
|
31
|
+
validateMenu(props.items)
|
|
32
|
+
const { items: _items, ...presentation } = props
|
|
33
|
+
return h(
|
|
34
|
+
ui.Popover,
|
|
35
|
+
{
|
|
36
|
+
...attrs,
|
|
37
|
+
...presentation,
|
|
38
|
+
role: 'menu',
|
|
39
|
+
padding: 'xs',
|
|
40
|
+
'onUpdate:open': (open: boolean) => emit('update:open', open),
|
|
41
|
+
onClose: (reason: PopoverCloseReason) => emit('close', reason),
|
|
42
|
+
},
|
|
43
|
+
() =>
|
|
44
|
+
h(ui.Column, { gap: 'xs', ...(keyboard ? { onKeydown: keyboard } : {}) }, () =>
|
|
45
|
+
props.items.map((item) => {
|
|
46
|
+
if ('type' in item)
|
|
47
|
+
return item.type === 'separator'
|
|
48
|
+
? h(ui.Separator, { key: `decoration:${item.key}` })
|
|
49
|
+
: h(ui.Text, {
|
|
50
|
+
key: `decoration:${item.key}`,
|
|
51
|
+
text: item.label,
|
|
52
|
+
accessibilityLabel: item.label,
|
|
53
|
+
variant: 'overline',
|
|
54
|
+
tone: 'muted',
|
|
55
|
+
})
|
|
56
|
+
const action = () =>
|
|
57
|
+
h(ui.Button, {
|
|
58
|
+
key: choiceKey(item.value),
|
|
59
|
+
text: item.label,
|
|
60
|
+
accessibilityLabel: item.label,
|
|
61
|
+
icon: item.icon,
|
|
62
|
+
variant: 'ghost',
|
|
63
|
+
disabled: item.disabled,
|
|
64
|
+
...(keyboard
|
|
65
|
+
? {
|
|
66
|
+
role: 'menuitem',
|
|
67
|
+
tabindex: -1,
|
|
68
|
+
style: {
|
|
69
|
+
justifyContent: 'flex-start',
|
|
70
|
+
color: item.destructive ? theme.value.colors.danger : undefined,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
onClick: () => {
|
|
75
|
+
if (!props.open || props.disabled || item.disabled) return
|
|
76
|
+
emit('select', item.value, item)
|
|
77
|
+
emit('update:open', false)
|
|
78
|
+
emit('close', 'select')
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
return h(
|
|
82
|
+
MThemeProvider,
|
|
83
|
+
{
|
|
84
|
+
key: choiceKey(item.value),
|
|
85
|
+
theme: item.destructive
|
|
86
|
+
? {
|
|
87
|
+
...theme.value,
|
|
88
|
+
colors: { ...theme.value.colors, text: theme.value.colors.danger },
|
|
89
|
+
}
|
|
90
|
+
: theme.value,
|
|
91
|
+
},
|
|
92
|
+
action,
|
|
93
|
+
)
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
}
|
|
@@ -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,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,26 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, type Component } from '@vue/runtime-core'
|
|
2
|
+
import { useComponentState } from './component-motion.js'
|
|
3
|
+
|
|
4
|
+
/** Decorative cells animate independently; the real editor never moves. */
|
|
5
|
+
export function createPinCell(Text: Component) {
|
|
6
|
+
return defineComponent({
|
|
7
|
+
name: 'MPinCell',
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: { active: Boolean, digit: String },
|
|
10
|
+
setup(props, { attrs }) {
|
|
11
|
+
const surface = useComponentState(
|
|
12
|
+
() => ({ scale: props.active ? 1.04 : 1, opacity: props.digit ? 1 : 0.8 }),
|
|
13
|
+
'feedback',
|
|
14
|
+
)
|
|
15
|
+
return () =>
|
|
16
|
+
h(
|
|
17
|
+
Text,
|
|
18
|
+
mergeProps(attrs, {
|
|
19
|
+
motionSurface: surface,
|
|
20
|
+
text: props.digit ?? '',
|
|
21
|
+
accessibilityHidden: true,
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { computed, ref, watch } from '@vue/runtime-core'
|
|
2
|
+
import { normalizePin, pinLength } from '../screen-components.js'
|
|
3
|
+
import { useComponentContent } from './component-motion.js'
|
|
4
|
+
|
|
5
|
+
export function usePinInput(
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: string
|
|
8
|
+
length: number
|
|
9
|
+
disabled: boolean
|
|
10
|
+
readonly: boolean
|
|
11
|
+
error?: string
|
|
12
|
+
},
|
|
13
|
+
emit: (event: 'update:modelValue' | 'complete' | 'focus' | 'blur', value?: string) => void,
|
|
14
|
+
) {
|
|
15
|
+
const focused = ref(false),
|
|
16
|
+
position = ref(0)
|
|
17
|
+
const value = computed(() => normalizePin(props.modelValue, props.length))
|
|
18
|
+
const feedback = useComponentContent(() => props.error, false)
|
|
19
|
+
const change = (raw: string) => {
|
|
20
|
+
if (props.disabled || props.readonly) return value.value
|
|
21
|
+
const next = normalizePin(raw, props.length)
|
|
22
|
+
if (next !== value.value) {
|
|
23
|
+
emit('update:modelValue', next)
|
|
24
|
+
if (next.length === props.length) emit('complete', next)
|
|
25
|
+
}
|
|
26
|
+
position.value = Math.min(next.length, props.length - 1)
|
|
27
|
+
return next
|
|
28
|
+
}
|
|
29
|
+
watch(() => props.length, pinLength, { immediate: true })
|
|
30
|
+
return { value, feedback, focused, position, change }
|
|
31
|
+
}
|
|
@@ -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
|
@@ -171,8 +171,10 @@ export const skeletonProps = {
|
|
|
171
171
|
}
|
|
172
172
|
export const rowProps = vueProps(rowContract)
|
|
173
173
|
export const columnProps = vueProps(columnContract)
|
|
174
|
+
const { motionRegion: _columnMotionRegion, ...columnLayoutProps } = columnProps
|
|
174
175
|
export const gridProps = {
|
|
175
176
|
...boxProps,
|
|
177
|
+
motionRegion: columnProps.motionRegion,
|
|
176
178
|
columns: { type: Number, default: undefined },
|
|
177
179
|
minColumnWidth: { type: Number, default: undefined },
|
|
178
180
|
gap: spacingProp,
|
|
@@ -350,7 +352,7 @@ export const screenProps = {
|
|
|
350
352
|
/** Puts the software keyboard away on a tap outside the editor and, with `scroll`, on a drag towards it. */
|
|
351
353
|
dismissKeyboard: { type: Boolean, default: true },
|
|
352
354
|
}
|
|
353
|
-
export const revealProps = { ...
|
|
355
|
+
export const revealProps = { ...columnLayoutProps, show: Boolean }
|
|
354
356
|
export const sheetProps = {
|
|
355
357
|
/** Web only. Omit to restore the captured opener; return null to leave focus to the application. */
|
|
356
358
|
returnFocus: {
|