@m3ui-vue/m3ui-vue 1.10.2 → 1.11.0

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 (292) hide show
  1. package/README.md +19 -4
  2. package/dist/API.md +195 -56
  3. package/dist/MButton-gWoOzFWf.js +284 -0
  4. package/dist/MButton-gWoOzFWf.js.map +1 -0
  5. package/dist/MColorPickerModal-CJYMvlgK.js +466 -0
  6. package/dist/MColorPickerModal-CJYMvlgK.js.map +1 -0
  7. package/dist/MDialog-CU8EYgCC.js +226 -0
  8. package/dist/MDialog-CU8EYgCC.js.map +1 -0
  9. package/dist/{MIcon-BSsJZhK7.js → MIcon-CkUc9kuQ.js} +10 -4
  10. package/dist/MIcon-CkUc9kuQ.js.map +1 -0
  11. package/dist/MIconButton-DTFOfsTy.js +317 -0
  12. package/dist/MIconButton-DTFOfsTy.js.map +1 -0
  13. package/dist/MListItem-Cdw2FqCT.js +1306 -0
  14. package/dist/MListItem-Cdw2FqCT.js.map +1 -0
  15. package/dist/MLoadingIndicator-BxAy2x7P.js +115 -0
  16. package/dist/MLoadingIndicator-BxAy2x7P.js.map +1 -0
  17. package/dist/{MMenuItem-US0Zbglq.js → MMenuItem-CEIKYvaX.js} +216 -214
  18. package/dist/MMenuItem-CEIKYvaX.js.map +1 -0
  19. package/dist/{MPdfViewer-DL9mRsd2.js → MPdfViewer-CEfyXGq2.js} +674 -671
  20. package/dist/MPdfViewer-CEfyXGq2.js.map +1 -0
  21. package/dist/MProgressBar-BzZMxq7M.js.map +1 -1
  22. package/dist/MSeekBar-B3_D-PwH.js +435 -0
  23. package/dist/MSeekBar-B3_D-PwH.js.map +1 -0
  24. package/dist/{MSegmentedButton-DMou-8sG.js → MSegmentedButton-Dg07j-4r.js} +4 -4
  25. package/dist/{MSegmentedButton-DMou-8sG.js.map → MSegmentedButton-Dg07j-4r.js.map} +1 -1
  26. package/dist/{MSignaturePad-WuvE_Cyl.js → MSignaturePad-3nddtLKI.js} +2 -2
  27. package/dist/{MSignaturePad-WuvE_Cyl.js.map → MSignaturePad-3nddtLKI.js.map} +1 -1
  28. package/dist/{MSlider-7TzhFHKS.js → MSlider-BrpLbqwt.js} +4 -4
  29. package/dist/{MSlider-7TzhFHKS.js.map → MSlider-BrpLbqwt.js.map} +1 -1
  30. package/dist/{MSpinner-CkIVBuGE.js → MSpinner-CLwzDH33.js} +2 -2
  31. package/dist/{MSpinner-CkIVBuGE.js.map → MSpinner-CLwzDH33.js.map} +1 -1
  32. package/dist/{MTextField-B6_iOczK.js → MTextField-CZRizAwA.js} +136 -134
  33. package/dist/MTextField-CZRizAwA.js.map +1 -0
  34. package/dist/{_useFieldValidation-COBJ1tWr.js → _useFieldValidation-DVcqyy9g.js} +2 -2
  35. package/dist/{_useFieldValidation-COBJ1tWr.js.map → _useFieldValidation-DVcqyy9g.js.map} +1 -1
  36. package/dist/api.json +1 -1
  37. package/dist/chart.js +1 -1
  38. package/dist/code-editor.js +3 -3
  39. package/dist/code-editor.js.map +1 -1
  40. package/dist/components/MAlert.vue.d.ts +1 -1
  41. package/dist/components/MAudioPlayer.vue.d.ts +3 -3
  42. package/dist/components/MAvatar.vue.d.ts +19 -1
  43. package/dist/components/MButton.vue.d.ts +2 -1
  44. package/dist/components/MChatBubble.vue.d.ts +2 -0
  45. package/dist/components/MCheckbox.vue.d.ts +2 -0
  46. package/dist/components/MDataTable.vue.d.ts +31 -3
  47. package/dist/components/MFlow.vue.d.ts +1 -1
  48. package/dist/components/MHotkeys.vue.d.ts +1 -0
  49. package/dist/components/MIcon.vue.d.ts +6 -0
  50. package/dist/components/MIconButton.vue.d.ts +5 -0
  51. package/dist/components/MKanban.vue.d.ts +1 -1
  52. package/dist/components/MLink.vue.d.ts +59 -0
  53. package/dist/components/MListItem.vue.d.ts +3 -1
  54. package/dist/components/MMapControl.vue.d.ts +1 -1
  55. package/dist/components/MNotificationCenter.vue.d.ts +1 -1
  56. package/dist/components/MNumberField.vue.d.ts +1 -1
  57. package/dist/components/MPagination.vue.d.ts +14 -1
  58. package/dist/components/MPdfSigner.vue.d.ts +2 -2
  59. package/dist/components/MRadio.vue.d.ts +2 -0
  60. package/dist/components/MRadioGroup.vue.d.ts +2 -0
  61. package/dist/components/MStatCard.vue.d.ts +2 -2
  62. package/dist/components/MSwitch.vue.d.ts +2 -0
  63. package/dist/components/MText.vue.d.ts +4 -2
  64. package/dist/components/MTextField.vue.d.ts +2 -0
  65. package/dist/components/_MDrawerItemList.vue.d.ts +6 -0
  66. package/dist/composables/_menuGroups.d.ts +10 -1
  67. package/dist/composables/_splitAttrs.d.ts +6 -0
  68. package/dist/composables/_springAnimation.d.ts +2 -2
  69. package/dist/composables/_useFocusTrap.d.ts +15 -0
  70. package/dist/composables/_usePaneResize.d.ts +1 -1
  71. package/dist/composables/_useSpring.d.ts +4 -4
  72. package/dist/composables/dynamicColor.d.ts +9 -1
  73. package/dist/composables/motion.d.ts +63 -0
  74. package/dist/composables/useConfirm.d.ts +28 -0
  75. package/dist/composables/useDevice.d.ts +8 -1
  76. package/dist/composables/useLocale.d.ts +14 -0
  77. package/dist/composables/useScrollReveal.d.ts +1 -1
  78. package/dist/composables/useTheme.d.ts +1 -0
  79. package/dist/composables/useToast.d.ts +7 -0
  80. package/dist/draw.js +556 -556
  81. package/dist/draw.js.map +1 -1
  82. package/dist/flow.js +854 -851
  83. package/dist/flow.js.map +1 -1
  84. package/dist/gantt.js +1118 -1096
  85. package/dist/gantt.js.map +1 -1
  86. package/dist/index.d.ts +8 -5
  87. package/dist/locales/index.d.ts +1 -0
  88. package/dist/locales/index.js +833 -1
  89. package/dist/locales/index.js.map +1 -1
  90. package/dist/locales/pl.d.ts +2 -0
  91. package/dist/m3ui-vue.css +1 -1
  92. package/dist/m3ui.js +10327 -9796
  93. package/dist/m3ui.js.map +1 -1
  94. package/dist/map.js +860 -860
  95. package/dist/map.js.map +1 -1
  96. package/dist/{material-color-utilities-CEFytLsr.js → material-color-utilities-BZsBNIhi.js} +276 -217
  97. package/dist/material-color-utilities-BZsBNIhi.js.map +1 -0
  98. package/dist/media.js +7 -7
  99. package/dist/{motion-BcejVTeX.js → motion-BqYcqcim.js} +15 -5
  100. package/dist/motion-BqYcqcim.js.map +1 -0
  101. package/dist/pdf-sign.js +140 -137
  102. package/dist/pdf-sign.js.map +1 -1
  103. package/dist/pdf.js +1 -1
  104. package/dist/plugin.d.ts +11 -0
  105. package/dist/rich-text-editor.js +7 -7
  106. package/dist/styles/theme.css +40 -0
  107. package/dist/styles.css +1 -1
  108. package/dist/terminal.js +1 -1
  109. package/dist/{useLocale-YRaOT12S.js → useLocale-BjcYauXr.js} +60 -4
  110. package/dist/useLocale-BjcYauXr.js.map +1 -0
  111. package/dist/{useThemeTokens-DyAdPQB0.js → useThemeTokens-D5nr5KHf.js} +28 -27
  112. package/dist/useThemeTokens-D5nr5KHf.js.map +1 -0
  113. package/package.json +17 -2
  114. package/src/__tests__/MAvatarImage.test.ts +37 -0
  115. package/src/__tests__/MDataTableControlled.test.ts +68 -0
  116. package/src/__tests__/MHotkeysSequence.test.ts +53 -0
  117. package/src/__tests__/MIconAxes.test.ts +16 -0
  118. package/src/__tests__/MIconButtonWidth.test.ts +22 -0
  119. package/src/__tests__/MLink.test.ts +46 -0
  120. package/src/__tests__/MPaginationPages.test.ts +43 -0
  121. package/src/__tests__/MTextEmphasized.test.ts +14 -0
  122. package/src/__tests__/controlDescription.test.ts +34 -0
  123. package/src/__tests__/customColor.test.ts +27 -0
  124. package/src/__tests__/dynamicColor.test.ts +3 -2
  125. package/src/__tests__/focusTrap.test.ts +124 -0
  126. package/src/__tests__/formatMessage.test.ts +20 -0
  127. package/src/__tests__/inputAttrs.test.ts +103 -0
  128. package/src/__tests__/localePresets.test.ts +2 -0
  129. package/src/__tests__/menuGroupsRemount.test.ts +40 -0
  130. package/src/__tests__/menuHydration.test.ts +41 -0
  131. package/src/__tests__/motionPrefs.test.ts +28 -0
  132. package/src/__tests__/ssr.test.ts +11 -0
  133. package/src/__tests__/ssrToast.test.ts +20 -0
  134. package/src/__tests__/toastDetails.test.ts +39 -0
  135. package/src/__tests__/useConfirm.test.ts +47 -0
  136. package/src/__tests__/useTheme.test.ts +14 -0
  137. package/src/__tests__/warningRole.test.ts +22 -0
  138. package/src/components/MAlert.vue +2 -2
  139. package/src/components/MAnimatedNumber.vue +9 -3
  140. package/src/components/MAutocomplete.vue +16 -4
  141. package/src/components/MAvailabilityCalendar.vue +3 -3
  142. package/src/components/MAvatar.vue +32 -5
  143. package/src/components/MAvatarGroup.vue +7 -2
  144. package/src/components/MBottomSheet.vue +18 -2
  145. package/src/components/MButton.vue +18 -5
  146. package/src/components/MCarousel.vue +3 -3
  147. package/src/components/MChatBubble.vue +14 -1
  148. package/src/components/MCheckbox.vue +21 -4
  149. package/src/components/MChip.vue +4 -2
  150. package/src/components/MCollapse.vue +7 -1
  151. package/src/components/MCommandPalette.vue +6 -2
  152. package/src/components/MContextMenu.vue +4 -4
  153. package/src/components/MCreditCardInput.vue +5 -0
  154. package/src/components/MDashboardGrid.vue +2 -1
  155. package/src/components/MDataTable.vue +63 -16
  156. package/src/components/MDialog.vue +21 -3
  157. package/src/components/MDiffViewer.vue +3 -3
  158. package/src/components/MDrawLayers.vue +3 -3
  159. package/src/components/MFabMenu.vue +7 -0
  160. package/src/components/MFloorPlan.vue +3 -3
  161. package/src/components/MFloorPlanInspector.vue +3 -3
  162. package/src/components/MFlow.vue +9 -5
  163. package/src/components/MFlowControls.vue +6 -0
  164. package/src/components/MFormBuilder.vue +1 -1
  165. package/src/components/MGantt.vue +10 -10
  166. package/src/components/MHotkeys.vue +61 -16
  167. package/src/components/MIcon.vue +17 -1
  168. package/src/components/MIconButton.vue +29 -6
  169. package/src/components/MImageCropper.vue +1 -1
  170. package/src/components/MKanban.vue +2 -1
  171. package/src/components/MLightbox.vue +5 -4
  172. package/src/components/MLink.vue +136 -0
  173. package/src/components/MListDetail.vue +7 -0
  174. package/src/components/MListItem.vue +7 -4
  175. package/src/components/MLoadingIndicator.vue +2 -1
  176. package/src/components/MMap.vue +3 -0
  177. package/src/components/MMapCluster.vue +2 -2
  178. package/src/components/MMapControl.vue +2 -2
  179. package/src/components/MMapMeasure.vue +1 -1
  180. package/src/components/MMaskField.vue +16 -3
  181. package/src/components/MMenu.vue +4 -4
  182. package/src/components/MMenuItem.vue +2 -2
  183. package/src/components/MMeterGroup.vue +3 -2
  184. package/src/components/MMortgageCalculator.vue +3 -3
  185. package/src/components/MMultiAutocomplete.vue +19 -7
  186. package/src/components/MMultiSelect.vue +19 -7
  187. package/src/components/MNavigationDrawer.vue +10 -3
  188. package/src/components/MNavigationRail.vue +5 -1
  189. package/src/components/MNotificationCenter.vue +2 -1
  190. package/src/components/MNotificationHost.vue +3 -3
  191. package/src/components/MNumberField.vue +23 -6
  192. package/src/components/MOdontogram.vue +4 -4
  193. package/src/components/MOrderBook.vue +4 -0
  194. package/src/components/MPagination.vue +91 -12
  195. package/src/components/MPdfSigner.vue +3 -3
  196. package/src/components/MPdfViewer.vue +7 -7
  197. package/src/components/MPhoneInput.vue +17 -4
  198. package/src/components/MProductConfigurator.vue +4 -4
  199. package/src/components/MProgressBar.vue +5 -0
  200. package/src/components/MQuiz.vue +8 -5
  201. package/src/components/MRadio.vue +24 -5
  202. package/src/components/MRadioGroup.vue +3 -0
  203. package/src/components/MReactions.vue +2 -2
  204. package/src/components/MResourceTimeline.vue +3 -3
  205. package/src/components/MResult.vue +1 -1
  206. package/src/components/MScrollField.vue +1 -1
  207. package/src/components/MSearchField.vue +6 -5
  208. package/src/components/MSeatMap.vue +5 -0
  209. package/src/components/MSeekBar.vue +3 -2
  210. package/src/components/MSelect.vue +16 -4
  211. package/src/components/MSideSheet.vue +25 -3
  212. package/src/components/MSimpleCarousel.vue +2 -2
  213. package/src/components/MSnackbar.vue +16 -13
  214. package/src/components/MSparkline.vue +2 -1
  215. package/src/components/MSpinner.vue +8 -0
  216. package/src/components/MSplitter.vue +1 -1
  217. package/src/components/MSpotlightSearch.vue +6 -2
  218. package/src/components/MSpreadsheet.vue +1 -1
  219. package/src/components/MStatCard.vue +2 -1
  220. package/src/components/MSwitch.vue +21 -4
  221. package/src/components/MTabs.vue +2 -1
  222. package/src/components/MTagInput.vue +19 -6
  223. package/src/components/MText.vue +23 -4
  224. package/src/components/MTextField.vue +25 -6
  225. package/src/components/MTimeline.vue +5 -5
  226. package/src/components/MToolbar.vue +2 -2
  227. package/src/components/MTour.vue +3 -0
  228. package/src/components/MTrackingTimeline.vue +6 -0
  229. package/src/components/MTypewriter.vue +7 -1
  230. package/src/components/MWindow.vue +10 -1
  231. package/src/components/_MColorPanel.vue +4 -4
  232. package/src/components/_MComment.vue +3 -2
  233. package/src/components/_MFlowNodeShell.vue +1 -1
  234. package/src/components/_MPdfPage.vue +1 -1
  235. package/src/components/_MTransferPane.vue +10 -0
  236. package/src/composables/_effectCanvas.ts +2 -1
  237. package/src/composables/_menuGroups.ts +10 -1
  238. package/src/composables/_splitAttrs.ts +29 -0
  239. package/src/composables/_springAnimation.ts +3 -3
  240. package/src/composables/_themeTransition.ts +3 -2
  241. package/src/composables/_useFocusTrap.ts +142 -0
  242. package/src/composables/_useMenuNav.ts +3 -3
  243. package/src/composables/_usePaneResize.ts +2 -1
  244. package/src/composables/_useSheetMotion.ts +3 -4
  245. package/src/composables/_useSpring.ts +16 -10
  246. package/src/composables/cron.ts +7 -6
  247. package/src/composables/dynamicColor.ts +21 -2
  248. package/src/composables/motion.ts +27 -0
  249. package/src/composables/useConfirm.ts +116 -0
  250. package/src/composables/useDevice.ts +23 -3
  251. package/src/composables/useFieldBg.ts +4 -0
  252. package/src/composables/useLocale.ts +74 -0
  253. package/src/composables/useNotification.ts +3 -0
  254. package/src/composables/useScrollReveal.ts +3 -3
  255. package/src/composables/useTheme.ts +8 -2
  256. package/src/composables/useToast.ts +27 -4
  257. package/src/directives/vSparkle.ts +2 -1
  258. package/src/index.ts +8 -5
  259. package/src/locales/ar.ts +7 -0
  260. package/src/locales/de.ts +7 -0
  261. package/src/locales/es.ts +7 -0
  262. package/src/locales/fr.ts +7 -0
  263. package/src/locales/index.ts +1 -0
  264. package/src/locales/ja.ts +7 -0
  265. package/src/locales/ko.ts +7 -0
  266. package/src/locales/pl.ts +807 -0
  267. package/src/locales/pt.ts +7 -0
  268. package/src/locales/zh.ts +7 -0
  269. package/src/plugin.ts +16 -0
  270. package/src/styles/theme.css +40 -0
  271. package/dist/MButton-B9RCM06i.js +0 -171
  272. package/dist/MButton-B9RCM06i.js.map +0 -1
  273. package/dist/MColorPickerModal-ChRtcZOo.js +0 -577
  274. package/dist/MColorPickerModal-ChRtcZOo.js.map +0 -1
  275. package/dist/MDialog-dk07tify.js +0 -167
  276. package/dist/MDialog-dk07tify.js.map +0 -1
  277. package/dist/MIcon-BSsJZhK7.js.map +0 -1
  278. package/dist/MIconButton-CrBPZidd.js +0 -288
  279. package/dist/MIconButton-CrBPZidd.js.map +0 -1
  280. package/dist/MListItem-h9H223vx.js +0 -1239
  281. package/dist/MListItem-h9H223vx.js.map +0 -1
  282. package/dist/MLoadingIndicator-YTV1Ov5w.js +0 -114
  283. package/dist/MLoadingIndicator-YTV1Ov5w.js.map +0 -1
  284. package/dist/MMenuItem-US0Zbglq.js.map +0 -1
  285. package/dist/MPdfViewer-DL9mRsd2.js.map +0 -1
  286. package/dist/MSeekBar-JFZcoJ8y.js +0 -434
  287. package/dist/MSeekBar-JFZcoJ8y.js.map +0 -1
  288. package/dist/MTextField-B6_iOczK.js.map +0 -1
  289. package/dist/material-color-utilities-CEFytLsr.js.map +0 -1
  290. package/dist/motion-BcejVTeX.js.map +0 -1
  291. package/dist/useLocale-YRaOT12S.js.map +0 -1
  292. package/dist/useThemeTokens-DyAdPQB0.js.map +0 -1
