vueless 0.0.254 → 0.0.255

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.
@@ -1,10 +1,9 @@
1
1
  import ULabel from "../ui.form-label";
2
- import URow from "../ui.container-row";
3
2
  import UCol from "../ui.container-col";
4
3
  import UText from "../ui.text-block";
5
4
  import UIcon from "../ui.image-icon";
6
5
 
7
- import { getArgTypes } from "../service.storybook";
6
+ import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
8
7
 
9
8
  /**
10
9
  * The `ULabel` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.form-label)
@@ -22,73 +21,51 @@ export default {
22
21
  },
23
22
  };
24
23
 
25
- const message = "This is plain text";
24
+ const defaultTemplate = "This is plain text";
26
25
 
27
26
  const DefaultTemplate = (args) => ({
28
- components: { ULabel, UText },
29
- setup() {
30
- return { args };
31
- },
32
- template: `
33
- <ULabel v-bind="args">
34
- <UText v-bind="args">${message}</UText>
35
- </ULabel>
36
- `,
37
- });
38
-
39
- const SlotTemplate = (args) => ({
40
27
  components: { ULabel, UText, UIcon },
41
28
  setup() {
42
- return { args };
29
+ const slots = getSlotNames(ULabel.name);
30
+
31
+ return { args, slots };
43
32
  },
44
33
  template: `
45
34
  <ULabel v-bind="args">
46
- <UText v-bind="args">${message}</UText>
47
- ${args.slotTemplate}
35
+ <UText v-bind="args">${getSlotsFragment(defaultTemplate)}</UText>
36
+ ${args.slotTemplate ? args.slotTemplate : ""}
48
37
  </ULabel>
49
38
  `,
50
39
  });
51
40
 
52
- const SizesTemplate = (args, { argTypes } = {}) => ({
53
- components: { ULabel, URow, UText },
54
- setup() {
55
- return {
56
- args,
57
- sizes: argTypes.size.options,
58
- };
59
- },
60
- template: `
61
- <URow>
62
- <ULabel
63
- v-for="(size, index) in sizes"
64
- v-bind="args"
65
- :size="size"
66
- :key="index"
67
- >
68
- <UText :size="size">This is <b>"{{ size }}"</b> size.</UText>
69
- </ULabel>
70
- </URow>
71
- `,
72
- });
73
-
74
- const LabelPlacementTemplate = (args, { argTypes } = {}) => ({
41
+ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
75
42
  components: { ULabel, UCol, UText },
76
43
  setup() {
44
+ function getText(value, name) {
45
+ return name === "size" ? `This is ${value} size.` : `This is ${value} label placement.`;
46
+ }
47
+
48
+ const { name, options } = argTypes[args.enum];
49
+ const prefixedOptions = options.map((option) => getText(option, name));
50
+
77
51
  return {
78
52
  args,
79
- placements: argTypes.align.options,
53
+ options: argTypes[args.enum].options,
54
+ prefixedOptions,
80
55
  };
81
56
  },
82
57
  template: `
83
58
  <UCol>
84
59
  <ULabel
85
- v-for="(align, index) in placements"
86
- v-bind="args"
87
- :align="align"
60
+ v-for="(option, index) in options"
88
61
  :key="index"
62
+ v-bind="args"
63
+ :[args.enum]="option"
89
64
  class="border border-gray-200 rounded p-4"
90
65
  >
91
- <UText>This is <b>"{{ align }}"</b> label placement.</UText>
66
+ <UText :[args.enum]="option">
67
+ {{ prefixedOptions[index] }}
68
+ </UText>
92
69
  </ULabel>
93
70
  </UCol>
94
71
  `,
@@ -97,11 +74,11 @@ const LabelPlacementTemplate = (args, { argTypes } = {}) => ({
97
74
  export const Default = DefaultTemplate.bind({});
98
75
  Default.args = {};
99
76
 
100
- export const Sizes = SizesTemplate.bind({});
101
- Sizes.args = {};
77
+ export const Sizes = EnumVariantTemplate.bind({});
78
+ Sizes.args = { enum: "size" };
102
79
 
103
- export const LabelPlacement = LabelPlacementTemplate.bind({});
104
- LabelPlacement.args = {};
80
+ export const LabelPlacement = EnumVariantTemplate.bind({});
81
+ LabelPlacement.args = { enum: "align" };
105
82
 
106
83
  export const Error = DefaultTemplate.bind({});
107
84
  Error.args = { error: "Error description" };
@@ -109,7 +86,7 @@ Error.args = { error: "Error description" };
109
86
  export const Disabled = DefaultTemplate.bind({});
110
87
  Disabled.args = { disabled: true };
111
88
 
112
- export const slotFooter = SlotTemplate.bind({});
89
+ export const slotFooter = DefaultTemplate.bind({});
113
90
  slotFooter.args = {
114
91
  slotTemplate: `
115
92
  <template #footer>
@@ -13,7 +13,9 @@ export default {
13
13
  id: "3160",
14
14
  title: "Form Inputs & Controls / Radio Group",
15
15
  component: URadioGroup,
16
- args: {},
16
+ args: {
17
+ modelValue: "One",
18
+ },
17
19
  argTypes: {
18
20
  ...getArgTypes(URadioGroup.name),
19
21
  },
@@ -36,14 +38,9 @@ const DefaultTemplate = (args) => ({
36
38
 
37
39
  return { args, slots, radios };
38
40
  },
39
- data() {
40
- return {
41
- value: args.value,
42
- };
43
- },
44
41
  template: `
45
42
  <UCol gap="2xl">
46
- <URadioGroup v-bind="args" v-model="value">
43
+ <URadioGroup v-bind="args" v-model="args.modelValue">
47
44
  <URadio
48
45
  v-for="(radio, index) in radios"
49
46
  :key="index"
@@ -53,7 +50,7 @@ const DefaultTemplate = (args) => ({
53
50
  </URadio>
54
51
  </URadioGroup>
55
52
  <UAlert color="gray" size="xs">
56
- <code>Selected value: <b>{{ value }}</b></code>
53
+ <code>Selected value: <b>{{ args.modelValue }}</b></code>
57
54
  </UAlert>
58
55
  </UCol>
59
56
  `,
@@ -70,18 +67,13 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
70
67
  radios,
71
68
  };
72
69
  },
73
- data() {
74
- return {
75
- value: args.value,
76
- };
77
- },
78
70
  template: `
79
71
  <URow class="!flex-col">
80
72
  <URadioGroup
81
73
  v-for="(option, index) in options"
82
74
  :key="index"
83
75
  v-bind="args"
84
- v-model="value"
76
+ v-model="args.modelValue"
85
77
  :[args.enum]="option"
86
78
  :label="option"
87
79
  :options="radios"
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import USelect from "../ui.form-select";
4
4
  import URow from "../ui.container-row";
@@ -36,66 +36,42 @@ export default {
36
36
  };
37
37
 
38
38
  const DefaultTemplate = (args) => ({
39
- components: { USelect },
39
+ components: { USelect, UIcon, UBadge },
40
40
  setup() {
41
- const slots = getSlotNames(USelect.name);
42
-
43
- return { args, slots };
44
- },
45
- template: `
46
- <USelect v-bind="args" v-model="args.modelValue">
47
- ${allSlotsFragment}
48
- </USelect>
49
- `,
50
- });
41
+ function getSelectedBadge(options, currentValue) {
42
+ return options?.find((option) => option.id === currentValue);
43
+ }
51
44
 
52
- const multipleTemplate = (args) => ({
53
- components: { USelect },
54
- setup() {
55
45
  const slots = getSlotNames(USelect.name);
56
46
 
57
- return { args, slots };
47
+ return { args, slots, getSelectedBadge };
58
48
  },
59
49
  template: `
60
- <USelect v-bind="args" multiple v-model="args.modelValue">
61
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
62
- <template v-if="args[slot]">{{ args[slot] }}</template>
63
- </template>
50
+ <USelect v-bind="args" v-model="args.modelValue">
51
+ ${args.slotTemplate || getSlotsFragment()}
64
52
  </USelect>
65
53
  `,
66
54
  });
67
55
 
68
- const OpenDirectionsTemplate = (args, { argTypes } = {}) => ({
56
+ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
69
57
  components: { USelect, URow },
70
58
  setup() {
71
59
  return {
72
60
  args,
73
- openDirections: argTypes.openDirection.options,
61
+ options: argTypes[args.enum].options,
74
62
  };
75
63
  },
76
64
  template: `
77
- <div class="flex flex-col gap-6">
78
- <URow>
79
- <USelect
80
- v-for="(openDirection, index) in openDirections"
81
- :key="index"
82
- v-bind="args"
83
- :open-direction="openDirection"
84
- :label="openDirection"
85
- v-model="args.modelValue"
86
- />
87
- </URow>
88
- <URow>
89
- <USelect
90
- v-for="(openDirection, index) in openDirections"
91
- :key="index"
92
- v-bind="args"
93
- :open-direction="openDirection"
94
- v-model="args.modelValue"
95
- label=""
96
- />
97
- </URow>
98
- </div>
65
+ <URow>
66
+ <USelect
67
+ v-for="(option, index) in options"
68
+ :key="index"
69
+ v-bind="args"
70
+ v-model="args.modelValue"
71
+ :[args.enum]="option"
72
+ :label="option"
73
+ />
74
+ </URow>
99
75
  `,
100
76
  });
101
77
 
@@ -109,8 +85,8 @@ const GroupValuesTemplate = (args) => ({
109
85
  template: `
110
86
  <USelect
111
87
  v-bind="args"
112
- label="Single"
113
88
  v-model="args.modelValue"
89
+ label="Single"
114
90
  />
115
91
  <USelect
116
92
  class="mt-5"
@@ -122,104 +98,14 @@ const GroupValuesTemplate = (args) => ({
122
98
  `,
123
99
  });
124
100
 
125
- const SizesTemplate = (args, { argTypes } = {}) => ({
126
- components: { USelect, URow },
127
- setup() {
128
- return {
129
- args,
130
- sizes: argTypes.size.options,
131
- };
132
- },
133
- template: `
134
- <div class="flex flex-col gap-6">
135
- <URow>
136
- <USelect
137
- v-for="(size, index) in sizes"
138
- v-bind="args"
139
- :key="index"
140
- :size="size"
141
- :label="size"
142
- v-model="args.modelValue"
143
- />
144
- </URow>
145
- <URow>
146
- <USelect
147
- v-for="(size, index) in sizes"
148
- v-bind="args"
149
- :key="index"
150
- :size="size"
151
- :label="size"
152
- label-outside
153
- v-model="args.modelValue"
154
- />
155
- </URow>
156
- <URow>
157
- <USelect
158
- v-for="(size, index) in sizes"
159
- v-bind="args"
160
- :key="index"
161
- :label="size"
162
- :size="size"
163
- multiple
164
- v-model="args.multipleModelValue"
165
- />
166
- </URow>
167
- </div>
168
- `,
169
- });
170
-
171
- const SlotTemplate = (args) => ({
172
- components: { USelect, UIcon },
173
- setup() {
174
- return { args };
175
- },
176
- template: `
177
- <USelect
178
- v-bind="args"
179
- v-model="args.modelValue"
180
- >
181
- ${args.slotTemplate}
182
- </USelect>
183
- `,
184
- });
185
-
186
- const BadgeTemplate = (args) => ({
187
- components: { USelect, UBadge },
188
- setup() {
189
- return { args };
190
- },
191
- methods: {
192
- getSelectedBadge(options, currentValue) {
193
- return options?.find((option) => option.id === currentValue);
194
- },
195
- },
196
- template: `
197
- <USelect
198
- v-bind="args"
199
- v-model="args.modelValue"
200
- >
201
- <template #after-caret="{ scopeProps }">
202
- <UBadge
203
- v-show="scopeProps?.modelValue"
204
- :label="getSelectedBadge(scopeProps?.options, scopeProps?.modelValue)?.badge"
205
- />
206
- </template>
207
- <template #option="{ option }">
208
- {{ option.label }}
209
- <UBadge :label="option.badge" />
210
- </template>
211
- </USelect>
212
- `,
213
- });
214
-
215
101
  export const Default = DefaultTemplate.bind({});
216
102
  Default.args = {};
217
103
 
218
- export const Multiple = multipleTemplate.bind({});
219
- Multiple.args = { modelValue: [] };
104
+ export const Multiple = DefaultTemplate.bind({});
105
+ Multiple.args = { multiple: true, modelValue: [] };
220
106
 
221
- export const openDirection = OpenDirectionsTemplate.bind({});
222
- openDirection.args = {};
107
+ export const openDirection = EnumVariantTemplate.bind({});
108
+ openDirection.args = { enum: "openDirection" };
223
109
 
224
110
  export const groupValue = GroupValuesTemplate.bind({});
225
111
  groupValue.args = {
@@ -280,53 +166,70 @@ optionIsHidden.args = {
280
166
  ],
281
167
  };
282
168
 
283
- export const sizes = SizesTemplate.bind({});
284
- sizes.args = { multipleModelValue: [] };
169
+ export const sizes = EnumVariantTemplate.bind({});
170
+ sizes.args = {
171
+ enum: "size",
172
+ multiple: true,
173
+ multipleModelValue: [],
174
+ };
285
175
 
286
- export const slotSelectedValueLabel = SlotTemplate.bind({});
176
+ export const slotSelectedValueLabel = DefaultTemplate.bind({});
287
177
  slotSelectedValueLabel.args = {
288
178
  slotTemplate: `
289
179
  <template #selected-label>
290
- 🤘🤘🤘
180
+ 🤘🤘🤘
291
181
  </template>
292
182
  `,
293
183
  };
294
184
 
295
- export const slotSelectedValueLabelAfter = SlotTemplate.bind({});
185
+ export const slotSelectedValueLabelAfter = DefaultTemplate.bind({});
296
186
  slotSelectedValueLabelAfter.args = {
297
187
  slotTemplate: `
298
188
  <template #selected-label-after>
299
- 🤘🤘🤘
189
+ 🤘🤘🤘
300
190
  </template>
301
191
  `,
302
192
  };
303
193
 
304
- export const slotOption = SlotTemplate.bind({});
194
+ export const slotOption = DefaultTemplate.bind({});
305
195
  slotOption.args = {
306
196
  slotTemplate: `
307
197
  <template #option>
308
- 🤘🤘🤘
198
+ 🤘🤘🤘
309
199
  </template>
310
200
  `,
311
201
  };
312
202
 
313
- export const slotAfterCaret = BadgeTemplate.bind({});
314
- slotAfterCaret.args = {};
203
+ export const slotAfterCaret = DefaultTemplate.bind({});
204
+ slotAfterCaret.args = {
205
+ slotTemplate: `
206
+ <template #after-caret="{ scopeProps }">
207
+ <UBadge
208
+ v-show="scopeProps?.modelValue"
209
+ :label="getSelectedBadge(scopeProps?.options, scopeProps?.modelValue)?.badge"
210
+ />
211
+ </template>
212
+ <template #option="{ option }">
213
+ {{ option.label }}
214
+ <UBadge :label="option.badge" />
215
+ </template>
216
+ `,
217
+ };
315
218
 
316
- export const slotBeforeCaret = SlotTemplate.bind({});
219
+ export const slotBeforeCaret = DefaultTemplate.bind({});
317
220
  slotBeforeCaret.args = {
318
221
  slotTemplate: `
319
222
  <template #before-caret>
320
- 🤘
223
+ 🤘
321
224
  </template>
322
225
  `,
323
226
  };
324
227
 
325
- export const slotBeforeOption = SlotTemplate.bind({});
228
+ export const slotBeforeOption = DefaultTemplate.bind({});
326
229
  slotBeforeOption.args = {
327
230
  slotTemplate: `
328
231
  <template #before-option>
329
- 🤘
232
+ 🤘
330
233
  </template>
331
234
  `,
332
235
  };
@@ -341,7 +244,7 @@ iconRight.args = {
341
244
  iconRight: "star",
342
245
  };
343
246
 
344
- export const iconLeftSlot = SlotTemplate.bind({});
247
+ export const iconLeftSlot = DefaultTemplate.bind({});
345
248
  iconLeftSlot.args = {
346
249
  slotTemplate: `
347
250
  <template #icon-left>
@@ -350,7 +253,7 @@ iconLeftSlot.args = {
350
253
  `,
351
254
  };
352
255
 
353
- export const iconRightSlot = SlotTemplate.bind({});
256
+ export const iconRightSlot = DefaultTemplate.bind({});
354
257
  iconRightSlot.args = {
355
258
  slotTemplate: `
356
259
  <template #icon-right>
@@ -359,20 +262,20 @@ iconRightSlot.args = {
359
262
  `,
360
263
  };
361
264
 
362
- export const slotLeft = SlotTemplate.bind({});
265
+ export const slotLeft = DefaultTemplate.bind({});
363
266
  slotLeft.args = {
364
267
  slotTemplate: `
365
268
  <template #left>
366
- 🤘
269
+ 🤘
367
270
  </template>
368
271
  `,
369
272
  };
370
273
 
371
- export const slotRight = SlotTemplate.bind({});
274
+ export const slotRight = DefaultTemplate.bind({});
372
275
  slotRight.args = {
373
276
  slotTemplate: `
374
277
  <template #right>
375
- 🤘
278
+ 🤘
376
279
  </template>
377
280
  `,
378
281
  };
@@ -1,4 +1,4 @@
1
- import { getArgTypes } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import USwitch from "../ui.form-switch";
4
4
  import UIcon from "../ui.image-icon";
@@ -22,50 +22,34 @@ export default {
22
22
  const DefaultTemplate = (args) => ({
23
23
  components: { USwitch, UIcon },
24
24
  setup() {
25
- return { args };
26
- },
27
- template: `
28
- <USwitch v-bind="args" v-model="args.value" />
29
- `,
30
- });
25
+ const slots = getSlotNames(USwitch.name);
31
26
 
32
- const ColorsTemplate = (args, { argTypes } = {}) => ({
33
- components: { USwitch, URow },
34
- setup() {
35
- return {
36
- args,
37
- colors: argTypes.color.options,
38
- };
27
+ return { args, slots };
39
28
  },
40
29
  template: `
41
- <URow>
42
- <USwitch
43
- v-for="(color, index) in colors"
44
- v-bind="args"
45
- :color="color"
46
- v-model="args.value"
47
- :key="index"
48
- />
49
- </URow>
30
+ <USwitch v-bind="args" v-model="args.modelValue">
31
+ ${args.slotTemplate || getSlotsFragment()}
32
+ </USwitch>
50
33
  `,
51
34
  });
52
35
 
53
- const SizesTemplate = (args, { argTypes } = {}) => ({
36
+ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
54
37
  components: { USwitch, URow },
55
38
  setup() {
56
39
  return {
57
40
  args,
58
- sizes: argTypes.size.options,
41
+ options: argTypes[args.enum].options,
59
42
  };
60
43
  },
61
44
  template: `
62
45
  <URow>
63
46
  <USwitch
64
- v-for="(size, index) in sizes"
65
- v-bind="args"
66
- :size="size"
67
- v-model="args.value"
47
+ v-for="(option, index) in options"
68
48
  :key="index"
49
+ v-bind="args"
50
+ v-model="args.modelValue"
51
+ :[args.enum]="option"
52
+ :label="option"
69
53
  />
70
54
  </URow>
71
55
  `,
@@ -80,14 +64,14 @@ label.args = { label: "Some label" };
80
64
  export const description = DefaultTemplate.bind({});
81
65
  description.args = { label: "Label", description: "Some description" };
82
66
 
83
- export const colors = ColorsTemplate.bind({});
84
- colors.args = { modelValue: true };
67
+ export const colors = EnumVariantTemplate.bind({});
68
+ colors.args = { enum: "color", modelValue: true };
85
69
 
86
70
  export const toggleLabel = DefaultTemplate.bind({});
87
71
  toggleLabel.args = { toggleLabel: true };
88
72
 
89
- export const sizes = SizesTemplate.bind({});
90
- sizes.args = { color: "yellow" };
73
+ export const sizes = EnumVariantTemplate.bind({});
74
+ sizes.args = { enum: "size", color: "yellow" };
91
75
 
92
76
  export const icon = DefaultTemplate.bind({});
93
77
  icon.args = { toggleIcon: true, color: "yellow" };
@@ -28,9 +28,7 @@ const DefaultTemplate = (args) => ({
28
28
  return { args, slots };
29
29
  },
30
30
  template: `
31
- <UTextarea
32
- v-bind="args"
33
- >
31
+ <UTextarea v-bind="args">
34
32
  ${args.slotTemplate || getSlotsFragment()}
35
33
  </UTextarea>
36
34
  `,
@@ -44,9 +44,9 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
44
44
  <URow>
45
45
  <UIcon
46
46
  v-for="(option, index) in options"
47
+ :key="index"
47
48
  v-bind="args"
48
49
  :[args.enum]="option"
49
- :key="index"
50
50
  />
51
51
  </URow>
52
52
  `,
@@ -56,8 +56,8 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
56
56
  <UProgress
57
57
  v-for="(option, index) in options"
58
58
  :key="index"
59
- :[args.enum]="option"
60
59
  v-bind="args"
60
+ :[args.enum]="option"
61
61
  :value="args.progress"
62
62
  />
63
63
  </UCol>
@@ -30,7 +30,7 @@ const DefaultTemplate = (args) => ({
30
30
  return { args, slots };
31
31
  },
32
32
  template: `
33
- <UTabs v-model="args.modelValue" v-bind="args">
33
+ <UTabs v-bind="args" v-model="args.modelValue">
34
34
  ${args.slotTemplate || getSlotsFragment()}
35
35
  </UTabs>
36
36
  `,
@@ -47,11 +47,11 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
47
47
  template: `
48
48
  <div class="space-y-16">
49
49
  <UTabs
50
- v-model="args.modelValue"
51
50
  v-for="(option, index) in options"
51
+ :key="index"
52
52
  v-bind="args"
53
+ v-model="args.modelValue"
53
54
  :[args.enum]="option"
54
- :key="index"
55
55
  />
56
56
  </div>
57
57
  `,
@@ -48,11 +48,11 @@ const ColorsTemplate = (args, { argTypes } = {}) => ({
48
48
  <URow v-for="(variant, index) in variants" :key="index">
49
49
  <UBadge
50
50
  v-for="(color, index) in colors"
51
+ :key="index"
51
52
  v-bind="args"
52
53
  :color="color"
53
54
  :variant="variant"
54
55
  :label="color"
55
- :key="index"
56
56
  />
57
57
  </URow>
58
58
  </UCol>
@@ -72,10 +72,10 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
72
72
  <URow>
73
73
  <UBadge
74
74
  v-for="(option, index) in options"
75
+ :key="index"
75
76
  v-bind="args"
76
77
  :[args.enum]="option"
77
78
  :label="getText(option)"
78
- :key="index"
79
79
  />
80
80
  </URow>
81
81
  `,