vueless 0.0.503 → 0.0.505
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/plugin-vite.d.ts +43 -11
- package/types.ts +31 -3
- package/ui.button/UButton.vue +101 -240
- package/ui.button/storybook/Docs.mdx +2 -2
- package/ui.button/storybook/{stories.js → stories.ts} +25 -12
- package/ui.button/types.ts +121 -0
- package/ui.button/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.button-link/ULink.vue +72 -223
- package/ui.button-link/storybook/Docs.mdx +2 -2
- package/ui.button-link/storybook/{stories.js → stories.ts} +30 -17
- package/ui.button-link/types.ts +131 -0
- package/ui.button-link/{useAttrs.js → useAttrs.ts} +15 -3
- package/ui.button-toggle/UToggle.vue +47 -165
- package/ui.button-toggle/storybook/Docs.mdx +2 -2
- package/ui.button-toggle/storybook/{stories.js → stories.ts} +13 -5
- package/ui.button-toggle/types.ts +85 -0
- package/ui.button-toggle/useAttrs.ts +18 -0
- package/ui.button-toggle-item/UToggleItem.vue +59 -110
- package/ui.button-toggle-item/storybook/Docs.mdx +2 -2
- package/ui.button-toggle-item/storybook/{stories.js → stories.ts} +10 -3
- package/ui.button-toggle-item/types.ts +40 -0
- package/ui.button-toggle-item/{useAttrs.js → useAttrs.ts} +16 -4
- package/ui.other-dot/UDot.vue +14 -42
- package/ui.other-dot/storybook/Docs.mdx +2 -2
- package/ui.other-dot/storybook/{stories.js → stories.ts} +13 -5
- package/ui.other-dot/types.ts +46 -0
- package/ui.other-dot/useAttrs.ts +18 -0
- package/ui.text-alert/UAlert.vue +85 -157
- package/ui.text-alert/storybook/Docs.mdx +2 -2
- package/ui.text-alert/storybook/{stories.js → stories.ts} +17 -9
- package/ui.text-alert/types.ts +76 -0
- package/ui.text-alert/useAttrs.ts +18 -0
- package/ui.text-badge/UBadge.vue +1 -0
- package/ui.text-badge/storybook/stories.ts +1 -8
- package/ui.text-badge/types.ts +2 -0
- package/ui.text-badge/useAttrs.ts +1 -3
- package/ui.text-block/UText.vue +1 -0
- package/ui.text-block/storybook/stories.ts +1 -1
- package/ui.text-block/types.ts +2 -0
- package/ui.text-block/useAttrs.ts +1 -1
- package/ui.text-empty/UEmpty.vue +39 -75
- package/ui.text-empty/storybook/Docs.mdx +2 -2
- package/ui.text-empty/storybook/{stories.js → stories.ts} +14 -6
- package/ui.text-empty/types.ts +30 -0
- package/ui.text-empty/useAttrs.ts +18 -0
- package/ui.text-file/UFile.vue +49 -109
- package/ui.text-file/storybook/Docs.mdx +2 -2
- package/ui.text-file/storybook/{stories.js → stories.ts} +10 -3
- package/ui.text-file/types.ts +45 -0
- package/ui.text-file/useAttrs.ts +18 -0
- package/ui.text-files/UFiles.vue +46 -106
- package/ui.text-files/storybook/Docs.mdx +2 -2
- package/ui.text-files/storybook/{stories.js → stories.ts} +10 -3
- package/ui.text-files/types.ts +45 -0
- package/ui.text-files/useAttrs.ts +18 -0
- package/ui.text-header/UHeader.vue +19 -76
- package/ui.text-header/storybook/Docs.mdx +2 -2
- package/ui.text-header/storybook/{stories.js → stories.ts} +13 -5
- package/ui.text-header/types.ts +66 -0
- package/ui.text-header/useAttrs.ts +18 -0
- package/ui.text-money/UMoney.vue +58 -168
- package/ui.text-money/storybook/Docs.mdx +2 -2
- package/ui.text-money/storybook/{stories.js → stories.ts} +13 -5
- package/ui.text-money/types.ts +101 -0
- package/ui.text-money/useAttrs.ts +18 -0
- package/ui.text-money/{utilMoney.js → utilMoney.ts} +1 -1
- package/ui.text-notify/UNotify.vue +89 -116
- package/ui.text-notify/storybook/Docs.mdx +2 -2
- package/ui.text-notify/storybook/{stories.js → stories.ts} +12 -5
- package/ui.text-notify/types.ts +25 -0
- package/ui.text-notify/useAttrs.ts +18 -0
- package/ui.text-notify/utilNotify.ts +140 -0
- package/web-types.json +285 -135
- package/ui.button-toggle/useAttrs.js +0 -15
- package/ui.other-dot/useAttrs.js +0 -15
- package/ui.text-alert/useAttrs.js +0 -15
- package/ui.text-empty/useAttrs.js +0 -15
- package/ui.text-file/useAttrs.js +0 -15
- package/ui.text-files/useAttrs.js +0 -15
- package/ui.text-header/useAttrs.js +0 -15
- package/ui.text-money/useAttrs.js +0 -15
- package/ui.text-notify/useAttrs.js +0 -15
- package/ui.text-notify/utilNotify.js +0 -86
- /package/ui.button/{config.js → config.ts} +0 -0
- /package/ui.button/{constants.js → constants.ts} +0 -0
- /package/ui.button-link/{config.js → config.ts} +0 -0
- /package/ui.button-link/{constants.js → constants.ts} +0 -0
- /package/ui.button-toggle/{config.js → config.ts} +0 -0
- /package/ui.button-toggle/{constants.js → constants.ts} +0 -0
- /package/ui.button-toggle-item/{config.js → config.ts} +0 -0
- /package/ui.button-toggle-item/{constants.js → constants.ts} +0 -0
- /package/ui.other-dot/{config.js → config.ts} +0 -0
- /package/ui.other-dot/{constants.js → constants.ts} +0 -0
- /package/ui.text-alert/{config.js → config.ts} +0 -0
- /package/ui.text-alert/{constants.js → constants.ts} +0 -0
- /package/ui.text-empty/{config.js → config.ts} +0 -0
- /package/ui.text-empty/{constants.js → constants.ts} +0 -0
- /package/ui.text-file/{config.js → config.ts} +0 -0
- /package/ui.text-file/{constants.js → constants.ts} +0 -0
- /package/ui.text-files/{config.js → config.ts} +0 -0
- /package/ui.text-files/{constants.js → constants.ts} +0 -0
- /package/ui.text-header/{config.js → config.ts} +0 -0
- /package/ui.text-header/{constants.js → constants.ts} +0 -0
- /package/ui.text-money/{config.js → config.ts} +0 -0
- /package/ui.text-money/{constants.js → constants.ts} +0 -0
- /package/ui.text-notify/{config.js → config.ts} +0 -0
- /package/ui.text-notify/{constants.js → constants.ts} +0 -0
package/ui.other-dot/UDot.vue
CHANGED
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div v-bind="dotAttrs" :data-test="dataTest" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
6
2
|
import { getDefault } from "../utils/ui.ts";
|
|
7
3
|
|
|
8
|
-
import { UDot } from "./constants.
|
|
9
|
-
import defaultConfig from "./config.
|
|
10
|
-
import useAttrs from "./useAttrs.
|
|
11
|
-
|
|
12
|
-
defineOptions({ inheritAttrs: false });
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
/**
|
|
16
|
-
* Dot color.
|
|
17
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
18
|
-
*/
|
|
19
|
-
color: {
|
|
20
|
-
type: String,
|
|
21
|
-
default: getDefault(defaultConfig, UDot).color,
|
|
22
|
-
},
|
|
4
|
+
import { UDot } from "./constants.ts";
|
|
5
|
+
import defaultConfig from "./config.ts";
|
|
6
|
+
import useAttrs from "./useAttrs.ts";
|
|
23
7
|
|
|
24
|
-
|
|
25
|
-
* Dot size.
|
|
26
|
-
* @values xs, sm, md, lg, xl
|
|
27
|
-
*/
|
|
28
|
-
size: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: getDefault(defaultConfig, UDot).size,
|
|
31
|
-
},
|
|
8
|
+
import type { UDotProps } from "./types.ts";
|
|
32
9
|
|
|
33
|
-
|
|
34
|
-
* Component config object.
|
|
35
|
-
*/
|
|
36
|
-
config: {
|
|
37
|
-
type: Object,
|
|
38
|
-
default: () => ({}),
|
|
39
|
-
},
|
|
10
|
+
defineOptions({ inheritAttrs: false });
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
dataTest:
|
|
45
|
-
type: String,
|
|
46
|
-
default: "",
|
|
47
|
-
},
|
|
12
|
+
const props = withDefaults(defineProps<UDotProps>(), {
|
|
13
|
+
color: getDefault<UDotProps>(defaultConfig, UDot).color,
|
|
14
|
+
size: getDefault<UDotProps>(defaultConfig, UDot).size,
|
|
15
|
+
dataTest: "",
|
|
48
16
|
});
|
|
49
17
|
|
|
50
18
|
const { dotAttrs } = useAttrs(props);
|
|
51
19
|
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div v-bind="dotAttrs" :data-test="dataTest" />
|
|
23
|
+
</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 UBadge from "../../ui.text-badge/UBadge.vue";
|
|
7
7
|
|
|
8
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
9
|
+
import type { UDotProps } from "../types.ts";
|
|
10
|
+
|
|
11
|
+
interface UDotArgs extends UDotProps {
|
|
12
|
+
slotTemplate?: string;
|
|
13
|
+
enum: "size" | "color";
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `UDot` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.other-dot)
|
|
10
18
|
*/
|
|
@@ -15,9 +23,9 @@ export default {
|
|
|
15
23
|
argTypes: {
|
|
16
24
|
...getArgTypes(UDot.__name),
|
|
17
25
|
},
|
|
18
|
-
};
|
|
26
|
+
} as Meta;
|
|
19
27
|
|
|
20
|
-
const DefaultTemplate = (args) => ({
|
|
28
|
+
const DefaultTemplate: StoryFn<UDotArgs> = (args: UDotArgs) => ({
|
|
21
29
|
components: { UDot },
|
|
22
30
|
setup() {
|
|
23
31
|
const slots = getSlotNames(UDot.__name);
|
|
@@ -26,17 +34,17 @@ const DefaultTemplate = (args) => ({
|
|
|
26
34
|
},
|
|
27
35
|
template: `
|
|
28
36
|
<UDot v-bind="args">
|
|
29
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
37
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
30
38
|
</UDot>
|
|
31
39
|
`,
|
|
32
40
|
});
|
|
33
41
|
|
|
34
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
42
|
+
const EnumVariantTemplate: StoryFn<UDotArgs> = (args: UDotArgs, { argTypes }) => ({
|
|
35
43
|
components: { UCol, URow, UDot, UBadge },
|
|
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,46 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UDotProps {
|
|
6
|
+
/**
|
|
7
|
+
* Dot color.
|
|
8
|
+
*/
|
|
9
|
+
color?:
|
|
10
|
+
| "brand"
|
|
11
|
+
| "grayscale"
|
|
12
|
+
| "gray"
|
|
13
|
+
| "red"
|
|
14
|
+
| "orange"
|
|
15
|
+
| "amber"
|
|
16
|
+
| "yellow"
|
|
17
|
+
| "lime"
|
|
18
|
+
| "green"
|
|
19
|
+
| "emerald"
|
|
20
|
+
| "teal"
|
|
21
|
+
| "cyan"
|
|
22
|
+
| "sky"
|
|
23
|
+
| "blue"
|
|
24
|
+
| "indigo"
|
|
25
|
+
| "violet"
|
|
26
|
+
| "purple"
|
|
27
|
+
| "fuchsia"
|
|
28
|
+
| "pink"
|
|
29
|
+
| "rose"
|
|
30
|
+
| "white";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Dot size.
|
|
34
|
+
*/
|
|
35
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Component config object.
|
|
39
|
+
*/
|
|
40
|
+
config?: Partial<typeof defaultConfig>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Data-test attribute for automated testing.
|
|
44
|
+
*/
|
|
45
|
+
dataTest?: string;
|
|
46
|
+
}
|
|
@@ -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 { UDotProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UDotProps): 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.text-alert/UAlert.vue
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { onMounted, ref, computed } from "vue";
|
|
3
|
+
import { getDefault } from "../utils/ui.ts";
|
|
4
|
+
|
|
5
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
6
|
+
import UButton from "../ui.button/UButton.vue";
|
|
7
|
+
import UText from "../ui.text-block/UText.vue";
|
|
8
|
+
|
|
9
|
+
import { UAlert } from "./constants.ts";
|
|
10
|
+
import defaultConfig from "./config.ts";
|
|
11
|
+
import useAttrs from "./useAttrs.ts";
|
|
12
|
+
|
|
13
|
+
import type { UAlertProps } from "./types.ts";
|
|
14
|
+
|
|
15
|
+
defineOptions({ inheritAttrs: false });
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<UAlertProps>(), {
|
|
18
|
+
variant: getDefault<UAlertProps>(defaultConfig, UAlert).variant,
|
|
19
|
+
bordered: getDefault<UAlertProps>(defaultConfig, UAlert).bordered,
|
|
20
|
+
size: getDefault<UAlertProps>(defaultConfig, UAlert).size,
|
|
21
|
+
color: getDefault<UAlertProps>(defaultConfig, UAlert).color,
|
|
22
|
+
timeout: getDefault<UAlertProps>(defaultConfig, UAlert).timeout,
|
|
23
|
+
closable: getDefault<UAlertProps>(defaultConfig, UAlert).closable,
|
|
24
|
+
dataTest: "",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits([
|
|
28
|
+
/**
|
|
29
|
+
* Triggers when the alert is hidden.
|
|
30
|
+
*/
|
|
31
|
+
"hidden",
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const isShownAlert = ref(true);
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
config,
|
|
38
|
+
wrapperAttrs,
|
|
39
|
+
bodyAttrs,
|
|
40
|
+
contentAttrs,
|
|
41
|
+
textAttrs,
|
|
42
|
+
titleAttrs,
|
|
43
|
+
descriptionAttrs,
|
|
44
|
+
closeButtonAttrs,
|
|
45
|
+
closeIconAttrs,
|
|
46
|
+
contentWrapperAttrs,
|
|
47
|
+
hasSlotContent,
|
|
48
|
+
} = useAttrs(props);
|
|
49
|
+
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
if (props.timeout > 0) {
|
|
52
|
+
setTimeout(() => onClickClose(), props.timeout);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function onClickClose() {
|
|
57
|
+
isShownAlert.value = false;
|
|
58
|
+
emit("hidden");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const closeIconSize = computed(() => {
|
|
62
|
+
const sizes = {
|
|
63
|
+
xs: "3xs",
|
|
64
|
+
sm: "2xs",
|
|
65
|
+
md: "xs",
|
|
66
|
+
lg: "sm",
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return sizes[props.size];
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const closeButtonColor = computed(() => {
|
|
73
|
+
if (props.color === "grayscale") return "white";
|
|
74
|
+
if (props.color === "white") return "grayscale";
|
|
75
|
+
|
|
76
|
+
return props.color;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const iconColor = computed(() => {
|
|
80
|
+
if (props.color === "white") return "gray";
|
|
81
|
+
|
|
82
|
+
return props.variant === "primary" ? "white" : props.color;
|
|
83
|
+
});
|
|
84
|
+
</script>
|
|
85
|
+
|
|
1
86
|
<template>
|
|
2
87
|
<div v-if="isShownAlert" :data-test="dataTest" v-bind="wrapperAttrs">
|
|
3
88
|
<!-- @slot Use it to add something above the text. -->
|
|
@@ -76,160 +161,3 @@
|
|
|
76
161
|
<slot name="bottom" />
|
|
77
162
|
</div>
|
|
78
163
|
</template>
|
|
79
|
-
|
|
80
|
-
<script setup>
|
|
81
|
-
import { onMounted, ref, computed } from "vue";
|
|
82
|
-
|
|
83
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
84
|
-
import UButton from "../ui.button/UButton.vue";
|
|
85
|
-
import UText from "../ui.text-block/UText.vue";
|
|
86
|
-
import { getDefault } from "../utils/ui.ts";
|
|
87
|
-
|
|
88
|
-
import { UAlert } from "./constants.js";
|
|
89
|
-
import defaultConfig from "./config.js";
|
|
90
|
-
import useAttrs from "./useAttrs.js";
|
|
91
|
-
|
|
92
|
-
defineOptions({ inheritAttrs: false });
|
|
93
|
-
|
|
94
|
-
const props = defineProps({
|
|
95
|
-
/**
|
|
96
|
-
* Alert title.
|
|
97
|
-
*/
|
|
98
|
-
title: {
|
|
99
|
-
type: String,
|
|
100
|
-
default: "",
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Alert description.
|
|
105
|
-
*/
|
|
106
|
-
description: {
|
|
107
|
-
type: String,
|
|
108
|
-
default: "",
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Alert variant.
|
|
113
|
-
* @values primary, secondary, thirdary
|
|
114
|
-
*/
|
|
115
|
-
variant: {
|
|
116
|
-
type: String,
|
|
117
|
-
default: getDefault(defaultConfig, UAlert).variant,
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Add border to the `thirdary` variant.
|
|
122
|
-
*/
|
|
123
|
-
bordered: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
default: getDefault(defaultConfig, UAlert).bordered,
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Alert size.
|
|
130
|
-
* @values xs, sm, md, lg
|
|
131
|
-
*/
|
|
132
|
-
size: {
|
|
133
|
-
type: String,
|
|
134
|
-
default: getDefault(defaultConfig, UAlert).size,
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Alert color.
|
|
139
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white */
|
|
140
|
-
color: {
|
|
141
|
-
type: String,
|
|
142
|
-
default: getDefault(defaultConfig, UAlert).color,
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Alert timeout.
|
|
147
|
-
*/
|
|
148
|
-
timeout: {
|
|
149
|
-
type: Number,
|
|
150
|
-
default: getDefault(defaultConfig, UAlert).timeout,
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Show close button.
|
|
155
|
-
*/
|
|
156
|
-
closable: {
|
|
157
|
-
type: Boolean,
|
|
158
|
-
default: getDefault(defaultConfig, UAlert).closable,
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Component config object.
|
|
163
|
-
*/
|
|
164
|
-
config: {
|
|
165
|
-
type: Object,
|
|
166
|
-
default: () => ({}),
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Data-test attribute for automated testing.
|
|
171
|
-
*/
|
|
172
|
-
dataTest: {
|
|
173
|
-
type: String,
|
|
174
|
-
default: "",
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const emit = defineEmits([
|
|
179
|
-
/**
|
|
180
|
-
* Triggers when the alert is hidden.
|
|
181
|
-
*/
|
|
182
|
-
"hidden",
|
|
183
|
-
]);
|
|
184
|
-
|
|
185
|
-
const isShownAlert = ref(true);
|
|
186
|
-
|
|
187
|
-
const {
|
|
188
|
-
config,
|
|
189
|
-
wrapperAttrs,
|
|
190
|
-
bodyAttrs,
|
|
191
|
-
contentAttrs,
|
|
192
|
-
textAttrs,
|
|
193
|
-
titleAttrs,
|
|
194
|
-
descriptionAttrs,
|
|
195
|
-
closeButtonAttrs,
|
|
196
|
-
closeIconAttrs,
|
|
197
|
-
contentWrapperAttrs,
|
|
198
|
-
hasSlotContent,
|
|
199
|
-
} = useAttrs(props);
|
|
200
|
-
|
|
201
|
-
onMounted(() => {
|
|
202
|
-
if (props.timeout > 0) {
|
|
203
|
-
setTimeout(() => onClickClose(), props.timeout);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
function onClickClose() {
|
|
208
|
-
isShownAlert.value = false;
|
|
209
|
-
emit("hidden");
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const closeIconSize = computed(() => {
|
|
213
|
-
const sizes = {
|
|
214
|
-
xs: "3xs",
|
|
215
|
-
sm: "2xs",
|
|
216
|
-
md: "xs",
|
|
217
|
-
lg: "sm",
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
return sizes[props.size];
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const closeButtonColor = computed(() => {
|
|
224
|
-
if (props.color === "grayscale") return "white";
|
|
225
|
-
if (props.color === "white") return "grayscale";
|
|
226
|
-
|
|
227
|
-
return props.color;
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const iconColor = computed(() => {
|
|
231
|
-
if (props.color === "white") return "gray";
|
|
232
|
-
|
|
233
|
-
return props.variant === "primary" ? "white" : props.color;
|
|
234
|
-
});
|
|
235
|
-
</script>
|
|
@@ -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} />
|
|
@@ -6,6 +6,14 @@ import UCol from "../../ui.container-col/UCol.vue";
|
|
|
6
6
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
7
7
|
import UButton from "../../ui.button/UButton.vue";
|
|
8
8
|
|
|
9
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
10
|
+
import type { UAlertProps } from "../types.ts";
|
|
11
|
+
|
|
12
|
+
interface UAlertArgs extends UAlertProps {
|
|
13
|
+
slotTemplate?: string;
|
|
14
|
+
enum: "size" | "color" | "variant";
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* The `UAlert` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-alert)
|
|
11
19
|
*/
|
|
@@ -20,9 +28,9 @@ export default {
|
|
|
20
28
|
argTypes: {
|
|
21
29
|
...getArgTypes(UAlert.__name),
|
|
22
30
|
},
|
|
23
|
-
};
|
|
31
|
+
} as Meta;
|
|
24
32
|
|
|
25
|
-
const DefaultTemplate = (args) => ({
|
|
33
|
+
const DefaultTemplate: StoryFn<UAlertArgs> = (args: UAlertArgs) => ({
|
|
26
34
|
components: { UAlert, UIcon, URow, UButton },
|
|
27
35
|
setup() {
|
|
28
36
|
const slots = getSlotNames(UAlert.__name);
|
|
@@ -31,25 +39,25 @@ const DefaultTemplate = (args) => ({
|
|
|
31
39
|
},
|
|
32
40
|
template: `
|
|
33
41
|
<UAlert v-bind="args">
|
|
34
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
42
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
35
43
|
</UAlert>
|
|
36
44
|
`,
|
|
37
45
|
});
|
|
38
46
|
|
|
39
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
47
|
+
const EnumVariantTemplate: StoryFn<UAlertArgs> = (args: UAlertArgs, { argTypes }) => ({
|
|
40
48
|
components: { UAlert, UCol },
|
|
41
49
|
setup() {
|
|
42
|
-
function getText(value) {
|
|
50
|
+
function getText(value: string) {
|
|
43
51
|
return `This is Alert's ${value} size`;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
let prefixedOptions = argTypes[args.enum]
|
|
54
|
+
let prefixedOptions = argTypes?.[args.enum]?.options;
|
|
47
55
|
|
|
48
|
-
if (argTypes[args.enum]
|
|
49
|
-
prefixedOptions = prefixedOptions
|
|
56
|
+
if (argTypes?.[args.enum]?.name === "size") {
|
|
57
|
+
prefixedOptions = prefixedOptions?.map((option) => getText(option));
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
return { args, options: argTypes[args.enum]
|
|
60
|
+
return { args, options: argTypes?.[args.enum]?.options, prefixedOptions };
|
|
53
61
|
},
|
|
54
62
|
template: `
|
|
55
63
|
<UCol align="stretch">
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UAlertProps {
|
|
6
|
+
/**
|
|
7
|
+
* Alert title.
|
|
8
|
+
*/
|
|
9
|
+
title?: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Alert description.
|
|
13
|
+
*/
|
|
14
|
+
description?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Alert variant.
|
|
18
|
+
*/
|
|
19
|
+
variant?: "primary" | "secondary" | "thirdary";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Add border to the `thirdary` variant.
|
|
23
|
+
*/
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Alert size.
|
|
28
|
+
*/
|
|
29
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Alert color.
|
|
33
|
+
*/
|
|
34
|
+
color?:
|
|
35
|
+
| "brand"
|
|
36
|
+
| "grayscale"
|
|
37
|
+
| "gray"
|
|
38
|
+
| "red"
|
|
39
|
+
| "orange"
|
|
40
|
+
| "amber"
|
|
41
|
+
| "yellow"
|
|
42
|
+
| "lime"
|
|
43
|
+
| "green"
|
|
44
|
+
| "emerald"
|
|
45
|
+
| "teal"
|
|
46
|
+
| "cyan"
|
|
47
|
+
| "sky"
|
|
48
|
+
| "blue"
|
|
49
|
+
| "indigo"
|
|
50
|
+
| "violet"
|
|
51
|
+
| "purple"
|
|
52
|
+
| "fuchsia"
|
|
53
|
+
| "pink"
|
|
54
|
+
| "rose"
|
|
55
|
+
| "white";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Alert timeout.
|
|
59
|
+
*/
|
|
60
|
+
timeout?: number;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Show close button.
|
|
64
|
+
*/
|
|
65
|
+
closable?: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Component config object.
|
|
69
|
+
*/
|
|
70
|
+
config?: Partial<typeof defaultConfig>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Data-test attribute for automated testing.
|
|
74
|
+
*/
|
|
75
|
+
dataTest?: string;
|
|
76
|
+
}
|
|
@@ -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 { UAlertProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UAlertProps): 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.text-badge/UBadge.vue
CHANGED
|
@@ -19,6 +19,7 @@ const props = withDefaults(defineProps<UBadgeProps>(), {
|
|
|
19
19
|
color: getDefault<UBadgeProps>(defaultConfig, UBadge).color,
|
|
20
20
|
round: getDefault<UBadgeProps>(defaultConfig, UBadge).round,
|
|
21
21
|
tabindex: getDefault<UBadgeProps>(defaultConfig, UBadge).tabindex,
|
|
22
|
+
dataTest: "",
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
const emit = defineEmits([
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
2
1
|
import {
|
|
3
2
|
getArgTypes,
|
|
4
3
|
getSlotNames,
|
|
@@ -11,6 +10,7 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
11
10
|
import URow from "../../ui.container-row/URow.vue";
|
|
12
11
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
13
12
|
|
|
13
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
14
14
|
import type { UBadgeProps } from "../types.ts";
|
|
15
15
|
|
|
16
16
|
interface UBadgeArgs extends UBadgeProps {
|
|
@@ -83,13 +83,6 @@ const EnumVariantTemplate: StoryFn<UBadgeArgs> = (args: UBadgeArgs, { argTypes }
|
|
|
83
83
|
},
|
|
84
84
|
template: `
|
|
85
85
|
<URow>
|
|
86
|
-
<UDropdownButton
|
|
87
|
-
label="Dropdown"
|
|
88
|
-
:options='[{"label":"option 1"},{"label":"option 2"},{"label":"option 3"}]'
|
|
89
|
-
variant="thirdary"
|
|
90
|
-
filled
|
|
91
|
-
>
|
|
92
|
-
</UDropdownButton>
|
|
93
86
|
<UBadge
|
|
94
87
|
v-for="(option, index) in options"
|
|
95
88
|
:key="index"
|
package/ui.text-badge/types.ts
CHANGED
|
@@ -4,9 +4,7 @@ import useUI from "../composables/useUI.ts";
|
|
|
4
4
|
import defaultConfig from "./config.ts";
|
|
5
5
|
|
|
6
6
|
import type { UseAttrs } from "../types.ts";
|
|
7
|
-
import type { UBadgeProps } from "./types.ts";
|
|
8
|
-
|
|
9
|
-
type Config = Partial<typeof defaultConfig>;
|
|
7
|
+
import type { UBadgeProps, Config } from "./types.ts";
|
|
10
8
|
|
|
11
9
|
export default function useAttrs(props: UBadgeProps): UseAttrs<Config> {
|
|
12
10
|
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
package/ui.text-block/UText.vue
CHANGED
|
@@ -13,6 +13,7 @@ const props = withDefaults(defineProps<UTextProps>(), {
|
|
|
13
13
|
size: getDefault<UTextProps>(defaultConfig, UText).size,
|
|
14
14
|
align: getDefault<UTextProps>(defaultConfig, UText).align,
|
|
15
15
|
line: getDefault<UTextProps>(defaultConfig, UText).line,
|
|
16
|
+
dataTest: "",
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
const { wrapperAttrs, htmlAttrs, hasSlotContent } = useAttrs(props);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
2
1
|
import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybook.ts";
|
|
3
2
|
|
|
4
3
|
import UText from "../../ui.text-block/UText.vue";
|
|
5
4
|
import URow from "../../ui.container-row/URow.vue";
|
|
6
5
|
|
|
6
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
7
7
|
import type { UTextProps } from "../types.ts";
|
|
8
8
|
|
|
9
9
|
interface UTextArgs extends UTextProps {
|