@nuxt/ui 2.8.1 → 2.10.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 (120) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1411 -1092
  3. package/dist/module.d.ts +1411 -1092
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +55 -11
  6. package/dist/runtime/components/data/Table.vue +47 -32
  7. package/dist/runtime/components/data/Table.vue.d.ts +22 -14
  8. package/dist/runtime/components/elements/Accordion.vue +33 -28
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +25 -18
  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 +28 -19
  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 +45 -37
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +22 -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/elements/Meter.vue +166 -0
  28. package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
  29. package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
  30. package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
  31. package/dist/runtime/components/elements/Progress.vue +284 -0
  32. package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
  33. package/dist/runtime/components/forms/Checkbox.vue +27 -17
  34. package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
  35. package/dist/runtime/components/forms/Form.vue +34 -9
  36. package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
  37. package/dist/runtime/components/forms/FormGroup.vue +51 -27
  38. package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
  39. package/dist/runtime/components/forms/Input.vue +41 -29
  40. package/dist/runtime/components/forms/Input.vue.d.ts +51 -24
  41. package/dist/runtime/components/forms/Radio.vue +32 -21
  42. package/dist/runtime/components/forms/Radio.vue.d.ts +36 -18
  43. package/dist/runtime/components/forms/RadioGroup.vue +136 -0
  44. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
  45. package/dist/runtime/components/forms/Range.vue +26 -16
  46. package/dist/runtime/components/forms/Range.vue.d.ts +37 -18
  47. package/dist/runtime/components/forms/Select.vue +34 -26
  48. package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
  49. package/dist/runtime/components/forms/SelectMenu.vue +104 -89
  50. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +53 -33
  51. package/dist/runtime/components/forms/Textarea.vue +43 -31
  52. package/dist/runtime/components/forms/Textarea.vue.d.ts +50 -23
  53. package/dist/runtime/components/forms/Toggle.vue +26 -15
  54. package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
  55. package/dist/runtime/components/layout/Card.vue +15 -10
  56. package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
  57. package/dist/runtime/components/layout/Container.vue +15 -10
  58. package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
  59. package/dist/runtime/components/layout/Divider.vue +107 -0
  60. package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
  61. package/dist/runtime/components/layout/Skeleton.vue +15 -10
  62. package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
  63. package/dist/runtime/components/navigation/CommandPalette.vue +57 -38
  64. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +24 -23
  65. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
  66. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
  67. package/dist/runtime/components/navigation/Pagination.vue +129 -64
  68. package/dist/runtime/components/navigation/Pagination.vue.d.ts +70 -25
  69. package/dist/runtime/components/navigation/Tabs.vue +17 -14
  70. package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
  71. package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
  72. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
  73. package/dist/runtime/components/overlays/ContextMenu.vue +21 -11
  74. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +20 -11
  75. package/dist/runtime/components/overlays/Modal.vue +16 -14
  76. package/dist/runtime/components/overlays/Modal.vue.d.ts +18 -11
  77. package/dist/runtime/components/overlays/Notification.vue +25 -15
  78. package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
  79. package/dist/runtime/components/overlays/Notifications.vue +19 -13
  80. package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
  81. package/dist/runtime/components/overlays/Popover.vue +39 -22
  82. package/dist/runtime/components/overlays/Popover.vue.d.ts +32 -11
  83. package/dist/runtime/components/overlays/Slideover.vue +15 -13
  84. package/dist/runtime/components/overlays/Slideover.vue.d.ts +18 -11
  85. package/dist/runtime/components/overlays/Tooltip.vue +31 -23
  86. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +19 -11
  87. package/dist/runtime/composables/useFormGroup.d.ts +12 -2
  88. package/dist/runtime/composables/useFormGroup.mjs +21 -4
  89. package/dist/runtime/composables/usePopper.d.ts +3 -3
  90. package/dist/runtime/composables/usePopper.mjs +47 -31
  91. package/dist/runtime/composables/useToast.d.ts +3 -3
  92. package/dist/runtime/composables/useUI.d.ts +10 -0
  93. package/dist/runtime/composables/useUI.mjs +24 -0
  94. package/dist/runtime/types/avatar.d.ts +10 -4
  95. package/dist/runtime/types/badge.d.ts +14 -0
  96. package/dist/runtime/types/button.d.ts +10 -3
  97. package/dist/runtime/types/command-palette.d.ts +3 -1
  98. package/dist/runtime/types/form.d.ts +18 -4
  99. package/dist/runtime/types/index.d.ts +4 -0
  100. package/dist/runtime/types/link.d.ts +1 -0
  101. package/dist/runtime/types/meter.d.ts +5 -0
  102. package/dist/runtime/types/notification.d.ts +5 -3
  103. package/dist/runtime/types/popper.d.ts +1 -0
  104. package/dist/runtime/types/progress.d.ts +4 -0
  105. package/dist/runtime/types/tabs.d.ts +1 -0
  106. package/dist/runtime/types/utils.d.ts +11 -0
  107. package/dist/runtime/ui.config.d.ts +1470 -0
  108. package/dist/runtime/{app.config.mjs → ui.config.mjs} +313 -97
  109. package/dist/runtime/utils/index.d.ts +5 -11
  110. package/dist/runtime/utils/index.mjs +21 -9
  111. package/dist/runtime/utils/lodash.d.ts +2 -0
  112. package/dist/runtime/utils/lodash.mjs +23 -0
  113. package/dist/runtime/utils/uid.d.ts +1 -0
  114. package/dist/runtime/utils/uid.mjs +4 -0
  115. package/dist/types.d.mts +1 -1
  116. package/dist/types.d.ts +1 -1
  117. package/package.json +27 -29
  118. package/dist/runtime/app.config.d.ts +0 -1203
  119. package/dist/runtime/utils/StateEmitter.d.ts +0 -17
  120. package/dist/runtime/utils/StateEmitter.mjs +0 -21
