@teammodlr/ui-kit 1.0.6 → 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,13 +1,14 @@
|
|
|
1
1
|
import MButtonGroup from "../ButtonGroup.vue";
|
|
2
2
|
import MButton from "../../button/Button.vue";
|
|
3
3
|
import {
|
|
4
|
-
MButtonGroupBasic
|
|
4
|
+
MButtonGroupBasic,
|
|
5
|
+
MButtonGroupIconGroup
|
|
5
6
|
} from "./index";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
createStory,
|
|
9
10
|
sizeArgType
|
|
10
|
-
} from "
|
|
11
|
+
} from "../../../__storybook__";
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
component: MButtonGroup,
|
|
@@ -19,3 +20,4 @@ export default {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const Basic = createStory(MButtonGroupBasic);
|
|
23
|
+
export const IconGroup = createStory(MButtonGroupIconGroup);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {globalStyle, style} from "@vanilla-extract/css";
|
|
2
|
+
import {base as button} from "../../button/style/Button.css";
|
|
3
|
+
import {border as buttonBorder} from "../../button/style/Button.css";
|
|
4
|
+
import {borderState} from "../../button/style/Button.css";
|
|
5
|
+
|
|
6
|
+
export const base = style({
|
|
7
|
+
display: "inline-flex",
|
|
8
|
+
position: "relative",
|
|
9
|
+
flexWrap: "nowrap",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
globalStyle(`${base} > ${button}:first-child:not(:last-child)`, {
|
|
13
|
+
marginRight: 0,
|
|
14
|
+
borderTopRightRadius: 0,
|
|
15
|
+
borderBottomRightRadius: 0
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
globalStyle(`${base} > ${button}:not(:first-child):not(:last-child)`, {
|
|
19
|
+
marginLeft: 0,
|
|
20
|
+
borderRadius: 0,
|
|
21
|
+
marginRight: 0,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
globalStyle(`${base} > ${button}:not(:first-child) ${buttonBorder}`, {
|
|
25
|
+
borderLeftWidth: 0,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
globalStyle(`${base} > ${button}:last-child:not(:first-child)`, {
|
|
29
|
+
marginLeft: 0,
|
|
30
|
+
borderTopLeftRadius: 0,
|
|
31
|
+
borderBottomLeftRadius: 0
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
globalStyle(`${base} > ${button}:not(:first-child) ${borderState}`, {
|
|
35
|
+
left: '-1px'
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const vertical = style({
|
|
39
|
+
flexDirection: "column",
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonGroup.css';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<input
|
|
2
|
+
<label :class="style.base" @click.prevent="toggle">
|
|
3
|
+
<input
|
|
5
4
|
v-model="checked"
|
|
6
5
|
type="checkbox"
|
|
7
6
|
:aria-checked="checked ? 'true' : 'false'"
|
|
@@ -10,33 +9,47 @@
|
|
|
10
9
|
:disabled="disabled || loading"
|
|
11
10
|
:name="name"
|
|
12
11
|
:id="id"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
:class="style.input"
|
|
13
|
+
v-bind="$attrs"
|
|
14
|
+
v-on="inputListeners"
|
|
15
|
+
/>
|
|
16
|
+
<span :class="classes">
|
|
17
|
+
<svg v-if="checked && !indeterminate" :class="style.checkmark" xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
fill="none" viewBox="0 0 24 24" width="24" height="24" focusable="false"><path fill="currentColor"
|
|
19
|
+
fill-rule="evenodd"
|
|
20
|
+
d="m21.042 6.855-11.34 11.17-6.398-7.178L5.096 9.25l4.72 5.294 9.542-9.399 1.684 1.71z"
|
|
21
|
+
clip-rule="evenodd"></path></svg>
|
|
22
|
+
<svg v-if="indeterminate && !checked" :class="style.checkmark" xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
fill="none" viewBox="0 0 24 24" width="24" height="24" focusable="false"><path fill="currentColor"
|
|
24
|
+
fill-rule="evenodd"
|
|
25
|
+
d="M21.3 13.2H2.8v-2.4h18.5v2.4z"
|
|
26
|
+
clip-rule="evenodd"></path></svg>
|
|
27
|
+
</span>
|
|
28
|
+
<span :class="style.label" :id="`${id}-label`">
|
|
29
|
+
<template v-if="hasSlot">
|
|
30
|
+
<slot/>
|
|
31
|
+
</template>
|
|
32
|
+
<template v-else>
|
|
33
|
+
{{ label }}
|
|
34
|
+
</template>
|
|
35
|
+
</span>
|
|
36
|
+
|
|
37
|
+
</label>
|
|
28
38
|
</template>
|
|
29
39
|
|
|
30
40
|
<script lang="ts">
|
|
31
|
-
import { defineComponent,
|
|
32
|
-
import {
|
|
33
|
-
import
|
|
41
|
+
import {computed, defineComponent, defineExpose, type PropType, ref, toRef, watch} from 'vue';
|
|
42
|
+
import {useInput} from '../../composables/useInput';
|
|
43
|
+
import {useInteractive} from "../../composables/useInteractive";
|
|
44
|
+
import type {Size} from '../../types/props';
|
|
45
|
+
import * as style from './style';
|
|
34
46
|
|
|
35
47
|
export default defineComponent({
|
|
36
48
|
name: "Checkbox",
|
|
37
49
|
emits: useInput.emits(),
|
|
38
50
|
props: {
|
|
39
51
|
...useInput.props(),
|
|
52
|
+
...useInteractive.props(),
|
|
40
53
|
label: {
|
|
41
54
|
type: String
|
|
42
55
|
},
|
|
@@ -44,10 +57,6 @@ export default defineComponent({
|
|
|
44
57
|
type: String as PropType<Size>,
|
|
45
58
|
default: 'md',
|
|
46
59
|
},
|
|
47
|
-
color: {
|
|
48
|
-
type: String as PropType<Color>,
|
|
49
|
-
default: 'blue',
|
|
50
|
-
},
|
|
51
60
|
disabled: {
|
|
52
61
|
type: Boolean,
|
|
53
62
|
default: false
|
|
@@ -55,10 +64,16 @@ export default defineComponent({
|
|
|
55
64
|
loading: {
|
|
56
65
|
type: Boolean,
|
|
57
66
|
default: false
|
|
58
|
-
}
|
|
67
|
+
},
|
|
68
|
+
indeterminate: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
59
72
|
},
|
|
60
|
-
setup(props, {
|
|
61
|
-
const
|
|
73
|
+
setup(props, {slots, emit}) {
|
|
74
|
+
const checkboxRef = ref<HTMLElement | null>(null);
|
|
75
|
+
|
|
76
|
+
const {focus, blur} = useInteractive(checkboxRef);
|
|
62
77
|
|
|
63
78
|
const {
|
|
64
79
|
id,
|
|
@@ -68,53 +83,53 @@ export default defineComponent({
|
|
|
68
83
|
setError,
|
|
69
84
|
formError,
|
|
70
85
|
formDisabled,
|
|
71
|
-
formLoading
|
|
72
|
-
|
|
86
|
+
formLoading,
|
|
87
|
+
inputListeners
|
|
88
|
+
} = useInput(props, {focus, emit});
|
|
73
89
|
|
|
74
|
-
const disabled = computed(() => formDisabled || props.disabled);
|
|
75
|
-
const loading = computed(() => formLoading || props.loading);
|
|
90
|
+
const disabled = computed(() => formDisabled || props.disabled || props.loading);
|
|
76
91
|
const name = toRef(props, 'name');
|
|
77
92
|
const checked = ref(false);
|
|
78
|
-
const checkboxRef = ref<HTMLElement | null>(null);
|
|
79
93
|
const hasSlot = computed(() => !!(slots.default));
|
|
80
94
|
|
|
81
|
-
const
|
|
95
|
+
const classes = computed(() => {
|
|
82
96
|
return [
|
|
83
|
-
|
|
97
|
+
style.checkbox,
|
|
98
|
+
[style.size[props.size]],
|
|
84
99
|
{
|
|
85
|
-
|
|
100
|
+
[style.disabled]: disabled.value,
|
|
101
|
+
[style.checked]: checked.value,
|
|
102
|
+
[style.indeterminate]: props.indeterminate,
|
|
86
103
|
}
|
|
87
104
|
]
|
|
88
105
|
});
|
|
89
106
|
|
|
90
|
-
const checkboxComputedClass = computed(() => {
|
|
91
|
-
return {
|
|
92
|
-
'm-checkbox': true,
|
|
93
|
-
'm-checkbox--checked': checked.value,
|
|
94
|
-
'm-checkbox--disabled': disabled.value || loading.value,
|
|
95
|
-
'm-checkbox--error': formError.value,
|
|
96
|
-
[`m-checkbox--${props.size}`]: true,
|
|
97
|
-
[`m-checkbox--${props.color}`]: true,
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
107
|
const inputError = computed(() => {
|
|
102
108
|
return formError.value || props.error;
|
|
103
109
|
});
|
|
104
110
|
|
|
105
111
|
watch(() => props.modelValue, (value) => {
|
|
106
112
|
checked.value = !!value;
|
|
107
|
-
}, {
|
|
113
|
+
}, {immediate: true});
|
|
108
114
|
|
|
109
115
|
watch(() => checked.value, (value) => {
|
|
110
116
|
emit('update:modelValue', value);
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
function toggle() {
|
|
114
|
-
if (disabled.value)
|
|
120
|
+
if (disabled.value) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (props.indeterminate) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
115
126
|
checked.value = !checked.value;
|
|
116
127
|
}
|
|
117
128
|
|
|
129
|
+
defineExpose({
|
|
130
|
+
focus,
|
|
131
|
+
blur,
|
|
132
|
+
})
|
|
118
133
|
|
|
119
134
|
return {
|
|
120
135
|
id,
|
|
@@ -124,16 +139,17 @@ export default defineComponent({
|
|
|
124
139
|
validate,
|
|
125
140
|
setError,
|
|
126
141
|
disabled,
|
|
127
|
-
loading,
|
|
128
142
|
name,
|
|
129
143
|
checked,
|
|
130
144
|
checkboxRef,
|
|
131
145
|
inputError,
|
|
132
146
|
toggle,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
style,
|
|
148
|
+
classes,
|
|
149
|
+
hasSlot,
|
|
150
|
+
inputListeners,
|
|
151
|
+
focus,
|
|
152
|
+
blur
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
})
|
|
@@ -0,0 +1,127 @@
|
|
|
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: '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]: '4px',
|
|
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
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const disabled = style({
|
|
77
|
+
opacity: 0.5,
|
|
78
|
+
cursor: 'not-allowed',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const indeterminate = style({
|
|
82
|
+
vars: {
|
|
83
|
+
[vars.borderColor]: themeVars.color.blue[500],
|
|
84
|
+
[vars.backgroundColor]: themeVars.color.blue[500],
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const label = style({
|
|
89
|
+
marginLeft: themeVars.space['0.5'],
|
|
90
|
+
fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
|
|
91
|
+
display: 'inline-block',
|
|
92
|
+
fontSize: themeVars.fontSize.base,
|
|
93
|
+
wordBreak: 'break-word',
|
|
94
|
+
cursor: 'pointer',
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
export const size = styleVariants({
|
|
98
|
+
xs: {
|
|
99
|
+
vars: {
|
|
100
|
+
[vars.height]: sizes.xs
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
sm: {
|
|
104
|
+
vars: {
|
|
105
|
+
[vars.height]: sizes.sm
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
md: {
|
|
109
|
+
vars: {
|
|
110
|
+
[vars.height]: sizes.md
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
lg: {
|
|
114
|
+
vars: {
|
|
115
|
+
[vars.height]: sizes.lg,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
xl: {
|
|
119
|
+
vars: {
|
|
120
|
+
[vars.height]: sizes.xl,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
globalStyle(`${base} ${input}:focus + ${checkbox}`, {
|
|
126
|
+
boxShadow: `0 0 0 2px ${themeVars.color.blue[100]}`,
|
|
127
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Checkbox.css'
|