@nypl/design-system-react-components 0.25.9 → 0.25.10

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 (78) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  3. package/dist/components/Fieldset/Fieldset.d.ts +1 -3
  4. package/dist/components/Form/Form.d.ts +13 -12
  5. package/dist/components/Form/FormTypes.d.ts +2 -2
  6. package/dist/components/HorizontalRule/HorizontalRule.d.ts +1 -1
  7. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  8. package/dist/components/SearchBar/SearchBar.d.ts +5 -5
  9. package/dist/components/Table/Table.d.ts +9 -3
  10. package/dist/components/Template/Template.d.ts +23 -4
  11. package/dist/design-system-react-components.cjs.development.js +197 -89
  12. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  13. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  14. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  15. package/dist/design-system-react-components.esm.js +186 -91
  16. package/dist/design-system-react-components.esm.js.map +1 -1
  17. package/dist/index.d.ts +4 -4
  18. package/dist/resources.scss +0 -2
  19. package/dist/theme/components/breadcrumb.d.ts +1 -1
  20. package/dist/theme/components/customTable.d.ts +12 -3
  21. package/package.json +40 -36
  22. package/src/components/Accordion/Accordion.stories.mdx +1 -1
  23. package/src/components/Accordion/Accordion.test.tsx +45 -1
  24. package/src/components/Accordion/Accordion.tsx +20 -8
  25. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +243 -0
  26. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +13 -2
  27. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +15 -0
  28. package/src/components/Breadcrumbs/Breadcrumbs.tsx +9 -3
  29. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +5 -5
  30. package/src/components/Card/Card.stories.mdx +1 -1
  31. package/src/components/Card/Card.tsx +4 -1
  32. package/src/components/Chakra/Flex.stories.mdx +113 -0
  33. package/src/components/DatePicker/DatePicker.stories.mdx +1 -1
  34. package/src/components/DatePicker/DatePicker.test.tsx +6 -6
  35. package/src/components/DatePicker/DatePicker.tsx +3 -4
  36. package/src/components/Fieldset/Fieldset.stories.mdx +1 -1
  37. package/src/components/Fieldset/Fieldset.tsx +2 -4
  38. package/src/components/Form/Form.stories.mdx +34 -16
  39. package/src/components/Form/Form.test.tsx +92 -3
  40. package/src/components/Form/Form.tsx +25 -21
  41. package/src/components/Form/FormTypes.tsx +2 -2
  42. package/src/components/Form/__snapshots__/Form.test.tsx.snap +0 -1
  43. package/src/components/Hero/Hero.stories.mdx +1 -1
  44. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +3 -2
  45. package/src/components/HorizontalRule/HorizontalRule.tsx +2 -2
  46. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +4 -4
  47. package/src/components/List/List.stories.mdx +1 -1
  48. package/src/components/List/List.tsx +1 -1
  49. package/src/components/Pagination/Pagination.stories.mdx +1 -1
  50. package/src/components/Pagination/Pagination.tsx +2 -2
  51. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
  52. package/src/components/RadioGroup/RadioGroup.stories.mdx +1 -1
  53. package/src/components/RadioGroup/RadioGroup.test.tsx +13 -11
  54. package/src/components/RadioGroup/RadioGroup.tsx +88 -89
  55. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +18 -18
  56. package/src/components/SearchBar/SearchBar.Test.tsx +106 -28
  57. package/src/components/SearchBar/SearchBar.stories.mdx +7 -4
  58. package/src/components/SearchBar/SearchBar.tsx +19 -20
  59. package/src/components/Select/Select.test.tsx +89 -0
  60. package/src/components/Select/Select.tsx +7 -1
  61. package/src/components/Select/__snapshots__/Select.test.tsx.snap +545 -0
  62. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +7 -0
  63. package/src/components/Table/Table.stories.mdx +118 -19
  64. package/src/components/Table/Table.test.tsx +80 -3
  65. package/src/components/Table/Table.tsx +26 -16
  66. package/src/components/Table/__snapshots__/Table.test.tsx.snap +1179 -0
  67. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  68. package/src/components/Tabs/Tabs.test.tsx +21 -5
  69. package/src/components/Tabs/Tabs.tsx +33 -18
  70. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +195 -0
  71. package/src/components/Template/Template.stories.mdx +79 -4
  72. package/src/components/Template/Template.test.tsx +65 -3
  73. package/src/components/Template/Template.tsx +58 -8
  74. package/src/components/Template/__snapshots__/Template.test.tsx.snap +93 -0
  75. package/src/index.ts +8 -2
  76. package/src/theme/components/breadcrumb.ts +1 -1
  77. package/src/theme/components/customTable.ts +16 -3
  78. package/src/utils/componentCategories.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -8,6 +8,50 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
