vueless 0.0.503 → 0.0.505

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 (108) hide show
  1. package/package.json +1 -1
  2. package/plugin-vite.d.ts +43 -11
  3. package/types.ts +31 -3
  4. package/ui.button/UButton.vue +101 -240
  5. package/ui.button/storybook/Docs.mdx +2 -2
  6. package/ui.button/storybook/{stories.js → stories.ts} +25 -12
  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.other-dot/UDot.vue +14 -42
  25. package/ui.other-dot/storybook/Docs.mdx +2 -2
  26. package/ui.other-dot/storybook/{stories.js → stories.ts} +13 -5
  27. package/ui.other-dot/types.ts +46 -0
  28. package/ui.other-dot/useAttrs.ts +18 -0
  29. package/ui.text-alert/UAlert.vue +85 -157
  30. package/ui.text-alert/storybook/Docs.mdx +2 -2
  31. package/ui.text-alert/storybook/{stories.js → stories.ts} +17 -9
  32. package/ui.text-alert/types.ts +76 -0
  33. package/ui.text-alert/useAttrs.ts +18 -0
  34. package/ui.text-badge/UBadge.vue +1 -0
  35. package/ui.text-badge/storybook/stories.ts +1 -8
  36. package/ui.text-badge/types.ts +2 -0
  37. package/ui.text-badge/useAttrs.ts +1 -3
  38. package/ui.text-block/UText.vue +1 -0
  39. package/ui.text-block/storybook/stories.ts +1 -1
  40. package/ui.text-block/types.ts +2 -0
  41. package/ui.text-block/useAttrs.ts +1 -1
  42. package/ui.text-empty/UEmpty.vue +39 -75
  43. package/ui.text-empty/storybook/Docs.mdx +2 -2
  44. package/ui.text-empty/storybook/{stories.js → stories.ts} +14 -6
  45. package/ui.text-empty/types.ts +30 -0
  46. package/ui.text-empty/useAttrs.ts +18 -0
  47. package/ui.text-file/UFile.vue +49 -109
  48. package/ui.text-file/storybook/Docs.mdx +2 -2
  49. package/ui.text-file/storybook/{stories.js → stories.ts} +10 -3
  50. package/ui.text-file/types.ts +45 -0
  51. package/ui.text-file/useAttrs.ts +18 -0
  52. package/ui.text-files/UFiles.vue +46 -106
  53. package/ui.text-files/storybook/Docs.mdx +2 -2
  54. package/ui.text-files/storybook/{stories.js → stories.ts} +10 -3
  55. package/ui.text-files/types.ts +45 -0
  56. package/ui.text-files/useAttrs.ts +18 -0
  57. package/ui.text-header/UHeader.vue +19 -76
  58. package/ui.text-header/storybook/Docs.mdx +2 -2
  59. package/ui.text-header/storybook/{stories.js → stories.ts} +13 -5
  60. package/ui.text-header/types.ts +66 -0
  61. package/ui.text-header/useAttrs.ts +18 -0
  62. package/ui.text-money/UMoney.vue +58 -168
  63. package/ui.text-money/storybook/Docs.mdx +2 -2
  64. package/ui.text-money/storybook/{stories.js → stories.ts} +13 -5
  65. package/ui.text-money/types.ts +101 -0
  66. package/ui.text-money/useAttrs.ts +18 -0
  67. package/ui.text-money/{utilMoney.js → utilMoney.ts} +1 -1
  68. package/ui.text-notify/UNotify.vue +89 -116
  69. package/ui.text-notify/storybook/Docs.mdx +2 -2
  70. package/ui.text-notify/storybook/{stories.js → stories.ts} +12 -5
  71. package/ui.text-notify/types.ts +25 -0
  72. package/ui.text-notify/useAttrs.ts +18 -0
  73. package/ui.text-notify/utilNotify.ts +140 -0
  74. package/web-types.json +285 -135
  75. package/ui.button-toggle/useAttrs.js +0 -15
  76. package/ui.other-dot/useAttrs.js +0 -15
  77. package/ui.text-alert/useAttrs.js +0 -15
  78. package/ui.text-empty/useAttrs.js +0 -15
  79. package/ui.text-file/useAttrs.js +0 -15
  80. package/ui.text-files/useAttrs.js +0 -15
  81. package/ui.text-header/useAttrs.js +0 -15
  82. package/ui.text-money/useAttrs.js +0 -15
  83. package/ui.text-notify/useAttrs.js +0 -15
  84. package/ui.text-notify/utilNotify.js +0 -86
  85. /package/ui.button/{config.js → config.ts} +0 -0
  86. /package/ui.button/{constants.js → constants.ts} +0 -0
  87. /package/ui.button-link/{config.js → config.ts} +0 -0
  88. /package/ui.button-link/{constants.js → constants.ts} +0 -0
  89. /package/ui.button-toggle/{config.js → config.ts} +0 -0
  90. /package/ui.button-toggle/{constants.js → constants.ts} +0 -0
  91. /package/ui.button-toggle-item/{config.js → config.ts} +0 -0
  92. /package/ui.button-toggle-item/{constants.js → constants.ts} +0 -0
  93. /package/ui.other-dot/{config.js → config.ts} +0 -0
  94. /package/ui.other-dot/{constants.js → constants.ts} +0 -0
  95. /package/ui.text-alert/{config.js → config.ts} +0 -0
  96. /package/ui.text-alert/{constants.js → constants.ts} +0 -0
  97. /package/ui.text-empty/{config.js → config.ts} +0 -0
  98. /package/ui.text-empty/{constants.js → constants.ts} +0 -0
  99. /package/ui.text-file/{config.js → config.ts} +0 -0
  100. /package/ui.text-file/{constants.js → constants.ts} +0 -0
  101. /package/ui.text-files/{config.js → config.ts} +0 -0
  102. /package/ui.text-files/{constants.js → constants.ts} +0 -0
  103. /package/ui.text-header/{config.js → config.ts} +0 -0
  104. /package/ui.text-header/{constants.js → constants.ts} +0 -0
  105. /package/ui.text-money/{config.js → config.ts} +0 -0
  106. /package/ui.text-money/{constants.js → constants.ts} +0 -0
  107. /package/ui.text-notify/{config.js → config.ts} +0 -0
  108. /package/ui.text-notify/{constants.js → constants.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.503",
3
+ "version": "0.0.505",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/plugin-vite.d.ts CHANGED
@@ -1,11 +1,43 @@
1
- export function VuelessUnpluginComponents(options?: unknown): import("vite").Plugin<unknown> & {
2
- api: import("unplugin-vue-components/types.js").PublicPluginAPI;
3
- };
4
-
5
- export function Vueless(options?: {
6
- env?: string;
7
- mode?: string;
8
- debug?: boolean;
9
- include?: string[];
10
- mirrorCacheDir?: string;
11
- }): never;
1
+ declare module "unplugin-vue-components" {
2
+ export function VuelessUnpluginComponents(options?: unknown): import("vite").Plugin<unknown> & {
3
+ api: import("unplugin-vue-components/types.js").PublicPluginAPI;
4
+ };
5
+ }
6
+
7
+ declare module "Vueless" {
8
+ import { Plugin } from "vite";
9
+ import { Config } from "svgo";
10
+ function Vueless(options?: {
11
+ env?: string;
12
+ mode?: string;
13
+ debug?: boolean;
14
+ include?: string[];
15
+ mirrorCacheDir?: string;
16
+ svgoConfig?: Config;
17
+ svgo?: boolean;
18
+ defaultImport?: "url" | "raw" | "component";
19
+ }): Plugin;
20
+ export default Vueless;
21
+ }
22
+
23
+ declare module "*.svg?component" {
24
+ import type { FunctionalComponent, SVGAttributes } from "vue";
25
+ const component: FunctionalComponent<SVGAttributes>;
26
+ export default component;
27
+ }
28
+
29
+ declare module "*.svg?url" {
30
+ const src: string;
31
+ export default src;
32
+ }
33
+
34
+ declare module "*.svg?raw" {
35
+ const content: string;
36
+ export default content;
37
+ }
38
+
39
+ declare module "*.svg?skipsvgo" {
40
+ import type { FunctionalComponent, SVGAttributes } from "vue";
41
+ const component: FunctionalComponent<SVGAttributes>;
42
+ export default component;
43
+ }
package/types.ts CHANGED
@@ -2,7 +2,18 @@ import { hasSlotContent } from "./composables/useUI.ts";
2
2
 
3
3
  // TODO: Import all components here
4
4
  import UTextDefaultConfig from "./ui.text-block/config.ts";
5
+ import UAlertDefaultConfig from "./ui.text-alert/config.ts";
6
+ import UEmptyDefaultConfig from "./ui.text-empty/config.ts";
7
+ import UFileDefaultConfig from "./ui.text-file/config.ts";
8
+ import UFilesDefaultConfig from "./ui.text-files/config.ts";
9
+ import UMoneyDefaultConfig from "./ui.text-money/config.ts";
10
+ import UHeaderDefaultConfig from "./ui.text-header/config.ts";
11
+ import UNotifyDefaultConfig from "./ui.text-notify/config.ts";
12
+ import UDotDefaultConfig from "./ui.other-dot/config.ts";
5
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";
6
17
  import UBadgeDefaultConfig from "./ui.text-badge/config.ts";
7
18
  import UCalendarDefaultConfig from "./ui.form-calendar/config.ts";
8
19
  import UDatePickerConfig from "./ui.form-date-picker/config.ts";
@@ -115,7 +126,18 @@ export type BrandColors =
115
126
 
116
127
  export interface Components {
117
128
  UText?: Partial<typeof UTextDefaultConfig>;
129
+ UAlert?: Partial<typeof UAlertDefaultConfig>;
130
+ UEmpty?: Partial<typeof UEmptyDefaultConfig>;
131
+ UFile?: Partial<typeof UFileDefaultConfig>;
132
+ UFiles?: Partial<typeof UFilesDefaultConfig>;
133
+ UMoney?: Partial<typeof UMoneyDefaultConfig>;
134
+ UHeader?: Partial<typeof UHeaderDefaultConfig>;
135
+ UNotify?: Partial<typeof UNotifyDefaultConfig>;
136
+ UDot?: Partial<typeof UDotDefaultConfig>;
118
137
  UButton?: Partial<typeof UButtonDefaultConfig>;
138
+ ULink?: Partial<typeof ULinkDefaultConfig>;
139
+ UToggle?: Partial<typeof UToggleDefaultConfig>;
140
+ UToggleItem?: Partial<typeof UToggleItemDefaultConfig>;
119
141
  UBadge?: Partial<typeof UBadgeDefaultConfig>;
120
142
  UCalendar?: Partial<typeof UCalendarDefaultConfig>;
121
143
  UDatePicker?: Partial<typeof UDatePickerConfig>;
@@ -346,19 +368,25 @@ export type ComponentType<T> = T extends new (...args: any) => {}
346
368
  ? 2
347
369
  : 0;
348
370
 
349
- export type ComponentProps<T> = T extends new (...args: any) => { $props: infer P }
371
+ export type ComponentProps<T> = T extends new (...args: any) => {
372
+ $props: infer P;
373
+ }
350
374
  ? NonNullable<P>
351
375
  : T extends (props: infer P, ...args: any) => any
352
376
  ? P
353
377
  : {};
354
378
 
355
- export type ComponentSlots<T> = T extends new (...args: any) => { $slots: infer S }
379
+ export type ComponentSlots<T> = T extends new (...args: any) => {
380
+ $slots: infer S;
381
+ }
356
382
  ? NonNullable<S>
357
383
  : T extends (props: any, ctx: { slots: infer S; attrs: any; emit: any }, ...args: any) => any
358
384
  ? NonNullable<S>
359
385
  : {};
360
386
 
361
- export type ComponentEmit<T> = T extends new (...args: any) => { $emit: infer E }
387
+ export type ComponentEmit<T> = T extends new (...args: any) => {
388
+ $emit: infer E;
389
+ }
362
390
  ? NonNullable<E>
363
391
  : {};
364
392
 
@@ -1,3 +1,104 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref, watchEffect, useId, watch } from "vue";
3
+
4
+ import { getDefault } from "../utils/ui.ts";
5
+ import ULoader from "../ui.loader/ULoader.vue";
6
+ import UIcon from "../ui.image-icon/UIcon.vue";
7
+
8
+ import defaultConfig from "./config.ts";
9
+ import useAttrs from "./useAttrs.ts";
10
+ import { UButton } from "./constants.ts";
11
+
12
+ import type { UButtonProps } from "./types.ts";
13
+
14
+ defineOptions({ inheritAttrs: false });
15
+
16
+ const props = withDefaults(defineProps<UButtonProps>(), {
17
+ variant: getDefault<UButtonProps>(defaultConfig, UButton).variant,
18
+ color: getDefault<UButtonProps>(defaultConfig, UButton).color,
19
+ size: getDefault<UButtonProps>(defaultConfig, UButton).size,
20
+ tag: getDefault<UButtonProps>(defaultConfig, UButton).tag,
21
+ tabindex: getDefault<UButtonProps>(defaultConfig, UButton).tabindex,
22
+ filled: getDefault<UButtonProps>(defaultConfig, UButton).filled,
23
+ disabled: getDefault<UButtonProps>(defaultConfig, UButton).disabled,
24
+ block: getDefault<UButtonProps>(defaultConfig, UButton).block,
25
+ round: getDefault<UButtonProps>(defaultConfig, UButton).round,
26
+ square: getDefault<UButtonProps>(defaultConfig, UButton).square,
27
+ loading: getDefault<UButtonProps>(defaultConfig, UButton).loading,
28
+ noRing: getDefault<UButtonProps>(defaultConfig, UButton).noRing,
29
+ dataTest: "",
30
+ });
31
+
32
+ const elementId = props.id || useId();
33
+
34
+ const { buttonAttrs, loaderAttrs, leftIconAttrs, rightIconAttrs, centerIconAttrs } =
35
+ useAttrs(props);
36
+
37
+ const buttonRef = ref(null);
38
+ const buttonStyle = ref(null);
39
+ const buttonWidth = ref(0);
40
+
41
+ const loaderSize = computed(() => {
42
+ const sizes = {
43
+ "2xs": "sm",
44
+ xs: "sm",
45
+ sm: "md",
46
+ md: "md",
47
+ lg: "lg",
48
+ xl: "lg",
49
+ };
50
+
51
+ return sizes[props.size];
52
+ });
53
+
54
+ const iconSize = computed(() => {
55
+ const sizes = {
56
+ "2xs": "2xs",
57
+ xs: "xs",
58
+ sm: "sm",
59
+ md: "sm",
60
+ lg: "md",
61
+ xl: "md",
62
+ };
63
+
64
+ return sizes[props.size];
65
+ });
66
+
67
+ const iconColor = computed(() => {
68
+ return props.variant === "primary" ? "white" : props.color;
69
+ });
70
+
71
+ watch(
72
+ () => props.loading,
73
+ (newValue, oldValue) => {
74
+ const isLoaderOn = newValue && oldValue !== undefined;
75
+
76
+ if (isLoaderOn && buttonRef.value) {
77
+ buttonWidth.value = buttonRef.value.offsetWidth;
78
+ }
79
+
80
+ buttonStyle.value = {
81
+ width: isLoaderOn ? `${buttonWidth.value}px` : null,
82
+ paddingLeft: isLoaderOn ? "0px" : null,
83
+ paddingRight: isLoaderOn ? "0px" : null,
84
+ };
85
+ },
86
+ { immediate: true },
87
+ );
88
+
89
+ watchEffect(() => {
90
+ props.loading && buttonRef.value.blur();
91
+ });
92
+
93
+ defineExpose({
94
+ /**
95
+ * A reference to the button element for direct DOM manipulation.
96
+ * @property {HTMLElement}
97
+ */
98
+ buttonRef,
99
+ });
100
+ </script>
101
+
1
102
  <template>
2
103
  <component
3
104
  :is="tag"
@@ -79,243 +180,3 @@
79
180
  </template>
80
181
  </component>
81
182
  </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>
@@ -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,18 @@ 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 type { Meta, StoryFn } from "@storybook/vue3";
16
+ import type { UButtonProps } from "../types.ts";
17
+
18
+ interface UButtonArgs extends UButtonProps {
19
+ slotTemplate?: string;
20
+ enum: "variant" | "size";
21
+ }
22
+
23
+ interface StoryArgType {
24
+ options?: string[];
25
+ }
26
+
15
27
  export default {
16
28
  id: "1010",
17
29
  title: "Buttons & Links / Button",
@@ -25,9 +37,9 @@ export default {
25
37
  parameters: {
26
38
  ...getDocsDescription(UButton.__name),
27
39
  },
28
- };
40
+ } as Meta;
29
41
 
30
- const DefaultTemplate = (args) => ({
42
+ const DefaultTemplate: StoryFn<UButtonArgs> = (args: UButtonArgs) => ({
31
43
  components: { UButton, UIcon },
32
44
  setup() {
33
45
  const slots = getSlotNames(UButton.__name);
@@ -36,15 +48,15 @@ const DefaultTemplate = (args) => ({
36
48
  },
37
49
  template: `
38
50
  <UButton v-bind="args">
39
- ${args.slotTemplate || getSlotsFragment()}
51
+ ${args.slotTemplate || getSlotsFragment("")}
40
52
  </UButton>
41
53
  `,
42
54
  });
43
55
 
44
- const EnumVariantTemplate = (args, { argTypes }) => ({
56
+ const EnumVariantTemplate: StoryFn<UButtonArgs> = (args: UButtonArgs, { argTypes }) => ({
45
57
  components: { UButton, URow, UCol },
46
58
  setup() {
47
- return { args, options: argTypes[args.enum].options };
59
+ return { args, options: argTypes?.[args.enum]?.options };
48
60
  },
49
61
  template: `
50
62
  <UCol>
@@ -61,16 +73,17 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
61
73
  `,
62
74
  });
63
75
 
64
- const ColorTemplate = (args, { argTypes }) => ({
76
+ const ColorTemplate: StoryFn<UButtonArgs> = (args, { argTypes }) => ({
65
77
  components: { UButton, URow, UCol },
66
78
  setup() {
67
- const variants = [...argTypes.variant.options, "thirdary"];
79
+ const variantOptions = (argTypes.variant as StoryArgType)?.options ?? [];
80
+ const variants = [...Array.from(variantOptions), "thirdary"];
68
81
 
69
82
  return {
70
83
  args,
71
84
  variants,
72
- colors: argTypes.color.options,
73
- shouldBeFilled: (variant, index) => {
85
+ colors: argTypes?.color?.options,
86
+ shouldBeFilled: (variant: string, index: number) => {
74
87
  return variant === "thirdary" && index === variants.length - 2;
75
88
  },
76
89
  };
@@ -104,7 +117,7 @@ Sizes.args = { enum: "size" };
104
117
  export const Round = EnumVariantTemplate.bind({});
105
118
  Round.args = { enum: "variant", round: true };
106
119
 
107
- export const Loading = (args) => ({
120
+ export const Loading: StoryFn<UButtonArgs> = (args) => ({
108
121
  components: { UButton, URow },
109
122
  setup() {
110
123
  const loading = ref(false);
@@ -147,7 +160,7 @@ Colors.args = {};
147
160
  export const Square = DefaultTemplate.bind({});
148
161
  Square.args = { square: true, icon: "filter_list" };
149
162
 
150
- export const IconProps = (args) => ({
163
+ export const IconProps: StoryFn<UButtonArgs> = (args) => ({
151
164
  components: { UButton, URow },
152
165
  setup() {
153
166
  return { args };
@@ -166,7 +179,7 @@ export const IconProps = (args) => ({
166
179
  `,
167
180
  });
168
181
 
169
- export const Slots = (args) => ({
182
+ export const Slots: StoryFn<UButtonArgs> = (args) => ({
170
183
  components: { UButton, UIcon, URow },
171
184
  setup() {
172
185
  return { args };
@@ -0,0 +1,121 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UButtonProps {
6
+ /**
7
+ * Button variant.
8
+ */
9
+ variant?: "primary" | "secondary" | "thirdary";
10
+
11
+ /**
12
+ * Button color.
13
+ */
14
+ color?:
15
+ | "brand"
16
+ | "grayscale"
17
+ | "gray"
18
+ | "red"
19
+ | "orange"
20
+ | "amber"
21
+ | "yellow"
22
+ | "lime"
23
+ | "green"
24
+ | "emerald"
25
+ | "teal"
26
+ | "cyan"
27
+ | "sky"
28
+ | "blue"
29
+ | "indigo"
30
+ | "violet"
31
+ | "purple"
32
+ | "fuchsia"
33
+ | "pink"
34
+ | "rose"
35
+ | "white";
36
+
37
+ /**
38
+ * Button size.
39
+ */
40
+ size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl";
41
+
42
+ /**
43
+ * Button label.
44
+ */
45
+ label?: string;
46
+
47
+ /**
48
+ * Allows changing button html tag.
49
+ */
50
+ tag?: string;
51
+
52
+ /**
53
+ * Icon name (appears instead of label).
54
+ */
55
+ icon?: string;
56
+
57
+ /**
58
+ * Left icon name.
59
+ */
60
+ leftIcon?: string;
61
+
62
+ /**
63
+ * Right icon name.
64
+ */
65
+ rightIcon?: string;
66
+
67
+ /**
68
+ * Controls the keyboard “Tab” focus order of elements.
69
+ */
70
+ tabindex?: string | number;
71
+
72
+ /**
73
+ * Fill the background for thirdary variant.
74
+ */
75
+ filled?: boolean;
76
+
77
+ /**
78
+ * Disable the button.
79
+ */
80
+ disabled?: boolean;
81
+
82
+ /**
83
+ * Make the Button fill the width with its container.
84
+ */
85
+ block?: boolean;
86
+
87
+ /**
88
+ * Set button corners rounded.
89
+ */
90
+ round?: boolean;
91
+
92
+ /**
93
+ * Set the same paddings for the button.
94
+ */
95
+ square?: boolean;
96
+
97
+ /**
98
+ * Enable loader.
99
+ */
100
+ loading?: boolean;
101
+
102
+ /**
103
+ * Remove button ring on focus.
104
+ */
105
+ noRing?: boolean;
106
+
107
+ /**
108
+ * Unique element id.
109
+ */
110
+ id?: string;
111
+
112
+ /**
113
+ * Component config object.
114
+ */
115
+ config?: Partial<typeof defaultConfig>;
116
+
117
+ /**
118
+ * Data-test attribute for automated testing.
119
+ */
120
+ dataTest?: string;
121
+ }