@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useContext, useCallback } from 'react';
|
|
2
|
+
import { Button } from '../../../../components/button/index.js';
|
|
3
|
+
import { ClearIcon, SearchIcon } from '../../../../components/icon/index.js';
|
|
4
|
+
import { InputGroup } from '../../../../components/input-group/index.js';
|
|
5
|
+
import { Input } from '../../../input/index.js';
|
|
6
|
+
import { MultiSelectContext } from '../../multi-select.component.js';
|
|
7
|
+
import { styles as searchbarStyles } from './multi-select-searchbar.styles.js';
|
|
8
|
+
export function MultiSelectSearchbar({ filterText, setFilterText, closeBtnRef }) {
|
|
9
|
+
const { size, inputRef, selectAllRef, listBoxRef } = useContext(MultiSelectContext);
|
|
10
|
+
const styles = searchbarStyles();
|
|
11
|
+
const handleInputKeyDown = useCallback((e)=>{
|
|
12
|
+
if (e.key === 'ArrowDown') {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
if (selectAllRef.current) {
|
|
15
|
+
selectAllRef.current.focus();
|
|
16
|
+
} else {
|
|
17
|
+
var _listBoxRef_current;
|
|
18
|
+
const firstItem = (_listBoxRef_current = listBoxRef.current) === null || _listBoxRef_current === void 0 ? void 0 : _listBoxRef_current.querySelector('[data-key]');
|
|
19
|
+
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (e.key === 'Escape' && filterText.length > 0) {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
setFilterText('');
|
|
25
|
+
}
|
|
26
|
+
if (e.key === 'Tab' && filterText.length > 0) {
|
|
27
|
+
var _closeBtnRef_current;
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
(_closeBtnRef_current = closeBtnRef.current) === null || _closeBtnRef_current === void 0 ? void 0 : _closeBtnRef_current.focus();
|
|
31
|
+
}
|
|
32
|
+
}, [
|
|
33
|
+
filterText.length,
|
|
34
|
+
setFilterText,
|
|
35
|
+
selectAllRef,
|
|
36
|
+
listBoxRef,
|
|
37
|
+
closeBtnRef
|
|
38
|
+
]);
|
|
39
|
+
return React.createElement("div", {
|
|
40
|
+
className: styles.searchInputWrapper()
|
|
41
|
+
}, React.createElement(InputGroup, {
|
|
42
|
+
before: {
|
|
43
|
+
icon: (props)=>React.createElement(SearchIcon, {
|
|
44
|
+
...props,
|
|
45
|
+
color: "muted"
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
after: filterText.length > 0 && {
|
|
49
|
+
inset: true,
|
|
50
|
+
element: React.createElement(Button, {
|
|
51
|
+
onClick: ()=>{
|
|
52
|
+
var _inputRef_current;
|
|
53
|
+
setFilterText('');
|
|
54
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
55
|
+
},
|
|
56
|
+
look: "unstyled",
|
|
57
|
+
className: styles.clearButton(),
|
|
58
|
+
ref: closeBtnRef,
|
|
59
|
+
"aria-label": "Clear filter text"
|
|
60
|
+
}, React.createElement(ClearIcon, {
|
|
61
|
+
color: "muted",
|
|
62
|
+
size: "small"
|
|
63
|
+
}))
|
|
64
|
+
},
|
|
65
|
+
"aria-label": "Filter options"
|
|
66
|
+
}, React.createElement(Input, {
|
|
67
|
+
ref: inputRef,
|
|
68
|
+
size: size,
|
|
69
|
+
value: filterText,
|
|
70
|
+
onChange: (e)=>setFilterText(e.target.value),
|
|
71
|
+
onKeyDown: handleInputKeyDown,
|
|
72
|
+
tabIndex: -1
|
|
73
|
+
})));
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
4
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
5
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
[x: string]: {
|
|
10
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
11
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
12
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {}, {
|
|
16
|
+
searchInputWrapper: string;
|
|
17
|
+
clearButton: string;
|
|
18
|
+
}, undefined, TVConfig<V, EV>, {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
21
|
+
clearButton?: import("tailwind-variants").ClassValue;
|
|
22
|
+
searchInputWrapper?: import("tailwind-variants").ClassValue;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} | {}, {
|
|
26
|
+
searchInputWrapper: string;
|
|
27
|
+
clearButton: string;
|
|
28
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
29
|
+
searchInputWrapper: string;
|
|
30
|
+
clearButton: string;
|
|
31
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MultiSelect, MultiSelectItem, MultiSelectSection } from './multi-select.component.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MultiSelectContextProps, MultiSelectItemProps, MultiSelectProps, MultiSelectValue } from './multi-select.types.js';
|
|
3
|
+
export declare const MultiSelectContext: React.Context<MultiSelectContextProps>;
|
|
4
|
+
export declare function BaseMultiSelect<T extends MultiSelectValue = MultiSelectValue>({ size, listBoxProps, selectionMode, selectedKeys, onSelectionChange, placeholder, showSingleSectionTitle, placement, portalContainer, id, ...props }: MultiSelectProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const MultiSelect: React.MemoExoticComponent<typeof BaseMultiSelect>;
|
|
6
|
+
export declare const MultiSelectItem: (props: MultiSelectItemProps) => JSX.Element;
|
|
7
|
+
export { Section as MultiSelectSection } from 'react-stately';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useRef, useState, memo, createContext } from 'react';
|
|
3
|
+
import { useFilter, useOverlayTrigger } from 'react-aria';
|
|
4
|
+
import { Item, useListState, useOverlayTriggerState } from 'react-stately';
|
|
5
|
+
import { MultiSelectDropdown } from './components/multi-select-dropdown/multi-select-dropdown.component.js';
|
|
6
|
+
import { MultiSelectListBoxTrigger } from './components/multi-select-list-box-trigger/multi-select-list-box-trigger.component.js';
|
|
7
|
+
import { styles as multiSelectStyles } from './multi-select.styles.js';
|
|
8
|
+
import { filterNodes } from './utils/filter-nodes.js';
|
|
9
|
+
export const MultiSelectContext = createContext({
|
|
10
|
+
overlayState: {},
|
|
11
|
+
listState: {},
|
|
12
|
+
listBoxRef: {
|
|
13
|
+
current: null
|
|
14
|
+
},
|
|
15
|
+
buttonRef: {
|
|
16
|
+
current: null
|
|
17
|
+
},
|
|
18
|
+
popoverRef: {
|
|
19
|
+
current: null
|
|
20
|
+
},
|
|
21
|
+
selectAllRef: {
|
|
22
|
+
current: null
|
|
23
|
+
},
|
|
24
|
+
inputRef: {
|
|
25
|
+
current: null
|
|
26
|
+
},
|
|
27
|
+
filterText: '',
|
|
28
|
+
overlayProps: {}
|
|
29
|
+
});
|
|
30
|
+
export function BaseMultiSelect({ size = 'medium', listBoxProps, selectionMode = 'multiple', selectedKeys, onSelectionChange, placeholder = 'Select', showSingleSectionTitle = false, placement, portalContainer, id, ...props }) {
|
|
31
|
+
const [filterText, setFilterText] = useState('');
|
|
32
|
+
const filter = useFilter({
|
|
33
|
+
sensitivity: 'base'
|
|
34
|
+
});
|
|
35
|
+
const listState = useListState({
|
|
36
|
+
...props,
|
|
37
|
+
selectedKeys,
|
|
38
|
+
selectionMode,
|
|
39
|
+
onSelectionChange,
|
|
40
|
+
filter: (nodes)=>filterNodes(nodes, filterText, (value, string)=>filter.contains(value, string))
|
|
41
|
+
});
|
|
42
|
+
const inputRef = useRef(null);
|
|
43
|
+
const buttonRef = useRef(null);
|
|
44
|
+
const popoverRef = useRef(null);
|
|
45
|
+
const selectAllRef = useRef(null);
|
|
46
|
+
const listBoxRef = useRef(null);
|
|
47
|
+
const overlayState = useOverlayTriggerState({
|
|
48
|
+
onOpenChange: (isOpen)=>{
|
|
49
|
+
if (isOpen) {
|
|
50
|
+
requestAnimationFrame(()=>{
|
|
51
|
+
var _inputRef_current;
|
|
52
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!isOpen) {
|
|
56
|
+
var _buttonRef_current;
|
|
57
|
+
(_buttonRef_current = buttonRef.current) === null || _buttonRef_current === void 0 ? void 0 : _buttonRef_current.focus();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const { triggerProps, overlayProps } = useOverlayTrigger({
|
|
62
|
+
type: 'dialog'
|
|
63
|
+
}, overlayState, buttonRef);
|
|
64
|
+
const styles = multiSelectStyles({});
|
|
65
|
+
return React.createElement(MultiSelectContext.Provider, {
|
|
66
|
+
value: {
|
|
67
|
+
filterText,
|
|
68
|
+
size,
|
|
69
|
+
overlayState,
|
|
70
|
+
listState,
|
|
71
|
+
buttonRef,
|
|
72
|
+
popoverRef,
|
|
73
|
+
placement,
|
|
74
|
+
selectAllRef,
|
|
75
|
+
listBoxRef,
|
|
76
|
+
inputRef,
|
|
77
|
+
overlayProps,
|
|
78
|
+
portalContainer
|
|
79
|
+
}
|
|
80
|
+
}, React.createElement("div", {
|
|
81
|
+
className: styles.root()
|
|
82
|
+
}, React.createElement(MultiSelectListBoxTrigger, {
|
|
83
|
+
placeholder: placeholder,
|
|
84
|
+
selectedKeys: selectedKeys,
|
|
85
|
+
showSingleSectionTitle: showSingleSectionTitle,
|
|
86
|
+
triggerProps: triggerProps,
|
|
87
|
+
id: id
|
|
88
|
+
}), overlayState.isOpen && React.createElement(MultiSelectDropdown, {
|
|
89
|
+
setFilterText: setFilterText,
|
|
90
|
+
...listBoxProps
|
|
91
|
+
})));
|
|
92
|
+
}
|
|
93
|
+
export const MultiSelect = memo(BaseMultiSelect);
|
|
94
|
+
export const MultiSelectItem = Item;
|
|
95
|
+
export { Section as MultiSelectSection } from 'react-stately';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
4
|
+
root?: import("tailwind-variants").ClassValue;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
} | {
|
|
8
|
+
[x: string]: {
|
|
9
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
10
|
+
root?: import("tailwind-variants").ClassValue;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
} | {}, {
|
|
14
|
+
root: string;
|
|
15
|
+
}, undefined, TVConfig<V, EV>, {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
18
|
+
root?: import("tailwind-variants").ClassValue;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} | {}, {
|
|
22
|
+
root: string;
|
|
23
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
24
|
+
root: string;
|
|
25
|
+
}, undefined, TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DOMProps } from '@react-types/shared';
|
|
2
|
+
import { Key, ReactNode, RefObject } from 'react';
|
|
3
|
+
import { AriaListBoxOptions, AriaPopoverProps } from 'react-aria';
|
|
4
|
+
import { ItemProps, ListProps, ListState, OverlayTriggerState } from 'react-stately';
|
|
5
|
+
import { MultiSelectSize } from './components/multi-select-list-box-trigger/multi-select-list-box-trigger.types.js';
|
|
6
|
+
export type MultiSelectContextProps<T extends object = object> = {
|
|
7
|
+
size?: MultiSelectSize;
|
|
8
|
+
overlayState: OverlayTriggerState;
|
|
9
|
+
listState: ListState<T>;
|
|
10
|
+
buttonRef: RefObject<HTMLButtonElement>;
|
|
11
|
+
listBoxRef: RefObject<HTMLUListElement>;
|
|
12
|
+
popoverRef: RefObject<HTMLDivElement>;
|
|
13
|
+
selectAllRef: RefObject<HTMLInputElement>;
|
|
14
|
+
inputRef: RefObject<HTMLInputElement>;
|
|
15
|
+
filterText: string;
|
|
16
|
+
overlayProps: DOMProps;
|
|
17
|
+
placement?: AriaPopoverProps['placement'];
|
|
18
|
+
portalContainer?: Element;
|
|
19
|
+
};
|
|
20
|
+
export type MultiSelectItemProps<T extends object = object> = {
|
|
21
|
+
description?: string;
|
|
22
|
+
} & ItemProps<T>;
|
|
23
|
+
export type MultiSelectValue = {
|
|
24
|
+
textValue?: string;
|
|
25
|
+
content?: ReactNode;
|
|
26
|
+
key: Key;
|
|
27
|
+
description?: string;
|
|
28
|
+
};
|
|
29
|
+
export type MultiSelectProps<T> = {
|
|
30
|
+
/**
|
|
31
|
+
* Props for the list box within the multi-select
|
|
32
|
+
*/
|
|
33
|
+
listBoxProps?: Omit<AriaListBoxOptions<T>, 'state' | 'selectionMode'>;
|
|
34
|
+
/**
|
|
35
|
+
* id for the base multi-select container for accessibility/other uses
|
|
36
|
+
*/
|
|
37
|
+
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Placeholder text for the input
|
|
40
|
+
*/
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Manual placement of the dropdown, will flip automatically if there is not enough space
|
|
44
|
+
* @default bottom
|
|
45
|
+
*/
|
|
46
|
+
placement?: AriaPopoverProps['placement'];
|
|
47
|
+
/**
|
|
48
|
+
* Element where the popover will be rendered, by default it will be into the body
|
|
49
|
+
*/
|
|
50
|
+
portalContainer?: Element;
|
|
51
|
+
/**
|
|
52
|
+
* Whether to show the section for the selected option in the field i.e. "Transaction: Savings" rather than "Savings"
|
|
53
|
+
* NOTE: Only works with single selectionMode multi-selects
|
|
54
|
+
*/
|
|
55
|
+
showSingleSectionTitle?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Size of input
|
|
58
|
+
* @default medium
|
|
59
|
+
*/
|
|
60
|
+
size?: MultiSelectSize;
|
|
61
|
+
} & ListProps<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function filterNodes(nodes, filterText, contains) {
|
|
2
|
+
if (!filterText) return nodes;
|
|
3
|
+
const arr = Array.from(nodes);
|
|
4
|
+
return arr.flatMap((node)=>{
|
|
5
|
+
if (node.type !== 'section') {
|
|
6
|
+
var _node_textValue;
|
|
7
|
+
return contains((_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '', filterText) ? [
|
|
8
|
+
node
|
|
9
|
+
] : [];
|
|
10
|
+
}
|
|
11
|
+
const childNodesArr = Array.from(node.childNodes || []);
|
|
12
|
+
const matchedChildren = childNodesArr.filter((child)=>{
|
|
13
|
+
var _child_textValue;
|
|
14
|
+
return contains((_child_textValue = child.textValue) !== null && _child_textValue !== void 0 ? _child_textValue : '', filterText);
|
|
15
|
+
});
|
|
16
|
+
if (matchedChildren.length === 0) return [];
|
|
17
|
+
const sectionWithMatches = {
|
|
18
|
+
...node,
|
|
19
|
+
childNodes: matchedChildren
|
|
20
|
+
};
|
|
21
|
+
return [
|
|
22
|
+
sectionWithMatches
|
|
23
|
+
];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TooltipContentProps } from './tooltip-content.types.js';
|
|
2
|
-
export declare function TooltipContent({ children, id }: TooltipContentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
export declare function TooltipContent({ children, id, position }: TooltipContentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { styles } from './tooltip-content.styles.js';
|
|
3
|
-
export function TooltipContent({ children, id }) {
|
|
3
|
+
export function TooltipContent({ children, id, position }) {
|
|
4
4
|
return children ? React.createElement("span", {
|
|
5
|
-
className: styles(
|
|
5
|
+
className: styles({
|
|
6
|
+
position
|
|
7
|
+
}),
|
|
6
8
|
role: "tooltip",
|
|
7
9
|
id: id
|
|
8
10
|
}, children) : null;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
position: {
|
|
3
|
+
top: string;
|
|
4
|
+
bottom: string;
|
|
5
|
+
};
|
|
6
|
+
}, undefined, "absolute left-1 top-full z-10 mt-2 whitespace-nowrap rounded-sm border border-border bg-background p-0.5 text-text", TVConfig<V, EV>, {
|
|
7
|
+
position: {
|
|
8
|
+
top: string;
|
|
9
|
+
bottom: string;
|
|
10
|
+
};
|
|
11
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
12
|
+
position: {
|
|
13
|
+
top: string;
|
|
14
|
+
bottom: string;
|
|
15
|
+
};
|
|
16
|
+
}, undefined, "absolute left-1 top-full z-10 mt-2 whitespace-nowrap rounded-sm border border-border bg-background p-0.5 text-text", TVConfig<V, EV>, unknown, unknown, undefined>>;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const styles = tv({
|
|
3
|
-
base: 'absolute left-1 top-full z-10 mt-2 whitespace-nowrap rounded-sm border border-border bg-background p-0.5 text-text'
|
|
3
|
+
base: 'absolute left-1 top-full z-10 mt-2 whitespace-nowrap rounded-sm border border-border bg-background p-0.5 text-text',
|
|
4
|
+
variants: {
|
|
5
|
+
position: {
|
|
6
|
+
top: 'top-auto bottom-full',
|
|
7
|
+
bottom: 'top-full mt-2 mb-0'
|
|
8
|
+
}
|
|
9
|
+
}
|
|
4
10
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TooltipProps } from './tooltip.types.js';
|
|
2
|
-
export declare function Tooltip({ children, tooltip, id, className }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Tooltip({ children, disabled, tooltip, id, className, position }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
|
3
3
|
import { mergeProps, useHover, useFocusRing } from 'react-aria';
|
|
4
4
|
import { TooltipContent } from './components/tooltip-content/tooltip-content.component.js';
|
|
5
5
|
import { styles } from './tooltip.styles.js';
|
|
6
|
-
export function Tooltip({ children, tooltip, id, className }) {
|
|
6
|
+
export function Tooltip({ children, disabled, tooltip, id, className, position = 'bottom' }) {
|
|
7
7
|
const localId = useId();
|
|
8
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
9
9
|
const tooltipWaitTime = useRef(null);
|
|
@@ -27,7 +27,7 @@ export function Tooltip({ children, tooltip, id, className }) {
|
|
|
27
27
|
}
|
|
28
28
|
}, []);
|
|
29
29
|
useEffect(()=>{
|
|
30
|
-
setIsOpen(isFocusVisible);
|
|
30
|
+
setIsOpen(isFocusVisible && !disabled);
|
|
31
31
|
}, [
|
|
32
32
|
isFocusVisible
|
|
33
33
|
]);
|
|
@@ -50,6 +50,7 @@ export function Tooltip({ children, tooltip, id, className }) {
|
|
|
50
50
|
className
|
|
51
51
|
})
|
|
52
52
|
}, children, isOpen && React.createElement(TooltipContent, {
|
|
53
|
-
id: id !== null && id !== void 0 ? id : localId
|
|
53
|
+
id: id !== null && id !== void 0 ? id : localId,
|
|
54
|
+
position: position
|
|
54
55
|
}, tooltip));
|
|
55
56
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { TooltipContentProps } from './components/tooltip-content/tooltip-content.types.js';
|
|
2
3
|
export type TooltipProps = {
|
|
3
4
|
children: ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
4
6
|
tooltip: string;
|
|
5
7
|
id?: string;
|
|
6
8
|
className?: string;
|
|
9
|
+
position?: TooltipContentProps['position'];
|
|
7
10
|
};
|