@teammodlr/ui-kit 2.3.18 → 2.3.21
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/modal/Modal.vue.d.ts +16 -6
- package/lib/components/select/Select.vue.d.ts +9 -0
- package/lib/index.cjs.js +7 -7
- package/lib/index.es.js +1699 -1677
- package/package.json +1 -1
- package/src/components/modal/Modal.vue +53 -54
- package/src/components/modal/examples/index.stories.ts +2 -1
- package/src/components/modal/examples/index.ts +1 -0
- package/src/components/modal/examples/open-prop.vue +50 -0
- package/src/components/select/Select.vue +9 -3
package/package.json
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport :to="'body'">
|
|
3
|
-
<TransitionGroup
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:leave-to-class="fade.leaveTo">
|
|
9
|
-
<div
|
|
10
|
-
:class="style.mask"
|
|
11
|
-
:style="{ zIndex: zIndex }"
|
|
12
|
-
v-if="isOpen"></div>
|
|
13
|
-
<div
|
|
14
|
-
tabIndex="-1"
|
|
15
|
-
v-if="isOpen"
|
|
16
|
-
@keydown="onWrapperKeyDown"
|
|
17
|
-
ref="wrapperRef"
|
|
18
|
-
role="dialog"
|
|
19
|
-
:class="computedWrapperClasses"
|
|
20
|
-
:style="computedWrapperStyles"
|
|
21
|
-
@click="onOutsideClick">
|
|
3
|
+
<TransitionGroup type="animation" :enter-active-class="fade.enterActive" :leave-active-class="fade.leaveActive"
|
|
4
|
+
:enter-from-class="fade.enterFrom" :leave-to-class="fade.leaveTo">
|
|
5
|
+
<div :class="style.mask" :style="{ zIndex: zIndex }" v-if="isOpen"></div>
|
|
6
|
+
<div tabIndex="-1" v-if="isOpen" @keydown="onWrapperKeyDown" ref="wrapperRef" role="dialog"
|
|
7
|
+
:class="computedWrapperClasses" :style="computedWrapperStyles" @click="onOutsideClick">
|
|
22
8
|
<!-- <Transition-->
|
|
23
9
|
<!-- type="animation"-->
|
|
24
10
|
<!-- :enter-active-class="modalScale.enterActive"-->
|
|
25
11
|
<!-- :leave-active-class="modalScale.leaveActive"-->
|
|
26
12
|
<!-- :enter-from-class="modalScale.enterFrom"-->
|
|
27
13
|
<!-- :leave-to-class="modalScale.leaveTo">-->
|
|
28
|
-
<div
|
|
29
|
-
:class="
|
|
30
|
-
role="document"
|
|
31
|
-
v-bind="$attrs"
|
|
32
|
-
:style="contentStyleRef">
|
|
33
|
-
<div
|
|
34
|
-
:class="computedContainerClasses"
|
|
35
|
-
@mousedown="onContentMouseDown"
|
|
36
|
-
@mouseup="onContentMouseUp"
|
|
14
|
+
<div :class="computedModalClasses" role="document" v-bind="$attrs" :style="contentStyleRef">
|
|
15
|
+
<div :class="computedContainerClasses" @mousedown="onContentMouseDown" @mouseup="onContentMouseUp"
|
|
37
16
|
ref="target">
|
|
38
17
|
<template v-if="loading">
|
|
39
18
|
<slot name="loading"> Loading...</slot>
|
|
@@ -43,17 +22,12 @@
|
|
|
43
22
|
<slot name="sidebar"></slot>
|
|
44
23
|
</div>
|
|
45
24
|
<div :class="style.content">
|
|
46
|
-
<div
|
|
47
|
-
v-if="title || showClose"
|
|
48
|
-
:class="style.header">
|
|
25
|
+
<div v-if="title || showClose" :class="style.header">
|
|
49
26
|
<div :class="style.title" v-if="title">
|
|
50
27
|
<div>{{ title }}</div>
|
|
51
28
|
</div>
|
|
52
29
|
</div>
|
|
53
|
-
<button
|
|
54
|
-
v-if="showClose"
|
|
55
|
-
:class="style.close"
|
|
56
|
-
@click="close"></button>
|
|
30
|
+
<button v-if="showClose" :class="style.close" @click="close"></button>
|
|
57
31
|
<div :class="style.body">
|
|
58
32
|
<slot name="body"></slot>
|
|
59
33
|
<slot></slot>
|
|
@@ -88,6 +62,10 @@ import { useZIndex } from '../../composables/useZIndex';
|
|
|
88
62
|
export default defineComponent({
|
|
89
63
|
name: 'MModal',
|
|
90
64
|
props: {
|
|
65
|
+
open: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: undefined
|
|
68
|
+
},
|
|
91
69
|
title: {
|
|
92
70
|
type: String,
|
|
93
71
|
default: ''
|
|
@@ -110,8 +88,8 @@ export default defineComponent({
|
|
|
110
88
|
default: true
|
|
111
89
|
},
|
|
112
90
|
onClose: {
|
|
113
|
-
type: Function as PropType<(e: MouseEvent | KeyboardEvent) => void>,
|
|
114
|
-
default: () => {}
|
|
91
|
+
type: Function as PropType<(e: MouseEvent | KeyboardEvent | undefined) => void>,
|
|
92
|
+
default: () => { }
|
|
115
93
|
},
|
|
116
94
|
zIndex: {
|
|
117
95
|
type: Number
|
|
@@ -130,10 +108,10 @@ export default defineComponent({
|
|
|
130
108
|
default: true
|
|
131
109
|
}
|
|
132
110
|
},
|
|
133
|
-
emits: ['open'],
|
|
111
|
+
emits: ['open', 'update:open'],
|
|
134
112
|
setup(props, { emit, slots }) {
|
|
135
113
|
const { nextZIndex } = useZIndex();
|
|
136
|
-
|
|
114
|
+
|
|
137
115
|
const target = ref();
|
|
138
116
|
const wrapperRef = shallowRef<HTMLDivElement>();
|
|
139
117
|
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
@@ -141,6 +119,26 @@ export default defineComponent({
|
|
|
141
119
|
const hasFooter = computed(() => !!slots.footer);
|
|
142
120
|
const transformOrigin = ref<string>();
|
|
143
121
|
|
|
122
|
+
const internalOpen = ref(false);
|
|
123
|
+
|
|
124
|
+
const isOpen = computed({
|
|
125
|
+
get: () => {
|
|
126
|
+
// If open prop is explicitly provided (v-model), use it
|
|
127
|
+
if (props.open !== undefined) {
|
|
128
|
+
return props.open;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return internalOpen.value;
|
|
132
|
+
},
|
|
133
|
+
set: (value: boolean) => {
|
|
134
|
+
if (props.open !== undefined) {
|
|
135
|
+
emit('update:open', value);
|
|
136
|
+
} else {
|
|
137
|
+
internalOpen.value = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
144
142
|
const contentStyleRef = computed(() => {
|
|
145
143
|
const { width, height } = props;
|
|
146
144
|
const contentStyle: CSSProperties = {};
|
|
@@ -230,7 +228,7 @@ export default defineComponent({
|
|
|
230
228
|
}
|
|
231
229
|
};
|
|
232
230
|
|
|
233
|
-
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
231
|
+
const close = (e: MouseEvent | KeyboardEvent | undefined) => {
|
|
234
232
|
props.onClose?.(e);
|
|
235
233
|
ownerScrollbarClose();
|
|
236
234
|
isOpen.value = false;
|
|
@@ -267,20 +265,21 @@ export default defineComponent({
|
|
|
267
265
|
}, 250);
|
|
268
266
|
}
|
|
269
267
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
268
|
+
watch(
|
|
269
|
+
() => isOpen.value,
|
|
270
|
+
(newValue, oldValue) => {
|
|
271
|
+
if (newValue && !oldValue) {
|
|
272
|
+
// Opening
|
|
273
|
+
ownerScrollbarOpen();
|
|
274
|
+
zIndex.value = props.zIndex ?? nextZIndex();
|
|
275
|
+
emit('open');
|
|
276
|
+
} else if (!newValue && oldValue) {
|
|
277
|
+
// Closing
|
|
278
|
+
ownerScrollbarClose();
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{ immediate: true }
|
|
282
|
+
);
|
|
284
283
|
|
|
285
284
|
return {
|
|
286
285
|
close,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MModal from '../Modal.vue';
|
|
2
|
-
import { MModalBasic, MModalForm, MModalSidebar } from './index';
|
|
2
|
+
import { MModalBasic, MModalForm, MModalSidebar, MModalOpenProp } from './index';
|
|
3
3
|
|
|
4
4
|
import { createStory, sizeArgType } from '../../../__storybook__';
|
|
5
5
|
|
|
@@ -14,3 +14,4 @@ export default {
|
|
|
14
14
|
export const Basic = createStory(MModalBasic);
|
|
15
15
|
export const ModalForm = createStory(MModalForm);
|
|
16
16
|
export const ModalSidebar = createStory(MModalSidebar);
|
|
17
|
+
export const OpenProp = createStory(MModalOpenProp);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MModal
|
|
3
|
+
v-model:open="isOpen"
|
|
4
|
+
ref="modal"
|
|
5
|
+
title="I am a modal"
|
|
6
|
+
class="fine-me"
|
|
7
|
+
wrap-class-name="hello-world">
|
|
8
|
+
<template #body>
|
|
9
|
+
<div>
|
|
10
|
+
<MInput />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
<template #footer>
|
|
14
|
+
<div style="display: flex; flex-grow: 1; justify-content: end">
|
|
15
|
+
<MButton variant="primary" @click="isOpen = false">
|
|
16
|
+
Okay
|
|
17
|
+
</MButton>
|
|
18
|
+
<MButton style="margin-left: 8px" @click="isOpen = false">
|
|
19
|
+
Cancel
|
|
20
|
+
</MButton>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
</MModal>
|
|
24
|
+
|
|
25
|
+
<div style="position: relative; width: 100%; height: 1000px">
|
|
26
|
+
<button
|
|
27
|
+
@click="open"
|
|
28
|
+
style="
|
|
29
|
+
position: absolute;
|
|
30
|
+
width: 100px;
|
|
31
|
+
height: 50px;
|
|
32
|
+
top: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
">
|
|
35
|
+
Top Left
|
|
36
|
+
</button>
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script lang="ts" setup>
|
|
42
|
+
import { ref } from 'vue';
|
|
43
|
+
|
|
44
|
+
const isOpen = ref(false)
|
|
45
|
+
const modal = ref<any>(null)
|
|
46
|
+
|
|
47
|
+
const open = (event: MouseEvent) => {
|
|
48
|
+
isOpen.value = true
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<Transition :enter-active-class="scale.enterActive" :leave-active-class="scale.leaveActive"
|
|
39
39
|
:enter-from-class="scale.enterFrom" :leave-to-class="scale.leaveTo">
|
|
40
40
|
<div :class="style.menu" v-if="isOpen" ref="popper" :style="computedConsistentWidth"
|
|
41
|
-
:aria-hidden="isOpen ? 'false' : 'true'">
|
|
41
|
+
:aria-hidden="isOpen ? 'false' : 'true'" :data-element="`select-menu-overlay-${id}`">
|
|
42
42
|
<div v-if="searchable || (multiple && selectAll)" :class="style.search">
|
|
43
43
|
<div v-if="multiple && selectAll" :class="style.checkAll">
|
|
44
44
|
<button role="button" type="button" :class="{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</button>
|
|
62
62
|
</div>
|
|
63
63
|
<input v-if="searchable" type="text" ref="searchRef" v-model="search" placeholder="Search"
|
|
64
|
-
:class="style.searchInput" />
|
|
64
|
+
:class="style.searchInput" :data-input="`select-menu-search-${id}`" />
|
|
65
65
|
</div>
|
|
66
66
|
<div :class="style.options">
|
|
67
67
|
<div v-for="(option, index) in computedOptions" :key="index" ref="optionsRef" :class="{
|
|
@@ -69,7 +69,9 @@
|
|
|
69
69
|
[style.optionSelected]: option.active,
|
|
70
70
|
[style.optionFocused]:
|
|
71
71
|
selectedIndex === index
|
|
72
|
-
}" @click.prevent="option.onClick" @hover="selectedIndex = index"
|
|
72
|
+
}" @click.prevent="option.onClick" @hover="selectedIndex = index"
|
|
73
|
+
:data-element="`select-menu-option-${id}-${option.value}`"
|
|
74
|
+
>
|
|
73
75
|
<span :class="style.optionIcon">
|
|
74
76
|
<svg v-if="option.active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
|
|
75
77
|
fill="currentColor" aria-hidden="true">
|
|
@@ -195,6 +197,10 @@ export default defineComponent({
|
|
|
195
197
|
zIndex: {
|
|
196
198
|
type: Number
|
|
197
199
|
},
|
|
200
|
+
showDataOptions: {
|
|
201
|
+
type: Boolean,
|
|
202
|
+
default: true
|
|
203
|
+
},
|
|
198
204
|
'onUpdate:value': [Function, Array] as PropType<MaybeArray<OnUpdateValue> | undefined>,
|
|
199
205
|
onUpdateValue: [Function, Array] as PropType<MaybeArray<OnUpdateValue> | undefined>,
|
|
200
206
|
},
|