@m3ui-vue/m3ui-vue 1.6.0 → 1.6.2

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 (158) hide show
  1. package/dist/API.md +940 -33
  2. package/dist/{MButton-CPghlKb0.js → MButton-OQ4wIERQ.js} +2 -2
  3. package/dist/{MButton-CPghlKb0.js.map → MButton-OQ4wIERQ.js.map} +1 -1
  4. package/dist/MColorPickerModal-NtkihoK6.js +577 -0
  5. package/dist/MColorPickerModal-NtkihoK6.js.map +1 -0
  6. package/dist/{MDialog-X50At1Gk.js → MDialog-DYMnaBlt.js} +3 -3
  7. package/dist/{MDialog-X50At1Gk.js.map → MDialog-DYMnaBlt.js.map} +1 -1
  8. package/dist/{MListItem-DVi1j1QI.js → MListItem-D2cNUyzP.js} +211 -168
  9. package/dist/MListItem-D2cNUyzP.js.map +1 -0
  10. package/dist/{MLoadingIndicator-vooA3110.js → MLoadingIndicator-DWUj0BAB.js} +2 -2
  11. package/dist/{MLoadingIndicator-vooA3110.js.map → MLoadingIndicator-DWUj0BAB.js.map} +1 -1
  12. package/dist/{MMenuItem-CRNZkVVr.js → MMenuItem-BuxYoASE.js} +133 -151
  13. package/dist/MMenuItem-BuxYoASE.js.map +1 -0
  14. package/dist/{MSeekBar-BL2W5_rD.js → MSeekBar-C4cn9RIF.js} +2 -2
  15. package/dist/{MSeekBar-BL2W5_rD.js.map → MSeekBar-C4cn9RIF.js.map} +1 -1
  16. package/dist/{MSlider-B9NcKTmZ.js → MSlider-BIkA6DiE.js} +2 -2
  17. package/dist/{MSlider-B9NcKTmZ.js.map → MSlider-BIkA6DiE.js.map} +1 -1
  18. package/dist/{MSpinner-_XpTRkAg.js → MSpinner-DZkXZJpc.js} +2 -2
  19. package/dist/{MSpinner-_XpTRkAg.js.map → MSpinner-DZkXZJpc.js.map} +1 -1
  20. package/dist/{MTextField-DpcPmR5B.js → MTextField-CNH-byir.js} +2 -2
  21. package/dist/{MTextField-DpcPmR5B.js.map → MTextField-CNH-byir.js.map} +1 -1
  22. package/dist/MTooltip-CK39Zon4.js +183 -0
  23. package/dist/MTooltip-CK39Zon4.js.map +1 -0
  24. package/dist/{_useEscapeStack-C5-BYr8y.js → _popupPosition-nL8SVKPK.js} +20 -2
  25. package/dist/_popupPosition-nL8SVKPK.js.map +1 -0
  26. package/dist/api.json +1 -1
  27. package/dist/code-editor.js +1 -1
  28. package/dist/components/MAddressField.vue.d.ts +54 -0
  29. package/dist/components/MAudioPlayer.vue.d.ts +1 -1
  30. package/dist/components/MAudioRecorder.vue.d.ts +51 -0
  31. package/dist/components/MAvailabilityCalendar.vue.d.ts +1 -1
  32. package/dist/components/MCameraCapture.vue.d.ts +51 -0
  33. package/dist/components/MCollapse.vue.d.ts +32 -0
  34. package/dist/components/MCountrySelect.vue.d.ts +41 -0
  35. package/dist/components/MCronField.vue.d.ts +26 -0
  36. package/dist/components/MDashboardGrid.vue.d.ts +65 -0
  37. package/dist/components/MDiffViewer.vue.d.ts +56 -0
  38. package/dist/components/MExpansionPanel.vue.d.ts +26 -3
  39. package/dist/components/MFilterBuilder.vue.d.ts +22 -0
  40. package/dist/components/MFlex.vue.d.ts +1 -1
  41. package/dist/components/MMapCluster.vue.d.ts +80 -0
  42. package/dist/components/MMapDraw.vue.d.ts +79 -0
  43. package/dist/components/MMentionField.vue.d.ts +102 -0
  44. package/dist/components/MNotificationCenter.vue.d.ts +57 -0
  45. package/dist/components/MQRScanner.vue.d.ts +52 -0
  46. package/dist/components/MQuiz.vue.d.ts +1 -1
  47. package/dist/components/MSimpleCarousel.vue.d.ts +1 -1
  48. package/dist/components/MStack.vue.d.ts +1 -1
  49. package/dist/components/MTimezoneSelect.vue.d.ts +39 -0
  50. package/dist/components/MToolbar.vue.d.ts +1 -1
  51. package/dist/components/MVideoPlayer.vue.d.ts +1 -1
  52. package/dist/components/_MFilterGroup.vue.d.ts +17 -0
  53. package/dist/composables/_caretPosition.d.ts +6 -0
  54. package/dist/composables/_useCamera.d.ts +16 -0
  55. package/dist/composables/_useFollowAnchor.d.ts +15 -0
  56. package/dist/composables/cron.d.ts +29 -0
  57. package/dist/composables/dashboardLayout.d.ts +28 -0
  58. package/dist/composables/filterBuilder.d.ts +55 -0
  59. package/dist/composables/mapAdapters.d.ts +6 -1
  60. package/dist/composables/mapSearch.d.ts +1 -0
  61. package/dist/composables/textDiff.d.ts +24 -0
  62. package/dist/composables/useLocale.d.ts +108 -0
  63. package/dist/draw.js +28 -27
  64. package/dist/draw.js.map +1 -1
  65. package/dist/flow.js +1 -1
  66. package/dist/gantt.js +1 -1
  67. package/dist/index.d.ts +25 -0
  68. package/dist/locales/index.js +749 -0
  69. package/dist/locales/index.js.map +1 -1
  70. package/dist/m3ui-vue.css +1 -1
  71. package/dist/m3ui.js +10444 -7495
  72. package/dist/m3ui.js.map +1 -1
  73. package/dist/map.d.ts +5 -0
  74. package/dist/map.js +1509 -617
  75. package/dist/map.js.map +1 -1
  76. package/dist/media.js +5 -5
  77. package/dist/pdf.js +5 -5
  78. package/dist/rich-text-editor.js +5 -5
  79. package/dist/styles.css +1 -1
  80. package/dist/{useLocale-COav9m8C.js → useLocale-DaVSTdm0.js} +108 -1
  81. package/dist/useLocale-DaVSTdm0.js.map +1 -0
  82. package/package.json +1 -1
  83. package/src/__tests__/MAddressField.test.ts +149 -0
  84. package/src/__tests__/MAudioRecorder.test.ts +125 -0
  85. package/src/__tests__/MCameraCapture.test.ts +154 -0
  86. package/src/__tests__/MCountrySelect.test.ts +67 -0
  87. package/src/__tests__/MCronField.test.ts +100 -0
  88. package/src/__tests__/MDashboardGrid.test.ts +122 -0
  89. package/src/__tests__/MDiffViewer.test.ts +68 -0
  90. package/src/__tests__/MExpansionPanel.test.ts +107 -0
  91. package/src/__tests__/MFilterBuilder.test.ts +130 -0
  92. package/src/__tests__/MMapCluster.test.ts +127 -0
  93. package/src/__tests__/MMapDraw.test.ts +188 -0
  94. package/src/__tests__/MMapLayers.test.ts +56 -0
  95. package/src/__tests__/MMentionField.test.ts +163 -0
  96. package/src/__tests__/MNotificationCenter.test.ts +94 -0
  97. package/src/__tests__/_fakeMaplibre.ts +14 -3
  98. package/src/__tests__/attrsFallthrough.test.ts +4 -0
  99. package/src/__tests__/cron.test.ts +68 -0
  100. package/src/__tests__/dashboardLayout.test.ts +45 -0
  101. package/src/__tests__/filterBuilder.test.ts +91 -0
  102. package/src/__tests__/followAnchor.test.ts +162 -0
  103. package/src/__tests__/ssr.test.ts +3 -0
  104. package/src/__tests__/textDiff.test.ts +37 -0
  105. package/src/components/MAddressField.vue +301 -0
  106. package/src/components/MAudioRecorder.vue +334 -0
  107. package/src/components/MAutocomplete.vue +3 -7
  108. package/src/components/MCameraCapture.vue +156 -0
  109. package/src/components/MCollapse.vue +91 -0
  110. package/src/components/MColorPicker.vue +4 -8
  111. package/src/components/MCountrySelect.vue +89 -0
  112. package/src/components/MCronField.vue +251 -0
  113. package/src/components/MDashboardGrid.vue +382 -0
  114. package/src/components/MDatePicker.vue +10 -7
  115. package/src/components/MDateRangePicker.vue +10 -7
  116. package/src/components/MDiffViewer.vue +234 -0
  117. package/src/components/MExpansionPanel.vue +56 -48
  118. package/src/components/MFilterBuilder.vue +47 -0
  119. package/src/components/MMapBaseLayers.vue +29 -28
  120. package/src/components/MMapCluster.vue +295 -0
  121. package/src/components/MMapDraw.vue +601 -0
  122. package/src/components/MMapMeasure.vue +1 -1
  123. package/src/components/MMapSearch.vue +1 -9
  124. package/src/components/MMentionField.vue +373 -0
  125. package/src/components/MMultiAutocomplete.vue +3 -7
  126. package/src/components/MMultiSelect.vue +3 -7
  127. package/src/components/MNotificationCenter.vue +252 -0
  128. package/src/components/MPhoneInput.vue +3 -10
  129. package/src/components/MQRScanner.vue +177 -0
  130. package/src/components/MSelect.vue +3 -7
  131. package/src/components/MTimePicker.vue +10 -7
  132. package/src/components/MTimezoneSelect.vue +116 -0
  133. package/src/components/_MFilterGroup.vue +210 -0
  134. package/src/composables/_caretPosition.ts +44 -0
  135. package/src/composables/_useCamera.ts +66 -0
  136. package/src/composables/_useFollowAnchor.ts +109 -0
  137. package/src/composables/cron.ts +179 -0
  138. package/src/composables/dashboardLayout.ts +94 -0
  139. package/src/composables/filterBuilder.ts +195 -0
  140. package/src/composables/mapAdapters.ts +29 -15
  141. package/src/composables/mapSearch.ts +10 -0
  142. package/src/composables/textDiff.ts +106 -0
  143. package/src/composables/useLocale.ts +215 -0
  144. package/src/index.ts +25 -0
  145. package/src/locales/de.ts +107 -0
  146. package/src/locales/es.ts +107 -0
  147. package/src/locales/fr.ts +107 -0
  148. package/src/locales/ja.ts +107 -0
  149. package/src/locales/ko.ts +107 -0
  150. package/src/locales/pt.ts +107 -0
  151. package/src/locales/zh.ts +107 -0
  152. package/src/map.ts +5 -0
  153. package/dist/MListItem-DVi1j1QI.js.map +0 -1
  154. package/dist/MMenuItem-CRNZkVVr.js.map +0 -1
  155. package/dist/MTooltip-BL3jPYPT.js +0 -754
  156. package/dist/MTooltip-BL3jPYPT.js.map +0 -1
  157. package/dist/_useEscapeStack-C5-BYr8y.js.map +0 -1
  158. package/dist/useLocale-COav9m8C.js.map +0 -1
