@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.
- package/README.md +1 -0
- package/dist/module.d.mts +1147 -1096
- package/dist/module.d.ts +1147 -1096
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -10
- package/dist/runtime/components/data/Table.vue +42 -29
- package/dist/runtime/components/data/Table.vue.d.ts +20 -13
- package/dist/runtime/components/elements/Accordion.vue +25 -22
- package/dist/runtime/components/elements/Accordion.vue.d.ts +21 -17
- package/dist/runtime/components/elements/Alert.vue +22 -18
- package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
- package/dist/runtime/components/elements/Avatar.vue +22 -16
- package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
- package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
- package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
- package/dist/runtime/components/elements/Badge.vue +21 -17
- package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
- package/dist/runtime/components/elements/Button.vue +22 -18
- package/dist/runtime/components/elements/Button.vue.d.ts +26 -17
- package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
- package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
- package/dist/runtime/components/elements/Dropdown.vue +15 -13
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +20 -17
- package/dist/runtime/components/elements/Kbd.vue +16 -12
- package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
- package/dist/runtime/components/elements/Link.vue +18 -5
- package/dist/runtime/components/forms/Checkbox.vue +27 -17
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
- package/dist/runtime/components/forms/Form.vue +2 -2
- package/dist/runtime/components/forms/FormGroup.vue +51 -27
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
- package/dist/runtime/components/forms/Input.vue +36 -28
- package/dist/runtime/components/forms/Input.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Radio.vue +27 -17
- package/dist/runtime/components/forms/Radio.vue.d.ts +35 -17
- package/dist/runtime/components/forms/Range.vue +26 -16
- package/dist/runtime/components/forms/Range.vue.d.ts +36 -17
- package/dist/runtime/components/forms/Select.vue +34 -26
- package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
- package/dist/runtime/components/forms/SelectMenu.vue +43 -33
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +49 -30
- package/dist/runtime/components/forms/Textarea.vue +38 -30
- package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Toggle.vue +26 -15
- package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
- package/dist/runtime/components/layout/Card.vue +15 -10
- package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Container.vue +15 -10
- package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Skeleton.vue +15 -10
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
- package/dist/runtime/components/navigation/CommandPalette.vue +50 -38
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +23 -22
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
- package/dist/runtime/components/navigation/Pagination.vue +64 -55
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +29 -22
- package/dist/runtime/components/navigation/Tabs.vue +16 -13
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
- package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
- package/dist/runtime/components/overlays/ContextMenu.vue +14 -9
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +18 -10
- package/dist/runtime/components/overlays/Modal.vue +15 -13
- package/dist/runtime/components/overlays/Modal.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Notification.vue +18 -14
- package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
- package/dist/runtime/components/overlays/Notifications.vue +18 -12
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
- package/dist/runtime/components/overlays/Popover.vue +18 -16
- package/dist/runtime/components/overlays/Popover.vue.d.ts +18 -11
- package/dist/runtime/components/overlays/Slideover.vue +15 -13
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Tooltip.vue +15 -13
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +18 -11
- package/dist/runtime/composables/useFormGroup.d.ts +12 -2
- package/dist/runtime/composables/useFormGroup.mjs +10 -4
- package/dist/runtime/composables/usePopper.mjs +40 -30
- package/dist/runtime/composables/useToast.d.ts +3 -3
- package/dist/runtime/composables/useUI.d.ts +10 -0
- package/dist/runtime/composables/useUI.mjs +24 -0
- package/dist/runtime/types/avatar.d.ts +10 -4
- package/dist/runtime/types/badge.d.ts +14 -0
- package/dist/runtime/types/button.d.ts +10 -3
- package/dist/runtime/types/command-palette.d.ts +2 -1
- package/dist/runtime/types/form.d.ts +8 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/link.d.ts +1 -0
- package/dist/runtime/types/notification.d.ts +5 -3
- package/dist/runtime/types/tabs.d.ts +1 -0
- package/dist/runtime/types/utils.d.ts +11 -0
- package/dist/runtime/ui.config.d.ts +1207 -0
- package/dist/runtime/{app.config.mjs → ui.config.mjs} +52 -80
- package/dist/runtime/utils/index.d.ts +5 -11
- package/dist/runtime/utils/index.mjs +21 -9
- package/dist/runtime/utils/lodash.d.ts +2 -0
- package/dist/runtime/utils/lodash.mjs +23 -0
- package/dist/runtime/utils/uid.d.ts +1 -0
- package/dist/runtime/utils/uid.mjs +4 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +19 -21
- 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
|
|
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: () =>
|
|
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:
|
|
31
|
+
type: PropType<any>;
|
|
34
32
|
default: () => any;
|
|
35
33
|
validator(value: string): boolean;
|
|
36
34
|
};
|
|
37
35
|
variant: {
|
|
38
|
-
type:
|
|
36
|
+
type: PropType<any>;
|
|
39
37
|
default: () => any;
|
|
40
38
|
validator(value: string): boolean;
|
|
41
39
|
};
|
|
42
|
-
|
|
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: () =>
|
|
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:
|
|
82
|
+
type: PropType<any>;
|
|
81
83
|
default: () => any;
|
|
82
84
|
validator(value: string): boolean;
|
|
83
85
|
};
|
|
84
86
|
variant: {
|
|
85
|
-
type:
|
|
87
|
+
type: PropType<any>;
|
|
86
88
|
default: () => any;
|
|
87
89
|
validator(value: string): boolean;
|
|
88
90
|
};
|
|
89
|
-
|
|
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:
|
|
104
|
-
ui: any
|
|
105
|
-
|
|
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 {
|
|
27
|
-
import {
|
|
26
|
+
import { useUI } from "../../composables/useUI";
|
|
27
|
+
import { mergeConfig } from "../../utils";
|
|
28
28
|
import appConfig from "#build/app.config";
|
|
29
|
-
import {
|
|
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: () =>
|
|
51
|
+
default: () => config.default.icon
|
|
51
52
|
},
|
|
52
53
|
size: {
|
|
53
54
|
type: String,
|
|
54
|
-
default: () =>
|
|
55
|
+
default: () => config.default.size,
|
|
55
56
|
validator(value) {
|
|
56
|
-
return Object.keys(
|
|
57
|
+
return Object.keys(config.size).includes(value);
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
60
|
chipColor: {
|
|
60
61
|
type: String,
|
|
61
|
-
default: () =>
|
|
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: () =>
|
|
69
|
+
default: () => config.default.chipPosition,
|
|
69
70
|
validator(value) {
|
|
70
|
-
return Object.keys(
|
|
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
|
|
87
|
-
const
|
|
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
|
-
),
|
|
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
|
-
|
|
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:
|
|
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:
|
|
25
|
+
type: PropType<any>;
|
|
27
26
|
default: () => any;
|
|
28
27
|
validator(value: string): boolean;
|
|
29
28
|
};
|
|
30
29
|
chipPosition: {
|
|
31
|
-
type:
|
|
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: (
|
|
35
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
37
36
|
default: null;
|
|
38
37
|
};
|
|
39
38
|
imgClass: {
|
|
40
39
|
type: StringConstructor;
|
|
41
40
|
default: string;
|
|
42
41
|
};
|
|
43
|
-
|
|
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
|
-
|
|
51
|
+
ui: import("vue").ComputedRef<any>;
|
|
52
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
49
53
|
[x: string]: unknown;
|
|
50
|
-
},
|
|
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:
|
|
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:
|
|
86
|
+
type: PropType<any>;
|
|
83
87
|
default: () => any;
|
|
84
88
|
validator(value: string): boolean;
|
|
85
89
|
};
|
|
86
90
|
chipPosition: {
|
|
87
|
-
type:
|
|
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: (
|
|
96
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
93
97
|
default: null;
|
|
94
98
|
};
|
|
95
99
|
imgClass: {
|
|
96
100
|
type: StringConstructor;
|
|
97
101
|
default: string;
|
|
98
102
|
};
|
|
99
|
-
|
|
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:
|
|
110
|
-
chipColor:
|
|
111
|
-
chipPosition:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
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(
|
|
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, {
|
|
28
|
-
const
|
|
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(
|
|
44
|
-
size: props.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:
|
|
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 {
|
|
12
|
-
import {
|
|
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: () =>
|
|
20
|
+
default: () => config.default.size,
|
|
20
21
|
validator(value) {
|
|
21
|
-
return Object.keys(
|
|
22
|
+
return Object.keys(config.size).includes(value);
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
color: {
|
|
25
26
|
type: String,
|
|
26
|
-
default: () =>
|
|
27
|
+
default: () => config.default.color,
|
|
27
28
|
validator(value) {
|
|
28
|
-
return [...appConfig.ui.colors, ...Object.keys(
|
|
29
|
+
return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
variant: {
|
|
32
33
|
type: String,
|
|
33
|
-
default: () =>
|
|
34
|
+
default: () => config.default.variant,
|
|
34
35
|
validator(value) {
|
|
35
36
|
return [
|
|
36
|
-
...Object.keys(
|
|
37
|
-
...Object.values(
|
|
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
|
|
51
|
-
const
|
|
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
|
-
),
|
|
65
|
+
), props.class);
|
|
62
66
|
});
|
|
63
67
|
return {
|
|
64
|
-
attrs
|
|
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:
|
|
5
|
+
type: PropType<"sm" | "md" | "xs" | "lg">;
|
|
6
6
|
default: () => any;
|
|
7
7
|
validator(value: string): boolean;
|
|
8
8
|
};
|
|
9
9
|
color: {
|
|
10
|
-
type:
|
|
10
|
+
type: PropType<any>;
|
|
11
11
|
default: () => any;
|
|
12
12
|
validator(value: string): boolean;
|
|
13
13
|
};
|
|
14
14
|
variant: {
|
|
15
|
-
type:
|
|
15
|
+
type: PropType<BadgeVariant>;
|
|
16
16
|
default: () => any;
|
|
17
17
|
validator(value: string): boolean;
|
|
18
18
|
};
|
|
19
19
|
label: {
|
|
20
|
-
type: (
|
|
20
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
21
21
|
default: null;
|
|
22
22
|
};
|
|
23
|
-
|
|
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("
|
|
32
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
29
33
|
[x: string]: unknown;
|
|
30
|
-
},
|
|
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:
|
|
38
|
+
type: PropType<"sm" | "md" | "xs" | "lg">;
|
|
35
39
|
default: () => any;
|
|
36
40
|
validator(value: string): boolean;
|
|
37
41
|
};
|
|
38
42
|
color: {
|
|
39
|
-
type:
|
|
43
|
+
type: PropType<any>;
|
|
40
44
|
default: () => any;
|
|
41
45
|
validator(value: string): boolean;
|
|
42
46
|
};
|
|
43
47
|
variant: {
|
|
44
|
-
type:
|
|
48
|
+
type: PropType<BadgeVariant>;
|
|
45
49
|
default: () => any;
|
|
46
50
|
validator(value: string): boolean;
|
|
47
51
|
};
|
|
48
52
|
label: {
|
|
49
|
-
type: (
|
|
53
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
50
54
|
default: null;
|
|
51
55
|
};
|
|
52
|
-
|
|
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:
|
|
58
|
-
ui: any
|
|
65
|
+
color: any;
|
|
66
|
+
ui: Partial<any>;
|
|
67
|
+
class: any;
|
|
59
68
|
label: string | number;
|
|
60
|
-
variant:
|
|
61
|
-
size:
|
|
69
|
+
variant: BadgeVariant;
|
|
70
|
+
size: "sm" | "md" | "xs" | "lg";
|
|
62
71
|
}, {}>;
|
|
63
72
|
export default _default;
|