react-aria-components 3.0.0-nightly-7eae25e12-241205 → 3.0.0-nightly-8228e4efd-241207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/Autocomplete.main.js +76 -0
  2. package/dist/Autocomplete.main.js.map +1 -0
  3. package/dist/Autocomplete.mjs +64 -0
  4. package/dist/Autocomplete.module.js +64 -0
  5. package/dist/Autocomplete.module.js.map +1 -0
  6. package/dist/ListBox.main.js +17 -1
  7. package/dist/ListBox.main.js.map +1 -1
  8. package/dist/ListBox.mjs +18 -2
  9. package/dist/ListBox.module.js +18 -2
  10. package/dist/ListBox.module.js.map +1 -1
  11. package/dist/Menu.main.js +18 -3
  12. package/dist/Menu.main.js.map +1 -1
  13. package/dist/Menu.mjs +20 -5
  14. package/dist/Menu.module.js +20 -5
  15. package/dist/Menu.module.js.map +1 -1
  16. package/dist/SearchField.main.js +4 -3
  17. package/dist/SearchField.main.js.map +1 -1
  18. package/dist/SearchField.mjs +5 -4
  19. package/dist/SearchField.module.js +5 -4
  20. package/dist/SearchField.module.js.map +1 -1
  21. package/dist/Tabs.main.js +3 -1
  22. package/dist/Tabs.main.js.map +1 -1
  23. package/dist/Tabs.mjs +4 -2
  24. package/dist/Tabs.module.js +4 -2
  25. package/dist/Tabs.module.js.map +1 -1
  26. package/dist/TextField.main.js +7 -4
  27. package/dist/TextField.main.js.map +1 -1
  28. package/dist/TextField.mjs +8 -5
  29. package/dist/TextField.module.js +8 -5
  30. package/dist/TextField.module.js.map +1 -1
  31. package/dist/import.mjs +3 -1
  32. package/dist/main.js +6 -0
  33. package/dist/main.js.map +1 -1
  34. package/dist/module.js +3 -1
  35. package/dist/module.js.map +1 -1
  36. package/dist/types.d.ts +17 -1
  37. package/dist/types.d.ts.map +1 -1
  38. package/i18n/ar-AE.js +1 -1
  39. package/i18n/ar-AE.mjs +1 -1
  40. package/i18n/bg-BG.js +1 -1
  41. package/i18n/bg-BG.mjs +1 -1
  42. package/i18n/cs-CZ.js +1 -1
  43. package/i18n/cs-CZ.mjs +1 -1
  44. package/i18n/da-DK.js +1 -1
  45. package/i18n/da-DK.mjs +1 -1
  46. package/i18n/de-DE.js +1 -1
  47. package/i18n/de-DE.mjs +1 -1
  48. package/i18n/el-GR.js +1 -1
  49. package/i18n/el-GR.mjs +1 -1
  50. package/i18n/en-US.js +1 -1
  51. package/i18n/en-US.mjs +1 -1
  52. package/i18n/es-ES.js +1 -1
  53. package/i18n/es-ES.mjs +1 -1
  54. package/i18n/et-EE.js +1 -1
  55. package/i18n/et-EE.mjs +1 -1
  56. package/i18n/fi-FI.js +1 -1
  57. package/i18n/fi-FI.mjs +1 -1
  58. package/i18n/fr-FR.js +1 -1
  59. package/i18n/fr-FR.mjs +1 -1
  60. package/i18n/he-IL.js +1 -1
  61. package/i18n/he-IL.mjs +1 -1
  62. package/i18n/hr-HR.js +1 -1
  63. package/i18n/hr-HR.mjs +1 -1
  64. package/i18n/hu-HU.js +1 -1
  65. package/i18n/hu-HU.mjs +1 -1
  66. package/i18n/index.js +1 -1
  67. package/i18n/index.mjs +1 -1
  68. package/i18n/it-IT.js +1 -1
  69. package/i18n/it-IT.mjs +1 -1
  70. package/i18n/ja-JP.js +1 -1
  71. package/i18n/ja-JP.mjs +1 -1
  72. package/i18n/ko-KR.js +1 -1
  73. package/i18n/ko-KR.mjs +1 -1
  74. package/i18n/lt-LT.js +1 -1
  75. package/i18n/lt-LT.mjs +1 -1
  76. package/i18n/lv-LV.js +1 -1
  77. package/i18n/lv-LV.mjs +1 -1
  78. package/i18n/nb-NO.js +1 -1
  79. package/i18n/nb-NO.mjs +1 -1
  80. package/i18n/nl-NL.js +1 -1
  81. package/i18n/nl-NL.mjs +1 -1
  82. package/i18n/pl-PL.js +1 -1
  83. package/i18n/pl-PL.mjs +1 -1
  84. package/i18n/pt-BR.js +1 -1
  85. package/i18n/pt-BR.mjs +1 -1
  86. package/i18n/pt-PT.js +1 -1
  87. package/i18n/pt-PT.mjs +1 -1
  88. package/i18n/ro-RO.js +1 -1
  89. package/i18n/ro-RO.mjs +1 -1
  90. package/i18n/ru-RU.js +1 -1
  91. package/i18n/ru-RU.mjs +1 -1
  92. package/i18n/sk-SK.js +1 -1
  93. package/i18n/sk-SK.mjs +1 -1
  94. package/i18n/sl-SI.js +1 -1
  95. package/i18n/sl-SI.mjs +1 -1
  96. package/i18n/sr-SP.js +1 -1
  97. package/i18n/sr-SP.mjs +1 -1
  98. package/i18n/sv-SE.js +1 -1
  99. package/i18n/sv-SE.mjs +1 -1
  100. package/i18n/tr-TR.js +1 -1
  101. package/i18n/tr-TR.mjs +1 -1
  102. package/i18n/uk-UA.js +1 -1
  103. package/i18n/uk-UA.mjs +1 -1
  104. package/i18n/zh-CN.js +1 -1
  105. package/i18n/zh-CN.mjs +1 -1
  106. package/i18n/zh-TW.js +1 -1
  107. package/i18n/zh-TW.mjs +1 -1
  108. package/package.json +32 -30
  109. package/src/Autocomplete.tsx +70 -0
  110. package/src/ListBox.tsx +8 -3
  111. package/src/Menu.tsx +14 -7
  112. package/src/SearchField.tsx +4 -3
  113. package/src/Tabs.tsx +4 -2
  114. package/src/TextField.tsx +6 -5
  115. package/src/index.ts +1 -0