@@ -0,0 +1,234 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Shows what changed between two texts (code, config, prose): side by side or unified, with the changed words
4
+ * highlighted inside changed lines, line numbers, counts of added and removed lines, and long unchanged stretches
5
+ * folded behind a "Show N unchanged lines" row (`context` lines kept around each change). Below `breakpoint` (its own
6
+ * width) side by side becomes unified. No editor or extra dependency: its own line and word diff (`diffLines`,
7
+ * `diffWords`, exported too).
8
+ *
9
+ * @slot header Replaces the header's title area (file names): `{ added, removed }`
10
+ * @event update:mode The view changed from its toggle
11
+ */
12
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
13
+ import MSegmentedButton from './MSegmentedButton.vue'
14
+ import { useLocale } from '../composables/useLocale'
15
+ import { diffLines, diffStats, diffWords, type DiffLine, type DiffPart } from '../composables/textDiff'
16
+
17
+ const props = withDefaults(
18
+ defineProps<{
19
+ /** The text before */
20
+ original: string
21
+ /** The text after */
22
+ modified: string
23
+ /** Side by side or unified (v-model:mode with the toggle) */
24
+ mode?: 'split' | 'unified'
25
+ /** Show the split / unified toggle in the header */
26
+ toggle?: boolean
27
+ /** The original's name in the header (a file name, "v1") */
28
+ originalLabel?: string
29
+ /** The modified version's name */
30
+ modifiedLabel?: string
31
+ /** Unchanged lines kept around each change; longer stretches fold (-1: never fold) */
32
+ context?: number
33
+ /** Highlight the changed words inside changed lines */
34
+ wordDiff?: boolean
35
+ /** Show line numbers */
36
+ lineNumbers?: boolean
37
+ /** Wrap long lines instead of scrolling */
38
+ wrap?: boolean
39
+ /** Below this width (px, its own) side by side shows unified */
40
+ breakpoint?: number
41
+ /** Limit the height (CSS), scrolling inside */
42
+ maxHeight?: string
43
+ }>(),
44
+ { mode: 'split', toggle: true, context: 3, wordDiff: true, lineNumbers: true, wrap: false, breakpoint: 640 },
45
+ )
46
+
47
+ const emit = defineEmits<{ 'update:mode': [mode: 'split' | 'unified'] }>()
48
+
49
+ const t = useLocale()
50
+ const root = ref<HTMLElement>()
51
+ const width = ref(0)
52
+ const current = ref(props.mode)
53
+ watch(() => props.mode, (m) => (current.value = m))
54
+ const view = computed(() => (current.value === 'split' && width.value > 0 && width.value < props.breakpoint ? 'unified' : current.value))
55
+ function setMode(m: 'split' | 'unified') {
56
+ current.value = m
57
+ emit('update:mode', m)
58
+ }
59
+
60
+ const diff = computed(() => diffLines(props.original, props.modified))
61
+ const stats = computed(() => diffStats(diff.value))
62
+ const expanded = ref(new Set<number>())
63
+ watch(() => [props.original, props.modified], () => (expanded.value = new Set()))
64
+
65
+ type Line = DiffLine & { parts?: DiffPart[] }
66
+ type Row = { kind: 'line'; line: Line } | { kind: 'fold'; id: number; count: number }
67
+
68
+ /** Change blocks get word diffs (each removed line with the added one at the same place), long equal runs fold */
69
+ const rows = computed<Row[]>(() => {
70
+ const lines: Line[] = diff.value.map((l) => ({ ...l }))
71
+ if (props.wordDiff) {
72
+ for (let i = 0; i < lines.length;) {
73
+ if (lines[i]!.op === 'equal') { i++; continue }
74
+ const removes: Line[] = []
75
+ const adds: Line[] = []
76
+ while (i < lines.length && lines[i]!.op === 'remove') removes.push(lines[i++]!)
77
+ while (i < lines.length && lines[i]!.op === 'add') adds.push(lines[i++]!)
78
+ for (let k = 0; k < Math.min(removes.length, adds.length); k++) {
79
+ const words = diffWords(removes[k]!.text, adds[k]!.text)
80
+ // Only worth it when much of the line stayed
81
+ const kept = words.filter((w) => w.op === 'equal').reduce((n, w) => n + w.text.trim().length, 0)
82
+ if (kept < Math.max(removes[k]!.text.trim().length, adds[k]!.text.trim().length) * 0.3) continue
83
+ removes[k]!.parts = words.filter((w) => w.op !== 'add')
84
+ adds[k]!.parts = words.filter((w) => w.op !== 'remove')
85
+ }
86
+ }
87
+ }
88
+ if (props.context < 0) return lines.map((line) => ({ kind: 'line', line }))
89
+ const out: Row[] = []
90
+ for (let i = 0; i < lines.length;) {
91
+ if (lines[i]!.op !== 'equal') { out.push({ kind: 'line', line: lines[i++]! }); continue }
92
+ let j = i
93
+ while (j < lines.length && lines[j]!.op === 'equal') j++
94
+ const head = i === 0 ? 0 : props.context
95
+ const tail = j === lines.length ? 0 : props.context
96
+ const hidden = j - i - head - tail
97
+ if (hidden > 1 && !expanded.value.has(i)) {
98
+ for (let k = i; k < i + head; k++) out.push({ kind: 'line', line: lines[k]! })
99
+ out.push({ kind: 'fold', id: i, count: hidden })
100
+ for (let k = j - tail; k < j; k++) out.push({ kind: 'line', line: lines[k]! })
101
+ } else for (let k = i; k < j; k++) out.push({ kind: 'line', line: lines[k]! })
102
+ i = j
103
+ }
104
+ return out
105
+ })
106
+
107
+ /** Side by side: removed lines on the left facing added ones on the right, equal ones on both */
108
+ const splitRows = computed(() => {
109
+ const out: ({ kind: 'pair'; left?: Line; right?: Line } | { kind: 'fold'; id: number; count: number })[] = []
110
+ const list = rows.value
111
+ for (let i = 0; i < list.length;) {
112
+ const r = list[i]!
113
+ if (r.kind === 'fold') { out.push(r); i++; continue }
114
+ if (r.line.op === 'equal') { out.push({ kind: 'pair', left: r.line, right: r.line }); i++; continue }
115
+ const removes: Line[] = []
116
+ const adds: Line[] = []
117
+ while (i < list.length && list[i]!.kind === 'line' && (list[i] as { line: Line }).line.op === 'remove') removes.push((list[i++] as { line: Line }).line)
118
+ while (i < list.length && list[i]!.kind === 'line' && (list[i] as { line: Line }).line.op === 'add') adds.push((list[i++] as { line: Line }).line)
119
+ for (let k = 0; k < Math.max(removes.length, adds.length); k++) out.push({ kind: 'pair', left: removes[k], right: adds[k] })
120
+ }
121
+ return out
122
+ })
123
+
124
+ const unfold = (id: number) => (expanded.value = new Set([...expanded.value, id]))
125
+
126
+ const BG = { equal: '', remove: 'bg-error-container/45', add: 'bg-success-container/45' } as const
127
+ const MARK = { remove: 'rounded-xs bg-error-container text-on-error-container', add: 'rounded-xs bg-success-container text-on-success-container' } as const
128
+ const SIGN = { equal: ' ', remove: '−', add: '+' } as const
129
+
130
+ let observer: ResizeObserver | undefined
131
+ onMounted(() => {
132
+ const measure = () => (width.value = root.value?.clientWidth ?? 0)
133
+ measure()
134
+ if (typeof ResizeObserver !== 'undefined' && root.value) {
135
+ observer = new ResizeObserver(measure)
136
+ observer.observe(root.value)
137
+ }
138
+ })
139
+ onBeforeUnmount(() => observer?.disconnect())
140
+
141
+ const modeOptions = computed(() => [
142
+ { value: 'split' as const, label: t.diffSplit, icon: 'vertical_split' },
143
+ { value: 'unified' as const, label: t.diffUnified, icon: 'view_agenda' },
144
+ ])
145
+ </script>
146
+
147
+ <template>
148
+ <div ref="root" class="m3-diff overflow-hidden rounded-md border border-outline-variant bg-surface text-on-surface">
149
+ <!-- Header: names, counts, the toggle -->
150
+ <div class="flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-outline-variant bg-surface-container-low px-4 py-2">
151
+ <div class="flex min-w-0 flex-1 items-center gap-2 text-label-large">
152
+ <slot name="header" :added="stats.added" :removed="stats.removed">
153
+ <span v-if="originalLabel" class="truncate font-mono text-on-surface-variant">{{ originalLabel }}</span>
154
+ <span v-if="originalLabel && modifiedLabel" class="text-on-surface-variant">→</span>
155
+ <span v-if="modifiedLabel" class="truncate font-mono">{{ modifiedLabel }}</span>
156
+ </slot>
157
+ <span class="ml-auto shrink-0 font-mono text-label-medium">
158
+ <span class="text-success">+{{ stats.added }}</span>
159
+ <span class="ml-2 text-error">−{{ stats.removed }}</span>
160
+ </span>
161
+ </div>
162
+ <MSegmentedButton
163
+ v-if="toggle && width >= breakpoint"
164
+ :model-value="current"
165
+ :options="modeOptions"
166
+ density="compact"
167
+ @update:model-value="(m: 'split' | 'unified') => setMode(m)"
168
+ />
169
+ </div>
170
+
171
+ <div class="overflow-auto font-mono text-[13px] leading-5" :style="{ maxHeight }">
172
+ <p v-if="!stats.added && !stats.removed" class="px-4 py-3 font-sans text-body-medium text-on-surface-variant">{{ t.diffNoChanges }}</p>
173
+
174
+ <!-- Unified -->
175
+ <table v-else-if="view === 'unified'" class="w-full border-collapse">
176
+ <tbody>
177
+ <template v-for="(r, i) in rows" :key="i">
178
+ <tr v-if="r.kind === 'fold'">
179
+ <td :colspan="lineNumbers ? 4 : 2" class="p-0">
180
+ <button type="button" class="w-full cursor-pointer bg-surface-container px-4 py-1 text-left font-sans text-label-medium text-primary hover:bg-surface-container-high" @click="unfold(r.id)">
181
+ ⋯ {{ t.diffUnchanged.replace('{n}', String(r.count)) }}
182
+ </button>
183
+ </td>
184
+ </tr>
185
+ <tr v-else :class="BG[r.line.op]">
186
+ <template v-if="lineNumbers">
187
+ <td class="w-px select-none whitespace-nowrap px-2 text-right text-on-surface-variant/70">{{ r.line.oldLine ?? '' }}</td>
188
+ <td class="w-px select-none whitespace-nowrap px-2 text-right text-on-surface-variant/70">{{ r.line.newLine ?? '' }}</td>
189
+ </template>
190
+ <td class="w-px select-none px-1 text-center" :class="r.line.op === 'add' ? 'text-success' : r.line.op === 'remove' ? 'text-error' : ''">{{ SIGN[r.line.op] }}</td>
191
+ <td class="pr-4" :class="wrap ? 'whitespace-pre-wrap break-all' : 'whitespace-pre'">
192
+ <template v-if="r.line.parts"><span v-for="(p, k) in r.line.parts" :key="k" :class="p.op !== 'equal' ? MARK[p.op] : ''">{{ p.text }}</span></template>
193
+ <template v-else>{{ r.line.text || ' ' }}</template>
194
+ </td>
195
+ </tr>
196
+ </template>
197
+ </tbody>
198
+ </table>
199
+
200
+ <!-- Side by side -->
201
+ <table v-else class="w-full table-fixed border-collapse">
202
+ <colgroup>
203
+ <col v-if="lineNumbers" class="w-12">
204
+ <col>
205
+ <col v-if="lineNumbers" class="w-12">
206
+ <col>
207
+ </colgroup>
208
+ <tbody>
209
+ <template v-for="(r, i) in splitRows" :key="i">
210
+ <tr v-if="r.kind === 'fold'">
211
+ <td :colspan="lineNumbers ? 4 : 2" class="p-0">
212
+ <button type="button" class="w-full cursor-pointer bg-surface-container px-4 py-1 text-left font-sans text-label-medium text-primary hover:bg-surface-container-high" @click="unfold(r.id)">
213
+ ⋯ {{ t.diffUnchanged.replace('{n}', String(r.count)) }}
214
+ </button>
215
+ </td>
216
+ </tr>
217
+ <tr v-else>
218
+ <td v-if="lineNumbers" class="select-none border-r border-outline-variant/50 px-2 text-right align-top text-on-surface-variant/70" :class="r.left ? BG[r.left.op] : 'bg-surface-container-low'">{{ r.left?.oldLine ?? '' }}</td>
219
+ <td class="overflow-hidden border-r border-outline-variant px-2 align-top" :class="[r.left ? BG[r.left.op] : 'bg-surface-container-low', wrap ? 'whitespace-pre-wrap break-all' : 'whitespace-pre']">
220
+ <template v-if="r.left?.parts"><span v-for="(p, k) in r.left.parts" :key="k" :class="p.op !== 'equal' ? MARK[p.op] : ''">{{ p.text }}</span></template>
221
+ <template v-else>{{ r.left?.text ?? '' }}</template>
222
+ </td>
223
+ <td v-if="lineNumbers" class="select-none border-r border-outline-variant/50 px-2 text-right align-top text-on-surface-variant/70" :class="r.right ? BG[r.right.op] : 'bg-surface-container-low'">{{ r.right?.newLine ?? '' }}</td>
224
+ <td class="overflow-hidden px-2 align-top" :class="[r.right ? BG[r.right.op] : 'bg-surface-container-low', wrap ? 'whitespace-pre-wrap break-all' : 'whitespace-pre']">
225
+ <template v-if="r.right?.parts"><span v-for="(p, k) in r.right.parts" :key="k" :class="p.op !== 'equal' ? MARK[p.op] : ''">{{ p.text }}</span></template>
226
+ <template v-else>{{ r.right?.text ?? '' }}</template>
227
+ </td>
228
+ </tr>
229
+ </template>
230
+ </tbody>
231
+ </table>
232
+ </div>
233
+ </div>
234
+ </template>
@@ -1,18 +1,27 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
- * A collapsible section with a smooth height animation. Works controlled via v-model, or uncontrolled by simply
4
- * omitting modelValue.
3
+ * A collapsible section with a smooth height animation (`MCollapse`). Works controlled via v-model, or uncontrolled by
4
+ * simply omitting modelValue. The header takes text props or slots of your own (a colored icon, a title with
5
+ * highlighted parts, a badge before the chevron); `expandable: false` makes it a plain row with nothing to open, and
6
+ * `flush` lets the body run edge to edge (a list).
5
7
  *
