vueless 0.0.531 → 0.0.533
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/package.json +1 -1
- package/types.ts +18 -0
- package/ui.container-group/types.ts +0 -1
- package/ui.image-avatar/UAvatar.vue +51 -115
- package/ui.image-avatar/storybook/Docs.mdx +2 -2
- package/ui.image-avatar/storybook/{stories.js → stories.ts} +13 -5
- package/ui.image-avatar/types.ts +71 -0
- package/ui.image-avatar/useAttrs.ts +18 -0
- package/ui.image-icon/UIcon.vue +28 -113
- package/ui.image-icon/storybook/Docs.mdx +1 -1
- package/ui.image-icon/storybook/{stories.js → stories.ts} +13 -5
- package/ui.image-icon/types.ts +83 -0
- package/ui.image-icon/useAttrs.ts +18 -0
- package/ui.loader/ULoader.vue +21 -41
- package/ui.loader/storybook/Docs.mdx +2 -2
- package/ui.loader/storybook/{stories.js → stories.ts} +15 -7
- package/ui.loader/types.ts +47 -0
- package/ui.loader/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.loader-overlay/ULoaderOverlay.vue +23 -35
- package/ui.loader-overlay/storybook/Docs.mdx +2 -2
- package/ui.loader-overlay/storybook/{stories.js → stories.ts} +22 -7
- package/ui.loader-overlay/types.ts +42 -0
- package/ui.loader-overlay/{useAttrs.js → useAttrs.ts} +5 -2
- package/ui.loader-overlay/useLoaderOverlay.ts +42 -0
- package/ui.loader-overlay/{utilLoaderOverlay.js → utilLoaderOverlay.ts} +2 -2
- package/ui.loader-progress/ULoaderProgress.vue +34 -49
- package/ui.loader-progress/{config.js → config.ts} +1 -0
- package/ui.loader-progress/storybook/Docs.mdx +2 -2
- package/ui.loader-progress/storybook/{stories.js → stories.ts} +24 -7
- package/ui.loader-progress/types.ts +46 -0
- package/ui.loader-progress/useAttrs.ts +36 -0
- package/ui.loader-progress/useLoaderProgress.ts +81 -0
- package/ui.loader-progress/utilLoaderProgress.ts +49 -0
- package/ui.navigation-pagination/UPagination.vue +141 -262
- package/ui.navigation-pagination/storybook/Docs.mdx +2 -2
- package/ui.navigation-pagination/storybook/{stories.js → stories.ts} +11 -4
- package/ui.navigation-pagination/types.ts +85 -0
- package/ui.navigation-pagination/{useAttrs.js → useAttrs.ts} +5 -2
- package/ui.navigation-progress/StepperProgress.vue +26 -47
- package/ui.navigation-progress/UProgress.vue +60 -118
- package/ui.navigation-progress/{config.js → config.ts} +1 -0
- package/ui.navigation-progress/storybook/Docs.mdx +2 -2
- package/ui.navigation-progress/storybook/{stories.js → stories.ts} +19 -7
- package/ui.navigation-progress/types.ts +93 -0
- package/ui.navigation-progress/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.navigation-tab/UTab.vue +18 -54
- package/ui.navigation-tab/storybook/Docs.mdx +2 -2
- package/ui.navigation-tab/storybook/{stories.js → stories.ts} +10 -5
- package/ui.navigation-tab/types.ts +30 -0
- package/ui.navigation-tab/{useAttrs.js → useAttrs.ts} +15 -3
- package/ui.navigation-tabs/UTabs.vue +29 -78
- package/ui.navigation-tabs/storybook/Docs.mdx +2 -2
- package/ui.navigation-tabs/storybook/{stories.js → stories.ts} +13 -5
- package/ui.navigation-tabs/types.ts +37 -0
- package/ui.navigation-tabs/useAttrs.ts +18 -0
- package/web-types.json +200 -84
- package/ui.image-avatar/useAttrs.js +0 -15
- package/ui.image-icon/useAttrs.js +0 -15
- package/ui.loader-overlay/useLoaderOverlay.js +0 -25
- package/ui.loader-progress/useAttrs.js +0 -15
- package/ui.loader-progress/useLoaderProgress.js +0 -65
- package/ui.loader-progress/utilLoaderProgress.js +0 -49
- package/ui.navigation-tabs/useAttrs.js +0 -15
- /package/ui.image-avatar/{config.js → config.ts} +0 -0
- /package/ui.image-avatar/{constants.js → constants.ts} +0 -0
- /package/ui.image-icon/{constants.js → constants.ts} +0 -0
- /package/ui.loader/{config.js → config.ts} +0 -0
- /package/ui.loader/{constants.js → constants.ts} +0 -0
- /package/ui.loader-overlay/{config.js → config.ts} +0 -0
- /package/ui.loader-overlay/{constants.js → constants.ts} +0 -0
- /package/ui.loader-progress/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-pagination/{config.js → config.ts} +0 -0
- /package/ui.navigation-pagination/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-progress/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-tab/{config.js → config.ts} +0 -0
- /package/ui.navigation-tab/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-tabs/{config.js → config.ts} +0 -0
- /package/ui.navigation-tabs/{constants.js → constants.ts} +0 -0
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -32,6 +32,15 @@ import UModalConfig from "./ui.container-modal/config.ts";
|
|
|
32
32
|
import UModalConfirmConfig from "./ui.container-modal-confirm/config.ts";
|
|
33
33
|
import UPageConfig from "./ui.container-page/config.ts";
|
|
34
34
|
import URowConfig from "./ui.container-row/config.ts";
|
|
35
|
+
import ULoaderConfig from "./ui.loader/config.ts";
|
|
36
|
+
import ULoaderOverlayConfig from "./ui.loader-overlay/config.ts";
|
|
37
|
+
import ULoaderProgressConfig from "./ui.loader-progress/config.ts";
|
|
38
|
+
import UPaginationConfig from "./ui.navigation-pagination/config.ts";
|
|
39
|
+
import UProgressConfig from "./ui.navigation-progress/config.ts";
|
|
40
|
+
import UTabConfig from "./ui.navigation-tab/config.ts";
|
|
41
|
+
import UTabsConfig from "./ui.navigation-tabs/config.ts";
|
|
42
|
+
import UAvatarConfig from "./ui.image-avatar/config.ts";
|
|
43
|
+
import UIconConfig from "./ui.image-icon/config.ts";
|
|
35
44
|
|
|
36
45
|
import type { ComputedRef, MaybeRef, Ref } from "vue";
|
|
37
46
|
import type { Props } from "tippy.js";
|
|
@@ -175,6 +184,15 @@ export interface Components {
|
|
|
175
184
|
UModalConfirm?: Partial<typeof UModalConfirmConfig>;
|
|
176
185
|
UPage?: Partial<typeof UPageConfig>;
|
|
177
186
|
URow?: Partial<typeof URowConfig>;
|
|
187
|
+
ULoader?: Partial<typeof ULoaderConfig>;
|
|
188
|
+
ULoaderOverlay?: Partial<typeof ULoaderOverlayConfig>;
|
|
189
|
+
ULoaderProgress?: Partial<typeof ULoaderProgressConfig>;
|
|
190
|
+
UPagination?: Partial<typeof UPaginationConfig>;
|
|
191
|
+
UProgress?: Partial<typeof UProgressConfig>;
|
|
192
|
+
UTab?: Partial<typeof UTabConfig>;
|
|
193
|
+
UTabs?: Partial<typeof UTabsConfig>;
|
|
194
|
+
UAvatar?: Partial<typeof UAvatarConfig>;
|
|
195
|
+
UIcon?: Partial<typeof UIconConfig>;
|
|
178
196
|
}
|
|
179
197
|
|
|
180
198
|
export interface Directives {
|
|
@@ -1,125 +1,24 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div
|
|
3
|
-
:title="label"
|
|
4
|
-
:style="backgroundImage"
|
|
5
|
-
:data-test="dataTest"
|
|
6
|
-
v-bind="avatarAttrs"
|
|
7
|
-
@click="onClick"
|
|
8
|
-
>
|
|
9
|
-
<template v-if="!backgroundImage">
|
|
10
|
-
<template v-if="labelFirstLetters">{{ labelFirstLetters }}</template>
|
|
11
|
-
<!--
|
|
12
|
-
@slot Use it to add something instead of the avatar image placeholder.
|
|
13
|
-
@binding {string} icon-name
|
|
14
|
-
@binding {string} icon-color
|
|
15
|
-
@binding {string} icon-size
|
|
16
|
-
-->
|
|
17
|
-
<slot
|
|
18
|
-
v-else
|
|
19
|
-
name="placeholder"
|
|
20
|
-
:icon-name="placeholderIcon"
|
|
21
|
-
:icon-color="componentColor"
|
|
22
|
-
:icon-size="size"
|
|
23
|
-
>
|
|
24
|
-
<UIcon
|
|
25
|
-
internal
|
|
26
|
-
:size="size"
|
|
27
|
-
:color="componentColor"
|
|
28
|
-
:name="placeholderIcon"
|
|
29
|
-
v-bind="placeholderIconAttrs"
|
|
30
|
-
/>
|
|
31
|
-
</slot>
|
|
32
|
-
</template>
|
|
33
|
-
</div>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
37
2
|
import { computed } from "vue";
|
|
38
3
|
|
|
39
4
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
40
5
|
import { getDefault } from "../utils/ui.ts";
|
|
41
6
|
|
|
42
|
-
import { UAvatar } from "./constants.
|
|
43
|
-
import defaultConfig from "./config.
|
|
44
|
-
import useAttrs from "./useAttrs.
|
|
45
|
-
|
|
46
|
-
defineOptions({ inheritAttrs: false });
|
|
47
|
-
|
|
48
|
-
const props = defineProps({
|
|
49
|
-
/**
|
|
50
|
-
* Avatar image source.
|
|
51
|
-
*/
|
|
52
|
-
src: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: "",
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Avatar label (username, nickname, etc.).
|
|
59
|
-
*/
|
|
60
|
-
label: {
|
|
61
|
-
type: String,
|
|
62
|
-
default: "",
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Avatar placeholder icon.
|
|
67
|
-
*/
|
|
68
|
-
placeholderIcon: {
|
|
69
|
-
type: String,
|
|
70
|
-
default: getDefault(defaultConfig, UAvatar).placeholderIcon,
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Avatar size.
|
|
75
|
-
* @values 3xs, 2xs, xs, sm, md, lg, xl, 2xl, 3xl
|
|
76
|
-
*/
|
|
77
|
-
size: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: getDefault(defaultConfig, UAvatar).size,
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Avatar color.
|
|
84
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
85
|
-
*/
|
|
86
|
-
color: {
|
|
87
|
-
type: String,
|
|
88
|
-
default: getDefault(defaultConfig, UAvatar).color,
|
|
89
|
-
},
|
|
7
|
+
import { UAvatar } from "./constants.ts";
|
|
8
|
+
import defaultConfig from "./config.ts";
|
|
9
|
+
import useAttrs from "./useAttrs.ts";
|
|
90
10
|
|
|
91
|
-
|
|
92
|
-
* Avatar corner rounding.
|
|
93
|
-
* @values dynamic, none, sm, md, lg, full
|
|
94
|
-
*/
|
|
95
|
-
rounded: {
|
|
96
|
-
type: String,
|
|
97
|
-
default: getDefault(defaultConfig, UAvatar).rounded,
|
|
98
|
-
},
|
|
11
|
+
import type { UAvatarProps } from "./types.ts";
|
|
99
12
|
|
|
100
|
-
|
|
101
|
-
* Add border to the avatar.
|
|
102
|
-
*/
|
|
103
|
-
bordered: {
|
|
104
|
-
type: Boolean,
|
|
105
|
-
default: getDefault(defaultConfig, UAvatar).bordered,
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Component config object.
|
|
110
|
-
*/
|
|
111
|
-
config: {
|
|
112
|
-
type: Object,
|
|
113
|
-
default: () => ({}),
|
|
114
|
-
},
|
|
13
|
+
defineOptions({ inheritAttrs: false });
|
|
115
14
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
15
|
+
const props = withDefaults(defineProps<UAvatarProps>(), {
|
|
16
|
+
placeholderIcon: getDefault<UAvatarProps>(defaultConfig, UAvatar).placeholderIcon,
|
|
17
|
+
size: getDefault<UAvatarProps>(defaultConfig, UAvatar).size,
|
|
18
|
+
color: getDefault<UAvatarProps>(defaultConfig, UAvatar).color,
|
|
19
|
+
rounded: getDefault<UAvatarProps>(defaultConfig, UAvatar).rounded,
|
|
20
|
+
bordered: getDefault<UAvatarProps>(defaultConfig, UAvatar).bordered,
|
|
21
|
+
dataTest: "",
|
|
123
22
|
});
|
|
124
23
|
|
|
125
24
|
const emit = defineEmits([
|
|
@@ -132,6 +31,8 @@ const emit = defineEmits([
|
|
|
132
31
|
const { avatarAttrs, placeholderIconAttrs } = useAttrs(props);
|
|
133
32
|
|
|
134
33
|
const labelFirstLetters = computed(() => {
|
|
34
|
+
if (!props.label) return "";
|
|
35
|
+
|
|
135
36
|
const [firstWord, secondWord] = props.label.split(" ");
|
|
136
37
|
|
|
137
38
|
const firstWordLetter = firstWord ? firstWord[0].toUpperCase() : "";
|
|
@@ -151,7 +52,42 @@ const componentColor = computed(() => {
|
|
|
151
52
|
return props.color === "white" ? "grayscale" : props.color;
|
|
152
53
|
});
|
|
153
54
|
|
|
154
|
-
function onClick(event) {
|
|
55
|
+
function onClick(event: Event) {
|
|
155
56
|
emit("click", event);
|
|
156
57
|
}
|
|
157
58
|
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div
|
|
62
|
+
:title="label"
|
|
63
|
+
:style="backgroundImage"
|
|
64
|
+
:data-test="dataTest"
|
|
65
|
+
v-bind="avatarAttrs"
|
|
66
|
+
@click="onClick"
|
|
67
|
+
>
|
|
68
|
+
<template v-if="!backgroundImage">
|
|
69
|
+
<template v-if="labelFirstLetters">{{ labelFirstLetters }}</template>
|
|
70
|
+
<!--
|
|
71
|
+
@slot Use it to add something instead of the avatar image placeholder.
|
|
72
|
+
@binding {string} icon-name
|
|
73
|
+
@binding {string} icon-color
|
|
74
|
+
@binding {string} icon-size
|
|
75
|
+
-->
|
|
76
|
+
<slot
|
|
77
|
+
v-else
|
|
78
|
+
name="placeholder"
|
|
79
|
+
:icon-name="placeholderIcon"
|
|
80
|
+
:icon-color="componentColor"
|
|
81
|
+
:icon-size="size"
|
|
82
|
+
>
|
|
83
|
+
<UIcon
|
|
84
|
+
internal
|
|
85
|
+
:size="size"
|
|
86
|
+
:color="componentColor"
|
|
87
|
+
:name="placeholderIcon"
|
|
88
|
+
v-bind="placeholderIconAttrs"
|
|
89
|
+
/>
|
|
90
|
+
</slot>
|
|
91
|
+
</template>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
5
|
-
import defaultConfig from "../config.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -5,6 +5,14 @@ import URow from "../../ui.container-row/URow.vue";
|
|
|
5
5
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
6
6
|
import ULoader from "../../ui.loader/ULoader.vue";
|
|
7
7
|
|
|
8
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
9
|
+
import type { UAvatarProps } from "../types.ts";
|
|
10
|
+
|
|
11
|
+
interface UAvatarArgs extends UAvatarProps {
|
|
12
|
+
slotTemplate?: string;
|
|
13
|
+
enum: "size" | "rounded" | "color";
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `UAvatar` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.image-avatar)
|
|
10
18
|
*/
|
|
@@ -15,9 +23,9 @@ export default {
|
|
|
15
23
|
argTypes: {
|
|
16
24
|
...getArgTypes(UAvatar.__name),
|
|
17
25
|
},
|
|
18
|
-
};
|
|
26
|
+
} as Meta;
|
|
19
27
|
|
|
20
|
-
const DefaultTemplate = (args) => ({
|
|
28
|
+
const DefaultTemplate: StoryFn<UAvatarArgs> = (args: UAvatarArgs) => ({
|
|
21
29
|
components: { UAvatar, ULoader },
|
|
22
30
|
setup() {
|
|
23
31
|
const slots = getSlotNames(UAvatar.__name);
|
|
@@ -26,17 +34,17 @@ const DefaultTemplate = (args) => ({
|
|
|
26
34
|
},
|
|
27
35
|
template: `
|
|
28
36
|
<UAvatar v-bind="args">
|
|
29
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
37
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
30
38
|
</UAvatar>
|
|
31
39
|
`,
|
|
32
40
|
});
|
|
33
41
|
|
|
34
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
42
|
+
const EnumVariantTemplate: StoryFn<UAvatarArgs> = (args: UAvatarArgs, { argTypes }) => ({
|
|
35
43
|
components: { UCol, URow, UAvatar },
|
|
36
44
|
setup() {
|
|
37
45
|
return {
|
|
38
46
|
args,
|
|
39
|
-
options: argTypes[args.enum]
|
|
47
|
+
options: argTypes?.[args.enum]?.options,
|
|
40
48
|
};
|
|
41
49
|
},
|
|
42
50
|
template: `
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UAvatarProps {
|
|
6
|
+
/**
|
|
7
|
+
* Avatar image source.
|
|
8
|
+
*/
|
|
9
|
+
src?: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Avatar label (username, nickname, etc.).
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Avatar placeholder icon.
|
|
18
|
+
*/
|
|
19
|
+
placeholderIcon?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Avatar size.
|
|
23
|
+
*/
|
|
24
|
+
size?: "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Avatar color.
|
|
28
|
+
*/
|
|
29
|
+
color?:
|
|
30
|
+
| "brand"
|
|
31
|
+
| "grayscale"
|
|
32
|
+
| "gray"
|
|
33
|
+
| "red"
|
|
34
|
+
| "orange"
|
|
35
|
+
| "amber"
|
|
36
|
+
| "yellow"
|
|
37
|
+
| "lime"
|
|
38
|
+
| "green"
|
|
39
|
+
| "emerald"
|
|
40
|
+
| "teal"
|
|
41
|
+
| "cyan"
|
|
42
|
+
| "sky"
|
|
43
|
+
| "blue"
|
|
44
|
+
| "indigo"
|
|
45
|
+
| "violet"
|
|
46
|
+
| "purple"
|
|
47
|
+
| "fuchsia"
|
|
48
|
+
| "pink"
|
|
49
|
+
| "rose"
|
|
50
|
+
| "white";
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Avatar corner rounding.
|
|
54
|
+
*/
|
|
55
|
+
rounded?: "dynamic" | "none" | "sm" | "md" | "lg" | "full";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Add border to the avatar.
|
|
59
|
+
*/
|
|
60
|
+
bordered?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Component config object.
|
|
64
|
+
*/
|
|
65
|
+
config?: Partial<typeof defaultConfig>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Data-test attribute for automated testing.
|
|
69
|
+
*/
|
|
70
|
+
dataTest?: string;
|
|
71
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import useUI from "../composables/useUI.ts";
|
|
2
|
+
|
|
3
|
+
import defaultConfig from "./config.ts";
|
|
4
|
+
|
|
5
|
+
import type { UseAttrs } from "../types.ts";
|
|
6
|
+
import type { UAvatarProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UAvatarProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
|
10
|
+
|
|
11
|
+
const keysAttrs = getKeysAttrs();
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
config,
|
|
15
|
+
...keysAttrs,
|
|
16
|
+
hasSlotContent,
|
|
17
|
+
};
|
|
18
|
+
}
|
package/ui.image-icon/UIcon.vue
CHANGED
|
@@ -1,120 +1,24 @@
|
|
|
1
|
-
<
|
|
2
|
-
<component
|
|
3
|
-
:is="dynamicComponent"
|
|
4
|
-
v-tooltip="tooltipConfig"
|
|
5
|
-
tabindex="-1"
|
|
6
|
-
v-bind="iconAttrs"
|
|
7
|
-
:data-test="dataTest"
|
|
8
|
-
@click="onClick"
|
|
9
|
-
/>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
13
2
|
import { computed, defineAsyncComponent } from "vue";
|
|
14
3
|
import { vTooltip } from "../directives";
|
|
15
4
|
import { getDefault } from "../utils/ui.ts";
|
|
16
5
|
import { isSSR } from "../utils/helper.ts";
|
|
17
6
|
import { VUELESS_ICONS_CACHED_DIR, VUELESS_LIBRARY } from "../constants.js";
|
|
18
7
|
|
|
19
|
-
import { UIcon } from "./constants.
|
|
8
|
+
import { UIcon } from "./constants.ts";
|
|
20
9
|
import defaultConfig from "./config.ts";
|
|
21
|
-
import useAttrs from "./useAttrs.
|
|
22
|
-
|
|
23
|
-
defineOptions({ inheritAttrs: false });
|
|
24
|
-
|
|
25
|
-
const props = defineProps({
|
|
26
|
-
/**
|
|
27
|
-
* Icon name.
|
|
28
|
-
*/
|
|
29
|
-
name: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: "",
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Icon source (svg as a vue component).
|
|
36
|
-
*/
|
|
37
|
-
src: {
|
|
38
|
-
type: Object,
|
|
39
|
-
default: () => {},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Icon color.
|
|
44
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, black, white
|
|
45
|
-
*/
|
|
46
|
-
color: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: getDefault(defaultConfig, UIcon).color,
|
|
49
|
-
},
|
|
10
|
+
import useAttrs from "./useAttrs.ts";
|
|
50
11
|
|
|
51
|
-
|
|
52
|
-
* Icon size.
|
|
53
|
-
* @values 4xs, 3xs, 2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl
|
|
54
|
-
*/
|
|
55
|
-
size: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: getDefault(defaultConfig, UIcon).size,
|
|
58
|
-
},
|
|
12
|
+
import type { UIconProps } from "./types.ts";
|
|
59
13
|
|
|
60
|
-
|
|
61
|
-
* Icon variant.
|
|
62
|
-
* @values light, default, dark
|
|
63
|
-
*/
|
|
64
|
-
variant: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: getDefault(defaultConfig, UIcon).variant,
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Make the icon interactive (cursor pointer, etc.).
|
|
71
|
-
*/
|
|
72
|
-
interactive: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: getDefault(defaultConfig, UIcon).interactive,
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Add tooltip text on hover.
|
|
79
|
-
*/
|
|
80
|
-
tooltip: {
|
|
81
|
-
type: String,
|
|
82
|
-
default: "",
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Tooltip settings.
|
|
87
|
-
* [See all settings here](https://kabbouchi.github.io/vue-tippy/4.0/features/placement.html).
|
|
88
|
-
*/
|
|
89
|
-
tooltipSettings: {
|
|
90
|
-
type: Object,
|
|
91
|
-
default: () => {},
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Component config object.
|
|
96
|
-
*/
|
|
97
|
-
config: {
|
|
98
|
-
type: Object,
|
|
99
|
-
default: () => ({}),
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Data-test attribute for automated testing.
|
|
104
|
-
*/
|
|
105
|
-
dataTest: {
|
|
106
|
-
type: String,
|
|
107
|
-
default: "",
|
|
108
|
-
},
|
|
14
|
+
defineOptions({ inheritAttrs: false });
|
|
109
15
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
default: false,
|
|
117
|
-
},
|
|
16
|
+
const props = withDefaults(defineProps<UIconProps>(), {
|
|
17
|
+
color: getDefault<UIconProps>(defaultConfig, UIcon).color,
|
|
18
|
+
size: getDefault<UIconProps>(defaultConfig, UIcon).size,
|
|
19
|
+
variant: getDefault<UIconProps>(defaultConfig, UIcon).variant,
|
|
20
|
+
interactive: getDefault<UIconProps>(defaultConfig, UIcon).interactive,
|
|
21
|
+
dataTest: "",
|
|
118
22
|
});
|
|
119
23
|
|
|
120
24
|
const emit = defineEmits([
|
|
@@ -144,11 +48,11 @@ const dynamicComponent = computed(() => {
|
|
|
144
48
|
generatedIcons.value.find(([path]) => path.includes(VUELESS_LIBRARY + "/" + props.name)),
|
|
145
49
|
);
|
|
146
50
|
|
|
147
|
-
const userLibrary = config.value
|
|
51
|
+
const userLibrary = config.value?.defaults?.library;
|
|
148
52
|
const library = props.internal && isInternalIcon ? VUELESS_LIBRARY : userLibrary;
|
|
149
|
-
const weight = config.value
|
|
150
|
-
const style = config.value
|
|
151
|
-
const isFill = props.name
|
|
53
|
+
const weight = config.value?.defaults?.weight;
|
|
54
|
+
const style = config.value?.defaults?.style;
|
|
55
|
+
const isFill = props.name?.endsWith(FILL_SUFFIX);
|
|
152
56
|
const name = props.name;
|
|
153
57
|
const src = props.src;
|
|
154
58
|
|
|
@@ -161,7 +65,7 @@ const dynamicComponent = computed(() => {
|
|
|
161
65
|
/* Dynamic import */
|
|
162
66
|
if (!name) return "";
|
|
163
67
|
|
|
164
|
-
function getIcon(params) {
|
|
68
|
+
function getIcon(params: Array<string | number | undefined>) {
|
|
165
69
|
const [, component] =
|
|
166
70
|
generatedIcons.value.find(([path]) =>
|
|
167
71
|
params.every(
|
|
@@ -216,7 +120,18 @@ const tooltipConfig = computed(() => ({
|
|
|
216
120
|
content: props.tooltip,
|
|
217
121
|
}));
|
|
218
122
|
|
|
219
|
-
function onClick(event) {
|
|
123
|
+
function onClick(event: Event) {
|
|
220
124
|
emit("click", event);
|
|
221
125
|
}
|
|
222
126
|
</script>
|
|
127
|
+
|
|
128
|
+
<template>
|
|
129
|
+
<component
|
|
130
|
+
:is="dynamicComponent"
|
|
131
|
+
v-tooltip="tooltipConfig"
|
|
132
|
+
tabindex="-1"
|
|
133
|
+
v-bind="iconAttrs"
|
|
134
|
+
:data-test="dataTest"
|
|
135
|
+
@click="onClick"
|
|
136
|
+
/>
|
|
137
|
+
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
5
|
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
@@ -3,6 +3,14 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
|
|
|
3
3
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
4
4
|
import URow from "../../ui.container-row/URow.vue";
|
|
5
5
|
|
|
6
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
7
|
+
import type { UIconProps } from "../types.ts";
|
|
8
|
+
|
|
9
|
+
interface UIconArgs extends UIconProps {
|
|
10
|
+
slotTemplate?: string;
|
|
11
|
+
enum: "color" | "size" | "variant";
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* The `UIcon` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.image-icon)
|
|
8
16
|
*/
|
|
@@ -16,9 +24,9 @@ export default {
|
|
|
16
24
|
argTypes: {
|
|
17
25
|
...getArgTypes(UIcon.__name),
|
|
18
26
|
},
|
|
19
|
-
};
|
|
27
|
+
} as Meta;
|
|
20
28
|
|
|
21
|
-
const DefaultTemplate = (args) => ({
|
|
29
|
+
const DefaultTemplate: StoryFn<UIconArgs> = (args: UIconArgs) => ({
|
|
22
30
|
components: { UIcon },
|
|
23
31
|
setup() {
|
|
24
32
|
const slots = getSlotNames(UIcon.__name);
|
|
@@ -27,17 +35,17 @@ const DefaultTemplate = (args) => ({
|
|
|
27
35
|
},
|
|
28
36
|
template: `
|
|
29
37
|
<UIcon v-bind="args">
|
|
30
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
38
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
31
39
|
</UIcon>
|
|
32
40
|
`,
|
|
33
41
|
});
|
|
34
42
|
|
|
35
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
43
|
+
const EnumVariantTemplate: StoryFn<UIconArgs> = (args: UIconArgs, { argTypes }) => ({
|
|
36
44
|
components: { UIcon, URow },
|
|
37
45
|
setup() {
|
|
38
46
|
return {
|
|
39
47
|
args,
|
|
40
|
-
options: argTypes[args.enum]
|
|
48
|
+
options: argTypes?.[args.enum]?.options,
|
|
41
49
|
};
|
|
42
50
|
},
|
|
43
51
|
template: `
|