@deephaven/components 1.19.1-console-types-fixes.0 → 1.21.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/dist/shortcuts/GlobalShortcuts.js +2 -2
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBox.d.ts +1 -1
- package/dist/spectrum/index.d.ts +1 -0
- package/dist/spectrum/index.d.ts.map +1 -1
- package/dist/spectrum/index.js +1 -0
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/listView/ListView.d.ts +1 -1
- package/dist/spectrum/listView/ListView.d.ts.map +1 -1
- package/dist/spectrum/listView/ListView.js.map +1 -1
- package/dist/spectrum/multiSelect/MultiSelect.css +326 -0
- package/dist/spectrum/multiSelect/MultiSelect.css.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelect.d.ts +7 -0
- package/dist/spectrum/multiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelect.js +445 -0
- package/dist/spectrum/multiSelect/MultiSelect.js.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectListBox.d.ts +29 -0
- package/dist/spectrum/multiSelect/MultiSelectListBox.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectListBox.js +41 -0
- package/dist/spectrum/multiSelect/MultiSelectListBox.js.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectNormalized.d.ts +8 -0
- package/dist/spectrum/multiSelect/MultiSelectNormalized.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectNormalized.js +37 -0
- package/dist/spectrum/multiSelect/MultiSelectNormalized.js.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectProps.d.ts +121 -0
- package/dist/spectrum/multiSelect/MultiSelectProps.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectProps.js +2 -0
- package/dist/spectrum/multiSelect/MultiSelectProps.js.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectTag.d.ts +14 -0
- package/dist/spectrum/multiSelect/MultiSelectTag.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/MultiSelectTag.js +36 -0
- package/dist/spectrum/multiSelect/MultiSelectTag.js.map +1 -0
- package/dist/spectrum/multiSelect/index.d.ts +4 -0
- package/dist/spectrum/multiSelect/index.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/index.js +4 -0
- package/dist/spectrum/multiSelect/index.js.map +1 -0
- package/dist/spectrum/multiSelect/multiSelectUtils.d.ts +53 -0
- package/dist/spectrum/multiSelect/multiSelectUtils.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/multiSelectUtils.js +166 -0
- package/dist/spectrum/multiSelect/multiSelectUtils.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectFilter.d.ts +27 -0
- package/dist/spectrum/multiSelect/useMultiSelectFilter.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectFilter.js +51 -0
- package/dist/spectrum/multiSelect/useMultiSelectFilter.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectKeyboard.d.ts +40 -0
- package/dist/spectrum/multiSelect/useMultiSelectKeyboard.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectKeyboard.js +200 -0
- package/dist/spectrum/multiSelect/useMultiSelectKeyboard.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectLoadingSpinner.d.ts +11 -0
- package/dist/spectrum/multiSelect/useMultiSelectLoadingSpinner.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectLoadingSpinner.js +44 -0
- package/dist/spectrum/multiSelect/useMultiSelectLoadingSpinner.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectNormalizedProps.d.ts +21 -0
- package/dist/spectrum/multiSelect/useMultiSelectNormalizedProps.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectNormalizedProps.js +83 -0
- package/dist/spectrum/multiSelect/useMultiSelectNormalizedProps.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectScrollListener.d.ts +17 -0
- package/dist/spectrum/multiSelect/useMultiSelectScrollListener.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectScrollListener.js +55 -0
- package/dist/spectrum/multiSelect/useMultiSelectScrollListener.js.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectState.d.ts +26 -0
- package/dist/spectrum/multiSelect/useMultiSelectState.d.ts.map +1 -0
- package/dist/spectrum/multiSelect/useMultiSelectState.js +67 -0
- package/dist/spectrum/multiSelect/useMultiSelectState.js.map +1 -0
- package/dist/spectrum/picker/Picker.d.ts +1 -1
- package/dist/spectrum/picker/PickerProps.d.ts +1 -1
- package/dist/spectrum/picker/PickerProps.d.ts.map +1 -1
- package/dist/spectrum/picker/PickerProps.js.map +1 -1
- package/dist/spectrum/picker/usePickerProps.js +1 -1
- package/dist/spectrum/picker/usePickerProps.js.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.d.ts +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.js +3 -0
- package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.js +12 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -1
- package/package.json +15 -8
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var _excluded = ["UNSAFE_className"],
|
|
2
|
+
_excluded2 = ["forceRerenderKey", "children"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
import cl from 'classnames';
|
|
11
|
+
import { MultiSelect } from "./MultiSelect.js";
|
|
12
|
+
import { useMultiSelectNormalizedProps } from "./useMultiSelectNormalizedProps.js";
|
|
13
|
+
/**
|
|
14
|
+
* MultiSelect that takes an array of `NormalizedItem` or `NormalizedSection` items as children.
|
|
15
|
+
* Handles converting selection keys and uses `useRenderNormalizedItem` to render items.
|
|
16
|
+
*/
|
|
17
|
+
import { createElement as _createElement } from "react";
|
|
18
|
+
export function MultiSelectNormalized(_ref) {
|
|
19
|
+
var {
|
|
20
|
+
UNSAFE_className
|
|
21
|
+
} = _ref,
|
|
22
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
var _useMultiSelectNormal = useMultiSelectNormalizedProps(props),
|
|
24
|
+
{
|
|
25
|
+
forceRerenderKey,
|
|
26
|
+
children
|
|
27
|
+
} = _useMultiSelectNormal,
|
|
28
|
+
multiSelectProps = _objectWithoutProperties(_useMultiSelectNormal, _excluded2);
|
|
29
|
+
return /*#__PURE__*/_createElement(MultiSelect
|
|
30
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
31
|
+
, _objectSpread(_objectSpread({}, multiSelectProps), {}, {
|
|
32
|
+
key: forceRerenderKey,
|
|
33
|
+
UNSAFE_className: cl('dh-multi-select-normalized', UNSAFE_className)
|
|
34
|
+
}), children);
|
|
35
|
+
}
|
|
36
|
+
export default MultiSelectNormalized;
|
|
37
|
+
//# sourceMappingURL=MultiSelectNormalized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelectNormalized.js","names":["cl","MultiSelect","useMultiSelectNormalizedProps","createElement","_createElement","MultiSelectNormalized","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_useMultiSelectNormal","forceRerenderKey","children","multiSelectProps","_excluded2","_objectSpread","key"],"sources":["../../../src/spectrum/multiSelect/MultiSelectNormalized.tsx"],"sourcesContent":["import cl from 'classnames';\nimport { MultiSelect } from './MultiSelect';\nimport { type MultiSelectNormalizedProps } from './MultiSelectProps';\nimport { useMultiSelectNormalizedProps } from './useMultiSelectNormalizedProps';\n\n/**\n * MultiSelect that takes an array of `NormalizedItem` or `NormalizedSection` items as children.\n * Handles converting selection keys and uses `useRenderNormalizedItem` to render items.\n */\nexport function MultiSelectNormalized({\n UNSAFE_className,\n ...props\n}: MultiSelectNormalizedProps): JSX.Element {\n const { forceRerenderKey, children, ...multiSelectProps } =\n useMultiSelectNormalizedProps(props);\n\n return (\n <MultiSelect\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...multiSelectProps}\n key={forceRerenderKey}\n UNSAFE_className={cl('dh-multi-select-normalized', UNSAFE_className)}\n >\n {children}\n </MultiSelect>\n );\n}\n\nexport default MultiSelectNormalized;\n"],"mappings":";;;;;;;;;AAAA,OAAOA,EAAE,MAAM,YAAY;AAAC,SACnBC,WAAW;AAAA,SAEXC,6BAA6B;AAEtC;AACA;AACA;AACA;AAHA,SAAAC,aAAA,IAAAC,cAAA;AAIA,OAAO,SAASC,qBAAqBA,CAAAC,IAAA,EAGO;EAAA,IAHN;MACpCC;IAE0B,CAAC,GAAAD,IAAA;IADxBE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,qBAAA,GACET,6BAA6B,CAACM,KAAK,CAAC;IADhC;MAAEI,gBAAgB;MAAEC;IAA8B,CAAC,GAAAF,qBAAA;IAAlBG,gBAAgB,GAAAL,wBAAA,CAAAE,qBAAA,EAAAI,UAAA;EAGvD,oBACEX,cAAA,CAACH;EACC;EAAA,EAAAe,aAAA,CAAAA,aAAA,KACIF,gBAAgB;IACpBG,GAAG,EAAEL,gBAAiB;IACtBL,gBAAgB,EAAEP,EAAE,CAAC,4BAA4B,EAAEO,gBAAgB;EAAE,IAEpEM,QACU,CAAC;AAElB;AAEA,eAAeR,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { FocusEvent, KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import type { AriaLabelingProps, LoadingState, StyleProps, ValidationState } from '@react-types/shared';
|
|
3
|
+
import type { MenuTriggerAction } from '../comboBox';
|
|
4
|
+
import type { ItemOrSection, MultipleItemSelectionProps, NormalizedItem, NormalizedSection, TooltipOptions } from '../utils';
|
|
5
|
+
/**
|
|
6
|
+
* Public props for the `@deephaven/components` `MultiSelect`.
|
|
7
|
+
*
|
|
8
|
+
* The MultiSelect is a hand-built composite (custom popover + search input +
|
|
9
|
+
* tag row + ListBox), not a thin wrapper around a Spectrum collection
|
|
10
|
+
* component. As such it owns its own prop surface rather than extending a
|
|
11
|
+
* Spectrum type. Reuse `StyleProps`, `AriaLabelingProps`, `ValidationState`,
|
|
12
|
+
* and `LoadingState` from `@react-types/shared` to stay consistent with the
|
|
13
|
+
* Spectrum vocabulary.
|
|
14
|
+
*
|
|
15
|
+
* Children follow the same shape as `PickerProps.children`: declarative
|
|
16
|
+
* `Item` / `Section` JSX (no render-function `items` pattern).
|
|
17
|
+
*/
|
|
18
|
+
export interface MultiSelectProps extends StyleProps, AriaLabelingProps, MultipleItemSelectionProps {
|
|
19
|
+
/** Item or Section elements to render in the dropdown. */
|
|
20
|
+
children?: ItemOrSection | ItemOrSection[] | null | undefined;
|
|
21
|
+
/** Can be set to true or a TooltipOptions to enable item tooltips. */
|
|
22
|
+
tooltip?: boolean | TooltipOptions;
|
|
23
|
+
/** The content to display as the field label. */
|
|
24
|
+
label?: ReactNode;
|
|
25
|
+
/** A description for the field. */
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
/** An error message for the field. */
|
|
28
|
+
errorMessage?: ReactNode;
|
|
29
|
+
/** Whether user input is required on the field before form submission. */
|
|
30
|
+
isRequired?: boolean;
|
|
31
|
+
/** Whether the input is disabled. */
|
|
32
|
+
isDisabled?: boolean;
|
|
33
|
+
/** Whether the input can be selected but not changed by the user. */
|
|
34
|
+
isReadOnly?: boolean;
|
|
35
|
+
/** Whether the input should display its "valid" or "invalid" visual styling. */
|
|
36
|
+
validationState?: ValidationState;
|
|
37
|
+
/** Whether the MultiSelect should be displayed with a quiet style. */
|
|
38
|
+
isQuiet?: boolean;
|
|
39
|
+
/** The label's overall position relative to the element it is labeling. */
|
|
40
|
+
labelPosition?: 'top' | 'side';
|
|
41
|
+
/** The label's horizontal alignment relative to the element it is labeling. */
|
|
42
|
+
labelAlign?: 'start' | 'end';
|
|
43
|
+
/** Whether the required state should be shown as an icon or text. */
|
|
44
|
+
necessityIndicator?: 'icon' | 'label';
|
|
45
|
+
/** A ContextualHelp element to place next to the label. */
|
|
46
|
+
contextualHelp?: ReactNode;
|
|
47
|
+
/** Controlled value of the search input. */
|
|
48
|
+
inputValue?: string;
|
|
49
|
+
/** Default (uncontrolled) value of the search input. */
|
|
50
|
+
defaultInputValue?: string;
|
|
51
|
+
/** Handler called when the search input value changes. */
|
|
52
|
+
onInputChange?: (value: string) => void;
|
|
53
|
+
/** Whether keyboard navigation is circular. */
|
|
54
|
+
shouldFocusWrap?: boolean;
|
|
55
|
+
/** The current loading state of the items. */
|
|
56
|
+
loadingState?: LoadingState;
|
|
57
|
+
/** The interaction required to display the menu. */
|
|
58
|
+
menuTrigger?: 'focus' | 'input' | 'manual';
|
|
59
|
+
/** Alignment of the menu relative to the input target. */
|
|
60
|
+
align?: 'start' | 'end';
|
|
61
|
+
/** Direction the menu will render relative to the input. */
|
|
62
|
+
direction?: 'bottom' | 'top';
|
|
63
|
+
/** Whether the menu should automatically flip direction when there isn't enough space. */
|
|
64
|
+
shouldFlip?: boolean;
|
|
65
|
+
/** Width of the menu. */
|
|
66
|
+
menuWidth?: string | number;
|
|
67
|
+
/** Whether the MultiSelect allows a non-item matching input value to be selected. */
|
|
68
|
+
allowsCustomValue?: boolean;
|
|
69
|
+
/** Whether the form value of the field is the selected key(s) or text(s). */
|
|
70
|
+
formValue?: 'key' | 'text';
|
|
71
|
+
/** Whether to use native HTML form validation, ARIA validation, or both. */
|
|
72
|
+
validationBehavior?: 'native' | 'aria';
|
|
73
|
+
/** Whether the element should receive focus on render. */
|
|
74
|
+
autoFocus?: boolean;
|
|
75
|
+
/** The name of the input element, used when submitting an HTML form. */
|
|
76
|
+
name?: string;
|
|
77
|
+
/** The element's unique identifier. */
|
|
78
|
+
id?: string;
|
|
79
|
+
/** Whether the field is hidden. */
|
|
80
|
+
isHidden?: boolean;
|
|
81
|
+
/** Handler called when the input receives focus. */
|
|
82
|
+
onFocus?: (e: FocusEvent) => void;
|
|
83
|
+
/** Handler called when the input loses focus. */
|
|
84
|
+
onBlur?: (e: FocusEvent) => void;
|
|
85
|
+
/** Handler called when the focus state changes. */
|
|
86
|
+
onFocusChange?: (isFocused: boolean) => void;
|
|
87
|
+
/** Handler called when a key is pressed. */
|
|
88
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
89
|
+
/** Handler called when a key is released. */
|
|
90
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Method that is called when the open state of the menu changes. The
|
|
93
|
+
* `menuTrigger` argument indicates the action that caused the change
|
|
94
|
+
* (`undefined` on close).
|
|
95
|
+
*/
|
|
96
|
+
onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void;
|
|
97
|
+
/** Handler called when the dropdown list is scrolled. */
|
|
98
|
+
onScroll?: (event: Event) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Handler called when search text changes. When provided, client-side
|
|
101
|
+
* filtering is skipped (server-side filtering is assumed by the consumer).
|
|
102
|
+
*/
|
|
103
|
+
onSearchTextChange?: (text: string) => void;
|
|
104
|
+
/**
|
|
105
|
+
* External label map for selected items whose data may not be present in
|
|
106
|
+
* `children` (e.g. filtered out by server-side search). Used as a fallback
|
|
107
|
+
* when rendering tags.
|
|
108
|
+
*/
|
|
109
|
+
selectedItemLabels?: Map<string, string>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Props consumed by `MultiSelectNormalized`. Built on top of `MultiSelectProps`
|
|
113
|
+
* so adding a prop to the base type automatically surfaces it on the
|
|
114
|
+
* normalized variant. Replaces declarative JSX `children` with a flat
|
|
115
|
+
* normalized item list (used by table-backed flows in `@deephaven/jsapi-components`).
|
|
116
|
+
*/
|
|
117
|
+
export type MultiSelectNormalizedProps = Omit<MultiSelectProps, 'children'> & {
|
|
118
|
+
normalizedItems: (NormalizedItem | NormalizedSection)[];
|
|
119
|
+
showItemIcons: boolean;
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=MultiSelectProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelectProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/multiSelect/MultiSelectProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,0BAA0B,EAC1B,cAAc,EACd,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBACf,SAAQ,UAAU,EAChB,iBAAiB,EACjB,0BAA0B;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9D,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,iDAAiD;IACjD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,mCAAmC;IACnC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,sCAAsC;IACtC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC/B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAA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M,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACjC,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,4CAA4C;IAC5C,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACvC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAErC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE1E,yDAAyD;IACzD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAC5E,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelectProps.js","names":[],"sources":["../../../src/spectrum/multiSelect/MultiSelectProps.ts"],"sourcesContent":["import type { FocusEvent, KeyboardEvent, ReactNode } from 'react';\nimport type {\n AriaLabelingProps,\n LoadingState,\n StyleProps,\n ValidationState,\n} from '@react-types/shared';\nimport type { MenuTriggerAction } from '../comboBox';\nimport type {\n ItemOrSection,\n MultipleItemSelectionProps,\n NormalizedItem,\n NormalizedSection,\n TooltipOptions,\n} from '../utils';\n\n/**\n * Public props for the `@deephaven/components` `MultiSelect`.\n *\n * The MultiSelect is a hand-built composite (custom popover + search input +\n * tag row + ListBox), not a thin wrapper around a Spectrum collection\n * component. As such it owns its own prop surface rather than extending a\n * Spectrum type. Reuse `StyleProps`, `AriaLabelingProps`, `ValidationState`,\n * and `LoadingState` from `@react-types/shared` to stay consistent with the\n * Spectrum vocabulary.\n *\n * Children follow the same shape as `PickerProps.children`: declarative\n * `Item` / `Section` JSX (no render-function `items` pattern).\n */\nexport interface MultiSelectProps\n extends StyleProps,\n AriaLabelingProps,\n MultipleItemSelectionProps {\n /** Item or Section elements to render in the dropdown. */\n children?: ItemOrSection | ItemOrSection[] | null | undefined;\n /** Can be set to true or a TooltipOptions to enable item tooltips. */\n tooltip?: boolean | TooltipOptions;\n /** The content to display as the field label. */\n label?: ReactNode;\n /** A description for the field. */\n description?: ReactNode;\n /** An error message for the field. */\n errorMessage?: ReactNode;\n /** Whether user input is required on the field before form submission. */\n isRequired?: boolean;\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n /** Whether the input should display its \"valid\" or \"invalid\" visual styling. */\n validationState?: ValidationState;\n /** Whether the MultiSelect should be displayed with a quiet style. */\n isQuiet?: boolean;\n /** The label's overall position relative to the element it is labeling. */\n labelPosition?: 'top' | 'side';\n /** The label's horizontal alignment relative to the element it is labeling. */\n labelAlign?: 'start' | 'end';\n /** Whether the required state should be shown as an icon or text. */\n necessityIndicator?: 'icon' | 'label';\n /** A ContextualHelp element to place next to the label. */\n contextualHelp?: ReactNode;\n\n /** Controlled value of the search input. */\n inputValue?: string;\n /** Default (uncontrolled) value of the search input. */\n defaultInputValue?: string;\n /** Handler called when the search input value changes. */\n onInputChange?: (value: string) => void;\n\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n /** The current loading state of the items. */\n loadingState?: LoadingState;\n /** The interaction required to display the menu. */\n menuTrigger?: 'focus' | 'input' | 'manual';\n /** Alignment of the menu relative to the input target. */\n align?: 'start' | 'end';\n /** Direction the menu will render relative to the input. */\n direction?: 'bottom' | 'top';\n /** Whether the menu should automatically flip direction when there isn't enough space. */\n shouldFlip?: boolean;\n /** Width of the menu. */\n menuWidth?: string | number;\n /** Whether the MultiSelect allows a non-item matching input value to be selected. */\n allowsCustomValue?: boolean;\n /** Whether the form value of the field is the selected key(s) or text(s). */\n formValue?: 'key' | 'text';\n /** Whether to use native HTML form validation, ARIA validation, or both. */\n validationBehavior?: 'native' | 'aria';\n /** Whether the element should receive focus on render. */\n autoFocus?: boolean;\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n /** The element's unique identifier. */\n id?: string;\n /** Whether the field is hidden. */\n isHidden?: boolean;\n /** Handler called when the input receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler called when the input loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler called when the focus state changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Handler called when a key is pressed. */\n onKeyDown?: (e: KeyboardEvent) => void;\n /** Handler called when a key is released. */\n onKeyUp?: (e: KeyboardEvent) => void;\n\n /**\n * Method that is called when the open state of the menu changes. The\n * `menuTrigger` argument indicates the action that caused the change\n * (`undefined` on close).\n */\n onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void;\n\n /** Handler called when the dropdown list is scrolled. */\n onScroll?: (event: Event) => void;\n\n /**\n * Handler called when search text changes. When provided, client-side\n * filtering is skipped (server-side filtering is assumed by the consumer).\n */\n onSearchTextChange?: (text: string) => void;\n\n /**\n * External label map for selected items whose data may not be present in\n * `children` (e.g. filtered out by server-side search). Used as a fallback\n * when rendering tags.\n */\n selectedItemLabels?: Map<string, string>;\n}\n\n/**\n * Props consumed by `MultiSelectNormalized`. Built on top of `MultiSelectProps`\n * so adding a prop to the base type automatically surfaces it on the\n * normalized variant. Replaces declarative JSX `children` with a flat\n * normalized item list (used by table-backed flows in `@deephaven/jsapi-components`).\n */\nexport type MultiSelectNormalizedProps = Omit<MultiSelectProps, 'children'> & {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n showItemIcons: boolean;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface MultiSelectTagProps {
|
|
2
|
+
tagKey: string;
|
|
3
|
+
label: string;
|
|
4
|
+
isDisabled: boolean;
|
|
5
|
+
isReadOnly: boolean;
|
|
6
|
+
onRemove: (key: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A tag rendered inside the `MultiSelect` trigger area.
|
|
10
|
+
* Private subcomponent of `MultiSelect`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function MultiSelectTag({ tagKey, label, isDisabled, isReadOnly, onRemove, }: MultiSelectTagProps): JSX.Element;
|
|
13
|
+
export default MultiSelectTag;
|
|
14
|
+
//# sourceMappingURL=MultiSelectTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelectTag.d.ts","sourceRoot":"","sources":["../../../src/spectrum/multiSelect/MultiSelectTag.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAqBnC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import CrossSmall from '@spectrum-icons/ui/CrossSmall';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* A tag rendered inside the `MultiSelect` trigger area.
|
|
5
|
+
* Private subcomponent of `MultiSelect`.
|
|
6
|
+
*/
|
|
7
|
+
export function MultiSelectTag(_ref) {
|
|
8
|
+
var {
|
|
9
|
+
tagKey,
|
|
10
|
+
label,
|
|
11
|
+
isDisabled,
|
|
12
|
+
isReadOnly,
|
|
13
|
+
onRemove
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
16
|
+
className: "dh-multi-select-tag",
|
|
17
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
18
|
+
className: "dh-multi-select-tag-label",
|
|
19
|
+
children: label
|
|
20
|
+
}), !isDisabled && !isReadOnly && /*#__PURE__*/_jsx("button", {
|
|
21
|
+
type: "button",
|
|
22
|
+
className: "dh-multi-select-tag-remove",
|
|
23
|
+
tabIndex: -1,
|
|
24
|
+
"aria-label": "Remove ".concat(label)
|
|
25
|
+
// Prevent the search input from losing focus when the user clicks the tag's remove
|
|
26
|
+
// button. `onPointerDown` fires before the input's blur, so suppressing its default
|
|
27
|
+
// keeps focus on the input.
|
|
28
|
+
,
|
|
29
|
+
onPointerDown: e => e.preventDefault(),
|
|
30
|
+
onClick: () => onRemove(tagKey),
|
|
31
|
+
children: /*#__PURE__*/_jsx(CrossSmall, {})
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export default MultiSelectTag;
|
|
36
|
+
//# sourceMappingURL=MultiSelectTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelectTag.js","names":["CrossSmall","jsx","_jsx","jsxs","_jsxs","MultiSelectTag","_ref","tagKey","label","isDisabled","isReadOnly","onRemove","className","children","type","tabIndex","concat","onPointerDown","e","preventDefault","onClick"],"sources":["../../../src/spectrum/multiSelect/MultiSelectTag.tsx"],"sourcesContent":["import CrossSmall from '@spectrum-icons/ui/CrossSmall';\n\nexport interface MultiSelectTagProps {\n tagKey: string;\n label: string;\n isDisabled: boolean;\n isReadOnly: boolean;\n onRemove: (key: string) => void;\n}\n\n/**\n * A tag rendered inside the `MultiSelect` trigger area.\n * Private subcomponent of `MultiSelect`.\n */\nexport function MultiSelectTag({\n tagKey,\n label,\n isDisabled,\n isReadOnly,\n onRemove,\n}: MultiSelectTagProps): JSX.Element {\n return (\n <span className=\"dh-multi-select-tag\">\n <span className=\"dh-multi-select-tag-label\">{label}</span>\n {!isDisabled && !isReadOnly && (\n <button\n type=\"button\"\n className=\"dh-multi-select-tag-remove\"\n tabIndex={-1}\n aria-label={`Remove ${label}`}\n // Prevent the search input from losing focus when the user clicks the tag's remove\n // button. `onPointerDown` fires before the input's blur, so suppressing its default\n // keeps focus on the input.\n onPointerDown={e => e.preventDefault()}\n onClick={() => onRemove(tagKey)}\n >\n <CrossSmall />\n </button>\n )}\n </span>\n );\n}\n\nexport default MultiSelectTag;\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,+BAA+B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAUvD;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAAC,IAAA,EAMO;EAAA,IANN;IAC7BC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,UAAU;IACVC;EACmB,CAAC,GAAAL,IAAA;EACpB,oBACEF,KAAA;IAAMQ,SAAS,EAAC,qBAAqB;IAAAC,QAAA,gBACnCX,IAAA;MAAMU,SAAS,EAAC,2BAA2B;MAAAC,QAAA,EAAEL;IAAK,CAAO,CAAC,EACzD,CAACC,UAAU,IAAI,CAACC,UAAU,iBACzBR,IAAA;MACEY,IAAI,EAAC,QAAQ;MACbF,SAAS,EAAC,4BAA4B;MACtCG,QAAQ,EAAE,CAAC,CAAE;MACb,wBAAAC,MAAA,CAAsBR,KAAK;MAC3B;MACA;MACA;MAAA;MACAS,aAAa,EAAEC,CAAC,IAAIA,CAAC,CAACC,cAAc,CAAC,CAAE;MACvCC,OAAO,EAAEA,CAAA,KAAMT,QAAQ,CAACJ,MAAM,CAAE;MAAAM,QAAA,eAEhCX,IAAA,CAACF,UAAU,IAAE;IAAC,CACR,CACT;EAAA,CACG,CAAC;AAEX;AAEA,eAAeK,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/multiSelect/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/multiSelect/index.ts"],"sourcesContent":["export * from './MultiSelect';\nexport * from './MultiSelectNormalized';\nexport * from './MultiSelectProps';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { type ItemKey } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Flat shape used internally by the `MultiSelect` keyboard / filter / state
|
|
5
|
+
* hooks. Not part of the public API.
|
|
6
|
+
*/
|
|
7
|
+
export interface MultiSelectFlatItem {
|
|
8
|
+
kind: 'item';
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Section-preserving shape used internally for client-side filtering. Not
|
|
14
|
+
* part of the public API.
|
|
15
|
+
*/
|
|
16
|
+
export interface MultiSelectFlatSection {
|
|
17
|
+
kind: 'section';
|
|
18
|
+
key: string;
|
|
19
|
+
title: ReactNode;
|
|
20
|
+
items: MultiSelectFlatItem[];
|
|
21
|
+
}
|
|
22
|
+
export type MultiSelectFlatEntry = MultiSelectFlatItem | MultiSelectFlatSection;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard that checks whether a flat entry is a section.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isFlatSection(entry: MultiSelectFlatEntry): entry is MultiSelectFlatSection;
|
|
27
|
+
/**
|
|
28
|
+
* Walk a JSX <Item>/<Section> children array and return a
|
|
29
|
+
* section-preserving flat representation suitable for the internal
|
|
30
|
+
* filter / keyboard / state hooks. Children are expected to have already
|
|
31
|
+
* been normalized via `wrapItemChildren` so primitives have been wrapped
|
|
32
|
+
* into `<Item>` elements.
|
|
33
|
+
*/
|
|
34
|
+
export declare function flattenJsxChildren(children: readonly ReactElement[]): MultiSelectFlatEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* Flatten a section-preserving entry list into a plain MultiSelectFlatItem[],
|
|
37
|
+
* extracting items out of any sections.
|
|
38
|
+
*/
|
|
39
|
+
export declare function flattenEntriesToItems(entries: readonly MultiSelectFlatEntry[]): MultiSelectFlatItem[];
|
|
40
|
+
/**
|
|
41
|
+
* Filter entries by search text. Items within sections are filtered
|
|
42
|
+
* individually; sections with no matching items are removed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function filterEntries(entries: readonly MultiSelectFlatEntry[], text: string, contains: (string: string, substring: string) => boolean): MultiSelectFlatEntry[];
|
|
45
|
+
/**
|
|
46
|
+
* Collect the set of all surviving item keys from a list of flat entries.
|
|
47
|
+
* Used to drive filterJsxChildrenByKeys so we don't re-walk JSX with the
|
|
48
|
+
* search text predicate.
|
|
49
|
+
*/
|
|
50
|
+
export declare function collectEntryItemKeys(entries: readonly MultiSelectFlatEntry[]): Set<string>;
|
|
51
|
+
export declare function filterJsxChildrenByKeys(children: readonly ReactElement[], survivingKeys: ReadonlySet<string>): ReactElement[];
|
|
52
|
+
export declare function resolveSelection(selection: 'all' | Iterable<ItemKey> | undefined, allKeys: string[]): Set<string>;
|
|
53
|
+
//# sourceMappingURL=multiSelectUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiSelectUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/multiSelect/multiSelectUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,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AAS,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,EAChD,OAAO,EAAE,MAAM,EAAE,GAChB,GAAG,CAAC,MAAM,CAAC,CAQb"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import { cloneElement } from 'react';
|
|
7
|
+
import { ensureArray } from '@deephaven/utils';
|
|
8
|
+
import { getItemTextValue, isItemElement, isSectionElement } from "../utils/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* Flat shape used internally by the `MultiSelect` keyboard / filter / state
|
|
11
|
+
* hooks. Not part of the public API.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Section-preserving shape used internally for client-side filtering. Not
|
|
15
|
+
* part of the public API.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* React prepends `.$` to user-supplied keys in the element's `.key` property.
|
|
19
|
+
* Strip that prefix so we get the original key value.
|
|
20
|
+
*/
|
|
21
|
+
function cleanReactKey(rawKey) {
|
|
22
|
+
return rawKey.replace(/^\.\$/, '');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Convert a JSX `<Item>` element into a flat `{key, label}` record. Returns
|
|
27
|
+
* `null` for items without a key.
|
|
28
|
+
*/
|
|
29
|
+
function itemElementToFlat(element) {
|
|
30
|
+
var _getItemTextValue;
|
|
31
|
+
if (element.key == null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var key = cleanReactKey(String(element.key));
|
|
35
|
+
var label = (_getItemTextValue = getItemTextValue(element)) !== null && _getItemTextValue !== void 0 ? _getItemTextValue : typeof element.props.children === 'string' ? element.props.children : key;
|
|
36
|
+
return {
|
|
37
|
+
kind: 'item',
|
|
38
|
+
key,
|
|
39
|
+
label
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Type guard that checks whether a flat entry is a section.
|
|
45
|
+
*/
|
|
46
|
+
export function isFlatSection(entry) {
|
|
47
|
+
return entry.kind === 'section';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Walk a JSX <Item>/<Section> children array and return a
|
|
52
|
+
* section-preserving flat representation suitable for the internal
|
|
53
|
+
* filter / keyboard / state hooks. Children are expected to have already
|
|
54
|
+
* been normalized via `wrapItemChildren` so primitives have been wrapped
|
|
55
|
+
* into `<Item>` elements.
|
|
56
|
+
*/
|
|
57
|
+
export function flattenJsxChildren(children) {
|
|
58
|
+
var entries = [];
|
|
59
|
+
children.forEach(child => {
|
|
60
|
+
if (isSectionElement(child)) {
|
|
61
|
+
var section = child;
|
|
62
|
+
var sectionKey = section.key != null ? cleanReactKey(String(section.key)) : String(entries.length);
|
|
63
|
+
var sectionItems = [];
|
|
64
|
+
ensureArray(section.props.children).forEach(sectionChild => {
|
|
65
|
+
if (isItemElement(sectionChild)) {
|
|
66
|
+
var item = itemElementToFlat(sectionChild);
|
|
67
|
+
if (item != null) {
|
|
68
|
+
sectionItems.push(item);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
entries.push({
|
|
73
|
+
kind: 'section',
|
|
74
|
+
key: sectionKey,
|
|
75
|
+
title: section.props.title,
|
|
76
|
+
items: sectionItems
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (isItemElement(child)) {
|
|
81
|
+
var item = itemElementToFlat(child);
|
|
82
|
+
if (item != null) {
|
|
83
|
+
entries.push(item);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return entries;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Flatten a section-preserving entry list into a plain MultiSelectFlatItem[],
|
|
92
|
+
* extracting items out of any sections.
|
|
93
|
+
*/
|
|
94
|
+
export function flattenEntriesToItems(entries) {
|
|
95
|
+
return entries.flatMap(entry => isFlatSection(entry) ? entry.items : [entry]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Filter entries by search text. Items within sections are filtered
|
|
100
|
+
* individually; sections with no matching items are removed.
|
|
101
|
+
*/
|
|
102
|
+
export function filterEntries(entries, text, contains) {
|
|
103
|
+
var result = [];
|
|
104
|
+
entries.forEach(entry => {
|
|
105
|
+
if (isFlatSection(entry)) {
|
|
106
|
+
var filtered = entry.items.filter(item => contains(item.label, text));
|
|
107
|
+
if (filtered.length > 0) {
|
|
108
|
+
result.push(_objectSpread(_objectSpread({}, entry), {}, {
|
|
109
|
+
items: filtered
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
} else if (contains(entry.label, text)) {
|
|
113
|
+
result.push(entry);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Collect the set of all surviving item keys from a list of flat entries.
|
|
121
|
+
* Used to drive filterJsxChildrenByKeys so we don't re-walk JSX with the
|
|
122
|
+
* search text predicate.
|
|
123
|
+
*/
|
|
124
|
+
export function collectEntryItemKeys(entries) {
|
|
125
|
+
var keys = new Set();
|
|
126
|
+
entries.forEach(entry => {
|
|
127
|
+
if (isFlatSection(entry)) {
|
|
128
|
+
entry.items.forEach(item => keys.add(item.key));
|
|
129
|
+
} else {
|
|
130
|
+
keys.add(entry.key);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return keys;
|
|
134
|
+
}
|
|
135
|
+
export function filterJsxChildrenByKeys(children, survivingKeys) {
|
|
136
|
+
var result = [];
|
|
137
|
+
children.forEach(child => {
|
|
138
|
+
if (isSectionElement(child)) {
|
|
139
|
+
var section = child;
|
|
140
|
+
var filteredChildren = filterJsxChildrenByKeys(ensureArray(section.props.children).filter(c => c != null), survivingKeys);
|
|
141
|
+
if (filteredChildren.length > 0) {
|
|
142
|
+
result.push(/*#__PURE__*/cloneElement(section, {
|
|
143
|
+
children: filteredChildren
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (isItemElement(child)) {
|
|
149
|
+
var item = child;
|
|
150
|
+
if (item.key != null && survivingKeys.has(cleanReactKey(String(item.key)))) {
|
|
151
|
+
result.push(child);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
export function resolveSelection(selection, allKeys) {
|
|
158
|
+
if (selection == null) {
|
|
159
|
+
return new Set();
|
|
160
|
+
}
|
|
161
|
+
if (selection === 'all') {
|
|
162
|
+
return new Set(allKeys);
|
|
163
|
+
}
|
|
164
|
+
return new Set([...selection].map(String));
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=multiSelectUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiSelectUtils.js","names":["cloneElement","ensureArray","getItemTextValue","isItemElement","isSectionElement","cleanReactKey","rawKey","replace","itemElementToFlat","element","_getItemTextValue","key","String","label","props","children","kind","isFlatSection","entry","flattenJsxChildren","entries","forEach","child","section","sectionKey","length","sectionItems","sectionChild","item","push","title","items","flattenEntriesToItems","flatMap","filterEntries","text","contains","result","filtered","filter","_objectSpread","collectEntryItemKeys","keys","Set","add","filterJsxChildrenByKeys","survivingKeys","filteredChildren","c","has","resolveSelection","selection","allKeys","map"],"sources":["../../../src/spectrum/multiSelect/multiSelectUtils.tsx"],"sourcesContent":["import { cloneElement, type ReactElement, type ReactNode } from 'react';\nimport { ensureArray } from '@deephaven/utils';\nimport {\n getItemTextValue,\n isItemElement,\n isSectionElement,\n type ItemElement,\n type ItemKey,\n type SectionElement,\n} from '../utils';\n\n/**\n * Flat shape used internally by the `MultiSelect` keyboard / filter / state\n * hooks. Not part of the public API.\n */\nexport interface MultiSelectFlatItem {\n kind: 'item';\n key: string;\n label: string;\n}\n\n/**\n * Section-preserving shape used internally for client-side filtering. Not\n * part of the public API.\n */\nexport interface MultiSelectFlatSection {\n kind: 'section';\n key: string;\n title: ReactNode;\n items: MultiSelectFlatItem[];\n}\n\nexport type MultiSelectFlatEntry = MultiSelectFlatItem | MultiSelectFlatSection;\n\n/**\n * React prepends `.$` to user-supplied keys in the element's `.key` property.\n * Strip that prefix so we get the original key value.\n */\nfunction cleanReactKey(rawKey: string): string {\n return rawKey.replace(/^\\.\\$/, '');\n}\n\n/**\n * Convert a JSX `<Item>` element into a flat `{key, label}` record. Returns\n * `null` for items without a key.\n */\nfunction itemElementToFlat(\n element: ItemElement<unknown>\n): MultiSelectFlatItem | null {\n if (element.key == null) {\n return null;\n }\n const key = cleanReactKey(String(element.key));\n const label =\n getItemTextValue(element) ??\n (typeof element.props.children === 'string' ? element.props.children : key);\n return { kind: 'item', key, label };\n}\n\n/**\n * Type guard that checks whether a flat entry is a section.\n */\nexport function isFlatSection(\n entry: MultiSelectFlatEntry\n): entry is MultiSelectFlatSection {\n return entry.kind === 'section';\n}\n\n/**\n * Walk a JSX <Item>/<Section> children array and return a\n * section-preserving flat representation suitable for the internal\n * filter / keyboard / state hooks. Children are expected to have already\n * been normalized via `wrapItemChildren` so primitives have been wrapped\n * into `<Item>` elements.\n */\nexport function flattenJsxChildren(\n children: readonly ReactElement[]\n): MultiSelectFlatEntry[] {\n const entries: MultiSelectFlatEntry[] = [];\n\n children.forEach(child => {\n if (isSectionElement(child)) {\n const section = child as SectionElement<unknown>;\n const sectionKey =\n section.key != null\n ? cleanReactKey(String(section.key))\n : String(entries.length);\n\n const sectionItems: MultiSelectFlatItem[] = [];\n ensureArray(section.props.children).forEach(sectionChild => {\n if (isItemElement(sectionChild)) {\n const item = itemElementToFlat(sectionChild);\n if (item != null) {\n sectionItems.push(item);\n }\n }\n });\n\n entries.push({\n kind: 'section',\n key: sectionKey,\n title: section.props.title,\n items: sectionItems,\n });\n return;\n }\n\n if (isItemElement(child)) {\n const item = itemElementToFlat(child);\n if (item != null) {\n entries.push(item);\n }\n }\n });\n\n return entries;\n}\n\n/**\n * Flatten a section-preserving entry list into a plain MultiSelectFlatItem[],\n * extracting items out of any sections.\n */\nexport function flattenEntriesToItems(\n entries: readonly MultiSelectFlatEntry[]\n): MultiSelectFlatItem[] {\n return entries.flatMap(entry =>\n isFlatSection(entry) ? entry.items : [entry]\n );\n}\n\n/**\n * Filter entries by search text. Items within sections are filtered\n * individually; sections with no matching items are removed.\n */\nexport function filterEntries(\n entries: readonly MultiSelectFlatEntry[],\n text: string,\n contains: (string: string, substring: string) => boolean\n): MultiSelectFlatEntry[] {\n const result: MultiSelectFlatEntry[] = [];\n entries.forEach(entry => {\n if (isFlatSection(entry)) {\n const filtered = entry.items.filter(item => contains(item.label, text));\n if (filtered.length > 0) {\n result.push({ ...entry, items: filtered });\n }\n } else if (contains(entry.label, text)) {\n result.push(entry);\n }\n });\n return result;\n}\n\n/**\n * Collect the set of all surviving item keys from a list of flat entries.\n * Used to drive filterJsxChildrenByKeys so we don't re-walk JSX with the\n * search text predicate.\n */\nexport function collectEntryItemKeys(\n entries: readonly MultiSelectFlatEntry[]\n): Set<string> {\n const keys = new Set<string>();\n entries.forEach(entry => {\n if (isFlatSection(entry)) {\n entry.items.forEach(item => keys.add(item.key));\n } else {\n keys.add(entry.key);\n }\n });\n return keys;\n}\n\nexport function filterJsxChildrenByKeys(\n children: readonly ReactElement[],\n survivingKeys: ReadonlySet<string>\n): ReactElement[] {\n const result: ReactElement[] = [];\n\n children.forEach(child => {\n if (isSectionElement(child)) {\n const section = child as SectionElement<unknown>;\n const filteredChildren = filterJsxChildrenByKeys(\n ensureArray(section.props.children).filter(\n (c): c is ReactElement => c != null\n ),\n survivingKeys\n );\n if (filteredChildren.length > 0) {\n result.push(\n cloneElement(section as ReactElement, {\n children: filteredChildren,\n })\n );\n }\n return;\n }\n\n if (isItemElement(child)) {\n const item = child as ItemElement<unknown>;\n if (\n item.key != null &&\n survivingKeys.has(cleanReactKey(String(item.key)))\n ) {\n result.push(child);\n }\n }\n });\n\n return result;\n}\n\nexport function resolveSelection(\n selection: 'all' | Iterable<ItemKey> | undefined,\n allKeys: string[]\n): Set<string> {\n if (selection == null) {\n return new Set<string>();\n }\n if (selection === 'all') {\n return new Set(allKeys);\n }\n return new Set([...selection].map(String));\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAA2C,OAAO;AACvE,SAASC,WAAW,QAAQ,kBAAkB;AAAC,SAE7CC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB;AAMlB;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAACC,MAAc,EAAU;EAC7C,OAAOA,MAAM,CAACC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AACpC;;AAEA;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;IAEA,IAAI5C,aAAa,CAACmB,KAAK,CAAC,EAAE;MACxB,IAAMM,IAAI,GAAGN,KAA6B;MAC1C,IACEM,IAAI,CAACjB,GAAG,IAAI,IAAI,IAChBmC,aAAa,CAACG,GAAG,CAAC5C,aAAa,CAACO,MAAM,CAACgB,IAAI,CAACjB,GAAG,CAAC,CAAC,CAAC,EAClD;QACA0B,MAAM,CAACR,IAAI,CAACP,KAAK,CAAC;MACpB;IACF;EACF,CAAC,CAAC;EAEF,OAAOe,MAAM;AACf;AAEA,OAAO,SAASa,gBAAgBA,CAC9BC,SAAgD,EAChDC,OAAiB,EACJ;EACb,IAAID,SAAS,IAAI,IAAI,EAAE;IACrB,OAAO,IAAIR,GAAG,CAAS,CAAC;EAC1B;EACA,IAAIQ,SAAS,KAAK,KAAK,EAAE;IACvB,OAAO,IAAIR,GAAG,CAACS,OAAO,CAAC;EACzB;EACA,OAAO,IAAIT,GAAG,CAAC,CAAC,GAAGQ,SAAS,CAAC,CAACE,GAAG,CAACzC,MAAM,CAAC,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type MultiSelectFlatEntry, type MultiSelectFlatItem } from './multiSelectUtils';
|
|
3
|
+
export interface UseMultiSelectFilterOptions {
|
|
4
|
+
allEntries: readonly MultiSelectFlatEntry[];
|
|
5
|
+
wrappedChildren: readonly ReactElement[];
|
|
6
|
+
inputValue: string | undefined;
|
|
7
|
+
defaultInputValue: string;
|
|
8
|
+
onInputChange: ((value: string) => void) | undefined;
|
|
9
|
+
onSearchTextChange: ((text: string) => void) | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface UseMultiSelectFilterResult {
|
|
12
|
+
/** Current search text (controlled or uncontrolled). */
|
|
13
|
+
searchText: string;
|
|
14
|
+
/** Set the search text and forward to onSearchTextChange if provided. */
|
|
15
|
+
setSearchText: (value: string) => void;
|
|
16
|
+
/** Flat list of items surviving the current filter (sections expanded). */
|
|
17
|
+
filteredItems: MultiSelectFlatItem[];
|
|
18
|
+
/** Filtered JSX children for `<ListBox>`. */
|
|
19
|
+
filteredJsxChildren: ReactElement[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Owns the search/filter state for `MultiSelect`. Supports controlled and
|
|
23
|
+
* uncontrolled `inputValue`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useMultiSelectFilter({ allEntries, wrappedChildren, inputValue, defaultInputValue, onInputChange, onSearchTextChange, }: UseMultiSelectFilterOptions): UseMultiSelectFilterResult;
|
|
26
|
+
export default useMultiSelectFilter;
|
|
27
|
+
//# sourceMappingURL=useMultiSelectFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMultiSelectFilter.d.ts","sourceRoot":"","sources":["../../../src/spectrum/multiSelect/useMultiSelectFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,OAAO,CAAC;AAGhE,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,eAAe,EAAE,SAAS,YAAY,EAAE,CAAC;IACzC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACrD,kBAAkB,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC1D;AAED,MAAM,WAAW,0BAA0B;IACzC,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2EAA2E;IAC3E,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,6CAA6C;IAC7C,mBAAmB,EAAE,YAAY,EAAE,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACnB,EAAE,2BAA2B,GAAG,0BAA0B,CA6C1D;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useFilter } from '@react-aria/i18n';
|
|
3
|
+
import { useControlledState } from '@react-stately/utils';
|
|
4
|
+
import { collectEntryItemKeys, filterEntries, filterJsxChildrenByKeys, flattenEntriesToItems } from "./multiSelectUtils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Owns the search/filter state for `MultiSelect`. Supports controlled and
|
|
7
|
+
* uncontrolled `inputValue`.
|
|
8
|
+
*/
|
|
9
|
+
export function useMultiSelectFilter(_ref) {
|
|
10
|
+
var {
|
|
11
|
+
allEntries,
|
|
12
|
+
wrappedChildren,
|
|
13
|
+
inputValue,
|
|
14
|
+
defaultInputValue,
|
|
15
|
+
onInputChange,
|
|
16
|
+
onSearchTextChange
|
|
17
|
+
} = _ref;
|
|
18
|
+
var [searchText, setSearchTextInternal] = useControlledState(inputValue, defaultInputValue, onInputChange);
|
|
19
|
+
var setSearchText = useCallback(value => {
|
|
20
|
+
setSearchTextInternal(value);
|
|
21
|
+
onSearchTextChange === null || onSearchTextChange === void 0 || onSearchTextChange(value);
|
|
22
|
+
}, [setSearchTextInternal, onSearchTextChange]);
|
|
23
|
+
var {
|
|
24
|
+
contains
|
|
25
|
+
} = useFilter({
|
|
26
|
+
sensitivity: 'base'
|
|
27
|
+
});
|
|
28
|
+
var shouldSkipFiltering = onSearchTextChange != null || searchText === '';
|
|
29
|
+
var filteredEntries = useMemo(() => {
|
|
30
|
+
if (shouldSkipFiltering) {
|
|
31
|
+
return allEntries;
|
|
32
|
+
}
|
|
33
|
+
return filterEntries(allEntries, searchText, contains);
|
|
34
|
+
}, [allEntries, searchText, contains, shouldSkipFiltering]);
|
|
35
|
+
var filteredItems = useMemo(() => flattenEntriesToItems(filteredEntries), [filteredEntries]);
|
|
36
|
+
var filteredJsxChildren = useMemo(() => {
|
|
37
|
+
if (shouldSkipFiltering) {
|
|
38
|
+
return wrappedChildren;
|
|
39
|
+
}
|
|
40
|
+
var survivingKeys = collectEntryItemKeys(filteredEntries);
|
|
41
|
+
return filterJsxChildrenByKeys(wrappedChildren, survivingKeys);
|
|
42
|
+
}, [wrappedChildren, filteredEntries, shouldSkipFiltering]);
|
|
43
|
+
return {
|
|
44
|
+
searchText,
|
|
45
|
+
setSearchText,
|
|
46
|
+
filteredItems,
|
|
47
|
+
filteredJsxChildren
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export default useMultiSelectFilter;
|
|
51
|
+
//# sourceMappingURL=useMultiSelectFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMultiSelectFilter.js","names":["useCallback","useMemo","useFilter","useControlledState","collectEntryItemKeys","filterEntries","filterJsxChildrenByKeys","flattenEntriesToItems","useMultiSelectFilter","_ref","allEntries","wrappedChildren","inputValue","defaultInputValue","onInputChange","onSearchTextChange","searchText","setSearchTextInternal","setSearchText","value","contains","sensitivity","shouldSkipFiltering","filteredEntries","filteredItems","filteredJsxChildren","survivingKeys"],"sources":["../../../src/spectrum/multiSelect/useMultiSelectFilter.ts"],"sourcesContent":["import { type ReactElement, useCallback, useMemo } from 'react';\nimport { useFilter } from '@react-aria/i18n';\nimport { useControlledState } from '@react-stately/utils';\nimport {\n collectEntryItemKeys,\n filterEntries,\n filterJsxChildrenByKeys,\n flattenEntriesToItems,\n type MultiSelectFlatEntry,\n type MultiSelectFlatItem,\n} from './multiSelectUtils';\n\nexport interface UseMultiSelectFilterOptions {\n allEntries: readonly MultiSelectFlatEntry[];\n wrappedChildren: readonly ReactElement[];\n inputValue: string | undefined;\n defaultInputValue: string;\n onInputChange: ((value: string) => void) | undefined;\n onSearchTextChange: ((text: string) => void) | undefined;\n}\n\nexport interface UseMultiSelectFilterResult {\n /** Current search text (controlled or uncontrolled). */\n searchText: string;\n /** Set the search text and forward to onSearchTextChange if provided. */\n setSearchText: (value: string) => void;\n /** Flat list of items surviving the current filter (sections expanded). */\n filteredItems: MultiSelectFlatItem[];\n /** Filtered JSX children for `<ListBox>`. */\n filteredJsxChildren: ReactElement[];\n}\n\n/**\n * Owns the search/filter state for `MultiSelect`. Supports controlled and\n * uncontrolled `inputValue`.\n */\nexport function useMultiSelectFilter({\n allEntries,\n wrappedChildren,\n inputValue,\n defaultInputValue,\n onInputChange,\n onSearchTextChange,\n}: UseMultiSelectFilterOptions): UseMultiSelectFilterResult {\n const [searchText, setSearchTextInternal] = useControlledState<string>(\n inputValue,\n defaultInputValue,\n onInputChange\n );\n\n const setSearchText = useCallback(\n (value: string) => {\n setSearchTextInternal(value);\n onSearchTextChange?.(value);\n },\n [setSearchTextInternal, onSearchTextChange]\n );\n\n const { contains } = useFilter({ sensitivity: 'base' });\n\n const shouldSkipFiltering = onSearchTextChange != null || searchText === '';\n\n const filteredEntries = useMemo<readonly MultiSelectFlatEntry[]>(() => {\n if (shouldSkipFiltering) {\n return allEntries;\n }\n return filterEntries(allEntries, searchText, contains);\n }, [allEntries, searchText, contains, shouldSkipFiltering]);\n\n const filteredItems = useMemo(\n () => flattenEntriesToItems(filteredEntries),\n [filteredEntries]\n );\n\n const filteredJsxChildren = useMemo<ReactElement[]>(() => {\n if (shouldSkipFiltering) {\n return wrappedChildren as ReactElement[];\n }\n const survivingKeys = collectEntryItemKeys(filteredEntries);\n return filterJsxChildrenByKeys(wrappedChildren, survivingKeys);\n }, [wrappedChildren, filteredEntries, shouldSkipFiltering]);\n\n return {\n searchText,\n setSearchText,\n filteredItems,\n filteredJsxChildren,\n };\n}\n\nexport default useMultiSelect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