@nypl/design-system-react-components 3.0.0-react-chakra-rc → 3.0.0-react-chakra-rc3
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/design-system-react-components.cjs +56 -56
- package/dist/design-system-react-components.js +14064 -14065
- package/dist/src/__tests__/mediaMatchMock.d.ts +79 -0
- package/dist/src/components/Accordion/Accordion.d.ts +7 -1
- package/dist/src/components/Link/Link.d.ts +4 -6
- package/dist/src/components/MultiSelect/MultiSelect.d.ts +55 -0
- package/dist/src/components/MultiSelect/MultiSelectItemsCountButton.d.ts +32 -0
- package/dist/src/components/Tabs/Tabs.d.ts +2 -2
- package/dist/src/hooks/useMultiSelect.d.ts +18 -0
- package/dist/src/index.d.ts +19 -4
- package/dist/src/theme/components/accordion.d.ts +3 -0
- package/dist/src/theme/components/featuredContent.d.ts +4 -4
- package/dist/src/theme/components/heading.d.ts +15 -210
- package/dist/src/theme/components/menu.d.ts +18 -6
- package/dist/src/theme/components/multiSelect.d.ts +106 -12
- package/dist/src/theme/components/multiSelectItemsCountButton.d.ts +52 -0
- package/dist/src/theme/components/skeletonLoader.d.ts +51 -60
- package/dist/src/theme/components/structuredContent.d.ts +5 -72
- package/dist/src/theme/components/tabs.d.ts +2 -4
- package/package.json +1 -1
- package/dist/src/components/NewsletterSignup/NewsletterSignup.d.ts +0 -49
- package/dist/src/components/SocialMediaLinks/SocialMediaLinks.d.ts +0 -43
- package/dist/src/components/SocialMediaLinks/SocialMediaLinksUtils.d.ts +0 -7
- package/dist/src/theme/components/multiSelectMenuButton.d.ts +0 -99
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NYPL Note:
|
|
3
|
+
* This file is directly taken from Chakra:
|
|
4
|
+
* https://github.com/chakra-ui/chakra-ui/blob/main/packages/media-query/tests/matchmedia-mock-plus.ts
|
|
5
|
+
*
|
|
6
|
+
* We need this to test the `useNYPLBreakpoints` hook and, unfortunately,
|
|
7
|
+
* this function is not exported by Chakra.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* This mock is a combination of jest-matchmedia-mock
|
|
11
|
+
* https://github.com/dyakovk/jest-matchmedia-mock and
|
|
12
|
+
* mq-polyfill https://github.com/bigslycat/mq-polyfill.
|
|
13
|
+
*
|
|
14
|
+
* A solution which allowed resizing and a more realistic implementation of
|
|
15
|
+
* matchMedia was the reason for its creation. Neither project provided a good
|
|
16
|
+
* solution. Combining their strong points does. The class will listen for a
|
|
17
|
+
* resize event which is provided by a resizeTo function defined in the test:
|
|
18
|
+
*
|
|
19
|
+
* window.resizeTo = function resizeTo(width, height) {
|
|
20
|
+
* Object.assign(this, {
|
|
21
|
+
* innerWidth: width,
|
|
22
|
+
* innerHeight: height,
|
|
23
|
+
* outerWidth: width,
|
|
24
|
+
* outerHeight: height,
|
|
25
|
+
* }).dispatchEvent(new this.Event('resize'))
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* Listeners are only called if there has been a change in the match
|
|
29
|
+
* status for their media query.
|
|
30
|
+
*/
|
|
31
|
+
type MediaQueryListener = (this: MediaQueryList) => void;
|
|
32
|
+
interface MediaQueryList {
|
|
33
|
+
readonly matches: boolean;
|
|
34
|
+
readonly media: string;
|
|
35
|
+
onchange: MediaQueryListener | null;
|
|
36
|
+
addListener(listener: MediaQueryListener): void;
|
|
37
|
+
removeListener(listener: MediaQueryListener): void;
|
|
38
|
+
addEventListener(type: "change", listener: MediaQueryListener): void;
|
|
39
|
+
removeEventListener(type: "change", listener: MediaQueryListener): void;
|
|
40
|
+
dispatchEvent(event: Event): boolean;
|
|
41
|
+
}
|
|
42
|
+
export default class MatchMedia {
|
|
43
|
+
private mediaQueries;
|
|
44
|
+
private prevMatchMap;
|
|
45
|
+
private mediaQueryList;
|
|
46
|
+
constructor();
|
|
47
|
+
private compileQuery;
|
|
48
|
+
private evalQuery;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* Adds a listener function for the window resize event
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
private handleResize;
|
|
55
|
+
private addListener;
|
|
56
|
+
private removeListener;
|
|
57
|
+
/**
|
|
58
|
+
* Returns an array listing the media queries for which the matchMedia has registered listeners
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
getMediaQueries(): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Returns a copy of the array of listeners for the specified media query
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
getListeners(mediaQuery: string): MediaQueryListener[];
|
|
67
|
+
/**
|
|
68
|
+
* Clears all registered media queries and their listeners
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Clears all registered media queries and their listeners,
|
|
74
|
+
* and destroys the implementation of `window.matchMedia`
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
destroy(): void;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -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
|
-
|
|
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 */
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ChakraComponent } from "@chakra-ui/react";
|
|
1
|
+
import { ChakraComponent, LinkProps as ChakraLinkProps } from "@chakra-ui/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare const linkTypesArray: readonly ["action", "backwards", "button", "buttonPrimary", "buttonSecondary", "buttonPill", "buttonCallout", "buttonNoBrand", "buttonDisabled", "default", "external", "forwards", "standalone"];
|
|
4
4
|
export type LinkTypes = typeof linkTypesArray[number];
|
|
5
|
-
export interface LinkProps {
|
|
6
|
-
/** Any child node passed to the component. */
|
|
7
|
-
children: React.ReactNode;
|
|
5
|
+
export interface LinkProps extends ChakraLinkProps {
|
|
8
6
|
/** Additional class name to render in the `Link` component. */
|
|
9
7
|
className?: string;
|
|
10
8
|
/** Used to include or remove visited state styles. Default is true. */
|
|
@@ -28,8 +26,8 @@ export interface LinkProps {
|
|
|
28
26
|
type?: LinkTypes;
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
|
-
* A component that uses an `href` prop or a child anchor element, to
|
|
32
|
-
* an anchor element with added styling and conventions.
|
|
29
|
+
* A component that uses an `href` prop or a child anchor `<a>` element, to
|
|
30
|
+
* create an anchor element with added styling and conventions.
|
|
33
31
|
*/
|
|
34
32
|
export declare const Link: ChakraComponent<React.ForwardRefExoticComponent<React.PropsWithChildren<LinkProps> & React.RefAttributes<HTMLDivElement & HTMLAnchorElement>>, React.PropsWithChildren<LinkProps>>;
|
|
35
33
|
export default Link;
|
|
@@ -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,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface MultiSelectItemsCountButtonProps {
|
|
3
|
+
/** An ID string that other components can cross reference for accessibility purposes. */
|
|
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
|
+
selectedItemsString: string;
|
|
13
|
+
/** The number of selected items. */
|
|
14
|
+
selectedItemsCount: number;
|
|
15
|
+
/** The callback function for the menu toggle. */
|
|
16
|
+
onMenuToggle?: () => void;
|
|
17
|
+
/** The action to perform for clear/reset button of MultiSelect. */
|
|
18
|
+
onClear?: () => void;
|
|
19
|
+
/** The action to perform for key down event. */
|
|
20
|
+
onKeyDown?: () => void;
|
|
21
|
+
/** Ref to the Accordion Button element. */
|
|
22
|
+
accordianButtonRef: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The toggle button component used to open and close the `MultiSelect` menu.
|
|
26
|
+
* A second button is rendered above the main button that displays the current
|
|
27
|
+
* number of selected items. Clicking on the second button will clear all
|
|
28
|
+
* the selected items and the main button's close event will not be fired
|
|
29
|
+
* (as expected).
|
|
30
|
+
*/
|
|
31
|
+
declare const MultiSelectItemsCountButton: React.ForwardRefExoticComponent<MultiSelectItemsCountButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
export default MultiSelectItemsCountButton;
|
|
@@ -5,11 +5,11 @@ export interface TabsDataProps {
|
|
|
5
5
|
content: string | React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export interface TabsProps {
|
|
8
|
-
/** The index of the tab to display
|
|
8
|
+
/** The index of the tab to display on the initial render. */
|
|
9
9
|
defaultIndex?: number;
|
|
10
10
|
/** ID that other components can cross reference for accessibility purposes */
|
|
11
11
|
id?: string;
|
|
12
|
-
/** The callback function invoked
|
|
12
|
+
/** The callback function invoked after every tab change event. The argument passed to the callback is the index of the tab just selected. */
|
|
13
13
|
onChange?: (index: number) => any;
|
|
14
14
|
/** Array of data to display */
|
|
15
15
|
tabsData?: TabsDataProps[];
|
|
@@ -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
|
+
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Box, Center, Circle, ColorModeScript, cookieStorageManager, cookieStorageManagerSSR, Flex, Grid, GridItem, HStack, localStorageManager, Spacer, Square, Stack, useColorMode, useColorModeValue, VStack, } from "@chakra-ui/react";
|
|
1
|
+
export { Box, Center, Circle, ColorModeScript, cookieStorageManager, cookieStorageManagerSSR, FocusLock, Flex, Grid, GridItem, HStack, localStorageManager, Spacer, Square, Stack, useColorMode, useColorModeValue, useStyleConfig, useMultiStyleConfig, VStack, } from "@chakra-ui/react";
|
|
2
2
|
export { default as Accordion } from "./components/Accordion/Accordion";
|
|
3
3
|
export type { AccordionTypes } from "./components/Accordion/Accordion";
|
|
4
4
|
export { default as AlphabetFilter } from "./components/AlphabetFilter/AlphabetFilter";
|
|
@@ -40,11 +40,20 @@ export { default as List } from "./components/List/List";
|
|
|
40
40
|
export type { DescriptionProps, ListTypes } from "./components/List/List";
|
|
41
41
|
export { default as Logo } from "./components/Logo/Logo";
|
|
42
42
|
export type { LogoNames, LogoSizes } from "./components/Logo/Logo";
|
|
43
|
+
export { default as MatchMedia } from "../src/__tests__/mediaMatchMock";
|
|
43
44
|
export { default as Menu } from "./components/Menu/Menu";
|
|
44
45
|
export type { ListItemsData, ActionItem, GroupItem, DividerItem, } from "./components/Menu/Menu";
|
|
45
46
|
export { ModalTrigger, useModal } from "./components/Modal/Modal";
|
|
46
|
-
export { default as
|
|
47
|
-
export type {
|
|
47
|
+
export { default as MultiSelect } from "./components/MultiSelect/MultiSelect";
|
|
48
|
+
export type { MultiSelectItem, SelectedItems, } from "./components/MultiSelect/MultiSelect";
|
|
49
|
+
/** The code associated with the MultiSelectGroup component will not be exported
|
|
50
|
+
* until the refactor of the v2 version of the MultiSelectGroup component has
|
|
51
|
+
* been completed.
|
|
52
|
+
* */
|
|
53
|
+
/** The code associated with the NewsletterSignup component and the
|
|
54
|
+
* NewsletterSignupViewType type will not be exported until the refactor of the
|
|
55
|
+
* component has been completed.
|
|
56
|
+
* */
|
|
48
57
|
export { default as Notification } from "./components/Notification/Notification";
|
|
49
58
|
export type { NotificationTypes } from "./components/Notification/Notification";
|
|
50
59
|
export { default as Pagination } from "./components/Pagination/Pagination";
|
|
@@ -61,7 +70,9 @@ export { default as SkeletonLoader } from "./components/SkeletonLoader/SkeletonL
|
|
|
61
70
|
export type { SkeletonLoaderImageRatios } from "./components/SkeletonLoader/SkeletonLoader";
|
|
62
71
|
export { default as SkipNavigation } from "./components/SkipNavigation/SkipNavigation";
|
|
63
72
|
export { default as Slider } from "./components/Slider/Slider";
|
|
64
|
-
|
|
73
|
+
/** The code associated with the SocialMediaLinks component will not be exported
|
|
74
|
+
* until the refactor of the component has been completed.
|
|
75
|
+
* */
|
|
65
76
|
export { default as StatusBadge } from "./components/StatusBadge/StatusBadge";
|
|
66
77
|
export type { StatusBadgeTypes } from "./components/StatusBadge/StatusBadge";
|
|
67
78
|
export { default as StructuredContent } from "./components/StructuredContent/StructuredContent";
|
|
@@ -80,6 +91,10 @@ export { default as Toggle } from "./components/Toggle/Toggle";
|
|
|
80
91
|
export type { ToggleSizes } from "./components/Toggle/Toggle";
|
|
81
92
|
export { default as useCarouselStyles } from "./hooks/useCarouselStyles";
|
|
82
93
|
export { default as useCloseDropDown } from "./hooks/useCloseDropDown";
|
|
94
|
+
/** The useFilterBar hooks will not be exported until the refactor of the v2
|
|
95
|
+
* versions of the FilterBar component has been completed.
|
|
96
|
+
* */
|
|
97
|
+
export { default as useMultiSelect } from "./hooks/useMultiSelect";
|
|
83
98
|
export { default as useNYPLBreakpoints } from "./hooks/useNYPLBreakpoints";
|
|
84
99
|
export { default as useNYPLTheme } from "./hooks/useNYPLTheme";
|
|
85
100
|
export { default as useWindowSize } from "./hooks/useWindowSize";
|
|
@@ -39,10 +39,10 @@ declare const FeaturedContent: {
|
|
|
39
39
|
alignItems: string;
|
|
40
40
|
display: string;
|
|
41
41
|
flexDirection: {
|
|
42
|
-
|
|
42
|
+
base: "column-reverse";
|
|
43
43
|
md: "row-reverse";
|
|
44
44
|
} | {
|
|
45
|
-
|
|
45
|
+
base: "column";
|
|
46
46
|
md: "row";
|
|
47
47
|
};
|
|
48
48
|
maxWidth: string;
|
|
@@ -80,11 +80,11 @@ declare const FeaturedContent: {
|
|
|
80
80
|
backgroundPosition: string;
|
|
81
81
|
backgroundSize: string;
|
|
82
82
|
height: {
|
|
83
|
-
|
|
83
|
+
base: "320px";
|
|
84
84
|
md: "auto";
|
|
85
85
|
};
|
|
86
86
|
width: {
|
|
87
|
-
|
|
87
|
+
base: "100%";
|
|
88
88
|
md: string;
|
|
89
89
|
};
|
|
90
90
|
};
|