@westpac/ui 0.57.4 → 0.59.0
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/CHANGELOG.md +12 -0
- package/dist/component-type.json +1 -1
- package/dist/components/compacta/compacta.component.d.ts +1 -1
- package/dist/components/compacta/compacta.component.js +21 -1
- package/dist/components/compacta/compacta.types.d.ts +12 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.js +20 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.d.ts +37 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.js +8 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.d.ts +5 -0
- package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.component.js +31 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.styles.d.ts +25 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.styles.js +6 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.types.d.ts +4 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.js +62 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.d.ts +82 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.js +32 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.d.ts +8 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.component.d.ts +1 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.component.js +93 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.styles.d.ts +64 -0
- package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.styles.js +26 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.js +35 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.d.ts +43 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.js +9 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.d.ts +5 -0
- package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.js +118 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.d.ts +263 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.js +99 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.d.ts +15 -0
- package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.component.js +52 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.styles.d.ts +31 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.styles.js +7 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.types.d.ts +6 -0
- package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.types.js +1 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.d.ts +2 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.js +74 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.d.ts +31 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.js +7 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.d.ts +6 -0
- package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.js +1 -0
- package/dist/components/multi-select/index.d.ts +2 -0
- package/dist/components/multi-select/index.js +1 -0
- package/dist/components/multi-select/multi-select.component.d.ts +7 -0
- package/dist/components/multi-select/multi-select.component.js +95 -0
- package/dist/components/multi-select/multi-select.styles.d.ts +25 -0
- package/dist/components/multi-select/multi-select.styles.js +6 -0
- package/dist/components/multi-select/multi-select.types.d.ts +61 -0
- package/dist/components/multi-select/multi-select.types.js +1 -0
- package/dist/components/multi-select/utils/filter-nodes.d.ts +2 -0
- package/dist/components/multi-select/utils/filter-nodes.js +25 -0
- package/dist/components/tooltip/components/tooltip-content/tooltip-content.component.d.ts +1 -1
- package/dist/components/tooltip/components/tooltip-content/tooltip-content.component.js +4 -2
- package/dist/components/tooltip/components/tooltip-content/tooltip-content.styles.d.ts +16 -1
- package/dist/components/tooltip/components/tooltip-content/tooltip-content.styles.js +7 -1
- package/dist/components/tooltip/components/tooltip-content/tooltip-content.types.d.ts +1 -0
- package/dist/components/tooltip/tooltip.component.d.ts +1 -1
- package/dist/components/tooltip/tooltip.component.js +4 -3
- package/dist/components/tooltip/tooltip.types.d.ts +3 -0
- package/dist/css/westpac-ui.css +366 -0
- package/dist/css/westpac-ui.min.css +366 -0
- package/package.json +4 -1
- package/src/components/compacta/compacta.component.tsx +21 -0
- package/src/components/compacta/compacta.types.ts +10 -0
- package/src/components/index.ts +1 -0
- package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.tsx +26 -0
- package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.ts +9 -0
- package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.ts +6 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.component.tsx +42 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.styles.ts +7 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-list-box-section/multi-select-list-box-section.types.ts +5 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.tsx +66 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.ts +33 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.ts +7 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.component.tsx +105 -0
- package/src/components/multi-select/components/multi-select-list-box/components/multi-select-select-all-option/multi-select-select-all-option.styles.ts +22 -0
- package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.tsx +42 -0
- package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.ts +10 -0
- package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.ts +6 -0
- package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.tsx +136 -0
- package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.ts +74 -0
- package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.ts +19 -0
- package/src/components/multi-select/components/multi-select-popover/multi-select-popover.component.tsx +64 -0
- package/src/components/multi-select/components/multi-select-popover/multi-select-popover.styles.ts +8 -0
- package/src/components/multi-select/components/multi-select-popover/multi-select-popover.types.ts +8 -0
- package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.tsx +81 -0
- package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.ts +8 -0
- package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.ts +7 -0
- package/src/components/multi-select/index.ts +2 -0
- package/src/components/multi-select/multi-select.component.tsx +116 -0
- package/src/components/multi-select/multi-select.styles.ts +7 -0
- package/src/components/multi-select/multi-select.types.ts +60 -0
- package/src/components/multi-select/utils/filter-nodes.ts +29 -0
- package/src/components/tooltip/components/tooltip-content/tooltip-content.component.tsx +2 -2
- package/src/components/tooltip/components/tooltip-content/tooltip-content.styles.ts +6 -0
- package/src/components/tooltip/components/tooltip-content/tooltip-content.types.ts +1 -0
- package/src/components/tooltip/tooltip.component.tsx +7 -3
- package/src/components/tooltip/tooltip.types.ts +4 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type CompactaProps } from './compacta.types.js';
|
|
2
|
-
export declare function Compacta({ className, children, titleTag: Tag, addText, ...props }: CompactaProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Compacta({ className, children, titleTag: Tag, addText, initialCompactas, ...props }: CompactaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ import { AddCircleIcon, ExpandLessIcon, ExpandMoreIcon, RemoveCircleIcon } from
|
|
|
7
7
|
import { VisuallyHidden } from '../index.js';
|
|
8
8
|
import { styles as compactaStyles } from './compacta.styles.js';
|
|
9
9
|
const loadAnimations = ()=>import('./compacta.utils.js').then((res)=>res.default);
|
|
10
|
-
export function Compacta({ className, children, titleTag: Tag = 'h3', addText = 'Add another', ...props }) {
|
|
10
|
+
export function Compacta({ className, children, titleTag: Tag = 'h3', addText = 'Add another', initialCompactas, ...props }) {
|
|
11
11
|
const [initial, setInitial] = useState(true);
|
|
12
12
|
const id = useId();
|
|
13
13
|
const [items, setItems] = useState([
|
|
@@ -129,6 +129,26 @@ export function Compacta({ className, children, titleTag: Tag = 'h3', addText =
|
|
|
129
129
|
items.length,
|
|
130
130
|
action
|
|
131
131
|
]);
|
|
132
|
+
useEffect(()=>{
|
|
133
|
+
if (initialCompactas) {
|
|
134
|
+
const newItems = initialCompactas.map((item, index)=>{
|
|
135
|
+
var _item_id, _ref, _ref1, _ref2;
|
|
136
|
+
var _item_title, _item_title1, _item_title2;
|
|
137
|
+
const itemId = (_item_id = item.id) !== null && _item_id !== void 0 ? _item_id : `${id}-${generateID()}`;
|
|
138
|
+
return {
|
|
139
|
+
id: itemId,
|
|
140
|
+
open: index === initialCompactas.length - 1 ? true : false,
|
|
141
|
+
delay: false,
|
|
142
|
+
title: {
|
|
143
|
+
primary: (_ref = (_item_title = item.title) === null || _item_title === void 0 ? void 0 : _item_title.primary) !== null && _ref !== void 0 ? _ref : '',
|
|
144
|
+
secondary: (_ref1 = (_item_title1 = item.title) === null || _item_title1 === void 0 ? void 0 : _item_title1.secondary) !== null && _ref1 !== void 0 ? _ref1 : '',
|
|
145
|
+
tertiary: (_ref2 = (_item_title2 = item.title) === null || _item_title2 === void 0 ? void 0 : _item_title2.tertiary) !== null && _ref2 !== void 0 ? _ref2 : ''
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
setItems(newItems);
|
|
150
|
+
}
|
|
151
|
+
}, []);
|
|
132
152
|
const styles = compactaStyles({});
|
|
133
153
|
return React.createElement("div", {
|
|
134
154
|
className: styles.base({
|
|
@@ -8,6 +8,18 @@ export type CompactaProps = {
|
|
|
8
8
|
* Component to repeat
|
|
9
9
|
*/
|
|
10
10
|
children: (...props: ContentProps[]) => ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The initial compactas to render. Each compacta needs a unique id if you want to pre-fill values.
|
|
13
|
+
* Each object contained within the array represents a compacta.
|
|
14
|
+
*/
|
|
15
|
+
initialCompactas?: {
|
|
16
|
+
id?: string;
|
|
17
|
+
title?: {
|
|
18
|
+
primary?: string;
|
|
19
|
+
secondary?: string;
|
|
20
|
+
tertiary?: string;
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
11
23
|
/**
|
|
12
24
|
* Tag for primary title
|
|
13
25
|
* @default h3
|
package/dist/components/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useContext, useRef } from 'react';
|
|
3
|
+
import { MultiSelectListBox } from '../../components/multi-select-list-box/multi-select-list-box.component.js';
|
|
4
|
+
import { MultiSelectContext } from '../../multi-select.component.js';
|
|
5
|
+
import { MultiSelectPopover } from '../multi-select-popover/multi-select-popover.component.js';
|
|
6
|
+
import { MultiSelectSearchbar } from '../multi-select-searchbar/multi-select-searchbar.component.js';
|
|
7
|
+
export function MultiSelectDropdown({ setFilterText, ...props }) {
|
|
8
|
+
const { filterText, listBoxRef } = useContext(MultiSelectContext);
|
|
9
|
+
const closeBtnRef = useRef(null);
|
|
10
|
+
return React.createElement(MultiSelectPopover, null, React.createElement(MultiSelectSearchbar, {
|
|
11
|
+
filterText: filterText,
|
|
12
|
+
setFilterText: setFilterText,
|
|
13
|
+
closeBtnRef: closeBtnRef
|
|
14
|
+
}), React.createElement(MultiSelectListBox, {
|
|
15
|
+
...props,
|
|
16
|
+
"aria-label": "multiselect list",
|
|
17
|
+
escapeKeyBehavior: "none",
|
|
18
|
+
listBoxRef: listBoxRef
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
4
|
+
popover?: import("tailwind-variants").ClassValue;
|
|
5
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
6
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
} | {
|
|
10
|
+
[x: string]: {
|
|
11
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
12
|
+
popover?: import("tailwind-variants").ClassValue;
|
|
13
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
14
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
} | {}, {
|
|
18
|
+
popover: string;
|
|
19
|
+
searchInputWrapper: string;
|
|
20
|
+
clearButton: string;
|
|
21
|
+
}, undefined, TVConfig<V, EV>, {
|
|
22
|
+
[key: string]: {
|
|
23
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
24
|
+
popover?: import("tailwind-variants").ClassValue;
|
|
25
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
26
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
} | {}, {
|
|
30
|
+
popover: string;
|
|
31
|
+
searchInputWrapper: string;
|
|
32
|
+
clearButton: string;
|
|
33
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
34
|
+
popover: string;
|
|
35
|
+
searchInputWrapper: string;
|
|
36
|
+
clearButton: string;
|
|
37
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
|
+
import { useListBoxSection } from 'react-aria';
|
|
4
|
+
import { MultiSelectContext } from '../../../../multi-select.component.js';
|
|
5
|
+
import { MultiSelectOption } from '../multi-select-option/multi-select-option.component.js';
|
|
6
|
+
import { styles as listBoxStyles } from './multi-select-list-box-section.styles.js';
|
|
7
|
+
export function MultiSelectListBoxSection({ section }) {
|
|
8
|
+
const { listState } = useContext(MultiSelectContext);
|
|
9
|
+
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
10
|
+
heading: section.rendered,
|
|
11
|
+
'aria-label': section['aria-label']
|
|
12
|
+
});
|
|
13
|
+
const styles = listBoxStyles();
|
|
14
|
+
const childNodes = useMemo(()=>{
|
|
15
|
+
var _listState_collection;
|
|
16
|
+
return (listState === null || listState === void 0 ? void 0 : (_listState_collection = listState.collection) === null || _listState_collection === void 0 ? void 0 : _listState_collection.getChildren) ? [
|
|
17
|
+
...listState.collection.getChildren(section.key)
|
|
18
|
+
] : [];
|
|
19
|
+
}, [
|
|
20
|
+
section.key,
|
|
21
|
+
listState === null || listState === void 0 ? void 0 : listState.collection
|
|
22
|
+
]);
|
|
23
|
+
return React.createElement(React.Fragment, null, React.createElement("li", itemProps, section.rendered && React.createElement("span", {
|
|
24
|
+
...headingProps,
|
|
25
|
+
className: styles.span(),
|
|
26
|
+
tabIndex: -1
|
|
27
|
+
}, section.rendered), React.createElement("ul", groupProps, childNodes.map((node)=>React.createElement(MultiSelectOption, {
|
|
28
|
+
key: node.key,
|
|
29
|
+
item: node
|
|
30
|
+
})))));
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
4
|
+
span?: import("tailwind-variants").ClassValue;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
} | {
|
|
8
|
+
[x: string]: {
|
|
9
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
10
|
+
span?: import("tailwind-variants").ClassValue;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
} | {}, {
|
|
14
|
+
span: string;
|
|
15
|
+
}, undefined, TVConfig<V, EV>, {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
18
|
+
span?: import("tailwind-variants").ClassValue;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} | {}, {
|
|
22
|
+
span: string;
|
|
23
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
24
|
+
span: string;
|
|
25
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useCallback, useContext, useRef } from 'react';
|
|
3
|
+
import { mergeProps, useFocusRing, useOption } from 'react-aria';
|
|
4
|
+
import { TickIcon } from '../../../../../icon/index.js';
|
|
5
|
+
import { MultiSelectContext } from '../../../../multi-select.component.js';
|
|
6
|
+
import { styles as optionStyles } from './multi-select-option.styles.js';
|
|
7
|
+
export function MultiSelectOption({ item }) {
|
|
8
|
+
var _item_props;
|
|
9
|
+
const { listState, selectAllRef, inputRef } = useContext(MultiSelectContext);
|
|
10
|
+
const selectionMode = listState.selectionManager.selectionMode;
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const { optionProps, isDisabled, isSelected } = useOption({
|
|
13
|
+
key: item.key
|
|
14
|
+
}, listState, ref);
|
|
15
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
16
|
+
const styles = optionStyles({
|
|
17
|
+
disabled: isDisabled,
|
|
18
|
+
selectionMode,
|
|
19
|
+
isFocusVisible
|
|
20
|
+
});
|
|
21
|
+
const handleButtonKeyDown = useCallback((e)=>{
|
|
22
|
+
if (e.key === 'ArrowUp' && item.index === 0) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
if (selectAllRef.current) {
|
|
25
|
+
var _selectAllRef_current;
|
|
26
|
+
(_selectAllRef_current = selectAllRef.current) === null || _selectAllRef_current === void 0 ? void 0 : _selectAllRef_current.focus();
|
|
27
|
+
} else {
|
|
28
|
+
var _inputRef_current;
|
|
29
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
listState.selectionManager.toggleSelection(item.key);
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
listState.selectionManager
|
|
38
|
+
]);
|
|
39
|
+
return React.createElement("li", {
|
|
40
|
+
...mergeProps(optionProps, focusProps),
|
|
41
|
+
ref: ref,
|
|
42
|
+
className: styles.root(),
|
|
43
|
+
onKeyDown: handleButtonKeyDown,
|
|
44
|
+
"aria-checked": selectionMode === 'multiple' ? isSelected : undefined,
|
|
45
|
+
"aria-selected": selectionMode === 'single' ? isSelected : undefined,
|
|
46
|
+
tabIndex: 0
|
|
47
|
+
}, React.createElement("div", {
|
|
48
|
+
className: styles.itemContainer()
|
|
49
|
+
}, React.createElement("div", {
|
|
50
|
+
className: styles.flexZero()
|
|
51
|
+
}, React.createElement("div", {
|
|
52
|
+
className: styles.checkbox()
|
|
53
|
+
}, isSelected && React.createElement(TickIcon, {
|
|
54
|
+
size: "small",
|
|
55
|
+
"aria-hidden": "true",
|
|
56
|
+
color: "hero"
|
|
57
|
+
}))), React.createElement("div", {
|
|
58
|
+
className: styles.body()
|
|
59
|
+
}, item.rendered)), ((_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.description) && React.createElement("div", {
|
|
60
|
+
className: styles.description()
|
|
61
|
+
}, item.props.description));
|
|
62
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
selectionMode: {
|
|
3
|
+
none: {};
|
|
4
|
+
multiple: {
|
|
5
|
+
checkbox: string;
|
|
6
|
+
};
|
|
7
|
+
single: {
|
|
8
|
+
checkbox: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
isFocusVisible: {
|
|
12
|
+
true: {
|
|
13
|
+
root: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
disabled: {
|
|
17
|
+
true: {
|
|
18
|
+
root: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}, {
|
|
22
|
+
root: string;
|
|
23
|
+
checkbox: string;
|
|
24
|
+
body: string;
|
|
25
|
+
flexZero: string;
|
|
26
|
+
itemContainer: string;
|
|
27
|
+
description: string;
|
|
28
|
+
}, undefined, TVConfig<V, EV>, {
|
|
29
|
+
selectionMode: {
|
|
30
|
+
none: {};
|
|
31
|
+
multiple: {
|
|
32
|
+
checkbox: string;
|
|
33
|
+
};
|
|
34
|
+
single: {
|
|
35
|
+
checkbox: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
isFocusVisible: {
|
|
39
|
+
true: {
|
|
40
|
+
root: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
disabled: {
|
|
44
|
+
true: {
|
|
45
|
+
root: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
root: string;
|
|
50
|
+
checkbox: string;
|
|
51
|
+
body: string;
|
|
52
|
+
flexZero: string;
|
|
53
|
+
itemContainer: string;
|
|
54
|
+
description: string;
|
|
55
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
56
|
+
selectionMode: {
|
|
57
|
+
none: {};
|
|
58
|
+
multiple: {
|
|
59
|
+
checkbox: string;
|
|
60
|
+
};
|
|
61
|
+
single: {
|
|
62
|
+
checkbox: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
isFocusVisible: {
|
|
66
|
+
true: {
|
|
67
|
+
root: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
disabled: {
|
|
71
|
+
true: {
|
|
72
|
+
root: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}, {
|
|
76
|
+
root: string;
|
|
77
|
+
checkbox: string;
|
|
78
|
+
body: string;
|
|
79
|
+
flexZero: string;
|
|
80
|
+
itemContainer: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
root: 'flex cursor-pointer flex-col justify-between bg-white p-2 text-sm text-text transition-[background-color] hover:bg-background',
|
|
5
|
+
checkbox: 'size-4',
|
|
6
|
+
body: 'typography-body-9 -mt-0.5 flex flex-1 items-center',
|
|
7
|
+
flexZero: 'flex-none',
|
|
8
|
+
itemContainer: 'flex gap-1',
|
|
9
|
+
description: 'typography-body-10 relative ml-5 text-muted'
|
|
10
|
+
},
|
|
11
|
+
variants: {
|
|
12
|
+
selectionMode: {
|
|
13
|
+
none: {},
|
|
14
|
+
multiple: {
|
|
15
|
+
checkbox: 'flex items-center justify-center rounded border border-hero bg-white'
|
|
16
|
+
},
|
|
17
|
+
single: {
|
|
18
|
+
checkbox: 'flex items-center justify-center'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
isFocusVisible: {
|
|
22
|
+
true: {
|
|
23
|
+
root: 'bg-background !outline-offset-[-2px] focus-outline'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
disabled: {
|
|
27
|
+
true: {
|
|
28
|
+
root: 'cursor-not-allowed text-muted'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MultiSelectSelectAllOption(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useCallback, useContext, useMemo } from 'react';
|
|
3
|
+
import { useOption, useFocusRing, mergeProps } from 'react-aria';
|
|
4
|
+
import { TickIcon } from '../../../../../icon/index.js';
|
|
5
|
+
import { MultiSelectContext } from '../../../../multi-select.component.js';
|
|
6
|
+
import { styles as selectAllOptionStyles } from './multi-select-select-all-option.styles.js';
|
|
7
|
+
export function MultiSelectSelectAllOption() {
|
|
8
|
+
const { listState, selectAllRef, listBoxRef, inputRef } = useContext(MultiSelectContext);
|
|
9
|
+
const allItemsAreSelected = useMemo(()=>listState.selectionManager.isSelectAll, [
|
|
10
|
+
listState.selectionManager.isSelectAll
|
|
11
|
+
]);
|
|
12
|
+
const withOneSelectionOrMore = useMemo(()=>!![
|
|
13
|
+
...listState.selectionManager.selectedKeys
|
|
14
|
+
].length, [
|
|
15
|
+
listState.selectionManager.selectedKeys
|
|
16
|
+
]);
|
|
17
|
+
const handleSelectionChange = useCallback(()=>{
|
|
18
|
+
if (!allItemsAreSelected) {
|
|
19
|
+
listState.selectionManager.setSelectedKeys(new Set([
|
|
20
|
+
...listState.selectionManager.selectedKeys,
|
|
21
|
+
...listState.selectionManager.collection.getKeys()
|
|
22
|
+
]));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return listState.selectionManager.clearSelection();
|
|
26
|
+
}, [
|
|
27
|
+
allItemsAreSelected,
|
|
28
|
+
listState.selectionManager
|
|
29
|
+
]);
|
|
30
|
+
const { optionProps } = useOption({
|
|
31
|
+
key: 'select-all'
|
|
32
|
+
}, listState, selectAllRef);
|
|
33
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
34
|
+
const styles = selectAllOptionStyles({
|
|
35
|
+
selected: withOneSelectionOrMore,
|
|
36
|
+
isFocusVisible
|
|
37
|
+
});
|
|
38
|
+
const handleInputKeyDown = useCallback((e)=>{
|
|
39
|
+
if (e.key === 'ArrowDown') {
|
|
40
|
+
var _listBoxRef_current;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
const firstItem = (_listBoxRef_current = listBoxRef.current) === null || _listBoxRef_current === void 0 ? void 0 : _listBoxRef_current.querySelector('[data-key]');
|
|
43
|
+
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
|
44
|
+
}
|
|
45
|
+
if (e.key === 'ArrowUp') {
|
|
46
|
+
var _inputRef_current;
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
49
|
+
}
|
|
50
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
handleSelectionChange();
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
handleSelectionChange,
|
|
56
|
+
listBoxRef,
|
|
57
|
+
inputRef
|
|
58
|
+
]);
|
|
59
|
+
let ariaChecked;
|
|
60
|
+
if (allItemsAreSelected) {
|
|
61
|
+
ariaChecked = 'true';
|
|
62
|
+
} else if (withOneSelectionOrMore) {
|
|
63
|
+
ariaChecked = 'mixed';
|
|
64
|
+
} else {
|
|
65
|
+
ariaChecked = 'false';
|
|
66
|
+
}
|
|
67
|
+
return React.createElement("div", {
|
|
68
|
+
className: styles.listItem(),
|
|
69
|
+
key: "select-all",
|
|
70
|
+
...mergeProps(optionProps, focusProps),
|
|
71
|
+
ref: selectAllRef,
|
|
72
|
+
onClick: handleSelectionChange,
|
|
73
|
+
onKeyDown: (e)=>{
|
|
74
|
+
handleInputKeyDown(e);
|
|
75
|
+
},
|
|
76
|
+
role: "option",
|
|
77
|
+
"aria-checked": ariaChecked,
|
|
78
|
+
"aria-label": "Select all options"
|
|
79
|
+
}, React.createElement("div", {
|
|
80
|
+
className: styles.button()
|
|
81
|
+
}, React.createElement("div", {
|
|
82
|
+
className: styles.checkbox(),
|
|
83
|
+
role: "presentation"
|
|
84
|
+
}, allItemsAreSelected && React.createElement(TickIcon, {
|
|
85
|
+
size: "small",
|
|
86
|
+
"aria-hidden": "true",
|
|
87
|
+
color: "hero"
|
|
88
|
+
}), !allItemsAreSelected && withOneSelectionOrMore && React.createElement("div", {
|
|
89
|
+
className: styles.indeterminate()
|
|
90
|
+
})), React.createElement("span", {
|
|
91
|
+
className: styles.label()
|
|
92
|
+
}, "Select all")));
|
|
93
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
selected: {
|
|
3
|
+
true: {
|
|
4
|
+
listItem: string;
|
|
5
|
+
};
|
|
6
|
+
false: {
|
|
7
|
+
listItem: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
isFocusVisible: {
|
|
11
|
+
true: {
|
|
12
|
+
listItem: string;
|
|
13
|
+
};
|
|
14
|
+
false: {};
|
|
15
|
+
};
|
|
16
|
+
}, {
|
|
17
|
+
listItem: string;
|
|
18
|
+
button: string;
|
|
19
|
+
checkbox: string;
|
|
20
|
+
indeterminate: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}, undefined, TVConfig<V, EV>, {
|
|
23
|
+
selected: {
|
|
24
|
+
true: {
|
|
25
|
+
listItem: string;
|
|
26
|
+
};
|
|
27
|
+
false: {
|
|
28
|
+
listItem: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
isFocusVisible: {
|
|
32
|
+
true: {
|
|
33
|
+
listItem: string;
|
|
34
|
+
};
|
|
35
|
+
false: {};
|
|
36
|
+
};
|
|
37
|
+
}, {
|
|
38
|
+
listItem: string;
|
|
39
|
+
button: string;
|
|
40
|
+
checkbox: string;
|
|
41
|
+
indeterminate: string;
|
|
42
|
+
label: string;
|
|
43
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
44
|
+
selected: {
|
|
45
|
+
true: {
|
|
46
|
+
listItem: string;
|
|
47
|
+
};
|
|
48
|
+
false: {
|
|
49
|
+
listItem: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
isFocusVisible: {
|
|
53
|
+
true: {
|
|
54
|
+
listItem: string;
|
|
55
|
+
};
|
|
56
|
+
false: {};
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
listItem: string;
|
|
60
|
+
button: string;
|
|
61
|
+
checkbox: string;
|
|
62
|
+
indeterminate: string;
|
|
63
|
+
label: string;
|
|
64
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
listItem: 'border-b border-b-border hover:bg-background',
|
|
5
|
+
button: 'flex w-full cursor-pointer items-center gap-1 p-2 focus-visible:bg-background focus-visible:outline-2 focus-visible:!outline-offset-[-2px] focus-visible:focus-outline',
|
|
6
|
+
checkbox: 'flex size-4 items-center justify-center rounded border border-hero bg-white',
|
|
7
|
+
indeterminate: 'block w-3/5 border-t-2 border-t-hero',
|
|
8
|
+
label: 'typography-body-9'
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
selected: {
|
|
12
|
+
true: {
|
|
13
|
+
listItem: 'bg-background'
|
|
14
|
+
},
|
|
15
|
+
false: {
|
|
16
|
+
listItem: ''
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
isFocusVisible: {
|
|
20
|
+
true: {
|
|
21
|
+
listItem: 'bg-background !outline-offset-[-2px] focus-outline'
|
|
22
|
+
},
|
|
23
|
+
false: {}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { useListBox } from 'react-aria';
|
|
4
|
+
import { MultiSelectContext } from '../../multi-select.component.js';
|
|
5
|
+
import { MultiSelectListBoxSection } from './components/multi-select-list-box-section/multi-select-list-box-section.component.js';
|
|
6
|
+
import { MultiSelectOption } from './components/multi-select-option/multi-select-option.component.js';
|
|
7
|
+
import { MultiSelectSelectAllOption } from './components/multi-select-select-all-option/multi-select-select-all-option.component.js';
|
|
8
|
+
import { styles as listBoxStyles } from './multi-select-list-box.styles.js';
|
|
9
|
+
export function MultiSelectListBox({ listBoxRef, ...props }) {
|
|
10
|
+
const { listState } = useContext(MultiSelectContext);
|
|
11
|
+
const selectionMode = listState.selectionManager.selectionMode;
|
|
12
|
+
const { listBoxProps } = useListBox({
|
|
13
|
+
selectionMode,
|
|
14
|
+
...props
|
|
15
|
+
}, listState, listBoxRef);
|
|
16
|
+
const stateCollection = [
|
|
17
|
+
...listState.collection
|
|
18
|
+
];
|
|
19
|
+
const styles = listBoxStyles();
|
|
20
|
+
return React.createElement("div", {
|
|
21
|
+
className: styles.container()
|
|
22
|
+
}, selectionMode === 'multiple' && stateCollection.length > 0 && React.createElement(MultiSelectSelectAllOption, null), React.createElement("ul", {
|
|
23
|
+
...listBoxProps,
|
|
24
|
+
ref: listBoxRef,
|
|
25
|
+
className: styles.ul()
|
|
26
|
+
}, stateCollection.length > 0 ? stateCollection.map((item)=>item.type === 'section' ? React.createElement(MultiSelectListBoxSection, {
|
|
27
|
+
key: item.key,
|
|
28
|
+
section: item
|
|
29
|
+
}) : React.createElement(MultiSelectOption, {
|
|
30
|
+
key: item.key,
|
|
31
|
+
item: item
|
|
32
|
+
})) : React.createElement("p", {
|
|
33
|
+
className: styles.noItemsText()
|
|
34
|
+
}, "No results. Try another search.")));
|
|
35
|
+
}
|