@m3ui-vue/m3ui-vue 0.8.5 → 0.8.7

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 (80) hide show
  1. package/README.md +5 -1
  2. package/dist/{MMenuItem-BXIxwIdM.js → MMenuItem-DmrsQrK7.js} +2 -2
  3. package/dist/{MMenuItem-BXIxwIdM.js.map → MMenuItem-DmrsQrK7.js.map} +1 -1
  4. package/dist/chart.js +5 -1
  5. package/dist/chart.js.map +1 -1
  6. package/dist/code-editor.js +1 -1
  7. package/dist/components/MBottomSheet.vue.d.ts +3 -3
  8. package/dist/components/MChatBubble.vue.d.ts +4 -2
  9. package/dist/components/MCheckbox.vue.d.ts +2 -0
  10. package/dist/components/MDragDropList.vue.d.ts +19 -6
  11. package/dist/components/MFileUpload.vue.d.ts +16 -4
  12. package/dist/components/MKanban.vue.d.ts +15 -6
  13. package/dist/components/MListDetail.vue.d.ts +31 -0
  14. package/dist/components/MNavigationRail.vue.d.ts +6 -3
  15. package/dist/components/MNavigationSuite.vue.d.ts +46 -0
  16. package/dist/components/MShortNavigationBar.vue.d.ts +6 -1
  17. package/dist/components/MSideSheet.vue.d.ts +4 -4
  18. package/dist/components/MSupportingPane.vue.d.ts +34 -0
  19. package/dist/components/MTransferList.vue.d.ts +57 -30
  20. package/dist/components/MWindow.vue.d.ts +39 -1
  21. package/dist/components/_MTransferPane.vue.d.ts +46 -0
  22. package/dist/composables/_useItemLink.d.ts +30 -0
  23. package/dist/composables/_useSheetMotion.d.ts +7 -0
  24. package/dist/composables/useLocale.d.ts +27 -0
  25. package/dist/composables/useWindowSizeClass.d.ts +19 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/locales/index.js +196 -7
  28. package/dist/locales/index.js.map +1 -1
  29. package/dist/m3ui-vue.css +1 -1
  30. package/dist/m3ui.js +4331 -2945
  31. package/dist/m3ui.js.map +1 -1
  32. package/dist/rich-text-editor.js +2 -2
  33. package/dist/styles.css +1 -1
  34. package/dist/{useLocale-DbREg9Zn.js → useLocale-Bircp823.js} +29 -2
  35. package/dist/useLocale-Bircp823.js.map +1 -0
  36. package/package.json +1 -1
  37. package/src/__tests__/MChart.test.ts +28 -0
  38. package/src/__tests__/MChatBubble.test.ts +33 -0
  39. package/src/__tests__/MDragDropList.test.ts +194 -0
  40. package/src/__tests__/MFileUpload.test.ts +78 -0
  41. package/src/__tests__/MKanban.test.ts +150 -0
  42. package/src/__tests__/MPullToRefresh.test.ts +67 -0
  43. package/src/__tests__/MRating.test.ts +72 -0
  44. package/src/__tests__/MShortNavigationBar.test.ts +25 -0
  45. package/src/__tests__/MTransferList.test.ts +149 -0
  46. package/src/__tests__/MWindow.test.ts +258 -0
  47. package/src/__tests__/adaptiveLayouts.test.ts +191 -0
  48. package/src/__tests__/sheets.test.ts +76 -0
  49. package/src/components/MBottomSheet.vue +11 -57
  50. package/src/components/MChart.vue +2 -1
  51. package/src/components/MChatBubble.vue +107 -20
  52. package/src/components/MCheckbox.vue +3 -0
  53. package/src/components/MDragDropList.vue +485 -56
  54. package/src/components/MFileUpload.vue +56 -20
  55. package/src/components/MKanban.vue +720 -78
  56. package/src/components/MListDetail.vue +103 -0
  57. package/src/components/MNavigationRail.vue +48 -31
  58. package/src/components/MNavigationSuite.vue +89 -0
  59. package/src/components/MPullToRefresh.vue +101 -35
  60. package/src/components/MRating.vue +163 -67
  61. package/src/components/MResult.vue +19 -9
  62. package/src/components/MShortNavigationBar.vue +37 -17
  63. package/src/components/MSideSheet.vue +11 -56
  64. package/src/components/MSupportingPane.vue +70 -0
  65. package/src/components/MTransferList.vue +174 -137
  66. package/src/components/MWindow.vue +507 -108
  67. package/src/components/_MTransferPane.vue +260 -0
  68. package/src/composables/_useItemLink.ts +19 -0
  69. package/src/composables/_useSheetMotion.ts +181 -0
  70. package/src/composables/useLocale.ts +75 -0
  71. package/src/composables/useWindowSizeClass.ts +93 -0
  72. package/src/index.ts +6 -0
  73. package/src/locales/de.ts +37 -0
  74. package/src/locales/es.ts +37 -0
  75. package/src/locales/fr.ts +37 -0
  76. package/src/locales/ja.ts +37 -0
  77. package/src/locales/ko.ts +37 -0
  78. package/src/locales/pt.ts +37 -0
  79. package/src/locales/zh.ts +37 -0
  80. package/dist/useLocale-DbREg9Zn.js.map +0 -1
