@getcortexlabs/mavis-core 0.1.0-alpha.3 → 0.1.0-alpha.5
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/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 +119 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +142 -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.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/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 +1201 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +242 -0
- package/dist/contracts.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 +20 -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-regions.d.ts +142 -0
- package/dist/experimental-regions.d.ts.map +1 -0
- package/dist/experimental-regions.js +315 -0
- package/dist/experimental-regions.js.map +1 -0
- package/dist/experimental.d.ts +134 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +502 -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/index.d.ts +38 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +10 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +12 -0
- package/dist/input.js.map +1 -1
- 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 +33 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +21 -0
- package/dist/motion.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/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/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 +8 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +4 -3
- package/dist/sheet.js.map +1 -1
- 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 +84 -11
- package/dist/theme/themes.js.map +1 -1
- package/dist/theme/types.d.ts +52 -1
- 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/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 +1989 -0
- package/dist/vue/component-props.d.ts.map +1 -0
- package/dist/vue/component-props.js +18 -0
- package/dist/vue/component-props.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 +18 -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 +927 -0
- package/dist/vue/date-picker.d.ts.map +1 -0
- package/dist/vue/date-picker.js +319 -0
- package/dist/vue/date-picker.js.map +1 -0
- package/dist/vue/date-props.d.ts +254 -0
- package/dist/vue/date-props.d.ts.map +1 -0
- package/dist/vue/date-props.js +74 -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 +129 -3
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +28 -2
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +24 -1
- 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/props.d.ts +2654 -637
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +228 -86
- package/dist/vue/props.js.map +1 -1
- 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 +962 -12
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +17 -7
- package/dist/vue/theme.js.map +1 -1
- 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/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/avatar.ts +11 -0
- package/src/badge.ts +11 -0
- package/src/capabilities.ts +145 -0
- package/src/chip.ts +20 -0
- package/src/choice.ts +41 -0
- package/src/combobox.ts +198 -0
- package/src/contracts.ts +295 -0
- package/src/date.ts +280 -0
- package/src/dialog.ts +20 -0
- package/src/empty-state.ts +4 -0
- package/src/experimental-regions.ts +463 -0
- package/src/experimental.ts +643 -0
- package/src/files.ts +408 -0
- package/src/form.ts +190 -0
- package/src/index.ts +64 -3
- package/src/input.ts +22 -0
- package/src/list-item.ts +5 -0
- package/src/motion.ts +22 -0
- package/src/navigation.ts +61 -0
- package/src/progress.ts +22 -0
- package/src/segmented.ts +39 -0
- package/src/sheet.ts +6 -3
- package/src/tabs.ts +35 -0
- package/src/theme/themes.ts +88 -11
- package/src/theme/types.ts +42 -1
- package/src/theme/typography.ts +84 -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 +24 -0
- package/src/vue/contracts.ts +33 -0
- package/src/vue/date-calendar.ts +76 -0
- package/src/vue/date-picker.ts +387 -0
- package/src/vue/date-props.ts +81 -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 +120 -3
- package/src/vue/index.ts +46 -2
- package/src/vue/inline-content.ts +71 -0
- package/src/vue/props.ts +258 -95
- package/src/vue/theme-provider.ts +74 -0
- package/src/vue/theme.ts +17 -6
- package/src/vue/toast.ts +99 -0
- package/src/vue/workflow-props.ts +41 -0
- package/src/vue/workflows.ts +257 -0
package/src/vue/props.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
viewContract,
|
|
3
|
+
flexContract,
|
|
4
|
+
boxContract,
|
|
5
|
+
motionBoxContract,
|
|
6
|
+
rowContract,
|
|
7
|
+
columnContract,
|
|
8
|
+
buttonContract,
|
|
9
|
+
textContract,
|
|
10
|
+
inputContract,
|
|
11
|
+
spacingProperty,
|
|
12
|
+
radiusProperty,
|
|
13
|
+
dimensionProperty,
|
|
14
|
+
weightProperty,
|
|
15
|
+
paletteTones,
|
|
16
|
+
} from '../contracts.js'
|
|
17
|
+
import { vueProps, vueProperty } from './contracts.js'
|
|
18
|
+
export type { Align, Justify } from '../contracts.js'
|
|
19
|
+
import type { MotionSurface, MotionScrollSource } from '../experimental.js'
|
|
20
|
+
import type { AccordionItem } from '../accordion.js'
|
|
21
|
+
import type { SegmentedOption } from '../segmented.js'
|
|
22
|
+
import type { TabOption } from '../tabs.js'
|
|
23
|
+
import type { SheetName } from '../sheet.js'
|
|
24
|
+
import { dialogCloseReasons, type DialogCloseReason } from '../dialog.js'
|
|
1
25
|
import type { ExtractPropTypes, ExtractPublicPropTypes, PropType } from '@vue/runtime-core'
|
|
2
|
-
import type { Palette,
|
|
3
|
-
import type
|
|
26
|
+
import type { Palette, Elevation } from '../theme/types.js'
|
|
27
|
+
import { isChoiceValue, type ChoiceValue, type ChoiceOption } from '../choice.js'
|
|
28
|
+
import type { ToastController } from '../toast.js'
|
|
4
29
|
import { iconSizes, type IconName, type IconSize } from '../icon.js'
|
|
5
30
|
import { sheetCloseReasons, type SheetCloseReason } from '../sheet.js'
|
|
6
31
|
|
|
@@ -12,15 +37,10 @@ function choice<T extends string>(values: readonly T[], defaultValue: T) {
|
|
|
12
37
|
}
|
|
13
38
|
}
|
|
14
39
|
|
|
15
|
-
export const spacingProp =
|
|
16
|
-
const radiusProp =
|
|
17
|
-
const dimensionProp =
|
|
18
|
-
|
|
19
|
-
export const viewProps = {
|
|
20
|
-
id: { type: String, default: undefined },
|
|
21
|
-
accessibilityLabel: { type: String, default: undefined },
|
|
22
|
-
accessibilityHidden: { type: Boolean, default: undefined },
|
|
23
|
-
}
|
|
40
|
+
export const spacingProp = vueProperty(spacingProperty)
|
|
41
|
+
const radiusProp = vueProperty(radiusProperty)
|
|
42
|
+
const dimensionProp = vueProperty(dimensionProperty)
|
|
43
|
+
export const viewProps = vueProps(viewContract)
|
|
24
44
|
|
|
25
45
|
export function viewAttrs(props: ExtractPropTypes<typeof viewProps>) {
|
|
26
46
|
return {
|
|
@@ -30,84 +50,127 @@ export function viewAttrs(props: ExtractPropTypes<typeof viewProps>) {
|
|
|
30
50
|
}
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
export const flexProps =
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
export const flexProps = vueProps(flexContract)
|
|
54
|
+
export const boxProps = vueProps(boxContract)
|
|
55
|
+
export const motionBoxProps = vueProps(motionBoxContract)
|
|
56
|
+
export const listItemProps = {
|
|
57
|
+
...viewProps,
|
|
58
|
+
...flexProps,
|
|
59
|
+
width: dimensionProp,
|
|
60
|
+
title: { type: String, required: true as const },
|
|
61
|
+
description: { type: String, default: '' },
|
|
62
|
+
interactive: Boolean,
|
|
63
|
+
disabled: Boolean,
|
|
36
64
|
}
|
|
37
|
-
export const
|
|
65
|
+
export const separatorProps = {
|
|
66
|
+
id: viewProps.id,
|
|
67
|
+
orientation: choice(['horizontal', 'vertical'] as const, 'horizontal'),
|
|
68
|
+
length: { type: Number, default: undefined },
|
|
69
|
+
spacing: { ...spacingProp, default: 'none' },
|
|
70
|
+
inset: { ...spacingProp, default: 'none' },
|
|
71
|
+
}
|
|
72
|
+
export const avatarProps = {
|
|
73
|
+
...viewProps,
|
|
74
|
+
src: { type: String, default: '' },
|
|
75
|
+
name: { type: String, default: '' },
|
|
76
|
+
size: choice(['sm', 'md', 'lg', 'xl'] as const, 'md'),
|
|
77
|
+
shape: choice(['circle', 'square'] as const, 'circle'),
|
|
78
|
+
}
|
|
79
|
+
export const badgeProps = {
|
|
38
80
|
...viewProps,
|
|
81
|
+
text: { type: [String, Number], required: true as const },
|
|
82
|
+
size: choice(['sm', 'md'] as const, 'md'),
|
|
83
|
+
tone: choice(
|
|
84
|
+
['neutral', 'primary', 'accent', 'success', 'warning', 'danger'] as const,
|
|
85
|
+
'neutral',
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
export const chipProps = {
|
|
89
|
+
id: viewProps.id,
|
|
90
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
39
91
|
...flexProps,
|
|
40
|
-
padding: spacingProp,
|
|
41
|
-
paddingX: spacingProp,
|
|
42
|
-
paddingY: spacingProp,
|
|
43
|
-
radius: radiusProp,
|
|
44
92
|
width: dimensionProp,
|
|
45
|
-
|
|
46
|
-
|
|
93
|
+
label: { type: String, required: true as const },
|
|
94
|
+
icon: { type: String as PropType<IconName>, default: undefined },
|
|
95
|
+
tone: choice(['primary', 'accent'] as const, 'primary'),
|
|
96
|
+
selectable: Boolean,
|
|
97
|
+
modelValue: Boolean,
|
|
98
|
+
removable: Boolean,
|
|
99
|
+
removeLabel: { type: String, default: undefined },
|
|
100
|
+
disabled: Boolean,
|
|
47
101
|
}
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
102
|
+
export const chipEmits = {
|
|
103
|
+
'update:modelValue': (value: boolean) => typeof value === 'boolean',
|
|
104
|
+
remove: () => true,
|
|
105
|
+
}
|
|
106
|
+
export const emptyStateProps = {
|
|
107
|
+
id: viewProps.id,
|
|
108
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
109
|
+
...flexProps,
|
|
110
|
+
width: dimensionProp,
|
|
111
|
+
title: { type: String, required: true as const },
|
|
112
|
+
description: { type: String, default: '' },
|
|
113
|
+
icon: { type: String as PropType<IconName>, default: 'inbox' },
|
|
114
|
+
tone: choice(['primary', 'accent'] as const, 'primary'),
|
|
115
|
+
compact: Boolean,
|
|
116
|
+
titleAs: choice(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const, 'h2'),
|
|
62
117
|
}
|
|
63
|
-
export const
|
|
64
|
-
|
|
118
|
+
export const progressProps = {
|
|
119
|
+
id: viewProps.id,
|
|
120
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
121
|
+
...flexProps,
|
|
122
|
+
width: dimensionProp,
|
|
123
|
+
value: { type: Number, default: 0 },
|
|
124
|
+
max: { type: Number, default: 100 },
|
|
125
|
+
indeterminate: Boolean,
|
|
126
|
+
label: { type: String, required: true as const },
|
|
127
|
+
indeterminateLabel: { type: String, default: 'Loading' },
|
|
128
|
+
size: choice(['sm', 'md', 'lg'] as const, 'md'),
|
|
129
|
+
tone: choice(['primary', 'accent', 'success', 'warning', 'danger'] as const, 'primary'),
|
|
130
|
+
}
|
|
131
|
+
export const alertProps = {
|
|
132
|
+
id: viewProps.id,
|
|
133
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
134
|
+
...flexProps,
|
|
135
|
+
width: dimensionProp,
|
|
136
|
+
title: { type: String, required: true as const },
|
|
137
|
+
description: { type: String, default: '' },
|
|
138
|
+
tone: choice(['info', 'success', 'warning', 'error'] as const, 'info'),
|
|
139
|
+
dismissible: Boolean,
|
|
140
|
+
closeLabel: { type: String, default: 'Dismiss message' },
|
|
141
|
+
announce: Boolean,
|
|
142
|
+
}
|
|
143
|
+
export const alertEmits = { close: () => true }
|
|
144
|
+
export const skeletonProps = {
|
|
145
|
+
id: viewProps.id,
|
|
146
|
+
...flexProps,
|
|
147
|
+
width: dimensionProp,
|
|
148
|
+
height: { ...dimensionProp, default: 16 },
|
|
149
|
+
radius: { ...radiusProp, default: 'sm' },
|
|
150
|
+
animated: { type: Boolean, default: true },
|
|
151
|
+
}
|
|
152
|
+
export const rowProps = vueProps(rowContract)
|
|
153
|
+
export const columnProps = vueProps(columnContract)
|
|
65
154
|
export const cardProps = {
|
|
155
|
+
motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
|
|
66
156
|
...boxProps,
|
|
67
|
-
padding:
|
|
68
|
-
radius:
|
|
157
|
+
padding: spacingProp,
|
|
158
|
+
radius: radiusProp,
|
|
159
|
+
elevation: { type: String as PropType<Elevation>, default: undefined },
|
|
69
160
|
gap: spacingProp,
|
|
70
161
|
interactive: Boolean,
|
|
71
162
|
disabled: Boolean,
|
|
72
163
|
}
|
|
73
|
-
export const buttonProps =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
variant: choice(['primary', 'secondary', 'ghost'] as const, 'primary'),
|
|
78
|
-
size: choice(['sm', 'md', 'lg'] as const, 'md'),
|
|
79
|
-
disabled: Boolean,
|
|
80
|
-
loading: Boolean,
|
|
81
|
-
loadingText: { type: String, default: 'Loading…' },
|
|
82
|
-
icon: { type: String as PropType<IconName>, default: undefined },
|
|
83
|
-
trailingIcon: { type: String as PropType<IconName>, default: undefined },
|
|
84
|
-
}
|
|
85
|
-
const tones: readonly (keyof Palette)[] = [
|
|
86
|
-
'background',
|
|
87
|
-
'surface',
|
|
88
|
-
'elevated',
|
|
89
|
-
'text',
|
|
90
|
-
'muted',
|
|
91
|
-
'primary',
|
|
92
|
-
'onPrimary',
|
|
93
|
-
'primarySoft',
|
|
94
|
-
'accent',
|
|
95
|
-
'onAccent',
|
|
96
|
-
'accentSoft',
|
|
97
|
-
'border',
|
|
98
|
-
'success',
|
|
99
|
-
'danger',
|
|
100
|
-
]
|
|
101
|
-
export const textProps = {
|
|
102
|
-
...viewProps,
|
|
103
|
-
...flexProps,
|
|
164
|
+
export const buttonProps = vueProps(buttonContract)
|
|
165
|
+
const tones = paletteTones
|
|
166
|
+
export const weightProp = vueProperty(weightProperty)
|
|
167
|
+
export const spanProps = {
|
|
104
168
|
text: { type: String, default: undefined },
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
align: choice(['left', 'center', 'right'] as const, 'left'),
|
|
109
|
-
wrap: { type: Boolean, default: true },
|
|
169
|
+
weight: weightProp,
|
|
170
|
+
tone: { type: String as PropType<keyof Palette>, default: undefined },
|
|
171
|
+
emphasis: { type: String as PropType<'strong' | 'em'>, default: undefined },
|
|
110
172
|
}
|
|
173
|
+
export const textProps = vueProps(textContract)
|
|
111
174
|
export const sliderProps = {
|
|
112
175
|
id: viewProps.id,
|
|
113
176
|
accessibilityHidden: viewProps.accessibilityHidden,
|
|
@@ -118,33 +181,113 @@ export const sliderProps = {
|
|
|
118
181
|
disabled: Boolean,
|
|
119
182
|
label: { type: String, required: true as const },
|
|
120
183
|
}
|
|
121
|
-
|
|
184
|
+
const booleanControlProps = {
|
|
122
185
|
id: viewProps.id,
|
|
123
186
|
accessibilityHidden: viewProps.accessibilityHidden,
|
|
124
187
|
...flexProps,
|
|
125
188
|
width: dimensionProp,
|
|
126
|
-
modelValue:
|
|
189
|
+
modelValue: Boolean,
|
|
127
190
|
label: { type: String, required: true as const },
|
|
128
|
-
placeholder: { type: String, default: '' },
|
|
129
191
|
helperText: { type: String, default: '' },
|
|
130
|
-
error: { type: String, default: '' },
|
|
131
|
-
type: choice(['text', 'email', 'password', 'tel', 'url', 'search'] as const, 'text'),
|
|
132
192
|
disabled: Boolean,
|
|
133
|
-
readonly: Boolean,
|
|
134
|
-
multiline: Boolean,
|
|
135
|
-
rows: { type: Number, default: 3 },
|
|
136
|
-
maxLength: { type: Number, default: undefined },
|
|
137
|
-
autocapitalize: {
|
|
138
|
-
type: String as PropType<'none' | 'sentences' | 'words' | 'characters'>,
|
|
139
|
-
default: undefined,
|
|
140
|
-
validator: (value: string) => ['none', 'sentences', 'words', 'characters'].includes(value),
|
|
141
|
-
},
|
|
142
|
-
autocorrect: { type: Boolean, default: undefined },
|
|
143
|
-
returnKey: choice(['done', 'next', 'go', 'search', 'send'] as const, 'done'),
|
|
144
|
-
icon: { type: String as PropType<IconName>, default: undefined },
|
|
145
|
-
trailingIcon: { type: String as PropType<IconName>, default: undefined },
|
|
146
193
|
}
|
|
194
|
+
export const switchProps = booleanControlProps
|
|
195
|
+
export const switchEmits = { 'update:modelValue': (value: boolean) => typeof value === 'boolean' }
|
|
196
|
+
export const checkboxProps = {
|
|
197
|
+
...booleanControlProps,
|
|
198
|
+
indeterminate: Boolean,
|
|
199
|
+
indeterminateLabel: { type: String, default: 'Partially selected' },
|
|
200
|
+
}
|
|
201
|
+
export const checkboxEmits = {
|
|
202
|
+
'update:modelValue': (value: boolean) => typeof value === 'boolean',
|
|
203
|
+
'update:indeterminate': (value: boolean) => typeof value === 'boolean',
|
|
204
|
+
}
|
|
205
|
+
export const radioGroupProps = {
|
|
206
|
+
id: viewProps.id,
|
|
207
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
208
|
+
...flexProps,
|
|
209
|
+
width: dimensionProp,
|
|
210
|
+
modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
|
|
211
|
+
options: { type: Array as PropType<readonly ChoiceOption[]>, required: true as const },
|
|
212
|
+
label: { type: String, required: true as const },
|
|
213
|
+
helperText: { type: String, default: '' },
|
|
214
|
+
disabled: Boolean,
|
|
215
|
+
}
|
|
216
|
+
export const radioGroupEmits = { 'update:modelValue': (value: ChoiceValue) => isChoiceValue(value) }
|
|
217
|
+
export const tabsProps = {
|
|
218
|
+
keepAlive: Boolean,
|
|
219
|
+
id: viewProps.id,
|
|
220
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
221
|
+
...flexProps,
|
|
222
|
+
width: dimensionProp,
|
|
223
|
+
modelValue: radioGroupProps.modelValue,
|
|
224
|
+
tabs: { type: Array as PropType<readonly TabOption[]>, required: true as const },
|
|
225
|
+
label: { type: String, required: true as const },
|
|
226
|
+
disabled: Boolean,
|
|
227
|
+
}
|
|
228
|
+
export const tabsEmits = radioGroupEmits
|
|
229
|
+
export const accordionProps = {
|
|
230
|
+
id: viewProps.id,
|
|
231
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
232
|
+
...flexProps,
|
|
233
|
+
width: dimensionProp,
|
|
234
|
+
items: { type: Array as PropType<readonly AccordionItem[]>, required: true as const },
|
|
235
|
+
modelValue: { type: Array as PropType<readonly ChoiceValue[]>, default: () => [] },
|
|
236
|
+
multiple: Boolean,
|
|
237
|
+
disabled: Boolean,
|
|
238
|
+
label: { type: String, required: true as const },
|
|
239
|
+
expandedLabel: { type: String, default: 'Expanded' },
|
|
240
|
+
collapsedLabel: { type: String, default: 'Collapsed' },
|
|
241
|
+
}
|
|
242
|
+
export const accordionEmits = {
|
|
243
|
+
'update:modelValue': (value: ChoiceValue[]) => Array.isArray(value) && value.every(isChoiceValue),
|
|
244
|
+
}
|
|
245
|
+
export const segmentedProps = {
|
|
246
|
+
id: viewProps.id,
|
|
247
|
+
accessibilityHidden: viewProps.accessibilityHidden,
|
|
248
|
+
...flexProps,
|
|
249
|
+
width: dimensionProp,
|
|
250
|
+
options: { type: Array as PropType<readonly SegmentedOption[]>, required: true as const },
|
|
251
|
+
modelValue: radioGroupProps.modelValue,
|
|
252
|
+
label: { type: String, required: true as const },
|
|
253
|
+
disabled: Boolean,
|
|
254
|
+
}
|
|
255
|
+
export const segmentedEmits = radioGroupEmits
|
|
256
|
+
|
|
257
|
+
export const dialogProps = {
|
|
258
|
+
id: viewProps.id,
|
|
259
|
+
open: Boolean,
|
|
260
|
+
title: { type: String, required: true as const },
|
|
261
|
+
description: { type: String, default: '' },
|
|
262
|
+
confirmLabel: { type: String, default: 'Continue' },
|
|
263
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
264
|
+
loadingLabel: { type: String, default: 'Working…' },
|
|
265
|
+
tone: choice(['default', 'danger'] as const, 'default'),
|
|
266
|
+
loading: Boolean,
|
|
267
|
+
dismissible: { type: Boolean, default: true },
|
|
268
|
+
}
|
|
269
|
+
export const dialogEmits = {
|
|
270
|
+
'update:open': (value: boolean) => typeof value === 'boolean',
|
|
271
|
+
confirm: () => true,
|
|
272
|
+
close: (reason: DialogCloseReason) => dialogCloseReasons.includes(reason),
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export const toastProps = {
|
|
276
|
+
controller: { type: Object as PropType<ToastController>, required: true as const },
|
|
277
|
+
closeLabel: { type: String, default: 'Dismiss notification' },
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export const selectProps = {
|
|
281
|
+
...radioGroupProps,
|
|
282
|
+
placeholder: { type: String, default: 'Select an option' },
|
|
283
|
+
error: { type: String, default: '' },
|
|
284
|
+
closeLabel: { type: String, default: 'Close' },
|
|
285
|
+
emptyText: { type: String, default: 'No options available' },
|
|
286
|
+
}
|
|
287
|
+
export const selectEmits = radioGroupEmits
|
|
288
|
+
export const inputProps = vueProps(inputContract)
|
|
147
289
|
export const inputEmits = {
|
|
290
|
+
action: () => true,
|
|
148
291
|
'update:modelValue': (value: string) => typeof value === 'string',
|
|
149
292
|
focus: () => true,
|
|
150
293
|
blur: () => true,
|
|
@@ -163,6 +306,7 @@ export const iconProps = {
|
|
|
163
306
|
label: { type: String, default: undefined },
|
|
164
307
|
}
|
|
165
308
|
export const screenProps = {
|
|
309
|
+
motionScroll: { type: Object as PropType<MotionScrollSource>, default: undefined },
|
|
166
310
|
...viewProps,
|
|
167
311
|
scroll: Boolean,
|
|
168
312
|
/** Puts the software keyboard away on a tap outside the editor and, with `scroll`, on a drag towards it. */
|
|
@@ -195,17 +339,36 @@ export const componentProps = {
|
|
|
195
339
|
MScreen: screenProps,
|
|
196
340
|
MRow: rowProps,
|
|
197
341
|
MColumn: columnProps,
|
|
198
|
-
MBox:
|
|
342
|
+
MBox: motionBoxProps,
|
|
199
343
|
MCard: cardProps,
|
|
200
344
|
MText: textProps,
|
|
201
345
|
MButton: buttonProps,
|
|
202
346
|
MSlider: sliderProps,
|
|
203
347
|
MInput: inputProps,
|
|
348
|
+
MSwitch: switchProps,
|
|
349
|
+
MCheckbox: checkboxProps,
|
|
350
|
+
MRadioGroup: radioGroupProps,
|
|
351
|
+
MSelect: selectProps,
|
|
352
|
+
MToast: toastProps,
|
|
353
|
+
MDialog: dialogProps,
|
|
354
|
+
MTabs: tabsProps,
|
|
355
|
+
MSkeleton: skeletonProps,
|
|
356
|
+
MProgress: progressProps,
|
|
357
|
+
MChip: chipProps,
|
|
358
|
+
MEmptyState: emptyStateProps,
|
|
359
|
+
MAccordion: accordionProps,
|
|
360
|
+
MSegmentedControl: segmentedProps,
|
|
361
|
+
MAlert: alertProps,
|
|
362
|
+
MListItem: listItemProps,
|
|
363
|
+
MSeparator: separatorProps,
|
|
364
|
+
MAvatar: avatarProps,
|
|
365
|
+
MBadge: badgeProps,
|
|
204
366
|
MIcon: iconProps,
|
|
205
367
|
MReveal: revealProps,
|
|
206
368
|
MSheet: sheetProps,
|
|
207
369
|
}
|
|
208
370
|
export type BoxProps = ExtractPropTypes<typeof boxProps>
|
|
209
371
|
export type ComponentProps = {
|
|
210
|
-
[Name in keyof typeof componentProps]: ExtractPublicPropTypes<(typeof componentProps)[Name]>
|
|
372
|
+
[Name in keyof typeof componentProps]: ExtractPublicPropTypes<(typeof componentProps)[Name]> &
|
|
373
|
+
(Name extends 'MSheet' ? SheetName : unknown)
|
|
211
374
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { computed, defineComponent, provide, type PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { MavisTheme } from '../theme/types.js'
|
|
3
|
+
import { themeKey, useMavisTheme, type AppearanceMode, type MavisThemeContext } from './theme.js'
|
|
4
|
+
|
|
5
|
+
export const themeProviderProps = {
|
|
6
|
+
theme: { type: Object as PropType<MavisTheme>, default: undefined },
|
|
7
|
+
darkTheme: { type: Object as PropType<MavisTheme>, default: undefined },
|
|
8
|
+
appearance: { type: String as PropType<AppearanceMode>, default: undefined },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Renderless, controlled scope. Device appearance is shared with the application subscription. */
|
|
12
|
+
export const MThemeProvider = defineComponent({
|
|
13
|
+
name: 'MThemeProvider',
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
props: themeProviderProps,
|
|
16
|
+
emits: {
|
|
17
|
+
'update:theme': (_theme: MavisTheme) => true,
|
|
18
|
+
'update:appearance': (_appearance: AppearanceMode) => true,
|
|
19
|
+
},
|
|
20
|
+
setup(props, { slots, emit }) {
|
|
21
|
+
const parent = useMavisTheme()
|
|
22
|
+
const themes = computed(() => {
|
|
23
|
+
if (props.darkTheme && props.darkTheme.appearance !== 'dark')
|
|
24
|
+
throw new RangeError('darkTheme must have dark appearance')
|
|
25
|
+
return {
|
|
26
|
+
...parent.themes.value,
|
|
27
|
+
...(props.theme ? { [props.theme.appearance]: props.theme } : {}),
|
|
28
|
+
...(props.darkTheme ? { dark: props.darkTheme } : {}),
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
const appearance = computed(() => {
|
|
32
|
+
const mode = props.appearance ?? props.theme?.appearance ?? parent.appearance.value
|
|
33
|
+
if (!['system', 'light', 'dark'].includes(mode))
|
|
34
|
+
throw new RangeError(`Unknown appearance mode: ${mode}`)
|
|
35
|
+
return mode
|
|
36
|
+
})
|
|
37
|
+
const theme = computed(() => {
|
|
38
|
+
const wanted =
|
|
39
|
+
appearance.value === 'system'
|
|
40
|
+
? (parent.systemAppearance.value ??
|
|
41
|
+
props.theme?.appearance ??
|
|
42
|
+
parent.theme.value.appearance)
|
|
43
|
+
: appearance.value
|
|
44
|
+
return (
|
|
45
|
+
themes.value[wanted] ??
|
|
46
|
+
themes.value[wanted === 'dark' ? 'light' : 'dark'] ??
|
|
47
|
+
parent.theme.value
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
const context: MavisThemeContext = {
|
|
51
|
+
theme,
|
|
52
|
+
themes,
|
|
53
|
+
appearance,
|
|
54
|
+
systemAppearance: parent.systemAppearance,
|
|
55
|
+
setTheme(next) {
|
|
56
|
+
emit('update:theme', next)
|
|
57
|
+
emit('update:appearance', next.appearance)
|
|
58
|
+
},
|
|
59
|
+
setAppearance(mode) {
|
|
60
|
+
if (!['system', 'light', 'dark'].includes(mode))
|
|
61
|
+
throw new RangeError(`Unknown appearance mode: ${mode}`)
|
|
62
|
+
emit('update:appearance', mode)
|
|
63
|
+
},
|
|
64
|
+
// No listener is owned by a scope; Vue disposes its computed effects on unmount.
|
|
65
|
+
dispose() {},
|
|
66
|
+
}
|
|
67
|
+
provide(themeKey, context)
|
|
68
|
+
return () => {
|
|
69
|
+
// Validate scopes even when their slot currently has no Mavis children.
|
|
70
|
+
void theme.value
|
|
71
|
+
return slots.default?.()
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
})
|
package/src/vue/theme.ts
CHANGED
|
@@ -28,23 +28,34 @@ function checkMode(mode: AppearanceMode) {
|
|
|
28
28
|
export function createThemeContext(options: MavisTheme | ThemeContextOptions = {}) {
|
|
29
29
|
const config: ThemeContextOptions = 'colors' in options ? { theme: options } : options
|
|
30
30
|
const initial = config.theme ?? mavis
|
|
31
|
-
const themes
|
|
32
|
-
|
|
31
|
+
const themes = shallowRef<Partial<Record<Appearance, MavisTheme>>>({
|
|
32
|
+
[initial.appearance]: initial,
|
|
33
|
+
})
|
|
34
|
+
if (config.darkTheme) {
|
|
35
|
+
if (config.darkTheme.appearance !== 'dark')
|
|
36
|
+
throw new RangeError('darkTheme must have dark appearance')
|
|
37
|
+
themes.value.dark = config.darkTheme
|
|
38
|
+
}
|
|
33
39
|
const appearance = shallowRef(checkMode(config.appearance ?? 'system'))
|
|
34
40
|
const theme = shallowRef(initial)
|
|
41
|
+
const systemAppearance = shallowRef(config.source?.current())
|
|
35
42
|
const resolve = () => {
|
|
36
43
|
const wanted =
|
|
37
44
|
appearance.value === 'system'
|
|
38
|
-
? (
|
|
45
|
+
? (systemAppearance.value ?? initial.appearance)
|
|
39
46
|
: appearance.value
|
|
40
|
-
theme.value =
|
|
47
|
+
theme.value =
|
|
48
|
+
themes.value[wanted] ?? themes.value[wanted === 'dark' ? 'light' : 'dark'] ?? initial
|
|
41
49
|
}
|
|
42
50
|
resolve()
|
|
43
|
-
const stop = config.source?.observe(() => {
|
|
51
|
+
const stop = config.source?.observe((next) => {
|
|
52
|
+
systemAppearance.value = next
|
|
44
53
|
if (appearance.value === 'system') resolve()
|
|
45
54
|
})
|
|
46
55
|
return {
|
|
47
56
|
theme: readonly(theme),
|
|
57
|
+
themes: readonly(themes),
|
|
58
|
+
systemAppearance: readonly(systemAppearance),
|
|
48
59
|
/** The selection: `system` follows the device; `light` and `dark` are explicit overrides. */
|
|
49
60
|
appearance: readonly(appearance),
|
|
50
61
|
setAppearance(mode: AppearanceMode) {
|
|
@@ -53,7 +64,7 @@ export function createThemeContext(options: MavisTheme | ThemeContextOptions = {
|
|
|
53
64
|
},
|
|
54
65
|
/** Registers the theme for its own appearance and pins that appearance. */
|
|
55
66
|
setTheme(next: MavisTheme) {
|
|
56
|
-
themes[next.appearance]
|
|
67
|
+
themes.value = { ...themes.value, [next.appearance]: next }
|
|
57
68
|
appearance.value = next.appearance
|
|
58
69
|
resolve()
|
|
59
70
|
},
|
package/src/vue/toast.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCurrentScope,
|
|
3
|
+
inject,
|
|
4
|
+
onScopeDispose,
|
|
5
|
+
ref,
|
|
6
|
+
shallowRef,
|
|
7
|
+
watch,
|
|
8
|
+
type App,
|
|
9
|
+
type InjectionKey,
|
|
10
|
+
type Ref,
|
|
11
|
+
} from '@vue/runtime-core'
|
|
12
|
+
import {
|
|
13
|
+
createToastController,
|
|
14
|
+
connectToast,
|
|
15
|
+
disposeToast,
|
|
16
|
+
type ToastController,
|
|
17
|
+
type ToastConnection,
|
|
18
|
+
type ToastSnapshot,
|
|
19
|
+
} from '../toast.js'
|
|
20
|
+
|
|
21
|
+
type AppToast = { controller: ToastController; requested: Ref<boolean>; closeLabel: string }
|
|
22
|
+
const appToastKey: InjectionKey<AppToast> = Symbol('mavis.appToast')
|
|
23
|
+
|
|
24
|
+
/** @internal Each plugin instance owns one queue, never a process-wide SSR singleton. */
|
|
25
|
+
export function installAppToast(app: App, options: { closeLabel?: string } = {}) {
|
|
26
|
+
const controller = createToastController({ persistent: true })
|
|
27
|
+
app.provide(appToastKey, {
|
|
28
|
+
controller,
|
|
29
|
+
requested: ref(false),
|
|
30
|
+
closeLabel: options.closeLabel ?? 'Dismiss notification',
|
|
31
|
+
})
|
|
32
|
+
app.onUnmount(() => disposeToast(controller))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @internal Screens only mount their application host after an app queue is requested. */
|
|
36
|
+
export function useAppToastHost() {
|
|
37
|
+
return inject(appToastKey, undefined)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Local by default. The app queue is owned by createMavis and hosted by each active Screen. */
|
|
41
|
+
export function useToast(options: { scope?: 'local' | 'app' } = {}): ToastController {
|
|
42
|
+
if (!getCurrentScope()) throw new Error('useToast must run inside a Vue setup or effect scope')
|
|
43
|
+
if (options.scope === 'app') {
|
|
44
|
+
const app = inject(appToastKey, undefined)
|
|
45
|
+
if (!app) throw new Error('App Toast needs createMavis on the current Vue app')
|
|
46
|
+
app.requested.value = true
|
|
47
|
+
return app.controller
|
|
48
|
+
}
|
|
49
|
+
const controller = createToastController()
|
|
50
|
+
onScopeDispose(() => disposeToast(controller))
|
|
51
|
+
return controller
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @internal Shared renderer binding; platform lifecycles activate and pause its clock. */
|
|
55
|
+
export function useToastHost(controller: () => ToastController) {
|
|
56
|
+
const snapshot = shallowRef<ToastSnapshot>({ visible: false })
|
|
57
|
+
let connection: ToastConnection | undefined
|
|
58
|
+
let active = false
|
|
59
|
+
const pauses = new Set<string>()
|
|
60
|
+
watch(
|
|
61
|
+
controller,
|
|
62
|
+
(next) => {
|
|
63
|
+
connection?.dispose()
|
|
64
|
+
connection = connectToast(next, (value) => {
|
|
65
|
+
snapshot.value = value
|
|
66
|
+
})
|
|
67
|
+
for (const reason of pauses) connection.pause(reason, true)
|
|
68
|
+
if (active) connection.activate()
|
|
69
|
+
},
|
|
70
|
+
{ immediate: true, flush: 'sync' },
|
|
71
|
+
)
|
|
72
|
+
onScopeDispose(() => connection?.dispose())
|
|
73
|
+
return {
|
|
74
|
+
snapshot,
|
|
75
|
+
activate() {
|
|
76
|
+
active = true
|
|
77
|
+
connection?.activate()
|
|
78
|
+
},
|
|
79
|
+
deactivate() {
|
|
80
|
+
active = false
|
|
81
|
+
pauses.clear()
|
|
82
|
+
connection?.deactivate()
|
|
83
|
+
},
|
|
84
|
+
pause(reason: string, paused: boolean) {
|
|
85
|
+
if (paused) pauses.add(reason)
|
|
86
|
+
else pauses.delete(reason)
|
|
87
|
+
connection?.pause(reason, paused)
|
|
88
|
+
},
|
|
89
|
+
begin(id: number) {
|
|
90
|
+
connection?.begin(id)
|
|
91
|
+
},
|
|
92
|
+
entered(id: number) {
|
|
93
|
+
connection?.entered(id)
|
|
94
|
+
},
|
|
95
|
+
left(id: number) {
|
|
96
|
+
connection?.left(id)
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
}
|