@getcortexlabs/mavis-core 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (127) hide show
  1. package/dist/app-icons.d.ts +27 -0
  2. package/dist/app-icons.d.ts.map +1 -0
  3. package/dist/app-icons.js +42 -0
  4. package/dist/app-icons.js.map +1 -0
  5. package/dist/capabilities.d.ts +7 -7
  6. package/dist/capabilities.d.ts.map +1 -1
  7. package/dist/capabilities.js +9 -4
  8. package/dist/capabilities.js.map +1 -1
  9. package/dist/choice-motion.d.ts +14 -0
  10. package/dist/choice-motion.d.ts.map +1 -0
  11. package/dist/choice-motion.js +5 -0
  12. package/dist/choice-motion.js.map +1 -0
  13. package/dist/contracts.d.ts +61 -1
  14. package/dist/contracts.d.ts.map +1 -1
  15. package/dist/contracts.js +8 -1
  16. package/dist/contracts.js.map +1 -1
  17. package/dist/experimental-playback.d.ts +63 -0
  18. package/dist/experimental-playback.d.ts.map +1 -0
  19. package/dist/experimental-playback.js +46 -0
  20. package/dist/experimental-playback.js.map +1 -0
  21. package/dist/experimental-regions.d.ts +12 -0
  22. package/dist/experimental-regions.d.ts.map +1 -1
  23. package/dist/experimental-regions.js +125 -0
  24. package/dist/experimental-regions.js.map +1 -1
  25. package/dist/experimental.d.ts +38 -4
  26. package/dist/experimental.d.ts.map +1 -1
  27. package/dist/experimental.js +70 -11
  28. package/dist/experimental.js.map +1 -1
  29. package/dist/index.d.ts +8 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +7 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/link.d.ts +12 -0
  34. package/dist/link.d.ts.map +1 -0
  35. package/dist/link.js +19 -0
  36. package/dist/link.js.map +1 -0
  37. package/dist/motion.d.ts +29 -4
  38. package/dist/motion.d.ts.map +1 -1
  39. package/dist/motion.js +55 -3
  40. package/dist/motion.js.map +1 -1
  41. package/dist/multi-select.d.ts +4 -0
  42. package/dist/multi-select.d.ts.map +1 -0
  43. package/dist/multi-select.js +23 -0
  44. package/dist/multi-select.js.map +1 -0
  45. package/dist/number-input.d.ts +21 -0
  46. package/dist/number-input.d.ts.map +1 -0
  47. package/dist/number-input.js +63 -0
  48. package/dist/number-input.js.map +1 -0
  49. package/dist/responsive.d.ts +18 -0
  50. package/dist/responsive.d.ts.map +1 -0
  51. package/dist/responsive.js +35 -0
  52. package/dist/responsive.js.map +1 -0
  53. package/dist/theme/themes.js +3 -3
  54. package/dist/theme/themes.js.map +1 -1
  55. package/dist/theme/types.d.ts +12 -3
  56. package/dist/theme/types.d.ts.map +1 -1
  57. package/dist/vue/component-props.d.ts +434 -0
  58. package/dist/vue/component-props.d.ts.map +1 -1
  59. package/dist/vue/component-props.js +4 -0
  60. package/dist/vue/component-props.js.map +1 -1
  61. package/dist/vue/configurator-props.d.ts +251 -0
  62. package/dist/vue/configurator-props.d.ts.map +1 -0
  63. package/dist/vue/configurator-props.js +56 -0
  64. package/dist/vue/configurator-props.js.map +1 -0
  65. package/dist/vue/configurator.d.ts +403 -0
  66. package/dist/vue/configurator.d.ts.map +1 -0
  67. package/dist/vue/configurator.js +287 -0
  68. package/dist/vue/configurator.js.map +1 -0
  69. package/dist/vue/contracts.d.ts.map +1 -1
  70. package/dist/vue/contracts.js +7 -1
  71. package/dist/vue/contracts.js.map +1 -1
  72. package/dist/vue/date-picker.d.ts +50 -12
  73. package/dist/vue/date-picker.d.ts.map +1 -1
  74. package/dist/vue/date-picker.js +28 -6
  75. package/dist/vue/date-picker.js.map +1 -1
  76. package/dist/vue/date-props.d.ts +9 -0
  77. package/dist/vue/date-props.d.ts.map +1 -1
  78. package/dist/vue/date-props.js +3 -0
  79. package/dist/vue/date-props.js.map +1 -1
  80. package/dist/vue/global-components.d.ts +19 -0
  81. package/dist/vue/global-components.d.ts.map +1 -1
  82. package/dist/vue/index.d.ts +6 -2
  83. package/dist/vue/index.d.ts.map +1 -1
  84. package/dist/vue/index.js +5 -2
  85. package/dist/vue/index.js.map +1 -1
  86. package/dist/vue/layout-context.d.ts +4 -2
  87. package/dist/vue/layout-context.d.ts.map +1 -1
  88. package/dist/vue/layout-context.js +7 -2
  89. package/dist/vue/layout-context.js.map +1 -1
  90. package/dist/vue/props.d.ts +365 -0
  91. package/dist/vue/props.d.ts.map +1 -1
  92. package/dist/vue/props.js +25 -1
  93. package/dist/vue/props.js.map +1 -1
  94. package/dist/vue/reveal-state.d.ts +18 -0
  95. package/dist/vue/reveal-state.d.ts.map +1 -0
  96. package/dist/vue/reveal-state.js +76 -0
  97. package/dist/vue/reveal-state.js.map +1 -0
  98. package/dist/vue/theme.d.ts +42 -0
  99. package/dist/vue/theme.d.ts.map +1 -1
  100. package/dist/vue/workflows.d.ts +1 -1
  101. package/package.json +1 -1
  102. package/src/app-icons.ts +57 -0
  103. package/src/capabilities.ts +9 -4
  104. package/src/choice-motion.ts +12 -0
  105. package/src/contracts.ts +12 -2
  106. package/src/experimental-playback.ts +115 -0
  107. package/src/experimental-regions.ts +151 -0
  108. package/src/experimental.ts +139 -21
  109. package/src/index.ts +10 -1
  110. package/src/link.ts +28 -0
  111. package/src/motion.ts +61 -3
  112. package/src/multi-select.ts +30 -0
  113. package/src/number-input.ts +80 -0
  114. package/src/responsive.ts +61 -0
  115. package/src/theme/themes.ts +3 -3
  116. package/src/theme/types.ts +13 -1
  117. package/src/vue/component-props.ts +4 -0
  118. package/src/vue/configurator-props.ts +59 -0
  119. package/src/vue/configurator.ts +350 -0
  120. package/src/vue/contracts.ts +7 -1
  121. package/src/vue/date-picker.ts +33 -6
  122. package/src/vue/date-props.ts +3 -0
  123. package/src/vue/global-components.ts +21 -1
  124. package/src/vue/index.ts +9 -1
  125. package/src/vue/layout-context.ts +10 -3
  126. package/src/vue/props.ts +27 -1
  127. package/src/vue/reveal-state.ts +83 -0
