@getcortexlabs/mavis-core 0.1.0-alpha.1 → 0.1.0-alpha.10

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 (417) hide show
  1. package/README.md +2 -2
  2. package/dist/accordion.d.ts +17 -0
  3. package/dist/accordion.d.ts.map +1 -0
  4. package/dist/accordion.js +42 -0
  5. package/dist/accordion.js.map +1 -0
  6. package/dist/alert.d.ts +21 -0
  7. package/dist/alert.d.ts.map +1 -0
  8. package/dist/alert.js +13 -0
  9. package/dist/alert.js.map +1 -0
  10. package/dist/app-icons.d.ts +27 -0
  11. package/dist/app-icons.d.ts.map +1 -0
  12. package/dist/app-icons.js +42 -0
  13. package/dist/app-icons.js.map +1 -0
  14. package/dist/avatar.d.ts +10 -0
  15. package/dist/avatar.d.ts.map +1 -0
  16. package/dist/avatar.js +11 -0
  17. package/dist/avatar.js.map +1 -0
  18. package/dist/badge.d.ts +7 -0
  19. package/dist/badge.d.ts.map +1 -0
  20. package/dist/badge.js +11 -0
  21. package/dist/badge.js.map +1 -0
  22. package/dist/capabilities.d.ts +132 -0
  23. package/dist/capabilities.d.ts.map +1 -0
  24. package/dist/capabilities.js +168 -0
  25. package/dist/capabilities.js.map +1 -0
  26. package/dist/chip.d.ts +9 -0
  27. package/dist/chip.d.ts.map +1 -0
  28. package/dist/chip.js +16 -0
  29. package/dist/chip.js.map +1 -0
  30. package/dist/choice-motion.d.ts +14 -0
  31. package/dist/choice-motion.d.ts.map +1 -0
  32. package/dist/choice-motion.js +5 -0
  33. package/dist/choice-motion.js.map +1 -0
  34. package/dist/choice.d.ts +15 -0
  35. package/dist/choice.d.ts.map +1 -0
  36. package/dist/choice.js +27 -0
  37. package/dist/choice.js.map +1 -0
  38. package/dist/collections.d.ts +46 -0
  39. package/dist/collections.d.ts.map +1 -0
  40. package/dist/collections.js +48 -0
  41. package/dist/collections.js.map +1 -0
  42. package/dist/combobox.d.ts +42 -0
  43. package/dist/combobox.d.ts.map +1 -0
  44. package/dist/combobox.js +159 -0
  45. package/dist/combobox.js.map +1 -0
  46. package/dist/contracts.d.ts +1321 -0
  47. package/dist/contracts.d.ts.map +1 -0
  48. package/dist/contracts.js +268 -0
  49. package/dist/contracts.js.map +1 -0
  50. package/dist/date-input.d.ts +10 -0
  51. package/dist/date-input.d.ts.map +1 -0
  52. package/dist/date-input.js +58 -0
  53. package/dist/date-input.js.map +1 -0
  54. package/dist/date-time.d.ts +19 -0
  55. package/dist/date-time.d.ts.map +1 -0
  56. package/dist/date-time.js +27 -0
  57. package/dist/date-time.js.map +1 -0
  58. package/dist/date.d.ts +96 -0
  59. package/dist/date.d.ts.map +1 -0
  60. package/dist/date.js +235 -0
  61. package/dist/date.js.map +1 -0
  62. package/dist/dialog.d.ts +4 -0
  63. package/dist/dialog.d.ts.map +1 -0
  64. package/dist/dialog.js +21 -0
  65. package/dist/dialog.js.map +1 -0
  66. package/dist/empty-state.d.ts +2 -0
  67. package/dist/empty-state.d.ts.map +1 -0
  68. package/dist/empty-state.js +5 -0
  69. package/dist/empty-state.js.map +1 -0
  70. package/dist/experimental-collections.d.ts +82 -0
  71. package/dist/experimental-collections.d.ts.map +1 -0
  72. package/dist/experimental-collections.js +8 -0
  73. package/dist/experimental-collections.js.map +1 -0
  74. package/dist/experimental-effects.d.ts +107 -0
  75. package/dist/experimental-effects.d.ts.map +1 -0
  76. package/dist/experimental-effects.js +24 -0
  77. package/dist/experimental-effects.js.map +1 -0
  78. package/dist/experimental-platforms.d.ts +94 -0
  79. package/dist/experimental-platforms.d.ts.map +1 -0
  80. package/dist/experimental-platforms.js +2 -0
  81. package/dist/experimental-platforms.js.map +1 -0
  82. package/dist/experimental-playback.d.ts +63 -0
  83. package/dist/experimental-playback.d.ts.map +1 -0
  84. package/dist/experimental-playback.js +46 -0
  85. package/dist/experimental-playback.js.map +1 -0
  86. package/dist/experimental-regions.d.ts +179 -0
  87. package/dist/experimental-regions.d.ts.map +1 -0
  88. package/dist/experimental-regions.js +554 -0
  89. package/dist/experimental-regions.js.map +1 -0
  90. package/dist/experimental-sensors.d.ts +42 -0
  91. package/dist/experimental-sensors.d.ts.map +1 -0
  92. package/dist/experimental-sensors.js +2 -0
  93. package/dist/experimental-sensors.js.map +1 -0
  94. package/dist/experimental-surfaces.d.ts +127 -0
  95. package/dist/experimental-surfaces.d.ts.map +1 -0
  96. package/dist/experimental-surfaces.js +2 -0
  97. package/dist/experimental-surfaces.js.map +1 -0
  98. package/dist/experimental.d.ts +197 -0
  99. package/dist/experimental.d.ts.map +1 -0
  100. package/dist/experimental.js +855 -0
  101. package/dist/experimental.js.map +1 -0
  102. package/dist/files.d.ts +87 -0
  103. package/dist/files.d.ts.map +1 -0
  104. package/dist/files.js +328 -0
  105. package/dist/files.js.map +1 -0
  106. package/dist/form.d.ts +39 -0
  107. package/dist/form.d.ts.map +1 -0
  108. package/dist/form.js +170 -0
  109. package/dist/form.js.map +1 -0
  110. package/dist/grid.d.ts +3 -0
  111. package/dist/grid.d.ts.map +1 -0
  112. package/dist/grid.js +16 -0
  113. package/dist/grid.js.map +1 -0
  114. package/dist/icon.d.ts +15 -0
  115. package/dist/icon.d.ts.map +1 -0
  116. package/dist/icon.js +28 -0
  117. package/dist/icon.js.map +1 -0
  118. package/dist/icons.d.ts +2002 -0
  119. package/dist/icons.d.ts.map +1 -0
  120. package/dist/icons.js +2003 -0
  121. package/dist/icons.js.map +1 -0
  122. package/dist/index.d.ts +56 -3
  123. package/dist/index.d.ts.map +1 -1
  124. package/dist/index.js +39 -1
  125. package/dist/index.js.map +1 -1
  126. package/dist/input.d.ts +14 -0
  127. package/dist/input.d.ts.map +1 -1
  128. package/dist/input.js +12 -0
  129. package/dist/input.js.map +1 -1
  130. package/dist/link.d.ts +36 -0
  131. package/dist/link.d.ts.map +1 -0
  132. package/dist/link.js +60 -0
  133. package/dist/link.js.map +1 -0
  134. package/dist/list-item.d.ts +3 -0
  135. package/dist/list-item.d.ts.map +1 -0
  136. package/dist/list-item.js +7 -0
  137. package/dist/list-item.js.map +1 -0
  138. package/dist/motion.d.ts +58 -0
  139. package/dist/motion.d.ts.map +1 -0
  140. package/dist/motion.js +73 -0
  141. package/dist/motion.js.map +1 -0
  142. package/dist/multi-select.d.ts +4 -0
  143. package/dist/multi-select.d.ts.map +1 -0
  144. package/dist/multi-select.js +23 -0
  145. package/dist/multi-select.js.map +1 -0
  146. package/dist/navigation-transition.d.ts +10 -0
  147. package/dist/navigation-transition.d.ts.map +1 -0
  148. package/dist/navigation-transition.js +10 -0
  149. package/dist/navigation-transition.js.map +1 -0
  150. package/dist/navigation.d.ts +22 -0
  151. package/dist/navigation.d.ts.map +1 -0
  152. package/dist/navigation.js +54 -0
  153. package/dist/navigation.js.map +1 -0
  154. package/dist/number-input.d.ts +21 -0
  155. package/dist/number-input.d.ts.map +1 -0
  156. package/dist/number-input.js +63 -0
  157. package/dist/number-input.js.map +1 -0
  158. package/dist/popover.d.ts +17 -0
  159. package/dist/popover.d.ts.map +1 -0
  160. package/dist/popover.js +19 -0
  161. package/dist/popover.js.map +1 -0
  162. package/dist/progress.d.ts +19 -0
  163. package/dist/progress.d.ts.map +1 -0
  164. package/dist/progress.js +19 -0
  165. package/dist/progress.js.map +1 -0
  166. package/dist/responsive.d.ts +18 -0
  167. package/dist/responsive.d.ts.map +1 -0
  168. package/dist/responsive.js +35 -0
  169. package/dist/responsive.js.map +1 -0
  170. package/dist/section-scroll.d.ts +14 -0
  171. package/dist/section-scroll.d.ts.map +1 -0
  172. package/dist/section-scroll.js +28 -0
  173. package/dist/section-scroll.js.map +1 -0
  174. package/dist/segmented.d.ts +11 -0
  175. package/dist/segmented.d.ts.map +1 -0
  176. package/dist/segmented.js +30 -0
  177. package/dist/segmented.js.map +1 -0
  178. package/dist/sheet.d.ts +19 -0
  179. package/dist/sheet.d.ts.map +1 -0
  180. package/dist/sheet.js +15 -0
  181. package/dist/sheet.js.map +1 -0
  182. package/dist/tabs.d.ts +11 -0
  183. package/dist/tabs.d.ts.map +1 -0
  184. package/dist/tabs.js +28 -0
  185. package/dist/tabs.js.map +1 -0
  186. package/dist/theme/themes.d.ts.map +1 -1
  187. package/dist/theme/themes.js +85 -12
  188. package/dist/theme/themes.js.map +1 -1
  189. package/dist/theme/types.d.ts +64 -4
  190. package/dist/theme/types.d.ts.map +1 -1
  191. package/dist/theme/typography.d.ts +10 -0
  192. package/dist/theme/typography.d.ts.map +1 -0
  193. package/dist/theme/typography.js +90 -0
  194. package/dist/theme/typography.js.map +1 -0
  195. package/dist/time.d.ts +34 -0
  196. package/dist/time.d.ts.map +1 -0
  197. package/dist/time.js +78 -0
  198. package/dist/time.js.map +1 -0
  199. package/dist/toast.d.ts +43 -0
  200. package/dist/toast.d.ts.map +1 -0
  201. package/dist/toast.js +228 -0
  202. package/dist/toast.js.map +1 -0
  203. package/dist/vue/button-content.d.ts +10 -0
  204. package/dist/vue/button-content.d.ts.map +1 -0
  205. package/dist/vue/button-content.js +54 -0
  206. package/dist/vue/button-content.js.map +1 -0
  207. package/dist/vue/cached-activity.d.ts +3 -0
  208. package/dist/vue/cached-activity.d.ts.map +1 -0
  209. package/dist/vue/cached-activity.js +13 -0
  210. package/dist/vue/cached-activity.js.map +1 -0
  211. package/dist/vue/combobox.d.ts +155 -0
  212. package/dist/vue/combobox.d.ts.map +1 -0
  213. package/dist/vue/combobox.js +195 -0
  214. package/dist/vue/combobox.js.map +1 -0
  215. package/dist/vue/component-props.d.ts +2853 -0
  216. package/dist/vue/component-props.d.ts.map +1 -0
  217. package/dist/vue/component-props.js +29 -0
  218. package/dist/vue/component-props.js.map +1 -0
  219. package/dist/vue/configurator-props.d.ts +277 -0
  220. package/dist/vue/configurator-props.d.ts.map +1 -0
  221. package/dist/vue/configurator-props.js +63 -0
  222. package/dist/vue/configurator-props.js.map +1 -0
  223. package/dist/vue/configurator.d.ts +403 -0
  224. package/dist/vue/configurator.d.ts.map +1 -0
  225. package/dist/vue/configurator.js +287 -0
  226. package/dist/vue/configurator.js.map +1 -0
  227. package/dist/vue/contracts.d.ts +18 -0
  228. package/dist/vue/contracts.d.ts.map +1 -0
  229. package/dist/vue/contracts.js +24 -0
  230. package/dist/vue/contracts.js.map +1 -0
  231. package/dist/vue/date-calendar.d.ts +64 -0
  232. package/dist/vue/date-calendar.d.ts.map +1 -0
  233. package/dist/vue/date-calendar.js +65 -0
  234. package/dist/vue/date-calendar.js.map +1 -0
  235. package/dist/vue/date-picker.d.ts +1000 -0
  236. package/dist/vue/date-picker.d.ts.map +1 -0
  237. package/dist/vue/date-picker.js +334 -0
  238. package/dist/vue/date-picker.js.map +1 -0
  239. package/dist/vue/date-props.d.ts +272 -0
  240. package/dist/vue/date-props.d.ts.map +1 -0
  241. package/dist/vue/date-props.js +78 -0
  242. package/dist/vue/date-props.js.map +1 -0
  243. package/dist/vue/dialog.d.ts +21 -0
  244. package/dist/vue/dialog.d.ts.map +1 -0
  245. package/dist/vue/dialog.js +58 -0
  246. package/dist/vue/dialog.js.map +1 -0
  247. package/dist/vue/files.d.ts +53 -0
  248. package/dist/vue/files.d.ts.map +1 -0
  249. package/dist/vue/files.js +40 -0
  250. package/dist/vue/files.js.map +1 -0
  251. package/dist/vue/forms.d.ts +4 -0
  252. package/dist/vue/forms.d.ts.map +1 -0
  253. package/dist/vue/forms.js +15 -0
  254. package/dist/vue/forms.js.map +1 -0
  255. package/dist/vue/global-components.d.ts +198 -3
  256. package/dist/vue/global-components.d.ts.map +1 -1
  257. package/dist/vue/index.d.ts +44 -4
  258. package/dist/vue/index.d.ts.map +1 -1
  259. package/dist/vue/index.js +36 -2
  260. package/dist/vue/index.js.map +1 -1
  261. package/dist/vue/inline-content.d.ts +54 -0
  262. package/dist/vue/inline-content.d.ts.map +1 -0
  263. package/dist/vue/inline-content.js +64 -0
  264. package/dist/vue/inline-content.js.map +1 -0
  265. package/dist/vue/layout-context.d.ts +4 -2
  266. package/dist/vue/layout-context.d.ts.map +1 -1
  267. package/dist/vue/layout-context.js +7 -2
  268. package/dist/vue/layout-context.js.map +1 -1
  269. package/dist/vue/list-motion.d.ts +7 -0
  270. package/dist/vue/list-motion.d.ts.map +1 -0
  271. package/dist/vue/list-motion.js +28 -0
  272. package/dist/vue/list-motion.js.map +1 -0
  273. package/dist/vue/loading-effect.d.ts +7 -0
  274. package/dist/vue/loading-effect.d.ts.map +1 -0
  275. package/dist/vue/loading-effect.js +32 -0
  276. package/dist/vue/loading-effect.js.map +1 -0
  277. package/dist/vue/menu.d.ts +122 -0
  278. package/dist/vue/menu.d.ts.map +1 -0
  279. package/dist/vue/menu.js +79 -0
  280. package/dist/vue/menu.js.map +1 -0
  281. package/dist/vue/navigation-controls.d.ts +124 -0
  282. package/dist/vue/navigation-controls.d.ts.map +1 -0
  283. package/dist/vue/navigation-controls.js +117 -0
  284. package/dist/vue/navigation-controls.js.map +1 -0
  285. package/dist/vue/navigation-props.d.ts +283 -0
  286. package/dist/vue/navigation-props.d.ts.map +1 -0
  287. package/dist/vue/navigation-props.js +82 -0
  288. package/dist/vue/navigation-props.js.map +1 -0
  289. package/dist/vue/navigation.d.ts +7 -0
  290. package/dist/vue/navigation.d.ts.map +1 -0
  291. package/dist/vue/navigation.js +15 -0
  292. package/dist/vue/navigation.js.map +1 -0
  293. package/dist/vue/platform.d.ts +37 -0
  294. package/dist/vue/platform.d.ts.map +1 -0
  295. package/dist/vue/platform.js +46 -0
  296. package/dist/vue/platform.js.map +1 -0
  297. package/dist/vue/props.d.ts +3326 -510
  298. package/dist/vue/props.d.ts.map +1 -1
  299. package/dist/vue/props.js +314 -83
  300. package/dist/vue/props.js.map +1 -1
  301. package/dist/vue/reveal-state.d.ts +18 -0
  302. package/dist/vue/reveal-state.d.ts.map +1 -0
  303. package/dist/vue/reveal-state.js +76 -0
  304. package/dist/vue/reveal-state.js.map +1 -0
  305. package/dist/vue/theme-provider.d.ts +58 -0
  306. package/dist/vue/theme-provider.d.ts.map +1 -0
  307. package/dist/vue/theme-provider.js +69 -0
  308. package/dist/vue/theme-provider.js.map +1 -0
  309. package/dist/vue/theme.d.ts +1029 -19
  310. package/dist/vue/theme.d.ts.map +1 -1
  311. package/dist/vue/theme.js +47 -2
  312. package/dist/vue/theme.js.map +1 -1
  313. package/dist/vue/time-picker.d.ts +488 -0
  314. package/dist/vue/time-picker.d.ts.map +1 -0
  315. package/dist/vue/time-picker.js +190 -0
  316. package/dist/vue/time-picker.js.map +1 -0
  317. package/dist/vue/toast.d.ts +29 -0
  318. package/dist/vue/toast.d.ts.map +1 -0
  319. package/dist/vue/toast.js +79 -0
  320. package/dist/vue/toast.js.map +1 -0
  321. package/dist/vue/virtual-list.d.ts +26 -0
  322. package/dist/vue/virtual-list.d.ts.map +1 -0
  323. package/dist/vue/virtual-list.js +2 -0
  324. package/dist/vue/virtual-list.js.map +1 -0
  325. package/dist/vue/workflow-props.d.ts +110 -0
  326. package/dist/vue/workflow-props.d.ts.map +1 -0
  327. package/dist/vue/workflow-props.js +37 -0
  328. package/dist/vue/workflow-props.js.map +1 -0
  329. package/dist/vue/workflows.d.ts +267 -0
  330. package/dist/vue/workflows.d.ts.map +1 -0
  331. package/dist/vue/workflows.js +200 -0
  332. package/dist/vue/workflows.js.map +1 -0
  333. package/package.json +5 -1
  334. package/src/accordion.ts +66 -0
  335. package/src/alert.ts +16 -0
  336. package/src/app-icons.ts +57 -0
  337. package/src/avatar.ts +11 -0
  338. package/src/badge.ts +11 -0
  339. package/src/capabilities.ts +171 -0
  340. package/src/chip.ts +20 -0
  341. package/src/choice-motion.ts +12 -0
  342. package/src/choice.ts +41 -0
  343. package/src/collections.ts +87 -0
  344. package/src/combobox.ts +198 -0
  345. package/src/contracts.ts +324 -0
  346. package/src/date-input.ts +87 -0
  347. package/src/date-time.ts +37 -0
  348. package/src/date.ts +280 -0
  349. package/src/dialog.ts +22 -0
  350. package/src/empty-state.ts +4 -0
  351. package/src/experimental-collections.ts +87 -0
  352. package/src/experimental-effects.ts +146 -0
  353. package/src/experimental-platforms.ts +96 -0
  354. package/src/experimental-playback.ts +115 -0
  355. package/src/experimental-regions.ts +777 -0
  356. package/src/experimental-sensors.ts +50 -0
  357. package/src/experimental-surfaces.ts +124 -0
  358. package/src/experimental.ts +1102 -0
  359. package/src/files.ts +408 -0
  360. package/src/form.ts +190 -0
  361. package/src/grid.ts +19 -0
  362. package/src/icon.ts +30 -0
  363. package/src/icons.ts +2002 -0
  364. package/src/index.ts +88 -2
  365. package/src/input.ts +27 -0
  366. package/src/link.ts +91 -0
  367. package/src/list-item.ts +5 -0
  368. package/src/motion.ts +80 -0
  369. package/src/multi-select.ts +30 -0
  370. package/src/navigation-transition.ts +14 -0
  371. package/src/navigation.ts +61 -0
  372. package/src/number-input.ts +80 -0
  373. package/src/popover.ts +38 -0
  374. package/src/progress.ts +22 -0
  375. package/src/responsive.ts +61 -0
  376. package/src/section-scroll.ts +46 -0
  377. package/src/segmented.ts +39 -0
  378. package/src/sheet.ts +31 -0
  379. package/src/tabs.ts +35 -0
  380. package/src/theme/themes.ts +89 -12
  381. package/src/theme/types.ts +55 -2
  382. package/src/theme/typography.ts +84 -0
  383. package/src/time.ts +83 -0
  384. package/src/toast.ts +249 -0
  385. package/src/vue/button-content.ts +60 -0
  386. package/src/vue/cached-activity.ts +13 -0
  387. package/src/vue/combobox.ts +238 -0
  388. package/src/vue/component-props.ts +42 -0
  389. package/src/vue/configurator-props.ts +67 -0
  390. package/src/vue/configurator.ts +350 -0
  391. package/src/vue/contracts.ts +39 -0
  392. package/src/vue/date-calendar.ts +76 -0
  393. package/src/vue/date-picker.ts +410 -0
  394. package/src/vue/date-props.ts +86 -0
  395. package/src/vue/dialog.ts +63 -0
  396. package/src/vue/files.ts +53 -0
  397. package/src/vue/forms.ts +20 -0
  398. package/src/vue/global-components.ts +182 -4
  399. package/src/vue/index.ts +84 -4
  400. package/src/vue/inline-content.ts +71 -0
  401. package/src/vue/layout-context.ts +10 -3
  402. package/src/vue/list-motion.ts +31 -0
  403. package/src/vue/loading-effect.ts +44 -0
  404. package/src/vue/menu.ts +100 -0
  405. package/src/vue/navigation-controls.ts +138 -0
  406. package/src/vue/navigation-props.ts +87 -0
  407. package/src/vue/navigation.ts +16 -0
  408. package/src/vue/platform.ts +73 -0
  409. package/src/vue/props.ts +348 -96
  410. package/src/vue/reveal-state.ts +83 -0
  411. package/src/vue/theme-provider.ts +74 -0
  412. package/src/vue/theme.ts +65 -3
  413. package/src/vue/time-picker.ts +227 -0
  414. package/src/vue/toast.ts +99 -0
  415. package/src/vue/virtual-list.ts +28 -0
  416. package/src/vue/workflow-props.ts +41 -0
  417. package/src/vue/workflows.ts +257 -0
