@m3ui-vue/m3ui-vue 1.1.4 → 1.2.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 (199) 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 +7131 -6216
  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__/MSkeleton.test.ts +38 -0
  103. package/src/__tests__/MTimeline.test.ts +238 -0
  104. package/src/__tests__/_fakeMaplibre.ts +3 -1
  105. package/src/__tests__/attrsFallthrough.test.ts +3 -0
  106. package/src/__tests__/escapeStack.test.ts +93 -0
  107. package/src/__tests__/ssr.test.ts +21 -2
  108. package/src/__tests__/useAutoGrow.test.ts +103 -0
  109. package/src/__tests__/useScrollReveal.test.ts +102 -0
  110. package/src/__tests__/useThemeTokens.test.ts +114 -0
  111. package/src/__tests__/vClickOutside.test.ts +82 -0
  112. package/src/__tests__/vFocusRing.test.ts +36 -0
  113. package/src/__tests__/vLongPress.test.ts +81 -0
  114. package/src/__tests__/vScrollElevation.test.ts +89 -0
  115. package/src/__tests__/vSkeleton.test.ts +48 -0
  116. package/src/__tests__/vStateLayer.test.ts +53 -0
  117. package/src/__tests__/vSwipe.test.ts +93 -0
  118. package/src/__tests__/vTooltip.test.ts +95 -0
  119. package/src/__tests__/viewportHints.test.ts +41 -0
  120. package/src/components/MAutocomplete.vue +5 -0
  121. package/src/components/MBottomSheet.vue +4 -1
  122. package/src/components/MButton.vue +15 -1
  123. package/src/components/MButtonGroup.vue +22 -17
  124. package/src/components/MCarousel.vue +7 -1
  125. package/src/components/MChart.vue +74 -34
  126. package/src/components/MCircleProgressBar.vue +14 -9
  127. package/src/components/MCommandPalette.vue +3 -2
  128. package/src/components/MContextMenu.vue +19 -60
  129. package/src/components/MDragDropList.vue +2 -0
  130. package/src/components/MIconButton.vue +40 -1
  131. package/src/components/MKanban.vue +2 -0
  132. package/src/components/MLightbox.vue +7 -2
  133. package/src/components/MMap.vue +38 -5
  134. package/src/components/MMapBaseLayers.vue +7 -3
  135. package/src/components/MMapFilter.vue +7 -4
  136. package/src/components/MMapGeoJson.vue +1 -1
  137. package/src/components/MMapLayers.vue +6 -2
  138. package/src/components/MMapMeasure.vue +5 -2
  139. package/src/components/MMenu.vue +18 -59
  140. package/src/components/MMenuItem.vue +11 -2
  141. package/src/components/MMultiAutocomplete.vue +5 -0
  142. package/src/components/MNavigationDrawer.vue +96 -11
  143. package/src/components/MNavigationRail.vue +4 -15
  144. package/src/components/MOverlay.vue +32 -13
  145. package/src/components/MProgressBar.vue +25 -27
  146. package/src/components/MPullToRefresh.vue +20 -1
  147. package/src/components/MRichTextEditor.vue +19 -5
  148. package/src/components/MSearchBar.vue +5 -0
  149. package/src/components/MSearchField.vue +142 -0
  150. package/src/components/MSegmentedButton.vue +19 -17
  151. package/src/components/MSelect.vue +10 -1
  152. package/src/components/MSideSheet.vue +5 -2
  153. package/src/components/MSimpleCarousel.vue +10 -1
  154. package/src/components/MSkeleton.vue +30 -8
  155. package/src/components/MSpotlightSearch.vue +3 -2
  156. package/src/components/MTextField.vue +15 -2
  157. package/src/components/MTimeline.vue +370 -81
  158. package/src/components/MTooltip.vue +20 -152
  159. package/src/components/_MDrawerItemList.vue +25 -6
  160. package/src/composables/_mapStyle.ts +45 -0
  161. package/src/composables/_themeTransition.ts +2 -0
  162. package/src/composables/_tooltipTrigger.ts +184 -0
  163. package/src/composables/_useMenuNav.ts +209 -0
  164. package/src/composables/useAutoGrow.ts +78 -0
  165. package/src/composables/useLocale.ts +5 -0
  166. package/src/composables/useMap.ts +43 -5
  167. package/src/composables/useMapFilter.ts +6 -5
  168. package/src/composables/useMapLayers.ts +7 -6
  169. package/src/composables/useScrollReveal.ts +151 -0
  170. package/src/composables/useThemeTokens.ts +116 -0
  171. package/src/composables/viewportHints.ts +80 -0
  172. package/src/directives/vClickOutside.ts +90 -0
  173. package/src/directives/vFocusRing.ts +60 -0
  174. package/src/directives/vLongPress.ts +134 -0
  175. package/src/directives/vReveal.ts +57 -0
  176. package/src/directives/vScrollElevation.ts +116 -0
  177. package/src/directives/vSkeleton.ts +87 -0
  178. package/src/directives/vStateLayer.ts +83 -0
  179. package/src/directives/vSwipe.ts +197 -0
  180. package/src/directives/vTooltip.ts +128 -0
  181. package/src/index.ts +28 -1
  182. package/src/locales/de.ts +2 -0
  183. package/src/locales/es.ts +2 -0
  184. package/src/locales/fr.ts +2 -0
  185. package/src/locales/ja.ts +2 -0
  186. package/src/locales/ko.ts +2 -0
  187. package/src/locales/pt.ts +2 -0
  188. package/src/locales/zh.ts +2 -0
  189. package/src/map.ts +1 -1
  190. package/src/plugin.ts +34 -0
  191. package/src/styles/theme.css +63 -0
  192. package/dist/MMenuItem-BfjqwcYP.js +0 -830
  193. package/dist/MMenuItem-BfjqwcYP.js.map +0 -1
  194. package/dist/MSlider-JflHJ70q.js.map +0 -1
  195. package/dist/MTextField-NaIB6RbM.js +0 -673
  196. package/dist/MTextField-NaIB6RbM.js.map +0 -1
  197. package/dist/composables/_useThemeTokens.d.ts +0 -7
  198. package/dist/useLocale-CXibICQA.js.map +0 -1
  199. package/src/composables/_useThemeTokens.ts +0 -42
