vueless 0.0.184 → 0.0.185
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 +1 -1
- package/ui.button/index.vue +0 -9
- package/ui.dropdown-badge/index.vue +1 -1
- package/ui.dropdown-button/index.vue +1 -1
- package/ui.dropdown-link/index.vue +1 -1
- package/ui.form-checkbox/composables/attrs.composable.js +8 -8
- package/ui.form-checkbox/index.vue +20 -8
- package/ui.form-checkbox-group/index.stories.js +142 -7
- package/ui.form-checkbox-group/index.vue +4 -2
- package/ui.form-radio/configs/default.config.js +5 -1
- package/ui.form-radio/index.vue +35 -10
- package/ui.form-radio-group/Docs.mdx +1 -0
- package/ui.form-radio-group/configs/default.config.js +1 -0
- package/ui.form-radio-group/index.stories.js +141 -11
- package/ui.form-radio-group/index.vue +2 -1
- package/ui.text-alert/configs/default.config.js +1 -1
- package/web-types.json +10 -6
package/package.json
CHANGED
package/ui.button/index.vue
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
:disabled="disabled"
|
|
7
7
|
:data-cy="dataCy"
|
|
8
8
|
v-bind="buttonAttrs"
|
|
9
|
-
@click="onClick"
|
|
10
9
|
>
|
|
11
10
|
<template v-if="loading">
|
|
12
11
|
<!-- Label is needed to prevent changing button height -->
|
|
@@ -180,8 +179,6 @@ const props = defineProps({
|
|
|
180
179
|
},
|
|
181
180
|
});
|
|
182
181
|
|
|
183
|
-
const emit = defineEmits(["click"]);
|
|
184
|
-
|
|
185
182
|
const { buttonAttrs, loaderAttrs, textAttrs } = useAttrs(props);
|
|
186
183
|
|
|
187
184
|
const buttonRef = ref(null);
|
|
@@ -204,10 +201,4 @@ const loaderSize = computed(() => {
|
|
|
204
201
|
const componentColor = computed(() => {
|
|
205
202
|
return props.variant === "primary" ? "white" : props.color;
|
|
206
203
|
});
|
|
207
|
-
|
|
208
|
-
function onClick(event) {
|
|
209
|
-
if (props.disabled) return;
|
|
210
|
-
|
|
211
|
-
emit("click", event);
|
|
212
|
-
}
|
|
213
204
|
</script>
|
|
@@ -189,7 +189,7 @@ const props = defineProps({
|
|
|
189
189
|
|
|
190
190
|
const emit = defineEmits(["select"]);
|
|
191
191
|
|
|
192
|
-
provide("hideDropdownOptions",
|
|
192
|
+
provide("hideDropdownOptions", hideOptions);
|
|
193
193
|
|
|
194
194
|
const isShownOptions = ref(false);
|
|
195
195
|
const selectedItem = ref("");
|
|
@@ -224,7 +224,7 @@ const props = defineProps({
|
|
|
224
224
|
|
|
225
225
|
const emit = defineEmits(["select"]);
|
|
226
226
|
|
|
227
|
-
provide("hideDropdownOptions",
|
|
227
|
+
provide("hideDropdownOptions", hideOptions);
|
|
228
228
|
|
|
229
229
|
const isShownOptions = ref(false);
|
|
230
230
|
const selectedItem = ref("");
|
|
@@ -210,7 +210,7 @@ const props = defineProps({
|
|
|
210
210
|
|
|
211
211
|
const emit = defineEmits(["select"]);
|
|
212
212
|
|
|
213
|
-
provide("hideDropdownOptions",
|
|
213
|
+
provide("hideDropdownOptions", hideOptions);
|
|
214
214
|
|
|
215
215
|
const isShownOptions = ref(false);
|
|
216
216
|
const selectedItem = ref("");
|
|
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
|
|
|
4
4
|
|
|
5
5
|
import defaultConfig from "../configs/default.config";
|
|
6
6
|
|
|
7
|
-
export function useAttrs(props) {
|
|
7
|
+
export function useAttrs(props, { checkboxColor, checkboxSize }) {
|
|
8
8
|
const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
|
|
9
9
|
const { checkbox, iconWrapper } = config.value;
|
|
10
10
|
|
|
@@ -23,22 +23,22 @@ export function useAttrs(props) {
|
|
|
23
23
|
const checkboxClasses = computed(() =>
|
|
24
24
|
setColor(
|
|
25
25
|
cvaCheckbox({
|
|
26
|
-
size:
|
|
26
|
+
size: checkboxSize.value,
|
|
27
27
|
label: Boolean(props.label),
|
|
28
|
-
color: getColor(
|
|
29
|
-
disabled: props.
|
|
28
|
+
color: getColor(checkboxColor.value),
|
|
29
|
+
disabled: props.disabled,
|
|
30
30
|
}),
|
|
31
|
-
|
|
31
|
+
checkboxColor.value,
|
|
32
32
|
),
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
const iconWrapperClasses = computed(() =>
|
|
36
36
|
setColor(
|
|
37
37
|
cvaIconWrapper({
|
|
38
|
-
size:
|
|
39
|
-
color: getColor(
|
|
38
|
+
size: checkboxSize.value,
|
|
39
|
+
color: getColor(checkboxColor.value),
|
|
40
40
|
}),
|
|
41
|
-
|
|
41
|
+
checkboxColor.value,
|
|
42
42
|
),
|
|
43
43
|
);
|
|
44
44
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ULabel
|
|
3
3
|
:for="id"
|
|
4
|
-
:size="
|
|
4
|
+
:size="checkboxSize"
|
|
5
5
|
:label="label"
|
|
6
6
|
:description="description"
|
|
7
7
|
:align="labelAlign"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
41
|
<script setup>
|
|
42
|
-
import { inject, ref, onMounted, computed } from "vue";
|
|
42
|
+
import { inject, ref, onMounted, computed, watchEffect } from "vue";
|
|
43
43
|
import { isEqual } from "lodash-es";
|
|
44
44
|
|
|
45
45
|
import UIcon from "../ui.image-icon";
|
|
@@ -54,9 +54,11 @@ import { useAttrs } from "./composables/attrs.composable";
|
|
|
54
54
|
/* Should be a string for correct web-types gen */
|
|
55
55
|
defineOptions({ name: "UCheckbox", inheritAttrs: false });
|
|
56
56
|
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const getCheckboxGroupName = inject("getCheckboxGroupName", null);
|
|
58
|
+
const getCheckboxGroupCheckedItems = inject("getCheckboxGroupCheckedItems", null);
|
|
59
59
|
const setCheckboxGroupCheckedItems = inject("setCheckboxGroupCheckedItems", null);
|
|
60
|
+
const getCheckboxGroupColor = inject("getCheckboxGroupColor", null);
|
|
61
|
+
const getCheckboxSize = inject("getCheckboxSize", null);
|
|
60
62
|
|
|
61
63
|
const props = defineProps({
|
|
62
64
|
/**
|
|
@@ -187,8 +189,13 @@ const props = defineProps({
|
|
|
187
189
|
const emit = defineEmits(["update:modelValue", "input"]);
|
|
188
190
|
|
|
189
191
|
const checkboxName = ref("");
|
|
192
|
+
const checkboxSize = ref(props.size);
|
|
193
|
+
const checkboxColor = ref(props.color);
|
|
190
194
|
|
|
191
|
-
const { config, checkboxAttrs, iconWrapperCellAttrs, labelAttrs, iconAttrs } = useAttrs(props
|
|
195
|
+
const { config, checkboxAttrs, iconWrapperCellAttrs, labelAttrs, iconAttrs } = useAttrs(props, {
|
|
196
|
+
checkboxColor,
|
|
197
|
+
checkboxSize,
|
|
198
|
+
});
|
|
192
199
|
|
|
193
200
|
const iconSize = computed(() => {
|
|
194
201
|
const sizes = {
|
|
@@ -203,7 +210,7 @@ const iconSize = computed(() => {
|
|
|
203
210
|
});
|
|
204
211
|
|
|
205
212
|
const isBinary = computed(() => !Array.isArray(props.modelValue));
|
|
206
|
-
const isCheckboxInGroup = computed(() => Boolean(
|
|
213
|
+
const isCheckboxInGroup = computed(() => Boolean(getCheckboxGroupName()));
|
|
207
214
|
|
|
208
215
|
const isChecked = computed(() => {
|
|
209
216
|
return isBinary.value && !isCheckboxInGroup.value
|
|
@@ -216,13 +223,18 @@ const checkboxValue = computed(() => {
|
|
|
216
223
|
});
|
|
217
224
|
|
|
218
225
|
const currentValue = computed(() => {
|
|
219
|
-
return isCheckboxInGroup.value ?
|
|
226
|
+
return isCheckboxInGroup.value ? getCheckboxGroupCheckedItems() : props.modelValue;
|
|
220
227
|
});
|
|
221
228
|
|
|
222
229
|
onMounted(() => {
|
|
223
|
-
checkboxName.value = isCheckboxInGroup.value ?
|
|
230
|
+
checkboxName.value = isCheckboxInGroup.value ? getCheckboxGroupName() : props.name;
|
|
224
231
|
});
|
|
225
232
|
|
|
233
|
+
watchEffect(
|
|
234
|
+
() => (checkboxColor.value = getCheckboxGroupColor ? getCheckboxGroupColor() : props.color),
|
|
235
|
+
);
|
|
236
|
+
watchEffect(() => (checkboxSize.value = getCheckboxSize ? getCheckboxSize() : props.size));
|
|
237
|
+
|
|
226
238
|
function onChange() {
|
|
227
239
|
let newModelValue;
|
|
228
240
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getArgTypes } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UCheckboxGroup from "../ui.form-checkbox-group";
|
|
4
|
+
import UCheckbox from "../ui.form-checkbox";
|
|
5
|
+
import UAlert from "../ui.text-alert";
|
|
6
|
+
import URow from "../ui.container-row";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* The `UCheckboxGroup` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.form-checkbox-group)
|
|
@@ -16,7 +19,7 @@ export default {
|
|
|
16
19
|
{ label: "checkbox 2", description: "some description 2", value: "2" },
|
|
17
20
|
{ label: "checkbox 3", description: "some description 3", value: "3" },
|
|
18
21
|
],
|
|
19
|
-
value: ["
|
|
22
|
+
value: ["One"],
|
|
20
23
|
},
|
|
21
24
|
argTypes: {
|
|
22
25
|
...getArgTypes(UCheckboxGroup.name),
|
|
@@ -24,25 +27,157 @@ export default {
|
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
const DefaultTemplate = (args) => ({
|
|
27
|
-
components: { UCheckboxGroup },
|
|
30
|
+
components: { UCheckboxGroup, UCheckbox, UAlert, URow },
|
|
28
31
|
setup() {
|
|
29
32
|
return { args };
|
|
30
33
|
},
|
|
31
34
|
data() {
|
|
32
35
|
return {
|
|
33
|
-
|
|
36
|
+
value: args.value,
|
|
34
37
|
};
|
|
35
38
|
},
|
|
36
39
|
template: `
|
|
37
|
-
<
|
|
40
|
+
<URow class="!flex-col">
|
|
41
|
+
<UCheckboxGroup v-bind="args" v-model="value">
|
|
42
|
+
<template v-for="(radio, index) in args.options" :key="index">
|
|
43
|
+
<UCheckbox
|
|
44
|
+
v-bind="radio"
|
|
45
|
+
>
|
|
46
|
+
</UCheckbox>
|
|
47
|
+
</template>
|
|
48
|
+
</UCheckboxGroup>
|
|
49
|
+
|
|
50
|
+
<URow>
|
|
51
|
+
<UAlert color="red" v-if=args.isDefaultStory>
|
|
52
|
+
<b>NOTE:</b> <p>UCheckboxGroup component have to have unique name attribute</p>
|
|
53
|
+
</UAlert>
|
|
54
|
+
<UAlert color="blue">
|
|
55
|
+
<p>Selected value: {{ value }}</p>
|
|
56
|
+
</UAlert>
|
|
57
|
+
</URow>
|
|
58
|
+
</URow>
|
|
59
|
+
`,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const OptionsTemplate = (args) => ({
|
|
63
|
+
components: { UCheckboxGroup, UCheckbox, UAlert, URow },
|
|
64
|
+
setup() {
|
|
65
|
+
return { args };
|
|
66
|
+
},
|
|
67
|
+
data() {
|
|
68
|
+
return {
|
|
69
|
+
value: args.value,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
template: `
|
|
73
|
+
<URow class="!flex-col">
|
|
74
|
+
<UCheckboxGroup v-bind="args" v-model="value" :options="args.options" />
|
|
75
|
+
|
|
76
|
+
<URow>
|
|
77
|
+
<UAlert color="blue">
|
|
78
|
+
<p>Selected value: {{ value }}</p>
|
|
79
|
+
</UAlert>
|
|
80
|
+
</URow>
|
|
81
|
+
</URow>
|
|
38
82
|
`,
|
|
39
83
|
});
|
|
40
84
|
|
|
41
85
|
export const Default = DefaultTemplate.bind({});
|
|
42
|
-
Default.args = {
|
|
86
|
+
Default.args = {
|
|
87
|
+
name: "Default",
|
|
88
|
+
isDefaultStory: true,
|
|
89
|
+
options: [
|
|
90
|
+
{ name: "Default", label: "String", description: "some description 1", value: "One" },
|
|
91
|
+
{ name: "Default", label: "Boolean", description: "some description 2", value: false },
|
|
92
|
+
{
|
|
93
|
+
name: "Default",
|
|
94
|
+
label: "Object",
|
|
95
|
+
description: "some description 3",
|
|
96
|
+
value: { key: "value" },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "Default",
|
|
100
|
+
label: "Object",
|
|
101
|
+
description: "some description 4",
|
|
102
|
+
value: ["Array", 1],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const Options = OptionsTemplate.bind({});
|
|
108
|
+
Options.args = {
|
|
109
|
+
name: "Options",
|
|
110
|
+
options: [
|
|
111
|
+
{ name: "Options", label: "Boolean", value: false },
|
|
112
|
+
{ name: "Options", label: "String", value: "One" },
|
|
113
|
+
{ name: "Options", label: "Number", value: 3 },
|
|
114
|
+
{ name: "Options", label: "Object", value: { key: "value" } },
|
|
115
|
+
{ name: "Options", label: "Array", value: ["Array", 1] },
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const ColorsTemplate = (args, { argTypes } = {}) => ({
|
|
120
|
+
components: { UCheckboxGroup, URow },
|
|
121
|
+
setup() {
|
|
122
|
+
return { args };
|
|
123
|
+
},
|
|
124
|
+
data() {
|
|
125
|
+
return {
|
|
126
|
+
value: args.value,
|
|
127
|
+
colors: argTypes.color.options,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
template: `
|
|
131
|
+
<URow class="!flex-col">
|
|
132
|
+
<UCheckboxGroup
|
|
133
|
+
v-bind="args"
|
|
134
|
+
v-for="color in colors"
|
|
135
|
+
:key="color"
|
|
136
|
+
:label="color"
|
|
137
|
+
:color="color"
|
|
138
|
+
:options="args.options"
|
|
139
|
+
name="color"
|
|
140
|
+
v-model="value"
|
|
141
|
+
/>
|
|
142
|
+
</URow>
|
|
143
|
+
`,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
147
|
+
components: { UCheckboxGroup, URow },
|
|
148
|
+
setup() {
|
|
149
|
+
return { args };
|
|
150
|
+
},
|
|
151
|
+
data() {
|
|
152
|
+
return {
|
|
153
|
+
value: args.value,
|
|
154
|
+
sizes: argTypes.size.options,
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
template: `
|
|
158
|
+
<URow class="!flex-col">
|
|
159
|
+
<UCheckboxGroup
|
|
160
|
+
v-bind="args"
|
|
161
|
+
v-for="size in sizes"
|
|
162
|
+
:key="size"
|
|
163
|
+
:label="size"
|
|
164
|
+
:size="size"
|
|
165
|
+
:options="args.options"
|
|
166
|
+
name="size"
|
|
167
|
+
v-model="value"
|
|
168
|
+
/>
|
|
169
|
+
</URow>
|
|
170
|
+
`,
|
|
171
|
+
});
|
|
43
172
|
|
|
44
173
|
export const disabled = DefaultTemplate.bind({});
|
|
45
|
-
disabled.args = { disabled: true };
|
|
174
|
+
disabled.args = { name: "Disabled", disabled: true };
|
|
46
175
|
|
|
47
176
|
export const error = DefaultTemplate.bind({});
|
|
48
|
-
error.args = { error: "some error" };
|
|
177
|
+
error.args = { name: "Error", error: "some error" };
|
|
178
|
+
|
|
179
|
+
export const Colors = ColorsTemplate.bind({});
|
|
180
|
+
Colors.args = { name: "Colors" };
|
|
181
|
+
|
|
182
|
+
export const Sizes = SizesTemplate.bind({});
|
|
183
|
+
Sizes.args = { name: "Sizes" };
|
|
@@ -144,8 +144,10 @@ const checkedItems = ref([]);
|
|
|
144
144
|
const { labelAttrs, checkboxAttrs, listAttrs } = useAttrs(props);
|
|
145
145
|
|
|
146
146
|
provide("setCheckboxGroupCheckedItems", (value) => (checkedItems.value = value));
|
|
147
|
-
provide("
|
|
148
|
-
provide("
|
|
147
|
+
provide("getCheckboxGroupCheckedItems", () => checkedItems.value);
|
|
148
|
+
provide("getCheckboxGroupName", () => props.name);
|
|
149
|
+
provide("getCheckboxGroupColor", () => props.color);
|
|
150
|
+
provide("getCheckboxSize", () => props.size);
|
|
149
151
|
|
|
150
152
|
watch(() => checkedItems.value.length, onChangeCheckedItems);
|
|
151
153
|
watch(() => props.modelValue.length, onModelValueChange, { immediate: true });
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
-
label:
|
|
2
|
+
label: {
|
|
3
|
+
wrapper: "inline-flex",
|
|
4
|
+
label: "cursor-pointer",
|
|
5
|
+
},
|
|
3
6
|
radio: {
|
|
4
7
|
base: `
|
|
8
|
+
cursor-pointer
|
|
5
9
|
transition duration-100 ease-in-out
|
|
6
10
|
border border-solid border-{color}-300 text-{color}-500
|
|
7
11
|
hover:border-{color}-400
|
package/ui.form-radio/index.vue
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
:disabled="disabled"
|
|
16
16
|
:name="radioName"
|
|
17
17
|
:value="radioValue"
|
|
18
|
-
:checked="checked"
|
|
18
|
+
:checked="checked || isChecked"
|
|
19
19
|
:data-cy="dataCy"
|
|
20
20
|
v-bind="radioAttrs"
|
|
21
|
-
@
|
|
21
|
+
@change="onChange"
|
|
22
22
|
/>
|
|
23
23
|
|
|
24
24
|
<slot />
|
|
@@ -42,7 +42,21 @@ import { URadio } from "./constants";
|
|
|
42
42
|
/* Should be a string for correct web-types gen */
|
|
43
43
|
defineOptions({ name: "URadio", inheritAttrs: false });
|
|
44
44
|
|
|
45
|
+
const setRadioGroupSelectedItem = inject("setRadioGroupSelectedItem", null);
|
|
46
|
+
const getRadioGroupName = inject("getRadioGroupName", null);
|
|
47
|
+
const getRadioGroupColor = inject("getRadioGroupColor", null);
|
|
48
|
+
const getRadioGroupSize = inject("getRadioGroupSize", null);
|
|
49
|
+
const getRadioGroupSelectedItem = inject("getRadioGroupSelectedItem", null);
|
|
50
|
+
|
|
45
51
|
const props = defineProps({
|
|
52
|
+
/**
|
|
53
|
+
* Native value attribute.
|
|
54
|
+
*/
|
|
55
|
+
modelValue: {
|
|
56
|
+
type: [Boolean, String, Number, Array, Object],
|
|
57
|
+
default: null,
|
|
58
|
+
},
|
|
59
|
+
|
|
46
60
|
/**
|
|
47
61
|
* Native value attribute.
|
|
48
62
|
*/
|
|
@@ -146,15 +160,21 @@ const props = defineProps({
|
|
|
146
160
|
|
|
147
161
|
const emit = defineEmits(["update:modelValue"]);
|
|
148
162
|
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const getRadioGroupColor = inject("getRadioGroupColor", null);
|
|
152
|
-
const getRadioGroupSize = inject("getRadioGroupSize", null);
|
|
153
|
-
|
|
154
|
-
const radioName = ref("");
|
|
163
|
+
const localValue = ref("");
|
|
164
|
+
const radioName = ref(null);
|
|
155
165
|
const radioColor = ref(getRadioGroupColor ? getRadioGroupColor() : props.color);
|
|
156
166
|
const radioSize = ref(getRadioGroupSize ? getRadioGroupSize() : props.size);
|
|
157
167
|
|
|
168
|
+
const isChecked = computed(() => {
|
|
169
|
+
const currentValue = props.modelValue ?? localValue.value;
|
|
170
|
+
|
|
171
|
+
if (typeof currentValue !== "object") {
|
|
172
|
+
return currentValue === props.value;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return JSON.stringify(currentValue) === JSON.stringify(props.value);
|
|
176
|
+
});
|
|
177
|
+
|
|
158
178
|
const { radioAttrs, labelAttrs } = useAttrs(props, { radioColor, radioSize });
|
|
159
179
|
|
|
160
180
|
const radioValue = computed(() => {
|
|
@@ -162,13 +182,18 @@ const radioValue = computed(() => {
|
|
|
162
182
|
});
|
|
163
183
|
|
|
164
184
|
onMounted(() => {
|
|
165
|
-
radioName.value = props.name || getRadioGroupName;
|
|
185
|
+
radioName.value = props.name || getRadioGroupName();
|
|
166
186
|
});
|
|
167
187
|
|
|
168
188
|
watchEffect(() => (radioColor.value = getRadioGroupColor ? getRadioGroupColor() : props.color));
|
|
169
189
|
watchEffect(() => (radioSize.value = getRadioGroupSize ? getRadioGroupSize() : props.size));
|
|
190
|
+
watchEffect(() => {
|
|
191
|
+
localValue.value = getRadioGroupSelectedItem ? getRadioGroupSelectedItem() : null;
|
|
192
|
+
|
|
193
|
+
emit("update:modelValue", props.value);
|
|
194
|
+
});
|
|
170
195
|
|
|
171
|
-
function
|
|
196
|
+
function onChange(event) {
|
|
172
197
|
setRadioGroupSelectedItem && setRadioGroupSelectedItem(props.value);
|
|
173
198
|
|
|
174
199
|
emit("update:modelValue", event.target.value);
|
|
@@ -2,6 +2,8 @@ import { getArgTypes } from "../service.storybook";
|
|
|
2
2
|
|
|
3
3
|
import URadioGroup from "../ui.form-radio-group";
|
|
4
4
|
import URadio from "../ui.form-radio";
|
|
5
|
+
import UAlert from "../ui.text-alert";
|
|
6
|
+
import URow from "../ui.container-row";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* The `URadioGroup` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.form-radio-group)
|
|
@@ -10,9 +12,16 @@ export default {
|
|
|
10
12
|
id: "3160",
|
|
11
13
|
title: "Form Inputs & Controls / Radio Group",
|
|
12
14
|
component: URadioGroup,
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
description: {
|
|
18
|
+
story: "Another description on the story, overriding the comments",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
13
22
|
args: {
|
|
14
23
|
label: "Label",
|
|
15
|
-
value: "
|
|
24
|
+
value: "One",
|
|
16
25
|
radios: [
|
|
17
26
|
{ name: "radio", label: "Radio 1", value: "1" },
|
|
18
27
|
{ name: "radio", label: "Radio 2", value: "2" },
|
|
@@ -25,21 +34,142 @@ export default {
|
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
const DefaultTemplate = (args) => ({
|
|
28
|
-
components: { URadioGroup, URadio },
|
|
37
|
+
components: { URadioGroup, URadio, UAlert, URow },
|
|
38
|
+
setup() {
|
|
39
|
+
return { args };
|
|
40
|
+
},
|
|
41
|
+
data() {
|
|
42
|
+
return {
|
|
43
|
+
value: args.value,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
template: `
|
|
47
|
+
<URow class="!flex-col">
|
|
48
|
+
<URadioGroup v-bind="args" v-model="value">
|
|
49
|
+
<template v-for="(radio,index) in args.radios" :key="index">
|
|
50
|
+
<URadio
|
|
51
|
+
v-bind="radio"
|
|
52
|
+
>
|
|
53
|
+
</URadio>
|
|
54
|
+
</template>
|
|
55
|
+
</URadioGroup>
|
|
56
|
+
|
|
57
|
+
<URow>
|
|
58
|
+
<UAlert color="red" v-if=args.isDefaultStory>
|
|
59
|
+
<b>NOTE:</b> <p>URadioGroup component have to have unique name attribute</p>
|
|
60
|
+
</UAlert>
|
|
61
|
+
<UAlert color="blue">
|
|
62
|
+
<p>Selected value: {{ value }}</p>
|
|
63
|
+
</UAlert>
|
|
64
|
+
</URow>
|
|
65
|
+
</URow>
|
|
66
|
+
`,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const OptionsTemplate = (args) => ({
|
|
70
|
+
components: { URadioGroup, URadio, UAlert, URow },
|
|
71
|
+
setup() {
|
|
72
|
+
return { args };
|
|
73
|
+
},
|
|
74
|
+
data() {
|
|
75
|
+
return {
|
|
76
|
+
value: args.value,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
template: `
|
|
80
|
+
<URow class="!flex-col">
|
|
81
|
+
<URadioGroup v-bind="args" v-model="value" :options="args.radios" />
|
|
82
|
+
|
|
83
|
+
<URow>
|
|
84
|
+
<UAlert color="blue">
|
|
85
|
+
<p>Selected value: {{ value }}</p>
|
|
86
|
+
</UAlert>
|
|
87
|
+
</URow>
|
|
88
|
+
</URow>
|
|
89
|
+
`,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const ColorsTemplate = (args, { argTypes } = {}) => ({
|
|
93
|
+
components: { URadioGroup, URow },
|
|
94
|
+
setup() {
|
|
95
|
+
return { args };
|
|
96
|
+
},
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
value: args.value,
|
|
100
|
+
colors: argTypes.color.options,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
template: `
|
|
104
|
+
<URow class="!flex-col">
|
|
105
|
+
<URadioGroup
|
|
106
|
+
v-bind="args"
|
|
107
|
+
v-for="color in colors"
|
|
108
|
+
:key="color"
|
|
109
|
+
:label="color"
|
|
110
|
+
:color="color"
|
|
111
|
+
:options="args.radios"
|
|
112
|
+
name="color"
|
|
113
|
+
v-model="value"
|
|
114
|
+
/>
|
|
115
|
+
</URow>
|
|
116
|
+
`,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
120
|
+
components: { URadioGroup, URow },
|
|
29
121
|
setup() {
|
|
30
122
|
return { args };
|
|
31
123
|
},
|
|
124
|
+
data() {
|
|
125
|
+
return {
|
|
126
|
+
value: args.value,
|
|
127
|
+
sizes: argTypes.size.options,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
32
130
|
template: `
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
131
|
+
<URow class="!flex-col">
|
|
132
|
+
<URadioGroup
|
|
133
|
+
v-bind="args"
|
|
134
|
+
v-for="size in sizes"
|
|
135
|
+
:key="size"
|
|
136
|
+
:label="size"
|
|
137
|
+
:size="size"
|
|
138
|
+
:options="args.radios"
|
|
139
|
+
name="size"
|
|
140
|
+
v-model="value"
|
|
141
|
+
/>
|
|
142
|
+
</URow>
|
|
41
143
|
`,
|
|
42
144
|
});
|
|
43
145
|
|
|
44
146
|
export const Default = DefaultTemplate.bind({});
|
|
45
|
-
Default.args = {
|
|
147
|
+
Default.args = {
|
|
148
|
+
name: "Default",
|
|
149
|
+
isDefaultStory: true,
|
|
150
|
+
radios: [
|
|
151
|
+
{ name: "slotValues", label: "Boolean", value: false },
|
|
152
|
+
{ name: "slotValues", label: "String", value: "One" },
|
|
153
|
+
{ name: "slotValues", label: "Number", value: 3 },
|
|
154
|
+
{ name: "slotValues", label: "Object", value: { key: "value" } },
|
|
155
|
+
{ name: "slotValues", label: "Array", value: ["Array", 1] },
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const Options = OptionsTemplate.bind({});
|
|
160
|
+
Options.args = {
|
|
161
|
+
name: "Options",
|
|
162
|
+
radios: [
|
|
163
|
+
{ name: "radioValues", label: "Boolean", value: false },
|
|
164
|
+
{ name: "radioValues", label: "String", value: "One" },
|
|
165
|
+
{ name: "radioValues", label: "Number", value: 3 },
|
|
166
|
+
{ name: "radioValues", label: "Object", value: { key: "value" } },
|
|
167
|
+
{ name: "radioValues", label: "Array", value: ["Array", 1] },
|
|
168
|
+
],
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const Colors = ColorsTemplate.bind({});
|
|
172
|
+
Colors.args = { name: "Colors" };
|
|
173
|
+
|
|
174
|
+
export const Sizes = SizesTemplate.bind({});
|
|
175
|
+
Sizes.args = { name: "Sizes" };
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<URadio
|
|
15
15
|
v-for="(option, index) in options"
|
|
16
16
|
:key="option.value"
|
|
17
|
-
:model-value="
|
|
17
|
+
:model-value="selectedItem"
|
|
18
18
|
:value="option.value"
|
|
19
19
|
:label="option.label"
|
|
20
20
|
:description="option.description"
|
|
@@ -143,6 +143,7 @@ const selectedItem = computed({
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
provide("setRadioGroupSelectedItem", (value) => (selectedItem.value = value));
|
|
146
|
+
provide("getRadioGroupSelectedItem", () => selectedItem.value);
|
|
146
147
|
provide("getRadioGroupName", () => props.name);
|
|
147
148
|
provide("getRadioGroupColor", () => props.color);
|
|
148
149
|
provide("getRadioGroupSize", () => props.size);
|
|
@@ -17,7 +17,7 @@ export default /*tw*/ {
|
|
|
17
17
|
base: `
|
|
18
18
|
flex gap-2 items-baseline
|
|
19
19
|
font-normal leading-normal
|
|
20
|
-
[&_b]:font-bold [&_i]:italic [&_p]:font-normal
|
|
20
|
+
[&_b]:font-bold [&_b]:font-bold [&_i]:italic [&_em]:italic [&_p]:font-normal
|
|
21
21
|
[&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4
|
|
22
22
|
[&_a:not([class]):hover]:no-underline [&_a:not([class])]:font-bold
|
|
23
23
|
[&_ul]:font-normal [&_ol]:font-normal
|
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.185",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -826,11 +826,6 @@
|
|
|
826
826
|
"default": "\"\""
|
|
827
827
|
}
|
|
828
828
|
],
|
|
829
|
-
"events": [
|
|
830
|
-
{
|
|
831
|
-
"name": "click"
|
|
832
|
-
}
|
|
833
|
-
],
|
|
834
829
|
"slots": [
|
|
835
830
|
{
|
|
836
831
|
"name": "left",
|
|
@@ -5796,6 +5791,15 @@
|
|
|
5796
5791
|
"name": "URadio",
|
|
5797
5792
|
"description": "",
|
|
5798
5793
|
"attributes": [
|
|
5794
|
+
{
|
|
5795
|
+
"name": "modelValue",
|
|
5796
|
+
"description": "Native value attribute.",
|
|
5797
|
+
"value": {
|
|
5798
|
+
"kind": "expression",
|
|
5799
|
+
"type": "boolean|string|number|array|object"
|
|
5800
|
+
},
|
|
5801
|
+
"default": "null"
|
|
5802
|
+
},
|
|
5799
5803
|
{
|
|
5800
5804
|
"name": "value",
|
|
5801
5805
|
"description": "Native value attribute.",
|