vueless 0.0.532 → 0.0.534

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 (51) hide show
  1. package/package.json +1 -1
  2. package/types.ts +12 -0
  3. package/ui.data-table/UTable.vue +16 -7
  4. package/ui.data-table/UTableRow.vue +0 -2
  5. package/ui.data-table/utilTable.ts +5 -1
  6. package/ui.image-avatar/UAvatar.vue +51 -115
  7. package/ui.image-avatar/storybook/Docs.mdx +2 -2
  8. package/ui.image-avatar/storybook/{stories.js → stories.ts} +13 -5
  9. package/ui.image-avatar/types.ts +71 -0
  10. package/ui.image-avatar/useAttrs.ts +18 -0
  11. package/ui.image-icon/UIcon.vue +28 -113
  12. package/ui.image-icon/storybook/Docs.mdx +1 -1
  13. package/ui.image-icon/storybook/{stories.js → stories.ts} +13 -5
  14. package/ui.image-icon/types.ts +83 -0
  15. package/ui.image-icon/useAttrs.ts +18 -0
  16. package/ui.navigation-pagination/UPagination.vue +141 -262
  17. package/ui.navigation-pagination/storybook/Docs.mdx +2 -2
  18. package/ui.navigation-pagination/storybook/{stories.js → stories.ts} +11 -4
  19. package/ui.navigation-pagination/types.ts +85 -0
  20. package/ui.navigation-pagination/{useAttrs.js → useAttrs.ts} +5 -2
  21. package/ui.navigation-progress/StepperProgress.vue +26 -47
  22. package/ui.navigation-progress/UProgress.vue +60 -118
  23. package/ui.navigation-progress/{config.js → config.ts} +1 -0
  24. package/ui.navigation-progress/storybook/Docs.mdx +2 -2
  25. package/ui.navigation-progress/storybook/{stories.js → stories.ts} +19 -7
  26. package/ui.navigation-progress/types.ts +93 -0
  27. package/ui.navigation-progress/{useAttrs.js → useAttrs.ts} +6 -3
  28. package/ui.navigation-tab/UTab.vue +18 -54
  29. package/ui.navigation-tab/storybook/Docs.mdx +2 -2
  30. package/ui.navigation-tab/storybook/{stories.js → stories.ts} +10 -5
  31. package/ui.navigation-tab/types.ts +30 -0
  32. package/ui.navigation-tab/{useAttrs.js → useAttrs.ts} +15 -3
  33. package/ui.navigation-tabs/UTabs.vue +29 -78
  34. package/ui.navigation-tabs/storybook/Docs.mdx +2 -2
  35. package/ui.navigation-tabs/storybook/{stories.js → stories.ts} +13 -5
  36. package/ui.navigation-tabs/types.ts +37 -0
  37. package/ui.navigation-tabs/useAttrs.ts +18 -0
  38. package/web-types.json +146 -77
  39. package/ui.image-avatar/useAttrs.js +0 -15
  40. package/ui.image-icon/useAttrs.js +0 -15
  41. package/ui.navigation-tabs/useAttrs.js +0 -15
  42. /package/ui.image-avatar/{config.js → config.ts} +0 -0
  43. /package/ui.image-avatar/{constants.js → constants.ts} +0 -0
  44. /package/ui.image-icon/{constants.js → constants.ts} +0 -0
  45. /package/ui.navigation-pagination/{config.js → config.ts} +0 -0
  46. /package/ui.navigation-pagination/{constants.js → constants.ts} +0 -0
  47. /package/ui.navigation-progress/{constants.js → constants.ts} +0 -0
  48. /package/ui.navigation-tab/{config.js → config.ts} +0 -0
  49. /package/ui.navigation-tab/{constants.js → constants.ts} +0 -0
  50. /package/ui.navigation-tabs/{config.js → config.ts} +0 -0
  51. /package/ui.navigation-tabs/{constants.js → constants.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.532",
3
+ "version": "0.0.534",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/types.ts CHANGED
@@ -35,6 +35,12 @@ import URowConfig from "./ui.container-row/config.ts";
35
35
  import ULoaderConfig from "./ui.loader/config.ts";
36
36
  import ULoaderOverlayConfig from "./ui.loader-overlay/config.ts";
37
37
  import ULoaderProgressConfig from "./ui.loader-progress/config.ts";
38
+ import UPaginationConfig from "./ui.navigation-pagination/config.ts";
39
+ import UProgressConfig from "./ui.navigation-progress/config.ts";
40
+ import UTabConfig from "./ui.navigation-tab/config.ts";
41
+ import UTabsConfig from "./ui.navigation-tabs/config.ts";
42
+ import UAvatarConfig from "./ui.image-avatar/config.ts";
43
+ import UIconConfig from "./ui.image-icon/config.ts";
38
44
 
39
45
  import type { ComputedRef, MaybeRef, Ref } from "vue";
40
46
  import type { Props } from "tippy.js";
@@ -181,6 +187,12 @@ export interface Components {
181
187
  ULoader?: Partial<typeof ULoaderConfig>;
182
188
  ULoaderOverlay?: Partial<typeof ULoaderOverlayConfig>;
183
189
  ULoaderProgress?: Partial<typeof ULoaderProgressConfig>;
190
+ UPagination?: Partial<typeof UPaginationConfig>;
191
+ UProgress?: Partial<typeof UProgressConfig>;
192
+ UTab?: Partial<typeof UTabConfig>;
193
+ UTabs?: Partial<typeof UTabsConfig>;
194
+ UAvatar?: Partial<typeof UAvatarConfig>;
195
+ UIcon?: Partial<typeof UIconConfig>;
184
196
  }
185
197
 
186
198
  export interface Directives {
@@ -3,7 +3,6 @@ import {
3
3
  ref,
4
4
  computed,
5
5
  watch,
6
- toValue,
7
6
  useSlots,
8
7
  nextTick,
9
8
  onMounted,
@@ -39,6 +38,7 @@ import { useLocale } from "../composables/useLocale.ts";
39
38
 
40
39
  import type { Cell, Row, RowId, UTableProps, UTableRowAttrs } from "./types.ts";
41
40
  import type { Ref, RendererElement, ComputedRef } from "vue";
41
+ import { isEqual } from "lodash-es";
42
42
 
43
43
  defineOptions({ inheritAttrs: false });
44
44
 
@@ -254,7 +254,15 @@ const tableRowAttrs = computed(() => ({
254
254
 
255
255
  watch(selectAll, onChangeSelectAll, { deep: true });
256
256
  watch(selectedRows, onChangeSelectedRows, { deep: true });
257
- watch(tableRows, () => emit("update:rows", toValue(tableRows)), { deep: true });
257
+ watch(
258
+ tableRows,
259
+ () => {
260
+ if (!isEqual(tableRows.value, props.rows)) {
261
+ emit("update:rows", tableRows.value);
262
+ }
263
+ },
264
+ { deep: true },
265
+ );
258
266
  watch(() => tableRows.value.length, updateSelectedRows);
259
267
  watch(() => props.rows, synchronizeTableItemsWithProps, { deep: true });
260
268
  watch(isHeaderSticky, setHeaderCellWidth);
@@ -337,7 +345,9 @@ function synchronizeTableItemsWithProps() {
337
345
  selectedRows.value = [];
338
346
  }
339
347
 
340
- tableRows.value = props.rows;
348
+ if (!isEqual(tableRows.value, props.rows)) {
349
+ tableRows.value = props.rows;
350
+ }
341
351
  }
342
352
 
343
353
  function updateSelectedRows() {
@@ -379,11 +389,11 @@ function onChangeSelectAll(selectAll: boolean) {
379
389
  if (selectAll && canSelectAll.value) {
380
390
  selectedRows.value = getFlatRows(tableRows.value).map((row) => row.id);
381
391
 
382
- tableRows.value.forEach((row) => switchRowCheck(row, true));
392
+ tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, true));
383
393
  } else if (!selectAll) {
384
394
  selectedRows.value = [];
385
395
 
386
- tableRows.value.forEach((row) => switchRowCheck(row, false));
396
+ tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, false));
387
397
  }
388
398
 
389
399
  canSelectAll.value = true;
@@ -406,8 +416,7 @@ function clearSelectedItems() {
406
416
  }
407
417
 
408
418
  function onToggleRowVisibility(rowId: string | number) {
409
- // TODO: Use map instead of forEach to get rid of implicit array mutation.
410
- tableRows.value.forEach((row) => toggleRowVisibility(row, rowId));
419
+ tableRows.value = tableRows.value.map((row) => toggleRowVisibility({ ...row }, rowId));
411
420
  }
412
421
 
413
422
  defineExpose({
@@ -290,8 +290,6 @@ function getRowAttrs(rowId: string | number) {
290
290
  :data-test="`${dataTest}-${key}-cell`"
291
291
  >
292
292
  {{ formatCellValue(value) }}
293
-
294
- {{ nestedRows }}
295
293
  </div>
296
294
  </slot>
297
295
  </template>
@@ -50,7 +50,7 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
50
50
  row.nestedData.isHidden = !row.nestedData.isHidden;
51
51
  }
52
52
 
53
- return;
53
+ return row;
54
54
  }
55
55
 
56
56
  if (row.row && !Array.isArray(row.row)) {
@@ -64,6 +64,8 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
64
64
  if (row.nestedData) {
65
65
  toggleRowVisibility(row.nestedData, targetRowId);
66
66
  }
67
+
68
+ return row;
67
69
  }
68
70
 
69
71
  export function switchRowCheck(row: Row, isChecked: boolean) {
@@ -76,6 +78,8 @@ export function switchRowCheck(row: Row, isChecked: boolean) {
76
78
  if (row.row && Array.isArray(row.row)) {
77
79
  row.row.map((currentRow) => switchRowCheck(currentRow, isChecked));
78
80
  }
81
+
82
+ return row;
79
83
  }
80
84
 
81
85
  export function getFlatRows(tableRows: Row[]) {
@@ -1,125 +1,24 @@
1
- <template>
2
- <div
3
- :title="label"
4
- :style="backgroundImage"
5
- :data-test="dataTest"
6
- v-bind="avatarAttrs"
7
- @click="onClick"
8
- >
9
- <template v-if="!backgroundImage">
10
- <template v-if="labelFirstLetters">{{ labelFirstLetters }}</template>
11
- <!--
12
- @slot Use it to add something instead of the avatar image placeholder.
13
- @binding {string} icon-name
14
- @binding {string} icon-color
15
- @binding {string} icon-size
16
- -->
17
- <slot
18
- v-else
19
- name="placeholder"
20
- :icon-name="placeholderIcon"
21
- :icon-color="componentColor"
22
- :icon-size="size"
23
- >
24
- <UIcon
25
- internal
26
- :size="size"
27
- :color="componentColor"
28
- :name="placeholderIcon"
29
- v-bind="placeholderIconAttrs"
30
- />
31
- </slot>
32
- </template>
33
- </div>
34
- </template>
35
-
36
- <script setup>
1
+ <script lang="ts" setup>
37
2
  import { computed } from "vue";
38
3
 
39
4
  import UIcon from "../ui.image-icon/UIcon.vue";
40
5
  import { getDefault } from "../utils/ui.ts";
41
6
 
42
- import { UAvatar } from "./constants.js";
43
- import defaultConfig from "./config.js";
44
- import useAttrs from "./useAttrs.js";
45
-
46
- defineOptions({ inheritAttrs: false });
47
-
48
- const props = defineProps({
49
- /**
50
- * Avatar image source.
51
- */
52
- src: {
53
- type: String,
54
- default: "",
55
- },
56
-
57
- /**
58
- * Avatar label (username, nickname, etc.).
59
- */
60
- label: {
61
- type: String,
62
- default: "",
63
- },
64
-
65
- /**
66
- * Avatar placeholder icon.
67
- */
68
- placeholderIcon: {
69
- type: String,
70
- default: getDefault(defaultConfig, UAvatar).placeholderIcon,
71
- },
72
-
73
- /**
74
- * Avatar size.
75
- * @values 3xs, 2xs, xs, sm, md, lg, xl, 2xl, 3xl
76
- */
77
- size: {
78
- type: String,
79
- default: getDefault(defaultConfig, UAvatar).size,
80
- },
81
-
82
- /**
83
- * Avatar color.
84
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
85
- */
86
- color: {
87
- type: String,
88
- default: getDefault(defaultConfig, UAvatar).color,
89
- },
7
+ import { UAvatar } from "./constants.ts";
8
+ import defaultConfig from "./config.ts";
9
+ import useAttrs from "./useAttrs.ts";
90
10
 
91
- /**
92
- * Avatar corner rounding.
93
- * @values dynamic, none, sm, md, lg, full
94
- */
95
- rounded: {
96
- type: String,
97
- default: getDefault(defaultConfig, UAvatar).rounded,
98
- },
11
+ import type { UAvatarProps } from "./types.ts";
99
12
 
100
- /**
101
- * Add border to the avatar.
102
- */
103
- bordered: {
104
- type: Boolean,
105
- default: getDefault(defaultConfig, UAvatar).bordered,
106
- },
107
-
108
- /**
109
- * Component config object.
110
- */
111
- config: {
112
- type: Object,
113
- default: () => ({}),
114
- },
13
+ defineOptions({ inheritAttrs: false });
115
14
 
116
- /**
117
- * Data-test attribute for automated testing.
118
- */
119
- dataTest: {
120
- type: String,
121
- default: "",
122
- },
15
+ const props = withDefaults(defineProps<UAvatarProps>(), {
16
+ placeholderIcon: getDefault<UAvatarProps>(defaultConfig, UAvatar).placeholderIcon,
17
+ size: getDefault<UAvatarProps>(defaultConfig, UAvatar).size,
18
+ color: getDefault<UAvatarProps>(defaultConfig, UAvatar).color,
19
+ rounded: getDefault<UAvatarProps>(defaultConfig, UAvatar).rounded,
20
+ bordered: getDefault<UAvatarProps>(defaultConfig, UAvatar).bordered,
21
+ dataTest: "",
123
22
  });
124
23
 
125
24
  const emit = defineEmits([
@@ -132,6 +31,8 @@ const emit = defineEmits([
132
31
  const { avatarAttrs, placeholderIconAttrs } = useAttrs(props);
133
32
 
134
33
  const labelFirstLetters = computed(() => {
34
+ if (!props.label) return "";
35
+
135
36
  const [firstWord, secondWord] = props.label.split(" ");
136
37
 
137
38
  const firstWordLetter = firstWord ? firstWord[0].toUpperCase() : "";
@@ -151,7 +52,42 @@ const componentColor = computed(() => {
151
52
  return props.color === "white" ? "grayscale" : props.color;
152
53
  });
153
54
 
154
- function onClick(event) {
55
+ function onClick(event: Event) {
155
56
  emit("click", event);
156
57
  }
157
58
  </script>
59
+
60
+ <template>
61
+ <div
62
+ :title="label"
63
+ :style="backgroundImage"
64
+ :data-test="dataTest"
65
+ v-bind="avatarAttrs"
66
+ @click="onClick"
67
+ >
68
+ <template v-if="!backgroundImage">
69
+ <template v-if="labelFirstLetters">{{ labelFirstLetters }}</template>
70
+ <!--
71
+ @slot Use it to add something instead of the avatar image placeholder.
72
+ @binding {string} icon-name
73
+ @binding {string} icon-color
74
+ @binding {string} icon-size
75
+ -->
76
+ <slot
77
+ v-else
78
+ name="placeholder"
79
+ :icon-name="placeholderIcon"
80
+ :icon-color="componentColor"
81
+ :icon-size="size"
82
+ >
83
+ <UIcon
84
+ internal
85
+ :size="size"
86
+ :color="componentColor"
87
+ :name="placeholderIcon"
88
+ v-bind="placeholderIconAttrs"
89
+ />
90
+ </slot>
91
+ </template>
92
+ </div>
93
+ </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 ULoader from "../../ui.loader/ULoader.vue";
7
7
 
8
+ import type { Meta, StoryFn } from "@storybook/vue3";
9
+ import type { UAvatarProps } from "../types.ts";
10
+
11
+ interface UAvatarArgs extends UAvatarProps {
12
+ slotTemplate?: string;
13
+ enum: "size" | "rounded" | "color";
14
+ }
15
+
8
16
  /**
9
17
  * The `UAvatar` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.image-avatar)
10
18
  */
@@ -15,9 +23,9 @@ export default {
15
23
  argTypes: {
16
24
  ...getArgTypes(UAvatar.__name),
17
25
  },
18
- };
26
+ } as Meta;
19
27
 
20
- const DefaultTemplate = (args) => ({
28
+ const DefaultTemplate: StoryFn<UAvatarArgs> = (args: UAvatarArgs) => ({
21
29
  components: { UAvatar, ULoader },
22
30
  setup() {
23
31
  const slots = getSlotNames(UAvatar.__name);
@@ -26,17 +34,17 @@ const DefaultTemplate = (args) => ({
26
34
  },
27
35
  template: `
28
36
  <UAvatar v-bind="args">
29
- ${args.slotTemplate || getSlotsFragment()}
37
+ ${args.slotTemplate || getSlotsFragment("")}
30
38
  </UAvatar>
31
39
  `,
32
40
  });
33
41
 
34
- const EnumVariantTemplate = (args, { argTypes }) => ({
42
+ const EnumVariantTemplate: StoryFn<UAvatarArgs> = (args: UAvatarArgs, { argTypes }) => ({
35
43
  components: { UCol, URow, UAvatar },
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,71 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UAvatarProps {
6
+ /**
7
+ * Avatar image source.
8
+ */
9
+ src?: string;
10
+
11
+ /**
12
+ * Avatar label (username, nickname, etc.).
13
+ */
14
+ label?: string;
15
+
16
+ /**
17
+ * Avatar placeholder icon.
18
+ */
19
+ placeholderIcon?: string;
20
+
21
+ /**
22
+ * Avatar size.
23
+ */
24
+ size?: "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
25
+
26
+ /**
27
+ * Avatar color.
28
+ */
29
+ color?:
30
+ | "brand"
31
+ | "grayscale"
32
+ | "gray"
33
+ | "red"
34
+ | "orange"
35
+ | "amber"
36
+ | "yellow"
37
+ | "lime"
38
+ | "green"
39
+ | "emerald"
40
+ | "teal"
41
+ | "cyan"
42
+ | "sky"
43
+ | "blue"
44
+ | "indigo"
45
+ | "violet"
46
+ | "purple"
47
+ | "fuchsia"
48
+ | "pink"
49
+ | "rose"
50
+ | "white";
51
+
52
+ /**
53
+ * Avatar corner rounding.
54
+ */
55
+ rounded?: "dynamic" | "none" | "sm" | "md" | "lg" | "full";
56
+
57
+ /**
58
+ * Add border to the avatar.
59
+ */
60
+ bordered?: boolean;
61
+
62
+ /**
63
+ * Component config object.
64
+ */
65
+ config?: Partial<typeof defaultConfig>;
66
+
67
+ /**
68
+ * Data-test attribute for automated testing.
69
+ */
70
+ dataTest?: string;
71
+ }
@@ -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 { UAvatarProps, Config } from "./types.ts";
7
+
8
+ export default function useAttrs(props: UAvatarProps): 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,120 +1,24 @@
1
- <template>
2
- <component
3
- :is="dynamicComponent"
4
- v-tooltip="tooltipConfig"
5
- tabindex="-1"
6
- v-bind="iconAttrs"
7
- :data-test="dataTest"
8
- @click="onClick"
9
- />
10
- </template>
11
-
12
- <script setup>
1
+ <script lang="ts" setup>
13
2
  import { computed, defineAsyncComponent } from "vue";
14
3
  import { vTooltip } from "../directives";
15
4
  import { getDefault } from "../utils/ui.ts";
16
5
  import { isSSR } from "../utils/helper.ts";
17
6
  import { VUELESS_ICONS_CACHED_DIR, VUELESS_LIBRARY } from "../constants.js";
18
7
 
19
- import { UIcon } from "./constants.js";
8
+ import { UIcon } from "./constants.ts";
20
9
  import defaultConfig from "./config.ts";
21
- import useAttrs from "./useAttrs.js";
22
-
23
- defineOptions({ inheritAttrs: false });
24
-
25
- const props = defineProps({
26
- /**
27
- * Icon name.
28
- */
29
- name: {
30
- type: String,
31
- default: "",
32
- },
33
-
34
- /**
35
- * Icon source (svg as a vue component).
36
- */
37
- src: {
38
- type: Object,
39
- default: () => {},
40
- },
41
-
42
- /**
43
- * Icon color.
44
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, black, white
45
- */
46
- color: {
47
- type: String,
48
- default: getDefault(defaultConfig, UIcon).color,
49
- },
10
+ import useAttrs from "./useAttrs.ts";
50
11
 
51
- /**
52
- * Icon size.
53
- * @values 4xs, 3xs, 2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl
54
- */
55
- size: {
56
- type: String,
57
- default: getDefault(defaultConfig, UIcon).size,
58
- },
12
+ import type { UIconProps } from "./types.ts";
59
13
 
60
- /**
61
- * Icon variant.
62
- * @values light, default, dark
63
- */
64
- variant: {
65
- type: String,
66
- default: getDefault(defaultConfig, UIcon).variant,
67
- },
68
-
69
- /**
70
- * Make the icon interactive (cursor pointer, etc.).
71
- */
72
- interactive: {
73
- type: Boolean,
74
- default: getDefault(defaultConfig, UIcon).interactive,
75
- },
76
-
77
- /**
78
- * Add tooltip text on hover.
79
- */
80
- tooltip: {
81
- type: String,
82
- default: "",
83
- },
84
-
85
- /**
86
- * Tooltip settings.
87
- * [See all settings here](https://kabbouchi.github.io/vue-tippy/4.0/features/placement.html).
88
- */
89
- tooltipSettings: {
90
- type: Object,
91
- default: () => {},
92
- },
93
-
94
- /**
95
- * Component config object.
96
- */
97
- config: {
98
- type: Object,
99
- default: () => ({}),
100
- },
101
-
102
- /**
103
- * Data-test attribute for automated testing.
104
- */
105
- dataTest: {
106
- type: String,
107
- default: "",
108
- },
14
+ defineOptions({ inheritAttrs: false });
109
15
 
110
- /**
111
- * Mark that Icon used inside Vueless components (used to get icons from vueless library).
112
- * @ignore
113
- */
114
- internal: {
115
- type: Boolean,
116
- default: false,
117
- },
16
+ const props = withDefaults(defineProps<UIconProps>(), {
17
+ color: getDefault<UIconProps>(defaultConfig, UIcon).color,
18
+ size: getDefault<UIconProps>(defaultConfig, UIcon).size,
19
+ variant: getDefault<UIconProps>(defaultConfig, UIcon).variant,
20
+ interactive: getDefault<UIconProps>(defaultConfig, UIcon).interactive,
21
+ dataTest: "",
118
22
  });
119
23
 
120
24
  const emit = defineEmits([
@@ -144,11 +48,11 @@ const dynamicComponent = computed(() => {
144
48
  generatedIcons.value.find(([path]) => path.includes(VUELESS_LIBRARY + "/" + props.name)),
145
49
  );
146
50
 
147
- const userLibrary = config.value.defaults.library;
51
+ const userLibrary = config.value?.defaults?.library;
148
52
  const library = props.internal && isInternalIcon ? VUELESS_LIBRARY : userLibrary;
149
- const weight = config.value.defaults.weight;
150
- const style = config.value.defaults.style;
151
- const isFill = props.name.endsWith(FILL_SUFFIX);
53
+ const weight = config.value?.defaults?.weight;
54
+ const style = config.value?.defaults?.style;
55
+ const isFill = props.name?.endsWith(FILL_SUFFIX);
152
56
  const name = props.name;
153
57
  const src = props.src;
154
58
 
@@ -161,7 +65,7 @@ const dynamicComponent = computed(() => {
161
65
  /* Dynamic import */
162
66
  if (!name) return "";
163
67
 
164
- function getIcon(params) {
68
+ function getIcon(params: Array<string | number | undefined>) {
165
69
  const [, component] =
166
70
  generatedIcons.value.find(([path]) =>
167
71
  params.every(
@@ -216,7 +120,18 @@ const tooltipConfig = computed(() => ({
216
120
  content: props.tooltip,
217
121
  }));
218
122
 
219
- function onClick(event) {
123
+ function onClick(event: Event) {
220
124
  emit("click", event);
221
125
  }
222
126
  </script>
127
+
128
+ <template>
129
+ <component
130
+ :is="dynamicComponent"
131
+ v-tooltip="tooltipConfig"
132
+ tabindex="-1"
133
+ v-bind="iconAttrs"
134
+ :data-test="dataTest"
135
+ @click="onClick"
136
+ />
137
+ </template>
@@ -1,7 +1,7 @@
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";
4
+ import * as stories from "./stories.ts";
5
5
  import defaultConfig from "../config.ts?raw"
6
6
 
7
7
  <Meta of={stories} />