vueless 0.0.151 → 0.0.152
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/package.json +8 -9
- package/preset.tailwind/index.js +1 -1
- package/ui.button/configs/default.config.js +2 -1
- package/ui.button-toggle/composables/attrs.composable.js +2 -0
- package/ui.button-toggle/configs/default.config.js +13 -11
- package/ui.button-toggle/index.stories.js +109 -44
- package/ui.button-toggle/index.vue +26 -41
- package/ui.button-toggle-item/composables/attrs.composable.js +14 -17
- package/ui.button-toggle-item/configs/default.config.js +15 -16
- package/ui.button-toggle-item/index.stories.js +2 -1
- package/ui.button-toggle-item/index.vue +9 -12
- package/web-types.json +22 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.152",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless Component Framework.",
|
|
6
6
|
"homepage": "https://vueless.com",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"cva": "^1.0.0-beta.1",
|
|
29
29
|
"lodash-es": "^4.17.21",
|
|
30
30
|
"tailwind-merge": "^2.3.0",
|
|
31
|
-
"tailwindcss": "^3.4.
|
|
31
|
+
"tailwindcss": "^3.4.4",
|
|
32
32
|
"tippy.js": "^6.3.7",
|
|
33
33
|
"vuedraggable": "^4.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@material-symbols/svg-500": "^0.17.4",
|
|
37
37
|
"@release-it/bumper": "^6.0.1",
|
|
38
|
-
"@vitejs/plugin-vue": "^5.0.
|
|
38
|
+
"@vitejs/plugin-vue": "^5.0.5",
|
|
39
39
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
40
|
-
"@vueless/plugin-vite": "^0.0.
|
|
41
|
-
"@vueless/storybook": "^0.0.
|
|
40
|
+
"@vueless/plugin-vite": "^0.0.28",
|
|
41
|
+
"@vueless/storybook": "^0.0.30",
|
|
42
42
|
"@vueless/web-types": "^0.0.8",
|
|
43
43
|
"autoprefixer": "^10.4.19",
|
|
44
44
|
"cssnano": "^6.1.2",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"prettier": "^3.2.5",
|
|
53
53
|
"prettier-eslint": "^16.3.0",
|
|
54
54
|
"release-it": "^17.2.1",
|
|
55
|
-
"vite": "^5.2.
|
|
55
|
+
"vite": "^5.2.13",
|
|
56
56
|
"vite-plugin-compression": "^0.5.1",
|
|
57
57
|
"vite-plugin-eslint": "^1.8.1",
|
|
58
|
-
"vue": "^3.4.
|
|
58
|
+
"vue": "^3.4.27",
|
|
59
59
|
"vue-router": "^4.3.2"
|
|
60
60
|
},
|
|
61
61
|
"resolutions": {
|
|
@@ -67,6 +67,5 @@
|
|
|
67
67
|
},
|
|
68
68
|
"bugs": {
|
|
69
69
|
"url": "https://github.com/vuelessjs/vueless/issues"
|
|
70
|
-
}
|
|
71
|
-
"web-types": "./web-types.json"
|
|
70
|
+
}
|
|
72
71
|
}
|
package/preset.tailwind/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export function vuelessPreset() {
|
|
|
25
25
|
const prodSafelist = getSafelist();
|
|
26
26
|
const devSafelist = [
|
|
27
27
|
{
|
|
28
|
-
pattern:
|
|
28
|
+
pattern: /^!?(border|bg|text|ring)-(.*)-((50|[1-9]00|950)?)$/,
|
|
29
29
|
variants: ["hover", "focus", "focus-within", "active", "disabled"],
|
|
30
30
|
},
|
|
31
31
|
];
|
|
@@ -3,7 +3,7 @@ export default /*tw*/ {
|
|
|
3
3
|
base: `
|
|
4
4
|
flex items-center justify-center
|
|
5
5
|
text-base font-medium outline-none
|
|
6
|
-
border border-solid
|
|
6
|
+
border border-solid
|
|
7
7
|
transition duration-100 ease-in-out
|
|
8
8
|
focus:ring-opacity-20 focus:ring-4 focus:ring-{color}-700
|
|
9
9
|
focus-within:ring-opacity-20 focus-within:ring-4 focus-within:ring-{color}-700
|
|
@@ -47,6 +47,7 @@ export default /*tw*/ {
|
|
|
47
47
|
true: "pointer-events-none gap-0",
|
|
48
48
|
},
|
|
49
49
|
pill: {
|
|
50
|
+
false: "rounded-lg",
|
|
50
51
|
true: "rounded-full",
|
|
51
52
|
},
|
|
52
53
|
block: {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
-
label: {
|
|
3
|
-
base: "flex flex-wrap",
|
|
4
|
-
variants: {
|
|
5
|
-
block: {
|
|
6
|
-
true: "w-full",
|
|
7
|
-
},
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
2
|
items: {
|
|
11
3
|
base: "flex flex-wrap",
|
|
12
4
|
variants: {
|
|
@@ -20,23 +12,33 @@ export default /*tw*/ {
|
|
|
20
12
|
},
|
|
21
13
|
separated: {
|
|
22
14
|
false: `
|
|
23
|
-
|
|
15
|
+
flex-nowrap -space-x-px gap-0
|
|
24
16
|
[&>*:first-child]:rounded-l-lg [&>*:first-child]:rounded-r-none
|
|
25
17
|
[&>*:last-child]:rounded-r-lg [&>*:last-child]:rounded-l-none
|
|
26
18
|
`,
|
|
27
19
|
},
|
|
28
20
|
},
|
|
21
|
+
compoundVariants: [
|
|
22
|
+
{ separated: false, variant: "thirdary", class: "space-x-0" },
|
|
23
|
+
{ separated: false, multiple: true, class: "space-x-px" },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
label: {
|
|
27
|
+
base: "flex flex-wrap",
|
|
28
|
+
variants: {
|
|
29
|
+
block: {
|
|
30
|
+
true: "w-full",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
29
33
|
},
|
|
30
34
|
item: "",
|
|
31
35
|
defaultVariants: {
|
|
32
|
-
color: "brand",
|
|
33
36
|
variant: "primary",
|
|
34
37
|
labelAlign: "top",
|
|
35
38
|
size: "md",
|
|
36
39
|
block: false,
|
|
37
40
|
pill: false,
|
|
38
41
|
square: false,
|
|
39
|
-
filled: false,
|
|
40
42
|
disabled: false,
|
|
41
43
|
multiple: false,
|
|
42
44
|
separated: false,
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { getArgTypes } from "../service.storybook";
|
|
2
3
|
|
|
3
4
|
import UToggle from "../ui.button-toggle";
|
|
4
5
|
import UIcon from "../ui.image-icon";
|
|
5
6
|
import UToggleItem from "../ui.button-toggle-item";
|
|
6
7
|
import URow from "../ui.container-row";
|
|
7
8
|
|
|
9
|
+
const OPTIONS = [
|
|
10
|
+
{ value: "11", label: "label 1" },
|
|
11
|
+
{ value: "12", label: "label 2" },
|
|
12
|
+
{ value: "13", label: "label 3" },
|
|
13
|
+
{ value: "14", label: "label 4" },
|
|
14
|
+
];
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `UToggle` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.button-toggle)
|
|
10
18
|
*/
|
|
11
19
|
export default {
|
|
20
|
+
components: { UIcon, UToggleItem },
|
|
12
21
|
title: "Buttons & Links / Toggle",
|
|
13
22
|
component: UToggle,
|
|
14
23
|
argTypes: {
|
|
@@ -25,26 +34,18 @@ const DefaultTemplate = (args) => ({
|
|
|
25
34
|
};
|
|
26
35
|
},
|
|
27
36
|
setup() {
|
|
28
|
-
|
|
29
|
-
{ value: "11", label: "label 1" },
|
|
30
|
-
{ value: "12", label: "label 2" },
|
|
31
|
-
{ value: "13", label: "label 3" },
|
|
32
|
-
{ value: "14", label: "label 4" },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
return { args, groupOptions };
|
|
37
|
+
return { args, OPTIONS };
|
|
36
38
|
},
|
|
37
39
|
template: `
|
|
38
40
|
<UToggle
|
|
39
41
|
v-model="value"
|
|
40
42
|
v-bind="args"
|
|
41
|
-
:options="
|
|
42
|
-
name="defaultTemplate"
|
|
43
|
+
:options="OPTIONS"
|
|
43
44
|
/>
|
|
44
45
|
`,
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
const
|
|
48
|
+
const multipleTemplate = (args) => ({
|
|
48
49
|
components: { UToggle },
|
|
49
50
|
data() {
|
|
50
51
|
return {
|
|
@@ -52,39 +53,27 @@ const checkboxTemplate = (args) => ({
|
|
|
52
53
|
};
|
|
53
54
|
},
|
|
54
55
|
setup() {
|
|
55
|
-
|
|
56
|
-
{ value: "11", label: "label 1" },
|
|
57
|
-
{ value: "12", label: "label 2" },
|
|
58
|
-
{ value: "13", label: "label 3" },
|
|
59
|
-
{ value: "14", label: "label 4" },
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
return { args, groupOptions };
|
|
56
|
+
return { args, OPTIONS };
|
|
63
57
|
},
|
|
64
58
|
template: `
|
|
65
59
|
<UToggle
|
|
66
60
|
v-model="value"
|
|
67
61
|
v-bind="args"
|
|
68
62
|
multiple
|
|
69
|
-
:options="
|
|
70
|
-
name="
|
|
63
|
+
:options="OPTIONS"
|
|
64
|
+
name="multipleTemplate"
|
|
71
65
|
/>
|
|
72
66
|
`,
|
|
73
67
|
});
|
|
74
68
|
|
|
75
69
|
const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
76
70
|
components: { UToggle, URow },
|
|
77
|
-
data() {
|
|
78
|
-
return {
|
|
79
|
-
value: "",
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
71
|
setup() {
|
|
83
|
-
const
|
|
72
|
+
const value = ref("");
|
|
84
73
|
|
|
85
74
|
return {
|
|
86
75
|
args,
|
|
87
|
-
|
|
76
|
+
value,
|
|
88
77
|
sizes: argTypes.size.options,
|
|
89
78
|
};
|
|
90
79
|
},
|
|
@@ -92,6 +81,9 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
92
81
|
<URow>
|
|
93
82
|
<UToggle
|
|
94
83
|
v-for="(size, index) in sizes"
|
|
84
|
+
:key="index"
|
|
85
|
+
name="sizeTemplate"
|
|
86
|
+
v-model="value"
|
|
95
87
|
v-bind="args"
|
|
96
88
|
:size="size"
|
|
97
89
|
:label="size"
|
|
@@ -99,14 +91,37 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
99
91
|
{ value: size + 1, label: size },
|
|
100
92
|
{ value: size + 2, label: size },
|
|
101
93
|
]"
|
|
102
|
-
|
|
94
|
+
/>
|
|
95
|
+
</URow>
|
|
96
|
+
`,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const VariantsTemplate = (args, { argTypes } = {}) => ({
|
|
100
|
+
components: { UToggle, URow },
|
|
101
|
+
setup() {
|
|
102
|
+
const value = ref("");
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
args,
|
|
106
|
+
value,
|
|
107
|
+
variants: argTypes.variant.options,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
template: `
|
|
111
|
+
<URow>
|
|
112
|
+
<UToggle
|
|
113
|
+
v-for="(variant, index) in variants"
|
|
103
114
|
:key="index"
|
|
104
115
|
name="sizeTemplate"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
v-model="value"
|
|
117
|
+
v-bind="args"
|
|
118
|
+
:variant="variant"
|
|
119
|
+
:label="variant"
|
|
120
|
+
:options="[
|
|
121
|
+
{ value: variant + 1, label: variant },
|
|
122
|
+
{ value: variant + 2, label: variant },
|
|
123
|
+
]"
|
|
124
|
+
/>
|
|
110
125
|
</URow>
|
|
111
126
|
`,
|
|
112
127
|
});
|
|
@@ -114,9 +129,11 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
114
129
|
const SlotTemplate = (args) => ({
|
|
115
130
|
components: { UToggle, UIcon, UToggleItem },
|
|
116
131
|
setup() {
|
|
132
|
+
const selected = ref("");
|
|
133
|
+
|
|
117
134
|
return {
|
|
118
135
|
args,
|
|
119
|
-
selected
|
|
136
|
+
selected,
|
|
120
137
|
};
|
|
121
138
|
},
|
|
122
139
|
template: `
|
|
@@ -128,31 +145,79 @@ const SlotTemplate = (args) => ({
|
|
|
128
145
|
|
|
129
146
|
export const Default = DefaultTemplate.bind({});
|
|
130
147
|
Default.args = {
|
|
131
|
-
name: "
|
|
148
|
+
name: "Default",
|
|
132
149
|
};
|
|
133
150
|
|
|
134
|
-
export const
|
|
135
|
-
|
|
136
|
-
|
|
151
|
+
export const label = DefaultTemplate.bind({});
|
|
152
|
+
label.args = {
|
|
153
|
+
label: "Label",
|
|
154
|
+
description: "description",
|
|
137
155
|
};
|
|
138
156
|
|
|
139
157
|
export const sizes = SizesTemplate.bind({});
|
|
140
158
|
sizes.args = {
|
|
141
|
-
name: "
|
|
159
|
+
name: "sizes",
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const variants = VariantsTemplate.bind({});
|
|
163
|
+
variants.args = {
|
|
164
|
+
name: "variants",
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const multiple = multipleTemplate.bind({});
|
|
168
|
+
multiple.args = {
|
|
169
|
+
name: "multiple",
|
|
142
170
|
};
|
|
143
171
|
|
|
144
172
|
export const block = DefaultTemplate.bind({});
|
|
145
173
|
block.args = {
|
|
146
|
-
name: "
|
|
174
|
+
name: "block",
|
|
147
175
|
block: true,
|
|
148
176
|
};
|
|
149
177
|
|
|
178
|
+
export const separated = DefaultTemplate.bind({});
|
|
179
|
+
separated.args = {
|
|
180
|
+
name: "separated",
|
|
181
|
+
separated: true,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const pill = DefaultTemplate.bind({});
|
|
185
|
+
pill.args = {
|
|
186
|
+
name: "pill",
|
|
187
|
+
pill: true,
|
|
188
|
+
separated: true,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const square = SlotTemplate.bind({});
|
|
192
|
+
square.args = {
|
|
193
|
+
name: "square",
|
|
194
|
+
variant: "secondary",
|
|
195
|
+
square: true,
|
|
196
|
+
slotTemplate: `
|
|
197
|
+
<template #default>
|
|
198
|
+
<UToggleItem value="1">
|
|
199
|
+
<UIcon name="star" />
|
|
200
|
+
</UToggleItem>
|
|
201
|
+
|
|
202
|
+
<UToggleItem value="2" >
|
|
203
|
+
<UIcon name="add" />
|
|
204
|
+
</UToggleItem>
|
|
205
|
+
|
|
206
|
+
<UToggleItem value="3">
|
|
207
|
+
<UIcon name="timer" />
|
|
208
|
+
</UToggleItem>
|
|
209
|
+
</template>
|
|
210
|
+
`,
|
|
211
|
+
};
|
|
212
|
+
|
|
150
213
|
export const slotDefault = SlotTemplate.bind({});
|
|
151
214
|
slotDefault.args = {
|
|
152
|
-
name: "
|
|
215
|
+
name: "slotDefault",
|
|
153
216
|
slotTemplate: `
|
|
154
217
|
<template #default>
|
|
155
|
-
<UToggleItem label="label" />
|
|
218
|
+
<UToggleItem label="label 1" value="1" />
|
|
219
|
+
<UToggleItem label="label 2" value="2" />
|
|
220
|
+
<UToggleItem label="label 3" value="3" />
|
|
156
221
|
</template>
|
|
157
222
|
`,
|
|
158
223
|
};
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
:name="name"
|
|
18
18
|
:model-value="item.value"
|
|
19
19
|
:value="item.value"
|
|
20
|
+
:disabled="disabled"
|
|
20
21
|
:label="item.label"
|
|
21
22
|
:data-cy="`${dataCy}-item-${index}`"
|
|
22
23
|
v-bind="itemAttrs"
|
|
@@ -49,15 +50,6 @@ const props = defineProps({
|
|
|
49
50
|
default: () => (!this.multiple ? "" : []),
|
|
50
51
|
},
|
|
51
52
|
|
|
52
|
-
/**
|
|
53
|
-
* Toggle variant.
|
|
54
|
-
* @values primary, secondary, thirdary
|
|
55
|
-
*/
|
|
56
|
-
variant: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: UIService.get(defaultConfig, UToggle).default.variant,
|
|
59
|
-
},
|
|
60
|
-
|
|
61
53
|
/**
|
|
62
54
|
* Toggle item options.
|
|
63
55
|
*/
|
|
@@ -67,11 +59,12 @@ const props = defineProps({
|
|
|
67
59
|
},
|
|
68
60
|
|
|
69
61
|
/**
|
|
70
|
-
* Toggle
|
|
62
|
+
* Toggle variant.
|
|
63
|
+
* @values primary, secondary, thirdary
|
|
71
64
|
*/
|
|
72
|
-
|
|
65
|
+
variant: {
|
|
73
66
|
type: String,
|
|
74
|
-
|
|
67
|
+
default: UIService.get(defaultConfig, UToggle).default.variant,
|
|
75
68
|
},
|
|
76
69
|
|
|
77
70
|
/**
|
|
@@ -83,6 +76,15 @@ const props = defineProps({
|
|
|
83
76
|
default: UIService.get(defaultConfig, UToggle).default.size,
|
|
84
77
|
},
|
|
85
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Label placement.
|
|
81
|
+
* @values top, topInside, topWithDesc, bottom, left, right
|
|
82
|
+
*/
|
|
83
|
+
labelAlign: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: UIService.get(defaultConfig, UToggle).default.labelAlign,
|
|
86
|
+
},
|
|
87
|
+
|
|
86
88
|
/**
|
|
87
89
|
* Toggle label.
|
|
88
90
|
*/
|
|
@@ -100,20 +102,11 @@ const props = defineProps({
|
|
|
100
102
|
},
|
|
101
103
|
|
|
102
104
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @values top, topInside, topWithDesc, bottom, left, right
|
|
105
|
+
* Toggle name.
|
|
105
106
|
*/
|
|
106
|
-
|
|
107
|
+
name: {
|
|
107
108
|
type: String,
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Make the toggle fill the width with its container.
|
|
113
|
-
*/
|
|
114
|
-
block: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
default: UIService.get(defaultConfig, UToggle).default.block,
|
|
109
|
+
required: true,
|
|
117
110
|
},
|
|
118
111
|
|
|
119
112
|
/**
|
|
@@ -124,15 +117,6 @@ const props = defineProps({
|
|
|
124
117
|
default: UIService.get(defaultConfig, UToggle).default.multiple,
|
|
125
118
|
},
|
|
126
119
|
|
|
127
|
-
/**
|
|
128
|
-
* Button color.
|
|
129
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
130
|
-
*/
|
|
131
|
-
color: {
|
|
132
|
-
type: String,
|
|
133
|
-
default: UIService.get(defaultConfig, UToggle).default.color,
|
|
134
|
-
},
|
|
135
|
-
|
|
136
120
|
/**
|
|
137
121
|
* Separate toggle items.
|
|
138
122
|
*/
|
|
@@ -150,11 +134,11 @@ const props = defineProps({
|
|
|
150
134
|
},
|
|
151
135
|
|
|
152
136
|
/**
|
|
153
|
-
*
|
|
137
|
+
* Make the toggle fill the width with its container.
|
|
154
138
|
*/
|
|
155
|
-
|
|
139
|
+
block: {
|
|
156
140
|
type: Boolean,
|
|
157
|
-
default: UIService.get(defaultConfig, UToggle).default.
|
|
141
|
+
default: UIService.get(defaultConfig, UToggle).default.block,
|
|
158
142
|
},
|
|
159
143
|
|
|
160
144
|
/**
|
|
@@ -224,23 +208,24 @@ function updateSelectedValue(value, checked) {
|
|
|
224
208
|
}
|
|
225
209
|
|
|
226
210
|
if (checked) {
|
|
227
|
-
selectedValue.value
|
|
211
|
+
const items = selectedValue.value || [];
|
|
212
|
+
|
|
213
|
+
items.push(value);
|
|
214
|
+
selectedValue.value = items;
|
|
228
215
|
} else {
|
|
229
216
|
selectedValue.value = selectedValue.value.filter((item) => String(item) !== String(value));
|
|
230
217
|
}
|
|
231
218
|
}
|
|
232
219
|
|
|
233
220
|
provide("toggleType", readonly(type));
|
|
221
|
+
provide("togglePill", () => props.pill);
|
|
234
222
|
provide("toggleName", () => props.name);
|
|
235
223
|
provide("toggleSize", () => props.size);
|
|
236
224
|
provide("toggleBlock", () => props.block);
|
|
225
|
+
provide("toggleSquare", () => props.square);
|
|
237
226
|
provide("toggleVariant", () => props.variant);
|
|
238
|
-
provide("toggleColor", () => props.color);
|
|
239
|
-
provide("toggleFilled", () => props.filled);
|
|
240
227
|
provide("toggleDisabled", () => props.disabled);
|
|
241
228
|
provide("toggleSeparated", () => props.separated);
|
|
242
|
-
provide("togglePill", () => props.pill);
|
|
243
|
-
provide("toggleSquare", () => props.square);
|
|
244
229
|
|
|
245
230
|
provide("toggleSelectedValue", {
|
|
246
231
|
selectedValue: readonly(selectedValue),
|
|
@@ -4,8 +4,8 @@ import useUI from "../../composable.ui";
|
|
|
4
4
|
|
|
5
5
|
import defaultConfig from "../configs/default.config";
|
|
6
6
|
|
|
7
|
-
export function useAttrs(props, { selectedValue, separated, variant
|
|
8
|
-
const { config, getAttrs
|
|
7
|
+
export function useAttrs(props, { selectedValue, separated, variant }) {
|
|
8
|
+
const { config, getAttrs } = useUI(defaultConfig, () => props.config);
|
|
9
9
|
const { button, selected } = config.value;
|
|
10
10
|
|
|
11
11
|
const cvaButton = cva({
|
|
@@ -14,11 +14,12 @@ export function useAttrs(props, { selectedValue, separated, variant, color }) {
|
|
|
14
14
|
compoundVariants: button.compoundVariants,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const buttonClasses = computed(() =>
|
|
18
|
-
cvaButton({
|
|
17
|
+
const buttonClasses = computed(() => {
|
|
18
|
+
return cvaButton({
|
|
19
|
+
variant: toValue(variant),
|
|
19
20
|
separated: toValue(separated),
|
|
20
|
-
})
|
|
21
|
-
);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
const cvaSelected = cva({
|
|
24
25
|
base: selected.base,
|
|
@@ -27,22 +28,18 @@ export function useAttrs(props, { selectedValue, separated, variant, color }) {
|
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
const selectedClasses = computed(() =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
variant: toValue(variant),
|
|
34
|
-
}),
|
|
35
|
-
toValue(color),
|
|
36
|
-
),
|
|
31
|
+
cvaSelected({
|
|
32
|
+
variant: toValue(variant),
|
|
33
|
+
}),
|
|
37
34
|
);
|
|
38
35
|
|
|
39
|
-
const buttonAttrsRaw = getAttrs("button", { isComponent: true, classes: buttonClasses });
|
|
40
36
|
const inputAttrs = getAttrs("input");
|
|
37
|
+
const buttonAttrsRaw = getAttrs("button", { isComponent: true, classes: buttonClasses });
|
|
41
38
|
|
|
42
39
|
const buttonAttrs = computed(() => {
|
|
43
|
-
const isSelected = Array.isArray(selectedValue
|
|
44
|
-
? selectedValue
|
|
45
|
-
: selectedValue
|
|
40
|
+
const isSelected = Array.isArray(selectedValue?.value)
|
|
41
|
+
? selectedValue?.value?.includes(props.value)
|
|
42
|
+
: selectedValue?.value === props.value;
|
|
46
43
|
|
|
47
44
|
return {
|
|
48
45
|
...buttonAttrsRaw.value,
|
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
button: {
|
|
3
|
-
base:
|
|
3
|
+
base: `
|
|
4
|
+
border-gray-300 font-normal
|
|
5
|
+
hover:text-brand-600 hover:border-brand-600 hover:relative hover:z-10
|
|
6
|
+
focus:text-brand-600 focus:border-brand-600 focus:relative focus:z-10 focus:ring-brand-600 focus-within:ring-brand-600
|
|
7
|
+
active:text-brand-700 active:border-brand-700 active:relative active:z-10
|
|
8
|
+
disabled:border-brand-300 disabled:z-0
|
|
9
|
+
`,
|
|
4
10
|
variants: {
|
|
5
11
|
separated: {
|
|
6
|
-
false: "
|
|
12
|
+
false: "rounded-none",
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
thirdary: "border-none hover:bg-brand-600 hover:bg-opacity-5",
|
|
7
16
|
},
|
|
8
17
|
},
|
|
9
18
|
},
|
|
10
19
|
input: "p-0 m-0 size-0 invisible absolute",
|
|
11
20
|
selected: {
|
|
12
|
-
base: "",
|
|
21
|
+
base: "relative disabled:z-10",
|
|
13
22
|
variants: {
|
|
14
23
|
variant: {
|
|
15
|
-
primary: "!bg-
|
|
16
|
-
secondary: "
|
|
17
|
-
thirdary: "
|
|
24
|
+
primary: "!text-white bg-brand-600 border-brand-600 disabled:border-brand-600",
|
|
25
|
+
secondary: "text-brand-600 border-brand-600 disabled:border-brand-600 bg-brand-600 bg-opacity-10",
|
|
26
|
+
thirdary: "text-brand-600 bg-brand-600 bg-opacity-10",
|
|
18
27
|
},
|
|
19
28
|
},
|
|
20
|
-
compoundVariants: [
|
|
21
|
-
{ color: "grayscale", variant: "primary", class: "!bg-brand-700 !border-brand-700" },
|
|
22
|
-
{ color: "grayscale", variant: "secondary", class: "!text-brand-700 !border-brand-700 !bg-brand-50 !bg-opacity-100" },
|
|
23
|
-
{ color: "grayscale", variant: "thirdary", class: "!text-brand-700 !bg-brand-50" },
|
|
24
|
-
{ color: "white", variant: "primary", class: "!text-brand-700 !border-brand-600 !bg-brand-50" },
|
|
25
|
-
{ color: "white", variant: "secondary", class: "!text-brand-700 !border-brand-600 !bg-brand-50" },
|
|
26
|
-
{ color: "white", variant: "thirdary", class: "!text-brand-700 !bg-brand-50" },
|
|
27
|
-
],
|
|
28
29
|
},
|
|
29
30
|
defaultVariants: {
|
|
30
|
-
color: "brand",
|
|
31
31
|
variant: "primary",
|
|
32
32
|
type: "radio",
|
|
33
33
|
size: "md",
|
|
34
34
|
block: false,
|
|
35
35
|
pill: false,
|
|
36
36
|
square: false,
|
|
37
|
-
filled: false,
|
|
38
37
|
disabled: false,
|
|
39
38
|
},
|
|
40
39
|
};
|
|
@@ -12,6 +12,7 @@ export default {
|
|
|
12
12
|
args: {
|
|
13
13
|
value: "1",
|
|
14
14
|
label: "Label",
|
|
15
|
+
modelValue: "",
|
|
15
16
|
},
|
|
16
17
|
argTypes: {
|
|
17
18
|
...getArgTypes(UToggleItem.name),
|
|
@@ -41,7 +42,7 @@ const SlotTemplate = (args) => ({
|
|
|
41
42
|
return { args };
|
|
42
43
|
},
|
|
43
44
|
template: `
|
|
44
|
-
<UToggleItem v-bind="args"
|
|
45
|
+
<UToggleItem v-bind="args" >
|
|
45
46
|
${args.slotTemplate}
|
|
46
47
|
</UToggleItem>
|
|
47
48
|
`,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<UButton
|
|
3
|
-
tag="label"
|
|
4
3
|
tabindex="0"
|
|
5
4
|
:for="id"
|
|
5
|
+
color="grayscale"
|
|
6
|
+
variant="secondary"
|
|
6
7
|
:label="label"
|
|
7
8
|
:size="toValue(size)"
|
|
8
|
-
:block="toValue(block)"
|
|
9
|
-
:variant="toValue(variant)"
|
|
10
|
-
:color="toValue(color)"
|
|
11
9
|
:pill="toValue(pill)"
|
|
12
|
-
:
|
|
10
|
+
:block="toValue(block)"
|
|
13
11
|
:square="toValue(square)"
|
|
12
|
+
:disabled="toValue(disabled)"
|
|
14
13
|
v-bind="buttonAttrs"
|
|
15
14
|
@click.stop="onClickSetValue"
|
|
16
15
|
>
|
|
@@ -118,21 +117,19 @@ const emit = defineEmits(["update:modelValue"]);
|
|
|
118
117
|
const name = inject("toggleName", () => "toggle");
|
|
119
118
|
const type = inject("toggleType", UIService.get(defaultConfig, UToggleItem).default.type);
|
|
120
119
|
const size = inject("toggleSize", UIService.get(defaultConfig, UToggleItem).default.size);
|
|
121
|
-
const block = inject("toggleBlock", UIService.get(defaultConfig, UToggleItem).default.block);
|
|
122
|
-
const variant = inject("toggleVariant", UIService.get(defaultConfig, UToggleItem).default.variant);
|
|
123
|
-
const color = inject("toggleColor", UIService.get(defaultConfig, UToggleItem).default.color);
|
|
124
|
-
const filled = inject("toggleFilled", UIService.get(defaultConfig, UToggleItem).default.filled);
|
|
125
120
|
const pill = inject("togglePill", UIService.get(defaultConfig, UToggleItem).default.pill);
|
|
121
|
+
const block = inject("toggleBlock", UIService.get(defaultConfig, UToggleItem).default.block);
|
|
126
122
|
const square = inject("toggleSquare", UIService.get(defaultConfig, UToggleItem).default.square);
|
|
127
|
-
const
|
|
123
|
+
const variant = inject("toggleVariant", UIService.get(defaultConfig, UToggleItem).default.variant);
|
|
124
|
+
const separated = inject("toggleSeparated", () => true);
|
|
128
125
|
// eslint-disable-next-line vue/no-dupe-keys, prettier/prettier
|
|
129
|
-
const disabled = inject("toggleDisabled", UIService.get(defaultConfig, UToggleItem).default.disabled);
|
|
126
|
+
const disabled = inject("toggleDisabled", props.disabled || UIService.get(defaultConfig, UToggleItem).default.disabled);
|
|
130
127
|
|
|
131
128
|
const { selectedValue, updateSelectedValue } = inject("toggleSelectedValue", {});
|
|
132
129
|
|
|
133
130
|
const selectedItem = ref("");
|
|
134
131
|
|
|
135
|
-
const { buttonAttrs, inputAttrs } = useAttrs(props, { selectedValue, separated, variant
|
|
132
|
+
const { buttonAttrs, inputAttrs } = useAttrs(props, { selectedValue, separated, variant });
|
|
136
133
|
|
|
137
134
|
onMounted(() => {
|
|
138
135
|
if (type.value === TYPE_RADIO) {
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.152",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -7002,15 +7002,6 @@
|
|
|
7002
7002
|
},
|
|
7003
7003
|
"default": "() => (!this.multiple ? \"\" : [])"
|
|
7004
7004
|
},
|
|
7005
|
-
{
|
|
7006
|
-
"name": "variant",
|
|
7007
|
-
"description": "Toggle variant.",
|
|
7008
|
-
"value": {
|
|
7009
|
-
"kind": "expression",
|
|
7010
|
-
"type": "'primary' | 'secondary' | 'thirdary'"
|
|
7011
|
-
},
|
|
7012
|
-
"default": "primary"
|
|
7013
|
-
},
|
|
7014
7005
|
{
|
|
7015
7006
|
"name": "options",
|
|
7016
7007
|
"description": "Toggle item options.",
|
|
@@ -7021,13 +7012,13 @@
|
|
|
7021
7012
|
"default": "[]"
|
|
7022
7013
|
},
|
|
7023
7014
|
{
|
|
7024
|
-
"name": "
|
|
7025
|
-
"
|
|
7026
|
-
"description": "Toggle name.",
|
|
7015
|
+
"name": "variant",
|
|
7016
|
+
"description": "Toggle variant.",
|
|
7027
7017
|
"value": {
|
|
7028
7018
|
"kind": "expression",
|
|
7029
|
-
"type": "
|
|
7030
|
-
}
|
|
7019
|
+
"type": "'primary' | 'secondary' | 'thirdary'"
|
|
7020
|
+
},
|
|
7021
|
+
"default": "primary"
|
|
7031
7022
|
},
|
|
7032
7023
|
{
|
|
7033
7024
|
"name": "size",
|
|
@@ -7038,6 +7029,15 @@
|
|
|
7038
7029
|
},
|
|
7039
7030
|
"default": "md"
|
|
7040
7031
|
},
|
|
7032
|
+
{
|
|
7033
|
+
"name": "labelAlign",
|
|
7034
|
+
"description": "Label placement.",
|
|
7035
|
+
"value": {
|
|
7036
|
+
"kind": "expression",
|
|
7037
|
+
"type": "'top' | 'topInside' | 'topWithDesc' | 'bottom' | 'left' | 'right'"
|
|
7038
|
+
},
|
|
7039
|
+
"default": "top"
|
|
7040
|
+
},
|
|
7041
7041
|
{
|
|
7042
7042
|
"name": "label",
|
|
7043
7043
|
"description": "Toggle label.",
|
|
@@ -7057,22 +7057,13 @@
|
|
|
7057
7057
|
"default": "\"\""
|
|
7058
7058
|
},
|
|
7059
7059
|
{
|
|
7060
|
-
"name": "
|
|
7061
|
-
"
|
|
7062
|
-
"
|
|
7063
|
-
"kind": "expression",
|
|
7064
|
-
"type": "'top' | 'topInside' | 'topWithDesc' | 'bottom' | 'left' | 'right'"
|
|
7065
|
-
},
|
|
7066
|
-
"default": "top"
|
|
7067
|
-
},
|
|
7068
|
-
{
|
|
7069
|
-
"name": "block",
|
|
7070
|
-
"description": "Make the toggle fill the width with its container.",
|
|
7060
|
+
"name": "name",
|
|
7061
|
+
"required": true,
|
|
7062
|
+
"description": "Toggle name.",
|
|
7071
7063
|
"value": {
|
|
7072
7064
|
"kind": "expression",
|
|
7073
|
-
"type": "
|
|
7074
|
-
}
|
|
7075
|
-
"default": "false"
|
|
7065
|
+
"type": "string"
|
|
7066
|
+
}
|
|
7076
7067
|
},
|
|
7077
7068
|
{
|
|
7078
7069
|
"name": "multiple",
|
|
@@ -7083,15 +7074,6 @@
|
|
|
7083
7074
|
},
|
|
7084
7075
|
"default": "false"
|
|
7085
7076
|
},
|
|
7086
|
-
{
|
|
7087
|
-
"name": "color",
|
|
7088
|
-
"description": "Button color.",
|
|
7089
|
-
"value": {
|
|
7090
|
-
"kind": "expression",
|
|
7091
|
-
"type": "'brand' | 'grayscale' | 'gray' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'white'"
|
|
7092
|
-
},
|
|
7093
|
-
"default": "brand"
|
|
7094
|
-
},
|
|
7095
7077
|
{
|
|
7096
7078
|
"name": "separated",
|
|
7097
7079
|
"description": "Separate toggle items.",
|
|
@@ -7111,8 +7093,8 @@
|
|
|
7111
7093
|
"default": "false"
|
|
7112
7094
|
},
|
|
7113
7095
|
{
|
|
7114
|
-
"name": "
|
|
7115
|
-
"description": "
|
|
7096
|
+
"name": "block",
|
|
7097
|
+
"description": "Make the toggle fill the width with its container.",
|
|
7116
7098
|
"value": {
|
|
7117
7099
|
"kind": "expression",
|
|
7118
7100
|
"type": "boolean"
|