6
8
  * @slot default Panel body content, revealed with a height animation when open
9
+ * @slot leading The header's start, instead of `icon` (an avatar, a colored icon)
10
+ * @slot title The title, instead of the `title` text (highlighted parts, a chip)
11
+ * @slot subtitle The line below the title, instead of the `subtitle` text
12
+ * @slot trailing Content before the chevron (a count, a status, a button)
7
13
  * @event update:modelValue Emitted when the panel is toggled — only meaningful when modelValue is passed
8
14
  * (controlled usage); powers v-model
15
+ * @event after-open The open animation finished
16
+ * @event after-close The close animation finished
9
17
  */
10
- import { computed, ref } from 'vue'
18
+ import { computed, ref, useId } from 'vue'
19
+ import MCollapse from './MCollapse.vue'
11
20
  import MIcon from './MIcon.vue'
12
21
 
13
22
  const props = withDefaults(defineProps<{
14
- /** Panel header text */
15
- title: string
23
+ /** Panel header text (or the `#title` slot) */
24
+ title?: string
16
25
  /** Secondary text in the header, below the title */
17
26
  subtitle?: string
18
27
  /** Leading Material Symbol icon in the header */
@@ -22,21 +31,28 @@ const props = withDefaults(defineProps<{
22
31
  * (uncontrolled).
23
32
  */
24
33
  modelValue?: boolean
25
- /** Disables toggling */
34
+ /** Disables toggling (dimmed) */
26
35
  disabled?: boolean
36
+ /** Whether it opens at all: false shows a plain header row, no chevron, not a button (not dimmed, unlike `disabled`) */
37
+ expandable?: boolean
38
+ /** The body with no padding or divider, for edge-to-edge content such as a list */
39
+ flush?: boolean
40
+ /** Unmount the body while closed */
41
+ unmountOnClose?: boolean
27
42
  /** Visual style of the panel container */
28
43
  variant?: 'outlined' | 'filled' | 'elevated'
29
- }>(), { modelValue: undefined, disabled: false, variant: 'outlined' })
44
+ }>(), { modelValue: undefined, disabled: false, expandable: true, flush: false, unmountOnClose: false, variant: 'outlined' })
30
45
 
