@getcortexlabs/mavis-core 0.1.0-alpha.8 → 0.1.0-rc.11.1

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 (282) hide show
  1. package/README.md +2 -2
  2. package/dist/capabilities.d.ts +7 -7
  3. package/dist/capabilities.d.ts.map +1 -1
  4. package/dist/capabilities.js +30 -4
  5. package/dist/capabilities.js.map +1 -1
  6. package/dist/chart.d.ts +43 -0
  7. package/dist/chart.d.ts.map +1 -0
  8. package/dist/chart.js +105 -0
  9. package/dist/chart.js.map +1 -0
  10. package/dist/collections.d.ts +46 -0
  11. package/dist/collections.d.ts.map +1 -0
  12. package/dist/collections.js +48 -0
  13. package/dist/collections.js.map +1 -0
  14. package/dist/contracts.d.ts +20 -0
  15. package/dist/contracts.d.ts.map +1 -1
  16. package/dist/contracts.js +2 -0
  17. package/dist/contracts.js.map +1 -1
  18. package/dist/date-input.d.ts +10 -0
  19. package/dist/date-input.d.ts.map +1 -0
  20. package/dist/date-input.js +58 -0
  21. package/dist/date-input.js.map +1 -0
  22. package/dist/date-time.d.ts +19 -0
  23. package/dist/date-time.d.ts.map +1 -0
  24. package/dist/date-time.js +27 -0
  25. package/dist/date-time.js.map +1 -0
  26. package/dist/discovery.d.ts +49 -0
  27. package/dist/discovery.d.ts.map +1 -0
  28. package/dist/discovery.js +80 -0
  29. package/dist/discovery.js.map +1 -0
  30. package/dist/experimental-regions.d.ts +10 -0
  31. package/dist/experimental-regions.d.ts.map +1 -1
  32. package/dist/experimental-regions.js +23 -0
  33. package/dist/experimental-regions.js.map +1 -1
  34. package/dist/experimental.d.ts +5 -0
  35. package/dist/experimental.d.ts.map +1 -1
  36. package/dist/experimental.js +29 -0
  37. package/dist/experimental.js.map +1 -1
  38. package/dist/grid.d.ts +3 -0
  39. package/dist/grid.d.ts.map +1 -0
  40. package/dist/grid.js +16 -0
  41. package/dist/grid.js.map +1 -0
  42. package/dist/index.d.ts +17 -3
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +13 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/input.d.ts +4 -0
  47. package/dist/input.d.ts.map +1 -1
  48. package/dist/input.js.map +1 -1
  49. package/dist/interactive.d.ts +36 -0
  50. package/dist/interactive.d.ts.map +1 -0
  51. package/dist/interactive.js +61 -0
  52. package/dist/interactive.js.map +1 -0
  53. package/dist/link.d.ts +24 -0
  54. package/dist/link.d.ts.map +1 -1
  55. package/dist/link.js +41 -0
  56. package/dist/link.js.map +1 -1
  57. package/dist/motion.d.ts +8 -0
  58. package/dist/motion.d.ts.map +1 -1
  59. package/dist/motion.js +11 -0
  60. package/dist/motion.js.map +1 -1
  61. package/dist/navigation-transition.d.ts +10 -0
  62. package/dist/navigation-transition.d.ts.map +1 -0
  63. package/dist/navigation-transition.js +10 -0
  64. package/dist/navigation-transition.js.map +1 -0
  65. package/dist/number-flow-format.d.ts +16 -0
  66. package/dist/number-flow-format.d.ts.map +1 -0
  67. package/dist/number-flow-format.js +49 -0
  68. package/dist/number-flow-format.js.map +1 -0
  69. package/dist/popover.d.ts +17 -0
  70. package/dist/popover.d.ts.map +1 -0
  71. package/dist/popover.js +19 -0
  72. package/dist/popover.js.map +1 -0
  73. package/dist/section-scroll.d.ts +14 -0
  74. package/dist/section-scroll.d.ts.map +1 -0
  75. package/dist/section-scroll.js +28 -0
  76. package/dist/section-scroll.js.map +1 -0
  77. package/dist/sheet.d.ts +7 -0
  78. package/dist/sheet.d.ts.map +1 -1
  79. package/dist/time.d.ts +34 -0
  80. package/dist/time.d.ts.map +1 -0
  81. package/dist/time.js +78 -0
  82. package/dist/time.js.map +1 -0
  83. package/dist/vue/carousel.d.ts +13 -0
  84. package/dist/vue/carousel.d.ts.map +1 -0
  85. package/dist/vue/carousel.js +136 -0
  86. package/dist/vue/carousel.js.map +1 -0
  87. package/dist/vue/chart.d.ts +194 -0
  88. package/dist/vue/chart.d.ts.map +1 -0
  89. package/dist/vue/chart.js +245 -0
  90. package/dist/vue/chart.js.map +1 -0
  91. package/dist/vue/command-palette.d.ts +129 -0
  92. package/dist/vue/command-palette.d.ts.map +1 -0
  93. package/dist/vue/command-palette.js +190 -0
  94. package/dist/vue/command-palette.js.map +1 -0
  95. package/dist/vue/component-motion.d.ts +17 -0
  96. package/dist/vue/component-motion.d.ts.map +1 -0
  97. package/dist/vue/component-motion.js +83 -0
  98. package/dist/vue/component-motion.js.map +1 -0
  99. package/dist/vue/component-props.d.ts +1505 -402
  100. package/dist/vue/component-props.d.ts.map +1 -1
  101. package/dist/vue/component-props.js +28 -0
  102. package/dist/vue/component-props.js.map +1 -1
  103. package/dist/vue/configurator-props.d.ts +21 -0
  104. package/dist/vue/configurator-props.d.ts.map +1 -1
  105. package/dist/vue/configurator-props.js +6 -0
  106. package/dist/vue/configurator-props.js.map +1 -1
  107. package/dist/vue/configurator.d.ts +3 -3
  108. package/dist/vue/configurator.d.ts.map +1 -1
  109. package/dist/vue/configurator.js +3 -1
  110. package/dist/vue/configurator.js.map +1 -1
  111. package/dist/vue/data-table.d.ts +17 -0
  112. package/dist/vue/data-table.d.ts.map +1 -0
  113. package/dist/vue/data-table.js +133 -0
  114. package/dist/vue/data-table.js.map +1 -0
  115. package/dist/vue/date-calendar.d.ts +2 -0
  116. package/dist/vue/date-calendar.d.ts.map +1 -1
  117. package/dist/vue/date-calendar.js +20 -1
  118. package/dist/vue/date-calendar.js.map +1 -1
  119. package/dist/vue/date-picker.d.ts +48 -13
  120. package/dist/vue/date-picker.d.ts.map +1 -1
  121. package/dist/vue/date-picker.js +67 -74
  122. package/dist/vue/date-picker.js.map +1 -1
  123. package/dist/vue/date-props.d.ts +15 -0
  124. package/dist/vue/date-props.d.ts.map +1 -1
  125. package/dist/vue/date-props.js +4 -0
  126. package/dist/vue/date-props.js.map +1 -1
  127. package/dist/vue/discovery-components.d.ts +50 -0
  128. package/dist/vue/discovery-components.d.ts.map +1 -0
  129. package/dist/vue/discovery-components.js +2 -0
  130. package/dist/vue/discovery-components.js.map +1 -0
  131. package/dist/vue/discovery-controls.d.ts +197 -0
  132. package/dist/vue/discovery-controls.d.ts.map +1 -0
  133. package/dist/vue/discovery-controls.js +185 -0
  134. package/dist/vue/discovery-controls.js.map +1 -0
  135. package/dist/vue/discovery-props.d.ts +249 -0
  136. package/dist/vue/discovery-props.d.ts.map +1 -0
  137. package/dist/vue/discovery-props.js +87 -0
  138. package/dist/vue/discovery-props.js.map +1 -0
  139. package/dist/vue/global-components.d.ts +134 -2
  140. package/dist/vue/global-components.d.ts.map +1 -1
  141. package/dist/vue/index.d.ts +27 -1
  142. package/dist/vue/index.d.ts.map +1 -1
  143. package/dist/vue/index.js +23 -1
  144. package/dist/vue/index.js.map +1 -1
  145. package/dist/vue/interactive-components.d.ts +31 -0
  146. package/dist/vue/interactive-components.d.ts.map +1 -0
  147. package/dist/vue/interactive-components.js +2 -0
  148. package/dist/vue/interactive-components.js.map +1 -0
  149. package/dist/vue/interactive-props.d.ts +254 -0
  150. package/dist/vue/interactive-props.d.ts.map +1 -0
  151. package/dist/vue/interactive-props.js +85 -0
  152. package/dist/vue/interactive-props.js.map +1 -0
  153. package/dist/vue/list-motion.d.ts +7 -0
  154. package/dist/vue/list-motion.d.ts.map +1 -0
  155. package/dist/vue/list-motion.js +28 -0
  156. package/dist/vue/list-motion.js.map +1 -0
  157. package/dist/vue/menu.d.ts +122 -0
  158. package/dist/vue/menu.d.ts.map +1 -0
  159. package/dist/vue/menu.js +79 -0
  160. package/dist/vue/menu.js.map +1 -0
  161. package/dist/vue/navigation-controls.d.ts +125 -0
  162. package/dist/vue/navigation-controls.d.ts.map +1 -0
  163. package/dist/vue/navigation-controls.js +130 -0
  164. package/dist/vue/navigation-controls.js.map +1 -0
  165. package/dist/vue/navigation-props.d.ts +283 -0
  166. package/dist/vue/navigation-props.d.ts.map +1 -0
  167. package/dist/vue/navigation-props.js +82 -0
  168. package/dist/vue/navigation-props.js.map +1 -0
  169. package/dist/vue/navigation.d.ts +7 -0
  170. package/dist/vue/navigation.d.ts.map +1 -0
  171. package/dist/vue/navigation.js +15 -0
  172. package/dist/vue/navigation.js.map +1 -0
  173. package/dist/vue/number-flow.d.ts +75 -0
  174. package/dist/vue/number-flow.d.ts.map +1 -0
  175. package/dist/vue/number-flow.js +57 -0
  176. package/dist/vue/number-flow.js.map +1 -0
  177. package/dist/vue/partition.d.ts +15 -0
  178. package/dist/vue/partition.d.ts.map +1 -0
  179. package/dist/vue/partition.js +42 -0
  180. package/dist/vue/partition.js.map +1 -0
  181. package/dist/vue/platform.d.ts +37 -0
  182. package/dist/vue/platform.d.ts.map +1 -0
  183. package/dist/vue/platform.js +46 -0
  184. package/dist/vue/platform.js.map +1 -0
  185. package/dist/vue/props.d.ts +233 -36
  186. package/dist/vue/props.d.ts.map +1 -1
  187. package/dist/vue/props.js +15 -1
  188. package/dist/vue/props.js.map +1 -1
  189. package/dist/vue/sortable-list.d.ts +24 -0
  190. package/dist/vue/sortable-list.d.ts.map +1 -0
  191. package/dist/vue/sortable-list.js +251 -0
  192. package/dist/vue/sortable-list.js.map +1 -0
  193. package/dist/vue/swipe-actions.d.ts +96 -0
  194. package/dist/vue/swipe-actions.d.ts.map +1 -0
  195. package/dist/vue/swipe-actions.js +174 -0
  196. package/dist/vue/swipe-actions.js.map +1 -0
  197. package/dist/vue/time-picker.d.ts +488 -0
  198. package/dist/vue/time-picker.d.ts.map +1 -0
  199. package/dist/vue/time-picker.js +190 -0
  200. package/dist/vue/time-picker.js.map +1 -0
  201. package/dist/vue/tree-view.d.ts +111 -0
  202. package/dist/vue/tree-view.d.ts.map +1 -0
  203. package/dist/vue/tree-view.js +204 -0
  204. package/dist/vue/tree-view.js.map +1 -0
  205. package/dist/vue/virtual-list.d.ts +26 -0
  206. package/dist/vue/virtual-list.d.ts.map +1 -0
  207. package/dist/vue/virtual-list.js +2 -0
  208. package/dist/vue/virtual-list.js.map +1 -0
  209. package/dist/vue/wayfinding-controls.d.ts +199 -0
  210. package/dist/vue/wayfinding-controls.d.ts.map +1 -0
  211. package/dist/vue/wayfinding-controls.js +330 -0
  212. package/dist/vue/wayfinding-controls.js.map +1 -0
  213. package/dist/vue/wayfinding-props.d.ts +221 -0
  214. package/dist/vue/wayfinding-props.d.ts.map +1 -0
  215. package/dist/vue/wayfinding-props.js +86 -0
  216. package/dist/vue/wayfinding-props.js.map +1 -0
  217. package/dist/vue/workflows.d.ts +2 -2
  218. package/dist/vue/workflows.d.ts.map +1 -1
  219. package/dist/vue/workflows.js +17 -4
  220. package/dist/vue/workflows.js.map +1 -1
  221. package/dist/wayfinding.d.ts +50 -0
  222. package/dist/wayfinding.d.ts.map +1 -0
  223. package/dist/wayfinding.js +54 -0
  224. package/dist/wayfinding.js.map +1 -0
  225. package/package.json +2 -2
  226. package/src/capabilities.ts +31 -4
  227. package/src/chart.ts +151 -0
  228. package/src/collections.ts +87 -0
  229. package/src/contracts.ts +2 -0
  230. package/src/date-input.ts +87 -0
  231. package/src/date-time.ts +37 -0
  232. package/src/discovery.ts +139 -0
  233. package/src/experimental-regions.ts +29 -0
  234. package/src/experimental.ts +40 -0
  235. package/src/grid.ts +19 -0
  236. package/src/index.ts +24 -3
  237. package/src/input.ts +5 -0
  238. package/src/interactive.ts +91 -0
  239. package/src/link.ts +63 -0
  240. package/src/motion.ts +14 -0
  241. package/src/navigation-transition.ts +14 -0
  242. package/src/number-flow-format.ts +68 -0
  243. package/src/popover.ts +38 -0
  244. package/src/section-scroll.ts +46 -0
  245. package/src/sheet.ts +11 -0
  246. package/src/time.ts +83 -0
  247. package/src/vue/carousel.ts +198 -0
  248. package/src/vue/chart.ts +337 -0
  249. package/src/vue/command-palette.ts +235 -0
  250. package/src/vue/component-motion.ts +109 -0
  251. package/src/vue/component-props.ts +57 -0
  252. package/src/vue/configurator-props.ts +6 -0
  253. package/src/vue/configurator.ts +3 -1
  254. package/src/vue/data-table.ts +190 -0
  255. package/src/vue/date-calendar.ts +30 -1
  256. package/src/vue/date-picker.ts +81 -85
  257. package/src/vue/date-props.ts +5 -0
  258. package/src/vue/discovery-components.ts +60 -0
  259. package/src/vue/discovery-controls.ts +241 -0
  260. package/src/vue/discovery-props.ts +92 -0
  261. package/src/vue/global-components.ts +124 -2
  262. package/src/vue/index.ts +46 -0
  263. package/src/vue/interactive-components.ts +29 -0
  264. package/src/vue/interactive-props.ts +90 -0
  265. package/src/vue/list-motion.ts +31 -0
  266. package/src/vue/menu.ts +100 -0
  267. package/src/vue/navigation-controls.ts +159 -0
  268. package/src/vue/navigation-props.ts +87 -0
  269. package/src/vue/navigation.ts +16 -0
  270. package/src/vue/number-flow.ts +83 -0
  271. package/src/vue/partition.ts +49 -0
  272. package/src/vue/platform.ts +73 -0
  273. package/src/vue/props.ts +16 -1
  274. package/src/vue/sortable-list.ts +308 -0
  275. package/src/vue/swipe-actions.ts +226 -0
  276. package/src/vue/time-picker.ts +227 -0
  277. package/src/vue/tree-view.ts +259 -0
  278. package/src/vue/virtual-list.ts +28 -0
  279. package/src/vue/wayfinding-controls.ts +430 -0
  280. package/src/vue/wayfinding-props.ts +97 -0
  281. package/src/vue/workflows.ts +17 -4
  282. package/src/wayfinding.ts +85 -0
