@thecb/components 6.4.0 → 7.0.0-beta.1

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 (58) hide show
  1. package/README.md +43 -0
  2. package/dist/index.cjs.js +12076 -11826
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +308 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.esm.js +4176 -3929
  7. package/dist/index.esm.js.map +1 -1
  8. package/package.json +6 -2
  9. package/src/components/atoms/button-with-action/index.d.ts +17 -0
  10. package/src/components/atoms/button-with-link/index.d.ts +14 -0
  11. package/src/components/atoms/card/Card.js +87 -0
  12. package/src/components/atoms/card/Card.theme.js +14 -0
  13. package/src/components/atoms/card/CardHeader.js +28 -0
  14. package/src/components/atoms/card/CardImage.styled.js +9 -0
  15. package/src/components/atoms/card/CardText.js +46 -0
  16. package/src/components/atoms/card/CardText.theme.js +12 -0
  17. package/src/components/atoms/card/index.d.ts +32 -0
  18. package/src/components/atoms/card/index.js +3 -0
  19. package/src/components/atoms/{welcome-card/Card.theme.js → card-registry/CardRegistry.theme.js} +0 -0
  20. package/src/components/atoms/{welcome-card/Card.js → card-registry/CardRegistryCard.js} +7 -3
  21. package/src/components/atoms/{welcome-card → card-registry}/index.js +4 -4
  22. package/src/components/atoms/display-card/DisplayCard.js +1 -1
  23. package/src/components/atoms/index.d.ts +11 -0
  24. package/src/components/atoms/index.js +3 -1
  25. package/src/components/atoms/layouts/Box.d.ts +32 -0
  26. package/src/components/atoms/layouts/Center.d.ts +11 -0
  27. package/src/components/atoms/layouts/Cluster.d.ts +19 -0
  28. package/src/components/atoms/layouts/Cover.d.ts +14 -0
  29. package/src/components/atoms/layouts/Stack.d.ts +27 -0
  30. package/src/components/atoms/layouts/Switcher.d.ts +17 -0
  31. package/src/components/atoms/layouts/index.d.ts +6 -0
  32. package/src/components/atoms/link/ExternalLink.d.ts +18 -0
  33. package/src/components/atoms/link/InternalLink.d.ts +19 -0
  34. package/src/components/atoms/link/index.d.ts +2 -0
  35. package/src/components/atoms/nav-footer/index.d.ts +17 -0
  36. package/src/components/atoms/nav-header/index.d.ts +16 -0
  37. package/src/components/atoms/nav-tabs/NavTab.js +47 -0
  38. package/src/components/atoms/nav-tabs/NavTab.theme.js +11 -0
  39. package/src/components/atoms/nav-tabs/NavTabs.js +24 -0
  40. package/src/components/atoms/nav-tabs/index.d.ts +10 -0
  41. package/src/components/atoms/nav-tabs/index.js +3 -0
  42. package/src/components/atoms/paragraph/index.d.ts +15 -0
  43. package/src/components/atoms/text/index.d.ts +16 -0
  44. package/src/components/atoms/title/index.d.ts +17 -0
  45. package/src/components/index.d.ts +3 -0
  46. package/src/components/molecules/footer-with-subfooter/FooterWithSubfooter.js +42 -0
  47. package/src/components/molecules/footer-with-subfooter/FooterWithSubfooter.theme.js +8 -0
  48. package/src/components/molecules/footer-with-subfooter/index.d.ts +14 -0
  49. package/src/components/molecules/footer-with-subfooter/index.js +3 -0
  50. package/src/components/molecules/index.d.ts +1 -0
  51. package/src/components/molecules/index.js +1 -0
  52. package/src/components/molecules/modal/Modal.js +7 -1
  53. package/src/components/molecules/popover/Popover.js +1 -1
  54. package/src/components/templates/default-page-template/DefaultPageTemplate.js +7 -2
  55. package/src/components/templates/default-page-template/index.d.ts +16 -0
  56. package/src/components/templates/index.d.ts +1 -0
  57. package/src/index.d.ts +1 -0
  58. package/src/util/expand.d.ts +3 -0
