@getcortexlabs/mavis-core 0.1.0-alpha.8 → 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.
Files changed (74) hide show
  1. package/dist/capabilities.d.ts +4 -4
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +2 -1
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/date-input.d.ts +10 -0
  6. package/dist/date-input.d.ts.map +1 -0
  7. package/dist/date-input.js +58 -0
  8. package/dist/date-input.js.map +1 -0
  9. package/dist/date-time.d.ts +19 -0
  10. package/dist/date-time.d.ts.map +1 -0
  11. package/dist/date-time.js +27 -0
  12. package/dist/date-time.js.map +1 -0
  13. package/dist/grid.d.ts +3 -0
  14. package/dist/grid.d.ts.map +1 -0
  15. package/dist/grid.js +16 -0
  16. package/dist/grid.js.map +1 -0
  17. package/dist/index.d.ts +5 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/input.d.ts +4 -0
  22. package/dist/input.d.ts.map +1 -1
  23. package/dist/input.js.map +1 -1
  24. package/dist/link.d.ts +22 -0
  25. package/dist/link.d.ts.map +1 -1
  26. package/dist/link.js +41 -0
  27. package/dist/link.js.map +1 -1
  28. package/dist/sheet.d.ts +7 -0
  29. package/dist/sheet.d.ts.map +1 -1
  30. package/dist/vue/component-props.d.ts +105 -0
  31. package/dist/vue/component-props.d.ts.map +1 -1
  32. package/dist/vue/configurator-props.d.ts +21 -0
  33. package/dist/vue/configurator-props.d.ts.map +1 -1
  34. package/dist/vue/configurator-props.js +6 -0
  35. package/dist/vue/configurator-props.js.map +1 -1
  36. package/dist/vue/configurator.d.ts +1 -1
  37. package/dist/vue/date-picker.d.ts +40 -5
  38. package/dist/vue/date-picker.d.ts.map +1 -1
  39. package/dist/vue/date-picker.js +67 -74
  40. package/dist/vue/date-picker.js.map +1 -1
  41. package/dist/vue/date-props.d.ts +9 -0
  42. package/dist/vue/date-props.d.ts.map +1 -1
  43. package/dist/vue/date-props.js +1 -0
  44. package/dist/vue/date-props.js.map +1 -1
  45. package/dist/vue/global-components.d.ts +3 -2
  46. package/dist/vue/global-components.d.ts.map +1 -1
  47. package/dist/vue/index.d.ts +2 -1
  48. package/dist/vue/index.d.ts.map +1 -1
  49. package/dist/vue/index.js +2 -1
  50. package/dist/vue/index.js.map +1 -1
  51. package/dist/vue/navigation.d.ts +7 -0
  52. package/dist/vue/navigation.d.ts.map +1 -0
  53. package/dist/vue/navigation.js +15 -0
  54. package/dist/vue/navigation.js.map +1 -0
  55. package/dist/vue/props.d.ts +157 -0
  56. package/dist/vue/props.d.ts.map +1 -1
  57. package/dist/vue/props.js +12 -0
  58. package/dist/vue/props.js.map +1 -1
  59. package/package.json +1 -1
  60. package/src/capabilities.ts +2 -1
  61. package/src/date-input.ts +87 -0
  62. package/src/date-time.ts +37 -0
  63. package/src/grid.ts +19 -0
  64. package/src/index.ts +6 -2
  65. package/src/input.ts +5 -0
  66. package/src/link.ts +61 -0
  67. package/src/sheet.ts +11 -0
  68. package/src/vue/configurator-props.ts +6 -0
  69. package/src/vue/date-picker.ts +81 -85
  70. package/src/vue/date-props.ts +2 -0
  71. package/src/vue/global-components.ts +3 -2
  72. package/src/vue/index.ts +2 -0
  73. package/src/vue/navigation.ts +16 -0
  74. package/src/vue/props.ts +13 -0
package/src/grid.ts ADDED
@@ -0,0 +1,19 @@
1
+ /** Equal-width grid columns; widths use CSS pixels on Web and DIPs on NativeScript. */
2
+ export function gridColumns(
3
+ columns: number | undefined,
4
+ minColumnWidth: number | undefined,
5
+ gap: number,
6
+ width?: number,
7
+ ): number {
8
+ if (columns !== undefined && (!Number.isSafeInteger(columns) || columns < 1))
9
+ throw new RangeError('columns must be a positive integer.')
10
+ if (minColumnWidth !== undefined && (!Number.isFinite(minColumnWidth) || minColumnWidth <= 0))
11
+ throw new RangeError('minColumnWidth must be finite and positive.')
12
+ if (!Number.isFinite(gap) || gap < 0)
13
+ throw new RangeError('Grid gap must be finite and non-negative.')
14
+ if (width !== undefined && (!Number.isFinite(width) || width < 0))
15
+ throw new RangeError('Grid content width must be finite and non-negative.')
16
+ if (minColumnWidth === undefined || width === undefined) return columns ?? 1
17
+ const fit = Math.max(1, Math.floor((Math.max(0, width) + gap) / (minColumnWidth + gap)))
18
+ return columns === undefined ? fit : Math.min(columns, fit)
19
+ }
package/src/index.ts CHANGED
@@ -32,9 +32,9 @@ export { validateInput, inputActionSize } from './input.js'
32
32
  export { icons, iconFontVersion } from './icons.js'
