vueless 0.0.503 → 0.0.504

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 (79) hide show
  1. package/package.json +1 -1
  2. package/plugin-vite.d.ts +43 -11
  3. package/types.ts +25 -3
  4. package/ui.other-dot/UDot.vue +14 -42
  5. package/ui.other-dot/storybook/Docs.mdx +2 -2
  6. package/ui.other-dot/storybook/{stories.js → stories.ts} +13 -5
  7. package/ui.other-dot/types.ts +46 -0
  8. package/ui.other-dot/useAttrs.ts +18 -0
  9. package/ui.text-alert/UAlert.vue +85 -157
  10. package/ui.text-alert/storybook/Docs.mdx +2 -2
  11. package/ui.text-alert/storybook/{stories.js → stories.ts} +17 -9
  12. package/ui.text-alert/types.ts +76 -0
  13. package/ui.text-alert/useAttrs.ts +18 -0
  14. package/ui.text-badge/UBadge.vue +1 -0
  15. package/ui.text-badge/storybook/stories.ts +1 -8
  16. package/ui.text-badge/types.ts +2 -0
  17. package/ui.text-badge/useAttrs.ts +1 -3
  18. package/ui.text-block/UText.vue +1 -0
  19. package/ui.text-block/storybook/stories.ts +1 -1
  20. package/ui.text-block/types.ts +2 -0
  21. package/ui.text-block/useAttrs.ts +1 -1
  22. package/ui.text-empty/UEmpty.vue +39 -75
  23. package/ui.text-empty/storybook/Docs.mdx +2 -2
  24. package/ui.text-empty/storybook/{stories.js → stories.ts} +14 -6
  25. package/ui.text-empty/types.ts +30 -0
  26. package/ui.text-empty/useAttrs.ts +18 -0
  27. package/ui.text-file/UFile.vue +49 -109
  28. package/ui.text-file/storybook/Docs.mdx +2 -2
  29. package/ui.text-file/storybook/{stories.js → stories.ts} +10 -3
  30. package/ui.text-file/types.ts +45 -0
  31. package/ui.text-file/useAttrs.ts +18 -0
  32. package/ui.text-files/UFiles.vue +46 -106
  33. package/ui.text-files/storybook/Docs.mdx +2 -2
  34. package/ui.text-files/storybook/{stories.js → stories.ts} +10 -3
  35. package/ui.text-files/types.ts +45 -0
  36. package/ui.text-files/useAttrs.ts +18 -0
  37. package/ui.text-header/UHeader.vue +19 -76
  38. package/ui.text-header/storybook/Docs.mdx +2 -2
  39. package/ui.text-header/storybook/{stories.js → stories.ts} +13 -5
  40. package/ui.text-header/types.ts +66 -0
  41. package/ui.text-header/useAttrs.ts +18 -0
  42. package/ui.text-money/UMoney.vue +58 -168
  43. package/ui.text-money/storybook/Docs.mdx +2 -2
  44. package/ui.text-money/storybook/{stories.js → stories.ts} +13 -5
  45. package/ui.text-money/types.ts +101 -0
  46. package/ui.text-money/useAttrs.ts +18 -0
  47. package/ui.text-money/{utilMoney.js → utilMoney.ts} +1 -1
  48. package/ui.text-notify/UNotify.vue +89 -116
  49. package/ui.text-notify/storybook/Docs.mdx +2 -2
  50. package/ui.text-notify/storybook/{stories.js → stories.ts} +12 -5
  51. package/ui.text-notify/types.ts +25 -0
  52. package/ui.text-notify/useAttrs.ts +18 -0
  53. package/ui.text-notify/utilNotify.ts +140 -0
  54. package/web-types.json +152 -77
  55. package/ui.other-dot/useAttrs.js +0 -15
  56. package/ui.text-alert/useAttrs.js +0 -15
  57. package/ui.text-empty/useAttrs.js +0 -15
  58. package/ui.text-file/useAttrs.js +0 -15
  59. package/ui.text-files/useAttrs.js +0 -15
  60. package/ui.text-header/useAttrs.js +0 -15
  61. package/ui.text-money/useAttrs.js +0 -15
  62. package/ui.text-notify/useAttrs.js +0 -15
  63. package/ui.text-notify/utilNotify.js +0 -86
  64. /package/ui.other-dot/{config.js → config.ts} +0 -0
  65. /package/ui.other-dot/{constants.js → constants.ts} +0 -0
  66. /package/ui.text-alert/{config.js → config.ts} +0 -0
  67. /package/ui.text-alert/{constants.js → constants.ts} +0 -0
  68. /package/ui.text-empty/{config.js → config.ts} +0 -0
  69. /package/ui.text-empty/{constants.js → constants.ts} +0 -0
  70. /package/ui.text-file/{config.js → config.ts} +0 -0
  71. /package/ui.text-file/{constants.js → constants.ts} +0 -0
  72. /package/ui.text-files/{config.js → config.ts} +0 -0
  73. /package/ui.text-files/{constants.js → constants.ts} +0 -0
  74. /package/ui.text-header/{config.js → config.ts} +0 -0
  75. /package/ui.text-header/{constants.js → constants.ts} +0 -0
  76. /package/ui.text-money/{config.js → config.ts} +0 -0
  77. /package/ui.text-money/{constants.js → constants.ts} +0 -0
  78. /package/ui.text-notify/{config.js → config.ts} +0 -0
  79. /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.504",
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,6 +2,14 @@ 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";
6
14
  import UBadgeDefaultConfig from "./ui.text-badge/config.ts";