@@ -1,31 +1,104 @@
1
- <script setup lang="ts">
2
- /**
3
- * A vertical event timeline with icon dots, dates, and colors — standard single-column or alternating
4
- * left/right layout.
5
- */
6
- import MIcon from "./MIcon.vue";
7
-
1
+ <script lang="ts">
8
2
  export interface TimelineItem {
3
+ /** Stable key for the entry (defaults to its index): set it when entries are added or removed */
4
+ key?: string | number;
9
5
  title: string;
10
6
  description?: string;
11
7
  date?: string;
12
8
  icon?: string;
13
9
  color?: "primary" | "secondary" | "tertiary" | "error" | "success";
10
+ /** Any CSS color for the dot (and its line), over `color` */
14
11
  dotColor?: string;
12
+ /**
13
+ * Progress of a step: `done` (filled, a solid line to the next), `current` (filled, with a pulsing halo) or
14
+ * `pending` (outlined, a dashed line). Over what the timeline's `current` gives it
15
+ */
16
+ status?: "done" | "current" | "pending";
17
+ /**
18
+ * A group to show it under ("Today", "Yesterday"): a header goes before each run of consecutive entries with the
19
+ * same group, and the line stops at the end of the run
20
+ */
21
+ group?: string;
15
22
  }
16
23
 
