@windstream/react-shared-components 0.0.37 → 0.0.38

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 (57) hide show
  1. package/dist/contentful/index.d.ts +9 -29
  2. package/dist/contentful/index.esm.js +1 -1
  3. package/dist/contentful/index.esm.js.map +1 -1
  4. package/dist/contentful/index.js +1 -1
  5. package/dist/contentful/index.js.map +1 -1
  6. package/dist/core.d.ts +2 -2
  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/dist/styles.css +1 -1
  12. package/package.json +1 -1
  13. package/src/components/accordion/index.tsx +49 -49
  14. package/src/components/alert-card/types.ts +9 -9
  15. package/src/components/brand-button/index.tsx +93 -93
  16. package/src/components/button/index.tsx +27 -27
  17. package/src/components/button/types.ts +14 -14
  18. package/src/components/checkbox/index.tsx +197 -197
  19. package/src/components/collapse/index.tsx +46 -46
  20. package/src/components/image/types.ts +33 -33
  21. package/src/components/input/index.tsx +6 -6
  22. package/src/components/link/index.tsx +97 -97
  23. package/src/components/link/types.ts +25 -25
  24. package/src/components/list/index.tsx +88 -88
  25. package/src/components/list/list-item/index.tsx +38 -38
  26. package/src/components/list/list-item/types.ts +13 -13
  27. package/src/components/list/types.ts +29 -29
  28. package/src/components/material-icon/index.tsx +44 -44
  29. package/src/components/material-icon/types.ts +31 -31
  30. package/src/components/modal/index.tsx +164 -164
  31. package/src/components/see-more/index.tsx +44 -44
  32. package/src/components/select/index.tsx +150 -150
  33. package/src/components/skeleton/index.tsx +61 -61
  34. package/src/components/text/index.tsx +25 -25
  35. package/src/components/text/types.ts +45 -45
  36. package/src/contentful/blocks/accordion/Accordion.stories.tsx +29 -29
  37. package/src/contentful/blocks/accordion/index.tsx +52 -52
  38. package/src/contentful/blocks/accordion/types.ts +17 -17
  39. package/src/contentful/blocks/button/index.tsx +5 -0
  40. package/src/contentful/blocks/button/types.ts +1 -0
  41. package/src/contentful/blocks/callout/Callout.stories.tsx +1 -1
  42. package/src/contentful/blocks/callout/index.tsx +15 -52
  43. package/src/contentful/blocks/callout/types.ts +1 -14
  44. package/src/contentful/blocks/find-kinetic/FindKinetic.stories.tsx +23 -23
  45. package/src/contentful/blocks/find-kinetic/index.tsx +80 -80
  46. package/src/contentful/blocks/find-kinetic/types.ts +18 -18
  47. package/src/contentful/blocks/footer/index.tsx +79 -79
  48. package/src/contentful/blocks/image-promo-bar/index.tsx +154 -154
  49. package/src/contentful/blocks/navigation/index.tsx +1 -2
  50. package/src/contentful/blocks/navigation/link-groups.tsx/index.tsx +64 -62
  51. package/src/contentful/blocks/primary-hero/index.tsx +163 -64
  52. package/src/contentful/blocks/primary-hero/types.ts +1 -0
  53. package/src/contentful/index.ts +45 -48
  54. package/src/hooks/use-body-scroll-lock.ts +34 -34
  55. package/src/setupTests.ts +46 -46
  56. package/src/contentful/blocks/cards/simple-card/index.tsx +0 -45
  57. package/src/contentful/blocks/cards/simple-card/types.ts +0 -11