7
15
  import UCalendarDefaultConfig from "./ui.form-calendar/config.ts";
@@ -115,6 +123,14 @@ export type BrandColors =
115
123
 
116
124
  export interface Components {
117
125
  UText?: Partial<typeof UTextDefaultConfig>;
126
+ UAlert?: Partial<typeof UAlertDefaultConfig>;
127
+ UEmpty?: Partial<typeof UEmptyDefaultConfig>;
128
+ UFile?: Partial<typeof UFileDefaultConfig>;
129
+ UFiles?: Partial<typeof UFilesDefaultConfig>;
130
+ UMoney?: Partial<typeof UMoneyDefaultConfig>;
131
+ UHeader?: Partial<typeof UHeaderDefaultConfig>;
132
+ UNotify?: Partial<typeof UNotifyDefaultConfig>;
133
+ UDot?: Partial<typeof UDotDefaultConfig>;
118
134
  UButton?: Partial<typeof UButtonDefaultConfig>;
119
135
  UBadge?: Partial<typeof UBadgeDefaultConfig>;
120
136
  UCalendar?: Partial<typeof UCalendarDefaultConfig>;
@@ -346,19 +362,25 @@ export type ComponentType<T> = T extends new (...args: any) => {}
346
362
  ? 2
347
363
  : 0;
348
364
 
349
- export type ComponentProps<T> = T extends new (...args: any) => { $props: infer P }
365
+ export type ComponentProps<T> = T extends new (...args: any) => {
366
+ $props: infer P;
367
+ }
350
368
  ? NonNullable<P>
351
369
  : T extends (props: infer P, ...args: any) => any
352
370
  ? P
353
371
  : {};
354
372
 
355
- export type ComponentSlots<T> = T extends new (...args: any) => { $slots: infer S }
373
+ export type ComponentSlots<T> = T extends new (...args: any) => {
374
+ $slots: infer S;
375
+ }
356
376
  ? NonNullable<S>
357
377
  : T extends (props: any, ctx: { slots: infer S; attrs: any; emit: any }, ...args: any) => any
358
378
  ? NonNullable<S>
359
379
  : {};
360
380
 
361
- export type ComponentEmit<T> = T extends new (...args: any) => { $emit: infer E }
381
+ export type ComponentEmit<T> = T extends new (...args: any) => {
382
+ $emit: infer E;
383
+ }
362
384
  ? NonNullable<E>
363
385
  : {};
364
386
 
@@ -1,51 +1,23 @@
1
- <template>
2
- <div v-bind="dotAttrs" :data-test="dataTest" />
3
- </template>
4
-
5
- <script setup>
1
+ <script lang="ts" setup>
6
2
  import { getDefault } from "../utils/ui.ts";
7
3
 
8
- import { UDot } from "./constants.js";
9
- import defaultConfig from "./config.js";
10
- import useAttrs from "./useAttrs.js";
11
-
12
- defineOptions({ inheritAttrs: false });
13
-
14
- const props = defineProps({
15
- /**
16
- * Dot color.
17
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
18
- */
19
- color: {
20
- type: String,
21
- default: getDefault(defaultConfig, UDot).color,
22
- },
4
+ import { UDot } from "./constants.ts";
5
+ import defaultConfig from "./config.ts";
6
+ import useAttrs from "./useAttrs.ts";
23
7
 
24
- /**
25
- * Dot size.
26
- * @values xs, sm, md, lg, xl
27
- */
28
- size: {
29
- type: String,
30
- default: getDefault(defaultConfig, UDot).size,
31
- },
8
+ import type { UDotProps } from "./types.ts";
32
9
 
33
- /**
34
- * Component config object.
35
- */
36
- config: {
37
- type: Object,
38
- default: () => ({}),
39
- },
10
+ defineOptions({ inheritAttrs: false });
40
11
 
41
- /**
42
- * Data-test attribute for automated testing.
43
- */
44
- dataTest: {
45
- type: String,
46
- default: "",
47
- },
12
+ const props = withDefaults(defineProps<UDotProps>(), {
13
+ color: getDefault<UDotProps>(defaultConfig, UDot).color,
14
+ size: getDefault<UDotProps>(defaultConfig, UDot).size,
15
+ dataTest: "",
48
16
  });
49
17
 
50
18
  const { dotAttrs } = useAttrs(props);
51
19
  </script>
20
+
21
+ <template>
22
+ <div v-bind="dotAttrs" :data-test="dataTest" />
23
+ </template>
@@ -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} />
@@ -5,6 +5,14 @@ import URow from "../../ui.container-row/URow.vue";
5
5
  import UCol from "../../ui.container-col/UCol.vue";
6
6
  import UBadge from "../../ui.text-badge/UBadge.vue";
7
7
 
8
+ import type { Meta, StoryFn } from "@storybook/vue3";
9
+ import type { UDotProps } from "../types.ts";
10
+
11
+ interface UDotArgs extends UDotProps {
12
+ slotTemplate?: string;
13
+ enum: "size" | "color";
14
+ }
15
+
8
16
  /**
9
17
  * The `UDot` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.other-dot)
10
18
  */
@@ -15,9 +23,9 @@ export default {
15
23
  argTypes: {
16
24
  ...getArgTypes(UDot.__name),
17
25
  },
18
- };
26
+ } as Meta;
19
27
 
20
- const DefaultTemplate = (args) => ({
28
+ const DefaultTemplate: StoryFn<UDotArgs> = (args: UDotArgs) => ({
21
29
  components: { UDot },
22
30
  setup() {
23
31
  const slots = getSlotNames(UDot.__name);
@@ -26,17 +34,17 @@ const DefaultTemplate = (args) => ({
26
34
  },
27
35
  template: `
28
36
  <UDot v-bind="args">
29
- ${args.slotTemplate || getSlotsFragment()}
37
+ ${args.slotTemplate || getSlotsFragment("")}
30
38
  </UDot>
31
39
  `,
32
40
  });
33
41
 
34
- const EnumVariantTemplate = (args, { argTypes }) => ({
42
+ const EnumVariantTemplate: StoryFn<UDotArgs> = (args: UDotArgs, { argTypes }) => ({
35
43
  components: { UCol, URow, UDot, UBadge },
36
44
  setup() {
37
45
  return {
38
46
  args,
39
- options: argTypes[args.enum].options,
47
+ options: argTypes?.[args.enum]?.options,
40
48
  };
41
49
  },
42
50
  template: `
@@ -0,0 +1,46 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UDotProps {
6
+ /**
7
+ * Dot color.
8
+ */
9
+ color?:
10
+ | "brand"
11
+ | "grayscale"
12
+ | "gray"
13
+ | "red"
14
+ | "orange"
15
+ | "amber"
16
+ | "yellow"
17
+ | "lime"
18
+ | "green"
19
+ | "emerald"
20
+ | "teal"
21
+ | "cyan"
22
+ | "sky"
23
+ | "blue"
24
+ | "indigo"
25
+ | "violet"
26
+ | "purple"
27
+ | "fuchsia"
28
+ | "pink"
29
+ | "rose"
30
+ | "white";
31
+
32
+ /**
33
+ * Dot size.
34
+ */
35
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
36
+
37
+ /**
38
+ * Component config object.
39
+ */
40
+ config?: Partial<typeof defaultConfig>;
41
+
42
+ /**
43
+ * Data-test attribute for automated testing.
44
+ */
45
+ dataTest?: string;
46
+ }
@@ -0,0 +1,18 @@
1
+ import useUI from "../composables/useUI.ts";
2
+
3
+ import defaultConfig from "./config.ts";
4
+
5
+ import type { UseAttrs } from "../types.ts";
6
+ import type { UDotProps, Config } from "./types.ts";
7
+
8
+ export default function useAttrs(props: UDotProps): UseAttrs<Config> {
9
+ const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
10
+
11
+ const keysAttrs = getKeysAttrs();
12
+
13
+ return {
14
+ config,
15
+ ...keysAttrs,
16
+ hasSlotContent,
17
+ };
18
+ }
@@ -1,3 +1,88 @@
1
+ <script lang="ts" setup>
2
+ import { onMounted, ref, computed } from "vue";
3
+ import { getDefault } from "../utils/ui.ts";
4
+
5
+ import UIcon from "../ui.image-icon/UIcon.vue";
6
+ import UButton from "../ui.button/UButton.vue";
7
+ import UText from "../ui.text-block/UText.vue";
8
+
9
+ import { UAlert } from "./constants.ts";
10
+ import defaultConfig from "./config.ts";
11
+ import useAttrs from "./useAttrs.ts";
12
+
13
+ import type { UAlertProps } from "./types.ts";
14
+
15
+ defineOptions({ inheritAttrs: false });
16
+
17
+ const props = withDefaults(defineProps<UAlertProps>(), {
18
+ variant: getDefault<UAlertProps>(defaultConfig, UAlert).variant,
19
+ bordered: getDefault<UAlertProps>(defaultConfig, UAlert).bordered,
20
+ size: getDefault<UAlertProps>(defaultConfig, UAlert).size,
21
+ color: getDefault<UAlertProps>(defaultConfig, UAlert).color,
22
+ timeout: getDefault<UAlertProps>(defaultConfig, UAlert).timeout,
23
+ closable: getDefault<UAlertProps>(defaultConfig, UAlert).closable,
24
+ dataTest: "",
25
+ });
26
+
27
+ const emit = defineEmits([
28
+ /**
29
+ * Triggers when the alert is hidden.
30
+ */
31
+ "hidden",
32
+ ]);
33
+
34
+ const isShownAlert = ref(true);
35
+
36
+ const {
37
+ config,
38
+ wrapperAttrs,
39
+ bodyAttrs,
40
+ contentAttrs,
41
+ textAttrs,
42
+ titleAttrs,
43
+ descriptionAttrs,
44
+ closeButtonAttrs,
45
+ closeIconAttrs,
46
+ contentWrapperAttrs,
47
+ hasSlotContent,
48
+ } = useAttrs(props);
49
+
50
+ onMounted(() => {
51
+ if (props.timeout > 0) {
52
+ setTimeout(() => onClickClose(), props.timeout);
53
+ }
54
+ });
55
+
56
+ function onClickClose() {
57
+ isShownAlert.value = false;
58
+ emit("hidden");
59
+ }
60
+
61
+ const closeIconSize = computed(() => {
62
+ const sizes = {
63
+ xs: "3xs",
64
+ sm: "2xs",
65
+ md: "xs",
66
+ lg: "sm",
67
+ };
68
+
69
+ return sizes[props.size];
70
+ });
71
+
72
+ const closeButtonColor = computed(() => {
73
+ if (props.color === "grayscale") return "white";
74
+ if (props.color === "white") return "grayscale";
75
+
76
+ return props.color;
77
+ });
78
+
79
+ const iconColor = computed(() => {
80
+ if (props.color === "white") return "gray";
81
+
82
+ return props.variant === "primary" ? "white" : props.color;
83
+ });
84
+ </script>
85
+
1
86
  <template>
2
87
  <div v-if="isShownAlert" :data-test="dataTest" v-bind="wrapperAttrs">
3
88
  <!-- @slot Use it to add something above the text. -->
@@ -76,160 +161,3 @@
76
161
  <slot name="bottom" />
77
162
  </div>
78
163
  </template>
79
-
80
- <script setup>
81
- import { onMounted, ref, computed } from "vue";
82
-
83
- import UIcon from "../ui.image-icon/UIcon.vue";
84
- import UButton from "../ui.button/UButton.vue";
85
- import UText from "../ui.text-block/UText.vue";
86
- import { getDefault } from "../utils/ui.ts";
87
-
88
- import { UAlert } from "./constants.js";
89
- import defaultConfig from "./config.js";
90
- import useAttrs from "./useAttrs.js";
91
-
92
- defineOptions({ inheritAttrs: false });
93
-
94
- const props = defineProps({
95
- /**
96
- * Alert title.
97
- */
98
- title: {
99
- type: String,
100
- default: "",
101
- },
102
-
103
- /**
104
- * Alert description.
105
- */
106
- description: {
107
- type: String,
108
- default: "",
109
- },
110
-
111
- /**
112
- * Alert variant.
113
- * @values primary, secondary, thirdary
114
- */
115
- variant: {
116
- type: String,
117
- default: getDefault(defaultConfig, UAlert).variant,
118
- },
119
-
120
- /**
121
- * Add border to the `thirdary` variant.
122
- */
123
- bordered: {
124
- type: Boolean,
125
- default: getDefault(defaultConfig, UAlert).bordered,
126
- },
127
-
128
- /**
129
- * Alert size.
130
- * @values xs, sm, md, lg
131
- */
132
- size: {
133
- type: String,
134
- default: getDefault(defaultConfig, UAlert).size,
135
- },
136
-
137
- /**
138
- * Alert color.
139
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white */
140
- color: {
141
- type: String,
142
- default: getDefault(defaultConfig, UAlert).color,
143
- },
144
-
145
- /**
146
- * Alert timeout.
147
- */
148
- timeout: {
149
- type: Number,
150
- default: getDefault(defaultConfig, UAlert).timeout,
151
- },
152
-
153
- /**
154
- * Show close button.
155
- */
156
- closable: {
157
- type: Boolean,
158
- default: getDefault(defaultConfig, UAlert).closable,
159
- },
160
-
161
- /**
162
- * Component config object.
163
- */
164
- config: {
165
- type: Object,
166
- default: () => ({}),
167
- },
168
-
169
- /**
170
- * Data-test attribute for automated testing.
171
- */
172
- dataTest: {
173
- type: String,
174
- default: "",
175
- },
176
- });
177
-
178
- const emit = defineEmits([
179
- /**
180
- * Triggers when the alert is hidden.
181
- */
182
- "hidden",
183
- ]);
184
-
185
- const isShownAlert = ref(true);
186
-
187
- const {
188
- config,
189
- wrapperAttrs,
190
- bodyAttrs,
191
- contentAttrs,
192
- textAttrs,
193
- titleAttrs,
194
- descriptionAttrs,
195
- closeButtonAttrs,
196
- closeIconAttrs,
197
- contentWrapperAttrs,
198
- hasSlotContent,
199
- } = useAttrs(props);
200
-
201
- onMounted(() => {
202
- if (props.timeout > 0) {
203
- setTimeout(() => onClickClose(), props.timeout);
204
- }
205
- });
206
-
207
- function onClickClose() {
208
- isShownAlert.value = false;
209
- emit("hidden");
210
- }
211
-
212
- const closeIconSize = computed(() => {
213
- const sizes = {
214
- xs: "3xs",
215
- sm: "2xs",
216
- md: "xs",
217
- lg: "sm",
218
- };
219
-
220
- return sizes[props.size];
221
- });
222
-
223
- const closeButtonColor = computed(() => {
224
- if (props.color === "grayscale") return "white";
225
- if (props.color === "white") return "grayscale";
226
-
227
- return props.color;
228
- });
229
-
230
- const iconColor = computed(() => {
231
- if (props.color === "white") return "gray";
232
-
233
- return props.variant === "primary" ? "white" : props.color;
234
- });
235
- </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} />
@@ -6,6 +6,14 @@ import UCol from "../../ui.container-col/UCol.vue";
6
6
  import UIcon from "../../ui.image-icon/UIcon.vue";
7
7
  import UButton from "../../ui.button/UButton.vue";
8
8
 
9
+ import type { Meta, StoryFn } from "@storybook/vue3";
10
+ import type { UAlertProps } from "../types.ts";
11
+
12
+ interface UAlertArgs extends UAlertProps {
13
+ slotTemplate?: string;
14
+ enum: "size" | "color" | "variant";
15
+ }
16
+
9
17
  /**
10
18
  * The `UAlert` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-alert)
11
19
  */
@@ -20,9 +28,9 @@ export default {
20
28
  argTypes: {
21
29
  ...getArgTypes(UAlert.__name),
22
30
  },
23
- };
31
+ } as Meta;
24
32
 
25
- const DefaultTemplate = (args) => ({
33
+ const DefaultTemplate: StoryFn<UAlertArgs> = (args: UAlertArgs) => ({
26
34
  components: { UAlert, UIcon, URow, UButton },
27
35
  setup() {
28
36
  const slots = getSlotNames(UAlert.__name);
@@ -31,25 +39,25 @@ const DefaultTemplate = (args) => ({
31
39
  },
32
40
  template: `
33
41
  <UAlert v-bind="args">
34
- ${args.slotTemplate || getSlotsFragment()}
42
+ ${args.slotTemplate || getSlotsFragment("")}
35
43
  </UAlert>
36
44
  `,
37
45
  });
38
46
 
39
- const EnumVariantTemplate = (args, { argTypes }) => ({
47
+ const EnumVariantTemplate: StoryFn<UAlertArgs> = (args: UAlertArgs, { argTypes }) => ({
40
48
  components: { UAlert, UCol },
41
49
  setup() {
42
- function getText(value) {
50
+ function getText(value: string) {
43
51
  return `This is Alert's ${value} size`;
44
52
  }
45
53
 
46
- let prefixedOptions = argTypes[args.enum].options;
54
+ let prefixedOptions = argTypes?.[args.enum]?.options;
47
55
 
48
- if (argTypes[args.enum].name === "size") {
49
- prefixedOptions = prefixedOptions.map((option) => getText(option));
56
+ if (argTypes?.[args.enum]?.name === "size") {
57
+ prefixedOptions = prefixedOptions?.map((option) => getText(option));
50
58
  }
51
59
 
52
- return { args, options: argTypes[args.enum].options, prefixedOptions };
60
+ return { args, options: argTypes?.[args.enum]?.options, prefixedOptions };
53
61
  },
54
62
  template: `
55
63
  <UCol align="stretch">