@@ -0,0 +1,11 @@
1
+ import { MATISSE_BLUE, CHARADE_GREY } from "../../../constants/colors";
2
+
3
+ const fontFamily = "Public Sans, sans-serif";
4
+ const activeColor = MATISSE_BLUE;
5
+ const linkColor = CHARADE_GREY;
6
+
7
+ export const fallbackValues = {
8
+ fontFamily,
9
+ activeColor,
10
+ linkColor
11
+ };
@@ -0,0 +1,24 @@
1
+ import React, { useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
3
+
4
+ import BoxWithShadow from "../box-with-shadow";
5
+ import Center from "../layouts/Center";
6
+ import Cluster from "../layouts/Cluster";
7
+ import NavTab from "./NavTab";
8
+
9
+ const NavTabs = ({ tabsConfig, tabGap }) => {
10
+ const { isMobile } = useContext(ThemeContext);
11
+
12
+ const tabs = tabsConfig.map(tabConfig => {
13
+ return <NavTab key={tabConfig.path} {...tabConfig} />;
14
+ });
15
+ return (
16
+ <BoxWithShadow variant="insetStandard" extraStyles="padding: 0">
17
+ <Center intrinsic>
18
+ {isMobile ? tabs : <Cluster childGap={tabGap}>{tabs}</Cluster>}
19
+ </Center>
20
+ </BoxWithShadow>
21
+ );
22
+ };
23
+
24
+ export default NavTabs;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface NavTabsProps {
5
+ tabsConfig: Array<{ path: string; label: string }>;
6
+ tabGap?: string;
7
+ }
8
+
9
+ export const NavTabs: React.FC<Expand<NavTabsProps> &
10
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,3 @@
1
+ import NavTabs from "./NavTabs";
2
+
3
+ export default NavTabs;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface ParagraphProps {
5
+ color?: string;
6
+ themeValues?: string;
7
+ weight?: string;
8
+ margin?: string;
9
+ extraStyles?: string;
10
+ dataQa?: string;
11
+ as?: string;
12
+ }
13
+
14
+ export const Paragraph: React.FC<Expand<ParagraphProps> &
15
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface TextProps {
5
+ weight?: string;
6
+ color?: string;
7
+ textWrap?: boolean;
8
+ extraStyles?: string;
9
+ hoverStyles?: string;
10
+ as?: string;
11
+ dataQa?: string;
12
+ variant?: string;
13
+ }
14
+
15
+ export const Text: React.FC<Expand<TextProps> &
16
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface TitleProps {
5
+ variant?: string;
6
+ color?: string;
7
+ margin?: string;
8
+ extraStyles?: string;
9
+ weight?: string;
10
+ textAlign?: string;
11
+ className?: string;
12
+ as?: string;
13
+ dataQa?: string;
14
+ }
15
+
16
+ export const Title: React.FC<Expand<TitleProps> &
17
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,3 @@
1
+ export * from "./atoms";
2
+ export * from "./molecules";
3
+ export * from "./templates";
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+ import { fallbackValues } from "./FooterWithSubfooter.theme";
5
+ import NavFooter from "../../atoms/nav-footer";
6
+
7
+ const FooterWithSubfooter = ({
8
+ footerLargeSide = "right",
9
+ footerLargeSideSize = "2",
10
+ leftFooterContent,
11
+ rightFooterContent,
12
+ leftSubfooterContent,
13
+ rightSubfooterContent,
14
+ themeValues
15
+ }) => {
16
+ return (
17
+ <>
18
+ <NavFooter
19
+ largeSide={footerLargeSide}
20
+ largeSideSize={footerLargeSideSize}
21
+ rightContent={rightFooterContent}
22
+ leftContent={leftFooterContent}
23
+ aria-label="footer"
24
+ backgroundColor={themeValues.footerBackgroundColor}
25
+ />
26
+ <NavFooter
27
+ backgroundColor={themeValues.subfooterBackgroundColor}
28
+ footerMinHeight="45px"
29
+ footerPadding="0 16px"
30
+ aria-label="subfooter"
31
+ leftContent={leftSubfooterContent}
32
+ rightContent={rightSubfooterContent}
33
+ ></NavFooter>
34
+ </>
35
+ );
36
+ };
37
+
38
+ export default themeComponent(
39
+ FooterWithSubfooter,
40
+ "FooterWithSubfooter",
41
+ fallbackValues
42
+ );
@@ -0,0 +1,8 @@
1
+ import { BRIGHT_GREY, STORM_GREY } from "../../../constants/colors";
2
+
3
+ const footerBackgroundColor = BRIGHT_GREY;
4
+ const subfooterBackgroundColor = STORM_GREY;
5
+ export const fallbackValues = {
6
+ footerBackgroundColor,
7
+ subfooterBackgroundColor
8
+ };
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface FooterWithSubfooterProps {
5
+ footerLargeSide?: "left" | "right";
6
+ footerLargeSideSize?: string;
7
+ leftFooterContent?: JSX.Element;
8
+ rightFooterContent?: JSX.Element;
9
+ leftSubfooterContent?: JSX.Element;
10
+ rightSubfooterContent?: JSX.Element;
11
+ }
12
+
13
+ export const FooterWithSubfooter: React.FC<Expand<FooterWithSubfooterProps> &
14
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,3 @@
1
+ import FooterWithSubfooter from "./FooterWithSubfooter";
2
+
3
+ export default FooterWithSubfooter;
@@ -0,0 +1 @@
1
+ export * from "./footer-with-subfooter";
@@ -5,6 +5,7 @@ export { default as EditNameForm } from "./edit-name-form";
5
5
  export { default as EditableList } from "./editable-list";
6
6
  export * from "./editable-table";
7
7
  export { default as EmailForm } from "./email-form";
8
+ export { default as FooterWithSubfooter } from "./footer-with-subfooter";
8
9
  export { default as ForgotPasswordForm } from "./forgot-password-form";
9
10
  export { default as HighlightTabRow } from "./highlight-tab-row";
10
11
  export { iconsMap as ObligationIcons } from "./obligation/icons";
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useContext } from "react";
1
+ import React, { Fragment, useContext, useRef } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import AriaModal from "react-aria-modal";
4
4
  import { WHITE, ATHENS_GREY, SILVER_GREY } from "../../../constants/colors";
