vueless 1.3.1-beta.1 → 1.3.2-beta.0
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/icons/internal/progress_activity.svg +1 -0
- package/package.json +1 -1
- package/ui.container-accordion/tests/UAccordion.test.ts +6 -9
- package/ui.container-accordion-item/tests/UAccordionItem.test.ts +18 -41
- package/ui.container-card/config.ts +2 -0
- package/ui.container-card/tests/UCard.test.ts +14 -31
- package/ui.container-card/types.ts +1 -1
- package/ui.container-col/tests/UCol.test.ts +11 -25
- package/ui.container-drawer/config.ts +1 -0
- package/ui.container-drawer/types.ts +1 -1
- package/ui.container-group/tests/UGroup.test.ts +12 -26
- package/ui.container-groups/tests/UGroups.test.ts +4 -11
- package/ui.container-modal/UModal.vue +1 -1
- package/ui.container-modal/config.ts +2 -1
- package/ui.container-modal/types.ts +1 -1
- package/ui.container-modal-confirm/UModalConfirm.vue +2 -2
- package/ui.container-modal-confirm/tests/UModalConfirm.test.ts +28 -57
- package/ui.container-modal-confirm/types.ts +1 -1
- package/ui.container-page/config.ts +2 -0
- package/ui.container-page/tests/UPage.test.ts +18 -38
- package/ui.container-page/types.ts +1 -1
- package/ui.container-row/tests/URow.test.ts +11 -25
- package/ui.form-calendar/config.ts +0 -1
- package/ui.form-checkbox/config.ts +14 -15
- package/ui.form-checkbox/storybook/docs.mdx +0 -16
- package/ui.form-checkbox/storybook/optionKeys.mdx +17 -0
- package/ui.form-checkbox/storybook/stories.ts +1 -3
- package/ui.form-checkbox-group/storybook/docs.mdx +2 -2
- package/ui.form-checkbox-multi-state/storybook/docs.mdx +3 -0
- package/ui.loader/ULoader.vue +10 -2
- package/ui.loader/config.ts +14 -1
- package/ui.loader/storybook/stories.ts +4 -1
- package/ui.loader/tests/ULoader.test.ts +74 -17
- package/ui.loader/types.ts +5 -0
- package/ui.loader-overlay/tests/ULoaderOverlay.test.ts +6 -15
- package/ui.loader-progress/tests/ULoaderProgress.test.ts +8 -18
- package/ui.navigation-breadcrumbs/tests/UBreadcrumbs.test.ts +18 -40
- package/ui.navigation-pagination/tests/UPagination.test.ts +18 -40
- package/ui.navigation-progress/tests/UProgress.test.ts +11 -25
- package/ui.navigation-tab/tests/UTab.test.ts +21 -46
- package/ui.navigation-tabs/tests/UTabs.test.ts +13 -30
- package/ui.other-chip/tests/UChip.test.ts +13 -29
- package/ui.other-dot/tests/UDot.test.ts +4 -10
- package/ui.other-theme-color-toggle/tests/UThemeColorToggle.test.ts +13 -29
- package/ui.skeleton/USkeleton.vue +6 -6
- package/ui.skeleton/config.ts +1 -13
- package/ui.skeleton/storybook/stories.ts +3 -20
- package/ui.skeleton/tests/USkeleton.test.ts +2 -27
- package/ui.skeleton/types.ts +0 -5
- package/ui.skeleton-choice/USkeletonChoice.vue +8 -8
- package/ui.skeleton-choice/config.ts +0 -1
- package/ui.skeleton-choice/storybook/stories.ts +3 -6
- package/ui.skeleton-choice/tests/USkeletonChoice.test.ts +7 -35
- package/ui.skeleton-choice/types.ts +0 -5
- package/ui.skeleton-input/USkeletonInput.vue +11 -10
- package/ui.skeleton-input/config.ts +0 -1
- package/ui.skeleton-input/storybook/stories.ts +4 -7
- package/ui.skeleton-input/tests/USkeletonInput.test.ts +11 -48
- package/ui.skeleton-input/types.ts +0 -5
- package/ui.skeleton-text/USkeletonText.vue +8 -8
- package/ui.skeleton-text/config.ts +2 -2
- package/ui.skeleton-text/storybook/stories.ts +1 -4
- package/ui.skeleton-text/tests/USkeletonText.test.ts +5 -32
- package/ui.skeleton-text/types.ts +0 -5
- package/ui.text-alert/tests/UAlert.test.ts +17 -38
- package/ui.text-badge/tests/UBadge.test.ts +19 -42
- package/ui.text-block/UText.vue +7 -7
- package/ui.text-block/config.ts +8 -7
- package/ui.text-block/storybook/stories.ts +13 -25
- package/ui.text-block/tests/UText.test.ts +27 -28
- package/ui.text-block/types.ts +6 -1
- package/ui.text-empty/tests/UEmpty.test.ts +14 -31
- package/ui.text-file/tests/UFile.test.ts +13 -30
- package/ui.text-files/tests/UFiles.test.ts +14 -32
- package/ui.text-header/config.ts +2 -0
- package/ui.text-header/tests/UHeader.test.ts +10 -23
- package/ui.text-notify/tests/UNotify.test.ts +12 -26
- package/ui.text-number/tests/UNumber.test.ts +16 -35
|
@@ -14,10 +14,8 @@ vi.mock("../../utils/theme.ts", () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
describe("UThemeColorToggle.vue", () => {
|
|
17
|
-
// Props tests
|
|
18
17
|
describe("Props", () => {
|
|
19
|
-
|
|
20
|
-
it("applies the correct size to color pickers", async () => {
|
|
18
|
+
it("Size – applies the correct size to color pickers", async () => {
|
|
21
19
|
const sizes = ["sm", "md", "lg"];
|
|
22
20
|
|
|
23
21
|
sizes.forEach((size) => {
|
|
@@ -39,8 +37,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
39
37
|
});
|
|
40
38
|
});
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
it("sets the primary color correctly", async () => {
|
|
40
|
+
it("Primary – sets the primary color correctly", async () => {
|
|
44
41
|
const primary = "blue";
|
|
45
42
|
|
|
46
43
|
const component = mount(UThemeColorToggle, {
|
|
@@ -55,8 +52,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
55
52
|
expect(primaryColorPicker.props("modelValue")).toBe(primary);
|
|
56
53
|
});
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
it("sets the neutral color correctly", async () => {
|
|
55
|
+
it("Neutral – sets the neutral color correctly", async () => {
|
|
60
56
|
const neutral = "gray";
|
|
61
57
|
|
|
62
58
|
const component = mount(UThemeColorToggle, {
|
|
@@ -71,8 +67,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
71
67
|
expect(neutralColorPicker.props("modelValue")).toBe(neutral);
|
|
72
68
|
});
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
it("passes primaryColors to the primary color picker", async () => {
|
|
70
|
+
it("PrimaryColors – passes primaryColors to the primary color picker", async () => {
|
|
76
71
|
const primaryColors = { blue: "#0000FF", red: "#FF0000" };
|
|
77
72
|
|
|
78
73
|
const component = mount(UThemeColorToggle, {
|
|
@@ -86,8 +81,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
86
81
|
expect(primaryColorPicker.props("colors")).toEqual(primaryColors);
|
|
87
82
|
});
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
it("passes neutralColors to the neutral color picker", async () => {
|
|
84
|
+
it("NeutralColors – passes neutralColors to the neutral color picker", async () => {
|
|
91
85
|
const neutralColors = { gray: "#808080", black: "#000000" };
|
|
92
86
|
|
|
93
87
|
const component = mount(UThemeColorToggle, {
|
|
@@ -101,8 +95,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
101
95
|
expect(neutralColorPicker.props("colors")).toEqual(neutralColors);
|
|
102
96
|
});
|
|
103
97
|
|
|
104
|
-
|
|
105
|
-
it("passes primaryLabels to the primary color picker", async () => {
|
|
98
|
+
it("PrimaryLabels – passes primaryLabels to the primary color picker", async () => {
|
|
106
99
|
const primaryLabels = { blue: "Blue", red: "Red" };
|
|
107
100
|
|
|
108
101
|
const component = mount(UThemeColorToggle, {
|
|
@@ -117,8 +110,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
117
110
|
expect(primaryColorPicker.props("labels")).toEqual(primaryLabels);
|
|
118
111
|
});
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
it("passes neutralLabels to the neutral color picker", async () => {
|
|
113
|
+
it("NeutralLabels – passes neutralLabels to the neutral color picker", async () => {
|
|
122
114
|
const neutralLabels = { gray: "Gray", black: "Black" };
|
|
123
115
|
|
|
124
116
|
const component = mount(UThemeColorToggle, {
|
|
@@ -133,8 +125,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
133
125
|
expect(neutralColorPicker.props("labels")).toEqual(neutralLabels);
|
|
134
126
|
});
|
|
135
127
|
|
|
136
|
-
|
|
137
|
-
it("applies the correct id attribute", () => {
|
|
128
|
+
it("ID – applies the correct id attribute", () => {
|
|
138
129
|
const id = "test-theme-toggle-id";
|
|
139
130
|
|
|
140
131
|
const component = mount(UThemeColorToggle, {
|
|
@@ -146,8 +137,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
146
137
|
expect(component.attributes("id")).toBe(id);
|
|
147
138
|
});
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
it("applies the correct data-test attribute", () => {
|
|
140
|
+
it("DataTest – applies the correct data-test attribute", () => {
|
|
151
141
|
const dataTest = "test-theme-toggle";
|
|
152
142
|
|
|
153
143
|
const component = mount(UThemeColorToggle, {
|
|
@@ -159,8 +149,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
159
149
|
expect(component.attributes("data-test")).toBe(dataTest);
|
|
160
150
|
});
|
|
161
151
|
|
|
162
|
-
|
|
163
|
-
it("shows divider when both primaryColors and neutralColors are provided", () => {
|
|
152
|
+
it("Divider – shows divider when both primaryColors and neutralColors are provided", () => {
|
|
164
153
|
const component = mount(UThemeColorToggle, {
|
|
165
154
|
props: {
|
|
166
155
|
primaryColors: { blue: "#0000FF" },
|
|
@@ -194,10 +183,8 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
194
183
|
});
|
|
195
184
|
});
|
|
196
185
|
|
|
197
|
-
// Events tests
|
|
198
186
|
describe("Events", () => {
|
|
199
|
-
|
|
200
|
-
it("emits update:primary event when primary color changes", async () => {
|
|
187
|
+
it("update:primary – emits update:primary event when primary color changes", async () => {
|
|
201
188
|
const primaryColors = { blue: "#0000FF", red: "#FF0000" };
|
|
202
189
|
const newColor = "red";
|
|
203
190
|
|
|
@@ -215,8 +202,7 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
215
202
|
expect(component.emitted("update:primary")![0]).toEqual([newColor]);
|
|
216
203
|
});
|
|
217
204
|
|
|
218
|
-
|
|
219
|
-
it("emits update:neutral event when neutral color changes", async () => {
|
|
205
|
+
it("update:neutral – emits update:neutral event when neutral color changes", async () => {
|
|
220
206
|
const neutralColors = { gray: "#808080", black: "#000000" };
|
|
221
207
|
const newColor = "black";
|
|
222
208
|
|
|
@@ -235,10 +221,8 @@ describe("UThemeColorToggle.vue", () => {
|
|
|
235
221
|
});
|
|
236
222
|
});
|
|
237
223
|
|
|
238
|
-
// Exposed refs tests
|
|
239
224
|
describe("Exposed refs", () => {
|
|
240
|
-
|
|
241
|
-
it("exposes listRef", () => {
|
|
225
|
+
it("listRef – exposes listRef", () => {
|
|
242
226
|
const component = mount(UThemeColorToggle, {});
|
|
243
227
|
|
|
244
228
|
expect(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from "vue";
|
|
3
2
|
import { useUI } from "../composables/useUI";
|
|
4
3
|
import { getDefaults } from "../utils/ui";
|
|
5
4
|
|
|
@@ -10,14 +9,15 @@ import type { Props, Config } from "./types";
|
|
|
10
9
|
|
|
11
10
|
defineOptions({ inheritAttrs: false });
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
withDefaults(defineProps<Props>(), {
|
|
14
13
|
...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Get element / nested component attributes for each config token ✨
|
|
18
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
19
|
+
*/
|
|
20
|
+
const { getDataTest, bodyAttrs } = useUI<Config>(defaultConfig);
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<template>
|
package/ui.skeleton/config.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
-
body:
|
|
3
|
-
base: "rounded-medium animate-pulse h-24 w-full bg-neutral/50",
|
|
4
|
-
variants: {
|
|
5
|
-
variant: {
|
|
6
|
-
light: "brightness-75",
|
|
7
|
-
default: "brightness-50",
|
|
8
|
-
dark: "brightness-25",
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
defaults: {
|
|
13
|
-
variant: "default",
|
|
14
|
-
},
|
|
2
|
+
body: "rounded-medium animate-pulse h-24 w-full bg-inverted/15",
|
|
15
3
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from "@storybook/vue3-vite";
|
|
2
|
-
import {
|
|
2
|
+
import { getArgTypes, getDocsDescription } from "../../utils/storybook";
|
|
3
3
|
|
|
4
4
|
import USkeleton from "../USkeleton.vue";
|
|
5
5
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
@@ -7,7 +7,7 @@ import UCol from "../../ui.container-col/UCol.vue";
|
|
|
7
7
|
import type { Props } from "../types";
|
|
8
8
|
|
|
9
9
|
interface SkeletonArgs extends Props {
|
|
10
|
-
enum
|
|
10
|
+
enum?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export default {
|
|
@@ -32,26 +32,9 @@ const DefaultTemplate: StoryFn<SkeletonArgs> = (args: SkeletonArgs) => ({
|
|
|
32
32
|
`,
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
const EnumVariantTemplate: StoryFn<SkeletonArgs> = (args: SkeletonArgs, { argTypes }) => ({
|
|
36
|
-
components: { USkeleton, UCol },
|
|
37
|
-
setup: () => ({ args, argTypes, getArgs }),
|
|
38
|
-
template: `
|
|
39
|
-
<UCol>
|
|
40
|
-
<USkeleton
|
|
41
|
-
v-for="option in argTypes?.[args.enum]?.options"
|
|
42
|
-
v-bind="getArgs(args, option)"
|
|
43
|
-
:key="option"
|
|
44
|
-
/>
|
|
45
|
-
</UCol>
|
|
46
|
-
`,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
35
|
export const Default = DefaultTemplate.bind({});
|
|
50
36
|
Default.args = {};
|
|
51
37
|
|
|
52
|
-
export const Variant = EnumVariantTemplate.bind({});
|
|
53
|
-
Variant.args = { enum: "variant" };
|
|
54
|
-
|
|
55
38
|
export const Slot: StoryFn<SkeletonArgs> = (args) => ({
|
|
56
39
|
components: { USkeleton, UCol },
|
|
57
40
|
setup() {
|
|
@@ -59,7 +42,7 @@ export const Slot: StoryFn<SkeletonArgs> = (args) => ({
|
|
|
59
42
|
},
|
|
60
43
|
template: `
|
|
61
44
|
<USkeleton v-bind="args" class="max-w-96 p-4">
|
|
62
|
-
<USkeleton class="w-15 h-10 rounded-small"
|
|
45
|
+
<USkeleton class="w-15 h-10 rounded-small" />
|
|
63
46
|
</USkeleton>
|
|
64
47
|
`,
|
|
65
48
|
});
|
|
@@ -3,32 +3,9 @@ import { describe, it, expect } from "vitest";
|
|
|
3
3
|
|
|
4
4
|
import USkeleton from "../USkeleton.vue";
|
|
5
5
|
|
|
6
|
-
import type { Props } from "../types";
|
|
7
|
-
|
|
8
6
|
describe("USkeleton.vue", () => {
|
|
9
|
-
// Props tests
|
|
10
7
|
describe("Props", () => {
|
|
11
|
-
|
|
12
|
-
it("applies the correct variant class", () => {
|
|
13
|
-
const variants = {
|
|
14
|
-
light: "brightness-75",
|
|
15
|
-
default: "brightness-50",
|
|
16
|
-
dark: "brightness-25",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
Object.entries(variants).forEach(([variant, classes]) => {
|
|
20
|
-
const component = mount(USkeleton, {
|
|
21
|
-
props: {
|
|
22
|
-
variant: variant as Props["variant"],
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
expect(component.attributes("class")).toContain(classes);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// DataTest prop
|
|
31
|
-
it("applies the correct data-test attribute", () => {
|
|
8
|
+
it("DataTest – applies the correct data-test attribute", () => {
|
|
32
9
|
const dataTest = "test-skeleton";
|
|
33
10
|
|
|
34
11
|
const component = mount(USkeleton, {
|
|
@@ -41,10 +18,8 @@ describe("USkeleton.vue", () => {
|
|
|
41
18
|
});
|
|
42
19
|
});
|
|
43
20
|
|
|
44
|
-
// Slots tests
|
|
45
21
|
describe("Slots", () => {
|
|
46
|
-
|
|
47
|
-
it("renders content from default slot", () => {
|
|
22
|
+
it("Default – renders content from default slot", () => {
|
|
48
23
|
const slotContent = "Custom Content";
|
|
49
24
|
const slotClass = "custom-content";
|
|
50
25
|
|
package/ui.skeleton/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from "vue";
|
|
3
2
|
import { useUI } from "../composables/useUI";
|
|
4
3
|
import { getDefaults } from "../utils/ui";
|
|
5
4
|
|
|
@@ -12,22 +11,23 @@ import USkeleton from "../ui.skeleton/USkeleton.vue";
|
|
|
12
11
|
|
|
13
12
|
defineOptions({ inheritAttrs: false });
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
withDefaults(defineProps<Props>(), {
|
|
16
15
|
...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
|
|
17
16
|
});
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Get element / nested component attributes for each config token ✨
|
|
20
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
21
|
+
*/
|
|
22
|
+
const { getDataTest, inputAttrs, labelAttrs, wrapperAttrs } = useUI<Config>(defaultConfig);
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
25
|
<template>
|
|
26
26
|
<div v-bind="wrapperAttrs" :data-test="getDataTest()">
|
|
27
|
-
<USkeleton
|
|
27
|
+
<USkeleton v-bind="inputAttrs" />
|
|
28
28
|
<!-- @slot Use it to customize the label skeleton. -->
|
|
29
29
|
<slot v-if="label" name="label">
|
|
30
|
-
<USkeleton
|
|
30
|
+
<USkeleton v-bind="labelAttrs" />
|
|
31
31
|
</slot>
|
|
32
32
|
</div>
|
|
33
33
|
</template>
|
|
@@ -8,7 +8,7 @@ import USkeleton from "../../ui.skeleton/USkeleton.vue";
|
|
|
8
8
|
import type { Props } from "../types";
|
|
9
9
|
|
|
10
10
|
interface SkeletonChoiceArgs extends Props {
|
|
11
|
-
enum: "
|
|
11
|
+
enum: "size" | "labelAlign" | "type";
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export default {
|
|
@@ -73,9 +73,6 @@ LabelAlign.args = { enum: "labelAlign" };
|
|
|
73
73
|
export const Sizes = EnumVariantTemplate.bind({});
|
|
74
74
|
Sizes.args = { enum: "size" };
|
|
75
75
|
|
|
76
|
-
export const Variant = EnumVariantTemplate.bind({});
|
|
77
|
-
Variant.args = { enum: "variant" };
|
|
78
|
-
|
|
79
76
|
export const LabelSlot: StoryFn<SkeletonChoiceArgs> = (args) => ({
|
|
80
77
|
components: { USkeletonChoice, USkeleton, UCol },
|
|
81
78
|
setup() {
|
|
@@ -85,8 +82,8 @@ export const LabelSlot: StoryFn<SkeletonChoiceArgs> = (args) => ({
|
|
|
85
82
|
<USkeletonChoice v-bind="args">
|
|
86
83
|
<template #label>
|
|
87
84
|
<UCol gap="2xs">
|
|
88
|
-
<USkeleton class="h-3 w-36 rounded-small"
|
|
89
|
-
<USkeleton class="h-1.5 rounded-small"
|
|
85
|
+
<USkeleton class="h-3 w-36 rounded-small" />
|
|
86
|
+
<USkeleton class="h-1.5 rounded-small" />
|
|
90
87
|
</UCol>
|
|
91
88
|
</template>
|
|
92
89
|
</USkeletonChoice>
|
|
@@ -7,10 +7,8 @@ import USkeleton from "../../ui.skeleton/USkeleton.vue";
|
|
|
7
7
|
import type { Props } from "../types";
|
|
8
8
|
|
|
9
9
|
describe("USkeletonChoice.vue", () => {
|
|
10
|
-
// Props tests
|
|
11
10
|
describe("Props", () => {
|
|
12
|
-
|
|
13
|
-
it("renders label skeleton when label prop is true", () => {
|
|
11
|
+
it("Label – renders label skeleton when label prop is true", () => {
|
|
14
12
|
const label = true;
|
|
15
13
|
|
|
16
14
|
const component = mount(USkeletonChoice, {
|
|
@@ -24,8 +22,7 @@ describe("USkeletonChoice.vue", () => {
|
|
|
24
22
|
expect(skeletons.length).toBe(2); // Input and label skeletons
|
|
25
23
|
});
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
it("does not render label skeleton when label prop is false", () => {
|
|
25
|
+
it("Label – does not render label skeleton when label prop is false", () => {
|
|
29
26
|
const label = false;
|
|
30
27
|
|
|
31
28
|
const component = mount(USkeletonChoice, {
|
|
@@ -39,8 +36,7 @@ describe("USkeletonChoice.vue", () => {
|
|
|
39
36
|
expect(skeletons.length).toBe(1); // Only input skeleton
|
|
40
37
|
});
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
it("applies the correct size class to wrapper", () => {
|
|
39
|
+
it("Size – applies the correct size class to wrapper", () => {
|
|
44
40
|
const size = {
|
|
45
41
|
sm: "gap-2",
|
|
46
42
|
md: "gap-2.5",
|
|
@@ -99,8 +95,7 @@ describe("USkeletonChoice.vue", () => {
|
|
|
99
95
|
});
|
|
100
96
|
});
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
it("applies the correct labelAlign class to wrapper", () => {
|
|
98
|
+
it("LabelAlign – applies the correct labelAlign class to wrapper", () => {
|
|
104
99
|
const labelAlign = {
|
|
105
100
|
left: "flex-row",
|
|
106
101
|
right: "flex-row-reverse",
|
|
@@ -117,8 +112,7 @@ describe("USkeletonChoice.vue", () => {
|
|
|
117
112
|
});
|
|
118
113
|
});
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
it("applies the correct type class to input", () => {
|
|
115
|
+
it("Type – applies the correct type class to input", () => {
|
|
122
116
|
const type = {
|
|
123
117
|
checkbox: "rounded-small",
|
|
124
118
|
radio: "rounded-full",
|
|
@@ -137,27 +131,7 @@ describe("USkeletonChoice.vue", () => {
|
|
|
137
131
|
});
|
|
138
132
|
});
|
|
139
133
|
|
|
140
|
-
|
|
141
|
-
it("passes the correct variant to skeleton components", () => {
|
|
142
|
-
const variants = ["light", "default", "dark"];
|
|
143
|
-
|
|
144
|
-
variants.forEach((variant) => {
|
|
145
|
-
const component = mount(USkeletonChoice, {
|
|
146
|
-
props: {
|
|
147
|
-
variant: variant as Props["variant"],
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const inputSkeleton = component.findAllComponents(USkeleton)[0];
|
|
152
|
-
const labelSkeleton = component.findAllComponents(USkeleton)[1];
|
|
153
|
-
|
|
154
|
-
expect(inputSkeleton.props("variant")).toBe(variant);
|
|
155
|
-
expect(labelSkeleton.props("variant")).toBe(variant);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// DataTest prop
|
|
160
|
-
it("applies the correct data-test attribute", () => {
|
|
134
|
+
it("DataTest – applies the correct data-test attribute", () => {
|
|
161
135
|
const dataTest = "test-skeleton-choice";
|
|
162
136
|
|
|
163
137
|
const component = mount(USkeletonChoice, {
|
|
@@ -170,10 +144,8 @@ describe("USkeletonChoice.vue", () => {
|
|
|
170
144
|
});
|
|
171
145
|
});
|
|
172
146
|
|
|
173
|
-
// Slots tests
|
|
174
147
|
describe("Slots", () => {
|
|
175
|
-
|
|
176
|
-
it("renders content from label slot", () => {
|
|
148
|
+
it("Label – renders content from label slot", () => {
|
|
177
149
|
const slotContent = "Custom Label";
|
|
178
150
|
const slotClass = "custom-label";
|
|
179
151
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from "vue";
|
|
3
2
|
import { useUI } from "../composables/useUI";
|
|
4
3
|
import { getDefaults } from "../utils/ui";
|
|
5
4
|
|
|
@@ -12,29 +11,31 @@ import USkeleton from "../ui.skeleton/USkeleton.vue";
|
|
|
12
11
|
|
|
13
12
|
defineOptions({ inheritAttrs: false });
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
withDefaults(defineProps<Props>(), {
|
|
16
15
|
...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
|
|
17
16
|
});
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Get element / nested component attributes for each config token ✨
|
|
20
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
21
|
+
*/
|
|
22
|
+
const { getDataTest, inputAttrs, textareaAttrs, labelAttrs, wrapperAttrs } =
|
|
23
|
+
useUI<Config>(defaultConfig);
|
|
23
24
|
</script>
|
|
24
25
|
|
|
25
26
|
<template>
|
|
26
27
|
<div v-bind="wrapperAttrs" :data-test="getDataTest()">
|
|
27
28
|
<!-- @slot Use it to customize the label skeleton. -->
|
|
28
|
-
<slot v-if="
|
|
29
|
-
<USkeleton
|
|
29
|
+
<slot v-if="labelAlign !== LABEL_ALIGN.topInside && label" name="label">
|
|
30
|
+
<USkeleton v-bind="labelAttrs" />
|
|
30
31
|
</slot>
|
|
31
32
|
|
|
32
|
-
<USkeleton v-if="
|
|
33
|
+
<USkeleton v-if="type === 'input'" v-bind="inputAttrs">
|
|
33
34
|
<!-- @slot Use it to add custom content inside the input skeleton. -->
|
|
34
35
|
<slot />
|
|
35
36
|
</USkeleton>
|
|
36
37
|
|
|
37
|
-
<USkeleton v-else
|
|
38
|
+
<USkeleton v-else v-bind="textareaAttrs">
|
|
38
39
|
<!-- @slot Use it to add custom content inside the textarea skeleton. -->
|
|
39
40
|
<slot />
|
|
40
41
|
</USkeleton>
|
|
@@ -16,7 +16,7 @@ import type { Props } from "../types";
|
|
|
16
16
|
|
|
17
17
|
interface SkeletonInputArgs extends Props {
|
|
18
18
|
slotTemplate?: string;
|
|
19
|
-
enum: "
|
|
19
|
+
enum: "size" | "labelAlign" | "type";
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default {
|
|
@@ -88,9 +88,6 @@ export const Types: StoryFn<SkeletonInputArgs> = (args: SkeletonInputArgs) => ({
|
|
|
88
88
|
export const Sizes = EnumTemplate.bind({});
|
|
89
89
|
Sizes.args = { enum: "size" };
|
|
90
90
|
|
|
91
|
-
export const Variants = EnumTemplate.bind({});
|
|
92
|
-
Variants.args = { enum: "variant" };
|
|
93
|
-
|
|
94
91
|
export const Slot: StoryFn<SkeletonInputArgs> = (args) => ({
|
|
95
92
|
components: { USkeletonInput, USkeleton, UCol },
|
|
96
93
|
setup() {
|
|
@@ -99,7 +96,7 @@ export const Slot: StoryFn<SkeletonInputArgs> = (args) => ({
|
|
|
99
96
|
template: `
|
|
100
97
|
<USkeletonInput label-align="top" v-bind="args" class="!max-w-96">
|
|
101
98
|
<UCol align="end" >
|
|
102
|
-
<USkeleton class="size-5 rounded-small"
|
|
99
|
+
<USkeleton class="size-5 rounded-small" />
|
|
103
100
|
</UCol>
|
|
104
101
|
</USkeletonInput>
|
|
105
102
|
`,
|
|
@@ -114,8 +111,8 @@ export const LabelSlot: StoryFn<SkeletonInputArgs> = (args) => ({
|
|
|
114
111
|
<USkeletonInput v-bind="args" label-align="top" class="!max-w-96">
|
|
115
112
|
<template #label>
|
|
116
113
|
<UCol gap="2xs"s>
|
|
117
|
-
<USkeleton class="h-3 w-36 rounded-small"
|
|
118
|
-
<USkeleton class="h-1.5 w-24 rounded-small"
|
|
114
|
+
<USkeleton class="h-3 w-36 rounded-small" />
|
|
115
|
+
<USkeleton class="h-1.5 w-24 rounded-small" />
|
|
119
116
|
</UCol>
|
|
120
117
|
</template>
|
|
121
118
|
</USkeletonInput>
|