@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.
- package/README.md +5 -1
- package/dist/{MMenuItem-BXIxwIdM.js → MMenuItem-DmrsQrK7.js} +2 -2
- package/dist/{MMenuItem-BXIxwIdM.js.map → MMenuItem-DmrsQrK7.js.map} +1 -1
- package/dist/chart.js +5 -1
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MBottomSheet.vue.d.ts +3 -3
- package/dist/components/MChatBubble.vue.d.ts +4 -2
- package/dist/components/MCheckbox.vue.d.ts +2 -0
- package/dist/components/MDragDropList.vue.d.ts +19 -6
- package/dist/components/MFileUpload.vue.d.ts +16 -4
- package/dist/components/MKanban.vue.d.ts +15 -6
- package/dist/components/MListDetail.vue.d.ts +31 -0
- package/dist/components/MNavigationRail.vue.d.ts +6 -3
- package/dist/components/MNavigationSuite.vue.d.ts +46 -0
- package/dist/components/MShortNavigationBar.vue.d.ts +6 -1
- package/dist/components/MSideSheet.vue.d.ts +4 -4
- package/dist/components/MSupportingPane.vue.d.ts +34 -0
- package/dist/components/MTransferList.vue.d.ts +57 -30
- package/dist/components/MWindow.vue.d.ts +39 -1
- package/dist/components/_MTransferPane.vue.d.ts +46 -0
- package/dist/composables/_useItemLink.d.ts +30 -0
- package/dist/composables/_useSheetMotion.d.ts +7 -0
- package/dist/composables/useLocale.d.ts +27 -0
- package/dist/composables/useWindowSizeClass.d.ts +19 -0
- package/dist/index.d.ts +6 -0
- package/dist/locales/index.js +196 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +4331 -2945
- package/dist/m3ui.js.map +1 -1
- package/dist/rich-text-editor.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/{useLocale-DbREg9Zn.js → useLocale-Bircp823.js} +29 -2
- package/dist/useLocale-Bircp823.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MChart.test.ts +28 -0
- package/src/__tests__/MChatBubble.test.ts +33 -0
- package/src/__tests__/MDragDropList.test.ts +194 -0
- package/src/__tests__/MFileUpload.test.ts +78 -0
- package/src/__tests__/MKanban.test.ts +150 -0
- package/src/__tests__/MPullToRefresh.test.ts +67 -0
- package/src/__tests__/MRating.test.ts +72 -0
- package/src/__tests__/MShortNavigationBar.test.ts +25 -0
- package/src/__tests__/MTransferList.test.ts +149 -0
- package/src/__tests__/MWindow.test.ts +258 -0
- package/src/__tests__/adaptiveLayouts.test.ts +191 -0
- package/src/__tests__/sheets.test.ts +76 -0
- package/src/components/MBottomSheet.vue +11 -57
- package/src/components/MChart.vue +2 -1
- package/src/components/MChatBubble.vue +107 -20
- package/src/components/MCheckbox.vue +3 -0
- package/src/components/MDragDropList.vue +485 -56
- package/src/components/MFileUpload.vue +56 -20
- package/src/components/MKanban.vue +720 -78
- package/src/components/MListDetail.vue +103 -0
- package/src/components/MNavigationRail.vue +48 -31
- package/src/components/MNavigationSuite.vue +89 -0
- package/src/components/MPullToRefresh.vue +101 -35
- package/src/components/MRating.vue +163 -67
- package/src/components/MResult.vue +19 -9
- package/src/components/MShortNavigationBar.vue +37 -17
- package/src/components/MSideSheet.vue +11 -56
- package/src/components/MSupportingPane.vue +70 -0
- package/src/components/MTransferList.vue +174 -137
- package/src/components/MWindow.vue +507 -108
- package/src/components/_MTransferPane.vue +260 -0
- package/src/composables/_useItemLink.ts +19 -0
- package/src/composables/_useSheetMotion.ts +181 -0
- package/src/composables/useLocale.ts +75 -0
- package/src/composables/useWindowSizeClass.ts +93 -0
- package/src/index.ts +6 -0
- package/src/locales/de.ts +37 -0
- package/src/locales/es.ts +37 -0
- package/src/locales/fr.ts +37 -0
- package/src/locales/ja.ts +37 -0
- package/src/locales/ko.ts +37 -0
- package/src/locales/pt.ts +37 -0
- package/src/locales/zh.ts +37 -0
- package/dist/useLocale-DbREg9Zn.js.map +0 -1
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
<script
|
|
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
|
|
14
|
+
import MTransferPane from './_MTransferPane.vue'
|
|
6
15
|
import { useLocale } from '../composables/useLocale'
|
|
7
16
|
|
|
8
17
|
const locale = useLocale()
|
|
9
18
|
|
|
10
|
-
|
|
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:
|
|
18
|
-
items:
|
|
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
|
-
|
|
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<
|
|
35
|
-
const checkedTarget = ref<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
|
-
|
|
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
|
-
|
|
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
|
|
60
|
-
const s = new Set(
|
|
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
|
-
|
|
94
|
+
set.value = s
|
|
63
95
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
87
|
-
emit('update:modelValue', props.modelValue.filter(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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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>
|