vueless 0.0.504 → 0.0.506

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/types.ts +6 -0
  3. package/ui.button/UButton.vue +106 -240
  4. package/ui.button/config.ts +167 -0
  5. package/ui.button/storybook/Docs.mdx +2 -2
  6. package/ui.button/storybook/{stories.js → stories.ts} +36 -16
  7. package/ui.button/types.ts +121 -0
  8. package/ui.button/{useAttrs.js → useAttrs.ts} +6 -3
  9. package/ui.button-link/ULink.vue +72 -223
  10. package/ui.button-link/storybook/Docs.mdx +2 -2
  11. package/ui.button-link/storybook/{stories.js → stories.ts} +30 -17
  12. package/ui.button-link/types.ts +131 -0
  13. package/ui.button-link/{useAttrs.js → useAttrs.ts} +15 -3
  14. package/ui.button-toggle/UToggle.vue +47 -165
  15. package/ui.button-toggle/storybook/Docs.mdx +2 -2
  16. package/ui.button-toggle/storybook/{stories.js → stories.ts} +13 -5
  17. package/ui.button-toggle/types.ts +85 -0
  18. package/ui.button-toggle/useAttrs.ts +18 -0
  19. package/ui.button-toggle-item/UToggleItem.vue +59 -110
  20. package/ui.button-toggle-item/storybook/Docs.mdx +2 -2
  21. package/ui.button-toggle-item/storybook/{stories.js → stories.ts} +10 -3
  22. package/ui.button-toggle-item/types.ts +40 -0
  23. package/ui.button-toggle-item/{useAttrs.js → useAttrs.ts} +16 -4
  24. package/ui.image-icon/UIcon.vue +1 -1
  25. package/ui.image-icon/config.ts +5 -4
  26. package/ui.loader/ULoader.vue +1 -1
  27. package/ui.loader/config.js +2 -1
  28. package/ui.loader-overlay/ULoaderOverlay.vue +1 -1
  29. package/web-types.json +137 -59
  30. package/ui.button/config.js +0 -164
  31. package/ui.button-toggle/useAttrs.js +0 -15
  32. /package/ui.button/{constants.js → constants.ts} +0 -0
  33. /package/ui.button-link/{config.js → config.ts} +0 -0
  34. /package/ui.button-link/{constants.js → constants.ts} +0 -0
  35. /package/ui.button-toggle/{config.js → config.ts} +0 -0
  36. /package/ui.button-toggle/{constants.js → constants.ts} +0 -0
  37. /package/ui.button-toggle-item/{config.js → config.ts} +0 -0
  38. /package/ui.button-toggle-item/{constants.js → constants.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.504",
3
+ "version": "0.0.506",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/types.ts CHANGED
@@ -11,6 +11,9 @@ import UHeaderDefaultConfig from "./ui.text-header/config.ts";
11
11
  import UNotifyDefaultConfig from "./ui.text-notify/config.ts";
12
12
  import UDotDefaultConfig from "./ui.other-dot/config.ts";
13
13
  import UButtonDefaultConfig from "./ui.button/config.ts";
14
+ import ULinkDefaultConfig from "./ui.button-link/config.ts";
15
+ import UToggleDefaultConfig from "./ui.button-toggle/config.ts";
16
+ import UToggleItemDefaultConfig from "./ui.button-toggle-item/config.ts";
14
17
  import UBadgeDefaultConfig from "./ui.text-badge/config.ts";
15
18
  import UCalendarDefaultConfig from "./ui.form-calendar/config.ts";
16
19
  import UDatePickerConfig from "./ui.form-date-picker/config.ts";
@@ -132,6 +135,9 @@ export interface Components {
132
135
  UNotify?: Partial<typeof UNotifyDefaultConfig>;
133
136
  UDot?: Partial<typeof UDotDefaultConfig>;
134
137
  UButton?: Partial<typeof UButtonDefaultConfig>;
138
+ ULink?: Partial<typeof ULinkDefaultConfig>;
139
+ UToggle?: Partial<typeof UToggleDefaultConfig>;
140
+ UToggleItem?: Partial<typeof UToggleItemDefaultConfig>;
135
141
  UBadge?: Partial<typeof UBadgeDefaultConfig>;
136
142
  UCalendar?: Partial<typeof UCalendarDefaultConfig>;
137
143
  UDatePicker?: Partial<typeof UDatePickerConfig>;
@@ -1,3 +1,109 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref, watchEffect, useId, watch } from "vue";
3
+
4
+ import { useDarkMode } from "../composables/useDarkMode.ts";
5
+ import { getDefault } from "../utils/ui.ts";
6
+ import ULoader from "../ui.loader/ULoader.vue";
7
+ import UIcon from "../ui.image-icon/UIcon.vue";
8
+
9
+ import defaultConfig from "./config.ts";
10
+ import useAttrs from "./useAttrs.ts";
11
+ import { UButton } from "./constants.ts";
12
+
13
+ import type { UButtonProps } from "./types.ts";
14
+
15
+ defineOptions({ inheritAttrs: false });
16
+
17
+ const props = withDefaults(defineProps<UButtonProps>(), {
18
+ variant: getDefault<UButtonProps>(defaultConfig, UButton).variant,
19
+ color: getDefault<UButtonProps>(defaultConfig, UButton).color,
20
+ size: getDefault<UButtonProps>(defaultConfig, UButton).size,
21
+ tag: getDefault<UButtonProps>(defaultConfig, UButton).tag,
22
+ tabindex: getDefault<UButtonProps>(defaultConfig, UButton).tabindex,
23
+ filled: getDefault<UButtonProps>(defaultConfig, UButton).filled,
24
+ disabled: getDefault<UButtonProps>(defaultConfig, UButton).disabled,
25
+ block: getDefault<UButtonProps>(defaultConfig, UButton).block,
26
+ round: getDefault<UButtonProps>(defaultConfig, UButton).round,
27
+ square: getDefault<UButtonProps>(defaultConfig, UButton).square,
28
+ loading: getDefault<UButtonProps>(defaultConfig, UButton).loading,
29
+ noRing: getDefault<UButtonProps>(defaultConfig, UButton).noRing,
30
+ dataTest: "",
31
+ });
32
+
33
+ const elementId = props.id || useId();
34
+
35
+ const { isDarkMode } = useDarkMode();
36
+
37
+ const { buttonAttrs, loaderAttrs, leftIconAttrs, rightIconAttrs, centerIconAttrs } =
38
+ useAttrs(props);
39
+
40
+ const buttonRef = ref(null);
41
+ const buttonStyle = ref({});
42
+ const buttonWidth = ref(0);
43
+
44
+ const loaderSize = computed(() => {
45
+ const sizes = {
46
+ "2xs": "sm",
47
+ xs: "sm",
48
+ sm: "md",
49
+ md: "md",
50
+ lg: "lg",
51
+ xl: "lg",
52
+ };
53
+
54
+ return sizes[props.size];
55
+ });
56
+
57
+ const iconSize = computed(() => {
58
+ const sizes = {
59
+ "2xs": "2xs",
60
+ xs: "xs",
61
+ sm: "sm",
62
+ md: "sm",
63
+ lg: "md",
64
+ xl: "md",
65
+ };
66
+
67
+ return sizes[props.size];
68
+ });
69
+
70
+ const iconColor = computed(() => {
71
+ const primaryColor = isDarkMode.value ? "black" : "white";
72
+
73
+ return props.variant === "primary" ? primaryColor : props.color;
74
+ });
75
+
76
+ watch(
77
+ () => props.loading,
78
+ (newValue, oldValue) => {
79
+ const isLoaderOn = newValue && oldValue !== undefined;
80
+
81
+ if (isLoaderOn && buttonRef.value) {
82
+ buttonWidth.value = buttonRef.value.offsetWidth;
83
+ }
84
+
85
+ buttonStyle.value = {
86
+ width: isLoaderOn ? `${buttonWidth.value}px` : null,
87
+ paddingLeft: isLoaderOn ? "0px" : null,
88
+ paddingRight: isLoaderOn ? "0px" : null,
89
+ };
90
+ },
91
+ { immediate: true },
92
+ );
93
+
94
+ watchEffect(() => {
95
+ props.loading && buttonRef.value.blur();
96
+ });
97
+
98
+ defineExpose({
99
+ /**
100
+ * A reference to the button element for direct DOM manipulation.
101
+ * @property {HTMLElement}
102
+ */
103
+ buttonRef,
104
+ });
105
+ </script>
106
+
1
107
  <template>
2
108
  <component
3
109
  :is="tag"
@@ -79,243 +185,3 @@
79
185
  </template>
80
186
  </component>
81
187
  </template>
82
-
83
- <script setup>
84
- import { computed, ref, watchEffect, useId, watch } from "vue";
85
-
86
- import { getDefault } from "../utils/ui.ts";
87
- import ULoader from "../ui.loader/ULoader.vue";
88
- import UIcon from "../ui.image-icon/UIcon.vue";
89
-
90
- import defaultConfig from "./config.js";
91
- import useAttrs from "./useAttrs.js";
92
- import { UButton } from "./constants.js";
93
-
94
- defineOptions({ inheritAttrs: false });
95
-
96
- const props = defineProps({
97
- /**
98
- * Button variant.
99
- * @values primary, secondary, thirdary
100
- */
101
- variant: {
102
- type: String,
103
- default: getDefault(defaultConfig, UButton).variant,
104
- },
105
-
106
- /**
107
- * Button color.
108
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
109
- */
110
- color: {
111
- type: String,
112
- default: getDefault(defaultConfig, UButton).color,
113
- },
114
-
115
- /**
116
- * Button size.
117
- * @values 2xs, xs, sm, md, lg, xl
118
- */
119
- size: {
120
- type: String,
121
- default: getDefault(defaultConfig, UButton).size,
122
- },
123
-
124
- /**
125
- * Button label.
126
- */
127
- label: {
128
- type: String,
129
- default: "",
130
- },
131
-
132
- /**
133
- * Allows changing button html tag.
134
- */
135
- tag: {
136
- type: String,
137
- default: getDefault(defaultConfig, UButton).tag,
138
- },
139
-
140
- /**
141
- * Icon name (appears instead of label).
142
- */
143
- icon: {
144
- type: String,
145
- default: "",
146
- },
147
-
148
- /**
149
- * Left icon name.
150
- */
151
- leftIcon: {
152
- type: String,
153
- default: "",
154
- },
155
-
156
- /**
157
- * Right icon name.
158
- */
159
- rightIcon: {
160
- type: String,
161
- default: "",
162
- },
163
-
164
- /**
165
- * Controls the keyboard “Tab” focus order of elements.
166
- */
167
- tabindex: {
168
- type: [String, Number],
169
- default: getDefault(defaultConfig, UButton).tabindex,
170
- },
171
-
172
- /**
173
- * Fill the background for thirdary variant.
174
- */
175
- filled: {
176
- type: Boolean,
177
- default: getDefault(defaultConfig, UButton).filled,
178
- },
179
-
180
- /**
181
- * Disable the button.
182
- */
183
- disabled: {
184
- type: Boolean,
185
- default: getDefault(defaultConfig, UButton).disabled,
186
- },
187
-
188
- /**
189
- * Make the Button fill the width with its container.
190
- */
191
- block: {
192
- type: Boolean,
193
- default: getDefault(defaultConfig, UButton).block,
194
- },
195
-
196
- /**
197
- * Set button corners rounded.
198
- */
199
- round: {
200
- type: Boolean,
201
- default: getDefault(defaultConfig, UButton).round,
202
- },
203
-
204
- /**
205
- * Set the same paddings for the button.
206
- */
207
- square: {
208
- type: Boolean,
209
- default: getDefault(defaultConfig, UButton).square,
210
- },
211
-
212
- /**
213
- * Enable loader.
214
- */
215
- loading: {
216
- type: Boolean,
217
- default: getDefault(defaultConfig, UButton).loading,
218
- },
219
-
220
- /**
221
- * Remove button ring on focus.
222
- */
223
- noRing: {
224
- type: Boolean,
225
- default: getDefault(defaultConfig, UButton).noRing,
226
- },
227
-
228
- /**
229
- * Unique element id.
230
- */
231
- id: {
232
- type: String,
233
- default: "",
234
- },
235
-
236
- /**
237
- * Component config object.
238
- */
239
- config: {
240
- type: Object,
241
- default: () => ({}),
242
- },
243
-
244
- /**
245
- * Data-test attribute for automated testing.
246
- */
247
- dataTest: {
248
- type: String,
249
- default: "",
250
- },
251
- });
252
-
253
- const elementId = props.id || useId();
254
-
255
- const { buttonAttrs, loaderAttrs, leftIconAttrs, rightIconAttrs, centerIconAttrs } =
256
- useAttrs(props);
257
-
258
- const buttonRef = ref(null);
259
- const buttonStyle = ref(null);
260
- const buttonWidth = ref(0);
261
-
262
- const loaderSize = computed(() => {
263
- const sizes = {
264
- "2xs": "sm",
265
- xs: "sm",
266
- sm: "md",
267
- md: "md",
268
- lg: "lg",
269
- xl: "lg",
270
- };
271
-
272
- return sizes[props.size];
273
- });
274
-
275
- const iconSize = computed(() => {
276
- const sizes = {
277
- "2xs": "2xs",
278
- xs: "xs",
279
- sm: "sm",
280
- md: "sm",
281
- lg: "md",
282
- xl: "md",
283
- };
284
-
285
- return sizes[props.size];
286
- });
287
-
288
- const iconColor = computed(() => {
289
- return props.variant === "primary" ? "white" : props.color;
290
- });
291
-
292
- watch(
293
- () => props.loading,
294
- (newValue, oldValue) => {
295
- const isLoaderOn = newValue && oldValue !== undefined;
296
-
297
- if (isLoaderOn && buttonRef.value) {
298
- buttonWidth.value = buttonRef.value.offsetWidth;
299
- }
300
-
301
- buttonStyle.value = {
302
- width: isLoaderOn ? `${buttonWidth.value}px` : null,
303
- paddingLeft: isLoaderOn ? "0px" : null,
304
- paddingRight: isLoaderOn ? "0px" : null,
305
- };
306
- },
307
- { immediate: true },
308
- );
309
-
310
- watchEffect(() => {
311
- props.loading && buttonRef.value.blur();
312
- });
313
-
314
- defineExpose({
315
- /**
316
- * A reference to the button element for direct DOM manipulation.
317
- * @property {HTMLElement}
318
- */
319
- buttonRef,
320
- });
321
- </script>
@@ -0,0 +1,167 @@
1
+ export default /*tw*/ {
2
+ button: {
3
+ base: `
4
+ flex items-center justify-center font-medium whitespace-nowrap
5
+ border border-transparent outline-none transition
6
+ disabled:cursor-not-allowed cursor-pointer
7
+ disabled:ring-0 disabled:ring-offset-0
8
+ focus:ring-dynamic focus-within:ring-dynamic
9
+ focus:ring-offset-dynamic focus-within:ring-offset-dynamic
10
+ focus:ring-{color}-700/15 focus-within:ring-{color}-700/15
11
+ dark:focus:ring-{color}-500/15 dark:focus-within:ring-{color}-500/15
12
+ `,
13
+ variants: {
14
+ size: {
15
+ "2xs": "px-2 py-1 text-xs gap-0.5",
16
+ xs: "px-3 py-1.5 text-xs gap-1",
17
+ sm: "px-4 py-2 text-sm gap-1.5",
18
+ md: "px-5 py-3 text-sm gap-1.5",
19
+ lg: "px-6 py-3.5 text-base gap-1.5",
20
+ xl: "px-7 py-4 text-base gap-2",
21
+ },
22
+ variant: {
23
+ primary: `
24
+ text-white dark:text-gray-900
25
+ bg-{color}-600 dark:bg-{color}-400
26
+ hover:bg-{color}-700 dark:hover:bg-{color}-500
27
+ focus:bg-{color}-700 dark:focus:bg-{color}-500
28
+ active:bg-{color}-800 dark:active:bg-{color}-600
29
+ disabled:bg-gray-400 dark:disabled:bg-gray-600
30
+ `,
31
+ secondary: `
32
+ text-{color}-600 border-{color}-600 dark:text-{color}-400 dark:border-{color}-400
33
+ hover:text-{color}-700 hover:border-{color}-700 dark:hover:text-{color}-500 dark:hover:border-{color}-500
34
+ focus:text-{color}-700 focus:border-{color}-700 dark:focus:text-{color}-500 dark:focus:border-{color}-500
35
+ active:text-{color}-800 active:border-{color}-800 dark:active:text-{color}-600 dark:active:border-{color}-600
36
+ disabled:text-gray-400 disabled:border-gray-400 dark:disabled:text-gray-600 dark:disabled:border-gray-600
37
+ `,
38
+ thirdary: `
39
+ text-{color}-600 dark:text-{color}-400
40
+ hover:text-{color}-700 hover:bg-{color}-700/10 dark:hover:text-{color}-500 dark:hover:bg-{color}-500/10
41
+ focus:text-{color}-700 focus:bg-{color}-700/10 dark:focus:text-{color}-500 dark:focus:bg-{color}-500/10
42
+ active:text-{color}-800 active:bg-{color}-800/15 dark:active:text-{color}-600 dark:active:bg-{color}-600/15
43
+ disabled:text-gray-400 disabled:bg-transparent dark:disabled:text-gray-600 dark:disabled:bg-transparent
44
+ `,
45
+ },
46
+ round: {
47
+ false: "rounded-dynamic",
48
+ true: "rounded-full",
49
+ },
50
+ noRing: {
51
+ true: "!ring-0 !ring-offset-0",
52
+ },
53
+ loading: {
54
+ true: "pointer-events-none gap-0",
55
+ },
56
+ block: {
57
+ true: "w-full",
58
+ },
59
+ },
60
+ compoundVariants: [
61
+ {
62
+ color: ["grayscale", "white"],
63
+ class: `
64
+ focus:ring-gray-700/15 dark:focus:ring-gray-500/15
65
+ focus-within:ring-gray-700/15 dark:focus-within:ring-gray-500/15
66
+ `,
67
+ },
68
+ {
69
+ color: "grayscale",
70
+ variant: "primary",
71
+ class: `
72
+ bg-gray-900 dark:bg-gray-100
73
+ hover:bg-gray-800 dark:hover:bg-gray-200
74
+ focus:bg-gray-800 dark:focus:bg-gray-200
75
+ active:bg-gray-700 dark:active:bg-gray-300
76
+ `,
77
+ },
78
+ {
79
+ color: "grayscale",
80
+ variant: "secondary",
81
+ class: `
82
+ text-gray-900 border-gray-900 dark:text-gray-100 dark:border-gray-100
83
+ hover:text-gray-800 hover:border-gray-800 dark:hover:text-gray-200 dark:hover:border-gray-200
84
+ focus:text-gray-800 focus:border-gray-800 dark:focus:text-gray-200 dark:focus:border-gray-200
85
+ active:text-gray-700 active:border-gray-700 dark:active:focus-gray-300 dark:active:border-gray-300
86
+ `,
87
+ },
88
+ {
89
+ color: "grayscale",
90
+ variant: "thirdary",
91
+ class: `
92
+ text-gray-900 dark:text-gray-100
93
+ hover:text-gray-800 hover:bg-gray-800/15 dark:hover:text-gray-200 dark:hover:bg-gray-200/15
94
+ focus:text-gray-800 focus:bg-gray-800/15 dark:focus:text-gray-200 dark:focus:bg-gray-200/15
95
+ active:text-gray-700 active:bg-gray-700/20 dark:active:text-gray-300 dark:active:bg-gray-300/20
96
+ `,
97
+ },
98
+ {
99
+ color: "white",
100
+ class: `
101
+ text-gray-900 dark:text-white
102
+ hover:text-gray-800 dark:hover:text-gray-100
103
+ focus:text-gray-800 dark:focus:text-gray-100
104
+ active:text-gray-700 dark:active:text-gray-200
105
+ `,
106
+ },
107
+ {
108
+ color: "white",
109
+ variant: "primary",
110
+ class: `
111
+ bg-white dark:text-gray-900
112
+ hover:bg-gray-50 dark:hover:text-gray-800
113
+ focus:bg-gray-50 dark:focus:text-gray-800
114
+ active:bg-gray-100 dark:active:text-gray-700
115
+ `,
116
+ },
117
+ {
118
+ color: "white",
119
+ variant: "secondary",
120
+ class: "border-gray-100 hover:border-gray-200 focus:border-gray-200 active:border-gray-300",
121
+ },
122
+ {
123
+ color: "white",
124
+ variant: "thirdary",
125
+ class: "hover:bg-white/10 focus:bg-white/10 active:bg-white/15",
126
+ },
127
+ { filled: true, variant: "thirdary", class: "bg-{color}-600/10 dark:bg-{color}-400/10" },
128
+ { filled: true, variant: "thirdary", color: ["grayscale", "white"], class: "bg-gray-900/5 dark:bg-gray-200/5" },
129
+ { rightIcon: true, size: "2xs", class: "pr-1" },
130
+ { rightIcon: true, size: "xs", class: "pr-2" },
131
+ { rightIcon: true, size: "sm", class: "pr-3" },
132
+ { rightIcon: true, size: "md", class: "pr-4" },
133
+ { rightIcon: true, size: "lg", class: "pr-5" },
134
+ { rightIcon: true, size: "xl", class: "pr-6" },
135
+ { leftIcon: true, size: "2xs", class: "pl-1" },
136
+ { leftIcon: true, size: "xs", class: "pl-2" },
137
+ { leftIcon: true, size: "sm", class: "pl-3" },
138
+ { leftIcon: true, size: "md", class: "pl-4" },
139
+ { leftIcon: true, size: "lg", class: "pl-5" },
140
+ { leftIcon: true, size: "xl", class: "pl-6" },
141
+ { square: true, size: "2xs", class: "p-1" },
142
+ { square: true, size: "xs", class: "p-1.5" },
143
+ { square: true, size: "sm", class: "p-2" },
144
+ { square: true, size: "md", class: "p-3" },
145
+ { square: true, size: "lg", class: "p-3.5" },
146
+ { square: true, size: "xl", class: "p-4" },
147
+ ],
148
+ },
149
+ loader: "{ULoader}",
150
+ leftIcon: "{UIcon}",
151
+ rightIcon: "{UIcon}",
152
+ centerIcon: "{UIcon}",
153
+ defaults: {
154
+ color: "brand",
155
+ variant: "primary",
156
+ tag: "button",
157
+ size: "md",
158
+ tabindex: 0,
159
+ round: false,
160
+ block: false,
161
+ square: false,
162
+ filled: false,
163
+ noRing: false,
164
+ loading: false,
165
+ disabled: false,
166
+ },
167
+ };
@@ -1,8 +1,8 @@
1
1
  import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
2
2
  import { getSource } from "../../utils/storybook.ts";
3
3
 
4
- import * as stories from "./stories.js";
5
- import defaultConfig from "../config.js?raw"
4
+ import * as stories from "./stories.ts";
5
+ import defaultConfig from "../config.ts?raw"
6
6
 
7
7
  <Meta of={stories} />
8
8
  <Title of={stories} />
@@ -12,6 +12,20 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
12
12
  import URow from "../../ui.container-row/URow.vue";
13
13
  import UCol from "../../ui.container-col/UCol.vue";
14
14
 
15
+ import { useDarkMode } from "../../composables/useDarkMode.ts";
16
+
17
+ import type { Meta, StoryFn } from "@storybook/vue3";
18
+ import type { UButtonProps } from "../types.ts";
19
+
20
+ interface UButtonArgs extends UButtonProps {
21
+ slotTemplate?: string;
22
+ enum: "variant" | "size";
23
+ }
24
+
25
+ interface StoryArgType {
26
+ options?: string[];
27
+ }
28
+
15
29
  export default {
16
30
  id: "1010",
17
31
  title: "Buttons & Links / Button",
@@ -25,9 +39,9 @@ export default {
25
39
  parameters: {
26
40
  ...getDocsDescription(UButton.__name),
27
41
  },
28
- };
42
+ } as Meta;
29
43
 
30
- const DefaultTemplate = (args) => ({
44
+ const DefaultTemplate: StoryFn<UButtonArgs> = (args: UButtonArgs) => ({
31
45
  components: { UButton, UIcon },
32
46
  setup() {
33
47
  const slots = getSlotNames(UButton.__name);
@@ -36,15 +50,15 @@ const DefaultTemplate = (args) => ({
36
50
  },
37
51
  template: `
38
52
  <UButton v-bind="args">
39
- ${args.slotTemplate || getSlotsFragment()}
53
+ ${args.slotTemplate || getSlotsFragment("")}
40
54
  </UButton>
41
55
  `,
42
56
  });
43
57
 
44
- const EnumVariantTemplate = (args, { argTypes }) => ({
58
+ const EnumVariantTemplate: StoryFn<UButtonArgs> = (args: UButtonArgs, { argTypes }) => ({
45
59
  components: { UButton, URow, UCol },
46
60
  setup() {
47
- return { args, options: argTypes[args.enum].options };
61
+ return { args, options: argTypes?.[args.enum]?.options };
48
62
  },
49
63
  template: `
50
64
  <UCol>
@@ -61,16 +75,17 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
61
75
  `,
62
76
  });
63
77
 
64
- const ColorTemplate = (args, { argTypes }) => ({
78
+ const ColorTemplate: StoryFn<UButtonArgs> = (args, { argTypes }) => ({
65
79
  components: { UButton, URow, UCol },
66
80
  setup() {
67
- const variants = [...argTypes.variant.options, "thirdary"];
81
+ const variantOptions = (argTypes.variant as StoryArgType)?.options ?? [];
82
+ const variants = [...Array.from(variantOptions), "thirdary"];
68
83
 
69
84
  return {
70
85
  args,
71
86
  variants,
72
- colors: argTypes.color.options,
73
- shouldBeFilled: (variant, index) => {
87
+ colors: argTypes?.color?.options,
88
+ shouldBeFilled: (variant: string, index: number) => {
74
89
  return variant === "thirdary" && index === variants.length - 2;
75
90
  },
76
91
  };
@@ -104,7 +119,7 @@ Sizes.args = { enum: "size" };
104
119
  export const Round = EnumVariantTemplate.bind({});
105
120
  Round.args = { enum: "variant", round: true };
106
121
 
107
- export const Loading = (args) => ({
122
+ export const Loading: StoryFn<UButtonArgs> = (args) => ({
108
123
  components: { UButton, URow },
109
124
  setup() {
110
125
  const loading = ref(false);
@@ -147,7 +162,7 @@ Colors.args = {};
147
162
  export const Square = DefaultTemplate.bind({});
148
163
  Square.args = { square: true, icon: "filter_list" };
149
164
 
150
- export const IconProps = (args) => ({
165
+ export const IconProps: StoryFn<UButtonArgs> = (args) => ({
151
166
  components: { UButton, URow },
152
167
  setup() {
153
168
  return { args };
@@ -166,10 +181,12 @@ export const IconProps = (args) => ({
166
181
  `,
167
182
  });
168
183
 
169
- export const Slots = (args) => ({
184
+ export const Slots: StoryFn<UButtonArgs> = (args) => ({
170
185
  components: { UButton, UIcon, URow },
171
186
  setup() {
172
- return { args };
187
+ const { isDarkMode } = useDarkMode();
188
+
189
+ return { args, isDarkMode };
173
190
  },
174
191
  template: `
175
192
  <URow no-mobile>
@@ -177,8 +194,9 @@ export const Slots = (args) => ({
177
194
  <template #left>
178
195
  <UIcon
179
196
  name="heart_plus"
180
- color="green"
181
197
  size="sm"
198
+ color="green"
199
+ :variant="isDarkMode ? 'dark' : 'default'"
182
200
  />
183
201
  </template>
184
202
  </UButton>
@@ -187,8 +205,9 @@ export const Slots = (args) => ({
187
205
  <template #default>
188
206
  <UIcon
189
207
  name="settings"
190
- color="green"
191
208
  size="sm"
209
+ color="green"
210
+ :variant="isDarkMode ? 'dark' : 'default'"
192
211
  />
193
212
  </template>
194
213
  </UButton>
@@ -197,8 +216,9 @@ export const Slots = (args) => ({
197
216
  <template #right>
198
217
  <UIcon
199
218
  name="delete"
200
- color="green"
201
219
  size="sm"
220
+ color="green"
221
+ :variant="isDarkMode ? 'dark' : 'default'"
202
222
  />
203
223
  </template>
204
224
  </UButton>