@getcortexlabs/mavis-core 0.1.0-alpha.4 → 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 (117) hide show
  1. package/README.md +2 -2
  2. package/dist/capabilities.d.ts +119 -0
  3. package/dist/capabilities.d.ts.map +1 -0
  4. package/dist/capabilities.js +142 -0
  5. package/dist/capabilities.js.map +1 -0
  6. package/dist/combobox.d.ts +42 -0
  7. package/dist/combobox.d.ts.map +1 -0
  8. package/dist/combobox.js +159 -0
  9. package/dist/combobox.js.map +1 -0
  10. package/dist/contracts.d.ts +1201 -0
  11. package/dist/contracts.d.ts.map +1 -0
  12. package/dist/contracts.js +242 -0
  13. package/dist/contracts.js.map +1 -0
  14. package/dist/date.d.ts +96 -0
  15. package/dist/date.d.ts.map +1 -0
  16. package/dist/date.js +235 -0
  17. package/dist/date.js.map +1 -0
  18. package/dist/experimental-regions.d.ts +142 -0
  19. package/dist/experimental-regions.d.ts.map +1 -0
  20. package/dist/experimental-regions.js +315 -0
  21. package/dist/experimental-regions.js.map +1 -0
  22. package/dist/experimental.d.ts +13 -1
  23. package/dist/experimental.d.ts.map +1 -1
  24. package/dist/experimental.js +153 -23
  25. package/dist/experimental.js.map +1 -1
  26. package/dist/files.d.ts +87 -0
  27. package/dist/files.d.ts.map +1 -0
  28. package/dist/files.js +328 -0
  29. package/dist/files.js.map +1 -0
  30. package/dist/form.d.ts +39 -0
  31. package/dist/form.d.ts.map +1 -0
  32. package/dist/form.js +170 -0
  33. package/dist/form.js.map +1 -0
  34. package/dist/index.d.ts +9 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +7 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/navigation.d.ts +22 -0
  39. package/dist/navigation.d.ts.map +1 -0
  40. package/dist/navigation.js +54 -0
  41. package/dist/navigation.js.map +1 -0
  42. package/dist/vue/combobox.d.ts +155 -0
  43. package/dist/vue/combobox.d.ts.map +1 -0
  44. package/dist/vue/combobox.js +195 -0
  45. package/dist/vue/combobox.js.map +1 -0
  46. package/dist/vue/component-props.d.ts +1989 -0
  47. package/dist/vue/component-props.d.ts.map +1 -0
  48. package/dist/vue/component-props.js +18 -0
  49. package/dist/vue/component-props.js.map +1 -0
  50. package/dist/vue/contracts.d.ts +18 -0
  51. package/dist/vue/contracts.d.ts.map +1 -0
  52. package/dist/vue/contracts.js +18 -0
  53. package/dist/vue/contracts.js.map +1 -0
  54. package/dist/vue/date-calendar.d.ts +64 -0
  55. package/dist/vue/date-calendar.d.ts.map +1 -0
  56. package/dist/vue/date-calendar.js +65 -0
  57. package/dist/vue/date-calendar.js.map +1 -0
  58. package/dist/vue/date-picker.d.ts +927 -0
  59. package/dist/vue/date-picker.d.ts.map +1 -0
  60. package/dist/vue/date-picker.js +319 -0
  61. package/dist/vue/date-picker.js.map +1 -0
  62. package/dist/vue/date-props.d.ts +254 -0
  63. package/dist/vue/date-props.d.ts.map +1 -0
  64. package/dist/vue/date-props.js +74 -0
  65. package/dist/vue/date-props.js.map +1 -0
  66. package/dist/vue/files.d.ts +53 -0
  67. package/dist/vue/files.d.ts.map +1 -0
  68. package/dist/vue/files.js +40 -0
  69. package/dist/vue/files.js.map +1 -0
  70. package/dist/vue/forms.d.ts +4 -0
  71. package/dist/vue/forms.d.ts.map +1 -0
  72. package/dist/vue/forms.js +15 -0
  73. package/dist/vue/forms.js.map +1 -0
  74. package/dist/vue/global-components.d.ts +35 -2
  75. package/dist/vue/global-components.d.ts.map +1 -1
  76. package/dist/vue/index.d.ts +12 -2
  77. package/dist/vue/index.d.ts.map +1 -1
  78. package/dist/vue/index.js +10 -1
  79. package/dist/vue/index.js.map +1 -1
  80. package/dist/vue/inline-content.d.ts +3 -1
  81. package/dist/vue/inline-content.d.ts.map +1 -1
  82. package/dist/vue/props.d.ts +1026 -495
  83. package/dist/vue/props.d.ts.map +1 -1
  84. package/dist/vue/props.js +17 -118
  85. package/dist/vue/props.js.map +1 -1
  86. package/dist/vue/workflow-props.d.ts +110 -0
  87. package/dist/vue/workflow-props.d.ts.map +1 -0
  88. package/dist/vue/workflow-props.js +37 -0
  89. package/dist/vue/workflow-props.js.map +1 -0
  90. package/dist/vue/workflows.d.ts +267 -0
  91. package/dist/vue/workflows.d.ts.map +1 -0
  92. package/dist/vue/workflows.js +200 -0
  93. package/dist/vue/workflows.js.map +1 -0
  94. package/package.json +1 -1
  95. package/src/capabilities.ts +145 -0
  96. package/src/combobox.ts +198 -0
  97. package/src/contracts.ts +295 -0
  98. package/src/date.ts +280 -0
  99. package/src/experimental-regions.ts +463 -0
  100. package/src/experimental.ts +158 -16
  101. package/src/files.ts +408 -0
  102. package/src/form.ts +190 -0
  103. package/src/index.ts +17 -0
  104. package/src/navigation.ts +61 -0
  105. package/src/vue/combobox.ts +238 -0
  106. package/src/vue/component-props.ts +24 -0
  107. package/src/vue/contracts.ts +33 -0
  108. package/src/vue/date-calendar.ts +76 -0
  109. package/src/vue/date-picker.ts +387 -0
  110. package/src/vue/date-props.ts +81 -0
  111. package/src/vue/files.ts +53 -0
  112. package/src/vue/forms.ts +20 -0
  113. package/src/vue/global-components.ts +44 -2
  114. package/src/vue/index.ts +13 -2
  115. package/src/vue/props.ts +34 -130
  116. package/src/vue/workflow-props.ts +41 -0
  117. package/src/vue/workflows.ts +257 -0
