@m3ui-vue/m3ui-vue 1.1.4 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/dist/API.md +511 -34
  2. package/dist/MMenuItem-DI351kIf.js +929 -0
  3. package/dist/MMenuItem-DI351kIf.js.map +1 -0
  4. package/dist/{MSlider-JflHJ70q.js → MSlider-BnEy5ieZ.js} +295 -320
  5. package/dist/MSlider-BnEy5ieZ.js.map +1 -0
  6. package/dist/MTextField-BBmkaIbO.js +633 -0
  7. package/dist/MTextField-BBmkaIbO.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +83 -49
  10. package/dist/chart.js.map +1 -1
  11. package/dist/code-editor.js +1 -1
  12. package/dist/components/MButton.vue.d.ts +7 -1
  13. package/dist/components/MButtonGroup.vue.d.ts +40 -31
  14. package/dist/components/MCarousel.vue.d.ts +2 -0
  15. package/dist/components/MChart.vue.d.ts +6 -0
  16. package/dist/components/MCircleProgressBar.vue.d.ts +5 -3
  17. package/dist/components/MContextMenu.vue.d.ts +2 -2
  18. package/dist/components/MCopyButton.vue.d.ts +1 -1
  19. package/dist/components/MExportButton.vue.d.ts +1 -1
  20. package/dist/components/MFab.vue.d.ts +2 -2
  21. package/dist/components/MFabMenu.vue.d.ts +1 -1
  22. package/dist/components/MIconButton.vue.d.ts +13 -1
  23. package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
  24. package/dist/components/MMap.vue.d.ts +20 -2
  25. package/dist/components/MMapBaseLayers.vue.d.ts +3 -0
  26. package/dist/components/MMapFilter.vue.d.ts +3 -0
  27. package/dist/components/MMapLayers.vue.d.ts +3 -0
  28. package/dist/components/MMenu.vue.d.ts +2 -2
  29. package/dist/components/MMenuItem.vue.d.ts +7 -3
  30. package/dist/components/MNavigationDrawer.vue.d.ts +13 -2
  31. package/dist/components/MOverlay.vue.d.ts +12 -1
  32. package/dist/components/MProgressBar.vue.d.ts +5 -3
  33. package/dist/components/MPullToRefresh.vue.d.ts +7 -2
  34. package/dist/components/MRichTextEditor.vue.d.ts +7 -1
  35. package/dist/components/MSearchField.vue.d.ts +58 -0
  36. package/dist/components/MSegmentedButton.vue.d.ts +31 -23
  37. package/dist/components/MSimpleCarousel.vue.d.ts +2 -0
  38. package/dist/components/MSkeleton.vue.d.ts +6 -3
  39. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  40. package/dist/components/MSwitch.vue.d.ts +1 -1
  41. package/dist/components/MTextField.vue.d.ts +5 -1
  42. package/dist/components/MTimeline.vue.d.ts +85 -22
  43. package/dist/components/MTooltip.vue.d.ts +1 -1
  44. package/dist/components/_MDrawerItemList.vue.d.ts +2 -0
  45. package/dist/composables/_mapStyle.d.ts +13 -0
  46. package/dist/composables/_themeTransition.d.ts +2 -0
  47. package/dist/composables/_tooltipTrigger.d.ts +22 -0
  48. package/dist/composables/_useMenuNav.d.ts +28 -0
  49. package/dist/composables/useAutoGrow.d.ts +21 -0
  50. package/dist/composables/useColorPalette.d.ts +1 -1
  51. package/dist/composables/useLocale.d.ts +3 -0
  52. package/dist/composables/useMap.d.ts +19 -3
  53. package/dist/composables/useMapFilter.d.ts +4 -1
  54. package/dist/composables/useMapLayers.d.ts +5 -2
  55. package/dist/composables/useScrollReveal.d.ts +44 -0
  56. package/dist/composables/useThemeTokens.d.ts +21 -0
  57. package/dist/composables/viewportHints.d.ts +27 -0
  58. package/dist/directives/vClickOutside.d.ts +25 -0
  59. package/dist/directives/vFocusRing.d.ts +22 -0
  60. package/dist/directives/vLongPress.d.ts +27 -0
  61. package/dist/directives/vReveal.d.ts +10 -0
  62. package/dist/directives/vScrollElevation.d.ts +31 -0
  63. package/dist/directives/vSkeleton.d.ts +19 -0
  64. package/dist/directives/vStateLayer.d.ts +20 -0
  65. package/dist/directives/vSwipe.d.ts +45 -0
  66. package/dist/directives/vTooltip.d.ts +23 -0
  67. package/dist/index.d.ts +28 -1
  68. package/dist/locales/index.js +21 -7
  69. package/dist/locales/index.js.map +1 -1
  70. package/dist/m3ui-vue.css +1 -1
  71. package/dist/m3ui.js +7132 -6217
  72. package/dist/m3ui.js.map +1 -1
  73. package/dist/map.d.ts +1 -1
  74. package/dist/map.js +821 -791
  75. package/dist/map.js.map +1 -1
  76. package/dist/motion-DZiXG09o.js +150 -0
  77. package/dist/motion-DZiXG09o.js.map +1 -0
  78. package/dist/plugin.d.ts +24 -0
  79. package/dist/rich-text-editor.js +13 -9
  80. package/dist/rich-text-editor.js.map +1 -1
  81. package/dist/styles/theme.css +63 -0
  82. package/dist/styles.css +1 -1
  83. package/dist/{useLocale-CXibICQA.js → useLocale-JYxDDeXC.js} +4 -2
  84. package/dist/useLocale-JYxDDeXC.js.map +1 -0
  85. package/dist/useThemeTokens-Bv-Uv8eX.js +135 -0
  86. package/dist/useThemeTokens-Bv-Uv8eX.js.map +1 -0
  87. package/package.json +1 -1
  88. package/src/__tests__/MButton.test.ts +22 -0
  89. package/src/__tests__/MCarousel.test.ts +9 -0
  90. package/src/__tests__/MChart.test.ts +77 -5
  91. package/src/__tests__/MIconButton.test.ts +33 -0
  92. package/src/__tests__/MMap.test.ts +53 -1
  93. package/src/__tests__/MMapLayers.test.ts +46 -2
  94. package/src/__tests__/MMenu.test.ts +104 -1
  95. package/src/__tests__/MMenuItem.test.ts +18 -0
  96. package/src/__tests__/MNavigationDrawer.test.ts +80 -0
  97. package/src/__tests__/MOverlay.test.ts +49 -0
  98. package/src/__tests__/MProgressBar.test.ts +41 -0
  99. package/src/__tests__/MPullToRefresh.test.ts +33 -0
  100. package/src/__tests__/MRichTextEditor.test.ts +22 -0
  101. package/src/__tests__/MSearchField.test.ts +71 -0
  102. package/src/__tests__/MSegmentedButton.test.ts +10 -0
  103. package/src/__tests__/MSkeleton.test.ts +38 -0
  104. package/src/__tests__/MTimeline.test.ts +238 -0
  105. package/src/__tests__/_fakeMaplibre.ts +3 -1
  106. package/src/__tests__/attrsFallthrough.test.ts +3 -0
  107. package/src/__tests__/escapeStack.test.ts +93 -0
  108. package/src/__tests__/ssr.test.ts +21 -2
  109. package/src/__tests__/useAutoGrow.test.ts +103 -0
  110. package/src/__tests__/useScrollReveal.test.ts +102 -0
  111. package/src/__tests__/useThemeTokens.test.ts +114 -0
  112. package/src/__tests__/vClickOutside.test.ts +82 -0
  113. package/src/__tests__/vFocusRing.test.ts +36 -0
  114. package/src/__tests__/vLongPress.test.ts +81 -0
  115. package/src/__tests__/vScrollElevation.test.ts +89 -0
  116. package/src/__tests__/vSkeleton.test.ts +48 -0
  117. package/src/__tests__/vStateLayer.test.ts +53 -0
  118. package/src/__tests__/vSwipe.test.ts +93 -0
  119. package/src/__tests__/vTooltip.test.ts +95 -0
  120. package/src/__tests__/viewportHints.test.ts +41 -0
  121. package/src/components/MAutocomplete.vue +5 -0
  122. package/src/components/MBottomSheet.vue +4 -1
  123. package/src/components/MButton.vue +15 -1
  124. package/src/components/MButtonGroup.vue +22 -17
  125. package/src/components/MCarousel.vue +7 -1
  126. package/src/components/MChart.vue +74 -34
  127. package/src/components/MCircleProgressBar.vue +14 -9
  128. package/src/components/MCommandPalette.vue +3 -2
  129. package/src/components/MContextMenu.vue +19 -60
  130. package/src/components/MDragDropList.vue +2 -0
  131. package/src/components/MIconButton.vue +40 -1
  132. package/src/components/MKanban.vue +2 -0
  133. package/src/components/MLightbox.vue +7 -2
  134. package/src/components/MMap.vue +38 -5
  135. package/src/components/MMapBaseLayers.vue +7 -3
  136. package/src/components/MMapFilter.vue +7 -4
  137. package/src/components/MMapGeoJson.vue +1 -1
  138. package/src/components/MMapLayers.vue +6 -2
  139. package/src/components/MMapMeasure.vue +5 -2
  140. package/src/components/MMenu.vue +18 -59
  141. package/src/components/MMenuItem.vue +11 -2
  142. package/src/components/MMultiAutocomplete.vue +5 -0
  143. package/src/components/MNavigationDrawer.vue +96 -11
  144. package/src/components/MNavigationRail.vue +4 -15
  145. package/src/components/MOverlay.vue +32 -13
  146. package/src/components/MProgressBar.vue +25 -27
  147. package/src/components/MPullToRefresh.vue +20 -1
  148. package/src/components/MRichTextEditor.vue +19 -5
  149. package/src/components/MSearchBar.vue +5 -0
  150. package/src/components/MSearchField.vue +142 -0
  151. package/src/components/MSegmentedButton.vue +20 -18
  152. package/src/components/MSelect.vue +10 -1
  153. package/src/components/MSideSheet.vue +5 -2
  154. package/src/components/MSimpleCarousel.vue +10 -1
  155. package/src/components/MSkeleton.vue +30 -8
  156. package/src/components/MSpotlightSearch.vue +3 -2
  157. package/src/components/MTextField.vue +15 -2
  158. package/src/components/MTimeline.vue +370 -81
  159. package/src/components/MTooltip.vue +20 -152
  160. package/src/components/_MDrawerItemList.vue +25 -6
  161. package/src/composables/_mapStyle.ts +45 -0
  162. package/src/composables/_themeTransition.ts +2 -0
  163. package/src/composables/_tooltipTrigger.ts +184 -0
  164. package/src/composables/_useMenuNav.ts +209 -0
  165. package/src/composables/useAutoGrow.ts +78 -0
  166. package/src/composables/useLocale.ts +5 -0
  167. package/src/composables/useMap.ts +43 -5
  168. package/src/composables/useMapFilter.ts +6 -5
  169. package/src/composables/useMapLayers.ts +7 -6
  170. package/src/composables/useScrollReveal.ts +151 -0
  171. package/src/composables/useThemeTokens.ts +116 -0
  172. package/src/composables/viewportHints.ts +80 -0
  173. package/src/directives/vClickOutside.ts +90 -0
  174. package/src/directives/vFocusRing.ts +60 -0
  175. package/src/directives/vLongPress.ts +134 -0
  176. package/src/directives/vReveal.ts +57 -0
  177. package/src/directives/vScrollElevation.ts +116 -0
  178. package/src/directives/vSkeleton.ts +87 -0
  179. package/src/directives/vStateLayer.ts +83 -0
  180. package/src/directives/vSwipe.ts +197 -0
  181. package/src/directives/vTooltip.ts +128 -0
  182. package/src/index.ts +28 -1
  183. package/src/locales/de.ts +2 -0
  184. package/src/locales/es.ts +2 -0
  185. package/src/locales/fr.ts +2 -0
  186. package/src/locales/ja.ts +2 -0
  187. package/src/locales/ko.ts +2 -0
  188. package/src/locales/pt.ts +2 -0
  189. package/src/locales/zh.ts +2 -0
  190. package/src/map.ts +1 -1
  191. package/src/plugin.ts +34 -0
  192. package/src/styles/theme.css +63 -0
  193. package/dist/MMenuItem-BfjqwcYP.js +0 -830
  194. package/dist/MMenuItem-BfjqwcYP.js.map +0 -1
  195. package/dist/MSlider-JflHJ70q.js.map +0 -1
  196. package/dist/MTextField-NaIB6RbM.js +0 -673
  197. package/dist/MTextField-NaIB6RbM.js.map +0 -1
  198. package/dist/composables/_useThemeTokens.d.ts +0 -7
  199. package/dist/useLocale-CXibICQA.js.map +0 -1
  200. package/src/composables/_useThemeTokens.ts +0 -42
