@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,19 +1,70 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div>
|
|
3
|
+
<button @click="showSuccess">Success</button>
|
|
4
|
+
<button @click="showInfo">Info</button>
|
|
5
|
+
<button @click="showWarning">Warning</button>
|
|
6
|
+
<button @click="showError">Error</button>
|
|
7
|
+
<hr />
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<button @click="showMessage">Success</button><br />
|
|
11
|
+
|
|
12
|
+
<button @click="updateNumber">+1</button>
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
3
16
|
</template>
|
|
4
17
|
|
|
5
18
|
<script lang="ts" setup>
|
|
19
|
+
import { ref } from 'vue';
|
|
20
|
+
import type { MessageReactive } from '../types';
|
|
6
21
|
import { useMessage } from '../useMessage';
|
|
7
22
|
|
|
8
23
|
const message = useMessage();
|
|
9
24
|
|
|
25
|
+
const number = ref(0);
|
|
26
|
+
let msg: MessageReactive | null = null;
|
|
27
|
+
|
|
10
28
|
const showMessage = () => {
|
|
29
|
+
msg = message.loading(`Loading`, {
|
|
30
|
+
timeout: 0
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function updateNumber() {
|
|
35
|
+
if (msg) {
|
|
36
|
+
// number.value++;
|
|
37
|
+
msg.content = `Saved Successfully`;
|
|
38
|
+
msg.type = 'success';
|
|
39
|
+
msg.timeout = 3000;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
11
43
|
|
|
12
|
-
|
|
44
|
+
const showSuccess = () => {
|
|
45
|
+
message.success(`Hello World`, {
|
|
46
|
+
timeout: 3000
|
|
47
|
+
});
|
|
48
|
+
};
|
|
13
49
|
|
|
14
|
-
|
|
15
|
-
|
|
50
|
+
const showInfo = () => {
|
|
51
|
+
message.info(`Hello World`, {
|
|
52
|
+
timeout: 3000
|
|
16
53
|
});
|
|
17
|
-
|
|
18
54
|
};
|
|
55
|
+
|
|
56
|
+
const showWarning = () => {
|
|
57
|
+
message.warning(`Hello World`, {
|
|
58
|
+
timeout: 3000
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const showError = () => {
|
|
63
|
+
message.error(`Hello World`, {
|
|
64
|
+
timeout: 3000
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
19
70
|
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<button @click="showMessage">Success</button><br />
|
|
4
|
+
|
|
5
|
+
<button @click="updateNumber">+1</button>
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { ref } from 'vue';
|
|
12
|
+
import type { MessageReactive } from '../types';
|
|
13
|
+
import { useMessage } from '../useMessage';
|
|
14
|
+
|
|
15
|
+
const message = useMessage();
|
|
16
|
+
|
|
17
|
+
const number = ref(0);
|
|
18
|
+
let msg: MessageReactive | null = null;
|
|
19
|
+
|
|
20
|
+
const showMessage = () => {
|
|
21
|
+
msg = message.success(`Hello World`, {
|
|
22
|
+
timeout: 3000
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function updateNumber() {
|
|
27
|
+
if (msg) {
|
|
28
|
+
number.value++;
|
|
29
|
+
msg.content = `Hello World ${number.value}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { createVar, style, styleVariants } from "@vanilla-extract/css";
|
|
2
|
+
import { themeVars } from "../../../styles/theme.css";
|
|
3
|
+
|
|
4
|
+
export const vars = {
|
|
5
|
+
top: createVar(),
|
|
6
|
+
left: createVar(),
|
|
7
|
+
right: createVar(),
|
|
8
|
+
iconColor: createVar(),
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const wrapper = style({
|
|
12
|
+
position: "fixed",
|
|
13
|
+
zIndex: 5000,
|
|
14
|
+
height: 0,
|
|
15
|
+
display: "flex",
|
|
16
|
+
flexDirection: "column",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
gap: themeVars.space['2.5'],
|
|
19
|
+
top: vars.top,
|
|
20
|
+
left: vars.left,
|
|
21
|
+
right: vars.right,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const base = style({
|
|
25
|
+
position: "relative",
|
|
26
|
+
display: "flex",
|
|
27
|
+
gap: themeVars.space['2'],
|
|
28
|
+
background: "#FFF",
|
|
29
|
+
boxShadow: themeVars.shadow.sm,
|
|
30
|
+
border: `1px solid ${themeVars.color.gray[100]}`,
|
|
31
|
+
borderRadius: "6px",
|
|
32
|
+
padding: "9px 12px",
|
|
33
|
+
pointerEvents: "all",
|
|
34
|
+
fontSize: themeVars.fontSize.base,
|
|
35
|
+
color: themeVars.color.gray[800],
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
transition: "top 0.3s ease-out 0.5s, bottom 0.3s ease-out 0.5s"
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const placement = styleVariants({
|
|
41
|
+
top: {
|
|
42
|
+
vars: {
|
|
43
|
+
[vars.top]: '12px',
|
|
44
|
+
[vars.left]: '0',
|
|
45
|
+
[vars.right]: '0',
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
['top-left']: {
|
|
49
|
+
vars: {
|
|
50
|
+
[vars.top]: '12px',
|
|
51
|
+
[vars.left]: '12px',
|
|
52
|
+
[vars.right]: 'unset',
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
['top-right']: {
|
|
56
|
+
vars: {
|
|
57
|
+
[vars.top]: '12px',
|
|
58
|
+
[vars.left]: 'unset',
|
|
59
|
+
[vars.right]: '12px',
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const icon = style({
|
|
65
|
+
alignSelf: 'center',
|
|
66
|
+
gridArea: '1 / 1 / 3',
|
|
67
|
+
width: '22px',
|
|
68
|
+
height: '22px',
|
|
69
|
+
color: vars.iconColor,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const message = style({
|
|
73
|
+
alignSelf: 'center',
|
|
74
|
+
gridArea: '1 / 2 / 3',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export const variant = styleVariants({
|
|
79
|
+
info: {
|
|
80
|
+
vars: {
|
|
81
|
+
[vars.iconColor]: themeVars.color.blue[500],
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
success: {
|
|
85
|
+
vars: {
|
|
86
|
+
[vars.iconColor]: themeVars.color.green[500],
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
warning: {
|
|
90
|
+
vars: {
|
|
91
|
+
[vars.iconColor]: themeVars.color.amber[500],
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
error: {
|
|
95
|
+
vars: {
|
|
96
|
+
[vars.iconColor]: themeVars.color.red[500],
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
default: {
|
|
100
|
+
vars: {
|
|
101
|
+
[vars.iconColor]: themeVars.color.gray[500],
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
loading: {
|
|
105
|
+
vars: {
|
|
106
|
+
[vars.iconColor]: themeVars.color.gray[500],
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Message.css";
|
|
@@ -6,8 +6,16 @@ export type MessageType =
|
|
|
6
6
|
| 'success'
|
|
7
7
|
| 'warning'
|
|
8
8
|
| 'error'
|
|
9
|
-
| 'loading'
|
|
10
9
|
| 'default'
|
|
10
|
+
| 'loading'
|
|
11
|
+
|
|
12
|
+
export type MessagePlacement =
|
|
13
|
+
| 'top'
|
|
14
|
+
| 'top-left'
|
|
15
|
+
| 'top-right'
|
|
16
|
+
| 'bottom'
|
|
17
|
+
| 'bottom-left'
|
|
18
|
+
| 'bottom-right'
|
|
11
19
|
|
|
12
20
|
export type MessageRenderMessage = (props: any) => VNodeChild
|
|
13
21
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport :to="'body'">
|
|
3
|
+
<Transition name="fade-out" mode="out-in" :enter-active-class="style.fadeBackgroundEnter"
|
|
4
|
+
:leave-active-class="style.fadeBackgroundLeave">
|
|
5
|
+
|
|
6
|
+
<div v-show="isOpen" :class="style.background" :style="{zIndex: zIndex}" @click="closeOutside">
|
|
7
|
+
<Transition name="fade-out" mode="out-in" :enter-active-class="style.fadeEnter"
|
|
8
|
+
:leave-active-class="style.fadeLeave" :enter-from-class="style.fadeEnterFrom">
|
|
9
|
+
|
|
10
|
+
<div v-if="isOpen" :class="containerClasses" @click.stop ref="target">
|
|
11
|
+
<div :class="style.header">
|
|
12
|
+
<div :class="style.title">
|
|
13
|
+
<div>
|
|
14
|
+
{{ title }}
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<button :class="style.close" @click="close">
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
<div :class="style.body">
|
|
21
|
+
<slot name="body"></slot>
|
|
22
|
+
</div>
|
|
23
|
+
<div :class="style.footer">
|
|
24
|
+
<slot name="footer"></slot>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
</Transition>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
</Transition>
|
|
33
|
+
</Teleport>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script lang="ts">
|
|
37
|
+
import type {PropType} from "vue";
|
|
38
|
+
import type {Size} from "../../types/props";
|
|
39
|
+
import {defineComponent, ref, computed, watch, nextTick} from 'vue';
|
|
40
|
+
import {useFocusTrap} from '@vueuse/integrations/useFocusTrap'
|
|
41
|
+
import * as style from './style';
|
|
42
|
+
import {useZIndex} from "../../composables/useZIndex";
|
|
43
|
+
|
|
44
|
+
export default defineComponent({
|
|
45
|
+
name: "MModal",
|
|
46
|
+
props: {
|
|
47
|
+
size: {
|
|
48
|
+
type: String as PropType<Size>,
|
|
49
|
+
default: 'md'
|
|
50
|
+
},
|
|
51
|
+
title: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ""
|
|
54
|
+
},
|
|
55
|
+
// TODO: if we add more transitions, we can add a prop to select which one to use.
|
|
56
|
+
// transition: {
|
|
57
|
+
// type: String,
|
|
58
|
+
// default: "scale",
|
|
59
|
+
// },
|
|
60
|
+
canClickOutside: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
64
|
+
zIndex: {
|
|
65
|
+
type: Number
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
emits: ['open'],
|
|
69
|
+
setup(props, {emit}) {
|
|
70
|
+
const {nextZIndex} = useZIndex();
|
|
71
|
+
const isOpen = ref(false);
|
|
72
|
+
const target = ref();
|
|
73
|
+
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
74
|
+
const {hasFocus, activate, deactivate} = useFocusTrap(target, {
|
|
75
|
+
immediate: true,
|
|
76
|
+
escapeDeactivates: false,
|
|
77
|
+
allowOutsideClick: true
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const containerClasses = computed(() => {
|
|
81
|
+
return [
|
|
82
|
+
style.container,
|
|
83
|
+
style.size[props.size],
|
|
84
|
+
];
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
const closeOutside = () => {
|
|
89
|
+
if (props.canClickOutside) {
|
|
90
|
+
isOpen.value = false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const close = () => {
|
|
95
|
+
isOpen.value = false;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const open = (element: HTMLElement | null) => {
|
|
99
|
+
isOpen.value = true;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
watch(() => isOpen.value, (value) => {
|
|
103
|
+
if (value) {
|
|
104
|
+
zIndex.value = props.zIndex ? zIndex.value++ : nextZIndex();
|
|
105
|
+
emit('open');
|
|
106
|
+
nextTick(() => {
|
|
107
|
+
activate()
|
|
108
|
+
})
|
|
109
|
+
} else {
|
|
110
|
+
deactivate()
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
close,
|
|
116
|
+
closeOutside,
|
|
117
|
+
open,
|
|
118
|
+
target,
|
|
119
|
+
style,
|
|
120
|
+
isOpen,
|
|
121
|
+
containerClasses,
|
|
122
|
+
zIndex
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MModal ref="modal" title="I am a modal" size="md" :canClickOutside="true" :canBounceOnOpen="false" :canSlideIn="true">
|
|
3
|
+
<template #body>
|
|
4
|
+
<div>
|
|
5
|
+
I am a body..
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<template #footer>
|
|
9
|
+
<div style="display: flex; flex-grow: 1; justify-content: end;">
|
|
10
|
+
<MButton variant="primary" @click="modal?.close()">
|
|
11
|
+
Okay
|
|
12
|
+
</MButton>
|
|
13
|
+
<MButton style="margin-left: 8px;" @click="modal?.close()">
|
|
14
|
+
Cancel
|
|
15
|
+
</MButton>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
</MModal>
|
|
19
|
+
|
|
20
|
+
<div style="position: relative; width: 100%; height: 1000px;">
|
|
21
|
+
<button @click="open" style="position: absolute; width: 100px; height: 50px; top: 0; left: 0;">Top Left</button>
|
|
22
|
+
<button @click="open" style="position: absolute; width: 100px; height: 50px; top: 0; right: 0;">Top Right</button>
|
|
23
|
+
<button @click="open" style="position: absolute; width: 100px; height: 50px; bottom: 0; left: 0;">Bottom
|
|
24
|
+
Left</button>
|
|
25
|
+
<button @click="open" style="position: absolute; width: 100px; height: 50px; bottom: 0; right: 0;">Bottom
|
|
26
|
+
Right</button>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import type { MButton } from '@/components';
|
|
32
|
+
import { ref } from 'vue'
|
|
33
|
+
|
|
34
|
+
const modal = ref<any>(null);
|
|
35
|
+
|
|
36
|
+
const open = (event: MouseEvent) => {
|
|
37
|
+
modal.value.open(event.target);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import MModal from "../Modal.vue";
|
|
2
|
+
import {
|
|
3
|
+
MModalBasic,
|
|
4
|
+
MModalForm
|
|
5
|
+
} from "./index";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
createStory, sizeArgType
|
|
9
|
+
} from "../../../__storybook__";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: MModal,
|
|
13
|
+
title: 'Components/Modal',
|
|
14
|
+
argTypes: {
|
|
15
|
+
...sizeArgType(),
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Basic = createStory(MModalBasic);
|
|
20
|
+
export const ModalForm = createStory(MModalForm);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MModal ref="modal" title="I am a modal" size="md" :canClickOutside="true" :canBounceOnOpen="false"
|
|
3
|
+
:canSlideIn="true">
|
|
4
|
+
<template #body>
|
|
5
|
+
<MForm @submit="onSubmit" :loading="loading" style="display: flex; flex-direction: column; gap: 10px;">
|
|
6
|
+
<MInput
|
|
7
|
+
label="Email"
|
|
8
|
+
placeholder="Email Address"
|
|
9
|
+
name="email"
|
|
10
|
+
v-model="email"
|
|
11
|
+
:rules="[rules.isRequired, rules.isEmail]"
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
<MInput
|
|
15
|
+
label="Name"
|
|
16
|
+
placeholder="Name"
|
|
17
|
+
name="name"
|
|
18
|
+
v-model="name"
|
|
19
|
+
:rules="[rules.isRequired]"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<MSelect
|
|
23
|
+
label="Option"
|
|
24
|
+
v-model="option"
|
|
25
|
+
:options="options"
|
|
26
|
+
:option-value="'id'"
|
|
27
|
+
:option-label="'name'"
|
|
28
|
+
:rules="[rules.isRequired]"
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
<MCheckbox
|
|
32
|
+
label="Agree to terms"
|
|
33
|
+
v-model="agree"
|
|
34
|
+
:rules="[rules.isRequired]"
|
|
35
|
+
>
|
|
36
|
+
Something here!
|
|
37
|
+
</MCheckbox>
|
|
38
|
+
|
|
39
|
+
<MColorPicker/>
|
|
40
|
+
|
|
41
|
+
</MForm>
|
|
42
|
+
</template>
|
|
43
|
+
<template #footer>
|
|
44
|
+
<div style="display: flex; flex-grow: 1; justify-content: end;">
|
|
45
|
+
<MButton variant="primary" @click="modal?.close()">
|
|
46
|
+
Okay
|
|
47
|
+
</MButton>
|
|
48
|
+
<MButton style="margin-left: 8px;" @click="modal?.close()">
|
|
49
|
+
Cancel
|
|
50
|
+
</MButton>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
</MModal>
|
|
54
|
+
|
|
55
|
+
<div style="position: relative; width: 100%; height: 1000px;">
|
|
56
|
+
<button @click="open" style="position: absolute; width: 100px; height: 50px; top: 0; left: 0;">Top Left</button>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<script lang="ts" setup>
|
|
61
|
+
import {MCheckbox, MSelect, MColorPicker} from '@/components';
|
|
62
|
+
import type {MButton} from '@/components';
|
|
63
|
+
import {ref} from 'vue'
|
|
64
|
+
|
|
65
|
+
const modal = ref<any>(null);
|
|
66
|
+
|
|
67
|
+
const open = (event: MouseEvent) => {
|
|
68
|
+
modal.value.open(event.target);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const rules = {
|
|
72
|
+
isEmail: (v: any) => /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) || 'E-mail must be valid',
|
|
73
|
+
isRequired: (v: any) => !!v || 'Field is required',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const options = Array.from({length: 50}, (_, i) => ({
|
|
77
|
+
id: i + 1,
|
|
78
|
+
name: `Option ${i + 1}`
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
const loading = ref(false);
|
|
82
|
+
const email = ref('');
|
|
83
|
+
const name = ref('');
|
|
84
|
+
const option = ref('');
|
|
85
|
+
const agree = ref(false);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
function onSubmit(valid: boolean) {
|
|
89
|
+
if (valid) {
|
|
90
|
+
loading.value = true;
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
console.log('submit', {email: email.value, name: name.value});
|
|
93
|
+
loading.value = false;
|
|
94
|
+
}, 3000);
|
|
95
|
+
} else {
|
|
96
|
+
console.log('invalid');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</script>
|