@nypl/design-system-react-components 2.0.0-rc8 → 2.0.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.
@@ -19,7 +19,6 @@ export { default as DSProvider } from "./theme/provider";
19
19
  export { default as FeedbackBox, useFeedbackBox, } from "./components/FeedbackBox/FeedbackBox";
20
20
  export type { FeedbackBoxViewType } from "./components/FeedbackBox/FeedbackBox";
21
21
  export { default as Fieldset } from "./components/Fieldset/Fieldset";
22
- export { default as FilterBar } from "./components/FilterBar/FilterBar";
23
22
  export { default as Form, FormField, FormRow } from "./components/Form/Form";
24
23
  export { default as Heading } from "./components/Heading/Heading";
25
24
  export type { HeadingSizes, HeadingLevels } from "./components/Heading/Heading";
@@ -40,10 +39,6 @@ export type { DescriptionProps, ListTypes } from "./components/List/List";
40
39
  export { default as Logo } from "./components/Logo/Logo";
41
40
  export type { LogoNames, LogoSizes } from "./components/Logo/Logo";
42
41
  export { ModalTrigger, useModal } from "./components/Modal/Modal";
43
- export { default as MultiSelect } from "./components/MultiSelect/MultiSelect";
44
- export type { MultiSelectProps, MultiSelectItem, SelectedItems, } from "./components/MultiSelect/MultiSelect";
45
- export { default as MultiSelectGroup } from "./components/MultiSelectGroup/MultiSelectGroup";
46
- export type { MultiSelectGroupProps } from "./components/MultiSelectGroup/MultiSelectGroup";
47
42
  export { default as Notification } from "./components/Notification/Notification";
48
43
  export type { NotificationTypes } from "./components/Notification/Notification";
49
44
  export { default as Pagination } from "./components/Pagination/Pagination";
@@ -79,8 +74,6 @@ export { default as Toggle } from "./components/Toggle/Toggle";
79
74
  export type { ToggleSizes } from "./components/Toggle/Toggle";
80
75
  export { default as useCarouselStyles } from "./hooks/useCarouselStyles";
81
76
  export { default as useCloseDropDown } from "./hooks/useCloseDropDown";
82
- export { default as useFilterBar } from "./hooks/useFilterBar";
83
- export { default as useMultiSelect } from "./hooks/useMultiSelect";
84
77
  export { default as useNYPLBreakpoints } from "./hooks/useNYPLBreakpoints";
85
78
  export { default as useNYPLTheme } from "./hooks/useNYPLTheme";
86
79
  export { default as useWindowSize } from "./hooks/useWindowSize";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nypl/design-system-react-components",
3
- "version": "2.0.0-rc8",
3
+ "version": "2.0.1",
4
4
  "description": "NYPL Reservoir Design System React Components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  "lint": "eslint src --ext=ts,tsx --cache",
39
39
  "prepare": "npm run build && husky install",
40
40
  "storybook": "storybook dev -p 6006",
41
- "build-storybook:v1": "storybook build -c .storybook -o ./reservoir/v1",
41
+ "build-storybook:v2": "storybook build -c .storybook -o ./reservoir/v2",
42
42
  "prebuild:storybook": "npm run test:generate-output",
43
43
  "build-storybook": "storybook build"
44
44
  },