17
- withDefaults(
24
+ export type TimelineStatus = NonNullable<TimelineItem["status"]>;
25
+ </script>
26
+
27
+ <script setup lang="ts" generic="T extends TimelineItem = TimelineItem">
28
+ /**
29
+ * An event timeline with icon dots, dates, and colors — a single column, alternating left/right, or horizontal.
30
+ * With `current` (or items' `status`) it tracks progress: done steps filled with a solid line, the current one
31
+ * pulsing, the rest outlined with a dashed line. Every part can be replaced through slots, which receive
32
+ * `{ item, index }`; your item type flows into them.
33
+ *
34
+ * @slot item Extra content under an entry's description (a card, chips, a button). With `bare`, the entry's whole
35
+ * content. `item-{index}` slots still work for a single entry and win over this one
36
+ * @slot title Replaces an entry's title row (title and date)
37
+ * @slot dot Replaces an entry's dot (an avatar, an image, a custom shape); the line still runs from it
38
+ * @slot group Replaces a group's header (scope: `{ group, items }`, the run of entries under it)
39
+ * @slot opposite Content across the line: on the empty side in the alternating layout, or in a column before the
40
+ * line in the single-column one (dates, times, amounts)
41
+ */
42
+ import { computed, onBeforeUpdate, onMounted, onUpdated, ref, useSlots } from "vue";
43
+ import MIcon from "./MIcon.vue";
44
+ import MButton from "./MButton.vue";
45
+ import { useLocale } from "../composables/useLocale";
46
+ import { motionSprings } from "../composables/motion";
47
+ import { playSamples, prefersReducedMotion, sampleSpring } from "../composables/_springAnimation";
48
+
49
+ const props = withDefaults(
18
50
  defineProps<{
19
51
  /** Array of timeline entries — required */
20
- items: TimelineItem[];
52
+ items: T[];
21
53
  /** Compact spacing between items */
22
54
  dense?: boolean;
23
- /** Alternate items left/right of a central line instead of a single left-aligned column */
55
+ /** Alternate items left/right of a central line instead of a single left-aligned column (vertical only) */
24
56
  alternating?: boolean;
57
+ /** Vertical (default) or horizontal: entries side by side along a line, scrolling sideways when they don't fit */
58
+ orientation?: "vertical" | "horizontal";
59
+ /** Leaves each entry's content to the `#item` slot: no title, description or date */
60
+ bare?: boolean;
61
+ /**
62
+ * Makes it a progress timeline (an order's tracking, a setup's steps): the index of the current step. The ones
63
+ * before are done, the ones after pending; an item's own `status` wins. `items.length` marks them all done
64
+ */
65
+ current?: number;
66
+ /**
67
+ * Lets the alternating layout fold into a single column (the line on the left, `#opposite` under the content)
68
+ * while the timeline is narrower than 32rem: its own width, so it works in a side column too
69
+ */
70
+ responsive?: boolean;
71
+ /**
72
+ * Entries added after it mounts fade and slide in, and the rest move to their new places, on M3 springs (none
73
+ * with reduced motion). Give items a `key`, or an insertion looks like a change to every entry after it
74
+ */
75
+ animate?: boolean;
76
+ /** Shows only the first entries (a count; groups' headers don't count), with a button for the rest */
77
+ limit?: number;
78
+ /** Whether the entries past `limit` show (v-model:expanded); the timeline keeps its own state otherwise */
79
+ expanded?: boolean;
25
80
  }>(),
26
- { dense: false, alternating: false },
81
+ {
82
+ dense: false, alternating: false, orientation: "vertical", bare: false, current: undefined, responsive: true,
83
+ animate: true, limit: undefined, expanded: undefined,
84
+ },
27
85
  );
28
86
 
87
+ const emit = defineEmits<{ "update:expanded": [expanded: boolean] }>();
88
+
89
+ defineSlots<{
90
+ item?: (props: { item: T; index: number }) => unknown;
91
+ title?: (props: { item: T; index: number }) => unknown;
92
+ dot?: (props: { item: T; index: number }) => unknown;
93
+ opposite?: (props: { item: T; index: number }) => unknown;
94
+ group?: (props: { group: string; items: T[] }) => unknown;
95
+ [name: `item-${number}`]: ((props: { item: T; index: number }) => unknown) | undefined;
96
+ }>();
97
+
98
+ const slots = useSlots();
99
+
100
+ // Literal class names: Tailwind only generates what appears in the source, so a class built at runtime
101
+ // (`bg-secondary` + '/30') rendered no line for anything but primary
29
102
  const dotBg: Record<string, string> = {
30
103
  primary: "bg-primary text-on-primary",
31
104
  secondary: "bg-secondary text-on-secondary",
@@ -33,92 +106,308 @@ const dotBg: Record<string, string> = {
33
106
  error: "bg-error text-on-error",
34
107
  success: "bg-success text-on-success",
35
108
  };
109
+ const lineBg: Record<string, string> = {
110
+ primary: "bg-primary/30",
111
+ secondary: "bg-secondary/30",
112
+ tertiary: "bg-tertiary/30",
113
+ error: "bg-error/30",
114
+ success: "bg-success/30",
115
+ };
116
+
117
+ const t = useLocale();
118
+
119
+ // `limit`: the first entries, then a button for the rest (all of them while expanded)
120
+ const ownExpanded = ref(false);
121
+ const isExpanded = computed(() => props.expanded ?? ownExpanded.value);
122
+ const limited = computed(() => props.limit !== undefined && props.items.length > props.limit);
123
+ const shown = computed(() => (limited.value && !isExpanded.value ? props.items.slice(0, props.limit) : props.items));
124
+ const hiddenCount = computed(() => props.items.length - shown.value.length);
125
+ const toggleLabel = computed(() =>
126
+ isExpanded.value ? t.timelineShowLess : t.timelineShowMore.replace("{count}", String(hiddenCount.value)),
127
+ );
128
+ function toggleExpanded() {
129
+ const next = !isExpanded.value;
130
+ ownExpanded.value = next;
131
+ emit("update:expanded", next);
132
+ }
133
+
134
+ const keyOf = (item: T, i: number) => item.key ?? i;
135
+ // Null when the timeline isn't about progress (no `current`, no `status`): the plain look
136
+ const statusOf = (item: T, i: number): TimelineStatus | null =>
137
+ item.status ?? (props.current === undefined ? null : i < props.current ? "done" : i === props.current ? "current" : "pending");
138
+ const pending = (item: T, i: number) => statusOf(item, i) === "pending";
139
+ // The line after an entry is dashed (still to come) unless that entry is done and the next one is reached
140
+ const dashed = (i: number) => {
141
+ const here = statusOf(props.items[i]!, i);
142
+ if (here === null) return false;
143
+ const next = props.items[i + 1];
144
+ return here !== "done" || (!!next && statusOf(next, i + 1) === "pending");
145
+ };
146
+ // One dot slot size for every entry: with any icon (or a #dot), small dots sit centered in the same 36px, so dots,
147
+ // line and text stay aligned when entries mix both
148
+ const wide = computed(() => !!slots.dot || props.items.some((item) => item.icon));
149
+ // A `dotColor` paints over the role's background (inline style); the icon keeps the role's on-color
150
+ // A pending step is outlined, its icon in on-surface-variant
151
+ const dotClass = (item: T, i: number, size = item.icon ? "h-9 w-9" : "h-3 w-3") => [
152
+ "relative",
153
+ size,
154
+ pending(item, i) ? "border-2 border-outline-variant bg-surface text-on-surface-variant" : dotBg[item.color ?? "primary"],
155
+ ];
156
+ const dotStyle = (item: T, i: number) => (item.dotColor && !pending(item, i) ? { backgroundColor: item.dotColor } : undefined);
157
+ // In a progress timeline a done step's line is solid; otherwise the usual 30% tint
158
+ const lineClass = (item: T, i: number, vertical: boolean) => {
159
+ if (dashed(i)) return vertical ? "border-l-2 border-dashed border-outline-variant" : "border-t-2 border-dashed border-outline-variant";
160
+ if (item.dotColor) return "";
161
+ return statusOf(item, i) === "done" ? dotBg[item.color ?? "primary"]!.split(" ")[0] : lineBg[item.color ?? "primary"];
162
+ };
163
+ const lineStyle = (item: T, i: number) => {
164
+ if (!item.dotColor || dashed(i)) return undefined;
165
+ return { backgroundColor: statusOf(item, i) === "done" ? item.dotColor : `color-mix(in srgb, ${item.dotColor} 30%, transparent)` };
166
+ };
167
+ // `item-{index}` (the original per-entry slot) wins over the generic `#item`
168
+ const itemSlot = (i: number) => (slots[`item-${i}`] ? `item-${i}` : slots.item ? "item" : null) as "item" | null;
169
+ // Groups: a header before each run of entries sharing `group`; the line ends with the run
170
+ const startsGroup = (i: number) => {
171
+ const group = props.items[i]?.group;
172
+ return group != null && (i === 0 || props.items[i - 1]!.group !== group);
173
+ };
174
+ const groupRun = (i: number) => {
175
+ const run: T[] = [];
176
+ for (let j = i; j < props.items.length && props.items[j]!.group === props.items[i]!.group; j++) run.push(props.items[j]!);
177
+ return run;
178
+ };
179
+ const hasGroups = computed(() => props.items.some((item) => item.group != null));
180
+ // The line ends with the last entry shown, and with each group's run
181
+ const isLast = (i: number) =>
182
+ i === shown.value.length - 1 || (hasGroups.value && props.items[i + 1]!.group !== props.items[i]!.group);
183
+
184
+ // ── Enter / move animation ────────────────────────────────────────────────────────────────────────────────────────
185
+ // FLIP, as MDragDropList does: every row's place before an update; after it, new rows slide in and the others spring
186
+ // from where they were. Rows are found by `data-timeline-row` (an entry's key, or `group:<name>` for a header,
187
+ // so a header stays put when an entry joins its group at the top)
188
+ const root = ref<HTMLElement>();
189
+ let mounted = false;
190
+ let before = new Map<string, DOMRect>();
191
+ const rows = () => Array.from(root.value?.querySelectorAll<HTMLElement>(":scope > [data-timeline-row]") ?? []);
192
+ const rowKey = (item: T, i: number) => String(keyOf(item, i));
193
+
194
+ onMounted(() => { mounted = true; });
195
+ onBeforeUpdate(() => {
196
+ before = new Map();
197
+ if (!props.animate || !mounted) return;
198
+ for (const row of rows()) before.set(row.dataset.timelineRow!, row.getBoundingClientRect());
199
+ });
200
+ onUpdated(() => {
201
+ if (!props.animate || !before.size || prefersReducedMotion()) return;
202
+ const along = props.orientation === "horizontal" ? "X" : "Y";
203
+ for (const row of rows()) {
204
+ const was = before.get(row.dataset.timelineRow!);
205
+ const now = row.getBoundingClientRect();
206
+ if (!was) {
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) => ({
209
+ transform: `translate${along}(${(1 - p) * -12}px)`,
210
+ opacity: String(Math.min(1, p * 1.4)),
211
+ }));
212
+ continue;
213
+ }
214
+ const dx = was.left - now.left;
215
+ const dy = was.top - now.top;
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) => ({
218
+ transform: `translate(${dx * p}px, ${dy * p}px)`,
219
+ }));
220
+ }
221
+ before = new Map();
222
+ });
36
223
  </script>