@@ -0,0 +1,59 @@
1
+ import type { PropType } from '@vue/runtime-core'
2
+ import type { ChoiceOption, ChoiceValue } from '../choice.js'
3
+ import type { NumberLocale } from '../number-input.js'
4
+ import { inputProps, boxProps } from './props.js'
5
+
6
+ const field = {
7
+ id: inputProps.id,
8
+ label: inputProps.label,
9
+ width: inputProps.width,
10
+ grow: inputProps.grow,
11
+ shrink: inputProps.shrink,
12
+ disabled: Boolean,
13
+ readonly: Boolean,
14
+ helperText: inputProps.helperText,
15
+ error: inputProps.error,
16
+ accessibilityHidden: inputProps.accessibilityHidden,
17
+ }
18
+ export const numberInputProps = {
19
+ ...field,
20
+ modelValue: { type: Number as PropType<number | null>, default: null },
21
+ draft: { type: String, default: undefined },
22
+ min: { type: Number, default: undefined },
23
+ max: { type: Number, default: undefined },
24
+ step: { type: Number, default: 1 },
25
+ locale: {
26
+ type: String as PropType<NumberLocale>,
27
+ default: 'en-US',
28
+ validator: (value: string) => ['en-US', 'pt-BR'].includes(value),
29
+ },
30
+ name: inputProps.name,
31
+ placeholder: inputProps.placeholder,
32
+ incrementLabel: { type: String, default: 'Increase' },
33
+ decrementLabel: { type: String, default: 'Decrease' },
34
+ }
35
+ export const multiSelectProps = {
36
+ ...field,
37
+ modelValue: { type: Array as PropType<readonly ChoiceValue[]>, default: () => [] },
38
+ options: { type: Array as PropType<readonly ChoiceOption[]>, required: true as const },
39
+ maxSelected: { type: Number, default: undefined },
40
+ placeholder: { type: String, default: 'Choose options' },
41
+ searchLabel: { type: String, default: 'Search options' },
42
+ closeLabel: { type: String, default: 'Done' },
43
+ emptyLabel: { type: String, default: 'No matching options' },
44
+ removeLabel: { type: String, default: 'Remove' },
45
+ }
46
+ export const imageProps = {
47
+ ...boxProps,
48
+ src: { type: String, required: true as const },
49
+ alt: { type: String, required: true as const },
50
+ aspectRatio: { type: Number, default: 4 / 3 },
51
+ fit: {
52
+ type: String as PropType<'cover' | 'contain'>,
53
+ default: 'cover',
54
+ validator: (value: string) => ['cover', 'contain'].includes(value),
55
+ },
56
+ radius: { ...boxProps.radius, default: 'md' },
57
+ loadingLabel: { type: String, default: 'Loading image' },
58
+ errorLabel: { type: String, default: 'Image unavailable' },
59
+ }
@@ -0,0 +1,350 @@
1
+ import {
2
+ computed,
3
+ onBeforeUnmount,
4
+ defineComponent,
5
+ h,
6
+ mergeProps,
7
+ nextTick,
8
+ ref,
9
+ watch,
10
+ type Component,
11
+ } from '@vue/runtime-core'
12
+ import type { InputHandle } from '../input.js'
13
+ import type { ChoiceValue } from '../choice.js'
14
+ import { choiceKey } from '../choice.js'
15
+ import {
16
+ formatNumber,
17
+ parseNumberDraft,
18
+ stepNumber,
19
+ validateNumberConstraints,
20
+ type NumberDraft,
21
+ } from '../number-input.js'
22
+ import { toggleMultiSelection, validateMultiSelection } from '../multi-select.js'
23
+ import { numberInputProps, multiSelectProps } from './configurator-props.js'
24
+ import { useButtonAction } from './button-content.js'
25
+
26
+ interface Primitives {
27
+ Column: Component
28
+ Row: Component
29
+ Text: Component
30
+ Button: Component
31
+ Input: Component
32
+ Chip: Component
33
+ Checkbox: Component
34
+ Sheet: Component
35
+ focusTrigger: (component: unknown) => void
36
+ }
37
+
38
+ /** Shared controls compose the renderer primitives, keeping editing and selection in one place. */
39
+ export function createConfiguratorControls(ui: Primitives, platform: 'web' | 'native') {
40
+ const NumberInput = defineComponent({
41
+ name: 'MNumberInput',
42
+ inheritAttrs: false,
43
+ props: numberInputProps,
44
+ emits: {
45
+ 'update:modelValue': (_value: number | null) => true,
46
+ 'update:draft': (_value: string) => true,
47
+ validityChange: (_value: NumberDraft) => true,
48
+ focus: () => true,
49
+ blur: () => true,
50
+ },
51
+ setup(props, { attrs, emit, expose }) {
52
+ useButtonAction()
53
+ const editor = ref<InputHandle>()
54
+ const local = ref(props.draft ?? formatNumber(props.modelValue, props.locale))
55
+ const draft = computed(() => props.draft ?? local.value)
56
+ const parsed = computed(() => parseNumberDraft(draft.value, props.locale, props))
57
+ let alive = true
58
+ onBeforeUnmount(() => {
59
+ alive = false
60
+ })
61
+ let revision = 0
62
+ let requested: number | null | undefined
63
+ function setDraft(value: string) {
64
+ local.value = value
65
+ emit('update:draft', value)
66
+ }
67
+ watch(
68
+ () => [props.modelValue, props.locale] as const,
69
+ ([value, locale], previous) => {
70
+ if (!Object.is(value, requested) || locale !== previous[1])
71
+ setDraft(formatNumber(value, locale))
72
+ requested = undefined
73
+ },
74
+ )
75
+ watch(
76
+ () => props.draft,
77
+ (value) => {
78
+ if (value !== undefined) local.value = value
79
+ },
80
+ )
81
+ function publish(value: number | null) {
82
+ const current = ++revision
83
+ requested = value
84
+ emit('update:modelValue', value)
85
+ void nextTick(() => {
86
+ if (!alive || current !== revision) return
87
+ if (!Object.is(props.modelValue, value))
88
+ setDraft(formatNumber(props.modelValue, props.locale))
89
+ requested = undefined
90
+ })
91
+ }
92
+ function edit(value: string) {
93
+ if (props.disabled || props.readonly) return
94
+ revision++
95
+ setDraft(value)
96
+ const validation = parseNumberDraft(value, props.locale, props)
97
+ emit('validityChange', validation)
98
+ if (validation.status === 'valid' || validation.status === 'empty')
99
+ publish(validation.value)
100
+ }
101
+ function step(direction: -1 | 1) {
102
+ if (props.disabled || props.readonly) return
103
+ const current = parsed.value.status === 'valid' ? parsed.value.value : props.modelValue
104
+ const value = stepNumber(current, direction, props)
105
+ setDraft(formatNumber(value, props.locale))
106
+ publish(value)
107
+ emit('validityChange', { status: 'valid', value })
108
+ }
109
+ expose({
110
+ focus: () => editor.value?.focus(),
111
+ blur: () => editor.value?.blur(),
112
+ } satisfies InputHandle)
113
+ return () => {
114
+ validateNumberConstraints(props)
115
+ if (!props.label.trim()) throw new TypeError('NumberInput requires a label.')
116
+ const blocked = props.disabled || props.readonly
117
+ const issue = ['invalid', 'range'].includes(parsed.value.status)
118
+ const message = issue
119
+ ? props.locale === 'pt-BR'
120
+ ? 'Informe um número dentro dos limites.'
121
+ : 'Enter a number within the allowed range.'
122
+ : ''
123
+ return h(
124
+ ui.Row,
125
+ {
126
+ gap: 'sm',
127
+ align: 'end',
128
+ width: props.width,
129
+ grow: props.grow,
130
+ shrink: props.shrink,
131
+ accessibilityHidden: props.accessibilityHidden,
132
+ },
133
+ () => [
134
+ h(
135
+ ui.Input,
136
+ mergeProps(attrs, {
137
+ ref: editor,
138
+ id: props.id,
139
+ modelValue: draft.value,
140
+ label: props.label,
141
+ name: props.name,
142
+ placeholder: props.placeholder,
143
+ inputmode: 'decimal',
144
+ disabled: props.disabled,
145
+ readonly: props.readonly,
146
+ helperText: props.helperText,
147
+ error: props.error || message,
148
+ accessibilityHidden: props.accessibilityHidden,
149
+ width: 0,
150
+ grow: 1,
151
+ autocorrect: false,
152
+ autocapitalize: 'none',
153
+ 'onUpdate:modelValue': edit,
154
+ onFocus: () => emit('focus'),
155
+ onBlur: () => emit('blur'),
156
+ ...(platform === 'web'
157
+ ? {
158
+ onKeydown: (event: {
159
+ key: string
160
+ isComposing: boolean
161
+ preventDefault(): void
162
+ }) => {
163
+ if (
164
+ !blocked &&
165
+ !event.isComposing &&
166
+ ['ArrowUp', 'ArrowDown'].includes(event.key)
167
+ ) {
168
+ event.preventDefault()
169
+ step(event.key === 'ArrowUp' ? 1 : -1)
170
+ }
171
+ },
172
+ }
173
+ : {}),
174
+ }),
175
+ ),
176
+ h(ui.Button, {
177
+ text: '−',
178
+ variant: 'secondary',
179
+ accessibilityLabel: `${props.decrementLabel}: ${props.label}`,
180
+ disabled:
181
+ blocked ||
182
+ (props.min !== undefined &&
183
+ props.modelValue !== null &&
184
+ props.modelValue <= props.min),
185
+ onClick: () => step(-1),
186
+ }),
187
+ h(ui.Button, {
188
+ text: '+',
189
+ variant: 'secondary',
190
+ accessibilityLabel: `${props.incrementLabel}: ${props.label}`,
191
+ disabled:
192
+ blocked ||
193
+ (props.max !== undefined &&
194
+ props.modelValue !== null &&
195
+ props.modelValue >= props.max),
196
+ onClick: () => step(1),
197
+ }),
198
+ ],
199
+ )
200
+ }
201
+ },
202
+ })
203
+ const MultiSelect = defineComponent({
204
+ name: 'MMultiSelect',
205
+ inheritAttrs: false,
206
+ props: multiSelectProps,
207
+ emits: { 'update:modelValue': (_values: ChoiceValue[]) => true },
208
+ setup(props, { attrs, emit }) {
209
+ useButtonAction()
210
+ const open = ref(false),
211
+ query = ref('')
212
+ const trigger = ref<unknown>()
213
+ let alive = true
214
+ onBeforeUnmount(() => {
215
+ alive = false
216
+ })
217
+ function restoreFocus() {
218
+ void nextTick(() => {
219
+ if (alive) ui.focusTrigger(trigger.value)
220
+ })
221
+ }
222
+ watch(
223
+ () => props.disabled || props.readonly,
224
+ (blocked) => {
225
+ if (blocked) open.value = false
226
+ },
227
+ )
228
+ watch(open, (value) => {
229
+ if (!value && platform === 'native' && !props.disabled) restoreFocus()
230
+ })
231
+ function toggle(value: ChoiceValue) {
232
+ if (props.disabled || props.readonly) return
233
+ const next = toggleMultiSelection(props.options, props.modelValue, value, props.maxSelected)
234
+ if (next) emit('update:modelValue', next)
235
+ }
236
+ return () => {
237
+ validateMultiSelection(props.options, props.modelValue, props.maxSelected)
238
+ if (!props.label.trim()) throw new TypeError('MultiSelect requires a label.')
239
+ const selected = props.modelValue.map((value) =>
240
+ props.options.find((option) => option.value === value)!,
241
+ )
242
+ const filter = query.value.trim().toLocaleLowerCase()
243
+ const options = props.options.filter((option) =>
244
+ option.label.toLocaleLowerCase().includes(filter),
245
+ )
246
+ return h(
247
+ ui.Column,
248
+ mergeProps(attrs, {
249
+ gap: 'sm',
250
+ width: props.width,
251
+ grow: props.grow,
252
+ shrink: props.shrink,
253
+ accessibilityHidden: props.accessibilityHidden,
254
+ }),
255
+ () => [
256
+ h(ui.Text, { text: props.label, variant: 'caption', weight: '600' }),
257
+ h(ui.Button, {
258
+ ref: trigger,
259
+ id: props.id,
260
+ text: selected.length ? `${props.label} · ${selected.length}` : props.placeholder,
261
+ accessibilityLabel: `${props.label}: ${selected.map((option) => option.label).join(', ') || props.placeholder}`,
262
+ variant: 'secondary',
263
+ disabled: props.disabled || props.readonly,
264
+ onClick: () => {
265
+ ui.focusTrigger(trigger.value)
266
+ query.value = ''
267
+ open.value = true
268
+ },
269
+ }),
270
+ selected.length
271
+ ? h(ui.Row, { gap: 'sm', wrap: true }, () =>
272
+ selected.map((option) =>
273
+ h(ui.Chip, {
274
+ key: choiceKey(option.value),
275
+ label: option.label,
276
+ removable: true,
277
+ removeLabel: `${props.removeLabel}: ${option.label}`,
278
+ disabled: props.disabled || props.readonly || option.disabled,
279
+ onRemove: () => {
280
+ toggle(option.value)
281
+ restoreFocus()
282
+ },
283
+ }),
284
+ ),
285
+ )
286
+ : null,
287
+ props.error || props.helperText
288
+ ? h(ui.Text, {
289
+ text: props.error || props.helperText,
290
+ tone: props.error ? 'danger' : 'muted',
291
+ variant: 'caption',
292
+ })
293
+ : null,
294
+ h(
295
+ ui.Sheet,
296
+ {
297
+ open: open.value,
298
+ title: props.label,
299
+ closeLabel: props.closeLabel,
300
+ 'onUpdate:open': (value: boolean) => {
301
+ open.value = value
302
+ },
303
+ },
304
+ () => [
305
+ h(ui.Column, { gap: 'md' }, () => [
306
+ h(ui.Input, {
307
+ modelValue: query.value,
308
+ label: props.searchLabel,
309
+ type: 'search',
310
+ autocorrect: false,
311
+ 'onUpdate:modelValue': (value: string) => {
312
+ query.value = value
313
+ },
314
+ }),
315
+ ...options.map((option) =>
316
+ h(ui.Checkbox, {
317
+ key: choiceKey(option.value),
318
+ label: option.label,
319
+ helperText: option.helperText ?? '',
320
+ modelValue: props.modelValue.includes(option.value),
321
+ disabled:
322
+ props.disabled ||
323
+ props.readonly ||
324
+ option.disabled ||
325
+ (!props.modelValue.includes(option.value) &&
326
+ props.maxSelected !== undefined &&
327
+ props.modelValue.length >= props.maxSelected),
328
+ 'onUpdate:modelValue': () => toggle(option.value),
329
+ }),
330
+ ),
331
+ !options.length ? h(ui.Text, { text: props.emptyLabel, tone: 'muted' }) : null,
332
+ h(ui.Button, {
333
+ text: props.closeLabel,
334
+ onClick: () => {
335
+ open.value = false
336
+ },
337
+ }),
338
+ ]),
339
+ ],
340
+ ),
341
+ ],
342
+ )
343
+ }
344
+ },
345
+ })
346
+ return {
347
+ MNumberInput: NumberInput as typeof NumberInput & { new (): InputHandle },
348
+ MMultiSelect: MultiSelect,
349
+ }
350
+ }
@@ -8,7 +8,13 @@ type VueProperty<P extends Property> = { type: PropType<PropertyValue<P>> } & (P
8
8
  : unknown) &