31
- const emit = defineEmits<{ 'update:modelValue': [boolean] }>()
46
+ const emit = defineEmits<{ 'update:modelValue': [boolean]; 'after-open': []; 'after-close': [] }>()
32
47
 
48
+ const bodyId = useId()
33
49
  const internal = ref(false)
34
50
  const isOpen = computed(() =>
35
- props.modelValue !== undefined ? props.modelValue : internal.value,
51
+ props.expandable && (props.modelValue !== undefined ? props.modelValue : internal.value),
36
52
  )
37
53
 
38
54
  function toggle() {
39
- if (props.disabled) return
55
+ if (props.disabled || !props.expandable) return
40
56
  const next = !isOpen.value
41
57
  if (props.modelValue !== undefined) emit('update:modelValue', next)
42
58
  else internal.value = next
@@ -51,57 +67,49 @@ const wrapperClass = computed(() => {
51
67
 
52
68
  <template>
53
69
  <div :class="wrapperClass" class="overflow-hidden">
54
- <!-- Header / trigger -->
55
- <button
56
- type="button"
57
- class="flex w-full items-center gap-4 px-5 py-4 text-left transition-colors duration-150 focus-visible:outline-none"
58
- :class="[
70
+ <!-- Header: a button when it opens, a plain row when it doesn't -->
71
+ <component
72
+ :is="expandable ? 'button' : 'div'"
73
+ :type="expandable ? 'button' : undefined"
74
+ class="flex w-full items-center gap-4 px-5 py-4 text-left transition-colors duration-150 focus-visible:outline-none focus-visible:bg-on-surface/10"
75
+ :class="expandable ? [
59
76
  disabled ? 'cursor-not-allowed opacity-[0.38]' : 'cursor-pointer hover:bg-on-surface/4',
60
77
  isOpen ? 'bg-on-surface/4' : '',
61
- ]"
62
- :aria-expanded="isOpen"
63
- :disabled="disabled"
78
+ ] : ''"
79
+ :aria-expanded="expandable ? isOpen : undefined"
80
+ :aria-controls="expandable ? bodyId : undefined"
81
+ :disabled="expandable ? disabled : undefined"
64
82
  @click="toggle"
65
83
  >
66
- <MIcon v-if="icon" :name="icon" :size="22" class="shrink-0 text-on-surface-variant" />
84
+ <slot name="leading">
85
+ <MIcon v-if="icon" :name="icon" :size="22" class="shrink-0 text-on-surface-variant" />
86
+ </slot>
67
87
  <div class="flex-1 min-w-0">
68
- <p class="text-body-large font-medium text-on-surface">{{ title }}</p>
69
- <p v-if="subtitle" class="text-body-small text-on-surface-variant">{{ subtitle }}</p>
88
+ <div class="text-body-large font-medium text-on-surface"><slot name="title">{{ title }}</slot></div>
89
+ <div v-if="subtitle || $slots.subtitle" class="text-body-small text-on-surface-variant"><slot name="subtitle">{{ subtitle }}</slot></div>
70
90
  </div>
91
+ <slot name="trailing" />
71
92
  <MIcon
93
+ v-if="expandable"
72
94
  name="expand_more"
73
95
  :size="22"
74
96
  class="shrink-0 text-on-surface-variant transition-transform duration-200"
75
97
  :class="isOpen ? 'rotate-180' : ''"
76
98
  />
77
- </button>
99
+ </component>
78
100
 
79
- <!-- Content with height animation -->
80
- <div class="expand-grid" :class="isOpen ? 'expand-open' : ''">
81
- <div class="expand-body">
82
- <div class="border-t border-outline-variant/60 px-5 py-4">
83
- <slot />
84
- </div>
101
+ <MCollapse
102
+ v-if="expandable"
103
+ :id="bodyId"
104
+ :open="isOpen"
105
+ :unmount-on-close="unmountOnClose"
106
+ @after-open="emit('after-open')"
107
+ @after-close="emit('after-close')"
108
+ >
109
+ <div v-if="flush" class="border-t border-outline-variant/60"><slot /></div>
110
+ <div v-else class="border-t border-outline-variant/60 px-5 py-4">
111
+ <slot />
85
112
  </div>
86
- </div>
113
+ </MCollapse>
87
114
  </div>
88
115
  </template>
89
-
90
- <style scoped>
91
- /*
92
- grid-template-rows: 0fr → 1fr expands to the exact content height,
93
- so the animation is always proportional — no max-height overshoot.
94
- */
95
- .expand-grid {
96
- display: grid;
97
- grid-template-rows: 0fr;
98
- transition: grid-template-rows 300ms ease-in-out;
99
- }
100
- .expand-grid.expand-open {
101
- grid-template-rows: 1fr;
102
- }
103
- .expand-body {
104
- min-height: 0;
105
- overflow: hidden;
106
- }
107
- </style>
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * A visual filter builder: conditions of field · operator · value, combined so all or any of them match, with
4
+ * nested groups for mixes like "status is open AND (priority is high OR due before Friday)". Each field's type
5
+ * (text, number, date, select, boolean) picks its operators and its value input. The filter is the v-model, a plain
6
+ * JSON tree; `filterRows(rows, filter, fields)` (or `matchesFilter`) applies it to a table's rows, or send it to your
7
+ * server. Rules still being filled in match everything. Lays out by its own width: rows wrap when narrow.
8
+ *
9
+ * @event update:modelValue The filter changed
10
+ */
11
+ import { computed } from 'vue'
12
+ import MFilterGroup from './_MFilterGroup.vue'
13
+ import { createFilter, type FilterField, type FilterGroup } from '../composables/filterBuilder'
14
+
15
+ const props = withDefaults(
16
+ defineProps<{
17
+ /** The filter (v-model): a group of rules and nested groups. Leave it out or null to start empty */
18
+ modelValue?: FilterGroup | null
19
+ /** The fields that can be filtered on; see `FilterField` */
20
+ fields: FilterField[]
21
+ /** How deep groups can nest (0: no groups, conditions only) */
22
+ maxDepth?: number
23
+ /** Read-only */
24
+ disabled?: boolean
25
+ }>(),
26
+ { modelValue: null, maxDepth: 1, disabled: false },
27
+ )
28
+
29
+ const emit = defineEmits<{ 'update:modelValue': [filter: FilterGroup] }>()
30
+
31
+ // Kept stable while the v-model is empty, so the root group's id doesn't change on every render
32
+ const empty = createFilter()
33
+ const root = computed(() => (props.modelValue && typeof props.modelValue === 'object' ? props.modelValue : empty))
34
+ </script>
35
+
36
+ <template>
37
+ <div class="m3-filter-builder" role="group">
38
+ <MFilterGroup
39
+ :group="root"
40
+ :fields="fields"
41
+ :depth="0"
42
+ :max-depth="maxDepth"
43
+ :disabled="disabled"
44
+ @update="(g: FilterGroup) => emit('update:modelValue', g)"
45
+ />
46
+ </div>
47
+ </template>
@@ -6,6 +6,7 @@
6
6
  * from the `/map` entry point.
7
7
  */
8
8
  import MIcon from './MIcon.vue'
9
+ import MTooltip from './MTooltip.vue'
9
10
  import { useLocale } from '../composables/useLocale'
10
11
  import { useMapLayers } from '../composables/useMapLayers'
11
12
  import type { MapSource } from '../composables/useMap'
@@ -32,34 +33,34 @@ const src = (image: string, base: string) => (/^(https?:|data:|\/\/)/.test(image
32
33
 
33
34
  <template>
34
35
  <div class="flex gap-2" :class="vertical ? 'flex-col' : 'flex-row flex-wrap'" role="radiogroup">
35
- <button
36
- v-for="layer in baseLayers"
37
- :key="layer.id"
38
- type="button"
39
- role="radio"
40
- class="m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110"
41
- :class="baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'"
42
- :title="layer.title"
43
- :aria-label="layer.title"
44
- :aria-checked="baseLayer === layer.id"
45
- @click="setBaseLayer(layer.id)"
46
- >
47
- <img v-if="layer.base?.image" :src="src(layer.base.image, imageBase)" alt="" class="size-full object-cover">
48
- <MIcon v-else name="map" :size="22" class="text-on-surface-variant" />
49
- </button>
50
- <button
51
- v-if="none"
52
- type="button"
53
- role="radio"
54
- class="m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110"
55
- :class="baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'"
56
- :title="t.mapNoBaseLayer"
57
- :aria-label="t.mapNoBaseLayer"
58
- :aria-checked="baseLayer === null"
59
- @click="setBaseLayer(null)"
60
- >
61
- <MIcon name="layers_clear" :size="22" class="text-on-surface-variant" />
62
- </button>
36
+ <!-- The library's tooltip, not the browser's title -->
37
+ <MTooltip v-for="layer in baseLayers" :key="layer.id" :text="layer.title" :placement="vertical ? 'right' : 'top'">
38
+ <button
39
+ type="button"
40
+ role="radio"
41
+ class="m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110"
42
+ :class="baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'"
43
+ :aria-label="layer.title"
44
+ :aria-checked="baseLayer === layer.id"
45
+ @click="setBaseLayer(layer.id)"
46
+ >
47
+ <img v-if="layer.base?.image" :src="src(layer.base.image, imageBase)" alt="" class="size-full object-cover">
48
+ <MIcon v-else name="map" :size="22" class="text-on-surface-variant" />
49
+ </button>
50
+ </MTooltip>
51
+ <MTooltip v-if="none" :text="t.mapNoBaseLayer" :placement="vertical ? 'right' : 'top'">
52
+ <button
53
+ type="button"
54
+ role="radio"
55
+ class="m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110"
56
+ :class="baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'"
57
+ :aria-label="t.mapNoBaseLayer"
58
+ :aria-checked="baseLayer === null"
59
+ @click="setBaseLayer(null)"
60
+ >
61
+ <MIcon name="layers_clear" :size="22" class="text-on-surface-variant" />
62
+ </button>
63
+ </MTooltip>
63
64
  </div>
64
65
  </template>
65
66