package/src/vue/theme.ts CHANGED
@@ -2,17 +2,79 @@ import { inject, readonly, shallowRef, type InjectionKey } from '@vue/runtime-co
2
2
  import { mavis } from '../theme/themes.js'
3
3
  import type { MavisTheme } from '../theme/types.js'
4
4
 
5
- export function createThemeContext(initial: MavisTheme) {
5
+ export type Appearance = MavisTheme['appearance']
6
+ export type AppearanceMode = Appearance | 'system'
7
+
8
+ /** Platform access to the device appearance; `current` is undefined while it is unknown, such as during SSR. */
9
+ export interface AppearanceSource {
10
+ current(): Appearance | undefined
11
+ observe(listener: (appearance: Appearance) => void): () => void
12
+ }
13
+
14
+ export interface ThemeContextOptions {
15
+ theme?: MavisTheme
16
+ darkTheme?: MavisTheme
17
+ appearance?: AppearanceMode
18
+ source?: AppearanceSource
19
+ }
20
+
21
+ const modes: readonly AppearanceMode[] = ['system', 'light', 'dark']
22
+
23
+ function checkMode(mode: AppearanceMode) {
24
+ if (!modes.includes(mode)) throw new RangeError(`Unknown appearance mode: ${String(mode)}`)
25
+ return mode
26
+ }
27
+
28
+ export function createThemeContext(options: MavisTheme | ThemeContextOptions = {}) {
29
+ const config: ThemeContextOptions = 'colors' in options ? { theme: options } : options
30
+ const initial = config.theme ?? mavis
31
+ const themes = shallowRef<Partial<Record<Appearance, MavisTheme>>>({
32
+ [initial.appearance]: initial,
33
+ })
34
+ if (config.darkTheme) {
35
+ if (config.darkTheme.appearance !== 'dark')
36
+ throw new RangeError('darkTheme must have dark appearance')
37
+ themes.value.dark = config.darkTheme
38
+ }
39
+ const appearance = shallowRef(checkMode(config.appearance ?? 'system'))
6
40
  const theme = shallowRef(initial)
41
+ const systemAppearance = shallowRef(config.source?.current())
42
+ const resolve = () => {
43
+ const wanted =
44
+ appearance.value === 'system'
45
+ ? (systemAppearance.value ?? initial.appearance)
46
+ : appearance.value
47
+ theme.value =
48
+ themes.value[wanted] ?? themes.value[wanted === 'dark' ? 'light' : 'dark'] ?? initial
49
+ }
50
+ resolve()
51
+ const stop = config.source?.observe((next) => {
52
+ systemAppearance.value = next
53
+ if (appearance.value === 'system') resolve()
54
+ })
7
55
  return {
8
56
  theme: readonly(theme),
57
+ themes: readonly(themes),
58
+ systemAppearance: readonly(systemAppearance),
59
+ /** The selection: `system` follows the device; `light` and `dark` are explicit overrides. */
60
+ appearance: readonly(appearance),
61
+ setAppearance(mode: AppearanceMode) {
62
+ appearance.value = checkMode(mode)
63
+ resolve()
64
+ },
65
+ /** Registers the theme for its own appearance and pins that appearance. */
9
66
  setTheme(next: MavisTheme) {
10
- theme.value = next
67
+ themes.value = { ...themes.value, [next.appearance]: next }
68
+ appearance.value = next.appearance
69
+ resolve()
70
+ },
71
+ dispose() {
72
+ stop?.()
11
73
  },
12
74
  }
13
75
  }
14
-
15
76
  export type MavisThemeContext = ReturnType<typeof createThemeContext>
77
+
16
78
  export const themeKey: InjectionKey<MavisThemeContext> = Symbol('mavis.theme')
17
79
 
18
80
  /** Without the plugin, individually imported components use the default theme. */
@@ -0,0 +1,227 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ mergeProps,
6
+ nextTick,
7
+ onBeforeUnmount,
8
+ ref,
9
+ watch,
10
+ type Component,
11
+ } from '@vue/runtime-core'
12
+ import {
13
+ formatTime,
14
+ localTime,
15
+ parseTime,
16
+ timeOptions,
17
+ validateTime,
18
+ type LocalTime,
19
+ type TimeValidation,
20
+ } from '../time.js'
21
+ import type { InputActionHandle, InputHandle } from '../input.js'
22
+ import { timePickerProps } from './navigation-props.js'
23
+ import { useButtonAction } from './button-content.js'
24
+
25
+ export function createTimePicker(
26
+ ui: {
27
+ Input: Component
28
+ Column: Component
29
+ Row: Component
30
+ Button: Component
31
+ Text: Component
32
+ Sheet: Component
33
+ Picker: Component
34
+ beforeOpen?: () => void
35
+ },
36
+ platform: 'web' | 'native',
37
+ ) {
38
+ const TimePicker = defineComponent({
39
+ name: 'MTimePicker',
40
+ inheritAttrs: false,
41
+ props: timePickerProps,
42
+ emits: {
43
+ 'update:modelValue': (_value: LocalTime | null) => true,
44
+ 'update:draft': (_value: string) => true,
45
+ validityChange: (_value: TimeValidation) => true,
46
+ focus: () => true,
47
+ blur: () => true,
48
+ },
49
+ setup(props, { attrs, emit, expose }) {
50
+ useButtonAction()
51
+ const editor = ref<InputActionHandle>()
52
+ const local = ref(props.draft ?? formatTime(props.modelValue, props))
53
+ const draft = computed(() => props.draft ?? local.value)
54
+ const validation = computed(() => parseTime(draft.value, props))
55
+ watch(validation, (value) => emit('validityChange', value), { immediate: true })
56
+ const open = ref(false)
57
+ const picked = ref<LocalTime>('00:00')
58
+ const touched = ref(false)
59
+ let alive = true
60
+ let revision = 0
61
+ let requested: LocalTime | null | undefined
62
+ onBeforeUnmount(() => {
63
+ alive = false
64
+ })
65
+ const setDraft = (value: string) => {
66
+ local.value = value
67
+ emit('update:draft', value)
68
+ }
69
+ watch(
70
+ () => [props.modelValue, props.locale, props.hourCycle] as const,
71
+ (value, previous) => {
72
+ if (value[0] !== requested || value[1] !== previous[1] || value[2] !== previous[2])
73
+ setDraft(formatTime(value[0], props))
74
+ requested = undefined
75
+ },
76
+ )
77
+ watch(
78
+ () => props.draft,
79
+ (value) => {
80
+ if (value !== undefined) local.value = value
81
+ },
82
+ )
83
+ watch(
84
+ () => props.disabled || props.readonly,
85
+ (blocked) => {
86
+ if (blocked) open.value = false
87
+ },
88
+ )
89
+ function publish(value: LocalTime | null) {
90
+ const current = ++revision
91
+ requested = value
92
+ emit('update:modelValue', value)
93
+ void nextTick(() => {
94
+ if (!alive || current !== revision) return
95
+ if (props.modelValue !== value) setDraft(formatTime(props.modelValue, props))
96
+ requested = undefined
97
+ })
98
+ }
99
+ function edit(value: string) {
100
+ if (props.disabled || props.readonly) return
101
+ revision++
102
+ setDraft(value)
103
+ const next = parseTime(value, props)
104
+ if (next.status === 'valid' || next.status === 'empty') publish(next.value)
105
+ }
106
+ function close() {
107
+ open.value = false
108
+ if (platform === 'native')
109
+ void nextTick(() => {
110
+ if (alive && !props.disabled) editor.value?.focusAction()
111
+ })
112
+ }
113
+ function choose() {
114
+ if (props.disabled || props.readonly) return
115
+ const options = timeOptions(props)
116
+ const value =
117
+ validation.value.status === 'valid' ? validation.value.value : props.modelValue
118
+ picked.value =
119
+ validateTime(value, props).status === 'valid'
120
+ ? value!
121
+ : localTime(Math.ceil(options.min / options.step) * options.step)
122
+ ui.beforeOpen?.()
123
+ editor.value?.focusAction()
124
+ open.value = true
125
+ }
126
+ expose({
127
+ focus: () => editor.value?.focus(),
128
+ blur: () => editor.value?.blur(),
129
+ } satisfies InputHandle)
130
+ return () => {
131
+ const options = timeOptions(props)
132
+ if (!props.label.trim()) throw new TypeError('TimePicker requires a label.')
133
+ const issue =
134
+ !['valid', 'empty'].includes(validation.value.status) &&
135
+ (validation.value.status !== 'incomplete' || touched.value)
136
+ const selected = validateTime(picked.value, props)
137
+ return h(ui.Column, { width: props.width, grow: props.grow, shrink: props.shrink }, () => [
138
+ h(
139
+ ui.Input,
140
+ mergeProps(attrs, {
141
+ ref: editor,
142
+ id: props.id,
143
+ label: props.label,
144
+ modelValue: draft.value,
145
+ placeholder: props.placeholder ?? (options.cycle === 'h23' ? 'HH:mm' : 'h:mm AM/PM'),
146
+ disabled: props.disabled,
147
+ readonly: props.readonly,
148
+ required: props.required,
149
+ helperText: props.helperText,
150
+ error: props.error || (issue ? props.invalidLabel : ''),
151
+ autocapitalize: 'none',
152
+ autocorrect: false,
153
+ trailingAction: {
154
+ icon: 'clock',
155
+ label: props.chooseLabel,
156
+ disabled: props.disabled || props.readonly,
157
+ },
158
+ 'onUpdate:modelValue': edit,
159
+ onAction: choose,
160
+ onFocus: () => emit('focus'),
161
+ onBlur: () => {
162
+ touched.value = true
163
+ emit('blur')
164
+ },
165
+ }),
166
+ ),
167
+ platform === 'web' && props.name
168
+ ? h('input', {
169
+ type: 'hidden',
170
+ name: props.name,
171
+ disabled: props.disabled,
172
+ value: props.modelValue ?? '',
173
+ })
174
+ : null,
175
+ h(
176
+ ui.Sheet,
177
+ {
178
+ open: open.value,
179
+ title: props.label,
180
+ closeLabel: props.cancelLabel,
181
+ 'onUpdate:open': (value: boolean) => {
182
+ if (!value) close()
183
+ },
184
+ },
185
+ () => [
186
+ h(ui.Picker, {
187
+ ...props,
188
+ modelValue: picked.value,
189
+ 'onUpdate:modelValue': (value: LocalTime) => {
190
+ picked.value = value
191
+ },
192
+ }),
193
+ selected.status !== 'valid'
194
+ ? h(ui.Text, { text: props.invalidLabel, tone: 'danger' })
195
+ : null,
196
+ h(ui.Row, { gap: 'sm', wrap: true }, () => [
197
+ h(ui.Button, {
198
+ text: props.confirmLabel,
199
+ disabled: selected.status !== 'valid' || props.disabled || props.readonly,
200
+ onClick: () => {
201
+ const next = validateTime(picked.value, props)
202
+ if (props.disabled || props.readonly || next.status !== 'valid') return
203
+ setDraft(formatTime(next.value, props))
204
+ publish(next.value)
205
+ close()
206
+ },
207
+ }),
208
+ h(ui.Button, {
209
+ text: props.clearLabel,
210
+ variant: 'ghost',
211
+ disabled: props.disabled || props.readonly || props.required,
212
+ onClick: () => {
213
+ if (props.disabled || props.readonly || props.required) return
214
+ setDraft('')
215
+ publish(null)
216
+ close()
217
+ },
218
+ }),
219
+ ]),
220
+ ],
221
+ ),
222
+ ])
223
+ }
224
+ },
225
+ })
226
+ return TimePicker as typeof TimePicker & { new (): InstanceType<typeof TimePicker> & InputHandle }
227
+ }
@@ -0,0 +1,99 @@
1
+ import {
2
+ getCurrentScope,
3
+ inject,
4
+ onScopeDispose,
5
+ ref,
6
+ shallowRef,
7
+ watch,
8
+ type App,
9
+ type InjectionKey,
10
+ type Ref,
11
+ } from '@vue/runtime-core'
12
+ import {
13
+ createToastController,
14
+ connectToast,
15
+ disposeToast,
16
+ type ToastController,
17
+ type ToastConnection,
18
+ type ToastSnapshot,
19
+ } from '../toast.js'
20
+
21
+ type AppToast = { controller: ToastController; requested: Ref<boolean>; closeLabel: string }
22
+ const appToastKey: InjectionKey<AppToast> = Symbol('mavis.appToast')
23
+
24
+ /** @internal Each plugin instance owns one queue, never a process-wide SSR singleton. */
25
+ export function installAppToast(app: App, options: { closeLabel?: string } = {}) {
26
+ const controller = createToastController({ persistent: true })
27
+ app.provide(appToastKey, {
28
+ controller,
29
+ requested: ref(false),
30
+ closeLabel: options.closeLabel ?? 'Dismiss notification',
31
+ })
32
+ app.onUnmount(() => disposeToast(controller))
33
+ }
34
+
35
+ /** @internal Screens only mount their application host after an app queue is requested. */
36
+ export function useAppToastHost() {
37
+ return inject(appToastKey, undefined)
38
+ }
39
+
40
+ /** Local by default. The app queue is owned by createMavis and hosted by each active Screen. */
41
+ export function useToast(options: { scope?: 'local' | 'app' } = {}): ToastController {
42
+ if (!getCurrentScope()) throw new Error('useToast must run inside a Vue setup or effect scope')
43
+ if (options.scope === 'app') {
44
+ const app = inject(appToastKey, undefined)
45
+ if (!app) throw new Error('App Toast needs createMavis on the current Vue app')
46
+ app.requested.value = true
47
+ return app.controller
48
+ }
49
+ const controller = createToastController()
50
+ onScopeDispose(() => disposeToast(controller))
51
+ return controller
52
+ }
53
+
54
+ /** @internal Shared renderer binding; platform lifecycles activate and pause its clock. */
55
+ export function useToastHost(controller: () => ToastController) {
56
+ const snapshot = shallowRef<ToastSnapshot>({ visible: false })
57
+ let connection: ToastConnection | undefined
58
+ let active = false
59
+ const pauses = new Set<string>()
60
+ watch(
61
+ controller,
62
+ (next) => {
63
+ connection?.dispose()
64
+ connection = connectToast(next, (value) => {
65
+ snapshot.value = value
66
+ })
67
+ for (const reason of pauses) connection.pause(reason, true)
68
+ if (active) connection.activate()
69
+ },
70
+ { immediate: true, flush: 'sync' },
71
+ )
72
+ onScopeDispose(() => connection?.dispose())
73
+ return {
74
+ snapshot,
75
+ activate() {
76
+ active = true
77
+ connection?.activate()
78
+ },
79
+ deactivate() {
80
+ active = false
81
+ pauses.clear()
82
+ connection?.deactivate()
83
+ },
84
+ pause(reason: string, paused: boolean) {
85
+ if (paused) pauses.add(reason)
86
+ else pauses.delete(reason)
87
+ connection?.pause(reason, paused)
88
+ },
89
+ begin(id: number) {
90
+ connection?.begin(id)
91
+ },
92
+ entered(id: number) {
93
+ connection?.entered(id)
94
+ },
95
+ left(id: number) {
96
+ connection?.left(id)
97
+ },
98
+ }
99
+ }
@@ -0,0 +1,28 @@
1
+ import type { VNode, VNodeChild, PublicProps } from '@vue/runtime-core'
2
+ import type { ChoiceValue } from '../choice.js'
3
+ import type { VirtualItemSlot, VirtualListHandle } from '../collections.js'
4
+ import type { ComponentProps } from './component-props.js'
5
+
6
+ /** Both renderers expose the same item type to template slots and key callbacks. */
7
+ type VirtualListProps<T> = PublicProps &
8
+ Omit<ComponentProps['MVirtualList'], 'items' | 'itemKey'> & {
9
+ items: readonly T[]
10
+ itemKey?: Extract<keyof T, string> | ((item: T) => ChoiceValue)
11
+ }
12
+ type VirtualListContext<T> = {
13
+ props: VirtualListProps<T>
14
+ attrs: Record<string, unknown>
15
+ emit: (event: string, ...args: unknown[]) => void
16
+ slots: { default?: (scope: VirtualItemSlot<T>) => VNodeChild; empty?: () => VNodeChild }
17
+ expose(exposed: VirtualListHandle): void
18
+ }
19
+ export interface VirtualListComponent {
20
+ <T>(
21
+ props: NonNullable<Awaited<typeof setup>>['props'],
22
+ context?: Pick<NonNullable<Awaited<typeof setup>>, 'attrs' | 'emit' | 'slots'>,
23
+ exposed?: NonNullable<Awaited<typeof setup>>['expose'],
24
+ setup?: Promise<VirtualListContext<T>>,
25
+ ): VNode & {
26
+ __ctx?: NonNullable<Awaited<typeof setup>>
27
+ }
28
+ }
@@ -0,0 +1,41 @@
1
+ import type { PropType } from '@vue/runtime-core'
2
+ import type { FormController } from '../form.js'
3
+ import type { StepOption } from '../navigation.js'
4
+ import type { ChoiceValue } from '../choice.js'
5
+
6
+ export const formGroupProps = {
7
+ label: { type: String, required: true as const },
8
+ description: { type: String, default: '' },
9
+ id: { type: String, default: undefined },
10
+ }
11
+ export const formErrorsProps = {
12
+ form: { type: Object as PropType<FormController>, required: true as const },
13
+ title: { type: String, default: 'Review these fields' },
14
+ announce: Boolean,
15
+ }
16
+ export const stepsProps = {
17
+ steps: { type: Array as PropType<readonly StepOption[]>, required: true as const },
18
+ modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
19
+ label: { type: String, required: true as const },
20
+ disabled: Boolean,
21
+ loading: Boolean,
22
+ currentLabel: { type: String, default: 'Current' },
23
+ completeLabel: { type: String, default: 'Complete' },
24
+ errorLabel: { type: String, default: 'Needs attention' },
25
+ }
26
+ export const paginationProps = {
27
+ modelValue: { type: Number, default: 1 },
28
+ total: { type: Number, required: true as const },
29
+ pageSize: { type: Number, default: 20 },
30
+ siblingCount: { type: Number, default: 1 },
31
+ label: { type: String, default: 'Result pages' },
32
+ previousLabel: { type: String, default: 'Previous' },
33
+ nextLabel: { type: String, default: 'Next' },
34
+ pageLabel: { type: String, default: 'Page' },
35
+ currentLabel: { type: String, default: 'Current' },
36
+ statusText: { type: String, default: '' },
37
+ emptyLabel: { type: String, default: 'No results' },
38
+ invalidPageLabel: { type: String, default: 'This page is no longer available.' },
39
+ loading: Boolean,
40
+ disabled: Boolean,
41
+ }