9
9
  (P extends { required: true } ? { required: true } : unknown)
10
10
 
11
- const constructors = { string: String, number: Number, boolean: Boolean, object: Object }
11
+ const constructors = {
12
+ string: String,
13
+ number: Number,
14
+ boolean: Boolean,
15
+ object: Object,
16
+ function: Function,
17
+ }
12
18
 
13
19
  /** Vue owns coercion and warnings; portable metadata owns names, defaults and allowed values. */
14
20
  export function vueProperty<P extends Property>(definition: P): VueProperty<P> {
@@ -5,6 +5,7 @@ import {
5
5
  mergeProps,
6
6
  nextTick,
7
7
  onBeforeUnmount,
8
+ onMounted,
8
9
  ref,
9
10
  watch,
10
11
  type Component,
@@ -32,8 +33,9 @@ import {
32
33
  } from './date-props.js'
33
34
  import { useButtonAction } from './button-content.js'
34
35
 
35
- type EntryProps = Omit<ExtractPropTypes<typeof dateRangePickerProps>, 'modelValue'> & {
36
+ type EntryProps = Omit<ExtractPropTypes<typeof dateRangePickerProps>, 'modelValue' | 'draft'> & {
36
37
  modelValue: CivilDate | null | DateRange
38
+ draft?: string | DateRangeDraft
37
39
  name?: string
38
40
  }
39
41
  interface DatePrimitives {
@@ -46,6 +48,8 @@ interface DatePrimitives {
46
48
  /** Internal adapter boundary: capture a focusable opener and dismiss the native keyboard. */
47
49
  beforeOpen(opener: unknown): void
48
50
  afterClose(opener: unknown): void
51
+ deferActions?: boolean
52
+ openerAttrs?: Record<string, unknown>
49
53
  }
50
54
  interface EntryEvents {
51
55
  model(value: CivilDate | null | DateRange): void
@@ -64,6 +68,10 @@ export function createDatePickers(primitives: DatePrimitives) {
64
68
  const end = ref('')
65
69
  const touched = ref(false)
66
70
  const open = ref(false)
71
+ const ready = ref(!primitives.deferActions)
72
+ onMounted(() => {
73
+ ready.value = true
74
+ })
67
75
  const endpoint = ref<'start' | 'end'>('start')
68
76
  const activeDate = ref<CivilDate>('2000-01-01')
69
77
  const first = ref<InputHandle>()
@@ -90,13 +98,22 @@ export function createDatePickers(primitives: DatePrimitives) {
90
98
  return { start: (props.modelValue as CivilDate | null) ?? '', end: '' }
91
99
  }
92
100
  function restore() {
93
- const value = snapshot()
101
+ // A controlled draft owns the editor. The canonical model remains independently valid.
102
+ const canonical = snapshot()
103
+ const value =
104
+ props.draft === undefined
105
+ ? canonical
106
+ : range
107
+ ? (props.draft as DateRangeDraft)
108
+ : { start: props.draft as string, end: '' }
109
+ if (!value || typeof value.start !== 'string' || typeof value.end !== 'string')
110
+ throw new TypeError('A date draft must contain text for each endpoint')
94
111
  start.value = value.start
95
112
  end.value = value.end
96
113
  }
97
114
  restore()
98
115
  watch(
99
- () => props.modelValue,
116
+ () => [props.modelValue, props.draft],
100
117
  () => {
101
118
  revision++
102
119
  restore()
@@ -137,6 +154,11 @@ export function createDatePickers(primitives: DatePrimitives) {
137
154
  const current = ++revision
138
155
  const draft = { start: start.value, end: end.value }
139
156
  events.draft(range ? { ...draft } : draft.start)
157
+ if (props.draft !== undefined) {
158
+ void nextTick(() => {
159
+ if (alive && revision === current) restore()
160
+ })
161
+ }
140
162
  if (!validity.value.valid) return
141
163
  const previous = snapshot()
142
164
  if (previous.start === draft.start && previous.end === draft.end) return
@@ -157,7 +179,7 @@ export function createDatePickers(primitives: DatePrimitives) {
157
179
  })
158
180
  }
159
181
  function show(which: 'start' | 'end') {
160
- if (props.disabled || props.readonly || open.value) return
182
+ if (!ready.value || props.disabled || props.readonly || open.value) return
161
183
  endpoint.value = which
162
184
  const draft = which === 'end' ? end.value : start.value
163
185
  let target = isCivilDate(draft) ? draft : (props.min ?? civilDate(`${props.initialMonth}-01`))
@@ -249,11 +271,12 @@ export function createDatePickers(primitives: DatePrimitives) {
249
271
  },
250
272
  }),
251
273
  h(Button, {
274
+ ...primitives.openerAttrs,
252
275
  ref: which === 'start' ? firstOpener : secondOpener,
253
276
  icon: 'calendar-days',
254
277
  variant: 'secondary',
255
278
  accessibilityLabel: `${props.calendarLabel ?? translations.calendar}: ${label(which)}`,
256
- disabled: props.disabled || props.readonly,
279
+ disabled: !ready.value || props.disabled || props.readonly,
257
280
  onClick: () => show(which),
258
281
  }),
259
282
  ],
@@ -278,7 +301,11 @@ export function createDatePickers(primitives: DatePrimitives) {
278
301
  text: props.clearLabel ?? `${translations.clear}: ${props.label}`,
279
302
  variant: 'ghost',
280
303
  size: 'sm',
281
- disabled: props.disabled || props.readonly || (!start.value && !end.value),
304
+ disabled:
305
+ !ready.value ||
306
+ props.disabled ||
307
+ props.readonly ||
308
+ (!start.value && !end.value),
282
309
  onClick: () => {
283
310
  if (props.disabled || props.readonly) return
284
311
  start.value = ''
@@ -32,11 +32,14 @@ const common = {
32
32
  }
33
33
  export const datePickerProps = {
34
34
  ...common,
35
+ /** Optional controlled editor text, including incomplete or invalid dates. */
36
+ draft: { type: String, default: undefined },
35
37
  modelValue: { type: String as PropType<CivilDate | null>, default: null },
36
38
  name: { type: String, default: undefined },
37
39
  }
38
40
  export const dateRangePickerProps = {
39
41
  ...common,
42
+ draft: { type: Object as PropType<DateRangeDraft>, default: undefined },
40
43
  modelValue: {
41
44
  type: Object as PropType<DateRange>,
42
45
  default: (): DateRange => ({ start: null, end: null }),
@@ -8,7 +8,7 @@ import type { DialogCloseReason } from '../dialog.js'
8
8
  import type { SheetCloseReason } from '../sheet.js'
9
9
  import type { InputHandle } from '../input.js'
10
10
 
11
- type Action = { onClick?: () => void }
11
+ type Action = { onClick?: () => void; onError?: (error: unknown) => void }
12
12
  type Model = { 'onUpdate:modelValue'?: (value: number) => void }
13
13
  type InputEvents = {
14
14
  onAction?: () => void
@@ -61,6 +61,22 @@ declare module '@vue/runtime-core' {
61
61
  },
62
62
  InputHandle
63
63
  >
64
+ MNumberInput: DefineComponent<
65
+ ComponentProps['MNumberInput'] & {
66
+ 'onUpdate:modelValue'?: (value: number | null) => void
67
+ 'onUpdate:draft'?: (value: string) => void
68
+ onValidityChange?: (value: import('../number-input.js').NumberDraft) => void
69
+ onFocus?: () => void
70
+ onBlur?: () => void
71
+ },
72
+ InputHandle
73
+ >
74
+ MMultiSelect: DefineComponent<
75
+ ComponentProps['MMultiSelect'] & { 'onUpdate:modelValue'?: (value: ChoiceValue[]) => void }
76
+ >
77
+ MImage: DefineComponent<
78
+ ComponentProps['MImage'] & { onLoad?: (src: string) => void; onError?: (src: string) => void }
79
+ >
64
80
  MFilePicker: DefineComponent<ComponentProps['MFilePicker'], InputHandle>
65
81
  MFormGroup: DefineComponent<ComponentProps['MFormGroup']>
66
82
  MFormErrors: DefineComponent<
@@ -75,6 +91,10 @@ declare module '@vue/runtime-core' {
75
91
  MScreen: DefineComponent<ComponentProps['MScreen']>
76
92
  MRow: DefineComponent<ComponentProps['MRow']>
77
93
  MColumn: DefineComponent<ComponentProps['MColumn']>
94
+ MStack: DefineComponent<ComponentProps['MStack']>
95
+ MLink: DefineComponent<
96
+ ComponentProps['MLink'] & Action & { onError?: (error: unknown) => void }
97
+ >
78
98
  MBox: DefineComponent<ComponentProps['MBox']>
79
99
  MCard: DefineComponent<ComponentProps['MCard'] & Action>
80
100
  MText: DefineComponent<ComponentProps['MText']>
package/src/vue/index.ts CHANGED
@@ -6,7 +6,7 @@ export type {
6
6
  AppearanceSource,
7
7
  ThemeContextOptions,
8
8
  } from './theme.js'
9
- export { layoutDirection, useDefaultShrink } from './layout-context.js'
9
+ export { layoutDirection, useDefaultShrink, useLayoutShrink } from './layout-context.js'
10
10
  export { textContent } from './text-content.js'
11
11
  export type {} from './global-components.js'
12
12
  export type { InputPlatformAttributes } from './global-components.js'
@@ -16,6 +16,9 @@ export {
16
16
  spacingProp,
17
17
  rowProps,
18
18
  columnProps,
19
+ stackProps,
20
+ linkProps,
21
+ linkEmits,
19
22
  cardProps,
20
23
  buttonProps,
21
24
  textProps,
@@ -75,3 +78,8 @@ export * from './files.js'
75
78
  export * from './forms.js'
76
79
  export * from './workflow-props.js'
77
80
  export * from './workflows.js'
81
+ export { useRevealState } from './reveal-state.js'
82
+ export type { RevealHost } from './reveal-state.js'
83
+
84
+ export * from './configurator-props.js'
85
+ export * from './configurator.js'
@@ -1,8 +1,15 @@
1
- import { inject, type InjectionKey } from '@vue/runtime-core'
1
+ import { computed, inject, unref, type InjectionKey, type Ref } from '@vue/runtime-core'
2
2
 
3
- export const layoutDirection: InjectionKey<'row' | 'column'> = Symbol('mavis.layout')
3
+ export const layoutDirection: InjectionKey<'row' | 'column' | Readonly<Ref<'row' | 'column'>>> =
4
+ Symbol('mavis.layout')
4
5
 
5
6
  /** Rows may wrap text to fit their width; columns preserve the natural height of content. */
6
7
  export function useDefaultShrink(): number {
7
- return inject(layoutDirection, 'column') === 'row' ? 1 : 0
8
+ return unref(inject(layoutDirection, 'column')) === 'row' ? 1 : 0
9
+ }
10
+
11
+ /** A responsive parent changes direction without replacing its children. */
12
+ export function useLayoutShrink() {
13
+ const direction = inject(layoutDirection, 'column')
14
+ return computed(() => (unref(direction) === 'row' ? 1 : 0))
8
15
  }