@servicetitan/anvil2 1.27.2 → 1.29.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 +76 -0
- package/dist/AnvilProvider-C7Li86-d.js +16 -0
- package/dist/AnvilProvider-C7Li86-d.js.map +1 -0
- package/dist/AnvilProvider.js +1 -1
- package/dist/{Combobox-DnTI2I3L.js → Combobox-DCrEfyl2.js} +2209 -228
- package/dist/Combobox-DCrEfyl2.js.map +1 -0
- package/dist/Combobox.css +443 -69
- package/dist/Combobox.js +1 -1
- package/dist/DateField-4jR9NvbC.js +1109 -0
- package/dist/DateField-4jR9NvbC.js.map +1 -0
- package/dist/DateField.js +1 -1
- package/dist/{Dialog-DQ9QXB5D.js → Dialog-CL3bfZuB.js} +2 -2
- package/dist/{Dialog-DQ9QXB5D.js.map → Dialog-CL3bfZuB.js.map} +1 -1
- package/dist/{Dialog-Kh2tcVWz-DqcNnouf.js → Dialog-CYBt_JdP-CmF0MUHL.js} +80 -51
- package/dist/Dialog-CYBt_JdP-CmF0MUHL.js.map +1 -0
- package/dist/Dialog.js +1 -1
- package/dist/Drawer-8nHrKktU.js +66 -0
- package/dist/Drawer-8nHrKktU.js.map +1 -0
- package/dist/{Drawer-C6fpnRDX.js → Drawer-UQlX-LQG-BSCnMRad.js} +97 -130
- package/dist/Drawer-UQlX-LQG-BSCnMRad.js.map +1 -0
- package/dist/{Drawer.css → Drawer-UQlX-LQG.css} +26 -25
- package/dist/Drawer.js +1 -1
- package/dist/{AnvilProvider-DNJk1Ait.js → HammerProvider-DuxhW0gv-C2voN5ro.js} +26 -15
- package/dist/HammerProvider-DuxhW0gv-C2voN5ro.js.map +1 -0
- package/dist/InputMask-B8N8PP1W-DlUKpMR4.js +323 -0
- package/dist/InputMask-B8N8PP1W-DlUKpMR4.js.map +1 -0
- package/dist/{InputMask-Ceh574pv.js → InputMask-jsL7rSOk.js} +2 -2
- package/dist/{InputMask-Ceh574pv.js.map → InputMask-jsL7rSOk.js.map} +1 -1
- package/dist/InputMask.js +1 -1
- package/dist/{Label-DWF2pXeG-1BhzVgZG.js → Label-CUVr-jvI-BXhER5eQ.js} +3 -3
- package/dist/{Label-DWF2pXeG-1BhzVgZG.js.map → Label-CUVr-jvI-BXhER5eQ.js.map} +1 -1
- package/dist/Menu-CsfX8-_z.js +1091 -0
- package/dist/Menu-CsfX8-_z.js.map +1 -0
- package/dist/Menu.css +116 -1
- package/dist/Menu.js +1 -1
- package/dist/{Page-BGkLs3bR.js → Page-vKi5JkDS.js} +70 -54
- package/dist/Page-vKi5JkDS.js.map +1 -0
- package/dist/Page.css +103 -70
- package/dist/Page.js +1 -1
- package/dist/{Popover-DzEc_Muv.js → Popover-OFlyW8gN.js} +2 -2
- package/dist/{Popover-DzEc_Muv.js.map → Popover-OFlyW8gN.js.map} +1 -1
- package/dist/{Popover-QKZtjN4_-CETYlWwq.js → Popover-tu_N1aS6-CSLR1Xzc.js} +351 -12
- package/dist/Popover-tu_N1aS6-CSLR1Xzc.js.map +1 -0
- package/dist/{Popover-QKZtjN4_.css → Popover-tu_N1aS6.css} +53 -1
- package/dist/Popover.js +1 -1
- package/dist/{ProgressBar-cKtBso7j-3CDyBaAN.js → ProgressBar-DQ1lsFk2-Ci4eqzM0.js} +3 -3
- package/dist/{ProgressBar-cKtBso7j-3CDyBaAN.js.map → ProgressBar-DQ1lsFk2-Ci4eqzM0.js.map} +1 -1
- package/dist/{ProgressBar-IItIByYc.js → ProgressBar-gVRLaKPz.js} +2 -2
- package/dist/{ProgressBar-IItIByYc.js.map → ProgressBar-gVRLaKPz.js.map} +1 -1
- package/dist/ProgressBar.js +1 -1
- package/dist/{SearchField-CWb0kaV8.js → SearchField-C-4icPUa.js} +2 -2
- package/dist/{SearchField-CWb0kaV8.js.map → SearchField-C-4icPUa.js.map} +1 -1
- package/dist/SearchField.js +1 -1
- package/dist/{TextField-D53XNiCi-C6_A5VRq.js → TextField-B8LHWOoC-DSV9zY-z.js} +2 -2
- package/dist/{TextField-D53XNiCi-C6_A5VRq.js.map → TextField-B8LHWOoC-DSV9zY-z.js.map} +1 -1
- package/dist/{TextField-s92xHzb3.js → TextField-DgxJO1a7.js} +2 -2
- package/dist/{TextField-s92xHzb3.js.map → TextField-DgxJO1a7.js.map} +1 -1
- package/dist/TextField.js +1 -1
- package/dist/{Textarea-B61wNIFr.js → Textarea-B-Dv2RXs.js} +2 -2
- package/dist/{Textarea-B61wNIFr.js.map → Textarea-B-Dv2RXs.js.map} +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/Toast.js +1 -1
- package/dist/{Toolbar-Cge6Nznj.js → Toolbar-7BeCY61H.js} +2 -2
- package/dist/{Toolbar-Cge6Nznj.js.map → Toolbar-7BeCY61H.js.map} +1 -1
- package/dist/Toolbar.js +1 -1
- package/dist/{Tooltip-89FIvMG0.js → Tooltip-BVBq-KxK.js} +2 -2
- package/dist/{Tooltip-89FIvMG0.js.map → Tooltip-BVBq-KxK.js.map} +1 -1
- package/dist/{Tooltip-DgM8NSPm-CRIQbuTm.js → Tooltip-C8sCGmKM-CLrDofvy.js} +222 -22
- package/dist/Tooltip-C8sCGmKM-CLrDofvy.js.map +1 -0
- package/dist/{Tooltip-DgM8NSPm.css → Tooltip-C8sCGmKM.css} +43 -1
- package/dist/Tooltip.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +1 -0
- package/dist/components/Page/Page.d.ts +4 -1
- package/dist/floating-ui.react-4AwURJA3.js +5989 -0
- package/dist/floating-ui.react-4AwURJA3.js.map +1 -0
- package/dist/{useKeyboardFocusables-CwVMAe5C-CIHqixNA.js → index.esm-CunAFnrh.js} +11 -59
- package/dist/index.esm-CunAFnrh.js.map +1 -0
- package/dist/index.js +16 -16
- package/dist/supportsPopover-8aJR37cf-8aJR37cf.js +6 -0
- package/dist/supportsPopover-8aJR37cf-8aJR37cf.js.map +1 -0
- package/dist/{toast-CHld8RKY.js → toast-CbokOkfo.js} +6 -2
- package/dist/toast-CbokOkfo.js.map +1 -0
- package/dist/useKeyboardFocusables-CwVMAe5C-DtjYOAmt.js +61 -0
- package/dist/useKeyboardFocusables-CwVMAe5C-DtjYOAmt.js.map +1 -0
- package/package.json +3 -3
- package/dist/AnvilProvider-DNJk1Ait.js.map +0 -1
- package/dist/Combobox-DnTI2I3L.js.map +0 -1
- package/dist/DateField-DocC46Mw.js +0 -565
- package/dist/DateField-DocC46Mw.js.map +0 -1
- package/dist/Dialog-Kh2tcVWz-DqcNnouf.js.map +0 -1
- package/dist/Drawer-C6fpnRDX.js.map +0 -1
- package/dist/InputMask-DQXw5qvG-BH4P-Woc.js +0 -195
- package/dist/InputMask-DQXw5qvG-BH4P-Woc.js.map +0 -1
- package/dist/Menu-D8SDm9s9.js +0 -706
- package/dist/Menu-D8SDm9s9.js.map +0 -1
- package/dist/Page-BGkLs3bR.js.map +0 -1
- package/dist/Popover-QKZtjN4_-CETYlWwq.js.map +0 -1
- package/dist/Tooltip-DgM8NSPm-CRIQbuTm.js.map +0 -1
- package/dist/floating-ui.react-P5949bpO.js +0 -28
- package/dist/floating-ui.react-P5949bpO.js.map +0 -1
- package/dist/floating-ui.react-dom-D912oS4K.js +0 -1841
- package/dist/floating-ui.react-dom-D912oS4K.js.map +0 -1
- package/dist/toast-CHld8RKY.js.map +0 -1
- package/dist/useKeyboardFocusables-CwVMAe5C-CIHqixNA.js.map +0 -1
- /package/dist/{Dialog-Kh2tcVWz.css → Dialog-CYBt_JdP.css} +0 -0
- /package/dist/{Label-DWF2pXeG.css → Label-CUVr-jvI.css} +0 -0
- /package/dist/{ProgressBar-cKtBso7j.css → ProgressBar-DQ1lsFk2.css} +0 -0
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useTrackingId } from './useTrackingId.js';
|
|
3
|
-
import React__default, { useRef, useCallback, useEffect, useMemo, cloneElement, useLayoutEffect, useReducer, Component, createContext, useState,
|
|
3
|
+
import React__default, { useRef, useCallback, useEffect, useMemo, cloneElement, useLayoutEffect, useReducer, Component, createContext, useState, useId, useContext, useDeferredValue } from 'react';
|
|
4
4
|
import { g as getDefaultExportFromCjs, c as cx } from './index-tZvMCc77.js';
|
|
5
5
|
import { a as _extends, _ as _objectWithoutPropertiesLoose } from './extends-Bg2s_OKl.js';
|
|
6
|
-
import { u as
|
|
6
|
+
import { e as PopoverLegacy, u as usePopoverLegacyContext, d as Popover, f as usePopoverContext } from './Popover-tu_N1aS6-CSLR1Xzc.js';
|
|
7
|
+
import { s as styles$3 } from './Listbox.module-CJuWm7RR-CJuWm7RR.js';
|
|
8
|
+
import { s as supportsPopover } from './supportsPopover-8aJR37cf-8aJR37cf.js';
|
|
7
9
|
import { F as Flex } from './Flex-pdHNcZrF-CdQdYhOU.js';
|
|
8
|
-
import {
|
|
9
|
-
import { S as Spinner } from './Spinner-DdirfhPp-c7cDfIit.js';
|
|
10
|
-
import { s as styles$2 } from './Listbox.module-CJuWm7RR-CJuWm7RR.js';
|
|
11
|
-
import { s as styles$1 } from './ListView.module-BqvHsIQ9-BqvHsIQ9.js';
|
|
12
|
-
import { I as Icon$1 } from './Icon-DbHA5GV1-DwO2aGkj.js';
|
|
13
|
-
import { c as checkboxStyles, a as SvgIndeterminateCheckBox, S as SvgCheckBox, b as SvgCheckBoxOutlineBlank } from './Checkbox.module-DMrZNVpb-DL8zOKBQ.js';
|
|
14
|
-
import { S as SvgCheck } from './check-Cf67OWrZ.js';
|
|
15
|
-
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-C6qizVc6-BkgAan7h.js';
|
|
16
|
-
import { L as Label } from './Label-DWF2pXeG-1BhzVgZG.js';
|
|
10
|
+
import { L as Label } from './Label-CUVr-jvI-BXhER5eQ.js';
|
|
17
11
|
import { B as Button } from './Button-Ce--YZ9L-Csh0Zzuf.js';
|
|
18
12
|
import { C as Chip } from './Chip-CAxTyjIZ-DfkCTnYy.js';
|
|
19
13
|
import { S as SvgClose } from './close-DZj38AEh.js';
|
|
20
14
|
import { S as SvgChevronRight } from './chevron_right-BdpsxX7x.js';
|
|
21
15
|
import { H as Helper } from './Helper-Ba5DBS51-DBtASfJG.js';
|
|
16
|
+
import { T as Text } from './Text-C2n3GDdC-rz_AelM0.js';
|
|
17
|
+
import { S as Spinner } from './Spinner-DdirfhPp-c7cDfIit.js';
|
|
18
|
+
import { s as styles$2 } from './ListView.module-BqvHsIQ9-BqvHsIQ9.js';
|
|
19
|
+
import { I as Icon$2 } from './Icon-DbHA5GV1-DwO2aGkj.js';
|
|
20
|
+
import { c as checkboxStyles, a as SvgIndeterminateCheckBox, S as SvgCheckBox, b as SvgCheckBoxOutlineBlank } from './Checkbox.module-DMrZNVpb-DL8zOKBQ.js';
|
|
21
|
+
import { S as SvgCheck } from './check-Cf67OWrZ.js';
|
|
22
|
+
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-C6qizVc6-BkgAan7h.js';
|
|
22
23
|
import { c as childrenToString } from './childrenToString-Bz9MqbHb-Bz9MqbHb.js';
|
|
23
24
|
|
|
24
25
|
import './Combobox.css';function _setPrototypeOf(t, e) {
|
|
@@ -6281,135 +6282,1937 @@ function getKeyAttributes(key) {
|
|
|
6281
6282
|
};
|
|
6282
6283
|
}
|
|
6283
6284
|
|
|
6284
|
-
const
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
const
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
const
|
|
6291
|
-
const
|
|
6292
|
-
const
|
|
6293
|
-
const
|
|
6294
|
-
const
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
"search-field": "_search-field_1ued6_4",
|
|
6302
|
-
item: item,
|
|
6303
|
-
input: input,
|
|
6304
|
-
"input-wrapper": "_input-wrapper_1ued6_19",
|
|
6305
|
-
"toggle-button-wrapper": "_toggle-button-wrapper_1ued6_32",
|
|
6306
|
-
"close-button-wrapper": "_close-button-wrapper_1ued6_33",
|
|
6307
|
-
prefix: prefix,
|
|
6308
|
-
suffix: suffix,
|
|
6309
|
-
combobox: combobox,
|
|
6310
|
-
select: select,
|
|
6311
|
-
"popover-content": "_popover-content_1ued6_74",
|
|
6312
|
-
"no-clear-button": "_no-clear-button_1ued6_93",
|
|
6313
|
-
"input-flex": "_input-flex_1ued6_96",
|
|
6314
|
-
"fake-placeholder": "_fake-placeholder_1ued6_124",
|
|
6315
|
-
"close-button": "_close-button_1ued6_33",
|
|
6316
|
-
"toggle-button": "_toggle-button_1ued6_32",
|
|
6317
|
-
"rows-wrapper": "_rows-wrapper_1ued6_157",
|
|
6318
|
-
"chip-wrapper": "_chip-wrapper_1ued6_167",
|
|
6319
|
-
chip: chip,
|
|
6320
|
-
listview: listview,
|
|
6321
|
-
"loading-spinner": "_loading-spinner_1ued6_212",
|
|
6322
|
-
empty: empty,
|
|
6323
|
-
children: children,
|
|
6324
|
-
Icon: Icon,
|
|
6325
|
-
small: small,
|
|
6326
|
-
large: large,
|
|
6327
|
-
error: error,
|
|
6328
|
-
"loading-infinite": "_loading-infinite_1ued6_286",
|
|
6329
|
-
"loading-progress": "_loading-progress_1ued6_286",
|
|
6330
|
-
disabled: disabled,
|
|
6331
|
-
"listview-option": "_listview-option_1ued6_304"
|
|
6285
|
+
const defaultItemToString$1 = function(item) {
|
|
6286
|
+
return item != null ? String(item) : "";
|
|
6287
|
+
};
|
|
6288
|
+
const defaultItemToKey$1 = function(item) {
|
|
6289
|
+
return item;
|
|
6290
|
+
};
|
|
6291
|
+
const useDownshiftEnvironment$1 = () => {
|
|
6292
|
+
const wrapperDivRef = useRef(null);
|
|
6293
|
+
const shadowRoot = wrapperDivRef.current ? wrapperDivRef.current.getRootNode() : null;
|
|
6294
|
+
const shadowDocument = wrapperDivRef.current && shadowRoot ? shadowRoot.ownerDocument : null;
|
|
6295
|
+
const environment = shadowDocument ? {
|
|
6296
|
+
document: shadowDocument,
|
|
6297
|
+
addEventListener: shadowDocument.addEventListener.bind(shadowRoot),
|
|
6298
|
+
removeEventListener: shadowDocument.removeEventListener.bind(shadowRoot),
|
|
6299
|
+
Node
|
|
6300
|
+
} : undefined;
|
|
6301
|
+
return { ref: wrapperDivRef, environment };
|
|
6332
6302
|
};
|
|
6333
6303
|
|
|
6334
|
-
const
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6304
|
+
const item$1 = "_item_tpkx3_6";
|
|
6305
|
+
const input$1 = "_input_tpkx3_19";
|
|
6306
|
+
const prefix$1 = "_prefix_tpkx3_47";
|
|
6307
|
+
const suffix$1 = "_suffix_tpkx3_48";
|
|
6308
|
+
const combobox$1 = "_combobox_tpkx3_63";
|
|
6309
|
+
const select$1 = "_select_tpkx3_72";
|
|
6310
|
+
const chip$1 = "_chip_tpkx3_168";
|
|
6311
|
+
const listview$1 = "_listview_tpkx3_209";
|
|
6312
|
+
const empty$1 = "_empty_tpkx3_217";
|
|
6313
|
+
const children$1 = "_children_tpkx3_245";
|
|
6314
|
+
const Icon$1 = "_Icon_tpkx3_248";
|
|
6315
|
+
const small$1 = "_small_tpkx3_253";
|
|
6316
|
+
const large$1 = "_large_tpkx3_256";
|
|
6317
|
+
const error$1 = "_error_tpkx3_274";
|
|
6318
|
+
const disabled$1 = "_disabled_tpkx3_287";
|
|
6319
|
+
const styles$1 = {
|
|
6320
|
+
"buttons-wrapper": "_buttons-wrapper_tpkx3_4",
|
|
6321
|
+
"search-field": "_search-field_tpkx3_5",
|
|
6322
|
+
item: item$1,
|
|
6323
|
+
input: input$1,
|
|
6324
|
+
"input-wrapper": "_input-wrapper_tpkx3_20",
|
|
6325
|
+
"toggle-button-wrapper": "_toggle-button-wrapper_tpkx3_33",
|
|
6326
|
+
"close-button-wrapper": "_close-button-wrapper_tpkx3_34",
|
|
6327
|
+
prefix: prefix$1,
|
|
6328
|
+
suffix: suffix$1,
|
|
6329
|
+
combobox: combobox$1,
|
|
6330
|
+
select: select$1,
|
|
6331
|
+
"popover-content": "_popover-content_tpkx3_75",
|
|
6332
|
+
"no-clear-button": "_no-clear-button_tpkx3_94",
|
|
6333
|
+
"input-flex": "_input-flex_tpkx3_97",
|
|
6334
|
+
"fake-placeholder": "_fake-placeholder_tpkx3_125",
|
|
6335
|
+
"close-button": "_close-button_tpkx3_34",
|
|
6336
|
+
"toggle-button": "_toggle-button_tpkx3_33",
|
|
6337
|
+
"rows-wrapper": "_rows-wrapper_tpkx3_158",
|
|
6338
|
+
"chip-wrapper": "_chip-wrapper_tpkx3_168",
|
|
6339
|
+
chip: chip$1,
|
|
6340
|
+
listview: listview$1,
|
|
6341
|
+
"loading-spinner": "_loading-spinner_tpkx3_213",
|
|
6342
|
+
empty: empty$1,
|
|
6343
|
+
children: children$1,
|
|
6344
|
+
Icon: Icon$1,
|
|
6345
|
+
small: small$1,
|
|
6346
|
+
large: large$1,
|
|
6347
|
+
error: error$1,
|
|
6348
|
+
"loading-infinite": "_loading-infinite_tpkx3_287",
|
|
6349
|
+
"loading-progress": "_loading-progress_tpkx3_287",
|
|
6350
|
+
disabled: disabled$1,
|
|
6351
|
+
"listview-option": "_listview-option_tpkx3_305"
|
|
6352
|
+
};
|
|
6353
|
+
|
|
6354
|
+
const ADD_NEW$1 = Symbol.for("add-new");
|
|
6355
|
+
const ComboboxLegacyContext = createContext(null);
|
|
6356
|
+
const useComboboxLegacy = function() {
|
|
6357
|
+
const context = useContext(
|
|
6358
|
+
ComboboxLegacyContext
|
|
6359
|
+
);
|
|
6360
|
+
if (context == null) {
|
|
6361
|
+
throw new Error("useComboboxLegacy must be wrapped in <ComboboxLegacy />");
|
|
6362
|
+
}
|
|
6363
|
+
return context;
|
|
6364
|
+
};
|
|
6365
|
+
const ComboboxLegacySingle = function(props) {
|
|
6366
|
+
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
6367
|
+
const {
|
|
6368
|
+
className,
|
|
6369
|
+
style,
|
|
6370
|
+
children,
|
|
6371
|
+
open,
|
|
6372
|
+
disabled,
|
|
6373
|
+
readOnly,
|
|
6374
|
+
items: itemsProp,
|
|
6375
|
+
itemToString: itemToStringProp,
|
|
6376
|
+
itemToKey: itemToKeyProp,
|
|
6377
|
+
onChange,
|
|
6378
|
+
disableCloseOnClickOutside = false,
|
|
6379
|
+
disableMatchReferenceWidth = false,
|
|
6380
|
+
disableCloseOnSelectItem = false,
|
|
6381
|
+
filterOptions,
|
|
6382
|
+
loading = false,
|
|
6383
|
+
root,
|
|
6384
|
+
onInputValueChange,
|
|
6385
|
+
environment: environmentProp,
|
|
6386
|
+
...rest
|
|
6387
|
+
} = componentProps;
|
|
6388
|
+
const ComboboxLegacyClassNames = cx(styles$1["combobox"], className);
|
|
6389
|
+
const [items, setItems] = useState(itemsProp);
|
|
6390
|
+
const [hasAddNew, setHasAddNew] = useState(false);
|
|
6391
|
+
const [onSelectItemAddNew, setOnSelectItemAddNew] = useState(undefined);
|
|
6392
|
+
const [hasExactMatch, setHasExactMatch] = useState(false);
|
|
6393
|
+
const [hasDisabledPopover, setHasDisabledPopover] = useState(false);
|
|
6394
|
+
const [hasEmpty, setHasEmpty] = useState(false);
|
|
6395
|
+
const [disabledItems, setDisabledItems] = useState([]);
|
|
6396
|
+
const [isReadOnly, setIsReadOnly] = useState(readOnly);
|
|
6397
|
+
const [isDisabled, setIsDisabled] = useState(disabled);
|
|
6398
|
+
const referenceRef = useRef(null);
|
|
6399
|
+
const contentRef = useRef(null);
|
|
6400
|
+
const handleOutsidePress = (e) => {
|
|
6401
|
+
const clickedInsideReference = referenceRef.current && e.target != null && referenceRef.current.contains(e.target);
|
|
6402
|
+
if (!clickedInsideReference) {
|
|
6403
|
+
closeMenu();
|
|
6404
|
+
return true;
|
|
6405
|
+
} else {
|
|
6406
|
+
return false;
|
|
6407
|
+
}
|
|
6408
|
+
};
|
|
6409
|
+
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment$1();
|
|
6410
|
+
const showAddNew = hasAddNew && !hasExactMatch;
|
|
6411
|
+
const combinedItems = useMemo(
|
|
6412
|
+
() => showAddNew ? [...items, ADD_NEW$1] : items,
|
|
6413
|
+
[items, showAddNew]
|
|
6414
|
+
);
|
|
6415
|
+
const itemToString = itemToStringProp ?? defaultItemToString$1;
|
|
6416
|
+
const itemToKey = itemToKeyProp ?? defaultItemToKey$1;
|
|
6353
6417
|
const {
|
|
6354
|
-
select,
|
|
6355
|
-
disableClearSelection,
|
|
6356
6418
|
isOpen,
|
|
6357
|
-
itemToString,
|
|
6358
6419
|
getLabelProps,
|
|
6359
6420
|
getInputProps,
|
|
6360
6421
|
getToggleButtonProps,
|
|
6361
6422
|
getMenuProps,
|
|
6423
|
+
getItemProps,
|
|
6424
|
+
highlightedIndex,
|
|
6362
6425
|
selectedItem,
|
|
6363
|
-
selectedItems,
|
|
6364
|
-
getSelectedItemProps,
|
|
6365
|
-
getDropdownProps,
|
|
6366
|
-
reset,
|
|
6367
|
-
removeSelectedItem,
|
|
6368
6426
|
selectItem,
|
|
6427
|
+
setInputValue,
|
|
6369
6428
|
inputValue,
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6429
|
+
closeMenu
|
|
6430
|
+
} = useCombobox$1({
|
|
6431
|
+
...rest,
|
|
6432
|
+
items: combinedItems,
|
|
6433
|
+
itemToString,
|
|
6434
|
+
itemToKey,
|
|
6435
|
+
isOpen: open,
|
|
6436
|
+
initialIsOpen: open,
|
|
6437
|
+
environment: environmentProp ?? environment,
|
|
6438
|
+
// NOTE: Reducer needs to be pure, side-effects should be in event handlers
|
|
6439
|
+
stateReducer(state, { type, changes }) {
|
|
6440
|
+
switch (type) {
|
|
6441
|
+
// keep ComboboxLegacy open onBlur, will call close using Popover's onOutsidePress
|
|
6442
|
+
case useCombobox$1.stateChangeTypes.InputBlur:
|
|
6443
|
+
return {
|
|
6444
|
+
...changes,
|
|
6445
|
+
isOpen: open != null ? open : true,
|
|
6446
|
+
highlightedIndex: state.highlightedIndex
|
|
6447
|
+
};
|
|
6448
|
+
case useCombobox$1.stateChangeTypes.InputKeyDownEnter:
|
|
6449
|
+
case useCombobox$1.stateChangeTypes.ItemClick:
|
|
6450
|
+
if (changes.selectedItem === ADD_NEW$1) {
|
|
6451
|
+
const stateInputValue = state.inputValue;
|
|
6452
|
+
setTimeout(() => {
|
|
6453
|
+
onSelectItemAddNew?.(stateInputValue);
|
|
6454
|
+
}, 0);
|
|
6455
|
+
return {
|
|
6456
|
+
...changes,
|
|
6457
|
+
selectedItem: state.selectedItem,
|
|
6458
|
+
inputValue: ""
|
|
6459
|
+
};
|
|
6460
|
+
} else {
|
|
6461
|
+
return {
|
|
6462
|
+
...changes,
|
|
6463
|
+
isOpen: open != null ? open : disableCloseOnSelectItem ? true : changes.isOpen,
|
|
6464
|
+
highlightedIndex: disableCloseOnSelectItem ? 0 : changes.highlightedIndex
|
|
6465
|
+
};
|
|
6466
|
+
}
|
|
6467
|
+
// prevent this from closing the popover by default
|
|
6468
|
+
case useCombobox$1.stateChangeTypes.InputClick:
|
|
6469
|
+
return { ...changes, isOpen: open != null ? open : true };
|
|
6470
|
+
default:
|
|
6471
|
+
return changes;
|
|
6472
|
+
}
|
|
6473
|
+
},
|
|
6474
|
+
onInputValueChange: onInputValueChange ?? (({ inputValue: inputValue2, type, selectedItem: selectedItem2 }) => {
|
|
6475
|
+
const inputValueMatchesSelectedItem = selectedItem2 != null && inputValue2 === itemToString(selectedItem2);
|
|
6476
|
+
const inputValueIsEmpty = inputValue2 == null || inputValue2 === "";
|
|
6477
|
+
if (type === useCombobox$1.stateChangeTypes.InputKeyDownEnter || type === useCombobox$1.stateChangeTypes.ItemClick) {
|
|
6478
|
+
setItems(itemsProp);
|
|
6479
|
+
setHasExactMatch(true);
|
|
6480
|
+
} else if (!inputValueMatchesSelectedItem && !inputValueIsEmpty) {
|
|
6481
|
+
setItems(matchSorter(itemsProp, inputValue2, filterOptions));
|
|
6482
|
+
setHasExactMatch(
|
|
6483
|
+
matchSorter(itemsProp, inputValue2, {
|
|
6484
|
+
...filterOptions,
|
|
6485
|
+
threshold: matchSorter.rankings.EQUAL
|
|
6486
|
+
}).length > 0
|
|
6487
|
+
);
|
|
6488
|
+
} else {
|
|
6489
|
+
setItems(itemsProp);
|
|
6490
|
+
setHasExactMatch(true);
|
|
6491
|
+
}
|
|
6492
|
+
}),
|
|
6493
|
+
onSelectedItemChange(changes) {
|
|
6494
|
+
const { selectedItem: selectedItem2 } = changes;
|
|
6495
|
+
if (onChange != null)
|
|
6496
|
+
onChange(selectedItem2 != null ? selectedItem2 : null);
|
|
6497
|
+
},
|
|
6498
|
+
onIsOpenChange({ isOpen: isOpen2, inputValue: inputValue2, selectedItem: selectedItem2 }) {
|
|
6499
|
+
if (isOpen2 === false) {
|
|
6500
|
+
setItems(itemsProp);
|
|
6501
|
+
if (inputValue2 === "") {
|
|
6502
|
+
selectItem(null);
|
|
6503
|
+
} else {
|
|
6504
|
+
setInputValue(selectedItem2 != null ? itemToString(selectedItem2) : "");
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
},
|
|
6508
|
+
isItemDisabled(item) {
|
|
6509
|
+
if (isDisabled || isReadOnly) {
|
|
6510
|
+
return !!isDisabled || !!isReadOnly;
|
|
6511
|
+
}
|
|
6512
|
+
if (item && item instanceof Object && "disabled" in item && item.disabled) {
|
|
6513
|
+
return true;
|
|
6514
|
+
}
|
|
6515
|
+
if (item && item instanceof Object && "readOnly" in item && item.readOnly) {
|
|
6516
|
+
return true;
|
|
6517
|
+
}
|
|
6518
|
+
if (disabledItems.includes(item)) {
|
|
6519
|
+
return true;
|
|
6520
|
+
}
|
|
6521
|
+
return false;
|
|
6393
6522
|
}
|
|
6394
|
-
);
|
|
6395
|
-
const
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
} : {},
|
|
6400
|
-
{
|
|
6401
|
-
[styles["error"]]: error
|
|
6523
|
+
});
|
|
6524
|
+
const firstRenderRef = useRef(true);
|
|
6525
|
+
useEffect(() => {
|
|
6526
|
+
if (firstRenderRef.current === true) {
|
|
6527
|
+
firstRenderRef.current = false;
|
|
6402
6528
|
}
|
|
6403
|
-
);
|
|
6404
|
-
|
|
6405
|
-
if (typeof disabled === "undefined") return;
|
|
6529
|
+
}, []);
|
|
6530
|
+
useEffect(() => {
|
|
6406
6531
|
setIsDisabled(disabled);
|
|
6407
|
-
}, [disabled
|
|
6408
|
-
|
|
6409
|
-
if (typeof readOnly === "undefined") return;
|
|
6532
|
+
}, [disabled]);
|
|
6533
|
+
useEffect(() => {
|
|
6410
6534
|
setIsReadOnly(readOnly);
|
|
6411
|
-
}, [readOnly
|
|
6412
|
-
|
|
6535
|
+
}, [readOnly]);
|
|
6536
|
+
useEffect(() => {
|
|
6537
|
+
if (firstRenderRef.current) return;
|
|
6538
|
+
const inputValueMatchesSelectedItem = selectedItem != null && inputValue === itemToString(selectedItem);
|
|
6539
|
+
const inputValueIsEmpty = inputValue == null || inputValue === "";
|
|
6540
|
+
if (!inputValueMatchesSelectedItem && !inputValueIsEmpty) {
|
|
6541
|
+
setItems(matchSorter(itemsProp, inputValue, filterOptions));
|
|
6542
|
+
setHasExactMatch(
|
|
6543
|
+
matchSorter(itemsProp, inputValue, {
|
|
6544
|
+
...filterOptions,
|
|
6545
|
+
threshold: matchSorter.rankings.EQUAL
|
|
6546
|
+
}).length > 0
|
|
6547
|
+
);
|
|
6548
|
+
} else {
|
|
6549
|
+
setItems(itemsProp);
|
|
6550
|
+
setHasExactMatch(true);
|
|
6551
|
+
}
|
|
6552
|
+
}, [itemsProp]);
|
|
6553
|
+
return /* @__PURE__ */ jsx(
|
|
6554
|
+
ComboboxLegacyContext.Provider,
|
|
6555
|
+
{
|
|
6556
|
+
value: {
|
|
6557
|
+
multiple: false,
|
|
6558
|
+
select: false,
|
|
6559
|
+
items,
|
|
6560
|
+
itemToString,
|
|
6561
|
+
itemToKey,
|
|
6562
|
+
isOpen,
|
|
6563
|
+
getLabelProps,
|
|
6564
|
+
getInputProps,
|
|
6565
|
+
getToggleButtonProps,
|
|
6566
|
+
getMenuProps,
|
|
6567
|
+
getItemProps,
|
|
6568
|
+
highlightedIndex,
|
|
6569
|
+
selectedItem,
|
|
6570
|
+
selectedItems: [],
|
|
6571
|
+
disabledItems,
|
|
6572
|
+
setDisabledItems,
|
|
6573
|
+
getSelectedItemProps: undefined,
|
|
6574
|
+
getDropdownProps: undefined,
|
|
6575
|
+
selectItem,
|
|
6576
|
+
inputValue,
|
|
6577
|
+
isDisabled,
|
|
6578
|
+
isReadOnly,
|
|
6579
|
+
setIsReadOnly,
|
|
6580
|
+
setIsDisabled,
|
|
6581
|
+
hasDisabledPopover,
|
|
6582
|
+
setHasDisabledPopover,
|
|
6583
|
+
hasEmpty,
|
|
6584
|
+
setHasEmpty,
|
|
6585
|
+
hasAddNew,
|
|
6586
|
+
setHasAddNew,
|
|
6587
|
+
onSelectItemAddNew,
|
|
6588
|
+
setOnSelectItemAddNew,
|
|
6589
|
+
hasExactMatch,
|
|
6590
|
+
setHasExactMatch,
|
|
6591
|
+
loading,
|
|
6592
|
+
referenceRef,
|
|
6593
|
+
contentRef,
|
|
6594
|
+
closeMenu
|
|
6595
|
+
},
|
|
6596
|
+
children: /* @__PURE__ */ jsx(
|
|
6597
|
+
"div",
|
|
6598
|
+
{
|
|
6599
|
+
className: ComboboxLegacyClassNames,
|
|
6600
|
+
"data-anv": "combobox",
|
|
6601
|
+
style: { ...style, ...layoutStyles },
|
|
6602
|
+
ref: wrapperDivRef,
|
|
6603
|
+
children: /* @__PURE__ */ jsx(
|
|
6604
|
+
PopoverLegacy,
|
|
6605
|
+
{
|
|
6606
|
+
root,
|
|
6607
|
+
open: isOpen,
|
|
6608
|
+
noPadding: true,
|
|
6609
|
+
disableCaret: true,
|
|
6610
|
+
fitScreen: true,
|
|
6611
|
+
disableFlipFallback: true,
|
|
6612
|
+
placement: "bottom-start",
|
|
6613
|
+
matchReferenceWidth: !disableMatchReferenceWidth,
|
|
6614
|
+
disableCloseOnClickOutside,
|
|
6615
|
+
onOutsidePress: handleOutsidePress,
|
|
6616
|
+
children
|
|
6617
|
+
}
|
|
6618
|
+
)
|
|
6619
|
+
}
|
|
6620
|
+
)
|
|
6621
|
+
}
|
|
6622
|
+
);
|
|
6623
|
+
};
|
|
6624
|
+
const ComboboxLegacyMultiple = function(props) {
|
|
6625
|
+
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
6626
|
+
const {
|
|
6627
|
+
className,
|
|
6628
|
+
style,
|
|
6629
|
+
children,
|
|
6630
|
+
open,
|
|
6631
|
+
items: itemsProp,
|
|
6632
|
+
itemToString: itemToStringProp,
|
|
6633
|
+
itemToKey: itemToKeyProp,
|
|
6634
|
+
onChange,
|
|
6635
|
+
onSelectedItemsChange,
|
|
6636
|
+
disableCloseOnClickOutside = false,
|
|
6637
|
+
disableMatchReferenceWidth = false,
|
|
6638
|
+
disableCloseOnSelectItem = false,
|
|
6639
|
+
disableClearInputValueOnSelectItem = false,
|
|
6640
|
+
filterOptions,
|
|
6641
|
+
loading = false,
|
|
6642
|
+
root,
|
|
6643
|
+
disabled,
|
|
6644
|
+
readOnly,
|
|
6645
|
+
stateReducer: _,
|
|
6646
|
+
onInputValueChange,
|
|
6647
|
+
initialSelectedItems,
|
|
6648
|
+
initialActiveIndex,
|
|
6649
|
+
defaultSelectedItems,
|
|
6650
|
+
defaultActiveIndex,
|
|
6651
|
+
activeIndex: activeIndexProp,
|
|
6652
|
+
selectedItems: selectedItemsProp,
|
|
6653
|
+
environment: environmentProp,
|
|
6654
|
+
...rest
|
|
6655
|
+
} = componentProps;
|
|
6656
|
+
const ComboboxLegacyClassNames = cx(styles$1["combobox"], className);
|
|
6657
|
+
const [items, setItems] = useState(itemsProp);
|
|
6658
|
+
const [hasAddNew, setHasAddNew] = useState(false);
|
|
6659
|
+
const [onSelectItemAddNew, setOnSelectItemAddNew] = useState(undefined);
|
|
6660
|
+
const [hasExactMatch, setHasExactMatch] = useState(false);
|
|
6661
|
+
const [hasDisabledPopover, setHasDisabledPopover] = useState(false);
|
|
6662
|
+
const [hasEmpty, setHasEmpty] = useState(false);
|
|
6663
|
+
const [disabledItems, setDisabledItems] = useState([]);
|
|
6664
|
+
const [isReadOnly, setIsReadOnly] = useState(readOnly);
|
|
6665
|
+
const [isDisabled, setIsDisabled] = useState(disabled);
|
|
6666
|
+
let storedSetInputValue = undefined;
|
|
6667
|
+
const referenceRef = useRef(null);
|
|
6668
|
+
const contentRef = useRef(null);
|
|
6669
|
+
const handleOutsidePress = (e) => {
|
|
6670
|
+
const clickedInsideReference = referenceRef.current && e.target != null && referenceRef.current.contains(e.target);
|
|
6671
|
+
if (!clickedInsideReference) {
|
|
6672
|
+
closeMenu();
|
|
6673
|
+
return true;
|
|
6674
|
+
} else {
|
|
6675
|
+
return false;
|
|
6676
|
+
}
|
|
6677
|
+
};
|
|
6678
|
+
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment$1();
|
|
6679
|
+
const showAddNew = hasAddNew && !hasExactMatch;
|
|
6680
|
+
const combinedItems = useMemo(
|
|
6681
|
+
() => showAddNew ? [...items, ADD_NEW$1] : items,
|
|
6682
|
+
[items, showAddNew]
|
|
6683
|
+
);
|
|
6684
|
+
const itemToString = itemToStringProp ?? defaultItemToString$1;
|
|
6685
|
+
const itemToKey = itemToKeyProp ?? defaultItemToKey$1;
|
|
6686
|
+
const {
|
|
6687
|
+
getSelectedItemProps,
|
|
6688
|
+
getDropdownProps,
|
|
6689
|
+
reset,
|
|
6690
|
+
selectedItems,
|
|
6691
|
+
addSelectedItem,
|
|
6692
|
+
removeSelectedItem,
|
|
6693
|
+
setSelectedItems
|
|
6694
|
+
} = useMultipleSelection({
|
|
6695
|
+
itemToKey,
|
|
6696
|
+
initialSelectedItems,
|
|
6697
|
+
initialActiveIndex,
|
|
6698
|
+
defaultSelectedItems,
|
|
6699
|
+
defaultActiveIndex,
|
|
6700
|
+
activeIndex: activeIndexProp,
|
|
6701
|
+
selectedItems: selectedItemsProp,
|
|
6702
|
+
environment: environmentProp ?? environment,
|
|
6703
|
+
stateReducer(state, { type, changes }) {
|
|
6704
|
+
switch (type) {
|
|
6705
|
+
// the Chip itself will handle "Backspace" and "Delete"
|
|
6706
|
+
// just return previous state
|
|
6707
|
+
case useMultipleSelection.stateChangeTypes.SelectedItemKeyDownBackspace:
|
|
6708
|
+
case useMultipleSelection.stateChangeTypes.SelectedItemKeyDownDelete:
|
|
6709
|
+
return state;
|
|
6710
|
+
case useMultipleSelection.stateChangeTypes.FunctionRemoveSelectedItem:
|
|
6711
|
+
return { ...changes, activeIndex: -1 };
|
|
6712
|
+
case useMultipleSelection.stateChangeTypes.FunctionReset:
|
|
6713
|
+
return { ...changes, selectedItems: [] };
|
|
6714
|
+
default:
|
|
6715
|
+
return changes;
|
|
6716
|
+
}
|
|
6717
|
+
},
|
|
6718
|
+
onStateChange({ type }) {
|
|
6719
|
+
switch (type) {
|
|
6720
|
+
case useMultipleSelection.stateChangeTypes.FunctionReset:
|
|
6721
|
+
storedSetInputValue?.("");
|
|
6722
|
+
break;
|
|
6723
|
+
}
|
|
6724
|
+
},
|
|
6725
|
+
onSelectedItemsChange(changes) {
|
|
6726
|
+
const { selectedItems: selectedItems2 } = changes;
|
|
6727
|
+
if (onChange != null) onChange(selectedItems2);
|
|
6728
|
+
if (onSelectedItemsChange != null) onSelectedItemsChange(changes);
|
|
6729
|
+
}
|
|
6730
|
+
});
|
|
6731
|
+
const {
|
|
6732
|
+
isOpen,
|
|
6733
|
+
getLabelProps,
|
|
6734
|
+
getInputProps,
|
|
6735
|
+
getToggleButtonProps,
|
|
6736
|
+
getMenuProps,
|
|
6737
|
+
getItemProps,
|
|
6738
|
+
highlightedIndex,
|
|
6739
|
+
selectedItem,
|
|
6740
|
+
selectItem,
|
|
6741
|
+
setInputValue,
|
|
6742
|
+
inputValue,
|
|
6743
|
+
closeMenu
|
|
6744
|
+
} = useCombobox$1({
|
|
6745
|
+
...rest,
|
|
6746
|
+
items: combinedItems,
|
|
6747
|
+
itemToString,
|
|
6748
|
+
itemToKey,
|
|
6749
|
+
selectedItem: null,
|
|
6750
|
+
isOpen: open,
|
|
6751
|
+
initialIsOpen: open,
|
|
6752
|
+
environment: environmentProp ?? environment,
|
|
6753
|
+
// NOTE: Reducer needs to be pure, side-effects should be in event handlers
|
|
6754
|
+
stateReducer(state, { type, changes }) {
|
|
6755
|
+
switch (type) {
|
|
6756
|
+
// keep ComboboxLegacy open onBlur, will call close using Popover's onOutsidePress
|
|
6757
|
+
case useCombobox$1.stateChangeTypes.InputBlur:
|
|
6758
|
+
return {
|
|
6759
|
+
...changes,
|
|
6760
|
+
inputValue: state.inputValue,
|
|
6761
|
+
selectedItem: null,
|
|
6762
|
+
isOpen: open != null ? open : true,
|
|
6763
|
+
highlightedIndex: state.highlightedIndex
|
|
6764
|
+
};
|
|
6765
|
+
case useCombobox$1.stateChangeTypes.InputKeyDownEnter:
|
|
6766
|
+
case useCombobox$1.stateChangeTypes.ItemClick:
|
|
6767
|
+
if (changes.selectedItem === ADD_NEW$1) {
|
|
6768
|
+
const stateInputValue = state.inputValue;
|
|
6769
|
+
setTimeout(() => {
|
|
6770
|
+
onSelectItemAddNew?.(stateInputValue);
|
|
6771
|
+
}, 0);
|
|
6772
|
+
return {
|
|
6773
|
+
...changes,
|
|
6774
|
+
selectedItem: state.selectedItem,
|
|
6775
|
+
inputValue: ""
|
|
6776
|
+
};
|
|
6777
|
+
} else {
|
|
6778
|
+
return {
|
|
6779
|
+
...changes,
|
|
6780
|
+
isOpen: open != null ? open : disableCloseOnSelectItem ? true : changes.isOpen,
|
|
6781
|
+
highlightedIndex: disableCloseOnSelectItem ? disableClearInputValueOnSelectItem || !state.inputValue ? state.highlightedIndex : 0 : changes.highlightedIndex,
|
|
6782
|
+
inputValue: disableClearInputValueOnSelectItem ? state.inputValue : ""
|
|
6783
|
+
};
|
|
6784
|
+
}
|
|
6785
|
+
// prevent this from closing the popover by default
|
|
6786
|
+
case useCombobox$1.stateChangeTypes.InputClick:
|
|
6787
|
+
return { ...changes, isOpen: open != null ? open : true };
|
|
6788
|
+
// prevent this from clearing the input value by default
|
|
6789
|
+
case useCombobox$1.stateChangeTypes.ControlledPropUpdatedSelectedItem:
|
|
6790
|
+
return { ...changes, inputValue: state.inputValue };
|
|
6791
|
+
default:
|
|
6792
|
+
return changes;
|
|
6793
|
+
}
|
|
6794
|
+
},
|
|
6795
|
+
onStateChange({ type, selectedItem: newSelectedItem }) {
|
|
6796
|
+
switch (type) {
|
|
6797
|
+
case useCombobox$1.stateChangeTypes.InputKeyDownEnter:
|
|
6798
|
+
case useCombobox$1.stateChangeTypes.ItemClick:
|
|
6799
|
+
case useCombobox$1.stateChangeTypes.InputBlur:
|
|
6800
|
+
if (newSelectedItem != null) {
|
|
6801
|
+
const itemAlreadySelected = selectedItems.some(
|
|
6802
|
+
(item) => itemToKey(item) === itemToKey(newSelectedItem)
|
|
6803
|
+
);
|
|
6804
|
+
if (itemAlreadySelected) {
|
|
6805
|
+
removeSelectedItem(newSelectedItem);
|
|
6806
|
+
} else {
|
|
6807
|
+
addSelectedItem(newSelectedItem);
|
|
6808
|
+
}
|
|
6809
|
+
}
|
|
6810
|
+
break;
|
|
6811
|
+
}
|
|
6812
|
+
},
|
|
6813
|
+
onInputValueChange: onInputValueChange ?? (({ inputValue: inputValue2, ...changes }) => {
|
|
6814
|
+
const { type, selectedItem: selectedItem2 } = changes;
|
|
6815
|
+
const inputValueMatchesSelectedItem = selectedItem2 != null && inputValue2 === itemToString(selectedItem2);
|
|
6816
|
+
const inputValueIsEmpty = inputValue2 == null || inputValue2 === "";
|
|
6817
|
+
if (type === useCombobox$1.stateChangeTypes.InputKeyDownEnter || type === useCombobox$1.stateChangeTypes.ItemClick) {
|
|
6818
|
+
setItems(itemsProp);
|
|
6819
|
+
setHasExactMatch(true);
|
|
6820
|
+
} else if (!inputValueMatchesSelectedItem && !inputValueIsEmpty) {
|
|
6821
|
+
setItems(matchSorter(itemsProp, inputValue2, filterOptions));
|
|
6822
|
+
setHasExactMatch(
|
|
6823
|
+
matchSorter(itemsProp, inputValue2, {
|
|
6824
|
+
...filterOptions,
|
|
6825
|
+
threshold: matchSorter.rankings.EQUAL
|
|
6826
|
+
}).length > 0
|
|
6827
|
+
);
|
|
6828
|
+
} else {
|
|
6829
|
+
setItems(itemsProp);
|
|
6830
|
+
setHasExactMatch(true);
|
|
6831
|
+
}
|
|
6832
|
+
}),
|
|
6833
|
+
onIsOpenChange({ isOpen: isOpen2 }) {
|
|
6834
|
+
if (isOpen2 === false) {
|
|
6835
|
+
setInputValue("");
|
|
6836
|
+
setItems(itemsProp);
|
|
6837
|
+
}
|
|
6838
|
+
},
|
|
6839
|
+
isItemDisabled(item) {
|
|
6840
|
+
if (isDisabled || isReadOnly) {
|
|
6841
|
+
return !!isDisabled || !!isReadOnly;
|
|
6842
|
+
}
|
|
6843
|
+
if (item && item instanceof Object && "disabled" in item && item.disabled) {
|
|
6844
|
+
return true;
|
|
6845
|
+
}
|
|
6846
|
+
if (item && item instanceof Object && "readOnly" in item && item.readOnly) {
|
|
6847
|
+
return true;
|
|
6848
|
+
}
|
|
6849
|
+
if (disabledItems.includes(item)) {
|
|
6850
|
+
return true;
|
|
6851
|
+
}
|
|
6852
|
+
return false;
|
|
6853
|
+
}
|
|
6854
|
+
});
|
|
6855
|
+
storedSetInputValue = setInputValue;
|
|
6856
|
+
const firstRenderRef = useRef(true);
|
|
6857
|
+
useEffect(() => {
|
|
6858
|
+
if (firstRenderRef.current === true) {
|
|
6859
|
+
firstRenderRef.current = false;
|
|
6860
|
+
}
|
|
6861
|
+
}, []);
|
|
6862
|
+
useEffect(() => {
|
|
6863
|
+
setIsDisabled(disabled);
|
|
6864
|
+
}, [disabled]);
|
|
6865
|
+
useEffect(() => {
|
|
6866
|
+
setIsReadOnly(readOnly);
|
|
6867
|
+
}, [readOnly]);
|
|
6868
|
+
useEffect(() => {
|
|
6869
|
+
if (firstRenderRef.current) return;
|
|
6870
|
+
const inputValueIsEmpty = inputValue == null || inputValue === "";
|
|
6871
|
+
if (!inputValueIsEmpty) {
|
|
6872
|
+
setItems(matchSorter(itemsProp, inputValue, filterOptions));
|
|
6873
|
+
setHasExactMatch(
|
|
6874
|
+
matchSorter(itemsProp, inputValue, {
|
|
6875
|
+
...filterOptions,
|
|
6876
|
+
threshold: matchSorter.rankings.EQUAL
|
|
6877
|
+
}).length > 0
|
|
6878
|
+
);
|
|
6879
|
+
} else {
|
|
6880
|
+
setItems(itemsProp);
|
|
6881
|
+
setHasExactMatch(true);
|
|
6882
|
+
}
|
|
6883
|
+
}, [itemsProp]);
|
|
6884
|
+
return /* @__PURE__ */ jsx(
|
|
6885
|
+
ComboboxLegacyContext.Provider,
|
|
6886
|
+
{
|
|
6887
|
+
value: {
|
|
6888
|
+
multiple: true,
|
|
6889
|
+
select: false,
|
|
6890
|
+
items,
|
|
6891
|
+
itemToString,
|
|
6892
|
+
itemToKey,
|
|
6893
|
+
isOpen,
|
|
6894
|
+
getLabelProps,
|
|
6895
|
+
getInputProps,
|
|
6896
|
+
getToggleButtonProps,
|
|
6897
|
+
getMenuProps,
|
|
6898
|
+
getItemProps,
|
|
6899
|
+
highlightedIndex,
|
|
6900
|
+
selectedItem,
|
|
6901
|
+
selectedItems,
|
|
6902
|
+
disabledItems,
|
|
6903
|
+
setDisabledItems,
|
|
6904
|
+
getSelectedItemProps,
|
|
6905
|
+
getDropdownProps,
|
|
6906
|
+
reset,
|
|
6907
|
+
addSelectedItem,
|
|
6908
|
+
removeSelectedItem,
|
|
6909
|
+
setSelectedItems,
|
|
6910
|
+
selectItem,
|
|
6911
|
+
inputValue,
|
|
6912
|
+
isDisabled,
|
|
6913
|
+
isReadOnly,
|
|
6914
|
+
setIsReadOnly,
|
|
6915
|
+
setIsDisabled,
|
|
6916
|
+
hasDisabledPopover,
|
|
6917
|
+
setHasDisabledPopover,
|
|
6918
|
+
hasEmpty,
|
|
6919
|
+
setHasEmpty,
|
|
6920
|
+
hasAddNew,
|
|
6921
|
+
setHasAddNew,
|
|
6922
|
+
onSelectItemAddNew,
|
|
6923
|
+
setOnSelectItemAddNew,
|
|
6924
|
+
hasExactMatch,
|
|
6925
|
+
setHasExactMatch,
|
|
6926
|
+
loading,
|
|
6927
|
+
referenceRef,
|
|
6928
|
+
contentRef,
|
|
6929
|
+
closeMenu
|
|
6930
|
+
},
|
|
6931
|
+
children: /* @__PURE__ */ jsx(
|
|
6932
|
+
"div",
|
|
6933
|
+
{
|
|
6934
|
+
className: ComboboxLegacyClassNames,
|
|
6935
|
+
"data-anv": "combobox",
|
|
6936
|
+
style: { ...style, ...layoutStyles },
|
|
6937
|
+
ref: wrapperDivRef,
|
|
6938
|
+
children: /* @__PURE__ */ jsx(
|
|
6939
|
+
PopoverLegacy,
|
|
6940
|
+
{
|
|
6941
|
+
root,
|
|
6942
|
+
open: !isDisabled && isOpen,
|
|
6943
|
+
noPadding: true,
|
|
6944
|
+
disableCaret: true,
|
|
6945
|
+
fitScreen: true,
|
|
6946
|
+
disableFlipFallback: true,
|
|
6947
|
+
placement: "bottom-start",
|
|
6948
|
+
matchReferenceWidth: !disableMatchReferenceWidth,
|
|
6949
|
+
disableCloseOnClickOutside,
|
|
6950
|
+
onOutsidePress: handleOutsidePress,
|
|
6951
|
+
children
|
|
6952
|
+
}
|
|
6953
|
+
)
|
|
6954
|
+
}
|
|
6955
|
+
)
|
|
6956
|
+
}
|
|
6957
|
+
);
|
|
6958
|
+
};
|
|
6959
|
+
const SelectLegacySingle = function(props) {
|
|
6960
|
+
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
6961
|
+
const {
|
|
6962
|
+
className,
|
|
6963
|
+
style,
|
|
6964
|
+
children,
|
|
6965
|
+
open,
|
|
6966
|
+
disabled,
|
|
6967
|
+
readOnly,
|
|
6968
|
+
items,
|
|
6969
|
+
itemToString: itemToStringProp,
|
|
6970
|
+
itemToKey: itemToKeyProp,
|
|
6971
|
+
onChange,
|
|
6972
|
+
disableClearSelection = false,
|
|
6973
|
+
disableCloseOnClickOutside = false,
|
|
6974
|
+
disableMatchReferenceWidth = false,
|
|
6975
|
+
disableCloseOnSelectItem = false,
|
|
6976
|
+
loading = false,
|
|
6977
|
+
root,
|
|
6978
|
+
environment: environmentProp,
|
|
6979
|
+
...rest
|
|
6980
|
+
} = componentProps;
|
|
6981
|
+
const ComboboxLegacyClassNames = cx(styles$1["combobox"], className);
|
|
6982
|
+
const [hasDisabledPopover, setHasDisabledPopover] = useState(false);
|
|
6983
|
+
const [hasEmpty, setHasEmpty] = useState(false);
|
|
6984
|
+
const [disabledItems, setDisabledItems] = useState([]);
|
|
6985
|
+
const [isReadOnly, setIsReadOnly] = useState(readOnly);
|
|
6986
|
+
const [isDisabled, setIsDisabled] = useState(disabled);
|
|
6987
|
+
const referenceRef = useRef(null);
|
|
6988
|
+
const contentRef = useRef(null);
|
|
6989
|
+
const handleOutsidePress = (e) => {
|
|
6990
|
+
const clickedInsideReference = referenceRef.current && e.target != null && referenceRef.current.contains(e.target);
|
|
6991
|
+
if (!clickedInsideReference) {
|
|
6992
|
+
closeMenu();
|
|
6993
|
+
return true;
|
|
6994
|
+
} else {
|
|
6995
|
+
return false;
|
|
6996
|
+
}
|
|
6997
|
+
};
|
|
6998
|
+
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment$1();
|
|
6999
|
+
const itemToString = itemToStringProp ?? defaultItemToString$1;
|
|
7000
|
+
const itemToKey = itemToKeyProp ?? defaultItemToKey$1;
|
|
7001
|
+
const {
|
|
7002
|
+
isOpen,
|
|
7003
|
+
getLabelProps,
|
|
7004
|
+
getToggleButtonProps,
|
|
7005
|
+
getMenuProps,
|
|
7006
|
+
getItemProps,
|
|
7007
|
+
highlightedIndex,
|
|
7008
|
+
selectedItem,
|
|
7009
|
+
selectItem,
|
|
7010
|
+
inputValue,
|
|
7011
|
+
closeMenu
|
|
7012
|
+
} = useSelect({
|
|
7013
|
+
...rest,
|
|
7014
|
+
items,
|
|
7015
|
+
itemToString,
|
|
7016
|
+
itemToKey,
|
|
7017
|
+
isOpen: open,
|
|
7018
|
+
initialIsOpen: open,
|
|
7019
|
+
environment: environmentProp ?? environment,
|
|
7020
|
+
// NOTE: Reducer needs to be pure, side-effects should be in event handlers
|
|
7021
|
+
stateReducer(state, { type, changes }) {
|
|
7022
|
+
switch (type) {
|
|
7023
|
+
// keep ComboboxLegacy open onBlur, will call close using Popover's onOutsidePress
|
|
7024
|
+
case useSelect.stateChangeTypes.ToggleButtonBlur:
|
|
7025
|
+
return {
|
|
7026
|
+
...changes,
|
|
7027
|
+
isOpen: open != null ? open : true,
|
|
7028
|
+
highlightedIndex: state.highlightedIndex
|
|
7029
|
+
};
|
|
7030
|
+
case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
7031
|
+
case useSelect.stateChangeTypes.ItemClick:
|
|
7032
|
+
return {
|
|
7033
|
+
...changes,
|
|
7034
|
+
isOpen: open != null ? open : disableCloseOnSelectItem ? true : changes.isOpen,
|
|
7035
|
+
highlightedIndex: disableCloseOnSelectItem ? 0 : changes.highlightedIndex
|
|
7036
|
+
};
|
|
7037
|
+
// prevent this from closing the popover by default
|
|
7038
|
+
case useSelect.stateChangeTypes.ToggleButtonClick:
|
|
7039
|
+
return { ...changes, isOpen: open != null ? open : true };
|
|
7040
|
+
default:
|
|
7041
|
+
return changes;
|
|
7042
|
+
}
|
|
7043
|
+
},
|
|
7044
|
+
onSelectedItemChange(changes) {
|
|
7045
|
+
const { selectedItem: selectedItem2 } = changes;
|
|
7046
|
+
if (onChange != null)
|
|
7047
|
+
onChange(selectedItem2 != null ? selectedItem2 : null);
|
|
7048
|
+
},
|
|
7049
|
+
isItemDisabled(item) {
|
|
7050
|
+
if (isDisabled || isReadOnly) {
|
|
7051
|
+
return !!isDisabled || !!isReadOnly;
|
|
7052
|
+
}
|
|
7053
|
+
if (item && item instanceof Object && "disabled" in item && item.disabled) {
|
|
7054
|
+
return true;
|
|
7055
|
+
}
|
|
7056
|
+
if (item && item instanceof Object && "readOnly" in item && item.readOnly) {
|
|
7057
|
+
return true;
|
|
7058
|
+
}
|
|
7059
|
+
if (disabledItems.includes(item)) {
|
|
7060
|
+
return true;
|
|
7061
|
+
}
|
|
7062
|
+
return false;
|
|
7063
|
+
}
|
|
7064
|
+
});
|
|
7065
|
+
useEffect(() => {
|
|
7066
|
+
setIsDisabled(disabled);
|
|
7067
|
+
}, [disabled]);
|
|
7068
|
+
useEffect(() => {
|
|
7069
|
+
setIsReadOnly(readOnly);
|
|
7070
|
+
}, [readOnly]);
|
|
7071
|
+
return /* @__PURE__ */ jsx(
|
|
7072
|
+
ComboboxLegacyContext.Provider,
|
|
7073
|
+
{
|
|
7074
|
+
value: {
|
|
7075
|
+
multiple: false,
|
|
7076
|
+
select: true,
|
|
7077
|
+
disableClearSelection,
|
|
7078
|
+
items,
|
|
7079
|
+
itemToString,
|
|
7080
|
+
itemToKey,
|
|
7081
|
+
isOpen,
|
|
7082
|
+
getLabelProps,
|
|
7083
|
+
getToggleButtonProps,
|
|
7084
|
+
getMenuProps,
|
|
7085
|
+
getItemProps,
|
|
7086
|
+
highlightedIndex,
|
|
7087
|
+
selectedItem,
|
|
7088
|
+
selectedItems: [],
|
|
7089
|
+
disabledItems,
|
|
7090
|
+
setDisabledItems,
|
|
7091
|
+
selectItem,
|
|
7092
|
+
inputValue,
|
|
7093
|
+
isDisabled,
|
|
7094
|
+
isReadOnly,
|
|
7095
|
+
setIsReadOnly,
|
|
7096
|
+
setIsDisabled,
|
|
7097
|
+
hasDisabledPopover,
|
|
7098
|
+
setHasDisabledPopover,
|
|
7099
|
+
hasEmpty,
|
|
7100
|
+
setHasEmpty,
|
|
7101
|
+
loading,
|
|
7102
|
+
referenceRef,
|
|
7103
|
+
contentRef,
|
|
7104
|
+
closeMenu
|
|
7105
|
+
},
|
|
7106
|
+
children: /* @__PURE__ */ jsx(
|
|
7107
|
+
"div",
|
|
7108
|
+
{
|
|
7109
|
+
className: ComboboxLegacyClassNames,
|
|
7110
|
+
"data-anv": "combobox",
|
|
7111
|
+
style: { ...style, ...layoutStyles },
|
|
7112
|
+
ref: wrapperDivRef,
|
|
7113
|
+
children: /* @__PURE__ */ jsx(
|
|
7114
|
+
PopoverLegacy,
|
|
7115
|
+
{
|
|
7116
|
+
root,
|
|
7117
|
+
open: isOpen,
|
|
7118
|
+
noPadding: true,
|
|
7119
|
+
disableCaret: true,
|
|
7120
|
+
fitScreen: true,
|
|
7121
|
+
disableFlipFallback: true,
|
|
7122
|
+
placement: "bottom-start",
|
|
7123
|
+
matchReferenceWidth: !disableMatchReferenceWidth,
|
|
7124
|
+
disableCloseOnClickOutside,
|
|
7125
|
+
onOutsidePress: handleOutsidePress,
|
|
7126
|
+
children
|
|
7127
|
+
}
|
|
7128
|
+
)
|
|
7129
|
+
}
|
|
7130
|
+
)
|
|
7131
|
+
}
|
|
7132
|
+
);
|
|
7133
|
+
};
|
|
7134
|
+
const SelectLegacyMultiple = function(props) {
|
|
7135
|
+
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
7136
|
+
const {
|
|
7137
|
+
className,
|
|
7138
|
+
style,
|
|
7139
|
+
children,
|
|
7140
|
+
open,
|
|
7141
|
+
items,
|
|
7142
|
+
itemToString: itemToStringProp,
|
|
7143
|
+
itemToKey: itemToKeyProp,
|
|
7144
|
+
onChange,
|
|
7145
|
+
onSelectedItemsChange,
|
|
7146
|
+
disableCloseOnClickOutside = false,
|
|
7147
|
+
disableMatchReferenceWidth = false,
|
|
7148
|
+
disableCloseOnSelectItem = false,
|
|
7149
|
+
loading = false,
|
|
7150
|
+
root,
|
|
7151
|
+
disabled,
|
|
7152
|
+
readOnly,
|
|
7153
|
+
stateReducer: _,
|
|
7154
|
+
initialSelectedItems,
|
|
7155
|
+
initialActiveIndex,
|
|
7156
|
+
defaultSelectedItems,
|
|
7157
|
+
defaultActiveIndex,
|
|
7158
|
+
activeIndex: activeIndexProp,
|
|
7159
|
+
selectedItems: selectedItemsProp,
|
|
7160
|
+
environment: environmentProp,
|
|
7161
|
+
...rest
|
|
7162
|
+
} = componentProps;
|
|
7163
|
+
const ComboboxLegacyClassNames = cx(styles$1["combobox"], className);
|
|
7164
|
+
const [hasDisabledPopover, setHasDisabledPopover] = useState(false);
|
|
7165
|
+
const [hasEmpty, setHasEmpty] = useState(false);
|
|
7166
|
+
const [disabledItems, setDisabledItems] = useState([]);
|
|
7167
|
+
const [isReadOnly, setIsReadOnly] = useState(readOnly);
|
|
7168
|
+
const [isDisabled, setIsDisabled] = useState(disabled);
|
|
7169
|
+
const referenceRef = useRef(null);
|
|
7170
|
+
const contentRef = useRef(null);
|
|
7171
|
+
const handleOutsidePress = (e) => {
|
|
7172
|
+
const clickedInsideReference = referenceRef.current && e.target != null && referenceRef.current.contains(e.target);
|
|
7173
|
+
if (!clickedInsideReference) {
|
|
7174
|
+
closeMenu();
|
|
7175
|
+
return true;
|
|
7176
|
+
} else {
|
|
7177
|
+
return false;
|
|
7178
|
+
}
|
|
7179
|
+
};
|
|
7180
|
+
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment$1();
|
|
7181
|
+
const itemToString = itemToStringProp ?? defaultItemToString$1;
|
|
7182
|
+
const itemToKey = itemToKeyProp ?? defaultItemToKey$1;
|
|
7183
|
+
const {
|
|
7184
|
+
getSelectedItemProps,
|
|
7185
|
+
getDropdownProps,
|
|
7186
|
+
reset,
|
|
7187
|
+
selectedItems,
|
|
7188
|
+
addSelectedItem,
|
|
7189
|
+
removeSelectedItem,
|
|
7190
|
+
setSelectedItems
|
|
7191
|
+
} = useMultipleSelection({
|
|
7192
|
+
itemToKey,
|
|
7193
|
+
initialSelectedItems,
|
|
7194
|
+
initialActiveIndex,
|
|
7195
|
+
defaultSelectedItems,
|
|
7196
|
+
defaultActiveIndex,
|
|
7197
|
+
activeIndex: activeIndexProp,
|
|
7198
|
+
selectedItems: selectedItemsProp,
|
|
7199
|
+
environment: environmentProp ?? environment,
|
|
7200
|
+
stateReducer(state, { type, changes }) {
|
|
7201
|
+
switch (type) {
|
|
7202
|
+
// the Chip itself will handle "Backspace" and "Delete"
|
|
7203
|
+
// just return previous state
|
|
7204
|
+
case useMultipleSelection.stateChangeTypes.SelectedItemKeyDownBackspace:
|
|
7205
|
+
case useMultipleSelection.stateChangeTypes.SelectedItemKeyDownDelete:
|
|
7206
|
+
return state;
|
|
7207
|
+
case useMultipleSelection.stateChangeTypes.FunctionRemoveSelectedItem:
|
|
7208
|
+
return { ...changes, activeIndex: -1 };
|
|
7209
|
+
case useMultipleSelection.stateChangeTypes.FunctionReset:
|
|
7210
|
+
return { ...changes, selectedItems: [] };
|
|
7211
|
+
default:
|
|
7212
|
+
return changes;
|
|
7213
|
+
}
|
|
7214
|
+
},
|
|
7215
|
+
onSelectedItemsChange(changes) {
|
|
7216
|
+
const { selectedItems: selectedItems2 } = changes;
|
|
7217
|
+
if (onChange != null) onChange(selectedItems2);
|
|
7218
|
+
if (onSelectedItemsChange != null) onSelectedItemsChange(changes);
|
|
7219
|
+
}
|
|
7220
|
+
});
|
|
7221
|
+
const {
|
|
7222
|
+
isOpen,
|
|
7223
|
+
getLabelProps,
|
|
7224
|
+
getToggleButtonProps,
|
|
7225
|
+
getMenuProps,
|
|
7226
|
+
getItemProps,
|
|
7227
|
+
highlightedIndex,
|
|
7228
|
+
selectedItem,
|
|
7229
|
+
selectItem,
|
|
7230
|
+
inputValue,
|
|
7231
|
+
closeMenu
|
|
7232
|
+
} = useSelect({
|
|
7233
|
+
...rest,
|
|
7234
|
+
items,
|
|
7235
|
+
itemToString,
|
|
7236
|
+
itemToKey,
|
|
7237
|
+
selectedItem: null,
|
|
7238
|
+
isOpen: open,
|
|
7239
|
+
initialIsOpen: open,
|
|
7240
|
+
environment: environmentProp ?? environment,
|
|
7241
|
+
// NOTE: Reducer needs to be pure, side-effects should be in event handlers
|
|
7242
|
+
stateReducer(state, { type, changes }) {
|
|
7243
|
+
switch (type) {
|
|
7244
|
+
// keep ComboboxLegacy open onBlur, will call close using Popover's onOutsidePress
|
|
7245
|
+
case useSelect.stateChangeTypes.ToggleButtonBlur:
|
|
7246
|
+
return {
|
|
7247
|
+
...changes,
|
|
7248
|
+
selectedItem: null,
|
|
7249
|
+
isOpen: open != null ? open : true,
|
|
7250
|
+
highlightedIndex: state.highlightedIndex
|
|
7251
|
+
};
|
|
7252
|
+
case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
7253
|
+
case useSelect.stateChangeTypes.ItemClick:
|
|
7254
|
+
return {
|
|
7255
|
+
...changes,
|
|
7256
|
+
isOpen: open != null ? open : disableCloseOnSelectItem ? true : changes.isOpen,
|
|
7257
|
+
highlightedIndex: disableCloseOnSelectItem ? 0 : changes.highlightedIndex
|
|
7258
|
+
};
|
|
7259
|
+
// prevent this from closing the popover by default
|
|
7260
|
+
case useSelect.stateChangeTypes.ToggleButtonClick:
|
|
7261
|
+
return { ...changes, isOpen: open != null ? open : true };
|
|
7262
|
+
default:
|
|
7263
|
+
return changes;
|
|
7264
|
+
}
|
|
7265
|
+
},
|
|
7266
|
+
onStateChange({ type, selectedItem: newSelectedItem }) {
|
|
7267
|
+
switch (type) {
|
|
7268
|
+
case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
7269
|
+
case useSelect.stateChangeTypes.ItemClick:
|
|
7270
|
+
case useSelect.stateChangeTypes.ToggleButtonBlur:
|
|
7271
|
+
if (newSelectedItem != null) {
|
|
7272
|
+
const itemAlreadySelected = selectedItems.some(
|
|
7273
|
+
(item) => itemToKey(item) === itemToKey(newSelectedItem)
|
|
7274
|
+
);
|
|
7275
|
+
if (itemAlreadySelected) {
|
|
7276
|
+
removeSelectedItem(newSelectedItem);
|
|
7277
|
+
} else {
|
|
7278
|
+
addSelectedItem(newSelectedItem);
|
|
7279
|
+
}
|
|
7280
|
+
}
|
|
7281
|
+
break;
|
|
7282
|
+
}
|
|
7283
|
+
},
|
|
7284
|
+
isItemDisabled(item) {
|
|
7285
|
+
if (isDisabled || isReadOnly) {
|
|
7286
|
+
return !!isDisabled || !!isReadOnly;
|
|
7287
|
+
}
|
|
7288
|
+
if (item && item instanceof Object && "disabled" in item && item.disabled) {
|
|
7289
|
+
return true;
|
|
7290
|
+
}
|
|
7291
|
+
if (item && item instanceof Object && "readOnly" in item && item.readOnly) {
|
|
7292
|
+
return true;
|
|
7293
|
+
}
|
|
7294
|
+
if (disabledItems.includes(item)) {
|
|
7295
|
+
return true;
|
|
7296
|
+
}
|
|
7297
|
+
return false;
|
|
7298
|
+
}
|
|
7299
|
+
});
|
|
7300
|
+
useEffect(() => {
|
|
7301
|
+
setIsDisabled(disabled);
|
|
7302
|
+
}, [disabled]);
|
|
7303
|
+
useEffect(() => {
|
|
7304
|
+
setIsReadOnly(readOnly);
|
|
7305
|
+
}, [readOnly]);
|
|
7306
|
+
return /* @__PURE__ */ jsx(
|
|
7307
|
+
ComboboxLegacyContext.Provider,
|
|
7308
|
+
{
|
|
7309
|
+
value: {
|
|
7310
|
+
multiple: true,
|
|
7311
|
+
select: true,
|
|
7312
|
+
items,
|
|
7313
|
+
itemToString,
|
|
7314
|
+
itemToKey,
|
|
7315
|
+
isOpen,
|
|
7316
|
+
getLabelProps,
|
|
7317
|
+
getToggleButtonProps,
|
|
7318
|
+
getMenuProps,
|
|
7319
|
+
getItemProps,
|
|
7320
|
+
highlightedIndex,
|
|
7321
|
+
selectedItem,
|
|
7322
|
+
selectedItems,
|
|
7323
|
+
disabledItems,
|
|
7324
|
+
setDisabledItems,
|
|
7325
|
+
getSelectedItemProps,
|
|
7326
|
+
getDropdownProps,
|
|
7327
|
+
reset,
|
|
7328
|
+
addSelectedItem,
|
|
7329
|
+
removeSelectedItem,
|
|
7330
|
+
setSelectedItems,
|
|
7331
|
+
selectItem,
|
|
7332
|
+
inputValue,
|
|
7333
|
+
isDisabled,
|
|
7334
|
+
isReadOnly,
|
|
7335
|
+
setIsReadOnly,
|
|
7336
|
+
setIsDisabled,
|
|
7337
|
+
hasDisabledPopover,
|
|
7338
|
+
setHasDisabledPopover,
|
|
7339
|
+
hasEmpty,
|
|
7340
|
+
setHasEmpty,
|
|
7341
|
+
loading,
|
|
7342
|
+
referenceRef,
|
|
7343
|
+
contentRef,
|
|
7344
|
+
closeMenu
|
|
7345
|
+
},
|
|
7346
|
+
children: /* @__PURE__ */ jsx(
|
|
7347
|
+
"div",
|
|
7348
|
+
{
|
|
7349
|
+
className: ComboboxLegacyClassNames,
|
|
7350
|
+
"data-anv": "combobox",
|
|
7351
|
+
style: { ...style, ...layoutStyles },
|
|
7352
|
+
ref: wrapperDivRef,
|
|
7353
|
+
children: /* @__PURE__ */ jsx(
|
|
7354
|
+
PopoverLegacy,
|
|
7355
|
+
{
|
|
7356
|
+
root,
|
|
7357
|
+
open: !isDisabled && isOpen,
|
|
7358
|
+
noPadding: true,
|
|
7359
|
+
disableCaret: true,
|
|
7360
|
+
fitScreen: true,
|
|
7361
|
+
disableFlipFallback: true,
|
|
7362
|
+
placement: "bottom-start",
|
|
7363
|
+
matchReferenceWidth: !disableMatchReferenceWidth,
|
|
7364
|
+
disableCloseOnClickOutside,
|
|
7365
|
+
onOutsidePress: handleOutsidePress,
|
|
7366
|
+
children
|
|
7367
|
+
}
|
|
7368
|
+
)
|
|
7369
|
+
}
|
|
7370
|
+
)
|
|
7371
|
+
}
|
|
7372
|
+
);
|
|
7373
|
+
};
|
|
7374
|
+
|
|
7375
|
+
const ComboboxLegacyTrigger = ({
|
|
7376
|
+
variant: variantProp = "combobox",
|
|
7377
|
+
className,
|
|
7378
|
+
label,
|
|
7379
|
+
size,
|
|
7380
|
+
error,
|
|
7381
|
+
hint,
|
|
7382
|
+
description,
|
|
7383
|
+
required,
|
|
7384
|
+
moreInfo,
|
|
7385
|
+
openMoreInfo,
|
|
7386
|
+
prefix,
|
|
7387
|
+
suffix,
|
|
7388
|
+
maxRows,
|
|
7389
|
+
id,
|
|
7390
|
+
disabled,
|
|
7391
|
+
readOnly,
|
|
7392
|
+
...rest
|
|
7393
|
+
}) => {
|
|
7394
|
+
const {
|
|
7395
|
+
select,
|
|
7396
|
+
disableClearSelection,
|
|
7397
|
+
isOpen,
|
|
7398
|
+
itemToString,
|
|
7399
|
+
getLabelProps,
|
|
7400
|
+
getInputProps,
|
|
7401
|
+
getToggleButtonProps,
|
|
7402
|
+
selectedItem,
|
|
7403
|
+
selectedItems,
|
|
7404
|
+
getSelectedItemProps,
|
|
7405
|
+
getDropdownProps,
|
|
7406
|
+
reset,
|
|
7407
|
+
removeSelectedItem,
|
|
7408
|
+
selectItem,
|
|
7409
|
+
inputValue,
|
|
7410
|
+
isDisabled,
|
|
7411
|
+
isReadOnly,
|
|
7412
|
+
referenceRef,
|
|
7413
|
+
contentRef,
|
|
7414
|
+
closeMenu,
|
|
7415
|
+
setIsDisabled,
|
|
7416
|
+
setIsReadOnly
|
|
7417
|
+
} = useComboboxLegacy();
|
|
7418
|
+
const variant = select ? "select" : "combobox";
|
|
7419
|
+
const context = usePopoverLegacyContext();
|
|
7420
|
+
const inputRef = useRef(null);
|
|
7421
|
+
const ComboboxLegacyTriggerClassNames = cx(styles$1["search-field"], {
|
|
7422
|
+
[styles$1["select"]]: variant === "select"
|
|
7423
|
+
});
|
|
7424
|
+
const noClearButton = isDisabled || isReadOnly || disableClearSelection;
|
|
7425
|
+
const ComboboxLegacyInputWrapperClassNames = cx(
|
|
7426
|
+
styles$1["input-wrapper"],
|
|
7427
|
+
className ? {
|
|
7428
|
+
[className]: variant === "select"
|
|
7429
|
+
} : {},
|
|
7430
|
+
{
|
|
7431
|
+
[styles$1["small"]]: size === "small",
|
|
7432
|
+
[styles$1["large"]]: size === "large",
|
|
7433
|
+
[styles$1["no-clear-button"]]: noClearButton
|
|
7434
|
+
}
|
|
7435
|
+
);
|
|
7436
|
+
const ComboboxLegacyInputClassNames = cx(
|
|
7437
|
+
styles$1["input"],
|
|
7438
|
+
className ? {
|
|
7439
|
+
[className]: variant === "combobox"
|
|
7440
|
+
} : {},
|
|
7441
|
+
{
|
|
7442
|
+
[styles$1["error"]]: error
|
|
7443
|
+
}
|
|
7444
|
+
);
|
|
7445
|
+
useLayoutEffect(() => {
|
|
7446
|
+
if (typeof disabled === "undefined") return;
|
|
7447
|
+
setIsDisabled(disabled);
|
|
7448
|
+
}, [disabled, setIsDisabled]);
|
|
7449
|
+
useLayoutEffect(() => {
|
|
7450
|
+
if (typeof readOnly === "undefined") return;
|
|
7451
|
+
setIsReadOnly(readOnly);
|
|
7452
|
+
}, [readOnly, setIsReadOnly]);
|
|
7453
|
+
const labelUid = "label" + useId();
|
|
7454
|
+
const helperUid = "helper" + useId();
|
|
7455
|
+
const placeholderUid = "placeholder" + useId();
|
|
7456
|
+
const ariaDescribedBy = `${helperUid} ${placeholderUid}`;
|
|
7457
|
+
const errorMessage = typeof error !== "boolean" ? error : undefined;
|
|
7458
|
+
const handleBlur = (e) => {
|
|
7459
|
+
const target = e.relatedTarget ?? e.target;
|
|
7460
|
+
const focusedOnReference = referenceRef.current && referenceRef.current.contains(target);
|
|
7461
|
+
const focusedOnContent = contentRef.current && contentRef.current.contains(target);
|
|
7462
|
+
if (!focusedOnReference && !focusedOnContent) {
|
|
7463
|
+
closeMenu();
|
|
7464
|
+
}
|
|
7465
|
+
};
|
|
7466
|
+
const rowsRef = useRef(null);
|
|
7467
|
+
const [stillCalculating, setStillCalculating] = useState(false);
|
|
7468
|
+
const [collapsedChips, setCollapsedChips] = useState(false);
|
|
7469
|
+
const [visibleChipsCount, setVisibleChipsCount] = useState(
|
|
7470
|
+
null
|
|
7471
|
+
);
|
|
7472
|
+
const [forceRenderCount, setForceRenderCount] = useState(0);
|
|
7473
|
+
useLayoutEffect(() => {
|
|
7474
|
+
if (maxRows === undefined) return;
|
|
7475
|
+
if (stillCalculating === false) {
|
|
7476
|
+
setStillCalculating(true);
|
|
7477
|
+
setCollapsedChips(false);
|
|
7478
|
+
setVisibleChipsCount(null);
|
|
7479
|
+
setForceRenderCount((x) => x + 1);
|
|
7480
|
+
} else if (rowsRef?.current?.children) {
|
|
7481
|
+
const children = rowsRef?.current?.children;
|
|
7482
|
+
const rowData = Array.from(children).reduce(
|
|
7483
|
+
(acc, child) => {
|
|
7484
|
+
const top = child.getBoundingClientRect().top;
|
|
7485
|
+
if (!acc.length) {
|
|
7486
|
+
return [{ count: 1, top }];
|
|
7487
|
+
} else if (acc[acc.length - 1].top === top) {
|
|
7488
|
+
return [
|
|
7489
|
+
...acc.slice(0, -1),
|
|
7490
|
+
{ count: acc[acc.length - 1].count + 1, top }
|
|
7491
|
+
];
|
|
7492
|
+
} else if (acc[acc.length - 1].top !== top) {
|
|
7493
|
+
return [...acc, { count: 1, top }];
|
|
7494
|
+
} else {
|
|
7495
|
+
return acc;
|
|
7496
|
+
}
|
|
7497
|
+
},
|
|
7498
|
+
[]
|
|
7499
|
+
);
|
|
7500
|
+
if (!rowData[maxRows] || visibleChipsCount === 0) {
|
|
7501
|
+
setStillCalculating(false);
|
|
7502
|
+
} else {
|
|
7503
|
+
setCollapsedChips(true);
|
|
7504
|
+
if (visibleChipsCount == null) {
|
|
7505
|
+
const firstGuess = Math.max(
|
|
7506
|
+
rowData.reduce((sum, row) => sum + row.count, -2),
|
|
7507
|
+
0
|
|
7508
|
+
);
|
|
7509
|
+
setVisibleChipsCount(firstGuess);
|
|
7510
|
+
} else {
|
|
7511
|
+
setVisibleChipsCount(visibleChipsCount - 1);
|
|
7512
|
+
}
|
|
7513
|
+
setForceRenderCount((x) => x + 1);
|
|
7514
|
+
}
|
|
7515
|
+
}
|
|
7516
|
+
}, [selectedItems.length, maxRows, forceRenderCount]);
|
|
7517
|
+
const selectedItemsDisplayCount = collapsedChips && maxRows != null && visibleChipsCount !== null ? visibleChipsCount : selectedItems.length;
|
|
7518
|
+
return /* @__PURE__ */ jsxs(
|
|
7519
|
+
"div",
|
|
7520
|
+
{
|
|
7521
|
+
className: ComboboxLegacyTriggerClassNames,
|
|
7522
|
+
"data-anv": "combobox-searchfield",
|
|
7523
|
+
ref: referenceRef,
|
|
7524
|
+
onBlur: handleBlur,
|
|
7525
|
+
children: [
|
|
7526
|
+
label ? /* @__PURE__ */ jsx(
|
|
7527
|
+
Label,
|
|
7528
|
+
{
|
|
7529
|
+
...getLabelProps({
|
|
7530
|
+
className: styles$1["label"],
|
|
7531
|
+
required,
|
|
7532
|
+
moreInfo,
|
|
7533
|
+
openMoreInfo,
|
|
7534
|
+
id: labelUid
|
|
7535
|
+
}),
|
|
7536
|
+
children: label
|
|
7537
|
+
}
|
|
7538
|
+
) : null,
|
|
7539
|
+
/* @__PURE__ */ jsxs(
|
|
7540
|
+
"div",
|
|
7541
|
+
{
|
|
7542
|
+
className: ComboboxLegacyInputWrapperClassNames,
|
|
7543
|
+
role: "presentation",
|
|
7544
|
+
...variant === "select" ? {
|
|
7545
|
+
...getToggleButtonProps({
|
|
7546
|
+
disabled: isDisabled,
|
|
7547
|
+
readOnly: isReadOnly,
|
|
7548
|
+
ref: context.refs.setReference,
|
|
7549
|
+
id,
|
|
7550
|
+
"aria-describedby": ariaDescribedBy,
|
|
7551
|
+
"aria-labelledby": labelUid
|
|
7552
|
+
})
|
|
7553
|
+
} : {
|
|
7554
|
+
ref: context.refs.setReference,
|
|
7555
|
+
onClick: () => inputRef.current?.focus()
|
|
7556
|
+
},
|
|
7557
|
+
children: [
|
|
7558
|
+
/* @__PURE__ */ jsxs("div", { className: styles$1["buttons-wrapper"], children: [
|
|
7559
|
+
(inputValue || selectedItem || selectedItems.length) && !noClearButton ? /* @__PURE__ */ jsx("div", { className: styles$1["close-button-wrapper"], children: /* @__PURE__ */ jsx(
|
|
7560
|
+
Button,
|
|
7561
|
+
{
|
|
7562
|
+
"aria-label": "clear selection",
|
|
7563
|
+
appearance: "ghost",
|
|
7564
|
+
size: "small",
|
|
7565
|
+
icon: SvgClose,
|
|
7566
|
+
className: styles$1["close-button"],
|
|
7567
|
+
onClick: (e) => {
|
|
7568
|
+
e.stopPropagation();
|
|
7569
|
+
if (reset != null) {
|
|
7570
|
+
reset();
|
|
7571
|
+
} else {
|
|
7572
|
+
selectItem(null);
|
|
7573
|
+
}
|
|
7574
|
+
},
|
|
7575
|
+
tabIndex: -1
|
|
7576
|
+
}
|
|
7577
|
+
) }) : null,
|
|
7578
|
+
/* @__PURE__ */ jsx("div", { className: styles$1["toggle-button-wrapper"], children: /* @__PURE__ */ jsx(
|
|
7579
|
+
Button,
|
|
7580
|
+
{
|
|
7581
|
+
...variant === "select" ? { tabIndex: -1 } : getToggleButtonProps(),
|
|
7582
|
+
className: styles$1["toggle-button"],
|
|
7583
|
+
"aria-label": "toggle menu",
|
|
7584
|
+
icon: SvgChevronRight,
|
|
7585
|
+
appearance: "ghost",
|
|
7586
|
+
size: "small",
|
|
7587
|
+
disabled: isDisabled
|
|
7588
|
+
}
|
|
7589
|
+
) })
|
|
7590
|
+
] }),
|
|
7591
|
+
/* @__PURE__ */ jsxs("div", { className: styles$1["rows-wrapper"], ref: rowsRef, children: [
|
|
7592
|
+
selectedItems.length && removeSelectedItem != null && getSelectedItemProps != null ? selectedItems.slice(0, selectedItemsDisplayCount).map((item, index) => {
|
|
7593
|
+
const { onClick, ...selectedItemProps } = getSelectedItemProps({
|
|
7594
|
+
selectedItem: item,
|
|
7595
|
+
index
|
|
7596
|
+
});
|
|
7597
|
+
return /* @__PURE__ */ jsx(
|
|
7598
|
+
"div",
|
|
7599
|
+
{
|
|
7600
|
+
className: styles$1["chip-wrapper"],
|
|
7601
|
+
children: /* @__PURE__ */ jsx(
|
|
7602
|
+
Chip,
|
|
7603
|
+
{
|
|
7604
|
+
...selectedItemProps,
|
|
7605
|
+
label: itemToString(item),
|
|
7606
|
+
onClose: isDisabled || isReadOnly ? undefined : (e) => {
|
|
7607
|
+
removeSelectedItem(item);
|
|
7608
|
+
},
|
|
7609
|
+
className: styles$1["chip"],
|
|
7610
|
+
title: itemToString(item)
|
|
7611
|
+
}
|
|
7612
|
+
)
|
|
7613
|
+
},
|
|
7614
|
+
`selected-item-${index}`
|
|
7615
|
+
);
|
|
7616
|
+
}) : null,
|
|
7617
|
+
collapsedChips && maxRows != null ? /* @__PURE__ */ jsx("div", { className: styles$1["chip-wrapper"], children: /* @__PURE__ */ jsx(
|
|
7618
|
+
Chip,
|
|
7619
|
+
{
|
|
7620
|
+
label: `+${selectedItems.length - selectedItemsDisplayCount}`,
|
|
7621
|
+
className: styles$1["chip"],
|
|
7622
|
+
title: selectedItems.slice(selectedItemsDisplayCount).map((item) => itemToString(item)).join(", ")
|
|
7623
|
+
}
|
|
7624
|
+
) }) : null,
|
|
7625
|
+
/* @__PURE__ */ jsxs(Flex, { className: styles$1["input-flex"], alignItems: "center", children: [
|
|
7626
|
+
prefix ? /* @__PURE__ */ jsx("div", { className: styles$1["prefix"], children: prefix }) : null,
|
|
7627
|
+
variant === "select" ? /* @__PURE__ */ jsx(
|
|
7628
|
+
"div",
|
|
7629
|
+
{
|
|
7630
|
+
...getDropdownProps != null ? getDropdownProps({
|
|
7631
|
+
className: ComboboxLegacyInputClassNames,
|
|
7632
|
+
required,
|
|
7633
|
+
preventKeyAction: isOpen
|
|
7634
|
+
}) : {
|
|
7635
|
+
className: ComboboxLegacyInputClassNames,
|
|
7636
|
+
required
|
|
7637
|
+
},
|
|
7638
|
+
children: selectedItems.length ? null : selectedItem ? itemToString(selectedItem) : /* @__PURE__ */ jsx(
|
|
7639
|
+
"span",
|
|
7640
|
+
{
|
|
7641
|
+
className: styles$1["fake-placeholder"],
|
|
7642
|
+
id: placeholderUid,
|
|
7643
|
+
children: rest.placeholder
|
|
7644
|
+
}
|
|
7645
|
+
)
|
|
7646
|
+
}
|
|
7647
|
+
) : /* @__PURE__ */ jsx(
|
|
7648
|
+
"input",
|
|
7649
|
+
{
|
|
7650
|
+
...getDropdownProps != null && getInputProps != null ? getInputProps(
|
|
7651
|
+
getDropdownProps({
|
|
7652
|
+
...rest,
|
|
7653
|
+
className: ComboboxLegacyInputClassNames,
|
|
7654
|
+
disabled: isDisabled,
|
|
7655
|
+
readOnly: isReadOnly,
|
|
7656
|
+
required,
|
|
7657
|
+
autoComplete: "off",
|
|
7658
|
+
id,
|
|
7659
|
+
"aria-describedby": ariaDescribedBy,
|
|
7660
|
+
"aria-labelledby": labelUid,
|
|
7661
|
+
preventKeyAction: isOpen,
|
|
7662
|
+
ref: inputRef
|
|
7663
|
+
})
|
|
7664
|
+
) : getInputProps != null ? getInputProps({
|
|
7665
|
+
...rest,
|
|
7666
|
+
className: ComboboxLegacyInputClassNames,
|
|
7667
|
+
disabled: isDisabled,
|
|
7668
|
+
readOnly: isReadOnly,
|
|
7669
|
+
required,
|
|
7670
|
+
autoComplete: "off",
|
|
7671
|
+
id,
|
|
7672
|
+
"aria-describedby": ariaDescribedBy,
|
|
7673
|
+
"aria-labelledby": labelUid,
|
|
7674
|
+
ref: inputRef
|
|
7675
|
+
}) : {}
|
|
7676
|
+
}
|
|
7677
|
+
),
|
|
7678
|
+
suffix ? /* @__PURE__ */ jsx("div", { className: styles$1["suffix"], children: suffix }) : null
|
|
7679
|
+
] })
|
|
7680
|
+
] })
|
|
7681
|
+
]
|
|
7682
|
+
}
|
|
7683
|
+
),
|
|
7684
|
+
hint || errorMessage || description ? /* @__PURE__ */ jsx(
|
|
7685
|
+
Helper,
|
|
7686
|
+
{
|
|
7687
|
+
id: helperUid,
|
|
7688
|
+
errorMessage,
|
|
7689
|
+
hint,
|
|
7690
|
+
description
|
|
7691
|
+
}
|
|
7692
|
+
) : null
|
|
7693
|
+
]
|
|
7694
|
+
}
|
|
7695
|
+
);
|
|
7696
|
+
};
|
|
7697
|
+
|
|
7698
|
+
const ComboboxLegacyContent = function({
|
|
7699
|
+
children,
|
|
7700
|
+
className,
|
|
7701
|
+
disablePopover = false,
|
|
7702
|
+
...rest
|
|
7703
|
+
}) {
|
|
7704
|
+
const {
|
|
7705
|
+
items,
|
|
7706
|
+
itemToKey,
|
|
7707
|
+
inputValue,
|
|
7708
|
+
selectedItem,
|
|
7709
|
+
selectedItems,
|
|
7710
|
+
setHasDisabledPopover,
|
|
7711
|
+
getMenuProps,
|
|
7712
|
+
getItemProps,
|
|
7713
|
+
isDisabled,
|
|
7714
|
+
isReadOnly,
|
|
7715
|
+
referenceRef,
|
|
7716
|
+
contentRef,
|
|
7717
|
+
closeMenu
|
|
7718
|
+
} = useComboboxLegacy();
|
|
7719
|
+
const ComboboxLegacyPopoverContentClassNames = cx(
|
|
7720
|
+
styles$1["popover-content"],
|
|
7721
|
+
className
|
|
7722
|
+
);
|
|
7723
|
+
useEffect(() => {
|
|
7724
|
+
setHasDisabledPopover(disablePopover);
|
|
7725
|
+
return () => {
|
|
7726
|
+
setHasDisabledPopover(false);
|
|
7727
|
+
};
|
|
7728
|
+
}, [disablePopover, setHasDisabledPopover]);
|
|
7729
|
+
const handleBlur = (e) => {
|
|
7730
|
+
const target = e.relatedTarget ?? e.target;
|
|
7731
|
+
const focusedOnReference = referenceRef.current && referenceRef.current.contains(target);
|
|
7732
|
+
const focusedOnContent = contentRef.current && contentRef.current.contains(target);
|
|
7733
|
+
if (!focusedOnReference && !focusedOnContent) {
|
|
7734
|
+
closeMenu();
|
|
7735
|
+
}
|
|
7736
|
+
};
|
|
7737
|
+
return disablePopover ? /* @__PURE__ */ jsx(
|
|
7738
|
+
"div",
|
|
7739
|
+
{
|
|
7740
|
+
...rest,
|
|
7741
|
+
className: ComboboxLegacyPopoverContentClassNames,
|
|
7742
|
+
ref: contentRef,
|
|
7743
|
+
onBlur: handleBlur,
|
|
7744
|
+
children: children ? children({
|
|
7745
|
+
items,
|
|
7746
|
+
inputValue,
|
|
7747
|
+
selectedItem,
|
|
7748
|
+
getMenuProps,
|
|
7749
|
+
getItemProps,
|
|
7750
|
+
listProps: {
|
|
7751
|
+
...getMenuProps({}, { suppressRefError: true }),
|
|
7752
|
+
style: {
|
|
7753
|
+
display: items.length ? "" : "none",
|
|
7754
|
+
overflow: "auto"
|
|
7755
|
+
}
|
|
7756
|
+
},
|
|
7757
|
+
options: items.map((item, index) => ({
|
|
7758
|
+
optionProps: {
|
|
7759
|
+
...getItemProps({
|
|
7760
|
+
item,
|
|
7761
|
+
index
|
|
7762
|
+
}),
|
|
7763
|
+
selected: itemToKey(selectedItem) === itemToKey(item) || selectedItems.some(
|
|
7764
|
+
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
7765
|
+
),
|
|
7766
|
+
disabled: !!isDisabled || !!isReadOnly
|
|
7767
|
+
// also see "isItemDisabled" function
|
|
7768
|
+
},
|
|
7769
|
+
item,
|
|
7770
|
+
index
|
|
7771
|
+
}))
|
|
7772
|
+
}) : null
|
|
7773
|
+
}
|
|
7774
|
+
) : /* @__PURE__ */ jsx(
|
|
7775
|
+
Popover.Content,
|
|
7776
|
+
{
|
|
7777
|
+
"data-anv": "combobox-content",
|
|
7778
|
+
...rest,
|
|
7779
|
+
className: ComboboxLegacyPopoverContentClassNames,
|
|
7780
|
+
ref: getMenuProps({ ref: contentRef }, { suppressRefError: true }).ref,
|
|
7781
|
+
onBlur: handleBlur,
|
|
7782
|
+
children: children ? children({
|
|
7783
|
+
items,
|
|
7784
|
+
inputValue,
|
|
7785
|
+
selectedItem,
|
|
7786
|
+
getMenuProps,
|
|
7787
|
+
getItemProps,
|
|
7788
|
+
listProps: {
|
|
7789
|
+
...getMenuProps({}, { suppressRefError: true }),
|
|
7790
|
+
style: {
|
|
7791
|
+
display: items.length ? undefined : "none",
|
|
7792
|
+
overflow: "auto"
|
|
7793
|
+
}
|
|
7794
|
+
},
|
|
7795
|
+
options: items.map((item, index) => ({
|
|
7796
|
+
optionProps: {
|
|
7797
|
+
...getItemProps({
|
|
7798
|
+
item,
|
|
7799
|
+
index
|
|
7800
|
+
}),
|
|
7801
|
+
selected: itemToKey(selectedItem) === itemToKey(item) || selectedItems.some(
|
|
7802
|
+
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
7803
|
+
),
|
|
7804
|
+
disabled: !!isDisabled || !!isReadOnly
|
|
7805
|
+
// also see "isItemDisabled" function
|
|
7806
|
+
},
|
|
7807
|
+
item,
|
|
7808
|
+
index
|
|
7809
|
+
}))
|
|
7810
|
+
}) : null
|
|
7811
|
+
}
|
|
7812
|
+
);
|
|
7813
|
+
};
|
|
7814
|
+
|
|
7815
|
+
const ComboboxLegacyList = function({
|
|
7816
|
+
children,
|
|
7817
|
+
...rest
|
|
7818
|
+
}) {
|
|
7819
|
+
const {
|
|
7820
|
+
getMenuProps,
|
|
7821
|
+
multiple,
|
|
7822
|
+
items,
|
|
7823
|
+
hasAddNew = false,
|
|
7824
|
+
hasEmpty,
|
|
7825
|
+
loading
|
|
7826
|
+
} = useComboboxLegacy();
|
|
7827
|
+
if (multiple) {
|
|
7828
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7829
|
+
/* @__PURE__ */ jsxs(
|
|
7830
|
+
"div",
|
|
7831
|
+
{
|
|
7832
|
+
...getMenuProps(rest),
|
|
7833
|
+
"data-anv": "combobox-list",
|
|
7834
|
+
className: cx(styles$1["listview"], styles$2["listview"]),
|
|
7835
|
+
style: {
|
|
7836
|
+
display: items.length || hasAddNew ? undefined : "none",
|
|
7837
|
+
overflow: "auto"
|
|
7838
|
+
},
|
|
7839
|
+
children: [
|
|
7840
|
+
children,
|
|
7841
|
+
loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Spinner, { className: styles$1["loading-spinner"] }) }) : null
|
|
7842
|
+
]
|
|
7843
|
+
}
|
|
7844
|
+
),
|
|
7845
|
+
!items.length && !hasEmpty ? /* @__PURE__ */ jsx("div", { className: styles$1["empty"], children: /* @__PURE__ */ jsx(Text, { subdued: true, size: "small", children: "No match found" }) }) : null
|
|
7846
|
+
] });
|
|
7847
|
+
} else {
|
|
7848
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7849
|
+
/* @__PURE__ */ jsxs(
|
|
7850
|
+
"ul",
|
|
7851
|
+
{
|
|
7852
|
+
...getMenuProps(rest),
|
|
7853
|
+
"data-anv": "combobox-list",
|
|
7854
|
+
className: styles$3["listbox"],
|
|
7855
|
+
style: {
|
|
7856
|
+
display: items.length || hasAddNew ? undefined : "none",
|
|
7857
|
+
overflow: "auto"
|
|
7858
|
+
},
|
|
7859
|
+
children: [
|
|
7860
|
+
children,
|
|
7861
|
+
loading ? /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Spinner, { className: styles$1["loading-spinner"] }) }) }) : null
|
|
7862
|
+
]
|
|
7863
|
+
}
|
|
7864
|
+
),
|
|
7865
|
+
!items.length && !hasEmpty ? /* @__PURE__ */ jsx("div", { className: styles$1["empty"], children: /* @__PURE__ */ jsx(Text, { subdued: true, size: "small", children: "No match found" }) }) : null
|
|
7866
|
+
] });
|
|
7867
|
+
}
|
|
7868
|
+
};
|
|
7869
|
+
|
|
7870
|
+
const ComboboxLegacyItem = function({
|
|
7871
|
+
children,
|
|
7872
|
+
disabled: disabledProp,
|
|
7873
|
+
item,
|
|
7874
|
+
index,
|
|
7875
|
+
alignItems,
|
|
7876
|
+
justifyItems,
|
|
7877
|
+
alignContent,
|
|
7878
|
+
justifyContent,
|
|
7879
|
+
placeItems,
|
|
7880
|
+
placeContent,
|
|
7881
|
+
gap,
|
|
7882
|
+
rowGap,
|
|
7883
|
+
columnGap,
|
|
7884
|
+
...rest
|
|
7885
|
+
}) {
|
|
7886
|
+
const {
|
|
7887
|
+
itemToKey,
|
|
7888
|
+
getItemProps,
|
|
7889
|
+
multiple,
|
|
7890
|
+
selectedItem,
|
|
7891
|
+
selectedItems,
|
|
7892
|
+
disabledItems,
|
|
7893
|
+
setDisabledItems,
|
|
7894
|
+
highlightedIndex
|
|
7895
|
+
} = useComboboxLegacy();
|
|
7896
|
+
const disabled = disabledProp || item && item instanceof Object && "disabled" in item && item.disabled;
|
|
7897
|
+
useEffect(() => {
|
|
7898
|
+
if (disabledProp && !disabledItems.includes(item)) {
|
|
7899
|
+
setDisabledItems([...disabledItems, item]);
|
|
7900
|
+
} else if (disabledItems.includes(item)) {
|
|
7901
|
+
setDisabledItems(disabledItems.filter((prevItem) => prevItem === item));
|
|
7902
|
+
}
|
|
7903
|
+
return () => {
|
|
7904
|
+
if (disabledItems.includes(item)) {
|
|
7905
|
+
setDisabledItems(disabledItems.filter((prevItem) => prevItem === item));
|
|
7906
|
+
}
|
|
7907
|
+
};
|
|
7908
|
+
}, [item, disabledProp, setDisabledItems]);
|
|
7909
|
+
if (multiple) {
|
|
7910
|
+
const checked = selectedItems.some(
|
|
7911
|
+
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
7912
|
+
);
|
|
7913
|
+
return /* @__PURE__ */ jsxs(
|
|
7914
|
+
"div",
|
|
7915
|
+
{
|
|
7916
|
+
"data-anv": "combobox-item",
|
|
7917
|
+
...getItemProps({
|
|
7918
|
+
item,
|
|
7919
|
+
index,
|
|
7920
|
+
"aria-selected": highlightedIndex === index,
|
|
7921
|
+
...rest
|
|
7922
|
+
}),
|
|
7923
|
+
className: cx(
|
|
7924
|
+
styles$1["listview-option"],
|
|
7925
|
+
styles$2["listview-option"]
|
|
7926
|
+
),
|
|
7927
|
+
children: [
|
|
7928
|
+
/* @__PURE__ */ jsx("div", { className: cx(styles$1["cell"], styles$2["cell"]), children: /* @__PURE__ */ jsx("div", { className: checkboxStyles["wrapper"], children: /* @__PURE__ */ jsxs("div", { className: checkboxStyles["checkbox"], children: [
|
|
7929
|
+
/* @__PURE__ */ jsx(
|
|
7930
|
+
"input",
|
|
7931
|
+
{
|
|
7932
|
+
type: "checkbox",
|
|
7933
|
+
checked,
|
|
7934
|
+
"aria-checked": checked,
|
|
7935
|
+
"aria-label": "Select",
|
|
7936
|
+
readOnly: true,
|
|
7937
|
+
...disabled ? { disabled: true } : {}
|
|
7938
|
+
}
|
|
7939
|
+
),
|
|
7940
|
+
/* @__PURE__ */ jsxs("span", { className: checkboxStyles["icon-wrapper"], "aria-hidden": true, children: [
|
|
7941
|
+
/* @__PURE__ */ jsx(
|
|
7942
|
+
Icon$2,
|
|
7943
|
+
{
|
|
7944
|
+
size: "large",
|
|
7945
|
+
svg: SvgIndeterminateCheckBox,
|
|
7946
|
+
className: checkboxStyles["icon-indeterminate"]
|
|
7947
|
+
}
|
|
7948
|
+
),
|
|
7949
|
+
/* @__PURE__ */ jsx(
|
|
7950
|
+
Icon$2,
|
|
7951
|
+
{
|
|
7952
|
+
size: "large",
|
|
7953
|
+
svg: SvgCheckBox,
|
|
7954
|
+
className: checkboxStyles["icon-checked"]
|
|
7955
|
+
}
|
|
7956
|
+
),
|
|
7957
|
+
/* @__PURE__ */ jsx(
|
|
7958
|
+
Icon$2,
|
|
7959
|
+
{
|
|
7960
|
+
size: "large",
|
|
7961
|
+
svg: SvgCheckBoxOutlineBlank,
|
|
7962
|
+
className: checkboxStyles["icon-unchecked"]
|
|
7963
|
+
}
|
|
7964
|
+
)
|
|
7965
|
+
] }),
|
|
7966
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true })
|
|
7967
|
+
] }) }) }),
|
|
7968
|
+
/* @__PURE__ */ jsx(
|
|
7969
|
+
Flex,
|
|
7970
|
+
{
|
|
7971
|
+
grow: 1,
|
|
7972
|
+
shrink: 1,
|
|
7973
|
+
alignItems,
|
|
7974
|
+
justifyItems,
|
|
7975
|
+
alignContent,
|
|
7976
|
+
justifyContent,
|
|
7977
|
+
placeItems,
|
|
7978
|
+
placeContent,
|
|
7979
|
+
gap,
|
|
7980
|
+
rowGap,
|
|
7981
|
+
columnGap,
|
|
7982
|
+
children
|
|
7983
|
+
}
|
|
7984
|
+
)
|
|
7985
|
+
]
|
|
7986
|
+
}
|
|
7987
|
+
);
|
|
7988
|
+
} else {
|
|
7989
|
+
return /* @__PURE__ */ jsxs(
|
|
7990
|
+
"li",
|
|
7991
|
+
{
|
|
7992
|
+
...getItemProps({
|
|
7993
|
+
item,
|
|
7994
|
+
index,
|
|
7995
|
+
"aria-selected": highlightedIndex === index,
|
|
7996
|
+
...rest
|
|
7997
|
+
}),
|
|
7998
|
+
"data-anv": "combobox-item",
|
|
7999
|
+
"data-checked": itemToKey(selectedItem) === itemToKey(item),
|
|
8000
|
+
className: styles$1["item"],
|
|
8001
|
+
...disabled ? { "aria-disabled": true } : {},
|
|
8002
|
+
children: [
|
|
8003
|
+
/* @__PURE__ */ jsx(
|
|
8004
|
+
Flex,
|
|
8005
|
+
{
|
|
8006
|
+
className: styles$3["children"],
|
|
8007
|
+
grow: 1,
|
|
8008
|
+
shrink: 1,
|
|
8009
|
+
alignItems,
|
|
8010
|
+
justifyItems,
|
|
8011
|
+
alignContent,
|
|
8012
|
+
justifyContent,
|
|
8013
|
+
placeItems,
|
|
8014
|
+
placeContent,
|
|
8015
|
+
gap,
|
|
8016
|
+
rowGap,
|
|
8017
|
+
columnGap,
|
|
8018
|
+
children
|
|
8019
|
+
}
|
|
8020
|
+
),
|
|
8021
|
+
/* @__PURE__ */ jsx(
|
|
8022
|
+
Icon$2,
|
|
8023
|
+
{
|
|
8024
|
+
"aria-hidden": true,
|
|
8025
|
+
svg: SvgCheck,
|
|
8026
|
+
inherit: true,
|
|
8027
|
+
className: styles$1["Icon"],
|
|
8028
|
+
style: {
|
|
8029
|
+
opacity: itemToKey(selectedItem) === itemToKey(item) ? 1 : 0
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
)
|
|
8033
|
+
]
|
|
8034
|
+
}
|
|
8035
|
+
);
|
|
8036
|
+
}
|
|
8037
|
+
};
|
|
8038
|
+
const ComboboxLegacyItemAddNew = function({
|
|
8039
|
+
onSelection,
|
|
8040
|
+
...props
|
|
8041
|
+
}) {
|
|
8042
|
+
const { items, setHasAddNew, hasExactMatch, setOnSelectItemAddNew } = useComboboxLegacy();
|
|
8043
|
+
useEffect(() => {
|
|
8044
|
+
setHasAddNew?.(true);
|
|
8045
|
+
return () => {
|
|
8046
|
+
setHasAddNew?.(false);
|
|
8047
|
+
};
|
|
8048
|
+
}, []);
|
|
8049
|
+
useEffect(() => {
|
|
8050
|
+
setOnSelectItemAddNew?.(() => onSelection);
|
|
8051
|
+
return () => {
|
|
8052
|
+
setOnSelectItemAddNew?.(undefined);
|
|
8053
|
+
};
|
|
8054
|
+
}, [setOnSelectItemAddNew, onSelection]);
|
|
8055
|
+
const firstRenderRef = useRef(true);
|
|
8056
|
+
useEffect(() => {
|
|
8057
|
+
if (firstRenderRef.current === true) {
|
|
8058
|
+
firstRenderRef.current = false;
|
|
8059
|
+
}
|
|
8060
|
+
}, []);
|
|
8061
|
+
return !hasExactMatch && !firstRenderRef.current ? /* @__PURE__ */ jsx(
|
|
8062
|
+
ComboboxLegacyItem,
|
|
8063
|
+
{
|
|
8064
|
+
...props,
|
|
8065
|
+
item: ADD_NEW$1,
|
|
8066
|
+
index: items.length
|
|
8067
|
+
}
|
|
8068
|
+
) : null;
|
|
8069
|
+
};
|
|
8070
|
+
|
|
8071
|
+
const ComboboxLegacyEmpty = function({
|
|
8072
|
+
children
|
|
8073
|
+
}) {
|
|
8074
|
+
const { items, setHasEmpty } = useComboboxLegacy();
|
|
8075
|
+
useEffect(() => {
|
|
8076
|
+
setHasEmpty?.(true);
|
|
8077
|
+
return () => {
|
|
8078
|
+
setHasEmpty?.(false);
|
|
8079
|
+
};
|
|
8080
|
+
});
|
|
8081
|
+
return !items.length ? children : null;
|
|
8082
|
+
};
|
|
8083
|
+
|
|
8084
|
+
const item = "_item_pdvrn_5";
|
|
8085
|
+
const group = "_group_pdvrn_18";
|
|
8086
|
+
const input = "_input_pdvrn_31";
|
|
8087
|
+
const prefix = "_prefix_pdvrn_59";
|
|
8088
|
+
const suffix = "_suffix_pdvrn_60";
|
|
8089
|
+
const combobox = "_combobox_pdvrn_75";
|
|
8090
|
+
const select = "_select_pdvrn_84";
|
|
8091
|
+
const chip = "_chip_pdvrn_180";
|
|
8092
|
+
const listview = "_listview_pdvrn_221";
|
|
8093
|
+
const empty = "_empty_pdvrn_229";
|
|
8094
|
+
const children = "_children_pdvrn_271";
|
|
8095
|
+
const Icon = "_Icon_pdvrn_274";
|
|
8096
|
+
const small = "_small_pdvrn_279";
|
|
8097
|
+
const large = "_large_pdvrn_282";
|
|
8098
|
+
const error = "_error_pdvrn_300";
|
|
8099
|
+
const disabled = "_disabled_pdvrn_313";
|
|
8100
|
+
const styles = {
|
|
8101
|
+
"buttons-wrapper": "_buttons-wrapper_pdvrn_3",
|
|
8102
|
+
"search-field": "_search-field_pdvrn_4",
|
|
8103
|
+
item: item,
|
|
8104
|
+
group: group,
|
|
8105
|
+
input: input,
|
|
8106
|
+
"input-wrapper": "_input-wrapper_pdvrn_32",
|
|
8107
|
+
"toggle-button-wrapper": "_toggle-button-wrapper_pdvrn_45",
|
|
8108
|
+
"close-button-wrapper": "_close-button-wrapper_pdvrn_46",
|
|
8109
|
+
prefix: prefix,
|
|
8110
|
+
suffix: suffix,
|
|
8111
|
+
combobox: combobox,
|
|
8112
|
+
select: select,
|
|
8113
|
+
"popover-content": "_popover-content_pdvrn_87",
|
|
8114
|
+
"no-clear-button": "_no-clear-button_pdvrn_106",
|
|
8115
|
+
"input-flex": "_input-flex_pdvrn_109",
|
|
8116
|
+
"fake-placeholder": "_fake-placeholder_pdvrn_137",
|
|
8117
|
+
"close-button": "_close-button_pdvrn_46",
|
|
8118
|
+
"toggle-button": "_toggle-button_pdvrn_45",
|
|
8119
|
+
"rows-wrapper": "_rows-wrapper_pdvrn_170",
|
|
8120
|
+
"chip-wrapper": "_chip-wrapper_pdvrn_180",
|
|
8121
|
+
chip: chip,
|
|
8122
|
+
listview: listview,
|
|
8123
|
+
"loading-spinner": "_loading-spinner_pdvrn_225",
|
|
8124
|
+
empty: empty,
|
|
8125
|
+
"group-title": "_group-title_pdvrn_240",
|
|
8126
|
+
children: children,
|
|
8127
|
+
Icon: Icon,
|
|
8128
|
+
small: small,
|
|
8129
|
+
large: large,
|
|
8130
|
+
error: error,
|
|
8131
|
+
"loading-infinite": "_loading-infinite_pdvrn_313",
|
|
8132
|
+
"loading-progress": "_loading-progress_pdvrn_313",
|
|
8133
|
+
disabled: disabled,
|
|
8134
|
+
"listview-option": "_listview-option_pdvrn_331"
|
|
8135
|
+
};
|
|
8136
|
+
|
|
8137
|
+
const ComboboxTrigger = ({
|
|
8138
|
+
variant: variantProp = "combobox",
|
|
8139
|
+
className,
|
|
8140
|
+
label,
|
|
8141
|
+
size,
|
|
8142
|
+
error,
|
|
8143
|
+
hint,
|
|
8144
|
+
description,
|
|
8145
|
+
required,
|
|
8146
|
+
moreInfo,
|
|
8147
|
+
openMoreInfo,
|
|
8148
|
+
prefix,
|
|
8149
|
+
suffix,
|
|
8150
|
+
maxRows,
|
|
8151
|
+
id,
|
|
8152
|
+
disabled,
|
|
8153
|
+
readOnly,
|
|
8154
|
+
...rest
|
|
8155
|
+
}) => {
|
|
8156
|
+
const {
|
|
8157
|
+
select,
|
|
8158
|
+
disableClearSelection,
|
|
8159
|
+
isOpen,
|
|
8160
|
+
itemToString,
|
|
8161
|
+
getLabelProps,
|
|
8162
|
+
getInputProps,
|
|
8163
|
+
getToggleButtonProps,
|
|
8164
|
+
getMenuProps,
|
|
8165
|
+
selectedItem,
|
|
8166
|
+
selectedItems,
|
|
8167
|
+
getSelectedItemProps,
|
|
8168
|
+
getDropdownProps,
|
|
8169
|
+
reset,
|
|
8170
|
+
removeSelectedItem,
|
|
8171
|
+
selectItem,
|
|
8172
|
+
inputValue,
|
|
8173
|
+
isDisabled,
|
|
8174
|
+
isReadOnly,
|
|
8175
|
+
referenceRef,
|
|
8176
|
+
closeMenu,
|
|
8177
|
+
setIsDisabled,
|
|
8178
|
+
setIsReadOnly
|
|
8179
|
+
} = useCombobox();
|
|
8180
|
+
const variant = select ? "select" : "combobox";
|
|
8181
|
+
const context = usePopoverContext();
|
|
8182
|
+
const inputRef = useRef(null);
|
|
8183
|
+
const ComboboxTriggerClassNames = cx(styles["search-field"], {
|
|
8184
|
+
[styles["select"]]: variant === "select"
|
|
8185
|
+
});
|
|
8186
|
+
const noClearButton = isDisabled || isReadOnly || disableClearSelection;
|
|
8187
|
+
const ComboboxInputWrapperClassNames = cx(
|
|
8188
|
+
styles["input-wrapper"],
|
|
8189
|
+
className ? {
|
|
8190
|
+
[className]: variant === "select"
|
|
8191
|
+
} : {},
|
|
8192
|
+
{
|
|
8193
|
+
[styles["small"]]: size === "small",
|
|
8194
|
+
[styles["large"]]: size === "large",
|
|
8195
|
+
[styles["no-clear-button"]]: noClearButton
|
|
8196
|
+
}
|
|
8197
|
+
);
|
|
8198
|
+
const ComboboxInputClassNames = cx(
|
|
8199
|
+
styles["input"],
|
|
8200
|
+
className ? {
|
|
8201
|
+
[className]: variant === "combobox"
|
|
8202
|
+
} : {},
|
|
8203
|
+
{
|
|
8204
|
+
[styles["error"]]: error
|
|
8205
|
+
}
|
|
8206
|
+
);
|
|
8207
|
+
useLayoutEffect(() => {
|
|
8208
|
+
if (typeof disabled === "undefined") return;
|
|
8209
|
+
setIsDisabled(disabled);
|
|
8210
|
+
}, [disabled, setIsDisabled]);
|
|
8211
|
+
useLayoutEffect(() => {
|
|
8212
|
+
if (typeof readOnly === "undefined") return;
|
|
8213
|
+
setIsReadOnly(readOnly);
|
|
8214
|
+
}, [readOnly, setIsReadOnly]);
|
|
8215
|
+
const helperUid = "helper" + useId();
|
|
6413
8216
|
const placeholderUid = "placeholder" + useId();
|
|
6414
8217
|
const ariaDescribedBy = `${helperUid} ${placeholderUid}`;
|
|
6415
8218
|
const errorMessage = typeof error !== "boolean" ? error : undefined;
|
|
@@ -6655,13 +8458,19 @@ const ComboboxTrigger = ({
|
|
|
6655
8458
|
);
|
|
6656
8459
|
};
|
|
6657
8460
|
const ComboboxSearchField$1 = (props) => {
|
|
8461
|
+
if (!supportsPopover()) return /* @__PURE__ */ jsx(ComboboxLegacyTrigger, { ...props });
|
|
6658
8462
|
return /* @__PURE__ */ jsx(ComboboxTrigger, { ...props, variant: "combobox" });
|
|
6659
8463
|
};
|
|
6660
8464
|
const ComboboxSelectTrigger$1 = (props) => {
|
|
8465
|
+
if (!supportsPopover())
|
|
8466
|
+
return /* @__PURE__ */ jsx(ComboboxLegacyTrigger, { ...props, variant: "select" });
|
|
6661
8467
|
return /* @__PURE__ */ jsx(ComboboxTrigger, { ...props, variant: "select" });
|
|
6662
8468
|
};
|
|
6663
8469
|
|
|
6664
|
-
const
|
|
8470
|
+
const ComboboxGroupContext = createContext(null);
|
|
8471
|
+
const ComboboxGroupProvider = ComboboxGroupContext.Provider;
|
|
8472
|
+
|
|
8473
|
+
const ComboboxContentElement = function({
|
|
6665
8474
|
children,
|
|
6666
8475
|
className,
|
|
6667
8476
|
disablePopover = false,
|
|
@@ -6679,7 +8488,8 @@ const ComboboxContent$1 = function({
|
|
|
6679
8488
|
isDisabled,
|
|
6680
8489
|
isReadOnly,
|
|
6681
8490
|
contentRef,
|
|
6682
|
-
closeMenu
|
|
8491
|
+
closeMenu,
|
|
8492
|
+
groups
|
|
6683
8493
|
} = useCombobox();
|
|
6684
8494
|
const ComboboxPopoverContentClassNames = cx(
|
|
6685
8495
|
styles["popover-content"],
|
|
@@ -6696,6 +8506,37 @@ const ComboboxContent$1 = function({
|
|
|
6696
8506
|
if (context?.controlled) return;
|
|
6697
8507
|
context?.popover.close?.(closeMenu);
|
|
6698
8508
|
};
|
|
8509
|
+
const resolveChildren = (groupItems) => children?.({
|
|
8510
|
+
items: groupItems,
|
|
8511
|
+
inputValue,
|
|
8512
|
+
selectedItem,
|
|
8513
|
+
getMenuProps,
|
|
8514
|
+
getItemProps,
|
|
8515
|
+
listProps: {
|
|
8516
|
+
...getMenuProps({}, { suppressRefError: true }),
|
|
8517
|
+
style: {
|
|
8518
|
+
display: groupItems.length ? undefined : "none",
|
|
8519
|
+
overflow: "auto"
|
|
8520
|
+
}
|
|
8521
|
+
},
|
|
8522
|
+
options: items.map((item, index) => ({
|
|
8523
|
+
optionProps: {
|
|
8524
|
+
...getItemProps({
|
|
8525
|
+
item,
|
|
8526
|
+
index
|
|
8527
|
+
}),
|
|
8528
|
+
tabIndex: disablePopover ? -1 : undefined,
|
|
8529
|
+
selected: itemToKey(selectedItem) === itemToKey(item) || selectedItems.some(
|
|
8530
|
+
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
8531
|
+
),
|
|
8532
|
+
disabled: !!isDisabled || !!isReadOnly
|
|
8533
|
+
// also see "isItemDisabled" function
|
|
8534
|
+
},
|
|
8535
|
+
item,
|
|
8536
|
+
index
|
|
8537
|
+
}))
|
|
8538
|
+
});
|
|
8539
|
+
const id = useId();
|
|
6699
8540
|
return disablePopover ? /* @__PURE__ */ jsx(
|
|
6700
8541
|
"div",
|
|
6701
8542
|
{
|
|
@@ -6703,35 +8544,27 @@ const ComboboxContent$1 = function({
|
|
|
6703
8544
|
className: ComboboxPopoverContentClassNames,
|
|
6704
8545
|
ref: contentRef,
|
|
6705
8546
|
onBlur: handleBlur,
|
|
6706
|
-
children:
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
item,
|
|
6723
|
-
index
|
|
6724
|
-
}),
|
|
6725
|
-
selected: itemToKey(selectedItem) === itemToKey(item) || selectedItems.some(
|
|
6726
|
-
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
8547
|
+
children: groups?.length ? groups.map((group) => /* @__PURE__ */ jsx(ComboboxGroupProvider, { value: group, children: /* @__PURE__ */ jsx(
|
|
8548
|
+
"ul",
|
|
8549
|
+
{
|
|
8550
|
+
"aria-labelledby": `${id}-group-${group.key}`,
|
|
8551
|
+
className: cx(styles["group"], styles$3["listbox"]),
|
|
8552
|
+
"data-anv": "combobox-group",
|
|
8553
|
+
role: "group",
|
|
8554
|
+
children: /* @__PURE__ */ jsxs("li", { children: [
|
|
8555
|
+
/* @__PURE__ */ jsx(
|
|
8556
|
+
Text,
|
|
8557
|
+
{
|
|
8558
|
+
className: styles["group-title"],
|
|
8559
|
+
id: `${id}-group-${group.key}`,
|
|
8560
|
+
variant: "eyebrow",
|
|
8561
|
+
children: group.label
|
|
8562
|
+
}
|
|
6727
8563
|
),
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
index
|
|
6733
|
-
}))
|
|
6734
|
-
}) : null
|
|
8564
|
+
resolveChildren(group.items)
|
|
8565
|
+
] })
|
|
8566
|
+
}
|
|
8567
|
+
) }, group.key)) : resolveChildren(items)
|
|
6735
8568
|
}
|
|
6736
8569
|
) : /* @__PURE__ */ jsx(
|
|
6737
8570
|
Popover.Content,
|
|
@@ -6742,41 +8575,58 @@ const ComboboxContent$1 = function({
|
|
|
6742
8575
|
ref: getMenuProps({ ref: contentRef }, { suppressRefError: true }).ref,
|
|
6743
8576
|
tabIndex: -1,
|
|
6744
8577
|
onBlur: handleBlur,
|
|
6745
|
-
children:
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
item,
|
|
6762
|
-
index
|
|
6763
|
-
}),
|
|
6764
|
-
tabIndex: -1,
|
|
6765
|
-
selected: itemToKey(selectedItem) === itemToKey(item) || selectedItems.some(
|
|
6766
|
-
(selectedItem2) => itemToKey(selectedItem2) === itemToKey(item)
|
|
8578
|
+
children: groups?.length ? groups.map((group) => /* @__PURE__ */ jsx(ComboboxGroupProvider, { value: group, children: /* @__PURE__ */ jsx(
|
|
8579
|
+
"ul",
|
|
8580
|
+
{
|
|
8581
|
+
"aria-labelledby": `${id}-group-${group.key}`,
|
|
8582
|
+
className: cx(styles["group"], styles$3["listbox"]),
|
|
8583
|
+
"data-anv": "combobox-group",
|
|
8584
|
+
role: "group",
|
|
8585
|
+
children: /* @__PURE__ */ jsxs("li", { children: [
|
|
8586
|
+
/* @__PURE__ */ jsx(
|
|
8587
|
+
Text,
|
|
8588
|
+
{
|
|
8589
|
+
className: styles["group-title"],
|
|
8590
|
+
id: `${id}-group-${group.key}`,
|
|
8591
|
+
variant: "eyebrow",
|
|
8592
|
+
children: group.label
|
|
8593
|
+
}
|
|
6767
8594
|
),
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
8595
|
+
resolveChildren(group.items)
|
|
8596
|
+
] })
|
|
8597
|
+
}
|
|
8598
|
+
) }, group.key)) : resolveChildren(items)
|
|
8599
|
+
}
|
|
8600
|
+
);
|
|
8601
|
+
};
|
|
8602
|
+
const ComboboxContent$1 = function({
|
|
8603
|
+
children,
|
|
8604
|
+
className,
|
|
8605
|
+
disablePopover = false,
|
|
8606
|
+
...rest
|
|
8607
|
+
}) {
|
|
8608
|
+
if (!supportsPopover())
|
|
8609
|
+
return /* @__PURE__ */ jsx(
|
|
8610
|
+
ComboboxLegacyContent,
|
|
8611
|
+
{
|
|
8612
|
+
disablePopover,
|
|
8613
|
+
className,
|
|
8614
|
+
...rest,
|
|
8615
|
+
children
|
|
8616
|
+
}
|
|
8617
|
+
);
|
|
8618
|
+
return /* @__PURE__ */ jsx(
|
|
8619
|
+
ComboboxContentElement,
|
|
8620
|
+
{
|
|
8621
|
+
disablePopover,
|
|
8622
|
+
className,
|
|
8623
|
+
...rest,
|
|
8624
|
+
children
|
|
6775
8625
|
}
|
|
6776
8626
|
);
|
|
6777
8627
|
};
|
|
6778
8628
|
|
|
6779
|
-
const
|
|
8629
|
+
const ComboboxListElement = function({
|
|
6780
8630
|
children,
|
|
6781
8631
|
...rest
|
|
6782
8632
|
}) {
|
|
@@ -6788,6 +8638,8 @@ const ComboboxList$1 = function({
|
|
|
6788
8638
|
hasEmpty,
|
|
6789
8639
|
loading
|
|
6790
8640
|
} = useCombobox();
|
|
8641
|
+
if (!supportsPopover())
|
|
8642
|
+
return /* @__PURE__ */ jsx(ComboboxLegacyList, { ...rest, children });
|
|
6791
8643
|
if (multiple) {
|
|
6792
8644
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6793
8645
|
/* @__PURE__ */ jsx(
|
|
@@ -6795,7 +8647,7 @@ const ComboboxList$1 = function({
|
|
|
6795
8647
|
{
|
|
6796
8648
|
...getMenuProps(rest),
|
|
6797
8649
|
"data-anv": "combobox-list",
|
|
6798
|
-
className: cx(styles["listview"], styles$
|
|
8650
|
+
className: cx(styles["listview"], styles$2["listview"]),
|
|
6799
8651
|
style: {
|
|
6800
8652
|
display: items.length || hasAddNew ? undefined : "none",
|
|
6801
8653
|
overflow: "auto"
|
|
@@ -6812,7 +8664,7 @@ const ComboboxList$1 = function({
|
|
|
6812
8664
|
{
|
|
6813
8665
|
...getMenuProps(rest),
|
|
6814
8666
|
"data-anv": "combobox-list",
|
|
6815
|
-
className: styles$
|
|
8667
|
+
className: styles$3["listbox"],
|
|
6816
8668
|
style: {
|
|
6817
8669
|
display: items.length || hasAddNew ? undefined : "none",
|
|
6818
8670
|
overflow: "auto"
|
|
@@ -6824,12 +8676,21 @@ const ComboboxList$1 = function({
|
|
|
6824
8676
|
] });
|
|
6825
8677
|
}
|
|
6826
8678
|
};
|
|
8679
|
+
const ComboboxList$1 = function({
|
|
8680
|
+
children,
|
|
8681
|
+
className,
|
|
8682
|
+
...rest
|
|
8683
|
+
}) {
|
|
8684
|
+
if (!supportsPopover())
|
|
8685
|
+
return /* @__PURE__ */ jsx(ComboboxLegacyList, { className, ...rest, children });
|
|
8686
|
+
return /* @__PURE__ */ jsx(ComboboxListElement, { className, ...rest, children });
|
|
8687
|
+
};
|
|
6827
8688
|
|
|
6828
|
-
const
|
|
8689
|
+
const ComboboxItemElement = function({
|
|
6829
8690
|
children,
|
|
6830
8691
|
disabled: disabledProp,
|
|
6831
8692
|
item,
|
|
6832
|
-
index,
|
|
8693
|
+
index: indexProp,
|
|
6833
8694
|
alignItems,
|
|
6834
8695
|
justifyItems,
|
|
6835
8696
|
alignContent,
|
|
@@ -6849,8 +8710,11 @@ const ComboboxItem$1 = function({
|
|
|
6849
8710
|
selectedItems,
|
|
6850
8711
|
disabledItems,
|
|
6851
8712
|
setDisabledItems,
|
|
6852
|
-
highlightedIndex
|
|
8713
|
+
highlightedIndex,
|
|
8714
|
+
items,
|
|
8715
|
+
groupBy
|
|
6853
8716
|
} = useCombobox();
|
|
8717
|
+
const index = groupBy ? items.indexOf(item) : indexProp;
|
|
6854
8718
|
const disabled = disabledProp || item && item instanceof Object && "disabled" in item && item.disabled;
|
|
6855
8719
|
useEffect(() => {
|
|
6856
8720
|
if (disabledProp && !disabledItems.includes(item)) {
|
|
@@ -6880,10 +8744,10 @@ const ComboboxItem$1 = function({
|
|
|
6880
8744
|
}),
|
|
6881
8745
|
className: cx(
|
|
6882
8746
|
styles["listview-option"],
|
|
6883
|
-
styles$
|
|
8747
|
+
styles$2["listview-option"]
|
|
6884
8748
|
),
|
|
6885
8749
|
children: [
|
|
6886
|
-
item !== ADD_NEW ? /* @__PURE__ */ jsx("div", { className: cx(styles["cell"], styles$
|
|
8750
|
+
item !== ADD_NEW ? /* @__PURE__ */ jsx("div", { className: cx(styles["cell"], styles$2["cell"]), children: /* @__PURE__ */ jsx("div", { className: checkboxStyles["wrapper"], children: /* @__PURE__ */ jsxs("div", { className: checkboxStyles["checkbox"], children: [
|
|
6887
8751
|
/* @__PURE__ */ jsx(
|
|
6888
8752
|
"input",
|
|
6889
8753
|
{
|
|
@@ -6898,7 +8762,7 @@ const ComboboxItem$1 = function({
|
|
|
6898
8762
|
),
|
|
6899
8763
|
/* @__PURE__ */ jsxs("span", { className: checkboxStyles["icon-wrapper"], "aria-hidden": true, children: [
|
|
6900
8764
|
/* @__PURE__ */ jsx(
|
|
6901
|
-
Icon$
|
|
8765
|
+
Icon$2,
|
|
6902
8766
|
{
|
|
6903
8767
|
size: "large",
|
|
6904
8768
|
svg: SvgIndeterminateCheckBox,
|
|
@@ -6906,7 +8770,7 @@ const ComboboxItem$1 = function({
|
|
|
6906
8770
|
}
|
|
6907
8771
|
),
|
|
6908
8772
|
/* @__PURE__ */ jsx(
|
|
6909
|
-
Icon$
|
|
8773
|
+
Icon$2,
|
|
6910
8774
|
{
|
|
6911
8775
|
size: "large",
|
|
6912
8776
|
svg: SvgCheckBox,
|
|
@@ -6914,7 +8778,7 @@ const ComboboxItem$1 = function({
|
|
|
6914
8778
|
}
|
|
6915
8779
|
),
|
|
6916
8780
|
/* @__PURE__ */ jsx(
|
|
6917
|
-
Icon$
|
|
8781
|
+
Icon$2,
|
|
6918
8782
|
{
|
|
6919
8783
|
size: "large",
|
|
6920
8784
|
svg: SvgCheckBoxOutlineBlank,
|
|
@@ -6962,7 +8826,7 @@ const ComboboxItem$1 = function({
|
|
|
6962
8826
|
/* @__PURE__ */ jsx(
|
|
6963
8827
|
Flex,
|
|
6964
8828
|
{
|
|
6965
|
-
className: styles$
|
|
8829
|
+
className: styles$3["children"],
|
|
6966
8830
|
grow: 1,
|
|
6967
8831
|
shrink: 1,
|
|
6968
8832
|
alignItems,
|
|
@@ -6978,7 +8842,7 @@ const ComboboxItem$1 = function({
|
|
|
6978
8842
|
}
|
|
6979
8843
|
),
|
|
6980
8844
|
/* @__PURE__ */ jsx(
|
|
6981
|
-
Icon$
|
|
8845
|
+
Icon$2,
|
|
6982
8846
|
{
|
|
6983
8847
|
"aria-hidden": true,
|
|
6984
8848
|
svg: SvgCheck,
|
|
@@ -6994,7 +8858,11 @@ const ComboboxItem$1 = function({
|
|
|
6994
8858
|
);
|
|
6995
8859
|
}
|
|
6996
8860
|
};
|
|
6997
|
-
const
|
|
8861
|
+
const ComboboxItem$1 = function(props) {
|
|
8862
|
+
if (!supportsPopover()) return /* @__PURE__ */ jsx(ComboboxLegacyItem, { ...props });
|
|
8863
|
+
return /* @__PURE__ */ jsx(ComboboxItemElement, { ...props });
|
|
8864
|
+
};
|
|
8865
|
+
const ComboboxItemAddNewElement = function({
|
|
6998
8866
|
onSelection,
|
|
6999
8867
|
...props
|
|
7000
8868
|
}) {
|
|
@@ -7026,8 +8894,12 @@ const ComboboxItemAddNew$1 = function({
|
|
|
7026
8894
|
}
|
|
7027
8895
|
) : null;
|
|
7028
8896
|
};
|
|
8897
|
+
const ComboboxItemAddNew$1 = function(props) {
|
|
8898
|
+
if (!supportsPopover()) return /* @__PURE__ */ jsx(ComboboxLegacyItemAddNew, { ...props });
|
|
8899
|
+
return /* @__PURE__ */ jsx(ComboboxItemAddNewElement, { ...props });
|
|
8900
|
+
};
|
|
7029
8901
|
|
|
7030
|
-
const
|
|
8902
|
+
const ComboboxEmptyElement = function({
|
|
7031
8903
|
children
|
|
7032
8904
|
}) {
|
|
7033
8905
|
const { items, setHasEmpty } = useCombobox();
|
|
@@ -7037,8 +8909,16 @@ const ComboboxEmpty$1 = function({
|
|
|
7037
8909
|
setHasEmpty?.(false);
|
|
7038
8910
|
};
|
|
7039
8911
|
});
|
|
8912
|
+
if (!supportsPopover()) return;
|
|
7040
8913
|
return !items.length ? children : null;
|
|
7041
8914
|
};
|
|
8915
|
+
const ComboboxEmpty$1 = function({
|
|
8916
|
+
children
|
|
8917
|
+
}) {
|
|
8918
|
+
if (!supportsPopover())
|
|
8919
|
+
return /* @__PURE__ */ jsx(ComboboxLegacyEmpty, { children });
|
|
8920
|
+
return /* @__PURE__ */ jsx(ComboboxEmptyElement, { children });
|
|
8921
|
+
};
|
|
7042
8922
|
|
|
7043
8923
|
const defaultItemToString = function(item) {
|
|
7044
8924
|
return item != null ? String(item) : "";
|
|
@@ -7059,6 +8939,40 @@ const useDownshiftEnvironment = () => {
|
|
|
7059
8939
|
return { ref: wrapperDivRef, environment };
|
|
7060
8940
|
};
|
|
7061
8941
|
|
|
8942
|
+
function useGroups({
|
|
8943
|
+
items,
|
|
8944
|
+
groupBy,
|
|
8945
|
+
groupToString,
|
|
8946
|
+
groupSorter = (a, b) => `${a}`.localeCompare(`${b}`)
|
|
8947
|
+
}) {
|
|
8948
|
+
const { groups, orderedItems } = useMemo(() => {
|
|
8949
|
+
if (!groupBy) return { groups: [], orderedItems: items };
|
|
8950
|
+
const groupsSansItems = [];
|
|
8951
|
+
const groupedItems = {};
|
|
8952
|
+
items.forEach((item) => {
|
|
8953
|
+
const groupKey = item[groupBy];
|
|
8954
|
+
if (!groupedItems[groupKey]) {
|
|
8955
|
+
groupedItems[groupKey] = [];
|
|
8956
|
+
}
|
|
8957
|
+
groupedItems[groupKey].push(item);
|
|
8958
|
+
});
|
|
8959
|
+
Object.keys(groupedItems).forEach((key) => {
|
|
8960
|
+
groupsSansItems.push({ key, label: groupToString?.(key) ?? key });
|
|
8961
|
+
});
|
|
8962
|
+
groupsSansItems.sort((a, b) => groupSorter(a.key, b.key));
|
|
8963
|
+
const orderedItems2 = [];
|
|
8964
|
+
const groups2 = groupsSansItems.map((group) => ({
|
|
8965
|
+
...group,
|
|
8966
|
+
items: groupedItems[group.key].map((item) => {
|
|
8967
|
+
orderedItems2.push(item);
|
|
8968
|
+
return item;
|
|
8969
|
+
})
|
|
8970
|
+
}));
|
|
8971
|
+
return { groups: groups2, orderedItems: orderedItems2 };
|
|
8972
|
+
}, [groupBy, groupSorter, groupToString, items]);
|
|
8973
|
+
return { groups, orderedItems };
|
|
8974
|
+
}
|
|
8975
|
+
|
|
7062
8976
|
const ADD_NEW = Symbol.for("add-new");
|
|
7063
8977
|
const ComboboxContext = createContext(null);
|
|
7064
8978
|
const useCombobox = function() {
|
|
@@ -7096,6 +9010,9 @@ const ComboboxSingle = function(props) {
|
|
|
7096
9010
|
root,
|
|
7097
9011
|
onInputValueChange,
|
|
7098
9012
|
environment: environmentProp,
|
|
9013
|
+
groupBy,
|
|
9014
|
+
groupToString,
|
|
9015
|
+
groupSorter,
|
|
7099
9016
|
...rest
|
|
7100
9017
|
} = componentProps;
|
|
7101
9018
|
const ComboboxClassNames = cx(styles["combobox"], className);
|
|
@@ -7115,10 +9032,22 @@ const ComboboxSingle = function(props) {
|
|
|
7115
9032
|
closeMenu();
|
|
7116
9033
|
};
|
|
7117
9034
|
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment();
|
|
9035
|
+
const { orderedItems: allItemsOrderedByGroup } = useGroups({
|
|
9036
|
+
items: itemsProp,
|
|
9037
|
+
groupBy,
|
|
9038
|
+
groupToString,
|
|
9039
|
+
groupSorter
|
|
9040
|
+
});
|
|
9041
|
+
const { groups: searchedGroups, orderedItems: searchedItemsOrderedByGroup } = useGroups({
|
|
9042
|
+
items,
|
|
9043
|
+
groupBy,
|
|
9044
|
+
groupToString,
|
|
9045
|
+
groupSorter
|
|
9046
|
+
});
|
|
7118
9047
|
const showAddNew = hasAddNew && !hasExactMatch;
|
|
7119
9048
|
const combinedItems = useMemo(
|
|
7120
|
-
() => showAddNew ? [...
|
|
7121
|
-
[
|
|
9049
|
+
() => showAddNew ? [...searchedItemsOrderedByGroup, ADD_NEW] : searchedItemsOrderedByGroup,
|
|
9050
|
+
[searchedItemsOrderedByGroup, showAddNew]
|
|
7122
9051
|
);
|
|
7123
9052
|
const itemToString = itemToStringProp ?? defaultItemToString;
|
|
7124
9053
|
const itemToKey = itemToKeyProp ?? defaultItemToKey;
|
|
@@ -7183,18 +9112,20 @@ const ComboboxSingle = function(props) {
|
|
|
7183
9112
|
const inputValueMatchesSelectedItem = selectedItem2 != null && inputValue2 === itemToString(selectedItem2);
|
|
7184
9113
|
const inputValueIsEmpty = inputValue2 == null || inputValue2 === "";
|
|
7185
9114
|
if (type === useCombobox$1.stateChangeTypes.InputKeyDownEnter || type === useCombobox$1.stateChangeTypes.ItemClick) {
|
|
7186
|
-
setItems(
|
|
9115
|
+
setItems(allItemsOrderedByGroup);
|
|
7187
9116
|
setHasExactMatch(true);
|
|
7188
9117
|
} else if (!inputValueMatchesSelectedItem && !inputValueIsEmpty && !disableFilter) {
|
|
7189
|
-
setItems(
|
|
9118
|
+
setItems(
|
|
9119
|
+
matchSorter(allItemsOrderedByGroup, inputValue2, filterOptions)
|
|
9120
|
+
);
|
|
7190
9121
|
setHasExactMatch(
|
|
7191
|
-
matchSorter(
|
|
9122
|
+
matchSorter(allItemsOrderedByGroup, inputValue2, {
|
|
7192
9123
|
...filterOptions,
|
|
7193
9124
|
threshold: matchSorter.rankings.EQUAL
|
|
7194
9125
|
}).length > 0
|
|
7195
9126
|
);
|
|
7196
9127
|
} else {
|
|
7197
|
-
setItems(
|
|
9128
|
+
setItems(allItemsOrderedByGroup);
|
|
7198
9129
|
setHasExactMatch(true);
|
|
7199
9130
|
}
|
|
7200
9131
|
}),
|
|
@@ -7206,7 +9137,7 @@ const ComboboxSingle = function(props) {
|
|
|
7206
9137
|
onIsOpenChange({ isOpen: isOpen2, inputValue: inputValue2, selectedItem: selectedItem2 }) {
|
|
7207
9138
|
if (isOpen2 === false) {
|
|
7208
9139
|
setTimeout(() => {
|
|
7209
|
-
setItems(
|
|
9140
|
+
setItems(allItemsOrderedByGroup);
|
|
7210
9141
|
if (inputValue2 === "") {
|
|
7211
9142
|
selectItem(null);
|
|
7212
9143
|
} else {
|
|
@@ -7250,25 +9181,25 @@ const ComboboxSingle = function(props) {
|
|
|
7250
9181
|
const inputValueMatchesSelectedItem = selectedItem != null && inputValue === itemToString(selectedItem);
|
|
7251
9182
|
const inputValueIsEmpty = inputValue == null || inputValue === "";
|
|
7252
9183
|
if (!inputValueMatchesSelectedItem && !inputValueIsEmpty && !disableFilter) {
|
|
7253
|
-
setItems(matchSorter(
|
|
9184
|
+
setItems(matchSorter(allItemsOrderedByGroup, inputValue, filterOptions));
|
|
7254
9185
|
setHasExactMatch(
|
|
7255
|
-
matchSorter(
|
|
9186
|
+
matchSorter(allItemsOrderedByGroup, inputValue, {
|
|
7256
9187
|
...filterOptions,
|
|
7257
9188
|
threshold: matchSorter.rankings.EQUAL
|
|
7258
9189
|
}).length > 0
|
|
7259
9190
|
);
|
|
7260
9191
|
} else {
|
|
7261
|
-
setItems(
|
|
9192
|
+
setItems(allItemsOrderedByGroup);
|
|
7262
9193
|
setHasExactMatch(true);
|
|
7263
9194
|
}
|
|
7264
|
-
}, [
|
|
9195
|
+
}, [allItemsOrderedByGroup]);
|
|
7265
9196
|
return /* @__PURE__ */ jsx(
|
|
7266
9197
|
ComboboxContext.Provider,
|
|
7267
9198
|
{
|
|
7268
9199
|
value: {
|
|
7269
9200
|
multiple: false,
|
|
7270
9201
|
select: false,
|
|
7271
|
-
items,
|
|
9202
|
+
items: searchedItemsOrderedByGroup,
|
|
7272
9203
|
itemToString,
|
|
7273
9204
|
itemToKey,
|
|
7274
9205
|
isOpen,
|
|
@@ -7303,7 +9234,10 @@ const ComboboxSingle = function(props) {
|
|
|
7303
9234
|
loading,
|
|
7304
9235
|
referenceRef,
|
|
7305
9236
|
contentRef,
|
|
7306
|
-
closeMenu
|
|
9237
|
+
closeMenu,
|
|
9238
|
+
groupBy,
|
|
9239
|
+
groupToString,
|
|
9240
|
+
groups: searchedGroups
|
|
7307
9241
|
},
|
|
7308
9242
|
children: /* @__PURE__ */ jsx(
|
|
7309
9243
|
"div",
|
|
@@ -7366,6 +9300,8 @@ const ComboboxMultiple = function(props) {
|
|
|
7366
9300
|
activeIndex: activeIndexProp,
|
|
7367
9301
|
selectedItems: selectedItemsProp,
|
|
7368
9302
|
environment: environmentProp,
|
|
9303
|
+
groupBy,
|
|
9304
|
+
groupToString,
|
|
7369
9305
|
...rest
|
|
7370
9306
|
} = componentProps;
|
|
7371
9307
|
const ComboboxClassNames = cx(styles["combobox"], className);
|
|
@@ -7386,10 +9322,20 @@ const ComboboxMultiple = function(props) {
|
|
|
7386
9322
|
closeMenu();
|
|
7387
9323
|
};
|
|
7388
9324
|
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment();
|
|
9325
|
+
const { orderedItems: allItemsOrderedByGroup } = useGroups({
|
|
9326
|
+
items: itemsProp,
|
|
9327
|
+
groupBy,
|
|
9328
|
+
groupToString
|
|
9329
|
+
});
|
|
9330
|
+
const { groups: searchedGroups, orderedItems: searchedItemsOrderedByGroup } = useGroups({
|
|
9331
|
+
items,
|
|
9332
|
+
groupBy,
|
|
9333
|
+
groupToString
|
|
9334
|
+
});
|
|
7389
9335
|
const showAddNew = hasAddNew && !hasExactMatch;
|
|
7390
9336
|
const combinedItems = useMemo(
|
|
7391
|
-
() => showAddNew ? [...items, ADD_NEW] :
|
|
7392
|
-
[items, showAddNew]
|
|
9337
|
+
() => showAddNew ? [...items, ADD_NEW] : searchedItemsOrderedByGroup,
|
|
9338
|
+
[items, searchedItemsOrderedByGroup, showAddNew]
|
|
7393
9339
|
);
|
|
7394
9340
|
const itemToString = itemToStringProp ?? defaultItemToString;
|
|
7395
9341
|
const itemToKey = itemToKeyProp ?? defaultItemToKey;
|
|
@@ -7529,18 +9475,20 @@ const ComboboxMultiple = function(props) {
|
|
|
7529
9475
|
const inputValueMatchesSelectedItem = selectedItem2 != null && inputValue2 === itemToString(selectedItem2);
|
|
7530
9476
|
const inputValueIsEmpty = inputValue2 == null || inputValue2 === "";
|
|
7531
9477
|
if (type === useCombobox$1.stateChangeTypes.InputKeyDownEnter || type === useCombobox$1.stateChangeTypes.ItemClick) {
|
|
7532
|
-
setItems(
|
|
9478
|
+
setItems(allItemsOrderedByGroup);
|
|
7533
9479
|
setHasExactMatch(true);
|
|
7534
9480
|
} else if (!inputValueMatchesSelectedItem && !inputValueIsEmpty && !disableFilter) {
|
|
7535
|
-
setItems(
|
|
9481
|
+
setItems(
|
|
9482
|
+
matchSorter(allItemsOrderedByGroup, inputValue2, filterOptions)
|
|
9483
|
+
);
|
|
7536
9484
|
setHasExactMatch(
|
|
7537
|
-
matchSorter(
|
|
9485
|
+
matchSorter(allItemsOrderedByGroup, inputValue2, {
|
|
7538
9486
|
...filterOptions,
|
|
7539
9487
|
threshold: matchSorter.rankings.EQUAL
|
|
7540
9488
|
}).length > 0
|
|
7541
9489
|
);
|
|
7542
9490
|
} else {
|
|
7543
|
-
setItems(
|
|
9491
|
+
setItems(allItemsOrderedByGroup);
|
|
7544
9492
|
setHasExactMatch(true);
|
|
7545
9493
|
}
|
|
7546
9494
|
}),
|
|
@@ -7548,7 +9496,7 @@ const ComboboxMultiple = function(props) {
|
|
|
7548
9496
|
if (isOpen2 === false) {
|
|
7549
9497
|
setTimeout(() => {
|
|
7550
9498
|
setInputValue("");
|
|
7551
|
-
setItems(
|
|
9499
|
+
setItems(allItemsOrderedByGroup);
|
|
7552
9500
|
}, 200);
|
|
7553
9501
|
}
|
|
7554
9502
|
},
|
|
@@ -7603,7 +9551,7 @@ const ComboboxMultiple = function(props) {
|
|
|
7603
9551
|
value: {
|
|
7604
9552
|
multiple: true,
|
|
7605
9553
|
select: false,
|
|
7606
|
-
items,
|
|
9554
|
+
items: searchedItemsOrderedByGroup,
|
|
7607
9555
|
itemToString,
|
|
7608
9556
|
itemToKey,
|
|
7609
9557
|
isOpen,
|
|
@@ -7642,7 +9590,10 @@ const ComboboxMultiple = function(props) {
|
|
|
7642
9590
|
loading,
|
|
7643
9591
|
referenceRef,
|
|
7644
9592
|
contentRef,
|
|
7645
|
-
closeMenu
|
|
9593
|
+
closeMenu,
|
|
9594
|
+
groupBy,
|
|
9595
|
+
groupToString,
|
|
9596
|
+
groups: searchedGroups
|
|
7646
9597
|
},
|
|
7647
9598
|
children: /* @__PURE__ */ jsx(
|
|
7648
9599
|
"div",
|
|
@@ -7693,6 +9644,8 @@ const SelectSingle = function(props) {
|
|
|
7693
9644
|
minPopoverHeight,
|
|
7694
9645
|
root,
|
|
7695
9646
|
environment: environmentProp,
|
|
9647
|
+
groupBy,
|
|
9648
|
+
groupToString,
|
|
7696
9649
|
...rest
|
|
7697
9650
|
} = componentProps;
|
|
7698
9651
|
const ComboboxClassNames = cx(styles["combobox"], className);
|
|
@@ -7710,6 +9663,11 @@ const SelectSingle = function(props) {
|
|
|
7710
9663
|
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment();
|
|
7711
9664
|
const itemToString = itemToStringProp ?? defaultItemToString;
|
|
7712
9665
|
const itemToKey = itemToKeyProp ?? defaultItemToKey;
|
|
9666
|
+
const { groups, orderedItems } = useGroups({
|
|
9667
|
+
items,
|
|
9668
|
+
groupBy,
|
|
9669
|
+
groupToString
|
|
9670
|
+
});
|
|
7713
9671
|
const {
|
|
7714
9672
|
isOpen,
|
|
7715
9673
|
getLabelProps,
|
|
@@ -7723,7 +9681,7 @@ const SelectSingle = function(props) {
|
|
|
7723
9681
|
closeMenu
|
|
7724
9682
|
} = useSelect({
|
|
7725
9683
|
...rest,
|
|
7726
|
-
items,
|
|
9684
|
+
items: orderedItems,
|
|
7727
9685
|
itemToString,
|
|
7728
9686
|
itemToKey,
|
|
7729
9687
|
isOpen: open,
|
|
@@ -7777,7 +9735,7 @@ const SelectSingle = function(props) {
|
|
|
7777
9735
|
multiple: false,
|
|
7778
9736
|
select: true,
|
|
7779
9737
|
disableClearSelection,
|
|
7780
|
-
items,
|
|
9738
|
+
items: orderedItems,
|
|
7781
9739
|
itemToString,
|
|
7782
9740
|
itemToKey,
|
|
7783
9741
|
isOpen,
|
|
@@ -7803,7 +9761,10 @@ const SelectSingle = function(props) {
|
|
|
7803
9761
|
loading,
|
|
7804
9762
|
referenceRef,
|
|
7805
9763
|
contentRef,
|
|
7806
|
-
closeMenu
|
|
9764
|
+
closeMenu,
|
|
9765
|
+
groups,
|
|
9766
|
+
groupBy,
|
|
9767
|
+
groupToString
|
|
7807
9768
|
},
|
|
7808
9769
|
children: /* @__PURE__ */ jsx(
|
|
7809
9770
|
"div",
|
|
@@ -7862,6 +9823,8 @@ const SelectMultiple = function(props) {
|
|
|
7862
9823
|
activeIndex: activeIndexProp,
|
|
7863
9824
|
selectedItems: selectedItemsProp,
|
|
7864
9825
|
environment: environmentProp,
|
|
9826
|
+
groupBy,
|
|
9827
|
+
groupToString,
|
|
7865
9828
|
...rest
|
|
7866
9829
|
} = componentProps;
|
|
7867
9830
|
const ComboboxClassNames = cx(styles["combobox"], className);
|
|
@@ -7879,6 +9842,7 @@ const SelectMultiple = function(props) {
|
|
|
7879
9842
|
const { ref: wrapperDivRef, environment } = useDownshiftEnvironment();
|
|
7880
9843
|
const itemToString = itemToStringProp ?? defaultItemToString;
|
|
7881
9844
|
const itemToKey = itemToKeyProp ?? defaultItemToKey;
|
|
9845
|
+
const { groups, orderedItems } = useGroups({ items, groupBy, groupToString });
|
|
7882
9846
|
const {
|
|
7883
9847
|
getSelectedItemProps,
|
|
7884
9848
|
getDropdownProps,
|
|
@@ -7931,7 +9895,7 @@ const SelectMultiple = function(props) {
|
|
|
7931
9895
|
closeMenu
|
|
7932
9896
|
} = useSelect({
|
|
7933
9897
|
...rest,
|
|
7934
|
-
items,
|
|
9898
|
+
items: orderedItems,
|
|
7935
9899
|
itemToString,
|
|
7936
9900
|
itemToKey,
|
|
7937
9901
|
selectedItem: null,
|
|
@@ -8000,7 +9964,7 @@ const SelectMultiple = function(props) {
|
|
|
8000
9964
|
value: {
|
|
8001
9965
|
multiple: true,
|
|
8002
9966
|
select: true,
|
|
8003
|
-
items,
|
|
9967
|
+
items: orderedItems,
|
|
8004
9968
|
itemToString,
|
|
8005
9969
|
itemToKey,
|
|
8006
9970
|
isOpen,
|
|
@@ -8032,7 +9996,10 @@ const SelectMultiple = function(props) {
|
|
|
8032
9996
|
loading,
|
|
8033
9997
|
referenceRef,
|
|
8034
9998
|
contentRef,
|
|
8035
|
-
closeMenu
|
|
9999
|
+
closeMenu,
|
|
10000
|
+
groupBy,
|
|
10001
|
+
groupToString,
|
|
10002
|
+
groups
|
|
8036
10003
|
},
|
|
8037
10004
|
children: /* @__PURE__ */ jsx(
|
|
8038
10005
|
"div",
|
|
@@ -8063,6 +10030,13 @@ const SelectMultiple = function(props) {
|
|
|
8063
10030
|
);
|
|
8064
10031
|
};
|
|
8065
10032
|
const ComboboxElement$1 = function(props) {
|
|
10033
|
+
if (!supportsPopover()) {
|
|
10034
|
+
if (isMultiple(props)) {
|
|
10035
|
+
return /* @__PURE__ */ jsx(ComboboxLegacyMultiple, { ...props });
|
|
10036
|
+
} else {
|
|
10037
|
+
return /* @__PURE__ */ jsx(ComboboxLegacySingle, { ...props });
|
|
10038
|
+
}
|
|
10039
|
+
}
|
|
8066
10040
|
if (isMultiple(props)) {
|
|
8067
10041
|
return /* @__PURE__ */ jsx(ComboboxMultiple, { ...props });
|
|
8068
10042
|
} else {
|
|
@@ -8070,6 +10044,13 @@ const ComboboxElement$1 = function(props) {
|
|
|
8070
10044
|
}
|
|
8071
10045
|
};
|
|
8072
10046
|
const ComboboxSelect$1 = function(props) {
|
|
10047
|
+
if (!supportsPopover()) {
|
|
10048
|
+
if (isMultiple(props)) {
|
|
10049
|
+
return /* @__PURE__ */ jsx(SelectLegacyMultiple, { ...props });
|
|
10050
|
+
} else {
|
|
10051
|
+
return /* @__PURE__ */ jsx(SelectLegacySingle, { ...props });
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
8073
10054
|
if (isMultiple(props)) {
|
|
8074
10055
|
return /* @__PURE__ */ jsx(SelectMultiple, { ...props });
|
|
8075
10056
|
} else {
|
|
@@ -8347,4 +10328,4 @@ const Combobox = Object.assign(ComboboxElement, {
|
|
|
8347
10328
|
});
|
|
8348
10329
|
|
|
8349
10330
|
export { Combobox as C, ComboboxElement as a, ComboboxSelect as b, ComboboxSearchField as c, ComboboxSelectTrigger as d, ComboboxContent as e, ComboboxList as f, ComboboxItem as g, ComboboxItemAddNew as h, ComboboxEmpty as i, useInfiniteCombobox as u };
|
|
8350
|
-
//# sourceMappingURL=Combobox-
|
|
10331
|
+
//# sourceMappingURL=Combobox-DCrEfyl2.js.map
|