@veritree/ui 0.19.2 → 0.20.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/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 +9 -6
- 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 +14 -16
- package/src/components/Drawer/VTDrawerClose.vue +9 -9
- package/src/components/Drawer/VTDrawerContent.vue +8 -8
- 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/package-lock.json +0 -13
- 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.20.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,11 @@
|
|
|
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
|
? '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
22
|
: isTertiary
|
|
23
|
-
? '
|
|
23
|
+
? 'text-secondary-400 hover:text-secondary-500 active:text-secondary-500 border-transparent disabled:text-gray-400'
|
|
24
24
|
: isIcon
|
|
25
25
|
? 'text-primary-100 focus-within:bg-gray-200 hover:bg-gray-200 active:bg-gray-300'
|
|
26
26
|
: null,
|
|
@@ -30,19 +30,18 @@
|
|
|
30
30
|
: isLarge
|
|
31
31
|
? isIcon
|
|
32
32
|
? 'h-8 w-8'
|
|
33
|
-
: 'h-10'
|
|
33
|
+
: 'h-12 sm:h-10'
|
|
34
34
|
: isSmall
|
|
35
35
|
? isIcon
|
|
36
36
|
? 'h-6 w-6 p-1'
|
|
37
37
|
: 'h-8'
|
|
38
38
|
: null,
|
|
39
39
|
]"
|
|
40
|
-
v-on="$listeners"
|
|
41
40
|
>
|
|
42
41
|
<VTSpinner v-if="busy" class="absolute inset-0 m-auto" />
|
|
43
42
|
<span
|
|
44
43
|
:class="[
|
|
45
|
-
headless ? null : 'inline-flex items-center gap-2 self-center
|
|
44
|
+
headless ? null : 'mx-auto inline-flex items-center gap-2 self-center',
|
|
46
45
|
headless && busy ? 'button--busy' : busy ? 'invisible' : null,
|
|
47
46
|
]"
|
|
48
47
|
>
|
|
@@ -116,7 +115,11 @@ export default {
|
|
|
116
115
|
},
|
|
117
116
|
|
|
118
117
|
tag() {
|
|
119
|
-
return this.$attrs.href
|
|
118
|
+
return this.$attrs.href
|
|
119
|
+
? 'a'
|
|
120
|
+
: this.to
|
|
121
|
+
? resolveComponent('NuxtLink')
|
|
122
|
+
: 'button';
|
|
120
123
|
},
|
|
121
124
|
|
|
122
125
|
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>
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Teleport to="body">
|
|
3
3
|
<div
|
|
4
|
-
v-if="
|
|
4
|
+
v-if="modelValue"
|
|
5
5
|
:id="id"
|
|
6
|
-
:class="
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
:class="
|
|
7
|
+
headless
|
|
8
|
+
? 'dialog'
|
|
9
|
+
: `fixed inset-0 z-50 grid grid-cols-1 grid-rows-1 ${classes}`
|
|
10
|
+
"
|
|
10
11
|
aria-modal="true"
|
|
12
|
+
v-bind="$attrs"
|
|
11
13
|
@click="onClick"
|
|
12
14
|
>
|
|
13
15
|
<slot></slot>
|
|
14
16
|
</div>
|
|
15
|
-
</
|
|
17
|
+
</Teleport>
|
|
16
18
|
</template>
|
|
17
19
|
|
|
18
20
|
<script>
|
|
19
|
-
import { Portal } from '@linusborg/vue-simple-portal';
|
|
20
21
|
import { genId } from '../../utils/ids';
|
|
21
22
|
|
|
22
23
|
export default {
|
|
23
24
|
name: 'VTDialog',
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
Portal,
|
|
27
|
-
},
|
|
26
|
+
inheritAttrs: false,
|
|
28
27
|
|
|
29
28
|
provide() {
|
|
30
29
|
return {
|
|
31
|
-
|
|
32
|
-
const id = this.id;
|
|
30
|
+
apiDialog: () => {
|
|
33
31
|
const componentId = this.componentId;
|
|
34
|
-
const isDark = this.dark;
|
|
35
|
-
const isHeadless = this.headless;
|
|
36
32
|
|
|
37
33
|
const registerContent = (content) => {
|
|
38
34
|
if (!content) return;
|
|
@@ -48,26 +44,22 @@ export default {
|
|
|
48
44
|
|
|
49
45
|
const emit = () => this.emit();
|
|
50
46
|
|
|
47
|
+
const full = this.full;
|
|
48
|
+
|
|
51
49
|
return {
|
|
52
|
-
id,
|
|
53
50
|
componentId,
|
|
54
|
-
isDark,
|
|
55
|
-
isHeadless,
|
|
56
51
|
hide,
|
|
57
52
|
emit,
|
|
58
53
|
registerContent,
|
|
59
54
|
registerOverlay,
|
|
55
|
+
full,
|
|
60
56
|
};
|
|
61
57
|
},
|
|
62
58
|
};
|
|
63
59
|
},
|
|
64
60
|
|
|
65
|
-
model: {
|
|
66
|
-
prop: 'visible',
|
|
67
|
-
},
|
|
68
|
-
|
|
69
61
|
props: {
|
|
70
|
-
|
|
62
|
+
modelValue: {
|
|
71
63
|
type: Boolean,
|
|
72
64
|
default: false,
|
|
73
65
|
},
|
|
@@ -75,7 +67,7 @@ export default {
|
|
|
75
67
|
type: Boolean,
|
|
76
68
|
default: false,
|
|
77
69
|
},
|
|
78
|
-
|
|
70
|
+
full: {
|
|
79
71
|
type: Boolean,
|
|
80
72
|
default: false,
|
|
81
73
|
},
|
|
@@ -94,6 +86,10 @@ export default {
|
|
|
94
86
|
return `dialog-${this.componentId}`;
|
|
95
87
|
},
|
|
96
88
|
|
|
89
|
+
classes() {
|
|
90
|
+
return !this.full ? 'p-4 md:p-6' : '';
|
|
91
|
+
},
|
|
92
|
+
|
|
97
93
|
hasContent() {
|
|
98
94
|
return this.content !== null;
|
|
99
95
|
},
|
|
@@ -103,15 +99,9 @@ export default {
|
|
|
103
99
|
},
|
|
104
100
|
},
|
|
105
101
|
|
|
106
|
-
watch: {
|
|
107
|
-
visible(isVisible) {
|
|
108
|
-
if (!isVisible) this.hide();
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
|
|
112
102
|
mounted() {
|
|
113
103
|
if (this.hasContent) this.content.show();
|
|
114
|
-
if (this.hasOverlay) this.overlay.show();
|
|
104
|
+
// if (this.hasOverlay) this.overlay.show();
|
|
115
105
|
},
|
|
116
106
|
|
|
117
107
|
methods: {
|
|
@@ -122,7 +112,7 @@ export default {
|
|
|
122
112
|
|
|
123
113
|
emit() {
|
|
124
114
|
this.$nextTick(() => {
|
|
125
|
-
this.$emit('
|
|
115
|
+
this.$emit('update:modelValue', false);
|
|
126
116
|
this.$emit('hidden');
|
|
127
117
|
});
|
|
128
118
|
},
|