@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.
Files changed (242) hide show
  1. package/README.md +2 -2
  2. package/dist/accordion.d.ts +17 -0
  3. package/dist/accordion.d.ts.map +1 -0
  4. package/dist/accordion.js +42 -0
  5. package/dist/accordion.js.map +1 -0
  6. package/dist/alert.d.ts +21 -0
  7. package/dist/alert.d.ts.map +1 -0
  8. package/dist/alert.js +13 -0
  9. package/dist/alert.js.map +1 -0
  10. package/dist/avatar.d.ts +10 -0
  11. package/dist/avatar.d.ts.map +1 -0
  12. package/dist/avatar.js +11 -0
  13. package/dist/avatar.js.map +1 -0
  14. package/dist/badge.d.ts +7 -0
  15. package/dist/badge.d.ts.map +1 -0
  16. package/dist/badge.js +11 -0
  17. package/dist/badge.js.map +1 -0
  18. package/dist/capabilities.d.ts +119 -0
  19. package/dist/capabilities.d.ts.map +1 -0
  20. package/dist/capabilities.js +142 -0
  21. package/dist/capabilities.js.map +1 -0
  22. package/dist/chip.d.ts +9 -0
  23. package/dist/chip.d.ts.map +1 -0
  24. package/dist/chip.js +16 -0
  25. package/dist/chip.js.map +1 -0
  26. package/dist/choice.d.ts +15 -0
  27. package/dist/choice.d.ts.map +1 -0
  28. package/dist/choice.js +27 -0
  29. package/dist/choice.js.map +1 -0
  30. package/dist/combobox.d.ts +42 -0
  31. package/dist/combobox.d.ts.map +1 -0
  32. package/dist/combobox.js +159 -0
  33. package/dist/combobox.js.map +1 -0
  34. package/dist/contracts.d.ts +1201 -0
  35. package/dist/contracts.d.ts.map +1 -0
  36. package/dist/contracts.js +242 -0
  37. package/dist/contracts.js.map +1 -0
  38. package/dist/date.d.ts +96 -0
  39. package/dist/date.d.ts.map +1 -0
  40. package/dist/date.js +235 -0
  41. package/dist/date.js.map +1 -0
  42. package/dist/dialog.d.ts +4 -0
  43. package/dist/dialog.d.ts.map +1 -0
  44. package/dist/dialog.js +20 -0
  45. package/dist/dialog.js.map +1 -0
  46. package/dist/empty-state.d.ts +2 -0
  47. package/dist/empty-state.d.ts.map +1 -0
  48. package/dist/empty-state.js +5 -0
  49. package/dist/empty-state.js.map +1 -0
  50. package/dist/experimental-regions.d.ts +142 -0
  51. package/dist/experimental-regions.d.ts.map +1 -0
  52. package/dist/experimental-regions.js +315 -0
  53. package/dist/experimental-regions.js.map +1 -0
  54. package/dist/experimental.d.ts +134 -0
  55. package/dist/experimental.d.ts.map +1 -0
  56. package/dist/experimental.js +502 -0
  57. package/dist/experimental.js.map +1 -0
  58. package/dist/files.d.ts +87 -0
  59. package/dist/files.d.ts.map +1 -0
  60. package/dist/files.js +328 -0
  61. package/dist/files.js.map +1 -0
  62. package/dist/form.d.ts +39 -0
  63. package/dist/form.d.ts.map +1 -0
  64. package/dist/form.js +170 -0
  65. package/dist/form.js.map +1 -0
  66. package/dist/index.d.ts +38 -4
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +23 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/input.d.ts +10 -0
  71. package/dist/input.d.ts.map +1 -1
  72. package/dist/input.js +12 -0
  73. package/dist/input.js.map +1 -1
  74. package/dist/list-item.d.ts +3 -0
  75. package/dist/list-item.d.ts.map +1 -0
  76. package/dist/list-item.js +7 -0
  77. package/dist/list-item.js.map +1 -0
  78. package/dist/motion.d.ts +33 -0
  79. package/dist/motion.d.ts.map +1 -0
  80. package/dist/motion.js +21 -0
  81. package/dist/motion.js.map +1 -0
  82. package/dist/navigation.d.ts +22 -0
  83. package/dist/navigation.d.ts.map +1 -0
  84. package/dist/navigation.js +54 -0
  85. package/dist/navigation.js.map +1 -0
  86. package/dist/progress.d.ts +19 -0
  87. package/dist/progress.d.ts.map +1 -0
  88. package/dist/progress.js +19 -0
  89. package/dist/progress.js.map +1 -0
  90. package/dist/segmented.d.ts +11 -0
  91. package/dist/segmented.d.ts.map +1 -0
  92. package/dist/segmented.js +30 -0
  93. package/dist/segmented.js.map +1 -0
  94. package/dist/sheet.d.ts +8 -1
  95. package/dist/sheet.d.ts.map +1 -1
  96. package/dist/sheet.js +4 -3
  97. package/dist/sheet.js.map +1 -1
  98. package/dist/tabs.d.ts +11 -0
  99. package/dist/tabs.d.ts.map +1 -0
  100. package/dist/tabs.js +28 -0
  101. package/dist/tabs.js.map +1 -0
  102. package/dist/theme/themes.d.ts.map +1 -1
  103. package/dist/theme/themes.js +84 -11
  104. package/dist/theme/themes.js.map +1 -1
  105. package/dist/theme/types.d.ts +52 -1
  106. package/dist/theme/types.d.ts.map +1 -1
  107. package/dist/theme/typography.d.ts +10 -0
  108. package/dist/theme/typography.d.ts.map +1 -0
  109. package/dist/theme/typography.js +90 -0
  110. package/dist/theme/typography.js.map +1 -0
  111. package/dist/toast.d.ts +43 -0
  112. package/dist/toast.d.ts.map +1 -0
  113. package/dist/toast.js +228 -0
  114. package/dist/toast.js.map +1 -0
  115. package/dist/vue/button-content.d.ts +10 -0
  116. package/dist/vue/button-content.d.ts.map +1 -0
  117. package/dist/vue/button-content.js +54 -0
  118. package/dist/vue/button-content.js.map +1 -0
  119. package/dist/vue/cached-activity.d.ts +3 -0
  120. package/dist/vue/cached-activity.d.ts.map +1 -0
  121. package/dist/vue/cached-activity.js +13 -0
  122. package/dist/vue/cached-activity.js.map +1 -0
  123. package/dist/vue/combobox.d.ts +155 -0
  124. package/dist/vue/combobox.d.ts.map +1 -0
  125. package/dist/vue/combobox.js +195 -0
  126. package/dist/vue/combobox.js.map +1 -0
  127. package/dist/vue/component-props.d.ts +1989 -0
  128. package/dist/vue/component-props.d.ts.map +1 -0
  129. package/dist/vue/component-props.js +18 -0
  130. package/dist/vue/component-props.js.map +1 -0
  131. package/dist/vue/contracts.d.ts +18 -0
  132. package/dist/vue/contracts.d.ts.map +1 -0
  133. package/dist/vue/contracts.js +18 -0
  134. package/dist/vue/contracts.js.map +1 -0
  135. package/dist/vue/date-calendar.d.ts +64 -0
  136. package/dist/vue/date-calendar.d.ts.map +1 -0
  137. package/dist/vue/date-calendar.js +65 -0
  138. package/dist/vue/date-calendar.js.map +1 -0
  139. package/dist/vue/date-picker.d.ts +927 -0
  140. package/dist/vue/date-picker.d.ts.map +1 -0
  141. package/dist/vue/date-picker.js +319 -0
  142. package/dist/vue/date-picker.js.map +1 -0
  143. package/dist/vue/date-props.d.ts +254 -0
  144. package/dist/vue/date-props.d.ts.map +1 -0
  145. package/dist/vue/date-props.js +74 -0
  146. package/dist/vue/date-props.js.map +1 -0
  147. package/dist/vue/dialog.d.ts +21 -0
  148. package/dist/vue/dialog.d.ts.map +1 -0
  149. package/dist/vue/dialog.js +58 -0
  150. package/dist/vue/dialog.js.map +1 -0
  151. package/dist/vue/files.d.ts +53 -0
  152. package/dist/vue/files.d.ts.map +1 -0
  153. package/dist/vue/files.js +40 -0
  154. package/dist/vue/files.js.map +1 -0
  155. package/dist/vue/forms.d.ts +4 -0
  156. package/dist/vue/forms.d.ts.map +1 -0
  157. package/dist/vue/forms.js +15 -0
  158. package/dist/vue/forms.js.map +1 -0
  159. package/dist/vue/global-components.d.ts +129 -3
  160. package/dist/vue/global-components.d.ts.map +1 -1
  161. package/dist/vue/index.d.ts +28 -2
  162. package/dist/vue/index.d.ts.map +1 -1
  163. package/dist/vue/index.js +24 -1
  164. package/dist/vue/index.js.map +1 -1
  165. package/dist/vue/inline-content.d.ts +54 -0
  166. package/dist/vue/inline-content.d.ts.map +1 -0
  167. package/dist/vue/inline-content.js +64 -0
  168. package/dist/vue/inline-content.js.map +1 -0
  169. package/dist/vue/props.d.ts +2654 -637
  170. package/dist/vue/props.d.ts.map +1 -1
  171. package/dist/vue/props.js +228 -86
  172. package/dist/vue/props.js.map +1 -1
  173. package/dist/vue/theme-provider.d.ts +58 -0
  174. package/dist/vue/theme-provider.d.ts.map +1 -0
  175. package/dist/vue/theme-provider.js +69 -0
  176. package/dist/vue/theme-provider.js.map +1 -0
  177. package/dist/vue/theme.d.ts +962 -12
  178. package/dist/vue/theme.d.ts.map +1 -1
  179. package/dist/vue/theme.js +17 -7
  180. package/dist/vue/theme.js.map +1 -1
  181. package/dist/vue/toast.d.ts +29 -0
  182. package/dist/vue/toast.d.ts.map +1 -0
  183. package/dist/vue/toast.js +79 -0
  184. package/dist/vue/toast.js.map +1 -0
  185. package/dist/vue/workflow-props.d.ts +110 -0
  186. package/dist/vue/workflow-props.d.ts.map +1 -0
  187. package/dist/vue/workflow-props.js +37 -0
  188. package/dist/vue/workflow-props.js.map +1 -0
  189. package/dist/vue/workflows.d.ts +267 -0
  190. package/dist/vue/workflows.d.ts.map +1 -0
  191. package/dist/vue/workflows.js +200 -0
  192. package/dist/vue/workflows.js.map +1 -0
  193. package/package.json +5 -1
  194. package/src/accordion.ts +66 -0
  195. package/src/alert.ts +16 -0
  196. package/src/avatar.ts +11 -0
  197. package/src/badge.ts +11 -0
  198. package/src/capabilities.ts +145 -0
  199. package/src/chip.ts +20 -0
  200. package/src/choice.ts +41 -0
  201. package/src/combobox.ts +198 -0
  202. package/src/contracts.ts +295 -0
  203. package/src/date.ts +280 -0
  204. package/src/dialog.ts +20 -0
  205. package/src/empty-state.ts +4 -0
  206. package/src/experimental-regions.ts +463 -0
  207. package/src/experimental.ts +643 -0
  208. package/src/files.ts +408 -0
  209. package/src/form.ts +190 -0
  210. package/src/index.ts +64 -3
  211. package/src/input.ts +22 -0
  212. package/src/list-item.ts +5 -0
  213. package/src/motion.ts +22 -0
  214. package/src/navigation.ts +61 -0
  215. package/src/progress.ts +22 -0
  216. package/src/segmented.ts +39 -0
  217. package/src/sheet.ts +6 -3
  218. package/src/tabs.ts +35 -0
  219. package/src/theme/themes.ts +88 -11
  220. package/src/theme/types.ts +42 -1
  221. package/src/theme/typography.ts +84 -0
  222. package/src/toast.ts +249 -0
  223. package/src/vue/button-content.ts +60 -0
  224. package/src/vue/cached-activity.ts +13 -0
  225. package/src/vue/combobox.ts +238 -0
  226. package/src/vue/component-props.ts +24 -0
  227. package/src/vue/contracts.ts +33 -0
  228. package/src/vue/date-calendar.ts +76 -0
  229. package/src/vue/date-picker.ts +387 -0
  230. package/src/vue/date-props.ts +81 -0
  231. package/src/vue/dialog.ts +63 -0
  232. package/src/vue/files.ts +53 -0
  233. package/src/vue/forms.ts +20 -0
  234. package/src/vue/global-components.ts +120 -3
  235. package/src/vue/index.ts +46 -2
  236. package/src/vue/inline-content.ts +71 -0
  237. package/src/vue/props.ts +258 -95
  238. package/src/vue/theme-provider.ts +74 -0
  239. package/src/vue/theme.ts +17 -6
  240. package/src/vue/toast.ts +99 -0
  241. package/src/vue/workflow-props.ts +41 -0
  242. 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, Spacing, Radius } from '../theme/types.js'