37
224
 
38
225
  <template>
39
- <div :class="alternating ? 'relative' : 'flex flex-col'">
40
- <!-- Standard layout -->
41
- <template v-if="!alternating">
42
- <div
43
- v-for="(item, i) in items"
44
- :key="i"
45
- class="relative flex gap-4"
46
- :class="dense ? 'pb-4' : 'pb-8'"
47
- >
48
- <!-- Line + dot -->
49
- <div class="flex flex-col items-center">
50
- <div
51
- class="z-1 flex shrink-0 items-center justify-center rounded-full"
52
- :class="[item.icon ? 'h-9 w-9' : 'h-3 w-3', dotBg[item.color ?? 'primary']]"
53
- :style="item.dotColor ? { backgroundColor: item.dotColor } : undefined"
54
- >
55
- <MIcon v-if="item.icon" :name="item.icon" :size="18" />
56
- </div>
57
- <div
58
- v-if="i < items.length - 1"
59
- class="w-[2px] flex-1"
60
- :class="dotBg[item.color ?? 'primary']!.split(' ')[0] + '/30'"
61
- style="min-height: 16px"
62
- />
226
+ <ol v-if="orientation === 'horizontal'" ref="root" class="flex list-none overflow-x-auto p-0" role="list">
227
+ <!-- Horizontal: entries side by side, the line running between their dots -->
228
+ <li
229
+ :data-timeline-row="rowKey(item, i)"
230
+ v-for="(item, i) in shown"
231
+ :key="keyOf(item, i)"
232
+ :aria-current="statusOf(item, i) === 'current' ? 'step' : undefined"
233
+ class="flex min-w-40 flex-1 flex-col"
234
+ >
235
+ <!-- A group's header above its first dot; the others keep the same height so the dots line up -->
236
+ <div v-if="hasGroups" class="mb-2 min-h-5 pr-3" :aria-hidden="!startsGroup(i) || undefined">
237
+ <template v-if="startsGroup(i)">
238
+ <slot name="group" :group="item.group!" :items="groupRun(i)">
239
+ <p class="text-title-small text-on-surface-variant">{{ item.group }}</p>
240
+ </slot>
241
+ </template>
242
+ </div>
243
+ <div class="flex items-center" :class="wide ? 'h-9' : 'h-3'">
244
+ <span class="flex shrink-0 justify-center" :class="wide ? 'w-9' : ''">
245
+ <slot name="dot" :item="item" :index="i">
246
+ <span class="z-1 flex shrink-0 items-center justify-center rounded-full" :class="dotClass(item, i)" :style="dotStyle(item, i)">
247
+ <span v-if="statusOf(item, i) === 'current'" aria-hidden="true" class="pointer-events-none absolute inset-0 rounded-full bg-inherit opacity-40 motion-safe:animate-ping" />
248
+ <MIcon v-if="item.icon" :name="item.icon" :size="18" class="relative" />
249
+ </span>
250
+ </slot>
251
+ </span>
252
+ <span v-if="!isLast(i)" class="min-w-4 flex-1" :class="[dashed(i) ? 'h-0' : 'h-[2px]', lineClass(item, i, false)]" :style="lineStyle(item, i)" />
253
+ </div>
254
+ <!-- The gap to the next entry is the content's padding, so the line above runs all the way to its dot -->
255
+ <div class="mt-3 min-w-0" :class="dense ? 'pr-3' : 'pr-6'">
256
+ <template v-if="!bare">
257
+ <slot name="title" :item="item" :index="i">
258
+ <p class="text-body-large font-medium" :class="pending(item, i) ? 'text-on-surface-variant' : 'text-on-surface'">{{ item.title }}</p>
259
+ <span v-if="item.date" class="text-label-small text-on-surface-variant">{{ item.date }}</span>
260
+ </slot>
261
+ <p v-if="item.description" class="mt-1 text-body-medium text-on-surface-variant">{{ item.description }}</p>
262
+ </template>
263
+ <div v-if="itemSlot(i)" :class="{ 'mt-2': !bare }">
264
+ <slot :name="itemSlot(i)!" :item="item" :index="i" />
63
265
  </div>
