@getcortexlabs/mavis-core 0.1.0-alpha.9 → 0.1.0-rc.12

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 (340) 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 +48 -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/creative-controls.d.ts +47 -0
  19. package/dist/creative-controls.d.ts.map +1 -0
  20. package/dist/creative-controls.js +112 -0
  21. package/dist/creative-controls.js.map +1 -0
  22. package/dist/dashboard.d.ts +72 -0
  23. package/dist/dashboard.d.ts.map +1 -0
  24. package/dist/dashboard.js +115 -0
  25. package/dist/dashboard.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/index.d.ts +15 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +13 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/interactive.d.ts +36 -0
  43. package/dist/interactive.d.ts.map +1 -0
  44. package/dist/interactive.js +61 -0
  45. package/dist/interactive.js.map +1 -0
  46. package/dist/link.d.ts +2 -0
  47. package/dist/link.d.ts.map +1 -1
  48. package/dist/link.js.map +1 -1
  49. package/dist/motion.d.ts +8 -0
  50. package/dist/motion.d.ts.map +1 -1
  51. package/dist/motion.js +11 -0
  52. package/dist/motion.js.map +1 -1
  53. package/dist/navigation-transition.d.ts +10 -0
  54. package/dist/navigation-transition.d.ts.map +1 -0
  55. package/dist/navigation-transition.js +10 -0
  56. package/dist/navigation-transition.js.map +1 -0
  57. package/dist/number-flow-format.d.ts +16 -0
  58. package/dist/number-flow-format.d.ts.map +1 -0
  59. package/dist/number-flow-format.js +49 -0
  60. package/dist/number-flow-format.js.map +1 -0
  61. package/dist/popover.d.ts +17 -0
  62. package/dist/popover.d.ts.map +1 -0
  63. package/dist/popover.js +19 -0
  64. package/dist/popover.js.map +1 -0
  65. package/dist/screen-components.d.ts +45 -0
  66. package/dist/screen-components.d.ts.map +1 -0
  67. package/dist/screen-components.js +23 -0
  68. package/dist/screen-components.js.map +1 -0
  69. package/dist/section-scroll.d.ts +14 -0
  70. package/dist/section-scroll.d.ts.map +1 -0
  71. package/dist/section-scroll.js +28 -0
  72. package/dist/section-scroll.js.map +1 -0
  73. package/dist/time.d.ts +34 -0
  74. package/dist/time.d.ts.map +1 -0
  75. package/dist/time.js +78 -0
  76. package/dist/time.js.map +1 -0
  77. package/dist/vue/animated-text.d.ts +101 -0
  78. package/dist/vue/animated-text.d.ts.map +1 -0
  79. package/dist/vue/animated-text.js +56 -0
  80. package/dist/vue/animated-text.js.map +1 -0
  81. package/dist/vue/carousel.d.ts +13 -0
  82. package/dist/vue/carousel.d.ts.map +1 -0
  83. package/dist/vue/carousel.js +136 -0
  84. package/dist/vue/carousel.js.map +1 -0
  85. package/dist/vue/chart.d.ts +194 -0
  86. package/dist/vue/chart.d.ts.map +1 -0
  87. package/dist/vue/chart.js +245 -0
  88. package/dist/vue/chart.js.map +1 -0
  89. package/dist/vue/command-palette.d.ts +129 -0
  90. package/dist/vue/command-palette.d.ts.map +1 -0
  91. package/dist/vue/command-palette.js +190 -0
  92. package/dist/vue/command-palette.js.map +1 -0
  93. package/dist/vue/component-motion.d.ts +17 -0
  94. package/dist/vue/component-motion.d.ts.map +1 -0
  95. package/dist/vue/component-motion.js +83 -0
  96. package/dist/vue/component-motion.js.map +1 -0
  97. package/dist/vue/component-props.d.ts +1708 -21
  98. package/dist/vue/component-props.d.ts.map +1 -1
  99. package/dist/vue/component-props.js +50 -0
  100. package/dist/vue/component-props.js.map +1 -1
  101. package/dist/vue/composer.d.ts +159 -0
  102. package/dist/vue/composer.d.ts.map +1 -0
  103. package/dist/vue/composer.js +142 -0
  104. package/dist/vue/composer.js.map +1 -0
  105. package/dist/vue/configurator.d.ts +2 -2
  106. package/dist/vue/configurator.d.ts.map +1 -1
  107. package/dist/vue/configurator.js +3 -1
  108. package/dist/vue/configurator.js.map +1 -1
  109. package/dist/vue/creative-controls.d.ts +328 -0
  110. package/dist/vue/creative-controls.d.ts.map +1 -0
  111. package/dist/vue/creative-controls.js +396 -0
  112. package/dist/vue/creative-controls.js.map +1 -0
  113. package/dist/vue/creative-props.d.ts +260 -0
  114. package/dist/vue/creative-props.d.ts.map +1 -0
  115. package/dist/vue/creative-props.js +92 -0
  116. package/dist/vue/creative-props.js.map +1 -0
  117. package/dist/vue/dashboard-charts.d.ts +240 -0
  118. package/dist/vue/dashboard-charts.d.ts.map +1 -0
  119. package/dist/vue/dashboard-charts.js +263 -0
  120. package/dist/vue/dashboard-charts.js.map +1 -0
  121. package/dist/vue/dashboard-effects.d.ts +211 -0
  122. package/dist/vue/dashboard-effects.d.ts.map +1 -0
  123. package/dist/vue/dashboard-effects.js +235 -0
  124. package/dist/vue/dashboard-effects.js.map +1 -0
  125. package/dist/vue/dashboard-props.d.ts +244 -0
  126. package/dist/vue/dashboard-props.d.ts.map +1 -0
  127. package/dist/vue/dashboard-props.js +94 -0
  128. package/dist/vue/dashboard-props.js.map +1 -0
  129. package/dist/vue/data-table.d.ts +17 -0
  130. package/dist/vue/data-table.d.ts.map +1 -0
  131. package/dist/vue/data-table.js +133 -0
  132. package/dist/vue/data-table.js.map +1 -0
  133. package/dist/vue/date-calendar.d.ts +2 -0
  134. package/dist/vue/date-calendar.d.ts.map +1 -1
  135. package/dist/vue/date-calendar.js +20 -1
  136. package/dist/vue/date-calendar.js.map +1 -1
  137. package/dist/vue/date-picker.d.ts +8 -8
  138. package/dist/vue/date-props.d.ts +6 -0
  139. package/dist/vue/date-props.d.ts.map +1 -1
  140. package/dist/vue/date-props.js +3 -0
  141. package/dist/vue/date-props.js.map +1 -1
  142. package/dist/vue/discovery-components.d.ts +50 -0
  143. package/dist/vue/discovery-components.d.ts.map +1 -0
  144. package/dist/vue/discovery-components.js +2 -0
  145. package/dist/vue/discovery-components.js.map +1 -0
  146. package/dist/vue/discovery-controls.d.ts +197 -0
  147. package/dist/vue/discovery-controls.d.ts.map +1 -0
  148. package/dist/vue/discovery-controls.js +185 -0
  149. package/dist/vue/discovery-controls.js.map +1 -0
  150. package/dist/vue/discovery-props.d.ts +249 -0
  151. package/dist/vue/discovery-props.d.ts.map +1 -0
  152. package/dist/vue/discovery-props.js +87 -0
  153. package/dist/vue/discovery-props.js.map +1 -0
  154. package/dist/vue/global-components.d.ts +237 -0
  155. package/dist/vue/global-components.d.ts.map +1 -1
  156. package/dist/vue/index.d.ts +41 -0
  157. package/dist/vue/index.d.ts.map +1 -1
  158. package/dist/vue/index.js +37 -0
  159. package/dist/vue/index.js.map +1 -1
  160. package/dist/vue/interactive-components.d.ts +31 -0
  161. package/dist/vue/interactive-components.d.ts.map +1 -0
  162. package/dist/vue/interactive-components.js +2 -0
  163. package/dist/vue/interactive-components.js.map +1 -0
  164. package/dist/vue/interactive-props.d.ts +254 -0
  165. package/dist/vue/interactive-props.d.ts.map +1 -0
  166. package/dist/vue/interactive-props.js +85 -0
  167. package/dist/vue/interactive-props.js.map +1 -0
  168. package/dist/vue/kanban.d.ts +150 -0
  169. package/dist/vue/kanban.d.ts.map +1 -0
  170. package/dist/vue/kanban.js +267 -0
  171. package/dist/vue/kanban.js.map +1 -0
  172. package/dist/vue/list-motion.d.ts +7 -0
  173. package/dist/vue/list-motion.d.ts.map +1 -0
  174. package/dist/vue/list-motion.js +28 -0
  175. package/dist/vue/list-motion.js.map +1 -0
  176. package/dist/vue/marquee.d.ts +96 -0
  177. package/dist/vue/marquee.d.ts.map +1 -0
  178. package/dist/vue/marquee.js +186 -0
  179. package/dist/vue/marquee.js.map +1 -0
  180. package/dist/vue/menu.d.ts +122 -0
  181. package/dist/vue/menu.d.ts.map +1 -0
  182. package/dist/vue/menu.js +79 -0
  183. package/dist/vue/menu.js.map +1 -0
  184. package/dist/vue/navigation-controls.d.ts +125 -0
  185. package/dist/vue/navigation-controls.d.ts.map +1 -0
  186. package/dist/vue/navigation-controls.js +130 -0
  187. package/dist/vue/navigation-controls.js.map +1 -0
  188. package/dist/vue/navigation-props.d.ts +283 -0
  189. package/dist/vue/navigation-props.d.ts.map +1 -0
  190. package/dist/vue/navigation-props.js +82 -0
  191. package/dist/vue/navigation-props.js.map +1 -0
  192. package/dist/vue/number-flow.d.ts +75 -0
  193. package/dist/vue/number-flow.d.ts.map +1 -0
  194. package/dist/vue/number-flow.js +57 -0
  195. package/dist/vue/number-flow.js.map +1 -0
  196. package/dist/vue/partition.d.ts +15 -0
  197. package/dist/vue/partition.d.ts.map +1 -0
  198. package/dist/vue/partition.js +42 -0
  199. package/dist/vue/partition.js.map +1 -0
  200. package/dist/vue/pin-cell.d.ts +14 -0
  201. package/dist/vue/pin-cell.d.ts.map +1 -0
  202. package/dist/vue/pin-cell.js +19 -0
  203. package/dist/vue/pin-cell.js.map +1 -0
  204. package/dist/vue/pin-input.d.ts +14 -0
  205. package/dist/vue/pin-input.d.ts.map +1 -0
  206. package/dist/vue/pin-input.js +23 -0
  207. package/dist/vue/pin-input.js.map +1 -0
  208. package/dist/vue/platform.d.ts +37 -0
  209. package/dist/vue/platform.d.ts.map +1 -0
  210. package/dist/vue/platform.js +46 -0
  211. package/dist/vue/platform.js.map +1 -0
  212. package/dist/vue/props.d.ts +82 -42
  213. package/dist/vue/props.d.ts.map +1 -1
  214. package/dist/vue/props.js +3 -1
  215. package/dist/vue/props.js.map +1 -1
  216. package/dist/vue/screen-component-props.d.ts +236 -0
  217. package/dist/vue/screen-component-props.d.ts.map +1 -0
  218. package/dist/vue/screen-component-props.js +90 -0
  219. package/dist/vue/screen-component-props.js.map +1 -0
  220. package/dist/vue/scroll-frame.d.ts +223 -0
  221. package/dist/vue/scroll-frame.d.ts.map +1 -0
  222. package/dist/vue/scroll-frame.js +346 -0
  223. package/dist/vue/scroll-frame.js.map +1 -0
  224. package/dist/vue/sortable-list.d.ts +24 -0
  225. package/dist/vue/sortable-list.d.ts.map +1 -0
  226. package/dist/vue/sortable-list.js +251 -0
  227. package/dist/vue/sortable-list.js.map +1 -0
  228. package/dist/vue/speed-dial.d.ts +73 -0
  229. package/dist/vue/speed-dial.d.ts.map +1 -0
  230. package/dist/vue/speed-dial.js +78 -0
  231. package/dist/vue/speed-dial.js.map +1 -0
  232. package/dist/vue/swipe-actions.d.ts +96 -0
  233. package/dist/vue/swipe-actions.d.ts.map +1 -0
  234. package/dist/vue/swipe-actions.js +174 -0
  235. package/dist/vue/swipe-actions.js.map +1 -0
  236. package/dist/vue/swipe-deck.d.ts +120 -0
  237. package/dist/vue/swipe-deck.d.ts.map +1 -0
  238. package/dist/vue/swipe-deck.js +229 -0
  239. package/dist/vue/swipe-deck.js.map +1 -0
  240. package/dist/vue/time-picker.d.ts +488 -0
  241. package/dist/vue/time-picker.d.ts.map +1 -0
  242. package/dist/vue/time-picker.js +190 -0
  243. package/dist/vue/time-picker.js.map +1 -0
  244. package/dist/vue/tour.d.ts +120 -0
  245. package/dist/vue/tour.d.ts.map +1 -0
  246. package/dist/vue/tour.js +165 -0
  247. package/dist/vue/tour.js.map +1 -0
  248. package/dist/vue/tree-view.d.ts +111 -0
  249. package/dist/vue/tree-view.d.ts.map +1 -0
  250. package/dist/vue/tree-view.js +204 -0
  251. package/dist/vue/tree-view.js.map +1 -0
  252. package/dist/vue/virtual-list.d.ts +26 -0
  253. package/dist/vue/virtual-list.d.ts.map +1 -0
  254. package/dist/vue/virtual-list.js +2 -0
  255. package/dist/vue/virtual-list.js.map +1 -0
  256. package/dist/vue/wayfinding-controls.d.ts +199 -0
  257. package/dist/vue/wayfinding-controls.d.ts.map +1 -0
  258. package/dist/vue/wayfinding-controls.js +330 -0
  259. package/dist/vue/wayfinding-controls.js.map +1 -0
  260. package/dist/vue/wayfinding-props.d.ts +221 -0
  261. package/dist/vue/wayfinding-props.d.ts.map +1 -0
  262. package/dist/vue/wayfinding-props.js +86 -0
  263. package/dist/vue/wayfinding-props.js.map +1 -0
  264. package/dist/vue/workflows.d.ts +2 -2
  265. package/dist/vue/workflows.d.ts.map +1 -1
  266. package/dist/vue/workflows.js +17 -4
  267. package/dist/vue/workflows.js.map +1 -1
  268. package/dist/wayfinding.d.ts +50 -0
  269. package/dist/wayfinding.d.ts.map +1 -0
  270. package/dist/wayfinding.js +54 -0
  271. package/dist/wayfinding.js.map +1 -0
  272. package/package.json +2 -2
  273. package/src/capabilities.ts +50 -4
  274. package/src/chart.ts +151 -0
  275. package/src/collections.ts +87 -0
  276. package/src/contracts.ts +2 -0
  277. package/src/creative-controls.ts +169 -0
  278. package/src/dashboard.ts +164 -0
  279. package/src/discovery.ts +139 -0
  280. package/src/experimental-regions.ts +29 -0
  281. package/src/experimental.ts +40 -0
  282. package/src/index.ts +23 -1
  283. package/src/interactive.ts +91 -0
  284. package/src/link.ts +2 -0
  285. package/src/motion.ts +14 -0
  286. package/src/navigation-transition.ts +14 -0
  287. package/src/number-flow-format.ts +68 -0
  288. package/src/popover.ts +38 -0
  289. package/src/screen-components.ts +59 -0
  290. package/src/section-scroll.ts +46 -0
  291. package/src/time.ts +83 -0
  292. package/src/vue/animated-text.ts +72 -0
  293. package/src/vue/carousel.ts +198 -0
  294. package/src/vue/chart.ts +337 -0
  295. package/src/vue/command-palette.ts +235 -0
  296. package/src/vue/component-motion.ts +109 -0
  297. package/src/vue/component-props.ts +104 -0
  298. package/src/vue/composer.ts +192 -0
  299. package/src/vue/configurator.ts +3 -1
  300. package/src/vue/creative-controls.ts +524 -0
  301. package/src/vue/creative-props.ts +94 -0
  302. package/src/vue/dashboard-charts.ts +346 -0
  303. package/src/vue/dashboard-effects.ts +304 -0
  304. package/src/vue/dashboard-props.ts +95 -0
  305. package/src/vue/data-table.ts +190 -0
  306. package/src/vue/date-calendar.ts +30 -1
  307. package/src/vue/date-props.ts +3 -0
  308. package/src/vue/discovery-components.ts +60 -0
  309. package/src/vue/discovery-controls.ts +241 -0
  310. package/src/vue/discovery-props.ts +92 -0
  311. package/src/vue/global-components.ts +237 -0
  312. package/src/vue/index.ts +64 -0
  313. package/src/vue/interactive-components.ts +29 -0
  314. package/src/vue/interactive-props.ts +90 -0
  315. package/src/vue/kanban.ts +360 -0
  316. package/src/vue/list-motion.ts +31 -0
  317. package/src/vue/marquee.ts +248 -0
  318. package/src/vue/menu.ts +100 -0
  319. package/src/vue/navigation-controls.ts +159 -0
  320. package/src/vue/navigation-props.ts +87 -0
  321. package/src/vue/number-flow.ts +83 -0
  322. package/src/vue/partition.ts +49 -0
  323. package/src/vue/pin-cell.ts +26 -0
  324. package/src/vue/pin-input.ts +31 -0
  325. package/src/vue/platform.ts +73 -0
  326. package/src/vue/props.ts +3 -1
  327. package/src/vue/screen-component-props.ts +92 -0
  328. package/src/vue/scroll-frame.ts +429 -0
  329. package/src/vue/sortable-list.ts +308 -0
  330. package/src/vue/speed-dial.ts +108 -0
  331. package/src/vue/swipe-actions.ts +226 -0
  332. package/src/vue/swipe-deck.ts +277 -0
  333. package/src/vue/time-picker.ts +227 -0
  334. package/src/vue/tour.ts +239 -0
  335. package/src/vue/tree-view.ts +259 -0
  336. package/src/vue/virtual-list.ts +28 -0
  337. package/src/vue/wayfinding-controls.ts +430 -0
  338. package/src/vue/wayfinding-props.ts +97 -0
  339. package/src/vue/workflows.ts +17 -4
  340. package/src/wayfinding.ts +85 -0