@@ -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;
@@ -17,14 +17,15 @@
17
17
  </template>
18
18
 
19
19
  <script>
20
- import { computed, defineComponent } from "vue";
21
- import { omit } from "lodash-es";
20
+ import { computed, defineComponent, toRef } from "vue";
22
21
  import { twMerge, twJoin } from "tailwind-merge";
23
22
  import UIcon from "../elements/Icon.vue";
24
23
  import ULink from "../elements/Link.vue";
25
- import { defuTwMerge } from "../../utils";
26
- import { useAppConfig } from "#imports";
24
+ import { useUI } from "../../composables/useUI";
25
+ import { mergeConfig } from "../../utils";
27
26
  import appConfig from "#build/app.config";
27
+ import { button } from "#ui/ui.config";
28
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.button, button);
28
29
  export default defineComponent({
29
30
  components: {
30
31
  UIcon,
@@ -58,25 +59,25 @@ export default defineComponent({
58
59
  },
59
60
  size: {
60
61
  type: String,
61
- default: () => appConfig.ui.button.default.size,
62
+ default: () => config.default.size,
62
63
  validator(value) {
63
- return Object.keys(appConfig.ui.button.size).includes(value);
64
+ return Object.keys(config.size).includes(value);
64
65
  }
65
66
  },
66
67
  color: {
67
68
  type: String,
68
- default: () => appConfig.ui.button.default.color,
69
+ default: () => config.default.color,
69
70
  validator(value) {
70
- return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.button.color)].includes(value);
71
+ return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
71
72
  }
72
73
  },
73
74
  variant: {
74
75
  type: String,
75
- default: () => appConfig.ui.button.default.variant,
76
+ default: () => config.default.variant,
76
77
  validator(value) {
77
78
  return [
78
- ...Object.keys(appConfig.ui.button.variant),
79
- ...Object.values(appConfig.ui.button.color).flatMap((value2) => Object.keys(value2))
79
+ ...Object.keys(config.variant),
80
+ ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
80
81
  ].includes(value);
81
82
  }
82
83
  },
@@ -86,7 +87,7 @@ export default defineComponent({
86
87
  },
87
88
  loadingIcon: {
88
89
  type: String,
89
- default: () => appConfig.ui.button.default.loadingIcon
90
+ default: () => config.default.loadingIcon
90
91
  },
91
92
  leadingIcon: {
92
93
  type: String,
@@ -112,14 +113,17 @@ export default defineComponent({
112
113
  type: Boolean,
113
114
  default: false
114
115
  },
116
+ class: {
117
+ type: [String, Object, Array],
118
+ default: void 0
119
+ },
115
120
  ui: {
116
121
  type: Object,
117
- default: () => ({})
122
+ default: void 0
118
123
  }
119
124
  },
120
- setup(props, { attrs, slots }) {
121
- const appConfig2 = useAppConfig();
122
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.button));
125
+ setup(props, { slots }) {
126
+ const { ui, attrs } = useUI("button", toRef(props, "ui"), config);
123
127
  const isLeading = computed(() => {
124
128
  return props.icon && props.leading || props.icon && !props.trailing || props.loading && !props.trailing || props.leadingIcon;
125
129
  });
@@ -138,7 +142,7 @@ export default defineComponent({
138
142
  props.padded && ui.value[isSquare.value ? "square" : "padding"][props.size],
139
143
  variant?.replaceAll("{color}", props.color),
140
144
  props.block ? "w-full flex justify-center items-center" : "inline-flex items-center"
141
- ), attrs.class);
145
+ ), props.class);
142
146
  });