@@ -0,0 +1,387 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ mergeProps,
6
+ nextTick,
7
+ onBeforeUnmount,
8
+ ref,
9
+ watch,
10
+ type Component,
11
+ type ExtractPropTypes,
12
+ } from '@vue/runtime-core'
13
+ import {
14
+ civilDate,
15
+ dateLocales,
16
+ dateValidationMessage,
17
+ isCivilDate,
18
+ validateDateConstraints,
19
+ validateDateDraft,
20
+ validateDateRangeDraft,
21
+ type CivilDate,
22
+ type DateRange,
23
+ type DateRangeDraft,
24
+ type DateValidation,
25
+ } from '../date.js'
26
+ import type { InputHandle } from '../input.js'
27
+ import {
28
+ datePickerProps,
29
+ datePickerEmits,
30
+ dateRangePickerProps,
31
+ dateRangePickerEmits,
32
+ } from './date-props.js'
33
+ import { useButtonAction } from './button-content.js'
34
+
35
+ type EntryProps = Omit<ExtractPropTypes<typeof dateRangePickerProps>, 'modelValue'> & {
36
+ modelValue: CivilDate | null | DateRange
37
+ name?: string
38
+ }
39
+ interface DatePrimitives {
40
+ Input: Component
41
+ Button: Component
42
+ Column: Component
43
+ Row: Component
44
+ Sheet: Component
45
+ Calendar: Component
46
+ /** Internal adapter boundary: capture a focusable opener and dismiss the native keyboard. */
47
+ beforeOpen(opener: unknown): void
48
+ afterClose(opener: unknown): void
49
+ }
50
+ interface EntryEvents {
51
+ model(value: CivilDate | null | DateRange): void
52
+ draft(value: string | DateRangeDraft): void
53
+ validity(value: DateValidation): void
54
+ focus(): void
55
+ blur(): void
56
+ }
57
+
58
+ /** @internal One Vue editing contract, composed with each renderer's existing primitives. */
59
+ export function createDatePickers(primitives: DatePrimitives) {
60
+ const { Input, Button, Column, Row, Sheet, Calendar } = primitives
61
+ function useEntry(props: EntryProps, range: boolean, events: EntryEvents) {
62
+ useButtonAction()
63
+ const start = ref('')
64
+ const end = ref('')
65
+ const touched = ref(false)
66
+ const open = ref(false)
67
+ const endpoint = ref<'start' | 'end'>('start')
68
+ const activeDate = ref<CivilDate>('2000-01-01')
69
+ const first = ref<InputHandle>()
70
+ const second = ref<InputHandle>()
71
+ const firstOpener = ref<unknown>()
72
+ const secondOpener = ref<unknown>()
73
+ let alive = true
74
+ let revision = 0
75
+ let returnFocus = true
76
+ const words = computed(() => {
77
+ if (!Object.hasOwn(dateLocales, props.locale))
78
+ throw new RangeError('Date locale must be en-US or pt-BR')
79
+ return dateLocales[props.locale]
80
+ })
81
+ function snapshot(): DateRangeDraft {
82
+ if (range) {
83
+ const value = props.modelValue as DateRange
84
+ if (!value || typeof value !== 'object')
85
+ throw new RangeError('A date range needs start and end endpoints')
86
+ for (const date of [value.start, value.end]) if (date !== null) civilDate(date)
87
+ return { start: value.start ?? '', end: value.end ?? '' }
88
+ }
89
+ if (props.modelValue !== null) civilDate(props.modelValue as string)
90
+ return { start: (props.modelValue as CivilDate | null) ?? '', end: '' }
91
+ }
92
+ function restore() {
93
+ const value = snapshot()
94
+ start.value = value.start
95
+ end.value = value.end
96
+ }
97
+ restore()
98
+ watch(
99
+ () => props.modelValue,
100
+ () => {
101
+ revision++
102
+ restore()
103
+ },
104
+ { deep: true },
105
+ )
106
+ const validity = computed(() => {
107
+ validateDateConstraints(props)
108
+ return range
109
+ ? validateDateRangeDraft({ start: start.value, end: end.value }, props)
110
+ : validateDateDraft(start.value, props)
111
+ })
112
+ watch(validity, (value, previous) => {
113
+ if (JSON.stringify(value) !== JSON.stringify(previous)) events.validity(value)
114
+ })
115
+ watch(
116
+ () => props.disabled || props.readonly,
117
+ (blocked) => {
118
+ if (blocked) close(false)
119
+ },
120
+ )
121
+ onBeforeUnmount(() => {
122
+ alive = false
123
+ revision++
124
+ })
125
+ function close(restoreFocus = true) {
126
+ if (!open.value) return
127
+ open.value = false
128
+ returnFocus = restoreFocus
129
+ }
130
+ function edit(which: 'start' | 'end', value: string) {
131
+ if (props.disabled || props.readonly) return
132
+ if (which === 'start') start.value = value
133
+ else end.value = value
134
+ propose()
135
+ }
136
+ function propose() {
137
+ const current = ++revision
138
+ const draft = { start: start.value, end: end.value }
139
+ events.draft(range ? { ...draft } : draft.start)
140
+ if (!validity.value.valid) return
141
+ const previous = snapshot()
142
+ if (previous.start === draft.start && previous.end === draft.end) return
143
+ events.model(
144
+ range
145
+ ? {
146
+ start: draft.start ? civilDate(draft.start) : null,
147
+ end: draft.end ? civilDate(draft.end) : null,
148
+ }
149
+ : draft.start
150
+ ? civilDate(draft.start)
151
+ : null,
152
+ )
153
+ // A model proposal is controlled. Invalid/incomplete drafts remain local; a rejected
154
+ // valid proposal returns to the parent's value without manufacturing another edit.
155
+ void nextTick(() => {
156
+ if (alive && revision === current) restore()
157
+ })
158
+ }
159
+ function show(which: 'start' | 'end') {
160
+ if (props.disabled || props.readonly || open.value) return
161
+ endpoint.value = which
162
+ const draft = which === 'end' ? end.value : start.value
163
+ let target = isCivilDate(draft) ? draft : (props.min ?? civilDate(`${props.initialMonth}-01`))
164
+ if (props.min && target < props.min) target = props.min
165
+ if (props.max && target > props.max) target = props.max
166
+ activeDate.value = target
167
+ primitives.beforeOpen(which === 'end' ? secondOpener.value : firstOpener.value)
168
+ open.value = true
169
+ }
170
+ const handle: InputHandle = {
171
+ focus: () => {
172
+ if (!props.disabled) first.value?.focus()
173
+ },
174
+ blur: () => {
175
+ first.value?.blur()
176
+ second.value?.blur()
177
+ },
178
+ }
179
+ function render(attrs: Record<string, unknown>) {
180
+ if (!props.label.trim()) throw new RangeError('A date picker needs a visible label')
181
+ for (const name of [
182
+ 'calendarLabel',
183
+ 'clearLabel',
184
+ 'closeLabel',
185
+ 'startLabel',
186
+ 'endLabel',
187
+ ] as const) {
188
+ if (props[name] !== undefined && !props[name]!.trim())
189
+ throw new RangeError(`${name} must not be blank`)
190
+ }
191
+ civilDate(`${props.initialMonth}-01`)
192
+ if (
193
+ props.firstDayOfWeek !== undefined &&
194
+ (!Number.isInteger(props.firstDayOfWeek) ||
195
+ props.firstDayOfWeek < 0 ||
196
+ props.firstDayOfWeek > 6)
197
+ )
198
+ throw new RangeError('firstDayOfWeek must be an integer from 0 to 6')
199
+ const translations = words.value
200
+ const label = (which: 'start' | 'end') =>
201
+ range
202
+ ? `${props.label} · ${which === 'start' ? (props.startLabel ?? translations.start) : (props.endLabel ?? translations.end)}`
203
+ : props.label
204
+ const startValidation = validateDateDraft(start.value, props)
205
+ const endValidation = validateDateDraft(end.value, props)
206
+ const startError =
207
+ touched.value || start.value.length >= 10
208
+ ? dateValidationMessage(startValidation, props.locale)
209
+ : ''
210
+ const endError =
211
+ touched.value || end.value.length >= 10
212
+ ? dateValidationMessage(endValidation, props.locale)
213
+ : ''
214
+ const rangeError =
215
+ startValidation.valid && endValidation.valid
216
+ ? dateValidationMessage(validity.value, props.locale)
217
+ : ''
218
+ const field = (which: 'start' | 'end') =>
219
+ h(
220
+ Row,
221
+ { gap: 'sm', align: 'end' },
222
+ {
223
+ default: () => [
224
+ h(Input, {
225
+ ref: which === 'start' ? first : second,
226
+ id: props.id ? `${props.id}${range ? `-${which}` : ''}` : undefined,
227
+ grow: 1,
228
+ shrink: 1,
229
+ label: label(which),
230
+ modelValue: which === 'start' ? start.value : end.value,
231
+ name: range ? (which === 'start' ? props.startName : props.endName) : props.name,
232
+ type: 'text',
233
+ placeholder: translations.format,
234
+ autocapitalize: 'none',
235
+ autocorrect: false,
236
+ disabled: props.disabled,
237
+ readonly: props.readonly,
238
+ helperText: !range || which === 'end' ? props.helperText : '',
239
+ error: !range
240
+ ? props.error || startError
241
+ : which === 'start'
242
+ ? startError
243
+ : props.error || endError || rangeError,
244
+ 'onUpdate:modelValue': (value: string) => edit(which, value),
245
+ onFocus: events.focus,
246
+ onBlur: () => {
247
+ touched.value = true
248
+ events.blur()
249
+ },
250
+ }),
251
+ h(Button, {
252
+ ref: which === 'start' ? firstOpener : secondOpener,
253
+ icon: 'calendar-days',
254
+ variant: 'secondary',
255
+ accessibilityLabel: `${props.calendarLabel ?? translations.calendar}: ${label(which)}`,
256
+ disabled: props.disabled || props.readonly,
257
+ onClick: () => show(which),
258
+ }),
259
+ ],
260
+ },
261
+ )
262
+ return h(
263
+ Column,
264
+ mergeProps(attrs, {
265
+ gap: 'sm',
266
+ width: props.width,
267
+ grow: props.grow,
268
+ shrink: props.shrink,
269
+ accessibilityHidden: props.accessibilityHidden,
270
+ onUnloaded: () => close(false),
271
+ }),
272
+ {
273
+ default: () => [
274
+ field('start'),
275
+ range ? field('end') : null,
276
+ props.clearable
277
+ ? h(Button, {
278
+ text: props.clearLabel ?? `${translations.clear}: ${props.label}`,
279
+ variant: 'ghost',
280
+ size: 'sm',
281
+ disabled: props.disabled || props.readonly || (!start.value && !end.value),
282
+ onClick: () => {
283
+ if (props.disabled || props.readonly) return
284
+ start.value = ''
285
+ end.value = ''
286
+ touched.value = false
287
+ propose()
288
+ },
289
+ })
290
+ : null,
291
+ h(
292
+ Sheet,
293
+ {
294
+ open: open.value,
295
+ title: label(endpoint.value),
296
+ closeLabel: props.closeLabel ?? translations.close,
297
+ 'onUpdate:open': (value: boolean) => {
298
+ if (!value) close()
299
+ },
300
+ },
301
+ {
302
+ default: () =>
303
+ h(Calendar, {
304
+ activeDate: activeDate.value,
305
+ onVnodeUnmounted: () => {
306
+ if (alive && returnFocus && !props.disabled && !open.value)
307
+ primitives.afterClose(
308
+ endpoint.value === 'end' ? secondOpener.value : firstOpener.value,
309
+ )
310
+ },
311
+ selected: isCivilDate(endpoint.value === 'end' ? end.value : start.value)
312
+ ? endpoint.value === 'end'
313
+ ? end.value
314
+ : start.value
315
+ : null,
316
+ rangeStart: range && isCivilDate(start.value) ? start.value : null,
317
+ rangeEnd: range && isCivilDate(end.value) ? end.value : null,
318
+ min: props.min,
319
+ max: props.max,
320
+ unavailableDates: props.unavailableDates,
321
+ locale: props.locale,
322
+ firstDayOfWeek: props.firstDayOfWeek,
323
+ 'onUpdate:activeDate': (value: CivilDate) => {
324
+ activeDate.value = value
325
+ },
326
+ onSelect: (value: CivilDate) => {
327
+ if (
328
+ !open.value ||
329
+ props.disabled ||
330
+ props.readonly ||
331
+ !validateDateDraft(value, props).valid
332
+ )
333
+ return
334
+ touched.value = true
335
+ edit(endpoint.value, value)
336
+ close()
337
+ },
338
+ }),
339
+ },
340
+ ),
341
+ ],
342
+ },
343
+ )
344
+ }
345
+ return { handle, render }
346
+ }
347
+ const Picker = defineComponent({
348
+ name: 'MDatePicker',
349
+ inheritAttrs: false,
350
+ props: datePickerProps,
351
+ emits: datePickerEmits,
352
+ setup(props, { attrs, emit, expose }) {
353
+ const entry = useEntry(props as EntryProps, false, {
354
+ model: (value) => emit('update:modelValue', value as CivilDate | null),
355
+ draft: (value) => emit('update:draft', value as string),
356
+ validity: (value) => emit('validityChange', value),
357
+ focus: () => emit('focus'),
358
+ blur: () => emit('blur'),
359
+ })
360
+ expose(entry.handle)
361
+ return () => entry.render(attrs)
362
+ },
363
+ })
364
+ const RangePicker = defineComponent({
365
+ name: 'MDateRangePicker',
366
+ inheritAttrs: false,
367
+ props: dateRangePickerProps,
368
+ emits: dateRangePickerEmits,
369
+ setup(props, { attrs, emit, expose }) {
370
+ const entry = useEntry(props, true, {
371
+ model: (value) => emit('update:modelValue', value as DateRange),
372
+ draft: (value) => emit('update:draft', value as DateRangeDraft),
373
+ validity: (value) => emit('validityChange', value),
374
+ focus: () => emit('focus'),
375
+ blur: () => emit('blur'),
376
+ })
377
+ expose(entry.handle)
378
+ return () => entry.render(attrs)
379
+ },
380
+ })
381
+ return {
382
+ MDatePicker: Picker as typeof Picker & { new (): InstanceType<typeof Picker> & InputHandle },
383
+ MDateRangePicker: RangePicker as typeof RangePicker & {
384
+ new (): InstanceType<typeof RangePicker> & InputHandle
385
+ },
386
+ }
387
+ }
@@ -0,0 +1,81 @@
1
+ import type { ExtractPublicPropTypes, PropType } from '@vue/runtime-core'
2
+ import type { CivilDate, DateLocale, DateRange, DateRangeDraft, DateValidation } from '../date.js'
3
+ import { isCivilDate } from '../date.js'
4
+ import { dimensionProperty } from '../contracts.js'
5
+ import { vueProperty } from './contracts.js'
6
+ import { flexProps, viewProps } from './props.js'
7
+
8
+ const dateOptions = {
9
+ min: { type: String as PropType<CivilDate>, default: undefined },
10
+ max: { type: String as PropType<CivilDate>, default: undefined },
11
+ unavailableDates: { type: Array as PropType<readonly CivilDate[]>, default: () => [] },
12
+ locale: { type: String as PropType<DateLocale>, default: 'en-US' as const },
13
+ firstDayOfWeek: { type: Number, default: undefined },
14
+ }
15
+ const common = {
16
+ id: viewProps.id,
17
+ accessibilityHidden: viewProps.accessibilityHidden,
18
+ ...flexProps,
19
+ width: vueProperty(dimensionProperty),
20
+ ...dateOptions,
21
+ label: { type: String, required: true as const },
22
+ helperText: { type: String, default: '' },
23
+ error: { type: String, default: '' },
24
+ disabled: Boolean,
25
+ readonly: Boolean,
26
+ clearable: { type: Boolean, default: true },
27
+ clearLabel: { type: String, default: undefined },
28
+ calendarLabel: { type: String, default: undefined },
29
+ closeLabel: { type: String, default: undefined },
30
+ /** Deterministic empty calendar snapshot; never reads the clock. */
31
+ initialMonth: { type: String, default: '2000-01' },
32
+ }
33
+ export const datePickerProps = {
34
+ ...common,
35
+ modelValue: { type: String as PropType<CivilDate | null>, default: null },
36
+ name: { type: String, default: undefined },
37
+ }
38
+ export const dateRangePickerProps = {
39
+ ...common,
40
+ modelValue: {
41
+ type: Object as PropType<DateRange>,
42
+ default: (): DateRange => ({ start: null, end: null }),
43
+ },
44
+ startLabel: { type: String, default: undefined },
45
+ endLabel: { type: String, default: undefined },
46
+ startName: { type: String, default: undefined },
47
+ endName: { type: String, default: undefined },
48
+ }
49
+ const editingEmits = {
50
+ validityChange: (value: DateValidation) => typeof value.valid === 'boolean',
51
+ focus: () => true,
52
+ blur: () => true,
53
+ }
54
+ export const datePickerEmits = {
55
+ ...editingEmits,
56
+ 'update:modelValue': (value: CivilDate | null) => value === null || isCivilDate(value),
57
+ 'update:draft': (value: string) => typeof value === 'string',
58
+ }
59
+ export const dateRangePickerEmits = {
60
+ ...editingEmits,
61
+ 'update:modelValue': (value: DateRange) =>
62
+ (value.start === null || isCivilDate(value.start)) &&
63
+ (value.end === null || isCivilDate(value.end)),
64
+ 'update:draft': (value: DateRangeDraft) =>
65
+ typeof value.start === 'string' && typeof value.end === 'string',
66
+ }
67
+ export type DatePickerProps = ExtractPublicPropTypes<typeof datePickerProps>
68
+ export type DateRangePickerProps = ExtractPublicPropTypes<typeof dateRangePickerProps>
69
+
70
+ /** @internal Shared themed calendar presentation contract. */
71
+ export const dateCalendarProps = {
72
+ ...dateOptions,
73
+ activeDate: { type: String as PropType<CivilDate>, required: true as const },
74
+ selected: { type: String as PropType<CivilDate | null>, default: null },
75
+ rangeStart: { type: String as PropType<CivilDate | null>, default: null },
76
+ rangeEnd: { type: String as PropType<CivilDate | null>, default: null },
77
+ }
78
+ export const dateCalendarEmits = {
79
+ select: (value: CivilDate) => isCivilDate(value),
80
+ 'update:activeDate': (value: CivilDate) => isCivilDate(value),
81
+ }
@@ -0,0 +1,53 @@
1
+ import { markRaw, onBeforeUnmount, onDeactivated, type PropType } from '@vue/runtime-core'
2
+ import {
3
+ createFileSelection,
4
+ type FileSelectionController,
5
+ type FileSelectionOptions,
6
+ type FileItem,
7
+ type FileSelectionErrorCode,
8
+ } from '../files.js'
9
+
10
+ /** Own this in the component that owns the selected files, not in a module singleton. */
11
+ export function useFileSelection(options: FileSelectionOptions = {}) {
12
+ const selection = markRaw(createFileSelection(options))
13
+ onDeactivated(() => selection.pause())
14
+ onBeforeUnmount(() => selection.dispose())
15
+ return selection
16
+ }
17
+
18
+ export const filePickerProps = {
19
+ selection: { type: Object as PropType<FileSelectionController>, required: true as const },
20
+ label: { type: String, required: true as const },
21
+ disabled: Boolean,
22
+ chooseLabel: { type: String, default: 'Choose files' },
23
+ uploadLabel: { type: String, default: 'Upload' },
24
+ cancelLabel: { type: String, default: 'Cancel' },
25
+ retryLabel: { type: String, default: 'Retry' },
26
+ removeLabel: { type: String, default: 'Remove' },
27
+ emptyLabel: { type: String, default: 'No files selected' },
28
+ pendingLabel: { type: String, default: 'Working' },
29
+ statusLabels: {
30
+ type: Object as PropType<Partial<Record<FileItem['status'], string>>>,
31
+ default: () => ({}),
32
+ },
33
+ errorLabels: {
34
+ type: Object as PropType<Partial<Record<FileSelectionErrorCode, string>>>,
35
+ default: () => ({}),
36
+ },
37
+ }
38
+
39
+ export function fileStatusText(
40
+ item: FileItem,
41
+ labels: Partial<Record<FileItem['status'], string>>,
42
+ ) {
43
+ return (
44
+ labels[item.status] ??
45
+ {
46
+ selected: 'Ready',
47
+ uploading: 'Uploading',
48
+ uploaded: 'Uploaded',
49
+ failed: 'Failed',
50
+ cancelled: 'Cancelled',
51
+ }[item.status]
52
+ )
53
+ }
@@ -0,0 +1,20 @@
1
+ import { markRaw, onScopeDispose } from '@vue/runtime-core'
2
+ import { useCachedActivity } from './cached-activity.js'
3
+ import {
4
+ createFormController,
5
+ type FormController,
6
+ type FormError,
7
+ type FormField,
8
+ } from '../form.js'
9
+
10
+ export function useFormController(initial: readonly FormError[] = []) {
11
+ const form = markRaw(createFormController(initial))
12
+ onScopeDispose(() => form.dispose())
13
+ return form
14
+ }
15
+ export function useFormField(form: FormController, field: FormField) {
16
+ const active = useCachedActivity()
17
+ const release = form.register({ ...field, target: () => (active.value ? field.target() : null) })
18
+ onScopeDispose(release)
19
+ return release
20
+ }
@@ -1,8 +1,9 @@
1
1
  import type { AccordionPanelProps } from '../accordion.js'
