srcdev-nuxt-components 9.4.6 → 9.4.7
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/.claude/commands/migrate-component.md +34 -3
- package/.claude/component-ledger/audit.json +1 -1
- package/.claude/component-ledger/build.mjs +27 -0
- package/.claude/component-ledger/output.html +8 -3
- package/.claude/component-ledger/template.html +7 -2
- package/.claude/skills/components/column-flow-grid.md +93 -0
- package/.claude/skills/components/entry-animation.md +88 -0
- package/.claude/skills/components/input-copy.md +2 -0
- package/.claude/skills/components/input-text-core.md +186 -0
- package/.claude/skills/components/masonry-grid.md +153 -0
- package/.claude/skills/components/pop-over.md +100 -0
- package/.claude/skills/index.md +6 -1
- package/.vscode/srcdev-component-column-flow-grid.code-snippets +39 -0
- package/.vscode/srcdev-component-entry-animation.code-snippets +29 -0
- package/.vscode/srcdev-component-input-text.code-snippets +107 -0
- package/.vscode/srcdev-component-masonry-grid.code-snippets +51 -0
- package/.vscode/srcdev-component-pop-over.code-snippets +44 -0
- package/app/components/01.atoms/animations/entry/EntryAnimation.vue +7 -1
- package/app/components/01.atoms/animations/entry/stories/EntryAnimation.stories.ts +47 -0
- package/app/components/01.atoms/animations/entry/tests/EntryAnimation.spec.ts +57 -0
- package/app/components/01.atoms/canvas-switcher/stories/CanvasSwitcher.stories.ts +9 -10
- package/app/components/01.atoms/content-wrappers/docs-pages/stories/ContentDocs.stories.ts +12 -13
- package/app/components/01.atoms/grids/column-flow-grid/CONSUMER-STYLING.md +33 -0
- package/app/components/01.atoms/grids/column-flow-grid/ColumnFlowGrid.vue +55 -0
- package/app/components/01.atoms/grids/column-flow-grid/stories/ColumnFlowGrid.stories.ts +178 -0
- package/app/components/01.atoms/grids/column-flow-grid/tests/ColumnFlowGrid.spec.ts +75 -0
- package/app/components/01.atoms/grids/masonry-grid/CONSUMER-STYLING.md +35 -0
- package/app/components/01.atoms/grids/masonry-grid/MasonryGrid.vue +178 -0
- package/app/components/01.atoms/grids/masonry-grid/stories/MasonryGrid.stories.ts +199 -0
- package/app/components/01.atoms/grids/masonry-grid/tests/MasonryGrid.spec.ts +158 -0
- package/app/components/01.atoms/pop-over/CONSUMER-STYLING.md +54 -0
- package/app/components/01.atoms/pop-over/PopOver.vue +201 -0
- package/app/components/01.atoms/pop-over/stories/PopOver.stories.ts +141 -0
- package/app/components/01.atoms/pop-over/tests/PopOver.spec.ts +195 -0
- package/app/components/01.atoms/pop-over/tests/__snapshots__/PopOver.spec.ts.snap +11 -0
- package/app/components/02.molecules/action-menu/stories/ActionMenu.stories.ts +8 -2
- package/app/components/02.molecules/input-copy/InputCopy.vue +14 -0
- package/app/components/02.molecules/input-copy/stories/InputCopy.stories.ts +15 -0
- package/app/components/02.molecules/input-copy/tests/InputCopy.spec.ts +41 -0
- package/app/components/05.forms/input-select/InputSelectCore.vue +1 -1
- package/app/components/05.forms/input-text/InputTextCore.vue +6 -0
- package/app/components/05.forms/input-text/stories/InputPasswordWithLabel.stories.ts +49 -20
- package/app/components/05.forms/input-text/stories/InputTextAsNumberWithLabel.stories.ts +41 -22
- package/app/components/05.forms/input-text/stories/InputTextCore.stories.ts +48 -22
- package/app/components/05.forms/input-text/stories/InputTextWithLabel.stories.ts +43 -17
- package/app/components/05.forms/input-text/tests/InputPasswordWithLabel.spec.ts +56 -0
- package/app/components/05.forms/input-text/tests/InputTextAsNumberWithLabel.spec.ts +61 -0
- package/app/components/05.forms/input-text/tests/InputTextCore.spec.ts +60 -0
- package/app/components/05.forms/input-text/tests/InputTextWithLabel.spec.ts +46 -0
- package/app/components/05.forms/input-text/variants/InputPasswordWithLabel.vue +7 -1
- package/app/components/05.forms/input-text/variants/InputTextAsNumberWithLabel.vue +8 -2
- package/app/components/05.forms/input-text/variants/InputTextWithLabel.vue +6 -0
- package/app/components/05.forms/input-textarea/stories/InputTextareaCore.stories.ts +20 -20
- package/app/components/05.forms/input-textarea/stories/InputTextareaWithLabel.stories.ts +32 -26
- package/app/types/forms/types.forms.d.ts +1 -1
- package/package.json +1 -1
- package/app/components/masonry-grid/MasonryGrid.vue +0 -68
- package/app/components/masonry-grid-ordered/MasonryGridOrdered.vue +0 -163
- package/app/components/masonry-grid-ordered/MasonryGridOrderedGridExperiment.vue +0 -259
- package/app/components/masonry-grid-ordered/stories/MasonryGridOrdered.stories.ts +0 -354
- package/app/components/masonry-grid-sorted/MasonryGridSorted.vue +0 -120
- package/app/components/pop-over/PopOver.vue +0 -90
- package/app/layouts/default.vue +0 -308
- package/app/layouts/site-navigation-demo.vue +0 -188
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
+
import { mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import PopOver from "../PopOver.vue";
|
|
4
|
+
|
|
5
|
+
interface PopOverInstance {
|
|
6
|
+
popoverId: string;
|
|
7
|
+
anchorName: string;
|
|
8
|
+
handleToggle: (event: Event) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const createWrapper = async (props: Record<string, unknown> = {}, slots: Record<string, string> = {}) => {
|
|
12
|
+
return mountSuspended(PopOver, { props, slots });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("PopOver", () => {
|
|
16
|
+
let wrapper: Awaited<ReturnType<typeof createWrapper>>;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
// Popover API is not implemented in jsdom — define stubs so we can test
|
|
20
|
+
Object.defineProperty(HTMLElement.prototype, "hidePopover", {
|
|
21
|
+
value: vi.fn(),
|
|
22
|
+
writable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(HTMLElement.prototype, "showPopover", {
|
|
26
|
+
value: vi.fn(),
|
|
27
|
+
writable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
wrapper?.unmount();
|
|
34
|
+
vi.restoreAllMocks();
|
|
35
|
+
delete (HTMLElement.prototype as unknown as Record<string, unknown>)["hidePopover"];
|
|
36
|
+
delete (HTMLElement.prototype as unknown as Record<string, unknown>)["showPopover"];
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("mounts without error", async () => {
|
|
40
|
+
wrapper = await createWrapper();
|
|
41
|
+
expect(wrapper.vm).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("renders correct HTML structure", async () => {
|
|
45
|
+
wrapper = await createWrapper(
|
|
46
|
+
{},
|
|
47
|
+
{ trigger: "<span>Open</span>", content: "<p>Details</p>" }
|
|
48
|
+
);
|
|
49
|
+
expect(wrapper.html()).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("Trigger", () => {
|
|
53
|
+
it("renders the trigger slot", async () => {
|
|
54
|
+
wrapper = await createWrapper({}, { trigger: '<span class="slot-trigger">Open</span>' });
|
|
55
|
+
expect(wrapper.find(".slot-trigger").text()).toBe("Open");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("trigger button has type='button'", async () => {
|
|
59
|
+
wrapper = await createWrapper();
|
|
60
|
+
expect(wrapper.find(".pop-over-trigger").attributes("type")).toBe("button");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("does not set aria-label on the trigger by default", async () => {
|
|
64
|
+
wrapper = await createWrapper();
|
|
65
|
+
expect(wrapper.find(".pop-over-trigger").attributes("aria-label")).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("sets aria-label on the trigger when triggerAriaLabel is given", async () => {
|
|
69
|
+
wrapper = await createWrapper({ triggerAriaLabel: "Show filters" });
|
|
70
|
+
expect(wrapper.find(".pop-over-trigger").attributes("aria-label")).toBe("Show filters");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("trigger button popovertarget matches the popover id", async () => {
|
|
74
|
+
wrapper = await createWrapper();
|
|
75
|
+
const vm = wrapper.vm as unknown as PopOverInstance;
|
|
76
|
+
expect(wrapper.find(".pop-over-trigger").attributes("popovertarget")).toBe(vm.popoverId);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("trigger button has popovertargetaction='toggle'", async () => {
|
|
80
|
+
wrapper = await createWrapper();
|
|
81
|
+
expect(wrapper.find(".pop-over-trigger").attributes("popovertargetaction")).toBe("toggle");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("Popover panel", () => {
|
|
86
|
+
it("renders the content slot", async () => {
|
|
87
|
+
wrapper = await createWrapper({}, { content: '<p class="slot-content">Details</p>' });
|
|
88
|
+
expect(wrapper.find(".pop-over-popover .slot-content").text()).toBe("Details");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("has the popover attribute", async () => {
|
|
92
|
+
wrapper = await createWrapper();
|
|
93
|
+
expect(wrapper.find(".pop-over-popover").attributes("popover")).toBeDefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("does not set aria-label by default", async () => {
|
|
97
|
+
wrapper = await createWrapper();
|
|
98
|
+
expect(wrapper.find(".pop-over-popover").attributes("aria-label")).toBeUndefined();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("sets aria-label when popoverAriaLabel is given", async () => {
|
|
102
|
+
wrapper = await createWrapper({ popoverAriaLabel: "Filter options" });
|
|
103
|
+
expect(wrapper.find(".pop-over-popover").attributes("aria-label")).toBe("Filter options");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("sets data-placement on the root element", async () => {
|
|
107
|
+
wrapper = await createWrapper({ placement: "top" });
|
|
108
|
+
expect(wrapper.find(".pop-over").attributes("data-placement")).toBe("top");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("defaults placement to right", async () => {
|
|
112
|
+
wrapper = await createWrapper();
|
|
113
|
+
expect(wrapper.find(".pop-over").attributes("data-placement")).toBe("right");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("Close button", () => {
|
|
118
|
+
it("has a default aria-label", async () => {
|
|
119
|
+
wrapper = await createWrapper();
|
|
120
|
+
expect(wrapper.find(".pop-over-close-button").attributes("aria-label")).toBe("Close");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("uses a custom closeButtonAriaLabel", async () => {
|
|
124
|
+
wrapper = await createWrapper({ closeButtonAriaLabel: "Dismiss" });
|
|
125
|
+
expect(wrapper.find(".pop-over-close-button").attributes("aria-label")).toBe("Dismiss");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("has popovertargetaction='hide' pointing at the popover", async () => {
|
|
129
|
+
wrapper = await createWrapper();
|
|
130
|
+
const vm = wrapper.vm as unknown as PopOverInstance;
|
|
131
|
+
const closeButton = wrapper.find(".pop-over-close-button");
|
|
132
|
+
expect(closeButton.attributes("popovertargetaction")).toBe("hide");
|
|
133
|
+
expect(closeButton.attributes("popovertarget")).toBe(vm.popoverId);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("handleToggle focus management", () => {
|
|
138
|
+
it("focuses the close button when the popover opens", async () => {
|
|
139
|
+
wrapper = await createWrapper();
|
|
140
|
+
const closeButtonEl = wrapper.find(".pop-over-close-button").element as HTMLElement;
|
|
141
|
+
const focusSpy = vi.spyOn(closeButtonEl, "focus");
|
|
142
|
+
|
|
143
|
+
const vm = wrapper.vm as unknown as PopOverInstance;
|
|
144
|
+
vm.handleToggle(Object.assign(new Event("toggle"), { newState: "open" }));
|
|
145
|
+
|
|
146
|
+
expect(focusSpy).toHaveBeenCalledOnce();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("does not move focus when the popover closes", async () => {
|
|
150
|
+
wrapper = await createWrapper();
|
|
151
|
+
const closeButtonEl = wrapper.find(".pop-over-close-button").element as HTMLElement;
|
|
152
|
+
const focusSpy = vi.spyOn(closeButtonEl, "focus");
|
|
153
|
+
|
|
154
|
+
const vm = wrapper.vm as unknown as PopOverInstance;
|
|
155
|
+
vm.handleToggle(Object.assign(new Event("toggle"), { newState: "closed" }));
|
|
156
|
+
|
|
157
|
+
expect(focusSpy).not.toHaveBeenCalled();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe("Anchor name", () => {
|
|
162
|
+
it("sets a unique --_anchor-name on the root element style", async () => {
|
|
163
|
+
wrapper = await createWrapper();
|
|
164
|
+
const style = wrapper.find(".pop-over").attributes("style") ?? "";
|
|
165
|
+
expect(style).toContain("--_anchor-name: --pop-over-anchor-");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("styleClassPassthrough", () => {
|
|
170
|
+
it("applies a string class to the root element", async () => {
|
|
171
|
+
wrapper = await createWrapper({ styleClassPassthrough: "custom-pop-over" });
|
|
172
|
+
expect(wrapper.find(".pop-over").classes()).toContain("custom-pop-over");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("applies an array of classes to the root element", async () => {
|
|
176
|
+
wrapper = await createWrapper({ styleClassPassthrough: ["pop-over-a", "pop-over-b"] });
|
|
177
|
+
expect(wrapper.find(".pop-over").classes()).toContain("pop-over-a");
|
|
178
|
+
expect(wrapper.find(".pop-over").classes()).toContain("pop-over-b");
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("root element always has the 'pop-over' class", async () => {
|
|
182
|
+
wrapper = await createWrapper({ styleClassPassthrough: "extra-class" });
|
|
183
|
+
expect(wrapper.find(".pop-over").classes()).toContain("pop-over");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("resets classes when styleClassPassthrough prop changes", async () => {
|
|
187
|
+
wrapper = await createWrapper({ styleClassPassthrough: "initial-class" });
|
|
188
|
+
expect(wrapper.find(".pop-over").classes()).toContain("initial-class");
|
|
189
|
+
|
|
190
|
+
await wrapper.setProps({ styleClassPassthrough: "updated-class" });
|
|
191
|
+
expect(wrapper.find(".pop-over").classes()).not.toContain("initial-class");
|
|
192
|
+
expect(wrapper.find(".pop-over").classes()).toContain("updated-class");
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`PopOver > renders correct HTML structure 1`] = `
|
|
4
|
+
"<div class="pop-over" style="--_anchor-name: --pop-over-anchor-v-0-0;" data-placement="right"><button popovertarget="pop-over-v-0-0" popovertargetaction="toggle" type="button" class="pop-over-trigger"><span>Open</span></button>
|
|
5
|
+
<div id="pop-over-v-0-0" popover="" class="pop-over-popover"><button popovertarget="pop-over-v-0-0" popovertargetaction="hide" type="button" class="pop-over-close-button" aria-label="Close"><span class="iconify i-lucide:x pop-over-close-button-icon" aria-hidden="true"></span></button>
|
|
6
|
+
<div class="pop-over-content">
|
|
7
|
+
<p>Details</p>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</div>"
|
|
11
|
+
`;
|
|
@@ -74,10 +74,16 @@ export const Default: Story = {
|
|
|
74
74
|
render: (args) => ({
|
|
75
75
|
components: { ActionMenu, ActionMenuItemCore },
|
|
76
76
|
setup() {
|
|
77
|
-
|
|
77
|
+
// `args` is Storybook's own reactive object — read from it directly (`args.x`) inside
|
|
78
|
+
// these computeds rather than destructuring it into local variables at setup-time, which
|
|
79
|
+
// would snapshot the values once and stop reflecting later Controls-panel changes.
|
|
80
|
+
const componentArgs = computed(() => {
|
|
81
|
+
const { itemCount, ...rest } = args;
|
|
82
|
+
return rest;
|
|
83
|
+
});
|
|
78
84
|
const lastAction = ref<string | null>(null);
|
|
79
85
|
const items = computed(() =>
|
|
80
|
-
actionItems.slice(0, itemCount ?? 5).map((item, i) => ({
|
|
86
|
+
actionItems.slice(0, args.itemCount ?? 5).map((item, i) => ({
|
|
81
87
|
...item,
|
|
82
88
|
slotName: `item-${i}`,
|
|
83
89
|
}))
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
<div class="input-copy" :class="elementClasses">
|
|
3
3
|
<div class="input-copy__wrapper">
|
|
4
4
|
<input
|
|
5
|
+
:id="resolvedId"
|
|
5
6
|
type="text"
|
|
6
7
|
class="input-copy__input"
|
|
8
|
+
:name="name || resolvedId"
|
|
7
9
|
:value="value"
|
|
8
10
|
:aria-label="ariaLabel || label"
|
|
9
11
|
readonly
|
|
@@ -26,6 +28,9 @@
|
|
|
26
28
|
<script setup lang="ts">
|
|
27
29
|
interface Props {
|
|
28
30
|
value: string;
|
|
31
|
+
/** Defaults to an auto-generated id — pass one explicitly only if something needs to target this input. */
|
|
32
|
+
id?: string;
|
|
33
|
+
name?: string;
|
|
29
34
|
label?: string;
|
|
30
35
|
ariaLabel?: string;
|
|
31
36
|
description?: string;
|
|
@@ -37,6 +42,8 @@ interface Props {
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
const props = withDefaults(defineProps<Props>(), {
|
|
45
|
+
id: undefined,
|
|
46
|
+
name: undefined,
|
|
40
47
|
label: undefined,
|
|
41
48
|
ariaLabel: undefined,
|
|
42
49
|
description: undefined,
|
|
@@ -47,6 +54,13 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
47
54
|
styleClassPassthrough: () => [],
|
|
48
55
|
});
|
|
49
56
|
|
|
57
|
+
// Readonly text inputs still need an id/name to satisfy "a form field element should have an
|
|
58
|
+
// id or name attribute" — auto-generated so every existing call site (none of which pass one)
|
|
59
|
+
// gets a valid, unique id for free. Named resolvedId, not id, so it can't be confused with (or
|
|
60
|
+
// silently shadow) the `id` prop it falls back to.
|
|
61
|
+
const autoId = useId();
|
|
62
|
+
const resolvedId = computed(() => props.id ?? autoId);
|
|
63
|
+
|
|
50
64
|
const emit = defineEmits<{
|
|
51
65
|
copy: [value: string];
|
|
52
66
|
copied: [value: string];
|
|
@@ -7,6 +7,11 @@ const meta: Meta<typeof InputCopy> = {
|
|
|
7
7
|
tags: ["autodocs"],
|
|
8
8
|
argTypes: {
|
|
9
9
|
value: { control: "text" },
|
|
10
|
+
id: {
|
|
11
|
+
control: "text",
|
|
12
|
+
description: "Defaults to an auto-generated id — pass one only if something needs to target this input.",
|
|
13
|
+
},
|
|
14
|
+
name: { control: "text", description: "Defaults to the resolved id if not provided." },
|
|
10
15
|
label: { control: "text" },
|
|
11
16
|
description: { control: "text" },
|
|
12
17
|
buttonText: { control: "text" },
|
|
@@ -101,6 +106,16 @@ export const NoDescription: Story = {
|
|
|
101
106
|
},
|
|
102
107
|
};
|
|
103
108
|
|
|
109
|
+
export const WithExplicitIdAndName: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
value: "sk_live_abc123defgh456xyz789uvw",
|
|
112
|
+
id: "checkout-license-key",
|
|
113
|
+
name: "licenseKey",
|
|
114
|
+
label: "License key",
|
|
115
|
+
description: "Demonstrates passing explicit id/name instead of relying on the auto-generated one.",
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
104
119
|
export const LongValue: Story = {
|
|
105
120
|
args: {
|
|
106
121
|
value: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.POdHyP_DQkT3WTZhu9qLWSwVe8ZlHfHEPBOzzVI3vFA",
|
|
@@ -178,4 +178,45 @@ describe("InputCopy", () => {
|
|
|
178
178
|
expect(wrapper.classes()).toContain("custom-class");
|
|
179
179
|
expect(wrapper.classes()).toContain("another-class");
|
|
180
180
|
});
|
|
181
|
+
|
|
182
|
+
it("auto-generates an id and mirrors it as the name when neither is provided", () => {
|
|
183
|
+
const wrapper = mount(InputCopy, {
|
|
184
|
+
props: {
|
|
185
|
+
value: "test-key",
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const input = wrapper.find("input");
|
|
190
|
+
const id = input.attributes("id");
|
|
191
|
+
|
|
192
|
+
expect(id).toBeTruthy();
|
|
193
|
+
expect(input.attributes("name")).toBe(id);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("uses the provided id prop instead of auto-generating one", () => {
|
|
197
|
+
const wrapper = mount(InputCopy, {
|
|
198
|
+
props: {
|
|
199
|
+
value: "test-key",
|
|
200
|
+
id: "license-key-input",
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const input = wrapper.find("input");
|
|
205
|
+
expect(input.attributes("id")).toBe("license-key-input");
|
|
206
|
+
expect(input.attributes("name")).toBe("license-key-input");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("uses the provided name prop instead of falling back to the id", () => {
|
|
210
|
+
const wrapper = mount(InputCopy, {
|
|
211
|
+
props: {
|
|
212
|
+
value: "test-key",
|
|
213
|
+
id: "license-key-input",
|
|
214
|
+
name: "licenseKey",
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const input = wrapper.find("input");
|
|
219
|
+
expect(input.attributes("id")).toBe("license-key-input");
|
|
220
|
+
expect(input.attributes("name")).toBe("licenseKey");
|
|
221
|
+
});
|
|
181
222
|
});
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
:name
|
|
28
28
|
:required
|
|
29
29
|
:maxlength
|
|
30
|
+
:min
|
|
31
|
+
:max
|
|
30
32
|
:class="['input-text-core', elementClasses, { dirty: isDirty }, { active: isActive }]"
|
|
31
33
|
:aria-invalid="fieldHasError ? 'true' : undefined"
|
|
32
34
|
:aria-describedby
|
|
@@ -49,6 +51,10 @@ interface Props {
|
|
|
49
51
|
type?: InputTypesText;
|
|
50
52
|
inputmode?: InputMode;
|
|
51
53
|
maxlength?: number;
|
|
54
|
+
/** Passed straight through to the native input — meaningful for type="date"/"number" etc. */
|
|
55
|
+
min?: string | number;
|
|
56
|
+
/** Passed straight through to the native input — meaningful for type="date"/"number" etc. */
|
|
57
|
+
max?: string | number;
|
|
52
58
|
id: string;
|
|
53
59
|
name: string;
|
|
54
60
|
required?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from "@nuxtjs/storybook";
|
|
2
|
+
import { computed } from "vue";
|
|
2
3
|
import StorybookComponent from "../variants/InputPasswordWithLabel.vue";
|
|
3
4
|
import type { FormUiTheme, InputUiVariant } from "~/types/forms/types.forms.d";
|
|
4
5
|
|
|
@@ -12,12 +13,14 @@ interface InputPasswordWithLabelStoryArgs {
|
|
|
12
13
|
fieldHasError: boolean;
|
|
13
14
|
required: boolean;
|
|
14
15
|
theme: FormUiTheme;
|
|
15
|
-
|
|
16
|
+
inputVariant: InputUiVariant;
|
|
16
17
|
styleClassPassthrough: string[];
|
|
17
18
|
useDescriptionSlot: boolean;
|
|
18
19
|
useDescriptionHtmlSlot: boolean;
|
|
19
20
|
descriptionContent: string;
|
|
20
21
|
descriptionHtmlContent: string;
|
|
22
|
+
showPasswordText: string;
|
|
23
|
+
hidePasswordText: string;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export default {
|
|
@@ -95,7 +98,7 @@ export default {
|
|
|
95
98
|
category: "Styling",
|
|
96
99
|
},
|
|
97
100
|
},
|
|
98
|
-
|
|
101
|
+
inputVariant: {
|
|
99
102
|
control: { type: "select" },
|
|
100
103
|
options: ["normal", "outlined", "underlined"],
|
|
101
104
|
description: "Input variant style",
|
|
@@ -140,6 +143,22 @@ export default {
|
|
|
140
143
|
category: "Slots",
|
|
141
144
|
},
|
|
142
145
|
},
|
|
146
|
+
|
|
147
|
+
// Localisation
|
|
148
|
+
showPasswordText: {
|
|
149
|
+
control: "text",
|
|
150
|
+
description: "Accessible name for the toggle button while the password is hidden",
|
|
151
|
+
table: {
|
|
152
|
+
category: "Localisation",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
hidePasswordText: {
|
|
156
|
+
control: "text",
|
|
157
|
+
description: "Accessible name for the toggle button while the password is visible",
|
|
158
|
+
table: {
|
|
159
|
+
category: "Localisation",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
143
162
|
},
|
|
144
163
|
args: {
|
|
145
164
|
modelValue: "",
|
|
@@ -158,34 +177,35 @@ export default {
|
|
|
158
177
|
descriptionContent: "Password should be at least 8 characters long",
|
|
159
178
|
descriptionHtmlContent:
|
|
160
179
|
"Password must contain: <strong>8+ characters</strong>, <em>uppercase</em>, <em>lowercase</em>, <em>numbers</em>",
|
|
180
|
+
showPasswordText: "Show password",
|
|
181
|
+
hidePasswordText: "Hide password",
|
|
161
182
|
},
|
|
162
183
|
} as Meta<typeof StorybookComponent>;
|
|
163
184
|
|
|
185
|
+
// `args` is Storybook's own reactive object — bind to it directly (`args.x`) rather than
|
|
186
|
+
// destructuring it into local variables/refs, which would snapshot the values once at setup()
|
|
187
|
+
// and stop reflecting later Controls-panel changes. `componentArgs` strips the non-prop
|
|
188
|
+
// slot-toggle args so they don't leak onto the component as unknown attributes.
|
|
164
189
|
const Template: StoryFn<InputPasswordWithLabelStoryArgs> = (args) => ({
|
|
165
190
|
components: { StorybookComponent },
|
|
166
191
|
setup() {
|
|
167
|
-
const
|
|
168
|
-
|
|
192
|
+
const componentArgs = computed(() => {
|
|
193
|
+
const { useDescriptionSlot, useDescriptionHtmlSlot, descriptionContent, descriptionHtmlContent, ...rest } = args;
|
|
194
|
+
return rest;
|
|
195
|
+
});
|
|
169
196
|
|
|
170
|
-
return {
|
|
171
|
-
passwordValue,
|
|
172
|
-
args: otherArgs,
|
|
173
|
-
descriptionContent: args.descriptionContent,
|
|
174
|
-
descriptionHtmlContent: args.descriptionHtmlContent,
|
|
175
|
-
useDescriptionSlot: args.useDescriptionSlot,
|
|
176
|
-
useDescriptionHtmlSlot: args.useDescriptionHtmlSlot,
|
|
177
|
-
};
|
|
197
|
+
return { args, componentArgs };
|
|
178
198
|
},
|
|
179
199
|
template: `
|
|
180
200
|
<StorybookComponent
|
|
181
|
-
v-model="
|
|
182
|
-
v-bind="
|
|
201
|
+
v-model="args.modelValue"
|
|
202
|
+
v-bind="componentArgs"
|
|
183
203
|
>
|
|
184
|
-
<template v-if="useDescriptionSlot" #description>{{ descriptionContent }}</template>
|
|
185
|
-
<template v-if="useDescriptionHtmlSlot" #descriptionHtml v-html="descriptionHtmlContent"></template>
|
|
204
|
+
<template v-if="args.useDescriptionSlot" #description>{{ args.descriptionContent }}</template>
|
|
205
|
+
<template v-if="args.useDescriptionHtmlSlot" #descriptionHtml v-html="args.descriptionHtmlContent"></template>
|
|
186
206
|
</StorybookComponent>
|
|
187
207
|
<div class="mt-4 text-sm text-gray-600">
|
|
188
|
-
Current value: {{
|
|
208
|
+
Current value: {{ args.modelValue ? '•'.repeat(args.modelValue.length) : 'Empty' }}
|
|
189
209
|
</div>
|
|
190
210
|
`,
|
|
191
211
|
});
|
|
@@ -239,18 +259,27 @@ PasswordTooShort.args = {
|
|
|
239
259
|
|
|
240
260
|
export const Outlined = Template.bind({});
|
|
241
261
|
Outlined.args = {
|
|
242
|
-
|
|
262
|
+
inputVariant: "outlined",
|
|
243
263
|
label: "Confirm Password",
|
|
244
264
|
placeholder: "Confirm your password",
|
|
245
265
|
};
|
|
246
266
|
|
|
247
267
|
export const Underlined = Template.bind({});
|
|
248
268
|
Underlined.args = {
|
|
249
|
-
|
|
269
|
+
inputVariant: "underlined",
|
|
250
270
|
label: "Master Password",
|
|
251
271
|
placeholder: "Enter master password",
|
|
252
272
|
};
|
|
253
273
|
|
|
274
|
+
export const LocalisedToggleText = Template.bind({});
|
|
275
|
+
LocalisedToggleText.storyName = "Localised Toggle Text";
|
|
276
|
+
LocalisedToggleText.args = {
|
|
277
|
+
label: "Mot de passe",
|
|
278
|
+
placeholder: "Saisissez votre mot de passe",
|
|
279
|
+
showPasswordText: "Afficher le mot de passe",
|
|
280
|
+
hidePasswordText: "Masquer le mot de passe",
|
|
281
|
+
};
|
|
282
|
+
|
|
254
283
|
export const AllVariants = Template.bind({});
|
|
255
284
|
AllVariants.storyName = "All Input Variants";
|
|
256
285
|
AllVariants.render = (args) => ({
|
|
@@ -279,7 +308,7 @@ AllVariants.render = (args) => ({
|
|
|
279
308
|
<h3 class="text-lg font-semibold capitalize">{{ variant }} Variant</h3>
|
|
280
309
|
<StorybookComponent
|
|
281
310
|
v-model="passwordValues[variant]"
|
|
282
|
-
v-bind="{ ...args,
|
|
311
|
+
v-bind="{ ...args, inputVariant: variant, label: variant + ' Password', name: variant + '-password' }"
|
|
283
312
|
/>
|
|
284
313
|
</div>
|
|
285
314
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryFn } from "@nuxtjs/storybook";
|
|
2
|
+
import { computed } from "vue";
|
|
2
3
|
import StorybookComponent from "../variants/InputTextAsNumberWithLabel.vue";
|
|
3
4
|
import type { FormUiTheme, InputUiVariant } from "~/types/forms/types.forms.d";
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ interface InputTextAsNumberWithLabelStoryArgs {
|
|
|
12
13
|
fieldHasError: boolean;
|
|
13
14
|
required: boolean;
|
|
14
15
|
theme: FormUiTheme;
|
|
15
|
-
|
|
16
|
+
inputVariant: InputUiVariant;
|
|
16
17
|
min: number;
|
|
17
18
|
max: number;
|
|
18
19
|
step: number;
|
|
@@ -23,6 +24,8 @@ interface InputTextAsNumberWithLabelStoryArgs {
|
|
|
23
24
|
useRightSlot: boolean;
|
|
24
25
|
leftSlotContent: string;
|
|
25
26
|
rightSlotContent: string;
|
|
27
|
+
stepDownText: string;
|
|
28
|
+
stepUpText: string;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export default {
|
|
@@ -123,7 +126,7 @@ export default {
|
|
|
123
126
|
category: "Styling",
|
|
124
127
|
},
|
|
125
128
|
},
|
|
126
|
-
|
|
129
|
+
inputVariant: {
|
|
127
130
|
control: { type: "select" },
|
|
128
131
|
options: ["normal", "outlined", "underlined"],
|
|
129
132
|
description: "Input variant style",
|
|
@@ -182,6 +185,22 @@ export default {
|
|
|
182
185
|
category: "Slots",
|
|
183
186
|
},
|
|
184
187
|
},
|
|
188
|
+
|
|
189
|
+
// Localisation
|
|
190
|
+
stepDownText: {
|
|
191
|
+
control: "text",
|
|
192
|
+
description: "Accessible name for the decrement button",
|
|
193
|
+
table: {
|
|
194
|
+
category: "Localisation",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
stepUpText: {
|
|
198
|
+
control: "text",
|
|
199
|
+
description: "Accessible name for the increment button",
|
|
200
|
+
table: {
|
|
201
|
+
category: "Localisation",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
185
204
|
},
|
|
186
205
|
args: {
|
|
187
206
|
modelValue: undefined,
|
|
@@ -204,37 +223,37 @@ export default {
|
|
|
204
223
|
useRightSlot: true,
|
|
205
224
|
leftSlotContent: "−",
|
|
206
225
|
rightSlotContent: "+",
|
|
226
|
+
stepDownText: "Step down",
|
|
227
|
+
stepUpText: "Step up",
|
|
207
228
|
},
|
|
208
229
|
} as Meta<typeof StorybookComponent>;
|
|
209
230
|
|
|
231
|
+
// `args` is Storybook's own reactive object — bind to it directly (`args.x`) rather than
|
|
232
|
+
// destructuring it into local variables/refs, which would snapshot the values once at setup()
|
|
233
|
+
// and stop reflecting later Controls-panel changes. `componentArgs` strips the non-prop
|
|
234
|
+
// slot-toggle args so they don't leak onto the component as unknown attributes.
|
|
210
235
|
const Template: StoryFn<InputTextAsNumberWithLabelStoryArgs> = (args) => ({
|
|
211
236
|
components: { StorybookComponent },
|
|
212
237
|
setup() {
|
|
213
|
-
const
|
|
214
|
-
|
|
238
|
+
const componentArgs = computed(() => {
|
|
239
|
+
const { useDescriptionSlot, descriptionContent, useLeftSlot, useRightSlot, leftSlotContent, rightSlotContent, ...rest } =
|
|
240
|
+
args;
|
|
241
|
+
return rest;
|
|
242
|
+
});
|
|
215
243
|
|
|
216
|
-
return {
|
|
217
|
-
numberValue,
|
|
218
|
-
args: otherArgs,
|
|
219
|
-
descriptionContent: args.descriptionContent,
|
|
220
|
-
useDescriptionSlot: args.useDescriptionSlot,
|
|
221
|
-
leftSlotContent: args.leftSlotContent,
|
|
222
|
-
rightSlotContent: args.rightSlotContent,
|
|
223
|
-
useLeftSlot: args.useLeftSlot,
|
|
224
|
-
useRightSlot: args.useRightSlot,
|
|
225
|
-
};
|
|
244
|
+
return { args, componentArgs };
|
|
226
245
|
},
|
|
227
246
|
template: `
|
|
228
247
|
<StorybookComponent
|
|
229
|
-
v-model="
|
|
230
|
-
v-bind="
|
|
248
|
+
v-model="args.modelValue"
|
|
249
|
+
v-bind="componentArgs"
|
|
231
250
|
>
|
|
232
|
-
<template v-if="useDescriptionSlot" #description>{{ descriptionContent }}</template>
|
|
233
|
-
<template v-if="useLeftSlot" #left>{{ leftSlotContent }}</template>
|
|
234
|
-
<template v-if="useRightSlot" #right>{{ rightSlotContent }}</template>
|
|
251
|
+
<template v-if="args.useDescriptionSlot" #description>{{ args.descriptionContent }}</template>
|
|
252
|
+
<template v-if="args.useLeftSlot" #left>{{ args.leftSlotContent }}</template>
|
|
253
|
+
<template v-if="args.useRightSlot" #right>{{ args.rightSlotContent }}</template>
|
|
235
254
|
</StorybookComponent>
|
|
236
255
|
<div class="mt-4 text-sm text-gray-600">
|
|
237
|
-
Current value: {{
|
|
256
|
+
Current value: {{ args.modelValue ?? 'undefined' }}
|
|
238
257
|
</div>
|
|
239
258
|
`,
|
|
240
259
|
});
|
|
@@ -331,7 +350,7 @@ Required.args = {
|
|
|
331
350
|
export const Outlined = Template.bind({});
|
|
332
351
|
Outlined.args = {
|
|
333
352
|
modelValue: 42,
|
|
334
|
-
|
|
353
|
+
inputVariant: "outlined",
|
|
335
354
|
label: "Temperature (°C)",
|
|
336
355
|
placeholder: "Enter temperature",
|
|
337
356
|
min: -50,
|
|
@@ -344,7 +363,7 @@ Outlined.args = {
|
|
|
344
363
|
export const Underlined = Template.bind({});
|
|
345
364
|
Underlined.args = {
|
|
346
365
|
modelValue: 10,
|
|
347
|
-
|
|
366
|
+
inputVariant: "underlined",
|
|
348
367
|
label: "Items Count",
|
|
349
368
|
placeholder: "Number of items",
|
|
350
369
|
min: 0,
|