vueless 0.0.718 → 0.0.720
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
CHANGED
|
@@ -23,7 +23,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits([
|
|
25
25
|
/**
|
|
26
|
-
* Triggers when toggle
|
|
26
|
+
* Triggers when toggle option is selected.
|
|
27
27
|
* @property {string} modelValue
|
|
28
28
|
*/
|
|
29
29
|
"update:modelValue",
|
|
@@ -34,24 +34,24 @@ const selectedValue = computed({
|
|
|
34
34
|
set: (value) => emit("update:modelValue", value),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
function isSelected(
|
|
37
|
+
function isSelected(option: UToggleOption) {
|
|
38
38
|
if (Array.isArray(selectedValue.value)) {
|
|
39
|
-
return selectedValue.value.includes(
|
|
39
|
+
return selectedValue.value.includes(option.value);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
return selectedValue.value ===
|
|
42
|
+
return selectedValue.value === option.value;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function onClickOption(
|
|
45
|
+
function onClickOption(option: UToggleOption) {
|
|
46
46
|
if (props.multiple) {
|
|
47
47
|
const newValue = Array.isArray(selectedValue.value) ? [...selectedValue.value] : [];
|
|
48
|
-
const index = newValue.indexOf(
|
|
48
|
+
const index = newValue.indexOf(option.value);
|
|
49
49
|
|
|
50
|
-
~index ? newValue.splice(index, 1) : newValue.push(
|
|
50
|
+
~index ? newValue.splice(index, 1) : newValue.push(option.value);
|
|
51
51
|
|
|
52
52
|
emit("update:modelValue", newValue);
|
|
53
53
|
} else {
|
|
54
|
-
emit("update:modelValue",
|
|
54
|
+
emit("update:modelValue", option.value);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -65,7 +65,7 @@ const mutatedProps = computed(() => ({
|
|
|
65
65
|
selected: isSelected,
|
|
66
66
|
}));
|
|
67
67
|
|
|
68
|
-
const { toggleLabelAttrs,
|
|
68
|
+
const { toggleLabelAttrs, optionsAttrs, toggleButtonInactiveAttrs, toggleButtonActiveAttrs } =
|
|
69
69
|
useUI<Config>(defaultConfig, mutatedProps);
|
|
70
70
|
</script>
|
|
71
71
|
|
|
@@ -82,17 +82,17 @@ const { toggleLabelAttrs, itemsAttrs, toggleButtonInactiveAttrs, toggleButtonAct
|
|
|
82
82
|
>
|
|
83
83
|
<template #label>
|
|
84
84
|
<!--
|
|
85
|
-
@slot Use this to add custom content instead of the label.
|
|
85
|
+
@slot Use this to add custom content instead of the entire Toggle label.
|
|
86
86
|
@binding {string} label
|
|
87
87
|
-->
|
|
88
88
|
<slot name="label" :label="label" />
|
|
89
89
|
</template>
|
|
90
90
|
|
|
91
|
-
<div v-bind="
|
|
91
|
+
<div v-bind="optionsAttrs">
|
|
92
92
|
<UButton
|
|
93
|
-
v-for="(
|
|
94
|
-
:key="
|
|
95
|
-
:label="
|
|
93
|
+
v-for="(option, index) in options"
|
|
94
|
+
:key="option.value"
|
|
95
|
+
:label="option.label"
|
|
96
96
|
tabindex="0"
|
|
97
97
|
color="gray"
|
|
98
98
|
:size="size"
|
|
@@ -100,38 +100,41 @@ const { toggleLabelAttrs, itemsAttrs, toggleButtonInactiveAttrs, toggleButtonAct
|
|
|
100
100
|
:block="block"
|
|
101
101
|
:square="square"
|
|
102
102
|
:disabled="disabled"
|
|
103
|
-
v-bind="isSelected(
|
|
104
|
-
:data-test="`${dataTest}-
|
|
105
|
-
@click="onClickOption(
|
|
103
|
+
v-bind="isSelected(option) ? toggleButtonActiveAttrs : toggleButtonInactiveAttrs"
|
|
104
|
+
:data-test="`${dataTest}-option-${index}`"
|
|
105
|
+
@click="onClickOption(option)"
|
|
106
106
|
>
|
|
107
107
|
<template #left="{ iconName }">
|
|
108
108
|
<!--
|
|
109
109
|
@slot Use it to add something before the label.
|
|
110
|
+
@binding {object} option
|
|
110
111
|
@binding {string} icon-name
|
|
111
112
|
@binding {number} index
|
|
112
113
|
-->
|
|
113
|
-
<slot name="left" :icon-name="iconName" :index="index" />
|
|
114
|
+
<slot name="left" :option="option" :icon-name="iconName" :index="index" />
|
|
114
115
|
</template>
|
|
115
116
|
|
|
116
117
|
<template #default="{ label, iconName }">
|
|
117
118
|
<!--
|
|
118
|
-
@slot Use it to add something instead of the toggle
|
|
119
|
+
@slot Use it to add something instead of the toggle option label.
|
|
120
|
+
@binding {object} option
|
|
119
121
|
@binding {string} label
|
|
120
122
|
@binding {string} icon-name
|
|
121
123
|
@binding {number} index
|
|
122
124
|
-->
|
|
123
|
-
<slot name="
|
|
124
|
-
{{
|
|
125
|
+
<slot name="option" :option="option" :label="label" :icon-name="iconName" :index="index">
|
|
126
|
+
{{ option.label }}
|
|
125
127
|
</slot>
|
|
126
128
|
</template>
|
|
127
129
|
|
|
128
130
|
<template #right="{ iconName }">
|
|
129
131
|
<!--
|
|
130
132
|
@slot Use it to add something after the label.
|
|
133
|
+
@binding {object} option
|
|
131
134
|
@binding {string} icon-name
|
|
132
135
|
@binding {number} index
|
|
133
136
|
-->
|
|
134
|
-
<slot name="right" :icon-name="iconName" :index="index" />
|
|
137
|
+
<slot name="right" :option="option" :icon-name="iconName" :index="index" />
|
|
135
138
|
</template>
|
|
136
139
|
</UButton>
|
|
137
140
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
tabButton: {
|
|
3
3
|
base: `
|
|
4
|
-
{UButton} -mb-px rounded-none border-transparent
|
|
4
|
+
{UButton} -mb-px rounded-none border-b-2 border-transparent
|
|
5
5
|
hover:bg-transparent dark:hover:bg-transparent
|
|
6
6
|
active:bg-transparent dark:active:bg-transparent
|
|
7
7
|
`,
|
|
@@ -10,7 +10,7 @@ export default /*tw*/ {
|
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
tabButtonActive: {
|
|
13
|
-
base: "{>tabButton}
|
|
13
|
+
base: "{>tabButton} border-b-brand-600",
|
|
14
14
|
defaults: {
|
|
15
15
|
color: "brand",
|
|
16
16
|
},
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
-
tabs:
|
|
2
|
+
tabs: {
|
|
3
|
+
base: "mb-6 flex flex-nowrap border-b border-gray-200 dark:border-gray-700",
|
|
4
|
+
variants: {
|
|
5
|
+
block: "w-full",
|
|
6
|
+
},
|
|
7
|
+
},
|
|
3
8
|
tab: "{UTab}",
|
|
4
9
|
defaults: {
|
|
5
10
|
size: "md",
|