@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.
Files changed (127) hide show
  1. package/dist/capabilities.d.ts +19 -6
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +17 -3
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/contracts.d.ts +42 -2
  6. package/dist/contracts.d.ts.map +1 -1
  7. package/dist/contracts.js +17 -0
  8. package/dist/contracts.js.map +1 -1
  9. package/dist/date-input.d.ts +10 -0
  10. package/dist/date-input.d.ts.map +1 -0
  11. package/dist/date-input.js +58 -0
  12. package/dist/date-input.js.map +1 -0
  13. package/dist/date-time.d.ts +19 -0
  14. package/dist/date-time.d.ts.map +1 -0
  15. package/dist/date-time.js +27 -0
  16. package/dist/date-time.js.map +1 -0
  17. package/dist/dialog.d.ts +1 -1
  18. package/dist/dialog.d.ts.map +1 -1
  19. package/dist/dialog.js +1 -0
  20. package/dist/dialog.js.map +1 -1
  21. package/dist/experimental-collections.d.ts +82 -0
  22. package/dist/experimental-collections.d.ts.map +1 -0
  23. package/dist/experimental-collections.js +8 -0
  24. package/dist/experimental-collections.js.map +1 -0
  25. package/dist/experimental-effects.d.ts +107 -0
  26. package/dist/experimental-effects.d.ts.map +1 -0
  27. package/dist/experimental-effects.js +24 -0
  28. package/dist/experimental-effects.js.map +1 -0
  29. package/dist/experimental-platforms.d.ts +94 -0
  30. package/dist/experimental-platforms.d.ts.map +1 -0
  31. package/dist/experimental-platforms.js +2 -0
  32. package/dist/experimental-platforms.js.map +1 -0
  33. package/dist/experimental-playback.d.ts +2 -2
  34. package/dist/experimental-playback.d.ts.map +1 -1
  35. package/dist/experimental-regions.d.ts +17 -2
  36. package/dist/experimental-regions.d.ts.map +1 -1
  37. package/dist/experimental-regions.js +91 -0
  38. package/dist/experimental-regions.js.map +1 -1
  39. package/dist/experimental-sensors.d.ts +42 -0
  40. package/dist/experimental-sensors.d.ts.map +1 -0
  41. package/dist/experimental-sensors.js +2 -0
  42. package/dist/experimental-sensors.js.map +1 -0
  43. package/dist/experimental-surfaces.d.ts +127 -0
  44. package/dist/experimental-surfaces.d.ts.map +1 -0
  45. package/dist/experimental-surfaces.js +2 -0
  46. package/dist/experimental-surfaces.js.map +1 -0
  47. package/dist/experimental.d.ts +28 -4
  48. package/dist/experimental.d.ts.map +1 -1
  49. package/dist/experimental.js +266 -1
  50. package/dist/experimental.js.map +1 -1
  51. package/dist/grid.d.ts +3 -0
  52. package/dist/grid.d.ts.map +1 -0
  53. package/dist/grid.js +16 -0
  54. package/dist/grid.js.map +1 -0
  55. package/dist/index.d.ts +5 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -0
  58. package/dist/index.js.map +1 -1
  59. package/dist/input.d.ts +4 -0
  60. package/dist/input.d.ts.map +1 -1
  61. package/dist/input.js.map +1 -1
  62. package/dist/link.d.ts +22 -0
  63. package/dist/link.d.ts.map +1 -1
  64. package/dist/link.js +41 -0
  65. package/dist/link.js.map +1 -1
  66. package/dist/sheet.d.ts +7 -0
  67. package/dist/sheet.d.ts.map +1 -1
  68. package/dist/vue/component-props.d.ts +167 -20
  69. package/dist/vue/component-props.d.ts.map +1 -1
  70. package/dist/vue/configurator-props.d.ts +26 -0
  71. package/dist/vue/configurator-props.d.ts.map +1 -1
  72. package/dist/vue/configurator-props.js +7 -0
  73. package/dist/vue/configurator-props.js.map +1 -1
  74. package/dist/vue/configurator.d.ts +1 -1
  75. package/dist/vue/date-picker.d.ts +40 -5
  76. package/dist/vue/date-picker.d.ts.map +1 -1
  77. package/dist/vue/date-picker.js +67 -74
  78. package/dist/vue/date-picker.js.map +1 -1
  79. package/dist/vue/date-props.d.ts +9 -0
  80. package/dist/vue/date-props.d.ts.map +1 -1
  81. package/dist/vue/date-props.js +1 -0
  82. package/dist/vue/date-props.js.map +1 -1
  83. package/dist/vue/global-components.d.ts +3 -2
  84. package/dist/vue/global-components.d.ts.map +1 -1
  85. package/dist/vue/index.d.ts +3 -1
  86. package/dist/vue/index.d.ts.map +1 -1
  87. package/dist/vue/index.js +3 -1
  88. package/dist/vue/index.js.map +1 -1
  89. package/dist/vue/loading-effect.d.ts +7 -0
  90. package/dist/vue/loading-effect.d.ts.map +1 -0
  91. package/dist/vue/loading-effect.js +32 -0
  92. package/dist/vue/loading-effect.js.map +1 -0
  93. package/dist/vue/navigation.d.ts +7 -0
  94. package/dist/vue/navigation.d.ts.map +1 -0
  95. package/dist/vue/navigation.js +15 -0
  96. package/dist/vue/navigation.js.map +1 -0
  97. package/dist/vue/props.d.ts +280 -43
  98. package/dist/vue/props.d.ts.map +1 -1
  99. package/dist/vue/props.js +19 -0
  100. package/dist/vue/props.js.map +1 -1
  101. package/package.json +1 -1
  102. package/src/capabilities.ts +17 -3
  103. package/src/contracts.ts +17 -0
  104. package/src/date-input.ts +87 -0
  105. package/src/date-time.ts +37 -0
  106. package/src/dialog.ts +3 -1
  107. package/src/experimental-collections.ts +87 -0
  108. package/src/experimental-effects.ts +146 -0
  109. package/src/experimental-platforms.ts +96 -0
  110. package/src/experimental-playback.ts +1 -1
  111. package/src/experimental-regions.ts +136 -2
  112. package/src/experimental-sensors.ts +50 -0
  113. package/src/experimental-surfaces.ts +124 -0
  114. package/src/experimental.ts +309 -8
  115. package/src/grid.ts +19 -0
  116. package/src/index.ts +6 -2
  117. package/src/input.ts +5 -0
  118. package/src/link.ts +61 -0
  119. package/src/sheet.ts +11 -0
  120. package/src/vue/configurator-props.ts +8 -0
  121. package/src/vue/date-picker.ts +81 -85
  122. package/src/vue/date-props.ts +2 -0
  123. package/src/vue/global-components.ts +3 -2
  124. package/src/vue/index.ts +3 -0
  125. package/src/vue/loading-effect.ts +44 -0
  126. package/src/vue/navigation.ts +16 -0
  127. package/src/vue/props.ts +21 -1