8
8
 
9
9
  ## Prerelease
10
10
 
11
+ ## 0.25.10 (February 22, 2022)
12
+
13
+ ### Adds
14
+
15
+ - Exports Chakra's `Flex` and `Spacer` components.
16
+ - Adds `TemplateAboveHeader` component in the set of "template" components.
17
+ - Adds the `aboveHeader` prop to the `TemplateAppContainer` component to render a `TemplateAboveHeader` component immediately before the `TemplateHeader` component.
18
+
19
+ ### Breaking Changes
20
+
21
+ - Renames the `Form` component's `"spacing"` prop to `"gap"` to be consistent with the `FormRow` and `FormField` components.
22
+ - Renames the `FormSpacing` enum to `FormGaps`.
23
+
24
+ ### Changes
25
+
26
+ - Passes an `onChange` prop to the `Select` component inside the `SearchBar` through its `selectProps` prop.
27
+ - Adds snapshot tests for the `Tabs` component and better checks to warn the user that the `Tabs` is missing data if data wasn't passed as props or children.
28
+ - Updates the `Form` component to warn developers when a child component in the `FormRow` component _is not_ a `FormField`.
29
+ - Adds an `onSubmit` prop to the `Form` component.
30
+ - Adds the `renderHeaderElement` prop to the `TemplateAppContainer` component. This prop is used to control whether the `TemplateAppContainer` component should render its own `<header>` HTML element through its `header` prop, or let the user pass in their own component that renders the `<header>` HTML element.
31
+ - Updates the `Fieldset` and `RadioGroup` so the `children` prop is declared through `React.PropsWithChildren` rather than in their respective prop interfaces.
32
+ - Adds snapshot tests for the `Accordion` component, as well as `id` props to the components within the `Accordion` so snapshot tests pass.
33
+ - Passes an `id` to the `Icon` in the `Select` component.
34
+ - Adds snapshot tests for the `Select` componnet.
35
+
36
+ ### Fixes
37
+
38
+ - Fixes `id` propagation issues in the `SearchBar` component and its children DS components.
39
+ - Fixing `Breadcrumbs` related logging issue with a CSS pseudo-selector and setting the `aria-label` to "Breadcrumbs". Adding an accessibility test that should fail when more than one `Breadcrumbs` component is rendered on a page since that landmark should only be rendered once on a web page.
40
+ - Exports the `FullDateType` interface related to the `DatePicker` component.
41
+ - Fixes and removes bad console logs from the `Pagination` and `List` components.
42
+ - Fixes auto-generated `id`s in the `Tabs` component.
43
+ - Fixes the Figma link for the `Hero` component.
44
+ - Fixes `Card` component bug for passing styles to the `CardHeading` correctly.
45
+ - Fixes the `Table` component so that a custom header text color of white does not visually hide row headers on a white background.
46
+
47
+ ### Updates
48
+
49
+ - Updates the following packages: multiple `@storybook/...` packages, `autoprefixer`, `eslint-plugin-storybook`, `husky`, `lint-staged`, `semantic-release-slack-bot`, `storybook-addon-designs`.
50
+ - Removed the following packages: `postcss`, `pretty-quick`.
51
+ - Added `@chakra-ui/react`, `@chakra-ui/system`, `@emotion/react`, `@emotion/styled`, and `framer-motion` as "peerDependencies".
52
+ - Updates the node version in Github Action workflows from Node v12 to Node v14.
53
+ - Updates how `/dist/resources.scss` is created through gulp.
54
+
11
55
  ## 0.25.9 (February 3, 2022)