@@ -0,0 +1,76 @@
1
+ var $c5ccf687772c0422$exports = require("./utils.main.js");
2
+ var $1bcfcef5af644e13$exports = require("./Input.main.js");
3
+ var $5lGAV$reactariaautocomplete = require("@react-aria/autocomplete");
4
+ var $5lGAV$reactstatelyautocomplete = require("@react-stately/autocomplete");
5
+ var $5lGAV$react = require("react");
6
+
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+
12
+ function $parcel$export(e, n, v, s) {
13
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
+ }
15
+
16
+ $parcel$export(module.exports, "AutocompleteContext", () => $33f48720060787fa$export$36e687af51cd0967);
17
+ $parcel$export(module.exports, "AutocompleteStateContext", () => $33f48720060787fa$export$68ee3368b6d68148);
18
+ $parcel$export(module.exports, "InternalAutocompleteContext", () => $33f48720060787fa$export$9fac5c9733526516);
19
+ $parcel$export(module.exports, "Autocomplete", () => $33f48720060787fa$export$2f2b9559550c7bbc);
20
+ /*
21
+ * Copyright 2022 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
31
+
32
+
33
+
34
+
35
+ const $33f48720060787fa$export$36e687af51cd0967 = /*#__PURE__*/ (0, $5lGAV$react.createContext)(null);
36
+ const $33f48720060787fa$export$68ee3368b6d68148 = /*#__PURE__*/ (0, $5lGAV$react.createContext)(null);
37
+ const $33f48720060787fa$export$9fac5c9733526516 = /*#__PURE__*/ (0, $5lGAV$react.createContext)(null);
38
+ const $33f48720060787fa$export$2f2b9559550c7bbc = /*#__PURE__*/ (0, $5lGAV$react.forwardRef)(function Autocomplete(props, ref) {
39
+ [props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $33f48720060787fa$export$36e687af51cd0967);
40
+ let { defaultFilter: defaultFilter } = props;
41
+ let state = (0, $5lGAV$reactstatelyautocomplete.useAutocompleteState)(props);
42
+ let collectionRef = (0, $5lGAV$react.useRef)(null);
43
+ let inputRef = (0, $5lGAV$react.useRef)(null);
44
+ let { inputProps: inputProps, collectionProps: collectionProps, collectionRef: mergedCollectionRef, filterFn: filterFn } = (0, $5lGAV$reactariaautocomplete.useAutocomplete)({
45
+ ...(0, $c5ccf687772c0422$exports.removeDataAttributes)(props),
46
+ defaultFilter: defaultFilter,
47
+ collectionRef: collectionRef,
48
+ inputRef: inputRef
49
+ }, state);
50
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($5lGAV$react))).createElement((0, $c5ccf687772c0422$exports.Provider), {
51
+ values: [
52
+ [
53
+ $33f48720060787fa$export$68ee3368b6d68148,
54
+ state
55
+ ],
56
+ [
57
+ (0, $1bcfcef5af644e13$exports.InputContext),
58
+ {
59
+ ...inputProps,
60
+ ref: inputRef
61
+ }
62
+ ],
63
+ [
64
+ $33f48720060787fa$export$9fac5c9733526516,
65
+ {
66
+ filterFn: filterFn,
67
+ collectionProps: collectionProps,
68
+ collectionRef: mergedCollectionRef
69
+ }
70
+ ]
71
+ ]
72
+ }, props.children);
73
+ });
74
+
75
+
76
+ //# sourceMappingURL=Autocomplete.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgBM,MAAM,0DAAsB,CAAA,GAAA,0BAAY,EAAqD;AAC7F,MAAM,0DAA2B,CAAA,GAAA,0BAAY,EAA4B;AAEzE,MAAM,0DAA8B,CAAA,GAAA,0BAAY,EAA2C;AAO3F,MAAM,0DAAe,CAAA,GAAA,uBAAS,EAAE,SAAS,aAAa,KAAwB,EAAE,GAAmC;IACxH,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,iBAAC,aAAa,EAAC,GAAG;IACtB,IAAI,QAAQ,CAAA,GAAA,oDAAmB,EAAE;IACjC,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAe;IACxC,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAoB;IAExC,IAAI,cACF,UAAU,mBACV,eAAe,EACf,eAAe,mBAAmB,YAClC,QAAQ,EACT,GAAG,CAAA,GAAA,4CAAc,EAAE;QAClB,GAAG,CAAA,GAAA,8CAAmB,EAAE,MAAM;uBAC9B;uBACA;kBACA;IACF,GAAG;IAEH,qBACE,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC;gBAA0B;aAAM;YACjC;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC;gBAA6B;8BAC5B;qCACA;oBACA,eAAe;gBACjB;aAAE;SACH;OACA,MAAM,QAAQ;AAGrB","sources":["packages/react-aria-components/src/Autocomplete.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaAutocompleteProps, CollectionOptions, useAutocomplete} from '@react-aria/autocomplete';\nimport {AutocompleteState, useAutocompleteState} from '@react-stately/autocomplete';\nimport {ContextValue, Provider, removeDataAttributes, SlotProps, useContextProps} from './utils';\nimport {InputContext} from './Input';\nimport React, {createContext, ForwardedRef, forwardRef, RefObject, useRef} from 'react';\n\nexport interface AutocompleteProps extends AriaAutocompleteProps, SlotProps {}\n\ninterface InternalAutocompleteContextValue {\n filterFn: (nodeTextValue: string) => boolean,\n collectionProps: CollectionOptions,\n collectionRef: RefObject<HTMLElement | null>\n}\n\nexport const AutocompleteContext = createContext<ContextValue<AutocompleteProps, HTMLInputElement>>(null);\nexport const AutocompleteStateContext = createContext<AutocompleteState | null>(null);\n// This context is to pass the register and filter down to whatever collection component is wrapped by the Autocomplete\nexport const InternalAutocompleteContext = createContext<InternalAutocompleteContextValue | null>(null);\n\n/**\n * A autocomplete combines a text input with a menu, allowing users to filter a list of options to items matching a query.\n */\n\n\nexport const Autocomplete = forwardRef(function Autocomplete(props: AutocompleteProps, ref: ForwardedRef<HTMLInputElement>) {\n [props, ref] = useContextProps(props, ref, AutocompleteContext);\n let {defaultFilter} = props;\n let state = useAutocompleteState(props);\n let collectionRef = useRef<HTMLElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n\n let {\n inputProps,\n collectionProps,\n collectionRef: mergedCollectionRef,\n filterFn\n } = useAutocomplete({\n ...removeDataAttributes(props),\n defaultFilter,\n collectionRef,\n inputRef\n }, state);\n\n return (\n <Provider\n values={[\n [AutocompleteStateContext, state],\n [InputContext, {...inputProps, ref: inputRef}],\n [InternalAutocompleteContext, {\n filterFn,\n collectionProps,\n collectionRef: mergedCollectionRef\n }]\n ]}>\n {props.children}\n </Provider>\n );\n});\n"],"names":[],"version":3,"file":"Autocomplete.main.js.map"}
@@ -0,0 +1,64 @@
1
+ import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, removeDataAttributes as $64fa3d84918910a7$export$ef03459518577ad4, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415} from "./utils.mjs";
2
+ import {InputContext as $3985021b0ad6602f$export$37fb8590cf2c088c} from "./Input.mjs";
3
+ import {useAutocomplete as $llkzs$useAutocomplete} from "@react-aria/autocomplete";
4
+ import {useAutocompleteState as $llkzs$useAutocompleteState} from "@react-stately/autocomplete";
5
+ import $llkzs$react, {createContext as $llkzs$createContext, forwardRef as $llkzs$forwardRef, useRef as $llkzs$useRef} from "react";
6
+
7
+ /*
8
+ * Copyright 2022 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ const $d2f53cda644affe3$export$36e687af51cd0967 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
23
+ const $d2f53cda644affe3$export$68ee3368b6d68148 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
24
+ const $d2f53cda644affe3$export$9fac5c9733526516 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
25
+ const $d2f53cda644affe3$export$2f2b9559550c7bbc = /*#__PURE__*/ (0, $llkzs$forwardRef)(function Autocomplete(props, ref) {
26
+ [props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $d2f53cda644affe3$export$36e687af51cd0967);
27
+ let { defaultFilter: defaultFilter } = props;
28
+ let state = (0, $llkzs$useAutocompleteState)(props);
29
+ let collectionRef = (0, $llkzs$useRef)(null);
30
+ let inputRef = (0, $llkzs$useRef)(null);
31
+ let { inputProps: inputProps, collectionProps: collectionProps, collectionRef: mergedCollectionRef, filterFn: filterFn } = (0, $llkzs$useAutocomplete)({
32
+ ...(0, $64fa3d84918910a7$export$ef03459518577ad4)(props),
33
+ defaultFilter: defaultFilter,
34
+ collectionRef: collectionRef,
35
+ inputRef: inputRef
36
+ }, state);
37
+ return /*#__PURE__*/ (0, $llkzs$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
38
+ values: [
39
+ [
40
+ $d2f53cda644affe3$export$68ee3368b6d68148,
41
+ state
42
+ ],
43
+ [
44
+ (0, $3985021b0ad6602f$export$37fb8590cf2c088c),
45
+ {
46
+ ...inputProps,
47
+ ref: inputRef
48
+ }
49
+ ],
50
+ [
51
+ $d2f53cda644affe3$export$9fac5c9733526516,
52
+ {
53
+ filterFn: filterFn,
54
+ collectionProps: collectionProps,
55
+ collectionRef: mergedCollectionRef
56
+ }
57
+ ]
58
+ ]
59
+ }, props.children);
60
+ });
61
+
62
+
63
+ export {$d2f53cda644affe3$export$36e687af51cd0967 as AutocompleteContext, $d2f53cda644affe3$export$68ee3368b6d68148 as AutocompleteStateContext, $d2f53cda644affe3$export$9fac5c9733526516 as InternalAutocompleteContext, $d2f53cda644affe3$export$2f2b9559550c7bbc as Autocomplete};
64
+ //# sourceMappingURL=Autocomplete.module.js.map
@@ -0,0 +1,64 @@
1
+ import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, removeDataAttributes as $64fa3d84918910a7$export$ef03459518577ad4, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415} from "./utils.module.js";
2
+ import {InputContext as $3985021b0ad6602f$export$37fb8590cf2c088c} from "./Input.module.js";
3
+ import {useAutocomplete as $llkzs$useAutocomplete} from "@react-aria/autocomplete";
4
+ import {useAutocompleteState as $llkzs$useAutocompleteState} from "@react-stately/autocomplete";
5
+ import $llkzs$react, {createContext as $llkzs$createContext, forwardRef as $llkzs$forwardRef, useRef as $llkzs$useRef} from "react";
6
+
7
+ /*
8
+ * Copyright 2022 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ const $d2f53cda644affe3$export$36e687af51cd0967 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
23
+ const $d2f53cda644affe3$export$68ee3368b6d68148 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
24
+ const $d2f53cda644affe3$export$9fac5c9733526516 = /*#__PURE__*/ (0, $llkzs$createContext)(null);
25
+ const $d2f53cda644affe3$export$2f2b9559550c7bbc = /*#__PURE__*/ (0, $llkzs$forwardRef)(function Autocomplete(props, ref) {
26
+ [props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $d2f53cda644affe3$export$36e687af51cd0967);
27
+ let { defaultFilter: defaultFilter } = props;
28
+ let state = (0, $llkzs$useAutocompleteState)(props);
29
+ let collectionRef = (0, $llkzs$useRef)(null);
30
+ let inputRef = (0, $llkzs$useRef)(null);
31
+ let { inputProps: inputProps, collectionProps: collectionProps, collectionRef: mergedCollectionRef, filterFn: filterFn } = (0, $llkzs$useAutocomplete)({
32
+ ...(0, $64fa3d84918910a7$export$ef03459518577ad4)(props),
33
+ defaultFilter: defaultFilter,
34
+ collectionRef: collectionRef,
35
+ inputRef: inputRef
36
+ }, state);
37
+ return /*#__PURE__*/ (0, $llkzs$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
38
+ values: [
39
+ [
40
+ $d2f53cda644affe3$export$68ee3368b6d68148,
41
+ state
42
+ ],
43
+ [
44
+ (0, $3985021b0ad6602f$export$37fb8590cf2c088c),
45
+ {
46
+ ...inputProps,
47
+ ref: inputRef
48
+ }
49
+ ],
50
+ [
51
+ $d2f53cda644affe3$export$9fac5c9733526516,
52
+ {
53
+ filterFn: filterFn,
54
+ collectionProps: collectionProps,
55
+ collectionRef: mergedCollectionRef
56
+ }
57
+ ]
58
+ ]
59
+ }, props.children);
60
+ });
61
+
62
+
63
+ export {$d2f53cda644affe3$export$36e687af51cd0967 as AutocompleteContext, $d2f53cda644affe3$export$68ee3368b6d68148 as AutocompleteStateContext, $d2f53cda644affe3$export$9fac5c9733526516 as InternalAutocompleteContext, $d2f53cda644affe3$export$2f2b9559550c7bbc as Autocomplete};
64
+ //# sourceMappingURL=Autocomplete.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgBM,MAAM,0DAAsB,CAAA,GAAA,oBAAY,EAAqD;AAC7F,MAAM,0DAA2B,CAAA,GAAA,oBAAY,EAA4B;AAEzE,MAAM,0DAA8B,CAAA,GAAA,oBAAY,EAA2C;AAO3F,MAAM,0DAAe,CAAA,GAAA,iBAAS,EAAE,SAAS,aAAa,KAAwB,EAAE,GAAmC;IACxH,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,iBAAC,aAAa,EAAC,GAAG;IACtB,IAAI,QAAQ,CAAA,GAAA,2BAAmB,EAAE;IACjC,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAe;IACxC,IAAI,WAAW,CAAA,GAAA,aAAK,EAAoB;IAExC,IAAI,cACF,UAAU,mBACV,eAAe,EACf,eAAe,mBAAmB,YAClC,QAAQ,EACT,GAAG,CAAA,GAAA,sBAAc,EAAE;QAClB,GAAG,CAAA,GAAA,yCAAmB,EAAE,MAAM;uBAC9B;uBACA;kBACA;IACF,GAAG;IAEH,qBACE,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC;gBAA0B;aAAM;YACjC;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC;gBAA6B;8BAC5B;qCACA;oBACA,eAAe;gBACjB;aAAE;SACH;OACA,MAAM,QAAQ;AAGrB","sources":["packages/react-aria-components/src/Autocomplete.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaAutocompleteProps, CollectionOptions, useAutocomplete} from '@react-aria/autocomplete';\nimport {AutocompleteState, useAutocompleteState} from '@react-stately/autocomplete';\nimport {ContextValue, Provider, removeDataAttributes, SlotProps, useContextProps} from './utils';\nimport {InputContext} from './Input';\nimport React, {createContext, ForwardedRef, forwardRef, RefObject, useRef} from 'react';\n\nexport interface AutocompleteProps extends AriaAutocompleteProps, SlotProps {}\n\ninterface InternalAutocompleteContextValue {\n filterFn: (nodeTextValue: string) => boolean,\n collectionProps: CollectionOptions,\n collectionRef: RefObject<HTMLElement | null>\n}\n\nexport const AutocompleteContext = createContext<ContextValue<AutocompleteProps, HTMLInputElement>>(null);\nexport const AutocompleteStateContext = createContext<AutocompleteState | null>(null);\n// This context is to pass the register and filter down to whatever collection component is wrapped by the Autocomplete\nexport const InternalAutocompleteContext = createContext<InternalAutocompleteContextValue | null>(null);\n\n/**\n * A autocomplete combines a text input with a menu, allowing users to filter a list of options to items matching a query.\n */\n\n\nexport const Autocomplete = forwardRef(function Autocomplete(props: AutocompleteProps, ref: ForwardedRef<HTMLInputElement>) {\n [props, ref] = useContextProps(props, ref, AutocompleteContext);\n let {defaultFilter} = props;\n let state = useAutocompleteState(props);\n let collectionRef = useRef<HTMLElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n\n let {\n inputProps,\n collectionProps,\n collectionRef: mergedCollectionRef,\n filterFn\n } = useAutocomplete({\n ...removeDataAttributes(props),\n defaultFilter,\n collectionRef,\n inputRef\n }, state);\n\n return (\n <Provider\n values={[\n [AutocompleteStateContext, state],\n [InputContext, {...inputProps, ref: inputRef}],\n [InternalAutocompleteContext, {\n filterFn,\n collectionProps,\n collectionRef: mergedCollectionRef\n }]\n ]}>\n {props.children}\n </Provider>\n );\n});\n"],"names":[],"version":3,"file":"Autocomplete.module.js.map"}
@@ -2,6 +2,7 @@ var $3114c2382242bdc0$exports = require("./Collection.main.js");
2
2
  var $c5ccf687772c0422$exports = require("./utils.main.js");