@@ -99,6 +99,11 @@ export interface MotionSharedOptions {
99
99
  transition?: Exclude<MotionOptions, { type: 'gravity' }>
100
100
  layoutTimeout?: number
101
101
  }
102
+ export interface MotionLayoutOptions {
103
+ transition?: Exclude<MotionOptions, { type: 'gravity' }>
104
+ size?: 'scale' | false
105
+ enter?: boolean
106
+ }
102
107
  export interface MotionSharedLayout extends MotionBinding {
103
108
  readonly active: boolean
104
109
  /** Explicit identity; follows replacement of this declared surface. */
@@ -151,6 +156,8 @@ type Available = {
151
156
  onAvailable(setup: () => void | (() => void)): () => void
152
157
  }
153
158
  export interface MotionRegion extends Available {
159
+ /** Animate keyed direct children after a synchronous data mutation. Not a virtual-list API. */
160
+ animateLayout(change: () => void, options?: MotionLayoutOptions): MotionPlayback
154
161
  onKeyboard(callback: (state: MotionKeyboardState) => void): MotionKeyboard
155
162
  /** Waits for initial native layout; the engine owns simulation and later geometry. */
156
163
  physicsWorld(
@@ -171,6 +178,7 @@ export interface MotionRegion extends Available {
171
178
  diagnostics(options: MotionDiagnosticsOptions): MotionDiagnostics
172
179
  }
173
180
  export interface MotionRegionAdapter {
181
+ animateLayout?(change: () => void, options: MotionLayoutOptions): MotionPlayback
174
182
  onKeyboard?(callback: (state: MotionKeyboardState) => void): Omit<MotionKeyboard, 'disposed'>
175
183
  physicsWorld?(
176
184
  bodies: readonly MotionCircleBody<MotionSurfaceAdapter>[],
@@ -396,6 +404,27 @@ function group(
396
404
  export function createMotionRegion(): MotionRegion {
397
405
  const entry: { state?: RegionState; setups: Set<() => () => void> } = { setups: new Set() }
398
406
  const region: MotionRegion = {
407
+ animateLayout(change, options = {}) {
408
+ const state = regionState(region)
409
+ if (typeof change !== 'function')
410
+ throw new TypeError('Layout motion needs a synchronous change callback.')
411
+ if (options.size !== undefined && options.size !== false && options.size !== 'scale')
412
+ throw new TypeError('Layout size must be scale or false.')
413
+ if (options.enter !== undefined && typeof options.enter !== 'boolean')
414
+ throw new TypeError('Layout enter must be a boolean.')
415
+ if (!state.adapter.animateLayout) throw new Error('Layout motion is unavailable.')
416
+ const raw = state.adapter.animateLayout(change, options)
417
+ const resource = { dispose: () => raw.stop() }
418
+ state.resources.add(resource)
419
+ const forget = () => state.resources.delete(resource)
420
+ void raw.finished.then(forget, forget)
421
+ return {
422
+ finished: raw.finished,
423
+ stop() {
424
+ if (state.valid && state.resources.has(resource)) raw.stop()
425
+ },
426
+ }
427
+ },
399
428
  get available() {
400
429
  return Boolean(entry.state?.valid)
401
430
  },
@@ -5,6 +5,9 @@ import {
5
5
  type MotionValueOptions,
6
6
  type MotionDecayOptions,
7
7
  } from './experimental-playback.js'
8
+ import { validateSectionScroll, type SectionScrollOptions } from './section-scroll.js'
9
+ export { sectionScrollRange } from './section-scroll.js'
10
+ export type { SectionScrollOptions, ScrollEdge } from './section-scroll.js'
8
11
  export * from './experimental-playback.js'
9
12
  export * from './experimental-effects.js'
10
13
  export * from './experimental-collections.js'
@@ -103,6 +106,12 @@ export interface MotionSurface extends MotionVisualSurface {
103
106
  frames: MotionScrollFrames,
104
107
  options: MotionScrollOptions,
105
108
  ): MotionScrollLink
109
+ scrollSection(
110
+ source: MotionScrollSource,
111
+ section: MotionRegion,
112
+ frames: MotionScrollFrames,
113
+ options?: SectionScrollOptions,
114
+ ): MotionScrollLink
106
115
  }
107
116
  export interface MotionBinding {
108
117
  readonly disposed: boolean
@@ -189,6 +198,12 @@ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
189
198
  frames: MotionScrollFrames,
190
199
  options: MotionScrollOptions,
191
200
  ): Omit<MotionScrollLink, 'disposed'>
201
+ scrollSection?(
202
+ source: MotionScrollAdapter,
203
+ section: MotionRegionAdapter,
204
+ frames: MotionScrollFrames,
205
+ options: SectionScrollOptions,
206
+ ): Omit<MotionScrollLink, 'disposed'>
192
207
  mapColor?(
193
208
  source: Pick<MotionReadable, 'get' | 'dispose'>,
194
209
  input: readonly number[],
@@ -963,6 +978,31 @@ export function createMotionSurface(): MotionSurface {
963
978
  for (const [, state] of entries) depend(state, handle)
964
979
  return handle
965
980
  },
981
+ scrollSection(source, section, frames, options = {}) {
982
+ const binding = current()
983
+ const scroll = scrollSources.get(source)
984
+ if (!scroll) throw new Error('Scroll source is unavailable.')
985
+ const region = regionState(section)
986
+ validateScroll(frames, { range: [0, 1] })
987
+ validateSectionScroll(options)
988
+ if (!binding.adapter.scrollSection) throw new Error('Section scroll motion is unavailable.')
989
+ const raw = binding.adapter.scrollSection(scroll.adapter, region.adapter, frames, options)
990
+ const resource = { dispose: () => link.dispose() }
991
+ const link = own(binding, {
992
+ get execution() {
993
+ return raw.execution
994
+ },
995
+ refresh: () => raw.refresh(),
996
+ dispose() {
997
+ scroll.links.delete(link)
998
+ region.resources.delete(resource)
999
+ raw.dispose()
1000
+ },
1001
+ })
1002
+ scroll.links.add(link)
1003
+ region.resources.add(resource)
1004
+ return link
1005
+ },
966
1006
  scrollLinked(source, frames, options) {
967
1007
  const binding = current()
968
1008
  const state = scrollSources.get(source)
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
@@ -1,6 +1,7 @@
1
1
  export { defineTheme, mavis, midnight } from './theme/themes.js'
2
2
  export { resolveSpace } from './theme/resolve.js'
3
- export { pressMotion, revealMotion, motionRecipe } from './motion.js'
3
+ export { pressMotion, revealMotion, motionRecipe, componentMotion } from './motion.js'
4
+ export type { ComponentMotion } from './motion.js'
4
5
  export type {
5
6
  FontFamily,
6
7
  MotionTheme,
@@ -32,9 +33,9 @@ export { validateInput, inputActionSize } from './input.js'
32
33
  export { icons, iconFontVersion } from './icons.js'
33
34
  export { iconGlyph, iconFontFamily, iconSizes, resolveIconSize, checkIconOnly } from './icon.js'
34
35
  export type { IconName, IconSize } from './icon.js'
35
- export type { InputHandle, InputAction } from './input.js'
36
+ export type { InputHandle, InputActionHandle, InputAction } from './input.js'
36
37
  export { checkSheetName, sheetCloseReasons } from './sheet.js'
37
- export type { SheetCloseReason, SheetName } from './sheet.js'
38
+ export type { SheetCloseReason, SheetName, SheetReturnFocus } from './sheet.js'
38
39
  export { isChoiceValue, choiceKey, validateChoices, canChoose } from './choice.js'
39
40
  export type { ChoiceValue, ChoiceOption } from './choice.js'
40
41
 
@@ -81,6 +82,8 @@ export { targetCapabilities, componentNames, themeContract } from './capabilitie
81
82
  export type { ComponentName, CapabilityStatus } from './capabilities.js'
82
83
 
83
84
  export * from './date.js'
85
+ export * from './date-input.js'
86
+ export * from './date-time.js'
84
87
  export * from './combobox.js'
85
88
  export * from './files.js'
86
89
  export * from './form.js'
@@ -92,3 +95,21 @@ export * from './app-icons.js'
92
95
  export * from './number-input.js'
93
96
  export * from './multi-select.js'
94
97
  export * from './choice-motion.js'
98
+
99
+ export { gridColumns } from './grid.js'
100
+
101
+ export * from './time.js'
102
+ export * from './popover.js'
103
+ export * from './collections.js'
104
+
105
+ export { defineNavigationTransition } from './navigation-transition.js'
106
+ export type { NavigationTransition } from './navigation-transition.js'
107
+
108
+ export * from './discovery.js'
109
+
110
+ export * from './wayfinding.js'
111
+ export * from './chart.js'
112
+
113
+ export * from './interactive.js'
114
+
115
+ export * from './number-flow-format.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
@@ -0,0 +1,91 @@
1
+ import { choiceKey, type ChoiceValue } from './choice.js'
2
+ import { virtualKeys, type VirtualItemKey } from './collections.js'
3
+ import type { IconName } from './icon.js'
4
+
5
+ export interface SwipeAction {
6
+ value: ChoiceValue
7
+ label: string
8
+ icon?: IconName
9
+ destructive?: boolean
10
+ disabled?: boolean
11
+ }
12
+ export type SwipeSide = 'start' | 'end' | null
13
+ export interface ViewerImage {
14
+ key: ChoiceValue
15
+ src: string
16
+ thumbnail?: string
17
+ alt: string
18
+ caption?: string
19
+ aspectRatio?: number
20
+ }
21
+ export interface SortableMove {
22
+ key: ChoiceValue
23
+ beforeKey: ChoiceValue | null
24
+ fromIndex: number
25
+ toIndex: number
26
+ }
27
+
28
+ export function finiteRange(value: number, min: number, max: number) {
29
+ if (![value, min, max].every(Number.isFinite) || min > max)
30
+ throw new RangeError('Expected a finite value and ordered bounds.')
31
+ return Math.max(min, Math.min(max, value))
32
+ }
33
+ export function positiveSize(value: number, name: string) {
34
+ if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be positive.`)
35
+ return value
36
+ }
37
+ export function moveItem<T>(
38
+ items: readonly T[],
39
+ itemKey: VirtualItemKey<T>,
40
+ key: ChoiceValue,
41
+ beforeKey: ChoiceValue | null,
42
+ ): { items: T[]; move: SortableMove } | null {
43
+ const keys = virtualKeys(items, itemKey)
44
+ const fromIndex = keys.indexOf(key)
45
+ if (fromIndex < 0 || beforeKey === key || (beforeKey !== null && !keys.includes(beforeKey)))
46
+ return null
47
+ const remaining = items.filter((_, index) => index !== fromIndex)
48
+ const remainingKeys = keys.filter((_, index) => index !== fromIndex)
49
+ const toIndex = beforeKey === null ? remaining.length : remainingKeys.indexOf(beforeKey)
50
+ if (toIndex === fromIndex) return null
51
+ remaining.splice(toIndex, 0, items[fromIndex]!)
52
+ return { items: remaining, move: { key, beforeKey, fromIndex, toIndex } }
53
+ }
54
+ export function validateActions(start: readonly SwipeAction[], end: readonly SwipeAction[]) {
55
+ const keys = new Set<string>()
56
+ for (const action of [...start, ...end]) {
57
+ const key = choiceKey(action.value)
58
+ if (keys.has(key)) throw new RangeError('Swipe actions require unique keys across both sides.')
59
+ if (!action.label.trim()) throw new TypeError('Swipe actions require visible labels.')
60
+ keys.add(key)
61
+ }
62
+ }
63
+ export function swipeDestination(
64
+ x: number,
65
+ velocity: number,
66
+ startWidth: number,
67
+ endWidth: number,
68
+ direction = 1,
69
+ ): SwipeSide {
70
+ const projected = (x + velocity * 0.12) * direction
71
+ return projected > startWidth * 0.45 && startWidth > 0
72
+ ? 'start'
73
+ : projected < -endWidth * 0.45 && endWidth > 0
74
+ ? 'end'
75
+ : null
76
+ }
77
+ export function panelValue(value: number, min: number, max: number, collapsible: boolean) {
78
+ finiteRange(min, 0, 100)
79
+ finiteRange(max, 0, 100)
80
+ if (min < 0 || max > 100 || min >= max)
81
+ throw new RangeError('Panel bounds must satisfy 0 <= min < max <= 100.')
82
+ return collapsible && value === 0 ? 0 : finiteRange(value, min, max)
83
+ }
84
+ export function validateViewer(images: readonly ViewerImage[]) {
85
+ virtualKeys(images, 'key')
86
+ for (const image of images) {
87
+ if (!image.src.trim() || !image.alt.trim())
88
+ throw new TypeError('Viewer images require src and descriptive alt text.')
89
+ if (image.aspectRatio !== undefined) positiveSize(image.aspectRatio, 'aspectRatio')
90
+ }
91
+ }
package/src/link.ts CHANGED
@@ -7,6 +7,69 @@ 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
+ /** Releases host hooks when the application unmounts. */
13
+ dispose?(): void
14
+ resolve(href: string): string
15
+ push: LinkNavigate
16
+ replace: LinkNavigate
17
+ back(): void | Promise<unknown>
18
+ }
19
+
20
+ /** The common string-route subset of Vue Router, Nuxt's router and vue-router-ns. */
21
+ export interface MavisRouter {
22
+ resolve(href: string): { href?: string; fullPath?: string }
23
+ push(href: string): unknown
24
+ replace(href: string): unknown
25
+ back(): unknown
26
+ }
27
+
28
+ export function isAppDestination(href: string): boolean {
29
+ return !/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href) && !href.includes('\\')
30
+ }
31
+
32
+ /** Retains router guards/history and Web base/hash URLs; does not install a router. */
33
+ export function createRouterNavigation(router: MavisRouter): MavisNavigation {
34
+ const internal = (href: string) => {
35
+ const value = linkDestination(href)
36
+ if (!isAppDestination(value))
37
+ throw new TypeError('Router navigation requires an in-app destination.')
38
+ return value
39
+ }
40
+ return {
41
+ resolve(href) {
42
+ const value = internal(href)
43
+ const resolved = router.resolve(value)
44
+ return linkDestination(resolved.href ?? resolved.fullPath ?? value)
45
+ },
46
+ async push(href) {
47
+ return router.push(internal(href))
48
+ },
49
+ async replace(href) {
50
+ return router.replace(internal(href))
51
+ },
52
+ async back() {
53
+ return router.back()
54
+ },
55
+ }
56
+ }
57
+
58
+ /** An explicit callback takes precedence. External links keep the platform default. */
59
+ export function resolveNavigation(
60
+ options: NavigationOptions,
61
+ navigation?: MavisNavigation,
62
+ ): NavigationOptions {
63
+ if (options.href === undefined) return options
64
+ const href = linkDestination(options.href)
65
+ if (options.navigate || !navigation || !isAppDestination(href)) return { ...options, href }
66
+ return {
67
+ ...options,
68
+ href: linkDestination(navigation.resolve(href)),
69
+ navigate: () => navigation.push(href),
70
+ }
71
+ }
72
+
10
73
  /** Navigation belongs to the host; the shared contract only validates its destination. */
11
74
  export function linkDestination(href: string): string {
12
75
  const value = href.trim()
package/src/motion.ts CHANGED
@@ -45,6 +45,20 @@ export const revealMotion = {
45
45
  enter: [{ opacity: [0, 1], y: [8, 0] }, { duration: 180 }],
46
46
  leave: [{ opacity: 0 }, { duration: 120 }],
47
47
  } as const
48
+
49
+ /** Shared interaction timing; components keep semantics and Jolt owns every frame. */
50
+ export type ComponentMotion = 'selection' | 'layout' | 'overlay' | 'data' | 'feedback'
51
+ export function componentMotion(theme: MavisTheme, kind: ComponentMotion) {
52
+ const motion = theme.motion
53
+ validateMotion(motion)
54
+ const factor = { selection: 1.5, layout: 1.8, overlay: 1, data: 2.4, feedback: 1.2 }[kind]
55
+ return {
56
+ type: kind === 'overlay' || kind === 'data' ? ('tween' as const) : ('spring' as const),
57
+ duration: motion.enterDuration * factor,
58
+ ease: motion.ease,
59
+ bounce: kind === 'feedback' ? Math.min(0.2, motion.releaseBounce) : 0,
60
+ }
61
+ }
48
62
  import type { MotionTheme, MavisTheme } from './theme/types.js'
49
63
 
50
64
  export const defaultMotion: Readonly<MotionTheme> = Object.freeze({
@@ -0,0 +1,14 @@
1
+ export interface NavigationTransition {
2
+ name?: 'fade' | 'slide' | 'none'
3
+ duration?: number
4
+ }
5
+ /** Shared policy; routers retain guard, history, cancellation and native-back ownership. */
6
+ export function defineNavigationTransition(options: NavigationTransition = {}) {
7
+ const name = options.name ?? 'fade',
8
+ duration = options.duration ?? 220
9
+ if (!['fade', 'slide', 'none'].includes(name))
10
+ throw new TypeError('Navigation transition must be fade, slide or none.')
11
+ if (!Number.isFinite(duration) || duration < 0 || duration > 10000)
12
+ throw new RangeError('Navigation duration must be between 0 and 10000ms.')
13
+ return Object.freeze({ name, duration })
14
+ }
@@ -0,0 +1,68 @@
1
+ /** Formatting options supported by both platform formatters and Intl. */
2
+ export interface NumberFlowFormat {
3
+ style?: 'decimal' | 'currency' | 'percent'
4
+ currency?: string
5
+ currencyDisplay?: 'symbol' | 'code'
6
+ useGrouping?: boolean
7
+ minimumIntegerDigits?: number
8
+ minimumFractionDigits?: number
9
+ maximumFractionDigits?: number
10
+ }
11
+
12
+ export function resolveNumberFlowFormat(options: NumberFlowFormat = {}): NumberFlowFormat {
13
+ const allowed = new Set([
14
+ 'style',
15
+ 'currency',
16
+ 'currencyDisplay',
17
+ 'useGrouping',
18
+ 'minimumIntegerDigits',
19
+ 'minimumFractionDigits',
20
+ 'maximumFractionDigits',
21
+ ])
22
+ for (const key of Object.keys(options))
23
+ if (!allowed.has(key))
24
+ throw new RangeError(
25
+ `Unsupported number format option: ${key}. Use formatValue for custom formatting.`,
26
+ )
27
+ const style = options.style ?? 'decimal'
28
+ if (!['decimal', 'currency', 'percent'].includes(style))
29
+ throw new RangeError('Unknown number format style.')
30
+ if (style === 'currency' && !/^[a-z]{3}$/i.test(options.currency ?? ''))
31
+ throw new RangeError('Currency formatting requires a three-letter currency code.')
32
+ if (
33
+ options.currencyDisplay !== undefined &&
34
+ !['symbol', 'code'].includes(options.currencyDisplay)
35
+ )
36
+ throw new RangeError('currencyDisplay must be symbol or code.')
37
+ if (options.useGrouping !== undefined && typeof options.useGrouping !== 'boolean')
38
+ throw new RangeError('useGrouping must be a boolean.')
39
+ for (const [key, min, max] of [
40
+ ['minimumIntegerDigits', 1, 21],
41
+ ['minimumFractionDigits', 0, 20],
42
+ ['maximumFractionDigits', 0, 20],
43
+ ] as const) {
44
+ const value = options[key]
45
+ if (value !== undefined && (!Number.isInteger(value) || value < min || value > max))
46
+ throw new RangeError(`${key} must be an integer from ${min} to ${max}.`)
47
+ }
48
+ if (
49
+ options.minimumFractionDigits !== undefined &&
50
+ options.maximumFractionDigits !== undefined &&
51
+ options.minimumFractionDigits > options.maximumFractionDigits
52
+ )
53
+ throw new RangeError('minimumFractionDigits cannot exceed maximumFractionDigits.')
54
+ return {
55
+ ...options,
56
+ style,
57
+ ...(options.currency ? { currency: options.currency.toUpperCase() } : {}),
58
+ }
59
+ }
60
+
61
+ export function numberFlowFractionDigits(options: NumberFlowFormat, currencyDigits = 2) {
62
+ const defaults =
63
+ options.style === 'currency' ? Math.max(0, currencyDigits) : options.style === 'percent' ? 0 : 3
64
+ const minimum =
65
+ options.minimumFractionDigits ??
66
+ Math.min(options.style === 'currency' ? defaults : 0, options.maximumFractionDigits ?? defaults)
67
+ return { minimum, maximum: options.maximumFractionDigits ?? Math.max(minimum, defaults) }
68
+ }
package/src/popover.ts ADDED
@@ -0,0 +1,38 @@
1
+ export type PopoverPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end'
2
+ export type PopoverCloseReason = 'trigger' | 'outside' | 'escape' | 'back' | 'select' | 'program'
3
+ export interface PopoverRect {
4
+ x: number
5
+ y: number
6
+ width: number
7
+ height: number
8
+ }
9
+
10
+ /** Coordinates share one CSS-pixel/DIP space. Flip vertically, then clamp to the viewport. */
11
+ export function placePopover(
12
+ anchor: PopoverRect,
13
+ panel: { width: number; height: number },
14
+ viewport: PopoverRect,
15
+ placement: PopoverPlacement,
16
+ rtl = false,
17
+ gap = 8,
18
+ margin = 8,
19
+ ) {
20
+ const bottom = anchor.y + anchor.height + gap
21
+ const top = anchor.y - gap - panel.height
22
+ const lower = viewport.y + viewport.height - margin
23
+ const upper = viewport.y + margin
24
+ let above = placement.startsWith('top')
25
+ if (above && top < upper && bottom + panel.height <= lower) above = false
26
+ else if (!above && bottom + panel.height > lower && top >= upper) above = true
27
+ const end = placement.endsWith('end') !== rtl
28
+ const clamp = (value: number, min: number, max: number) =>
29
+ Math.max(min, Math.min(value, Math.max(min, max)))
30
+ return {
31
+ x: clamp(
32
+ end ? anchor.x + anchor.width - panel.width : anchor.x,
33
+ viewport.x + margin,
34
+ viewport.x + viewport.width - panel.width - margin,
35
+ ),
36
+ y: clamp(above ? top : bottom, upper, lower - panel.height),
37
+ }
38
+ }
@@ -0,0 +1,46 @@
1
+ export type ScrollEdge = 'start' | 'center' | 'end'
2
+ export interface SectionScrollOptions {
3
+ /** [section edge, viewport edge]. Default: ['start', 'end']. */
4
+ start?: readonly [ScrollEdge, ScrollEdge]
5
+ /** [section edge, viewport edge]. Default: ['end', 'start']. */
6
+ end?: readonly [ScrollEdge, ScrollEdge]
7
+ }
8
+ const edge = { start: 0, center: 0.5, end: 1 } as const
9
+ export function validateSectionScroll(options: SectionScrollOptions) {
10
+ for (const value of [options.start, options.end])
11
+ if (
12
+ value !== undefined &&
13
+ (!Array.isArray(value) ||
14
+ value.length !== 2 ||
15
+ value.some((part) => !Object.hasOwn(edge, part)))
16
+ )
17
+ throw new TypeError(
18
+ 'Section points must pair start, center or end for the section and viewport.',
19
+ )
20
+ }
21
+ /** Renderer geometry only; Jolt owns interpolation, scheduling and reduced motion. */
22
+ export function sectionScrollRange(
23
+ top: number,
24
+ height: number,
25
+ viewport: number,
26
+ maximum: number,
27
+ options: SectionScrollOptions,
28
+ ) {
29
+ validateSectionScroll(options)
30
+ if (
31
+ ![top, height, viewport, maximum].every(Number.isFinite) ||
32
+ height < 0 ||
33
+ viewport < 0 ||
34
+ maximum < 0
35
+ )
36
+ throw new RangeError('Section geometry must be finite.')
37
+ const position = ([section, screen]: readonly [ScrollEdge, ScrollEdge]) =>
38
+ top + height * edge[section] - viewport * edge[screen]
39
+ const start = position(options.start ?? ['start', 'end'])
40
+ const end = position(options.end ?? ['end', 'start'])
41
+ if (end < start) throw new RangeError('Section end must follow its start.')
42
+ const clamp = (value: number) => Math.max(0, Math.min(maximum, value))
43
+ const range = [clamp(start), clamp(end)] as const
44
+ // A section with no traversable range settles; never divide by zero or add a clock.
45
+ return { range: range[1] > range[0] ? range : ([0, 1] as const), settled: range[1] <= range[0] }
46
+ }
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)
package/src/time.ts ADDED
@@ -0,0 +1,83 @@
1
+ /** A wall-clock time, independent of date, timezone and daylight-saving transitions. */
2
+ export type LocalTime = string
3
+ export type TimeLocale = 'en-US' | 'pt-BR'
4
+ export type HourCycle = 'h12' | 'h23'
5
+ export interface TimeOptions {
6
+ locale?: TimeLocale
7
+ hourCycle?: HourCycle
8
+ min?: LocalTime
9
+ max?: LocalTime
10
+ minuteStep?: number
11
+ }
12
+ export type TimeValidation =
13
+ | { status: 'empty'; value: null }
14
+ | { status: 'valid'; value: LocalTime }
15
+ | { status: 'incomplete' | 'invalid' | 'range' | 'step'; value: null }
16
+
17
+ export function timeMinutes(value: LocalTime): number {
18
+ if (!/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value))
19
+ throw new RangeError('Time must use HH:mm between 00:00 and 23:59.')
20
+ return Number(value.slice(0, 2)) * 60 + Number(value.slice(3))
21
+ }
22
+ export function localTime(minutes: number): LocalTime {
23
+ if (!Number.isInteger(minutes) || minutes < 0 || minutes >= 1440)
24
+ throw new RangeError('Time requires an integer minute within one day.')
25
+ return `${String(Math.floor(minutes / 60)).padStart(2, '0')}:${String(minutes % 60).padStart(2, '0')}`
26
+ }
27
+ export function timeOptions(options: TimeOptions = {}) {
28
+ const min = options.min === undefined ? 0 : timeMinutes(options.min)
29
+ const max = options.max === undefined ? 1439 : timeMinutes(options.max)
30
+ const step = options.minuteStep ?? 1
31
+ if (min > max)
32
+ throw new RangeError('Time min must not exceed max; overnight ranges are not supported.')
33
+ if (!Number.isInteger(step) || step < 1 || step > 30 || 60 % step)
34
+ throw new RangeError('minuteStep must be a divisor of 60 between 1 and 30.')
35
+ if (Math.ceil(min / step) * step > max)
36
+ throw new RangeError('Time bounds contain no selectable time.')
37
+ const locale = options.locale ?? 'en-US'
38
+ const cycle = options.hourCycle ?? (locale === 'pt-BR' ? 'h23' : 'h12')
39
+ if (!['en-US', 'pt-BR'].includes(locale) || !['h12', 'h23'].includes(cycle))
40
+ throw new RangeError('Unsupported time locale or hour cycle.')
41
+ return { min, max, step, cycle }
42
+ }
43
+ export function validateTime(value: LocalTime | null, options: TimeOptions = {}): TimeValidation {
44
+ const { min, max, step } = timeOptions(options)
45
+ if (value === null) return { status: 'empty', value: null }
46
+ let minutes: number
47
+ try {
48
+ minutes = timeMinutes(value)
49
+ } catch {
50
+ return { status: 'invalid', value: null }
51
+ }
52
+ if (minutes < min || minutes > max) return { status: 'range', value: null }
53
+ if (minutes % step) return { status: 'step', value: null }
54
+ return { status: 'valid', value }
55
+ }
56
+ /** Deterministic during SSR and on native runtimes without Intl. Never constructs a Date. */
57
+ export function formatTime(value: LocalTime | null, options: TimeOptions = {}): string {
58
+ const { cycle } = timeOptions(options)
59
+ if (value === null) return ''
60
+ const minutes = timeMinutes(value)
61
+ if (cycle === 'h23') return value
62
+ const hour = Math.floor(minutes / 60)
63
+ return `${hour % 12 || 12}:${value.slice(3)} ${hour < 12 ? 'AM' : 'PM'}`
64
+ }
65
+ export function parseTime(draft: string, options: TimeOptions = {}): TimeValidation {
66
+ const { cycle } = timeOptions(options)
67
+ const text = draft.trim()
68
+ if (!text) return { status: 'empty', value: null }
69
+ const match =
70
+ cycle === 'h23' ? /^(\d{1,2}):(\d{2})$/.exec(text) : /^(\d{1,2}):(\d{2})\s*(AM|PM)$/i.exec(text)
71
+ if (!match)
72
+ return {
73
+ status: /^\d{0,2}(?::\d{0,2})?\s*[apm]{0,2}$/i.test(text) ? 'incomplete' : 'invalid',
74
+ value: null,
75
+ }
76
+ let hour = Number(match[1])
77
+ if (Number(match[2]) > 59) return { status: 'invalid', value: null }
78
+ if (cycle === 'h12') {
79
+ if (hour < 1 || hour > 12) return { status: 'invalid', value: null }
80
+ hour = (hour % 12) + (match[3]!.toUpperCase() === 'PM' ? 12 : 0)
81
+ } else if (hour > 23) return { status: 'invalid', value: null }
82
+ return validateTime(localTime(hour * 60 + Number(match[2])), options)
83
+ }