@ouestfrance/sipa-bms-ui 8.22.1 → 8.22.3
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/dist/components/button/BmsButton.vue.d.ts +1 -1
- package/dist/components/button/BmsIconButton.vue.d.ts +1 -1
- package/dist/components/button/UiButton.vue.d.ts +1 -1
- package/dist/components/layout/BmsHeaderTitle.vue.d.ts +1 -1
- package/dist/components/navigation/BmsBreadcrumb.vue.d.ts +1 -1
- package/dist/components/navigation/BmsShortLinkMenu.vue.d.ts +2 -2
- package/dist/components/table/BmsPagination.vue.d.ts +2 -2
- package/dist/plugins/router-history/router-history.composable.d.ts +1 -1
- package/dist/sipa-bms-ui.css +16 -16
- package/dist/sipa-bms-ui.es.js +3608 -3142
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +3608 -3142
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +18 -18
- package/src/components/button/BmsButton.stories.js +142 -3
- package/src/components/form/BmsChip.stories.js +104 -2
- package/src/components/form/BmsInputCheckboxCaptionGroup.stories.js +157 -2
- package/src/components/form/BmsInputCheckboxGroup.stories.js +119 -2
- package/src/components/form/BmsInputCode.stories.js +109 -2
- package/src/components/form/BmsInputFile.stories.js +110 -2
- package/src/components/form/BmsInputRadioCaptionGroup.stories.js +138 -2
- package/src/components/form/BmsInputRadioGroup.stories.js +120 -2
- package/src/components/form/BmsInputText.stories.js +269 -1
- package/src/components/form/BmsMultiSelect.vue +3 -1
- package/src/components/form/BmsSearch.stories.js +89 -2
- package/src/components/form/BmsSelect.stories.js +220 -2
- package/src/components/form/BmsSelect.vue +5 -3
- package/src/components/form/BmsTag.stories.js +119 -3
- package/src/components/form/BmsTextArea.stories.js +146 -2
- package/src/components/form/RawAutocomplete.vue +3 -1
- package/src/components/layout/BmsForm.stories.js +216 -0
- package/src/components/layout/BmsHeaderTitle.stories.js +136 -1
- package/src/components/table/BmsTable.stories.js +247 -1
- package/src/documentation/button/secondaryButton.mdx +114 -3
- package/src/documentation/checkboxCaptionGroup.mdx +99 -0
- package/src/documentation/checkboxGroup.mdx +99 -0
- package/src/documentation/chip.mdx +85 -11
- package/src/documentation/inputCode.mdx +97 -0
- package/src/documentation/inputFile.mdx +90 -13
- package/src/documentation/inputText.mdx +183 -0
- package/src/documentation/layout/form.mdx +74 -0
- package/src/documentation/layout/headerTitle.mdx +124 -0
- package/src/documentation/layout/table.mdx +111 -0
- package/src/documentation/radioCaptionGroup.mdx +86 -19
- package/src/documentation/radioGroup.mdx +85 -18
- package/src/documentation/search.mdx +85 -13
- package/src/documentation/select.mdx +137 -16
- package/src/documentation/tag.mdx +91 -11
- package/src/documentation/textArea.mdx +126 -13
- package/src/documentation/fields_text.mdx +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BmsInputText from '@/components/form/BmsInputText.vue';
|
|
2
2
|
import { within } from 'storybook/test';
|
|
3
|
-
import { BookOpen, CloudLightning } from 'lucide-vue-next';
|
|
3
|
+
import { BookOpen, CloudLightning, Mail, Eye } from 'lucide-vue-next';
|
|
4
4
|
import template from '@/documentation/template_field_dependency.mdx';
|
|
5
5
|
import { ref } from 'vue';
|
|
6
6
|
|
|
@@ -114,3 +114,271 @@ export const WithFocusState = {
|
|
|
114
114
|
await canvas.getByRole('input').focus();
|
|
115
115
|
},
|
|
116
116
|
};
|
|
117
|
+
|
|
118
|
+
// Simple template for documentation (without small variant)
|
|
119
|
+
const SimpleTemplate = (args) => ({
|
|
120
|
+
setup() {
|
|
121
|
+
const modelValue = ref(args.modelValue || '');
|
|
122
|
+
return { args, modelValue };
|
|
123
|
+
},
|
|
124
|
+
components: {
|
|
125
|
+
BmsInputText,
|
|
126
|
+
BookOpen,
|
|
127
|
+
CloudLightning,
|
|
128
|
+
},
|
|
129
|
+
template: `
|
|
130
|
+
<BmsInputText v-bind="args" v-model="modelValue">
|
|
131
|
+
<template v-if="args.iconStart" #icon-start><BookOpen/></template>
|
|
132
|
+
<template v-if="args.iconEnd" #icon-end><CloudLightning/></template>
|
|
133
|
+
</BmsInputText>
|
|
134
|
+
`,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Playground with default values for documentation
|
|
138
|
+
export const PlaygroundInputText = SimpleTemplate.bind({});
|
|
139
|
+
PlaygroundInputText.parameters = { chromatic: { disable: true } };
|
|
140
|
+
PlaygroundInputText.args = {
|
|
141
|
+
label: 'Email address',
|
|
142
|
+
placeholder: 'example@email.com',
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Do: Simple input with label
|
|
146
|
+
export const DoWithLabel = SimpleTemplate.bind({});
|
|
147
|
+
DoWithLabel.parameters = { chromatic: { disable: true } };
|
|
148
|
+
DoWithLabel.args = {
|
|
149
|
+
label: 'Full name',
|
|
150
|
+
placeholder: 'John Doe',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Do: Input with placeholder
|
|
154
|
+
export const DoWithPlaceholder = SimpleTemplate.bind({});
|
|
155
|
+
DoWithPlaceholder.parameters = { chromatic: { disable: true } };
|
|
156
|
+
DoWithPlaceholder.args = {
|
|
157
|
+
label: 'Email address',
|
|
158
|
+
placeholder: 'example@email.com',
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Do: Input with caption
|
|
162
|
+
export const DoWithCaption = SimpleTemplate.bind({});
|
|
163
|
+
DoWithCaption.parameters = { chromatic: { disable: true } };
|
|
164
|
+
DoWithCaption.args = {
|
|
165
|
+
label: 'Password',
|
|
166
|
+
placeholder: 'Enter your password',
|
|
167
|
+
captions: ['Must be at least 8 characters'],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Do: Input with icon at start
|
|
171
|
+
export const DoWithIconStart = () => ({
|
|
172
|
+
components: { BmsInputText, Mail },
|
|
173
|
+
setup() {
|
|
174
|
+
const value = ref('');
|
|
175
|
+
return { value };
|
|
176
|
+
},
|
|
177
|
+
template: `
|
|
178
|
+
<BmsInputText
|
|
179
|
+
label="Email"
|
|
180
|
+
v-model="value"
|
|
181
|
+
placeholder="example@email.com"
|
|
182
|
+
>
|
|
183
|
+
<template #icon-start><Mail /></template>
|
|
184
|
+
</BmsInputText>
|
|
185
|
+
`,
|
|
186
|
+
});
|
|
187
|
+
DoWithIconStart.parameters = { chromatic: { disable: true } };
|
|
188
|
+
|
|
189
|
+
// Do: Input with icon at end
|
|
190
|
+
export const DoWithIconEnd = () => ({
|
|
191
|
+
components: { BmsInputText, Eye },
|
|
192
|
+
setup() {
|
|
193
|
+
const value = ref('');
|
|
194
|
+
return { value };
|
|
195
|
+
},
|
|
196
|
+
template: `
|
|
197
|
+
<BmsInputText
|
|
198
|
+
label="Password"
|
|
199
|
+
v-model="value"
|
|
200
|
+
placeholder="Enter your password"
|
|
201
|
+
>
|
|
202
|
+
<template #icon-end><Eye /></template>
|
|
203
|
+
</BmsInputText>
|
|
204
|
+
`,
|
|
205
|
+
});
|
|
206
|
+
DoWithIconEnd.parameters = { chromatic: { disable: true } };
|
|
207
|
+
|
|
208
|
+
// Do: Input with both icons
|
|
209
|
+
export const DoWithIcons = () => ({
|
|
210
|
+
components: { BmsInputText, Mail, Eye },
|
|
211
|
+
setup() {
|
|
212
|
+
const value = ref('');
|
|
213
|
+
return { value };
|
|
214
|
+
},
|
|
215
|
+
template: `
|
|
216
|
+
<BmsInputText
|
|
217
|
+
label="Email"
|
|
218
|
+
v-model="value"
|
|
219
|
+
placeholder="example@email.com"
|
|
220
|
+
>
|
|
221
|
+
<template #icon-start><Mail /></template>
|
|
222
|
+
<template #icon-end><Eye /></template>
|
|
223
|
+
</BmsInputText>
|
|
224
|
+
`,
|
|
225
|
+
});
|
|
226
|
+
DoWithIcons.parameters = { chromatic: { disable: true } };
|
|
227
|
+
|
|
228
|
+
// Do: Disabled state
|
|
229
|
+
export const DoDisabled = SimpleTemplate.bind({});
|
|
230
|
+
DoDisabled.parameters = { chromatic: { disable: true } };
|
|
231
|
+
DoDisabled.args = {
|
|
232
|
+
label: 'Account ID',
|
|
233
|
+
modelValue: 'ACC-12345',
|
|
234
|
+
disabled: true,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// Do: Loading state
|
|
238
|
+
export const DoLoading = SimpleTemplate.bind({});
|
|
239
|
+
DoLoading.parameters = { chromatic: { disable: true } };
|
|
240
|
+
DoLoading.args = {
|
|
241
|
+
label: 'Email',
|
|
242
|
+
placeholder: 'Loading...',
|
|
243
|
+
loading: true,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Do: Input with max length
|
|
247
|
+
export const DoWithMaxLength = SimpleTemplate.bind({});
|
|
248
|
+
DoWithMaxLength.parameters = { chromatic: { disable: true } };
|
|
249
|
+
DoWithMaxLength.args = {
|
|
250
|
+
label: 'Username',
|
|
251
|
+
placeholder: 'Enter username',
|
|
252
|
+
maxlength: 20,
|
|
253
|
+
modelValue: 'myusernameiswaytoolong',
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// Do: Input with min and max length
|
|
257
|
+
export const DoWithMinMaxLength = SimpleTemplate.bind({});
|
|
258
|
+
DoWithMinMaxLength.parameters = { chromatic: { disable: true } };
|
|
259
|
+
DoWithMinMaxLength.args = {
|
|
260
|
+
label: 'Password',
|
|
261
|
+
placeholder: 'Enter password',
|
|
262
|
+
minlength: 8,
|
|
263
|
+
maxlength: 20,
|
|
264
|
+
modelValue: 'pass123',
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// Don't: Long labels
|
|
268
|
+
export const DontLongLabel = SimpleTemplate.bind({});
|
|
269
|
+
DontLongLabel.parameters = { chromatic: { disable: true } };
|
|
270
|
+
DontLongLabel.args = {
|
|
271
|
+
label:
|
|
272
|
+
'Please enter your complete full name including first name, middle name if applicable, and last name',
|
|
273
|
+
placeholder: 'Name',
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const DoShortLabel = SimpleTemplate.bind({});
|
|
277
|
+
DoShortLabel.parameters = { chromatic: { disable: true } };
|
|
278
|
+
DoShortLabel.args = {
|
|
279
|
+
label: 'Full name',
|
|
280
|
+
placeholder: 'John Doe',
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// Don't: No label
|
|
284
|
+
export const DontNoLabel = SimpleTemplate.bind({});
|
|
285
|
+
DontNoLabel.parameters = { chromatic: { disable: true } };
|
|
286
|
+
DontNoLabel.args = {
|
|
287
|
+
placeholder: 'Enter your email',
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// Don't: Generic placeholder
|
|
291
|
+
export const DontGenericPlaceholder = SimpleTemplate.bind({});
|
|
292
|
+
DontGenericPlaceholder.parameters = { chromatic: { disable: true } };
|
|
293
|
+
DontGenericPlaceholder.args = {
|
|
294
|
+
label: 'Email',
|
|
295
|
+
placeholder: 'Enter text here',
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
export const DoSpecificPlaceholder = SimpleTemplate.bind({});
|
|
299
|
+
DoSpecificPlaceholder.parameters = { chromatic: { disable: true } };
|
|
300
|
+
DoSpecificPlaceholder.args = {
|
|
301
|
+
label: 'Email',
|
|
302
|
+
placeholder: 'example@email.com',
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// Don't: Too many icons
|
|
306
|
+
export const DontTooManyIcons = () => ({
|
|
307
|
+
components: { BmsInputText, Mail, Eye, BookOpen },
|
|
308
|
+
setup() {
|
|
309
|
+
const value = ref('');
|
|
310
|
+
return { value };
|
|
311
|
+
},
|
|
312
|
+
template: `
|
|
313
|
+
<BmsInputText
|
|
314
|
+
label="Email"
|
|
315
|
+
v-model="value"
|
|
316
|
+
placeholder="example@email.com"
|
|
317
|
+
>
|
|
318
|
+
<template #icon-start>
|
|
319
|
+
<Mail />
|
|
320
|
+
<BookOpen />
|
|
321
|
+
</template>
|
|
322
|
+
<template #icon-end>
|
|
323
|
+
<Eye />
|
|
324
|
+
<BookOpen />
|
|
325
|
+
</template>
|
|
326
|
+
</BmsInputText>
|
|
327
|
+
`,
|
|
328
|
+
});
|
|
329
|
+
DontTooManyIcons.parameters = { chromatic: { disable: true } };
|
|
330
|
+
|
|
331
|
+
export const DoOneIcon = () => ({
|
|
332
|
+
components: { BmsInputText, Mail },
|
|
333
|
+
setup() {
|
|
334
|
+
const value = ref('');
|
|
335
|
+
return { value };
|
|
336
|
+
},
|
|
337
|
+
template: `
|
|
338
|
+
<BmsInputText
|
|
339
|
+
label="Email"
|
|
340
|
+
v-model="value"
|
|
341
|
+
placeholder="example@email.com"
|
|
342
|
+
>
|
|
343
|
+
<template #icon-start><Mail /></template>
|
|
344
|
+
</BmsInputText>
|
|
345
|
+
`,
|
|
346
|
+
});
|
|
347
|
+
DoOneIcon.parameters = { chromatic: { disable: true } };
|
|
348
|
+
|
|
349
|
+
// Don't: No error feedback
|
|
350
|
+
export const DontNoErrorFeedback = SimpleTemplate.bind({});
|
|
351
|
+
DontNoErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
352
|
+
DontNoErrorFeedback.args = {
|
|
353
|
+
label: 'Email',
|
|
354
|
+
placeholder: 'email@example.com',
|
|
355
|
+
modelValue: 'invalid-email',
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
export const DoWithErrorFeedback = SimpleTemplate.bind({});
|
|
359
|
+
DoWithErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
360
|
+
DoWithErrorFeedback.args = {
|
|
361
|
+
label: 'Email',
|
|
362
|
+
placeholder: 'email@example.com',
|
|
363
|
+
modelValue: 'invalid-email',
|
|
364
|
+
errors: ['Please enter a valid email address'],
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// Don't: No caption for complex requirements
|
|
368
|
+
export const DontNoCaption = SimpleTemplate.bind({});
|
|
369
|
+
DontNoCaption.parameters = { chromatic: { disable: true } };
|
|
370
|
+
DontNoCaption.args = {
|
|
371
|
+
label: 'Username',
|
|
372
|
+
placeholder: 'Enter username',
|
|
373
|
+
modelValue: 'JohnDoe',
|
|
374
|
+
errors: ['Error'],
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export const DoWithHelpfulCaption = SimpleTemplate.bind({});
|
|
378
|
+
DoWithHelpfulCaption.parameters = { chromatic: { disable: true } };
|
|
379
|
+
DoWithHelpfulCaption.args = {
|
|
380
|
+
label: 'Username',
|
|
381
|
+
placeholder: 'Enter username',
|
|
382
|
+
modelValue: 'JohnDoe',
|
|
383
|
+
errors: ['Username is already taken'],
|
|
384
|
+
};
|
|
@@ -108,7 +108,9 @@ onKeyUp('Tab', closeDatalist);
|
|
|
108
108
|
onKeyDown('Backspace', onBackspace);
|
|
109
109
|
|
|
110
110
|
const onSelectClick = () => {
|
|
111
|
-
|
|
111
|
+
if (!props.disabled) {
|
|
112
|
+
isDatalistOpen.value = !isDatalistOpen.value;
|
|
113
|
+
}
|
|
112
114
|
};
|
|
113
115
|
const onInput = (e: InputEvent) => {
|
|
114
116
|
emits('input', e);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import BmsSearch from '@/components/form/BmsSearch.vue';
|
|
2
2
|
import { within } from 'storybook/test';
|
|
3
|
+
import { ref } from 'vue';
|
|
3
4
|
|
|
4
5
|
import template from '@/documentation/template_field_dependency.mdx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
8
|
+
title: 'Composants/form/Search',
|
|
9
|
+
component: BmsSearch,
|
|
7
10
|
parameters: {
|
|
8
11
|
docs: {
|
|
9
12
|
page: template,
|
|
10
13
|
},
|
|
11
14
|
},
|
|
12
|
-
title: 'Composants/form/Search',
|
|
13
|
-
component: BmsSearch,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
const Template = (args) => ({
|
|
@@ -70,3 +71,89 @@ export const WithFocusState = {
|
|
|
70
71
|
await canvas.getByRole('input').focus();
|
|
71
72
|
},
|
|
72
73
|
};
|
|
74
|
+
|
|
75
|
+
// Simple template for documentation (without small variant)
|
|
76
|
+
const SimpleTemplate = (args) => ({
|
|
77
|
+
setup() {
|
|
78
|
+
const modelValue = ref(args.modelValue || '');
|
|
79
|
+
return { args, modelValue };
|
|
80
|
+
},
|
|
81
|
+
components: {
|
|
82
|
+
BmsSearch,
|
|
83
|
+
},
|
|
84
|
+
template: `
|
|
85
|
+
<BmsSearch v-bind="args" v-model="modelValue" />
|
|
86
|
+
`,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Playground with default values for documentation
|
|
90
|
+
export const PlaygroundSearch = SimpleTemplate.bind({});
|
|
91
|
+
PlaygroundSearch.parameters = { chromatic: { disable: true } };
|
|
92
|
+
PlaygroundSearch.args = {
|
|
93
|
+
placeholder: 'Search...',
|
|
94
|
+
modelValue: '',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Do: Search with clear placeholder
|
|
98
|
+
export const DoWithClearPlaceholder = SimpleTemplate.bind({});
|
|
99
|
+
DoWithClearPlaceholder.parameters = { chromatic: { disable: true } };
|
|
100
|
+
DoWithClearPlaceholder.args = {
|
|
101
|
+
placeholder: 'Search products...',
|
|
102
|
+
modelValue: '',
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Do: Search with value and clear button
|
|
106
|
+
export const DoWithValue = SimpleTemplate.bind({});
|
|
107
|
+
DoWithValue.parameters = { chromatic: { disable: true } };
|
|
108
|
+
DoWithValue.args = {
|
|
109
|
+
placeholder: 'Search...',
|
|
110
|
+
modelValue: 'search term',
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Do: Disabled state
|
|
114
|
+
export const DoDisabled = SimpleTemplate.bind({});
|
|
115
|
+
DoDisabled.parameters = { chromatic: { disable: true } };
|
|
116
|
+
DoDisabled.args = {
|
|
117
|
+
placeholder: 'Search...',
|
|
118
|
+
modelValue: 'search term',
|
|
119
|
+
disabled: true,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Do: Search with error feedback
|
|
123
|
+
export const DoWithErrorFeedback = SimpleTemplate.bind({});
|
|
124
|
+
DoWithErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
125
|
+
DoWithErrorFeedback.args = {
|
|
126
|
+
placeholder: 'Search...',
|
|
127
|
+
modelValue: 'invalid search',
|
|
128
|
+
errors: ['Search query is too short'],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Don't: Generic placeholder
|
|
132
|
+
export const DontGenericPlaceholder = SimpleTemplate.bind({});
|
|
133
|
+
DontGenericPlaceholder.parameters = { chromatic: { disable: true } };
|
|
134
|
+
DontGenericPlaceholder.args = {
|
|
135
|
+
placeholder: 'Type here',
|
|
136
|
+
modelValue: '',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const DoSpecificPlaceholder = SimpleTemplate.bind({});
|
|
140
|
+
DoSpecificPlaceholder.parameters = { chromatic: { disable: true } };
|
|
141
|
+
DoSpecificPlaceholder.args = {
|
|
142
|
+
placeholder: 'Search by name, email, or ID...',
|
|
143
|
+
modelValue: '',
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Don't: No error feedback
|
|
147
|
+
export const DontNoErrorFeedback = SimpleTemplate.bind({});
|
|
148
|
+
DontNoErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
149
|
+
DontNoErrorFeedback.args = {
|
|
150
|
+
placeholder: 'Search...',
|
|
151
|
+
modelValue: 'invalid',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Don't: Search without placeholder
|
|
155
|
+
export const DontNoPlaceholder = SimpleTemplate.bind({});
|
|
156
|
+
DontNoPlaceholder.parameters = { chromatic: { disable: true } };
|
|
157
|
+
DontNoPlaceholder.args = {
|
|
158
|
+
modelValue: '',
|
|
159
|
+
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import BmsSelect from '@/components/form/BmsSelect.vue';
|
|
2
2
|
import { within } from 'storybook/test';
|
|
3
|
+
import { ref } from 'vue';
|
|
3
4
|
|
|
4
5
|
import template from '@/documentation/template_field_dependency.mdx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
8
|
+
title: 'Composants/form/Select',
|
|
9
|
+
component: BmsSelect,
|
|
7
10
|
parameters: {
|
|
8
11
|
docs: {
|
|
9
12
|
page: template,
|
|
10
13
|
},
|
|
11
14
|
},
|
|
12
|
-
title: 'Composants/form/Select',
|
|
13
|
-
component: BmsSelect,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
const Template = (args) => ({
|
|
@@ -141,3 +142,220 @@ WithIncorrectValue.args = {
|
|
|
141
142
|
{ label: 'c', value: 'c' },
|
|
142
143
|
],
|
|
143
144
|
};
|
|
145
|
+
|
|
146
|
+
// Simple template for documentation (without small variant)
|
|
147
|
+
const SimpleTemplate = (args) => ({
|
|
148
|
+
setup() {
|
|
149
|
+
const modelValue = ref(args.modelValue || '');
|
|
150
|
+
return { args, modelValue };
|
|
151
|
+
},
|
|
152
|
+
components: {
|
|
153
|
+
BmsSelect,
|
|
154
|
+
},
|
|
155
|
+
template: `
|
|
156
|
+
<BmsSelect v-bind="args" v-model="modelValue" />
|
|
157
|
+
`,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Playground with default values for documentation
|
|
161
|
+
export const PlaygroundSelect = SimpleTemplate.bind({});
|
|
162
|
+
PlaygroundSelect.parameters = { chromatic: { disable: true } };
|
|
163
|
+
PlaygroundSelect.args = {
|
|
164
|
+
label: 'Country',
|
|
165
|
+
placeholder: 'Select a country',
|
|
166
|
+
modelValue: '',
|
|
167
|
+
options: [
|
|
168
|
+
{ label: 'France', value: 'fr' },
|
|
169
|
+
{ label: 'Germany', value: 'de' },
|
|
170
|
+
{ label: 'Spain', value: 'es' },
|
|
171
|
+
{ label: 'Italy', value: 'it' },
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Do: Simple select with label
|
|
176
|
+
export const DoWithLabel = SimpleTemplate.bind({});
|
|
177
|
+
DoWithLabel.parameters = { chromatic: { disable: true } };
|
|
178
|
+
DoWithLabel.args = {
|
|
179
|
+
label: 'Country',
|
|
180
|
+
modelValue: '',
|
|
181
|
+
options: [
|
|
182
|
+
{ label: 'France', value: 'fr' },
|
|
183
|
+
{ label: 'Germany', value: 'de' },
|
|
184
|
+
{ label: 'Spain', value: 'es' },
|
|
185
|
+
],
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Do: Select with placeholder
|
|
189
|
+
export const DoWithPlaceholder = SimpleTemplate.bind({});
|
|
190
|
+
DoWithPlaceholder.parameters = { chromatic: { disable: true } };
|
|
191
|
+
DoWithPlaceholder.args = {
|
|
192
|
+
label: 'Country',
|
|
193
|
+
placeholder: 'Choose your country',
|
|
194
|
+
modelValue: '',
|
|
195
|
+
options: [
|
|
196
|
+
{ label: 'France', value: 'fr' },
|
|
197
|
+
{ label: 'Germany', value: 'de' },
|
|
198
|
+
{ label: 'Spain', value: 'es' },
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Do: Select with caption
|
|
203
|
+
export const DoWithCaption = SimpleTemplate.bind({});
|
|
204
|
+
DoWithCaption.parameters = { chromatic: { disable: true } };
|
|
205
|
+
DoWithCaption.args = {
|
|
206
|
+
label: 'Payment method',
|
|
207
|
+
placeholder: 'Select payment method',
|
|
208
|
+
modelValue: '',
|
|
209
|
+
captions: ['We accept all major credit cards'],
|
|
210
|
+
options: [
|
|
211
|
+
{ label: 'Credit Card', value: 'cc' },
|
|
212
|
+
{ label: 'PayPal', value: 'pp' },
|
|
213
|
+
{ label: 'Bank Transfer', value: 'bt' },
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Do: Disabled state
|
|
218
|
+
export const DoDisabled = SimpleTemplate.bind({});
|
|
219
|
+
DoDisabled.parameters = { chromatic: { disable: true } };
|
|
220
|
+
DoDisabled.args = {
|
|
221
|
+
label: 'Country',
|
|
222
|
+
modelValue: 'fr',
|
|
223
|
+
disabled: true,
|
|
224
|
+
options: [
|
|
225
|
+
{ label: 'France', value: 'fr' },
|
|
226
|
+
{ label: 'Germany', value: 'de' },
|
|
227
|
+
{ label: 'Spain', value: 'es' },
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Do: Loading state
|
|
232
|
+
export const DoLoading = SimpleTemplate.bind({});
|
|
233
|
+
DoLoading.parameters = { chromatic: { disable: true } };
|
|
234
|
+
DoLoading.args = {
|
|
235
|
+
label: 'Country',
|
|
236
|
+
placeholder: 'Loading...',
|
|
237
|
+
loading: true,
|
|
238
|
+
modelValue: '',
|
|
239
|
+
options: [],
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// Do: Select with error feedback
|
|
243
|
+
export const DoWithErrorFeedback = SimpleTemplate.bind({});
|
|
244
|
+
DoWithErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
245
|
+
DoWithErrorFeedback.args = {
|
|
246
|
+
label: 'Country',
|
|
247
|
+
placeholder: 'Select a country',
|
|
248
|
+
modelValue: '',
|
|
249
|
+
errors: ['Please select a country'],
|
|
250
|
+
options: [
|
|
251
|
+
{ label: 'France', value: 'fr' },
|
|
252
|
+
{ label: 'Germany', value: 'de' },
|
|
253
|
+
{ label: 'Spain', value: 'es' },
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Do: Select with helpful caption
|
|
258
|
+
export const DoWithHelpfulCaption = SimpleTemplate.bind({});
|
|
259
|
+
DoWithHelpfulCaption.parameters = { chromatic: { disable: true } };
|
|
260
|
+
DoWithHelpfulCaption.args = {
|
|
261
|
+
label: 'Payment method',
|
|
262
|
+
placeholder: 'Select payment method',
|
|
263
|
+
modelValue: '',
|
|
264
|
+
captions: ['Select your preferred payment method to proceed'],
|
|
265
|
+
errors: ['Payment method is required'],
|
|
266
|
+
options: [
|
|
267
|
+
{ label: 'Credit Card', value: 'cc' },
|
|
268
|
+
{ label: 'PayPal', value: 'pp' },
|
|
269
|
+
{ label: 'Bank Transfer', value: 'bt' },
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Don't: Long labels
|
|
274
|
+
export const DontLongLabel = SimpleTemplate.bind({});
|
|
275
|
+
DontLongLabel.parameters = { chromatic: { disable: true } };
|
|
276
|
+
DontLongLabel.args = {
|
|
277
|
+
label:
|
|
278
|
+
'Please select the country where you currently reside and where you would like to receive your shipment',
|
|
279
|
+
placeholder: 'Country',
|
|
280
|
+
modelValue: '',
|
|
281
|
+
options: [
|
|
282
|
+
{ label: 'France', value: 'fr' },
|
|
283
|
+
{ label: 'Germany', value: 'de' },
|
|
284
|
+
],
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export const DoShortLabel = SimpleTemplate.bind({});
|
|
288
|
+
DoShortLabel.parameters = { chromatic: { disable: true } };
|
|
289
|
+
DoShortLabel.args = {
|
|
290
|
+
label: 'Country',
|
|
291
|
+
placeholder: 'Select country',
|
|
292
|
+
modelValue: '',
|
|
293
|
+
options: [
|
|
294
|
+
{ label: 'France', value: 'fr' },
|
|
295
|
+
{ label: 'Germany', value: 'de' },
|
|
296
|
+
],
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// Don't: No label
|
|
300
|
+
export const DontNoLabel = SimpleTemplate.bind({});
|
|
301
|
+
DontNoLabel.parameters = { chromatic: { disable: true } };
|
|
302
|
+
DontNoLabel.args = {
|
|
303
|
+
placeholder: 'Select an option',
|
|
304
|
+
modelValue: '',
|
|
305
|
+
options: [
|
|
306
|
+
{ label: 'Option 1', value: '1' },
|
|
307
|
+
{ label: 'Option 2', value: '2' },
|
|
308
|
+
],
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// Don't: Generic placeholder
|
|
312
|
+
export const DontGenericPlaceholder = SimpleTemplate.bind({});
|
|
313
|
+
DontGenericPlaceholder.parameters = { chromatic: { disable: true } };
|
|
314
|
+
DontGenericPlaceholder.args = {
|
|
315
|
+
label: 'Country',
|
|
316
|
+
placeholder: 'Select',
|
|
317
|
+
modelValue: '',
|
|
318
|
+
options: [
|
|
319
|
+
{ label: 'France', value: 'fr' },
|
|
320
|
+
{ label: 'Germany', value: 'de' },
|
|
321
|
+
],
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export const DoSpecificPlaceholder = SimpleTemplate.bind({});
|
|
325
|
+
DoSpecificPlaceholder.parameters = { chromatic: { disable: true } };
|
|
326
|
+
DoSpecificPlaceholder.args = {
|
|
327
|
+
label: 'Country',
|
|
328
|
+
placeholder: 'Choose your country',
|
|
329
|
+
modelValue: '',
|
|
330
|
+
options: [
|
|
331
|
+
{ label: 'France', value: 'fr' },
|
|
332
|
+
{ label: 'Germany', value: 'de' },
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// Don't: No error feedback
|
|
337
|
+
export const DontNoErrorFeedback = SimpleTemplate.bind({});
|
|
338
|
+
DontNoErrorFeedback.parameters = { chromatic: { disable: true } };
|
|
339
|
+
DontNoErrorFeedback.args = {
|
|
340
|
+
label: 'Country',
|
|
341
|
+
placeholder: 'Select a country',
|
|
342
|
+
modelValue: '',
|
|
343
|
+
options: [
|
|
344
|
+
{ label: 'France', value: 'fr' },
|
|
345
|
+
{ label: 'Germany', value: 'de' },
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// Don't: No caption for complex requirements
|
|
350
|
+
export const DontNoCaption = SimpleTemplate.bind({});
|
|
351
|
+
DontNoCaption.parameters = { chromatic: { disable: true } };
|
|
352
|
+
DontNoCaption.args = {
|
|
353
|
+
label: 'Payment method',
|
|
354
|
+
placeholder: 'Select payment method',
|
|
355
|
+
modelValue: '',
|
|
356
|
+
errors: ['Error'],
|
|
357
|
+
options: [
|
|
358
|
+
{ label: 'Credit Card', value: 'cc' },
|
|
359
|
+
{ label: 'PayPal', value: 'pp' },
|
|
360
|
+
],
|
|
361
|
+
};
|
|
@@ -96,9 +96,11 @@ const onSelect = (option: any) => {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const onSelectClick = () => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (!props.disabled) {
|
|
100
|
+
isDatalistOpen.value = !isDatalistOpen.value;
|
|
101
|
+
if (isDatalistOpen) {
|
|
102
|
+
setFocus();
|
|
103
|
+
}
|
|
102
104
|
}
|
|
103
105
|
};
|
|
104
106
|
|