vueless 0.0.690 → 0.0.691
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-input/storybook/stories.ts +106 -35
package/package.json
CHANGED
|
@@ -9,6 +9,8 @@ import UInput from "../../ui.form-input/UInput.vue";
|
|
|
9
9
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
10
10
|
import UButton from "../../ui.button/UButton.vue";
|
|
11
11
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
12
|
+
import URow from "../../ui.container-row/URow.vue";
|
|
13
|
+
import UAvatar from "../../ui.image-avatar/UAvatar.vue";
|
|
12
14
|
|
|
13
15
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
14
16
|
import type { Props } from "../types.ts";
|
|
@@ -36,14 +38,18 @@ export default {
|
|
|
36
38
|
} as Meta;
|
|
37
39
|
|
|
38
40
|
const DefaultTemplate: StoryFn<UInputArgs> = (args: UInputArgs) => ({
|
|
39
|
-
components: { UInput, UIcon
|
|
41
|
+
components: { UInput, UIcon },
|
|
40
42
|
setup() {
|
|
41
43
|
const slots = getSlotNames(UInput.__name);
|
|
42
44
|
|
|
43
45
|
return { args, slots };
|
|
44
46
|
},
|
|
45
47
|
template: `
|
|
46
|
-
<UInput
|
|
48
|
+
<UInput
|
|
49
|
+
v-bind="args"
|
|
50
|
+
v-model="args.modelValue"
|
|
51
|
+
class="max-w-96"
|
|
52
|
+
>
|
|
47
53
|
${args.slotTemplate || getSlotsFragment("")}
|
|
48
54
|
</UInput>
|
|
49
55
|
`,
|
|
@@ -52,19 +58,58 @@ const DefaultTemplate: StoryFn<UInputArgs> = (args: UInputArgs) => ({
|
|
|
52
58
|
const EnumVariantTemplate: StoryFn<UInputArgs> = (args: UInputArgs, { argTypes }) => ({
|
|
53
59
|
components: { UInput, UCol },
|
|
54
60
|
setup() {
|
|
61
|
+
function getDescription(option: string) {
|
|
62
|
+
switch (option) {
|
|
63
|
+
case "string":
|
|
64
|
+
return "Only letters are allowed";
|
|
65
|
+
case "number":
|
|
66
|
+
return "Numbers are allowed (including decimals)";
|
|
67
|
+
case "integer":
|
|
68
|
+
return "Only integers are allowed";
|
|
69
|
+
case "stringAndNumber":
|
|
70
|
+
return "Letters and numbers are allowed";
|
|
71
|
+
case "symbol":
|
|
72
|
+
return "Special characters are allowed";
|
|
73
|
+
default:
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let filteredOptions = argTypes?.[args.enum]?.options;
|
|
79
|
+
|
|
80
|
+
if (args.enum === "labelAlign") {
|
|
81
|
+
filteredOptions = argTypes?.[args.enum]?.options?.filter(
|
|
82
|
+
(item) => item !== "right" && item !== "topWithDesc",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
55
86
|
return {
|
|
56
87
|
args,
|
|
57
|
-
|
|
88
|
+
filteredOptions,
|
|
89
|
+
getDescription,
|
|
58
90
|
};
|
|
59
91
|
},
|
|
60
92
|
template: `
|
|
61
93
|
<UCol>
|
|
62
94
|
<UInput
|
|
63
|
-
v-for="(option, index) in
|
|
95
|
+
v-for="(option, index) in filteredOptions"
|
|
64
96
|
:key="index"
|
|
65
97
|
v-bind="args"
|
|
66
98
|
:[args.enum]="option"
|
|
67
99
|
:label="option"
|
|
100
|
+
:description="getDescription(option)"
|
|
101
|
+
class="max-w-96"
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<UInput
|
|
105
|
+
v-if="args.enum === 'validationRule'"
|
|
106
|
+
v-bind="args"
|
|
107
|
+
validation-rule="^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
|
|
108
|
+
label="Custom RegExp"
|
|
109
|
+
description="Enter a valid hex color code (e.g., #FF5733)"
|
|
110
|
+
labelAlign="topWithDesc"
|
|
111
|
+
placeholder="#FF5733"
|
|
112
|
+
class="max-w-96"
|
|
68
113
|
/>
|
|
69
114
|
</UCol>
|
|
70
115
|
`,
|
|
@@ -73,23 +118,20 @@ const EnumVariantTemplate: StoryFn<UInputArgs> = (args: UInputArgs, { argTypes }
|
|
|
73
118
|
export const Default = DefaultTemplate.bind({});
|
|
74
119
|
Default.args = {};
|
|
75
120
|
|
|
76
|
-
export const
|
|
77
|
-
|
|
121
|
+
export const Placeholder = DefaultTemplate.bind({});
|
|
122
|
+
Placeholder.args = { placeholder: "Type something here..." };
|
|
78
123
|
|
|
79
124
|
export const Description = DefaultTemplate.bind({});
|
|
80
|
-
Description.args = { description: "
|
|
125
|
+
Description.args = { description: "Provide additional details if necessary." };
|
|
81
126
|
|
|
82
127
|
export const Error = DefaultTemplate.bind({});
|
|
83
|
-
Error.args = { error: "
|
|
84
|
-
|
|
85
|
-
export const Placeholder = DefaultTemplate.bind({});
|
|
86
|
-
Placeholder.args = { placeholder: "some placeholder text" };
|
|
128
|
+
Error.args = { error: "This field is required. Please enter a value." };
|
|
87
129
|
|
|
88
130
|
export const Readonly = DefaultTemplate.bind({});
|
|
89
|
-
Readonly.args = { readonly: true, modelValue: "
|
|
131
|
+
Readonly.args = { readonly: true, modelValue: "Pre-filled content that cannot be changed" };
|
|
90
132
|
|
|
91
|
-
export const
|
|
92
|
-
|
|
133
|
+
export const Disabled = DefaultTemplate.bind({});
|
|
134
|
+
Disabled.args = { disabled: true };
|
|
93
135
|
|
|
94
136
|
export const TypePassword = DefaultTemplate.bind({});
|
|
95
137
|
TypePassword.args = { type: "password" };
|
|
@@ -101,28 +143,57 @@ export const Sizes = EnumVariantTemplate.bind({});
|
|
|
101
143
|
Sizes.args = { enum: "size" };
|
|
102
144
|
|
|
103
145
|
export const ValidationRules = EnumVariantTemplate.bind({});
|
|
104
|
-
ValidationRules.args = { enum: "validationRule" };
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
146
|
+
ValidationRules.args = { enum: "validationRule", labelAlign: "topWithDesc" };
|
|
147
|
+
ValidationRules.parameters = {
|
|
148
|
+
docs: {
|
|
149
|
+
description: {
|
|
150
|
+
story:
|
|
151
|
+
"`validationRule` prop prevents some characters from input. You can use predefined values or your own RegExp.",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
111
155
|
|
|
112
|
-
export const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
156
|
+
export const IconProps: StoryFn<UInputArgs> = (args) => ({
|
|
157
|
+
components: { UInput, URow },
|
|
158
|
+
setup() {
|
|
159
|
+
return { args };
|
|
160
|
+
},
|
|
161
|
+
template: `
|
|
162
|
+
<URow>
|
|
163
|
+
<UInput
|
|
164
|
+
v-bind="args"
|
|
165
|
+
left-icon="feedback"
|
|
166
|
+
label="Your opinion"
|
|
167
|
+
placeholder="Share your feedback with us"
|
|
168
|
+
/>
|
|
169
|
+
<UInput
|
|
170
|
+
v-bind="args"
|
|
171
|
+
right-icon="person"
|
|
172
|
+
label="Username"
|
|
173
|
+
placeholder="Enter your username"
|
|
174
|
+
/>
|
|
175
|
+
</URow>
|
|
118
176
|
`,
|
|
119
|
-
};
|
|
177
|
+
});
|
|
120
178
|
|
|
121
|
-
export const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
179
|
+
export const Slots: StoryFn<UInputArgs> = (args) => ({
|
|
180
|
+
components: { UInput, URow, UButton, UAvatar },
|
|
181
|
+
setup() {
|
|
182
|
+
return { args };
|
|
183
|
+
},
|
|
184
|
+
template: `
|
|
185
|
+
<URow no-mobile>
|
|
186
|
+
<UInput v-bind="args">
|
|
187
|
+
<template #left>
|
|
188
|
+
<UAvatar />
|
|
189
|
+
</template>
|
|
190
|
+
</UInput>
|
|
191
|
+
|
|
192
|
+
<UInput v-bind="args" :config="{ rightSlot: 'pr-0' }">
|
|
193
|
+
<template #right>
|
|
194
|
+
<UButton label="Search" size="sm" class="rounded-l-none h-full" />
|
|
195
|
+
</template>
|
|
196
|
+
</UInput>
|
|
197
|
+
</URow>
|
|
127
198
|
`,
|
|
128
|
-
};
|
|
199
|
+
});
|