vueless 0.0.780 → 0.0.782
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.form-checkbox-group/storybook/stories.ts +1 -2
- package/ui.form-input-file/UInputFile.vue +30 -16
- package/ui.form-input-file/config.ts +12 -0
- package/ui.form-label/config.ts +5 -5
- package/ui.form-label/storybook/stories.ts +31 -16
- package/ui.form-radio/storybook/stories.ts +60 -10
- package/ui.form-radio-group/storybook/stories.ts +53 -18
- package/ui.form-switch/config.ts +5 -1
- package/ui.form-switch/storybook/stories.ts +27 -10
package/package.json
CHANGED
|
@@ -132,8 +132,7 @@ Options.parameters = {
|
|
|
132
132
|
docs: {
|
|
133
133
|
description: {
|
|
134
134
|
story:
|
|
135
|
-
|
|
136
|
-
"Every option you pass via the `options` prop can be of different type (`Boolean` | `String` | `Number` | `Array` | `Object`).",
|
|
135
|
+
"Every option you pass via the `options` prop can be of different type (see object meta keys table below).",
|
|
137
136
|
},
|
|
138
137
|
},
|
|
139
138
|
};
|
|
@@ -36,10 +36,10 @@ const emit = defineEmits([
|
|
|
36
36
|
"update:modelValue",
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Triggers
|
|
39
|
+
* Triggers error changes.
|
|
40
40
|
* @property {string} value
|
|
41
41
|
*/
|
|
42
|
-
"
|
|
42
|
+
"error",
|
|
43
43
|
]);
|
|
44
44
|
|
|
45
45
|
const { tm } = useLocale();
|
|
@@ -47,6 +47,8 @@ const { tm } = useLocale();
|
|
|
47
47
|
const dropZoneRef = ref<HTMLDivElement | null>(null);
|
|
48
48
|
const fileInputRef = ref<HTMLInputElement | null>(null);
|
|
49
49
|
|
|
50
|
+
const localError = ref("");
|
|
51
|
+
|
|
50
52
|
const elementId = props.id || useId();
|
|
51
53
|
|
|
52
54
|
const i18nGlobal = tm(COMPONENT_NAME);
|
|
@@ -61,10 +63,7 @@ const currentFiles = computed<File | File[] | null>({
|
|
|
61
63
|
},
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
const currentError = computed(
|
|
65
|
-
get: () => props.error,
|
|
66
|
-
set: (newValue) => emit("update:error", newValue),
|
|
67
|
-
});
|
|
66
|
+
const currentError = computed(() => localError.value || props.error);
|
|
68
67
|
|
|
69
68
|
const extensionNames = computed(() => {
|
|
70
69
|
return props.allowedFileTypes.map((type) => type.replace(".", ""));
|
|
@@ -105,6 +104,7 @@ onBeforeUnmount(() => {
|
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
watch(() => props.multiple, normalizeFilesForMultipleMode);
|
|
107
|
+
watch(currentError, () => emit("error", currentError.value));
|
|
108
108
|
|
|
109
109
|
function normalizeFilesForMultipleMode() {
|
|
110
110
|
if (!props.multiple) return;
|
|
@@ -131,13 +131,19 @@ function validate(file: File) {
|
|
|
131
131
|
|
|
132
132
|
const isValidSize = Number(targetFileSize) <= props.maxFileSize;
|
|
133
133
|
|
|
134
|
-
if (!
|
|
135
|
-
|
|
134
|
+
if (!isValidType) {
|
|
135
|
+
localError.value = currentLocale.value.formatError;
|
|
136
|
+
|
|
137
|
+
return;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
if (!
|
|
139
|
-
|
|
140
|
+
if (!isValidSize && props.maxFileSize) {
|
|
141
|
+
localError.value = currentLocale.value.sizeError;
|
|
142
|
+
|
|
143
|
+
return;
|
|
140
144
|
}
|
|
145
|
+
|
|
146
|
+
localError.value = "";
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
function onChangeFile(event: Event) {
|
|
@@ -242,10 +248,18 @@ function onClickRemoveItem(id: string | number) {
|
|
|
242
248
|
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
243
249
|
*/
|
|
244
250
|
const mutatedProps = computed(() => ({
|
|
245
|
-
error: Boolean(
|
|
251
|
+
error: Boolean(currentError.value),
|
|
246
252
|
label: Boolean(props.label),
|
|
247
253
|
}));
|
|
248
254
|
|
|
255
|
+
defineExpose({
|
|
256
|
+
/**
|
|
257
|
+
* An error.
|
|
258
|
+
* @property {boolean}
|
|
259
|
+
*/
|
|
260
|
+
error: currentError,
|
|
261
|
+
});
|
|
262
|
+
|
|
249
263
|
const {
|
|
250
264
|
getDataTest,
|
|
251
265
|
config,
|
|
@@ -260,6 +274,8 @@ const {
|
|
|
260
274
|
inputAttrs,
|
|
261
275
|
fileListAttrs,
|
|
262
276
|
buttonsAttrs,
|
|
277
|
+
chooseFileButtonErrorAttrs,
|
|
278
|
+
clearButtonErrorAttrs,
|
|
263
279
|
} = useUI<Config>(defaultConfig, mutatedProps);
|
|
264
280
|
</script>
|
|
265
281
|
|
|
@@ -268,7 +284,7 @@ const {
|
|
|
268
284
|
:for="elementId"
|
|
269
285
|
:size="size"
|
|
270
286
|
:label="label"
|
|
271
|
-
:error="
|
|
287
|
+
:error="currentError"
|
|
272
288
|
:align="labelAlign"
|
|
273
289
|
:disabled="disabled"
|
|
274
290
|
:description="description"
|
|
@@ -316,11 +332,10 @@ const {
|
|
|
316
332
|
:for="elementId"
|
|
317
333
|
tag="label"
|
|
318
334
|
variant="thirdary"
|
|
319
|
-
:color="error ? 'red' : 'brand'"
|
|
320
335
|
:right-icon="config.defaults.chooseFileIcon"
|
|
321
336
|
:label="currentLocale.uploadFile"
|
|
322
337
|
:disabled="disabled"
|
|
323
|
-
v-bind="chooseFileButtonAttrs"
|
|
338
|
+
v-bind="currentError ? chooseFileButtonErrorAttrs : chooseFileButtonAttrs"
|
|
324
339
|
:data-test="getDataTest('upload')"
|
|
325
340
|
/>
|
|
326
341
|
|
|
@@ -343,9 +358,8 @@ const {
|
|
|
343
358
|
filled
|
|
344
359
|
variant="thirdary"
|
|
345
360
|
:disabled="disabled"
|
|
346
|
-
:color="error ? 'red' : 'brand'"
|
|
347
361
|
:left-icon="config.defaults.clearIcon"
|
|
348
|
-
v-bind="clearButtonAttrs"
|
|
362
|
+
v-bind="currentError ? clearButtonErrorAttrs : clearButtonAttrs"
|
|
349
363
|
:data-test="getDataTest('clear')"
|
|
350
364
|
@click="onClickResetFiles"
|
|
351
365
|
/>
|
|
@@ -65,6 +65,12 @@ export default /*tw*/ {
|
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
+
chooseFileButtonError: {
|
|
69
|
+
base: "{>chooseFileButton}",
|
|
70
|
+
defaults: {
|
|
71
|
+
color: "red",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
68
74
|
clearButton: {
|
|
69
75
|
base: "{UButton}",
|
|
70
76
|
defaults: {
|
|
@@ -75,6 +81,12 @@ export default /*tw*/ {
|
|
|
75
81
|
},
|
|
76
82
|
},
|
|
77
83
|
},
|
|
84
|
+
clearButtonError: {
|
|
85
|
+
base: "{>clearButton}",
|
|
86
|
+
defaults: {
|
|
87
|
+
color: "red",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
78
90
|
input: "sr-only",
|
|
79
91
|
i18n: {
|
|
80
92
|
sizeError: "File size is too big.",
|
package/ui.form-label/config.ts
CHANGED
|
@@ -33,7 +33,7 @@ export default /*tw*/ {
|
|
|
33
33
|
},
|
|
34
34
|
align: {
|
|
35
35
|
top: "font-medium",
|
|
36
|
-
topInside: "font-normal absolute
|
|
36
|
+
topInside: "font-normal absolute text-gray-500 group-focus-within:text-brand-600",
|
|
37
37
|
topWithDesc: "font-medium",
|
|
38
38
|
left: "font-normal",
|
|
39
39
|
right: "font-normal",
|
|
@@ -47,9 +47,9 @@ export default /*tw*/ {
|
|
|
47
47
|
},
|
|
48
48
|
compoundVariants: [
|
|
49
49
|
{ interactive: true, disabled: false, class: "hover:cursor-pointer" },
|
|
50
|
-
{ align: "topInside", size: "sm", class: "top-
|
|
51
|
-
{ align: "topInside", size: "md", class: "top-
|
|
52
|
-
{ align: "topInside", size: "lg", class: "top-
|
|
50
|
+
{ align: "topInside", size: "sm", class: "-top-3 text-2xs" },
|
|
51
|
+
{ align: "topInside", size: "md", class: "-top-4 text-xs" },
|
|
52
|
+
{ align: "topInside", size: "lg", class: "-top-5 text-sm" },
|
|
53
53
|
{ align: "topWithDesc", size: "sm", class: "-mt-px" },
|
|
54
54
|
{ align: "topWithDesc", size: "md", class: "" },
|
|
55
55
|
{ align: "topWithDesc", size: "lg", class: "mt-px" },
|
|
@@ -69,7 +69,7 @@ export default /*tw*/ {
|
|
|
69
69
|
},
|
|
70
70
|
align: {
|
|
71
71
|
top: "",
|
|
72
|
-
topInside: "
|
|
72
|
+
topInside: "mt-1.5",
|
|
73
73
|
topWithDesc: "pt-0.5",
|
|
74
74
|
left: "pt-0.5",
|
|
75
75
|
right: "pt-0.5",
|
|
@@ -24,8 +24,8 @@ export default {
|
|
|
24
24
|
title: "Form Inputs & Controls / Label",
|
|
25
25
|
component: ULabel,
|
|
26
26
|
args: {
|
|
27
|
-
label: "
|
|
28
|
-
description: "
|
|
27
|
+
label: "Email Address",
|
|
28
|
+
description: "We'll never share your email with anyone else.",
|
|
29
29
|
},
|
|
30
30
|
argTypes: {
|
|
31
31
|
...getArgTypes(ULabel.__name),
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
},
|
|
38
38
|
} as Meta;
|
|
39
39
|
|
|
40
|
-
const defaultTemplate = "
|
|
40
|
+
const defaultTemplate = "johndoe@example.com";
|
|
41
41
|
|
|
42
42
|
const DefaultTemplate: StoryFn<ULabelArgs> = (args: ULabelArgs) => ({
|
|
43
43
|
components: { ULabel, UText, UIcon, UBadge },
|
|
@@ -78,13 +78,12 @@ const EnumVariantTemplate: StoryFn<ULabelArgs> = (args: ULabelArgs, { argTypes }
|
|
|
78
78
|
};
|
|
79
79
|
},
|
|
80
80
|
template: `
|
|
81
|
-
<UCol>
|
|
81
|
+
<UCol class="gap-10">
|
|
82
82
|
<ULabel
|
|
83
83
|
v-for="(option, index) in options"
|
|
84
84
|
:key="index"
|
|
85
85
|
v-bind="args"
|
|
86
86
|
:[args.enum]="option"
|
|
87
|
-
class="border border-gray-200 rounded-dynamic-sm p-4"
|
|
88
87
|
>
|
|
89
88
|
<UText :[args.enum]="option">
|
|
90
89
|
{{ prefixedOptions[index] }}
|
|
@@ -95,23 +94,39 @@ const EnumVariantTemplate: StoryFn<ULabelArgs> = (args: ULabelArgs, { argTypes }
|
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
export const Default = DefaultTemplate.bind({});
|
|
98
|
-
Default.args = {};
|
|
97
|
+
Default.args = { description: "" };
|
|
99
98
|
|
|
100
|
-
export const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export const LabelPlacement = EnumVariantTemplate.bind({});
|
|
104
|
-
LabelPlacement.args = { enum: "align" };
|
|
99
|
+
export const Description = DefaultTemplate.bind({});
|
|
100
|
+
Description.args = {};
|
|
105
101
|
|
|
106
102
|
export const Error = DefaultTemplate.bind({});
|
|
107
|
-
Error.args = { error: "
|
|
103
|
+
Error.args = { error: "Please enter a valid email address." };
|
|
108
104
|
|
|
109
105
|
export const Disabled = DefaultTemplate.bind({});
|
|
110
106
|
Disabled.args = { disabled: true };
|
|
111
107
|
|
|
108
|
+
export const Interactive = DefaultTemplate.bind({});
|
|
109
|
+
Interactive.args = { interactive: true };
|
|
110
|
+
Interactive.parameters = {
|
|
111
|
+
docs: {
|
|
112
|
+
description: {
|
|
113
|
+
story: "Make the label interactive (cursor pointer on hover).",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const Centred = DefaultTemplate.bind({});
|
|
119
|
+
Centred.args = { centred: true };
|
|
120
|
+
|
|
121
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
122
|
+
Sizes.args = { enum: "size" };
|
|
123
|
+
|
|
124
|
+
export const LabelPlacement = EnumVariantTemplate.bind({});
|
|
125
|
+
LabelPlacement.args = { enum: "align" };
|
|
126
|
+
|
|
112
127
|
export const SlotLabel = DefaultTemplate.bind({});
|
|
113
128
|
SlotLabel.args = {
|
|
114
|
-
label: "
|
|
129
|
+
label: "Email Address",
|
|
115
130
|
slotTemplate: `
|
|
116
131
|
<template #label="{ label }">
|
|
117
132
|
<UBadge :label="label" color="green" />
|
|
@@ -119,11 +134,11 @@ SlotLabel.args = {
|
|
|
119
134
|
`,
|
|
120
135
|
};
|
|
121
136
|
|
|
122
|
-
export const
|
|
123
|
-
|
|
137
|
+
export const SlotBottom = DefaultTemplate.bind({});
|
|
138
|
+
SlotBottom.args = {
|
|
124
139
|
slotTemplate: `
|
|
125
140
|
<template #bottom>
|
|
126
|
-
<
|
|
141
|
+
<UBadge label="Your opinion is important for us!" color="green" class="max-w-fit" />
|
|
127
142
|
</template>
|
|
128
143
|
`,
|
|
129
144
|
};
|
|
@@ -7,13 +7,14 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import URadio from "../../ui.form-radio/URadio.vue";
|
|
9
9
|
import UBadge from "../../ui.text-badge/UBadge.vue";
|
|
10
|
+
import URow from "../../ui.container-row/URow.vue";
|
|
10
11
|
|
|
11
12
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
12
13
|
import type { Props } from "../types.ts";
|
|
13
14
|
|
|
14
15
|
interface URadioArgs extends Props {
|
|
15
16
|
slotTemplate?: string;
|
|
16
|
-
enum: "
|
|
17
|
+
enum: "size" | "labelAlign" | "color";
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export default {
|
|
@@ -22,7 +23,7 @@ export default {
|
|
|
22
23
|
component: URadio,
|
|
23
24
|
args: {
|
|
24
25
|
name: "radio1",
|
|
25
|
-
label: "
|
|
26
|
+
label: "Payment Method",
|
|
26
27
|
value: "1",
|
|
27
28
|
color: "brand",
|
|
28
29
|
},
|
|
@@ -50,26 +51,75 @@ const DefaultTemplate: StoryFn<URadioArgs> = (args: URadioArgs) => ({
|
|
|
50
51
|
`,
|
|
51
52
|
});
|
|
52
53
|
|
|
54
|
+
const EnumVariantTemplate: StoryFn<URadioArgs> = (args: URadioArgs, { argTypes }) => ({
|
|
55
|
+
components: { URadio, URow },
|
|
56
|
+
setup() {
|
|
57
|
+
return {
|
|
58
|
+
args,
|
|
59
|
+
options: argTypes?.[args.enum]?.options,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
template: `
|
|
63
|
+
<URow :class="{ '!flex-col': args.enum === 'labelAlign' }">
|
|
64
|
+
<URadio
|
|
65
|
+
v-for="(option, index) in options"
|
|
66
|
+
:key="index"
|
|
67
|
+
v-bind="args"
|
|
68
|
+
v-model="args.modelValue"
|
|
69
|
+
:[args.enum]="option"
|
|
70
|
+
:label="option"
|
|
71
|
+
/>
|
|
72
|
+
</URow>
|
|
73
|
+
`,
|
|
74
|
+
});
|
|
75
|
+
|
|
53
76
|
export const Default = DefaultTemplate.bind({});
|
|
54
77
|
Default.args = {};
|
|
55
78
|
|
|
79
|
+
export const Description = DefaultTemplate.bind({});
|
|
80
|
+
Description.args = {
|
|
81
|
+
name: "radio3",
|
|
82
|
+
label: "Subscription Plan",
|
|
83
|
+
description: "Choose your preferred plan. You can change it anytime.",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Error = DefaultTemplate.bind({});
|
|
87
|
+
Error.args = {
|
|
88
|
+
description: "Please select a payment method.",
|
|
89
|
+
error: "This field is required. Please make a selection.",
|
|
90
|
+
};
|
|
91
|
+
|
|
56
92
|
export const Disabled = DefaultTemplate.bind({});
|
|
57
93
|
Disabled.args = { disabled: true, name: "radio2" };
|
|
58
94
|
|
|
59
|
-
export const Description = DefaultTemplate.bind({});
|
|
60
|
-
Description.args = { name: "radio3", description: "description" };
|
|
61
|
-
|
|
62
95
|
export const Checked = DefaultTemplate.bind({});
|
|
63
96
|
Checked.args = { checked: true, name: "radio4" };
|
|
64
97
|
|
|
65
|
-
export const
|
|
66
|
-
|
|
98
|
+
export const LabelPlacement = EnumVariantTemplate.bind({});
|
|
99
|
+
LabelPlacement.args = { enum: "labelAlign" };
|
|
100
|
+
|
|
101
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
102
|
+
Sizes.args = { enum: "size" };
|
|
103
|
+
|
|
104
|
+
export const Color = EnumVariantTemplate.bind({});
|
|
105
|
+
Color.args = { enum: "color" };
|
|
106
|
+
|
|
107
|
+
export const SlotLabel = DefaultTemplate.bind({});
|
|
108
|
+
SlotLabel.args = {
|
|
109
|
+
slotTemplate: `
|
|
110
|
+
<template #label="{ label }">
|
|
111
|
+
<UBadge :label="label" color="green" />
|
|
112
|
+
</template>
|
|
113
|
+
`,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const SlotBottom = DefaultTemplate.bind({});
|
|
117
|
+
SlotBottom.args = {
|
|
67
118
|
name: "radio5",
|
|
68
|
-
label: "radio",
|
|
69
119
|
value: "radio",
|
|
70
120
|
slotTemplate: `
|
|
71
|
-
<template #
|
|
72
|
-
<UBadge label="
|
|
121
|
+
<template #bottom>
|
|
122
|
+
<UBadge label="Add to favorite" color="green" size="sm" />
|
|
73
123
|
</template>
|
|
74
124
|
`,
|
|
75
125
|
};
|
|
@@ -9,6 +9,7 @@ import URadioGroup from "../../ui.form-radio-group/URadioGroup.vue";
|
|
|
9
9
|
import URadio from "../../ui.form-radio/URadio.vue";
|
|
10
10
|
import UAlert from "../../ui.text-alert/UAlert.vue";
|
|
11
11
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
12
|
+
import UBadge from "../../ui.text-badge/UBadge.vue";
|
|
12
13
|
|
|
13
14
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
14
15
|
import type { Props } from "../types.ts";
|
|
@@ -23,14 +24,11 @@ export default {
|
|
|
23
24
|
title: "Form Inputs & Controls / Radio Group",
|
|
24
25
|
component: URadioGroup,
|
|
25
26
|
args: {
|
|
26
|
-
label: "
|
|
27
|
-
modelValue: "One",
|
|
27
|
+
label: "Select your preferred delivery option:",
|
|
28
28
|
options: [
|
|
29
|
-
{
|
|
30
|
-
{
|
|
31
|
-
{
|
|
32
|
-
{ label: "Object", value: { key: "value" } },
|
|
33
|
-
{ label: "Array", value: ["Array", 1] },
|
|
29
|
+
{ value: "standard", label: "Standard Shipping (3-5 business days)" },
|
|
30
|
+
{ value: "express", label: "Express Shipping (1-2 business days)" },
|
|
31
|
+
{ value: "pickup", label: "In-Store Pickup (Available same day)" },
|
|
34
32
|
],
|
|
35
33
|
},
|
|
36
34
|
argTypes: {
|
|
@@ -44,7 +42,7 @@ export default {
|
|
|
44
42
|
} as Meta;
|
|
45
43
|
|
|
46
44
|
const DefaultTemplate: StoryFn<URadioGroupArgs> = (args: URadioGroupArgs) => ({
|
|
47
|
-
components: { URadioGroup, URadio, UAlert, UCol },
|
|
45
|
+
components: { URadioGroup, URadio, UAlert, UCol, UBadge },
|
|
48
46
|
setup() {
|
|
49
47
|
const slots = getSlotNames(URadioGroup.__name);
|
|
50
48
|
|
|
@@ -62,8 +60,8 @@ const DefaultTemplate: StoryFn<URadioGroupArgs> = (args: URadioGroupArgs) => ({
|
|
|
62
60
|
</URadio>
|
|
63
61
|
</URadioGroup>
|
|
64
62
|
|
|
65
|
-
<UAlert
|
|
66
|
-
<
|
|
63
|
+
<UAlert size="sm" variant="thirdary" color="green" bordered>
|
|
64
|
+
<p>Selected value: {{ args.modelValue }}</p>
|
|
67
65
|
</UAlert>
|
|
68
66
|
</UCol>
|
|
69
67
|
`,
|
|
@@ -98,21 +96,58 @@ Default.args = {
|
|
|
98
96
|
name: "Default",
|
|
99
97
|
};
|
|
100
98
|
|
|
99
|
+
export const Description = DefaultTemplate.bind({});
|
|
100
|
+
Description.args = {
|
|
101
|
+
name: "Description",
|
|
102
|
+
label: "Delivery Options",
|
|
103
|
+
description:
|
|
104
|
+
"Select your preferred delivery method. Additional charges may apply for expedited shipping.",
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const Error = DefaultTemplate.bind({});
|
|
108
|
+
Error.args = {
|
|
109
|
+
name: "Error",
|
|
110
|
+
error: "Please, select at least one option to proceed.",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const Disabled = DefaultTemplate.bind({});
|
|
114
|
+
Disabled.args = {
|
|
115
|
+
name: "Disabled",
|
|
116
|
+
disabled: true,
|
|
117
|
+
};
|
|
118
|
+
|
|
101
119
|
export const Options = DefaultTemplate.bind({});
|
|
102
120
|
Options.args = {
|
|
103
121
|
name: "Options",
|
|
104
|
-
modelValue: "Custom string value",
|
|
105
122
|
options: [
|
|
106
|
-
{ label: "
|
|
107
|
-
{ label: "
|
|
108
|
-
{ label: "
|
|
109
|
-
{ label: "Object", value: {
|
|
110
|
-
{ label: "Array", value: ["
|
|
123
|
+
{ label: "String", value: "Subscribed" },
|
|
124
|
+
{ label: "Number", value: 42 },
|
|
125
|
+
{ label: "Boolean", value: true },
|
|
126
|
+
{ label: "Object", value: { id: 101, status: "active" } },
|
|
127
|
+
{ label: "Array", value: ["Admin", "Editor"] },
|
|
111
128
|
],
|
|
112
129
|
};
|
|
130
|
+
Options.parameters = {
|
|
131
|
+
docs: {
|
|
132
|
+
description: {
|
|
133
|
+
story:
|
|
134
|
+
"Every option you pass via the `options` prop can be of different type (see object meta keys table below).",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
140
|
+
Sizes.args = { enum: "size", name: "Sizes" };
|
|
113
141
|
|
|
114
142
|
export const Colors = EnumVariantTemplate.bind({});
|
|
115
143
|
Colors.args = { enum: "color", name: "Colors" };
|
|
116
144
|
|
|
117
|
-
export const
|
|
118
|
-
|
|
145
|
+
export const SlotLabel = DefaultTemplate.bind({});
|
|
146
|
+
SlotLabel.args = {
|
|
147
|
+
name: "SlotLabel",
|
|
148
|
+
slotTemplate: `
|
|
149
|
+
<template #label="{ label }">
|
|
150
|
+
<UBadge :label="label" color="green" variant="thirdary" />
|
|
151
|
+
</template>
|
|
152
|
+
`,
|
|
153
|
+
};
|
package/ui.form-switch/config.ts
CHANGED
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
import USwitch from "../../ui.form-switch/USwitch.vue";
|
|
9
9
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
10
10
|
import URow from "../../ui.container-row/URow.vue";
|
|
11
|
+
import UBadge from "../../ui.text-badge/UBadge.vue";
|
|
11
12
|
|
|
12
13
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
13
14
|
import type { Props } from "../types.ts";
|
|
14
15
|
|
|
15
16
|
interface USwitchArgs extends Props {
|
|
16
17
|
slotTemplate?: string;
|
|
17
|
-
enum: "size" | "color";
|
|
18
|
+
enum: "size" | "color" | "labelAlign";
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default {
|
|
@@ -35,7 +36,7 @@ export default {
|
|
|
35
36
|
} as Meta;
|
|
36
37
|
|
|
37
38
|
const DefaultTemplate: StoryFn<USwitchArgs> = (args: USwitchArgs) => ({
|
|
38
|
-
components: { USwitch, UIcon },
|
|
39
|
+
components: { USwitch, UIcon, UBadge },
|
|
39
40
|
setup() {
|
|
40
41
|
const slots = getSlotNames(USwitch.__name);
|
|
41
42
|
|
|
@@ -57,7 +58,7 @@ const EnumVariantTemplate: StoryFn<USwitchArgs> = (args: USwitchArgs, { argTypes
|
|
|
57
58
|
};
|
|
58
59
|
},
|
|
59
60
|
template: `
|
|
60
|
-
<URow>
|
|
61
|
+
<URow :class="{ '!flex-col max-w-fit': args.enum === 'labelAlign' }">
|
|
61
62
|
<USwitch
|
|
62
63
|
v-for="(option, index) in options"
|
|
63
64
|
:key="index"
|
|
@@ -74,10 +75,19 @@ export const Default = DefaultTemplate.bind({});
|
|
|
74
75
|
Default.args = {};
|
|
75
76
|
|
|
76
77
|
export const Label = DefaultTemplate.bind({});
|
|
77
|
-
Label.args = { label: "
|
|
78
|
+
Label.args = { label: "Enable Notifications" };
|
|
78
79
|
|
|
79
80
|
export const Description = DefaultTemplate.bind({});
|
|
80
|
-
Description.args = {
|
|
81
|
+
Description.args = {
|
|
82
|
+
label: "Enable Dark Mode",
|
|
83
|
+
description: "Switch to a darker color scheme to reduce eye strain.",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const LabelPlacement = EnumVariantTemplate.bind({});
|
|
87
|
+
LabelPlacement.args = { enum: "labelAlign" };
|
|
88
|
+
|
|
89
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
90
|
+
Sizes.args = { enum: "size", color: "yellow" };
|
|
81
91
|
|
|
82
92
|
export const Colors = EnumVariantTemplate.bind({});
|
|
83
93
|
Colors.args = { enum: "color", modelValue: true };
|
|
@@ -85,11 +95,18 @@ Colors.args = { enum: "color", modelValue: true };
|
|
|
85
95
|
export const ToggleLabel = DefaultTemplate.bind({});
|
|
86
96
|
ToggleLabel.args = { toggleLabel: true };
|
|
87
97
|
|
|
88
|
-
export const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export const Icon = DefaultTemplate.bind({});
|
|
92
|
-
Icon.args = { toggleIcon: true, color: "yellow" };
|
|
98
|
+
export const ToggleIcon = DefaultTemplate.bind({});
|
|
99
|
+
ToggleIcon.args = { toggleIcon: true, color: "yellow" };
|
|
93
100
|
|
|
94
101
|
export const Disabled = DefaultTemplate.bind({});
|
|
95
102
|
Disabled.args = { disabled: true };
|
|
103
|
+
|
|
104
|
+
export const SlotLabel = DefaultTemplate.bind({});
|
|
105
|
+
SlotLabel.args = {
|
|
106
|
+
label: "Enable Notifications",
|
|
107
|
+
slotTemplate: `
|
|
108
|
+
<template #label="{ label }">
|
|
109
|
+
<UBadge :label="label" color="green" />
|
|
110
|
+
</template>
|
|
111
|
+
`,
|
|
112
|
+
};
|