@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,4 +1,3 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
4
3
  modelValue: {
@@ -25,17 +24,20 @@ declare const _default: import("vue").DefineComponent<{
25
24
  type: BooleanConstructor;
26
25
  default: boolean;
27
26
  };
28
- ui: {
27
+ class: {
29
28
  type: PropType<any>;
30
- default: () => {};
29
+ default: undefined;
30
+ };
31
+ ui: {
32
+ type: PropType<Partial<any>>;
33
+ default: undefined;
31
34
  };
32
35
  }, {
33
- attrs: import("lodash").Omit<{
34
- [x: string]: unknown;
35
- }, "class">;
36
36
  ui: import("vue").ComputedRef<any>;
37
+ attrs: import("vue").ComputedRef<Pick<{
38
+ [x: string]: unknown;
39
+ }, string>>;
37
40
  isOpen: import("vue").WritableComputedRef<boolean>;
38
- wrapperClass: import("vue").ComputedRef<string>;
39
41
  transitionClass: import("vue").ComputedRef<any>;
40
42
  close: (value: boolean) => void;
41
43
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -63,15 +65,20 @@ declare const _default: import("vue").DefineComponent<{
63
65
  type: BooleanConstructor;
64
66
  default: boolean;
65
67
  };
66
- ui: {
68
+ class: {
67
69
  type: PropType<any>;
68
- default: () => {};
70
+ default: undefined;
71
+ };
72
+ ui: {
73
+ type: PropType<Partial<any>>;
74
+ default: undefined;
69
75
  };
70
76
  }>> & {
71
- onClose?: ((...args: any[]) => any) | undefined;
72
77
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
78
+ onClose?: ((...args: any[]) => any) | undefined;
73
79
  }, {
74
- ui: any;
80
+ ui: Partial<any>;
81
+ class: any;
75
82
  modelValue: boolean;
76
83
  appear: boolean;
77
84
  overlay: boolean;
@@ -1,6 +1,12 @@
1
1
  <template>
2
2
  <Transition appear v-bind="ui.transition">
3
- <div :class="wrapperClass" v-bind="attrs" @mouseover="onMouseover" @mouseleave="onMouseleave">
3
+ <div
4
+ :class="wrapperClass"
5
+ role="status"
6
+ v-bind="attrs"
7
+ @mouseover="onMouseover"
8
+ @mouseleave="onMouseleave"
9
+ >
4
10
  <div :class="[ui.container, ui.rounded, ui.ring]">
5
11
  <div :class="ui.padding">
6
12
  <div class="flex gap-3" :class="{ 'items-start': description || $slots.description, 'items-center': !description && !$slots.description }">
@@ -28,7 +34,7 @@
28
34
  <UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="onAction(action)" />
29
35
  </div>
30
36
 
31
- <UButton v-if="closeButton" v-bind="{ ...ui.default.closeButton, ...closeButton }" @click.stop="onClose" />
37
+ <UButton v-if="closeButton" aria-label="Close" v-bind="{ ...ui.default.closeButton, ...closeButton }" @click.stop="onClose" />
32
38
  </div>
33
39
  </div>
34
40
  </div>
@@ -39,16 +45,17 @@
39
45
  </template>
40
46
 
41
47
  <script>
42
- import { ref, computed, onMounted, onUnmounted, watchEffect, defineComponent } from "vue";
43
- import { omit } from "lodash-es";
48
+ import { ref, computed, toRef, onMounted, onUnmounted, watchEffect, defineComponent } from "vue";
44
49
  import { twMerge, twJoin } from "tailwind-merge";
45
50
  import UIcon from "../elements/Icon.vue";
46
51
  import UAvatar from "../elements/Avatar.vue";
47
52
  import UButton from "../elements/Button.vue";
53
+ import { useUI } from "../../composables/useUI";
48
54
  import { useTimer } from "../../composables/useTimer";
49
- import { defuTwMerge } from "../../utils";
50
- import { useAppConfig } from "#imports";
55
+ import { mergeConfig } from "../../utils";
51
56
  import appConfig from "#build/app.config";
57
+ import { notification } from "#ui/ui.config";
58
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.notification, notification);
52
59
  export default defineComponent({
53
60
  components: {
54
61
  UIcon,
@@ -71,7 +78,7 @@ export default defineComponent({
71
78
  },
72
79
  icon: {
73
80
  type: String,
74
- default: () => appConfig.ui.notification.default.icon
81
+ default: () => config.default.icon
75
82
  },
76
83
  avatar: {
77
84
  type: Object,
@@ -79,7 +86,7 @@ export default defineComponent({
79
86
  },
80
87
  closeButton: {
81
88
  type: Object,
82
- default: () => appConfig.ui.notification.default.closeButton
89
+ default: () => config.default.closeButton
83
90
  },
84
91
  timeout: {
85
92
  type: Number,
@@ -95,20 +102,23 @@ export default defineComponent({
95
102
  },
96
103
  color: {
97
104
  type: String,
98
- default: () => appConfig.ui.notification.default.color,
105
+ default: () => config.default.color,
99
106
  validator(value) {
100
107
  return ["gray", ...appConfig.ui.colors].includes(value);
101
108
  }
102
109
  },
110
+ class: {
111
+ type: [String, Object, Array],
112
+ default: void 0
113
+ },
103
114
  ui: {
104
115
  type: Object,
105
- default: () => ({})
116
+ default: void 0
106
117
  }
107
118
  },
108
119
  emits: ["close"],
109
- setup(props, { attrs, emit }) {
110
- const appConfig2 = useAppConfig();
111
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.notification));
120
+ setup(props, { emit }) {
121
+ const { ui, attrs } = useUI("notification", toRef(props, "ui"), config);
112
122
  let timer = null;
113
123
  const remaining = ref(props.timeout);
114
124
  const wrapperClass = computed(() => {
@@ -117,7 +127,7 @@ export default defineComponent({
117
127
  ui.value.background,
118
128
  ui.value.rounded,
119
129
  ui.value.shadow
120
- ), attrs.class);
130
+ ), props.class);
121
131
  });
122
132
  const progressClass = computed(() => {
123
133
  return twJoin(
@@ -180,9 +190,9 @@ export default defineComponent({
180
190
  }
181
191
  });
182
192
  return {
183
- attrs: omit(attrs, ["class"]),
184
193
  // eslint-disable-next-line vue/no-dupe-keys
185
194
  ui,
195
+ attrs,
186
196
  wrapperClass,
187
197
  progressClass,
188
198
  progressStyle,
@@ -1,11 +1,8 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { NotificationAction } from '../../types/notification';
4
- import type { Avatar } from '../../types/avatar';
5
- import type { Button } from '../../types/button';
2
+ import type { Avatar, Button, NotificationAction } from '../../types';
6
3
  declare const _default: import("vue").DefineComponent<{
7
4
  id: {
8
- type: (StringConstructor | NumberConstructor)[];
5
+ type: (NumberConstructor | StringConstructor)[];
9
6
  required: true;
10
7
  };
11
8
  title: {
@@ -26,7 +23,7 @@ declare const _default: import("vue").DefineComponent<{
26
23
  };
27
24
  closeButton: {
28
25
  type: PropType<Button>;
29
- default: () => any;
26
+ default: () => Button;
30
27
  };
31
28
  timeout: {
32
29
  type: NumberConstructor;
@@ -41,19 +38,23 @@ declare const _default: import("vue").DefineComponent<{
41
38
  default: null;
42
39
  };
43
40
  color: {
44
- type: StringConstructor;
41
+ type: PropType<any>;
45
42
  default: () => any;
46
43
  validator(value: string): boolean;
47
44
  };
48
- ui: {
45
+ class: {
49
46
  type: PropType<any>;
50
- default: () => {};
47
+ default: undefined;
48
+ };
49
+ ui: {
50
+ type: PropType<Partial<any>>;
51
+ default: undefined;
51
52
  };
52
53
  }, {
53
- attrs: import("lodash").Omit<{
54
- [x: string]: unknown;
55
- }, "class">;
56
54
  ui: import("vue").ComputedRef<any>;
55
+ attrs: import("vue").ComputedRef<Pick<{
56
+ [x: string]: unknown;
57
+ }, string>>;
57
58
  wrapperClass: import("vue").ComputedRef<string>;
58
59
  progressClass: import("vue").ComputedRef<string>;
59
60
  progressStyle: import("vue").ComputedRef<{
@@ -66,7 +67,7 @@ declare const _default: import("vue").DefineComponent<{
66
67
  onAction: (action: NotificationAction) => void;
67
68
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "close"[], "close", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
68
69
  id: {
69
- type: (StringConstructor | NumberConstructor)[];
70
+ type: (NumberConstructor | StringConstructor)[];
70
71
  required: true;
71
72
  };
72
73
  title: {
@@ -87,7 +88,7 @@ declare const _default: import("vue").DefineComponent<{
87
88
  };
88
89
  closeButton: {
89
90
  type: PropType<Button>;
90
- default: () => any;
91
+ default: () => Button;
91
92
  };
92
93
  timeout: {
93
94
  type: NumberConstructor;
@@ -102,13 +103,17 @@ declare const _default: import("vue").DefineComponent<{
102
103
  default: null;
103
104
  };
104
105
  color: {
105
- type: StringConstructor;
106
+ type: PropType<any>;
106
107
  default: () => any;
107
108
  validator(value: string): boolean;
108
109
  };
109
- ui: {
110
+ class: {
110
111
  type: PropType<any>;
111
- default: () => {};
112
+ default: undefined;
113
+ };
114
+ ui: {
115
+ type: PropType<Partial<any>>;
116
+ default: undefined;
112
117
  };
113
118
  }>> & {
114
119
  onClose?: ((...args: any[]) => any) | undefined;
@@ -120,7 +125,8 @@ declare const _default: import("vue").DefineComponent<{
120
125
  timeout: number;
121
126
  actions: NotificationAction[];
122
127
  callback: Function;
123
- color: string;
124
- ui: any;
128
+ color: any;
129
+ ui: Partial<any>;
130
+ class: any;
125
131
  }, {}>;
126
132
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="wrapperClass" v-bind="attrs">
2
+ <div :class="wrapperClass" role="region" v-bind="attrs">
3
3
  <div v-if="notifications.length" :class="ui.container">
4
4
  <div v-for="notification of notifications" :key="notification.id">
5
5
  <UNotification
@@ -18,42 +18,48 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
- import { computed, defineComponent } from "vue";
22
- import { omit } from "lodash-es";
21
+ import { computed, toRef, defineComponent } from "vue";
23
22
  import { twMerge, twJoin } from "tailwind-merge";
24
23
  import UNotification from "./Notification.vue";
24
+ import { useUI } from "../../composables/useUI";
25
25
  import { useToast } from "../../composables/useToast";
26
- import { defuTwMerge } from "../../utils";
27
- import { useState, useAppConfig } from "#imports";
26
+ import { mergeConfig } from "../../utils";
27
+ import { useState } from "#imports";
28
+ import appConfig from "#build/app.config";
29
+ import { notifications } from "#ui/ui.config";
30
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.notifications, notifications);
28
31
  export default defineComponent({
29
32
  components: {
30
33
  UNotification
31
34
  },
32
35
  inheritAttrs: false,
33
36
  props: {
37
+ class: {
38
+ type: [String, Object, Array],
39
+ default: void 0
40
+ },
34
41
  ui: {
35
42
  type: Object,
36
- default: () => ({})
43
+ default: void 0
37
44
  }
38
45
  },
39
- setup(props, { attrs }) {
40
- const appConfig2 = useAppConfig();
41
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.notifications));
46
+ setup(props) {
47
+ const { ui, attrs } = useUI("notifications", toRef(props, "ui"), config);
42
48
  const toast = useToast();
43
- const notifications = useState("notifications", () => []);
49
+ const notifications2 = useState("notifications", () => []);
44
50
  const wrapperClass = computed(() => {
45
51
  return twMerge(twJoin(
46
52
  ui.value.wrapper,
47
53
  ui.value.position,
48
54
  ui.value.width
49
- ), attrs.class);
55
+ ), props.class);
50
56
  });
51
57
  return {
52
- attrs: omit(attrs, ["class"]),
53
58
  // eslint-disable-next-line vue/no-dupe-keys
54
59
  ui,
60
+ attrs,
55
61
  toast,
56
- notifications,
62
+ notifications: notifications2,
57
63
  wrapperClass
58
64
  };
59
65
  }
@@ -1,29 +1,32 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { Notification } from '../../types/notification';
2
+ import type { Notification } from '../../types';
4
3
  declare const _default: import("vue").DefineComponent<{
5
- ui: {
4
+ class: {
6
5
  type: PropType<any>;
7
- default: () => {};
6
+ default: undefined;
7
+ };
8
+ ui: {
9
+ type: PropType<Partial<any>>;
10
+ default: undefined;
8
11
  };
9
12
  }, {
10
- attrs: import("lodash").Omit<{
11
- [x: string]: unknown;
12
- }, "class">;
13
13
  ui: import("vue").ComputedRef<any>;
14
+ attrs: import("vue").ComputedRef<Pick<{
15
+ [x: string]: unknown;
16
+ }, string>>;
14
17
  toast: {
15
18
  add: (notification: Partial<Notification>) => {
16
19
  id: string;
17
20
  title?: string | undefined;
18
21
  description?: string | undefined;
19
22
  icon?: string | undefined;
20
- avatar?: import("../../types/avatar").Avatar | undefined;
21
- closeButton?: import("../../types/button").Button | undefined;
23
+ avatar?: import("../../types").Avatar | undefined;
24
+ closeButton?: import("../../types").Button | undefined;
22
25
  timeout?: number | undefined;
23
- actions?: import("../../types/notification").NotificationAction[] | undefined;
26
+ actions?: import("../../types").NotificationAction[] | undefined;
24
27
  click?: Function | undefined;
25
28
  callback?: Function | undefined;
26
- color?: string | undefined;
29
+ color?: any;
27
30
  ui?: any;
28
31
  };
29
32
  remove: (id: string) => void;
@@ -31,11 +34,16 @@ declare const _default: import("vue").DefineComponent<{
31
34
  notifications: any;
32
35
  wrapperClass: import("vue").ComputedRef<string>;
33
36
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
34
- ui: {
37
+ class: {
35
38
  type: PropType<any>;
36
- default: () => {};
39
+ default: undefined;
40
+ };
41
+ ui: {
42
+ type: PropType<Partial<any>>;
43
+ default: undefined;
37
44
  };
38
45
  }>>, {
39
- ui: any;
46
+ ui: Partial<any>;
47
+ class: any;
40
48
  }, {}>;
41
49
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <HPopover ref="popover" v-slot="{ open, close }" :class="wrapperClass" v-bind="attrs" @mouseleave="onMouseLeave">
2
+ <HPopover ref="popover" v-slot="{ open: headlessOpen, close }" :class="ui.wrapper" v-bind="attrs" @mouseleave="onMouseLeave">
3
3
  <HPopoverButton
4
4
  ref="trigger"
5
5
  as="div"
@@ -8,32 +8,36 @@
8
8
  role="button"
9
9
  @mouseover="onMouseOver"
10
10
  >
11
- <slot :open="open" :close="close">
11
+ <slot :open="(open !== undefined) ? open : headlessOpen" :close="close">
12
12
  <button :disabled="disabled">
13
13
  Open
14
14
  </button>
15
15
  </slot>
16
16
  </HPopoverButton>
17
17
 
18
- <div v-if="open" ref="container" :class="[ui.container, ui.width]" :style="containerStyle" @mouseover="onMouseOver">
18
+ <div v-if="(open !== undefined) ? open : headlessOpen" ref="container" :class="[ui.container, ui.width]" :style="containerStyle" @mouseover="onMouseOver">
19
19
  <Transition appear v-bind="ui.transition">
20
- <HPopoverPanel :class="[ui.base, ui.background, ui.ring, ui.rounded, ui.shadow]" static>
21
- <slot name="panel" :open="open" :close="close" />
22
- </HPopoverPanel>
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
+ <HPopoverPanel :class="[ui.base, ui.background, ui.ring, ui.rounded, ui.shadow]" static>
23
+ <slot name="panel" :open="(open !== undefined) ? open : headlessOpen" :close="close" />
24
+ </HPopoverPanel>
25
+ </div>
23
26
  </Transition>
24
27
  </div>
25
28
  </HPopover>
26
29
  </template>
27
30
 
28
31
  <script>
29
- import { computed, ref, onMounted, defineComponent } from "vue";
32
+ import { computed, ref, toRef, onMounted, defineComponent } from "vue";
30
33
  import { defu } from "defu";
31
- import { omit } from "lodash-es";
32
- import { twMerge } from "tailwind-merge";
33
34
  import { Popover as HPopover, PopoverButton as HPopoverButton, PopoverPanel as HPopoverPanel } from "@headlessui/vue";
35
+ import { useUI } from "../../composables/useUI";
34
36
  import { usePopper } from "../../composables/usePopper";
35
- import { defuTwMerge } from "../../utils";
36
- import { useAppConfig } from "#imports";
37
+ import { mergeConfig } from "../../utils";
38
+ import appConfig from "#build/app.config";
39
+ import { popover } from "#ui/ui.config";
40
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.popover, popover);
37
41
  export default defineComponent({
38
42
  components: {
39
43
  HPopover,
@@ -47,6 +51,10 @@ export default defineComponent({
47
51
  default: "click",
48
52
  validator: (value) => ["click", "hover"].includes(value)
49
53
  },
54
+ open: {
55
+ type: Boolean,
56
+ default: void 0
57
+ },
50
58
  disabled: {
51
59
  type: Boolean,
52
60
  default: false
@@ -63,22 +71,25 @@ export default defineComponent({
63
71
  type: Object,
64
72
  default: () => ({})
65
73
  },
74
+ class: {
75
+ type: [String, Object, Array],
76
+ default: void 0
77
+ },
66
78
  ui: {
67
79
  type: Object,
68
- default: () => ({})
80
+ default: void 0
69
81
  }
70
82
  },
71
- setup(props, { attrs }) {
72
- const appConfig2 = useAppConfig();
73
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.popover));
83
+ setup(props) {
84
+ const { ui, attrs } = useUI("popover", toRef(props, "ui"), config, toRef(props, "class"));
74
85
  const popper = computed(() => defu(props.mode === "hover" ? { offsetDistance: 0 } : {}, props.popper, ui.value.popper));
75
86
  const [trigger, container] = usePopper(popper.value);
76
- const popover = ref(null);
87
+ const popover2 = ref(null);
77
88
  const popoverApi = ref(null);
78
89
  let openTimeout = null;
79
90
  let closeTimeout = null;
80
91
  onMounted(() => {
81
- const popoverProvides = popover.value?.$.provides;
92
+ const popoverProvides = popover2.value?.$.provides;
82
93
  if (!popoverProvides) {
83
94
  return;
84
95
  }
@@ -87,9 +98,14 @@ export default defineComponent({
87
98
  });
88
99
  const containerStyle = computed(() => {
89
100
  const offsetDistance = props.popper?.offsetDistance || ui.value.popper?.offsetDistance || 8;
90
- return props.mode === "hover" ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {};
101
+ const padding = `${offsetDistance}px`;
102
+ return props.mode === "hover" ? {
103
+ paddingTop: padding,
104
+ paddingBottom: padding,
105
+ paddingLeft: padding,
106
+ paddingRight: padding
107
+ } : {};
91
108
  });
92
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
93
109
  function onMouseOver() {
94
110
  if (props.mode !== "hover" || !popoverApi.value) {
95
111
  return;
@@ -123,14 +139,15 @@ export default defineComponent({
123
139
  }, props.closeDelay);
124
140
  }
125
141
  return {
126
- attrs: omit(attrs, ["class"]),
127
142
  // eslint-disable-next-line vue/no-dupe-keys
128
143
  ui,
129
- popover,
144
+ attrs,
145
+ popover: popover2,
146
+ // eslint-disable-next-line vue/no-dupe-keys
147
+ popper,
130
148
  trigger,
131
149
  container,
132
150
  containerStyle,
133
- wrapperClass,
134
151
  onMouseOver,
135
152
  onMouseLeave
136
153
  };
@@ -1,12 +1,15 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
- import type { PopperOptions } from '../../types/popper';
2
+ import type { PopperOptions } from '../../types';
4
3
  declare const _default: import("vue").DefineComponent<{
5
4
  mode: {
6
5
  type: PropType<"click" | "hover">;
7
6
  default: string;
8
7
  validator: (value: string) => boolean;
9
8
  };
9
+ open: {
10
+ type: BooleanConstructor;
11
+ default: undefined;
12
+ };
10
13
  disabled: {
11
14
  type: BooleanConstructor;
12
15
  default: boolean;
@@ -23,26 +26,34 @@ declare const _default: import("vue").DefineComponent<{
23
26
  type: PropType<PopperOptions>;
24
27
  default: () => {};
25
28
  };
26
- ui: {
29
+ class: {
27
30
  type: PropType<any>;
28
- default: () => {};
31
+ default: undefined;
32
+ };
33
+ ui: {
34
+ type: PropType<Partial<any>>;
35
+ default: undefined;
29
36
  };
30
37
  }, {
31
- attrs: import("lodash").Omit<{
32
- [x: string]: unknown;
33
- }, "class">;
34
38
  ui: import("vue").ComputedRef<any>;
39
+ attrs: import("vue").ComputedRef<Pick<{
40
+ [x: string]: unknown;
41
+ }, string>>;
35
42
  popover: any;
43
+ popper: import("vue").ComputedRef<PopperOptions>;
36
44
  trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
37
45
  container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
38
46
  containerStyle: import("vue").ComputedRef<{
39
47
  paddingTop: string;
40
48
  paddingBottom: string;
49
+ paddingLeft: string;
50
+ paddingRight: string;
41
51
  } | {
42
52
  paddingTop?: undefined;
43
53
  paddingBottom?: undefined;
54
+ paddingLeft?: undefined;
55
+ paddingRight?: undefined;
44
56
  }>;
45
- wrapperClass: import("vue").ComputedRef<string>;
46
57
  onMouseOver: () => void;
47
58
  onMouseLeave: () => void;
48
59
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -51,6 +62,10 @@ declare const _default: import("vue").DefineComponent<{
51
62
  default: string;
52
63
  validator: (value: string) => boolean;
53
64
  };
65
+ open: {
66
+ type: BooleanConstructor;
67
+ default: undefined;
68
+ };
54
69
  disabled: {
55
70
  type: BooleanConstructor;
56
71
  default: boolean;
@@ -67,14 +82,20 @@ declare const _default: import("vue").DefineComponent<{
67
82
  type: PropType<PopperOptions>;
68
83
  default: () => {};
69
84
  };
70
- ui: {
85
+ class: {
71
86
  type: PropType<any>;
72
- default: () => {};
87
+ default: undefined;
88
+ };
89
+ ui: {
90
+ type: PropType<Partial<any>>;
91
+ default: undefined;
73
92
  };
74
93
  }>>, {
75
- ui: any;
94
+ ui: Partial<any>;
76
95
  popper: PopperOptions;
96
+ class: any;
77
97
  disabled: boolean;
98
+ open: boolean;
78
99
  mode: "click" | "hover";
79
100
  openDelay: number;
80
101
  closeDelay: number;