@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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { defineComponent, h, inject, mergeProps, type Component } from '@vue/runtime-core'
|
|
2
|
+
import { choiceKey } from '../choice.js'
|
|
3
|
+
import { validateNavigation } from '../collections.js'
|
|
4
|
+
import { appBarProps, tabBarProps } from './navigation-props.js'
|
|
5
|
+
import { navigationKey } from './navigation.js'
|
|
6
|
+
import { useMavisTheme } from './theme.js'
|
|
7
|
+
|
|
8
|
+
export function createNavigationControls(
|
|
9
|
+
ui: { Row: Component; Column: Component; Text: Component; Button: Component; Badge: Component },
|
|
10
|
+
platform: 'web' | 'native',
|
|
11
|
+
) {
|
|
12
|
+
const MAppBar = defineComponent({
|
|
13
|
+
name: 'MAppBar',
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
props: appBarProps,
|
|
16
|
+
emits: { back: () => true, error: (_error: unknown) => true },
|
|
17
|
+
setup(props, { attrs, slots, emit }) {
|
|
18
|
+
const navigation = inject(navigationKey, undefined)
|
|
19
|
+
const { theme } = useMavisTheme()
|
|
20
|
+
async function back() {
|
|
21
|
+
try {
|
|
22
|
+
const navigate = props.navigateBack ?? navigation?.back
|
|
23
|
+
if (!navigate) throw new Error('MAppBar back requires navigation or navigateBack.')
|
|
24
|
+
await navigate()
|
|
25
|
+
emit('back')
|
|
26
|
+
} catch (error) {
|
|
27
|
+
emit('error', error)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return () => {
|
|
31
|
+
if (!props.title.trim()) throw new TypeError('App bars require a title.')
|
|
32
|
+
return h(
|
|
33
|
+
ui.Row,
|
|
34
|
+
mergeProps(
|
|
35
|
+
{
|
|
36
|
+
id: props.id,
|
|
37
|
+
padding: 'md',
|
|
38
|
+
gap: 'md',
|
|
39
|
+
shrink: 0,
|
|
40
|
+
backgroundColor: theme.value.colors.surface,
|
|
41
|
+
},
|
|
42
|
+
attrs,
|
|
43
|
+
platform === 'web'
|
|
44
|
+
? { role: 'group', 'aria-label': props.title, class: 'm-app-bar' }
|
|
45
|
+
: {},
|
|
46
|
+
),
|
|
47
|
+
() => [
|
|
48
|
+
props.back
|
|
49
|
+
? h(ui.Button, {
|
|
50
|
+
icon: 'arrow-left',
|
|
51
|
+
accessibilityLabel: props.backLabel,
|
|
52
|
+
variant: 'ghost',
|
|
53
|
+
onClick: back,
|
|
54
|
+
})
|
|
55
|
+
: null,
|
|
56
|
+
slots.leading?.(),
|
|
57
|
+
h(ui.Column, { grow: 1, shrink: 1, gap: 'xs' }, () => [
|
|
58
|
+
h(ui.Text, { text: props.title, variant: 'heading', as: 'h1' }),
|
|
59
|
+
props.subtitle
|
|
60
|
+
? h(ui.Text, { text: props.subtitle, variant: 'caption', tone: 'muted' })
|
|
61
|
+
: null,
|
|
62
|
+
]),
|
|
63
|
+
slots.actions?.(),
|
|
64
|
+
],
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
const MTabBar = defineComponent({
|
|
70
|
+
name: 'MTabBar',
|
|
71
|
+
inheritAttrs: false,
|
|
72
|
+
props: tabBarProps,
|
|
73
|
+
emits: { error: (_error: unknown) => true },
|
|
74
|
+
setup(props, { attrs, emit }) {
|
|
75
|
+
const { theme } = useMavisTheme()
|
|
76
|
+
return () => {
|
|
77
|
+
validateNavigation(props.items)
|
|
78
|
+
if (!props.label.trim()) throw new TypeError('Tab bars require a navigation label.')
|
|
79
|
+
return h(
|
|
80
|
+
ui.Row,
|
|
81
|
+
mergeProps(
|
|
82
|
+
{
|
|
83
|
+
id: props.id,
|
|
84
|
+
gap: 'xs',
|
|
85
|
+
padding: 'sm',
|
|
86
|
+
shrink: 0,
|
|
87
|
+
backgroundColor: theme.value.colors.surface,
|
|
88
|
+
},
|
|
89
|
+
attrs,
|
|
90
|
+
platform === 'web'
|
|
91
|
+
? {
|
|
92
|
+
role: 'navigation',
|
|
93
|
+
'aria-label': props.label,
|
|
94
|
+
class: 'm-tab-bar',
|
|
95
|
+
style: props.safeArea
|
|
96
|
+
? {
|
|
97
|
+
paddingBottom:
|
|
98
|
+
'max(var(--m-tab-padding, 8px), env(safe-area-inset-bottom))',
|
|
99
|
+
}
|
|
100
|
+
: undefined,
|
|
101
|
+
}
|
|
102
|
+
: { accessibilityLabel: props.label },
|
|
103
|
+
),
|
|
104
|
+
() =>
|
|
105
|
+
props.items.map((item) => {
|
|
106
|
+
const current = item.value === props.modelValue
|
|
107
|
+
return h(
|
|
108
|
+
ui.Button,
|
|
109
|
+
{
|
|
110
|
+
key: choiceKey(item.value),
|
|
111
|
+
grow: 1,
|
|
112
|
+
shrink: 1,
|
|
113
|
+
text: item.label,
|
|
114
|
+
icon: item.icon,
|
|
115
|
+
href: item.href,
|
|
116
|
+
navigate: item.navigate,
|
|
117
|
+
disabled: props.disabled || item.disabled,
|
|
118
|
+
variant: current ? 'primary' : 'ghost',
|
|
119
|
+
accessibilityLabel: `${item.label}${item.badge !== undefined ? ` ${item.badge}` : ''}${current && platform === 'native' ? `. ${props.currentLabel}` : ''}`,
|
|
120
|
+
...(platform === 'web' ? { 'aria-current': current ? 'page' : undefined } : {}),
|
|
121
|
+
onError: (error: unknown) => emit('error', error),
|
|
122
|
+
},
|
|
123
|
+
item.badge === undefined
|
|
124
|
+
? undefined
|
|
125
|
+
: {
|
|
126
|
+
trailing: () => [
|
|
127
|
+
platform === 'web' ? ' ' : null,
|
|
128
|
+
h(ui.Badge, { text: String(item.badge), accessibilityHidden: true }),
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
)
|
|
132
|
+
}),
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
return { MAppBar, MTabBar }
|
|
138
|
+
}
|
|
@@ -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,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
|
+
})
|