@teammodlr/ui-kit 1.0.7 → 2.0.0
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/__storybook__/argTypes.d.ts +10 -1
- package/lib/components/avatar/Avatar.vue.d.ts +16 -30
- package/lib/components/avatar/style/Avatar.css.d.ts +9 -0
- package/lib/components/avatar/style/index.d.ts +1 -0
- package/lib/components/avatargroup/AvatarGroup.vue.d.ts +28 -13
- package/lib/components/avatargroup/style/AvatarGroup.css.d.ts +2 -0
- package/lib/components/avatargroup/style/index.d.ts +1 -0
- package/lib/components/avatargroup/symbol.d.ts +13 -0
- package/lib/components/badge/Badge.vue.d.ts +30 -0
- package/lib/components/badge/style/Badge.css.d.ts +4 -0
- package/lib/components/badge/style/index.d.ts +1 -0
- package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +12 -3
- package/lib/components/{breadcrumbitem → breadcrumb}/BreadcrumbItem.vue.d.ts +11 -0
- package/lib/components/breadcrumb/style/Breadcrumb.css.d.ts +4 -0
- package/lib/components/breadcrumb/style/index.d.ts +1 -0
- package/lib/components/breadcrumb/symbol.d.ts +13 -0
- package/lib/components/button/Button.vue.d.ts +39 -28
- package/lib/components/button/style/Button.css.d.ts +24 -0
- package/lib/components/button/style/index.d.ts +1 -0
- package/lib/components/buttongroup/ButtonGroup.vue.d.ts +2 -13
- package/lib/components/buttongroup/style/ButtonGroup.css.d.ts +2 -0
- package/lib/components/buttongroup/style/index.d.ts +1 -0
- package/lib/components/buttongroup/symbol.d.ts +6 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +17 -20
- package/lib/components/checkbox/style/Checkbox.css.d.ts +16 -0
- package/lib/components/checkbox/style/index.d.ts +1 -0
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +75 -0
- package/lib/components/colorpicker/style/ColorPicker.css.d.ts +9 -0
- package/lib/components/colorpicker/style/index.d.ts +1 -0
- package/lib/components/colorpicker/utils.d.ts +16 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +5 -4
- package/lib/components/dropdown/DropdownItem.vue.d.ts +12 -5
- package/lib/components/dropdown/DropdownList.vue.d.ts +4 -1
- package/lib/components/dropdown/style/Dropdown.css.d.ts +5 -0
- package/lib/components/dropdown/style/index.d.ts +1 -0
- package/lib/components/dropdown/symbol.d.ts +6 -0
- package/lib/components/index.d.ts +10 -1
- package/lib/components/input/Input.vue.d.ts +35 -19
- package/lib/components/input/style/Input.css.d.ts +23 -0
- package/lib/components/input/style/index.d.ts +1 -0
- package/lib/components/link/Link.vue.d.ts +2 -2
- package/lib/components/messageprovider/Message.vue.d.ts +13 -1
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +6 -5
- package/lib/components/messageprovider/style/Message.css.d.ts +12 -0
- package/lib/components/messageprovider/style/index.d.ts +1 -0
- package/lib/components/messageprovider/types.d.ts +2 -1
- package/lib/components/modal/Modal.vue.d.ts +52 -0
- package/lib/components/modal/style/Modal.css.d.ts +21 -0
- package/lib/components/modal/style/index.d.ts +1 -0
- package/lib/components/radio/Radio.vue.d.ts +85 -0
- package/lib/components/radio/style/Checkbox.css.d.ts +16 -0
- package/lib/components/radio/style/index.d.ts +1 -0
- package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -0
- package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -0
- package/lib/components/radiobutton/style/index.d.ts +1 -0
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -0
- package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -0
- package/lib/components/radiobuttongroup/style/index.d.ts +1 -0
- package/lib/components/radiobuttongroup/symbol.d.ts +9 -0
- package/lib/components/select/Select.vue.d.ts +22 -13
- package/lib/components/select/style/Select.css.d.ts +30 -0
- package/lib/components/select/style/index.d.ts +1 -0
- package/lib/components/skeleton/Skeleton.vue.d.ts +15 -21
- package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -0
- package/lib/components/skeleton/style/index.d.ts +2 -0
- package/lib/components/slider/Slider.vue.d.ts +32 -0
- package/lib/components/slider/style/Slider.css.d.ts +4 -0
- package/lib/components/slider/style/index.d.ts +1 -0
- package/lib/components/tab/TabGroup.vue.d.ts +1 -1
- package/lib/components/table/Table.vue.d.ts +1 -1
- package/lib/components/tag/Tag.vue.d.ts +44 -0
- package/lib/components/tag/style/Tag.css.d.ts +11 -0
- package/lib/components/tag/style/index.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.vue.d.ts +17 -2
- package/lib/components/tooltip/style/Tooltip.css.d.ts +6 -0
- package/lib/components/tooltip/style/index.d.ts +1 -0
- package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +46 -16
- package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -0
- package/lib/components/virtualscroll/style/index.d.ts +1 -0
- package/lib/composables/useInput.d.ts +1 -1
- package/lib/composables/useInteractive.d.ts +15 -0
- package/lib/composables/useZIndex.d.ts +8 -0
- package/lib/index.cjs.js +8 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.es.js +3688 -1692
- package/lib/style.css +1 -1
- package/lib/styles/theme.css.d.ts +147 -0
- package/lib/styles/typography.css.d.ts +22 -0
- package/lib/types/props.d.ts +1 -0
- package/package.json +33 -26
- package/src/__storybook__/argTypes.ts +19 -1
- package/src/components/avatar/Avatar.vue +33 -26
- package/src/components/avatar/examples/index.stories.ts +1 -1
- package/src/components/avatar/style/Avatar.css.ts +92 -0
- package/src/components/avatar/style/index.ts +1 -0
- package/src/components/avatargroup/AvatarGroup.vue +71 -32
- package/src/components/avatargroup/examples/basic.vue +33 -7
- package/src/components/avatargroup/examples/index.stories.ts +4 -8
- package/src/components/avatargroup/style/AvatarGroup.css.ts +21 -0
- package/src/components/avatargroup/style/index.ts +1 -0
- package/src/components/avatargroup/symbol.ts +17 -0
- package/src/components/badge/Badge.css +128 -0
- package/src/components/badge/Badge.vue +43 -0
- package/src/components/badge/examples/basic.vue +10 -0
- package/src/components/badge/examples/index.stories.ts +21 -0
- package/src/components/badge/examples/index.ts +1 -0
- package/src/components/badge/style/Badge.css.ts +124 -0
- package/src/components/badge/style/index.ts +1 -0
- package/src/components/breadcrumb/Breadcrumb.vue +22 -15
- package/src/components/breadcrumb/BreadcrumbItem.vue +73 -0
- package/src/components/breadcrumb/examples/basic.vue +5 -7
- package/src/components/breadcrumb/examples/index.stories.ts +2 -2
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -0
- package/src/components/breadcrumb/style/index.ts +1 -0
- package/src/components/breadcrumb/symbol.ts +17 -0
- package/src/components/button/Button.vue +194 -107
- package/src/components/button/examples/icon-left.vue +12 -0
- package/src/components/button/examples/icon.vue +6 -7
- package/src/components/button/examples/index.stories.ts +9 -7
- package/src/components/button/examples/index.ts +3 -2
- package/src/components/button/examples/variants-secondary.vue +8 -0
- package/src/components/button/examples/variants.vue +8 -0
- package/src/components/button/style/Button.css.ts +585 -0
- package/src/components/button/style/index.ts +1 -0
- package/src/components/buttongroup/ButtonGroup.vue +36 -47
- package/src/components/buttongroup/examples/basic.vue +2 -2
- package/src/components/buttongroup/examples/icon-group.vue +22 -0
- package/src/components/buttongroup/examples/index.stories.ts +4 -2
- package/src/components/buttongroup/examples/index.ts +1 -0
- package/src/components/buttongroup/style/ButtonGroup.css.ts +40 -0
- package/src/components/buttongroup/style/index.ts +1 -0
- package/src/components/buttongroup/symbol.ts +8 -0
- package/src/components/checkbox/Checkbox.vue +70 -54
- package/src/components/checkbox/examples/index.stories.ts +1 -1
- package/src/components/checkbox/style/Checkbox.css.ts +127 -0
- package/src/components/checkbox/style/index.ts +1 -0
- package/src/components/colorpicker/ColorPicker.vue +283 -0
- package/src/components/colorpicker/examples/basic.vue +3 -0
- package/src/components/colorpicker/examples/index.stories.ts +17 -0
- package/src/components/colorpicker/examples/index.ts +1 -0
- package/src/components/colorpicker/style/ColorPicker.css.ts +97 -0
- package/src/components/colorpicker/style/index.ts +1 -0
- package/src/components/colorpicker/utils.ts +188 -0
- package/src/components/dropdown/Dropdown.vue +45 -24
- package/src/components/dropdown/DropdownItem.vue +121 -118
- package/src/components/dropdown/DropdownList.vue +3 -3
- package/src/components/dropdown/DropdownWrapper.vue +2 -1
- package/src/components/dropdown/examples/custom.vue +13 -0
- package/src/components/dropdown/examples/index.stories.ts +4 -2
- package/src/components/dropdown/examples/index.ts +1 -0
- package/src/components/dropdown/style/Dropdown.css.ts +48 -0
- package/src/components/dropdown/style/index.ts +1 -0
- package/src/components/dropdown/symbol.ts +8 -0
- package/src/components/form/examples/basic.vue +4 -2
- package/src/components/form/examples/index.stories.ts +4 -2
- package/src/components/image/examples/index.stories.ts +1 -1
- package/src/components/index.ts +10 -2
- package/src/components/input/Input.vue +84 -42
- package/src/components/input/examples/basic.vue +2 -1
- package/src/components/input/examples/index.stories.ts +1 -1
- package/src/components/input/examples/prefix.vue +4 -2
- package/src/components/input/examples/suffix.vue +4 -2
- package/src/components/input/style/Input.css.ts +221 -0
- package/src/components/input/style/index.ts +1 -0
- package/src/components/link/examples/index.stories.ts +1 -1
- package/src/components/messageprovider/Message.vue +52 -5
- package/src/components/messageprovider/MessageProvider.css +0 -13
- package/src/components/messageprovider/MessageProvider.vue +18 -16
- package/src/components/messageprovider/examples/basic.vue +56 -5
- package/src/components/messageprovider/examples/index.stories.ts +0 -1
- package/src/components/messageprovider/examples/index.ts +1 -0
- package/src/components/messageprovider/examples/update.vue +34 -0
- package/src/components/messageprovider/examples/wrapper.vue +1 -1
- package/src/components/messageprovider/style/Message.css.ts +109 -0
- package/src/components/messageprovider/style/index.ts +1 -0
- package/src/components/messageprovider/types.ts +9 -1
- package/src/components/modal/Modal.vue +126 -0
- package/src/components/modal/examples/basic.vue +40 -0
- package/src/components/modal/examples/index.stories.ts +20 -0
- package/src/components/modal/examples/index.ts +2 -0
- package/src/components/modal/examples/modal-form.vue +99 -0
- package/src/components/modal/style/Modal.css.ts +257 -0
- package/src/components/modal/style/index.ts +1 -0
- package/src/components/radio/Checkbox.css +185 -0
- package/src/components/radio/Radio.vue +137 -0
- package/src/components/radio/examples/basic.vue +9 -0
- package/src/components/radio/examples/index.stories.ts +19 -0
- package/src/components/radio/examples/index.ts +2 -0
- package/src/components/radio/style/Checkbox.css.ts +132 -0
- package/src/components/radio/style/index.ts +1 -0
- package/src/components/radiobutton/RadioButton.vue +131 -0
- package/src/components/radiobutton/style/RadioButton.css.ts +185 -0
- package/src/components/radiobutton/style/index.ts +1 -0
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +75 -0
- package/src/components/radiobuttongroup/examples/basic.vue +17 -0
- package/src/components/radiobuttongroup/examples/index.stories.ts +22 -0
- package/src/components/radiobuttongroup/examples/index.ts +2 -0
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -0
- package/src/components/radiobuttongroup/style/index.ts +1 -0
- package/src/components/radiobuttongroup/symbol.ts +11 -0
- package/src/components/select/Select.css +0 -226
- package/src/components/select/Select.vue +116 -48
- package/src/components/select/examples/index.stories.ts +1 -1
- package/src/components/select/examples/multiple.vue +1 -2
- package/src/components/select/style/Select.css.ts +254 -0
- package/src/components/select/style/index.ts +1 -0
- package/src/components/skeleton/Skeleton.vue +55 -47
- package/src/components/skeleton/examples/index.stories.ts +1 -8
- package/src/components/skeleton/style/Skeleton.css.ts +57 -0
- package/src/components/skeleton/style/index.ts +2 -0
- package/src/components/slider/Slider.vue +76 -0
- package/src/components/slider/style/Slider.css.ts +43 -0
- package/src/components/slider/style/index.ts +1 -0
- package/src/components/tab/examples/index.stories.ts +1 -1
- package/src/components/table/examples/index.stories.ts +1 -1
- package/src/components/tag/Tag.css +0 -0
- package/src/components/tag/Tag.vue +66 -0
- package/src/components/tag/examples/basic.vue +5 -0
- package/src/components/tag/examples/index.stories.ts +22 -0
- package/src/components/tag/examples/index.ts +1 -0
- package/src/components/tag/style/Tag.css.ts +79 -0
- package/src/components/tag/style/index.ts +1 -0
- package/src/components/tooltip/Tooltip.css +0 -6
- package/src/components/tooltip/Tooltip.vue +53 -22
- package/src/components/tooltip/examples/basic.vue +2 -5
- package/src/components/tooltip/examples/index.stories.ts +1 -1
- package/src/components/tooltip/style/Tooltip.css.ts +48 -0
- package/src/components/tooltip/style/index.ts +1 -0
- package/src/components/virtualscroll/VirtualScroll.vue +159 -53
- package/src/components/virtualscroll/examples/basic.vue +21 -27
- package/src/components/virtualscroll/examples/index.stories.ts +2 -18
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +18 -0
- package/src/components/virtualscroll/style/index.ts +1 -0
- package/src/composables/useInput.ts +2 -2
- package/src/composables/useInteractive.ts +20 -0
- package/src/composables/usePopper.ts +1 -1
- package/src/composables/useZIndex.ts +31 -0
- package/src/css/components.css +4 -3
- package/src/css/normalize.css +0 -379
- package/src/css/variables.css +2 -2
- package/src/examples/cards/cards.stories.ts +9 -0
- package/src/examples/cards/sidebar.vue +263 -0
- package/src/index.ts +1 -1
- package/src/styles/theme.css.ts +149 -0
- package/src/styles/typography.css.ts +91 -0
- package/src/types/props.ts +2 -0
- package/lib/components/breadcrumbitem/index.d.ts +0 -1
- package/src/components/avatar/Avatar.css +0 -69
- package/src/components/breadcrumbitem/BreadcrumbItem.vue +0 -66
- package/src/components/breadcrumbitem/index.ts +0 -1
- package/src/components/button/examples/colors-secondary.vue +0 -8
- package/src/components/button/examples/colors.vue +0 -8
- package/src/components/dropdown/Dropdown.css +0 -68
- /package/src/components/button/{Button.css → Button-old.css} +0 -0
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="wrapper" :class="computedWrapperClasses">
|
|
3
3
|
<div ref="referenceRef" :class="computedReferenceClasses" @click="toggleDropdown">
|
|
4
|
-
<slot
|
|
4
|
+
<slot/>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<DropdownWrapper>
|
|
8
8
|
<Teleport :disabled="isNested" to="body">
|
|
9
9
|
<transition :name="transitionName">
|
|
10
|
-
<div v-show="isOpen" ref="popper" :class="
|
|
11
|
-
|
|
12
|
-
`m-dropdown-menu--${placement}`
|
|
13
|
-
]">
|
|
14
|
-
<slot name="menu" />
|
|
10
|
+
<div v-show="isOpen" ref="popper" :class="menuClasses">
|
|
11
|
+
<slot name="menu"/>
|
|
15
12
|
</div>
|
|
16
13
|
</transition>
|
|
17
14
|
</Teleport>
|
|
@@ -20,12 +17,26 @@
|
|
|
20
17
|
</template>
|
|
21
18
|
|
|
22
19
|
<script lang="ts">
|
|
23
|
-
import {
|
|
24
|
-
import type {
|
|
25
|
-
import {
|
|
26
|
-
|
|
20
|
+
import {usePopper} from '../../composables/usePopper';
|
|
21
|
+
import type {Placement, VirtualElement} from '@popperjs/core';
|
|
22
|
+
import {
|
|
23
|
+
defineComponent,
|
|
24
|
+
inject,
|
|
25
|
+
ref,
|
|
26
|
+
type PropType,
|
|
27
|
+
provide,
|
|
28
|
+
watch,
|
|
29
|
+
onMounted,
|
|
30
|
+
nextTick,
|
|
31
|
+
computed,
|
|
32
|
+
toRef, reactive
|
|
33
|
+
} from 'vue';
|
|
34
|
+
import {onClickOutside, useEventListener} from '@vueuse/core';
|
|
27
35
|
import DropdownWrapper from './DropdownWrapper.vue';
|
|
28
|
-
import {
|
|
36
|
+
import {useLabel} from './hooks';
|
|
37
|
+
import type {DropdownState} from "./symbol";
|
|
38
|
+
import {DROPDOWN_STATE} from "./symbol";
|
|
39
|
+
import * as style from "./style";
|
|
29
40
|
|
|
30
41
|
export default defineComponent({
|
|
31
42
|
name: 'Dropdown',
|
|
@@ -71,16 +82,17 @@ export default defineComponent({
|
|
|
71
82
|
},
|
|
72
83
|
onSelect: {
|
|
73
84
|
type: Function as PropType<(labels: any) => void>,
|
|
74
|
-
default: () => {
|
|
85
|
+
default: () => {
|
|
86
|
+
}
|
|
75
87
|
}
|
|
76
88
|
},
|
|
77
89
|
emits: [
|
|
78
90
|
'update:open'
|
|
79
91
|
],
|
|
80
|
-
setup(props, {
|
|
81
|
-
const
|
|
92
|
+
setup(props, {emit}) {
|
|
93
|
+
const parentState = inject(DROPDOWN_STATE, null);
|
|
82
94
|
|
|
83
|
-
const isNested = !!
|
|
95
|
+
const isNested = !!parentState;
|
|
84
96
|
const label = toRef(props, 'label')
|
|
85
97
|
const isOpen = ref(props.open);
|
|
86
98
|
const placement = ref(props.placement);
|
|
@@ -114,22 +126,25 @@ export default defineComponent({
|
|
|
114
126
|
return referenceRef.value;
|
|
115
127
|
});
|
|
116
128
|
|
|
117
|
-
const {
|
|
129
|
+
const {popper, transferTo, updatePopper} = usePopper({
|
|
118
130
|
reference: reference,
|
|
119
131
|
placement,
|
|
120
132
|
transfer,
|
|
121
133
|
wrapper,
|
|
122
134
|
isDrop: true,
|
|
123
|
-
offset: isNested ? [-2, 2] :
|
|
135
|
+
offset: isNested ? [-2, 2] : [0, 5]
|
|
124
136
|
});
|
|
125
137
|
|
|
126
138
|
const currentLabel = useLabel(label, referenceRef)
|
|
127
139
|
|
|
128
140
|
provide("dropdown-select", null);
|
|
129
|
-
|
|
130
|
-
|
|
141
|
+
|
|
142
|
+
const startState: DropdownState = reactive({
|
|
143
|
+
handleSelect: handleSelect,
|
|
131
144
|
isOpen: isOpen,
|
|
132
|
-
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
provide(DROPDOWN_STATE, startState);
|
|
133
148
|
|
|
134
149
|
watch(() => props.open, (value) => {
|
|
135
150
|
isOpen.value = value;
|
|
@@ -160,7 +175,6 @@ export default defineComponent({
|
|
|
160
175
|
onClickOutside(wrapper, (e) => {
|
|
161
176
|
let parent = e.target as HTMLElement;
|
|
162
177
|
|
|
163
|
-
// fail safe of 10
|
|
164
178
|
let i = 0;
|
|
165
179
|
while (parent) {
|
|
166
180
|
if (parent.classList.contains('m-dropdown-menu')) {
|
|
@@ -194,10 +208,9 @@ export default defineComponent({
|
|
|
194
208
|
function handleSelect(labels: string[]) {
|
|
195
209
|
isOpen.value = false;
|
|
196
210
|
props.onSelect(labels);
|
|
197
|
-
|
|
198
|
-
if (typeof state?.handleSelect === 'function') {
|
|
211
|
+
if (typeof parentState?.handleSelect === 'function') {
|
|
199
212
|
// @ts-ignore
|
|
200
|
-
|
|
213
|
+
parentState.handleSelect([currentLabel.value!, ...labels]);
|
|
201
214
|
}
|
|
202
215
|
}
|
|
203
216
|
|
|
@@ -215,6 +228,13 @@ export default defineComponent({
|
|
|
215
228
|
|
|
216
229
|
});
|
|
217
230
|
|
|
231
|
+
const menuClasses = computed(() => {
|
|
232
|
+
return [
|
|
233
|
+
'm-dropdown-menu',
|
|
234
|
+
style.menu
|
|
235
|
+
]
|
|
236
|
+
})
|
|
237
|
+
|
|
218
238
|
const transitionName = computed(() => {
|
|
219
239
|
return `m-transition__${props.transitionName}`;
|
|
220
240
|
});
|
|
@@ -227,6 +247,7 @@ export default defineComponent({
|
|
|
227
247
|
isOpen,
|
|
228
248
|
isNested,
|
|
229
249
|
placement,
|
|
250
|
+
menuClasses,
|
|
230
251
|
computedWrapperClasses,
|
|
231
252
|
computedReferenceClasses,
|
|
232
253
|
transitionName,
|
|
@@ -1,118 +1,121 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<li ref="wrapper" :class="computedWrapperClasses" role="menuitem" tabindex="0" @click="handleSelect">
|
|
3
|
-
<div v-if="hasIconLeft" class="
|
|
4
|
-
<slot name="icon-left" />
|
|
5
|
-
</div>
|
|
6
|
-
<div class="
|
|
7
|
-
<slot />
|
|
8
|
-
</div>
|
|
9
|
-
<!-- <div v-if="hotkey" class="m-dropdown__hotkeys">
|
|
10
|
-
<template v-for="key in hotkey.split('+')">
|
|
11
|
-
<kbd>{{ key }}</kbd>
|
|
12
|
-
</template>
|
|
13
|
-
</div> -->
|
|
14
|
-
<div v-if="hasIconRight" class="
|
|
15
|
-
<slot name="icon-right" />
|
|
16
|
-
</div>
|
|
17
|
-
</li>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
import { defineComponent, inject,
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
export default defineComponent({
|
|
26
|
-
name: "DropdownItem",
|
|
27
|
-
props: {
|
|
28
|
-
label: {
|
|
29
|
-
type: [String, Number],
|
|
30
|
-
default: null
|
|
31
|
-
},
|
|
32
|
-
disabled: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: false
|
|
35
|
-
},
|
|
36
|
-
reference: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false
|
|
39
|
-
},
|
|
40
|
-
onSelect: {
|
|
41
|
-
type: Function as PropType<(label: string | number) => void>,
|
|
42
|
-
default: () => { }
|
|
43
|
-
},
|
|
44
|
-
hotkey: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: null
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
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
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<li ref="wrapper" :class="computedWrapperClasses" role="menuitem" tabindex="0" @click="handleSelect">
|
|
3
|
+
<div v-if="hasIconLeft" :class="style.menuItemIcon">
|
|
4
|
+
<slot name="icon-left" />
|
|
5
|
+
</div>
|
|
6
|
+
<div :class="style.menuItemText">
|
|
7
|
+
<slot />
|
|
8
|
+
</div>
|
|
9
|
+
<!-- <div v-if="hotkey" class="m-dropdown__hotkeys">
|
|
10
|
+
<template v-for="key in hotkey.split('+')">
|
|
11
|
+
<kbd>{{ key }}</kbd>
|
|
12
|
+
</template>
|
|
13
|
+
</div> -->
|
|
14
|
+
<div v-if="hasIconRight" :class="style.menuItemIcon">
|
|
15
|
+
<slot name="icon-right" />
|
|
16
|
+
</div>
|
|
17
|
+
</li>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import {computed, defineComponent, inject, type PropType, ref, toRef} from 'vue';
|
|
22
|
+
import {useLabel} from './hooks';
|
|
23
|
+
import * as style from "./style";
|
|
24
|
+
|
|
25
|
+
export default defineComponent({
|
|
26
|
+
name: "DropdownItem",
|
|
27
|
+
props: {
|
|
28
|
+
label: {
|
|
29
|
+
type: [String, Number],
|
|
30
|
+
default: null
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
reference: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
onSelect: {
|
|
41
|
+
type: Function as PropType<(label: string | number) => void>,
|
|
42
|
+
default: () => { }
|
|
43
|
+
},
|
|
44
|
+
hotkey: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: null
|
|
47
|
+
},
|
|
48
|
+
description: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: null
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
emits: [],
|
|
54
|
+
setup(props, { slots }) {
|
|
55
|
+
const parentSelect = inject('dropdown-select', null);
|
|
56
|
+
// const state = inject(DROPDOWN_STATE, null);
|
|
57
|
+
// const keys = useMagicKeys({
|
|
58
|
+
// passive: false,
|
|
59
|
+
// onEventFired: (event) => {
|
|
60
|
+
|
|
61
|
+
// // only fire when the dropdown is open
|
|
62
|
+
// if (state?.isOpen.value) {
|
|
63
|
+
// event.preventDefault();
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// });
|
|
67
|
+
|
|
68
|
+
const hasIconLeft = computed(() => !!(slots['icon-left']));
|
|
69
|
+
const hasIconRight = computed(() => !!(slots['icon-right']));
|
|
70
|
+
|
|
71
|
+
const wrapper = ref(null);
|
|
72
|
+
const label = toRef(props, 'label')
|
|
73
|
+
const isReference = ref(props.reference)
|
|
74
|
+
const currentLabel = useLabel(label, wrapper)
|
|
75
|
+
function handleSelect() {
|
|
76
|
+
if (props.disabled || isReference.value) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof parentSelect === 'function') {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
parentSelect([currentLabel.value!]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
props.onSelect(currentLabel.value!);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// const isOpen = computed(() => {
|
|
89
|
+
// return state?.isOpen.value;
|
|
90
|
+
// });
|
|
91
|
+
|
|
92
|
+
const computedWrapperClasses = computed(() => {
|
|
93
|
+
return [
|
|
94
|
+
style.menuItem
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// onMounted(() => {
|
|
99
|
+
// if (props.hotkey) {
|
|
100
|
+
// const combination = keys[props.hotkey];
|
|
101
|
+
|
|
102
|
+
// whenever(combination, (v) => {
|
|
103
|
+
// if (v && isOpen.value) {
|
|
104
|
+
// handleSelect();
|
|
105
|
+
// }
|
|
106
|
+
// })
|
|
107
|
+
// }
|
|
108
|
+
// })
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
wrapper,
|
|
113
|
+
hasIconLeft,
|
|
114
|
+
hasIconRight,
|
|
115
|
+
handleSelect,
|
|
116
|
+
computedWrapperClasses,
|
|
117
|
+
style
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
</script>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ul>
|
|
2
|
+
<ul :class="style.menuItems">
|
|
3
3
|
<slot />
|
|
4
4
|
</ul>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
8
|
import { defineComponent } from 'vue';
|
|
9
|
+
import * as style from "./style";
|
|
9
10
|
|
|
10
11
|
export default defineComponent({
|
|
11
12
|
name: "DropdownList",
|
|
12
13
|
setup() {
|
|
13
14
|
|
|
14
|
-
// computed classes
|
|
15
15
|
return {
|
|
16
|
-
|
|
16
|
+
style
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
})
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import { defineComponent, inject, provide } from 'vue';
|
|
7
|
+
import {DROPDOWN_STATE} from "./symbol";
|
|
7
8
|
|
|
8
9
|
export default defineComponent({
|
|
9
10
|
name: 'DropdownWrapper',
|
|
10
11
|
setup() {
|
|
11
|
-
const state = inject(
|
|
12
|
+
const state = inject(DROPDOWN_STATE, null);
|
|
12
13
|
|
|
13
14
|
// @ts-ignore
|
|
14
15
|
provide('dropdown-select', state?.handleSelect);
|
|
@@ -5,9 +5,10 @@ import MButton from '../../button/Button.vue';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
MDropdownBasic,
|
|
8
|
-
MDropdownContext
|
|
8
|
+
MDropdownContext,
|
|
9
|
+
MDropdownCustom
|
|
9
10
|
} from './index';
|
|
10
|
-
import { createStory } from '
|
|
11
|
+
import { createStory } from '../../../__storybook__';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
component: MDropdown,
|
|
@@ -20,4 +21,5 @@ export default {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export const Basic = createStory(MDropdownBasic);
|
|
24
|
+
export const Custom = createStory(MDropdownCustom);
|
|
23
25
|
export const Context = createStory(MDropdownContext);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { style } from "@vanilla-extract/css";
|
|
2
|
+
import { themeVars } from "../../../styles/theme.css";
|
|
3
|
+
|
|
4
|
+
export const menu = style({
|
|
5
|
+
backgroundColor: "#ffffff",
|
|
6
|
+
borderRadius: "5px",
|
|
7
|
+
padding: '5px 0',
|
|
8
|
+
zIndex: 4000,
|
|
9
|
+
boxSizing: "border-box",
|
|
10
|
+
position: "relative",
|
|
11
|
+
minWidth: "200px",
|
|
12
|
+
maxWidth: "350px",
|
|
13
|
+
border: `1px solid ${themeVars.color.gray[200]}`,
|
|
14
|
+
boxShadow: themeVars.shadow.md
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const menuItems = style({
|
|
18
|
+
listStyle: "none",
|
|
19
|
+
margin: 0,
|
|
20
|
+
padding: 0,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const menuItem = style({
|
|
24
|
+
position: "relative",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
cursor: "pointer",
|
|
28
|
+
minHeight: "36px",
|
|
29
|
+
fontSize: themeVars.fontSize.base,
|
|
30
|
+
paddingBlock: themeVars.space['1.5'],
|
|
31
|
+
paddingInline: themeVars.space['3'],
|
|
32
|
+
gap: themeVars.space[2],
|
|
33
|
+
color: themeVars.color.gray[800],
|
|
34
|
+
transition: "background-color 0.05s ease-in-out",
|
|
35
|
+
':hover': {
|
|
36
|
+
backgroundColor: themeVars.color.gray[100],
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const menuItemText = style({
|
|
41
|
+
flex: 1,
|
|
42
|
+
whiteSpace: "nowrap",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const menuItemIcon = style({
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Dropdown.css';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<MForm @submit="onSubmit" :loading="loading">
|
|
2
|
+
<MForm @submit="onSubmit" :loading="loading" style="display: flex; flex-direction: column; gap: 10px;">
|
|
3
3
|
<MInput
|
|
4
4
|
label="Email"
|
|
5
5
|
placeholder="Email Address"
|
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
Something here!
|
|
34
34
|
</MCheckbox>
|
|
35
35
|
|
|
36
|
+
<MColorPicker />
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
<MButton type="submit" color="blue">Submit</MButton>
|
|
38
40
|
</MForm>
|
|
39
41
|
</template>
|
|
40
42
|
|
|
41
43
|
<script lang="ts" setup>
|
|
42
|
-
import { MCheckbox, MSelect } from '@/components';
|
|
44
|
+
import { MCheckbox, MSelect, MColorPicker } from '@/components';
|
|
43
45
|
import { ref } from 'vue';
|
|
44
46
|
|
|
45
47
|
const rules = {
|
|
@@ -3,11 +3,12 @@ import MInput from '../../input/Input.vue';
|
|
|
3
3
|
import MButton from '../../button/Button.vue';
|
|
4
4
|
import MSelect from '../../select/Select.vue';
|
|
5
5
|
import MCheckbox from '../../checkbox/Checkbox.vue';
|
|
6
|
+
import MColorPicker from '../../colorpicker/ColorPicker.vue';
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
MFormBasic
|
|
9
10
|
} from './index';
|
|
10
|
-
import { createStory } from '
|
|
11
|
+
import { createStory } from '../../../__storybook__';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
component: MForm,
|
|
@@ -15,7 +16,8 @@ export default {
|
|
|
15
16
|
MInput,
|
|
16
17
|
MButton,
|
|
17
18
|
MSelect,
|
|
18
|
-
MCheckbox
|
|
19
|
+
MCheckbox,
|
|
20
|
+
MColorPicker
|
|
19
21
|
},
|
|
20
22
|
title: 'Components/Form'
|
|
21
23
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
export { default as MBadge } from './badge/Badge.vue';
|
|
1
2
|
export { default as MButton } from './button/Button.vue';
|
|
2
3
|
export { default as MButtonGroup } from './buttongroup/ButtonGroup.vue';
|
|
3
4
|
export { default as MForm } from './form/Form.vue';
|
|
4
5
|
export { default as MInput } from './input/Input.vue';
|
|
6
|
+
export { default as MTag } from './tag/Tag.vue';
|
|
5
7
|
export { default as MSelect } from './select/Select.vue';
|
|
6
8
|
export { default as MCheckbox } from './checkbox/Checkbox.vue';
|
|
9
|
+
export { default as MRadio } from './radio/Radio.vue';
|
|
10
|
+
export { default as MRadioButton } from './radiobutton/RadioButton.vue';
|
|
11
|
+
export { default as MRadioButtonGroup } from './radiobuttongroup/RadioButtonGroup.vue';
|
|
7
12
|
export { default as MBreadcrumb } from './breadcrumb/Breadcrumb.vue';
|
|
8
|
-
export { default as MBreadcrumbItem } from './
|
|
9
|
-
|
|
13
|
+
export { default as MBreadcrumbItem } from './breadcrumb/BreadcrumbItem.vue';
|
|
14
|
+
export { default as MVirtualScroll } from './virtualscroll/VirtualScroll.vue';
|
|
10
15
|
export { default as MAvatar } from './avatar/Avatar.vue';
|
|
11
16
|
export { default as MAvatarGroup } from './avatargroup/AvatarGroup.vue';
|
|
12
17
|
export { default as MImage } from './image/Image.vue';
|
|
@@ -25,3 +30,6 @@ export { default as MDropdown } from './dropdown/Dropdown.vue';
|
|
|
25
30
|
export { default as MDropdownWrapper } from './dropdown/DropdownWrapper.vue';
|
|
26
31
|
export { default as MDropdownList } from './dropdown/DropdownList.vue';
|
|
27
32
|
export { default as MDropdownItem } from './dropdown/DropdownItem.vue';
|
|
33
|
+
export { default as MModal } from './modal/Modal.vue';
|
|
34
|
+
export { default as MColorPicker } from './colorpicker/ColorPicker.vue';
|
|
35
|
+
export { default as MSlider } from './slider/Slider.vue';
|