@@ -0,0 +1,95 @@
1
+ import type { PropType } from '@vue/runtime-core'
2
+ import type { KanbanCard, KanbanColumn, DonutSegment, SparklinePoint } from '../dashboard.js'
3
+ const label = { type: String, required: true as const }
4
+ const animated = { type: Boolean, default: true }
5
+ const colors = {
6
+ type: Array as PropType<readonly string[]>,
7
+ default: () => ['#9C5270', '#51847B', '#D5AD6C'],
8
+ }
9
+ export const kanbanProps = {
10
+ id: String,
11
+ label,
12
+ columns: { type: Array as PropType<readonly KanbanColumn[]>, required: true as const },
13
+ modelValue: { type: Array as PropType<readonly KanbanCard[]>, required: true as const },
14
+ query: { type: String, default: '' },
15
+ disabled: Boolean,
16
+ animated,
17
+ draggable: { type: Boolean, default: true },
18
+ moveLabel: { type: String, default: 'Move card' },
19
+ upLabel: { type: String, default: 'Move up' },
20
+ downLabel: { type: String, default: 'Move down' },
21
+ emptyLabel: { type: String, default: 'No cards' },
22
+ fullLabel: { type: String, default: 'Column full' },
23
+ }
24
+ export const donutChartProps = {
25
+ id: String,
26
+ label,
27
+ segments: { type: Array as PropType<readonly DonutSegment[]>, required: true as const },
28
+ modelValue: { type: String as PropType<string | null>, default: null },
29
+ size: { type: Number, default: 220 },
30
+ strokeWidth: { type: Number, default: 12 },
31
+ animated,
32
+ animateNumber: Boolean,
33
+ disabled: Boolean,
34
+ totalLabel: { type: String, default: 'Total' },
35
+ emptyLabel: { type: String, default: 'No data' },
36
+ formatValue: Function as PropType<(value: number) => string>,
37
+ }
38
+ export const sparklineProps = {
39
+ id: String,
40
+ label,
41
+ points: { type: Array as PropType<readonly SparklinePoint[]>, required: true as const },
42
+ domain: Array as unknown as PropType<readonly [number, number]>,
43
+ height: { type: Number, default: 64 },
44
+ color: String,
45
+ animated,
46
+ showData: Boolean,
47
+ dataLabel: { type: String, default: 'View data' },
48
+ emptyLabel: { type: String, default: 'No data' },
49
+ formatValue: Function as PropType<(value: number) => string>,
50
+ }
51
+ const background = {
52
+ id: String,
53
+ colors,
54
+ height: { type: Number, default: 280 },
55
+ radius: { type: String as PropType<'none' | 'sm' | 'md' | 'lg' | 'full'>, default: 'lg' },
56
+ }
57
+ export const gradientBackgroundProps = {
58
+ ...background,
59
+ angle: { type: Number, default: 130 },
60
+ animated,
61
+ active: Boolean,
62
+ duration: { type: Number, default: 12000 },
63
+ }
64
+ export const particleFieldProps = {
65
+ ...background,
66
+ active: Boolean,
67
+ density: { type: Number, default: 12 },
68
+ speed: { type: Number, default: 28 },
69
+ lifetime: { type: Number, default: 3000 },
70
+ duration: Number,
71
+ size: { type: Number, default: 3 },
72
+ shape: { type: String as PropType<'circle' | 'rectangle' | 'ring'>, default: 'circle' },
73
+ backgroundColor: { type: String, default: '#202A32' },
74
+ }
75
+ export const confettiProps = {
76
+ id: String,
77
+ colors,
78
+ trigger: { type: [String, Number], default: 0 },
79
+ count: { type: Number, default: 70 },
80
+ disabled: Boolean,
81
+ }
82
+ export const dashboardEnvironmentProps = { interactive: Boolean }
83
+ export const dashboardPlotProps = { height: { type: Number, required: true as const } }
84
+ export const dashboardShapeProps = {
85
+ d: { type: String, required: true as const },
86
+ viewBox: {
87
+ type: Array as unknown as PropType<readonly [number, number, number, number]>,
88
+ required: true as const,
89
+ },
90
+ color: { type: String, required: true as const },
91
+ strokeWidth: { type: Number, default: 2 },
92
+ start: { type: Number, default: 0 },
93
+ end: { type: Number, default: 1 },
94
+ animated,
95
+ }
@@ -0,0 +1,190 @@
1
+ import type { DataTableComponent } from './discovery-components.js'
2
+ import {
3
+ computed,
4
+ defineComponent,
5
+ h,
6
+ mergeProps,
7
+ type Component,
8
+ type VNodeChild,
9
+ } from '@vue/runtime-core'
10
+ import { choiceKey, type ChoiceValue } from '../choice.js'
11
+ import {
12
+ collectionKeys,
13
+ nextDataSort,
14
+ selectPage,
15
+ validateColumns,
16
+ type DataColumn,
17
+ type DataSort,
18
+ } from '../discovery.js'
19
+ import { dataTableProps } from './discovery-props.js'
20
+ import { useMavisTheme } from './theme.js'
21
+
22
+ export function createDataTable(
23
+ ui: {
24
+ Column: Component
25
+ Row: Component
26
+ Text: Component
27
+ Button: Component
28
+ Checkbox: Component
29
+ Progress: Component
30
+ table: (
31
+ columns: readonly DataColumn[],
32
+ header: VNodeChild[],
33
+ rows: { key: string; cells: VNodeChild[]; selected: boolean }[],
34
+ label: string,
35
+ busy: boolean,
36
+ ) => VNodeChild
37
+ },
38
+ platform: 'web' | 'native',
39
+ ) {
40
+ return defineComponent({
41
+ name: 'MDataTable',
42
+ inheritAttrs: false,
43
+ props: dataTableProps,
44
+ emits: {
45
+ 'update:sort': (_sort: DataSort | null) => true,
46
+ 'update:selected': (_selected: ChoiceValue[]) => true,
47
+ },
48
+ setup(props, { attrs, slots, emit }) {
49
+ const { theme } = useMavisTheme()
50
+ const keys = computed(() => collectionKeys(props.items, props.itemKey))
51
+ const selectable = computed(() =>
52
+ keys.value.filter((_, index) => !props.rowDisabled?.(props.items[index]!)),
53
+ )
54
+ const selectedIds = computed(() => new Set(props.selected.map(choiceKey)))
55
+ function select(page: readonly ChoiceValue[], checked: boolean) {
56
+ if (!props.disabled && !props.loading)
57
+ emit('update:selected', selectPage(props.selected, page, checked))
58
+ }
59
+ return () => {
60
+ validateColumns(props.columns)
61
+ if (
62
+ props.sort &&
63
+ !props.columns.some((column) => column.key === props.sort!.key && column.sortable)
64
+ )
65
+ throw new RangeError('Sort must identify a sortable column.')
66
+ const count = selectable.value.filter((key) => selectedIds.value.has(choiceKey(key))).length
67
+ const headers = props.columns.map((column) =>
68
+ column.sortable
69
+ ? h(ui.Button, {
70
+ text: column.label,
71
+ variant: 'ghost',
72
+ disabled: props.disabled || props.loading,
73
+ icon:
74
+ props.sort?.key !== column.key
75
+ ? 'arrow-up-down'
76
+ : props.sort.direction === 'ascending'
77
+ ? 'arrow-up'
78
+ : 'arrow-down',
79
+ accessibilityLabel: `${column.label}${platform === 'native' && props.sort?.key === column.key ? `, ${props.sort.direction}` : ''}`,
80
+ onClick: () => {
81
+ if (!props.disabled && !props.loading)
82
+ emit('update:sort', nextDataSort(props.sort, column.key))
83
+ },
84
+ })
85
+ : h(ui.Text, { text: column.label, weight: '600', variant: 'caption' }),
86
+ )
87
+ const columns = props.columns.map((column) => ({
88
+ ...column,
89
+ sort: props.sort?.key === column.key ? props.sort.direction : undefined,
90
+ }))
91
+ if (props.selectable) {
92
+ let selectionKey = '__mavis_selection'
93
+ while (columns.some((column) => column.key === selectionKey))
94
+ selectionKey = '_' + selectionKey
95
+ columns.unshift({
96
+ key: selectionKey,
97
+ // The checkbox carries the accessible label; this column has no visible caption.
98
+ label: '',
99
+ width: 64,
100
+ sort: undefined,
101
+ })
102
+ headers.unshift(
103
+ h(ui.Checkbox, {
104
+ label: props.selectAllLabel,
105
+ modelValue: count > 0 && count === selectable.value.length,
106
+ indeterminate: count > 0 && count < selectable.value.length,
107
+ disabled: props.disabled || props.loading || !selectable.value.length,
108
+ 'onUpdate:modelValue': (value: boolean) => select(selectable.value, value),
109
+ ...(platform === 'web' ? { class: 'm-data-table-selection' } : {}),
110
+ }),
111
+ )
112
+ }
113
+ const rows = props.items.map((item, index) => {
114
+ const key = keys.value[index]!
115
+ const cells = props.columns.map((column) => {
116
+ const raw = column.value ? column.value(item) : item[column.key]
117
+ const value =
118
+ raw == null || typeof raw === 'string' || typeof raw === 'number' ? raw : String(raw)
119
+ const slot = { item, itemKey: key, column, value, index }
120
+ return (
121
+ slots[`cell:${column.key}`]?.(slot) ??
122
+ slots.cell?.(slot) ??
123
+ h(ui.Text, {
124
+ text: String(value ?? '—'),
125
+ align: column.align === 'end' ? 'right' : 'left',
126
+ })
127
+ )
128
+ })
129
+ if (props.selectable)
130
+ cells.unshift(
131
+ h(ui.Checkbox, {
132
+ label: `${props.selectLabel} ${props.rowLabel?.(item) ?? String(key)}`,
133
+ modelValue: selectedIds.value.has(choiceKey(key)),
134
+ disabled: props.disabled || props.loading || props.rowDisabled?.(item),
135
+ 'onUpdate:modelValue': (value: boolean) => {
136
+ if (!props.rowDisabled?.(item)) select([key], value)
137
+ },
138
+ ...(platform === 'web' ? { class: 'm-data-table-selection' } : {}),
139
+ }),
140
+ )
141
+ return { key: choiceKey(key), cells, selected: selectedIds.value.has(choiceKey(key)) }
142
+ })
143
+ return h(
144
+ ui.Column,
145
+ mergeProps(
146
+ { id: props.id, gap: 'md' },
147
+ attrs,
148
+ platform === 'web'
149
+ ? {
150
+ class: 'm-data-table',
151
+ style: {
152
+ '--m-color-border': theme.value.colors.border,
153
+ '--m-color-primarySoft': theme.value.colors.primarySoft,
154
+ },
155
+ }
156
+ : {},
157
+ ),
158
+ () => [
159
+ h(ui.Row, { justify: 'between', gap: 'md', wrap: true }, () => [
160
+ h(ui.Text, { as: 'h2', variant: 'heading', text: props.label }),
161
+ slots.actions?.(),
162
+ ]),
163
+ h(
164
+ ui.Column,
165
+ { radius: 'lg', backgroundColor: theme.value.colors.surface, gap: 'none' },
166
+ () => [
167
+ props.loading
168
+ ? h(ui.Progress, { indeterminate: true, label: props.loadingLabel, size: 'sm' })
169
+ : null,
170
+ ui.table(columns, headers, rows, props.label, props.loading),
171
+ !rows.length
172
+ ? (slots.empty?.() ??
173
+ h(ui.Text, {
174
+ text: props.loading ? props.loadingLabel : props.emptyLabel,
175
+ tone: 'muted',
176
+ style: { padding: 24 },
177
+ ...(platform === 'web'
178
+ ? { role: 'status' }
179
+ : { accessibilityLiveRegion: 'polite' }),
180
+ }))
181
+ : null,
182
+ ],
183
+ ),
184
+ slots.footer?.(),
185
+ ],
186
+ )
187
+ }
188
+ },
189
+ }) as unknown as DataTableComponent
190
+ }
@@ -1,4 +1,7 @@
1
- import { computed, watch, type ExtractPropTypes } from '@vue/runtime-core'
1
+ import { createMotionSurface } from '../experimental.js'
2
+ import { componentMotion } from '../motion.js'
3
+ import { useMavisTheme } from './theme.js'
4
+ import { computed, watch, markRaw, onScopeDispose, type ExtractPropTypes } from '@vue/runtime-core'
2
5
  import {
3
6
  addCivilDays,
4
7
  addCivilMonths,
@@ -74,3 +77,29 @@ export function useDateCalendar(
74
77
  )
75
78
  return { words, title, firstDay, cells, weekdays, available, move, canPage, page, key, inRange }
76
79
  }
