@nuxt/ui 2.8.1 → 2.9.0

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 (103) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1147 -1096
  3. package/dist/module.d.ts +1147 -1096
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +35 -10
  6. package/dist/runtime/components/data/Table.vue +42 -29
  7. package/dist/runtime/components/data/Table.vue.d.ts +20 -13
  8. package/dist/runtime/components/elements/Accordion.vue +25 -22
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +21 -17
  10. package/dist/runtime/components/elements/Alert.vue +22 -18
  11. package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
  12. package/dist/runtime/components/elements/Avatar.vue +22 -16
  13. package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
  14. package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
  15. package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
  16. package/dist/runtime/components/elements/Badge.vue +21 -17
  17. package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
  18. package/dist/runtime/components/elements/Button.vue +22 -18
  19. package/dist/runtime/components/elements/Button.vue.d.ts +26 -17
  20. package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
  21. package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
  22. package/dist/runtime/components/elements/Dropdown.vue +15 -13
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +20 -17
  24. package/dist/runtime/components/elements/Kbd.vue +16 -12
  25. package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
  26. package/dist/runtime/components/elements/Link.vue +18 -5
  27. package/dist/runtime/components/forms/Checkbox.vue +27 -17
  28. package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
  29. package/dist/runtime/components/forms/Form.vue +2 -2
  30. package/dist/runtime/components/forms/FormGroup.vue +51 -27
  31. package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
  32. package/dist/runtime/components/forms/Input.vue +36 -28
  33. package/dist/runtime/components/forms/Input.vue.d.ts +41 -23
  34. package/dist/runtime/components/forms/Radio.vue +27 -17
  35. package/dist/runtime/components/forms/Radio.vue.d.ts +35 -17
  36. package/dist/runtime/components/forms/Range.vue +26 -16
  37. package/dist/runtime/components/forms/Range.vue.d.ts +36 -17
  38. package/dist/runtime/components/forms/Select.vue +34 -26
  39. package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
  40. package/dist/runtime/components/forms/SelectMenu.vue +43 -33
  41. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +49 -30
  42. package/dist/runtime/components/forms/Textarea.vue +38 -30
  43. package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -23
  44. package/dist/runtime/components/forms/Toggle.vue +26 -15
  45. package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
  46. package/dist/runtime/components/layout/Card.vue +15 -10
  47. package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
  48. package/dist/runtime/components/layout/Container.vue +15 -10
  49. package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
  50. package/dist/runtime/components/layout/Skeleton.vue +15 -10
  51. package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
  52. package/dist/runtime/components/navigation/CommandPalette.vue +50 -38
  53. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +23 -22
  54. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
  55. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
  56. package/dist/runtime/components/navigation/Pagination.vue +64 -55
  57. package/dist/runtime/components/navigation/Pagination.vue.d.ts +29 -22
  58. package/dist/runtime/components/navigation/Tabs.vue +16 -13
  59. package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
  60. package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
  61. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
  62. package/dist/runtime/components/overlays/ContextMenu.vue +14 -9
  63. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +18 -10
  64. package/dist/runtime/components/overlays/Modal.vue +15 -13
  65. package/dist/runtime/components/overlays/Modal.vue.d.ts +17 -10
  66. package/dist/runtime/components/overlays/Notification.vue +18 -14
  67. package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
  68. package/dist/runtime/components/overlays/Notifications.vue +18 -12
  69. package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
  70. package/dist/runtime/components/overlays/Popover.vue +18 -16
  71. package/dist/runtime/components/overlays/Popover.vue.d.ts +18 -11
  72. package/dist/runtime/components/overlays/Slideover.vue +15 -13
  73. package/dist/runtime/components/overlays/Slideover.vue.d.ts +17 -10
  74. package/dist/runtime/components/overlays/Tooltip.vue +15 -13
  75. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +18 -11
  76. package/dist/runtime/composables/useFormGroup.d.ts +12 -2
  77. package/dist/runtime/composables/useFormGroup.mjs +10 -4
  78. package/dist/runtime/composables/usePopper.mjs +40 -30
  79. package/dist/runtime/composables/useToast.d.ts +3 -3
  80. package/dist/runtime/composables/useUI.d.ts +10 -0
  81. package/dist/runtime/composables/useUI.mjs +24 -0
  82. package/dist/runtime/types/avatar.d.ts +10 -4
  83. package/dist/runtime/types/badge.d.ts +14 -0
  84. package/dist/runtime/types/button.d.ts +10 -3
  85. package/dist/runtime/types/command-palette.d.ts +2 -1
  86. package/dist/runtime/types/form.d.ts +8 -1
  87. package/dist/runtime/types/index.d.ts +2 -0
  88. package/dist/runtime/types/link.d.ts +1 -0
  89. package/dist/runtime/types/notification.d.ts +5 -3
  90. package/dist/runtime/types/tabs.d.ts +1 -0
  91. package/dist/runtime/types/utils.d.ts +11 -0
  92. package/dist/runtime/ui.config.d.ts +1207 -0
  93. package/dist/runtime/{app.config.mjs → ui.config.mjs} +52 -80
  94. package/dist/runtime/utils/index.d.ts +5 -11
  95. package/dist/runtime/utils/index.mjs +21 -9
  96. package/dist/runtime/utils/lodash.d.ts +2 -0
  97. package/dist/runtime/utils/lodash.mjs +23 -0
  98. package/dist/runtime/utils/uid.d.ts +1 -0
  99. package/dist/runtime/utils/uid.mjs +4 -0
  100. package/dist/types.d.mts +1 -1
  101. package/dist/types.d.ts +1 -1
  102. package/package.json +19 -21
  103. package/dist/runtime/app.config.d.ts +0 -1203
