srcdev-nuxt-components 9.5.1 → 9.5.3

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.
Files changed (30) hide show
  1. package/.claude/skills/components/canvas-switcher.md +5 -1
  2. package/.claude/skills/components/eyebrow-text.md +6 -4
  3. package/.claude/skills/components/input-error.md +1 -1
  4. package/.claude/skills/components/services-card.md +25 -2
  5. package/.claude/skills/storybook-add-story.md +5 -0
  6. package/.vscode/srcdev-component-eyebrow-text.code-snippets +4 -0
  7. package/.vscode/srcdev-component-services-card.code-snippets +38 -7
  8. package/app/components/01.atoms/page-row/stories/PageRow.stories.ts +47 -13
  9. package/app/components/01.atoms/text-blocks/eyebrow-text/CONSUMER-STYLING.md +5 -1
  10. package/app/components/01.atoms/text-blocks/eyebrow-text/EyebrowText.vue +4 -1
  11. package/app/components/03.organisms/services/services-card/CONSUMER-STYLING.md +28 -3
  12. package/app/components/03.organisms/services/services-card/ServicesCard.vue +111 -18
  13. package/app/components/03.organisms/services/services-card/stories/ServicesCard.stories.ts +122 -0
  14. package/app/components/03.organisms/services/services-card/tests/__snapshots__/ServicesCard.spec.ts.snap +4 -1
  15. package/app/components/03.organisms/services/services-grids/stories/ServicesCardGrid.stories.ts +100 -19
  16. package/app/components/03.organisms/services/services-grids/tests/__snapshots__/ServicesCardGrid.spec.ts.snap +12 -3
  17. package/app/components/05.forms/input-checkbox/MultipleCheckboxes.vue +2 -2
  18. package/app/components/05.forms/input-checkbox/SingleCheckbox.vue +1 -1
  19. package/app/components/05.forms/input-number/InputNumberField.vue +1 -1
  20. package/app/components/05.forms/input-radio/MultipleRadiobuttons.vue +2 -2
  21. package/app/components/05.forms/input-range/InputRangeDefault.vue +1 -1
  22. package/app/components/05.forms/input-select/InputSelectWithLabel.vue +1 -1
  23. package/app/components/05.forms/input-text/InputTextAsNumberWithLabel.vue +1 -1
  24. package/app/components/05.forms/input-text/InputTextWithLabel.vue +1 -1
  25. package/app/components/05.forms/input-text/tests/InputTextWithLabel.spec.ts +24 -0
  26. package/app/components/05.forms/input-textarea/InputTextareaWithLabel.vue +1 -1
  27. package/app/components/05.forms/toggle-switch/ToggleSwitchWithLabel.vue +4 -4
  28. package/app/composables/tests/useAriaDescribedById.spec.ts +31 -15
  29. package/app/composables/useAriaDescribedById.ts +6 -2
  30. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from "vitest";
2
2
  import { ref } from "vue";
3
- import type { Slots } from "vue";
3
+ import type { Slot, Slots } from "vue";
4
4
  import { mockNuxtImport } from "@nuxt/test-utils/runtime";
5
5
  import { useAriaDescribedById } from "../useAriaDescribedById";
6
6
 