@@ -1,21 +1,26 @@
1
- <script setup lang="ts">
1
+ <script lang="ts">
2
+ export interface TransferItem {
3
+ value: string | number
4
+ label: string
5
+ icon?: string
6
+ /** Optional second line under the label (an email, a role, a short description). */
7
+ description?: string
8
+ }
9
+ </script>
10
+
11
+ <script setup lang="ts" generic="T extends TransferItem = TransferItem">
2
12
  import { computed, ref } from 'vue'
3
- import MIcon from './MIcon.vue'
4
13
  import MIconButton from './MIconButton.vue'
5
- import MCheckbox from './MCheckbox.vue'
14
+ import MTransferPane from './_MTransferPane.vue'
6
15
  import { useLocale } from '../composables/useLocale'
7
16
 
8
17
  const locale = useLocale()
9
18
 
10
- export interface TransferItem {
11
- value: string | number
12
- label: string
13
- icon?: string
14
- }
19
+ type Value = string | number
15
20
 
16
21
  const props = withDefaults(defineProps<{
17
- modelValue: (string | number)[]
18
- items: TransferItem[]
22
+ modelValue: Value[]
23
+ items: T[]
19
24
  sourceTitle?: string
20
25
  targetTitle?: string
21
26
  filterable?: boolean
@@ -25,172 +30,204 @@ const props = withDefaults(defineProps<{
25
30
  moveRightLabel?: string
26
31
  moveLeftLabel?: string
27
32
  moveAllLeftLabel?: string
33
+ /** Height of each list's scroll area (any CSS length). */
34
+ listHeight?: string
35
+ /**
36
+ * Fully custom rows: the `#item` slot draws the whole row (no checkbox, padding, min height
37
+ * or background). The row stays clickable, focusable (Space checks it, Enter moves it) and
38
+ * animated; use the slot's `checked` to style the checked state.
39
+ */
40
+ bare?: boolean
28
41
  }>(), {
29
42
  filterable: false,
43
+ listHeight: '280px',
44
+ bare: false,
30
45
  })
31
46
 
32
- const emit = defineEmits<{ 'update:modelValue': [(string | number)[]] }>()
47
+ defineSlots<{
48
+ /**
49
+ * Custom row content. Without `bare` it replaces the icon and text, keeping the checkbox,
50
+ * highlight and hover. Buttons, links, fields and `[data-transfer-action]` elements inside
51
+ * keep their own clicks instead of checking the row.
52
+ */
53
+ item?: (props: {
54
+ /** Your item, with any extra fields it carries. */
55
+ item: T
56
+ checked: boolean
57
+ /** Which pane the row is in. */
58
+ side: 'source' | 'target'
59
+ /** Check or uncheck the row. */
60
+ toggle: () => void
61
+ /** Send just this row to the other pane. */
62
+ move: () => void
63
+ }) => unknown
64
+ 'source-empty'?: () => unknown
65
+ 'target-empty'?: () => unknown
66
+ }>()
67
+
68
+ const emit = defineEmits<{ 'update:modelValue': [Value[]] }>()
33
69
 
34
- const checkedSource = ref<Set<string | number>>(new Set())
35
- const checkedTarget = ref<Set<string | number>>(new Set())
70
+ const checkedSource = ref<Set<Value>>(new Set())
71
+ const checkedTarget = ref<Set<Value>>(new Set())
36
72
  const sourceSearch = ref('')
37
73
  const targetSearch = ref('')
38
74
 
75
+ function matches(item: TransferItem, q: string) {
76
+ if (!q) return true
77
+ const needle = q.toLowerCase()
78
+ return item.label.toLowerCase().includes(needle) || !!item.description?.toLowerCase().includes(needle)
79
+ }
80
+
39
81
  const sourceItems = computed(() => {
40
82
  const selected = new Set(props.modelValue)
41
- let list = props.items.filter(i => !selected.has(i.value))
42
- if (sourceSearch.value) {
43
- const q = sourceSearch.value.toLowerCase()
44
- list = list.filter(i => i.label.toLowerCase().includes(q))
45
- }
46
- return list
83
+ return props.items.filter((i) => !selected.has(i.value) && matches(i, sourceSearch.value))
47
84
  })
48
85
 
49
86
  const targetItems = computed(() => {
50
87
  const selected = new Set(props.modelValue)
51
- let list = props.items.filter(i => selected.has(i.value))
52
- if (targetSearch.value) {
53
- const q = targetSearch.value.toLowerCase()
54
- list = list.filter(i => i.label.toLowerCase().includes(q))
55
- }
56
- return list
88
+ return props.items.filter((i) => selected.has(i.value) && matches(i, targetSearch.value))
57
89
  })
58
90
 
59
- function toggleSource(value: string | number) {
60
- const s = new Set(checkedSource.value)
91
+ function toggleIn(set: typeof checkedSource, value: Value) {
92
+ const s = new Set(set.value)
61
93
  s.has(value) ? s.delete(value) : s.add(value)
62
- checkedSource.value = s
94
+ set.value = s
63
95
  }
64
- function toggleTarget(value: string | number) {
65
- const s = new Set(checkedTarget.value)
66
- s.has(value) ? s.delete(value) : s.add(value)
67
- checkedTarget.value = s
96
+
97
+ // Select-all acts on what's visible (i.e. what the search left).
98
+ function toggleAllIn(set: typeof checkedSource, visible: TransferItem[]) {
99
+ const allChecked = visible.length > 0 && visible.every((i) => set.value.has(i.value))
100
+ const s = new Set(set.value)
101
+ for (const i of visible) allChecked ? s.delete(i.value) : s.add(i.value)
102
+ set.value = s
68
103
  }
69
104
 
105
+ const toggleSource = (v: Value) => toggleIn(checkedSource, v)
106
+ const toggleTarget = (v: Value) => toggleIn(checkedTarget, v)
107
+ const toggleAllSource = () => toggleAllIn(checkedSource, sourceItems.value)
108
+ const toggleAllTarget = () => toggleAllIn(checkedTarget, targetItems.value)
109
+
70
110
  function moveRight() {
71
- const next = [...props.modelValue, ...checkedSource.value]
72
- emit('update:modelValue', next)
111
+ emit('update:modelValue', [...props.modelValue, ...checkedSource.value])
73
112
  checkedSource.value = new Set()
74
113
  }
75
114
  function moveLeft() {
76
115
  const remove = checkedTarget.value
77
- emit('update:modelValue', props.modelValue.filter(v => !remove.has(v)))
116
+ emit('update:modelValue', props.modelValue.filter((v) => !remove.has(v)))
78
117
  checkedTarget.value = new Set()
79
118
  }
80
119
  function moveAllRight() {
81
- const all = sourceItems.value.map(i => i.value)
82
- emit('update:modelValue', [...props.modelValue, ...all])
120
+ emit('update:modelValue', [...props.modelValue, ...sourceItems.value.map((i) => i.value)])
83
121
  checkedSource.value = new Set()
84
122
  }
85
123
  function moveAllLeft() {
86
- const keep = targetItems.value.map(i => i.value)
87
- emit('update:modelValue', props.modelValue.filter(v => !new Set(keep).has(v)))
124
+ const remove = new Set(targetItems.value.map((i) => i.value))
125
+ emit('update:modelValue', props.modelValue.filter((v) => !remove.has(v)))
88
126
  checkedTarget.value = new Set()
89
127
  }
128
+
129
+ // Double-click / Enter on a row moves just that item across.
130
+ function activateSource(value: Value) {
131
+ emit('update:modelValue', [...props.modelValue, value])
132
+ const s = new Set(checkedSource.value)
133
+ s.delete(value)
134
+ checkedSource.value = s
135
+ }
136
+ function activateTarget(value: Value) {
137
+ emit('update:modelValue', props.modelValue.filter((v) => v !== value))
138
+ const s = new Set(checkedTarget.value)
139
+ s.delete(value)
140
+ checkedTarget.value = s
141
+ }
90
142
  </script>
91
143
 
92
144
  <template>
93
- <div class="flex items-stretch gap-2">
94
- <!-- Source list -->
95
- <div class="flex min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-outline-variant">
96
- <div class="flex items-center justify-between border-b border-outline-variant bg-surface-container px-3 py-2">
97
- <span class="text-label-large font-medium text-on-surface">{{ sourceTitle ?? locale.available }}</span>
98
- <span class="text-label-small text-on-surface-variant">{{ sourceItems.length }}</span>
99
- </div>
100
- <div v-if="filterable" class="border-b border-outline-variant px-3 py-2">
101
- <input
102
- v-model="sourceSearch"
103
- type="text"
104
- :placeholder="searchPlaceholder ?? locale.search"
105
- class="w-full bg-transparent text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant/50"
106
- />
107
- </div>
108
- <div class="flex-1 overflow-y-auto" style="max-height: 240px">
109
- <button
110
- v-for="item in sourceItems"
111
- :key="item.value"
112
- type="button"
113
- class="flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-on-surface/4"
114
- @click="toggleSource(item.value)"
115
- >
116
- <MCheckbox :model-value="checkedSource.has(item.value)" @update:model-value="toggleSource(item.value)" />
117
- <MIcon v-if="item.icon" :name="item.icon" :size="18" class="shrink-0 text-on-surface-variant" />
118
- <span class="flex-1 truncate text-body-medium text-on-surface">{{ item.label }}</span>
119
- </button>
120
- <slot v-if="!sourceItems.length" name="source-empty">
121
- <p class="px-3 py-4 text-center text-body-small text-on-surface-variant">
122
- {{ emptyText ?? locale.noItems }}
123
- </p>
124
- </slot>
125
- </div>
126
- </div>
145
+ <!--
146
+ Container query, not a viewport breakpoint: the panes sit side by side whenever the
147
+ component itself is wide enough (@xl = 36rem), and stack with up/down arrows otherwise,
148
+ whatever the screen size.
149
+ -->
150
+ <div class="@container">
151
+ <div class="flex flex-col items-stretch gap-3 @xl:flex-row">
152
+ <MTransferPane
153
+ :title="sourceTitle ?? locale.available"
154
+ :items="sourceItems"
155
+ :checked="checkedSource"
156
+ :filterable="filterable"
157
+ :search="sourceSearch"
158
+ :search-placeholder="searchPlaceholder ?? locale.search"
159
+ :empty-text="emptyText ?? locale.noItems"
160
+ :list-height="listHeight"
161
+ enter-from="end"
162
+ :select-all-label="locale.selectAll"
163
+ :clear-search-label="locale.clearSearch"
164
+ :bare="bare"
165
+ @toggle="toggleSource"
166
+ @toggle-all="toggleAllSource"
167
+ @activate="activateSource"
168
+ @update:search="sourceSearch = $event"
169
+ >
170
+ <template v-if="$slots.item" #item="row"><slot name="item" v-bind="row" :item="row.item as T" side="source" /></template>
171
+ <template v-if="$slots['source-empty']" #empty><slot name="source-empty" /></template>
172
+ </MTransferPane>
127
173
 
128
- <!-- Transfer buttons -->
129
- <div class="flex flex-col items-center justify-center gap-1">
130
- <MIconButton
131
- icon="keyboard_double_arrow_right"
132
- :label="moveAllRightLabel ?? locale.moveAllRight"
133
- :size="36"
134
- :disabled="!sourceItems.length"
135
- @click="moveAllRight"
136
- />
137
- <MIconButton
138
- icon="chevron_right"
139
- :label="moveRightLabel ?? locale.moveRight"
140
- variant="tonal"
141
- :size="36"
142
- :disabled="!checkedSource.size"
143
- @click="moveRight"
144
- />
145
- <MIconButton
146
- icon="chevron_left"
147
- :label="moveLeftLabel ?? locale.moveLeft"
148
- variant="tonal"
149
- :size="36"
150
- :disabled="!checkedTarget.size"
151
- @click="moveLeft"
152
- />
153
- <MIconButton
154
- icon="keyboard_double_arrow_left"
155
- :label="moveAllLeftLabel ?? locale.moveAllLeft"
156
- :size="36"
157
- :disabled="!targetItems.length"
158
- @click="moveAllLeft"
159
- />
160
- </div>
161
-
162
- <!-- Target list -->
163
- <div class="flex min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-outline-variant">
164
- <div class="flex items-center justify-between border-b border-outline-variant bg-surface-container px-3 py-2">
165
- <span class="text-label-large font-medium text-on-surface">{{ targetTitle ?? locale.selected }}</span>
166
- <span class="text-label-small text-on-surface-variant">{{ targetItems.length }}</span>
167
- </div>
168
- <div v-if="filterable" class="border-b border-outline-variant px-3 py-2">
169
- <input
170
- v-model="targetSearch"
171
- type="text"
172
- :placeholder="searchPlaceholder ?? locale.search"
173
- class="w-full bg-transparent text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant/50"
174
+ <!-- Transfer buttons: tonal for the checked items, outlined for "all" -->
175
+ <div class="flex items-center justify-center gap-2 @xl:flex-col">
176
+ <MIconButton
177
+ icon="keyboard_double_arrow_right"
178
+ variant="outlined"
179
+ class="rotate-90 @xl:rotate-0"
180
+ :label="moveAllRightLabel ?? locale.moveAllRight"
181
+ :disabled="!sourceItems.length"
182
+ @click="moveAllRight"
183
+ />
184
+ <MIconButton
185
+ icon="chevron_right"
186
+ variant="tonal"
187
+ class="rotate-90 @xl:rotate-0"
188
+ :label="moveRightLabel ?? locale.moveRight"
189
+ :disabled="!checkedSource.size"
190
+ @click="moveRight"
191
+ />
192
+ <MIconButton
193
+ icon="chevron_left"
194
+ variant="tonal"
195
+ class="rotate-90 @xl:rotate-0"
196
+ :label="moveLeftLabel ?? locale.moveLeft"
197
+ :disabled="!checkedTarget.size"
198
+ @click="moveLeft"
199
+ />
200
+ <MIconButton
201
+ icon="keyboard_double_arrow_left"
202
+ variant="outlined"
203
+ class="rotate-90 @xl:rotate-0"
204
+ :label="moveAllLeftLabel ?? locale.moveAllLeft"
205
+ :disabled="!targetItems.length"
206
+ @click="moveAllLeft"
174
207
  />
175
208
  </div>
176
- <div class="flex-1 overflow-y-auto" style="max-height: 240px">
177
- <button
178
- v-for="item in targetItems"
179
- :key="item.value"
180
- type="button"
181
- class="flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-on-surface/4"
182
- @click="toggleTarget(item.value)"
183
- >
184
- <MCheckbox :model-value="checkedTarget.has(item.value)" @update:model-value="toggleTarget(item.value)" />
185
- <MIcon v-if="item.icon" :name="item.icon" :size="18" class="shrink-0 text-on-surface-variant" />
186
- <span class="flex-1 truncate text-body-medium text-on-surface">{{ item.label }}</span>
187
- </button>
188
- <slot v-if="!targetItems.length" name="target-empty">
189
- <p class="px-3 py-4 text-center text-body-small text-on-surface-variant">
190
- {{ emptyText ?? locale.noItems }}
191
- </p>
192
- </slot>
193
- </div>
209
+
210
+ <MTransferPane
211
+ :title="targetTitle ?? locale.selected"
212
+ :items="targetItems"
213
+ :checked="checkedTarget"
214
+ :filterable="filterable"
215
+ :search="targetSearch"
216
+ :search-placeholder="searchPlaceholder ?? locale.search"
217
+ :empty-text="emptyText ?? locale.noItems"
218
+ :list-height="listHeight"
219
+ enter-from="start"
220
+ :select-all-label="locale.selectAll"
221
+ :clear-search-label="locale.clearSearch"
222
+ :bare="bare"
223
+ @toggle="toggleTarget"
224
+ @toggle-all="toggleAllTarget"
225
+ @activate="activateTarget"
226
+ @update:search="targetSearch = $event"
227
+ >
228
+ <template v-if="$slots.item" #item="row"><slot name="item" v-bind="row" :item="row.item as T" side="target" /></template>
229
+ <template v-if="$slots['target-empty']" #empty><slot name="target-empty" /></template>
230
+ </MTransferPane>
194
231
  </div>
195
232
  </div>
196
233
  </template>