@windstream/react-shared-components 0.2.86 → 0.2.88

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 (44) hide show
  1. package/dist/contentful/index.d.ts +20 -4
  2. package/dist/contentful/index.esm.js +4 -4
  3. package/dist/contentful/index.esm.js.map +1 -1
  4. package/dist/contentful/index.js +4 -4
  5. package/dist/contentful/index.js.map +1 -1
  6. package/dist/core.d.ts +1 -1
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/components/checklist/index.test.tsx +31 -1
  13. package/src/components/checklist/index.tsx +1 -0
  14. package/src/components/checklist/types.ts +2 -0
  15. package/src/contentful/blocks/accordion/index.test.tsx +53 -0
  16. package/src/contentful/blocks/accordion/index.tsx +7 -2
  17. package/src/contentful/blocks/accordion/types.ts +4 -0
  18. package/src/contentful/blocks/callout/{callout.stories.tsx → Callout.stories.tsx} +1 -1
  19. package/src/contentful/blocks/callout/field-props.test.tsx +184 -0
  20. package/src/contentful/blocks/callout/index.tsx +26 -4
  21. package/src/contentful/blocks/callout/types.ts +17 -1
  22. package/src/contentful/blocks/cards/blog-card/index.tsx +6 -2
  23. package/src/contentful/blocks/cards/blog-card/types.ts +4 -0
  24. package/src/contentful/blocks/cards/floating-image-card/index.tsx +4 -2
  25. package/src/contentful/blocks/cards/floating-image-card/types.ts +4 -0
  26. package/src/contentful/blocks/cards/full-image-card/index.tsx +24 -5
  27. package/src/contentful/blocks/cards/full-image-card/types.ts +4 -0
  28. package/src/contentful/blocks/cards/product-card/index.test.tsx +29 -4
  29. package/src/contentful/blocks/cards/product-card/index.tsx +46 -44
  30. package/src/contentful/blocks/cards/product-card/types.ts +1 -1
  31. package/src/contentful/blocks/cards/simple-card/index.tsx +21 -3
  32. package/src/contentful/blocks/cards/simple-card/types.ts +4 -0
  33. package/src/contentful/blocks/carousel/helper.test.tsx +24 -0
  34. package/src/contentful/blocks/carousel/helper.tsx +1 -1
  35. package/src/contentful/blocks/comparison-table/index.test.tsx +75 -0
  36. package/src/contentful/blocks/comparison-table/index.tsx +15 -3
  37. package/src/contentful/blocks/comparison-table/types.ts +8 -2
  38. package/src/contentful/blocks/cta-callout/index.test.tsx +93 -1
  39. package/src/contentful/blocks/cta-callout/index.tsx +9 -2
  40. package/src/contentful/blocks/cta-callout/types.ts +3 -0
  41. package/src/contentful/blocks/modal/index.test.tsx +75 -2
  42. package/src/contentful/blocks/modal/index.tsx +11 -2
  43. package/src/contentful/blocks/modal/types.ts +4 -0
  44. package/src/contentful/blocks/navigation/{navigation.stories.tsx → Navigation.stories.tsx} +1 -1
@@ -51,8 +51,10 @@ jest.mock("@shared/components/material-icon", () => ({
51
51
  }));
52
52
 