@@ -38,7 +38,7 @@ describe("useAriaDescribedById", () => {
38
38
  describe("ariaDescribedby", () => {
39
39
  it("is null when no slots and no error", () => {
40
40
  const { ariaDescribedby } = useAriaDescribedById("email", ref(false), noSlots);
41
- expect(ariaDescribedby.value).toBeNull();
41
+ expect(ariaDescribedby()).toBeNull();
42
42
  });
43
43
 
44
44
  it("includes descriptionId when descriptionText slot is present", () => {
@@ -47,7 +47,7 @@ describe("useAriaDescribedById", () => {
47
47
  ref(false),
48
48
  withSlot("descriptionText")
49
49
  );
50
- expect(ariaDescribedby.value).toContain(descriptionId);
50
+ expect(ariaDescribedby()).toContain(descriptionId);
51
51
  });
52
52
 
53
53
  it("includes descriptionId when descriptionHtml slot is present", () => {
@@ -56,7 +56,7 @@ describe("useAriaDescribedById", () => {
56
56
  ref(false),
57
57
  withSlot("descriptionHtml")
58
58
  );
59
- expect(ariaDescribedby.value).toContain(descriptionId);
59
+ expect(ariaDescribedby()).toContain(descriptionId);
60
60
  });
61
61
 
62
62
  it("includes descriptionId when description slot is present", () => {
@@ -65,17 +65,17 @@ describe("useAriaDescribedById", () => {
65
65
  ref(false),
66
66
  withSlot("description")
67
67
  );
68
- expect(ariaDescribedby.value).toContain(descriptionId);
68
+ expect(ariaDescribedby()).toContain(descriptionId);
69
69
  });
70
70
 
71
71
  it("includes errorId when fieldHasError is true", () => {
72
72
  const { errorId, ariaDescribedby } = useAriaDescribedById("email", ref(true), noSlots);
73
- expect(ariaDescribedby.value).toContain(errorId);
73
+ expect(ariaDescribedby()).toContain(errorId);
74
74
  });
75
75
 
76
76
  it("does not include errorId when fieldHasError is false (value is null)", () => {
77
77
  const { ariaDescribedby } = useAriaDescribedById("email", ref(false), noSlots);
78
- expect(ariaDescribedby.value).toBeNull();
78
+ expect(ariaDescribedby()).toBeNull();
79
79
  });
80
80
 
81
81
  it("does not include errorId when slot is present but fieldHasError is false", () => {
@@ -84,7 +84,7 @@ describe("useAriaDescribedById", () => {
84
84
  ref(false),
85
85
  withSlot("descriptionText")
86
86
  );
87
- expect(ariaDescribedby.value).not.toContain(errorId);
87
+ expect(ariaDescribedby()).not.toContain(errorId);
88
88
  });
89
89
 
90
90
  it("includes both descriptionId and errorId when slot present and error active", () => {
@@ -94,8 +94,8 @@ describe("useAriaDescribedById", () => {
94
94
  fieldHasError,
95
95
  withSlot("descriptionText")
96
96
  );
97
- expect(ariaDescribedby.value).toContain(descriptionId);
98
- expect(ariaDescribedby.value).toContain(errorId);
97
+ expect(ariaDescribedby()).toContain(descriptionId);
98
+ expect(ariaDescribedby()).toContain(errorId);
99
99
  });
100
100
 
101
101
  it("descriptionId appears before errorId in the combined string", () => {
@@ -105,7 +105,7 @@ describe("useAriaDescribedById", () => {
105
105
  fieldHasError,
106
106
  withSlot("descriptionText")
107
107
  );
108
- const value = ariaDescribedby.value!;
108
+ const value = ariaDescribedby()!;
109
109
  expect(value.indexOf(descriptionId)).toBeLessThan(value.indexOf(errorId));
110
110
  });
111
111
  });
@@ -116,19 +116,35 @@ describe("useAriaDescribedById", () => {
116
116
  it("ariaDescribedby updates when fieldHasError changes to true", async () => {
117
117
  const fieldHasError = ref(false);
118
118
  const { errorId, ariaDescribedby } = useAriaDescribedById("email", fieldHasError, noSlots);
119
- expect(ariaDescribedby.value).toBeNull();
119
+ expect(ariaDescribedby()).toBeNull();
120
120
  fieldHasError.value = true;
121
121
  await nextTick();
122
- expect(ariaDescribedby.value).toContain(errorId);
122
+ expect(ariaDescribedby()).toContain(errorId);
123
123
  });
124
124
 
125
125
  it("ariaDescribedby updates when fieldHasError changes back to false", async () => {
126
126
  const fieldHasError = ref(true);
127
127
  const { ariaDescribedby } = useAriaDescribedById("email", fieldHasError, noSlots);
128
- expect(ariaDescribedby.value).toBeTruthy();
128
+ expect(ariaDescribedby()).toBeTruthy();
129
129
  fieldHasError.value = false;
130
130
  await nextTick();
131
- expect(ariaDescribedby.value).toBeNull();
131
+ expect(ariaDescribedby()).toBeNull();
132
+ });
133
+
134
+ it("picks up a description slot added after setup", () => {
135
+ const slots: Record<string, Slot> = {};
136
+ const { descriptionId, ariaDescribedby } = useAriaDescribedById("email", ref(false), slots as Slots);
137
+ expect(ariaDescribedby()).toBeNull();
138
+ slots.descriptionText = () => [];
139
+ expect(ariaDescribedby()).toBe(descriptionId);
140
+ });
141
+
142
+ it("drops a description slot removed after setup", () => {
143
+ const slots: Record<string, Slot> = { descriptionText: () => [] };
144
+ const { ariaDescribedby } = useAriaDescribedById("email", ref(false), slots as Slots);
145
+ expect(ariaDescribedby()).toBeTruthy();
146
+ delete slots.descriptionText;
147
+ expect(ariaDescribedby()).toBeNull();
132
148
  });
133
149
  });
134
150
  });
@@ -5,7 +5,11 @@ export function useAriaDescribedById(name: string | Ref<string>, fieldHasError:
5
5
  const errorId = `${id}-error-message`;
6
6
  const descriptionId = `${id}-description`;
7
7
 
8
- const ariaDescribedby = computed(() => {
8
+ // A plain function, not a computed: the slots object isn't reactive, so a computed would cache
9
+ // its first answer and keep pointing at (or away from) the description after a description slot
10
+ // is added or removed post-mount (Claude.md pitfall #25). Call it from the template,
11
+ // `:aria-describedby="ariaDescribedby()"`, so it's re-evaluated on every render.
12
+ const ariaDescribedby = () => {
9
13
  const hasDescription = slots.descriptionText || slots.descriptionHtml || slots.description;
10
14
  const ids = [];
11
15
 
@@ -13,7 +17,7 @@ export function useAriaDescribedById(name: string | Ref<string>, fieldHasError:
13
17
  if (fieldHasError.value) ids.push(errorId);
14
18
 
15
19
  return ids.length ? ids.join(" ") : null;
16
- });
20
+ };
17
21
 
18
22
  return { id, errorId, descriptionId, ariaDescribedby };
19
23
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-components",
3
3
  "type": "module",
4
- "version": "9.5.1",
4
+ "version": "9.5.3",
5
5
  "main": "nuxt.config.ts",
6
6
  "types": "types.d.ts",
7
7
  "license": "MIT",