@@ -42,8 +42,8 @@ export type TimelineStatus = NonNullable<TimelineItem["status"]>;
42
42
  import { computed, onBeforeUpdate, onMounted, onUpdated, ref, useSlots } from "vue";
43
43
  import MIcon from "./MIcon.vue";
44
44
  import MButton from "./MButton.vue";
45
- import { useLocale } from "../composables/useLocale";
46
- import { motionSprings } from "../composables/motion";
45
+ import { useLocale, formatMessage } from "../composables/useLocale";
46
+ import { appSprings } from "../composables/motion";
47
47
  import { playSamples, prefersReducedMotion, sampleSpring } from "../composables/_springAnimation";
48
48
 
49
49
  const props = withDefaults(
@@ -123,7 +123,7 @@ const limited = computed(() => props.limit !== undefined && props.items.length >
123
123
  const shown = computed(() => (limited.value && !isExpanded.value ? props.items.slice(0, props.limit) : props.items));
124
124
  const hiddenCount = computed(() => props.items.length - shown.value.length);
125
125
  const toggleLabel = computed(() =>
126
- isExpanded.value ? t.timelineShowLess : t.timelineShowMore.replace("{count}", String(hiddenCount.value)),
126
+ isExpanded.value ? t.timelineShowLess : formatMessage(t.timelineShowMore, { count: String(hiddenCount.value) }, t.lang),
127
127
  );
128
128
  function toggleExpanded() {
129
129
  const next = !isExpanded.value;
@@ -205,7 +205,7 @@ onUpdated(() => {
205
205
  const now = row.getBoundingClientRect();
206
206
  if (!was) {
207
207
  // New: in from a short way back along the timeline, fading in
208
- playSamples(row, sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.001), (p) => ({
208
+ playSamples(row, sampleSpring(0, 1, 0, appSprings().defaultSpatial, 0.001), (p) => ({
209
209
  transform: `translate${along}(${(1 - p) * -12}px)`,
210
210
  opacity: String(Math.min(1, p * 1.4)),
211
211
  }));
@@ -214,7 +214,7 @@ onUpdated(() => {
214
214
  const dx = was.left - now.left;
215
215
  const dy = was.top - now.top;
216
216
  if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5) continue;
217
- playSamples(row, sampleSpring(1, 0, 0, motionSprings.standard.defaultSpatial, 0.001), (p) => ({
217
+ playSamples(row, sampleSpring(1, 0, 0, appSprings().defaultSpatial, 0.001), (p) => ({
218
218
  transform: `translate(${dx * p}px, ${dy * p}px)`,
219
219
  }));
220
220
  }
@@ -13,7 +13,7 @@
13
13
  * @event update:expanded The toolbar collapsed or expanded on scroll (`collapseOnScroll`)
14
14
  */
15
15
  import { computed, onMounted, onUnmounted, onUpdated, ref, useSlots, watch } from 'vue'
16
- import { motionSprings } from '../composables/motion'
16
+ import { motionSprings, shouldReduceMotion } from '../composables/motion'
17
17
  import MToolbarFab from './_MToolbarFab.vue'
18
18
 
19
19
  const props = withDefaults(defineProps<{
@@ -100,7 +100,7 @@ let last = 0
100
100
  let full = 0
101
101
  let lead = 0
102
102
  let trail = 0
103
- const reduceMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches
103
+ const reduceMotion = () => shouldReduceMotion()
104
104
  const size = () => (isVertical.value ? 'height' : 'width')
105
105
  const measure = (el?: HTMLElement) => (el ? (isVertical.value ? el.offsetHeight : el.offsetWidth) : 0)
106
106
 
@@ -391,6 +391,9 @@ onBeforeUnmount(() => { stopListeners(); clearHighlight() })
391
391
  @media (prefers-reduced-motion: reduce) {
392
392
  .m3-tour-ring { animation: none; }
393
393
  }
394
+ /* createM3UI({ reducedMotion: 'always' }) */
395
+ :root[data-m3-motion='reduce'] .m3-tour-ring { animation: none; }
396
+
394
397
 
395
398
  .m3-tour-enter-active,
396
399
  .m3-tour-leave-active {
@@ -255,4 +255,10 @@ const statusChip = computed(() =>
255
255
  display: none;
256
256
  }
257
257
  }
258
+ /* createM3UI({ reducedMotion: 'always' }) */
259
+ :root[data-m3-motion='reduce'] .m3-tracking-pulse {
260
+ animation: none;
261
+ display: none;
262
+ }
263
+
258
264
  </style>
@@ -11,6 +11,7 @@
11
11
  * @event done Emitted when the last phrase is typed and `loop` is off
12
12
  */
13
13
  import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
14
+ import { shouldReduceMotion } from '../composables/motion'
14
15
 
15
16
  const props = withDefaults(
16
17
  defineProps<{
@@ -61,7 +62,7 @@ const split = (s: string) => (segmenter ? Array.from(segmenter.segment(s), (g) =
61
62
 
62
63
  const shown = ref<string[]>([])
63
64
  const index = ref(0)
64
- const reduced = typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
65
+ const reduced = shouldReduceMotion()
65
66
 
66
67
  let timer: ReturnType<typeof setTimeout> | undefined
67
68
  let running = false
@@ -192,4 +193,9 @@ const typed = computed(() => shown.value.join(''))
192
193
  animation: none;
193
194
  }
194
195
  }
196
+ /* createM3UI({ reducedMotion: 'always' }) */
197
+ :root[data-m3-motion='reduce'] .m3-typewriter-cursor {
198
+ animation: none;
199
+ }
200
+
195
201
  </style>
@@ -3,6 +3,7 @@
3
3
  // Kept below the app-level overlay scale (dialogs/spotlight/command palette use z-50)
4
4
  // so windows never render on top of a real modal.
5
5
  import { ref as moduleRef } from 'vue'
6
+ import { shouldReduceMotion } from '../composables/motion'
6
7
 
7
8
  let sharedZIndex = 10
8
9
  let nextId = 0
@@ -246,7 +247,7 @@ function restoreUnderPointer() {
246
247
  maximized.value = false
247
248
  tiled.value = null
248
249
  restoreOnMove = false
249
- const reduced = typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
250
+ const reduced = shouldReduceMotion()
250
251
  if (reduced) {
251
252
  winWidth.value = restoreBox.w
252
253
  winHeight.value = restoreBox.h
@@ -765,4 +766,12 @@ const resizeHandles: { dir: ResizeDirection; class: string; cursor: string }[] =
765
766
  transition: none;
766
767
  }
767
768
  }
769
+ /* createM3UI({ reducedMotion: 'always' }) */
770
+ :root[data-m3-motion='reduce'] .m3-window-geometry,
771
+ :root[data-m3-motion='reduce'] .m3-window-snap-preview,
772
+ :root[data-m3-motion='reduce'] .m3-window-enter-active,
773
+ :root[data-m3-motion='reduce'] .m3-window-leave-active {
774
+ transition: none;
775
+ }
776
+
768
777
  </style>
@@ -249,7 +249,7 @@ defineExpose({ focus: () => areaEl.value?.focus({ preventScroll: true }) })
249
249
  aria-valuemin="0"
250
250
  aria-valuemax="100"
251
251
  :aria-valuetext="`${t.colorSaturation} ${Math.round(s)}%, ${t.colorBrightness} ${Math.round(v)}%`"
252
- class="relative h-40 w-full shrink-0 cursor-crosshair touch-none rounded-md outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
252
+ class="relative h-40 w-full shrink-0 cursor-crosshair touch-none rounded-md outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-secondary"
253
253
  :style="{ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueColor})` }"
254
254
  @pointerdown="onPointerDown('area', $event)"
255
255
  @pointermove="onPointerMove('area', $event)"
@@ -320,7 +320,7 @@ defineExpose({ focus: () => areaEl.value?.focus({ preventScroll: true }) })
320
320
  <button
321
321
  v-if="showOriginal"
322
322
  type="button"
323
- class="m3-cp-swatch flex w-12 shrink-0 cursor-pointer items-center justify-center rounded-s-full outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
323
+ class="m3-cp-swatch flex w-12 shrink-0 cursor-pointer items-center justify-center rounded-s-full outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-secondary"
324
324
  :style="{ background: fill(original!) }"
325
325
  :aria-label="t.colorOriginal"
326
326
  v-tooltip="t.colorOriginal"
@@ -341,7 +341,7 @@ defineExpose({ focus: () => areaEl.value?.focus({ preventScroll: true }) })
341
341
  <div class="flex items-start gap-2">
342
342
  <button
343
343
  type="button"
344
- class="flex h-10 shrink-0 cursor-pointer items-center gap-0.5 rounded-full bg-secondary-container pe-2 ps-3 text-label-large text-on-secondary-container outline-none transition-[background-color] duration-150 hover:bg-[color-mix(in_srgb,var(--color-secondary-container),var(--color-on-secondary-container)_8%)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
344
+ class="flex h-10 shrink-0 cursor-pointer items-center gap-0.5 rounded-full bg-secondary-container pe-2 ps-3 text-label-large text-on-secondary-container outline-none transition-[background-color] duration-150 hover:bg-[color-mix(in_srgb,var(--color-secondary-container),var(--color-on-secondary-container)_8%)] focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-secondary"
345
345
  :aria-label="`${t.colorFormat}: ${formatLabel}`"
346
346
  @click="cycleFormat"
347
347
  >
@@ -387,7 +387,7 @@ defineExpose({ focus: () => areaEl.value?.focus({ preventScroll: true }) })
387
387
  v-for="color in group.colors"
388
388
  :key="color"
389
389
  type="button"
390
- class="m3-cp-swatch m3-cp-morph flex aspect-square cursor-pointer items-center justify-center outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
390
+ class="m3-cp-swatch m3-cp-morph flex aspect-square cursor-pointer items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-secondary"
391
391
  :class="{ 'm3-cp-morph-selected': isSelected(color) }"
392
392
  :style="{ background: fill(color) }"
393
393
  :aria-label="color"
@@ -8,6 +8,7 @@ import MReactions from './MReactions.vue'
8
8
  import CommentComposer from './_MCommentComposer.vue'
9
9
  import { COMMENT_THREAD_KEY, type CommentItem } from './_commentThread'
10
10
  import { vRipple } from '../directives/vRipple'
11
+ import { formatMessage } from '../composables/useLocale'
11
12
 
12
13
  defineOptions({ name: 'MComment' })
13
14
 
@@ -38,7 +39,7 @@ const initials = computed(() => {
38
39
  // @mentions in the text stand out
39
40
  const pieces = computed(() => props.comment.text.split(/(@[\p{L}\p{N}_.-]+)/u).map((text) => ({ text, mention: text.startsWith('@') })))
40
41
  const showRepliesLabel = computed(() =>
41
- replies.value.length === 1 ? t.commentShowReply : t.commentShowReplies.replace('{count}', String(replies.value.length)),
42
+ replies.value.length === 1 ? t.commentShowReply : formatMessage(t.commentShowReplies, { count: String(replies.value.length) }, t.lang),
42
43
  )
43
44
 
44
45
  function startReply() {
@@ -113,7 +114,7 @@ function startReply() {
113
114
  <CommentComposer
114
115
  v-if="replying"
115
116
  class="mt-2"
116
- :label="t.commentReplyTo.replace('{name}', comment.author.name)"
117
+ :label="formatMessage(t.commentReplyTo, { name: comment.author.name }, t.lang)"
117
118
  :submit-label="t.commentSend"
118
119
  :mention-sources="ctx.mentionSources.value"
119
120
  cancelable
@@ -64,7 +64,7 @@ onBeforeUnmount(() => flow.registerNodeEl(id, null))
64
64
  <template>
65
65
  <div
66
66
  ref="el"
67
- class="m3-flow-node absolute top-0 left-0 rounded-md outline-none focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-secondary"
67
+ class="m3-flow-node absolute top-0 left-0 rounded-md outline-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-secondary"
68
68
  :class="[node.class, draggable && (dragging ? 'cursor-grabbing' : 'cursor-grab')]"
69
69
  :style="{
70
70
  transform: `translate(${pos.x}px, ${pos.y}px)`,
@@ -443,7 +443,7 @@ defineExpose({ root, currentHit })
443
443
  <button
444
444
  v-if="'x' in s"
445
445
  type="button"
446
- class="m3-pdf-note absolute flex size-7 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full shadow-elevation-2 outline-none focus-visible:ring-2 focus-visible:ring-primary"
446
+ class="m3-pdf-note absolute flex size-7 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full shadow-elevation-2 outline-none focus-visible:ring-2 focus-visible:ring-secondary"
447
447
  :class="{ 'ring-2 ring-primary': s.a.id === selectedId }"
448
448
  :style="{ left: `${s.x}px`, top: `${s.y}px`, backgroundColor: s.a.color }"
449
449
  :aria-label="s.a.text || 'Note'"
@@ -258,4 +258,14 @@ function onRowSpace(e: KeyboardEvent, value: Value) {
258
258
  transition: none;
259
259
  }
260
260
  }
261
+ /* createM3UI({ reducedMotion: 'always' }) */
262
+ :root[data-m3-motion='reduce'] .m3-tl-start-move,
263
+ :root[data-m3-motion='reduce'] .m3-tl-end-move,
264
+ :root[data-m3-motion='reduce'] .m3-tl-start-enter-active,
265
+ :root[data-m3-motion='reduce'] .m3-tl-end-enter-active,
266
+ :root[data-m3-motion='reduce'] .m3-tl-start-leave-active,
267
+ :root[data-m3-motion='reduce'] .m3-tl-end-leave-active {
268
+ transition: none;
269
+ }
270
+
261
271
  </style>
@@ -1,3 +1,4 @@
1
+ import { shouldReduceMotion } from './motion'
1
2
  // One canvas over the page shared by the canvas effects (useConfetti, useFireworks): created when the first one
2
3
  // starts, removed when the last one ends. It never takes pointer events and assistive technology ignores it. Each
3
4
  // effect is a layer stepped once per frame in one rAF loop, after the canvas has been cleared.
@@ -86,7 +87,7 @@ export function themeColors(el: Element, roles: string[]) {
86
87
 
87
88
  /** Whether the system asks for reduced motion. */
88
89
  export function reducedMotion() {
89
- return !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
90
+ return shouldReduceMotion()
90
91
  }
91
92
 
92
93
  /** Where an effect starts: the pointer of an event, an element's center, or a point in viewport pixels */
@@ -1,4 +1,4 @@
1
- import { Fragment, type VNode } from 'vue'
1
+ import { Fragment, type FunctionalComponent, type VNode, type VNodeChild } from 'vue'
2
2
  import MMenuDivider from '../components/MMenuDivider.vue'
3
3
 
4
4
  function flattenVNodes(vnodes: VNode[]): VNode[] {
@@ -29,3 +29,12 @@ export function splitMenuGroups(vnodes: VNode[]): VNode[][] {
29
29
  }
30
30
  return result.filter((g) => g.length > 0)
31
31
  }
32
+
33
+ /**
34
+ * Renders VNodes built elsewhere (a menu group, a push submenu's header or content). A stable component type: an
35
+ * inline `<component :is="() => nodes" />` is a new function on every render, so Vue treats it as a different
36
+ * component each time and unmounts and re-creates everything inside it (items lost focus and DOM identity on any
37
+ * re-render of the menu).
38
+ */
39
+ export const RenderNodes: FunctionalComponent<{ nodes?: () => VNodeChild }> = (props) => (props.nodes?.() ?? null) as VNode | null
40
+ RenderNodes.props = ['nodes']
@@ -0,0 +1,29 @@
1
+ import { useAttrs } from 'vue'
2
+
3
+ /**
4
+ * Splits a field's fallthrough attrs between its wrapper and its native control: `class`, `style` and `data-*` stay
5
+ * on the field's box (so `[data-testid] input` style selectors keep working), everything else (`id`, `inputmode`,
6
+ * `maxlength`, `aria-*`, native listeners…) belongs on the `<input>`. Use with `defineOptions({ inheritAttrs: false })`.
7
+ *
8
+ * Returns functions, not computeds: `$attrs` isn't reactive (in production a computed over it never updates), but a
9
+ * component re-renders whenever its attrs change, so calling these from the template always reads the current ones.
10
+ */
11
+ const isRootAttr = (k: string) => k === 'class' || k === 'style' || k.startsWith('data-')
12
+
13
+ export function useSplitAttrs() {
14
+ const attrs = useAttrs()
15
+ return {
16
+ rootAttrs: () => {
17
+ const root: Record<string, unknown> = {}
18
+ for (const k in attrs) if (isRootAttr(k)) root[k] = attrs[k]
19
+ return root
20
+ },
21
+ inputAttrs: () => {
22
+ const rest: Record<string, unknown> = {}
23
+ for (const k in attrs) if (!isRootAttr(k)) rest[k] = attrs[k]
24
+ return rest
25
+ },
26
+ /** The consumer's `id`, if given: the control takes it, so `<label for>` and `getElementById` keep working */
27
+ attrId: () => attrs.id as string | undefined,
28
+ }
29
+ }
@@ -1,4 +1,4 @@
1
- import type { SpringSpec } from './motion'
1
+ import { shouldReduceMotion, type SpringSpec } from './motion'
2
2
 
3
3
  /*
4
4
  * Internal (not exported from index.ts): springs played as Web Animations.
@@ -70,5 +70,5 @@ export function playSamples(
70
70
  return anim
71
71
  }
72
72
 
73
- export const prefersReducedMotion = () =>
74
- typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
73
+ // The user's setting or createM3UI({ reducedMotion: 'always' })
74
+ export const prefersReducedMotion = shouldReduceMotion
@@ -1,3 +1,4 @@
1
+ import { shouldReduceMotion } from './motion'
1
2
  // Internal: animates a theme change (dark mode, palette, contrast).
2
3
  //
3
4
  // Firefox (and any browser without @property) transitions six color properties on every element
@@ -14,7 +15,7 @@ const COLOR_TOKENS = [
14
15
  'on-surface-variant', 'surface-container-lowest', 'surface-container-low', 'surface-container',
15
16
  'surface-container-high', 'surface-container-highest', 'inverse-surface', 'inverse-on-surface', 'inverse-primary',
16
17
  'outline', 'outline-variant', 'shadow', 'scrim',
17
- ...['primary', 'secondary', 'tertiary', 'error', 'success'].flatMap((c) => [c, `on-${c}`, `${c}-container`, `on-${c}-container`]),
18
+ ...['primary', 'secondary', 'tertiary', 'error', 'success', 'warning'].flatMap((c) => [c, `on-${c}`, `${c}-container`, `on-${c}-container`]),
18
19
  ...['primary', 'secondary', 'tertiary'].flatMap((c) => [`${c}-fixed`, `${c}-fixed-dim`, `on-${c}-fixed`, `on-${c}-fixed-variant`]),
19
20
  ].map((t) => `--color-${t}`)
20
21
 
@@ -41,7 +42,7 @@ let timer: ReturnType<typeof setTimeout> | undefined
41
42
  /** Runs `apply` (the DOM writes of a theme change) with the theme transition. */
42
43
  export function themeTransition(apply: () => void) {
43
44
  if (typeof document === 'undefined') return apply()
44
- const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
45
+ const reduced = shouldReduceMotion()
45
46
  if (reduced) return apply()
46
47
  const root = document.documentElement
47
48
 
@@ -0,0 +1,142 @@
1
+ import { getCurrentInstance, nextTick, onBeforeUnmount, watch } from 'vue'
2
+
3
+ /*
4
+ * Internal (not exported from index.ts): keyboard focus for modal surfaces (dialogs, modal sheets and drawers), as
5
+ * the ARIA dialog pattern asks:
6
+ * - on open, focus moves inside: to an element marked `autofocus` / `data-autofocus`, else the first focusable
7
+ * one, else the surface itself (made focusable with tabindex -1);
8
+ * - while open, Tab and Shift+Tab cycle inside it (only the top-most surface traps, so a select's modal or a
9
+ * confirm opened from a dialog takes over and hands back);
10
+ * - on close, focus returns to what had it before (the button that opened it), unless the user already moved it
11
+ * somewhere else.
12
+ */
13
+
14
+ const FOCUSABLE = [
15
+ 'a[href]', 'area[href]', 'button:not([disabled])', 'input:not([disabled]):not([type="hidden"])',
16
+ 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'audio[controls]', 'video[controls]',
17
+ '[contenteditable]:not([contenteditable="false"])', '[tabindex]:not([tabindex="-1"])',
18
+ ].join(',')
19
+
20
+ /** The elements Tab reaches inside `root`, in order (skipping inert, hidden and disabled ones) */
21
+ export function focusableIn(root: HTMLElement): HTMLElement[] {
22
+ return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(
23
+ (el) => el.tabIndex >= 0 && !el.closest('[inert], [hidden]') && getComputedStyle(el).visibility !== 'hidden',
24
+ )
25
+ }
26
+
27
+ const stack: symbol[] = []
28
+ let listening = false
29
+ const handlers = new Map<symbol, (e: KeyboardEvent) => void>()
30
+
31
+ function onKeydown(e: KeyboardEvent) {
32
+ if (e.key !== 'Tab' || !stack.length) return
33
+ handlers.get(stack[stack.length - 1]!)?.(e)
34
+ }
35
+
36
+ export interface FocusTrapOptions {
37
+ /** What gets focus on open, instead of the first autofocus / focusable element */
38
+ initialFocus?: () => HTMLElement | null | undefined
39
+ /** Return focus to the element that had it before opening (default true) */
40
+ restoreFocus?: boolean
41
+ }
42
+
43
+ /**
44
+ * Traps keyboard focus in `container()` while `active()` is true; see the file comment. `container` is read after
45
+ * the DOM updates, so a surface rendered by the same `v-if` that `active` drives is already there.
46
+ */
47
+ export function useFocusTrap(
48
+ container: () => HTMLElement | null | undefined,
49
+ active: () => boolean,
50
+ options: FocusTrapOptions = {},
51
+ ) {
52
+ const key = Symbol('focus-trap')
53
+ let previous: HTMLElement | null = null
54
+ let held = false
55
+ // The surface as it was while open: on close its ref is already cleared while a leave animation still shows it
56
+ let lastRoot: HTMLElement | null = null
57
+
58
+ function trapTab(e: KeyboardEvent) {
59
+ const root = container()
60
+ if (root) lastRoot = root
61
+ if (!root) return
62
+ const items = focusableIn(root)
63
+ const current = document.activeElement as HTMLElement | null
64
+ if (!items.length) {
65
+ e.preventDefault()
66
+ root.focus()
67
+ return
68
+ }
69
+ const first = items[0]!
70
+ const last = items[items.length - 1]!
71
+ if (!current || !root.contains(current)) {
72
+ // Focus had escaped (a click on the scrim, a teleported popup that closed): bring it back
73
+ e.preventDefault()
74
+ ;(e.shiftKey ? last : first).focus()
75
+ } else if (e.shiftKey && (current === first || current === root)) {
76
+ e.preventDefault()
77
+ last.focus()
78
+ } else if (!e.shiftKey && current === last) {
79
+ e.preventDefault()
80
+ first.focus()
81
+ }
82
+ }
83
+
84
+ function focusInitial() {
85
+ const root = container()
86
+ if (!root) return
87
+ lastRoot = root
88
+ // Something inside already took focus while mounting (an input focusing itself): leave it
89
+ if (root.contains(document.activeElement)) return
90
+ const target =
91
+ options.initialFocus?.() ??
92
+ root.querySelector<HTMLElement>('[autofocus], [data-autofocus]') ??
93
+ focusableIn(root)[0]
94
+ if (target) target.focus({ preventScroll: true })
95
+ else {
96
+ if (!root.hasAttribute('tabindex')) root.setAttribute('tabindex', '-1')
97
+ root.focus({ preventScroll: true })
98
+ }
99
+ }
100
+
101
+ function start() {
102
+ if (held || typeof document === 'undefined') return
103
+ held = true
104
+ previous = document.activeElement as HTMLElement | null
105
+ stack.push(key)
106
+ handlers.set(key, trapTab)
107
+ if (!listening) {
108
+ document.addEventListener('keydown', onKeydown)
109
+ listening = true
110
+ }
111
+ nextTick(focusInitial)
112
+ }
113
+
114
+ function stop() {
115
+ if (!held) return
116
+ held = false
117
+ const i = stack.lastIndexOf(key)
118
+ if (i >= 0) stack.splice(i, 1)
119
+ handlers.delete(key)
120
+ if (!stack.length && listening) {
121
+ document.removeEventListener('keydown', onKeydown)
122
+ listening = false
123
+ }
124
+ const back = previous
125
+ previous = null
126
+ if (options.restoreFocus === false || !back) return
127
+ // Restore only when focus is still ours to give: inside the closing surface, or dropped on <body> because the
128
+ // surface was removed. A click that closed it by landing on another control keeps that control focused.
129
+ nextTick(() => {
130
+ const now = document.activeElement
131
+ const root = container() ?? lastRoot
132
+ lastRoot = null
133
+ const ours = !now || now === document.body || !now.isConnected || (root && root.contains(now))
134
+ if (ours && back.isConnected) back.focus({ preventScroll: true })
135
+ })
136
+ }
137
+
138
+ watch(() => !!active(), (on) => (on ? start() : stop()), { immediate: true, flush: 'post' })
139
+ if (getCurrentInstance()) onBeforeUnmount(stop)
140
+
141
+ return { focusFirst: focusInitial }
142
+ }
@@ -1,5 +1,5 @@
1
1
  import { computed, nextTick, onUnmounted, ref } from 'vue'
2
- import { motionSprings } from './motion'
2
+ import { appSprings } from './motion'
3
3
  import { playSamples, prefersReducedMotion, sampleSpring } from './_springAnimation'
4
4
  import { isRtl } from './_rtl'
5
5
 
@@ -83,7 +83,7 @@ export function useMenuNav(focusFirst: () => void) {
83
83
  nextTick(() => {
84
84
  const to = el.offsetHeight
85
85
  const anim = Math.abs(to - from) < 1 ? null
86
- : playSamples(el, sampleSpring(from, to, 0, motionSprings.standard.defaultSpatial, 0.5), (h) => ({ height: `${h}px` }))
86
+ : playSamples(el, sampleSpring(from, to, 0, appSprings().defaultSpatial, 0.5), (h) => ({ height: `${h}px` }))
87
87
  const slide = new Promise((r) => setTimeout(r, SLIDE_SETTLE_MS))
88
88
  Promise.all([slide, anim?.finished.catch(() => {})]).then(restore)
89
89
  })
@@ -183,7 +183,7 @@ export function useMenuNav(focusFirst: () => void) {
183
183
  level.style.opacity = ''
184
184
  if (prefersReducedMotion() || dx < 1) return
185
185
  const width = navBox.value?.clientWidth || 1
186
- playSamples(level, sampleSpring(dx, 0, 0, motionSprings.standard.defaultSpatial, 0.5), (x) => ({
186
+ playSamples(level, sampleSpring(dx, 0, 0, appSprings().defaultSpatial, 0.5), (x) => ({
187
187
  transform: `translateX(${x * sg}px)`,
188
188
  opacity: String(1 - 0.5 * Math.min(1, x / width)),
189
189
  }))
@@ -1,4 +1,5 @@
1
1
  import { computed, onMounted, onUnmounted, ref, watch, type Ref } from 'vue'
2
+ import { shouldReduceMotion } from './motion'
2
3
  import { isRtl, logicalKey } from './_rtl'
3
4
 
4
5
  /**
@@ -127,7 +128,7 @@ let busy = false // dragging or settling: the watcher below leaves the width alo
127
128
  function animateTo(a: PaneAnchor, velocity = 0) {
128
129
  cancelAnimationFrame(raf)
129
130
  const target = resolve(a)
130
- const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches
131
+ const reduced = shouldReduceMotion()
131
132
  if (reduced || !o.pane.value) {
132
133
  busy = false
133
134
  write(target)
@@ -1,5 +1,7 @@
1
1
  import { onBeforeUnmount } from 'vue'
2
- import { motionSprings, type SpringSpec } from './motion'
2
+ import { type SpringSpec } from './motion'
3
+ // Springs of the app's motion scheme, read when each animation starts
4
+ import { DEFAULT_SPATIAL, FAST_EFFECTS, DEFAULT_EFFECTS } from './_useSpring'
3
5
  import { sampleSpring, sampleAt, playSamples, prefersReducedMotion } from './_springAnimation'
4
6
  import { isRtl } from './_rtl'
5
7
 
@@ -30,9 +32,6 @@ import { isRtl } from './_rtl'
30
32
  * the panel slides out to the left and drags are read mirrored.
31
33
  */
32
34
 
33
- const DEFAULT_SPATIAL = motionSprings.standard.defaultSpatial
34
- const FAST_EFFECTS = motionSprings.standard.fastEffects
35
- const DEFAULT_EFFECTS = motionSprings.standard.defaultEffects
36
35
 
37
36
  /** Past this many px, or this fast (px/s), a released drag leaves its anchor (off-screen = dismissed). */
38
37
  const DISMISS_DISTANCE = 100
@@ -1,20 +1,26 @@
1
1
  // A set of numbers (corner radii, sizes...) that springs toward a target, written to the DOM once per
2
2
  // frame through `apply`. Same integration as the rest of the library (semi-implicit Euler), in fixed 4ms
3
3
  // substeps so a stiff spring stays stable on a dropped frame. `useSpring` is public (index.ts, with the
4
- // motion tokens); the constants below are the library's internal shorthands for the Standard scheme.
4
+ // motion tokens); the constants below are the library's internal shorthands for the app's scheme.
5
5
  import { onMounted, onUnmounted, watch } from 'vue'
6
- import { cubicBezier, motionSprings, type SpringSpec } from './motion'
6
+ import { appSprings, cubicBezier, type SpringSpec } from './motion'
7
7
 
8
8
  export type { SpringSpec }
9
9
 
10
- /** MotionSchemeKeyTokens.FastSpatial in the Standard scheme (StandardMotionTokens.SpringFastSpatial*) */
11
- export const FAST_SPATIAL: SpringSpec = motionSprings.standard.fastSpatial
12
- /** MotionSchemeKeyTokens.FastEffects in the Standard scheme */
13
- export const FAST_EFFECTS: SpringSpec = motionSprings.standard.fastEffects
14
- /** MotionSchemeKeyTokens.DefaultEffects in the Standard scheme */
15
- export const DEFAULT_EFFECTS: SpringSpec = motionSprings.standard.defaultEffects
16
- /** MotionSchemeKeyTokens.DefaultSpatial in the Standard scheme */
17
- export const DEFAULT_SPATIAL: SpringSpec = motionSprings.standard.defaultSpatial
10
+ // Read through getters, so a spring picks up the app's motion scheme (createM3UI({ motionScheme })) when it runs
11
+ // rather than when this module loads
12
+ const live = (name: keyof ReturnType<typeof appSprings>): SpringSpec => ({
13
+ get dampingRatio() { return appSprings()[name].dampingRatio },
14
+ get stiffness() { return appSprings()[name].stiffness },
15
+ })
16
+ /** MotionSchemeKeyTokens.FastSpatial in the app's scheme (Standard unless createM3UI picks Expressive) */
17
+ export const FAST_SPATIAL: SpringSpec = live('fastSpatial')
18
+ /** MotionSchemeKeyTokens.FastEffects (the same in both schemes) */
19
+ export const FAST_EFFECTS: SpringSpec = live('fastEffects')
20
+ /** MotionSchemeKeyTokens.DefaultEffects (the same in both schemes) */
21
+ export const DEFAULT_EFFECTS: SpringSpec = live('defaultEffects')
22
+ /** MotionSchemeKeyTokens.DefaultSpatial in the app's scheme */
23
+ export const DEFAULT_SPATIAL: SpringSpec = live('defaultSpatial')
18
24
 
19
25
  const SUBSTEP = 0.004
20
26
 
@@ -5,6 +5,7 @@
5
5
  * either runs (crontab's rule). Used by MCronField; usable on their own.
6
6
  */
7
7
  import type { M3Locale } from './useLocale'
8
+ import { formatMessage } from './useLocale'
8
9
 
9
10
  /** An expression read into the values each field allows. */
10
11
  export interface CronSchedule {
@@ -158,10 +159,10 @@ export function describeCron(expression: string, t: CronStrings): string | null
158
159
  const [mf, hf] = s.fields
159
160
  const oneMinute = s.minutes.length === 1 ? s.minutes[0]! : null
160
161
  if (s.any.minutes && s.any.hours) when = t.cronEveryMinute
161
- else if (step(mf!) && s.any.hours) when = t.cronEveryNMinutes.replace('{n}', step(mf!)!)
162
- else if (oneMinute !== null && s.any.hours) when = t.cronHourlyAt.replace('{m}', String(oneMinute))
163
- else if (oneMinute !== null && step(hf!)) when = t.cronEveryNHoursAt.replace('{n}', step(hf!)!).replace('{m}', String(oneMinute))
164
- else if (oneMinute !== null && s.hours.length <= 6) when = t.cronAt.replace('{time}', list(s.hours.map((h) => time(h, oneMinute))))
162
+ else if (step(mf!) && s.any.hours) when = formatMessage(t.cronEveryNMinutes, { n: step(mf!)! }, t.lang)
163
+ else if (oneMinute !== null && s.any.hours) when = formatMessage(t.cronHourlyAt, { m: String(oneMinute) }, t.lang)
164
+ else if (oneMinute !== null && step(hf!)) when = formatMessage(t.cronEveryNHoursAt, { n: step(hf!)!, m: String(oneMinute) }, t.lang)
165
+ else if (oneMinute !== null && s.hours.length <= 6) when = formatMessage(t.cronAt, { time: list(s.hours.map((h) => time(h, oneMinute))) }, t.lang)
165
166
  else {
166
167
  when = t.cronMinutesOfHours
167
168
  .replace('{minutes}', list(compact(s.minutes, String, t.cronRange)))
@@ -170,10 +171,10 @@ export function describeCron(expression: string, t: CronStrings): string | null
170
171
 
171
172
  // Which days
172
173
  const parts = [when]
173
- const domText = s.any.days ? '' : t.cronOnDaysOfMonth.replace('{days}', list(compact(s.days, String, t.cronRange)))
174
+ const domText = s.any.days ? '' : formatMessage(t.cronOnDaysOfMonth, { days: list(compact(s.days, String, t.cronRange)) }, t.lang)
174
175
  const dowText = s.any.weekdays ? '' : list(compact(s.weekdays, weekday, t.cronRange))
175
176
  if (domText && dowText) parts.push(list([domText, dowText], 'disjunction'))
176
177
  else if (domText || dowText) parts.push(domText || dowText)
177
- if (!s.any.months) parts.push(t.cronInMonths.replace('{months}', list(compact(s.months, month, t.cronRange))))
178
+ if (!s.any.months) parts.push(formatMessage(t.cronInMonths, { months: list(compact(s.months, month, t.cronRange)) }, t.lang))
178
179
  return parts.join(', ')
179
180
  }