@teammodlr/ui-kit 2.0.9 → 2.0.10
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/dropdown/Dropdown.vue.d.ts +2 -8
- package/lib/index.cjs.js +4 -4
- package/lib/index.es.js +2498 -2952
- package/package.json +1 -1
- package/src/components/dropdown/Dropdown.vue +24 -21
- package/src/components/dropdown/examples/basic.vue +0 -1
- package/src/components/dropdown/examples/index.stories.ts +5 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<span ref="wrapper" :class="computedWrapperClasses">
|
|
3
3
|
<span ref="referenceRef" :class="computedReferenceClasses" @click="toggleDropdown">
|
|
4
4
|
<slot/>
|
|
5
5
|
</span>
|
|
@@ -7,21 +7,17 @@
|
|
|
7
7
|
<DropdownWrapper>
|
|
8
8
|
<Teleport :disabled="isNested" to="body">
|
|
9
9
|
<transition :name="transitionName">
|
|
10
|
-
<div v-show="isOpen" ref="
|
|
10
|
+
<div v-show="isOpen" ref="popper" :class="menuClasses">
|
|
11
11
|
<slot name="menu"/>
|
|
12
12
|
</div>
|
|
13
13
|
</transition>
|
|
14
14
|
</Teleport>
|
|
15
15
|
</DropdownWrapper>
|
|
16
|
-
</
|
|
16
|
+
</span>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script lang="ts">
|
|
20
|
-
import {
|
|
21
|
-
useFloating, offset,
|
|
22
|
-
flip,
|
|
23
|
-
shift,
|
|
24
|
-
} from '@floating-ui/vue';
|
|
20
|
+
import {usePopper} from '../../composables/usePopper';
|
|
25
21
|
import type {Placement, VirtualElement} from '@popperjs/core';
|
|
26
22
|
import {
|
|
27
23
|
defineComponent,
|
|
@@ -100,13 +96,9 @@ export default defineComponent({
|
|
|
100
96
|
const label = toRef(props, 'label')
|
|
101
97
|
const isOpen = ref(props.open);
|
|
102
98
|
const placement = ref(props.placement);
|
|
99
|
+
const transfer = toRef(props, 'transfer');
|
|
103
100
|
const wrapper = ref(null);
|
|
104
101
|
const referenceRef = ref(null);
|
|
105
|
-
const floating = ref(null);
|
|
106
|
-
const {floatingStyles} = useFloating(referenceRef, floating, {
|
|
107
|
-
placement: placement.value as any,
|
|
108
|
-
middleware: [offset(15), flip()]
|
|
109
|
-
});
|
|
110
102
|
|
|
111
103
|
const reference = computed(() => {
|
|
112
104
|
if (props.virtual !== null) {
|
|
@@ -134,6 +126,15 @@ export default defineComponent({
|
|
|
134
126
|
return referenceRef.value;
|
|
135
127
|
});
|
|
136
128
|
|
|
129
|
+
const {popper, transferTo, updatePopper} = usePopper({
|
|
130
|
+
reference: reference,
|
|
131
|
+
placement,
|
|
132
|
+
transfer,
|
|
133
|
+
wrapper,
|
|
134
|
+
isDrop: true,
|
|
135
|
+
offset: isNested ? [-2, 2] : [0, 5]
|
|
136
|
+
});
|
|
137
|
+
|
|
137
138
|
const currentLabel = useLabel(label, referenceRef)
|
|
138
139
|
|
|
139
140
|
provide("dropdown-select", null);
|
|
@@ -154,6 +155,10 @@ export default defineComponent({
|
|
|
154
155
|
});
|
|
155
156
|
|
|
156
157
|
watch(isOpen, (value) => {
|
|
158
|
+
if (value) {
|
|
159
|
+
updatePopper();
|
|
160
|
+
}
|
|
161
|
+
|
|
157
162
|
emit('update:open', value);
|
|
158
163
|
});
|
|
159
164
|
|
|
@@ -164,11 +169,10 @@ export default defineComponent({
|
|
|
164
169
|
});
|
|
165
170
|
|
|
166
171
|
useEventListener('resize', () => {
|
|
167
|
-
|
|
168
|
-
// TODO: Fix this for floating-ui
|
|
172
|
+
updatePopper();
|
|
169
173
|
});
|
|
170
174
|
|
|
171
|
-
onClickOutside(
|
|
175
|
+
onClickOutside(wrapper, (e) => {
|
|
172
176
|
let parent = e.target as HTMLElement;
|
|
173
177
|
|
|
174
178
|
let i = 0;
|
|
@@ -238,6 +242,8 @@ export default defineComponent({
|
|
|
238
242
|
return {
|
|
239
243
|
wrapper,
|
|
240
244
|
referenceRef,
|
|
245
|
+
popper,
|
|
246
|
+
transferTo,
|
|
241
247
|
isOpen,
|
|
242
248
|
isNested,
|
|
243
249
|
placement,
|
|
@@ -245,11 +251,8 @@ export default defineComponent({
|
|
|
245
251
|
computedWrapperClasses,
|
|
246
252
|
computedReferenceClasses,
|
|
247
253
|
transitionName,
|
|
248
|
-
toggleDropdown
|
|
249
|
-
|
|
250
|
-
floating,
|
|
251
|
-
floatingStyles
|
|
254
|
+
toggleDropdown
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
257
|
})
|
|
255
|
-
</script>
|
|
258
|
+
</script>
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
MDropdownContext,
|
|
9
9
|
MDropdownCustom
|
|
10
10
|
} from './index';
|
|
11
|
-
import {
|
|
11
|
+
import {createStory, popperPositionArgType} from '../../../__storybook__';
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
component: MDropdown,
|
|
@@ -17,7 +17,10 @@ export default {
|
|
|
17
17
|
MDropdownItem,
|
|
18
18
|
MButton
|
|
19
19
|
},
|
|
20
|
-
title: 'Components/Dropdown'
|
|
20
|
+
title: 'Components/Dropdown',
|
|
21
|
+
argTypes: {
|
|
22
|
+
...popperPositionArgType()
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export const Basic = createStory(MDropdownBasic);
|