12
56
 
13
57
  ### Adds
@@ -43,6 +87,7 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
43
87
  - Updates the `Template` component to use `s` (16px) spacing on the left and right sides of the main content area.
44
88
  - Updates the `HelperErrorText` component to allow HTML to be passed in as a string or HTML.
45
89
  - Updates how the `HelperErrorText` component renders text in the following components: `Checkbox`, `CheckboxGroup`, `ComponentWrapper`, `DatePicker`, `Radio`, `RadioGroup`, `SearchBar`, `Select`, `Slider`, `TextInput`, `Toggle`, `VideoPlayer`.
90
+ - Updates the `HorizontalRule` component to use "100%" as the default value for the `width` prop.
46
91
 
47
92
  ### Fixes
48
93
 
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { DatePickerTypes } from "./DatePickerTypes";
3
3
  import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
4
4
  import { TextInputRefType } from "../TextInput/TextInput";
5
- interface FullDateType {
5
+ export interface FullDateType {
6
6
  /** Date object that gets returned for the onChange
7
7
  * function only for date ranges. */
8
8
  endDate?: Date;
@@ -1,7 +1,5 @@
1
1
  import React from "react";
2
2
  interface FieldsetProps {
3
- /** Children to render. Typically form-related components are used. */
4
- children: React.ReactNode;
5
3
  /** Additional class name to add. */
6
4
  className?: string;
7
5
  /** ID that other components can cross reference for accessibility purposes */
@@ -21,5 +19,5 @@ interface FieldsetProps {
21
19
  * A wrapper component that renders a `fieldset` element along with a `legend`
22
20
  * element as its first child. Commonly used to wrap form components.
23
21
  */
24
- declare const Fieldset: React.FC<FieldsetProps>;
22
+ declare const Fieldset: ({ children, className, id, isLegendHidden, isRequired, legendText, optReqFlag, }: React.PropsWithChildren<FieldsetProps>) => JSX.Element;
25
23
  export default Fieldset;
@@ -1,24 +1,24 @@
1
1
  import * as React from "react";
2
- import { FormSpacing } from "./FormTypes";
3
- export interface FormChildProps {
4
- /** className to be applied to FormRow */
2
+ import { FormGaps } from "./FormTypes";
3
+ interface FormBaseProps {
4
+ /** className to be applied to FormRow, FormField, and Form */
5
5
  className?: string;
6
- /** Spacing size (internal use) */
7
- gap?: FormSpacing;
6
+ /** Optional spacing size; if omitted, the default `large` (2rem / 32px)
7
+ * spacing will be used; ```IMPORTANT: for general form layout, this prop
8
+ * should not be used``` */
9
+ gap?: FormGaps;
8
10
  /** ID that other components can cross reference (internal use) */
9
11
  id?: string;
10
12
  }
11
- export interface FormProps {
13
+ export interface FormChildProps extends FormBaseProps {
14
+ }
15
+ export interface FormProps extends FormBaseProps {
12
16
  /** Optional form `action` attribute */
13
17
  action?: string;
14
- /** Optional className you can add in addition to `form` */
15
- className?: string;
16
- /** Optional ID that other components can cross reference */
17
- id?: string;
18
18
  /** Optional form `method` attribute */
19
19
  method?: "get" | "post";
20
- /** Optional spacing size; if omitted, the default `large` (2rem / 32px) spacing will be used; ```IMPORTANT: for general form layout, this prop should not be used``` */
21
- spacing?: FormSpacing;
20
+ /** Function to call for the `onSubmit` form event. */
21
+ onSubmit?: (e: React.FormEvent<HTMLFormElement>) => void;
22
22
  }
23
23
  /** FormRow child-component */
24
24
  export declare function FormRow(props: React.PropsWithChildren<FormChildProps>): JSX.Element;
@@ -26,3 +26,4 @@ export declare function FormRow(props: React.PropsWithChildren<FormChildProps>):
26
26
  export declare function FormField(props: React.PropsWithChildren<FormChildProps>): JSX.Element;
27
27
  /** Main Form component */
28
28
  export default function Form(props: React.PropsWithChildren<FormProps>): JSX.Element;
29
+ export {};
@@ -1,2 +1,2 @@
1
- import { GridGaps as FormSpacing } from "../Grid/GridTypes";
2
- export { FormSpacing };
1
+ import { GridGaps as FormGaps } from "../Grid/GridTypes";
2
+ export { FormGaps };
@@ -13,7 +13,7 @@ export interface HorizontalRuleProps {
13
13
  height?: string;
14
14
  /** Optional width value. This value should be entered with the same
15
15
  * formatting as a CSS width attribute (ex. `50%`, `640px`, `20rem`). If
16
- * omitted, the horizontal rule will have a default width of "auto". */
16
+ * omitted, the horizontal rule will have a default width of "100%". */
17
17
  width?: string;
18
18
  }
19
19
  export default function HorizontalRule(props: HorizontalRuleProps): JSX.Element;
@@ -2,8 +2,6 @@ import * as React from "react";
2
2
  import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
3
3
  import { RadioGroupLayoutTypes } from "./RadioGroupLayoutTypes";
4
4
  export interface RadioGroupProps {
5
- /** Any child node passed to the component. */
6
- children: React.ReactNode;
7
5
  /** Additional class name. */
8
6
  className?: string;
9
7
  /** Populates the initial value of the input */
@@ -39,5 +37,7 @@ export interface RadioGroupProps {
39
37
  showLabel?: boolean;
40
38
  }
41
39
  export declare const onChangeDefault: () => void;
42
- declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLInputElement>>;
40
+ declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & {
41
+ children?: React.ReactNode;
42
+ } & React.RefAttributes<HTMLInputElement>>;
43
43
  export default RadioGroup;
@@ -1,14 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
3
- interface SelectProps {
3
+ interface BaseProps {
4
4
  labelText: string;
5
5
  name: string;
6
+ onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
7
+ }
8
+ export interface SelectProps extends BaseProps {
6
9
  optionsData: string[];
7
10
  }
8
- interface TextInputProps {
9
- labelText: string;
10
- name: string;
11
- onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
11
+ export interface TextInputProps extends BaseProps {
12
12
  placeholder: string;
13
13
  value?: string;
14
14
  }
@@ -10,14 +10,20 @@ export interface TableProps {
10
10
  columnHeadersTextColor?: string;
11
11
  /** ID that other components can cross reference for accessibility purposes. */
12
12
  id?: string;
13
- /** If true, the first cell of each row in the `Table` component will be visually styled as a header. The default value is false */
14
- useRowHeaders?: boolean;
15
- /** If true, a border will be displayed between each row in the `Table` component. The default value is false. */
13
+ /** If true, a border will be displayed between each row in the `Table`
14
+ * component. The default value is false. */
16
15
  showRowDividers?: boolean;
17
16
  /** Two-dimensional array used to populate the table rows. */
18
17
  tableData: string[][];
19
18
  /** Displays `Table` title element. */
20
19
  titleText?: string;
20
+ /** If true, the first cell of each row in the `Table` component will be
21
+ * visually styled as a header. The default value is false */
22
+ useRowHeaders?: boolean;
21
23
  }
24
+ /**
25
+ * Basic `Table` component used to organize and display tabular data in
26
+ * rows and columns.
27
+ */
22
28
  declare function Table(props: React.PropsWithChildren<TableProps>): JSX.Element;
23
29
  export default Table;
@@ -1,6 +1,10 @@
1
1
  import * as React from "react";
2
2
  export interface TemplateProps {
3
3
  }
4
+ export interface TemplateHeaderProps {
5
+ /** Flag to render an HTML header element. True by default. */
6
+ renderHeaderElement?: boolean;
7
+ }
4
8
  export interface TemplateFooterProps {
5
9
  /** Flag to render an HTML footer element. True by default. */
6
10
  renderFooterElement?: boolean;
@@ -12,7 +16,10 @@ export interface TemplateSidebarProps {
12
16
  }
13
17
  export interface TemplateContentProps extends TemplateSidebarProps {
14
18
  }
15
- export interface TemplateAppContainerProps extends TemplateFooterProps, TemplateSidebarProps {
19
+ export interface TemplateAppContainerProps extends TemplateFooterProps, TemplateHeaderProps, TemplateSidebarProps {
20
+ /** DOM that will be rendered before the rest of the components in
21
+ * `TemplateAppContainer` and immediately before the `TemplateHeader` component. */
22
+ aboveHeader?: React.ReactElement;
16
23
  /** DOM that will be rendered in the `TemplateBreakout` component section. */
17
24
  breakout?: React.ReactElement;
18
25
  /** DOM that will be rendered in the `TemplateContentPrimary` component section. */
@@ -31,11 +38,23 @@ export interface TemplateAppContainerProps extends TemplateFooterProps, Template
31
38
  * components. For backwards compatibility, this renders a `nypl-ds` CSS class.
32
39
  */
33
40
  declare const Template: (props: React.PropsWithChildren<TemplateProps>) => JSX.Element;
41
+ /**
42
+ * This optional component renders its children from edge-to-edge and should
43
+ * be used for alerts or notifications that are typically site-wide. This must
44
+ * be rendered immediately before the `TemplateHeader` component. This is meant
45
+ * for components that render an `aside` HTML element or HTML element with the
46
+ * `role="complementary"` attribute. These elements should *not* be rendered
47
+ * in the `header` HTML section since that's an accessibility violation.
48
+ */
49
+ declare const TemplateAboveHeader: (props: React.PropsWithChildren<TemplateProps>) => JSX.Element;
34
50
  /**
35
51
  * This optional component should be the first child of the `Template`
36
- * component. This is rendered as an HTML `<header>` element.
52
+ * component. This is rendered as an HTML `<header>` element. If an HTML
53
+ * `<header>` element is already passed in a custom component as the children,
54
+ * set `renderFooterElement` to `false`. Otherwise, the parent wrapper will
55
+ * render an HTML `<header>` element.
37
56
  */
38
- declare const TemplateHeader: (props: React.PropsWithChildren<TemplateProps>) => JSX.Element;
57
+ declare const TemplateHeader: ({ children, renderHeaderElement, }: React.PropsWithChildren<TemplateHeaderProps>) => JSX.Element;
39
58
  /**
40
59
  * This optional component should be used inside the `TemplateHeader` component.
41
60
  * This is meant to render its children from edge to edge and is most useful
@@ -93,4 +112,4 @@ declare const TemplateFooter: ({ children, renderFooterElement, }: React.PropsWi
93
112
  * `TemplateContentPrimary` section, then pass it as a prop to `contentPrimary`.
94
113
  */
95
114
  declare const TemplateAppContainer: (props: React.PropsWithChildren<TemplateAppContainerProps>) => JSX.Element;
96
- export { TemplateAppContainer, Template, TemplateHeader, TemplateBreakout, TemplateContent, TemplateContentTop, TemplateContentPrimary, TemplateContentSidebar, TemplateFooter, };
115
+ export { TemplateAppContainer, Template, TemplateAboveHeader, TemplateHeader, TemplateBreakout, TemplateContent, TemplateContentTop, TemplateContentPrimary, TemplateContentSidebar, TemplateFooter, };