33
33
  export { iconGlyph, iconFontFamily, iconSizes, resolveIconSize, checkIconOnly } from './icon.js'
34
34
  export type { IconName, IconSize } from './icon.js'
35
- export type { InputHandle, InputAction } from './input.js'
35
+ export type { InputHandle, InputActionHandle, InputAction } from './input.js'
36
36
  export { checkSheetName, sheetCloseReasons } from './sheet.js'
37
- export type { SheetCloseReason, SheetName } from './sheet.js'
37
+ export type { SheetCloseReason, SheetName, SheetReturnFocus } from './sheet.js'
38
38
  export { isChoiceValue, choiceKey, validateChoices, canChoose } from './choice.js'
39
39
  export type { ChoiceValue, ChoiceOption } from './choice.js'
40
40
 
@@ -81,6 +81,8 @@ export { targetCapabilities, componentNames, themeContract } from './capabilitie
81
81
  export type { ComponentName, CapabilityStatus } from './capabilities.js'
82
82
 
83
83
  export * from './date.js'
84
+ export * from './date-input.js'
85
+ export * from './date-time.js'
84
86
  export * from './combobox.js'
85
87
  export * from './files.js'
86
88
  export * from './form.js'
@@ -92,3 +94,5 @@ export * from './app-icons.js'
92
94
  export * from './number-input.js'
93
95
  export * from './multi-select.js'
94
96
  export * from './choice-motion.js'
97
+
98
+ export { gridColumns } from './grid.js'
package/src/input.ts CHANGED
@@ -14,6 +14,11 @@ export interface InputHandle {
14
14
  blur(): void
15
15
  }
16
16
 
17
+ /** Text input action focus never opens the editing keyboard. */
18
+ export interface InputActionHandle extends InputHandle {
19
+ focusAction(): void
20
+ }
21
+
17
22
  /** Editing limits constrain user input; they never rewrite application state. */