@@ -6,6 +6,17 @@ import {
6
6
  type MotionDecayOptions,
7
7
  } from './experimental-playback.js'
8
8
  export * from './experimental-playback.js'
9
+ export * from './experimental-effects.js'
10
+ export * from './experimental-collections.js'
11
+ export * from './experimental-surfaces.js'
12
+ export * from './experimental-platforms.js'
13
+ import {
14
+ mapGradientBindings,
15
+ type MotionVisualSurface,
16
+ type MotionVisualAdapter,
17
+ type MotionGradient,
18
+ type MotionCircular,
19
+ } from './experimental-effects.js'
9
20
  /** Experimental, single-surface motion contract. No platform objects cross this boundary. */
10
21
  import {
11
22
  regionState,
@@ -17,22 +28,51 @@ import {
17
28
  type MotionPointerAdapter,
18
29
  } from './experimental-regions.js'
19
30
  export * from './experimental-regions.js'
31
+ export * from './experimental-sensors.js'
32
+ import type {
33
+ MotionSensor,
34
+ MotionSensorKind,
35
+ MotionSensorOptions,
36
+ MotionSensorAdapter,
37
+ } from './experimental-sensors.js'
20
38
  export type MotionValues = Partial<
21
39
  Record<'scale' | 'scaleX' | 'scaleY' | 'x' | 'y' | 'rotate' | 'opacity', number>
22
40
  >
23
41
  export type MotionFrames = { [K in keyof MotionValues]?: number | readonly (number | null)[] }
24
- export interface MotionOptions {
25
- type?: 'spring' | 'tween'
26
- duration?: number
27
- bounce?: number
28
- ease?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'
42
+ export type MotionOptions = (
43
+ | {
44
+ type?: 'spring' | 'tween'
45
+ duration?: number
46
+ bounce?: number
47
+ ease?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'
48
+ acceleration?: never
49
+ restitution?: never
50
+ }
51
+ | {
52
+ type: 'gravity'
53
+ acceleration?: number
54
+ restitution?: number
55
+ duration?: never
56
+ bounce?: never
57
+ ease?: never
58
+ }
59
+ ) & {
60
+ velocity?: number
29
61
  delay?: number
62
+ haptic?:
63
+ | 'light'
64
+ | 'medium'
65
+ | 'heavy'
66
+ | false
67
+ | { style: 'light' | 'medium' | 'heavy'; times?: readonly number[] }
30
68
  }
69
+
31
70
  export interface MotionPlayback {
32
71
  readonly finished: Promise<boolean>
33
72
  stop(): void
34
73
  }
35
- export interface MotionSurface {
74
+ export interface MotionSurface extends MotionVisualSurface {
75
+ sensor(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensor
36
76
  readonly available: boolean
37
77
  animate(values: MotionFrames, options?: MotionOptions): MotionControlledPlayback
38
78
  set(values: MotionValues): MotionPlayback
@@ -120,7 +160,8 @@ export interface MotionDrag extends MotionBinding {
120
160
  export type MotionValueAdapter = Pick<MotionValue, 'get' | 'set' | 'dispose'>
121
161
  export type MotionSpringAdapter = Omit<MotionSpring, 'disposed' | 'to'>
122
162
  export type MotionDragAdapter = Omit<MotionDrag, 'disposed'>
123
- export interface MotionSurfaceAdapter {
163
+ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
164
+ sensor?(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensorAdapter
124
165
  /** The renderer borrows its host runtime and owns only this child's resources. */
125
166
  use?(setup: (adapter: MotionSurfaceAdapter) => () => void): () => void
126
167
  pointerFollow?(region: MotionRegionAdapter, options: MotionPointerOptions): MotionPointerAdapter
@@ -449,6 +490,39 @@ function ownValue<T extends Pick<MotionReadable, 'get' | 'dispose'>>(
449
490
  }
450
491
 
451
492
  export function createMotionSurface(): MotionSurface {
493
+ // Validate the portable gravity contract before a renderer relinquishes scroll ownership.
494
+ // Trajectory compilation, velocity inheritance and playback remain entirely in Jolt.
495
+ const gravityFrames = (frames: readonly unknown[], options?: MotionOptions) => {
496
+ if (options?.type !== 'gravity') return
497
+ if (
498
+ frames.length < 1 ||
499
+ frames.length > 2 ||
500
+ frames.some(
501
+ (value, index) =>
502
+ !(index === 0 && frames.length === 2 && value === null) &&
503
+ (typeof value !== 'number' || !Number.isFinite(value)),
504
+ )
505
+ )
506
+ throw new TypeError('Gravity needs one fixed numeric landing position.')
507
+ if (
508
+ options.acceleration !== undefined &&
509
+ (!Number.isFinite(options.acceleration) || options.acceleration <= 0)
510
+ )
511
+ throw new RangeError('Gravity acceleration must be finite and positive.')
512
+ if (
513
+ options.restitution !== undefined &&
514
+ (!Number.isFinite(options.restitution) || options.restitution < 0 || options.restitution >= 1)
515
+ )
516
+ throw new RangeError('Gravity restitution must be in [0, 1).')
517
+ if (options.velocity !== undefined && !Number.isFinite(options.velocity))
518
+ throw new RangeError('Gravity velocity must be finite.')
519
+ if (
520
+ options.duration !== undefined ||
521
+ options.ease !== undefined ||
522
+ options.bounce !== undefined
523
+ )
524
+ throw new TypeError('Gravity timing comes from physics.')
525
+ }
452
526
  const current = () => {
453
527
  const binding = bindings.get(surface)
454
528
  if (!binding?.valid)
@@ -484,8 +558,171 @@ export function createMotionSurface(): MotionSurface {
484
558
  get available() {
485
559
  return Boolean(bindings.get(surface)?.valid)
486
560
  },
487
- animate: (values, options) => run((adapter) => adapter.animate(values, options)),
561
+ animate(values, options) {
562
+ if (options?.type === 'gravity') {
563
+ const keys = Object.keys(values)
564
+ if (!keys.length || keys.some((key) => key !== 'x' && key !== 'y'))
565
+ throw new TypeError('Gravity applies only to x/y or a numeric motion value.')
566
+ for (const value of Object.values(values))
567
+ gravityFrames(Array.isArray(value) ? value : [value], options)
568
+ }
569
+ return run((adapter) => adapter.animate(values, options))
570
+ },
488
571
  set: (values) => run((adapter) => adapter.set(values)),
572
+ supports: (effect) => current().adapter.supports?.(effect) ?? false,
573
+ particles(options) {
574
+ const binding = current()
575
+ if (!binding.adapter.particles) throw new Error('Particles are unavailable.')
576
+ return own(binding, binding.adapter.particles(options))
577
+ },
578
+ confetti(options) {
579
+ const binding = current()
580
+ if (!binding.adapter.confetti) throw new Error('Confetti is unavailable.')
581
+ return own(binding, binding.adapter.confetti(options))
582
+ },
583
+ blur(options) {
584
+ const binding = current()
585
+ if (!binding.adapter.blur) throw new Error('Blur is unavailable.')
586
+ const raw = binding.adapter.blur(options)
587
+ return own(binding, {
588
+ animate: (amount: number, timing?: MotionOptions) => run(() => raw.animate(amount, timing)),
589
+ set: (amount: number) => raw.set(amount),
590
+ stop: () => raw.stop(),
591
+ snapshot: () => raw.snapshot(),
592
+ dispose: () => raw.dispose(),
593
+ })
594
+ },
595
+ shape(options) {
596
+ const binding = current()
597
+ if (!binding.adapter.shape) throw new Error('Shapes are unavailable.')
598
+ const raw = binding.adapter.shape(options)
599
+ return own(binding, {
600
+ animate: (
601
+ values: import('./experimental-surfaces.js').MotionShapeValues,
602
+ timing?: MotionOptions,
603
+ ) => run(() => raw.animate(values, timing)),
604
+ set: (values: import('./experimental-surfaces.js').MotionShapeValues) => raw.set(values),
605
+ stop: () => raw.stop(),
606
+ dispose: () => raw.dispose(),
607
+ })
608
+ },
609
+ liquid(options) {
610
+ const binding = current()
611
+ if (!binding.adapter.liquid) throw new Error('Liquid images are unavailable.')
612
+ return own(binding, binding.adapter.liquid(options))
613
+ },
614
+ async imageEffect(name, options) {
615
+ const binding = current()
616
+ if (!binding.adapter.imageEffect) throw new Error('Image effects are unavailable.')
617
+ const raw = await binding.adapter.imageEffect(name, options, () => binding.valid)
618
+ if (!binding.valid) {
619
+ raw.stop()
620
+ throw new Error('Image presentation changed while preparing the effect.')
621
+ }
622
+ const control = run(() => raw)
623
+ // Keep the controlled playback accessors live while adding image-specific controls.
624
+ return Object.defineProperties(control, {
625
+ reverse: {
626
+ value: () => {
627
+ if (!binding.valid) throw new Error('Image presentation is disposed.')
628
+ ;(raw as MotionPlayback & { reverse(): void }).reverse()
629
+ },
630
+ },
631
+ finish: {
632
+ value: () => {
633
+ if (!binding.valid) throw new Error('Image presentation is disposed.')
634
+ ;(raw as MotionPlayback & { finish(): void }).finish()
635
+ },
636
+ },
637
+ }) as import('./experimental-surfaces.js').MotionImagePlayback
638
+ },
639
+ symbolEffect: (name, options) =>
640
+ run((adapter) => {
641
+ if (!adapter.symbolEffect) throw new Error('Icon effects are unavailable.')
642
+ return adapter.symbolEffect(name, options)
643
+ }),
644
+ followKeyboard(options) {
645
+ const binding = current()
646
+ if (!binding.adapter.followKeyboard) throw new Error('Keyboard following is unavailable.')
647
+ if (options?.offset !== undefined && (!Number.isFinite(options.offset) || options.offset < 0))
648
+ throw new RangeError('Keyboard offset must be finite and nonnegative.')
649
+ return own(binding, binding.adapter.followKeyboard(options))
650
+ },
651
+ gradient(options) {
652
+ const binding = current()
653
+ if (!binding.adapter.gradient) throw new Error('Gradients are unavailable.')
654
+ const raw = binding.adapter.gradient(options)
655
+ const children = new Set<MotionBinding>()
656
+ return own<Omit<MotionGradient, 'disposed'>>(binding, {
657
+ type: raw.type,
658
+ get suspended() {
659
+ return raw.suspended
660
+ },
661
+ animate: (values, options) => run(() => raw.animate(values, options)),
662
+ set: (values) => raw.set(values),
663
+ stop: () => raw.stop(),
664
+ suspend: () => raw.suspend(),
665
+ resume: () => raw.resume(),
666
+ bind(input) {
667
+ const parents = new Set<ValueState>()
668
+ const unwrap = (value: MotionReadable | MotionColor) => {
669
+ const state = source(value, binding)
670
+ parents.add(state)
671
+ return state.raw
672
+ }
673
+ const values = mapGradientBindings(
674
+ input,
675
+ (value) => unwrap(value) as Pick<MotionReadable, 'get' | 'dispose'>,
676
+ (value) => unwrap(value) as Pick<MotionColor, 'get' | 'dispose'>,
677
+ )
678
+ const linked = raw.bind(values)
679
+ const handle = own(binding, {
680
+ dispose() {
681
+ children.delete(handle)
682
+ linked.dispose()
683
+ },
684
+ })
685
+ children.add(handle)
686
+ for (const parent of parents) depend(parent, handle)
687
+ return handle
688
+ },
689
+ dispose() {
690
+ for (const child of [...children]) child.dispose()
691
+ raw.dispose()
692
+ },
693
+ })
694
+ },
695
+ shimmer(options) {
696
+ const binding = current()
697
+ if (!binding.adapter.shimmer) throw new Error('Shimmer is unavailable.')
698
+ return own(binding, binding.adapter.shimmer(options))
699
+ },
700
+ loader(options) {
701
+ const binding = current()
702
+ if (!binding.adapter.loader) throw new Error('Loaders are unavailable.')
703
+ return own(binding, binding.adapter.loader(options))
704
+ },
705
+ circular() {
706
+ const binding = current()
707
+ if (!binding.adapter.circular) throw new Error('Circular visibility is unavailable.')
708
+ const raw = binding.adapter.circular()
709
+ return own<Omit<MotionCircular, 'disposed'>>(binding, {
710
+ supported: raw.supported,
711
+ reveal: (options) => run(() => raw.reveal(options)),
712
+ conceal: (options) => run(() => raw.conceal(options)),
713
+ dispose: () => raw.dispose(),
714
+ })
715
+ },
716
+ animateText: (options) =>
717
+ run((adapter) => {
718
+ if (!adapter.animateText) throw new Error('Text entrance is unavailable.')
719
+ return adapter.animateText(options)
720
+ }),
721
+ rollTo: (value, options) =>
722
+ run((adapter) => {
723
+ if (!adapter.rollTo) throw new Error('Rolling text is unavailable.')
724
+ return adapter.rollTo(value, options)
725
+ }),
489
726
  use(setup) {
490
727
  return surface.onAvailable(() => {
491
728
  const binding = current()
@@ -512,6 +749,69 @@ export function createMotionSurface(): MotionSurface {
512
749
  return binding.adapter.use?.(start) ?? start(binding.adapter)
513
750
  })
514
751
  },
752
+ sensor(kind, options) {
753
+ const binding = current()
754
+ if (!binding.adapter.sensor) throw new Error('Sensor input is unavailable.')
755
+ const raw = binding.adapter.sensor(kind, options)
756
+ const values: MotionReadable[] = []
757
+ const wrap = (value: Pick<MotionValueAdapter, 'get' | 'dispose'>) => {
758
+ const result = ownValue(binding, value, false)
759
+ values.push(result)
760
+ return result
761
+ }
762
+ const x = wrap(raw.x),
763
+ y = wrap(raw.y),
764
+ z = wrap(raw.z)
765
+ const quaternion = raw.quaternion && {
766
+ x: wrap(raw.quaternion.x),
767
+ y: wrap(raw.quaternion.y),
768
+ z: wrap(raw.quaternion.z),
769
+ w: wrap(raw.quaternion.w),
770
+ }
771
+ let disposed = false
772
+ const assert = () => {
773
+ if (disposed || !binding.valid) throw new Error('Sensor presentation is disposed.')
774
+ }
775
+ return own(binding, {
776
+ kind: raw.kind,
777
+ x,
778
+ y,
779
+ z,
780
+ quaternion,
781
+ get status() {
782
+ return disposed ? ('disposed' as const) : raw.status
783
+ },
784
+ get available() {
785
+ return !disposed && raw.available
786
+ },
787
+ get paused() {
788
+ return raw.paused
789
+ },
790
+ pause() {
791
+ assert()
792
+ raw.pause()
793
+ },
794
+ resume() {
795
+ assert()
796
+ raw.resume()
797
+ },
798
+ recenter() {
799
+ assert()
800
+ raw.recenter()
801
+ },
802
+ async requestPermission() {
803
+ assert()
804
+ const result = await raw.requestPermission()
805
+ return disposed || !binding.valid ? ('unavailable' as const) : result
806
+ },
807
+ snapshot: () => raw.snapshot(),
808
+ dispose() {
809
+ disposed = true
810
+ for (const value of values) value.dispose()
811
+ raw.dispose()
812
+ },
813
+ })
814
+ },
515
815
  pointerFollow(region, options = {}) {
516
816
  const binding = current()
517
817
  validatePointer(options)
@@ -597,6 +897,7 @@ export function createMotionSurface(): MotionSurface {
597
897
  }
598
898
  },
599
899
  animateValue(value, frames, options) {
900
+ gravityFrames(Array.isArray(frames) ? frames : [frames], options)
600
901
  const binding = current()
601
902
  const parent = source(value, binding, true)
602
903
  if (!binding.adapter.animateValue) throw new Error('Scalar playback is unavailable.')
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)
@@ -1,6 +1,7 @@
1
1
  import type { PropType } from '@vue/runtime-core'
2
2
  import type { ChoiceOption, ChoiceValue } from '../choice.js'
3
3
  import type { NumberLocale } from '../number-input.js'
4
+ import type { MotionSurface } from '../experimental.js'
4
5
  import { inputProps, boxProps } from './props.js'
5
6
 
6
7
  const field = {
@@ -44,7 +45,14 @@ export const multiSelectProps = {
44
45
  removeLabel: { type: String, default: 'Remove' },
45
46
  }
46
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 },
47
54
  ...boxProps,
55
+ motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
48
56
  src: { type: String, required: true as const },
49
57
  alt: { type: String, required: true as const },
50
58
  aspectRatio: { type: Number, default: 4 / 3 },