@@ -1,31 +1,31 @@
1
- import type { CSSProperties } from "react";
2
- import {
3
- emphasis,
4
- iconNameList,
5
- OpticalSizes,
6
- sizes,
7
- weights,
8
- } from "./constants";
9
-
10
- export type Fill = 1 | 0;
11
-
12
- export type IconName = (typeof iconNameList)[number];
13
-
14
- export type OpticalSize = (typeof OpticalSizes)[number];
15
- export type Weight = (typeof weights)[number];
16
- export type Emphasis = (typeof emphasis)[number];
17
- export type Size = (typeof sizes)[number];
18
-
19
- export type IconProps = {
20
- name: IconName;
21
- fill?: Fill;
22
- opticalSize?: OpticalSize;
23
- weight?: Weight;
24
- emphasis?: Emphasis;
25
- size?: Size;
26
- color?: string;
27
- style?: CSSProperties;
28
- className?: string;
29
- onClick?: () => void;
30
- dataTestId?: string;
31
- };
1
+ import type { CSSProperties } from "react";
2
+ import {
3
+ emphasis,
4
+ iconNameList,
5
+ OpticalSizes,
6
+ sizes,
7
+ weights,
8
+ } from "./constants";
9
+
10
+ export type Fill = 1 | 0;
11
+
12
+ export type IconName = (typeof iconNameList)[number];
13
+
14
+ export type OpticalSize = (typeof OpticalSizes)[number];
15
+ export type Weight = (typeof weights)[number];
16
+ export type Emphasis = (typeof emphasis)[number];
17
+ export type Size = (typeof sizes)[number];
18
+
19
+ export type IconProps = {
20
+ name: IconName;
21
+ fill?: Fill;
22
+ opticalSize?: OpticalSize;
23
+ weight?: Weight;
24
+ emphasis?: Emphasis;
25
+ size?: Size;
26
+ color?: string;
27
+ style?: CSSProperties;
28
+ className?: string;
29
+ onClick?: () => void;
30
+ dataTestId?: string;
31
+ };
@@ -1,164 +1,164 @@
1
- "use client";
2
-
3
- import React, { useEffect, useMemo, useState } from "react";
4
- import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
5
- import { cx } from "../../utils";
6
- import { Button } from "../button";
7
- import { MaterialIcon } from "../material-icon";
8
- import { Animation, ModalProps, Shape, Size } from "./types";
9
- import ReactModal from "react-modal";
10
- import { Transition } from "react-transition-group";
11
-
12
- const Modal: React.FC<ModalProps> = ({
13
- size = "md",
14
- shape = "default",
15
- animation = "popper",
16
- centered,
17
- title,
18
- isOpen,
19
- children,
20
- bodyStyle,
21
- className,
22
- bodyClassName,
23
- portalClassName,
24
- overlayClassName,
25
- closeButtonClassName,
26
- closeWrapperClassName,
27
- onRequestClose,
28
- parentSelector,
29
- hideScrollOnIsOpenFalse = true,
30
- hideCloseButton = false,
31
- ...modalProps
32
- }: ModalProps) => {
33
- // Use the custom hook to lock/unlock the body scroll when the modal is open/closed.
34
- useBodyScrollLock(isOpen, hideScrollOnIsOpenFalse);
35
-
36
- // Animation cannot run at the same time as the modal opening
37
- const [isTransitioning, setIsTransitioning] = useState(false);
38
-
39
- useEffect(() => {
40
- // Run animation one frame after rendering the modal
41
- setIsTransitioning(isOpen);
42
- }, [isOpen]);
43
-
44
- const parent = useMemo(() => {
45
- /* istanbul ignore next */ if (typeof document === "undefined") return null;
46
- let parent = document.querySelector("main") || document.body;
47
- if (parentSelector)
48
- parent = document.querySelector(parentSelector) || document.body;
49
-
50
- return parent;
51
- }, [parentSelector]);
52
-
53
- if (!parent) return null;
54
-
55
- // Don't render anything when modal is closed
56
- if (!isOpen) {
57
- return null;
58
- }
59
-
60
- const getSizeClasses = (size: Size) => {
61
- const sizeMap = {
62
- xl: "inset-[5%] min-h-fit",
63
- lg: "inset-[10%] min-h-fit",
64
- md: "inset-[15%] min-h-fit",
65
- sm: "top-[18%] w-[640px]",
66
- xs: "w-[calc(100%-30px)]",
67
- };
68
- return sizeMap[size];
69
- };
70
-
71
- const getAnimationClasses = (animation: Animation, state: string) => {
72
- if (animation === "popper") {
73
- const baseClasses = "transition-transform duration-300";
74
- if (state === "entering" || state === "entered") {
75
- return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
76
- }
77
- if (state === "exiting" || state === "exited") {
78
- return `${baseClasses} opacity-0 translate-y-[-18px] duration-[180ms]`;
79
- }
80
- return `${baseClasses} opacity-0 translate-y-[-18px]`;
81
- }
82
- if (animation === "bottomSheet") {
83
- const baseClasses = "transition-transform duration-200 ease-in-out";
84
- if (state === "entering" || state === "entered") {
85
- return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
86
- }
87
- if (state === "exiting" || state === "exited") {
88
- return `${baseClasses} opacity-0 translate-y-full duration-[180ms]`;
89
- }
90
- return `${baseClasses} opacity-0 translate-y-full`;
91
- }
92
- return "";
93
- };
94
-
95
- return (
96
- <Transition enter exit in={isTransitioning} timeout={0}>
97
- {(state: string) => (
98
- <ReactModal
99
- ariaHideApp={false}
100
- isOpen={isOpen}
101
- onRequestClose={onRequestClose}
102
- closeTimeoutMS={0}
103
- parentSelector={() => parent}
104
- className={cx(
105
- "absolute min-w-[150px] max-w-[calc(100vw-30px)] overflow-auto rounded-lg bg-white outline-none",
106
- getSizeClasses(size),
107
- shape === "rounded" && "rounded-3xl",
108
- centered && "top-0 translate-y-[calc(50vh-50%)]",
109
- getAnimationClasses(animation, state),
110
- className
111
- )}
112
- portalClassName={cx("z-80", portalClassName)}
113
- overlayClassName={cx(
114
- "z-80 fixed inset-0 bg-black/50 flex items-center justify-center pb-[300px]",
115
- overlayClassName
116
- )}
117
- {...modalProps}
118
- >
119
- {!hideCloseButton && (
120
- <div className={cx(closeWrapperClassName)}>
121
- <Button
122
- className={cx(
123
- "absolute right-0 top-0 float-right h-6 cursor-pointer p-5 text-text",
124
- closeButtonClassName
125
- )}
126
- onClick={onRequestClose as () => void}
127
- data-testid="close-button"
128
- data-track-element-name="modal_close_button"
129
- data-track-click-text="Close Modal"
130
- data-track-element-clicked="modal"
131
- >
132
- <MaterialIcon name="close" size={24} />
133
- </Button>
134
- </div>
135
- )}
136
-
137
- {title ? (
138
- <div
139
- className={cx(
140
- "border-b border-border-secondary-on-bg-fill px-[7px] py-[7px] text-text"
141
- )}
142
- >
143
- {title}
144
- </div>
145
- ) : null}
146
- <div
147
- className={cx("p-5", bodyClassName)}
148
- style={bodyStyle}
149
- data-testid={modalProps["data-testid"]}
150
- data-cy={modalProps["data-cy"]}
151
- >
152
- {children}
153
- </div>
154
- </ReactModal>
155
- )}
156
- </Transition>
157
- );
158
- };
159
-
160
- export { Modal };
161
-
162
- Modal.displayName = "Modal";
163
-
164
- export type { ModalProps, Size, Shape, Animation };
1
+ "use client";
2
+
3
+ import React, { useEffect, useMemo, useState } from "react";
4
+ import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
5
+ import { cx } from "../../utils";
6
+ import { Button } from "../button";
7
+ import { MaterialIcon } from "../material-icon";
8
+ import { Animation, ModalProps, Shape, Size } from "./types";
9
+ import ReactModal from "react-modal";
10
+ import { Transition } from "react-transition-group";
11
+
12
+ const Modal: React.FC<ModalProps> = ({
13
+ size = "md",
14
+ shape = "default",
15
+ animation = "popper",
16
+ centered,
17
+ title,
18
+ isOpen,
19
+ children,
20
+ bodyStyle,
21
+ className,
22
+ bodyClassName,
23
+ portalClassName,
24
+ overlayClassName,
25
+ closeButtonClassName,
26
+ closeWrapperClassName,
27
+ onRequestClose,
28
+ parentSelector,
29
+ hideScrollOnIsOpenFalse = true,
30
+ hideCloseButton = false,
31
+ ...modalProps
32
+ }: ModalProps) => {
33
+ // Use the custom hook to lock/unlock the body scroll when the modal is open/closed.
34
+ useBodyScrollLock(isOpen, hideScrollOnIsOpenFalse);
35
+
36
+ // Animation cannot run at the same time as the modal opening
37
+ const [isTransitioning, setIsTransitioning] = useState(false);
38
+
39
+ useEffect(() => {
40
+ // Run animation one frame after rendering the modal
41
+ setIsTransitioning(isOpen);
42
+ }, [isOpen]);
43
+
44
+ const parent = useMemo(() => {
45
+ /* istanbul ignore next */ if (typeof document === "undefined") return null;
46
+ let parent = document.querySelector("main") || document.body;
47
+ if (parentSelector)
48
+ parent = document.querySelector(parentSelector) || document.body;
49
+
50
+ return parent;
51
+ }, [parentSelector]);
52
+
53
+ if (!parent) return null;
54
+
55
+ // Don't render anything when modal is closed
56
+ if (!isOpen) {
57
+ return null;
58
+ }
59
+
60
+ const getSizeClasses = (size: Size) => {
61
+ const sizeMap = {
62
+ xl: "inset-[5%] min-h-fit",
63
+ lg: "inset-[10%] min-h-fit",
64
+ md: "inset-[15%] min-h-fit",
65
+ sm: "top-[18%] w-[640px]",
66
+ xs: "w-[calc(100%-30px)]",
67
+ };
68
+ return sizeMap[size];
69
+ };
70
+
71
+ const getAnimationClasses = (animation: Animation, state: string) => {
72
+ if (animation === "popper") {
73
+ const baseClasses = "transition-transform duration-300";
74
+ if (state === "entering" || state === "entered") {
75
+ return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
76
+ }
77
+ if (state === "exiting" || state === "exited") {
78
+ return `${baseClasses} opacity-0 translate-y-[-18px] duration-[180ms]`;
79
+ }
80
+ return `${baseClasses} opacity-0 translate-y-[-18px]`;
81
+ }
82
+ if (animation === "bottomSheet") {
83
+ const baseClasses = "transition-transform duration-200 ease-in-out";
84
+ if (state === "entering" || state === "entered") {
85
+ return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
86
+ }
87
+ if (state === "exiting" || state === "exited") {
88
+ return `${baseClasses} opacity-0 translate-y-full duration-[180ms]`;
89
+ }
90
+ return `${baseClasses} opacity-0 translate-y-full`;
91
+ }
92
+ return "";
93
+ };
94
+
95
+ return (
96
+ <Transition enter exit in={isTransitioning} timeout={0}>
97
+ {(state: string) => (
98
+ <ReactModal
99
+ ariaHideApp={false}
100
+ isOpen={isOpen}
101
+ onRequestClose={onRequestClose}
102
+ closeTimeoutMS={0}
103
+ parentSelector={() => parent}
104
+ className={cx(
105
+ "absolute min-w-[150px] max-w-[calc(100vw-30px)] overflow-auto rounded-lg bg-white outline-none",
106
+ getSizeClasses(size),
107
+ shape === "rounded" && "rounded-3xl",
108
+ centered && "top-0 translate-y-[calc(50vh-50%)]",
109
+ getAnimationClasses(animation, state),
110
+ className
111
+ )}
112
+ portalClassName={cx("z-80", portalClassName)}
113
+ overlayClassName={cx(
114
+ "z-80 fixed inset-0 bg-black/50 flex items-center justify-center pb-[300px]",
115
+ overlayClassName
116
+ )}
117
+ {...modalProps}
118
+ >
119
+ {!hideCloseButton && (
120
+ <div className={cx(closeWrapperClassName)}>
121
+ <Button
122
+ className={cx(
123
+ "absolute right-0 top-0 float-right h-6 cursor-pointer p-5 text-text",
124
+ closeButtonClassName
125
+ )}
126
+ onClick={onRequestClose as () => void}
127
+ data-testid="close-button"
128
+ data-track-element-name="modal_close_button"
129
+ data-track-click-text="Close Modal"
130
+ data-track-element-clicked="modal"
131
+ >
132
+ <MaterialIcon name="close" size={24} />
133
+ </Button>
134
+ </div>
135
+ )}
136
+
137
+ {title ? (
138
+ <div
139
+ className={cx(
140
+ "border-b border-border-secondary-on-bg-fill px-[7px] py-[7px] text-text"
141
+ )}
142
+ >
143
+ {title}
144
+ </div>
145
+ ) : null}
146
+ <div
147
+ className={cx("p-5", bodyClassName)}
148
+ style={bodyStyle}
149
+ data-testid={modalProps["data-testid"]}
150
+ data-cy={modalProps["data-cy"]}
151
+ >
152
+ {children}
153
+ </div>
154
+ </ReactModal>
155
+ )}
156
+ </Transition>
157
+ );
158
+ };
159
+
160
+ export { Modal };
161
+
162
+ Modal.displayName = "Modal";
163
+
164
+ export type { ModalProps, Size, Shape, Animation };
@@ -1,44 +1,44 @@
1
- "use client";
2
-
3
- import { useState } from "react";
4
-
5
- import { Button } from "@shared/components/button";
6
- import { Checklist } from "@shared/components/checklist";
7
- import { Collapse } from "@shared/components/collapse";
8
- import { MaterialIcon } from "@shared/components/material-icon";
9
- import { SeeMoreProps } from "@shared/components/see-more/types";
10
-
11
- export const SeeMore: React.FC<SeeMoreProps> = props => {
12
- const { list, text } = props;
13
- const [showDetails, setShowDetails] = useState<boolean>(true);
14
- return (
15
- <div className="mt-3">
16
- <Button
17
- type="button"
18
- className="flex items-center gap-2 text-base font-semibold text-gray-900"
19
- aria-expanded={showDetails}
20
- onClick={e => {
21
- e.stopPropagation();
22
- setShowDetails(v => !v);
23
- }}
24
- >
25
- <span>{text || "See details"}</span>
26
- <MaterialIcon
27
- name={showDetails ? "keyboard_arrow_down" : "keyboard_arrow_up"}
28
- fill={1}
29
- size={24}
30
- />
31
- </Button>
32
-
33
- <Collapse open={showDetails}>
34
- <div className="pt-1">
35
- <Checklist listItemClassName="body3" items={list} />
36
- </div>
37
- </Collapse>
38
- </div>
39
- );
40
- };
41
-
42
- SeeMore.displayName = "SeeMore";
43
-
44
- export type { SeeMoreProps };
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+
5
+ import { Button } from "@shared/components/button";
6
+ import { Checklist } from "@shared/components/checklist";
7
+ import { Collapse } from "@shared/components/collapse";
8
+ import { MaterialIcon } from "@shared/components/material-icon";
9
+ import { SeeMoreProps } from "@shared/components/see-more/types";
10
+
11
+ export const SeeMore: React.FC<SeeMoreProps> = props => {
12
+ const { list, text } = props;
13
+ const [showDetails, setShowDetails] = useState<boolean>(true);
14
+ return (
15
+ <div className="mt-3">
16
+ <Button
17
+ type="button"
18
+ className="flex items-center gap-2 text-base font-semibold text-gray-900"
19
+ aria-expanded={showDetails}
20
+ onClick={e => {
21
+ e.stopPropagation();
22
+ setShowDetails(v => !v);
23
+ }}
24
+ >
25
+ <span>{text || "See details"}</span>
26
+ <MaterialIcon
27
+ name={showDetails ? "keyboard_arrow_down" : "keyboard_arrow_up"}
28
+ fill={1}
29
+ size={24}
30
+ />
31
+ </Button>
32
+
33
+ <Collapse open={showDetails}>
34
+ <div className="pt-1">
35
+ <Checklist listItemClassName="body3" items={list} />
36
+ </div>
37
+ </Collapse>
38
+ </div>
39
+ );
40
+ };
41
+
42
+ SeeMore.displayName = "SeeMore";
43
+
44
+ export type { SeeMoreProps };