vueless 0.0.658 → 0.0.659

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.658",
3
+ "version": "0.0.659",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -82,6 +82,7 @@ const { toggleLabelAttrs, itemsAttrs, itemAttrs } = useUI<Config>(defaultConfig)
82
82
  :description="description"
83
83
  :align="labelAlign"
84
84
  :disabled="disabled"
85
+ :error="error"
85
86
  centred
86
87
  v-bind="toggleLabelAttrs"
87
88
  :data-test="dataTest"
@@ -1,4 +1,4 @@
1
- import { ref } from "vue";
1
+ import { ref, computed } from "vue";
2
2
  import {
3
3
  getArgTypes,
4
4
  getSlotNames,
@@ -10,6 +10,7 @@ import UToggle from "../../ui.button-toggle/UToggle.vue";
10
10
  import UIcon from "../../ui.image-icon/UIcon.vue";
11
11
  import UToggleItem from "../../ui.button-toggle-item/UToggleItem.vue";
12
12
  import URow from "../../ui.container-row/URow.vue";
13
+ import UBadge from "../../ui.text-badge/UBadge.vue";
13
14
 
14
15
  import type { Meta, StoryFn } from "@storybook/vue3";
15
16
  import type { Props } from "../types.ts";
@@ -24,12 +25,13 @@ export default {
24
25
  title: "Buttons & Links / Toggle",
25
26
  component: UToggle,
26
27
  args: {
28
+ label: "Please choose an option",
27
29
  modelValue: "11",
28
30
  options: [
29
- { value: "11", label: "label 1" },
30
- { value: "12", label: "label 2" },
31
- { value: "13", label: "label 3" },
32
- { value: "14", label: "label 4" },
31
+ { value: "11", label: "Admin" },
32
+ { value: "12", label: "Editor" },
33
+ { value: "13", label: "Viewer" },
34
+ { value: "14", label: "Guest" },
33
35
  ],
34
36
  },
35
37
  argTypes: {
@@ -44,14 +46,26 @@ export default {
44
46
  } as Meta;
45
47
 
46
48
  const DefaultTemplate: StoryFn<UToggleArgs> = (args: UToggleArgs) => ({
47
- components: { UToggle, UIcon, UToggleItem },
49
+ components: { UToggle, UIcon, UToggleItem, UBadge },
48
50
  setup() {
49
51
  const slots = getSlotNames(UToggle.__name);
52
+ const modelValueRef = ref(args.modelValue);
53
+ const error = computed(() => {
54
+ if (args.name === "error" && Array.isArray(modelValueRef.value)) {
55
+ return modelValueRef.value?.length === 0 ? "Please select at least one option" : "";
56
+ }
50
57
 
51
- return { args, slots };
58
+ return "";
59
+ });
60
+
61
+ return { args, slots, modelValueRef, error };
52
62
  },
53
63
  template: `
54
- <UToggle v-bind="args" v-model="args.modelValue">
64
+ <UToggle
65
+ v-bind="args"
66
+ v-model="modelValueRef"
67
+ :error="error"
68
+ >
55
69
  ${args.slotTemplate || getSlotsFragment("")}
56
70
  </UToggle>
57
71
  `,
@@ -60,11 +74,11 @@ const DefaultTemplate: StoryFn<UToggleArgs> = (args: UToggleArgs) => ({
60
74
  const EnumVariantTemplate: StoryFn<UToggleArgs> = (args: UToggleArgs, { argTypes }) => ({
61
75
  components: { UToggle, URow },
62
76
  setup() {
63
- const value = ref("");
77
+ const values = ref(["2xs", "xs", "sm", "md", "lg", "xl"]);
64
78
 
65
79
  return {
66
80
  args,
67
- value,
81
+ values,
68
82
  options: argTypes?.[args.enum]?.options,
69
83
  };
70
84
  },
@@ -74,13 +88,14 @@ const EnumVariantTemplate: StoryFn<UToggleArgs> = (args: UToggleArgs, { argTypes
74
88
  v-for="(option, index) in options"
75
89
  :key="index"
76
90
  v-bind="args"
77
- v-model="value"
91
+ v-model="values[option]"
78
92
  :[args.enum]="option"
79
93
  :label="option"
80
94
  :options="[
81
95
  { value: option + 1, label: option },
82
96
  { value: option + 2, label: option },
83
97
  ]"
98
+ class="w-auto"
84
99
  />
85
100
  </URow>
86
101
  `,
@@ -94,24 +109,35 @@ Default.args = {
94
109
  export const Disabled = DefaultTemplate.bind({});
95
110
  Disabled.args = {
96
111
  name: "Disabled",
97
- disabled: true,
112
+ label: "You can disable the whole toggle or specific items",
113
+ options: [
114
+ { value: "11", label: "Admin" },
115
+ { value: "12", label: "Editor", disabled: true },
116
+ { value: "13", label: "Viewer" },
117
+ { value: "14", label: "Guest", disabled: true },
118
+ ],
98
119
  };
99
120
 
100
- export const Label = DefaultTemplate.bind({});
101
- Label.args = {
102
- name: "Label",
103
- label: "Label",
104
- description: "description",
105
- };
121
+ export const Description = DefaultTemplate.bind({});
122
+ Description.args = { name: "Description", description: "You can also add description" };
106
123
 
107
124
  export const Sizes = EnumVariantTemplate.bind({});
108
- Sizes.args = {
109
- name: "sizeTemplate",
110
- enum: "size",
111
- };
125
+ Sizes.args = { name: "sizeTemplate", enum: "size" };
112
126
 
113
127
  export const Multiple = DefaultTemplate.bind({});
114
- Multiple.args = { name: "multipleTemplate", multiple: true };
128
+ Multiple.args = {
129
+ name: "multiple",
130
+ multiple: true,
131
+ label: "You can choose more than one option",
132
+ };
133
+
134
+ export const Error = DefaultTemplate.bind({});
135
+ Error.args = {
136
+ name: "error",
137
+ multiple: true,
138
+ modelValue: [],
139
+ label: "If no option is selected, error message is displayed",
140
+ };
115
141
 
116
142
  export const Block = DefaultTemplate.bind({});
117
143
  Block.args = { name: "block", block: true };
@@ -126,6 +152,7 @@ export const Square = DefaultTemplate.bind({});
126
152
  Square.args = {
127
153
  name: "square",
128
154
  square: true,
155
+ label: "Square prop is useful when icons are present",
129
156
  slotTemplate: `
130
157
  <template #default>
131
158
  <UToggleItem value="1">
@@ -143,14 +170,21 @@ Square.args = {
143
170
  `,
144
171
  };
145
172
 
146
- export const SlotDefault = DefaultTemplate.bind({});
147
- SlotDefault.args = {
148
- name: "slotDefault",
173
+ export const DefaultSlot = DefaultTemplate.bind({});
174
+ DefaultSlot.args = {
175
+ name: "defaultSlot",
176
+ label: "Please select an operation to proceed",
149
177
  slotTemplate: `
150
178
  <template #default>
151
- <UToggleItem label="label 1" value="1" />
152
- <UToggleItem label="label 2" value="2" />
153
- <UToggleItem label="label 3" value="3" />
179
+ <UToggleItem value="1">
180
+ <UBadge label="Download" color="green" right-icon="download" />
181
+ </UToggleItem>
182
+ <UToggleItem value="2">
183
+ <UBadge label="Edit" color="amber" right-icon="edit" />
184
+ </UToggleItem>
185
+ <UToggleItem value="3">
186
+ <UBadge label="Delete" color="red" right-icon="delete" />
187
+ </UToggleItem>
154
188
  </template>
155
189
  `,
156
190
  };
@@ -26,6 +26,11 @@ export interface Props {
26
26
  */
27
27
  size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl";
28
28
 
29
+ /**
30
+ * Error message.
31
+ */
32
+ error?: string;
33
+
29
34
  /**
30
35
  * Label placement.
31
36
  */
@@ -7,6 +7,7 @@ import {
7
7
 
8
8
  import UToggleItem from "../../ui.button-toggle-item/UToggleItem.vue";
9
9
  import UIcon from "../../ui.image-icon/UIcon.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";
@@ -58,26 +59,32 @@ Default.args = {};
58
59
  export const Disabled = DefaultTemplate.bind({});
59
60
  Disabled.args = { disabled: true };
60
61
 
61
- export const SlotLeft = DefaultTemplate.bind({});
62
- SlotLeft.args = {
63
- slotTemplate: `
64
- <template #left>
65
- <UIcon
66
- name="star"
67
- color="green"
68
- />
69
- </template>
70
- `,
71
- };
62
+ export const Slots: StoryFn<UToggleItemArgs> = (args) => ({
63
+ components: { UToggleItem, UIcon, URow },
64
+ setup() {
65
+ return { args };
66
+ },
67
+ template: `
68
+ <URow>
69
+ <UToggleItem label="Download">
70
+ <template #left>
71
+ <UIcon
72
+ name="download"
73
+ color="green"
74
+ size="sm"
75
+ />
76
+ </template>
77
+ </UToggleItem>
72
78
 
73
- export const SlotRight = DefaultTemplate.bind({});
74
- SlotRight.args = {
75
- slotTemplate: `
76
- <template #right>
77
- <UIcon
78
- name="star"
79
- color="green"
80
- />
81
- </template>
79
+ <UToggleItem label="Edit">
80
+ <template #right>
81
+ <UIcon
82
+ name="edit"
83
+ color="orange"
84
+ size="sm"
85
+ />
86
+ </template>
87
+ </UToggleItem>
88
+ </URow>
82
89
  `,
83
- };
90
+ });
@@ -110,7 +110,7 @@ const { config, dropdownButtonAttrs, dropdownListAttrs, dropdownIconAttrs, wrapp
110
110
  @slot Use it to add something after the label.
111
111
  @binding {boolean} opened
112
112
  -->
113
- <slot name="right" :opened="isShownOptions">
113
+ <slot name="toggle" :opened="isShownOptions">
114
114
  <UIcon
115
115
  v-if="!noIcon"
116
116
  internal
@@ -9,6 +9,7 @@ import UDropdownButton from "../../ui.dropdown-button/UDropdownButton.vue";
9
9
  import URow from "../../ui.container-row/URow.vue";
10
10
  import UCol from "../../ui.container-col/UCol.vue";
11
11
  import UIcon from "../../ui.image-icon/UIcon.vue";
12
+ import ULink from "../../ui.button-link/ULink.vue";
12
13
 
13
14
  import type { Meta, StoryFn } from "@storybook/vue3";
14
15
  import type { Props } from "../types.ts";
@@ -18,7 +19,7 @@ interface DefaultUDropdownButtonArgs extends Props {
18
19
  }
19
20
 
20
21
  interface EnumUDropdownButtonArgs extends DefaultUDropdownButtonArgs {
21
- enum: keyof Pick<Props, "size" | "variant">;
22
+ enum: keyof Pick<Props, "size" | "variant" | "xPosition" | "yPosition">;
22
23
  }
23
24
 
24
25
  export default {
@@ -36,7 +37,7 @@ export default {
36
37
  docs: {
37
38
  ...getDocsDescription(UDropdownButton.__name),
38
39
  story: {
39
- height: "200px",
40
+ height: "250px",
40
41
  },
41
42
  },
42
43
  },
@@ -45,7 +46,7 @@ export default {
45
46
  const DefaultTemplate: StoryFn<DefaultUDropdownButtonArgs> = (
46
47
  args: DefaultUDropdownButtonArgs,
47
48
  ) => ({
48
- components: { UDropdownButton, UIcon },
49
+ components: { UDropdownButton, UIcon, ULink },
49
50
  setup() {
50
51
  const slots = getSlotNames(UDropdownButton.__name);
51
52
 
@@ -122,19 +123,35 @@ Variants.args = { enum: "variant" };
122
123
  export const Sizes = EnumVariantTemplate.bind({});
123
124
  Sizes.args = { enum: "size" };
124
125
 
126
+ export const DropdownListXPosition = EnumVariantTemplate.bind({});
127
+ DropdownListXPosition.args = { enum: "xPosition" };
128
+
129
+ export const DropdownListYPosition = EnumVariantTemplate.bind({});
130
+ DropdownListYPosition.args = { enum: "yPosition" };
131
+
125
132
  export const VariantColors = VariantColorsTemplate.bind({});
126
133
  VariantColors.args = {};
127
134
 
128
135
  export const WithoutDropdownIcon = EnumVariantTemplate.bind({});
129
136
  WithoutDropdownIcon.args = { enum: "variant", noIcon: true };
130
137
 
138
+ export const CustomDropdownIcon = DefaultTemplate.bind({});
139
+ CustomDropdownIcon.args = {
140
+ config: {
141
+ defaults: {
142
+ dropdownIcon: "expand_circle_down",
143
+ },
144
+ },
145
+ };
146
+
131
147
  export const DefaultSlot = DefaultTemplate.bind({});
132
148
  DefaultSlot.args = {
133
149
  slotTemplate: `
134
150
  <template #default>
135
- Custom label
151
+ <UIcon name="unfold_more" color="white" />
136
152
  </template>
137
153
  `,
154
+ noIcon: true,
138
155
  };
139
156
 
140
157
  export const LeftSlot = DefaultTemplate.bind({});
@@ -142,22 +159,22 @@ LeftSlot.args = {
142
159
  slotTemplate: `
143
160
  <template #left>
144
161
  <UIcon
145
- name="archive"
146
- color="red"
162
+ name="heart_plus"
147
163
  size="sm"
164
+ color="green"
148
165
  />
149
166
  </template>
150
167
  `,
151
168
  };
152
169
 
153
- export const RightSlot = DefaultTemplate.bind({});
154
- RightSlot.args = {
170
+ export const SlotToggle = DefaultTemplate.bind({});
171
+ SlotToggle.args = {
155
172
  slotTemplate: `
156
- <template #right>
157
- <UIcon
158
- name="archive"
159
- color="red"
160
- size="sm"
173
+ <template #toggle="{ opened }">
174
+ <ULink
175
+ :label="opened ? 'collapse' : 'expand'"
176
+ color="green"
177
+ :ring=false
161
178
  />
162
179
  </template>
163
180
  `,
@@ -423,9 +423,9 @@ const {
423
423
  rightSlotAttrs,
424
424
  leftIconAttrs,
425
425
  rightIconAttrs,
426
- beforeCaretAttrs,
427
- afterCaretAttrs,
428
- toggleAttrs,
426
+ beforeToggleAttrs,
427
+ afterToggleAttrs,
428
+ toggleWrapperAttrs,
429
429
  clearAttrs,
430
430
  clearMultipleTextAttrs,
431
431
  clearMultipleAttrs,
@@ -487,17 +487,21 @@ const {
487
487
  </slot>
488
488
  </div>
489
489
 
490
- <div v-if="hasSlotContent($slots['after-caret'])" v-bind="afterCaretAttrs" :tabindex="-1">
490
+ <div
491
+ v-if="hasSlotContent($slots['after-toggle']) && !(multiple && localValue?.length)"
492
+ v-bind="afterToggleAttrs"
493
+ :tabindex="-1"
494
+ >
491
495
  <!--
492
- @slot Use it to add something after caret.
496
+ @slot Use it to add something after toggle.
493
497
  @binding {object} option
494
498
  -->
495
- <slot :option="localValue" name="after-caret" />
499
+ <slot :option="localValue" name="after-toggle" />
496
500
  </div>
497
501
 
498
502
  <div
499
503
  v-show="!multiple || (!isLocalValue && multiple)"
500
- v-bind="toggleAttrs"
504
+ v-bind="toggleWrapperAttrs"
501
505
  :tabindex="-1"
502
506
  @mousedown.prevent.stop="toggle"
503
507
  >
@@ -539,14 +543,14 @@ const {
539
543
  </div>
540
544
 
541
545
  <div
542
- v-if="hasSlotContent($slots['before-caret']) && !(multiple && localValue?.length)"
543
- v-bind="beforeCaretAttrs"
546
+ v-if="hasSlotContent($slots['before-toggle']) && !(multiple && localValue?.length)"
547
+ v-bind="beforeToggleAttrs"
544
548
  >
545
549
  <!--
546
- @slot Use it to add something before caret.
550
+ @slot Use it to add something before toggle.
547
551
  @binding {object} option
548
552
  -->
549
- <slot :option="localValue" name="before-caret" />
553
+ <slot :option="localValue" name="before-toggle" />
550
554
  </div>
551
555
 
552
556
  <div ref="innerWrapperRef" v-bind="innerWrapperAttrs">
@@ -78,10 +78,10 @@ export default /*tw*/ {
78
78
  leftIcon: "{UIcon} {>selectIcon}",
79
79
  rightIcon: "{UIcon} {>selectIcon}",
80
80
  leftSlot: "pr-1.5",
81
- rightSlot: "{>caret} pr-3",
82
- beforeCaret: "{>caret}",
83
- afterCaret: "{>caret} mr-3 items-start pt-3",
84
- caret: {
81
+ rightSlot: "{>toggle} pr-3",
82
+ beforeToggle: "{>toggle}",
83
+ afterToggle: "{>toggle} mr-3 items-start pt-3",
84
+ toggle: {
85
85
  base: "flex items-center",
86
86
  compoundVariants: [
87
87
  { labelAlign: "topInside", size: "sm", label: true, class: "-mt-5" },
@@ -89,9 +89,9 @@ export default /*tw*/ {
89
89
  { labelAlign: "topInside", size: "lg", label: true, class: "-mt-7" },
90
90
  ],
91
91
  },
92
- toggle: "{>caret} mr-3",
92
+ toggleWrapper: "{>toggle} mr-3",
93
93
  toggleIcon: "{UIcon} {>selectIcon} transition duration-300 group-[]/active:rotate-180",
94
- clear: "{>caret}",
94
+ clear: "{>toggle}",
95
95
  clearIcon: "{UIcon} {>selectIcon}",
96
96
  clearMultiple: "flex items-center",
97
97
  clearMultipleIcon: "{UIcon} {>selectIcon}",
@@ -250,19 +250,19 @@ SlotOption.args = {
250
250
  `,
251
251
  };
252
252
 
253
- export const SlotAfterCaret = DefaultTemplate.bind({});
254
- SlotAfterCaret.args = {
253
+ export const SlotAfterToggle = DefaultTemplate.bind({});
254
+ SlotAfterToggle.args = {
255
255
  slotTemplate: `
256
- <template #after-caret="{ scopeProps }">
256
+ <template #after-toggle>
257
257
  🤘
258
258
  </template>
259
259
  `,
260
260
  };
261
261
 
262
- export const SlotBeforeCaret = DefaultTemplate.bind({});
263
- SlotBeforeCaret.args = {
262
+ export const SlotBeforeToggle = DefaultTemplate.bind({});
263
+ SlotBeforeToggle.args = {
264
264
  slotTemplate: `
265
- <template #before-caret>
265
+ <template #before-toggle>
266
266
  🤘
267
267
  </template>
268
268
  `,