@nypl/design-system-react-components 3.0.0-react-chakra-rc → 3.0.0-react-chakra-rc2

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.
@@ -3,12 +3,18 @@ import React from "react";
3
3
  export type AccordionTypes = "default" | "warning" | "error";
4
4
  export interface AccordionDataProps {
5
5
  accordionType?: AccordionTypes;
6
- label: string;
6
+ ariaLabel?: string;
7
+ /** Ref to the DOM element of the AccordionButton. */
8
+ buttonInteractionRef?: any;
9
+ label: string | JSX.Element;
7
10
  panel: string | React.ReactNode;
8
11
  }
9
12
  export interface AccordionProps {
10
13
  /** Array of data to display, and an optional accordionType */
11
14
  accordionData: AccordionDataProps[];
15
+ /** Global aria-label value that is applied to all accordions if individual
16
+ * ariaLabel props are not included with accordionData entries. */
17
+ ariaLabel?: string;
12
18
  /** ID that other components can cross reference for accessibility purposes */
13
19
  id?: string;
14
20
  /** Whether the accordion is open by default only on its initial rendering */
@@ -0,0 +1,55 @@
1
+ import React from "react";
2
+ import { ChakraComponent } from "@chakra-ui/react";
3
+ export interface MultiSelectItem {
4
+ id: string;
5
+ name: string;
6
+ isDisabled?: boolean;
7
+ children?: MultiSelectItem[];
8
+ }
9
+ export declare const multiSelectWidthsArray: readonly ["fitContent", "full"];
10
+ export type MultiSelectWidths = typeof multiSelectWidthsArray[number];
11
+ export declare const multiSelectListOverflowArray: readonly ["scroll", "expand"];
12
+ export type MultiSelectListOverflowTypes = typeof multiSelectListOverflowArray[number];
13
+ export interface SelectedItems {
14
+ [name: string]: {
15
+ items: string[];
16
+ };
17
+ }
18
+ export interface MultiSelectProps {
19
+ /** The button text rendered within the MultiSelect. */
20
+ buttonText: string;
21
+ /** The number of items that will be visible in the list when the component first loads. */
22
+ defaultItemsVisible?: number;
23
+ /** The action to perform for clear/reset button of MultiSelect. */
24
+ onClear?: () => void;
25
+ /** The action to perform on the checkbox's onChange function. */
26
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
27
+ /** The action to perform for a mixed state checkbox (parent checkbox). */
28
+ onMixedStateChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
29
+ /** An ID string that other components can cross reference for accessibility purposes. */
30
+ id: string;
31
+ /** Boolean value used to control how the MultiSelect component will render within the page
32
+ * and interact with other DOM elements.
33
+ * The default value is false. */
34
+ isBlockElement?: boolean;
35
+ /** Set the default open or closed state of the Multiselect. */
36
+ isDefaultOpen?: boolean;
37
+ /** Boolean value used to enable the component's search functionality
38
+ * The default value is false. */
39
+ isSearchable?: boolean;
40
+ /** The items to be rendered in the Multiselect as checkbox options. */
41
+ items: MultiSelectItem[];
42
+ /** listOverflow is a property indicating how the list should handle overflow, with options limited to either "scroll" or "expand." */
43
+ listOverflow?: MultiSelectListOverflowTypes;
44
+ /** The selected items state (items that were checked by user). */
45
+ selectedItems: SelectedItems;
46
+ /** Value used to set the width for the MultiSelect component. */
47
+ width?: MultiSelectWidths;
48
+ }
49
+ /**
50
+ The MultiSelect component is a customizable form input that supports multiple configurations,
51
+ including search functionality, checkbox options, and hierarchical structure,
52
+ with a parent checkbox toggling all children and dynamic styling through Chakra UI.
53
+ */
54
+ export declare const MultiSelect: ChakraComponent<React.ForwardRefExoticComponent<React.PropsWithChildren<MultiSelectProps> & React.RefAttributes<HTMLDivElement>>, React.PropsWithChildren<MultiSelectProps>>;
55
+ export default MultiSelect;
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ export interface MultiSelectItemsCountButtonProps {
3
+ id: string;
4
+ /** The id of the MultiSelect using this button. */
5
+ multiSelectId: string;
6
+ /** The label text rendered within the MultiSelect using this button. */
7
+ multiSelectLabelText: string;
8
+ /** The open status of the MultiSelect menu. */
9
+ isOpen: boolean;
10
+ /** The selected items state (items that were checked by user). */
11
+ selectedItemsString: string;
12
+ selectedItemsCount: number;
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
+ /** Ref to the Accordion Button element. */
19
+ accordianButtonRef: any;
20
+ }
21
+ /**
22
+ * The toggle button component used to open and close the `MultiSelect` menu.
23
+ * A second button is rendered above the main button that displays the current
24
+ * number of selected items. Clicking on the second button will clear all
25
+ * the selected items and the main button's close event will not be fired
26
+ * (as expected).
27
+ */
28
+ declare const MultiSelectItemsCountButton: React.ForwardRefExoticComponent<MultiSelectItemsCountButtonProps & React.RefAttributes<HTMLButtonElement>>;
29
+ export default MultiSelectItemsCountButton;
@@ -0,0 +1,18 @@
1
+ import { MultiSelectItem, SelectedItems } from "../components/MultiSelect/MultiSelect";
2
+ /**
3
+ * The useMultiSelect hook returns an object containing all the functions and
4
+ * state needed to handle the selectedItems of a `MultiSelect` component. It can
5
+ * be used in conjunction with one single `MultiSelect` component as well as a
6
+ * group of `MultiSelect`s in the `MultiSelectGroup` component. The returned
7
+ * object includes the functions onChange, onClear, onMixedStateChange for
8
+ * handling any changes to the selection of items and the current state of the
9
+ * selection: selectedItems.
10
+ */
11
+ export default function useMultiSelect(initialState?: SelectedItems): {
12
+ selectedItems: {} | SelectedItems;
13
+ setSelectedItems: (newState: SelectedItems) => void;
14
+ onChange: (itemId: string, multiSelectId: string) => void;
15
+ onMixedStateChange: (parentId: string, multiSelectId: string, items: MultiSelectItem[]) => void;
16
+ onClear: (multiSelectId: string) => void;
17
+ onClearAll: () => void;
18
+ };
@@ -43,6 +43,8 @@ export type { LogoNames, LogoSizes } from "./components/Logo/Logo";
43
43
  export { default as Menu } from "./components/Menu/Menu";
44
44
  export type { ListItemsData, ActionItem, GroupItem, DividerItem, } from "./components/Menu/Menu";
45
45
  export { ModalTrigger, useModal } from "./components/Modal/Modal";
46
+ export { default as MultiSelect } from "./components/MultiSelect/MultiSelect";
47
+ export type { MultiSelectItem, SelectedItems, } from "./components/MultiSelect/MultiSelect";
46
48
  export { default as NewsletterSignup } from "./components/NewsletterSignup/NewsletterSignup";
47
49
  export type { NewsletterSignupViewType } from "./components/NewsletterSignup/NewsletterSignup";
48
50
  export { default as Notification } from "./components/Notification/Notification";
@@ -80,6 +82,7 @@ export { default as Toggle } from "./components/Toggle/Toggle";
80
82
  export type { ToggleSizes } from "./components/Toggle/Toggle";
81
83
  export { default as useCarouselStyles } from "./hooks/useCarouselStyles";
82
84
  export { default as useCloseDropDown } from "./hooks/useCloseDropDown";
85
+ export { default as useMultiSelect } from "./hooks/useMultiSelect";
83
86
  export { default as useNYPLBreakpoints } from "./hooks/useNYPLBreakpoints";
84
87
  export { default as useNYPLTheme } from "./hooks/useNYPLTheme";
85
88
  export { default as useWindowSize } from "./hooks/useWindowSize";
@@ -17,6 +17,9 @@ declare const Accordion: {
17
17
  };
18
18
  color: string;
19
19
  fontWeight: string;
20
+ svg: {
21
+ marginStart: string;
22
+ };
20
23
  _dark: {
21
24
  bg: string;
22
25
  color: string;
@@ -1,10 +1,4 @@
1
1
  export declare const multiSelectWidths: {
2
- default: {
3
- width: {
4
- base: string;
5
- md: string;
6
- };
7
- };
8
2
  fitContent: {
9
3
  width: {
10
4
  base: string;
@@ -13,17 +7,117 @@ export declare const multiSelectWidths: {
13
7
  minWidth: {
14
8
  md: string;
15
9
  };
10
+ maxWidth: {
11
+ md: string;
12
+ };
16
13
  };
17
14
  full: {
18
15
  width: string;
19
16
  };
20
17
  };
21
18
  declare const MultiSelect: {
22
- parts: string[];
23
- baseStyle: ({ isBlockElement, isOpen, width }: {
24
- isBlockElement: any;
25
- isOpen: any;
26
- width?: string;
27
- }) => any;
19
+ baseStyle?: ({ isBlockElement, width }: import("@chakra-ui/styled-system").StyleFunctionProps) => {
20
+ base: {
21
+ position: string;
22
+ };
23
+ menuChildren: {
24
+ paddingLeft: string;
25
+ marginBottom: number;
26
+ };
27
+ viewAllButton: {
28
+ color: string;
29
+ marginLeft: string;
30
+ px: string;
31
+ py: string;
32
+ _hover: {
33
+ bg: string;
34
+ };
35
+ _dark: {
36
+ color: string;
37
+ _hover: {
38
+ bg: string;
39
+ };
40
+ };
41
+ };
42
+ buttonTextLabel: {
43
+ marginLeft: string;
44
+ textOverflow: string;
45
+ overflow: string;
46
+ marginBottom: number;
47
+ };
48
+ menuSearchInputBox: {
49
+ input: {
50
+ backgroundColor: string;
51
+ border: string;
52
+ };
53
+ };
54
+ accordionStyles: {
55
+ ".chakra-accordion__item": {
56
+ _dark: {
57
+ bgColor: string;
58
+ };
59
+ };
60
+ ".chakra-accordion__button": {
61
+ backgroundColor: string;
62
+ fontWeight: string;
63
+ minWidth: string;
64
+ position: string;
65
+ width: string | {
66
+ base: "100%";
67
+ md: "fit-content";
68
+ };
69
+ overflow: string;
70
+ zIndex: number;
71
+ div: {
72
+ overflow: string;
73
+ textOverflow: string;
74
+ whiteSpace: string;
75
+ };
76
+ span: {
77
+ overflow: string;
78
+ };
79
+ _hover: {
80
+ backgroundColor: string;
81
+ };
82
+ _dark: {
83
+ backgroundColor: string;
84
+ borderStartColor: string;
85
+ borderStartWidth: string;
86
+ _hover: {
87
+ borderStartColor: string;
88
+ };
89
+ };
90
+ _expanded: {
91
+ bgColor: string;
92
+ _dark: {
93
+ bgColor: string;
94
+ };
95
+ };
96
+ };
97
+ ".chakra-collapse": any;
98
+ ".chakra-accordion__panel": {
99
+ bgColor: string;
100
+ _dark: {
101
+ bgColor: string;
102
+ };
103
+ };
104
+ };
105
+ };
106
+ sizes?: {
107
+ [key: string]: import("@chakra-ui/styled-system").PartsStyleInterpolation<{
108
+ keys: ("base" | "accordionStyles" | "buttonTextLabel" | "menuChildren" | "menuSearchInputBox" | "viewAllButton")[];
109
+ }>;
110
+ };
111
+ variants?: {
112
+ [key: string]: import("@chakra-ui/styled-system").PartsStyleInterpolation<{
113
+ keys: ("base" | "accordionStyles" | "buttonTextLabel" | "menuChildren" | "menuSearchInputBox" | "viewAllButton")[];
114
+ }>;
115
+ };
116
+ defaultProps?: {
117
+ size?: string | number;
118
+ variant?: string | number;
119
+ colorScheme?: string;
120
+ };
121
+ parts: ("base" | "accordionStyles" | "buttonTextLabel" | "menuChildren" | "menuSearchInputBox" | "viewAllButton")[];
28
122
  };
29
123
  export default MultiSelect;
@@ -0,0 +1,52 @@
1
+ declare const MultiSelectItemsCountButton: {
2
+ baseStyle?: ({ isOpen }: import("@chakra-ui/styled-system").StyleFunctionProps) => {
3
+ alignItems: string;
4
+ backgroundColor: string;
5
+ border: string;
6
+ borderRadius: string;
7
+ borderColor: string;
8
+ display: string;
9
+ flexShrink: number;
10
+ fontSize: string;
11
+ justifyContent: string;
12
+ left: string;
13
+ marginRight: string;
14
+ position: string;
15
+ top: {
16
+ base: "12px";
17
+ md: "10px";
18
+ };
19
+ width: string;
20
+ zIndex: number;
21
+ _hover: {
22
+ borderColor: string;
23
+ };
24
+ svg: {
25
+ marginLeft: string;
26
+ marginRight: string;
27
+ marginTop: string;
28
+ };
29
+ _dark: {
30
+ backgroundColor: string;
31
+ borderColor: string;
32
+ svg: {
33
+ fill: string;
34
+ };
35
+ _hover: {
36
+ borderColor: string;
37
+ };
38
+ };
39
+ };
40
+ sizes?: {
41
+ [key: string]: import("@chakra-ui/styled-system").SystemStyleInterpolation;
42
+ };
43
+ variants?: {
44
+ [key: string]: import("@chakra-ui/styled-system").SystemStyleInterpolation;
45
+ };
46
+ defaultProps?: {
47
+ size?: string | number;
48
+ variant?: string | number;
49
+ colorScheme?: string;
50
+ };
51
+ };
52
+ export default MultiSelectItemsCountButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nypl/design-system-react-components",
3
- "version": "3.0.0-react-chakra-rc",
3
+ "version": "3.0.0-react-chakra-rc2",
4
4
  "description": "NYPL Reservoir Design System React Components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,99 +0,0 @@
1
- declare const MultiSelectMenuButton: {
2
- parts: string[];
3
- baseStyle: ({ hasSelectedItems, isOpen }: {
4
- hasSelectedItems?: boolean;
5
- isOpen?: boolean;
6
- }) => {
7
- buttonLabel: {
8
- color: string;
9
- justifyContent: string;
10
- overflow: string;
11
- marginLeft: string;
12
- marginRight: string;
13
- textAlign: string;
14
- textOverflow: string;
15
- whiteSpace: string;
16
- transition: string;
17
- _dark: {
18
- color: string;
19
- };
20
- };
21
- menuButton: {
22
- alignItems: string;
23
- backgroundColor: string;
24
- borderBottomLeftRadius: string;
25
- borderBottomRightRadius: string;
26
- borderColor: string;
27
- borderRadius: string;
28
- borderWidth: string;
29
- fontSize: string;
30
- minHeight: {
31
- base: string;
32
- md: string;
33
- };
34
- px: string;
35
- py: string;
36
- display: string;
37
- justifyContent: string;
38
- width: string;
39
- _hover: {
40
- backgroundColor: string;
41
- borderColor: string;
42
- };
43
- svg: {
44
- marginTop: string;
45
- };
46
- _dark: {
47
- backgroundColor: string;
48
- borderBottomLeftRadius: string;
49
- borderBottomRightRadius: string;
50
- borderColor: string;
51
- svg: {
52
- fill: string;
53
- };
54
- _hover: {
55
- backgroundColor: string;
56
- borderColor: string;
57
- };
58
- };
59
- };
60
- selectedItemsCountButton: {
61
- alignItems: string;
62
- backgroundColor: string;
63
- border: string;
64
- borderRadius: string;
65
- borderColor: string;
66
- display: string;
67
- flexShrink: number;
68
- fontSize: string;
69
- justifyContent: string;
70
- left: string;
71
- marginRight: string;
72
- position: string;
73
- top: {
74
- base: string;
75
- md: string;
76
- };
77
- width: string;
78
- _hover: {
79
- borderColor: string;
80
- };
81
- svg: {
82
- marginLeft: string;
83
- marginRight: string;
84
- marginTop: string;
85
- };
86
- _dark: {
87
- backgroundColor: string;
88
- borderColor: string;
89
- svg: {
90
- fill: string;
91
- };
92
- _hover: {
93
- borderColor: string;
94
- };
95
- };
96
- };
97
- };
98
- };
99
- export default MultiSelectMenuButton;