3
- import type { Dimension } from '../layout.js'
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 = { type: [String, Number] as PropType<Spacing>, default: undefined }
16
- const radiusProp = { type: [String, Number] as PropType<Radius | number>, default: undefined }
17
- const dimensionProp = { type: [Number, String] as PropType<Dimension>, default: undefined }
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
- grow: { type: Number, default: 0 },
35
- shrink: { type: Number, default: undefined },
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 boxProps = {
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
- height: dimensionProp,
46
- backgroundColor: String,
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 type Align = 'start' | 'center' | 'end' | 'stretch'
49
- export type Justify = 'start' | 'center' | 'end' | 'between' | 'around'
50
-
51
- function layoutProps(direction: 'row' | 'column') {
52
- return {
53
- ...boxProps,
54
- gap: spacingProp,
55
- align: choice<Align>(
56
- ['start', 'center', 'end', 'stretch'],
57
- direction === 'row' ? 'center' : 'stretch',
58
- ),
59
- justify: choice<Justify>(['start', 'center', 'end', 'between', 'around'], 'start'),
60
- wrap: Boolean,
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 rowProps = layoutProps('row')
64
- export const columnProps = layoutProps('column')
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: { ...spacingProp, default: 'lg' },
68
- radius: { ...radiusProp, default: 'lg' },
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
- ...viewProps,
75
- ...flexProps,
76
- text: { type: String, default: undefined },
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
- as: choice(['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const, 'p'),
106
- variant: choice(['display', 'title', 'heading', 'body', 'caption', 'overline'] as const, 'body'),
107
- tone: choice<keyof Palette>(tones, 'text'),
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
- export const inputProps = {
184
+ const booleanControlProps = {
122
185
  id: viewProps.id,
123
186
  accessibilityHidden: viewProps.accessibilityHidden,
124
187
  ...flexProps,
125
188
  width: dimensionProp,
126
- modelValue: { type: String, default: '' },
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: boxProps,
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: Partial<Record<Appearance, MavisTheme>> = { [initial.appearance]: initial }
32
- if (config.darkTheme) themes.dark = config.darkTheme
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
- ? (config.source?.current() ?? initial.appearance)
45
+ ? (systemAppearance.value ?? initial.appearance)
39
46
  : appearance.value
40
- theme.value = themes[wanted] ?? themes[wanted === 'dark' ? 'light' : 'dark'] ?? initial
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] = next
67
+ themes.value = { ...themes.value, [next.appearance]: next }
57
68
  appearance.value = next.appearance
58
69
  resolve()
59
70
  },
@@ -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
+ }