@veritree/ui 0.20.1 → 0.21.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/.prettierrc +2 -1
- package/index.js +64 -68
- package/mixins/floating-ui-content.js +81 -0
- package/mixins/floating-ui-item.js +266 -0
- package/mixins/floating-ui.js +67 -0
- package/mixins/form-control-icon.js +53 -0
- package/mixins/form-control.js +71 -0
- package/nuxt.js +30 -23
- package/package.json +9 -4
- package/src/components/Alert/VTAlert.vue +55 -14
- package/src/components/Avatar/VTAvatar.vue +32 -29
- package/src/components/Button/VTButton.vue +20 -7
- package/src/components/Checkbox/VTCheckbox.vue +134 -0
- package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
- package/src/components/Checkbox/VTCheckboxText.vue +20 -0
- package/src/components/Dialog/VTDialog.vue +22 -32
- package/src/components/Dialog/VTDialogClose.vue +19 -25
- package/src/components/Dialog/VTDialogContent.vue +24 -19
- package/src/components/Dialog/VTDialogFooter.vue +11 -16
- package/src/components/Dialog/VTDialogHeader.vue +16 -18
- package/src/components/Dialog/VTDialogMain.vue +11 -18
- package/src/components/Dialog/VTDialogOverlay.vue +14 -18
- package/src/components/Dialog/VTDialogTitle.vue +10 -7
- package/src/components/Disclosure/VTDisclosureContent.vue +1 -1
- package/src/components/Disclosure/VTDisclosureDetails.vue +1 -1
- package/src/components/Disclosure/VTDisclosureHeader.vue +2 -2
- package/src/components/Disclosure/VTDisclosureIcon.vue +1 -1
- package/src/components/Drawer/VTDrawer.vue +6 -15
- package/src/components/Drawer/VTDrawerClose.vue +5 -5
- package/src/components/Drawer/VTDrawerContent.vue +9 -9
- package/src/components/Drawer/VTDrawerFooter.vue +3 -3
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +45 -28
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +29 -64
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +8 -14
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +11 -124
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +3 -12
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +91 -121
- package/src/components/Form/VTFormFeedback.vue +39 -22
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +40 -0
- package/src/components/Form/VTInputIcon.vue +35 -0
- package/src/components/Form/VTInputPassword.vue +55 -0
- package/src/components/Form/VTTextarea.vue +22 -0
- package/src/components/Listbox/VTListbox.vue +122 -50
- package/src/components/Listbox/VTListboxContent.vue +20 -116
- package/src/components/Listbox/VTListboxItem.vue +115 -166
- package/src/components/Listbox/VTListboxLabel.vue +3 -14
- package/src/components/Listbox/VTListboxList.vue +10 -40
- package/src/components/Listbox/VTListboxSearch.vue +76 -68
- package/src/components/Listbox/VTListboxTrigger.vue +75 -86
- package/src/components/Popover/VTPopover.vue +42 -29
- package/src/components/Popover/VTPopoverContent.vue +24 -59
- package/src/components/Popover/VTPopoverDivider.vue +4 -11
- package/src/components/Popover/VTPopoverItem.vue +21 -14
- package/src/components/Popover/VTPopoverTrigger.vue +126 -21
- package/src/components/ProgressBar/VTProgressBar.vue +21 -3
- package/src/components/Skeleton/VTSkeleton.vue +11 -0
- package/src/components/Skeleton/VTSkeletonItem.vue +9 -0
- package/src/components/Tabs/VTTab.vue +4 -3
- package/src/components/Tabs/VTTabGroup.vue +9 -7
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Tooltip/VTTooltip.vue +65 -0
- package/src/components/Tooltip/VTTooltipContent.vue +59 -0
- package/src/components/Tooltip/VTTooltipTrigger.vue +98 -0
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +93 -0
- package/src/components/Input/VTInput.vue +0 -82
- package/src/components/Input/VTInputDate.vue +0 -36
- package/src/components/Input/VTInputFile.vue +0 -60
- package/src/components/Input/VTInputUpload.vue +0 -54
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const formControlMixin = {
|
|
2
|
+
props: {
|
|
3
|
+
disabled: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
default: false,
|
|
6
|
+
},
|
|
7
|
+
headless: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: [String, Number, Object, Array],
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
variant: {
|
|
16
|
+
type: [String, Object, Function],
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
computed: {
|
|
22
|
+
attrsComputed() {
|
|
23
|
+
// `Object.assign` merges objects together to form a new object
|
|
24
|
+
return Object.assign(
|
|
25
|
+
{},
|
|
26
|
+
// We add all the listeners from the parent
|
|
27
|
+
this.$attrs,
|
|
28
|
+
// Then we can add custom listeners or override the
|
|
29
|
+
// behavior of some listeners.
|
|
30
|
+
{
|
|
31
|
+
// This ensures that the component works with v-model
|
|
32
|
+
onInput: (event) => {
|
|
33
|
+
// if (this.lazy) return;
|
|
34
|
+
this.$emit('update:modelValue', event.target.value);
|
|
35
|
+
},
|
|
36
|
+
onBlur: (event) => {
|
|
37
|
+
this.$emit('blur', event);
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
isError() {
|
|
44
|
+
return this.variant === 'error';
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const formControlStyleMixin = {
|
|
50
|
+
computed: {
|
|
51
|
+
classComputed() {
|
|
52
|
+
return [
|
|
53
|
+
this.headless
|
|
54
|
+
? `${this.name}`
|
|
55
|
+
: 'leading-0 flex outline-none w-full max-w-full appearance-none items-center justify-between rounded border border-solid px-3 py-2 font-inherit text-base text-inherit file:hidden focus:border-secondary-200 appearance-none',
|
|
56
|
+
// variant styles
|
|
57
|
+
this.headless
|
|
58
|
+
? `${this.name}--${this.variant}`
|
|
59
|
+
: this.isError
|
|
60
|
+
? 'border-error-300'
|
|
61
|
+
: 'border-gray-300',
|
|
62
|
+
// height styles
|
|
63
|
+
this.headless
|
|
64
|
+
? null
|
|
65
|
+
: this.name === 'textarea'
|
|
66
|
+
? 'min-h-10' // limit it because input type number height can be different from other input types
|
|
67
|
+
: 'h-12 md:h-10',
|
|
68
|
+
];
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
package/nuxt.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
2
3
|
|
|
3
4
|
const components = [
|
|
4
|
-
'src/components/Alert',
|
|
5
|
-
'src/components/Avatar',
|
|
6
|
-
'src/components/Button',
|
|
7
|
-
'src/components/
|
|
8
|
-
'src/components/
|
|
9
|
-
'src/components/
|
|
10
|
-
'src/components/
|
|
11
|
-
'src/components/
|
|
12
|
-
'src/components/
|
|
13
|
-
'src/components/
|
|
14
|
-
'src/components/
|
|
15
|
-
'src/components/
|
|
16
|
-
'src/components/
|
|
17
|
-
|
|
5
|
+
'./src/components/Alert',
|
|
6
|
+
'./src/components/Avatar',
|
|
7
|
+
'./src/components/Button',
|
|
8
|
+
'./src/components/Checkbox',
|
|
9
|
+
'./src/components/Drawer',
|
|
10
|
+
'./src/components/Dialog',
|
|
11
|
+
'./src/components/Disclosure',
|
|
12
|
+
'./src/components/DropdownMenu',
|
|
13
|
+
'./src/components/Form',
|
|
14
|
+
'./src/components/Listbox',
|
|
15
|
+
'./src/components/Image',
|
|
16
|
+
'./src/components/Popover',
|
|
17
|
+
'./src/components/ProgressBar',
|
|
18
|
+
'./src/components/Skeleton',
|
|
19
|
+
'./src/components/Tabs',
|
|
20
|
+
'./src/components/Tooltip',
|
|
21
|
+
];
|
|
18
22
|
|
|
19
|
-
export default
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
export default defineNuxtModule({
|
|
24
|
+
hooks: {
|
|
25
|
+
'components:dirs'(dirs) {
|
|
26
|
+
components.forEach((component) => {
|
|
27
|
+
dirs.push({
|
|
28
|
+
path: fileURLToPath(new URL(component, import.meta.url)),
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritree/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-0",
|
|
4
4
|
"description": "veritree ui library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,8 +11,13 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@veritree/icons": "^0.
|
|
14
|
+
"@floating-ui/dom": "^1.0.4",
|
|
15
|
+
"@veritree/icons": "^0.45.1"
|
|
16
16
|
},
|
|
17
|
-
"devDependencies": {
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@nuxt/kit": "^3.0.0",
|
|
19
|
+
"prettier": "^2.7.1",
|
|
20
|
+
"prettier-plugin-tailwindcss": "^0.1.13",
|
|
21
|
+
"tailwindcss": "^3.2.4"
|
|
22
|
+
}
|
|
18
23
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
v-if="
|
|
3
|
+
v-if="isVisible"
|
|
4
4
|
:class="[
|
|
5
5
|
// default styles
|
|
6
|
-
headless
|
|
7
|
-
? 'alert'
|
|
8
|
-
: 'flex items-start gap-3 rounded border border-solid p-3',
|
|
6
|
+
headless ? 'alert' : 'flex items-start gap-3 rounded border border-solid',
|
|
9
7
|
// variant styles
|
|
10
8
|
headless
|
|
11
9
|
? `alert--${variant}`
|
|
@@ -16,6 +14,14 @@
|
|
|
16
14
|
: isWarning
|
|
17
15
|
? 'border-warning-300 bg-warning-200 text-warning-700'
|
|
18
16
|
: null,
|
|
17
|
+
// sizes styles
|
|
18
|
+
headless
|
|
19
|
+
? `alert--${size}`
|
|
20
|
+
: isLarge
|
|
21
|
+
? 'p-3'
|
|
22
|
+
: isSmall
|
|
23
|
+
? 'py-1 px-2 text-sm'
|
|
24
|
+
: null,
|
|
19
25
|
]"
|
|
20
26
|
role="alert"
|
|
21
27
|
>
|
|
@@ -23,9 +29,15 @@
|
|
|
23
29
|
<button
|
|
24
30
|
v-if="dismissable"
|
|
25
31
|
:class="[
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
// default styles
|
|
33
|
+
headless ? 'alert-close' : 'ml-auto h-4 w-4 shrink-0 text-current',
|
|
34
|
+
headless
|
|
35
|
+
? `alert-close--${variant}`
|
|
36
|
+
: isLarge
|
|
37
|
+
? 'mt-1'
|
|
38
|
+
: isSmall
|
|
39
|
+
? 'mt-0.5'
|
|
40
|
+
: null,
|
|
29
41
|
]"
|
|
30
42
|
@click="hide"
|
|
31
43
|
>
|
|
@@ -35,14 +47,30 @@
|
|
|
35
47
|
</template>
|
|
36
48
|
|
|
37
49
|
<script>
|
|
50
|
+
import IconClose from '@veritree/icons/src/components/IconClose.vue';
|
|
51
|
+
|
|
38
52
|
export default {
|
|
39
53
|
name: 'VTAlert',
|
|
40
54
|
|
|
55
|
+
components: {
|
|
56
|
+
IconClose,
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
modelValueLocal: true,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
|
|
41
65
|
props: {
|
|
42
66
|
variant: {
|
|
43
67
|
type: String,
|
|
44
68
|
default: 'success',
|
|
45
69
|
},
|
|
70
|
+
size: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: 'large',
|
|
73
|
+
},
|
|
46
74
|
headless: {
|
|
47
75
|
type: Boolean,
|
|
48
76
|
default: false,
|
|
@@ -51,12 +79,10 @@ export default {
|
|
|
51
79
|
type: Boolean,
|
|
52
80
|
default: false,
|
|
53
81
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
show: true,
|
|
59
|
-
};
|
|
82
|
+
modelValue: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: null,
|
|
85
|
+
},
|
|
60
86
|
},
|
|
61
87
|
|
|
62
88
|
computed: {
|
|
@@ -71,12 +97,27 @@ export default {
|
|
|
71
97
|
isWarning() {
|
|
72
98
|
return this.variant === 'warning';
|
|
73
99
|
},
|
|
100
|
+
|
|
101
|
+
isLarge() {
|
|
102
|
+
return this.size === 'large';
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
isSmall() {
|
|
106
|
+
return this.size === 'small';
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
isVisible() {
|
|
110
|
+
return this.modelValue !== null ? this.modelValue : this.modelValueLocal;
|
|
111
|
+
},
|
|
74
112
|
},
|
|
75
113
|
|
|
76
114
|
methods: {
|
|
77
115
|
hide() {
|
|
116
|
+
this.modelValue !== null
|
|
117
|
+
? this.$emit('update:modelValue', false)
|
|
118
|
+
: (this.modelValueLocal = false);
|
|
119
|
+
|
|
78
120
|
this.$emit('dismiss');
|
|
79
|
-
this.show = false;
|
|
80
121
|
},
|
|
81
122
|
},
|
|
82
123
|
};
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
:class="[
|
|
4
|
+
// default styles
|
|
5
|
+
headless
|
|
6
|
+
? 'avatar'
|
|
7
|
+
: 'flex items-center justify-center overflow-hidden rounded-full bg-white border border-solid',
|
|
8
|
+
// variant styles
|
|
9
|
+
headless ? `avatar--${variant}` : null,
|
|
10
|
+
// sizes styles
|
|
11
|
+
headless
|
|
12
|
+
? `avatar--${size}`
|
|
13
|
+
: isSmall
|
|
14
|
+
? 'h-8 w-8'
|
|
15
|
+
: isLarge
|
|
16
|
+
? 'h-10 w-10'
|
|
17
|
+
: null,
|
|
18
|
+
]"
|
|
12
19
|
>
|
|
13
20
|
<slot></slot>
|
|
14
21
|
</div>
|
|
@@ -18,32 +25,28 @@
|
|
|
18
25
|
export default {
|
|
19
26
|
name: 'VTAvatar',
|
|
20
27
|
|
|
21
|
-
provide() {
|
|
22
|
-
return {
|
|
23
|
-
api: () => {
|
|
24
|
-
const { dark: isDark, headless: isHeadless, light: isLight } = this;
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
isDark,
|
|
28
|
-
isHeadless,
|
|
29
|
-
isLight,
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
|
|
35
28
|
props: {
|
|
36
29
|
headless: {
|
|
37
30
|
type: Boolean,
|
|
38
31
|
default: false,
|
|
39
32
|
},
|
|
40
|
-
|
|
41
|
-
type:
|
|
42
|
-
default:
|
|
33
|
+
variant: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'primary',
|
|
43
36
|
},
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
default:
|
|
37
|
+
size: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: 'large',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
computed: {
|
|
44
|
+
isLarge() {
|
|
45
|
+
return this.size === 'large';
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
isSmall() {
|
|
49
|
+
return this.size === 'small';
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
52
|
};
|
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
headless
|
|
17
17
|
? `button--${variant}`
|
|
18
18
|
: isPrimary
|
|
19
|
-
? '
|
|
19
|
+
? 'bg-secondary-400 hover:bg-secondary-500 active:bg-secondary-600 border-transparent text-white disabled:bg-gray-200 disabled:text-gray-400'
|
|
20
20
|
: isSecondary
|
|
21
|
-
?
|
|
21
|
+
? isGhost
|
|
22
|
+
? 'border-gray-500 text-gray-100 hover:bg-white hover:text-gray-700'
|
|
23
|
+
: 'border-gray-400 bg-white text-gray-700 hover:bg-gray-100 active:bg-gray-200 disabled:border-gray-300 disabled:text-gray-400'
|
|
22
24
|
: isTertiary
|
|
23
|
-
? '
|
|
25
|
+
? 'text-secondary-400 hover:text-secondary-500 active:text-secondary-500 border-transparent disabled:text-gray-400'
|
|
24
26
|
: isIcon
|
|
25
27
|
? 'text-primary-100 focus-within:bg-gray-200 hover:bg-gray-200 active:bg-gray-300'
|
|
26
28
|
: null,
|
|
@@ -30,19 +32,18 @@
|
|
|
30
32
|
: isLarge
|
|
31
33
|
? isIcon
|
|
32
34
|
? 'h-8 w-8'
|
|
33
|
-
: 'h-10'
|
|
35
|
+
: 'h-12 sm:h-10'
|
|
34
36
|
: isSmall
|
|
35
37
|
? isIcon
|
|
36
38
|
? 'h-6 w-6 p-1'
|
|
37
39
|
: 'h-8'
|
|
38
40
|
: null,
|
|
39
41
|
]"
|
|
40
|
-
v-on="$listeners"
|
|
41
42
|
>
|
|
42
43
|
<VTSpinner v-if="busy" class="absolute inset-0 m-auto" />
|
|
43
44
|
<span
|
|
44
45
|
:class="[
|
|
45
|
-
headless ? null : 'inline-flex items-center gap-2 self-center
|
|
46
|
+
headless ? null : 'mx-auto inline-flex items-center gap-2 self-center',
|
|
46
47
|
headless && busy ? 'button--busy' : busy ? 'invisible' : null,
|
|
47
48
|
]"
|
|
48
49
|
>
|
|
@@ -84,6 +85,10 @@ export default {
|
|
|
84
85
|
type: Boolean,
|
|
85
86
|
default: false,
|
|
86
87
|
},
|
|
88
|
+
style: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: 'normal', // normal or ghost
|
|
91
|
+
},
|
|
87
92
|
},
|
|
88
93
|
|
|
89
94
|
computed: {
|
|
@@ -115,8 +120,16 @@ export default {
|
|
|
115
120
|
return this.disabled || this.busy;
|
|
116
121
|
},
|
|
117
122
|
|
|
123
|
+
isGhost() {
|
|
124
|
+
return this.style === 'ghost';
|
|
125
|
+
},
|
|
126
|
+
|
|
118
127
|
tag() {
|
|
119
|
-
return this.$attrs.href
|
|
128
|
+
return this.$attrs.href
|
|
129
|
+
? 'a'
|
|
130
|
+
: this.to
|
|
131
|
+
? resolveComponent('NuxtLink')
|
|
132
|
+
: 'button';
|
|
120
133
|
},
|
|
121
134
|
|
|
122
135
|
type() {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input
|
|
3
|
+
type="checkbox"
|
|
4
|
+
v-model="modelValueComputed"
|
|
5
|
+
:value="value"
|
|
6
|
+
:checked="checked"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:indeterminate="indeterminate"
|
|
9
|
+
:class="[
|
|
10
|
+
headless
|
|
11
|
+
? 'input-checkbox'
|
|
12
|
+
: 'h-[18px] w-[18px] shrink-0 appearance-none rounded border border-solid bg-no-repeat align-middle focus-visible:ring-2 focus-visible:ring-white',
|
|
13
|
+
headless
|
|
14
|
+
? `input-checkbox--${variant}`
|
|
15
|
+
: isError
|
|
16
|
+
? 'border-error-300'
|
|
17
|
+
: 'border-gray-300',
|
|
18
|
+
checked
|
|
19
|
+
? headless
|
|
20
|
+
? 'input-checkbox--checked'
|
|
21
|
+
: 'border-secondary-300 bg-secondary-300'
|
|
22
|
+
: null,
|
|
23
|
+
disabled
|
|
24
|
+
? headless
|
|
25
|
+
? 'input-checkbox--disabled'
|
|
26
|
+
: 'pointer-events-none bg-gray-100'
|
|
27
|
+
: null,
|
|
28
|
+
indeterminate
|
|
29
|
+
? headless
|
|
30
|
+
? 'input-checkbox--indeterminate'
|
|
31
|
+
: 'border-secondary-200 bg-secondary-200'
|
|
32
|
+
: null,
|
|
33
|
+
]"
|
|
34
|
+
v-bind="$attrs"
|
|
35
|
+
@change="onChange"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
/**
|
|
41
|
+
* Notes:
|
|
42
|
+
* - Not tested with an array yet
|
|
43
|
+
*/
|
|
44
|
+
export default {
|
|
45
|
+
props: {
|
|
46
|
+
disabled: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
indeterminate: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
headless: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
58
|
+
modelValue: {
|
|
59
|
+
type: [Array, Boolean],
|
|
60
|
+
default: null,
|
|
61
|
+
},
|
|
62
|
+
variant: {
|
|
63
|
+
type: [String, Object, Function],
|
|
64
|
+
default: '',
|
|
65
|
+
},
|
|
66
|
+
value: {
|
|
67
|
+
type: [Boolean, Object],
|
|
68
|
+
default: null,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
data() {
|
|
73
|
+
return {
|
|
74
|
+
checked: false,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
computed: {
|
|
79
|
+
modelValueComputed: {
|
|
80
|
+
get() {
|
|
81
|
+
return this.modelValue;
|
|
82
|
+
},
|
|
83
|
+
set(value) {
|
|
84
|
+
this.$emit('update:modelValue', value);
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
isError() {
|
|
89
|
+
return this.variant === 'error';
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
watch: {
|
|
94
|
+
indeterminate(newVal) {
|
|
95
|
+
this.checked = !newVal;
|
|
96
|
+
this.$el.indeterminate = newVal;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
checked(newVal) {
|
|
100
|
+
if (newVal) {
|
|
101
|
+
this.$el.indeterminate = false;
|
|
102
|
+
this.$emit('update:indeterminate', false);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
mounted() {
|
|
108
|
+
if (this.indeterminate) {
|
|
109
|
+
this.$el.indeterminate = this.indeterminate;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
methods: {
|
|
114
|
+
onChange(event) {
|
|
115
|
+
this.checked = event.target.checked;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<style scoped>
|
|
122
|
+
input:not(.input-checkbox):checked,
|
|
123
|
+
input:not(.input-checkbox):indeterminate {
|
|
124
|
+
background-size: cover;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
input:not(.input-checkbox):checked {
|
|
128
|
+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9.00016 16.17L4.83016 12L3.41016 13.41L9.00016 19L21.0002 7.00003L19.5902 5.59003L9.00016 16.17Z' fill='%23ffffff'/%3E%3Cpath d='M9.00016 16.17L4.83016 12L3.41016 13.41L9.00016 19L21.0002 7.00003L19.5902 5.59003L9.00016 16.17Z' fill='%23ffffff' /%3E%3C/svg%3E%0A");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
input:not(.input-checkbox):indeterminate {
|
|
132
|
+
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19 13H5V11H19V13Z' fill='%23ffffff'/%3E%3Cpath d='M19 13H5V11H19V13Z' fill='%23ffffff'/%3E%3C/svg%3E%0A");
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="as" :class="[headless ? 'input-checkbox-text' : 'text-sm']"
|
|
3
|
+
><slot />
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
props: {
|
|
10
|
+
as: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'div',
|
|
13
|
+
},
|
|
14
|
+
headless: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
</script>
|