143
147
  const leadingIconName = computed(() => {
144
148
  if (props.loading) {
@@ -167,7 +171,7 @@ export default defineComponent({
167
171
  );
168
172
  });
169
173
  return {
170
- attrs: omit(attrs, ["class"]),
174
+ attrs,
171
175
  isLeading,
172
176
  isTrailing,
173
177
  isSquare,
@@ -1,5 +1,5 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
2
+ import type { ButtonVariant } from '../../types';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  type: {
5
5
  type: StringConstructor;
@@ -26,17 +26,17 @@ declare const _default: import("vue").DefineComponent<{
26
26
  default: boolean;
27
27
  };
28
28
  size: {
29
- type: StringConstructor;
29
+ type: PropType<"sm" | "md" | "xs" | "2xs" | "lg" | "xl">;
30
30
  default: () => any;
31
31
  validator(value: string): boolean;
32
32
  };
33
33
  color: {
34
- type: StringConstructor;
34
+ type: PropType<any>;
35
35
  default: () => any;
36
36
  validator(value: string): boolean;
37
37
  };
38
38
  variant: {
39
- type: StringConstructor;
39
+ type: PropType<ButtonVariant>;
40
40
  default: () => any;
41
41
  validator(value: string): boolean;
42
42
  };
@@ -72,14 +72,18 @@ declare const _default: import("vue").DefineComponent<{
72
72
  type: BooleanConstructor;
73
73
  default: boolean;
74
74
  };
75
- ui: {
75
+ class: {
76
76
  type: PropType<any>;
77
- default: () => {};
77
+ default: undefined;
78
+ };
79
+ ui: {
80
+ type: PropType<Partial<any>>;
81
+ default: undefined;
78
82
  };
79
83
  }, {
80
- attrs: import("lodash").Omit<{
84
+ attrs: import("vue").ComputedRef<Pick<{
81
85
  [x: string]: unknown;
82
- }, "class">;
86
+ }, string>>;
83
87
  isLeading: import("vue").ComputedRef<string | true>;
84
88
  isTrailing: import("vue").ComputedRef<string | true>;
85
89
  isSquare: import("vue").ComputedRef<boolean>;
@@ -114,17 +118,17 @@ declare const _default: import("vue").DefineComponent<{
114
118
  default: boolean;
115
119
  };
116
120
  size: {
117
- type: StringConstructor;
121
+ type: PropType<"sm" | "md" | "xs" | "2xs" | "lg" | "xl">;
118
122
  default: () => any;
119
123
  validator(value: string): boolean;
120
124
  };
121
125
  color: {
122
- type: StringConstructor;
126
+ type: PropType<any>;
123
127
  default: () => any;
124
128
  validator(value: string): boolean;
125
129
  };
126
130
  variant: {
127
- type: StringConstructor;
131
+ type: PropType<ButtonVariant>;
128
132
  default: () => any;
129
133
  validator(value: string): boolean;
130
134
  };
@@ -160,20 +164,26 @@ declare const _default: import("vue").DefineComponent<{
160
164
  type: BooleanConstructor;
161
165
  default: boolean;
162
166
  };
163
- ui: {
167
+ class: {
164
168
  type: PropType<any>;
165
- default: () => {};
169
+ default: undefined;
170
+ };
171
+ ui: {
172
+ type: PropType<Partial<any>>;
173
+ default: undefined;
166
174
  };
167
175
  }>>, {
176
+ truncate: boolean;
168
177
  icon: string;
169
- color: string;
170
- ui: any;
178
+ color: any;
179
+ ui: Partial<any>;
180
+ class: any;
171
181
  label: string;
172
- type: string;
173
182
  loading: boolean;
183
+ type: string;
174
184
  disabled: boolean;
175
- variant: string;
176
- size: string;
185
+ variant: ButtonVariant;
186
+ size: "sm" | "md" | "xs" | "2xs" | "lg" | "xl";
177
187
  block: boolean;
178
188
  padded: boolean;
179
189
  loadingIcon: string;
@@ -182,6 +192,5 @@ declare const _default: import("vue").DefineComponent<{
182
192
  trailing: boolean;
183
193
  leading: boolean;
184
194
  square: boolean;
185
- truncate: boolean;
186
195
  }, {}>;
187
196
  export default _default;
@@ -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<"sm" | "md" | "xs" | "2xs" | "lg" | "xl">;
5
5
  default: null;
6
6
  validator(value: string): boolean;
7
7
  };
@@ -10,15 +10,19 @@ declare const _default: import("vue").DefineComponent<{
10
10
  default: string;
11
11
  validator(value: string): boolean;
12
12
  };
13
- ui: {
13
+ class: {
14
14
  type: PropType<any>;
15
- default: () => {};
15
+ default: undefined;
16
+ };
17
+ ui: {
18
+ type: PropType<Partial<any>>;
19
+ default: undefined;
16
20
  };
17
21
  }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
18
22
  [key: string]: any;
19
23
  }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
20
24
  size: {
21
- type: StringConstructor;
25
+ type: PropType<"sm" | "md" | "xs" | "2xs" | "lg" | "xl">;
22
26
  default: null;
23
27
  validator(value: string): boolean;
24
28
  };
@@ -27,13 +31,18 @@ declare const _default: import("vue").DefineComponent<{
27
31
  default: string;
28
32
  validator(value: string): boolean;
29
33
  };
30
- ui: {
34
+ class: {
31
35
  type: PropType<any>;
32
- default: () => {};
36
+ default: undefined;
37
+ };
38
+ ui: {
39
+ type: PropType<Partial<any>>;
40
+ default: undefined;
33
41
  };
34
42
  }>>, {
35
- ui: any;
36
- size: string;
43
+ ui: Partial<any>;
44
+ class: any;
45
+ size: "sm" | "md" | "xs" | "2xs" | "lg" | "xl";
37
46
  orientation: "horizontal" | "vertical";
38
47
  }, {}>;
39
48
  export default _default;
@@ -1,9 +1,11 @@
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 { useAppConfig } from "#imports";
3
+ import { useUI } from "../../composables/useUI.mjs";
4
+ import { mergeConfig, getSlotsChildren } from "../../utils/index.mjs";
6
5
  import appConfig from "#build/app.config";
6
+ import { button, buttonGroup } from "#ui/ui.config";
7
+ const buttonConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.button, button);
8
+ const buttonGroupConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.buttonGroup, buttonGroup);
7
9
  export default defineComponent({
8
10
  inheritAttrs: false,
9
11
  props: {
@@ -11,7 +13,7 @@ export default defineComponent({
11
13
  type: String,
12
14
  default: null,
13
15
  validator(value) {
14
- return Object.keys(appConfig.ui.button.size).includes(value);
16
+ return Object.keys(buttonConfig.size).includes(value);
15
17
  }
16
18
  },
17
19
  orientation: {
@@ -21,14 +23,17 @@ export default defineComponent({
21
23
  return ["horizontal", "vertical"].includes(value);
22
24
  }
23
25
  },
26
+ class: {
27
+ type: [String, Object, Array],
28
+ default: void 0
29
+ },
24
30
  ui: {
25
31
  type: Object,
26
- default: () => ({})
32
+ default: void 0
27
33
  }
28
34
  },
29
- setup(props, { attrs, slots }) {
30
- const appConfig2 = useAppConfig();
31
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.buttonGroup));
35
+ setup(props, { slots }) {
36
+ const { ui, attrs } = useUI("buttonGroup", toRef(props, "ui"), buttonGroupConfig);
32
37
  const children = computed(() => getSlotsChildren(slots));
33
38
  const rounded = computed(() => {
34
39
  const roundedMap = {
@@ -46,11 +51,6 @@ export default defineComponent({
46
51
  });
47
52
  const clones = computed(() => children.value.map((node, index) => {
48
53
  const vProps = {};
49
- if (props.orientation === "vertical") {
50
- ui.value.wrapper = "flex flex-col -space-y-px";
51
- } else {
52
- ui.value.wrapper = "inline-flex -space-x-px";
53
- }
54
54
  if (props.size) {
55
55
  vProps.size = props.size;
56
56
  }
@@ -65,6 +65,13 @@ export default defineComponent({
65
65
  }
66
66
  return cloneVNode(node, vProps);
67
67
  }));
68
- return () => h("div", { class: twMerge(twJoin(ui.value.wrapper, ui.value.rounded, ui.value.shadow), attrs.class), ...omit(attrs, ["class"]) }, clones.value);
68
+ const wrapperClass = computed(() => {
69
+ return twMerge(twJoin(
70
+ ui.value.wrapper[props.orientation],
71
+ ui.value.rounded,
72
+ ui.value.shadow
73
+ ), props.class);
74
+ });
75
+ return () => h("div", { class: wrapperClass.value, ...attrs.value }, clones.value);
69
76
  }
70
77
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <HMenu v-slot="{ open }" as="div" :class="wrapperClass" v-bind="attrs" @mouseleave="onMouseLeave">
2
+ <HMenu v-slot="{ open }" as="div" :class="ui.wrapper" v-bind="attrs" @mouseleave="onMouseLeave">
3
3
  <HMenuButton
4
4
  ref="trigger"
5
5
  as="div"
@@ -17,46 +17,50 @@
17
17
 
18
18
  <div v-if="open && items.length" ref="container" :class="[ui.container, ui.width]" :style="containerStyle" @mouseover="onMouseOver">
19
19
  <Transition appear v-bind="ui.transition">
20
- <HMenuItems :class="[ui.base, ui.divide, ui.ring, ui.rounded, ui.shadow, ui.background, ui.height]" static>
21
- <div v-for="(subItems, index) of items" :key="index" :class="ui.padding">
22
- <HMenuItem v-for="(item, subIndex) of subItems" :key="subIndex" v-slot="{ active, disabled: itemDisabled }" :disabled="item.disabled">
23
- <ULink
24
- v-bind="omit(item, ['label', 'slot', 'icon', 'iconClass', 'avatar', 'shortcuts', 'disabled', 'click'])"
25
- :class="[ui.item.base, ui.item.padding, ui.item.size, ui.item.rounded, active ? ui.item.active : ui.item.inactive, itemDisabled && ui.item.disabled]"
26
- @click="item.click"
27
- >
28
- <slot :name="item.slot || 'item'" :item="item">
29
- <UIcon v-if="item.icon" :name="item.icon" :class="[ui.item.icon.base, active ? ui.item.icon.active : ui.item.icon.inactive, item.iconClass]" />
30
- <UAvatar v-else-if="item.avatar" v-bind="{ size: ui.item.avatar.size, ...item.avatar }" :class="ui.item.avatar.base" />
20
+ <div>
21
+ <div v-if="popper.arrow" data-popper-arrow :class="['invisible before:visible before:block before:rotate-45 before:z-[-1]', Object.values(ui.arrow)]" />
22
+ <HMenuItems :class="[ui.base, ui.divide, ui.ring, ui.rounded, ui.shadow, ui.background, ui.height]" static>
23
+ <div v-for="(subItems, index) of items" :key="index" :class="ui.padding">
24
+ <HMenuItem v-for="(item, subIndex) of subItems" :key="subIndex" v-slot="{ active, disabled: itemDisabled }" :disabled="item.disabled">
25
+ <component
26
+ :is="!!item.to ? NuxtLink : 'button'"
27
+ v-bind="omit(item, ['label', 'slot', 'icon', 'iconClass', 'avatar', 'shortcuts', 'disabled', 'click'])"
28
+ :class="[ui.item.base, ui.item.padding, ui.item.size, ui.item.rounded, active ? ui.item.active : ui.item.inactive, itemDisabled && ui.item.disabled]"
29
+ @click="item.click"
30
+ >
31
+ <slot :name="item.slot || 'item'" :item="item">
32
+ <UIcon v-if="item.icon" :name="item.icon" :class="[ui.item.icon.base, active ? ui.item.icon.active : ui.item.icon.inactive, item.iconClass]" />
33
+ <UAvatar v-else-if="item.avatar" v-bind="{ size: ui.item.avatar.size, ...item.avatar }" :class="ui.item.avatar.base" />
31
34
 
32
- <span class="truncate">{{ item.label }}</span>
35
+ <span class="truncate">{{ item.label }}</span>
33
36
 
34
- <span v-if="item.shortcuts?.length" :class="ui.item.shortcuts">
35
- <UKbd v-for="shortcut of item.shortcuts" :key="shortcut">{{ shortcut }}</UKbd>
36
- </span>
37
- </slot>
38
- </ULink>
39
- </HMenuItem>
40
- </div>
41
- </HMenuItems>
37
+ <span v-if="item.shortcuts?.length" :class="ui.item.shortcuts">
38
+ <UKbd v-for="shortcut of item.shortcuts" :key="shortcut">{{ shortcut }}</UKbd>
39
+ </span>
40
+ </slot>
41
+ </component>
42
+ </HMenuItem>
43
+ </div>
44
+ </HMenuItems>
45
+ </div>
42
46
  </Transition>
43
47
  </div>
44
48
  </HMenu>
45
49
  </template>
46
50
 
47
51
  <script>
48
- import { defineComponent, ref, computed, onMounted } from "vue";
52
+ import { defineComponent, ref, computed, toRef, onMounted, resolveComponent } from "vue";
49
53
  import { Menu as HMenu, MenuButton as HMenuButton, MenuItems as HMenuItems, MenuItem as HMenuItem } from "@headlessui/vue";
50
54
  import { defu } from "defu";
51
- import { omit } from "lodash-es";
52
- import { twMerge } from "tailwind-merge";
53
55
  import UIcon from "../elements/Icon.vue";
54
56
  import UAvatar from "../elements/Avatar.vue";
55
57
  import UKbd from "../elements/Kbd.vue";
56
- import ULink from "../elements/Link.vue";
58
+ import { useUI } from "../../composables/useUI";
57
59
  import { usePopper } from "../../composables/usePopper";
58
- import { defuTwMerge } from "../../utils";
59
- import { useAppConfig } from "#imports";
60
+ import { mergeConfig, omit } from "../../utils";
61
+ import appConfig from "#build/app.config";
62
+ import { dropdown } from "#ui/ui.config";
63
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.dropdown, dropdown);
60
64
  export default defineComponent({
61
65
  components: {
62
66
  HMenu,
@@ -65,8 +69,7 @@ export default defineComponent({
65
69
  HMenuItem,
66
70
  UIcon,
67
71
  UAvatar,
68
- UKbd,
69
- ULink
72
+ UKbd
70
73
  },
71
74
  inheritAttrs: false,
72
75
  props: {
@@ -95,14 +98,17 @@ export default defineComponent({
95
98
  type: Number,
96
99
  default: 0
97
100
  },
101
+ class: {
102
+ type: [String, Object, Array],
103
+ default: void 0
104
+ },
98
105
  ui: {
99
106
  type: Object,
100
- default: () => ({})
107
+ default: void 0
101
108
  }
102
109
  },
103
- setup(props, { attrs }) {
104
- const appConfig2 = useAppConfig();
105
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.dropdown));
110
+ setup(props) {
111
+ const { ui, attrs } = useUI("dropdown", toRef(props, "ui"), config, toRef(props, "class"));
106
112
  const popper = computed(() => defu(props.mode === "hover" ? { offsetDistance: 0 } : {}, props.popper, ui.value.popper));
107
113
  const [trigger, container] = usePopper(popper.value);
108
114
  const menuApi = ref(null);
@@ -122,7 +128,6 @@ export default defineComponent({
122
128
  const offsetDistance = props.popper?.offsetDistance || ui.value.popper?.offsetDistance || 8;
123
129
  return props.mode === "hover" ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {};
124
130
  });
125
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
126
131
  function onMouseOver() {
127
132
  if (props.mode !== "hover" || !menuApi.value) {
128
133
  return;
@@ -155,17 +160,20 @@ export default defineComponent({
155
160
  closeTimeout = null;
156
161
  }, props.closeDelay);
157
162
  }
163
+ const NuxtLink = resolveComponent("NuxtLink");
158
164
  return {
159
- attrs: omit(attrs, ["class"]),
160
165
  // eslint-disable-next-line vue/no-dupe-keys
161
166
  ui,
167
+ attrs,
168
+ // eslint-disable-next-line vue/no-dupe-keys
169
+ popper,
162
170
  trigger,
163
171
  container,
164
172
  containerStyle,
165
- wrapperClass,
166
173
  onMouseOver,
167
174
  onMouseLeave,
168
- omit
175
+ omit,
176
+ NuxtLink
169
177
  };
170
178
  }
171
179
  });
@@ -1,7 +1,6 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { DropdownItem } from '../../types/dropdown';
4
- import type { PopperOptions } from '../../types/popper';
2
+ import { omit } from '../../utils';
3
+ import type { DropdownItem, PopperOptions } from '../../types';
5
4
  declare const _default: import("vue").DefineComponent<{
6
5
  items: {
7
6
  type: PropType<DropdownItem[][]>;
@@ -28,15 +27,20 @@ declare const _default: import("vue").DefineComponent<{
28
27
  type: NumberConstructor;
29
28
  default: number;
30
29
  };
31
- ui: {
30
+ class: {
32
31
  type: PropType<any>;
33
- default: () => {};
32
+ default: undefined;
33
+ };
34
+ ui: {
35
+ type: PropType<Partial<any>>;
36
+ default: undefined;
34
37
  };
35
38
  }, {
36
- attrs: import("lodash").Omit<{
37
- [x: string]: unknown;
38
- }, "class">;
39
39
  ui: import("vue").ComputedRef<any>;
40
+ attrs: import("vue").ComputedRef<Pick<{
41
+ [x: string]: unknown;
42
+ }, string>>;
43
+ popper: import("vue").ComputedRef<PopperOptions>;
40
44
  trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
41
45
  container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
42
46
  containerStyle: import("vue").ComputedRef<{
@@ -46,14 +50,10 @@ declare const _default: import("vue").DefineComponent<{
46
50
  paddingTop?: undefined;
47
51
  paddingBottom?: undefined;
48
52
  }>;
49
- wrapperClass: import("vue").ComputedRef<string>;
50
53
  onMouseOver: () => void;
51
54
  onMouseLeave: () => void;
52
- omit: {
53
- <T extends object, K extends import("lodash").PropertyName[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
54
- <T_1 extends object, K_1 extends keyof T_1>(object: T_1 | null | undefined, ...paths: import("lodash").Many<K_1>[]): import("lodash").Omit<T_1, K_1>;
55
- <T_2 extends object>(object: T_2 | null | undefined, ...paths: import("lodash").Many<import("lodash").PropertyName>[]): Partial<T_2>;
56
- };
55
+ omit: typeof omit;
56
+ NuxtLink: string | import("vue").ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
57
57
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
58
58
  items: {
59
59
  type: PropType<DropdownItem[][]>;
@@ -80,13 +80,18 @@ declare const _default: import("vue").DefineComponent<{
80
80
  type: NumberConstructor;
81
81
  default: number;
82
82
  };
83
- ui: {
83
+ class: {
84
84
  type: PropType<any>;
85
- default: () => {};
85
+ default: undefined;
86
+ };
87
+ ui: {
88
+ type: PropType<Partial<any>>;
89
+ default: undefined;
86
90
  };
87
91
  }>>, {
88
- ui: any;
92
+ ui: Partial<any>;
89
93
  popper: PopperOptions;
94
+ class: any;
90
95
  disabled: boolean;
91
96
  items: DropdownItem[][];
92
97
  mode: "click" | "hover";