@@ -1,7 +1,5 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { Avatar } from '../../types/avatar';
4
- import type { Button } from '../../types/button';
2
+ import type { Avatar, Button } from '../../types';
5
3
  declare const _default: import("vue").DefineComponent<{
6
4
  title: {
7
5
  type: StringConstructor;
@@ -21,7 +19,7 @@ declare const _default: import("vue").DefineComponent<{
21
19
  };
22
20
  closeButton: {
23
21
  type: PropType<Button>;
24
- default: () => any;
22
+ default: () => Button;
25
23
  };
26
24
  actions: {
27
25
  type: PropType<(Button & {
@@ -30,24 +28,28 @@ declare const _default: import("vue").DefineComponent<{
30
28
  default: () => never[];
31
29
  };
32
30
  color: {
33
- type: StringConstructor;
31
+ type: PropType<any>;
34
32
  default: () => any;
35
33
  validator(value: string): boolean;
36
34
  };
37
35
  variant: {
38
- type: StringConstructor;
36
+ type: PropType<any>;
39
37
  default: () => any;
40
38
  validator(value: string): boolean;
41
39
  };
42
- ui: {
40
+ class: {
43
41
  type: PropType<any>;
44
- default: () => {};
42
+ default: undefined;
43
+ };
44
+ ui: {
45
+ type: PropType<Partial<any>>;
46
+ default: undefined;
45
47
  };
46
48
  }, {
47
- attrs: import("lodash").Omit<{
48
- [x: string]: unknown;
49
- }, "class">;
50
49
  ui: import("vue").ComputedRef<any>;
50
+ attrs: import("vue").ComputedRef<Pick<{
51
+ [x: string]: unknown;
52
+ }, string>>;
51
53
  alertClass: import("vue").ComputedRef<string>;
52
54
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "close"[], "close", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
53
55
  title: {
@@ -68,7 +70,7 @@ declare const _default: import("vue").DefineComponent<{
68
70
  };
69
71
  closeButton: {
70
72
  type: PropType<Button>;
71
- default: () => any;
73
+ default: () => Button;
72
74
  };
73
75
  actions: {
74
76
  type: PropType<(Button & {
@@ -77,18 +79,22 @@ declare const _default: import("vue").DefineComponent<{
77
79
  default: () => never[];
78
80
  };
79
81
  color: {
80
- type: StringConstructor;
82
+ type: PropType<any>;
81
83
  default: () => any;
82
84
  validator(value: string): boolean;
83
85
  };
84
86
  variant: {
85
- type: StringConstructor;
87
+ type: PropType<any>;
86
88
  default: () => any;
87
89
  validator(value: string): boolean;
88
90
  };
89
- ui: {
91
+ class: {
90
92
  type: PropType<any>;
91
- default: () => {};
93
+ default: undefined;
94
+ };
95
+ ui: {
96
+ type: PropType<Partial<any>>;
97
+ default: undefined;
92
98
  };
93
99
  }>> & {
94
100
  onClose?: ((...args: any[]) => any) | undefined;
@@ -100,8 +106,9 @@ declare const _default: import("vue").DefineComponent<{
100
106
  actions: (Button & {
101
107
  click?: Function | undefined;
102
108
  })[];
103
- color: string;
104
- ui: any;
105
- variant: string;
109
+ color: any;
110
+ ui: Partial<any>;
111
+ class: any;
112
+ variant: any;
106
113
  }, {}>;
107
114
  export default _default;
@@ -20,13 +20,14 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
- import { defineComponent, ref, computed, watch } from "vue";
23
+ import { defineComponent, ref, computed, toRef, watch } from "vue";
24
24
  import { twMerge, twJoin } from "tailwind-merge";
25
25
  import UIcon from "../elements/Icon.vue";
26
- import { defuTwMerge } from "../../utils";
27
- import { useAppConfig } from "#imports";
26
+ import { useUI } from "../../composables/useUI";
27
+ import { mergeConfig } from "../../utils";
28
28
  import appConfig from "#build/app.config";
29
- import { omit } from "lodash-es";
29
+ import { avatar } from "#ui/ui.config";
30
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.avatar, avatar);
30
31
  export default defineComponent({
31
32
  components: {
32
33
  UIcon
@@ -47,27 +48,27 @@ export default defineComponent({
47
48
  },
48
49
  icon: {
49
50
  type: String,
50
- default: () => appConfig.ui.avatar.default.icon
51
+ default: () => config.default.icon
51
52
  },
52
53
  size: {
53
54
  type: String,
54
- default: () => appConfig.ui.avatar.default.size,
55
+ default: () => config.default.size,
55
56
  validator(value) {
56
- return Object.keys(appConfig.ui.avatar.size).includes(value);
57
+ return Object.keys(config.size).includes(value);
57
58
  }
58
59
  },
59
60
  chipColor: {
60
61
  type: String,
61
- default: () => appConfig.ui.avatar.default.chipColor,
62
+ default: () => config.default.chipColor,
62
63
  validator(value) {
63
64
  return ["gray", ...appConfig.ui.colors].includes(value);
64
65
  }
65
66
  },
66
67
  chipPosition: {
67
68
  type: String,
68
- default: () => appConfig.ui.avatar.default.chipPosition,
69
+ default: () => config.default.chipPosition,
69
70
  validator(value) {
70
- return Object.keys(appConfig.ui.avatar.chip.position).includes(value);
71
+ return Object.keys(config.chip.position).includes(value);
71
72
  }
72
73
  },
73
74
  chipText: {
@@ -78,14 +79,17 @@ export default defineComponent({
78
79
  type: String,
79
80
  default: ""
80
81
  },
82
+ class: {
83
+ type: [String, Object, Array],
84
+ default: void 0
85
+ },
81
86
  ui: {
82
87
  type: Object,
83
- default: () => ({})
88
+ default: void 0
84
89
  }
85
90
  },
86
- setup(props, { attrs }) {
87
- const appConfig2 = useAppConfig();
88
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.avatar));
91
+ setup(props) {
92
+ const { ui, attrs } = useUI("avatar", toRef(props, "ui"), config);
89
93
  const url = computed(() => {
90
94
  if (typeof props.src === "boolean") {
91
95
  return null;
@@ -101,7 +105,7 @@ export default defineComponent({
101
105
  (error.value || !url.value) && ui.value.background,
102
106
  ui.value.rounded,
103
107
  ui.value.size[props.size]
104
- ), attrs.class);
108
+ ), props.class);
105
109
  });
106
110
  const imgClass = computed(() => {
107
111
  return twMerge(twJoin(
@@ -133,7 +137,9 @@ export default defineComponent({
133
137
  error.value = true;
134
138
  }
135
139
  return {
136
- attrs: omit(attrs, ["class"]),
140
+ // eslint-disable-next-line vue/no-dupe-keys
141
+ ui,
142
+ attrs,
137
143
  wrapperClass,
138
144
  // eslint-disable-next-line vue/no-dupe-keys
139
145
  imgClass,
@@ -1,4 +1,3 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
4
3
  src: {
@@ -18,36 +17,41 @@ declare const _default: import("vue").DefineComponent<{
18
17
  default: () => any;
19
18
  };
20
19
  size: {
21
- type: StringConstructor;
20
+ type: PropType<"sm" | "3xs" | "md" | "xs" | "2xs" | "lg" | "xl" | "2xl" | "3xl">;
22
21
  default: () => any;
23
22
  validator(value: string): boolean;
24
23
  };
25
24
  chipColor: {
26
- type: StringConstructor;
25
+ type: PropType<any>;
27
26
  default: () => any;
28
27
  validator(value: string): boolean;
29
28
  };
30
29
  chipPosition: {
31
- type: StringConstructor;
30
+ type: PropType<"top-right" | "bottom-right" | "top-left" | "bottom-left">;
32
31
  default: () => any;
33
32
  validator(value: string): boolean;
34
33
  };
35
34
  chipText: {
36
- type: (StringConstructor | NumberConstructor)[];
35
+ type: (NumberConstructor | StringConstructor)[];
37
36
  default: null;
38
37
  };
39
38
  imgClass: {
40
39
  type: StringConstructor;
41
40
  default: string;
42
41
  };
43
- ui: {
42
+ class: {
44
43
  type: PropType<any>;
45
- default: () => {};
44
+ default: undefined;
45
+ };
46
+ ui: {
47
+ type: PropType<Partial<any>>;
48
+ default: undefined;
46
49
  };
47
50
  }, {
48
- attrs: import("lodash").Omit<{
51
+ ui: import("vue").ComputedRef<any>;
52
+ attrs: import("vue").ComputedRef<Pick<{
49
53
  [x: string]: unknown;
50
- }, "class">;
54
+ }, string>>;
51
55
  wrapperClass: import("vue").ComputedRef<string>;
52
56
  imgClass: import("vue").ComputedRef<string>;
53
57
  iconClass: import("vue").ComputedRef<string>;
@@ -74,41 +78,46 @@ declare const _default: import("vue").DefineComponent<{
74
78
  default: () => any;
75
79
  };
76
80
  size: {
77
- type: StringConstructor;
81
+ type: PropType<"sm" | "3xs" | "md" | "xs" | "2xs" | "lg" | "xl" | "2xl" | "3xl">;
78
82
  default: () => any;
79
83
  validator(value: string): boolean;
80
84
  };
81
85
  chipColor: {
82
- type: StringConstructor;
86
+ type: PropType<any>;
83
87
  default: () => any;
84
88
  validator(value: string): boolean;
85
89
  };
86
90
  chipPosition: {
87
- type: StringConstructor;
91
+ type: PropType<"top-right" | "bottom-right" | "top-left" | "bottom-left">;
88
92
  default: () => any;
89
93
  validator(value: string): boolean;
90
94
  };
91
95
  chipText: {
92
- type: (StringConstructor | NumberConstructor)[];
96
+ type: (NumberConstructor | StringConstructor)[];
93
97
  default: null;
94
98
  };
95
99
  imgClass: {
96
100
  type: StringConstructor;
97
101
  default: string;
98
102
  };
99
- ui: {
103
+ class: {
100
104
  type: PropType<any>;
101
- default: () => {};
105
+ default: undefined;
106
+ };
107
+ ui: {
108
+ type: PropType<Partial<any>>;
109
+ default: undefined;
102
110
  };
103
111
  }>>, {
104
112
  alt: string;
105
113
  icon: string;
106
- ui: any;
114
+ ui: Partial<any>;
115
+ class: any;
107
116
  src: string | boolean;
108
117
  text: string;
109
- size: string;
110
- chipColor: string;
111
- chipPosition: string;
118
+ size: "sm" | "3xs" | "md" | "xs" | "2xs" | "lg" | "xl" | "2xl" | "3xl";
119
+ chipColor: any;
120
+ chipPosition: "top-right" | "bottom-right" | "top-left" | "bottom-left";
112
121
  chipText: string | number;
113
122
  imgClass: string;
114
123
  }, {}>;
@@ -1,7 +1,7 @@
1
1
  import type { PropType } from 'vue';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  size: {
4
- type: StringConstructor;
4
+ type: PropType<string | number | symbol>;
5
5
  default: null;
6
6
  validator(value: string): boolean;
7
7
  };
@@ -9,15 +9,19 @@ declare const _default: import("vue").DefineComponent<{
9
9
  type: NumberConstructor;
10
10
  default: null;
11
11
  };
12
- ui: {
12
+ class: {
13
13
  type: PropType<any>;
14
- default: () => {};
14
+ default: undefined;
15
+ };
16
+ ui: {
17
+ type: PropType<Partial<any>>;
18
+ default: undefined;
15
19
  };
16
20
  }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
21
  [key: string]: any;
18
22
  }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
19
23
  size: {
20
- type: StringConstructor;
24
+ type: PropType<string | number | symbol>;
21
25
  default: null;
22
26
  validator(value: string): boolean;
23
27
  };
@@ -25,13 +29,18 @@ declare const _default: import("vue").DefineComponent<{
25
29
  type: NumberConstructor;
26
30
  default: null;
27
31
  };
28
- ui: {
32
+ class: {
29
33
  type: PropType<any>;
30
- default: () => {};
34
+ default: undefined;
35
+ };
36
+ ui: {
37
+ type: PropType<Partial<any>>;
38
+ default: undefined;
31
39
  };
32
40
  }>>, {
33
- ui: any;
34
- size: string;
41
+ ui: Partial<any>;
42
+ class: any;
43
+ size: string | number | symbol;
35
44
  max: number;
36
45
  }, {}>;
37
46
  export default _default;
@@ -1,10 +1,12 @@
1
- import { h, cloneVNode, computed, defineComponent } from "vue";
2
- import { omit } from "lodash-es";
1
+ import { h, cloneVNode, computed, toRef, defineComponent } from "vue";
3
2
  import { twMerge, twJoin } from "tailwind-merge";
4
- import { defuTwMerge, getSlotsChildren } from "../../utils/index.mjs";
5
- import Avatar from "./Avatar.vue";
6
- import { useAppConfig } from "#imports";
3
+ import UAvatar from "./Avatar.vue";
4
+ import { useUI } from "../../composables/useUI.mjs";
5
+ import { mergeConfig, getSlotsChildren } from "../../utils/index.mjs";
7
6
  import appConfig from "#build/app.config";
7
+ import { avatar, avatarGroup } from "#ui/ui.config";
8
+ const avatarConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.avatar, avatar);
9
+ const avatarGroupConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.avatarGroup, avatarGroup);
8
10
  export default defineComponent({
9
11
  inheritAttrs: false,
10
12
  props: {
@@ -12,21 +14,24 @@ export default defineComponent({
12
14
  type: String,
13
15
  default: null,
14
16
  validator(value) {
15
- return Object.keys(appConfig.ui.avatar.size).includes(value);
17
+ return Object.keys(avatarConfig.size).includes(value);
16
18
  }
17
19
  },
18
20
  max: {
19
21
  type: Number,
20
22
  default: null
21
23
  },
24
+ class: {
25
+ type: [String, Object, Array],
26
+ default: void 0
27
+ },
22
28
  ui: {
23
29
  type: Object,
24
- default: () => ({})
30
+ default: void 0
25
31
  }
26
32
  },
27
- setup(props, { attrs, slots }) {
28
- const appConfig2 = useAppConfig();
29
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.avatarGroup));
33
+ setup(props, { slots }) {
34
+ const { ui, attrs } = useUI("avatarGroup", toRef(props, "ui"), avatarGroupConfig, toRef(props, "class"));
30
35
  const children = computed(() => getSlotsChildren(slots));
31
36
  const max = computed(() => typeof props.max === "string" ? parseInt(props.max, 10) : props.max);
32
37
  const clones = computed(() => children.value.map((node, index) => {
@@ -40,14 +45,14 @@ export default defineComponent({
40
45
  return cloneVNode(node, vProps);
41
46
  }
42
47
  if (max.value !== void 0 && index === max.value) {
43
- return h(Avatar, {
44
- size: props.size || appConfig2.ui.avatar.default.size,
48
+ return h(UAvatar, {
49
+ size: props.size || avatarConfig.default.size,
45
50
  text: `+${children.value.length - max.value}`,
46
51
  class: twJoin(ui.value.ring, ui.value.margin)
47
52
  });
48
53
  }
49
54
  return null;
50
55
  }).filter(Boolean).reverse());
51
- return () => h("div", { class: twMerge(ui.value.wrapper, attrs.class), ...omit(attrs, ["class"]) }, clones.value);
56
+ return () => h("div", { class: ui.value.wrapper, ...attrs.value }, clones.value);
52
57
  }
53
58
  });
@@ -5,36 +5,37 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
- import { computed, defineComponent } from "vue";
9
- import { omit } from "lodash-es";
8
+ import { computed, toRef, defineComponent } from "vue";
10
9
  import { twMerge, twJoin } from "tailwind-merge";
11
- import { defuTwMerge } from "../../utils";
12
- import { useAppConfig } from "#imports";
10
+ import { useUI } from "../../composables/useUI";
11
+ import { mergeConfig } from "../../utils";
13
12
  import appConfig from "#build/app.config";
13
+ import { badge } from "#ui/ui.config";
14
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.badge, badge);
14
15
  export default defineComponent({
15
16
  inheritAttrs: false,
16
17
  props: {
17
18
  size: {
18
19
  type: String,
19
- default: () => appConfig.ui.badge.default.size,
20
+ default: () => config.default.size,
20
21
  validator(value) {
21
- return Object.keys(appConfig.ui.badge.size).includes(value);
22
+ return Object.keys(config.size).includes(value);
22
23
  }
23
24
  },
24
25
  color: {
25
26
  type: String,
26
- default: () => appConfig.ui.badge.default.color,
27
+ default: () => config.default.color,
27
28
  validator(value) {
28
- return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.badge.color)].includes(value);
29
+ return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
29
30
  }
30
31
  },
31
32
  variant: {
32
33
  type: String,
33
- default: () => appConfig.ui.badge.default.variant,
34
+ default: () => config.default.variant,
34
35
  validator(value) {
35
36
  return [
36
- ...Object.keys(appConfig.ui.badge.variant),
37
- ...Object.values(appConfig.ui.badge.color).flatMap((value2) => Object.keys(value2))
37
+ ...Object.keys(config.variant),
38
+ ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
38
39
  ].includes(value);
39
40
  }
40
41
  },
@@ -42,14 +43,17 @@ export default defineComponent({
42
43
  type: [String, Number],
43
44
  default: null
44
45
  },
46
+ class: {
47
+ type: [String, Object, Array],
48
+ default: void 0
49
+ },
45
50
  ui: {
46
51
  type: Object,
47
- default: () => ({})
52
+ default: void 0
48
53
  }
49
54
  },
50
- setup(props, { attrs }) {
51
- const appConfig2 = useAppConfig();
52
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.badge));
55
+ setup(props) {
56
+ const { ui, attrs } = useUI("badge", toRef(props, "ui"), config);
53
57
  const badgeClass = computed(() => {
54
58
  const variant = ui.value.color?.[props.color]?.[props.variant] || ui.value.variant[props.variant];
55
59
  return twMerge(twJoin(
@@ -58,10 +62,10 @@ export default defineComponent({
58
62
  ui.value.rounded,
59
63
  ui.value.size[props.size],
60
64
  variant?.replaceAll("{color}", props.color)
61
- ), attrs.class);
65
+ ), props.class);
62
66
  });
63
67
  return {
64
- attrs: omit(attrs, ["class"]),
68
+ attrs,
65
69
  badgeClass
66
70
  };
67
71
  }
@@ -1,63 +1,72 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
2
+ import type { BadgeVariant } from '../../types';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  size: {
5
- type: StringConstructor;
5
+ type: PropType<"sm" | "md" | "xs" | "lg">;
6
6
  default: () => any;
7
7
  validator(value: string): boolean;
8
8
  };
9
9
  color: {
10
- type: StringConstructor;
10
+ type: PropType<any>;
11
11
  default: () => any;
12
12
  validator(value: string): boolean;
13
13
  };
14
14
  variant: {
15
- type: StringConstructor;
15
+ type: PropType<BadgeVariant>;
16
16
  default: () => any;
17
17
  validator(value: string): boolean;
18
18
  };
19
19
  label: {
20
- type: (StringConstructor | NumberConstructor)[];
20
+ type: (NumberConstructor | StringConstructor)[];
21
21
  default: null;
22
22
  };
23
- ui: {
23
+ class: {
24
24
  type: PropType<any>;
25
- default: () => {};
25
+ default: undefined;
26
+ };
27
+ ui: {
28
+ type: PropType<Partial<any>>;
29
+ default: undefined;
26
30
  };
27
31
  }, {
28
- attrs: import("lodash").Omit<{
32
+ attrs: import("vue").ComputedRef<Pick<{
29
33
  [x: string]: unknown;
30
- }, "class">;
34
+ }, string>>;
31
35
  badgeClass: import("vue").ComputedRef<string>;
32
36
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
33
37
  size: {
34
- type: StringConstructor;
38
+ type: PropType<"sm" | "md" | "xs" | "lg">;
35
39
  default: () => any;
36
40
  validator(value: string): boolean;
37
41
  };
38
42
  color: {
39
- type: StringConstructor;
43
+ type: PropType<any>;
40
44
  default: () => any;
41
45
  validator(value: string): boolean;
42
46
  };
43
47
  variant: {
44
- type: StringConstructor;
48
+ type: PropType<BadgeVariant>;
45
49
  default: () => any;
46
50
  validator(value: string): boolean;
47
51
  };
48
52
  label: {
49
- type: (StringConstructor | NumberConstructor)[];
53
+ type: (NumberConstructor | StringConstructor)[];
50
54
  default: null;
51
55
  };
52
- ui: {
56
+ class: {
53
57
  type: PropType<any>;
54
- default: () => {};
58
+ default: undefined;
59
+ };
60
+ ui: {
61
+ type: PropType<Partial<any>>;
62
+ default: undefined;
55
63
  };
56
64
  }>>, {
57
- color: string;
58
- ui: any;
65
+ color: any;
66
+ ui: Partial<any>;
67
+ class: any;
59
68
  label: string | number;
60
- variant: string;
61
- size: string;
69
+ variant: BadgeVariant;
70
+ size: "sm" | "md" | "xs" | "lg";
62
71
  }, {}>;
63
72
  export default _default;