vueless 0.0.503 → 0.0.504
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 +25 -3
- 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 +152 -77
- 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.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
|
@@ -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 {
|
package/ui.text-block/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ import useUI from "../composables/useUI.ts";
|
|
|
3
3
|
import defaultConfig from "./config.ts";
|
|
4
4
|
|
|
5
5
|
import type { UseAttrs } from "../types.ts";
|
|
6
|
-
import type { UTextProps } from "./types.ts";
|
|
6
|
+
import type { UTextProps, Config } from "./types.ts";
|
|
7
7
|
|
|
8
8
|
export default function useAttrs(props: UTextProps): UseAttrs<Config> {
|
|
9
9
|
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
package/ui.text-empty/UEmpty.vue
CHANGED
|
@@ -1,87 +1,21 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div :data-test="dataTest" v-bind="wrapperAttrs">
|
|
3
|
-
<div v-bind="headerAttrs">
|
|
4
|
-
<!-- @slot Use it to add something to the header. -->
|
|
5
|
-
<slot name="header">
|
|
6
|
-
<div v-bind="emptyIconWrapperAttrs">
|
|
7
|
-
<UIcon
|
|
8
|
-
internal
|
|
9
|
-
:name="config.defaults.emptyIcon"
|
|
10
|
-
color="gray"
|
|
11
|
-
:size="iconSize"
|
|
12
|
-
v-bind="emptyIconAttrs"
|
|
13
|
-
/>
|
|
14
|
-
</div>
|
|
15
|
-
</slot>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<!-- @slot Use it to add something inside. -->
|
|
19
|
-
<slot>
|
|
20
|
-
<UHeader v-if="title" :label="title" :size="titleSize" v-bind="titleAttrs" />
|
|
21
|
-
<div v-if="description" v-bind="descriptionAttrs" v-text="description" />
|
|
22
|
-
</slot>
|
|
23
|
-
|
|
24
|
-
<div v-bind="footerAttrs">
|
|
25
|
-
<!-- @slot Use it to add something to the footer. -->
|
|
26
|
-
<slot name="footer" />
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
32
2
|
import { computed } from "vue";
|
|
33
3
|
|
|
34
4
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
35
5
|
import UHeader from "../ui.text-header/UHeader.vue";
|
|
36
6
|
import { getDefault } from "../utils/ui.ts";
|
|
37
7
|
|
|
38
|
-
import { UEmpty } from "./constants.
|
|
39
|
-
import defaultConfig from "./config.
|
|
40
|
-
import useAttrs from "./useAttrs.
|
|
41
|
-
|
|
42
|
-
defineOptions({ inheritAttrs: false });
|
|
43
|
-
|
|
44
|
-
const props = defineProps({
|
|
45
|
-
/**
|
|
46
|
-
* Empty state title.
|
|
47
|
-
*/
|
|
48
|
-
title: {
|
|
49
|
-
type: String,
|
|
50
|
-
default: "",
|
|
51
|
-
},
|
|
8
|
+
import { UEmpty } from "./constants.ts";
|
|
9
|
+
import defaultConfig from "./config.ts";
|
|
10
|
+
import useAttrs from "./useAttrs.ts";
|
|
52
11
|
|
|
53
|
-
|
|
54
|
-
* Empty state description.
|
|
55
|
-
*/
|
|
56
|
-
description: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: "",
|
|
59
|
-
},
|
|
12
|
+
import type { UEmptyProps } from "./types.ts";
|
|
60
13
|
|
|
61
|
-
|
|
62
|
-
* Empty state size.
|
|
63
|
-
* @values sm, md, lg
|
|
64
|
-
*/
|
|
65
|
-
size: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: getDefault(defaultConfig, UEmpty).size,
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Component config object.
|
|
72
|
-
*/
|
|
73
|
-
config: {
|
|
74
|
-
type: Object,
|
|
75
|
-
default: () => ({}),
|
|
76
|
-
},
|
|
14
|
+
defineOptions({ inheritAttrs: false });
|
|
77
15
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
dataTest: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: "",
|
|
84
|
-
},
|
|
16
|
+
const props = withDefaults(defineProps<UEmptyProps>(), {
|
|
17
|
+
size: getDefault<UEmptyProps>(defaultConfig, UEmpty).size,
|
|
18
|
+
dataTest: "",
|
|
85
19
|
});
|
|
86
20
|
|
|
87
21
|
const {
|
|
@@ -115,3 +49,33 @@ const titleSize = computed(() => {
|
|
|
115
49
|
return sizes[props.size];
|
|
116
50
|
});
|
|
117
51
|
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div :data-test="dataTest" v-bind="wrapperAttrs">
|
|
55
|
+
<div v-bind="headerAttrs">
|
|
56
|
+
<!-- @slot Use it to add something to the header. -->
|
|
57
|
+
<slot name="header">
|
|
58
|
+
<div v-bind="emptyIconWrapperAttrs">
|
|
59
|
+
<UIcon
|
|
60
|
+
internal
|
|
61
|
+
:name="config.defaults.emptyIcon"
|
|
62
|
+
color="gray"
|
|
63
|
+
:size="iconSize"
|
|
64
|
+
v-bind="emptyIconAttrs"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</slot>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<!-- @slot Use it to add something inside. -->
|
|
71
|
+
<slot>
|
|
72
|
+
<UHeader v-if="title" :label="title" :size="titleSize" v-bind="titleAttrs" />
|
|
73
|
+
<div v-if="description" v-bind="descriptionAttrs" v-text="description" />
|
|
74
|
+
</slot>
|
|
75
|
+
|
|
76
|
+
<div v-bind="footerAttrs">
|
|
77
|
+
<!-- @slot Use it to add something to the footer. -->
|
|
78
|
+
<slot name="footer" />
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</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 UButton from "../../ui.button/UButton.vue";
|
|
|
5
5
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
6
6
|
import URow from "../../ui.container-row/URow.vue";
|
|
7
7
|
|
|
8
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
9
|
+
import type { UEmptyProps } from "../types.ts";
|
|
10
|
+
|
|
11
|
+
interface UEmptyArgs extends UEmptyProps {
|
|
12
|
+
slotTemplate?: string;
|
|
13
|
+
enum: "size";
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `UEmpty` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-empty)
|
|
10
18
|
*/
|
|
@@ -14,14 +22,14 @@ export default {
|
|
|
14
22
|
component: UEmpty,
|
|
15
23
|
args: {
|
|
16
24
|
title: "No contacts",
|
|
17
|
-
description: "There
|
|
25
|
+
description: "There are no contacts in the list.",
|
|
18
26
|
},
|
|
19
27
|
argTypes: {
|
|
20
28
|
...getArgTypes(UEmpty.__name),
|
|
21
29
|
},
|
|
22
|
-
};
|
|
30
|
+
} as Meta;
|
|
23
31
|
|
|
24
|
-
const DefaultTemplate = (args) => ({
|
|
32
|
+
const DefaultTemplate: StoryFn<UEmptyArgs> = (args: UEmptyArgs) => ({
|
|
25
33
|
components: { UEmpty, UIcon, UButton },
|
|
26
34
|
setup() {
|
|
27
35
|
const slots = getSlotNames(UEmpty.__name);
|
|
@@ -30,17 +38,17 @@ const DefaultTemplate = (args) => ({
|
|
|
30
38
|
},
|
|
31
39
|
template: `
|
|
32
40
|
<UEmpty v-bind="args">
|
|
33
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
41
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
34
42
|
</UEmpty>
|
|
35
43
|
`,
|
|
36
44
|
});
|
|
37
45
|
|
|
38
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
46
|
+
const EnumVariantTemplate: StoryFn<UEmptyArgs> = (args: UEmptyArgs, { argTypes }) => ({
|
|
39
47
|
components: { UEmpty, URow },
|
|
40
48
|
setup() {
|
|
41
49
|
return {
|
|
42
50
|
args,
|
|
43
|
-
options: argTypes[args.enum]
|
|
51
|
+
options: argTypes?.[args.enum]?.options,
|
|
44
52
|
};
|
|
45
53
|
},
|
|
46
54
|
template: `
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UEmptyProps {
|
|
6
|
+
/**
|
|
7
|
+
* Empty state title.
|
|
8
|
+
*/
|
|
9
|
+
title?: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Empty state description.
|
|
13
|
+
*/
|
|
14
|
+
description?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Empty state size.
|
|
18
|
+
*/
|
|
19
|
+
size?: "sm" | "md" | "lg";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Component config object.
|
|
23
|
+
*/
|
|
24
|
+
config?: Partial<typeof defaultConfig>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Data-test attribute for automated testing.
|
|
28
|
+
*/
|
|
29
|
+
dataTest?: string;
|
|
30
|
+
}
|
|
@@ -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 { UEmptyProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UEmptyProps): 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-file/UFile.vue
CHANGED
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<ULink :href="url" no-ring v-bind="fileAttrs" :data-test="dataTest">
|
|
3
|
-
<slot name="left" :file="{ elementId, label, url, imageUrl }" />
|
|
4
|
-
|
|
5
|
-
<slot :file="{ elementId, label, url, imageUrl }">
|
|
6
|
-
<div v-bind="bodyAttrs">
|
|
7
|
-
<img v-if="imageUrl" :alt="label" :src="imageUrl" v-bind="fileImageAttrs" />
|
|
8
|
-
|
|
9
|
-
<UIcon
|
|
10
|
-
v-else
|
|
11
|
-
internal
|
|
12
|
-
interactive
|
|
13
|
-
color="gray"
|
|
14
|
-
:size="iconSize"
|
|
15
|
-
:name="config.defaults.fileIcon"
|
|
16
|
-
v-bind="fileIconAttrs"
|
|
17
|
-
@focus="onFocus"
|
|
18
|
-
@blur="onBlur"
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
|
-
<ULink :label="label" :size="size" color="gray" dashed no-ring v-bind="fileLabelAttrs" />
|
|
22
|
-
</div>
|
|
23
|
-
</slot>
|
|
24
|
-
|
|
25
|
-
<slot name="right" :file="{ elementId, label, url, imageUrl }">
|
|
26
|
-
<UIcon
|
|
27
|
-
v-if="removable"
|
|
28
|
-
internal
|
|
29
|
-
interactive
|
|
30
|
-
color="gray"
|
|
31
|
-
:size="removeIconSize"
|
|
32
|
-
:name="config.defaults.removeIcon"
|
|
33
|
-
v-bind="removeIconAttrs"
|
|
34
|
-
:data-test="`${dataTest}-remove-item`"
|
|
35
|
-
@click.stop.prevent="onRemove"
|
|
36
|
-
/>
|
|
37
|
-
</slot>
|
|
38
|
-
</ULink>
|
|
39
|
-
</template>
|
|
40
|
-
|
|
41
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
42
2
|
import { computed, ref, useId } from "vue";
|
|
43
3
|
|
|
44
4
|
import ULink from "../ui.button-link/ULink.vue";
|
|
@@ -46,77 +6,17 @@ import UIcon from "../ui.image-icon/UIcon.vue";
|
|
|
46
6
|
|
|
47
7
|
import { getDefault } from "../utils/ui.ts";
|
|
48
8
|
|
|
49
|
-
import useAttrs from "./useAttrs.
|
|
50
|
-
import { UFile } from "./constants.
|
|
51
|
-
import defaultConfig from "./config.
|
|
52
|
-
|
|
53
|
-
defineOptions({ inheritAttrs: false });
|
|
54
|
-
|
|
55
|
-
const props = defineProps({
|
|
56
|
-
/**
|
|
57
|
-
* File url.
|
|
58
|
-
*/
|
|
59
|
-
url: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: "",
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Image url.
|
|
66
|
-
*/
|
|
67
|
-
imageUrl: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: "",
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* File label.
|
|
74
|
-
*/
|
|
75
|
-
label: {
|
|
76
|
-
type: String,
|
|
77
|
-
default: "",
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* File size.
|
|
82
|
-
* @values sm, md, lg
|
|
83
|
-
*/
|
|
84
|
-
size: {
|
|
85
|
-
type: String,
|
|
86
|
-
default: getDefault(defaultConfig, UFile).size,
|
|
87
|
-
},
|
|
9
|
+
import useAttrs from "./useAttrs.ts";
|
|
10
|
+
import { UFile } from "./constants.ts";
|
|
11
|
+
import defaultConfig from "./config.ts";
|
|
88
12
|
|
|
89
|
-
|
|
90
|
-
* Unique element id.
|
|
91
|
-
*/
|
|
92
|
-
id: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: "",
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Show remove button.
|
|
99
|
-
*/
|
|
100
|
-
removable: {
|
|
101
|
-
type: Boolean,
|
|
102
|
-
default: false,
|
|
103
|
-
},
|
|
13
|
+
import type { UFileProps } from "./types.ts";
|
|
104
14
|
|
|
105
|
-
|
|
106
|
-
* Component config object.
|
|
107
|
-
*/
|
|
108
|
-
config: {
|
|
109
|
-
type: Object,
|
|
110
|
-
default: () => ({}),
|
|
111
|
-
},
|
|
15
|
+
defineOptions({ inheritAttrs: false });
|
|
112
16
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
dataTest: {
|
|
117
|
-
type: String,
|
|
118
|
-
default: "",
|
|
119
|
-
},
|
|
17
|
+
const props = withDefaults(defineProps<UFileProps>(), {
|
|
18
|
+
size: getDefault<UFileProps>(defaultConfig, UFile).size,
|
|
19
|
+
dataTest: "",
|
|
120
20
|
});
|
|
121
21
|
|
|
122
22
|
const emit = defineEmits([
|
|
@@ -173,3 +73,43 @@ function onBlur() {
|
|
|
173
73
|
focus.value = false;
|
|
174
74
|
}
|
|
175
75
|
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<ULink :href="url" no-ring v-bind="fileAttrs" :data-test="dataTest">
|
|
79
|
+
<slot name="left" :file="{ elementId, label, url, imageUrl }" />
|
|
80
|
+
|
|
81
|
+
<slot :file="{ elementId, label, url, imageUrl }">
|
|
82
|
+
<div v-bind="bodyAttrs">
|
|
83
|
+
<img v-if="imageUrl" :alt="label" :src="imageUrl" v-bind="fileImageAttrs" />
|
|
84
|
+
|
|
85
|
+
<UIcon
|
|
86
|
+
v-else
|
|
87
|
+
internal
|
|
88
|
+
interactive
|
|
89
|
+
color="gray"
|
|
90
|
+
:size="iconSize"
|
|
91
|
+
:name="config.defaults.fileIcon"
|
|
92
|
+
v-bind="fileIconAttrs"
|
|
93
|
+
@focus="onFocus"
|
|
94
|
+
@blur="onBlur"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<ULink :label="label" :size="size" color="gray" dashed no-ring v-bind="fileLabelAttrs" />
|
|
98
|
+
</div>
|
|
99
|
+
</slot>
|
|
100
|
+
|
|
101
|
+
<slot name="right" :file="{ elementId, label, url, imageUrl }">
|
|
102
|
+
<UIcon
|
|
103
|
+
v-if="removable"
|
|
104
|
+
internal
|
|
105
|
+
interactive
|
|
106
|
+
color="gray"
|
|
107
|
+
:size="removeIconSize"
|
|
108
|
+
:name="config.defaults.removeIcon"
|
|
109
|
+
v-bind="removeIconAttrs"
|
|
110
|
+
:data-test="`${dataTest}-remove-item`"
|
|
111
|
+
@click.stop.prevent="onRemove"
|
|
112
|
+
/>
|
|
113
|
+
</slot>
|
|
114
|
+
</ULink>
|
|
115
|
+
</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} />
|
|
@@ -2,6 +2,13 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
|
|
|
2
2
|
|
|
3
3
|
import UFile from "../../ui.text-file/UFile.vue";
|
|
4
4
|
|
|
5
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
6
|
+
import type { UFileProps } from "../types.ts";
|
|
7
|
+
|
|
8
|
+
interface UFileArgs extends UFileProps {
|
|
9
|
+
slotTemplate?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
13
|
* The `UFile` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-file)
|
|
7
14
|
*/
|
|
@@ -16,9 +23,9 @@ export default {
|
|
|
16
23
|
argTypes: {
|
|
17
24
|
...getArgTypes(UFile.__name),
|
|
18
25
|
},
|
|
19
|
-
};
|
|
26
|
+
} as Meta;
|
|
20
27
|
|
|
21
|
-
const DefaultTemplate = (args) => ({
|
|
28
|
+
const DefaultTemplate: StoryFn<UFileArgs> = (args: UFileArgs) => ({
|
|
22
29
|
components: { UFile },
|
|
23
30
|
setup() {
|
|
24
31
|
const slots = getSlotNames(UFile.__name);
|
|
@@ -27,7 +34,7 @@ const DefaultTemplate = (args) => ({
|
|
|
27
34
|
},
|
|
28
35
|
template: `
|
|
29
36
|
<UFile v-bind="args">
|
|
30
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
37
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
31
38
|
</UFile>
|
|
32
39
|
`,
|
|
33
40
|
});
|