3
3
  var $0c2289d253cb4544$exports = require("./DragAndDrop.main.js");
4
4
  var $c7efb75a1a3fe2d2$exports = require("./Header.main.js");
5
+ var $33f48720060787fa$exports = require("./Autocomplete.main.js");
5
6
  var $54b202ace195eaa4$exports = require("./Separator.main.js");
6
7
  var $a8a589c28affdc40$exports = require("./Text.main.js");
7
8
  var $59TRP$reactaria = require("react-aria");
@@ -45,6 +46,7 @@ $parcel$export(module.exports, "ListBoxItem", () => $a03b42240404b420$export$a11
45
46
 
46
47
 
47
48
 
49
+
48
50
  const $a03b42240404b420$export$7ff8f37d2d81a48d = /*#__PURE__*/ (0, $59TRP$react.createContext)(null);
49
51
  const $a03b42240404b420$export$7c5906fe4f1f2af2 = /*#__PURE__*/ (0, $59TRP$react.createContext)(null);
50
52
  const $a03b42240404b420$export$41f133550aa26f48 = /*#__PURE__*/ (0, $59TRP$react.forwardRef)(function ListBox(props, ref) {
@@ -76,13 +78,27 @@ function $a03b42240404b420$var$StandaloneListBox({ props: props, listBoxRef: lis
76
78
  items: null
77
79
  };
78
80
  let { layoutDelegate: layoutDelegate } = (0, $59TRP$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
81
+ let { filterFn: filterFn, collectionProps: collectionProps, collectionRef: collectionRef } = (0, $59TRP$react.useContext)((0, $33f48720060787fa$exports.InternalAutocompleteContext)) || {};
82
+ // Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens
83
+ listBoxRef = (0, $59TRP$reactariautils.useObjectRef)((0, $59TRP$react.useMemo)(()=>(0, $59TRP$reactariautils.mergeRefs)(listBoxRef, collectionRef !== undefined ? collectionRef : null), [
84
+ collectionRef,
85
+ listBoxRef
86
+ ]));
87
+ let filteredCollection = (0, $59TRP$react.useMemo)(()=>filterFn ? collection.filter(filterFn) : collection, [
88
+ collection,
89
+ filterFn
90
+ ]);
79
91
  let state = (0, $59TRP$reactstately.useListState)({
80
92
  ...props,
93
+ collection: filteredCollection,
81
94
  layoutDelegate: layoutDelegate
82
95
  });
83
96
  return /*#__PURE__*/ (0, ($parcel$interopDefault($59TRP$react))).createElement($a03b42240404b420$var$ListBoxInner, {
84
97
  state: state,
85
- props: props,
98
+ props: {
99
+ ...props,
100
+ ...collectionProps
101
+ },
86
102
  listBoxRef: listBoxRef
87
103
  });
88
104
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoE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C;AAEA,MAAM,qEAAiC,CAAA,GAAA,uBAAS,EAAE","sources":["packages/react-aria-components/src/ListBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxOptions, AriaListBoxProps, DraggableItemResult, DragPreviewRenderer, DroppableCollectionResult, DroppableItemResult, FocusScope, ListKeyboardDelegate, mergeProps, useCollator, useFocusRing, useHover, useListBox, useListBoxSection, useLocale, useOption} from 'react-aria';\nimport {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps} from './Collection';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, ScrollableProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {DragAndDropContext, DropIndicatorContext, DropIndicatorProps, useDndPersistedKeys, useRenderDropIndicator} from './DragAndDrop';\nimport {DragAndDropHooks} from './useDragAndDrop';\nimport {DraggableCollectionState, DroppableCollectionState, ListState, Node, Orientation, SelectionBehavior, useListState} from 'react-stately';\nimport {filterDOMProps, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, HoverEvents, Key, LinkDOMProps, RefObject} from '@react-types/shared';\nimport {HeaderContext} from './Header';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';\nimport {SeparatorContext} from './Separator';\nimport {TextContext} from './Text';\n\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n isDropTarget: boolean,\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n layout: 'stack' | 'grid',\n /**\n * State of the listbox.\n */\n state: ListState<unknown>\n}\n\nexport interface ListBoxProps<T> extends Omit<AriaListBoxProps<T>, 'children' | 'label'>, CollectionProps<T>, StyleRenderProps<ListBoxRenderProps>, SlotProps, ScrollableProps<HTMLDivElement> {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the ListBox. */\n dragAndDropHooks?: DragAndDropHooks,\n /** Provides content to display when there are no items in the list. */\n renderEmptyState?: (props: ListBoxRenderProps) => ReactNode,\n /**\n * Whether the items are arranged in a stack or grid.\n * @default 'stack'\n */\n layout?: 'stack' | 'grid',\n /**\n * The primary orientation of the items. Usually this is the\n * direction that the collection scrolls.\n * @default 'vertical'\n */\n orientation?: Orientation\n}\n\nexport const ListBoxContext = createContext<ContextValue<ListBoxProps<any>, HTMLDivElement>>(null);\nexport const ListStateContext = createContext<ListState<any> | null>(null);\n\n/**\n * A listbox displays a list of options and allows a user to select one or more of them.\n */\nexport const ListBox = /*#__PURE__*/ (forwardRef as forwardRefType)(function ListBox<T extends object>(props: ListBoxProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ListBoxContext);\n let state = useContext(ListStateContext);\n\n // The structure of ListBox is a bit strange because it needs to work inside other components like ComboBox and Select.\n // Those components render two copies of their children so that the collection can be built even when the popover is closed.\n // The first copy sends a collection document via context which we render the collection portal into.\n // The second copy sends a ListState object via context which we use to render the ListBox without rebuilding the state.\n // Otherwise, we have a standalone ListBox, so we need to create a collection and state ourselves.\n\n if (state) {\n return <ListBoxInner state={state} props={props} listBoxRef={ref} />;\n }\n\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => <StandaloneListBox props={props} listBoxRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\nfunction StandaloneListBox({props, listBoxRef, collection}) {\n props = {...props, collection, children: null, items: null};\n let {layoutDelegate} = useContext(CollectionRendererContext);\n let state = useListState({...props, layoutDelegate});\n return <ListBoxInner state={state} props={props} listBoxRef={listBoxRef} />;\n}\n\ninterface ListBoxInnerProps<T> {\n state: ListState<T>,\n props: ListBoxProps<T> & AriaListBoxOptions<T>,\n listBoxRef: RefObject<HTMLDivElement | null>\n}\n\nfunction ListBoxInner<T extends object>({state, props, listBoxRef}: ListBoxInnerProps<T>) {\n let {dragAndDropHooks, layout = 'stack', orientation = 'vertical'} = props;\n let {collection, selectionManager} = state;\n let isListDraggable = !!dragAndDropHooks?.useDraggableCollectionState;\n let isListDroppable = !!dragAndDropHooks?.useDroppableCollectionState;\n let {direction} = useLocale();\n let {disabledBehavior, disabledKeys} = selectionManager;\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let {isVirtualized, layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate, CollectionRoot} = useContext(CollectionRendererContext);\n let keyboardDelegate = useMemo(() => (\n props.keyboardDelegate || new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction,\n layoutDelegate\n })\n ), [collection, collator, listBoxRef, disabledBehavior, disabledKeys, orientation, direction, props.keyboardDelegate, layout, layoutDelegate]);\n\n let {listBoxProps} = useListBox({\n ...props,\n shouldSelectOnPressUp: isListDraggable || props.shouldSelectOnPressUp,\n keyboardDelegate,\n isVirtualized\n }, state, listBoxRef);\n\n let dragHooksProvided = useRef(isListDraggable);\n let dropHooksProvided = useRef(isListDroppable);\n useEffect(() => {\n if (dragHooksProvided.current !== isListDraggable) {\n console.warn('Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');\n }\n if (dropHooksProvided.current !== isListDroppable) {\n console.warn('Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');\n }\n }, [isListDraggable, isListDroppable]);\n\n let dragState: DraggableCollectionState | undefined = undefined;\n let dropState: DroppableCollectionState | undefined = undefined;\n let droppableCollection: DroppableCollectionResult | undefined = undefined;\n let isRootDropTarget = false;\n let dragPreview: JSX.Element | null = null;\n let preview = useRef<DragPreviewRenderer>(null);\n\n if (isListDraggable && dragAndDropHooks) {\n dragState = dragAndDropHooks.useDraggableCollectionState!({\n collection,\n selectionManager,\n preview: dragAndDropHooks.renderDragPreview ? preview : undefined\n });\n dragAndDropHooks.useDraggableCollection!({}, dragState, listBoxRef);\n\n let DragPreview = dragAndDropHooks.DragPreview!;\n dragPreview = dragAndDropHooks.renderDragPreview\n ? <DragPreview ref={preview}>{dragAndDropHooks.renderDragPreview}</DragPreview>\n : null;\n }\n\n if (isListDroppable && dragAndDropHooks) {\n dropState = dragAndDropHooks.useDroppableCollectionState!({\n collection,\n selectionManager\n });\n\n let dropTargetDelegate = dragAndDropHooks.dropTargetDelegate || ctxDropTargetDelegate || new dragAndDropHooks.ListDropTargetDelegate(collection, listBoxRef, {orientation, layout, direction});\n droppableCollection = dragAndDropHooks.useDroppableCollection!({\n keyboardDelegate,\n dropTargetDelegate\n }, dropState, listBoxRef);\n\n isRootDropTarget = dropState.isDropTarget({type: 'root'});\n }\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isDropTarget: isRootDropTarget,\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n layout: props.layout || 'stack',\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-ListBox',\n values: renderValues\n });\n\n let emptyState: JSX.Element | null = null;\n if (state.collection.size === 0 && props.renderEmptyState) {\n emptyState = (\n <div\n // eslint-disable-next-line\n role=\"option\"\n style={{display: 'contents'}}>\n {props.renderEmptyState(renderValues)}\n </div>\n );\n }\n\n return (\n <FocusScope>\n <div\n {...filterDOMProps(props)}\n {...mergeProps(listBoxProps, focusProps, droppableCollection?.collectionProps)}\n {...renderProps}\n ref={listBoxRef}\n slot={props.slot || undefined}\n onScroll={props.onScroll}\n data-drop-target={isRootDropTarget || undefined}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-layout={props.layout || 'stack'}\n data-orientation={props.orientation || 'vertical'}>\n <Provider\n values={[\n [ListBoxContext, props],\n [ListStateContext, state],\n [DragAndDropContext, {dragAndDropHooks, dragState, dropState}],\n [SeparatorContext, {elementType: 'div'}],\n [DropIndicatorContext, {render: ListBoxDropIndicatorWrapper}],\n [SectionContext, {name: 'ListBoxSection', render: ListBoxSectionInner}]\n ]}>\n <CollectionRoot\n collection={collection}\n scrollRef={listBoxRef}\n persistedKeys={useDndPersistedKeys(selectionManager, dragAndDropHooks, dropState)}\n renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)} />\n </Provider>\n {emptyState}\n {dragPreview}\n </div>\n </FocusScope>\n );\n}\n\nexport interface ListBoxSectionProps<T> extends SectionProps<T> {}\n\nfunction ListBoxSectionInner<T extends object>(props: ListBoxSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-ListBoxSection') {\n let state = useContext(ListStateContext)!;\n let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let [headingRef, heading] = useSlot();\n let {headingProps, groupProps} = useListBoxSection({\n heading,\n 'aria-label': props['aria-label'] ?? undefined\n });\n let renderProps = useRenderProps({\n defaultClassName: className,\n className: props.className,\n style: props.style,\n values: {}\n });\n\n return (\n <section\n {...filterDOMProps(props as any)}\n {...groupProps}\n {...renderProps}\n ref={ref}>\n <HeaderContext.Provider value={{...headingProps, ref: headingRef}}>\n <CollectionBranch\n collection={state.collection}\n parent={section}\n renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)} />\n </HeaderContext.Provider>\n </section>\n );\n}\n\n/**\n * A ListBoxSection represents a section within a ListBox.\n */\nexport const ListBoxSection = /*#__PURE__*/ createBranchComponent('section', ListBoxSectionInner);\n\nexport interface ListBoxItemRenderProps extends ItemRenderProps {}\n\nexport interface ListBoxItemProps<T = object> extends RenderProps<ListBoxItemRenderProps>, LinkDOMProps, HoverEvents {\n /** The unique id of the item. */\n id?: Key,\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n value?: T,\n /** A string representation of the item's contents, used for features like typeahead. */\n textValue?: string,\n /** An accessibility label for this item. */\n 'aria-label'?: string,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: () => void\n}\n\n/**\n * A ListBoxItem represents an individual option in a ListBox.\n */\nexport const ListBoxItem = /*#__PURE__*/ createLeafComponent('item', function ListBoxItem<T extends object>(props: ListBoxItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n let ref = useObjectRef<any>(forwardedRef);\n let state = useContext(ListStateContext)!;\n let {dragAndDropHooks, dragState, dropState} = useContext(DragAndDropContext)!;\n let {optionProps, labelProps, descriptionProps, ...states} = useOption(\n {key: item.key, 'aria-label': props?.['aria-label']},\n state,\n ref\n );\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection && !states.hasAction,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let draggableItem: DraggableItemResult | null = null;\n if (dragState && dragAndDropHooks) {\n draggableItem = dragAndDropHooks.useDraggableItem!({key: item.key}, dragState);\n }\n\n let droppableItem: DroppableItemResult | null = null;\n if (dropState && dragAndDropHooks) {\n droppableItem = dragAndDropHooks.useDroppableItem!({\n target: {type: 'item', key: item.key, dropPosition: 'on'}\n }, dropState, ref);\n }\n\n let isDragging = dragState && dragState.isDragging(item.key);\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: props.children,\n defaultClassName: 'react-aria-ListBoxItem',\n values: {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior,\n allowsDragging: !!dragState,\n isDragging,\n isDropTarget: droppableItem?.isDropTarget\n }\n });\n\n useEffect(() => {\n if (!item.textValue) {\n console.warn('A `textValue` prop is required for <ListBoxItem> elements with non-plain text children in order to support accessibility features such as type to select.');\n }\n }, [item.textValue]);\n\n let ElementType: React.ElementType = props.href ? 'a' : 'div';\n\n return (\n <ElementType\n {...mergeProps(optionProps, hoverProps, draggableItem?.dragProps, droppableItem?.dropProps)}\n {...renderProps}\n ref={ref}\n data-allows-dragging={!!dragState || undefined}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={states.isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-dragging={isDragging || undefined}\n data-drop-target={droppableItem?.isDropTarget || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <Provider\n values={[\n [TextContext, {\n slots: {\n [DEFAULT_SLOT]: labelProps,\n label: labelProps,\n description: descriptionProps\n }\n }]\n ]}>\n {renderProps.children}\n </Provider>\n </ElementType>\n );\n});\n\nfunction ListBoxDropIndicatorWrapper(props: DropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n ref = useObjectRef(ref);\n let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n let {dropIndicatorProps, isHidden, isDropTarget} = dragAndDropHooks!.useDropIndicator!(\n props,\n dropState!,\n ref\n );\n\n if (isHidden) {\n return null;\n }\n\n return (\n <ListBoxDropIndicatorForwardRef {...props} dropIndicatorProps={dropIndicatorProps} isDropTarget={isDropTarget} ref={ref} />\n );\n}\n\ninterface ListBoxDropIndicatorProps extends DropIndicatorProps {\n dropIndicatorProps: React.HTMLAttributes<HTMLElement>,\n isDropTarget: boolean\n}\n\nfunction ListBoxDropIndicator(props: ListBoxDropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n let {\n dropIndicatorProps,\n isDropTarget,\n ...otherProps\n } = props;\n\n let renderProps = useRenderProps({\n ...otherProps,\n defaultClassName: 'react-aria-DropIndicator',\n values: {\n isDropTarget\n }\n });\n\n return (\n <div\n {...dropIndicatorProps}\n {...renderProps}\n // eslint-disable-next-line\n role=\"option\"\n ref={ref as RefObject<HTMLDivElement | null>}\n data-drop-target={isDropTarget || undefined} />\n );\n}\n\nconst ListBoxDropIndicatorForwardRef = forwardRef(ListBoxDropIndicator);\n"],"names":[],"version":3,"file":"ListBox.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AAqEM,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAmD;AACtF,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAAyB;AAK9D,MAAM,4CAAwB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,QAA0B,KAAsB,EAAE,GAAiC;IAC9J,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,QAAQ,CAAA,GAAA,uBAAS,EAAE;IAEvB,uHAAuH;IACvH,4HAA4H;IAC5H,qGAAqG;IACrG,wHAAwH;IACxH,kGAAkG;IAElG,IAAI,OACF,qBAAO,0DAAC;QAAa,OAAO;QAAO,OAAO;QAAO,YAAY;;IAG/D,qBACE,0DAAC,CAAA,GAAA,6CAAgB;QAAE,uBAAS,0DAAC,CAAA,GAAA,sCAAS,GAAM;OACzC,CAAA,2BAAc,0DAAC;YAAkB,OAAO;YAAO,YAAY;YAAK,YAAY;;AAGnF;AAE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AC7B,oBAAkB,CAAA,0BAAA,oCAAA,cAAe,YAAY,KAAI;QACjD,uBAAqB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,YAAY,MAAM,gBAAgB,CAAC,aAAa;qBACvH,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,qCAAU;gBAAG;oBACZ,OAAO;wBACL,CAAC,CAAA,GAAA,sCAAW,EAAE,EAAE;wBAChB,OAAO;wBACP,aAAa;oBACf;gBACF;aAAE;SACH;OACA,YAAY,QAAQ;AAI7B;AAEA,SAAS,kDAA4B,KAAyB,EAAE,GAA8B;IAC5F,MAAM,CAAA,GAAA,kCAAW,EAAE;IACnB,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,4CAAiB;IAChE,IAAI,sBAAC,kBAAkB,YAAE,QAAQ,gBAAE,YAAY,EAAC,GAAG,iBAAkB,gBAAgB,CACnF,OACA,WACA;IAGF,IAAI,UACF,OAAO;IAGT,qBACE,0DAAC;QAAgC,GAAG,KAAK;QAAE,oBAAoB;QAAoB,cAAc;QAAc,KAAK;;AAExH;AAOA,SAAS,2CAAqB,KAAgC,EAAE,GAA8B;IAC5F,IAAI,sBACF,kBAAkB,gBAClB,YAAY,EACZ,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,UAAU;QACb,kBAAkB;QAClB,QAAQ;0BACN;QACF;IACF;IAEA,qBACE,0DAAC;QACE,GAAG,kBAAkB;QACrB,GAAG,WAAW;QACf,2BAA2B;QAC3B,MAAK;QACL,KAAK;QACL,oBAAkB,gBAAgB;;AAExC;AAEA,MAAM,qEAAiC,CAAA,GAAA,uBAAS,EAAE","sources":["packages/react-aria-components/src/ListBox.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxOptions, AriaListBoxProps, DraggableItemResult, DragPreviewRenderer, DroppableCollectionResult, DroppableItemResult, FocusScope, ListKeyboardDelegate, mergeProps, useCollator, useFocusRing, useHover, useListBox, useListBoxSection, useLocale, useOption} from 'react-aria';\nimport {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps} from './Collection';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, ScrollableProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {DragAndDropContext, DropIndicatorContext, DropIndicatorProps, useDndPersistedKeys, useRenderDropIndicator} from './DragAndDrop';\nimport {DragAndDropHooks} from './useDragAndDrop';\nimport {DraggableCollectionState, DroppableCollectionState, ListState, Node, Orientation, SelectionBehavior, useListState} from 'react-stately';\nimport {filterDOMProps, mergeRefs, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, HoverEvents, Key, LinkDOMProps, RefObject} from '@react-types/shared';\nimport {HeaderContext} from './Header';\nimport {InternalAutocompleteContext} from './Autocomplete';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';\nimport {SeparatorContext} from './Separator';\nimport {TextContext} from './Text';\n\nexport interface ListBoxRenderProps {\n /**\n * Whether the listbox has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the listbox is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the listbox is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the listbox is currently the active drop target.\n * @selector [data-drop-target]\n */\n isDropTarget: boolean,\n /**\n * Whether the items are arranged in a stack or grid.\n * @selector [data-layout=\"stack | grid\"]\n */\n layout: 'stack' | 'grid',\n /**\n * State of the listbox.\n */\n state: ListState<unknown>\n}\n\nexport interface ListBoxProps<T> extends Omit<AriaListBoxProps<T>, 'children' | 'label'>, CollectionProps<T>, StyleRenderProps<ListBoxRenderProps>, SlotProps, ScrollableProps<HTMLDivElement> {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the ListBox. */\n dragAndDropHooks?: DragAndDropHooks,\n /** Provides content to display when there are no items in the list. */\n renderEmptyState?: (props: ListBoxRenderProps) => ReactNode,\n /**\n * Whether the items are arranged in a stack or grid.\n * @default 'stack'\n */\n layout?: 'stack' | 'grid',\n /**\n * The primary orientation of the items. Usually this is the\n * direction that the collection scrolls.\n * @default 'vertical'\n */\n orientation?: Orientation\n}\n\nexport const ListBoxContext = createContext<ContextValue<ListBoxProps<any>, HTMLDivElement>>(null);\nexport const ListStateContext = createContext<ListState<any> | null>(null);\n\n/**\n * A listbox displays a list of options and allows a user to select one or more of them.\n */\nexport const ListBox = /*#__PURE__*/ (forwardRef as forwardRefType)(function ListBox<T extends object>(props: ListBoxProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ListBoxContext);\n let state = useContext(ListStateContext);\n\n // The structure of ListBox is a bit strange because it needs to work inside other components like ComboBox and Select.\n // Those components render two copies of their children so that the collection can be built even when the popover is closed.\n // The first copy sends a collection document via context which we render the collection portal into.\n // The second copy sends a ListState object via context which we use to render the ListBox without rebuilding the state.\n // Otherwise, we have a standalone ListBox, so we need to create a collection and state ourselves.\n\n if (state) {\n return <ListBoxInner state={state} props={props} listBoxRef={ref} />;\n }\n\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => <StandaloneListBox props={props} listBoxRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\nfunction StandaloneListBox({props, listBoxRef, collection}) {\n props = {...props, collection, children: null, items: null};\n let {layoutDelegate} = useContext(CollectionRendererContext);\n let {filterFn, collectionProps, collectionRef} = useContext(InternalAutocompleteContext) || {};\n // Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens\n listBoxRef = useObjectRef(useMemo(() => mergeRefs(listBoxRef, collectionRef !== undefined ? collectionRef as RefObject<HTMLDivElement> : null), [collectionRef, listBoxRef]));\n let filteredCollection = useMemo(() => filterFn ? collection.filter(filterFn) : collection, [collection, filterFn]);\n let state = useListState({...props, collection: filteredCollection, layoutDelegate});\n return <ListBoxInner state={state} props={{...props, ...collectionProps}} listBoxRef={listBoxRef} />;\n}\n\ninterface ListBoxInnerProps<T> {\n state: ListState<T>,\n props: ListBoxProps<T> & AriaListBoxOptions<T>,\n listBoxRef: RefObject<HTMLDivElement | null>\n}\n\nfunction ListBoxInner<T extends object>({state, props, listBoxRef}: ListBoxInnerProps<T>) {\n let {dragAndDropHooks, layout = 'stack', orientation = 'vertical'} = props;\n let {collection, selectionManager} = state;\n let isListDraggable = !!dragAndDropHooks?.useDraggableCollectionState;\n let isListDroppable = !!dragAndDropHooks?.useDroppableCollectionState;\n let {direction} = useLocale();\n let {disabledBehavior, disabledKeys} = selectionManager;\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let {isVirtualized, layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate, CollectionRoot} = useContext(CollectionRendererContext);\n let keyboardDelegate = useMemo(() => (\n props.keyboardDelegate || new ListKeyboardDelegate({\n collection,\n collator,\n ref: listBoxRef,\n disabledKeys,\n disabledBehavior,\n layout,\n orientation,\n direction,\n layoutDelegate\n })\n ), [collection, collator, listBoxRef, disabledBehavior, disabledKeys, orientation, direction, props.keyboardDelegate, layout, layoutDelegate]);\n\n let {listBoxProps} = useListBox({\n ...props,\n shouldSelectOnPressUp: isListDraggable || props.shouldSelectOnPressUp,\n keyboardDelegate,\n isVirtualized\n }, state, listBoxRef);\n\n let dragHooksProvided = useRef(isListDraggable);\n let dropHooksProvided = useRef(isListDroppable);\n useEffect(() => {\n if (dragHooksProvided.current !== isListDraggable) {\n console.warn('Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');\n }\n if (dropHooksProvided.current !== isListDroppable) {\n console.warn('Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');\n }\n }, [isListDraggable, isListDroppable]);\n\n let dragState: DraggableCollectionState | undefined = undefined;\n let dropState: DroppableCollectionState | undefined = undefined;\n let droppableCollection: DroppableCollectionResult | undefined = undefined;\n let isRootDropTarget = false;\n let dragPreview: JSX.Element | null = null;\n let preview = useRef<DragPreviewRenderer>(null);\n\n if (isListDraggable && dragAndDropHooks) {\n dragState = dragAndDropHooks.useDraggableCollectionState!({\n collection,\n selectionManager,\n preview: dragAndDropHooks.renderDragPreview ? preview : undefined\n });\n dragAndDropHooks.useDraggableCollection!({}, dragState, listBoxRef);\n\n let DragPreview = dragAndDropHooks.DragPreview!;\n dragPreview = dragAndDropHooks.renderDragPreview\n ? <DragPreview ref={preview}>{dragAndDropHooks.renderDragPreview}</DragPreview>\n : null;\n }\n\n if (isListDroppable && dragAndDropHooks) {\n dropState = dragAndDropHooks.useDroppableCollectionState!({\n collection,\n selectionManager\n });\n\n let dropTargetDelegate = dragAndDropHooks.dropTargetDelegate || ctxDropTargetDelegate || new dragAndDropHooks.ListDropTargetDelegate(collection, listBoxRef, {orientation, layout, direction});\n droppableCollection = dragAndDropHooks.useDroppableCollection!({\n keyboardDelegate,\n dropTargetDelegate\n }, dropState, listBoxRef);\n\n isRootDropTarget = dropState.isDropTarget({type: 'root'});\n }\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isDropTarget: isRootDropTarget,\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n layout: props.layout || 'stack',\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-ListBox',\n values: renderValues\n });\n\n let emptyState: JSX.Element | null = null;\n if (state.collection.size === 0 && props.renderEmptyState) {\n emptyState = (\n <div\n // eslint-disable-next-line\n role=\"option\"\n style={{display: 'contents'}}>\n {props.renderEmptyState(renderValues)}\n </div>\n );\n }\n\n return (\n <FocusScope>\n <div\n {...filterDOMProps(props)}\n {...mergeProps(listBoxProps, focusProps, droppableCollection?.collectionProps)}\n {...renderProps}\n ref={listBoxRef}\n slot={props.slot || undefined}\n onScroll={props.onScroll}\n data-drop-target={isRootDropTarget || undefined}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-layout={props.layout || 'stack'}\n data-orientation={props.orientation || 'vertical'}>\n <Provider\n values={[\n [ListBoxContext, props],\n [ListStateContext, state],\n [DragAndDropContext, {dragAndDropHooks, dragState, dropState}],\n [SeparatorContext, {elementType: 'div'}],\n [DropIndicatorContext, {render: ListBoxDropIndicatorWrapper}],\n [SectionContext, {name: 'ListBoxSection', render: ListBoxSectionInner}]\n ]}>\n <CollectionRoot\n collection={collection}\n scrollRef={listBoxRef}\n persistedKeys={useDndPersistedKeys(selectionManager, dragAndDropHooks, dropState)}\n renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)} />\n </Provider>\n {emptyState}\n {dragPreview}\n </div>\n </FocusScope>\n );\n}\n\nexport interface ListBoxSectionProps<T> extends SectionProps<T> {}\n\nfunction ListBoxSectionInner<T extends object>(props: ListBoxSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-ListBoxSection') {\n let state = useContext(ListStateContext)!;\n let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let [headingRef, heading] = useSlot();\n let {headingProps, groupProps} = useListBoxSection({\n heading,\n 'aria-label': props['aria-label'] ?? undefined\n });\n let renderProps = useRenderProps({\n defaultClassName: className,\n className: props.className,\n style: props.style,\n values: {}\n });\n\n return (\n <section\n {...filterDOMProps(props as any)}\n {...groupProps}\n {...renderProps}\n ref={ref}>\n <HeaderContext.Provider value={{...headingProps, ref: headingRef}}>\n <CollectionBranch\n collection={state.collection}\n parent={section}\n renderDropIndicator={useRenderDropIndicator(dragAndDropHooks, dropState)} />\n </HeaderContext.Provider>\n </section>\n );\n}\n\n/**\n * A ListBoxSection represents a section within a ListBox.\n */\nexport const ListBoxSection = /*#__PURE__*/ createBranchComponent('section', ListBoxSectionInner);\n\nexport interface ListBoxItemRenderProps extends ItemRenderProps {}\n\nexport interface ListBoxItemProps<T = object> extends RenderProps<ListBoxItemRenderProps>, LinkDOMProps, HoverEvents {\n /** The unique id of the item. */\n id?: Key,\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n value?: T,\n /** A string representation of the item's contents, used for features like typeahead. */\n textValue?: string,\n /** An accessibility label for this item. */\n 'aria-label'?: string,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /**\n * Handler that is called when a user performs an action on the item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: () => void\n}\n\n/**\n * A ListBoxItem represents an individual option in a ListBox.\n */\nexport const ListBoxItem = /*#__PURE__*/ createLeafComponent('item', function ListBoxItem<T extends object>(props: ListBoxItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n let ref = useObjectRef<any>(forwardedRef);\n let state = useContext(ListStateContext)!;\n let {dragAndDropHooks, dragState, dropState} = useContext(DragAndDropContext)!;\n let {optionProps, labelProps, descriptionProps, ...states} = useOption(\n {key: item.key, 'aria-label': props?.['aria-label']},\n state,\n ref\n );\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection && !states.hasAction,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let draggableItem: DraggableItemResult | null = null;\n if (dragState && dragAndDropHooks) {\n draggableItem = dragAndDropHooks.useDraggableItem!({key: item.key}, dragState);\n }\n\n let droppableItem: DroppableItemResult | null = null;\n if (dropState && dragAndDropHooks) {\n droppableItem = dragAndDropHooks.useDroppableItem!({\n target: {type: 'item', key: item.key, dropPosition: 'on'}\n }, dropState, ref);\n }\n\n let isDragging = dragState && dragState.isDragging(item.key);\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: props.children,\n defaultClassName: 'react-aria-ListBoxItem',\n values: {\n ...states,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior,\n allowsDragging: !!dragState,\n isDragging,\n isDropTarget: droppableItem?.isDropTarget\n }\n });\n\n useEffect(() => {\n if (!item.textValue) {\n console.warn('A `textValue` prop is required for <ListBoxItem> elements with non-plain text children in order to support accessibility features such as type to select.');\n }\n }, [item.textValue]);\n\n let ElementType: React.ElementType = props.href ? 'a' : 'div';\n\n return (\n <ElementType\n {...mergeProps(optionProps, hoverProps, draggableItem?.dragProps, droppableItem?.dropProps)}\n {...renderProps}\n ref={ref}\n data-allows-dragging={!!dragState || undefined}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={states.isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-dragging={isDragging || undefined}\n data-drop-target={droppableItem?.isDropTarget || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <Provider\n values={[\n [TextContext, {\n slots: {\n [DEFAULT_SLOT]: labelProps,\n label: labelProps,\n description: descriptionProps\n }\n }]\n ]}>\n {renderProps.children}\n </Provider>\n </ElementType>\n );\n});\n\nfunction ListBoxDropIndicatorWrapper(props: DropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n ref = useObjectRef(ref);\n let {dragAndDropHooks, dropState} = useContext(DragAndDropContext)!;\n let {dropIndicatorProps, isHidden, isDropTarget} = dragAndDropHooks!.useDropIndicator!(\n props,\n dropState!,\n ref\n );\n\n if (isHidden) {\n return null;\n }\n\n return (\n <ListBoxDropIndicatorForwardRef {...props} dropIndicatorProps={dropIndicatorProps} isDropTarget={isDropTarget} ref={ref} />\n );\n}\n\ninterface ListBoxDropIndicatorProps extends DropIndicatorProps {\n dropIndicatorProps: React.HTMLAttributes<HTMLElement>,\n isDropTarget: boolean\n}\n\nfunction ListBoxDropIndicator(props: ListBoxDropIndicatorProps, ref: ForwardedRef<HTMLElement>) {\n let {\n dropIndicatorProps,\n isDropTarget,\n ...otherProps\n } = props;\n\n let renderProps = useRenderProps({\n ...otherProps,\n defaultClassName: 'react-aria-DropIndicator',\n values: {\n isDropTarget\n }\n });\n\n return (\n <div\n {...dropIndicatorProps}\n {...renderProps}\n // eslint-disable-next-line\n role=\"option\"\n ref={ref as RefObject<HTMLDivElement | null>}\n data-drop-target={isDropTarget || undefined} />\n );\n}\n\nconst ListBoxDropIndicatorForwardRef = forwardRef(ListBoxDropIndicator);\n"],"names":[],"version":3,"file":"ListBox.main.js.map"}
package/dist/ListBox.mjs CHANGED
@@ -2,12 +2,13 @@ import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5,
2
2
  import {DEFAULT_SLOT as $64fa3d84918910a7$export$c62b8e45d58ddad9, Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8} from "./utils.mjs";
3
3
  import {DragAndDropContext as $612b8eb6cb90e02d$export$d188a835a7bc5783, DropIndicatorContext as $612b8eb6cb90e02d$export$f55761759794cf55, useDndPersistedKeys as $612b8eb6cb90e02d$export$d1e8e3fbb7461f6, useRenderDropIndicator as $612b8eb6cb90e02d$export$971707d8a129a1f7} from "./DragAndDrop.mjs";
4
4
  import {HeaderContext as $72a5793c14baf454$export$e0e4026c12a8bdbb} from "./Header.mjs";
5
+ import {InternalAutocompleteContext as $d2f53cda644affe3$export$9fac5c9733526516} from "./Autocomplete.mjs";
5
6
  import {SeparatorContext as $431f98aba6844401$export$6615d83f6de245ce} from "./Separator.mjs";
6
7
  import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.mjs";
7
8
  import {useLocale as $e8Bmu$useLocale, useCollator as $e8Bmu$useCollator, ListKeyboardDelegate as $e8Bmu$ListKeyboardDelegate, useListBox as $e8Bmu$useListBox, useFocusRing as $e8Bmu$useFocusRing, FocusScope as $e8Bmu$FocusScope, mergeProps as $e8Bmu$mergeProps, useListBoxSection as $e8Bmu$useListBoxSection, useOption as $e8Bmu$useOption, useHover as $e8Bmu$useHover} from "react-aria";
8
9
  import {CollectionBuilder as $e8Bmu$CollectionBuilder, Collection as $e8Bmu$Collection, createBranchComponent as $e8Bmu$createBranchComponent, createLeafComponent as $e8Bmu$createLeafComponent} from "@react-aria/collections";
9
10
  import {useListState as $e8Bmu$useListState} from "react-stately";
10
- import {filterDOMProps as $e8Bmu$filterDOMProps, useObjectRef as $e8Bmu$useObjectRef} from "@react-aria/utils";
11
+ import {useObjectRef as $e8Bmu$useObjectRef, mergeRefs as $e8Bmu$mergeRefs, filterDOMProps as $e8Bmu$filterDOMProps} from "@react-aria/utils";
11
12
  import $e8Bmu$react, {createContext as $e8Bmu$createContext, forwardRef as $e8Bmu$forwardRef, useContext as $e8Bmu$useContext, useMemo as $e8Bmu$useMemo, useRef as $e8Bmu$useRef, useEffect as $e8Bmu$useEffect} from "react";
12
13
 
13
14
  /*
@@ -31,6 +32,7 @@ import $e8Bmu$react, {createContext as $e8Bmu$createContext, forwardRef as $e8Bm
31
32
 
32
33
 
33
34
 
35
+
34
36
  const $eed445e0843c11d0$export$7ff8f37d2d81a48d = /*#__PURE__*/ (0, $e8Bmu$createContext)(null);
35
37
  const $eed445e0843c11d0$export$7c5906fe4f1f2af2 = /*#__PURE__*/ (0, $e8Bmu$createContext)(null);
36
38
  const $eed445e0843c11d0$export$41f133550aa26f48 = /*#__PURE__*/ (0, $e8Bmu$forwardRef)(function ListBox(props, ref) {
@@ -62,13 +64,27 @@ function $eed445e0843c11d0$var$StandaloneListBox({ props: props, listBoxRef: lis
62
64
  items: null
63
65
  };
64
66
  let { layoutDelegate: layoutDelegate } = (0, $e8Bmu$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
67
+ let { filterFn: filterFn, collectionProps: collectionProps, collectionRef: collectionRef } = (0, $e8Bmu$useContext)((0, $d2f53cda644affe3$export$9fac5c9733526516)) || {};
68
+ // Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens
69
+ listBoxRef = (0, $e8Bmu$useObjectRef)((0, $e8Bmu$useMemo)(()=>(0, $e8Bmu$mergeRefs)(listBoxRef, collectionRef !== undefined ? collectionRef : null), [
70
+ collectionRef,
71
+ listBoxRef
72
+ ]));
73
+ let filteredCollection = (0, $e8Bmu$useMemo)(()=>filterFn ? collection.filter(filterFn) : collection, [
74
+ collection,
75
+ filterFn
76
+ ]);
65
77
  let state = (0, $e8Bmu$useListState)({
66
78
  ...props,
79
+ collection: filteredCollection,
67
80
  layoutDelegate: layoutDelegate
68
81
  });
69
82
  return /*#__PURE__*/ (0, $e8Bmu$react).createElement($eed445e0843c11d0$var$ListBoxInner, {
70
83
  state: state,
71
- props: props,
84
+ props: {
85
+ ...props,
86
+ ...collectionProps
87
+ },
72
88
  listBoxRef: listBoxRef
73
89
  });
74
90
  }
@@ -2,12 +2,13 @@ import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5,
2
2
  import {DEFAULT_SLOT as $64fa3d84918910a7$export$c62b8e45d58ddad9, Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8} from "./utils.module.js";
3
3
  import {DragAndDropContext as $612b8eb6cb90e02d$export$d188a835a7bc5783, DropIndicatorContext as $612b8eb6cb90e02d$export$f55761759794cf55, useDndPersistedKeys as $612b8eb6cb90e02d$export$d1e8e3fbb7461f6, useRenderDropIndicator as $612b8eb6cb90e02d$export$971707d8a129a1f7} from "./DragAndDrop.module.js";
4
4
  import {HeaderContext as $72a5793c14baf454$export$e0e4026c12a8bdbb} from "./Header.module.js";
5
+ import {InternalAutocompleteContext as $d2f53cda644affe3$export$9fac5c9733526516} from "./Autocomplete.module.js";
5
6
  import {SeparatorContext as $431f98aba6844401$export$6615d83f6de245ce} from "./Separator.module.js";
6
7
  import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.module.js";
7
8
  import {useLocale as $e8Bmu$useLocale, useCollator as $e8Bmu$useCollator, ListKeyboardDelegate as $e8Bmu$ListKeyboardDelegate, useListBox as $e8Bmu$useListBox, useFocusRing as $e8Bmu$useFocusRing, FocusScope as $e8Bmu$FocusScope, mergeProps as $e8Bmu$mergeProps, useListBoxSection as $e8Bmu$useListBoxSection, useOption as $e8Bmu$useOption, useHover as $e8Bmu$useHover} from "react-aria";
8
9
  import {CollectionBuilder as $e8Bmu$CollectionBuilder, Collection as $e8Bmu$Collection, createBranchComponent as $e8Bmu$createBranchComponent, createLeafComponent as $e8Bmu$createLeafComponent} from "@react-aria/collections";
9
10
  import {useListState as $e8Bmu$useListState} from "react-stately";
10
- import {filterDOMProps as $e8Bmu$filterDOMProps, useObjectRef as $e8Bmu$useObjectRef} from "@react-aria/utils";
11
+ import {useObjectRef as $e8Bmu$useObjectRef, mergeRefs as $e8Bmu$mergeRefs, filterDOMProps as $e8Bmu$filterDOMProps} from "@react-aria/utils";
11
12
  import $e8Bmu$react, {createContext as $e8Bmu$createContext, forwardRef as $e8Bmu$forwardRef, useContext as $e8Bmu$useContext, useMemo as $e8Bmu$useMemo, useRef as $e8Bmu$useRef, useEffect as $e8Bmu$useEffect} from "react";
12
13
 
13
14
  /*
@@ -31,6 +32,7 @@ import $e8Bmu$react, {createContext as $e8Bmu$createContext, forwardRef as $e8Bm
31
32
 
32
33
 
33
34
 
35
+
34
36
  const $eed445e0843c11d0$export$7ff8f37d2d81a48d = /*#__PURE__*/ (0, $e8Bmu$createContext)(null);
35
37
  const $eed445e0843c11d0$export$7c5906fe4f1f2af2 = /*#__PURE__*/ (0, $e8Bmu$createContext)(null);
36
38
  const $eed445e0843c11d0$export$41f133550aa26f48 = /*#__PURE__*/ (0, $e8Bmu$forwardRef)(function ListBox(props, ref) {
@@ -62,13 +64,27 @@ function $eed445e0843c11d0$var$StandaloneListBox({ props: props, listBoxRef: lis
62
64
  items: null
63
65
  };
64
66
  let { layoutDelegate: layoutDelegate } = (0, $e8Bmu$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
67
+ let { filterFn: filterFn, collectionProps: collectionProps, collectionRef: collectionRef } = (0, $e8Bmu$useContext)((0, $d2f53cda644affe3$export$9fac5c9733526516)) || {};
68
+ // Memoed so that useAutocomplete callback ref is properly only called once on mount and not everytime a rerender happens
69
+ listBoxRef = (0, $e8Bmu$useObjectRef)((0, $e8Bmu$useMemo)(()=>(0, $e8Bmu$mergeRefs)(listBoxRef, collectionRef !== undefined ? collectionRef : null), [
70
+ collectionRef,
71
+ listBoxRef
72
+ ]));
73
+ let filteredCollection = (0, $e8Bmu$useMemo)(()=>filterFn ? collection.filter(filterFn) : collection, [
74
+ collection,
75
+ filterFn
76
+ ]);
65
77
  let state = (0, $e8Bmu$useListState)({
66
78
  ...props,
79
+ collection: filteredCollection,
67
80
  layoutDelegate: layoutDelegate
68
81
  });
69
82
  return /*#__PURE__*/ (0, $e8Bmu$react).createElement($eed445e0843c11d0$var$ListBoxInner, {
70
83
  state: state,
71
- props: props,
84
+ props: {
85
+ ...props,
86
+ ...collectionProps
87
+ },
72
88
  listBoxRef: listBoxRef
73
89
  });
74
90
  }