18
23
  export function validateInput(options: {
19
24
  multiline: boolean
package/src/link.ts CHANGED
@@ -7,6 +7,67 @@ export interface NavigationOptions {
7
7
  rel?: string
8
8
  }
9
9
 
10
+ /** App-owned navigation. Instances belong to one app (and one SSR request). */
11
+ export interface MavisNavigation {
12
+ resolve(href: string): string
13
+ push: LinkNavigate
14
+ replace: LinkNavigate
15
+ back(): void | Promise<unknown>
16
+ }
17
+
18
+ /** The common string-route subset of Vue Router, Nuxt's router and vue-router-ns. */
19
+ export interface MavisRouter {
20
+ resolve(href: string): { href?: string; fullPath?: string }
21
+ push(href: string): unknown
22
+ replace(href: string): unknown
23
+ back(): unknown
24
+ }
25
+
26
+ export function isAppDestination(href: string): boolean {
27
+ return !/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href) && !href.includes('\\')
28
+ }
29
+
30
+ /** Retains router guards/history and Web base/hash URLs; does not install a router. */
31
+ export function createRouterNavigation(router: MavisRouter): MavisNavigation {
32
+ const internal = (href: string) => {
33
+ const value = linkDestination(href)
34
+ if (!isAppDestination(value))
35
+ throw new TypeError('Router navigation requires an in-app destination.')
36
+ return value
37
+ }
38
+ return {
39
+ resolve(href) {
40
+ const value = internal(href)
41
+ const resolved = router.resolve(value)
42
+ return linkDestination(resolved.href ?? resolved.fullPath ?? value)
43
+ },
44
+ async push(href) {
45
+ return router.push(internal(href))
46
+ },
47
+ async replace(href) {
48
+ return router.replace(internal(href))
49
+ },
50
+ async back() {
51
+ return router.back()
52
+ },
53
+ }
54
+ }
55
+
56
+ /** An explicit callback takes precedence. External links keep the platform default. */
57
+ export function resolveNavigation(
58
+ options: NavigationOptions,
59
+ navigation?: MavisNavigation,
60
+ ): NavigationOptions {
61
+ if (options.href === undefined) return options
62
+ const href = linkDestination(options.href)
63
+ if (options.navigate || !navigation || !isAppDestination(href)) return { ...options, href }
64
+ return {
65
+ ...options,
66
+ href: linkDestination(navigation.resolve(href)),
67
+ navigate: () => navigation.push(href),
68
+ }
69
+ }
70
+
10
71
  /** Navigation belongs to the host; the shared contract only validates its destination. */
11
72
  export function linkDestination(href: string): string {
12
73
  const value = href.trim()
package/src/sheet.ts CHANGED
@@ -18,3 +18,14 @@ export function checkSheetName(title: string | undefined, label: string | undefi
18
18
  if (!name) throw new RangeError('A sheet needs a nonempty title or accessibilityLabel')
19
19
  return name
20
20
  }
21
+
22
+ /** Web focus destination, resolved after the native dialog close event. A string is an element ID. */
23
+ export type SheetReturnFocus =
24
+ | string
25
+ | false
26
+ | ((
27
+ reason: SheetCloseReason,
28
+ ) =>
29
+ | { readonly isConnected: boolean; focus(options?: { preventScroll?: boolean }): unknown }
30
+ | null
31
+ | undefined)
@@ -45,6 +45,12 @@ export const multiSelectProps = {
45
45
  removeLabel: { type: String, default: 'Remove' },
46
46
  }
47
47
  export const imageProps = {
48
+ /** Web image-selection and request hints, forwarded to the inner img. */
49
+ srcset: { type: String, default: undefined },
50
+ sizes: { type: String, default: undefined },
51
+ loading: { type: String as PropType<'eager' | 'lazy'>, default: undefined },
52
+ decoding: { type: String as PropType<'async' | 'sync' | 'auto'>, default: undefined },
53
+ fetchpriority: { type: String as PropType<'high' | 'low' | 'auto'>, default: undefined },
48
54
  ...boxProps,
49
55
  motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
50
56
  src: { type: String, required: true as const },
@@ -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, Row, Sheet, Calendar } = primitives
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 ?? '', end: value.end ?? '' }
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) ?? '', end: '' }
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
- ? validateDateRangeDraft({ start: start.value, end: end.value }, props)
127
- : validateDateDraft(start.value, props)
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: draft.start ? civilDate(draft.start) : null,
169
- end: draft.end ? civilDate(draft.end) : null,
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 = isCivilDate(draft) ? draft : (props.min ?? civilDate(`${props.initialMonth}-01`))
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' ? secondOpener.value : firstOpener.value)
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 = validateDateDraft(start.value, props)
227
- const endValidation = validateDateDraft(end.value, props)
228
- const startError =
229
- touched.value || start.value.length >= 10
230
- ? dateValidationMessage(startValidation, props.locale)
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
- Row,
243
- { gap: 'sm', align: 'end' },
244
- {
245
- default: () => [
246
- h(Input, {
247
- ref: which === 'start' ? first : second,
248
- id: props.id ? `${props.id}${range ? `-${which}` : ''}` : undefined,
249
- grow: 1,
250
- shrink: 1,
251
- label: label(which),
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: isCivilDate(endpoint.value === 'end' ? end.value : start.value)
339
- ? endpoint.value === 'end'
340
- ? end.value
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
  }),
@@ -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
- InputHandle
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,
@@ -84,3 +85,4 @@ export type { RevealHost } from './reveal-state.js'
84
85
  export * from './configurator-props.js'
85
86
  export * from './configurator.js'
86
87
  export { useLoadingDecoration } from './loading-effect.js'
88
+ export { navigationKey, useMavisNavigation, useNavigationOptions } from './navigation.js'
@@ -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,
@@ -170,6 +171,12 @@ export const skeletonProps = {
170
171
  }
171
172
  export const rowProps = vueProps(rowContract)
172
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
+ }
173
180
  export const stackProps = {
174
181
  ...columnProps,
175
182
  direction: choice(['row', 'column'] as const, 'column'),
@@ -345,6 +352,11 @@ export const screenProps = {
345
352
  }
346
353
  export const revealProps = { ...columnProps, show: Boolean }
347
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
+ },
348
360
  id: viewProps.id,
349
361
  accessibilityLabel: viewProps.accessibilityLabel,
350
362
  open: Boolean,
@@ -371,6 +383,7 @@ export const componentProps = {
371
383
  MRow: rowProps,
372
384
  MColumn: columnProps,
373
385
  MStack: stackProps,
386
+ MGrid: gridProps,
374
387
  MLink: linkProps,
375
388
  MBox: motionBoxProps,
376
389
  MCard: cardProps,