@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.
Files changed (110) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/component-type.json +1 -1
  3. package/dist/components/compacta/compacta.component.d.ts +1 -1
  4. package/dist/components/compacta/compacta.component.js +21 -1
  5. package/dist/components/compacta/compacta.types.d.ts +12 -0
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/index.js +1 -0
  8. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.d.ts +2 -0
  9. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.js +20 -0
  10. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.d.ts +37 -0
  11. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.js +8 -0
  12. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.d.ts +5 -0
  13. package/dist/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.js +1 -0
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.d.ts +2 -0
  21. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.js +62 -0
  22. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.d.ts +82 -0
  23. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.js +32 -0
  24. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.d.ts +8 -0
  25. package/dist/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.js +1 -0
  26. 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
  27. 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
  28. 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
  29. 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
  30. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.d.ts +2 -0
  31. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.js +35 -0
  32. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.d.ts +43 -0
  33. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.js +9 -0
  34. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.d.ts +5 -0
  35. package/dist/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.js +1 -0
  36. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.d.ts +2 -0
  37. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.js +118 -0
  38. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.d.ts +263 -0
  39. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.js +99 -0
  40. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.d.ts +15 -0
  41. package/dist/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.js +1 -0
  42. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.component.d.ts +2 -0
  43. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.component.js +52 -0
  44. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.styles.d.ts +31 -0
  45. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.styles.js +7 -0
  46. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.types.d.ts +6 -0
  47. package/dist/components/multi-select/components/multi-select-popover/multi-select-popover.types.js +1 -0
  48. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.d.ts +2 -0
  49. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.js +74 -0
  50. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.d.ts +31 -0
  51. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.js +7 -0
  52. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.d.ts +6 -0
  53. package/dist/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.js +1 -0
  54. package/dist/components/multi-select/index.d.ts +2 -0
  55. package/dist/components/multi-select/index.js +1 -0
  56. package/dist/components/multi-select/multi-select.component.d.ts +7 -0
  57. package/dist/components/multi-select/multi-select.component.js +95 -0
  58. package/dist/components/multi-select/multi-select.styles.d.ts +25 -0
  59. package/dist/components/multi-select/multi-select.styles.js +6 -0
  60. package/dist/components/multi-select/multi-select.types.d.ts +61 -0
  61. package/dist/components/multi-select/multi-select.types.js +1 -0
  62. package/dist/components/multi-select/utils/filter-nodes.d.ts +2 -0
  63. package/dist/components/multi-select/utils/filter-nodes.js +25 -0
  64. package/dist/components/tooltip/components/tooltip-content/tooltip-content.component.d.ts +1 -1
  65. package/dist/components/tooltip/components/tooltip-content/tooltip-content.component.js +4 -2
  66. package/dist/components/tooltip/components/tooltip-content/tooltip-content.styles.d.ts +16 -1
  67. package/dist/components/tooltip/components/tooltip-content/tooltip-content.styles.js +7 -1
  68. package/dist/components/tooltip/components/tooltip-content/tooltip-content.types.d.ts +1 -0
  69. package/dist/components/tooltip/tooltip.component.d.ts +1 -1
  70. package/dist/components/tooltip/tooltip.component.js +4 -3
  71. package/dist/components/tooltip/tooltip.types.d.ts +3 -0
  72. package/dist/css/westpac-ui.css +366 -0
  73. package/dist/css/westpac-ui.min.css +366 -0
  74. package/package.json +4 -1
  75. package/src/components/compacta/compacta.component.tsx +21 -0
  76. package/src/components/compacta/compacta.types.ts +10 -0
  77. package/src/components/index.ts +1 -0
  78. package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.component.tsx +26 -0
  79. package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.styles.ts +9 -0
  80. package/src/components/multi-select/components/multi-select-dropdown/multi-select-dropdown.types.ts +6 -0
  81. 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
  82. 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
  83. 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
  84. package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.component.tsx +66 -0
  85. package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.styles.ts +33 -0
  86. package/src/components/multi-select/components/multi-select-list-box/components/multi-select-option/multi-select-option.types.ts +7 -0
  87. 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
  88. 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
  89. package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.component.tsx +42 -0
  90. package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.styles.ts +10 -0
  91. package/src/components/multi-select/components/multi-select-list-box/multi-select-list-box.types.ts +6 -0
  92. package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.tsx +136 -0
  93. package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.styles.ts +74 -0
  94. package/src/components/multi-select/components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.ts +19 -0
  95. package/src/components/multi-select/components/multi-select-popover/multi-select-popover.component.tsx +64 -0
  96. package/src/components/multi-select/components/multi-select-popover/multi-select-popover.styles.ts +8 -0
  97. package/src/components/multi-select/components/multi-select-popover/multi-select-popover.types.ts +8 -0
  98. package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.component.tsx +81 -0
  99. package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.styles.ts +8 -0
  100. package/src/components/multi-select/components/multi-select-searchbar/multi-select-searchbar.types.ts +7 -0
  101. package/src/components/multi-select/index.ts +2 -0
  102. package/src/components/multi-select/multi-select.component.tsx +116 -0
  103. package/src/components/multi-select/multi-select.styles.ts +7 -0
  104. package/src/components/multi-select/multi-select.types.ts +60 -0
  105. package/src/components/multi-select/utils/filter-nodes.ts +29 -0
  106. package/src/components/tooltip/components/tooltip-content/tooltip-content.component.tsx +2 -2
  107. package/src/components/tooltip/components/tooltip-content/tooltip-content.styles.ts +6 -0
  108. package/src/components/tooltip/components/tooltip-content/tooltip-content.types.ts +1 -0
  109. package/src/components/tooltip/tooltip.component.tsx +7 -3
  110. 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