80
+
81
+ /** Month presentation never delays canonical dates or keyboard focus. */
82
+ export function useCalendarMotion(read: () => string) {
83
+ const { theme } = useMavisTheme()
84
+ const surface = markRaw(createMotionSurface())
85
+ onScopeDispose(
86
+ surface.use((owner) => {
87
+ owner.set({ x: 0, opacity: 1 })
88
+ }),
89
+ )
90
+ watch(
91
+ () => read().slice(0, 7),
92
+ (month, previous) => {
93
+ if (surface.available)
94
+ surface.animate(
95
+ {
96
+ x: [(month > previous ? 1 : -1) * theme.value.motion.enterOffset * 2, 0],
97
+ opacity: [0.65, 1],
98
+ },
99
+ componentMotion(theme.value, 'overlay'),
100
+ )
101
+ },
102
+ { flush: 'post' },
103
+ )
104
+ return surface
105
+ }
@@ -74,6 +74,9 @@ export type DateRangePickerProps = ExtractPublicPropTypes<typeof dateRangePicker
74
74
 
75
75
  /** @internal Shared themed calendar presentation contract. */
76
76
  export const dateCalendarProps = {
77
+ autofocus: { type: Boolean, default: true },
78
+ disabled: Boolean,
79
+ readonly: Boolean,
77
80
  ...dateOptions,
78
81
  activeDate: { type: String as PropType<CivilDate>, required: true as const },
79
82
  selected: { type: String as PropType<CivilDate | null>, default: null },
@@ -0,0 +1,60 @@
1
+ import type { PublicProps, VNode, VNodeChild } from '@vue/runtime-core'
2
+ import type { ComponentProps } from './component-props.js'
3
+ import type { ChoiceValue } from '../choice.js'
4
+ import type { VirtualItemSlot } from '../collections.js'
5
+ import type { DataColumn, DataCellSlot, DataSort } from '../discovery.js'
6
+
7
+ type Key<T> = Extract<keyof T, string> | ((item: T) => ChoiceValue)
8
+ interface Context<P, S> {
9
+ props: P
10
+ attrs: Record<string, unknown>
11
+ emit: (event: string, ...args: unknown[]) => void
12
+ slots: S
13
+ }
14
+ type CarouselProps<T> = PublicProps &
15
+ Omit<ComponentProps['MCarousel'], 'items' | 'itemKey'> & {
16
+ items: readonly T[]
17
+ itemKey?: Key<T>
18
+ 'onUpdate:modelValue'?: (key: ChoiceValue) => void
19
+ }
20
+ type CarouselContext<T> = Context<
21
+ CarouselProps<T>,
22
+ { default?: (scope: VirtualItemSlot<T>) => VNodeChild; empty?: () => VNodeChild }
23
+ >
24
+ export interface CarouselComponent {
25
+ <T>(
26
+ props: NonNullable<Awaited<typeof setup>>['props'],
27
+ context?: Pick<NonNullable<Awaited<typeof setup>>, 'attrs' | 'emit' | 'slots'>,
28
+ exposed?: undefined,
29
+ setup?: Promise<CarouselContext<T>>,
30
+ ): VNode & { __ctx?: NonNullable<Awaited<typeof setup>> }
31
+ }
32
+ type TableProps<T> = PublicProps &
33
+ Omit<
34
+ ComponentProps['MDataTable'],
35
+ 'items' | 'itemKey' | 'columns' | 'rowLabel' | 'rowDisabled'
36
+ > & {
37
+ items: readonly T[]
38
+ itemKey?: Key<T>
39
+ columns: readonly DataColumn<T>[]
40
+ rowLabel?: (item: T) => string
41
+ rowDisabled?: (item: T) => boolean
42
+ 'onUpdate:sort'?: (sort: DataSort | null) => void
43
+ 'onUpdate:selected'?: (keys: ChoiceValue[]) => void
44
+ }
45
+ type TableSlots<T> = {
46
+ cell?: (scope: DataCellSlot<T>) => VNodeChild
47
+ actions?: () => VNodeChild
48
+ footer?: () => VNodeChild
49
+ empty?: () => VNodeChild
50
+ } & {
51
+ [name: `cell:${string}`]: ((scope: DataCellSlot<T>) => VNodeChild) | undefined
52
+ }
53
+ export interface DataTableComponent {
54
+ <T>(
55
+ props: NonNullable<Awaited<typeof setup>>['props'],
56
+ context?: Pick<NonNullable<Awaited<typeof setup>>, 'attrs' | 'emit' | 'slots'>,
57
+ exposed?: undefined,
58
+ setup?: Promise<Context<TableProps<T>, TableSlots<T>>>,
59
+ ): VNode & { __ctx?: NonNullable<Awaited<typeof setup>> }
60
+ }
@@ -0,0 +1,241 @@
1
+ import { useComponentState } from './component-motion.js'
2
+ import {
3
+ computed,
4
+ defineComponent,
5
+ h,
6
+ mergeProps,
7
+ ref,
8
+ watch,
9
+ type Component,
10
+ } from '@vue/runtime-core'
11
+ import { calendarProps, ratingProps } from './discovery-props.js'
12
+ import { ratingValue } from '../discovery.js'
13
+ import {
14
+ civilDate,
15
+ dateAvailability,
16
+ validateDateConstraints,
17
+ validateDateRangeDraft,
18
+ type CivilDate,
19
+ type DateRange,
20
+ } from '../date.js'
21
+ import { useMavisTheme } from './theme.js'
22
+
23
+ interface Primitives {
24
+ Column: Component
25
+ Row: Component
26
+ Text: Component
27
+ Button: Component
28
+ Icon: Component
29
+ Slider: Component
30
+ Calendar: Component
31
+ }
32
+ function initialCalendarDate(
33
+ value: CivilDate | null,
34
+ props: { min?: CivilDate; max?: CivilDate; initialMonth: string },
35
+ ) {
36
+ let date = value ?? props.min ?? civilDate(`${props.initialMonth}-01`)
37
+ if (props.min && date < props.min) date = props.min
38
+ if (props.max && date > props.max) date = props.max
39
+ return date
40
+ }
41
+ export function createDiscoveryControls(ui: Primitives, platform: 'web' | 'native') {
42
+ const MCalendar = defineComponent({
43
+ name: 'MCalendar',
44
+ inheritAttrs: false,
45
+ props: calendarProps,
46
+ emits: {
47
+ 'update:modelValue': (_value: CivilDate | DateRange | null) => true,
48
+ invalid: () => true,
49
+ },
50
+ setup(props, { attrs, emit, slots }) {
51
+ const { theme } = useMavisTheme()
52
+ const selected = computed(() =>
53
+ typeof props.modelValue === 'string' ? civilDate(props.modelValue) : null,
54
+ )
55
+ const range = computed(() =>
56
+ typeof props.modelValue === 'object' && props.modelValue !== null
57
+ ? props.modelValue
58
+ : { start: null, end: null },
59
+ )
60
+ const active = ref<CivilDate>(initialCalendarDate(selected.value ?? range.value.start, props))
61
+ const invalid = ref(false)
62
+ watch(
63
+ () => [props.modelValue, props.initialMonth],
64
+ () => {
65
+ active.value = initialCalendarDate(
66
+ selected.value ?? range.value.end ?? range.value.start,
67
+ props,
68
+ )
69
+ invalid.value = false
70
+ },
71
+ )
72
+ function select(date: CivilDate) {
73
+ if (props.disabled || props.readonly || dateAvailability(date, props)) return
74
+ invalid.value = false
75
+ if (props.mode === 'single') emit('update:modelValue', date)
76
+ else if (!range.value.start || range.value.end)
77
+ emit('update:modelValue', { start: date, end: null })
78
+ else {
79
+ const next =
80
+ date < range.value.start
81
+ ? { start: date, end: range.value.start }
82
+ : { start: range.value.start, end: date }
83
+ if (!validateDateRangeDraft({ start: next.start, end: next.end }, props).valid) {
84
+ invalid.value = true
85
+ emit('invalid')
86
+ } else emit('update:modelValue', next)
87
+ }
88
+ }
89
+ return () => {
90
+ validateDateConstraints(props)
91
+ if (
92
+ props.mode === 'single' &&
93
+ props.modelValue !== null &&
94
+ typeof props.modelValue !== 'string'
95
+ )
96
+ throw new TypeError('Single calendars require a civil date.')
97
+ if (props.mode === 'range' && typeof props.modelValue === 'string')
98
+ throw new TypeError('Range calendars require start and end.')
99
+ for (const date of [range.value.start, range.value.end]) if (date !== null) civilDate(date)
100
+ return h(
101
+ ui.Column,
102
+ mergeProps(
103
+ {
104
+ id: props.id,
105
+ gap: 'md',
106
+ padding: 'sm',
107
+ radius: 'lg',
108
+ backgroundColor: theme.value.colors.surface,
109
+ },
110
+ attrs,
111
+ platform === 'web'
112
+ ? { role: 'group', 'aria-label': props.label, class: 'm-calendar' }
113
+ : {},
114
+ ),
115
+ () => [
116
+ h(ui.Text, { as: 'h2', variant: 'heading', text: props.label }),
117
+ h(ui.Calendar, {
118
+ ...props,
119
+ autofocus: false,
120
+ activeDate: active.value,
121
+ selected: selected.value,
122
+ rangeStart: range.value.start,
123
+ rangeEnd: range.value.end,
124
+ 'onUpdate:activeDate': (date: CivilDate) => {
125
+ active.value = date
126
+ },
127
+ onSelect: select,
128
+ }),
129
+ invalid.value
130
+ ? h(ui.Text, {
131
+ text: props.invalidRangeLabel,
132
+ tone: 'danger',
133
+ ...(platform === 'web'
134
+ ? { role: 'alert' }
135
+ : { accessibilityLiveRegion: 'assertive' }),
136
+ })
137
+ : null,
138
+ slots.footer?.(),
139
+ ],
140
+ )
141
+ }
142
+ },
143
+ })
144
+ const RatingStar = defineComponent({
145
+ props: { filled: Boolean, half: Boolean, readonly: Boolean, disabled: Boolean, label: String },
146
+ emits: ['choose'],
147
+ setup(props, { emit }) {
148
+ const motion = useComponentState(
149
+ () => ({
150
+ scale: props.filled || props.half ? 1 : 0.9,
151
+ rotate: props.filled || props.half ? 0 : -8,
152
+ }),
153
+ 'feedback',
154
+ )
155
+ return () =>
156
+ props.readonly
157
+ ? h(ui.Icon, {
158
+ name: props.half ? 'star-half' : 'star',
159
+ size: 28,
160
+ tone: props.filled || props.half ? 'primary' : 'muted',
161
+ motionSurface: motion,
162
+ accessibilityHidden: true,
163
+ })
164
+ : h(ui.Button, {
165
+ icon: props.half ? 'star-half' : 'star',
166
+ variant: props.filled || props.half ? 'primary' : 'secondary',
167
+ motionSurface: motion,
168
+ disabled: props.disabled,
169
+ accessibilityLabel: props.label,
170
+ onClick: () => emit('choose'),
171
+ })
172
+ },
173
+ })
174
+ const MRating = defineComponent({
175
+ name: 'MRating',
176
+ inheritAttrs: false,
177
+ props: ratingProps,
178
+ emits: { 'update:modelValue': (_value: number) => true },
179
+ setup(props, { attrs, emit }) {
180
+ const value = computed(() => ratingValue(props.modelValue, props.max, props.step))
181
+ const label = (next: number) =>
182
+ props.formatValue?.(next, props.max) ?? `${next} / ${props.max}`
183
+ function choose(next: number) {
184
+ if (!props.readonly && !props.disabled && next !== value.value)
185
+ emit('update:modelValue', ratingValue(next, props.max, props.step))
186
+ }
187
+ return () =>
188
+ h(
189
+ ui.Column,
190
+ mergeProps(
191
+ { id: props.id, gap: 'sm' },
192
+ attrs,
193
+ platform === 'web'
194
+ ? { class: 'm-rating', role: 'group', 'aria-label': props.label }
195
+ : {},
196
+ ),
197
+ () => [
198
+ h(ui.Row, { justify: 'between', gap: 'sm', wrap: true }, () => [
199
+ h(ui.Text, { text: props.label, weight: '600' }),
200
+ h(ui.Text, { text: label(value.value), tone: 'muted', variant: 'caption' }),
201
+ ]),
202
+ h(ui.Row, { gap: 'xs', wrap: true }, () =>
203
+ Array.from({ length: props.max }, (_, index) => {
204
+ const filled = value.value >= index + 1
205
+ const half = value.value > index && !filled
206
+ return h(RatingStar, {
207
+ key: index,
208
+ filled,
209
+ half,
210
+ readonly: props.readonly,
211
+ disabled: props.disabled,
212
+ label: `${props.label}: ${label(index + 1)}`,
213
+ onChoose: () => choose(index + 1),
214
+ })
215
+ }),
216
+ ),
217
+ !props.readonly && props.step === 0.5
218
+ ? h(ui.Slider, {
219
+ modelValue: value.value,
220
+ min: 0,
221
+ max: props.max,
222
+ step: props.step,
223
+ label: props.label,
224
+ disabled: props.disabled,
225
+ 'onUpdate:modelValue': choose,
226
+ })
227
+ : null,
228
+ props.clearable && !props.readonly
229
+ ? h(ui.Button, {
230
+ text: props.clearLabel,
231
+ variant: 'ghost',
232
+ disabled: props.disabled || value.value === 0,
233
+ onClick: () => choose(0),
234
+ })
235
+ : null,
236
+ ],
237
+ )
238
+ },
239
+ })
240
+ return { MCalendar, MRating }
241
+ }