@teammodlr/ui-kit 2.2.2 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/dialog/Dialog.vue.d.ts +1 -1
- package/lib/components/dropdown/Dropdown.vue.d.ts +25 -27
- package/lib/components/dropdown/DropdownItem.vue.d.ts +1 -2
- package/lib/components/index.d.ts +1 -2
- package/lib/components/messageprovider/Message.vue.d.ts +1 -1
- package/lib/components/modal/Modal.vue.d.ts +1 -1
- package/lib/components/primative/primitive.d.ts +1 -1
- package/lib/index.cjs.js +10 -8
- package/lib/index.es.js +8363 -4234
- package/lib/style.css +1 -1
- package/package.json +2 -1
- package/src/components/dropdown/Dropdown.vue +207 -331
- package/src/components/dropdown/DropdownHeading.vue +23 -23
- package/src/components/dropdown/DropdownItem.vue +116 -151
- package/src/components/dropdown/DropdownSeperator.vue +26 -23
- package/src/components/dropdown/examples/basic.vue +246 -119
- package/src/components/dropdown/examples/context.vue +52 -71
- package/src/components/dropdown/style/Dropdown.css.ts +159 -158
- package/src/components/index.ts +3 -2
- package/src/components/tooltip/Tooltip.vue +1 -1
- package/lib/components/dropdown/DropdownTrigger.vue.d.ts +0 -11
- package/lib/components/dropdown/DropdownWrapper.vue.d.ts +0 -2
- package/src/components/dropdown/DropdownTrigger.vue +0 -20
- package/src/components/dropdown/DropdownWrapper.vue +0 -18
|
@@ -1,331 +1,207 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
as-child
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
import {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
nextTick(() => {
|
|
209
|
-
setPlacement(props.placement);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
useEventListener('resize', () => {
|
|
214
|
-
updatePopper();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
onClickOutside(wrapper, e => {
|
|
218
|
-
let parent = e.target as HTMLElement;
|
|
219
|
-
|
|
220
|
-
let i = 0;
|
|
221
|
-
while (parent) {
|
|
222
|
-
if (parent.classList.contains('m-dropdown-menu')) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
parent = parent.parentElement as HTMLElement;
|
|
226
|
-
|
|
227
|
-
if (i > 10) {
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
i++;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
isOpen.value = false;
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
function setPlacement(value: Placement) {
|
|
237
|
-
const [xPlacement] = value.split('-');
|
|
238
|
-
|
|
239
|
-
if (isNested && xPlacement !== 'right' && xPlacement !== 'left') {
|
|
240
|
-
placement.value = 'right-start';
|
|
241
|
-
} else {
|
|
242
|
-
placement.value = value;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function toggleDropdown() {
|
|
247
|
-
isOpen.value = !isOpen.value;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function handleSelect(labels: string[]) {
|
|
251
|
-
isOpen.value = false;
|
|
252
|
-
props.onSelect(labels);
|
|
253
|
-
if (typeof parentState?.handleSelect === 'function') {
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
parentState.handleSelect([currentLabel.value!, ...labels]);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const computedWrapperClasses = computed(() => {
|
|
260
|
-
return [
|
|
261
|
-
'm-dropdown',
|
|
262
|
-
{
|
|
263
|
-
'm-dropdown--open': isOpen.value,
|
|
264
|
-
'm-dropdown--nested': isNested
|
|
265
|
-
}
|
|
266
|
-
];
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const computedReferenceClasses = computed(() => {});
|
|
270
|
-
|
|
271
|
-
const menuClasses = computed(() => {
|
|
272
|
-
return ['m-dropdown-menu', style.menu];
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
const transitionName = computed(() => {
|
|
276
|
-
return `m-transition__${props.transitionName}`;
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
const maxHeight = ref('auto');
|
|
280
|
-
useEventListener(window, 'resize', () => {
|
|
281
|
-
if (isOpen.value) {
|
|
282
|
-
resize();
|
|
283
|
-
updatePopper();
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
watchEffect(() => {
|
|
288
|
-
resize();
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
function resize() {
|
|
292
|
-
if (!isOpen.value || !reference.value) {
|
|
293
|
-
maxHeight.value = 'auto';
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// @ts-ignore
|
|
298
|
-
const referenceElement = reference.value.$el.getBoundingClientRect()
|
|
299
|
-
const referenceHeight = referenceElement.height;
|
|
300
|
-
|
|
301
|
-
const referenceTop = referenceElement.top;
|
|
302
|
-
if (!referenceHeight || !referenceTop) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
let windowHeight = window.innerHeight;
|
|
306
|
-
|
|
307
|
-
maxHeight.value = `${
|
|
308
|
-
windowHeight - referenceHeight - referenceTop - 30
|
|
309
|
-
}px`;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return {
|
|
313
|
-
wrapper,
|
|
314
|
-
referenceRef,
|
|
315
|
-
popper,
|
|
316
|
-
transferTo,
|
|
317
|
-
isOpen,
|
|
318
|
-
isNested,
|
|
319
|
-
placement,
|
|
320
|
-
menuClasses,
|
|
321
|
-
computedWrapperClasses,
|
|
322
|
-
computedReferenceClasses,
|
|
323
|
-
transitionName,
|
|
324
|
-
toggleDropdown,
|
|
325
|
-
zIndex,
|
|
326
|
-
scale,
|
|
327
|
-
maxHeight
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<ContextMenuRoot v-if="contextMenu">
|
|
3
|
+
<ContextMenuTrigger as-child>
|
|
4
|
+
<slot />
|
|
5
|
+
</ContextMenuTrigger>
|
|
6
|
+
<ContextMenuPortal>
|
|
7
|
+
<ContextMenuContent :align="placement" :class="menuClasses" :side-offset="5">
|
|
8
|
+
<slot name="menu" />
|
|
9
|
+
</ContextMenuContent>
|
|
10
|
+
</ContextMenuPortal>
|
|
11
|
+
</ContextMenuRoot>
|
|
12
|
+
<DropdownMenuRoot v-model:open="isOpen" v-else :modal="modal">
|
|
13
|
+
<DropdownMenuTrigger as-child>
|
|
14
|
+
<slot />
|
|
15
|
+
</DropdownMenuTrigger>
|
|
16
|
+
<DropdownMenuPortal>
|
|
17
|
+
<DropdownMenuContent :align="placement" :class="menuClasses" :side-offset="5">
|
|
18
|
+
<slot name="menu" />
|
|
19
|
+
</DropdownMenuContent>
|
|
20
|
+
</DropdownMenuPortal>
|
|
21
|
+
</DropdownMenuRoot>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import {
|
|
26
|
+
DropdownMenuArrow,
|
|
27
|
+
DropdownMenuCheckboxItem,
|
|
28
|
+
DropdownMenuContent,
|
|
29
|
+
DropdownMenuItem,
|
|
30
|
+
DropdownMenuItemIndicator,
|
|
31
|
+
DropdownMenuLabel,
|
|
32
|
+
DropdownMenuPortal,
|
|
33
|
+
DropdownMenuRadioGroup,
|
|
34
|
+
DropdownMenuRadioItem,
|
|
35
|
+
DropdownMenuRoot,
|
|
36
|
+
DropdownMenuSeparator,
|
|
37
|
+
DropdownMenuSub,
|
|
38
|
+
DropdownMenuSubContent,
|
|
39
|
+
DropdownMenuSubTrigger,
|
|
40
|
+
DropdownMenuTrigger,
|
|
41
|
+
|
|
42
|
+
ContextMenuCheckboxItem,
|
|
43
|
+
ContextMenuContent,
|
|
44
|
+
ContextMenuItem,
|
|
45
|
+
ContextMenuItemIndicator,
|
|
46
|
+
ContextMenuLabel,
|
|
47
|
+
ContextMenuPortal,
|
|
48
|
+
ContextMenuRadioGroup,
|
|
49
|
+
ContextMenuRadioItem,
|
|
50
|
+
ContextMenuRoot,
|
|
51
|
+
ContextMenuSeparator,
|
|
52
|
+
ContextMenuSub,
|
|
53
|
+
ContextMenuSubContent,
|
|
54
|
+
ContextMenuSubTrigger,
|
|
55
|
+
ContextMenuTrigger,
|
|
56
|
+
} from 'radix-vue';
|
|
57
|
+
import {
|
|
58
|
+
computed,
|
|
59
|
+
defineComponent,
|
|
60
|
+
ref,
|
|
61
|
+
watch,
|
|
62
|
+
type PropType
|
|
63
|
+
} from 'vue';
|
|
64
|
+
import { useZIndex } from '../../composables/useZIndex';
|
|
65
|
+
import { scale } from '../../styles/transitions.css';
|
|
66
|
+
import * as style from './style';
|
|
67
|
+
import { DROPDOWN_STATE } from './symbol';
|
|
68
|
+
|
|
69
|
+
export default defineComponent({
|
|
70
|
+
name: 'Dropdown',
|
|
71
|
+
components: {
|
|
72
|
+
DropdownMenuArrow,
|
|
73
|
+
DropdownMenuCheckboxItem,
|
|
74
|
+
DropdownMenuContent,
|
|
75
|
+
DropdownMenuItem,
|
|
76
|
+
DropdownMenuItemIndicator,
|
|
77
|
+
DropdownMenuLabel,
|
|
78
|
+
DropdownMenuPortal,
|
|
79
|
+
DropdownMenuRadioGroup,
|
|
80
|
+
DropdownMenuRadioItem,
|
|
81
|
+
DropdownMenuRoot,
|
|
82
|
+
DropdownMenuSeparator,
|
|
83
|
+
DropdownMenuSub,
|
|
84
|
+
DropdownMenuSubContent,
|
|
85
|
+
DropdownMenuSubTrigger,
|
|
86
|
+
DropdownMenuTrigger,
|
|
87
|
+
|
|
88
|
+
ContextMenuCheckboxItem,
|
|
89
|
+
ContextMenuContent,
|
|
90
|
+
ContextMenuItem,
|
|
91
|
+
ContextMenuItemIndicator,
|
|
92
|
+
ContextMenuLabel,
|
|
93
|
+
ContextMenuPortal,
|
|
94
|
+
ContextMenuRadioGroup,
|
|
95
|
+
ContextMenuRadioItem,
|
|
96
|
+
ContextMenuRoot,
|
|
97
|
+
ContextMenuSeparator,
|
|
98
|
+
ContextMenuSub,
|
|
99
|
+
ContextMenuSubContent,
|
|
100
|
+
ContextMenuSubTrigger,
|
|
101
|
+
ContextMenuTrigger,
|
|
102
|
+
},
|
|
103
|
+
props: {
|
|
104
|
+
open: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
modal: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false
|
|
111
|
+
},
|
|
112
|
+
placement: {
|
|
113
|
+
type: String as PropType<"start" | "center" | "end">,
|
|
114
|
+
default: 'start'
|
|
115
|
+
},
|
|
116
|
+
transfer: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false
|
|
119
|
+
},
|
|
120
|
+
trigger: {
|
|
121
|
+
type: String as PropType<'click' | 'hover'>,
|
|
122
|
+
default: 'click'
|
|
123
|
+
},
|
|
124
|
+
contextMenu: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: false
|
|
127
|
+
},
|
|
128
|
+
x: {
|
|
129
|
+
type: Number,
|
|
130
|
+
default: 0
|
|
131
|
+
},
|
|
132
|
+
y: {
|
|
133
|
+
type: Number,
|
|
134
|
+
default: 0
|
|
135
|
+
},
|
|
136
|
+
label: {
|
|
137
|
+
default: null,
|
|
138
|
+
static: true
|
|
139
|
+
},
|
|
140
|
+
transitionName: {
|
|
141
|
+
type: String,
|
|
142
|
+
default: 'fade'
|
|
143
|
+
},
|
|
144
|
+
onSelect: {
|
|
145
|
+
type: Function as PropType<(labels: any) => void>,
|
|
146
|
+
default: () => {}
|
|
147
|
+
},
|
|
148
|
+
zIndex: {
|
|
149
|
+
type: Number
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
emits: ['update:open'],
|
|
153
|
+
setup(props, { emit }) {
|
|
154
|
+
const { nextZIndex } = useZIndex();
|
|
155
|
+
const isOpen = ref(props.open);
|
|
156
|
+
const placement = ref(props.placement);
|
|
157
|
+
const wrapper = ref(null);
|
|
158
|
+
const referenceRef = ref<HTMLElement>();
|
|
159
|
+
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
160
|
+
|
|
161
|
+
watch(
|
|
162
|
+
() => props.open,
|
|
163
|
+
value => {
|
|
164
|
+
isOpen.value = value;
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
function toggleDropdown() {
|
|
169
|
+
isOpen.value = !isOpen.value;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
const computedWrapperClasses = computed(() => {
|
|
174
|
+
return [
|
|
175
|
+
'm-dropdown',
|
|
176
|
+
{
|
|
177
|
+
'm-dropdown--open': isOpen.value
|
|
178
|
+
}
|
|
179
|
+
];
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const computedReferenceClasses = computed(() => {});
|
|
183
|
+
|
|
184
|
+
const menuClasses = computed(() => {
|
|
185
|
+
return ['m-dropdown-menu', style.menu];
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const transitionName = computed(() => {
|
|
189
|
+
return `m-transition__${props.transitionName}`;
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
wrapper,
|
|
194
|
+
referenceRef,
|
|
195
|
+
isOpen,
|
|
196
|
+
placement,
|
|
197
|
+
menuClasses,
|
|
198
|
+
computedWrapperClasses,
|
|
199
|
+
computedReferenceClasses,
|
|
200
|
+
transitionName,
|
|
201
|
+
toggleDropdown,
|
|
202
|
+
zIndex,
|
|
203
|
+
scale
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
</script>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
<slot />
|
|
4
|
-
</
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
import { computed, defineComponent } from 'vue';
|
|
9
|
-
import * as style from './style';
|
|
10
|
-
|
|
11
|
-
export default defineComponent({
|
|
12
|
-
name: 'DropdownHeading',
|
|
13
|
-
setup() {
|
|
14
|
-
const computedClasses = computed(() => {
|
|
15
|
-
return [style.heading];
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
computedClasses
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="computedClasses">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { computed, defineComponent } from 'vue';
|
|
9
|
+
import * as style from './style';
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: 'DropdownHeading',
|
|
13
|
+
setup() {
|
|
14
|
+
const computedClasses = computed(() => {
|
|
15
|
+
return [style.heading];
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
computedClasses
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
</script>
|