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
|
@@ -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 UFiles from "../../ui.text-files/UFiles.vue";
|
|
4
4
|
|
|
5
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
6
|
+
import type { UFilesProps } from "../types.ts";
|
|
7
|
+
|
|
8
|
+
interface UFilesArgs extends UFilesProps {
|
|
9
|
+
slotTemplate?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
13
|
* The `UFiles` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-files)
|
|
7
14
|
*/
|
|
@@ -19,9 +26,9 @@ export default {
|
|
|
19
26
|
argTypes: {
|
|
20
27
|
...getArgTypes(UFiles.__name),
|
|
21
28
|
},
|
|
22
|
-
};
|
|
29
|
+
} as Meta;
|
|
23
30
|
|
|
24
|
-
const DefaultTemplate = (args) => ({
|
|
31
|
+
const DefaultTemplate: StoryFn<UFilesArgs> = (args: UFilesArgs) => ({
|
|
25
32
|
components: { UFiles },
|
|
26
33
|
setup() {
|
|
27
34
|
const slots = getSlotNames(UFiles.__name);
|
|
@@ -30,7 +37,7 @@ const DefaultTemplate = (args) => ({
|
|
|
30
37
|
},
|
|
31
38
|
template: `
|
|
32
39
|
<UFiles v-bind="args">
|
|
33
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
40
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
34
41
|
</UFiles>
|
|
35
42
|
`,
|
|
36
43
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UFilesProps {
|
|
6
|
+
/**
|
|
7
|
+
* List of file objects.
|
|
8
|
+
*/
|
|
9
|
+
fileList?: Array<object>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* File list label.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* File list label placement.
|
|
18
|
+
*/
|
|
19
|
+
labelAlign?: "top" | "topWithDesc";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* File list description.
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* File list size.
|
|
28
|
+
*/
|
|
29
|
+
size?: "sm" | "md" | "lg";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Show remove button for each file
|
|
33
|
+
*/
|
|
34
|
+
removable?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Component config object.
|
|
38
|
+
*/
|
|
39
|
+
config?: Partial<typeof defaultConfig>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Data-test attribute for automated testing.
|
|
43
|
+
*/
|
|
44
|
+
dataTest?: string;
|
|
45
|
+
}
|
|
@@ -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 { UFilesProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UFilesProps): 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
|
+
}
|
|
@@ -1,85 +1,28 @@
|
|
|
1
|
-
<
|
|
2
|
-
<component :is="tag" v-bind="headerAttrs" :data-test="dataTest">
|
|
3
|
-
<slot>{{ label }}</slot>
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
8
2
|
import { getDefault } from "../utils/ui.ts";
|
|
9
3
|
|
|
10
|
-
import { UHeader } from "./constants.
|
|
11
|
-
import defaultConfig from "./config.
|
|
12
|
-
import useAttrs from "./useAttrs.
|
|
13
|
-
|
|
14
|
-
defineOptions({ inheritAttrs: false });
|
|
15
|
-
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
/**
|
|
18
|
-
* Header label.
|
|
19
|
-
*/
|
|
20
|
-
label: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: "",
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Header size.
|
|
27
|
-
* @values xs, sm, md, lg, xl, 2xl
|
|
28
|
-
*/
|
|
29
|
-
size: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: getDefault(defaultConfig, UHeader).size,
|
|
32
|
-
},
|
|
4
|
+
import { UHeader } from "./constants.ts";
|
|
5
|
+
import defaultConfig from "./config.ts";
|
|
6
|
+
import useAttrs from "./useAttrs.ts";
|
|
33
7
|
|
|
34
|
-
|
|
35
|
-
* Header color.
|
|
36
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
37
|
-
*/
|
|
38
|
-
color: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: getDefault(defaultConfig, UHeader).color,
|
|
41
|
-
},
|
|
8
|
+
import type { UHeaderProps } from "./types.ts";
|
|
42
9
|
|
|
43
|
-
|
|
44
|
-
* Allows changing HTML tag.
|
|
45
|
-
*/
|
|
46
|
-
tag: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: getDefault(defaultConfig, UHeader).tag,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Removes text line height (disable for multiline headers).
|
|
53
|
-
*/
|
|
54
|
-
line: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: getDefault(defaultConfig, UHeader).line,
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Show the underline.
|
|
61
|
-
*/
|
|
62
|
-
underlined: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
default: getDefault(defaultConfig, UHeader).underlined,
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Component config object.
|
|
69
|
-
*/
|
|
70
|
-
config: {
|
|
71
|
-
type: Object,
|
|
72
|
-
default: () => ({}),
|
|
73
|
-
},
|
|
10
|
+
defineOptions({ inheritAttrs: false });
|
|
74
11
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
12
|
+
const props = withDefaults(defineProps<UHeaderProps>(), {
|
|
13
|
+
size: getDefault<UHeaderProps>(defaultConfig, UHeader).size,
|
|
14
|
+
color: getDefault<UHeaderProps>(defaultConfig, UHeader).color,
|
|
15
|
+
tag: getDefault<UHeaderProps>(defaultConfig, UHeader).tag,
|
|
16
|
+
line: getDefault<UHeaderProps>(defaultConfig, UHeader).line,
|
|
17
|
+
underlined: getDefault<UHeaderProps>(defaultConfig, UHeader).underlined,
|
|
18
|
+
dataTest: "",
|
|
82
19
|
});
|
|
83
20
|
|
|
84
21
|
const { headerAttrs } = useAttrs(props);
|
|
85
22
|
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<component :is="tag" v-bind="headerAttrs" :data-test="dataTest">
|
|
26
|
+
<slot>{{ label }}</slot>
|
|
27
|
+
</component>
|
|
28
|
+
</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} />
|
|
@@ -3,6 +3,14 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
|
|
|
3
3
|
import UHeader from "../../ui.text-header/UHeader.vue";
|
|
4
4
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
5
5
|
|
|
6
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
7
|
+
import type { UHeaderProps } from "../types.ts";
|
|
8
|
+
|
|
9
|
+
interface UHeaderArgs extends UHeaderProps {
|
|
10
|
+
slotTemplate?: string;
|
|
11
|
+
enum: "size" | "color";
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* The `UHeader` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-header)
|
|
8
16
|
*/
|
|
@@ -16,9 +24,9 @@ export default {
|
|
|
16
24
|
argTypes: {
|
|
17
25
|
...getArgTypes(UHeader.__name),
|
|
18
26
|
},
|
|
19
|
-
};
|
|
27
|
+
} as Meta;
|
|
20
28
|
|
|
21
|
-
const DefaultTemplate = (args) => ({
|
|
29
|
+
const DefaultTemplate: StoryFn<UHeaderArgs> = (args: UHeaderArgs) => ({
|
|
22
30
|
components: { UHeader },
|
|
23
31
|
setup() {
|
|
24
32
|
const slots = getSlotNames(UHeader.__name);
|
|
@@ -27,17 +35,17 @@ const DefaultTemplate = (args) => ({
|
|
|
27
35
|
},
|
|
28
36
|
template: `
|
|
29
37
|
<UHeader v-bind="args">
|
|
30
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
38
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
31
39
|
</UHeader>
|
|
32
40
|
`,
|
|
33
41
|
});
|
|
34
42
|
|
|
35
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
43
|
+
const EnumVariantTemplate: StoryFn<UHeaderArgs> = (args: UHeaderArgs, { argTypes }) => ({
|
|
36
44
|
components: { UHeader, UCol },
|
|
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: `
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UHeaderProps {
|
|
6
|
+
/**
|
|
7
|
+
* Header label.
|
|
8
|
+
*/
|
|
9
|
+
label?: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Header size.
|
|
13
|
+
*/
|
|
14
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Header color.
|
|
18
|
+
*/
|
|
19
|
+
color?:
|
|
20
|
+
| "brand"
|
|
21
|
+
| "grayscale"
|
|
22
|
+
| "gray"
|
|
23
|
+
| "red"
|
|
24
|
+
| "orange"
|
|
25
|
+
| "amber"
|
|
26
|
+
| "yellow"
|
|
27
|
+
| "lime"
|
|
28
|
+
| "green"
|
|
29
|
+
| "emerald"
|
|
30
|
+
| "teal"
|
|
31
|
+
| "cyan"
|
|
32
|
+
| "sky"
|
|
33
|
+
| "blue"
|
|
34
|
+
| "indigo"
|
|
35
|
+
| "violet"
|
|
36
|
+
| "purple"
|
|
37
|
+
| "fuchsia"
|
|
38
|
+
| "pink"
|
|
39
|
+
| "rose"
|
|
40
|
+
| "white";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Allows changing HTML tag.
|
|
44
|
+
*/
|
|
45
|
+
tag?: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Removes text line height (disable for multiline headers).
|
|
49
|
+
*/
|
|
50
|
+
line?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Show the underline.
|
|
54
|
+
*/
|
|
55
|
+
underlined?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Component config object.
|
|
59
|
+
*/
|
|
60
|
+
config?: Partial<typeof defaultConfig>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Data-test attribute for automated testing.
|
|
64
|
+
*/
|
|
65
|
+
dataTest?: string;
|
|
66
|
+
}
|
|
@@ -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 { UHeaderProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UHeaderProps): 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-money/UMoney.vue
CHANGED
|
@@ -1,178 +1,30 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div v-bind="moneyAttrs">
|
|
3
|
-
<div v-if="hasSlotContent($slots['left'])" v-bind="slotLeftAttrs">
|
|
4
|
-
<!-- @slot Use it to add something before money amount. -->
|
|
5
|
-
<slot name="left" />
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
<div :data-test="dataTest" v-bind="sumAttrs">
|
|
9
|
-
<span
|
|
10
|
-
v-if="currencySymbolPosition.left"
|
|
11
|
-
v-bind="symbolAttrs"
|
|
12
|
-
v-text="symbol + currencySpace"
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
<span v-if="value" v-bind="mathSignAttrs" v-text="mathSign" />
|
|
16
|
-
|
|
17
|
-
<span v-bind="integerAttrs" v-text="preparedMoney.integer" />
|
|
18
|
-
|
|
19
|
-
<span
|
|
20
|
-
v-if="maxFractionDigits > 0"
|
|
21
|
-
v-bind="pennyAttrs"
|
|
22
|
-
v-text="preparedMoney.decimalSeparator + preparedMoney.penny"
|
|
23
|
-
/>
|
|
24
|
-
|
|
25
|
-
<span
|
|
26
|
-
v-if="currencySymbolPosition.right"
|
|
27
|
-
v-bind="symbolAttrs"
|
|
28
|
-
v-text="currencySpace + symbol"
|
|
29
|
-
/>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<div v-if="hasSlotContent($slots['right'])" v-bind="slotRightAttrs">
|
|
33
|
-
<!-- @slot Use it to add something after money amount. -->
|
|
34
|
-
<slot name="right" />
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
40
2
|
import { computed } from "vue";
|
|
41
3
|
|
|
42
4
|
import { getDefault } from "../utils/ui.ts";
|
|
43
5
|
|
|
44
|
-
import { UMoney } from "./constants.
|
|
45
|
-
import defaultConfig from "./config.
|
|
46
|
-
import { useAttrs } from "./useAttrs.
|
|
47
|
-
import { separatedMoney, MONEY_SIGN_TYPE } from "./utilMoney.
|
|
6
|
+
import { UMoney } from "./constants.ts";
|
|
7
|
+
import defaultConfig from "./config.ts";
|
|
8
|
+
import { useAttrs } from "./useAttrs.ts";
|
|
9
|
+
import { separatedMoney, MONEY_SIGN_TYPE } from "./utilMoney.ts";
|
|
10
|
+
|
|
11
|
+
import type { UMoneyProps } from "./types.ts";
|
|
48
12
|
|
|
49
13
|
defineOptions({ inheritAttrs: false });
|
|
50
14
|
|
|
51
|
-
const props = defineProps({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
size: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: getDefault(defaultConfig, UMoney).size,
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Money color.
|
|
71
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
72
|
-
*/
|
|
73
|
-
color: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: getDefault(defaultConfig, UMoney).color,
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Money currency symbol.
|
|
80
|
-
*/
|
|
81
|
-
symbol: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: "",
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Money currency symbol align.
|
|
88
|
-
* @values right, left
|
|
89
|
-
*/
|
|
90
|
-
symbolAlign: {
|
|
91
|
-
type: String,
|
|
92
|
-
default: getDefault(defaultConfig, UMoney).symbolAlign,
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Add space between currency symbol and sum.
|
|
97
|
-
*/
|
|
98
|
-
symbolDivided: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: getDefault(defaultConfig, UMoney).symbolDivided,
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Money sign.
|
|
105
|
-
* @values default, positive, negative
|
|
106
|
-
*/
|
|
107
|
-
sign: {
|
|
108
|
-
type: String,
|
|
109
|
-
default: getDefault(defaultConfig, UMoney).sign,
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Minimal number of signs after the decimal separator (fractional part of a number).
|
|
114
|
-
*/
|
|
115
|
-
minFractionDigits: {
|
|
116
|
-
type: Number,
|
|
117
|
-
default: getDefault(defaultConfig, UMoney).minFractionDigits,
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Maximal number of signs after the decimal separator (fractional part of a number).
|
|
122
|
-
*/
|
|
123
|
-
maxFractionDigits: {
|
|
124
|
-
type: Number,
|
|
125
|
-
default: getDefault(defaultConfig, UMoney).maxFractionDigits,
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* A symbol used to separate the integer part from the fractional part of a number.
|
|
130
|
-
*/
|
|
131
|
-
decimalSeparator: {
|
|
132
|
-
type: String,
|
|
133
|
-
default: getDefault(defaultConfig, UMoney).decimalSeparator,
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* A symbol used to separate the thousand parts of a number.
|
|
138
|
-
*/
|
|
139
|
-
thousandsSeparator: {
|
|
140
|
-
type: String,
|
|
141
|
-
default: getDefault(defaultConfig, UMoney).thousandsSeparator,
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Money align.
|
|
146
|
-
* @values right, left
|
|
147
|
-
*/
|
|
148
|
-
align: {
|
|
149
|
-
type: String,
|
|
150
|
-
default: getDefault(defaultConfig, UMoney).align,
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Make money planned (add brackets).
|
|
155
|
-
*/
|
|
156
|
-
planned: {
|
|
157
|
-
type: Boolean,
|
|
158
|
-
default: getDefault(defaultConfig, UMoney).planned,
|
|
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
|
-
},
|
|
15
|
+
const props = withDefaults(defineProps<UMoneyProps>(), {
|
|
16
|
+
size: getDefault<UMoneyProps>(defaultConfig, UMoney).size,
|
|
17
|
+
color: getDefault<UMoneyProps>(defaultConfig, UMoney).color,
|
|
18
|
+
symbolAlign: getDefault<UMoneyProps>(defaultConfig, UMoney).symbolAlign,
|
|
19
|
+
symbolDivided: getDefault<UMoneyProps>(defaultConfig, UMoney).symbolDivided,
|
|
20
|
+
sign: getDefault<UMoneyProps>(defaultConfig, UMoney).sign,
|
|
21
|
+
minFractionDigits: getDefault<UMoneyProps>(defaultConfig, UMoney).minFractionDigits,
|
|
22
|
+
maxFractionDigits: getDefault<UMoneyProps>(defaultConfig, UMoney).maxFractionDigits,
|
|
23
|
+
decimalSeparator: getDefault<UMoneyProps>(defaultConfig, UMoney).decimalSeparator,
|
|
24
|
+
thousandsSeparator: getDefault<UMoneyProps>(defaultConfig, UMoney).thousandsSeparator,
|
|
25
|
+
align: getDefault<UMoneyProps>(defaultConfig, UMoney).align,
|
|
26
|
+
planned: getDefault<UMoneyProps>(defaultConfig, UMoney).planned,
|
|
27
|
+
dataTest: "",
|
|
176
28
|
});
|
|
177
29
|
|
|
178
30
|
const {
|
|
@@ -217,3 +69,41 @@ const preparedMoney = computed(() => {
|
|
|
217
69
|
);
|
|
218
70
|
});
|
|
219
71
|
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<div v-bind="moneyAttrs">
|
|
75
|
+
<div v-if="hasSlotContent($slots['left'])" v-bind="slotLeftAttrs">
|
|
76
|
+
<!-- @slot Use it to add something before money amount. -->
|
|
77
|
+
<slot name="left" />
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div :data-test="dataTest" v-bind="sumAttrs">
|
|
81
|
+
<span
|
|
82
|
+
v-if="currencySymbolPosition.left"
|
|
83
|
+
v-bind="symbolAttrs"
|
|
84
|
+
v-text="symbol + currencySpace"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<span v-if="value" v-bind="mathSignAttrs" v-text="mathSign" />
|
|
88
|
+
|
|
89
|
+
<span v-bind="integerAttrs" v-text="preparedMoney.integer" />
|
|
90
|
+
|
|
91
|
+
<span
|
|
92
|
+
v-if="maxFractionDigits > 0"
|
|
93
|
+
v-bind="pennyAttrs"
|
|
94
|
+
v-text="preparedMoney.decimalSeparator + preparedMoney.penny"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<span
|
|
98
|
+
v-if="currencySymbolPosition.right"
|
|
99
|
+
v-bind="symbolAttrs"
|
|
100
|
+
v-text="currencySpace + symbol"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div v-if="hasSlotContent($slots['right'])" v-bind="slotRightAttrs">
|
|
105
|
+
<!-- @slot Use it to add something after money amount. -->
|
|
106
|
+
<slot name="right" />
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</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} />
|
|
@@ -6,6 +6,14 @@ import URow from "../../ui.container-row/URow.vue";
|
|
|
6
6
|
import DebitIcon from "../../ui.text-money/assets/debit.svg?component";
|
|
7
7
|
import CreditIcon from "../../ui.text-money/assets/credit.svg?component";
|
|
8
8
|
|
|
9
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
10
|
+
import type { UMoneyProps } from "../types.ts";
|
|
11
|
+
|
|
12
|
+
interface UMoneyArgs extends UMoneyProps {
|
|
13
|
+
slotTemplate?: string;
|
|
14
|
+
enum: "color" | "size" | "sign" | "symbolAlign" | "align";
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
const COMPONENT_CLASSES = "flex justify-center w-1/6";
|
|
10
18
|
|
|
11
19
|
/**
|
|
@@ -23,9 +31,9 @@ export default {
|
|
|
23
31
|
argTypes: {
|
|
24
32
|
...getArgTypes(UMoney.__name),
|
|
25
33
|
},
|
|
26
|
-
};
|
|
34
|
+
} as Meta;
|
|
27
35
|
|
|
28
|
-
const DefaultTemplate = (args) => ({
|
|
36
|
+
const DefaultTemplate: StoryFn<UMoneyArgs> = (args: UMoneyArgs) => ({
|
|
29
37
|
components: { UMoney, UIcon },
|
|
30
38
|
setup() {
|
|
31
39
|
const slots = getSlotNames(UMoney.__name);
|
|
@@ -40,13 +48,13 @@ const DefaultTemplate = (args) => ({
|
|
|
40
48
|
template: `
|
|
41
49
|
<div class="${COMPONENT_CLASSES}">
|
|
42
50
|
<UMoney v-bind="args">
|
|
43
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
51
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
44
52
|
</UMoney>
|
|
45
53
|
</div>
|
|
46
54
|
`,
|
|
47
55
|
});
|
|
48
56
|
|
|
49
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
57
|
+
const EnumVariantTemplate: StoryFn<UMoneyArgs> = (args: UMoneyArgs, { argTypes }) => ({
|
|
50
58
|
components: { UMoney, URow },
|
|
51
59
|
setup() {
|
|
52
60
|
const slots = getSlotNames(UMoney.__name);
|
|
@@ -54,7 +62,7 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
|
54
62
|
return {
|
|
55
63
|
args,
|
|
56
64
|
slots,
|
|
57
|
-
options: argTypes[args.enum]
|
|
65
|
+
options: argTypes?.[args.enum]?.options,
|
|
58
66
|
};
|
|
59
67
|
},
|
|
60
68
|
template: `
|