@@ -14,6 +14,7 @@ import { useLocale } from '../composables/useLocale'
14
14
  import { useDebounce } from '../composables/useDebounce'
15
15
  import type { MultiSelectOption } from './MMultiSelect.vue'
16
16
  import { useScrollLock } from '../composables/_useScrollLock'
17
+ import { useEscapeStack } from '../composables/_useEscapeStack'
17
18
 
18
19
  // Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
19
20
  // auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
@@ -217,6 +218,7 @@ function closeDropdown() {
217
218
  }
218
219
 
219
220
  useScrollLock(modalOpen)
221
+ useEscapeStack(modalOpen, closeDropdown)
220
222
 
221
223
  function onInputFocus() {
222
224
  openDropdown()
@@ -250,6 +252,9 @@ function onScroll(e: Event) {
250
252
 
251
253
  function onKeydown(e: KeyboardEvent) {
252
254
  if (e.key === 'Escape') {
255
+ // Closing the list uses the key: keep it from also closing a dialog around the field. With nothing open it
256
+ // only leaves the field and passes on
257
+ if (open.value || modalOpen.value) e.stopPropagation()
253
258
  closeDropdown()
254
259
  inputEl.value?.blur()
255
260
  return
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { ref, reactive, watch, provide, computed, nextTick, onBeforeUnmount } from "vue";
18
18
  import MIcon from "./MIcon.vue";
19
+ import MBadge from "./MBadge.vue";
19
20
  import MDrawerItemList from "./_MDrawerItemList.vue";
20
21
  import { motionSprings, type SpringSpec } from "../composables/motion";
21
22
  import { sampleSpring, sampleAt, playSamples, prefersReducedMotion } from "../composables/_springAnimation";
@@ -58,6 +59,11 @@ const props = withDefaults(
58
59
  modal?: boolean;
59
60
  /** Compact mode (72px) showing only icons — inline variant only */
60
61
  collapsed?: boolean;
62
+ /**
63
+ * In `collapsed` mode, shows each item's label under its icon, with the selection on a 56×32 pill around
64
+ * the icon, like MNavigationRail's collapsed items — nested items included
65
+ */
66
+ collapsedLabels?: boolean;
61
67
  /** Custom drawer width (e.g. "320px", "25rem"). Defaults to 22.5rem (360px) */
62
68
  width?: string;
63
69
  /**
@@ -67,8 +73,12 @@ const props = withDefaults(
67
73
  side?: 'left' | 'right' | 'top' | 'bottom';
68
74
  /** Lets the modal drawer be swiped closed toward its edge; with false it only closes through v-model or the scrim */
69
75
  swipeEnabled?: boolean;
76
+ /** Opens the groups that hold the selected item (and the selected item, if it's a group) whenever `selected` changes */
77
+ expandSelected?: boolean;
78
+ /** Keeps one group open per level: opening a group, by hand or through `expandSelected`, closes its siblings */
79
+ accordion?: boolean;
70
80
  }>(),
71
- { modal: true, side: 'left', swipeEnabled: true },
81
+ { modal: true, side: 'left', swipeEnabled: true, expandSelected: true, accordion: false },
72
82
  );
73
83
 
74
84
  const emit = defineEmits<{
@@ -94,9 +104,39 @@ function isItemOpen(item: DrawerItem) {
94
104
  return openItems[item.value] === true;
95
105
  }
96
106
 
107
+ // The item's ancestors, outermost first, ending with the item itself (null when it isn't in the drawer)
108
+ function pathTo(value: string | number, items: DrawerItem[]): DrawerItem[] | null {
109
+ for (const item of items) {
110
+ if (item.value === value) return [item];
111
+ const rest = item.children?.length ? pathTo(value, item.children) : null;
112
+ if (rest) return [item, ...rest];
113
+ }
114
+ return null;
115
+ }
116
+
117
+ function setOpen(item: DrawerItem, open: boolean) {
118
+ if (open && props.accordion) {
119
+ const path = pathTo(item.value, props.sections.flatMap((s) => s.items));
120
+ const siblings = path && path.length > 1 ? path[path.length - 2]!.children! : props.sections.flatMap((s) => s.items);
121
+ for (const s of siblings) if (s !== item && s.children?.length) openItems[s.value] = false;
122
+ }
123
+ openItems[item.value] = open;
124
+ }
125
+
126
+ watch(
127
+ () => props.selected,
128
+ (value) => {
129
+ if (!props.expandSelected || value === undefined) return;
130
+ for (const item of pathTo(value, props.sections.flatMap((s) => s.items)) ?? []) {
131
+ if (item.children?.length && !openItems[item.value]) setOpen(item, true);
132
+ }
133
+ },
134
+ { immediate: true },
135
+ );
136
+
97
137
  function toggleItem(item: DrawerItem) {
98
138
  refreshListTouchAction();
99
- openItems[item.value] = !openItems[item.value];
139
+ setOpen(item, !openItems[item.value]);
100
140
  }
101
141
 
102
142
  function close() {
@@ -119,7 +159,7 @@ function onChildSelect(item: DrawerItem) {
119
159
 
120
160
  function onChildToggle(item: DrawerItem) {
121
161
  refreshListTouchAction();
122
- openItems[item.value] = !openItems[item.value];
162
+ setOpen(item, !openItems[item.value]);
123
163
  }
124
164
 
125
165
  function subEnter(el: Element, done: () => void) {
@@ -147,6 +187,16 @@ provide("nd-open-items", openItems);
147
187
  provide("nd-toggle-item", onChildToggle);
148
188
  provide("nd-select-item", onChildSelect);
149
189
  provide("nd-collapsed", collapsedRef);
190
+ // Collapsed with labels under the icons (rail look); only the inline variant collapses
191
+ const rail = computed(() => !props.modal && collapsedRef.value && !!props.collapsedLabels)
192
+ provide("nd-rail", rail);
193
+ provide("nd-collapsed-labels", computed(() => !props.modal && !!props.collapsedLabels));
194
+
195
+ // A collapsed item's badge sits on its icon: a number as a count, anything else ("New") as a dot
196
+ function badgeProps(badge: string | number) {
197
+ const n = typeof badge === 'number' ? badge : badge.trim() === '' ? NaN : Number(badge)
198
+ return Number.isFinite(n) ? { count: n } : { dot: true }
199
+ }
150
200
 
151
201
  defineExpose({ openItems })
152
202
 
@@ -584,6 +634,7 @@ function onPanelClickCapture(e: MouseEvent) {
584
634
  v-bind="$attrs"
585
635
  class="nd-inline flex h-full shrink-0 flex-col bg-surface"
586
636
  :class="[
637
+ rail ? 'nd-rail' : '',
587
638
  inlineSide === 'right' ? 'border-l border-outline-variant rounded-l-lg' : 'border-r border-outline-variant rounded-r-lg',
588
639
  !modelValue
589
640
  ? inlineSide === 'right' ? 'nd-hidden w-0 border-l-0' : 'nd-hidden w-0 border-r-0'
@@ -612,7 +663,8 @@ function onPanelClickCapture(e: MouseEvent) {
612
663
  </div>
613
664
 
614
665
  <div
615
- class="scrollbar-none flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overflow-x-hidden px-3 py-2"
666
+ class="scrollbar-none flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overflow-x-hidden py-2"
667
+ :class="rail ? 'px-2' : 'px-3'"
616
668
  >
617
669
  <template v-for="(section, si) in sections" :key="si">
618
670
  <div v-if="si > 0" class="my-1 border-t border-outline-variant" />
@@ -621,7 +673,8 @@ function onPanelClickCapture(e: MouseEvent) {
621
673
  <button
622
674
  v-if="section.title && section.collapsible"
623
675
  type="button"
624
- class="mt-1 flex w-full shrink-0 cursor-pointer items-center gap-3 overflow-hidden whitespace-nowrap rounded-xl px-3 py-2.5 text-on-surface-variant hover:bg-on-surface/8"
676
+ class="mt-1 flex w-full shrink-0 cursor-pointer items-center gap-3 overflow-hidden whitespace-nowrap rounded-xl py-2.5 text-on-surface-variant hover:bg-on-surface/8"
677
+ :class="rail ? 'px-4' : 'px-3'"
625
678
  :title="collapsed ? section.title : undefined"
626
679
  @click="toggleSection(section, si)"
627
680
  >
@@ -663,23 +716,38 @@ function onPanelClickCapture(e: MouseEvent) {
663
716
  :to="item.to && !item.disabled ? item.to : undefined"
664
717
  :type="item.to ? undefined : 'button'"
665
718
  :title="collapsed ? item.label : undefined"
666
- class="flex w-full shrink-0 items-center gap-3 overflow-hidden whitespace-nowrap rounded-full py-4 text-left focus-visible:outline-none"
719
+ class="relative flex w-full shrink-0 items-center gap-3 overflow-hidden whitespace-nowrap text-left focus-visible:outline-none"
667
720
  :class="[
668
- section.collapsible && !collapsed ? 'pl-8 pr-3' : 'px-3',
721
+ // Rail look: 56px tall, the icon in a 56×32 pill at the top and the label under it, the
722
+ // icon at the same x as expanded (8 + 16 = 12 + 12) so collapsing never moves it sideways
723
+ rail ? 'px-4 pt-2 pb-6' : ['rounded-full py-4', section.collapsible && !collapsed ? 'pl-8 pr-3' : 'px-3'],
669
724
  item.disabled
670
725
  ? 'cursor-not-allowed opacity-[0.38]'
671
726
  : item.value === selected
672
- ? 'bg-secondary-container text-on-secondary-container'
673
- : 'cursor-pointer text-on-surface-variant hover:bg-on-surface/8',
727
+ ? rail ? 'text-on-secondary-container' : 'bg-secondary-container text-on-secondary-container'
728
+ : rail ? 'group cursor-pointer text-on-surface-variant' : 'cursor-pointer text-on-surface-variant hover:bg-on-surface/8',
674
729
  ]"
675
730
  :disabled="item.disabled && !item.to"
676
731
  @click="select(item)"
677
732
  >
733
+ <span
734
+ v-if="rail"
735
+ aria-hidden="true"
736
+ class="pointer-events-none absolute left-0 top-1 h-8 w-14 rounded-full transition-colors"
737
+ :class="item.value === selected && !item.disabled ? 'bg-secondary-container' : 'group-hover:bg-on-surface/8'"
738
+ />
739
+ <MBadge
740
+ v-if="collapsed && item.icon && item.badge != null"
741
+ v-bind="badgeProps(item.badge)"
742
+ class="shrink-0"
743
+ >
744
+ <MIcon :name="item.icon" :size="item.iconSize ?? 24" />
745
+ </MBadge>
678
746
  <MIcon
679
- v-if="item.icon"
747
+ v-else-if="item.icon"
680
748
  :name="item.icon"
681
749
  :size="item.iconSize ?? 24"
682
- class="shrink-0"
750
+ class="relative shrink-0"
683
751
  />
684
752
  <span
685
753
  class="nd-label min-w-0 flex-1 font-medium"
@@ -698,6 +766,11 @@ function onPanelClickCapture(e: MouseEvent) {
698
766
  >
699
767
  {{ item.badge }}
700
768
  </span>
769
+ <span
770
+ v-if="collapsedLabels"
771
+ class="nd-rail-label pointer-events-none absolute left-0 top-10 w-14 truncate text-center text-label-medium font-medium"
772
+ :class="item.value === selected ? 'text-secondary' : 'text-on-surface-variant'"
773
+ >{{ item.label }}</span>
701
774
  </component>
702
775
  <div v-if="item.children?.length && isItemOpen(item)" class="nd-children-divider" />
703
776
  <Transition
@@ -802,6 +875,18 @@ function onPanelClickCapture(e: MouseEvent) {
802
875
  transition: opacity 100ms cubic-bezier(0.2, 0, 0, 1);
803
876
  }
804
877
 
878
+ /* Labels under the icons (collapsedLabels): fade in once the width has mostly shrunk, out at once */
879
+ .nd-rail-label,
880
+ :deep(.nd-rail-label) {
881
+ opacity: 0;
882
+ transition: opacity 100ms cubic-bezier(0.2, 0, 0, 1);
883
+ }
884
+ .nd-inline.nd-rail .nd-rail-label,
885
+ .nd-inline.nd-rail :deep(.nd-rail-label) {
886
+ opacity: 1;
887
+ transition: opacity 200ms 150ms cubic-bezier(0.2, 0, 0, 1);
888
+ }
889
+
805
890
  /* Elements that should collapse to 0 height when sidebar is collapsed */
806
891
  .nd-inline .nd-collapse-h {
807
892
  max-height: 80px;
@@ -14,6 +14,7 @@ import MBadge from './MBadge.vue'
14
14
  import { useItemLink, type ItemLink } from '../composables/_useItemLink'
15
15
  import { sampleSpring, sampleAt, playSamples, prefersReducedMotion } from '../composables/_springAnimation'
16
16
  import { useScrollLock } from '../composables/_useScrollLock'
17
+ import { useEscapeStack } from '../composables/_useEscapeStack'
17
18
 
18
19
  export interface NavRailItem {
19
20
  value: string | number
@@ -89,9 +90,6 @@ function selectModal(item: NavRailItem) {
89
90
  emit('update:modelValue', item.value)
90
91
  close()
91
92
  }
92
- function onKeydown(e: KeyboardEvent) {
93
- if (e.key === 'Escape') close()
94
- }
95
93
 
96
94
  /*
97
95
  * Modal panel open/close: a real width spring (rAF + semi-implicit Euler), not a CSS
@@ -357,21 +355,12 @@ function onPanelLeave(el: Element, done: () => void) {
357
355
  else done()
358
356
  }
359
357
 
360
- watch(
361
- () => props.modal && props.expanded,
362
- (open) => {
363
- if (open) {
364
- document.addEventListener('keydown', onKeydown)
365
- } else {
366
- document.removeEventListener('keydown', onKeydown)
367
- }
368
- },
369
- )
358
+ // The modal panel closes on Escape through the library's stack (a dialog or menu opened over it takes it first)
359
+ useEscapeStack(() => !!(props.modal && props.expanded), close)
370
360
 
371
361
  onUnmounted(() => {
372
362
  slideAnim?.cancel()
373
363
  slideScrimAnim?.cancel()
374
- document.removeEventListener('keydown', onKeydown)
375
364
  })
376
365
  useScrollLock(() => props.modal && props.expanded)
377
366
  </script>
@@ -533,7 +522,7 @@ useScrollLock(() => props.modal && props.expanded)
533
522
  -->
534
523
  <Teleport v-if="modal" to="body">
535
524
  <Transition :css="false" @enter="onPanelEnter" @leave="onPanelLeave">
536
- <div v-if="expanded" class="fixed inset-0 z-100" @keydown.escape="close">
525
+ <div v-if="expanded" class="fixed inset-0 z-100">
537
526
  <div class="wnr-scrim absolute inset-0 bg-scrim/32" @click="close" />
538
527
 
539
528
  <nav
@@ -1,12 +1,18 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
3
  * Full-screen overlay with scrim and teleport to body. A generic low-level building block — content is entirely
4
- * up to you via the default slot.
4
+ * up to you via the default slot. Your class, role and aria attributes go on the content layer (over the scrim),
5
+ * so `class="flex items-center justify-center bg-black"` lays out and paints the slot.
5
6
  *
6
7
  * @slot default Content shown over the scrim.
7
- * @event update:modelValue Emitted with false when the scrim is clicked, for v-model support
8
+ * @event update:modelValue Emitted with false when the scrim is clicked (or Escape is pressed with closeOnEscape),
9
+ * for v-model support
8
10
  */
9
11
  import { computed } from 'vue'
12
+ import { useEscapeStack } from '../composables/_useEscapeStack'
13
+ import { useScrollLock } from '../composables/_useScrollLock'
14
+
15
+ defineOptions({ inheritAttrs: false })
10
16
 
11
17
  const props = withDefaults(
12
18
  defineProps<{
@@ -16,8 +22,17 @@ const props = withDefaults(
16
22
  scrim?: boolean
17
23
  /** Z-index value */
18
24
  zIndex?: number
25
+ /**
26
+ * Closes on Escape. It shares the library's Escape stack with MDialog and the sheets, so a dialog or menu opened
27
+ * over it takes Escape first
28
+ */
29
+ closeOnEscape?: boolean
30
+ /** Locks the page's scroll while open (shared with the library's other modal surfaces, so stacking is safe) */
31
+ lockScroll?: boolean
32
+ /** Name of a `<Transition>` (your CSS classes) to play instead of the default fade */
33
+ transition?: string
19
34
  }>(),
20
- { modelValue: true, scrim: true, zIndex: 50 },
35
+ { modelValue: true, scrim: true, zIndex: 50, closeOnEscape: false, lockScroll: false },
21
36
  )
22
37
 
23
38
  const emit = defineEmits<{
@@ -28,27 +43,31 @@ const style = computed(() => ({
28
43
  zIndex: props.zIndex,
29
44
  }))
30
45
 
31
- function handleScrimClick() {
46
+ function close() {
32
47
  emit('update:modelValue', false)
33
48
  }
49
+
50
+ useEscapeStack(() => props.closeOnEscape && props.modelValue, close)
51
+ useScrollLock(() => props.lockScroll && props.modelValue)
52
+
53
+ const fade = {
54
+ enterActiveClass: 'transition-opacity duration-200',
55
+ leaveActiveClass: 'transition-opacity duration-150',
56
+ enterFromClass: 'opacity-0',
57
+ leaveToClass: 'opacity-0',
58
+ }
34
59
  </script>
35
60
 
36
61
  <template>
37
62
  <Teleport to="body">
38
- <Transition
39
- appear
40
- enter-active-class="transition-opacity duration-200"
41
- leave-active-class="transition-opacity duration-150"
42
- enter-from-class="opacity-0"
43
- leave-to-class="opacity-0"
44
- >
63
+ <Transition appear v-bind="transition ? { name: transition } : fade">
45
64
  <div v-if="modelValue" class="fixed inset-0" :style="style">
46
65
  <div
47
66
  v-if="scrim"
48
67
  class="absolute inset-0 bg-scrim/32"
49
- @click="handleScrimClick"
68
+ @click="close"
50
69
  />
51
- <div class="relative h-full w-full">
70
+ <div class="relative h-full w-full" v-bind="$attrs">
52
71
  <slot />
53
72
  </div>
54
73
  </div>
@@ -10,8 +10,10 @@ const props = withDefaults(
10
10
  value?: number;
11
11
  /** Indeterminate animation — also implied by omitting value */
12
12
  indeterminate?: boolean;
13
- /** Bar color */
14
- color?: "primary" | "secondary" | "tertiary" | "error";
13
+ /** Bar color: an M3 role or any CSS color (`#fff` over a photo, say) */
14
+ color?: "primary" | "secondary" | "tertiary" | "error" | (string & {});
15
+ /** Track color: an M3 role or any CSS color. Default the role's container, or the bar color at 24% for a CSS color */
16
+ trackColor?: string;
15
17
  /** Bar style */
16
18
  variant?: "linear" | "wavy";
17
19
  /** Label text above the bar */
@@ -25,15 +27,18 @@ const props = withDefaults(
25
27
  const isIndeterminate = computed(() => props.indeterminate || props.value === undefined);
26
28
  const clampedValue = computed(() => Math.min(100, Math.max(0, props.value ?? 0)));
27
29
 
28
- const colorMap: Record<
29
- "primary" | "secondary" | "tertiary" | "error",
30
- { bar: string; track: string; text: string }
31
- > = {
32
- primary: { bar: "bg-primary", track: "bg-primary-container", text: "text-primary" },
33
- secondary: { bar: "bg-secondary", track: "bg-secondary-container", text: "text-secondary" },
34
- tertiary: { bar: "bg-tertiary", track: "bg-tertiary-container", text: "text-tertiary" },
35
- error: { bar: "bg-error", track: "bg-error-container", text: "text-error" },
36
- };
30
+ const ROLES = ["primary", "secondary", "tertiary", "error"];
31
+ const roleOr = (c: string) => (ROLES.includes(c) || c.endsWith("-container") ? `var(--color-${c})` : c);
32
+ // Both colors go through custom properties on the root, read by the bar/track/wave below.
33
+ const colorVars = computed(() => {
34
+ const bar = roleOr(props.color);
35
+ const track = props.trackColor
36
+ ? roleOr(props.trackColor)
37
+ : ROLES.includes(props.color)
38
+ ? `var(--color-${props.color}-container)`
39
+ : `color-mix(in srgb, ${props.color} 24%, transparent)`;
40
+ return { "--m3-progress-bar": bar, "--m3-progress-track": track };
41
+ });
37
42
 
38
43
  // ── Wave geometry ─────────────────────────────────────────────────────────
39
44
  const PERIOD = 20;
@@ -199,14 +204,14 @@ watch(isIndeterminate, async (v) => {
199
204
  </script>
200
205
 
201
206
  <template>
202
- <div class="flex flex-col gap-1">
207
+ <div class="flex flex-col gap-1" :style="colorVars">
203
208
  <span v-if="label" class="text-label-small text-on-surface-variant">{{ label }}</span>
204
209
 
205
210
  <!-- ── Linear variant ────────────────────────────────────────────────── -->
206
211
  <div
207
212
  v-if="variant === 'linear'"
208
213
  class="relative w-full overflow-hidden rounded-full"
209
- :class="isIndeterminate ? colorMap[color].track : ''"
214
+ :class="isIndeterminate ? 'bg-(--m3-progress-track)' : ''"
210
215
  :style="{ height: `${effectiveThickness}px` }"
211
216
  role="progressbar"
212
217
  :aria-valuenow="isIndeterminate ? undefined : clampedValue"
@@ -217,20 +222,17 @@ watch(isIndeterminate, async (v) => {
217
222
  a fixed gap after the active bar, not flush against it. -->
218
223
  <template v-if="!isIndeterminate">
219
224
  <div
220
- class="absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 ease-in-out"
221
- :class="colorMap[color].bar"
225
+ class="absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 ease-in-out bg-(--m3-progress-bar)"
222
226
  :style="{ width: `${clampedValue}%` }"
223
227
  />
224
228
  <div
225
- class="absolute inset-y-0 right-0 rounded-full transition-[left] duration-300 ease-in-out"
226
- :class="colorMap[color].track"
229
+ class="absolute inset-y-0 right-0 rounded-full transition-[left] duration-300 ease-in-out bg-(--m3-progress-track)"
227
230
  :style="{ left: `calc(${clampedValue}% + 4px)` }"
228
231
  />
229
232
  </template>
230
233
  <div
231
234
  v-else
232
- class="absolute inset-y-0 w-2/5 rounded-full animate-[m3-progress-indeterminate_1.6s_ease-in-out_infinite]"
233
- :class="colorMap[color].bar"
235
+ class="absolute inset-y-0 w-2/5 rounded-full animate-[m3-progress-indeterminate_1.6s_ease-in-out_infinite] bg-(--m3-progress-bar)"
234
236
  />
235
237
  </div>
236
238
 
@@ -253,8 +255,7 @@ watch(isIndeterminate, async (v) => {
253
255
  style="clip-path: inset(0 100% 0 0)"
254
256
  >
255
257
  <svg
256
- class="absolute top-0 left-0 h-full"
257
- :class="colorMap[color].text"
258
+ class="absolute top-0 left-0 h-full text-(--m3-progress-bar)"
258
259
  :width="waveWidth"
259
260
  :height="waveViewH"
260
261
  :viewBox="`0 0 ${waveWidth} ${waveViewH}`"
@@ -272,15 +273,13 @@ watch(isIndeterminate, async (v) => {
272
273
  <!-- Inactive track — rAF owns left and height; no Vue-managed left -->
273
274
  <div
274
275
  ref="trackEl"
275
- class="absolute right-0"
276
- :class="colorMap[color].track"
276
+ class="absolute right-0 bg-(--m3-progress-track)"
277
277
  style="border-radius: 9999px; top: 50%; transform: translateY(-50%);"
278
278
  />
279
279
 
280
280
  <!-- Stop dot at far right -->
281
281
  <div
282
- class="absolute rounded-full"
283
- :class="colorMap[color].bar"
282
+ class="absolute rounded-full bg-(--m3-progress-bar)"
284
283
  :style="{
285
284
  right: '0',
286
285
  top: '50%',
@@ -294,8 +293,7 @@ watch(isIndeterminate, async (v) => {
294
293
  <!-- INDETERMINATE — keeps original CSS-animated wide strip -->
295
294
  <div v-else class="absolute inset-0 overflow-hidden rounded-full">
296
295
  <div
297
- class="absolute top-0 left-0 h-full animate-[m3-wave-flow_0.9s_linear_infinite]"
298
- :class="colorMap[color].text"
296
+ class="absolute top-0 left-0 h-full animate-[m3-wave-flow_0.9s_linear_infinite] text-(--m3-progress-bar)"
299
297
  :style="{ width: `${waveWidth}px` }"
300
298
  >
301
299
  <svg
@@ -8,7 +8,7 @@
8
8
  * @event refresh Emitted when the user drags past threshold and releases. Set refreshing to true in the
9
9
  * handler, then back to false once the fetch resolves.
10
10
  */
11
- import { ref, watch, onMounted, onBeforeUnmount } from "vue";
11
+ import { ref, watch, onMounted, onBeforeUnmount, onActivated } from "vue";
12
12
  import MLoadingIndicator from "./MLoadingIndicator.vue";
13
13
 
14
14
  const props = withDefaults(
@@ -254,9 +254,27 @@ onMounted(() => {
254
254
  el.addEventListener("touchmove", onTouchMove, { passive: false });
255
255
  el.addEventListener("touchend", onTouchEnd);
256
256
  el.addEventListener("scroll", updateTouchAction, { passive: true });
257
+ el.addEventListener("scroll", rememberScroll, { passive: true });
257
258
  updateTouchAction();
258
259
  el.addEventListener("touchcancel", onTouchEnd);
259
260
  });
261
+ // Inside a <KeepAlive>, the browser forgets a detached element's scroll position (and reads 0 once it's detached),
262
+ // so remember the last one from the scroll events and put it back when the view comes back.
263
+ let lastScrollTop = 0;
264
+ function rememberScroll() {
265
+ lastScrollTop = scrollEl.value?.scrollTop ?? 0;
266
+ }
267
+ onActivated(() => {
268
+ if (lastScrollTop && scrollEl.value) scrollEl.value.scrollTop = lastScrollTop;
269
+ });
270
+
271
+ defineExpose({
272
+ /** The element that scrolls the slot's content */
273
+ scrollEl,
274
+ /** Scrolls the content, like `Element.scrollTo()` (e.g. `{ top: 0, behavior: 'smooth' }`) */
275
+ scrollTo: (options: ScrollToOptions) => scrollEl.value?.scrollTo(options),
276
+ });
277
+
260
278
  onBeforeUnmount(() => {
261
279
  pulling = false;
262
280
  const el = scrollEl.value;
@@ -265,6 +283,7 @@ onBeforeUnmount(() => {
265
283
  el.removeEventListener("touchmove", onTouchMove);
266
284
  el.removeEventListener("touchend", onTouchEnd);
267
285
  el.removeEventListener("scroll", updateTouchAction);
286
+ el.removeEventListener("scroll", rememberScroll);
268
287
  el.removeEventListener("touchcancel", onTouchEnd);
269
288
  });
270
289
  </script>
@@ -52,15 +52,20 @@ const props = withDefaults(
52
52
  placeholder?: string
53
53
  /** Disables editing */
54
54
  disabled?: boolean
55
- /** Minimum editor height */
55
+ /** Minimum height of the text area (not used with `fill`) */
56
56
  minHeight?: string
57
+ /**
58
+ * Fills the height you give the editor (`class="h-full"`, `flex-1`…): the toolbar stays put and the text
59
+ * scrolls inside, instead of the editor growing with its content
60
+ */
61
+ fill?: boolean
57
62
  /**
58
63
  * Object with all toolbar/dialog label overrides for i18n (see `RichTextEditorLabels`) — defaults come from
59
64
  * useLocale()
60
65
  */
61
66
  labels?: RichTextEditorLabels
62
67
  }>(),
63
- { disabled: false, minHeight: '200px' },
68
+ { disabled: false, minHeight: '200px', fill: false },
64
69
  )
65
70
 
66
71
  const l = computed<Required<RichTextEditorLabels>>(() => ({
@@ -231,10 +236,13 @@ function confirmImage() {
231
236
  <template>
232
237
  <div
233
238
  class="overflow-hidden rounded-lg border transition-colors duration-150"
234
- :class="disabled ? 'border-outline-variant/50 opacity-60' : 'border-outline-variant focus-within:border-primary'"
239
+ :class="[
240
+ disabled ? 'border-outline-variant/50 opacity-60' : 'border-outline-variant focus-within:border-primary',
241
+ { 'flex flex-col': fill },
242
+ ]"
235
243
  >
236
244
  <!-- Toolbar -->
237
- <div v-if="ready" class="flex flex-wrap items-center gap-0.5 border-b border-outline-variant bg-surface-container px-2 py-1.5">
245
+ <div v-if="ready" class="flex shrink-0 flex-wrap items-center gap-0.5 border-b border-outline-variant bg-surface-container px-2 py-1.5">
238
246
  <!-- Heading menu -->
239
247
  <MMenu align="left">
240
248
  <template #trigger>
@@ -293,7 +301,8 @@ function confirmImage() {
293
301
  <div
294
302
  ref="editorContainer"
295
303
  class="rte-content bg-surface px-4 py-3 text-body-large text-on-surface"
296
- :style="{ minHeight: minHeight }"
304
+ :class="{ 'rte-fill flex min-h-0 flex-1 flex-col overflow-y-auto': fill }"
305
+ :style="fill ? undefined : { minHeight }"
297
306
  />
298
307
 
299
308
  <!-- Link dialog -->
@@ -322,6 +331,11 @@ function confirmImage() {
322
331
  min-height: inherit;
323
332
  }
324
333
 
334
+ /* Filling: the document takes the whole area, so a click anywhere below the text lands in it. */
335
+ .rte-fill :deep(.tiptap) {
336
+ flex: 1;
337
+ }
338
+
325
339
  .rte-content :deep(.tiptap p.is-editor-empty:first-child::before) {
326
340
  content: attr(data-placeholder);
327
341
  float: left;
@@ -20,6 +20,7 @@ import MSpinner from './MSpinner.vue'
20
20
  import { useLocale } from '../composables/useLocale'
21
21
  import { searchAppBarKey } from '../composables/_searchAppBar'
22
22
  import { useScrollLock } from '../composables/_useScrollLock'
23
+ import { useEscapeStack } from '../composables/_useEscapeStack'
23
24
 
24
25
  // Root is a fragment (bar div + a sibling Teleport for the expanded overlay panel), so Vue
25
26
  // can't auto-apply a consumer's class/attrs to either one — forward them onto the bar div below.
@@ -121,6 +122,8 @@ function onClear() {
121
122
 
122
123
  function onKeydown(e: KeyboardEvent) {
123
124
  if (e.key === 'Escape') {
125
+ // Collapsing uses the key: keep it from also closing a dialog around the bar
126
+ if (expanded.value) e.stopPropagation()
124
127
  close()
125
128
  inputEl.value?.blur()
126
129
  } else if (e.key === 'Enter') {
@@ -151,6 +154,8 @@ onUnmounted(() => {
151
154
  })
152
155
 
153
156
  useScrollLock(() => expanded.value && fullscreen.value)
157
+ // Expanded, it's a popup (or a modal view): Escape collapses it first, wherever the focus is
158
+ useEscapeStack(() => expanded.value, () => close())
154
159
  </script>
155
160
 
156
161
  <template>