2
2
  import type { TabPanelProps } from '../tabs.js'
3
- import type { ChoiceValue } from '../choice.js'
3
+ import type { CivilDate, DateRange, DateRangeDraft, DateValidation } from '../date.js'
4
+ import type { ChoiceValue, ChoiceOption } from '../choice.js'
4
5
  import type { DefineComponent } from '@vue/runtime-core'
5
- import type { ComponentProps } from './props.js'
6
+ import type { ComponentProps } from './component-props.js'
6
7
  import type { DialogCloseReason } from '../dialog.js'
7
8
  import type { SheetCloseReason } from '../sheet.js'
8
9
  import type { InputHandle } from '../input.js'
@@ -30,6 +31,47 @@ declare module '@vue/runtime-core' {
30
31
  export interface GlobalComponents {
31
32
  MThemeProvider: typeof import('./theme-provider.js').MThemeProvider
32
33
  MSpan: typeof import('./inline-content.js').MSpan
34
+ MDatePicker: DefineComponent<
35
+ ComponentProps['MDatePicker'] & {
36
+ 'onUpdate:modelValue'?: (value: CivilDate | null) => void
37
+ 'onUpdate:draft'?: (value: string) => void
38
+ onValidityChange?: (value: DateValidation) => void
39
+ onFocus?: () => void
40
+ onBlur?: () => void
41
+ },
42
+ InputHandle
43
+ >
44
+ MDateRangePicker: DefineComponent<
45
+ ComponentProps['MDateRangePicker'] & {
46
+ 'onUpdate:modelValue'?: (value: DateRange) => void
47
+ 'onUpdate:draft'?: (value: DateRangeDraft) => void
48
+ onValidityChange?: (value: DateValidation) => void
49
+ onFocus?: () => void
50
+ onBlur?: () => void
51
+ },
52
+ InputHandle
53
+ >
54
+ MCombobox: DefineComponent<
55
+ ComponentProps['MCombobox'] & {
56
+ 'onUpdate:modelValue'?: (value: ChoiceValue | null) => void
57
+ 'onUpdate:query'?: (value: string) => void
58
+ onSelect?: (value: ChoiceOption | null) => void
59
+ onFocus?: () => void
60
+ onBlur?: () => void
61
+ },
62
+ InputHandle
63
+ >
64
+ MFilePicker: DefineComponent<ComponentProps['MFilePicker'], InputHandle>
65
+ MFormGroup: DefineComponent<ComponentProps['MFormGroup']>
66
+ MFormErrors: DefineComponent<
67
+ ComponentProps['MFormErrors'] & { onFocus?: (field: string, focused: boolean) => void }
68
+ >
69
+ MSteps: DefineComponent<
70
+ ComponentProps['MSteps'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
71
+ >
72
+ MPagination: DefineComponent<
73
+ ComponentProps['MPagination'] & { 'onUpdate:modelValue'?: (value: number) => void }
74
+ >
33
75
  MScreen: DefineComponent<ComponentProps['MScreen']>
34
76
  MRow: DefineComponent<ComponentProps['MRow']>
35
77
  MColumn: DefineComponent<ComponentProps['MColumn']>
package/src/vue/index.ts CHANGED
@@ -12,6 +12,7 @@ export type {} from './global-components.js'
12
12
  export type { InputPlatformAttributes } from './global-components.js'
13
13
  export {
14
14
  boxProps,
15
+ motionBoxProps,
15
16
  spacingProp,
16
17
  rowProps,
17
18
  columnProps,
@@ -34,12 +35,11 @@ export {
34
35
  revealProps,
35
36
  sheetProps,
36
37
  sheetEmits,
37
- componentProps,
38
38
  viewAttrs,
39
39
  actionEmits,
40
40
  sliderEmits,
41
41
  } from './props.js'
42
- export type { BoxProps, ComponentProps, Align, Justify } from './props.js'
42
+ export type { BoxProps, Align, Justify } from './props.js'
43
43
 
44
44
  export { useToast, useToastHost, installAppToast, useAppToastHost } from './toast.js'
45
45
  export { toastProps } from './props.js'
@@ -64,3 +64,14 @@ export { spanProps } from './props.js'
64
64
 
65
65
  export { useCachedActivity } from './cached-activity.js'
66
66
  export { buttonContent, ButtonAdornment, useButtonAction } from './button-content.js'
67
+
68
+ export { componentProps } from './component-props.js'
69
+ export type { ComponentProps } from './component-props.js'
70
+ export * from './date-props.js'
71
+ export * from './date-picker.js'
72
+ export * from './date-calendar.js'
73
+ export * from './combobox.js'
74
+ export * from './files.js'
75
+ export * from './forms.js'
76
+ export * from './workflow-props.js'
77
+ export * from './workflows.js'