@@ -48,3 +48,4 @@ export * from './pass-code-view/index.js';
48
48
  export * from './progress-indicator/index.js';
49
49
  export * from './header/index.js';
50
50
  export * from './footer/index.js';
51
+ export * from './multi-select/index.js';
@@ -48,3 +48,4 @@ export * from './pass-code-view/index.js';
48
48
  export * from './progress-indicator/index.js';
49
49
  export * from './header/index.js';
50
50
  export * from './footer/index.js';
51
+ export * from './multi-select/index.js';
@@ -0,0 +1,2 @@
1
+ import { MultiSelectDropdownProps } from './multi-select-dropdown.types.js';
2
+ export declare function MultiSelectDropdown<T extends object = object>({ setFilterText, ...props }: MultiSelectDropdownProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -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>>;
@@ -0,0 +1,8 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ slots: {
4
+ popover: 'shadow',
5
+ searchInputWrapper: 'border-b border-b-border p-2',
6
+ clearButton: 'mb-0.5 px-2'
7
+ }
8
+ });
@@ -0,0 +1,5 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { AriaListBoxOptions } from 'react-aria';
3
+ export type MultiSelectDropdownProps<T> = {
4
+ setFilterText: Dispatch<SetStateAction<string>>;
5
+ } & AriaListBoxOptions<T>;
@@ -0,0 +1,2 @@
1
+ import type { MultiSelectSectionProps } from './multi-select-list-box-section.types.js';
2
+ export declare function MultiSelectListBoxSection<T>({ section }: MultiSelectSectionProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -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,6 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const styles = tv({
3
+ slots: {
4
+ span: 'typography-body-10 flex h-6 items-center bg-background px-2.5 py-1 align-middle text-hero'
5
+ }
6
+ });
@@ -0,0 +1,4 @@
1
+ import type { Node } from '@react-types/shared';
2
+ export type MultiSelectSectionProps<T> = {
3
+ section: Node<T>;
4
+ };
@@ -0,0 +1,2 @@
1
+ import { MultiSelectOptionProps } from './multi-select-option.types.js';
2
+ export declare function MultiSelectOption<T>({ item }: MultiSelectOptionProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -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,8 @@
1
+ import type { Node } from '@react-types/shared';
2
+ export type MultiSelectOptionProps<T> = {
3
+ item: Omit<Node<T>, 'props'> & {
4
+ props?: {
5
+ description?: string;
6
+ };
7
+ };
8
+ };
@@ -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,2 @@
1
+ import type { MultiSelectListBoxProps } from './multi-select-list-box.types.js';
2
+ export declare function MultiSelectListBox<T extends object = object>({ listBoxRef, ...props }: MultiSelectListBoxProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -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
+ }