266
+ </div>
267
+ </li>
268
+ <!-- Past `limit`: the button, level with the dots -->
269
+ <li v-if="limited" data-timeline-row="more" class="flex shrink-0 flex-col pr-2">
270
+ <div v-if="hasGroups" class="mb-2 min-h-5" aria-hidden="true" />
271
+ <div class="flex items-center" :class="wide ? 'h-9' : 'h-3'">
272
+ <MButton variant="text" size="sm" :icon="isExpanded ? 'expand_less' : 'expand_more'" :aria-expanded="isExpanded" @click="toggleExpanded">
273
+ {{ toggleLabel }}
274
+ </MButton>
275
+ </div>
276
+ </li>
277
+ </ol>
278
+
279
+ <ol v-else-if="!alternating" ref="root" class="flex list-none flex-col p-0" role="list">
280
+ <!-- Vertical, single column (with an optional #opposite column before the line) -->
281
+ <template v-for="(item, i) in shown" :key="keyOf(item, i)">
282
+ <li v-if="startsGroup(i)" :data-timeline-row="`group:${item.group}`" class="pb-3" :class="{ 'pt-2': i > 0 }">
283
+ <slot name="group" :group="item.group!" :items="groupRun(i)">
284
+ <p class="text-title-small text-on-surface-variant">{{ item.group }}</p>
285
+ </slot>
286
+ </li>
287
+ <li
288
+ :data-timeline-row="rowKey(item, i)"
289
+ :aria-current="statusOf(item, i) === 'current' ? 'step' : undefined"
290
+ class="relative flex gap-4"
291
+ >
292
+ <!-- The gap to the next entry is padding on the text columns, not on the row: the line column stretches over
293
+ the whole row and reaches the next dot -->
294
+ <div v-if="$slots.opposite" class="w-24 shrink-0 text-right" :class="dense ? 'pb-4' : 'pb-8'">
295
+ <slot name="opposite" :item="item" :index="i" />
296
+ </div>
297
+
298
+ <!-- Line + dot -->
299
+ <div class="flex shrink-0 flex-col items-center" :class="{ 'w-9': wide }">
300
+ <slot name="dot" :item="item" :index="i">
301
+ <span class="z-1 flex shrink-0 items-center justify-center rounded-full" :class="dotClass(item, i)" :style="dotStyle(item, i)">
302
+ <span v-if="statusOf(item, i) === 'current'" aria-hidden="true" class="pointer-events-none absolute inset-0 rounded-full bg-inherit opacity-40 motion-safe:animate-ping" />
303
+ <MIcon v-if="item.icon" :name="item.icon" :size="18" class="relative" />
304
+ </span>
305
+ </slot>
306
+ <span v-if="!isLast(i)" class="flex-1" :class="[dashed(i) ? 'w-0' : 'w-[2px]', lineClass(item, i, true)]" :style="[{ minHeight: '16px' }, lineStyle(item, i)]" />
307
+ </div>
64
308
 
65
- <!-- Content -->
66
- <div :class="item.icon ? '' : 'pt-0'" class="-mt-0.5 flex-1">
67
- <div class="flex items-baseline justify-between gap-2">
68
- <p class="text-body-large font-medium text-on-surface">{{ item.title }}</p>
69
- <span v-if="item.date" class="shrink-0 text-label-small text-on-surface-variant">{{
70
- item.date
71
- }}</span>
72
- </div>
73
- <p v-if="item.description" class="mt-1 text-body-medium text-on-surface-variant">
74
- {{ item.description }}
75
- </p>
76
- <div v-if="$slots[`item-${i}`]" class="mt-2">
77
- <slot :name="`item-${i}`" :item="item" />
78
- </div>
309
+ <!-- Content -->
310
+ <div class="-mt-0.5 min-w-0 flex-1" :class="dense ? 'pb-4' : 'pb-8'">
311
+ <template v-if="!bare">
312
+ <slot name="title" :item="item" :index="i">
313
+ <div class="flex items-baseline justify-between gap-2">
314
+ <p class="text-body-large font-medium" :class="pending(item, i) ? 'text-on-surface-variant' : 'text-on-surface'">{{ item.title }}</p>
315
+ <span v-if="item.date" class="shrink-0 text-label-small text-on-surface-variant">{{ item.date }}</span>
316
+ </div>
317
+ </slot>
318
+ <p v-if="item.description" class="mt-1 text-body-medium text-on-surface-variant">{{ item.description }}</p>
319
+ </template>
320
+ <div v-if="itemSlot(i)" :class="{ 'mt-2': !bare }">
321
+ <slot :name="itemSlot(i)!" :item="item" :index="i" />
79
322
  </div>
80
323
  </div>
324
+ </li>
81
325
  </template>
326
+ <!-- Past `limit`: the button, its label lined up with the entries' text -->
327
+ <li v-if="limited" data-timeline-row="more" class="flex gap-4">
328
+ <div v-if="$slots.opposite" class="w-24 shrink-0" />
329
+ <div class="shrink-0" :class="wide ? 'w-9' : 'w-3'" />
330
+ <div class="-ml-3">
331
+ <MButton variant="text" size="sm" :icon="isExpanded ? 'expand_less' : 'expand_more'" :aria-expanded="isExpanded" @click="toggleExpanded">
332
+ {{ toggleLabel }}
333
+ </MButton>
334
+ </div>
335
+ </li>
336
+ </ol>
82
337
 
83
- <!-- Alternating layout -->
84
- <template v-else>
338
+ <ol v-else ref="root" class="relative list-none p-0" :class="{ '@container': responsive }" role="list">
339
+ <template v-for="(item, i) in shown" :key="keyOf(item, i)">
340
+ <!-- A group's header: centered over the line, or at the start once folded -->
341
+ <li v-if="startsGroup(i)" :data-timeline-row="`group:${item.group}`" class="pb-3" :class="[{ 'pt-2': i > 0 }, responsive ? 'text-left @lg:text-center' : 'text-center']">
342
+ <slot name="group" :group="item.group!" :items="groupRun(i)">
343
+ <p class="text-title-small text-on-surface-variant">{{ item.group }}</p>
344
+ </slot>
345
+ </li>
346
+ <!-- Alternating: entries left and right of a central line. With `responsive`, below 32rem (the list's own width)
347
+ each entry is a grid instead: the line in the first column, the content and then #opposite in the second -->
348
+ <li
349
+ :data-timeline-row="rowKey(item, i)"
350
+ :aria-current="statusOf(item, i) === 'current' ? 'step' : undefined"
351
+ :class="responsive
352
+ ? ['grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 @lg:flex @lg:items-stretch @lg:gap-x-0', i % 2 === 0 ? '@lg:flex-row' : '@lg:flex-row-reverse']
353
+ : ['flex items-stretch', i % 2 === 0 ? 'flex-row' : 'flex-row-reverse']"
354
+ >
355
+ <!-- Content side -->
85
356
  <div
86
- v-for="(item, i) in items"
87
- :key="i"
88
- class="flex items-stretch"
89
- :class="i % 2 === 0 ? 'flex-row' : 'flex-row-reverse'"
357
+ class="min-w-0"
358
+ :class="responsive
359
+ ? ['col-start-2 row-start-1 text-left @lg:flex-1', i % 2 === 0 ? '@lg:text-right' : '', dense ? '@lg:pb-4' : '@lg:pb-8']
360
+ : ['flex-1', i % 2 === 0 ? 'text-right' : 'text-left', dense ? 'pb-4' : 'pb-8']"
90
361
  >
91
- <!-- Content side -->
92
- <div
93
- class="flex-1"
94
- :class="[i % 2 === 0 ? 'text-right' : 'text-left', dense ? 'pb-4' : 'pb-8']"
95
- >
96
- <p class="text-body-large font-medium text-on-surface">{{ item.title }}</p>
97
- <p v-if="item.description" class="mt-1 text-body-medium text-on-surface-variant">
98
- {{ item.description }}
99
- </p>
100
- <span
101
- v-if="item.date"
102
- class="mt-1 inline-block text-label-small text-on-surface-variant"
103
- >{{ item.date }}</span
104
- >
362
+ <template v-if="!bare">
363
+ <slot name="title" :item="item" :index="i">
364
+ <p class="text-body-large font-medium" :class="pending(item, i) ? 'text-on-surface-variant' : 'text-on-surface'">{{ item.title }}</p>
365
+ </slot>
366
+ <p v-if="item.description" class="mt-1 text-body-medium text-on-surface-variant">{{ item.description }}</p>
367
+ <span v-if="item.date && !$slots.title" class="mt-1 inline-block text-label-small text-on-surface-variant">{{ item.date }}</span>
368
+ </template>
369
+ <div v-if="itemSlot(i)" :class="{ 'mt-2': !bare }">
370
+ <slot :name="itemSlot(i)!" :item="item" :index="i" />
105
371
  </div>
372
+ </div>
106
373
 
107
- <!-- Center column: dot + continuous line -->
108
- <div class="flex w-14 shrink-0 flex-col items-center">
109
- <div
374
+ <!-- Center column: dot + continuous line -->
375
+ <div
376
+ class="flex shrink-0 flex-col items-center"
377
+ :class="responsive ? 'col-start-1 row-span-2 row-start-1 w-9 @lg:w-14' : 'w-14'"
378
+ >
379
+ <slot name="dot" :item="item" :index="i">
380
+ <span
110
381
  class="z-1 flex shrink-0 items-center justify-center rounded-full"
111
- :class="[item.icon ? 'h-9 w-9' : 'h-3.5 w-3.5', dotBg[item.color ?? 'primary']]"
112
- :style="item.dotColor ? { backgroundColor: item.dotColor } : undefined"
382
+ :class="dotClass(item, i, item.icon ? 'h-9 w-9' : 'h-3.5 w-3.5')"
383
+ :style="dotStyle(item, i)"
113
384
  >
114
- <MIcon v-if="item.icon" :name="item.icon" :size="18" />
115
- </div>
116
- <div v-if="i < items.length - 1" class="w-[2px] flex-1 bg-outline-variant" />
117
- </div>
385
+ <span v-if="statusOf(item, i) === 'current'" aria-hidden="true" class="pointer-events-none absolute inset-0 rounded-full bg-inherit opacity-40 motion-safe:animate-ping" />
386
+ <MIcon v-if="item.icon" :name="item.icon" :size="18" class="relative" />
387
+ </span>
388
+ </slot>
389
+ <span v-if="!isLast(i)" class="flex-1" :class="[dashed(i) ? 'w-0' : 'w-[2px]', lineClass(item, i, true)]" :style="lineStyle(item, i)" />
390
+ </div>
118
391
 
119
- <!-- Empty side -->
120
- <div class="flex-1" />
392
+ <!-- Opposite side (folded: under the content, carrying the gap to the next entry) -->
393
+ <div
394
+ class="min-w-0"
395
+ :class="[
396
+ responsive
397
+ ? ['col-start-2 row-start-2 text-left @lg:flex-1', i % 2 === 0 ? '' : '@lg:text-right']
398
+ : ['flex-1', i % 2 === 0 ? 'text-left' : 'text-right'],
399
+ dense ? 'pb-4' : 'pb-8',
400
+ ]"
401
+ >
402
+ <slot name="opposite" :item="item" :index="i" />
121
403
  </div>
404
+ </li>
122
405
  </template>
123
- </div>
406
+ <!-- Past `limit`: the button, centered under the line (folded: lined up with the entries' text) -->
407
+ <li v-if="limited" data-timeline-row="more" class="flex" :class="responsive ? 'justify-start pl-9 @lg:justify-center @lg:pl-0' : 'justify-center'">
408
+ <MButton variant="text" size="sm" :icon="isExpanded ? 'expand_less' : 'expand_more'" :aria-expanded="isExpanded" @click="toggleExpanded">
409
+ {{ toggleLabel }}
410
+ </MButton>
411
+ </li>
412
+ </ol>
124
413
  </template>