@@ -47,10 +47,14 @@ const Modal = ({
47
47
  children
48
48
  }) => {
49
49
  const { isMobile } = useContext(ThemeContext);
50
+ const closeBtnRef = useRef(null);
51
+ const modalBodyTextRef = useRef(null);
50
52
  return (
51
53
  <Fragment>
52
54
  {modalOpen && (
53
55
  <AriaModal
56
+ initialFocus={closeBtnRef || modalBodyTextRef}
57
+ focusTrapOptions={{ delayInitialFocus: false, fallbackFocus: closeBtnRef || modalBodyTextRef }} // fallback to resolve unit test errors https://github.com/focus-trap/focus-trap-react/issues/91
54
58
  onExit={onExit}
55
59
  getApplicationNode={getApplicationNode}
56
60
  titleText={modalHeaderText}
@@ -80,6 +84,7 @@ const Modal = ({
80
84
  <Box background={modalBodyBg} padding="1.5rem">
81
85
  <Stack childGap="1.5rem">
82
86
  <Box
87
+ ref={modalBodyTextRef}
83
88
  borderWidthOverride={noBorder && "0 0 2px 0"}
84
89
  borderColor={!noBorder && SILVER_GREY}
85
90
  padding={!noBorder && "0 0 1.5rem 0"}
@@ -169,6 +174,7 @@ const Modal = ({
169
174
  ) : (
170
175
  <Box padding="0.5rem">
171
176
  <ButtonWithAction
177
+ ref={closeBtnRef}
172
178
  action={hideModal}
173
179
  variant="primary"
174
180
  text={closeButtonText}
@@ -43,7 +43,7 @@ const Popover = ({
43
43
  }
44
44
  };
45
45
 
46
- const triggerRef = useOutsideClickHook(() => handleTogglePopover(false));
46
+ const triggerRef = useOutsideClick(() => handleTogglePopover(false));
47
47
 
48
48
  return (
49
49
  <Box padding="0" extraStyles={`position: relative; ${extraStyles}`}>
@@ -14,7 +14,8 @@ const CenterSingle = ({
14
14
  content,
15
15
  themeValues,
16
16
  maxWidth = "75rem",
17
- gutters = "2rem"
17
+ gutters = "2rem",
18
+ fillPageVertical = false
18
19
  }) => {
19
20
  const themeContext = useContext(ThemeContext);
20
21
  const { isMobile } = themeContext;
@@ -26,7 +27,11 @@ const CenterSingle = ({
26
27
  background={COOL_GREY_05}
27
28
  extraStyles="flex-grow: 1;"
28
29
  >
29
- <Cover childGap="0" fillCenter>
30
+ <Cover
31
+ childGap="0"
32
+ fillCenter
33
+ style={{ minHeight: fillPageVertical ? "100vh" : "initial" }}
34
+ >
30
35
  {header ? header : <Box padding="0" />}
31
36
  <Box
32
37
  padding="0"
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface DefaultPageTemplateProps {
5
+ content: JSX.Element;
6
+ header?: JSX.Element;
7
+ subHeader?: JSX.Element;
8
+ footer?: JSX.Element;
9
+ hideMobileSubHeader?: boolean;
10
+ maxWidth?: string;
11
+ gutters?: string;
12
+ fillPageVertical?: Boolean;
13
+ }
14
+
15
+ export const DefaultPageTemplate: React.FC<Expand<DefaultPageTemplateProps> &
16
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1 @@
1
+ export * from "./default-page-template";
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./components";
@@ -0,0 +1,3 @@
1
+ type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
2
+
3
+ export default Expand;