@@ -1,61 +0,0 @@
1
- import React from "react";
2
- import { LayoutTypes } from "../../helpers/types";
3
- import { SelectedItems } from "../MultiSelect/MultiSelect";
4
- interface FilterBarCommonProps {
5
- children: React.ReactNode;
6
- /** The id of the MultiSelect. */
7
- id?: string;
8
- /** Determines on Mobile if filter modal overlay is open or closed */
9
- isOpen: boolean;
10
- /** Heading text of FilterBar */
11
- headingText: string;
12
- /** Renders the layout of the FilterBar child components in a row or column. */
13
- layout?: LayoutTypes;
14
- /** The selected items state (items that were checked by user). */
15
- selectedItems: SelectedItems;
16
- /** User for the global `Clear Filters` button. This button is always shown on mobile, optional on desktop */
17
- onClear: () => void;
18
- /** If passed, the global `Clear Filters` button will render on desktop and tablet */
19
- showClearAll?: boolean;
20
- /** Set width of `FilterBar` child components */
21
- filterWidth?: string;
22
- }
23
- /** Types related to an optional global submit button `Apply Filters` */
24
- type SubmitAllProps = {
25
- /** If passed the `Apply Filters` button will render on desktop and tablet */
26
- showSubmitAll?: false;
27
- /** Function for `Apply Filters` button, needs to be provided by the consuming app */
28
- onSubmit?: never;
29
- }
30
- /** onSubmit is required only if showSubmitAll is passed */
31
- | {
32
- showSubmitAll: true;
33
- onSubmit: () => void;
34
- };
35
- /** Types related to the Modal handling */
36
- type HandleModalProps = {
37
- /** If onToggle is passed as prop, it will open and close the filter modal on mobile */
38
- onToggle: () => void;
39
- /** onOpen and onClose will not be used in this scenario */
40
- onOpen?: never;
41
- onClose?: never;
42
- } | {
43
- /** If onToggle is omitted, onOpen and onClose should be provided instead */
44
- onToggle?: undefined;
45
- /** onOpen will open the filter modal on mobile */
46
- onOpen: () => void;
47
- /** onClose will close the filter modal on mobile */
48
- onClose: () => void;
49
- };
50
- export type FilterBarProps = FilterBarCommonProps & SubmitAllProps & HandleModalProps;
51
- /**
52
- * `FilterBar` is a wrapper component for filter components.
53
- * The DS considers the following components as filter components:
54
- * - `MultiSelectGroup`
55
- *
56
- * The wrapped components/ component groups can be displayed in a column or
57
- * in a row layout. `FilterBar` can render additional `Clear All` and a `Apply Filters` buttons. The two
58
- * _optional_ buttons are controlled by the `showClearAll`/ `onClear` or `showSubmitAll`/`onSubmit` props repectively.
59
- */
60
- export declare const FilterBar: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<React.PropsWithChildren<FilterBarProps> & React.RefAttributes<HTMLDivElement>>, {}>;
61
- export default FilterBar;
@@ -1,61 +0,0 @@
1
- import React from "react";
2
- export interface MultiSelectItem {
3
- id: string;
4
- name: string;
5
- children?: MultiSelectItem[];
6
- }
7
- export declare const multiSelectWidthsArray: readonly ["default", "fitContent", "full"];
8
- export type MultiSelectWidths = typeof multiSelectWidthsArray[number];
9
- export interface SelectedItems {
10
- [name: string]: {
11
- items: string[];
12
- };
13
- }
14
- interface MultiSelectCommonProps {
15
- /** The id of the MultiSelect. */
16
- id: string;
17
- /** Set the default open or closed state of the Multiselect. */
18
- isDefaultOpen?: boolean;
19
- /** Boolean value used to control how the MultiSelect component will render within the page and interact with other DOM elements.
20
- * The default value is false. */
21
- isBlockElement?: boolean;
22
- /** The items to be rendered in the Multiselect as checkbox options. */
23
- items: MultiSelectItem[];
24
- /** The label text rendered within the MultiSelect. */
25
- labelText: string;
26
- /** The action to perform for clear/reset button of MultiSelect. */
27
- onClear?: () => void;
28
- /** The type of MultiSelect that will be rendered. */
29
- type: "listbox" | "dialog";
30
- /** The selected items state (items that were checked by user). */
31
- selectedItems: SelectedItems;
32
- /** Value used to set the width for the MultiSelect component. */
33
- width?: MultiSelectWidths;
34
- }
35
- type ListboxOnChange = (selectedItem: MultiSelectItem, id: string) => void;
36
- type DialogOnChange = (event: React.ChangeEvent<HTMLInputElement>) => void;
37
- type MultiSelectVariantsProps = {
38
- type: "listbox";
39
- onApply?: never;
40
- /** The action to perform for downshift's onSelectedItemChange function. */
41
- onChange: ListboxOnChange;
42
- onMixedStateChange?: never;
43
- } | {
44
- type: "dialog";
45
- /** The action to perform for save/apply button of multiselect. */
46
- onApply: () => void;
47
- /** The action to perform on the checkbox's onChange function. */
48
- onChange: DialogOnChange;
49
- /** The action to perform for a mixed state checkbox (parent checkbox). */
50
- onMixedStateChange?: DialogOnChange;
51
- };
52
- export type MultiSelectProps = MultiSelectCommonProps & MultiSelectVariantsProps;
53
- /**
54
- * The `MultiSelect` component is a form input element that presents a list
55
- * of `Checkbox` components from which a user can make one or multiple
56
- * selections. Two variants of the MultiSelect component are offered, each with
57
- * slightly different functionality and requirements. Because of these
58
- * differences, the two variants are broken out in separate stories below.
59
- */
60
- export declare const MultiSelect: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<React.PropsWithChildren<MultiSelectProps> & React.RefAttributes<HTMLDivElement>>, {}>;
61
- export default MultiSelect;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { MultiSelectProps } from "./MultiSelect";
3
- export declare const MultiSelectDialog: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<Omit<MultiSelectProps, "onChange"> & {
4
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
5
- } & {
6
- children?: React.ReactNode;
7
- } & React.RefAttributes<HTMLDivElement>>, {}>;
8
- export default MultiSelectDialog;
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import { MultiSelectItem, MultiSelectProps } from "./MultiSelect";
3
- /** MultiSelectListbox renders a non-hierarchical list of checkbox options for the `type="listbox". It leverager downshift-js for accessiblity. */
4
- export declare const MultiSelectListbox: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<Omit<MultiSelectProps, "onChange"> & {
5
- onChange: (selectedItem: MultiSelectItem, id: string) => void;
6
- } & {
7
- children?: React.ReactNode;
8
- } & React.RefAttributes<HTMLElement>>, {}>;
9
- export default MultiSelectListbox;
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import { SelectedItems } from "./MultiSelect";
3
- export interface MultiSelectMenuButtonProps {
4
- id: string;
5
- /** The id of the MultiSelect using this button. */
6
- multiSelectId: string;
7
- /** The label text rendered within the MultiSelect using this button. */
8
- multiSelectLabelText: string;
9
- /** The open status of the MultiSelect menu. */
10
- isOpen: boolean;
11
- /** The selected items state (items that were checked by user). */
12
- selectedItems: SelectedItems;
13
- /** The callback function for the menu toggle. */
14
- onMenuToggle?: () => void;
15
- /** The action to perform for clear/reset button of MultiSelect. */
16
- onClear?: () => void;
17
- onKeyDown?: () => void;
18
- }
19
- /**
20
- * The toggle button component used to open and close the `MultiSelect` menu.
21
- * A second button is rendered above the main button that displays the current
22
- * number of selected items. Clicking on the second button will clear all
23
- * the selected items and the main button's close event will not be fired
24
- * (as expected).
25
- */
26
- declare const MultiSelectMenuButton: React.ForwardRefExoticComponent<MultiSelectMenuButtonProps & React.RefAttributes<HTMLButtonElement>>;
27
- export default MultiSelectMenuButton;
@@ -1,28 +0,0 @@
1
- import React from "react";
2
- import { LayoutTypes } from "../../helpers/types";
3
- import { MultiSelectWidths } from "../MultiSelect/MultiSelect";
4
- export interface MultiSelectGroupProps {
5
- children: React.ReactNode;
6
- /** Additional className to use. */
7
- className?: string;
8
- /** The id of the MultiSelectGroup. */
9
- id: string;
10
- /** The label text rendered within the MultiSelectGroup. */
11
- labelText: string;
12
- /** Renders the layout of `MultiSelect` components in a row or column. */
13
- layout?: LayoutTypes;
14
- /** Width will be passed on each `MultiSelect` component. */
15
- multiSelectWidth?: MultiSelectWidths;
16
- /** Is set to `true` by default and determines if the `labelText` is visible on the site. */
17
- showLabel?: boolean;
18
- }
19
- /**
20
- * `MultiSelectGroup` is a wrapper component specific for `MultiSelect` components. The wrapped `MutliSelect` components can be displayed in a
21
- * column or in a row. The `MultiSelectGroup` component renders all the necessary
22
- * wrapping and associated text elements, but the child elements
23
- * _need_ to be `MultiSelect` components from the NYPL Design System.
24
- */
25
- export declare const MultiSelectGroup: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<MultiSelectGroupProps & {
26
- children?: React.ReactNode;
27
- } & React.RefAttributes<HTMLDivElement>>, {}>;
28
- export default MultiSelectGroup;
@@ -1,21 +0,0 @@
1
- import { SelectedItems } from "./../components/MultiSelect/MultiSelect";
2
- /**
3
- * The `useFilterBar` hook returns an object containing all the functions and state needed to control a FilterBar component and its child components.
4
- * The returned object includes the functions `onChange`, `onMixedStateChange`, `onClear` and `onClearAll` for handling any changes to the selectedItems object,
5
- * a `setSelectedItems` function that allows to set an initial selectedItems state
6
- * and the current state of the selection: `selectedItems`.
7
- * In addition it returns all props to handle a filter module overlay for the mobile view: a boolean value representing the current module state: `isModalOpen`,
8
- * an `onToggle` function to change the module state or alternatively `onOpen` and `onClose` functions.
9
- */
10
- export default function useFilterBar(initialState?: SelectedItems): {
11
- selectedItems: {} | SelectedItems;
12
- setSelectedItems: (newState: SelectedItems) => void;
13
- isModalOpen: boolean;
14
- onOpen: () => void;
15
- onClose: () => void;
16
- onToggle: () => void;
17
- onChange: (itemId: string, multiSelectId: string) => void;
18
- onMixedStateChange: (parentId: string, multiSelectId: string, items: import("./../components/MultiSelect/MultiSelect").MultiSelectItem[]) => void;
19
- onClear: (multiSelectId: string) => void;
20
- onClearAll: () => void;
21
- };
@@ -1,15 +0,0 @@
1
- import { MultiSelectItem, SelectedItems } from "../components/MultiSelect/MultiSelect";
2
- /**
3
- * The useMultiSelect hook returns an object containing all the functions and state needed to handle the selectedItems of a `MultiSelect` component.
4
- * It can be used in conjunction with one single `MultiSelect` component as well as a group of `MultiSelect`s in the `MultiSelectGroup` component.
5
- * The returned object includes the functions onChange, onClear, onMixedStateChange for handling any changes to the selection of items
6
- * and the current state of the selection: selectedItems.
7
- */
8
- export default function useMultiSelect(initialState?: SelectedItems): {
9
- selectedItems: {} | SelectedItems;
10
- setSelectedItems: (newState: SelectedItems) => void;
11
- onChange: (itemId: string, multiSelectId: string) => void;
12
- onMixedStateChange: (parentId: string, multiSelectId: string, items: MultiSelectItem[]) => void;
13
- onClear: (multiSelectId: string) => void;
14
- onClearAll: () => void;
15
- };