@nuxt/ui 0.4.0 → 2.8.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/LICENSE.md +9 -0
- package/README.md +63 -50
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +1234 -0
- package/dist/module.d.ts +1234 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +407 -0
- package/dist/runtime/app.config.d.ts +1203 -0
- package/dist/runtime/app.config.mjs +1057 -0
- package/dist/runtime/components/data/Table.vue +251 -0
- package/dist/runtime/components/data/Table.vue.d.ts +215 -0
- package/dist/runtime/components/elements/Accordion.vue +138 -0
- package/dist/runtime/components/elements/Accordion.vue.d.ts +80 -0
- package/dist/runtime/components/elements/Alert.vue +120 -0
- package/dist/runtime/components/elements/Alert.vue.d.ts +107 -0
- package/dist/runtime/components/elements/Avatar.vue +149 -0
- package/dist/runtime/components/elements/Avatar.vue.d.ts +115 -0
- package/dist/runtime/components/elements/AvatarGroup.d.ts +37 -0
- package/dist/runtime/components/elements/AvatarGroup.mjs +53 -0
- package/dist/runtime/components/elements/Badge.vue +69 -0
- package/dist/runtime/components/elements/Badge.vue.d.ts +63 -0
- package/dist/runtime/components/elements/Button.vue +182 -0
- package/dist/runtime/components/elements/Button.vue.d.ts +187 -0
- package/dist/runtime/components/elements/ButtonGroup.d.ts +39 -0
- package/dist/runtime/components/elements/ButtonGroup.mjs +70 -0
- package/dist/runtime/components/elements/Dropdown.vue +172 -0
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +96 -0
- package/dist/runtime/components/elements/Icon.vue +15 -0
- package/dist/runtime/components/elements/Icon.vue.d.ts +12 -0
- package/dist/runtime/components/elements/Kbd.vue +55 -0
- package/dist/runtime/components/elements/Kbd.vue.d.ts +42 -0
- package/dist/runtime/components/elements/Link.vue +80 -0
- package/dist/runtime/components/elements/Link.vue.d.ts +9 -0
- package/dist/runtime/components/forms/Checkbox.vue +136 -0
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +129 -0
- package/dist/runtime/components/forms/Form.vue +186 -0
- package/dist/runtime/components/forms/Form.vue.d.ts +50 -0
- package/dist/runtime/components/forms/FormGroup.vue +97 -0
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +98 -0
- package/dist/runtime/components/forms/Input.vue +250 -0
- package/dist/runtime/components/forms/Input.vue.d.ts +214 -0
- package/dist/runtime/components/forms/Radio.vue +122 -0
- package/dist/runtime/components/forms/Radio.vue.d.ts +109 -0
- package/dist/runtime/components/forms/Range.vue +163 -0
- package/dist/runtime/components/forms/Range.vue.d.ts +119 -0
- package/dist/runtime/components/forms/Select.vue +307 -0
- package/dist/runtime/components/forms/Select.vue.d.ts +229 -0
- package/dist/runtime/components/forms/SelectMenu.vue +429 -0
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +330 -0
- package/dist/runtime/components/forms/Textarea.vue +184 -0
- package/dist/runtime/components/forms/Textarea.vue.d.ts +161 -0
- package/dist/runtime/components/forms/Toggle.vue +113 -0
- package/dist/runtime/components/forms/Toggle.vue.d.ts +83 -0
- package/dist/runtime/components/layout/Card.vue +58 -0
- package/dist/runtime/components/layout/Card.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Container.vue +43 -0
- package/dist/runtime/components/layout/Container.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Skeleton.vue +37 -0
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +22 -0
- package/dist/runtime/components/navigation/CommandPalette.vue +304 -0
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +224 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +152 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +63 -0
- package/dist/runtime/components/navigation/Pagination.vue +197 -0
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +125 -0
- package/dist/runtime/components/navigation/Tabs.vue +138 -0
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +69 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue +79 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +37 -0
- package/dist/runtime/components/overlays/ContextMenu.vue +74 -0
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +54 -0
- package/dist/runtime/components/overlays/Modal.vue +113 -0
- package/dist/runtime/components/overlays/Modal.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Notification.vue +197 -0
- package/dist/runtime/components/overlays/Notification.vue.d.ts +126 -0
- package/dist/runtime/components/overlays/Notifications.vue +61 -0
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +41 -0
- package/dist/runtime/components/overlays/Popover.vue +139 -0
- package/dist/runtime/components/overlays/Popover.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Slideover.vue +103 -0
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +84 -0
- package/dist/runtime/components/overlays/Tooltip.vue +118 -0
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +82 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +13 -0
- package/dist/runtime/composables/defineShortcuts.mjs +108 -0
- package/dist/runtime/composables/useCopyToClipboard.d.ts +10 -0
- package/dist/runtime/composables/useCopyToClipboard.mjs +26 -0
- package/dist/runtime/composables/useFormGroup.d.ts +6 -0
- package/dist/runtime/composables/useFormGroup.mjs +30 -0
- package/dist/runtime/composables/usePopper.d.ts +232 -0
- package/dist/runtime/composables/usePopper.mjs +78 -0
- package/dist/runtime/composables/useShortcuts.d.ts +12 -0
- package/dist/runtime/composables/useShortcuts.mjs +24 -0
- package/dist/runtime/composables/useTimer.d.ts +8 -0
- package/dist/runtime/composables/useTimer.mjs +51 -0
- package/dist/runtime/composables/useToast.d.ts +18 -0
- package/dist/runtime/composables/useToast.mjs +22 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.mjs +46 -0
- package/dist/runtime/types/accordion.d.ts +9 -0
- package/dist/runtime/types/avatar.d.ts +9 -0
- package/dist/runtime/types/button.d.ts +23 -0
- package/dist/runtime/types/clipboard.d.ts +3 -0
- package/dist/runtime/types/command-palette.d.ts +26 -0
- package/dist/runtime/types/dropdown.d.ts +13 -0
- package/dist/runtime/types/form.d.ts +21 -0
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/link.d.ts +8 -0
- package/dist/runtime/types/notification.d.ts +22 -0
- package/dist/runtime/types/popper.d.ts +14 -0
- package/dist/runtime/types/tabs.d.ts +6 -0
- package/dist/runtime/types/vertical-navigation.d.ts +11 -0
- package/dist/runtime/ui.css +13 -0
- package/dist/runtime/utils/StateEmitter.d.ts +17 -0
- package/dist/runtime/utils/StateEmitter.mjs +21 -0
- package/dist/runtime/utils/index.d.ts +11 -0
- package/dist/runtime/utils/index.mjs +33 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +57 -40
- package/LICENSE +0 -21
- package/dist/assets/styles.css +0 -14
- package/dist/components/NButton.vue +0 -19
- package/dist/components/NCard.vue +0 -5
- package/dist/components/NCheckbox.vue +0 -35
- package/dist/components/NDarkToggle.vue +0 -28
- package/dist/components/NDialog.vue +0 -59
- package/dist/components/NDropdown.vue +0 -31
- package/dist/components/NIcon.vue +0 -9
- package/dist/components/NLink.vue +0 -17
- package/dist/components/NRadio.vue +0 -40
- package/dist/components/NSwitch.vue +0 -37
- package/dist/components/NTextInput.vue +0 -34
- package/dist/components/NTip.vue +0 -16
- package/dist/components/NuxtContentLogo.vue +0 -7
- package/dist/components/NuxtExampleLayout.vue +0 -82
- package/dist/components/NuxtLogo.vue +0 -20
- package/dist/components/nuxt/NDarkToggle.vue +0 -28
- package/dist/nuxt.d.ts +0 -16
- package/dist/nuxt.mjs +0 -36
- package/dist/unocss.d.ts +0 -7
- package/dist/unocss.mjs +0 -117
- package/nuxt.cjs +0 -7
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="alertClass" v-bind="attrs">
|
|
3
|
+
<div class="flex gap-3" :class="{ 'items-start': (description || $slots.description), 'items-center': !description && !$slots.description }">
|
|
4
|
+
<UIcon v-if="icon" :name="icon" :class="ui.icon.base" />
|
|
5
|
+
<UAvatar v-if="avatar" v-bind="{ size: ui.avatar.size, ...avatar }" :class="ui.avatar.base" />
|
|
6
|
+
|
|
7
|
+
<div class="w-0 flex-1">
|
|
8
|
+
<p :class="ui.title">
|
|
9
|
+
<slot name="title" :title="title">
|
|
10
|
+
{{ title }}
|
|
11
|
+
</slot>
|
|
12
|
+
</p>
|
|
13
|
+
<p v-if="description || $slots.description" :class="ui.description">
|
|
14
|
+
<slot name="description" :description="description">
|
|
15
|
+
{{ description }}
|
|
16
|
+
</slot>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<div v-if="(description || $slots.description) && actions.length" class="mt-3 flex items-center gap-2">
|
|
20
|
+
<UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="action.click" />
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="flex-shrink-0 flex items-center gap-3">
|
|
24
|
+
<div v-if="!description && !$slots.description && actions.length" class="flex items-center gap-2">
|
|
25
|
+
<UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="action.click" />
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<UButton v-if="closeButton" v-bind="{ ...ui.default.closeButton, ...closeButton }" @click.stop="$emit('close')" />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import { computed, defineComponent } from "vue";
|
|
36
|
+
import { twMerge, twJoin } from "tailwind-merge";
|
|
37
|
+
import UIcon from "../elements/Icon.vue";
|
|
38
|
+
import UAvatar from "../elements/Avatar.vue";
|
|
39
|
+
import UButton from "../elements/Button.vue";
|
|
40
|
+
import { defuTwMerge } from "../../utils";
|
|
41
|
+
import { useAppConfig } from "#imports";
|
|
42
|
+
import appConfig from "#build/app.config";
|
|
43
|
+
import { omit } from "lodash-es";
|
|
44
|
+
export default defineComponent({
|
|
45
|
+
components: {
|
|
46
|
+
UIcon,
|
|
47
|
+
UAvatar,
|
|
48
|
+
UButton
|
|
49
|
+
},
|
|
50
|
+
inheritAttrs: false,
|
|
51
|
+
props: {
|
|
52
|
+
title: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
description: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: null
|
|
59
|
+
},
|
|
60
|
+
icon: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: () => appConfig.ui.alert.default.icon
|
|
63
|
+
},
|
|
64
|
+
avatar: {
|
|
65
|
+
type: Object,
|
|
66
|
+
default: null
|
|
67
|
+
},
|
|
68
|
+
closeButton: {
|
|
69
|
+
type: Object,
|
|
70
|
+
default: () => appConfig.ui.alert.default.closeButton
|
|
71
|
+
},
|
|
72
|
+
actions: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: () => []
|
|
75
|
+
},
|
|
76
|
+
color: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: () => appConfig.ui.alert.default.color,
|
|
79
|
+
validator(value) {
|
|
80
|
+
return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.alert.color)].includes(value);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
variant: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: () => appConfig.ui.alert.default.variant,
|
|
86
|
+
validator(value) {
|
|
87
|
+
return [
|
|
88
|
+
...Object.keys(appConfig.ui.alert.variant),
|
|
89
|
+
...Object.values(appConfig.ui.alert.color).flatMap((value2) => Object.keys(value2))
|
|
90
|
+
].includes(value);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
ui: {
|
|
94
|
+
type: Object,
|
|
95
|
+
default: () => ({})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
emits: ["close"],
|
|
99
|
+
setup(props, { attrs }) {
|
|
100
|
+
const appConfig2 = useAppConfig();
|
|
101
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.alert));
|
|
102
|
+
const alertClass = computed(() => {
|
|
103
|
+
const variant = ui.value.color?.[props.color]?.[props.variant] || ui.value.variant[props.variant];
|
|
104
|
+
return twMerge(twJoin(
|
|
105
|
+
ui.value.wrapper,
|
|
106
|
+
ui.value.rounded,
|
|
107
|
+
ui.value.shadow,
|
|
108
|
+
ui.value.padding,
|
|
109
|
+
variant?.replaceAll("{color}", props.color)
|
|
110
|
+
), attrs.class);
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
attrs: omit(attrs, ["class"]),
|
|
114
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
115
|
+
ui,
|
|
116
|
+
alertClass
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import type { Avatar } from '../../types/avatar';
|
|
4
|
+
import type { Button } from '../../types/button';
|
|
5
|
+
declare const _default: import("vue").DefineComponent<{
|
|
6
|
+
title: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
description: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: null;
|
|
13
|
+
};
|
|
14
|
+
icon: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: () => any;
|
|
17
|
+
};
|
|
18
|
+
avatar: {
|
|
19
|
+
type: PropType<Avatar>;
|
|
20
|
+
default: null;
|
|
21
|
+
};
|
|
22
|
+
closeButton: {
|
|
23
|
+
type: PropType<Button>;
|
|
24
|
+
default: () => any;
|
|
25
|
+
};
|
|
26
|
+
actions: {
|
|
27
|
+
type: PropType<(Button & {
|
|
28
|
+
click?: Function | undefined;
|
|
29
|
+
})[]>;
|
|
30
|
+
default: () => never[];
|
|
31
|
+
};
|
|
32
|
+
color: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: () => any;
|
|
35
|
+
validator(value: string): boolean;
|
|
36
|
+
};
|
|
37
|
+
variant: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: () => any;
|
|
40
|
+
validator(value: string): boolean;
|
|
41
|
+
};
|
|
42
|
+
ui: {
|
|
43
|
+
type: PropType<any>;
|
|
44
|
+
default: () => {};
|
|
45
|
+
};
|
|
46
|
+
}, {
|
|
47
|
+
attrs: import("lodash").Omit<{
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
}, "class">;
|
|
50
|
+
ui: import("vue").ComputedRef<any>;
|
|
51
|
+
alertClass: import("vue").ComputedRef<string>;
|
|
52
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "close"[], "close", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
53
|
+
title: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
required: true;
|
|
56
|
+
};
|
|
57
|
+
description: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: null;
|
|
60
|
+
};
|
|
61
|
+
icon: {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
default: () => any;
|
|
64
|
+
};
|
|
65
|
+
avatar: {
|
|
66
|
+
type: PropType<Avatar>;
|
|
67
|
+
default: null;
|
|
68
|
+
};
|
|
69
|
+
closeButton: {
|
|
70
|
+
type: PropType<Button>;
|
|
71
|
+
default: () => any;
|
|
72
|
+
};
|
|
73
|
+
actions: {
|
|
74
|
+
type: PropType<(Button & {
|
|
75
|
+
click?: Function | undefined;
|
|
76
|
+
})[]>;
|
|
77
|
+
default: () => never[];
|
|
78
|
+
};
|
|
79
|
+
color: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: () => any;
|
|
82
|
+
validator(value: string): boolean;
|
|
83
|
+
};
|
|
84
|
+
variant: {
|
|
85
|
+
type: StringConstructor;
|
|
86
|
+
default: () => any;
|
|
87
|
+
validator(value: string): boolean;
|
|
88
|
+
};
|
|
89
|
+
ui: {
|
|
90
|
+
type: PropType<any>;
|
|
91
|
+
default: () => {};
|
|
92
|
+
};
|
|
93
|
+
}>> & {
|
|
94
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
description: string;
|
|
97
|
+
icon: string;
|
|
98
|
+
avatar: Avatar;
|
|
99
|
+
closeButton: Button;
|
|
100
|
+
actions: (Button & {
|
|
101
|
+
click?: Function | undefined;
|
|
102
|
+
})[];
|
|
103
|
+
color: string;
|
|
104
|
+
ui: any;
|
|
105
|
+
variant: string;
|
|
106
|
+
}, {}>;
|
|
107
|
+
export default _default;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span :class="wrapperClass">
|
|
3
|
+
<img
|
|
4
|
+
v-if="url && !error"
|
|
5
|
+
:class="imgClass"
|
|
6
|
+
:alt="alt"
|
|
7
|
+
:src="url"
|
|
8
|
+
v-bind="attrs"
|
|
9
|
+
@error="onError"
|
|
10
|
+
>
|
|
11
|
+
<span v-else-if="text" :class="ui.text">{{ text }}</span>
|
|
12
|
+
<UIcon v-else-if="icon" :name="icon" :class="iconClass" />
|
|
13
|
+
<span v-else-if="placeholder" :class="ui.placeholder">{{ placeholder }}</span>
|
|
14
|
+
|
|
15
|
+
<span v-if="chipColor" :class="chipClass">
|
|
16
|
+
{{ chipText }}
|
|
17
|
+
</span>
|
|
18
|
+
<slot />
|
|
19
|
+
</span>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { defineComponent, ref, computed, watch } from "vue";
|
|
24
|
+
import { twMerge, twJoin } from "tailwind-merge";
|
|
25
|
+
import UIcon from "../elements/Icon.vue";
|
|
26
|
+
import { defuTwMerge } from "../../utils";
|
|
27
|
+
import { useAppConfig } from "#imports";
|
|
28
|
+
import appConfig from "#build/app.config";
|
|
29
|
+
import { omit } from "lodash-es";
|
|
30
|
+
export default defineComponent({
|
|
31
|
+
components: {
|
|
32
|
+
UIcon
|
|
33
|
+
},
|
|
34
|
+
inheritAttrs: false,
|
|
35
|
+
props: {
|
|
36
|
+
src: {
|
|
37
|
+
type: [String, Boolean],
|
|
38
|
+
default: null
|
|
39
|
+
},
|
|
40
|
+
alt: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: null
|
|
43
|
+
},
|
|
44
|
+
text: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: null
|
|
47
|
+
},
|
|
48
|
+
icon: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: () => appConfig.ui.avatar.default.icon
|
|
51
|
+
},
|
|
52
|
+
size: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: () => appConfig.ui.avatar.default.size,
|
|
55
|
+
validator(value) {
|
|
56
|
+
return Object.keys(appConfig.ui.avatar.size).includes(value);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
chipColor: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: () => appConfig.ui.avatar.default.chipColor,
|
|
62
|
+
validator(value) {
|
|
63
|
+
return ["gray", ...appConfig.ui.colors].includes(value);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
chipPosition: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: () => appConfig.ui.avatar.default.chipPosition,
|
|
69
|
+
validator(value) {
|
|
70
|
+
return Object.keys(appConfig.ui.avatar.chip.position).includes(value);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
chipText: {
|
|
74
|
+
type: [String, Number],
|
|
75
|
+
default: null
|
|
76
|
+
},
|
|
77
|
+
imgClass: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: ""
|
|
80
|
+
},
|
|
81
|
+
ui: {
|
|
82
|
+
type: Object,
|
|
83
|
+
default: () => ({})
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
setup(props, { attrs }) {
|
|
87
|
+
const appConfig2 = useAppConfig();
|
|
88
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.avatar));
|
|
89
|
+
const url = computed(() => {
|
|
90
|
+
if (typeof props.src === "boolean") {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return props.src;
|
|
94
|
+
});
|
|
95
|
+
const placeholder = computed(() => {
|
|
96
|
+
return (props.alt || "").split(" ").map((word) => word.charAt(0)).join("").substring(0, 2);
|
|
97
|
+
});
|
|
98
|
+
const wrapperClass = computed(() => {
|
|
99
|
+
return twMerge(twJoin(
|
|
100
|
+
ui.value.wrapper,
|
|
101
|
+
(error.value || !url.value) && ui.value.background,
|
|
102
|
+
ui.value.rounded,
|
|
103
|
+
ui.value.size[props.size]
|
|
104
|
+
), attrs.class);
|
|
105
|
+
});
|
|
106
|
+
const imgClass = computed(() => {
|
|
107
|
+
return twMerge(twJoin(
|
|
108
|
+
ui.value.rounded,
|
|
109
|
+
ui.value.size[props.size]
|
|
110
|
+
), props.imgClass);
|
|
111
|
+
});
|
|
112
|
+
const iconClass = computed(() => {
|
|
113
|
+
return twJoin(
|
|
114
|
+
ui.value.icon.base,
|
|
115
|
+
ui.value.icon.size[props.size]
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
const chipClass = computed(() => {
|
|
119
|
+
return twJoin(
|
|
120
|
+
ui.value.chip.base,
|
|
121
|
+
ui.value.chip.size[props.size],
|
|
122
|
+
ui.value.chip.position[props.chipPosition],
|
|
123
|
+
ui.value.chip.background.replaceAll("{color}", props.chipColor)
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
const error = ref(false);
|
|
127
|
+
watch(() => props.src, () => {
|
|
128
|
+
if (error.value) {
|
|
129
|
+
error.value = false;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
function onError() {
|
|
133
|
+
error.value = true;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
attrs: omit(attrs, ["class"]),
|
|
137
|
+
wrapperClass,
|
|
138
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
139
|
+
imgClass,
|
|
140
|
+
iconClass,
|
|
141
|
+
chipClass,
|
|
142
|
+
url,
|
|
143
|
+
placeholder,
|
|
144
|
+
error,
|
|
145
|
+
onError
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
</script>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
src: {
|
|
5
|
+
type: (BooleanConstructor | StringConstructor)[];
|
|
6
|
+
default: null;
|
|
7
|
+
};
|
|
8
|
+
alt: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: null;
|
|
11
|
+
};
|
|
12
|
+
text: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: null;
|
|
15
|
+
};
|
|
16
|
+
icon: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: () => any;
|
|
19
|
+
};
|
|
20
|
+
size: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: () => any;
|
|
23
|
+
validator(value: string): boolean;
|
|
24
|
+
};
|
|
25
|
+
chipColor: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: () => any;
|
|
28
|
+
validator(value: string): boolean;
|
|
29
|
+
};
|
|
30
|
+
chipPosition: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
default: () => any;
|
|
33
|
+
validator(value: string): boolean;
|
|
34
|
+
};
|
|
35
|
+
chipText: {
|
|
36
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
37
|
+
default: null;
|
|
38
|
+
};
|
|
39
|
+
imgClass: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
ui: {
|
|
44
|
+
type: PropType<any>;
|
|
45
|
+
default: () => {};
|
|
46
|
+
};
|
|
47
|
+
}, {
|
|
48
|
+
attrs: import("lodash").Omit<{
|
|
49
|
+
[x: string]: unknown;
|
|
50
|
+
}, "class">;
|
|
51
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
52
|
+
imgClass: import("vue").ComputedRef<string>;
|
|
53
|
+
iconClass: import("vue").ComputedRef<string>;
|
|
54
|
+
chipClass: import("vue").ComputedRef<string>;
|
|
55
|
+
url: import("vue").ComputedRef<string | null>;
|
|
56
|
+
placeholder: import("vue").ComputedRef<string>;
|
|
57
|
+
error: import("vue").Ref<boolean>;
|
|
58
|
+
onError: () => void;
|
|
59
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
|
+
src: {
|
|
61
|
+
type: (BooleanConstructor | StringConstructor)[];
|
|
62
|
+
default: null;
|
|
63
|
+
};
|
|
64
|
+
alt: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: null;
|
|
67
|
+
};
|
|
68
|
+
text: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: null;
|
|
71
|
+
};
|
|
72
|
+
icon: {
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
default: () => any;
|
|
75
|
+
};
|
|
76
|
+
size: {
|
|
77
|
+
type: StringConstructor;
|
|
78
|
+
default: () => any;
|
|
79
|
+
validator(value: string): boolean;
|
|
80
|
+
};
|
|
81
|
+
chipColor: {
|
|
82
|
+
type: StringConstructor;
|
|
83
|
+
default: () => any;
|
|
84
|
+
validator(value: string): boolean;
|
|
85
|
+
};
|
|
86
|
+
chipPosition: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: () => any;
|
|
89
|
+
validator(value: string): boolean;
|
|
90
|
+
};
|
|
91
|
+
chipText: {
|
|
92
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
93
|
+
default: null;
|
|
94
|
+
};
|
|
95
|
+
imgClass: {
|
|
96
|
+
type: StringConstructor;
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
99
|
+
ui: {
|
|
100
|
+
type: PropType<any>;
|
|
101
|
+
default: () => {};
|
|
102
|
+
};
|
|
103
|
+
}>>, {
|
|
104
|
+
alt: string;
|
|
105
|
+
icon: string;
|
|
106
|
+
ui: any;
|
|
107
|
+
src: string | boolean;
|
|
108
|
+
text: string;
|
|
109
|
+
size: string;
|
|
110
|
+
chipColor: string;
|
|
111
|
+
chipPosition: string;
|
|
112
|
+
chipText: string | number;
|
|
113
|
+
imgClass: string;
|
|
114
|
+
}, {}>;
|
|
115
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
size: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: null;
|
|
6
|
+
validator(value: string): boolean;
|
|
7
|
+
};
|
|
8
|
+
max: {
|
|
9
|
+
type: NumberConstructor;
|
|
10
|
+
default: null;
|
|
11
|
+
};
|
|
12
|
+
ui: {
|
|
13
|
+
type: PropType<any>;
|
|
14
|
+
default: () => {};
|
|
15
|
+
};
|
|
16
|
+
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
size: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: null;
|
|
22
|
+
validator(value: string): boolean;
|
|
23
|
+
};
|
|
24
|
+
max: {
|
|
25
|
+
type: NumberConstructor;
|
|
26
|
+
default: null;
|
|
27
|
+
};
|
|
28
|
+
ui: {
|
|
29
|
+
type: PropType<any>;
|
|
30
|
+
default: () => {};
|
|
31
|
+
};
|
|
32
|
+
}>>, {
|
|
33
|
+
ui: any;
|
|
34
|
+
size: string;
|
|
35
|
+
max: number;
|
|
36
|
+
}, {}>;
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { h, cloneVNode, computed, defineComponent } from "vue";
|
|
2
|
+
import { omit } from "lodash-es";
|
|
3
|
+
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";
|
|
7
|
+
import appConfig from "#build/app.config";
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
size: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: null,
|
|
14
|
+
validator(value) {
|
|
15
|
+
return Object.keys(appConfig.ui.avatar.size).includes(value);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
max: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: null
|
|
21
|
+
},
|
|
22
|
+
ui: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: () => ({})
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
setup(props, { attrs, slots }) {
|
|
28
|
+
const appConfig2 = useAppConfig();
|
|
29
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.avatarGroup));
|
|
30
|
+
const children = computed(() => getSlotsChildren(slots));
|
|
31
|
+
const max = computed(() => typeof props.max === "string" ? parseInt(props.max, 10) : props.max);
|
|
32
|
+
const clones = computed(() => children.value.map((node, index) => {
|
|
33
|
+
const vProps = {};
|
|
34
|
+
if (!props.max || max.value && index < max.value) {
|
|
35
|
+
if (props.size) {
|
|
36
|
+
vProps.size = props.size;
|
|
37
|
+
}
|
|
38
|
+
vProps.class = node.props.class || "";
|
|
39
|
+
vProps.class = twMerge(twJoin(vProps.class, ui.value.ring, ui.value.margin), vProps.class);
|
|
40
|
+
return cloneVNode(node, vProps);
|
|
41
|
+
}
|
|
42
|
+
if (max.value !== void 0 && index === max.value) {
|
|
43
|
+
return h(Avatar, {
|
|
44
|
+
size: props.size || appConfig2.ui.avatar.default.size,
|
|
45
|
+
text: `+${children.value.length - max.value}`,
|
|
46
|
+
class: twJoin(ui.value.ring, ui.value.margin)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}).filter(Boolean).reverse());
|
|
51
|
+
return () => h("div", { class: twMerge(ui.value.wrapper, attrs.class), ...omit(attrs, ["class"]) }, clones.value);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span :class="badgeClass" v-bind="attrs">
|
|
3
|
+
<slot>{{ label }}</slot>
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { computed, defineComponent } from "vue";
|
|
9
|
+
import { omit } from "lodash-es";
|
|
10
|
+
import { twMerge, twJoin } from "tailwind-merge";
|
|
11
|
+
import { defuTwMerge } from "../../utils";
|
|
12
|
+
import { useAppConfig } from "#imports";
|
|
13
|
+
import appConfig from "#build/app.config";
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
inheritAttrs: false,
|
|
16
|
+
props: {
|
|
17
|
+
size: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: () => appConfig.ui.badge.default.size,
|
|
20
|
+
validator(value) {
|
|
21
|
+
return Object.keys(appConfig.ui.badge.size).includes(value);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
color: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: () => appConfig.ui.badge.default.color,
|
|
27
|
+
validator(value) {
|
|
28
|
+
return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.badge.color)].includes(value);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: () => appConfig.ui.badge.default.variant,
|
|
34
|
+
validator(value) {
|
|
35
|
+
return [
|
|
36
|
+
...Object.keys(appConfig.ui.badge.variant),
|
|
37
|
+
...Object.values(appConfig.ui.badge.color).flatMap((value2) => Object.keys(value2))
|
|
38
|
+
].includes(value);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
label: {
|
|
42
|
+
type: [String, Number],
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
ui: {
|
|
46
|
+
type: Object,
|
|
47
|
+
default: () => ({})
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
setup(props, { attrs }) {
|
|
51
|
+
const appConfig2 = useAppConfig();
|
|
52
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.badge));
|
|
53
|
+
const badgeClass = computed(() => {
|
|
54
|
+
const variant = ui.value.color?.[props.color]?.[props.variant] || ui.value.variant[props.variant];
|
|
55
|
+
return twMerge(twJoin(
|
|
56
|
+
ui.value.base,
|
|
57
|
+
ui.value.font,
|
|
58
|
+
ui.value.rounded,
|
|
59
|
+
ui.value.size[props.size],
|
|
60
|
+
variant?.replaceAll("{color}", props.color)
|
|
61
|
+
), attrs.class);
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
attrs: omit(attrs, ["class"]),
|
|
65
|
+
badgeClass
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
</script>
|