@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {createVar, globalKeyframes, globalStyle, style, styleVariants} from "@vanilla-extract/css";
|
|
2
|
+
import { themeVars } from "../../../styles/theme.css";
|
|
3
|
+
import { fonts} from "../../../styles/typography.css";
|
|
4
|
+
|
|
5
|
+
const sizes = {
|
|
6
|
+
xs: '16px',
|
|
7
|
+
sm: '18px',
|
|
8
|
+
md: '20px',
|
|
9
|
+
lg: '22px',
|
|
10
|
+
xl: '24px',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const vars = {
|
|
14
|
+
height: createVar(),
|
|
15
|
+
radius: createVar(),
|
|
16
|
+
backgroundColor: createVar(),
|
|
17
|
+
borderColor: createVar(),
|
|
18
|
+
color: createVar()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const base = style({
|
|
22
|
+
position: "relative",
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
cursor: "pointer",
|
|
26
|
+
gap: themeVars.space['1.5'],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const input = style({
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
opacity: 0,
|
|
32
|
+
cursor: "pointer"
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const checkmark = style({
|
|
36
|
+
position: "absolute",
|
|
37
|
+
width: `calc(${vars.height} - 2px)`,
|
|
38
|
+
height: `calc(${vars.height} - 2px)`,
|
|
39
|
+
top: "50%",
|
|
40
|
+
left: "50%",
|
|
41
|
+
transform: "translate(-50%, -50%)",
|
|
42
|
+
color: "white",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const checkbox = style({
|
|
46
|
+
vars: {
|
|
47
|
+
[vars.height]: sizes.md,
|
|
48
|
+
[vars.radius]: themeVars.rounded.full,
|
|
49
|
+
[vars.backgroundColor]: 'white',
|
|
50
|
+
[vars.borderColor]: themeVars.color.gray[300],
|
|
51
|
+
[vars.color]: themeVars.color.gray[600],
|
|
52
|
+
},
|
|
53
|
+
position: "relative",
|
|
54
|
+
width: vars.height,
|
|
55
|
+
height: vars.height,
|
|
56
|
+
borderRadius: vars.radius,
|
|
57
|
+
backgroundColor: vars.backgroundColor,
|
|
58
|
+
border: `1px solid ${vars.borderColor}`,
|
|
59
|
+
color: vars.color,
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
transition: `all 0.125s ${themeVars.transition.default}`
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const checked = style({
|
|
65
|
+
vars: {
|
|
66
|
+
[vars.borderColor]: themeVars.color.blue[500],
|
|
67
|
+
[vars.backgroundColor]: themeVars.color.blue[500],
|
|
68
|
+
},
|
|
69
|
+
selectors: {
|
|
70
|
+
['&:after']: {
|
|
71
|
+
content: '',
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
top: '50%',
|
|
74
|
+
left: '50%',
|
|
75
|
+
transform: 'translate(-50%, -50%)',
|
|
76
|
+
width: `calc(${vars.height} - 10px)`,
|
|
77
|
+
height: `calc(${vars.height} - 10px)`,
|
|
78
|
+
borderRadius: themeVars.rounded.full,
|
|
79
|
+
backgroundColor: "#FFF"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const disabled = style({
|
|
85
|
+
opacity: 0.5,
|
|
86
|
+
cursor: 'not-allowed',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const indeterminate = style({
|
|
90
|
+
vars: {
|
|
91
|
+
[vars.borderColor]: themeVars.color.blue[500],
|
|
92
|
+
[vars.backgroundColor]: themeVars.color.blue[500],
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const label = style({
|
|
97
|
+
marginLeft: themeVars.space['0.5'],
|
|
98
|
+
fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
|
|
99
|
+
display: 'inline-block',
|
|
100
|
+
fontSize: themeVars.fontSize.base,
|
|
101
|
+
wordBreak: 'break-word',
|
|
102
|
+
cursor: 'pointer',
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
export const size = styleVariants({
|
|
106
|
+
xs: {
|
|
107
|
+
vars: {
|
|
108
|
+
[vars.height]: sizes.xs
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
sm: {
|
|
112
|
+
vars: {
|
|
113
|
+
[vars.height]: sizes.sm
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
md: {
|
|
117
|
+
vars: {
|
|
118
|
+
[vars.height]: sizes.md
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
lg: {
|
|
122
|
+
vars: {
|
|
123
|
+
[vars.height]: sizes.lg,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
xl: {
|
|
127
|
+
vars: {
|
|
128
|
+
[vars.height]: sizes.xl,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Checkbox.css'
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :class="computedClasses" :disabled="disabled" @click="handleClick" v-bind="$attrs" :aria-selected="selected" :aria-disabled="disabled">
|
|
3
|
+
<input type="radio" :class="computedRadioClasses" :name="name" :value="id" :disabled="disabled">
|
|
4
|
+
<span>
|
|
5
|
+
<slot />
|
|
6
|
+
</span>
|
|
7
|
+
</label>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import type {PropType} from "vue";
|
|
12
|
+
import {computed, defineComponent, defineExpose, inject, ref} from "vue";
|
|
13
|
+
import type {Size} from "../../types/props";
|
|
14
|
+
import * as style from "./style";
|
|
15
|
+
import {useInteractive} from "../../composables/useInteractive";
|
|
16
|
+
import {useInput} from "../../composables/useInput";
|
|
17
|
+
import {RADIO_BUTTON_GROUP_STATE} from "../radiobuttongroup/symbol";
|
|
18
|
+
|
|
19
|
+
export default defineComponent({
|
|
20
|
+
name: "MRadioButton",
|
|
21
|
+
props: {
|
|
22
|
+
...useInput.props(),
|
|
23
|
+
...useInteractive.props(),
|
|
24
|
+
id: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'button',
|
|
31
|
+
},
|
|
32
|
+
size: {
|
|
33
|
+
type: String as PropType<Size>,
|
|
34
|
+
default: 'md'
|
|
35
|
+
},
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
icon: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
onClick: {
|
|
45
|
+
type: Function as PropType<(e: MouseEvent) => void>,
|
|
46
|
+
default: () => {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
emits: ['update:modelValue'],
|
|
51
|
+
setup(props, {emit}) {
|
|
52
|
+
const radioRef = ref<HTMLElement | null>(null);
|
|
53
|
+
const parentState = inject(RADIO_BUTTON_GROUP_STATE, null);
|
|
54
|
+
const value = computed(() => {
|
|
55
|
+
return parentState?.modelValue;
|
|
56
|
+
});
|
|
57
|
+
const sizeValue = computed<Size>(() => {
|
|
58
|
+
return parentState?.size || props.size;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const name = computed(() => {
|
|
62
|
+
return parentState?.name;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const {focus, blur} = useInteractive(radioRef);
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
id,
|
|
69
|
+
insideForm,
|
|
70
|
+
reset,
|
|
71
|
+
validate,
|
|
72
|
+
setError,
|
|
73
|
+
formError,
|
|
74
|
+
formDisabled,
|
|
75
|
+
formLoading,
|
|
76
|
+
inputListeners
|
|
77
|
+
} = useInput(props, {focus, emit});
|
|
78
|
+
|
|
79
|
+
const selected = computed(() => {
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
return value.value === props.id;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const computedClasses = computed(() => {
|
|
85
|
+
return [
|
|
86
|
+
style.base,
|
|
87
|
+
[style.size[sizeValue.value]],
|
|
88
|
+
{
|
|
89
|
+
[style.icon]: props.icon,
|
|
90
|
+
[style.variant.default]: !selected.value,
|
|
91
|
+
[style.variant.active]: selected.value,
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const computedRadioClasses = computed(() => {
|
|
97
|
+
return [
|
|
98
|
+
style.radio
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const handleClick = (e: MouseEvent): void => {
|
|
103
|
+
if (props.disabled) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
parentState.doUpdateValue(props.id);
|
|
110
|
+
props.onClick(e);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
defineExpose({
|
|
114
|
+
focus,
|
|
115
|
+
blur,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
radioRef,
|
|
120
|
+
computedClasses,
|
|
121
|
+
handleClick,
|
|
122
|
+
selected,
|
|
123
|
+
value,
|
|
124
|
+
name,
|
|
125
|
+
focus,
|
|
126
|
+
blur,
|
|
127
|
+
computedRadioClasses
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
</script>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {createVar, globalStyle, style, styleVariants} from "@vanilla-extract/css";
|
|
2
|
+
import {themeVars} from "../../../styles/theme.css";
|
|
3
|
+
import {fonts} from "../../../styles/typography.css";
|
|
4
|
+
|
|
5
|
+
const sizes = {
|
|
6
|
+
xs: '22px',
|
|
7
|
+
sm: '28px',
|
|
8
|
+
md: '36px',
|
|
9
|
+
lg: '40px',
|
|
10
|
+
xl: '45px',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const borderRadiuses = {
|
|
14
|
+
xs: '2px',
|
|
15
|
+
sm: '3px',
|
|
16
|
+
md: '4px',
|
|
17
|
+
lg: '6px',
|
|
18
|
+
xl: '8px',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const padding = {
|
|
22
|
+
xs: `0 ${themeVars.space[1]}`,
|
|
23
|
+
sm: `0 ${themeVars.space[2]}`,
|
|
24
|
+
md: `0 ${themeVars.space[3]}`,
|
|
25
|
+
lg: `0 ${themeVars.space[3]}`,
|
|
26
|
+
xl: `0 ${themeVars.space[4]}`,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const vars = {
|
|
30
|
+
height: createVar(),
|
|
31
|
+
radius: createVar(),
|
|
32
|
+
padding: createVar(),
|
|
33
|
+
backgroundColor: createVar(),
|
|
34
|
+
borderColor: createVar(),
|
|
35
|
+
boxShadowColor: createVar(),
|
|
36
|
+
color: createVar(),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const base = style({
|
|
40
|
+
vars: {
|
|
41
|
+
[vars.borderColor]: "transparent",
|
|
42
|
+
},
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
boxSizing: 'border-box',
|
|
45
|
+
display: 'inline-flex',
|
|
46
|
+
fontSize: themeVars.fontSize.base,
|
|
47
|
+
fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
|
|
48
|
+
maxWidth: '100%',
|
|
49
|
+
width: 'auto',
|
|
50
|
+
position: 'relative',
|
|
51
|
+
textAlign: 'center',
|
|
52
|
+
textDecoration: 'none',
|
|
53
|
+
verticalAlign: 'middle',
|
|
54
|
+
whiteSpace: 'nowrap',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
height: vars.height,
|
|
57
|
+
lineHeight: vars.height,
|
|
58
|
+
borderRadius: vars.radius,
|
|
59
|
+
padding: vars.padding,
|
|
60
|
+
zIndex: "auto",
|
|
61
|
+
backgroundColor: vars.backgroundColor,
|
|
62
|
+
border: `1px solid ${vars.borderColor}`,
|
|
63
|
+
color: vars.color,
|
|
64
|
+
transition: `color .3s ${themeVars.transition.default},
|
|
65
|
+
background-color .3s ${themeVars.transition.default},
|
|
66
|
+
box-shadow .3s ${themeVars.transition.default},
|
|
67
|
+
border-color .3s ${themeVars.transition.default}`,
|
|
68
|
+
fontFamily: 'inherit',
|
|
69
|
+
':hover': {
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
},
|
|
72
|
+
':focus': {
|
|
73
|
+
outline: 'none',
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const variant = styleVariants({
|
|
78
|
+
active: {
|
|
79
|
+
vars: {
|
|
80
|
+
[vars.backgroundColor]: "white",
|
|
81
|
+
[vars.color]: themeVars.color.blue[500],
|
|
82
|
+
[vars.boxShadowColor]: themeVars.color.gray[900],
|
|
83
|
+
[vars.borderColor]: themeVars.color.gray[200],
|
|
84
|
+
},
|
|
85
|
+
boxShadow: `0 .5px 0px 4px rgba(0, 0, 0, 0.01)`,
|
|
86
|
+
':hover': {
|
|
87
|
+
vars: {
|
|
88
|
+
[vars.color]: themeVars.color.blue[600],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
':focus': {
|
|
92
|
+
vars: {
|
|
93
|
+
[vars.color]: themeVars.color.blue[500],
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
default: {
|
|
98
|
+
vars: {
|
|
99
|
+
[vars.color]: themeVars.color.gray[400],
|
|
100
|
+
[vars.backgroundColor]: 'transparent',
|
|
101
|
+
[vars.boxShadowColor]: themeVars.color.blue[500],
|
|
102
|
+
[vars.borderColor]: "transparent",
|
|
103
|
+
},
|
|
104
|
+
':hover': {
|
|
105
|
+
vars: {
|
|
106
|
+
[vars.color]: themeVars.color.blue[400],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
':focus': {
|
|
110
|
+
vars: {
|
|
111
|
+
[vars.color]: themeVars.color.blue[400],
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const size = styleVariants({
|
|
118
|
+
xs: {
|
|
119
|
+
vars: {
|
|
120
|
+
[vars.height]: sizes.xs,
|
|
121
|
+
[vars.radius]: borderRadiuses.xs,
|
|
122
|
+
[vars.padding]: padding.xs,
|
|
123
|
+
},
|
|
124
|
+
fontSize: themeVars.fontSize.small,
|
|
125
|
+
},
|
|
126
|
+
sm: {
|
|
127
|
+
vars: {
|
|
128
|
+
[vars.height]: sizes.sm,
|
|
129
|
+
[vars.radius]: borderRadiuses.sm,
|
|
130
|
+
[vars.padding]: padding.sm,
|
|
131
|
+
},
|
|
132
|
+
fontSize: themeVars.fontSize.small,
|
|
133
|
+
},
|
|
134
|
+
md: {
|
|
135
|
+
vars: {
|
|
136
|
+
[vars.height]: sizes.md,
|
|
137
|
+
[vars.radius]: borderRadiuses.md,
|
|
138
|
+
[vars.padding]: padding.md,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
lg: {
|
|
142
|
+
vars: {
|
|
143
|
+
[vars.height]: sizes.lg,
|
|
144
|
+
[vars.radius]: borderRadiuses.lg,
|
|
145
|
+
[vars.padding]: padding.lg,
|
|
146
|
+
},
|
|
147
|
+
fontSize: themeVars.fontSize.large,
|
|
148
|
+
},
|
|
149
|
+
xl: {
|
|
150
|
+
vars: {
|
|
151
|
+
[vars.height]: sizes.xl,
|
|
152
|
+
[vars.radius]: borderRadiuses.xl,
|
|
153
|
+
[vars.padding]: padding.xl,
|
|
154
|
+
},
|
|
155
|
+
fontSize: themeVars.fontSize.large,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export const icon = style({
|
|
160
|
+
display: 'flex',
|
|
161
|
+
flexGrow: 0,
|
|
162
|
+
flexShrink: 0,
|
|
163
|
+
fontSize: 0,
|
|
164
|
+
lineHeight: 0,
|
|
165
|
+
userSelect: 'none'
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
globalStyle(`${icon} > svg`, {
|
|
169
|
+
overflow: 'hidden',
|
|
170
|
+
pointerEvents: 'none',
|
|
171
|
+
maxWidth: '100%',
|
|
172
|
+
maxHeight: '100%',
|
|
173
|
+
verticalAlign: 'middle'
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const radio = style({
|
|
177
|
+
pointerEvents: "none",
|
|
178
|
+
position: "absolute",
|
|
179
|
+
border: 0,
|
|
180
|
+
left: 0,
|
|
181
|
+
right: 0,
|
|
182
|
+
top: 0,
|
|
183
|
+
bottom: 0,
|
|
184
|
+
opacity: 0
|
|
185
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RadioButton.css';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="computedClasses"
|
|
4
|
+
>
|
|
5
|
+
<slot/>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import {computed, defineComponent, type PropType, provide, reactive, toRef} from "vue";
|
|
11
|
+
import type {Size} from '../../types/props';
|
|
12
|
+
import * as style from "./style";
|
|
13
|
+
import type {RadioButtonGroupState} from "./symbol";
|
|
14
|
+
import {RADIO_BUTTON_GROUP_STATE} from "./symbol";
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name: "MRadioButtonGroup",
|
|
18
|
+
props: {
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: String as PropType<Size>,
|
|
25
|
+
default: 'md'
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
block: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
emits: ['update:modelValue'],
|
|
37
|
+
setup(props, {emit}) {
|
|
38
|
+
|
|
39
|
+
function doUpdateValue (value: string | number) {
|
|
40
|
+
emit('update:modelValue', value)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const selectedValue = computed({
|
|
44
|
+
get() {
|
|
45
|
+
return props.modelValue;
|
|
46
|
+
},
|
|
47
|
+
set(value) {
|
|
48
|
+
doUpdateValue(value);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const state: RadioButtonGroupState = reactive({
|
|
53
|
+
size: toRef(props, 'size'),
|
|
54
|
+
name: toRef(props, 'name'),
|
|
55
|
+
modelValue: selectedValue,
|
|
56
|
+
doUpdateValue
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
provide(RADIO_BUTTON_GROUP_STATE, state);
|
|
60
|
+
|
|
61
|
+
const computedClasses = computed(() => {
|
|
62
|
+
return [
|
|
63
|
+
style.base,
|
|
64
|
+
{
|
|
65
|
+
[style.block]: props.block
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
computedClasses
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MRadioButtonGroup v-model="value" size="sm" name="text-align">
|
|
3
|
+
<MRadioButton icon id="left-align">
|
|
4
|
+
<svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 10h14M3 6h18M3 18h14M3 14h18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
|
|
5
|
+
</MRadioButton>
|
|
6
|
+
<MRadioButton icon id="center-align">
|
|
7
|
+
<svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 6h18M3 14h18M6 10h12M6 18h12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
|
|
8
|
+
</MRadioButton>
|
|
9
|
+
<MRadioButton icon id="right-align">
|
|
10
|
+
<svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 10h14M3 6h18M7 18h14M3 14h18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
|
|
11
|
+
</MRadioButton>
|
|
12
|
+
</MRadioButtonGroup>
|
|
13
|
+
</template>
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { ref } from 'vue'
|
|
16
|
+
const value = ref("left-align");
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import MRadioButtonGroup from "../RadioButtonGroup.vue";
|
|
2
|
+
import MRadioButton from "../../radiobutton/RadioButton.vue";
|
|
3
|
+
import {
|
|
4
|
+
MRadioButtonGroupBasic,
|
|
5
|
+
} from "./index";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
createStory, sizeArgType, colorArgType
|
|
9
|
+
} from "../../../__storybook__";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: MRadioButtonGroup,
|
|
13
|
+
subcomponents: {
|
|
14
|
+
MRadioButton
|
|
15
|
+
},
|
|
16
|
+
title: 'Components/Radio Button Group',
|
|
17
|
+
argTypes: {
|
|
18
|
+
...sizeArgType(),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Basic = createStory(MRadioButtonGroupBasic);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {createVar, globalStyle, style} from "@vanilla-extract/css";
|
|
2
|
+
import {base as button} from "../../radiobutton/style/RadioButton.css";
|
|
3
|
+
import {themeVars} from "../../../styles/theme.css";
|
|
4
|
+
|
|
5
|
+
const vars = {
|
|
6
|
+
padding: createVar(),
|
|
7
|
+
borderRadius: createVar(),
|
|
8
|
+
gap: createVar()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const base = style({
|
|
12
|
+
vars: {
|
|
13
|
+
[vars.padding]: themeVars.space[1],
|
|
14
|
+
[vars.borderRadius]: themeVars.rounded.default,
|
|
15
|
+
[vars.gap]: themeVars.space[1],
|
|
16
|
+
},
|
|
17
|
+
display: "inline-flex",
|
|
18
|
+
position: "relative",
|
|
19
|
+
flexWrap: "nowrap",
|
|
20
|
+
backgroundColor: themeVars.color.gray[100],
|
|
21
|
+
padding: vars.padding,
|
|
22
|
+
borderRadius: vars.borderRadius,
|
|
23
|
+
gap: vars.gap,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const vertical = style({
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const block = style({
|
|
31
|
+
display: "flex",
|
|
32
|
+
alignItems: "stretch",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
globalStyle(`${base}${block} > ${button}`, {
|
|
36
|
+
flex: 1,
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RadioButtonGroup.css';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type {InjectionKey} from "vue";
|
|
2
|
+
import type {Size} from "../../types/props";
|
|
3
|
+
|
|
4
|
+
export interface RadioButtonGroupState {
|
|
5
|
+
size: Size,
|
|
6
|
+
name: string,
|
|
7
|
+
modelValue: string | number,
|
|
8
|
+
doUpdateValue: (value: string | number) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const RADIO_BUTTON_GROUP_STATE: InjectionKey<RadioButtonGroupState> = Symbol('RADIO_BUTTON_GROUP_STATE');
|