@teammodlr/ui-kit 2.3.10 → 2.3.14
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/env.d.ts +1 -1
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +11 -1
- package/lib/index.cjs.js +3 -3
- package/lib/index.es.js +324 -318
- package/lib/nuxt.js +35 -35
- package/lib/nuxt.plugin.js +8 -8
- package/package.json +1 -1
- package/src/__storybook__/argTypes.ts +53 -53
- package/src/__storybook__/createStory.ts +15 -15
- package/src/__storybook__/index.ts +2 -2
- package/src/components/avatar/Avatar.vue +110 -110
- package/src/components/avatar/examples/basic.vue +6 -6
- package/src/components/avatar/examples/custom-size.vue +7 -7
- package/src/components/avatar/examples/index.stories.ts +25 -25
- package/src/components/avatar/examples/index.ts +5 -5
- package/src/components/avatar/examples/sizes.vue +33 -33
- package/src/components/avatar/examples/slots.vue +8 -8
- package/src/components/avatar/examples/variants.vue +18 -18
- package/src/components/avatar/style/Avatar.css.ts +92 -92
- package/src/components/avatar/style/index.ts +1 -1
- package/src/components/avatargroup/AvatarGroup.vue +72 -72
- package/src/components/avatargroup/examples/basic.vue +37 -37
- package/src/components/avatargroup/examples/index.stories.ts +19 -19
- package/src/components/avatargroup/examples/index.ts +1 -1
- package/src/components/avatargroup/style/AvatarGroup.css.ts +26 -26
- package/src/components/avatargroup/style/index.ts +1 -1
- package/src/components/avatargroup/symbol.ts +17 -17
- package/src/components/badge/Badge.vue +43 -43
- package/src/components/badge/examples/basic.vue +10 -10
- package/src/components/badge/examples/index.stories.ts +19 -19
- package/src/components/badge/examples/index.ts +1 -1
- package/src/components/badge/style/Badge.css.ts +135 -135
- package/src/components/badge/style/index.ts +1 -1
- package/src/components/breadcrumb/Breadcrumb.vue +54 -54
- package/src/components/breadcrumb/BreadcrumbItem.vue +72 -72
- package/src/components/breadcrumb/examples/basic.vue +7 -7
- package/src/components/breadcrumb/examples/index.stories.ts +16 -16
- package/src/components/breadcrumb/examples/index.ts +1 -1
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -40
- package/src/components/breadcrumb/style/index.ts +1 -1
- package/src/components/breadcrumb/symbol.ts +18 -18
- package/src/components/button/Button.vue +203 -203
- package/src/components/button/examples/basic.vue +3 -3
- package/src/components/button/examples/disabled.vue +3 -3
- package/src/components/button/examples/icon-left.vue +12 -12
- package/src/components/button/examples/icon.vue +9 -9
- package/src/components/button/examples/index.stories.ts +37 -37
- package/src/components/button/examples/index.ts +9 -9
- package/src/components/button/examples/link.vue +3 -3
- package/src/components/button/examples/rounded.vue +7 -7
- package/src/components/button/examples/size.vue +7 -7
- package/src/components/button/examples/variants-secondary.vue +10 -10
- package/src/components/button/examples/variants.vue +10 -10
- package/src/components/button/style/index.ts +1 -1
- package/src/components/buttongroup/ButtonGroup.vue +36 -36
- package/src/components/buttongroup/examples/basic.vue +9 -9
- package/src/components/buttongroup/examples/icon-group.vue +21 -21
- package/src/components/buttongroup/examples/index.stories.ts +17 -17
- package/src/components/buttongroup/examples/index.ts +2 -2
- package/src/components/buttongroup/style/ButtonGroup.css.ts +42 -42
- package/src/components/buttongroup/style/index.ts +1 -1
- package/src/components/buttongroup/symbol.ts +9 -9
- package/src/components/checkbox/Checkbox.vue +149 -149
- package/src/components/checkbox/examples/basic.vue +9 -9
- package/src/components/checkbox/examples/index.stories.ts +16 -16
- package/src/components/checkbox/examples/index.ts +2 -2
- package/src/components/checkbox/examples/slot.vue +14 -14
- package/src/components/checkbox/style/Checkbox.css.ts +178 -178
- package/src/components/checkbox/style/index.ts +1 -1
- package/src/components/colorpicker/ColorPicker.vue +15 -4
- package/src/components/colorpicker/examples/index.stories.ts +12 -12
- package/src/components/colorpicker/examples/index.ts +1 -1
- package/src/components/colorpicker/style/index.ts +1 -1
- package/src/components/configprovider/ConfigProvider.vue +38 -38
- package/src/components/configprovider/types.ts +3 -3
- package/src/components/confirm/Confirm.vue +65 -65
- package/src/components/confirm/examples/basic.vue +48 -48
- package/src/components/confirm/examples/index.stories.ts +26 -26
- package/src/components/confirm/examples/index.ts +1 -1
- package/src/components/confirm/examples/wrapper.vue +9 -9
- package/src/components/confirm/props.ts +24 -24
- package/src/components/confirm/providerProps.ts +10 -10
- package/src/components/confirm/types.ts +33 -33
- package/src/components/confirm/useConfirm.ts +14 -14
- package/src/components/dialog/examples/basic.vue +23 -23
- package/src/components/dialog/examples/index.stories.ts +14 -14
- package/src/components/dialog/examples/index.ts +1 -1
- package/src/components/dialog/style/index.ts +1 -1
- package/src/components/dialogprovider/examples/index.stories.ts +26 -26
- package/src/components/dropdown/DropdownList.vue +20 -20
- package/src/components/dropdown/examples/index.stories.ts +26 -26
- package/src/components/dropdown/examples/index.ts +3 -3
- package/src/components/dropdown/hooks.ts +30 -30
- package/src/components/dropdown/style/index.ts +1 -1
- package/src/components/dropdown/symbol.ts +9 -9
- package/src/components/form/Form.vue +153 -153
- package/src/components/form/examples/basic.vue +75 -75
- package/src/components/form/examples/index.stories.ts +23 -23
- package/src/components/form/examples/index.ts +1 -1
- package/src/components/form/style/Form.css.ts +28 -28
- package/src/components/form/style/index.ts +2 -2
- package/src/components/form/symbol.ts +16 -16
- package/src/components/image/Image.vue +71 -71
- package/src/components/image/examples/basic.vue +5 -5
- package/src/components/image/examples/index.stories.ts +10 -10
- package/src/components/image/examples/index.ts +1 -1
- package/src/components/input/Input.vue +233 -233
- package/src/components/input/examples/basic.vue +21 -21
- package/src/components/input/examples/index.stories.ts +26 -26
- package/src/components/input/examples/index.ts +6 -6
- package/src/components/input/examples/left-icon.vue +9 -9
- package/src/components/input/examples/prefix.vue +5 -5
- package/src/components/input/examples/right-icon.vue +9 -9
- package/src/components/input/examples/sizes.vue +9 -9
- package/src/components/input/examples/suffix.vue +7 -7
- package/src/components/input/style/Input.css.ts +294 -294
- package/src/components/input/style/index.ts +1 -1
- package/src/components/link/Link.vue +53 -53
- package/src/components/link/examples/basic.vue +3 -3
- package/src/components/link/examples/index.stories.ts +15 -15
- package/src/components/link/examples/index.ts +1 -1
- package/src/components/messageprovider/Message.vue +135 -135
- package/src/components/messageprovider/MessageProvider.vue +152 -152
- package/src/components/messageprovider/examples/basic.vue +70 -70
- package/src/components/messageprovider/examples/index.stories.ts +26 -26
- package/src/components/messageprovider/examples/index.ts +2 -2
- package/src/components/messageprovider/examples/update.vue +34 -34
- package/src/components/messageprovider/examples/wrapper.vue +9 -9
- package/src/components/messageprovider/style/Message.css.ts +111 -111
- package/src/components/messageprovider/style/index.ts +1 -1
- package/src/components/messageprovider/types.ts +56 -56
- package/src/components/messageprovider/useMessage.ts +14 -14
- package/src/components/modal/Modal.vue +310 -310
- package/src/components/modal/examples/basic.vue +80 -80
- package/src/components/modal/examples/index.stories.ts +16 -16
- package/src/components/modal/examples/index.ts +3 -3
- package/src/components/modal/examples/modal-form.vue +99 -99
- package/src/components/modal/examples/sidebar.vue +79 -79
- package/src/components/modal/style/Modal.css.ts +318 -318
- package/src/components/modal/style/index.ts +1 -1
- package/src/components/pagination/Pagination.vue +296 -296
- package/src/components/pagination/examples/basic.vue +17 -17
- package/src/components/pagination/examples/index.stories.ts +11 -11
- package/src/components/pagination/examples/index.ts +1 -1
- package/src/components/pagination/style/Pagination.css.ts +93 -93
- package/src/components/pagination/style/index.ts +1 -1
- package/src/components/radio/Radio.vue +136 -136
- package/src/components/radio/examples/basic.vue +8 -8
- package/src/components/radio/examples/group.vue +15 -15
- package/src/components/radio/examples/index.stories.ts +16 -16
- package/src/components/radio/examples/index.ts +2 -2
- package/src/components/radio/style/Checkbox.css.ts +130 -130
- package/src/components/radio/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +131 -131
- package/src/components/radiobutton/style/RadioButton.css.ts +189 -189
- package/src/components/radiobutton/style/index.ts +1 -1
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +74 -74
- package/src/components/radiobuttongroup/examples/basic.vue +16 -16
- package/src/components/radiobuttongroup/examples/index.stories.ts +18 -18
- package/src/components/radiobuttongroup/examples/index.ts +1 -1
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -37
- package/src/components/radiobuttongroup/style/index.ts +1 -1
- package/src/components/radiobuttongroup/symbol.ts +12 -12
- package/src/components/renderer/examlpes/basic.vue +23 -23
- package/src/components/renderer/examlpes/index.stories.ts +14 -14
- package/src/components/renderer/examlpes/index.ts +1 -1
- package/src/components/renderer/props.ts +14 -14
- package/src/components/renderer/renderer.ts +16 -16
- package/src/components/select/Select.vue +4 -0
- package/src/components/select/examples/basic.vue +26 -26
- package/src/components/select/examples/index.stories.ts +16 -16
- package/src/components/select/examples/index.ts +3 -3
- package/src/components/select/examples/multiple.vue +21 -21
- package/src/components/select/examples/searchable.vue +20 -20
- package/src/components/select/style/index.ts +1 -1
- package/src/components/select/types.ts +27 -27
- package/src/components/skeleton/Skeleton.vue +55 -55
- package/src/components/skeleton/examples/basic.vue +3 -3
- package/src/components/skeleton/examples/index.stories.ts +13 -13
- package/src/components/skeleton/examples/index.ts +2 -2
- package/src/components/skeleton/examples/post.vue +8 -8
- package/src/components/skeleton/style/Skeleton.css.ts +72 -72
- package/src/components/skeleton/style/index.ts +2 -2
- package/src/components/slider/style/Slider.css.ts +50 -50
- package/src/components/slider/style/index.ts +1 -1
- package/src/components/switch/Switch.vue +132 -132
- package/src/components/switch/examples/basic.vue +9 -9
- package/src/components/switch/examples/index.stories.ts +15 -15
- package/src/components/switch/examples/index.ts +2 -2
- package/src/components/switch/examples/slot.vue +11 -11
- package/src/components/switch/style/index.ts +1 -1
- package/src/components/tab/examples/basic.vue +23 -23
- package/src/components/tab/examples/index.ts +2 -2
- package/src/components/tab/examples/vertical.vue +19 -19
- package/src/components/table/Table.vue +198 -198
- package/src/components/table/TableBody.vue +13 -13
- package/src/components/table/TableCell.vue +13 -13
- package/src/components/table/TableHead.vue +46 -46
- package/src/components/table/TableHeadRow.vue +15 -15
- package/src/components/table/TableRow.vue +19 -19
- package/src/components/table/examples/basic.vue +61 -61
- package/src/components/table/examples/empty.vue +44 -44
- package/src/components/table/examples/index.stories.ts +17 -17
- package/src/components/table/examples/index.ts +3 -3
- package/src/components/table/examples/selected.vue +68 -68
- package/src/components/table/style/Table.css.ts +62 -62
- package/src/components/table/style/index.ts +1 -1
- package/src/components/table/types/index.ts +6 -6
- package/src/components/tag/Tag.vue +72 -72
- package/src/components/tag/examples/basic.vue +5 -5
- package/src/components/tag/examples/index.stories.ts +16 -16
- package/src/components/tag/examples/index.ts +1 -1
- package/src/components/tag/style/Tag.css.ts +83 -83
- package/src/components/tag/style/index.ts +1 -1
- package/src/components/textarea/Textarea.vue +180 -180
- package/src/components/textarea/examples/basic.vue +8 -8
- package/src/components/textarea/examples/index.stories.ts +14 -14
- package/src/components/textarea/examples/index.ts +1 -1
- package/src/components/textarea/style/Textarea.css.ts +191 -191
- package/src/components/textarea/style/index.ts +1 -1
- package/src/components/tooltip/examples/basic.vue +5 -5
- package/src/components/tooltip/examples/index.stories.ts +17 -17
- package/src/components/tooltip/examples/index.ts +2 -2
- package/src/components/tooltip/examples/placement.vue +9 -9
- package/src/components/tooltip/style/Tooltip.css.ts +90 -90
- package/src/components/tooltip/style/index.ts +1 -1
- package/src/components/transfer/Transfer.vue +145 -145
- package/src/components/transfer/examples/basic.vue +21 -21
- package/src/components/transfer/examples/index.stories.ts +12 -12
- package/src/components/transfer/examples/index.ts +1 -1
- package/src/components/transfer/style/Transfer.css.ts +81 -81
- package/src/components/transfer/style/index.ts +1 -1
- package/src/components/tree/Tree.vue +138 -138
- package/src/components/tree/TreeNode.vue +109 -109
- package/src/components/tree/TreeNodeToggle.vue +48 -48
- package/src/components/tree/examples/basic.vue +458 -458
- package/src/components/tree/examples/index.stories.ts +12 -12
- package/src/components/tree/examples/index.ts +1 -1
- package/src/components/tree/props.ts +97 -97
- package/src/components/tree/style/Tree.css.ts +75 -75
- package/src/components/tree/style/index.ts +1 -1
- package/src/components/tree/types.ts +103 -103
- package/src/components/virtualscroll/VirtualScroll.css +13 -13
- package/src/components/virtualscroll/VirtualScroll.vue +166 -166
- package/src/components/virtualscroll/examples/basic.vue +31 -31
- package/src/components/virtualscroll/examples/index.stories.ts +11 -11
- package/src/components/virtualscroll/examples/index.ts +1 -1
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +17 -17
- package/src/components/virtualscroll/style/index.ts +1 -1
- package/src/composables/element.ts +13 -13
- package/src/composables/index.ts +5 -5
- package/src/composables/useCachedUid.ts +15 -15
- package/src/composables/useEventListener.ts +19 -19
- package/src/composables/useInput.ts +151 -151
- package/src/composables/useInteractive.ts +19 -19
- package/src/composables/useIsServer.ts +7 -7
- package/src/composables/useMergedState.ts +18 -18
- package/src/composables/useMount.ts +43 -43
- package/src/composables/usePopper.ts +215 -215
- package/src/composables/useZIndex.ts +33 -33
- package/src/create.ts +38 -38
- package/src/css/components.css +16 -16
- package/src/css/index.css +4 -4
- package/src/css/transitions.css +40 -40
- package/src/css/variables.css +80 -80
- package/src/examples/cards/cards.stories.ts +9 -9
- package/src/examples/cards/sidebar.vue +262 -262
- package/src/examples/modal/modal.stories.ts +9 -9
- package/src/examples/modal/modal.vue +52 -52
- package/src/exports/nuxt.js +35 -35
- package/src/exports/nuxt.plugin.js +8 -8
- package/src/index.ts +5 -5
- package/src/install.ts +8 -8
- package/src/shims-vue.d.ts +6 -6
- package/src/styles/theme.css.ts +181 -181
- package/src/types/props.ts +21 -21
- package/src/utils/call.ts +34 -34
- package/src/utils/injection.ts +45 -45
- package/volar.d.ts +16 -16
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<img :class="computedClasses" :style="computedStyles" :src="source" :alt="alt" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { defineComponent, watch, ref, computed } from 'vue';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default defineComponent({
|
|
10
|
-
name: "MImage",
|
|
11
|
-
props: {
|
|
12
|
-
src: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true,
|
|
15
|
-
},
|
|
16
|
-
scrSet: {
|
|
17
|
-
type: String,
|
|
18
|
-
default: "",
|
|
19
|
-
},
|
|
20
|
-
fit: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: "cover",
|
|
23
|
-
},
|
|
24
|
-
alt: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: "",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
emits: {
|
|
30
|
-
error: (e: Event) => true
|
|
31
|
-
},
|
|
32
|
-
setup(props, { emit }) {
|
|
33
|
-
const source = ref<string | undefined>("");
|
|
34
|
-
|
|
35
|
-
if (typeof window !== 'undefined' && Image) {
|
|
36
|
-
watch(() => props.src, (src) => {
|
|
37
|
-
if(!src) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const image = new Image();
|
|
42
|
-
image.onload = () => {
|
|
43
|
-
source.value = props.src;
|
|
44
|
-
};
|
|
45
|
-
image.onerror = () => {
|
|
46
|
-
emit('error', new Event('error'));
|
|
47
|
-
};
|
|
48
|
-
image.src = src;
|
|
49
|
-
},
|
|
50
|
-
{ immediate: true })
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const computedClasses = computed(() => {
|
|
54
|
-
return {
|
|
55
|
-
"m-image": true,
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const computedStyles = computed(() => {
|
|
60
|
-
return {
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
source,
|
|
66
|
-
computedClasses,
|
|
67
|
-
computedStyles,
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<img :class="computedClasses" :style="computedStyles" :src="source" :alt="alt" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { defineComponent, watch, ref, computed } from 'vue';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: "MImage",
|
|
11
|
+
props: {
|
|
12
|
+
src: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
scrSet: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "",
|
|
19
|
+
},
|
|
20
|
+
fit: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "cover",
|
|
23
|
+
},
|
|
24
|
+
alt: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
emits: {
|
|
30
|
+
error: (e: Event) => true
|
|
31
|
+
},
|
|
32
|
+
setup(props, { emit }) {
|
|
33
|
+
const source = ref<string | undefined>("");
|
|
34
|
+
|
|
35
|
+
if (typeof window !== 'undefined' && Image) {
|
|
36
|
+
watch(() => props.src, (src) => {
|
|
37
|
+
if(!src) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const image = new Image();
|
|
42
|
+
image.onload = () => {
|
|
43
|
+
source.value = props.src;
|
|
44
|
+
};
|
|
45
|
+
image.onerror = () => {
|
|
46
|
+
emit('error', new Event('error'));
|
|
47
|
+
};
|
|
48
|
+
image.src = src;
|
|
49
|
+
},
|
|
50
|
+
{ immediate: true })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const computedClasses = computed(() => {
|
|
54
|
+
return {
|
|
55
|
+
"m-image": true,
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const computedStyles = computed(() => {
|
|
60
|
+
return {
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
source,
|
|
66
|
+
computedClasses,
|
|
67
|
+
computedStyles,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<MImage
|
|
3
|
-
src="https://images.unsplash.com/photo-1672745256937-4e60a4534413?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=976&q=80"
|
|
4
|
-
/>
|
|
5
|
-
</template>
|
|
1
|
+
<template>
|
|
2
|
+
<MImage
|
|
3
|
+
src="https://images.unsplash.com/photo-1672745256937-4e60a4534413?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=976&q=80"
|
|
4
|
+
/>
|
|
5
|
+
</template>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createStory } from '../../../__storybook__';
|
|
2
|
-
import MImage from '../Image.vue';
|
|
3
|
-
import { MImageBasic } from './index';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
component: MImage,
|
|
7
|
-
title: 'Components/Image'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const Basic = createStory(MImageBasic);
|
|
1
|
+
import { createStory } from '../../../__storybook__';
|
|
2
|
+
import MImage from '../Image.vue';
|
|
3
|
+
import { MImageBasic } from './index';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: MImage,
|
|
7
|
+
title: 'Components/Image'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const Basic = createStory(MImageBasic);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as MImageBasic } from './basic.vue';
|
|
1
|
+
export { default as MImageBasic } from './basic.vue';
|
|
@@ -1,233 +1,233 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="container" :class="computedContainerClasses">
|
|
3
|
-
<label v-if="label" :for="id" :id="`${id}-label`" :class="style.label">
|
|
4
|
-
{{ label }}
|
|
5
|
-
</label>
|
|
6
|
-
<div v-if="description" :class="style.description">
|
|
7
|
-
{{ description }}
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
<div :class="wrapperComputedClasses">
|
|
11
|
-
<div v-if="hasLeftIcon" :class="style.leftIcon">
|
|
12
|
-
<slot name="icon-left" />
|
|
13
|
-
</div>
|
|
14
|
-
<div v-if="hasPrefix" :class="style.prefix">
|
|
15
|
-
<slot name="prefix" />
|
|
16
|
-
</div>
|
|
17
|
-
<input
|
|
18
|
-
ref="element"
|
|
19
|
-
:id="id"
|
|
20
|
-
:type="inputType"
|
|
21
|
-
:placeholder="placeholder"
|
|
22
|
-
:name="name"
|
|
23
|
-
:value="modelValue || ''"
|
|
24
|
-
:readonly="readonly"
|
|
25
|
-
v-on="inputListeners"
|
|
26
|
-
:class="inputComputedClasses"
|
|
27
|
-
v-bind="$attrs"
|
|
28
|
-
:disabled="disabled || loading"
|
|
29
|
-
:aria-disabled="disabled ? 'true' : 'false'"
|
|
30
|
-
:aria-labelledby="`${id}-label`"
|
|
31
|
-
/>
|
|
32
|
-
<div v-if="hasSuffix" :class="style.suffix">
|
|
33
|
-
<slot name="suffix" />
|
|
34
|
-
</div>
|
|
35
|
-
<div v-if="hasRightIcon" :class="style.rightIcon">
|
|
36
|
-
<slot name="icon-right" />
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
<div v-if="hasHelpMessage" :class="style.helpMessage">
|
|
40
|
-
<slot name="help" />
|
|
41
|
-
</div>
|
|
42
|
-
<div v-if="inputError" :class="style.errorMessage">
|
|
43
|
-
{{ inputError }}
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<script lang="ts">
|
|
49
|
-
import type { PropType } from "vue";
|
|
50
|
-
import type { Size } from "../../types/props";
|
|
51
|
-
import {
|
|
52
|
-
defineComponent,
|
|
53
|
-
ref,
|
|
54
|
-
computed,
|
|
55
|
-
toRef
|
|
56
|
-
} from "vue";
|
|
57
|
-
import { useInput } from "../../composables/useInput";
|
|
58
|
-
import { useInteractive } from "../../composables/useInteractive";
|
|
59
|
-
import * as style from './style';
|
|
60
|
-
|
|
61
|
-
export default defineComponent({
|
|
62
|
-
name: 'MInput',
|
|
63
|
-
props: {
|
|
64
|
-
...useInput.props(),
|
|
65
|
-
...useInteractive.props(),
|
|
66
|
-
label: {
|
|
67
|
-
type: String
|
|
68
|
-
},
|
|
69
|
-
size: {
|
|
70
|
-
type: String as PropType<Size>,
|
|
71
|
-
default: 'md',
|
|
72
|
-
},
|
|
73
|
-
type: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: 'text',
|
|
76
|
-
validator: (value: string) => ['text', 'password', 'number', 'email', 'date', 'datetime'].includes(value)
|
|
77
|
-
},
|
|
78
|
-
placeholder: {
|
|
79
|
-
type: String,
|
|
80
|
-
default: ''
|
|
81
|
-
},
|
|
82
|
-
loading: {
|
|
83
|
-
type: Boolean,
|
|
84
|
-
default: false
|
|
85
|
-
},
|
|
86
|
-
readonly: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: false
|
|
89
|
-
},
|
|
90
|
-
disabled: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: false
|
|
93
|
-
},
|
|
94
|
-
description: {
|
|
95
|
-
type: String,
|
|
96
|
-
default: ''
|
|
97
|
-
},
|
|
98
|
-
block: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: false
|
|
101
|
-
},
|
|
102
|
-
error: {
|
|
103
|
-
type: String,
|
|
104
|
-
default: ''
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
emits: useInput.emits(),
|
|
108
|
-
setup(props, { slots, emit, expose }) {
|
|
109
|
-
const element = ref<HTMLInputElement|null>(null);
|
|
110
|
-
const { focus, blur } = useInteractive(element);
|
|
111
|
-
const {
|
|
112
|
-
id,
|
|
113
|
-
insideForm,
|
|
114
|
-
reset,
|
|
115
|
-
inputListeners,
|
|
116
|
-
validate,
|
|
117
|
-
setError,
|
|
118
|
-
formError,
|
|
119
|
-
formDisabled,
|
|
120
|
-
formLoading
|
|
121
|
-
} = useInput(props, { focus, emit });
|
|
122
|
-
|
|
123
|
-
const showPassword = ref(false);
|
|
124
|
-
const name = toRef(props, 'name');
|
|
125
|
-
|
|
126
|
-
const hasLeftIcon = computed(() => !!(slots['icon-left']));
|
|
127
|
-
const hasRightIcon = computed(() => !!(slots['icon-right']));
|
|
128
|
-
const hasPrefix = computed(() => !!(slots['prefix']));
|
|
129
|
-
const hasSuffix = computed(() => !!(slots['suffix']));
|
|
130
|
-
const hasHelpMessage = computed(() => !!(slots['help-message'] || slots['help']));
|
|
131
|
-
const disabled = computed(() => formDisabled || props.disabled);
|
|
132
|
-
const loading = computed(() => formLoading || props.loading);
|
|
133
|
-
|
|
134
|
-
const inputType = computed(() => {
|
|
135
|
-
const type = props.type;
|
|
136
|
-
if (type === 'password') {
|
|
137
|
-
return showPassword.value ? 'text' : 'password';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return type;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const readonly = computed(() => (props.loading || props.readonly));
|
|
144
|
-
|
|
145
|
-
const computedContainerClasses = computed(() => {
|
|
146
|
-
return [
|
|
147
|
-
{
|
|
148
|
-
[style.block]: props.block,
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const wrapperComputedClasses = computed(() => {
|
|
154
|
-
return [
|
|
155
|
-
style.wrapper,
|
|
156
|
-
style.base,
|
|
157
|
-
style.size[props.size],
|
|
158
|
-
{
|
|
159
|
-
[style.block]: props.block,
|
|
160
|
-
[style.error]: inputError.value,
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const inputComputedClasses = computed(() => {
|
|
166
|
-
return [
|
|
167
|
-
style.input,
|
|
168
|
-
{
|
|
169
|
-
[style.block]: props.block,
|
|
170
|
-
[style.disabled]: disabled.value || loading.value,
|
|
171
|
-
[style.hasLeftIcon]: hasLeftIcon.value,
|
|
172
|
-
[style.hasRightIcon]: hasRightIcon.value,
|
|
173
|
-
}
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
// return [
|
|
177
|
-
// 'm-input',
|
|
178
|
-
// `m-input--${props.size}`,
|
|
179
|
-
// {
|
|
180
|
-
// 'm-input--disabled': disabled.value || loading.value,
|
|
181
|
-
// 'm-input--readonly': readonly.value,
|
|
182
|
-
// 'm-input--focused': focused.value,
|
|
183
|
-
// 'm-input--error': inputError.value,
|
|
184
|
-
// 'm-input--icon-left': hasLeftIcon.value,
|
|
185
|
-
// 'm-input--icon-right': hasRightIcon.value,
|
|
186
|
-
// 'm-input--loading': props.loading,
|
|
187
|
-
// 'm-input--password': props.type === 'password'
|
|
188
|
-
// }
|
|
189
|
-
// ]
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
const inputError = computed(() => {
|
|
193
|
-
return formError.value || props.error;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
const onClear = () => {
|
|
197
|
-
emit('update:modelValue', '');
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
expose({
|
|
201
|
-
focus,
|
|
202
|
-
blur,
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
return {
|
|
206
|
-
element,
|
|
207
|
-
id,
|
|
208
|
-
inputType,
|
|
209
|
-
disabled,
|
|
210
|
-
loading,
|
|
211
|
-
readonly,
|
|
212
|
-
inputComputedClasses,
|
|
213
|
-
wrapperComputedClasses,
|
|
214
|
-
computedContainerClasses,
|
|
215
|
-
name,
|
|
216
|
-
hasLeftIcon,
|
|
217
|
-
hasRightIcon,
|
|
218
|
-
hasSuffix,
|
|
219
|
-
hasPrefix,
|
|
220
|
-
hasHelpMessage,
|
|
221
|
-
inputError,
|
|
222
|
-
style,
|
|
223
|
-
|
|
224
|
-
onClear,
|
|
225
|
-
validate,
|
|
226
|
-
setError,
|
|
227
|
-
focus,
|
|
228
|
-
blur,
|
|
229
|
-
inputListeners
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="container" :class="computedContainerClasses">
|
|
3
|
+
<label v-if="label" :for="id" :id="`${id}-label`" :class="style.label">
|
|
4
|
+
{{ label }}
|
|
5
|
+
</label>
|
|
6
|
+
<div v-if="description" :class="style.description">
|
|
7
|
+
{{ description }}
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div :class="wrapperComputedClasses">
|
|
11
|
+
<div v-if="hasLeftIcon" :class="style.leftIcon">
|
|
12
|
+
<slot name="icon-left" />
|
|
13
|
+
</div>
|
|
14
|
+
<div v-if="hasPrefix" :class="style.prefix">
|
|
15
|
+
<slot name="prefix" />
|
|
16
|
+
</div>
|
|
17
|
+
<input
|
|
18
|
+
ref="element"
|
|
19
|
+
:id="id"
|
|
20
|
+
:type="inputType"
|
|
21
|
+
:placeholder="placeholder"
|
|
22
|
+
:name="name"
|
|
23
|
+
:value="modelValue || ''"
|
|
24
|
+
:readonly="readonly"
|
|
25
|
+
v-on="inputListeners"
|
|
26
|
+
:class="inputComputedClasses"
|
|
27
|
+
v-bind="$attrs"
|
|
28
|
+
:disabled="disabled || loading"
|
|
29
|
+
:aria-disabled="disabled ? 'true' : 'false'"
|
|
30
|
+
:aria-labelledby="`${id}-label`"
|
|
31
|
+
/>
|
|
32
|
+
<div v-if="hasSuffix" :class="style.suffix">
|
|
33
|
+
<slot name="suffix" />
|
|
34
|
+
</div>
|
|
35
|
+
<div v-if="hasRightIcon" :class="style.rightIcon">
|
|
36
|
+
<slot name="icon-right" />
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div v-if="hasHelpMessage" :class="style.helpMessage">
|
|
40
|
+
<slot name="help" />
|
|
41
|
+
</div>
|
|
42
|
+
<div v-if="inputError" :class="style.errorMessage">
|
|
43
|
+
{{ inputError }}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script lang="ts">
|
|
49
|
+
import type { PropType } from "vue";
|
|
50
|
+
import type { Size } from "../../types/props";
|
|
51
|
+
import {
|
|
52
|
+
defineComponent,
|
|
53
|
+
ref,
|
|
54
|
+
computed,
|
|
55
|
+
toRef
|
|
56
|
+
} from "vue";
|
|
57
|
+
import { useInput } from "../../composables/useInput";
|
|
58
|
+
import { useInteractive } from "../../composables/useInteractive";
|
|
59
|
+
import * as style from './style';
|
|
60
|
+
|
|
61
|
+
export default defineComponent({
|
|
62
|
+
name: 'MInput',
|
|
63
|
+
props: {
|
|
64
|
+
...useInput.props(),
|
|
65
|
+
...useInteractive.props(),
|
|
66
|
+
label: {
|
|
67
|
+
type: String
|
|
68
|
+
},
|
|
69
|
+
size: {
|
|
70
|
+
type: String as PropType<Size>,
|
|
71
|
+
default: 'md',
|
|
72
|
+
},
|
|
73
|
+
type: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: 'text',
|
|
76
|
+
validator: (value: string) => ['text', 'password', 'number', 'email', 'date', 'datetime'].includes(value)
|
|
77
|
+
},
|
|
78
|
+
placeholder: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: ''
|
|
81
|
+
},
|
|
82
|
+
loading: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false
|
|
85
|
+
},
|
|
86
|
+
readonly: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false
|
|
89
|
+
},
|
|
90
|
+
disabled: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false
|
|
93
|
+
},
|
|
94
|
+
description: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: ''
|
|
97
|
+
},
|
|
98
|
+
block: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false
|
|
101
|
+
},
|
|
102
|
+
error: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: ''
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
emits: useInput.emits(),
|
|
108
|
+
setup(props, { slots, emit, expose }) {
|
|
109
|
+
const element = ref<HTMLInputElement|null>(null);
|
|
110
|
+
const { focus, blur } = useInteractive(element);
|
|
111
|
+
const {
|
|
112
|
+
id,
|
|
113
|
+
insideForm,
|
|
114
|
+
reset,
|
|
115
|
+
inputListeners,
|
|
116
|
+
validate,
|
|
117
|
+
setError,
|
|
118
|
+
formError,
|
|
119
|
+
formDisabled,
|
|
120
|
+
formLoading
|
|
121
|
+
} = useInput(props, { focus, emit });
|
|
122
|
+
|
|
123
|
+
const showPassword = ref(false);
|
|
124
|
+
const name = toRef(props, 'name');
|
|
125
|
+
|
|
126
|
+
const hasLeftIcon = computed(() => !!(slots['icon-left']));
|
|
127
|
+
const hasRightIcon = computed(() => !!(slots['icon-right']));
|
|
128
|
+
const hasPrefix = computed(() => !!(slots['prefix']));
|
|
129
|
+
const hasSuffix = computed(() => !!(slots['suffix']));
|
|
130
|
+
const hasHelpMessage = computed(() => !!(slots['help-message'] || slots['help']));
|
|
131
|
+
const disabled = computed(() => formDisabled || props.disabled);
|
|
132
|
+
const loading = computed(() => formLoading || props.loading);
|
|
133
|
+
|
|
134
|
+
const inputType = computed(() => {
|
|
135
|
+
const type = props.type;
|
|
136
|
+
if (type === 'password') {
|
|
137
|
+
return showPassword.value ? 'text' : 'password';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return type;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const readonly = computed(() => (props.loading || props.readonly));
|
|
144
|
+
|
|
145
|
+
const computedContainerClasses = computed(() => {
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
[style.block]: props.block,
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const wrapperComputedClasses = computed(() => {
|
|
154
|
+
return [
|
|
155
|
+
style.wrapper,
|
|
156
|
+
style.base,
|
|
157
|
+
style.size[props.size],
|
|
158
|
+
{
|
|
159
|
+
[style.block]: props.block,
|
|
160
|
+
[style.error]: inputError.value,
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const inputComputedClasses = computed(() => {
|
|
166
|
+
return [
|
|
167
|
+
style.input,
|
|
168
|
+
{
|
|
169
|
+
[style.block]: props.block,
|
|
170
|
+
[style.disabled]: disabled.value || loading.value,
|
|
171
|
+
[style.hasLeftIcon]: hasLeftIcon.value,
|
|
172
|
+
[style.hasRightIcon]: hasRightIcon.value,
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
// return [
|
|
177
|
+
// 'm-input',
|
|
178
|
+
// `m-input--${props.size}`,
|
|
179
|
+
// {
|
|
180
|
+
// 'm-input--disabled': disabled.value || loading.value,
|
|
181
|
+
// 'm-input--readonly': readonly.value,
|
|
182
|
+
// 'm-input--focused': focused.value,
|
|
183
|
+
// 'm-input--error': inputError.value,
|
|
184
|
+
// 'm-input--icon-left': hasLeftIcon.value,
|
|
185
|
+
// 'm-input--icon-right': hasRightIcon.value,
|
|
186
|
+
// 'm-input--loading': props.loading,
|
|
187
|
+
// 'm-input--password': props.type === 'password'
|
|
188
|
+
// }
|
|
189
|
+
// ]
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const inputError = computed(() => {
|
|
193
|
+
return formError.value || props.error;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const onClear = () => {
|
|
197
|
+
emit('update:modelValue', '');
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
expose({
|
|
201
|
+
focus,
|
|
202
|
+
blur,
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
element,
|
|
207
|
+
id,
|
|
208
|
+
inputType,
|
|
209
|
+
disabled,
|
|
210
|
+
loading,
|
|
211
|
+
readonly,
|
|
212
|
+
inputComputedClasses,
|
|
213
|
+
wrapperComputedClasses,
|
|
214
|
+
computedContainerClasses,
|
|
215
|
+
name,
|
|
216
|
+
hasLeftIcon,
|
|
217
|
+
hasRightIcon,
|
|
218
|
+
hasSuffix,
|
|
219
|
+
hasPrefix,
|
|
220
|
+
hasHelpMessage,
|
|
221
|
+
inputError,
|
|
222
|
+
style,
|
|
223
|
+
|
|
224
|
+
onClear,
|
|
225
|
+
validate,
|
|
226
|
+
setError,
|
|
227
|
+
focus,
|
|
228
|
+
blur,
|
|
229
|
+
inputListeners
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
</script>
|