53
53
  jest.mock("@shared/components/text", () => ({
54
- Text: ({ as: Tag = "span", children, className }: any) => (
55
- <Tag className={className}>{children}</Tag>
54
+ Text: ({ as: Tag = "span", children, className, ...rest }: any) => (
55
+ <Tag className={className} {...rest}>
56
+ {children}
57
+ </Tag>
56
58
  ),
57
59
  }));
58
60
 
@@ -74,6 +76,77 @@ describe("Modal", () => {
74
76
 
75
77
  beforeEach(() => jest.clearAllMocks());
76
78
 
79
+ describe("fieldProps", () => {
80
+ it("tags title, description and content without changing child tags", () => {
81
+ const tag = (field: string) => ({
82
+ "data-contentful-field-id": field,
83
+ "data-contentful-entry-id": "modal",
84
+ "data-contentful-locale": "en-US",
85
+ });
86
+ const { container } = render(
87
+ <Modal
88
+ {...defaultProps}
89
+ title="Tagged modal"
90
+ description="Tagged description"
91
+ content={<span {...tag("nested")}>Nested content</span>}
92
+ fieldProps={{
93
+ title: tag("title"),
94
+ description: tag("description"),
95
+ content: tag("content"),
96
+ }}
97
+ >
98
+ <span>Extra child</span>
99
+ </Modal>
100
+ );
101
+ expect(screen.getByText("Tagged modal")).toHaveAttribute(
102
+ "data-contentful-field-id",
103
+ "title"
104
+ );
105
+ expect(screen.getByText("Tagged description")).toHaveAttribute(
106
+ "data-contentful-field-id",
107
+ "description"
108
+ );
109
+ expect(screen.getByText("Nested content").parentElement).toHaveAttribute(
110
+ "data-contentful-field-id",
111
+ "content"
112
+ );
113
+ expect(screen.getByText("Nested content")).toHaveAttribute(
114
+ "data-contentful-field-id",
115
+ "nested"
116
+ );
117
+ expect(screen.getByText("Extra child").parentElement).toBe(
118
+ screen.getByText("Nested content").parentElement
119
+ );
120
+ container
121
+ .querySelectorAll("[data-contentful-field-id]")
122
+ .forEach(element => {
123
+ expect(element).toHaveAttribute("data-contentful-entry-id", "modal");
124
+ expect(element).toHaveAttribute("data-contentful-locale", "en-US");
125
+ });
126
+ });
127
+
128
+ it("supports partial fieldProps without creating absent fields", () => {
129
+ const { container } = render(
130
+ <Modal
131
+ {...defaultProps}
132
+ title="Title only"
133
+ fieldProps={{
134
+ title: { "data-contentful-field-id": "title" },
135
+ description: { "data-contentful-field-id": "description" },
136
+ }}
137
+ />
138
+ );
139
+ expect(
140
+ container.querySelectorAll("[data-contentful-field-id]")
141
+ ).toHaveLength(1);
142
+ });
143
+
144
+ it("does not add tagging attributes when fieldProps is omitted", () => {
145
+ const { container } = render(<Modal {...defaultProps} title="No tags" />);
146
+ expect(container.querySelector("[data-contentful-field-id]")).toBeNull();
147
+ });
148
+ });
149
+
77
150
  describe("Rendering", () => {
78
151
  it("renders dialog root with open state", () => {
79
152
  render(<Modal {...defaultProps} />);
@@ -31,6 +31,7 @@ export const Modal: React.FC<ExtendedModalProps> = props => {
31
31
  bodyClassName,
32
32
  type = "modal",
33
33
  index = 0,
34
+ fieldProps,
34
35
  } = props;
35
36
 
36
37
  return (
@@ -93,18 +94,26 @@ export const Modal: React.FC<ExtendedModalProps> = props => {
93
94
  "mb-4 md:mb-[60px]"
94
95
  )}
95
96
  as="h2"
97
+ {...fieldProps?.title}
96
98
  >
97
99
  {title}
98
100
  </Text>
99
101
  ) : null}
100
102
 
101
103
  {description ? (
102
- <Text as="div" className="mb-8 sm:mb-5">
104
+ <Text
105
+ as="div"
106
+ className="mb-8 sm:mb-5"
107
+ {...fieldProps?.description}
108
+ >
103
109
  {description}
104
110
  </Text>
105
111
  ) : null}
106
112
 
107
- <div className="flex flex-col gap-4 sm:gap-5">
113
+ <div
114
+ className="flex flex-col gap-4 sm:gap-5"
115
+ {...fieldProps?.content}
116
+ >
108
117
  {content}
109
118
  {children ? children : null}
110
119
  </div>
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
2
 
3
+ import type { FieldProps } from "@shared/types/field-props";
4
+
3
5
  export type ModalProps = {
4
6
  isOpen: boolean;
5
7
  onRequestClose?: () => void;
@@ -9,4 +11,6 @@ export type ModalProps = {
9
11
  content?: React.ReactNode;
10
12
  children?: React.ReactNode;
11
13
  bodyClassName?: string;
14
+ /** DOM attributes for modal fields; `content` tags the region containing content and children. */
15
+ fieldProps?: FieldProps<"title" | "description" | "content">;
12
16
  };
@@ -7,7 +7,7 @@ import {
7
7
  UTILITY_LINKS,
8
8
  ACCOUNT_LINKS,
9
9
  SUPPORT_LINKS,
10
- } from "./navigation.stories.mocks";
10
+ } from "./Navigation.stories.mocks";
11
11
 
12
12
  const searchFormStyle = `
13
13
  form[name="searchForm"] {