@getcortexlabs/mavis-core 0.1.0-alpha.7 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capabilities.d.ts +19 -6
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +17 -3
- package/dist/capabilities.js.map +1 -1
- package/dist/contracts.d.ts +42 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +17 -0
- package/dist/contracts.js.map +1 -1
- package/dist/date-input.d.ts +10 -0
- package/dist/date-input.d.ts.map +1 -0
- package/dist/date-input.js +58 -0
- package/dist/date-input.js.map +1 -0
- package/dist/date-time.d.ts +19 -0
- package/dist/date-time.d.ts.map +1 -0
- package/dist/date-time.js +27 -0
- package/dist/date-time.js.map +1 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +1 -0
- package/dist/dialog.js.map +1 -1
- package/dist/experimental-collections.d.ts +82 -0
- package/dist/experimental-collections.d.ts.map +1 -0
- package/dist/experimental-collections.js +8 -0
- package/dist/experimental-collections.js.map +1 -0
- package/dist/experimental-effects.d.ts +107 -0
- package/dist/experimental-effects.d.ts.map +1 -0
- package/dist/experimental-effects.js +24 -0
- package/dist/experimental-effects.js.map +1 -0
- package/dist/experimental-platforms.d.ts +94 -0
- package/dist/experimental-platforms.d.ts.map +1 -0
- package/dist/experimental-platforms.js +2 -0
- package/dist/experimental-platforms.js.map +1 -0
- package/dist/experimental-playback.d.ts +2 -2
- package/dist/experimental-playback.d.ts.map +1 -1
- package/dist/experimental-regions.d.ts +17 -2
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +91 -0
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental-sensors.d.ts +42 -0
- package/dist/experimental-sensors.d.ts.map +1 -0
- package/dist/experimental-sensors.js +2 -0
- package/dist/experimental-sensors.js.map +1 -0
- package/dist/experimental-surfaces.d.ts +127 -0
- package/dist/experimental-surfaces.d.ts.map +1 -0
- package/dist/experimental-surfaces.js +2 -0
- package/dist/experimental-surfaces.js.map +1 -0
- package/dist/experimental.d.ts +28 -4
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +266 -1
- package/dist/experimental.js.map +1 -1
- package/dist/grid.d.ts +3 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +16 -0
- package/dist/grid.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js.map +1 -1
- package/dist/link.d.ts +22 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +41 -0
- package/dist/link.js.map +1 -1
- package/dist/sheet.d.ts +7 -0
- package/dist/sheet.d.ts.map +1 -1
- package/dist/vue/component-props.d.ts +167 -20
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/configurator-props.d.ts +26 -0
- package/dist/vue/configurator-props.d.ts.map +1 -1
- package/dist/vue/configurator-props.js +7 -0
- package/dist/vue/configurator-props.js.map +1 -1
- package/dist/vue/configurator.d.ts +1 -1
- package/dist/vue/date-picker.d.ts +40 -5
- package/dist/vue/date-picker.d.ts.map +1 -1
- package/dist/vue/date-picker.js +67 -74
- package/dist/vue/date-picker.js.map +1 -1
- package/dist/vue/date-props.d.ts +9 -0
- package/dist/vue/date-props.d.ts.map +1 -1
- package/dist/vue/date-props.js +1 -0
- package/dist/vue/date-props.js.map +1 -1
- package/dist/vue/global-components.d.ts +3 -2
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +3 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +3 -1
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/loading-effect.d.ts +7 -0
- package/dist/vue/loading-effect.d.ts.map +1 -0
- package/dist/vue/loading-effect.js +32 -0
- package/dist/vue/loading-effect.js.map +1 -0
- package/dist/vue/navigation.d.ts +7 -0
- package/dist/vue/navigation.d.ts.map +1 -0
- package/dist/vue/navigation.js +15 -0
- package/dist/vue/navigation.js.map +1 -0
- package/dist/vue/props.d.ts +280 -43
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +19 -0
- package/dist/vue/props.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities.ts +17 -3
- package/src/contracts.ts +17 -0
- package/src/date-input.ts +87 -0
- package/src/date-time.ts +37 -0
- package/src/dialog.ts +3 -1
- package/src/experimental-collections.ts +87 -0
- package/src/experimental-effects.ts +146 -0
- package/src/experimental-platforms.ts +96 -0
- package/src/experimental-playback.ts +1 -1
- package/src/experimental-regions.ts +136 -2
- package/src/experimental-sensors.ts +50 -0
- package/src/experimental-surfaces.ts +124 -0
- package/src/experimental.ts +309 -8
- package/src/grid.ts +19 -0
- package/src/index.ts +6 -2
- package/src/input.ts +5 -0
- package/src/link.ts +61 -0
- package/src/sheet.ts +11 -0
- package/src/vue/configurator-props.ts +8 -0
- package/src/vue/date-picker.ts +81 -85
- package/src/vue/date-props.ts +2 -0
- package/src/vue/global-components.ts +3 -2
- package/src/vue/index.ts +3 -0
- package/src/vue/loading-effect.ts +44 -0
- package/src/vue/navigation.ts +16 -0
- package/src/vue/props.ts +21 -1
package/src/vue/date-picker.ts
CHANGED
|
@@ -15,15 +15,20 @@ import {
|
|
|
15
15
|
civilDate,
|
|
16
16
|
dateLocales,
|
|
17
17
|
dateValidationMessage,
|
|
18
|
-
isCivilDate,
|
|
19
18
|
validateDateConstraints,
|
|
20
19
|
validateDateDraft,
|
|
21
|
-
validateDateRangeDraft,
|
|
22
20
|
type CivilDate,
|
|
23
21
|
type DateRange,
|
|
24
22
|
type DateRangeDraft,
|
|
25
23
|
type DateValidation,
|
|
26
24
|
} from '../date.js'
|
|
25
|
+
import {
|
|
26
|
+
formatDateInput,
|
|
27
|
+
parseDateInput,
|
|
28
|
+
validateDateInput,
|
|
29
|
+
validateDateRangeInput,
|
|
30
|
+
dateInputPlaceholder,
|
|
31
|
+
} from '../date-input.js'
|
|
27
32
|
import type { InputHandle } from '../input.js'
|
|
28
33
|
import {
|
|
29
34
|
datePickerProps,
|
|
@@ -49,7 +54,6 @@ interface DatePrimitives {
|
|
|
49
54
|
beforeOpen(opener: unknown): void
|
|
50
55
|
afterClose(opener: unknown): void
|
|
51
56
|
deferActions?: boolean
|
|
52
|
-
openerAttrs?: Record<string, unknown>
|
|
53
57
|
}
|
|
54
58
|
interface EntryEvents {
|
|
55
59
|
model(value: CivilDate | null | DateRange): void
|
|
@@ -61,7 +65,7 @@ interface EntryEvents {
|
|
|
61
65
|
|
|
62
66
|
/** @internal One Vue editing contract, composed with each renderer's existing primitives. */
|
|
63
67
|
export function createDatePickers(primitives: DatePrimitives) {
|
|
64
|
-
const { Input, Button, Column,
|
|
68
|
+
const { Input, Button, Column, Sheet, Calendar } = primitives
|
|
65
69
|
function useEntry(props: EntryProps, range: boolean, events: EntryEvents) {
|
|
66
70
|
useButtonAction()
|
|
67
71
|
const start = ref('')
|
|
@@ -76,8 +80,6 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
76
80
|
const activeDate = ref<CivilDate>('2000-01-01')
|
|
77
81
|
const first = ref<InputHandle>()
|
|
78
82
|
const second = ref<InputHandle>()
|
|
79
|
-
const firstOpener = ref<unknown>()
|
|
80
|
-
const secondOpener = ref<unknown>()
|
|
81
83
|
let alive = true
|
|
82
84
|
let revision = 0
|
|
83
85
|
let returnFocus = true
|
|
@@ -86,16 +88,21 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
86
88
|
throw new RangeError('Date locale must be en-US or pt-BR')
|
|
87
89
|
return dateLocales[props.locale]
|
|
88
90
|
})
|
|
91
|
+
const parse = (value: string) => parseDateInput(value, props.dateFormat, props.locale)
|
|
92
|
+
const format = (value: CivilDate | null) =>
|
|
93
|
+
value ? formatDateInput(value, props.dateFormat, props.locale) : ''
|
|
94
|
+
const validate = (value: string) =>
|
|
95
|
+
validateDateInput(value, props, props.dateFormat, props.locale)
|
|
89
96
|
function snapshot(): DateRangeDraft {
|
|
90
97
|
if (range) {
|
|
91
98
|
const value = props.modelValue as DateRange
|
|
92
99
|
if (!value || typeof value !== 'object')
|
|
93
100
|
throw new RangeError('A date range needs start and end endpoints')
|
|
94
101
|
for (const date of [value.start, value.end]) if (date !== null) civilDate(date)
|
|
95
|
-
return { start: value.start
|
|
102
|
+
return { start: format(value.start), end: format(value.end) }
|
|
96
103
|
}
|
|
97
104
|
if (props.modelValue !== null) civilDate(props.modelValue as string)
|
|
98
|
-
return { start: (props.modelValue as CivilDate | null)
|
|
105
|
+
return { start: format(props.modelValue as CivilDate | null), end: '' }
|
|
99
106
|
}
|
|
100
107
|
function restore() {
|
|
101
108
|
// A controlled draft owns the editor. The canonical model remains independently valid.
|
|
@@ -120,11 +127,27 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
120
127
|
},
|
|
121
128
|
{ deep: true },
|
|
122
129
|
)
|
|
130
|
+
watch(
|
|
131
|
+
() => [props.dateFormat, props.locale] as const,
|
|
132
|
+
(_next, previous) => {
|
|
133
|
+
revision++
|
|
134
|
+
if (props.draft !== undefined) return
|
|
135
|
+
for (const draft of [start, end]) {
|
|
136
|
+
const parsed = parseDateInput(draft.value, previous[0], previous[1])
|
|
137
|
+
if (parsed) draft.value = format(parsed)
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
)
|
|
123
141
|
const validity = computed(() => {
|
|
124
142
|
validateDateConstraints(props)
|
|
125
143
|
return range
|
|
126
|
-
?
|
|
127
|
-
|
|
144
|
+
? validateDateRangeInput(
|
|
145
|
+
{ start: start.value, end: end.value },
|
|
146
|
+
props,
|
|
147
|
+
props.dateFormat,
|
|
148
|
+
props.locale,
|
|
149
|
+
)
|
|
150
|
+
: validate(start.value)
|
|
128
151
|
})
|
|
129
152
|
watch(validity, (value, previous) => {
|
|
130
153
|
if (JSON.stringify(value) !== JSON.stringify(previous)) events.validity(value)
|
|
@@ -165,12 +188,10 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
165
188
|
events.model(
|
|
166
189
|
range
|
|
167
190
|
? {
|
|
168
|
-
start:
|
|
169
|
-
end:
|
|
191
|
+
start: parse(draft.start),
|
|
192
|
+
end: parse(draft.end),
|
|
170
193
|
}
|
|
171
|
-
: draft.start
|
|
172
|
-
? civilDate(draft.start)
|
|
173
|
-
: null,
|
|
194
|
+
: parse(draft.start),
|
|
174
195
|
)
|
|
175
196
|
// A model proposal is controlled. Invalid/incomplete drafts remain local; a rejected
|
|
176
197
|
// valid proposal returns to the parent's value without manufacturing another edit.
|
|
@@ -182,11 +203,11 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
182
203
|
if (!ready.value || props.disabled || props.readonly || open.value) return
|
|
183
204
|
endpoint.value = which
|
|
184
205
|
const draft = which === 'end' ? end.value : start.value
|
|
185
|
-
let target =
|
|
206
|
+
let target = parse(draft) ?? props.min ?? civilDate(`${props.initialMonth}-01`)
|
|
186
207
|
if (props.min && target < props.min) target = props.min
|
|
187
208
|
if (props.max && target > props.max) target = props.max
|
|
188
209
|
activeDate.value = target
|
|
189
|
-
primitives.beforeOpen(which === 'end' ?
|
|
210
|
+
primitives.beforeOpen(which === 'end' ? second.value : first.value)
|
|
190
211
|
open.value = true
|
|
191
212
|
}
|
|
192
213
|
const handle: InputHandle = {
|
|
@@ -219,69 +240,50 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
219
240
|
)
|
|
220
241
|
throw new RangeError('firstDayOfWeek must be an integer from 0 to 6')
|
|
221
242
|
const translations = words.value
|
|
243
|
+
const placeholder = dateInputPlaceholder(props.dateFormat, props.locale)
|
|
244
|
+
const message = (value: DateValidation) =>
|
|
245
|
+
dateValidationMessage(value, props.locale).replace(translations.format, placeholder)
|
|
222
246
|
const label = (which: 'start' | 'end') =>
|
|
223
247
|
range
|
|
224
248
|
? `${props.label} · ${which === 'start' ? (props.startLabel ?? translations.start) : (props.endLabel ?? translations.end)}`
|
|
225
249
|
: props.label
|
|
226
|
-
const startValidation =
|
|
227
|
-
const endValidation =
|
|
228
|
-
const startError =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
: ''
|
|
232
|
-
const endError =
|
|
233
|
-
touched.value || end.value.length >= 10
|
|
234
|
-
? dateValidationMessage(endValidation, props.locale)
|
|
235
|
-
: ''
|
|
236
|
-
const rangeError =
|
|
237
|
-
startValidation.valid && endValidation.valid
|
|
238
|
-
? dateValidationMessage(validity.value, props.locale)
|
|
239
|
-
: ''
|
|
250
|
+
const startValidation = validate(start.value)
|
|
251
|
+
const endValidation = validate(end.value)
|
|
252
|
+
const startError = touched.value || start.value.length >= 10 ? message(startValidation) : ''
|
|
253
|
+
const endError = touched.value || end.value.length >= 10 ? message(endValidation) : ''
|
|
254
|
+
const rangeError = startValidation.valid && endValidation.valid ? message(validity.value) : ''
|
|
240
255
|
const field = (which: 'start' | 'end') =>
|
|
241
|
-
h(
|
|
242
|
-
|
|
243
|
-
{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
modelValue: which === 'start' ? start.value : end.value,
|
|
253
|
-
name: range ? (which === 'start' ? props.startName : props.endName) : props.name,
|
|
254
|
-
type: 'text',
|
|
255
|
-
placeholder: translations.format,
|
|
256
|
-
autocapitalize: 'none',
|
|
257
|
-
autocorrect: false,
|
|
258
|
-
disabled: props.disabled,
|
|
259
|
-
readonly: props.readonly,
|
|
260
|
-
helperText: !range || which === 'end' ? props.helperText : '',
|
|
261
|
-
error: !range
|
|
262
|
-
? props.error || startError
|
|
263
|
-
: which === 'start'
|
|
264
|
-
? startError
|
|
265
|
-
: props.error || endError || rangeError,
|
|
266
|
-
'onUpdate:modelValue': (value: string) => edit(which, value),
|
|
267
|
-
onFocus: events.focus,
|
|
268
|
-
onBlur: () => {
|
|
269
|
-
touched.value = true
|
|
270
|
-
events.blur()
|
|
271
|
-
},
|
|
272
|
-
}),
|
|
273
|
-
h(Button, {
|
|
274
|
-
...primitives.openerAttrs,
|
|
275
|
-
ref: which === 'start' ? firstOpener : secondOpener,
|
|
276
|
-
icon: 'calendar-days',
|
|
277
|
-
variant: 'secondary',
|
|
278
|
-
accessibilityLabel: `${props.calendarLabel ?? translations.calendar}: ${label(which)}`,
|
|
279
|
-
disabled: !ready.value || props.disabled || props.readonly,
|
|
280
|
-
onClick: () => show(which),
|
|
281
|
-
}),
|
|
282
|
-
],
|
|
256
|
+
h(Input, {
|
|
257
|
+
ref: which === 'start' ? first : second,
|
|
258
|
+
id: props.id ? `${props.id}${range ? `-${which}` : ''}` : undefined,
|
|
259
|
+
label: label(which),
|
|
260
|
+
modelValue: which === 'start' ? start.value : end.value,
|
|
261
|
+
name: range ? (which === 'start' ? props.startName : props.endName) : props.name,
|
|
262
|
+
type: 'text',
|
|
263
|
+
trailingAction: {
|
|
264
|
+
icon: 'calendar-days',
|
|
265
|
+
label: `${props.calendarLabel ?? translations.calendar}: ${label(which)}`,
|
|
266
|
+
disabled: !ready.value,
|
|
283
267
|
},
|
|
284
|
-
|
|
268
|
+
onAction: () => show(which),
|
|
269
|
+
placeholder,
|
|
270
|
+
autocapitalize: 'none',
|
|
271
|
+
autocorrect: false,
|
|
272
|
+
disabled: props.disabled,
|
|
273
|
+
readonly: props.readonly,
|
|
274
|
+
helperText: !range || which === 'end' ? props.helperText : '',
|
|
275
|
+
error: !range
|
|
276
|
+
? props.error || startError
|
|
277
|
+
: which === 'start'
|
|
278
|
+
? startError
|
|
279
|
+
: props.error || endError || rangeError,
|
|
280
|
+
'onUpdate:modelValue': (value: string) => edit(which, value),
|
|
281
|
+
onFocus: events.focus,
|
|
282
|
+
onBlur: () => {
|
|
283
|
+
touched.value = true
|
|
284
|
+
events.blur()
|
|
285
|
+
},
|
|
286
|
+
})
|
|
285
287
|
return h(
|
|
286
288
|
Column,
|
|
287
289
|
mergeProps(attrs, {
|
|
@@ -331,17 +333,11 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
331
333
|
activeDate: activeDate.value,
|
|
332
334
|
onVnodeUnmounted: () => {
|
|
333
335
|
if (alive && returnFocus && !props.disabled && !open.value)
|
|
334
|
-
primitives.afterClose(
|
|
335
|
-
endpoint.value === 'end' ? secondOpener.value : firstOpener.value,
|
|
336
|
-
)
|
|
336
|
+
primitives.afterClose(endpoint.value === 'end' ? second.value : first.value)
|
|
337
337
|
},
|
|
338
|
-
selected:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
: start.value
|
|
342
|
-
: null,
|
|
343
|
-
rangeStart: range && isCivilDate(start.value) ? start.value : null,
|
|
344
|
-
rangeEnd: range && isCivilDate(end.value) ? end.value : null,
|
|
338
|
+
selected: parse(endpoint.value === 'end' ? end.value : start.value),
|
|
339
|
+
rangeStart: range ? parse(start.value) : null,
|
|
340
|
+
rangeEnd: range ? parse(end.value) : null,
|
|
345
341
|
min: props.min,
|
|
346
342
|
max: props.max,
|
|
347
343
|
unavailableDates: props.unavailableDates,
|
|
@@ -359,7 +355,7 @@ export function createDatePickers(primitives: DatePrimitives) {
|
|
|
359
355
|
)
|
|
360
356
|
return
|
|
361
357
|
touched.value = true
|
|
362
|
-
edit(endpoint.value, value)
|
|
358
|
+
edit(endpoint.value, format(value))
|
|
363
359
|
close()
|
|
364
360
|
},
|
|
365
361
|
}),
|
package/src/vue/date-props.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtractPublicPropTypes, PropType } from '@vue/runtime-core'
|
|
2
2
|
import type { CivilDate, DateLocale, DateRange, DateRangeDraft, DateValidation } from '../date.js'
|
|
3
3
|
import { isCivilDate } from '../date.js'
|
|
4
|
+
import type { DateInputFormat } from '../date-input.js'
|
|
4
5
|
import { dimensionProperty } from '../contracts.js'
|
|
5
6
|
import { vueProperty } from './contracts.js'
|
|
6
7
|
import { flexProps, viewProps } from './props.js'
|
|
@@ -13,6 +14,7 @@ const dateOptions = {
|
|
|
13
14
|
firstDayOfWeek: { type: Number, default: undefined },
|
|
14
15
|
}
|
|
15
16
|
const common = {
|
|
17
|
+
dateFormat: { type: String as PropType<DateInputFormat>, default: 'iso' as const },
|
|
16
18
|
id: viewProps.id,
|
|
17
19
|
accessibilityHidden: viewProps.accessibilityHidden,
|
|
18
20
|
...flexProps,
|
|
@@ -6,7 +6,7 @@ import type { DefineComponent } from '@vue/runtime-core'
|
|
|
6
6
|
import type { ComponentProps } from './component-props.js'
|
|
7
7
|
import type { DialogCloseReason } from '../dialog.js'
|
|
8
8
|
import type { SheetCloseReason } from '../sheet.js'
|
|
9
|
-
import type { InputHandle } from '../input.js'
|
|
9
|
+
import type { InputHandle, InputActionHandle } from '../input.js'
|
|
10
10
|
|
|
11
11
|
type Action = { onClick?: () => void; onError?: (error: unknown) => void }
|
|
12
12
|
type Model = { 'onUpdate:modelValue'?: (value: number) => void }
|
|
@@ -92,6 +92,7 @@ declare module '@vue/runtime-core' {
|
|
|
92
92
|
MRow: DefineComponent<ComponentProps['MRow']>
|
|
93
93
|
MColumn: DefineComponent<ComponentProps['MColumn']>
|
|
94
94
|
MStack: DefineComponent<ComponentProps['MStack']>
|
|
95
|
+
MGrid: DefineComponent<ComponentProps['MGrid']>
|
|
95
96
|
MLink: DefineComponent<
|
|
96
97
|
ComponentProps['MLink'] & Action & { onError?: (error: unknown) => void }
|
|
97
98
|
>
|
|
@@ -118,7 +119,7 @@ declare module '@vue/runtime-core' {
|
|
|
118
119
|
>
|
|
119
120
|
MInput: DefineComponent<
|
|
120
121
|
ComponentProps['MInput'] & InputEvents & InputPlatformAttributes,
|
|
121
|
-
|
|
122
|
+
InputActionHandle
|
|
122
123
|
>
|
|
123
124
|
MSelect: DefineComponent<
|
|
124
125
|
ComponentProps['MSelect'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
|
package/src/vue/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export {
|
|
|
17
17
|
rowProps,
|
|
18
18
|
columnProps,
|
|
19
19
|
stackProps,
|
|
20
|
+
gridProps,
|
|
20
21
|
linkProps,
|
|
21
22
|
linkEmits,
|
|
22
23
|
cardProps,
|
|
@@ -83,3 +84,5 @@ export type { RevealHost } from './reveal-state.js'
|
|
|
83
84
|
|
|
84
85
|
export * from './configurator-props.js'
|
|
85
86
|
export * from './configurator.js'
|
|
87
|
+
export { useLoadingDecoration } from './loading-effect.js'
|
|
88
|
+
export { navigationKey, useMavisNavigation, useNavigationOptions } from './navigation.js'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { watch, onScopeDispose } from '@vue/runtime-core'
|
|
2
|
+
import { markRaw } from '@vue/reactivity'
|
|
3
|
+
import {
|
|
4
|
+
createMotionSurface,
|
|
5
|
+
type MotionLoadingEffect,
|
|
6
|
+
type MotionLoaderOptions,
|
|
7
|
+
} from '../experimental.js'
|
|
8
|
+
|
|
9
|
+
/** Internal decoration; the declared presentation and Jolt own its lifetime. */
|
|
10
|
+
export function useLoadingDecoration(
|
|
11
|
+
settings: () => MotionLoaderOptions & {
|
|
12
|
+
kind: 'shimmer' | 'dots' | 'bars' | 'ring'
|
|
13
|
+
animated: boolean
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
const surface = markRaw(createMotionSurface())
|
|
17
|
+
const off = surface.use((motion) => {
|
|
18
|
+
let resource: MotionLoadingEffect | undefined
|
|
19
|
+
const stop = watch(
|
|
20
|
+
settings,
|
|
21
|
+
(options) => {
|
|
22
|
+
resource?.dispose()
|
|
23
|
+
resource = undefined
|
|
24
|
+
if (!options.animated) return
|
|
25
|
+
resource =
|
|
26
|
+
options.kind === 'shimmer'
|
|
27
|
+
? motion.shimmer({ duration: options.duration })
|
|
28
|
+
: motion.loader({
|
|
29
|
+
style: options.kind,
|
|
30
|
+
size: options.size,
|
|
31
|
+
color: options.color,
|
|
32
|
+
duration: options.duration,
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
{ immediate: true },
|
|
36
|
+
)
|
|
37
|
+
return () => {
|
|
38
|
+
stop()
|
|
39
|
+
resource?.dispose()
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
onScopeDispose(off)
|
|
43
|
+
return surface
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from '@vue/runtime-core'
|
|
2
|
+
import { resolveNavigation, type MavisNavigation, type NavigationOptions } from '../link.js'
|
|
3
|
+
|
|
4
|
+
export const navigationKey: InjectionKey<MavisNavigation | undefined> = Symbol('mavis-navigation')
|
|
5
|
+
|
|
6
|
+
export function useMavisNavigation(): MavisNavigation {
|
|
7
|
+
const navigation = inject(navigationKey, undefined)
|
|
8
|
+
if (!navigation) throw new Error('Provide navigation when installing Mavis in this app.')
|
|
9
|
+
return navigation
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Renderer helper; read reactive component props at render/activation time. */
|
|
13
|
+
export function useNavigationOptions(options: NavigationOptions) {
|
|
14
|
+
const navigation = inject(navigationKey, undefined)
|
|
15
|
+
return () => resolveNavigation(options, navigation)
|
|
16
|
+
}
|
package/src/vue/props.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SheetReturnFocus } from '../sheet.js'
|
|
1
2
|
import {
|
|
2
3
|
viewContract,
|
|
3
4
|
flexContract,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
} from '../contracts.js'
|
|
17
18
|
import { vueProps, vueProperty } from './contracts.js'
|
|
18
19
|
export type { Align, Justify } from '../contracts.js'
|
|
19
|
-
import type { MotionSurface, MotionScrollSource } from '../experimental.js'
|
|
20
|
+
import type { MotionSurface, MotionScrollSource, MotionRegion } from '../experimental.js'
|
|
20
21
|
import type { AccordionItem } from '../accordion.js'
|
|
21
22
|
import type { SegmentedOption } from '../segmented.js'
|
|
22
23
|
import type { TabOption } from '../tabs.js'
|
|
@@ -166,9 +167,16 @@ export const skeletonProps = {
|
|
|
166
167
|
height: { ...dimensionProp, default: 16 },
|
|
167
168
|
radius: { ...radiusProp, default: 'sm' },
|
|
168
169
|
animated: { type: Boolean, default: true },
|
|
170
|
+
effect: choice(['pulse', 'shimmer'] as const, 'pulse'),
|
|
169
171
|
}
|
|
170
172
|
export const rowProps = vueProps(rowContract)
|
|
171
173
|
export const columnProps = vueProps(columnContract)
|
|
174
|
+
export const gridProps = {
|
|
175
|
+
...boxProps,
|
|
176
|
+
columns: { type: Number, default: undefined },
|
|
177
|
+
minColumnWidth: { type: Number, default: undefined },
|
|
178
|
+
gap: spacingProp,
|
|
179
|
+
}
|
|
172
180
|
export const stackProps = {
|
|
173
181
|
...columnProps,
|
|
174
182
|
direction: choice(['row', 'column'] as const, 'column'),
|
|
@@ -281,6 +289,8 @@ export const segmentedEmits = radioGroupEmits
|
|
|
281
289
|
export const dialogProps = {
|
|
282
290
|
id: viewProps.id,
|
|
283
291
|
open: Boolean,
|
|
292
|
+
/** Opt-in Web drag presentation. Native retains its existing in-page modal owner. */
|
|
293
|
+
interactive: Boolean,
|
|
284
294
|
title: { type: String, required: true as const },
|
|
285
295
|
description: { type: String, default: '' },
|
|
286
296
|
confirmLabel: { type: String, default: 'Continue' },
|
|
@@ -319,6 +329,9 @@ export const inputEmits = {
|
|
|
319
329
|
}
|
|
320
330
|
export const iconProps = {
|
|
321
331
|
id: viewProps.id,
|
|
332
|
+
motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
|
|
333
|
+
/** Optional native iOS SF Symbol artwork; name remains the portable fallback. */
|
|
334
|
+
systemName: { type: String, default: undefined },
|
|
322
335
|
name: { type: String as PropType<IconName>, required: true as const },
|
|
323
336
|
size: {
|
|
324
337
|
type: [String, Number] as PropType<IconSize>,
|
|
@@ -330,6 +343,7 @@ export const iconProps = {
|
|
|
330
343
|
label: { type: String, default: undefined },
|
|
331
344
|
}
|
|
332
345
|
export const screenProps = {
|
|
346
|
+
motionRegion: { type: Object as PropType<MotionRegion>, default: undefined },
|
|
333
347
|
motionScroll: { type: Object as PropType<MotionScrollSource>, default: undefined },
|
|
334
348
|
...viewProps,
|
|
335
349
|
scroll: Boolean,
|
|
@@ -338,6 +352,11 @@ export const screenProps = {
|
|
|
338
352
|
}
|
|
339
353
|
export const revealProps = { ...columnProps, show: Boolean }
|
|
340
354
|
export const sheetProps = {
|
|
355
|
+
/** Web only. Omit to restore the captured opener; return null to leave focus to the application. */
|
|
356
|
+
returnFocus: {
|
|
357
|
+
type: [String, Boolean, Function] as PropType<SheetReturnFocus>,
|
|
358
|
+
default: undefined,
|
|
359
|
+
},
|
|
341
360
|
id: viewProps.id,
|
|
342
361
|
accessibilityLabel: viewProps.accessibilityLabel,
|
|
343
362
|
open: Boolean,
|
|
@@ -364,6 +383,7 @@ export const componentProps = {
|
|
|
364
383
|
MRow: rowProps,
|
|
365
384
|
MColumn: columnProps,
|
|
366
385
|
MStack: stackProps,
|
|
386
|
+
MGrid: gridProps,
|
|
367
387
|
MLink: linkProps,
|
|
368
388
|
MBox: motionBoxProps,
|
|
369
389
|
MCard: cardProps,
|