vueless 0.0.513 → 0.0.515
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 +26 -0
- package/ui.button-link/types.ts +3 -1
- package/ui.button-link/useAttrs.ts +2 -2
- package/ui.container-accordion/UAccordion.vue +33 -69
- package/ui.container-accordion/storybook/Docs.mdx +2 -2
- package/ui.container-accordion/storybook/{stories.js → stories.ts} +10 -3
- package/ui.container-accordion/types.ts +35 -0
- package/ui.container-accordion/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-card/UCard.vue +43 -71
- package/ui.container-card/storybook/Docs.mdx +2 -2
- package/ui.container-card/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-card/types.ts +25 -0
- package/ui.container-card/useAttrs.ts +18 -0
- package/ui.container-col/UCol.vue +21 -79
- package/ui.container-col/storybook/Docs.mdx +2 -2
- package/ui.container-col/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-col/types.ts +54 -0
- package/ui.container-col/useAttrs.ts +18 -0
- package/ui.container-divider/UDivider.vue +22 -94
- package/ui.container-divider/storybook/Docs.mdx +2 -2
- package/ui.container-divider/storybook/{stories.js → stories.ts} +13 -5
- package/ui.container-divider/types.ts +55 -0
- package/ui.container-divider/useAttrs.ts +23 -0
- package/ui.container-group/UGroup.vue +31 -73
- package/ui.container-group/storybook/Docs.mdx +2 -2
- package/ui.container-group/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-group/types.ts +36 -0
- package/ui.container-group/useAttrs.ts +18 -0
- package/ui.container-modal/UModal.vue +122 -232
- package/ui.container-modal/storybook/Docs.mdx +2 -2
- package/ui.container-modal/storybook/{stories.js → stories.ts} +16 -6
- package/ui.container-modal/types.ts +82 -0
- package/ui.container-modal/useAttrs.ts +22 -0
- package/ui.container-modal-confirm/UModalConfirm.vue +82 -199
- package/ui.container-modal-confirm/storybook/Docs.mdx +2 -2
- package/ui.container-modal-confirm/storybook/{stories.js → stories.ts} +14 -3
- package/ui.container-modal-confirm/types.ts +106 -0
- package/ui.container-modal-confirm/useAttrs.ts +18 -0
- package/ui.container-page/UPage.vue +79 -153
- package/ui.container-page/storybook/Docs.mdx +2 -2
- package/ui.container-page/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-page/types.ts +57 -0
- package/ui.container-page/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-row/URow.vue +22 -87
- package/ui.container-row/storybook/Docs.mdx +2 -2
- package/ui.container-row/storybook/{stories.js → stories.ts} +11 -3
- package/ui.container-row/types.ts +59 -0
- package/ui.container-row/useAttrs.ts +18 -0
- package/ui.dropdown-badge/UDropdownBadge.vue +70 -167
- package/ui.dropdown-badge/storybook/Docs.mdx +2 -2
- package/ui.dropdown-badge/storybook/{stories.js → stories.ts} +16 -5
- package/ui.dropdown-badge/types.ts +93 -0
- package/ui.dropdown-badge/{useAttrs.js → useAttrs.ts} +13 -2
- package/ui.dropdown-button/UDropdownButton.vue +85 -203
- package/ui.dropdown-button/storybook/Docs.mdx +2 -2
- package/ui.dropdown-button/storybook/{stories.js → stories.ts} +25 -11
- package/ui.dropdown-button/types.ts +108 -0
- package/ui.dropdown-button/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.dropdown-link/UDropdownLink.vue +84 -194
- package/ui.dropdown-link/storybook/Docs.mdx +2 -2
- package/ui.dropdown-link/storybook/{stories.js → stories.ts} +20 -9
- package/ui.dropdown-link/types.ts +103 -0
- package/ui.dropdown-link/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.dropdown-list/UDropdownList.vue +112 -177
- package/ui.dropdown-list/storybook/Docs.mdx +2 -2
- package/ui.dropdown-list/storybook/{stories.js → stories.ts} +23 -7
- package/ui.dropdown-list/types.ts +52 -0
- package/ui.dropdown-list/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.dropdown-list/usePointer.ts +111 -0
- package/web-types.json +298 -146
- package/ui.container-card/useAttrs.js +0 -15
- package/ui.container-col/useAttrs.js +0 -15
- package/ui.container-divider/useAttrs.js +0 -20
- package/ui.container-group/useAttrs.js +0 -15
- package/ui.container-modal/useAttrs.js +0 -19
- package/ui.container-modal-confirm/useAttrs.js +0 -15
- package/ui.container-row/useAttrs.js +0 -15
- package/ui.dropdown-list/usePointer.js +0 -86
- /package/ui.container-accordion/{config.js → config.ts} +0 -0
- /package/ui.container-accordion/{constants.js → constants.ts} +0 -0
- /package/ui.container-card/{config.js → config.ts} +0 -0
- /package/ui.container-card/{constants.js → constants.ts} +0 -0
- /package/ui.container-col/{config.js → config.ts} +0 -0
- /package/ui.container-col/{constants.js → constants.ts} +0 -0
- /package/ui.container-divider/{config.js → config.ts} +0 -0
- /package/ui.container-divider/{constants.js → constants.ts} +0 -0
- /package/ui.container-group/{config.js → config.ts} +0 -0
- /package/ui.container-group/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal/{config.js → config.ts} +0 -0
- /package/ui.container-modal/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal-confirm/{config.js → config.ts} +0 -0
- /package/ui.container-modal-confirm/{constants.js → constants.ts} +0 -0
- /package/ui.container-page/{config.js → config.ts} +0 -0
- /package/ui.container-page/{constants.js → constants.ts} +0 -0
- /package/ui.container-row/{config.js → config.ts} +0 -0
- /package/ui.container-row/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-badge/{config.js → config.ts} +0 -0
- /package/ui.dropdown-badge/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-button/{config.js → config.ts} +0 -0
- /package/ui.dropdown-button/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-link/{config.js → config.ts} +0 -0
- /package/ui.dropdown-link/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-list/{config.js → config.ts} +0 -0
- /package/ui.dropdown-list/{constants.js → constants.ts} +0 -0
|
@@ -9,6 +9,13 @@ import UButton from "../../ui.button/UButton.vue";
|
|
|
9
9
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
10
10
|
import UHeader from "../../ui.text-header/UHeader.vue";
|
|
11
11
|
|
|
12
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
13
|
+
import type { UPageProps } from "../types.ts";
|
|
14
|
+
|
|
15
|
+
interface UPageArgs extends UPageProps {
|
|
16
|
+
slotTemplate?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* The `UPage` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.container-page)
|
|
14
21
|
*/
|
|
@@ -23,7 +30,7 @@ export default {
|
|
|
23
30
|
argTypes: {
|
|
24
31
|
...getArgTypes(UPage.__name),
|
|
25
32
|
},
|
|
26
|
-
};
|
|
33
|
+
} as Meta;
|
|
27
34
|
|
|
28
35
|
const defaultTemplate = `
|
|
29
36
|
<UCard title="Card title">
|
|
@@ -35,7 +42,7 @@ const defaultTemplate = `
|
|
|
35
42
|
</UCard>
|
|
36
43
|
`;
|
|
37
44
|
|
|
38
|
-
const DefaultTemplate = (args) => ({
|
|
45
|
+
const DefaultTemplate: StoryFn<UPageArgs> = (args: UPageArgs) => ({
|
|
39
46
|
components: {
|
|
40
47
|
UPage,
|
|
41
48
|
UCard,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
import type { RouteLocationRaw } from "vue-router";
|
|
4
|
+
|
|
5
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
6
|
+
|
|
7
|
+
export interface UPageProps {
|
|
8
|
+
/**
|
|
9
|
+
* Page size (width).
|
|
10
|
+
*/
|
|
11
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "wide";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Page title.
|
|
15
|
+
*/
|
|
16
|
+
title?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Page title size.
|
|
20
|
+
*/
|
|
21
|
+
titleSize?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Set page description.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Back link vue-router route object.
|
|
30
|
+
*/
|
|
31
|
+
backTo?: RouteLocationRaw;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Back link label.
|
|
35
|
+
*/
|
|
36
|
+
backLabel?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets background light gray (useful if the page contains nested cards).
|
|
40
|
+
*/
|
|
41
|
+
gray?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Stick right page rounding.
|
|
45
|
+
*/
|
|
46
|
+
fixedRounding?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Component config object.
|
|
50
|
+
*/
|
|
51
|
+
config?: Partial<typeof defaultConfig>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Data-test attribute for automated testing.
|
|
55
|
+
*/
|
|
56
|
+
dataTest?: string;
|
|
57
|
+
}
|
|
@@ -2,10 +2,21 @@ import { computed } from "vue";
|
|
|
2
2
|
import useUI from "../composables/useUI.ts";
|
|
3
3
|
import { isMobileApp } from "../utils/platform.ts";
|
|
4
4
|
|
|
5
|
-
import defaultConfig from "./config.
|
|
5
|
+
import defaultConfig from "./config.ts";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import type { Ref } from "vue";
|
|
8
|
+
import type { UseAttrs } from "../types.ts";
|
|
9
|
+
import type { UPageProps, Config } from "./types.ts";
|
|
10
|
+
|
|
11
|
+
type ComponentState = {
|
|
12
|
+
isMobileBreakpoint: Ref<boolean>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default function useAttrs(
|
|
16
|
+
props: UPageProps,
|
|
17
|
+
{ isMobileBreakpoint }: ComponentState,
|
|
18
|
+
): UseAttrs<Config> {
|
|
19
|
+
const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
|
|
9
20
|
defaultConfig,
|
|
10
21
|
() => props.config,
|
|
11
22
|
"wrapper",
|
|
@@ -1,96 +1,31 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div v-bind="wrapperAttrs" :data-test="dataTest">
|
|
3
|
-
<!-- @slot Use it to add something inside. -->
|
|
4
|
-
<slot />
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
9
2
|
import { getDefault } from "../utils/ui.ts";
|
|
10
3
|
|
|
11
|
-
import { URow } from "./constants.
|
|
12
|
-
import defaultConfig from "./config.
|
|
13
|
-
import useAttrs from "./useAttrs.
|
|
14
|
-
|
|
15
|
-
defineOptions({ inheritAttrs: false });
|
|
16
|
-
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
/**
|
|
19
|
-
* The distance between nested elements.
|
|
20
|
-
* @values none, 2xs, xs, sm, md, lg, xl, 2xl
|
|
21
|
-
*/
|
|
22
|
-
gap: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: getDefault(defaultConfig, URow).gap,
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Items vertical align (align-items).
|
|
29
|
-
* @values start, end, center, stretch, baseline
|
|
30
|
-
*/
|
|
31
|
-
align: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: getDefault(defaultConfig, URow).align,
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Items vertical align for multi-row flex containers (align-content).
|
|
38
|
-
* @values start, end, center, around, evenly, between, normal, stretch, baseline
|
|
39
|
-
*/
|
|
40
|
-
content: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: getDefault(defaultConfig, URow).content,
|
|
43
|
-
},
|
|
4
|
+
import { URow } from "./constants.ts";
|
|
5
|
+
import defaultConfig from "./config.ts";
|
|
6
|
+
import useAttrs from "./useAttrs.ts";
|
|
44
7
|
|
|
45
|
-
|
|
46
|
-
* Items horizontally align (justify-content).
|
|
47
|
-
* @values start, end, center, around, evenly, between
|
|
48
|
-
*/
|
|
49
|
-
justify: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: getDefault(defaultConfig, URow).justify,
|
|
52
|
-
},
|
|
8
|
+
import type { URowProps } from "./types.ts";
|
|
53
9
|
|
|
54
|
-
|
|
55
|
-
* Reverse nested items order.
|
|
56
|
-
*/
|
|
57
|
-
reverse: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: getDefault(defaultConfig, URow).reverse,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Allow items to wrap (flex flex-wrap).
|
|
64
|
-
*/
|
|
65
|
-
wrap: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
default: getDefault(defaultConfig, URow).wrap,
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Disables mobile adaptivity.
|
|
72
|
-
*/
|
|
73
|
-
noMobile: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: getDefault(defaultConfig, URow).noMobile,
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Component config object.
|
|
80
|
-
*/
|
|
81
|
-
config: {
|
|
82
|
-
type: Object,
|
|
83
|
-
default: () => ({}),
|
|
84
|
-
},
|
|
10
|
+
defineOptions({ inheritAttrs: false });
|
|
85
11
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
12
|
+
const props = withDefaults(defineProps<URowProps>(), {
|
|
13
|
+
gap: getDefault<URowProps>(defaultConfig, URow).gap,
|
|
14
|
+
align: getDefault<URowProps>(defaultConfig, URow).align,
|
|
15
|
+
content: getDefault<URowProps>(defaultConfig, URow).content,
|
|
16
|
+
justify: getDefault<URowProps>(defaultConfig, URow).justify,
|
|
17
|
+
reverse: getDefault<URowProps>(defaultConfig, URow).reverse,
|
|
18
|
+
wrap: getDefault<URowProps>(defaultConfig, URow).wrap,
|
|
19
|
+
noMobile: getDefault<URowProps>(defaultConfig, URow).noMobile,
|
|
20
|
+
dataTest: "",
|
|
93
21
|
});
|
|
94
22
|
|
|
95
23
|
const { wrapperAttrs } = useAttrs(props);
|
|
96
24
|
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div v-bind="wrapperAttrs" :data-test="dataTest">
|
|
28
|
+
<!-- @slot Use it to add something inside. -->
|
|
29
|
+
<slot />
|
|
30
|
+
</div>
|
|
31
|
+
</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 UInput from "../../ui.form-input/UInput.vue";
|
|
|
5
5
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
6
6
|
import UButton from "../../ui.button/UButton.vue";
|
|
7
7
|
|
|
8
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
9
|
+
import type { URowProps } from "../types.ts";
|
|
10
|
+
|
|
11
|
+
interface URowArgs extends URowProps {
|
|
12
|
+
slotTemplate?: string;
|
|
13
|
+
enum: "gap" | "align";
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `URow` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.container-row)
|
|
10
18
|
*/
|
|
@@ -15,14 +23,14 @@ export default {
|
|
|
15
23
|
argTypes: {
|
|
16
24
|
...getArgTypes(URow.__name),
|
|
17
25
|
},
|
|
18
|
-
};
|
|
26
|
+
} as Meta;
|
|
19
27
|
|
|
20
28
|
const defaultTemplate = `
|
|
21
29
|
<UInput label="Name" />
|
|
22
30
|
<UButton label="Submit" size="xs" block />
|
|
23
31
|
`;
|
|
24
32
|
|
|
25
|
-
const DefaultTemplate = (args) => ({
|
|
33
|
+
const DefaultTemplate: StoryFn<URowArgs> = (args: URowArgs) => ({
|
|
26
34
|
components: { URow, UInput, UButton },
|
|
27
35
|
setup() {
|
|
28
36
|
const slots = getSlotNames(URow.__name);
|
|
@@ -36,7 +44,7 @@ const DefaultTemplate = (args) => ({
|
|
|
36
44
|
`,
|
|
37
45
|
});
|
|
38
46
|
|
|
39
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
47
|
+
const EnumVariantTemplate: StoryFn<URowArgs> = (args: URowArgs, { argTypes }) => ({
|
|
40
48
|
components: { UCol, URow, UInput, UButton },
|
|
41
49
|
setup() {
|
|
42
50
|
const isGapEnum = argTypes[args.enum].name === "gap";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface URowProps {
|
|
6
|
+
/**
|
|
7
|
+
* The distance between nested elements.
|
|
8
|
+
*/
|
|
9
|
+
gap?: "none" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Items vertical align (align-items).
|
|
13
|
+
*/
|
|
14
|
+
align?: "start" | "end" | "center" | "stretch" | "baseline";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Items vertical align for multi-row flex containers (align-content).
|
|
18
|
+
*/
|
|
19
|
+
content?:
|
|
20
|
+
| "start"
|
|
21
|
+
| "end"
|
|
22
|
+
| "center"
|
|
23
|
+
| "around"
|
|
24
|
+
| "evenly"
|
|
25
|
+
| "between"
|
|
26
|
+
| "normal"
|
|
27
|
+
| "stretch"
|
|
28
|
+
| "baseline";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Items horizontally align (justify-content).
|
|
32
|
+
*/
|
|
33
|
+
justify?: "start" | "end" | "center" | "around" | "evenly" | "between";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reverse nested items order.
|
|
37
|
+
*/
|
|
38
|
+
reverse?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Allow items to wrap (flex flex-wrap).
|
|
42
|
+
*/
|
|
43
|
+
wrap?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Disables mobile adaptivity.
|
|
47
|
+
*/
|
|
48
|
+
noMobile?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Component config object.
|
|
52
|
+
*/
|
|
53
|
+
config?: Partial<typeof defaultConfig>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Data-test attribute for automated testing.
|
|
57
|
+
*/
|
|
58
|
+
dataTest?: string;
|
|
59
|
+
}
|
|
@@ -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 { URowProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: URowProps): 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,3 +1,73 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { nextTick, ref, useId } from "vue";
|
|
3
|
+
|
|
4
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
5
|
+
import UBadge from "../ui.text-badge/UBadge.vue";
|
|
6
|
+
import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
|
|
7
|
+
|
|
8
|
+
import { getDefault } from "../utils/ui.ts";
|
|
9
|
+
|
|
10
|
+
import { vClickOutside } from "../directives";
|
|
11
|
+
|
|
12
|
+
import defaultConfig from "./config.ts";
|
|
13
|
+
import { UDropdownBadge } from "./constants.ts";
|
|
14
|
+
import useAttrs from "./useAttrs.ts";
|
|
15
|
+
|
|
16
|
+
import type { UDropdownBadgeProps } from "./types.ts";
|
|
17
|
+
|
|
18
|
+
defineOptions({ inheritAttrs: false });
|
|
19
|
+
|
|
20
|
+
const props = withDefaults(defineProps<UDropdownBadgeProps>(), {
|
|
21
|
+
labelKey: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).labelKey,
|
|
22
|
+
variant: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).variant,
|
|
23
|
+
color: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).color,
|
|
24
|
+
size: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).size,
|
|
25
|
+
round: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).round,
|
|
26
|
+
noIcon: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).noIcon,
|
|
27
|
+
yPosition: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).yPosition,
|
|
28
|
+
xPosition: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).xPosition,
|
|
29
|
+
dataTest: "",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits([
|
|
33
|
+
/**
|
|
34
|
+
* Triggers on dropdown option click.
|
|
35
|
+
* @property {string} value
|
|
36
|
+
*/
|
|
37
|
+
"clickOption",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
const isShownOptions = ref(false);
|
|
41
|
+
const dropdownListRef = ref(null);
|
|
42
|
+
|
|
43
|
+
const elementId = props.id || useId();
|
|
44
|
+
|
|
45
|
+
const { config, wrapperAttrs, dropdownBadgeAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
|
|
46
|
+
props,
|
|
47
|
+
{
|
|
48
|
+
isShownOptions,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
function onClickBadge() {
|
|
53
|
+
isShownOptions.value = !isShownOptions.value;
|
|
54
|
+
|
|
55
|
+
if (isShownOptions.value) {
|
|
56
|
+
nextTick(() => dropdownListRef.value.wrapperRef.focus());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function hideOptions() {
|
|
61
|
+
isShownOptions.value = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function onClickOption(option) {
|
|
65
|
+
emit("clickOption", option);
|
|
66
|
+
|
|
67
|
+
hideOptions();
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
1
71
|
<template>
|
|
2
72
|
<div v-click-outside="hideOptions" v-bind="wrapperAttrs">
|
|
3
73
|
<UBadge
|
|
@@ -61,170 +131,3 @@
|
|
|
61
131
|
/>
|
|
62
132
|
</div>
|
|
63
133
|
</template>
|
|
64
|
-
|
|
65
|
-
<script setup>
|
|
66
|
-
import { nextTick, ref, useId } from "vue";
|
|
67
|
-
|
|
68
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
69
|
-
import UBadge from "../ui.text-badge/UBadge.vue";
|
|
70
|
-
import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
|
|
71
|
-
|
|
72
|
-
import { getDefault } from "../utils/ui.ts";
|
|
73
|
-
|
|
74
|
-
import { vClickOutside } from "../directives";
|
|
75
|
-
|
|
76
|
-
import defaultConfig from "./config.js";
|
|
77
|
-
import { UDropdownBadge } from "./constants.js";
|
|
78
|
-
import useAttrs from "./useAttrs.js";
|
|
79
|
-
|
|
80
|
-
defineOptions({ inheritAttrs: false });
|
|
81
|
-
|
|
82
|
-
const props = defineProps({
|
|
83
|
-
/**
|
|
84
|
-
* Badge label.
|
|
85
|
-
*/
|
|
86
|
-
label: {
|
|
87
|
-
type: String,
|
|
88
|
-
default: "",
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Options list.
|
|
93
|
-
*/
|
|
94
|
-
options: {
|
|
95
|
-
type: Array,
|
|
96
|
-
default: () => [],
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Label key in the item object of options.
|
|
101
|
-
*/
|
|
102
|
-
labelKey: {
|
|
103
|
-
type: String,
|
|
104
|
-
default: getDefault(defaultConfig, UDropdownBadge).labelKey,
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Badge variant.
|
|
109
|
-
* @values primary, secondary, thirdary
|
|
110
|
-
*/
|
|
111
|
-
variant: {
|
|
112
|
-
type: String,
|
|
113
|
-
default: getDefault(defaultConfig, UDropdownBadge).variant,
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Badge color.
|
|
118
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
119
|
-
*/
|
|
120
|
-
color: {
|
|
121
|
-
type: String,
|
|
122
|
-
default: getDefault(defaultConfig, UDropdownBadge).color,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Badge size.
|
|
127
|
-
* @values sm, md, lg
|
|
128
|
-
*/
|
|
129
|
-
size: {
|
|
130
|
-
type: String,
|
|
131
|
-
default: getDefault(defaultConfig, UDropdownBadge).size,
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Set badge corners rounded.
|
|
136
|
-
*/
|
|
137
|
-
round: {
|
|
138
|
-
type: Boolean,
|
|
139
|
-
default: getDefault(defaultConfig, UDropdownBadge).round,
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Hide dropdown icon.
|
|
144
|
-
*/
|
|
145
|
-
noIcon: {
|
|
146
|
-
type: Boolean,
|
|
147
|
-
default: getDefault(defaultConfig, UDropdownBadge).noIcon,
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The position of dropdown list on the y-axis.
|
|
152
|
-
* @values top, bottom
|
|
153
|
-
*/
|
|
154
|
-
yPosition: {
|
|
155
|
-
type: String,
|
|
156
|
-
default: getDefault(defaultConfig, UDropdownBadge).yPosition,
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* The position of dropdown list on the x-axis.
|
|
161
|
-
* @values left, right
|
|
162
|
-
*/
|
|
163
|
-
xPosition: {
|
|
164
|
-
type: String,
|
|
165
|
-
default: getDefault(defaultConfig, UDropdownBadge).xPosition,
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Unique element id.
|
|
170
|
-
*/
|
|
171
|
-
id: {
|
|
172
|
-
type: String,
|
|
173
|
-
default: "",
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Component config object.
|
|
178
|
-
*/
|
|
179
|
-
config: {
|
|
180
|
-
type: Object,
|
|
181
|
-
default: () => ({}),
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Data-test attribute for automated testing.
|
|
186
|
-
*/
|
|
187
|
-
dataTest: {
|
|
188
|
-
type: String,
|
|
189
|
-
default: "",
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
const emit = defineEmits([
|
|
194
|
-
/**
|
|
195
|
-
* Triggers on dropdown option click.
|
|
196
|
-
* @property {string} value
|
|
197
|
-
*/
|
|
198
|
-
"clickOption",
|
|
199
|
-
]);
|
|
200
|
-
|
|
201
|
-
const isShownOptions = ref(false);
|
|
202
|
-
const dropdownListRef = ref(null);
|
|
203
|
-
|
|
204
|
-
const elementId = props.id || useId();
|
|
205
|
-
|
|
206
|
-
const { config, wrapperAttrs, dropdownBadgeAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
|
|
207
|
-
props,
|
|
208
|
-
{
|
|
209
|
-
isShownOptions,
|
|
210
|
-
},
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
function onClickBadge() {
|
|
214
|
-
isShownOptions.value = !isShownOptions.value;
|
|
215
|
-
|
|
216
|
-
if (isShownOptions.value) {
|
|
217
|
-
nextTick(() => dropdownListRef.value.wrapperRef.focus());
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function hideOptions() {
|
|
222
|
-
isShownOptions.value = false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function onClickOption(option) {
|
|
226
|
-
emit("clickOption", option);
|
|
227
|
-
|
|
228
|
-
hideOptions();
|
|
229
|
-
}
|
|
230
|
-
</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} />
|
|
@@ -4,6 +4,14 @@ import UDropdownBadge from "../../ui.dropdown-badge/UDropdownBadge.vue";
|
|
|
4
4
|
import URow from "../../ui.container-row/URow.vue";
|
|
5
5
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
6
6
|
|
|
7
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
8
|
+
import type { UDropdownBadgeProps } from "../types.ts";
|
|
9
|
+
|
|
10
|
+
interface UDropdownBadgeArgs extends UDropdownBadgeProps {
|
|
11
|
+
slotTemplate?: string;
|
|
12
|
+
enum: "color" | "size";
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* The `UDropdownBadge` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.dropdown-badge)
|
|
9
17
|
*/
|
|
@@ -25,9 +33,9 @@ export default {
|
|
|
25
33
|
},
|
|
26
34
|
},
|
|
27
35
|
},
|
|
28
|
-
};
|
|
36
|
+
} as Meta;
|
|
29
37
|
|
|
30
|
-
const DefaultTemplate = (args) => ({
|
|
38
|
+
const DefaultTemplate: StoryFn<UDropdownBadgeArgs> = (args: UDropdownBadgeArgs) => ({
|
|
31
39
|
components: { UDropdownBadge, UIcon },
|
|
32
40
|
setup() {
|
|
33
41
|
const slots = getSlotNames(UDropdownBadge.__name);
|
|
@@ -38,17 +46,20 @@ const DefaultTemplate = (args) => ({
|
|
|
38
46
|
<UDropdownBadge
|
|
39
47
|
v-bind="args"
|
|
40
48
|
>
|
|
41
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
49
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
42
50
|
</UDropdownBadge>
|
|
43
51
|
`,
|
|
44
52
|
});
|
|
45
53
|
|
|
46
|
-
const EnumVariantTemplate = (
|
|
54
|
+
const EnumVariantTemplate: StoryFn<UDropdownBadgeArgs> = (
|
|
55
|
+
args: UDropdownBadgeArgs,
|
|
56
|
+
{ argTypes },
|
|
57
|
+
) => ({
|
|
47
58
|
components: { UDropdownBadge, URow },
|
|
48
59
|
setup() {
|
|
49
60
|
return {
|
|
50
61
|
args,
|
|
51
|
-
options: argTypes[args.enum]
|
|
62
|
+
options: argTypes?.[args.enum]?.options,
|
|
52
63
|
};
|
|
53
64
|
},
|
|
54
65
|
template: `
|