@nypl/design-system-react-components 1.3.1 → 1.4.0-rc
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.
- package/dist/components/FilterBar/FilterBar.d.ts +111 -0
- package/dist/components/FilterBar/FilterBar.stories.d.ts +7 -0
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +6 -6
- package/dist/components/MultiSelect/MultiSelect.d.ts +78 -0
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +4 -0
- package/dist/components/MultiSelect/MultiSelectDialog.d.ts +8 -0
- package/dist/components/MultiSelect/MultiSelectListbox.d.ts +9 -0
- package/dist/components/MultiSelect/MultiSelectMenuButton.d.ts +27 -0
- package/dist/components/MultiSelectGroup/MultiSelectGroup.d.ts +26 -0
- package/dist/components/MultiSelectGroup/MultiSelectGroup.stories.d.ts +4 -0
- package/dist/components/Slider/Slider.d.ts +2 -0
- package/dist/design-system-react-components.cjs.development.js +1425 -305
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +1422 -307
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/__tests__/useFilterBar.test.d.ts +1 -0
- package/dist/hooks/__tests__/useMultiSelect.test.d.ts +1 -0
- package/dist/hooks/useFilterBar.d.ts +21 -0
- package/dist/hooks/useMultiSelect.d.ts +15 -0
- package/dist/index.d.ts +5 -0
- package/dist/theme/components/feedbackBox.d.ts +6 -0
- package/dist/theme/components/filterBar.d.ts +30 -0
- package/dist/theme/components/link.d.ts +22 -0
- package/dist/theme/components/multiSelect.d.ts +29 -0
- package/dist/theme/components/multiSelectMenuButton.d.ts +72 -0
- package/dist/utils/utils.d.ts +4 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -1738
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
declare 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
|
+
declare 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 declare 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<(FilterBarCommonProps & {
|
|
61
|
+
/** If passed the `Apply Filters` button will render on desktop and tablet */
|
|
62
|
+
showSubmitAll?: false;
|
|
63
|
+
/** Function for `Apply Filters` button, needs to be provided by the consuming app */
|
|
64
|
+
onSubmit?: never;
|
|
65
|
+
} & {
|
|
66
|
+
/** If onToggle is passed as prop, it will open and close the filter modal on mobile */
|
|
67
|
+
onToggle: () => void;
|
|
68
|
+
/** onOpen and onClose will not be used in this scenario */
|
|
69
|
+
onOpen?: never;
|
|
70
|
+
onClose?: never;
|
|
71
|
+
} & {
|
|
72
|
+
children?: React.ReactNode;
|
|
73
|
+
} & React.RefAttributes<HTMLDivElement>) | (FilterBarCommonProps & {
|
|
74
|
+
/** If passed the `Apply Filters` button will render on desktop and tablet */
|
|
75
|
+
showSubmitAll?: false;
|
|
76
|
+
/** Function for `Apply Filters` button, needs to be provided by the consuming app */
|
|
77
|
+
onSubmit?: never;
|
|
78
|
+
} & {
|
|
79
|
+
/** If onToggle is omitted, onOpen and onClose should be provided instead */
|
|
80
|
+
onToggle?: undefined;
|
|
81
|
+
/** onOpen will open the filter modal on mobile */
|
|
82
|
+
onOpen: () => void;
|
|
83
|
+
/** onClose will close the filter modal on mobile */
|
|
84
|
+
onClose: () => void;
|
|
85
|
+
} & {
|
|
86
|
+
children?: React.ReactNode;
|
|
87
|
+
} & React.RefAttributes<HTMLDivElement>) | (FilterBarCommonProps & {
|
|
88
|
+
showSubmitAll: true;
|
|
89
|
+
onSubmit: () => void;
|
|
90
|
+
} & {
|
|
91
|
+
/** If onToggle is passed as prop, it will open and close the filter modal on mobile */
|
|
92
|
+
onToggle: () => void;
|
|
93
|
+
/** onOpen and onClose will not be used in this scenario */
|
|
94
|
+
onOpen?: never;
|
|
95
|
+
onClose?: never;
|
|
96
|
+
} & {
|
|
97
|
+
children?: React.ReactNode;
|
|
98
|
+
} & React.RefAttributes<HTMLDivElement>) | (FilterBarCommonProps & {
|
|
99
|
+
showSubmitAll: true;
|
|
100
|
+
onSubmit: () => void;
|
|
101
|
+
} & {
|
|
102
|
+
/** If onToggle is omitted, onOpen and onClose should be provided instead */
|
|
103
|
+
onToggle?: undefined;
|
|
104
|
+
/** onOpen will open the filter modal on mobile */
|
|
105
|
+
onOpen: () => void;
|
|
106
|
+
/** onClose will close the filter modal on mobile */
|
|
107
|
+
onClose: () => void;
|
|
108
|
+
} & {
|
|
109
|
+
children?: React.ReactNode;
|
|
110
|
+
} & React.RefAttributes<HTMLDivElement>)>, {}>;
|
|
111
|
+
export default FilterBar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Story } from "@storybook/react/types-6-0";
|
|
3
|
+
import { FilterBarProps } from "./FilterBar";
|
|
4
|
+
export declare const FilterBarStory: Story<FilterBarProps>;
|
|
5
|
+
export declare const FilterBarLayoutStory: () => JSX.Element;
|
|
6
|
+
export declare const FilterBarRowContainerStory: () => JSX.Element;
|
|
7
|
+
export declare const FilterBarColumnContainerStory: () => JSX.Element;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare type AriaLiveValues = "assertive" | "off" | "polite";
|
|
2
|
+
export declare type AriaLiveValues = "assertive" | "off" | "polite" | undefined;
|
|
3
3
|
export declare type HelperErrorTextType = string | JSX.Element;
|
|
4
4
|
interface HelperErrorTextProps {
|
|
5
|
-
/** Aria attribute. When true, assistive technologies will
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
/** Aria attribute. When true, assistive technologies will read the entire
|
|
6
|
+
* DOM element. When false, only changes (additionals or removals) will be
|
|
7
|
+
* read. True by default. */
|
|
8
8
|
ariaAtomic?: boolean;
|
|
9
|
-
/** Aria attribute used
|
|
9
|
+
/** Aria attribute used to handle live updates for the helper and error text.
|
|
10
10
|
* This indicates the priority of the text and when it should be presented to
|
|
11
11
|
* users using screen readers; "off" indicates that the content should not be
|
|
12
12
|
* presented, "polite" that it will be announced at the next available time
|
|
13
13
|
* slot, and "assertive" that it should be announced immediately. This is set
|
|
14
|
-
* to "
|
|
14
|
+
* to "polite" by default. */
|
|
15
15
|
ariaLive?: AriaLiveValues;
|
|
16
16
|
/** Additional className to add. */
|
|
17
17
|
className?: string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface MultiSelectItem {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
children?: MultiSelectItem[];
|
|
6
|
+
}
|
|
7
|
+
export declare type MultiSelectWidths = "default" | "fitContent" | "full";
|
|
8
|
+
export interface SelectedItems {
|
|
9
|
+
[name: string]: {
|
|
10
|
+
items: string[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface MultiSelectCommonProps {
|
|
14
|
+
/** The id of the MultiSelect. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Set the default open or closed state of the Multiselect. */
|
|
17
|
+
isDefaultOpen?: boolean;
|
|
18
|
+
/** Boolean value used to control how the MultiSelect component will render within the page and interact with other DOM elements.
|
|
19
|
+
* The default value is false. */
|
|
20
|
+
isBlockElement?: boolean;
|
|
21
|
+
/** The items to be rendered in the Multiselect as checkbox options. */
|
|
22
|
+
items: MultiSelectItem[];
|
|
23
|
+
/** The label of the MultiSelect. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** The action to perform for clear/reset button of MultiSelect. */
|
|
26
|
+
onClear?: () => void;
|
|
27
|
+
/** The variant of the MultiSelect. */
|
|
28
|
+
variant: "listbox" | "dialog";
|
|
29
|
+
/** The selected items state (items that were checked by user). */
|
|
30
|
+
selectedItems: SelectedItems;
|
|
31
|
+
/** Value used to set the width for the MultiSelect component. */
|
|
32
|
+
width?: MultiSelectWidths;
|
|
33
|
+
}
|
|
34
|
+
declare type ListboxOnChange = (selectedItem: MultiSelectItem, id: string) => void;
|
|
35
|
+
declare type DialogOnChange = (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
36
|
+
declare type MultiSelectVariantsProps = {
|
|
37
|
+
variant: "listbox";
|
|
38
|
+
onApply?: never;
|
|
39
|
+
/** The action to perform for downshift's onSelectedItemChange function. */
|
|
40
|
+
onChange: ListboxOnChange;
|
|
41
|
+
onMixedStateChange?: never;
|
|
42
|
+
} | {
|
|
43
|
+
variant: "dialog";
|
|
44
|
+
/** The action to perform for save/apply button of multiselect. */
|
|
45
|
+
onApply: () => void;
|
|
46
|
+
/** The action to perform on the checkbox's onChange function. */
|
|
47
|
+
onChange: DialogOnChange;
|
|
48
|
+
/** The action to perform for a mixed state checkbox (parent checkbox). */
|
|
49
|
+
onMixedStateChange?: DialogOnChange;
|
|
50
|
+
};
|
|
51
|
+
export declare type MultiSelectProps = MultiSelectCommonProps & MultiSelectVariantsProps;
|
|
52
|
+
/**
|
|
53
|
+
* The `MultiSelect` component is a form input element that presents a list
|
|
54
|
+
* of `Checkbox` components from which a user can make one or multiple
|
|
55
|
+
* selections. Two variants of the MultiSelect component are offered, each with
|
|
56
|
+
* slightly different functionality and requirements. Because of these
|
|
57
|
+
* differences, the two variants are broken out in separate stories below.
|
|
58
|
+
*/
|
|
59
|
+
export declare const MultiSelect: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<(MultiSelectCommonProps & {
|
|
60
|
+
variant: "listbox";
|
|
61
|
+
onApply?: never;
|
|
62
|
+
/** The action to perform for downshift's onSelectedItemChange function. */
|
|
63
|
+
onChange: ListboxOnChange;
|
|
64
|
+
onMixedStateChange?: never;
|
|
65
|
+
} & {
|
|
66
|
+
children?: React.ReactNode;
|
|
67
|
+
} & React.RefAttributes<HTMLDivElement>) | (MultiSelectCommonProps & {
|
|
68
|
+
variant: "dialog";
|
|
69
|
+
/** The action to perform for save/apply button of multiselect. */
|
|
70
|
+
onApply: () => void;
|
|
71
|
+
/** The action to perform on the checkbox's onChange function. */
|
|
72
|
+
onChange: DialogOnChange;
|
|
73
|
+
/** The action to perform for a mixed state checkbox (parent checkbox). */
|
|
74
|
+
onMixedStateChange?: DialogOnChange;
|
|
75
|
+
} & {
|
|
76
|
+
children?: React.ReactNode;
|
|
77
|
+
} & React.RefAttributes<HTMLDivElement>)>, {}>;
|
|
78
|
+
export default MultiSelect;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MultiSelectProps } from "./MultiSelect";
|
|
3
|
+
export declare const MultiSelectDialog: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<Pick<MultiSelectProps, "id" | "isDefaultOpen" | "isBlockElement" | "items" | "label" | "onClear" | "variant" | "selectedItems" | "width" | "onApply" | "onMixedStateChange"> & {
|
|
4
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
} & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
} & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
8
|
+
export default MultiSelectDialog;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MultiSelectItem, MultiSelectProps } from "./MultiSelect";
|
|
3
|
+
/** MultiSelectListbox renders a non-hierarchical list of checkbox options for the `variant="listbox". It leverager downshift-js for accessiblity. */
|
|
4
|
+
export declare const MultiSelectListbox: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<Pick<MultiSelectProps, "id" | "isDefaultOpen" | "isBlockElement" | "items" | "label" | "onClear" | "variant" | "selectedItems" | "width" | "onApply" | "onMixedStateChange"> & {
|
|
5
|
+
onChange: (selectedItem: MultiSelectItem, id: string) => void;
|
|
6
|
+
} & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & React.RefAttributes<HTMLElement>>, {}>;
|
|
9
|
+
export default MultiSelectListbox;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 of the MultiSelect using this button. */
|
|
8
|
+
multiSelectLabel: 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;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
id: string;
|
|
9
|
+
labelText: string;
|
|
10
|
+
/** Renders the layout of `MultiSelect` components in a row or column. */
|
|
11
|
+
layout?: LayoutTypes;
|
|
12
|
+
/** Width will be passed on each `MultiSelect` component. */
|
|
13
|
+
multiSelectWidth?: MultiSelectWidths;
|
|
14
|
+
/** Is set to `true` by default and determines if the `labelText` is visible on the site. */
|
|
15
|
+
showLabel?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `MultiSelectGroup` is a wrapper component specific for `MultiSelect` components. The wrapped `MutliSelect` components can be displayed in a
|
|
19
|
+
* column or in a row. The `MultiSelectGroup` component renders all the necessary
|
|
20
|
+
* wrapping and associated text elements, but the child elements
|
|
21
|
+
* _need_ to be `MultiSelect` components from the NYPL Design System.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MultiSelectGroup: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<MultiSelectGroupProps & {
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
} & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
26
|
+
export default MultiSelectGroup;
|
|
@@ -35,6 +35,8 @@ export interface SliderProps {
|
|
|
35
35
|
name?: string;
|
|
36
36
|
/** Callback function that gets the value(s) selected. */
|
|
37
37
|
onChange?: (val: number | number[]) => void;
|
|
38
|
+
/** Callback function when the user is done selecting a new value. */
|
|
39
|
+
onChangeEnd?: (val: number | number[]) => void;
|
|
38
40
|
/** Offers the ability to hide the `TextInput` boxes. */
|
|
39
41
|
showBoxes?: boolean;
|
|
40
42
|
/** Offers the ability to hide the helper/invalid text. */
|