@react-aria/autocomplete 3.0.0-alpha.35 → 3.0.0-alpha.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ar-AE.main.js +6 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +8 -0
- package/dist/ar-AE.module.js +8 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +6 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +8 -0
- package/dist/bg-BG.module.js +8 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +6 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +8 -0
- package/dist/cs-CZ.module.js +8 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +6 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +8 -0
- package/dist/da-DK.module.js +8 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +6 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +8 -0
- package/dist/de-DE.module.js +8 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +6 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +8 -0
- package/dist/el-GR.module.js +8 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +6 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +8 -0
- package/dist/en-US.module.js +8 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +6 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +8 -0
- package/dist/es-ES.module.js +8 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +6 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +8 -0
- package/dist/et-EE.module.js +8 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +6 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +8 -0
- package/dist/fi-FI.module.js +8 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +6 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +8 -0
- package/dist/fr-FR.module.js +8 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +6 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +8 -0
- package/dist/he-IL.module.js +8 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +6 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +8 -0
- package/dist/hr-HR.module.js +8 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +6 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +8 -0
- package/dist/hu-HU.module.js +8 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +3 -1
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +6 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +8 -0
- package/dist/it-IT.module.js +8 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +6 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +8 -0
- package/dist/ja-JP.module.js +8 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +6 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +8 -0
- package/dist/ko-KR.module.js +8 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +6 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +8 -0
- package/dist/lt-LT.module.js +8 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +6 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +8 -0
- package/dist/lv-LV.module.js +8 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -1
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +6 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +8 -0
- package/dist/nb-NO.module.js +8 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +6 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +8 -0
- package/dist/nl-NL.module.js +8 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +6 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +8 -0
- package/dist/pl-PL.module.js +8 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +6 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +8 -0
- package/dist/pt-BR.module.js +8 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +6 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +8 -0
- package/dist/pt-PT.module.js +8 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +6 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +8 -0
- package/dist/ro-RO.module.js +8 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +6 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +8 -0
- package/dist/ru-RU.module.js +8 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +6 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +8 -0
- package/dist/sk-SK.module.js +8 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +6 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +8 -0
- package/dist/sl-SI.module.js +8 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +6 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +8 -0
- package/dist/sr-SP.module.js +8 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +6 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +8 -0
- package/dist/sv-SE.module.js +8 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +6 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +8 -0
- package/dist/tr-TR.module.js +8 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +37 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +6 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +8 -0
- package/dist/uk-UA.module.js +8 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/useAutocomplete.main.js +222 -0
- package/dist/useAutocomplete.main.js.map +1 -0
- package/dist/useAutocomplete.mjs +217 -0
- package/dist/useAutocomplete.module.js +217 -0
- package/dist/useAutocomplete.module.js.map +1 -0
- package/dist/zh-CN.main.js +6 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +8 -0
- package/dist/zh-CN.module.js +8 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +6 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +8 -0
- package/dist/zh-TW.module.js +8 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +16 -12
- package/src/index.ts +3 -0
- package/src/useAutocomplete.ts +290 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/ro-RO.json"],"sourcesContent":["{\n \"collectionLabel\": \"Sugestii\"\n}\n"],"names":[],"version":3,"file":"ro-RO.main.js.map"}
|
package/dist/ro-RO.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/ro-RO.json"],"sourcesContent":["{\n \"collectionLabel\": \"Sugestii\"\n}\n"],"names":[],"version":3,"file":"ro-RO.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,6EAAW,CAAC;AACpD","sources":["packages/@react-aria/autocomplete/intl/ru-RU.json"],"sourcesContent":["{\n \"collectionLabel\": \"Предложения\"\n}\n"],"names":[],"version":3,"file":"ru-RU.main.js.map"}
|
package/dist/ru-RU.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var $bafcc9870f83af97$exports = {};
|
|
2
|
+
$bafcc9870f83af97$exports = {
|
|
3
|
+
"collectionLabel": `\u{41F}\u{440}\u{435}\u{434}\u{43B}\u{43E}\u{436}\u{435}\u{43D}\u{438}\u{44F}`
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export {$bafcc9870f83af97$exports as default};
|
|
8
|
+
//# sourceMappingURL=ru-RU.module.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var $bafcc9870f83af97$exports = {};
|
|
2
|
+
$bafcc9870f83af97$exports = {
|
|
3
|
+
"collectionLabel": `\u{41F}\u{440}\u{435}\u{434}\u{43B}\u{43E}\u{436}\u{435}\u{43D}\u{438}\u{44F}`
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export {$bafcc9870f83af97$exports as default};
|
|
8
|
+
//# sourceMappingURL=ru-RU.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,6EAAW,CAAC;AACpD","sources":["packages/@react-aria/autocomplete/intl/ru-RU.json"],"sourcesContent":["{\n \"collectionLabel\": \"Предложения\"\n}\n"],"names":[],"version":3,"file":"ru-RU.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,SAAM,CAAC;AAC/C","sources":["packages/@react-aria/autocomplete/intl/sk-SK.json"],"sourcesContent":["{\n \"collectionLabel\": \"Návrhy\"\n}\n"],"names":[],"version":3,"file":"sk-SK.main.js.map"}
|
package/dist/sk-SK.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,SAAM,CAAC;AAC/C","sources":["packages/@react-aria/autocomplete/intl/sk-SK.json"],"sourcesContent":["{\n \"collectionLabel\": \"Návrhy\"\n}\n"],"names":[],"version":3,"file":"sk-SK.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/sl-SI.json"],"sourcesContent":["{\n \"collectionLabel\": \"Predlogi\"\n}\n"],"names":[],"version":3,"file":"sl-SI.main.js.map"}
|
package/dist/sl-SI.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/sl-SI.json"],"sourcesContent":["{\n \"collectionLabel\": \"Predlogi\"\n}\n"],"names":[],"version":3,"file":"sl-SI.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/sr-SP.json"],"sourcesContent":["{\n \"collectionLabel\": \"Predlozi\"\n}\n"],"names":[],"version":3,"file":"sr-SP.main.js.map"}
|
package/dist/sr-SP.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,QAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/sr-SP.json"],"sourcesContent":["{\n \"collectionLabel\": \"Predlozi\"\n}\n"],"names":[],"version":3,"file":"sr-SP.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,UAAO,CAAC;AAChD","sources":["packages/@react-aria/autocomplete/intl/sv-SE.json"],"sourcesContent":["{\n \"collectionLabel\": \"Förslag\"\n}\n"],"names":[],"version":3,"file":"sv-SE.main.js.map"}
|
package/dist/sv-SE.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,UAAO,CAAC;AAChD","sources":["packages/@react-aria/autocomplete/intl/sv-SE.json"],"sourcesContent":["{\n \"collectionLabel\": \"Förslag\"\n}\n"],"names":[],"version":3,"file":"sv-SE.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,WAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/tr-TR.json"],"sourcesContent":["{\n \"collectionLabel\": \"Öneriler\"\n}\n"],"names":[],"version":3,"file":"tr-TR.main.js.map"}
|
package/dist/tr-TR.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,WAAQ,CAAC;AACjD","sources":["packages/@react-aria/autocomplete/intl/tr-TR.json"],"sourcesContent":["{\n \"collectionLabel\": \"Öneriler\"\n}\n"],"names":[],"version":3,"file":"tr-TR.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { AriaButtonProps } from "@react-types/button";
|
|
|
2
2
|
import { AriaListBoxOptions } from "@react-aria/listbox";
|
|
3
3
|
import { AriaSearchAutocompleteProps } from "@react-types/autocomplete";
|
|
4
4
|
import { ComboBoxState } from "@react-stately/combobox";
|
|
5
|
-
import { DOMAttributes, KeyboardDelegate, LayoutDelegate, RefObject, ValidationResult } from "@react-types/shared";
|
|
5
|
+
import { DOMAttributes, KeyboardDelegate, LayoutDelegate, RefObject, ValidationResult, AriaLabelingProps, DOMProps } from "@react-types/shared";
|
|
6
6
|
import { InputHTMLAttributes } from "react";
|
|
7
|
+
import { AriaTextFieldProps } from "@react-aria/textfield";
|
|
8
|
+
import { AutocompleteProps, AutocompleteState } from "@react-stately/autocomplete";
|
|
7
9
|
export interface SearchAutocompleteAria<T> extends ValidationResult {
|
|
8
10
|
/** Props for the label element. */
|
|
9
11
|
labelProps: DOMAttributes;
|
|
@@ -41,6 +43,40 @@ export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocomplete
|
|
|
41
43
|
* @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
|
|
42
44
|
*/
|
|
43
45
|
export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T>;
|
|
46
|
+
export interface CollectionOptions extends DOMProps, AriaLabelingProps {
|
|
47
|
+
/** Whether the collection items should use virtual focus instead of being focused directly. */
|
|
48
|
+
shouldUseVirtualFocus: boolean;
|
|
49
|
+
/** Whether typeahead is disabled. */
|
|
50
|
+
disallowTypeAhead: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface AriaAutocompleteProps extends AutocompleteProps {
|
|
53
|
+
/**
|
|
54
|
+
* An optional filter function used to determine if a option should be included in the autocomplete list.
|
|
55
|
+
* Include this if the items you are providing to your wrapped collection aren't filtered by default.
|
|
56
|
+
*/
|
|
57
|
+
filter?: (textValue: string, inputValue: string) => boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface AriaAutocompleteOptions extends Omit<AriaAutocompleteProps, 'children'> {
|
|
60
|
+
/** The ref for the wrapped collection element. */
|
|
61
|
+
collectionRef: RefObject<HTMLElement | null>;
|
|
62
|
+
}
|
|
63
|
+
export interface AutocompleteAria {
|
|
64
|
+
/** Props for the autocomplete textfield/searchfield element. These should be passed to the textfield/searchfield aria hooks respectively. */
|
|
65
|
+
textFieldProps: AriaTextFieldProps;
|
|
66
|
+
/** Props for the collection, to be passed to collection's respective aria hook (e.g. useMenu). */
|
|
67
|
+
collectionProps: CollectionOptions;
|
|
68
|
+
/** Ref to attach to the wrapped collection. */
|
|
69
|
+
collectionRef: RefObject<HTMLElement | null>;
|
|
70
|
+
/** A filter function that returns if the provided collection node should be filtered out of the collection. */
|
|
71
|
+
filterFn?: (nodeTextValue: string) => boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Provides the behavior and accessibility implementation for a autocomplete component.
|
|
75
|
+
* A autocomplete combines a text input with a collection, allowing users to filter the collection's contents match a query.
|
|
76
|
+
* @param props - Props for the autocomplete.
|
|
77
|
+
* @param state - State for the autocomplete, as returned by `useAutocompleteState`.
|
|
78
|
+
*/
|
|
79
|
+
export function UNSTABLE_useAutocomplete(props: AriaAutocompleteOptions, state: AutocompleteState): AutocompleteAria;
|
|
44
80
|
export type { AriaSearchAutocompleteProps } from '@react-types/autocomplete';
|
|
45
81
|
|
|
46
82
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;AAsBA,wCAAwC,CAAC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Aa,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAA;CAC7C;AAED;IACE,6IAA6I;IAC7I,cAAc,EAAE,kBAAkB,CAAC;IACnC,kGAAkG;IAClG,eAAe,EAAE,iBAAiB,CAAC;IACnC,+CAA+C;IAC/C,aAAa,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IAC7C,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAA;CAC9C;AAED;;;;;GAKG;AACH,yCAAyC,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,iBAAiB,GAAG,gBAAgB,CAwOnH;AClRD,YAAY,EAAC,2BAA2B,EAAC,MAAM,2BAA2B,CAAC","sources":["packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts","packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/useAutocomplete.ts","packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2021 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 */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport {UNSTABLE_useAutocomplete} from './useAutocomplete';\n\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\nexport type {AriaAutocompleteProps, AriaAutocompleteOptions, AutocompleteAria, CollectionOptions} from './useAutocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,mBAAmB,CAAC,sEAAU,CAAC;AACnD","sources":["packages/@react-aria/autocomplete/intl/uk-UA.json"],"sourcesContent":["{\n \"collectionLabel\": \"Пропозиції\"\n}\n"],"names":[],"version":3,"file":"uk-UA.main.js.map"}
|
package/dist/uk-UA.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,sEAAU,CAAC;AACnD","sources":["packages/@react-aria/autocomplete/intl/uk-UA.json"],"sourcesContent":["{\n \"collectionLabel\": \"Пропозиції\"\n}\n"],"names":[],"version":3,"file":"uk-UA.module.js.map"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
var $fbc7b37667f52272$exports = require("./intlStrings.main.js");
|
|
2
|
+
var $4yz2I$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $4yz2I$react = require("react");
|
|
4
|
+
var $4yz2I$reactariai18n = require("@react-aria/i18n");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function $parcel$interopDefault(a) {
|
|
8
|
+
return a && a.__esModule ? a.default : a;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function $parcel$export(e, n, v, s) {
|
|
12
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
$parcel$export(module.exports, "UNSTABLE_useAutocomplete", () => $d43aec1bf2be84e8$export$2d6947d4992da88e);
|
|
16
|
+
/*
|
|
17
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
+
* governing permissions and limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
function $d43aec1bf2be84e8$export$2d6947d4992da88e(props, state) {
|
|
31
|
+
let { collectionRef: collectionRef, filter: filter } = props;
|
|
32
|
+
let collectionId = (0, $4yz2I$reactariautils.useId)();
|
|
33
|
+
let timeout = (0, $4yz2I$react.useRef)(undefined);
|
|
34
|
+
let delayNextActiveDescendant = (0, $4yz2I$react.useRef)(false);
|
|
35
|
+
let queuedActiveDescendant = (0, $4yz2I$react.useRef)(null);
|
|
36
|
+
let lastCollectionNode = (0, $4yz2I$react.useRef)(null);
|
|
37
|
+
let updateActiveDescendant = (0, $4yz2I$reactariautils.useEffectEvent)((e)=>{
|
|
38
|
+
let { target: target } = e;
|
|
39
|
+
if (queuedActiveDescendant.current === target.id) return;
|
|
40
|
+
clearTimeout(timeout.current);
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (target !== collectionRef.current) {
|
|
43
|
+
if (delayNextActiveDescendant.current) {
|
|
44
|
+
queuedActiveDescendant.current = target.id;
|
|
45
|
+
timeout.current = setTimeout(()=>{
|
|
46
|
+
state.setFocusedNodeId(target.id);
|
|
47
|
+
queuedActiveDescendant.current = null;
|
|
48
|
+
}, 500);
|
|
49
|
+
} else state.setFocusedNodeId(target.id);
|
|
50
|
+
} else state.setFocusedNodeId(null);
|
|
51
|
+
delayNextActiveDescendant.current = false;
|
|
52
|
+
});
|
|
53
|
+
let callbackRef = (0, $4yz2I$react.useCallback)((collectionNode)=>{
|
|
54
|
+
var _lastCollectionNode_current;
|
|
55
|
+
if (collectionNode != null) {
|
|
56
|
+
var // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement
|
|
57
|
+
// of the letter you just typed. If we recieve another UPDATE_ACTIVEDESCENDANT call then we clear the queued update
|
|
58
|
+
// We track lastCollectionNode to do proper cleanup since callbackRefs just pass null when unmounting. This also handles
|
|
59
|
+
// React 19's extra call of the callback ref in strict mode
|
|
60
|
+
_lastCollectionNode_current1;
|
|
61
|
+
(_lastCollectionNode_current1 = lastCollectionNode.current) === null || _lastCollectionNode_current1 === void 0 ? void 0 : _lastCollectionNode_current1.removeEventListener((0, $4yz2I$reactariautils.UPDATE_ACTIVEDESCENDANT), updateActiveDescendant);
|
|
62
|
+
lastCollectionNode.current = collectionNode;
|
|
63
|
+
collectionNode.addEventListener((0, $4yz2I$reactariautils.UPDATE_ACTIVEDESCENDANT), updateActiveDescendant);
|
|
64
|
+
} else (_lastCollectionNode_current = lastCollectionNode.current) === null || _lastCollectionNode_current === void 0 ? void 0 : _lastCollectionNode_current.removeEventListener((0, $4yz2I$reactariautils.UPDATE_ACTIVEDESCENDANT), updateActiveDescendant);
|
|
65
|
+
}, [
|
|
66
|
+
updateActiveDescendant
|
|
67
|
+
]);
|
|
68
|
+
// Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection
|
|
69
|
+
let mergedCollectionRef = (0, $4yz2I$reactariautils.useObjectRef)((0, $4yz2I$react.useMemo)(()=>(0, $4yz2I$reactariautils.mergeRefs)(collectionRef, callbackRef), [
|
|
70
|
+
collectionRef,
|
|
71
|
+
callbackRef
|
|
72
|
+
]));
|
|
73
|
+
let focusFirstItem = (0, $4yz2I$reactariautils.useEffectEvent)(()=>{
|
|
74
|
+
var _collectionRef_current;
|
|
75
|
+
delayNextActiveDescendant.current = true;
|
|
76
|
+
(_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new CustomEvent((0, $4yz2I$reactariautils.FOCUS_EVENT), {
|
|
77
|
+
cancelable: true,
|
|
78
|
+
bubbles: true,
|
|
79
|
+
detail: {
|
|
80
|
+
focusStrategy: 'first'
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
let clearVirtualFocus = (0, $4yz2I$reactariautils.useEffectEvent)(()=>{
|
|
85
|
+
var _collectionRef_current;
|
|
86
|
+
state.setFocusedNodeId(null);
|
|
87
|
+
let clearFocusEvent = new CustomEvent((0, $4yz2I$reactariautils.CLEAR_FOCUS_EVENT), {
|
|
88
|
+
cancelable: true,
|
|
89
|
+
bubbles: true
|
|
90
|
+
});
|
|
91
|
+
clearTimeout(timeout.current);
|
|
92
|
+
delayNextActiveDescendant.current = false;
|
|
93
|
+
(_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(clearFocusEvent);
|
|
94
|
+
});
|
|
95
|
+
// TODO: update to see if we can tell what kind of event (paste vs backspace vs typing) is happening instead
|
|
96
|
+
let onChange = (value)=>{
|
|
97
|
+
// Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when deleting text
|
|
98
|
+
// for screen reader announcements
|
|
99
|
+
if (state.inputValue !== value && state.inputValue.length <= value.length) focusFirstItem();
|
|
100
|
+
else clearVirtualFocus();
|
|
101
|
+
state.setInputValue(value);
|
|
102
|
+
};
|
|
103
|
+
let keyDownTarget = (0, $4yz2I$react.useRef)(null);
|
|
104
|
+
// For textfield specific keydown operations
|
|
105
|
+
let onKeyDown = (e)=>{
|
|
106
|
+
var _collectionRef_current;
|
|
107
|
+
keyDownTarget.current = e.target;
|
|
108
|
+
if (e.nativeEvent.isComposing) return;
|
|
109
|
+
switch(e.key){
|
|
110
|
+
case 'a':
|
|
111
|
+
if ((0, $4yz2I$reactariautils.isCtrlKeyPressed)(e)) return;
|
|
112
|
+
break;
|
|
113
|
+
case 'Escape':
|
|
114
|
+
// Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and
|
|
115
|
+
// close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check
|
|
116
|
+
// for isPropagationStopped
|
|
117
|
+
if (e.isDefaultPrevented()) return;
|
|
118
|
+
break;
|
|
119
|
+
case ' ':
|
|
120
|
+
// Space shouldn't trigger onAction so early return.
|
|
121
|
+
return;
|
|
122
|
+
case 'Home':
|
|
123
|
+
case 'End':
|
|
124
|
+
case 'PageDown':
|
|
125
|
+
case 'PageUp':
|
|
126
|
+
case 'ArrowUp':
|
|
127
|
+
case 'ArrowDown':
|
|
128
|
+
{
|
|
129
|
+
var _collectionRef_current1;
|
|
130
|
+
if ((e.key === 'Home' || e.key === 'End') && state.focusedNodeId == null && e.shiftKey) return;
|
|
131
|
+
// Prevent these keys from moving the text cursor in the input
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
// Move virtual focus into the wrapped collection
|
|
134
|
+
let focusCollection = new CustomEvent((0, $4yz2I$reactariautils.FOCUS_EVENT), {
|
|
135
|
+
cancelable: true,
|
|
136
|
+
bubbles: true
|
|
137
|
+
});
|
|
138
|
+
(_collectionRef_current1 = collectionRef.current) === null || _collectionRef_current1 === void 0 ? void 0 : _collectionRef_current1.dispatchEvent(focusCollection);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case 'ArrowLeft':
|
|
142
|
+
case 'ArrowRight':
|
|
143
|
+
// TODO: will need to special case this so it doesn't clear the focused key if we are currently
|
|
144
|
+
// focused on a submenutrigger? May not need to since focus would
|
|
145
|
+
// But what about wrapped grids where ArrowLeft and ArrowRight should navigate left/right
|
|
146
|
+
clearVirtualFocus();
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
// Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter
|
|
150
|
+
// or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events
|
|
151
|
+
// like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble
|
|
152
|
+
// as expected
|
|
153
|
+
if (!e.isPropagationStopped()) e.stopPropagation();
|
|
154
|
+
if (state.focusedNodeId == null) (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
155
|
+
else {
|
|
156
|
+
let item = document.getElementById(state.focusedNodeId);
|
|
157
|
+
item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
let onKeyUpCapture = (0, $4yz2I$reactariautils.useEffectEvent)((e)=>{
|
|
161
|
+
// Dispatch simulated key up events for things like triggering links in listbox
|
|
162
|
+
// Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair
|
|
163
|
+
// is detected by usePress instead of the original keyup originating from the input
|
|
164
|
+
if (e.target === keyDownTarget.current) {
|
|
165
|
+
var _collectionRef_current;
|
|
166
|
+
e.stopImmediatePropagation();
|
|
167
|
+
if (state.focusedNodeId == null) (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new KeyboardEvent(e.type, e));
|
|
168
|
+
else {
|
|
169
|
+
let item = document.getElementById(state.focusedNodeId);
|
|
170
|
+
item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.type, e));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
(0, $4yz2I$react.useEffect)(()=>{
|
|
175
|
+
document.addEventListener('keyup', onKeyUpCapture, true);
|
|
176
|
+
return ()=>{
|
|
177
|
+
document.removeEventListener('keyup', onKeyUpCapture, true);
|
|
178
|
+
};
|
|
179
|
+
}, [
|
|
180
|
+
onKeyUpCapture
|
|
181
|
+
]);
|
|
182
|
+
let stringFormatter = (0, $4yz2I$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($fbc7b37667f52272$exports))), '@react-aria/autocomplete');
|
|
183
|
+
let collectionProps = (0, $4yz2I$reactariautils.useLabels)({
|
|
184
|
+
id: collectionId,
|
|
185
|
+
'aria-label': stringFormatter.format('collectionLabel')
|
|
186
|
+
});
|
|
187
|
+
let filterFn = (0, $4yz2I$react.useCallback)((nodeTextValue)=>{
|
|
188
|
+
if (filter) return filter(nodeTextValue, state.inputValue);
|
|
189
|
+
return true;
|
|
190
|
+
}, [
|
|
191
|
+
state.inputValue,
|
|
192
|
+
filter
|
|
193
|
+
]);
|
|
194
|
+
var _state_focusedNodeId;
|
|
195
|
+
return {
|
|
196
|
+
textFieldProps: {
|
|
197
|
+
value: state.inputValue,
|
|
198
|
+
onChange: onChange,
|
|
199
|
+
onKeyDown: onKeyDown,
|
|
200
|
+
autoComplete: 'off',
|
|
201
|
+
'aria-haspopup': 'listbox',
|
|
202
|
+
'aria-controls': collectionId,
|
|
203
|
+
// TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)
|
|
204
|
+
'aria-autocomplete': 'list',
|
|
205
|
+
'aria-activedescendant': (_state_focusedNodeId = state.focusedNodeId) !== null && _state_focusedNodeId !== void 0 ? _state_focusedNodeId : undefined,
|
|
206
|
+
// This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.
|
|
207
|
+
autoCorrect: 'off',
|
|
208
|
+
// This disable's the macOS Safari spell check auto corrections.
|
|
209
|
+
spellCheck: 'false'
|
|
210
|
+
},
|
|
211
|
+
collectionProps: (0, $4yz2I$reactariautils.mergeProps)(collectionProps, {
|
|
212
|
+
// TODO: shouldFocusOnHover? shouldFocusWrap? Should it be up to the wrapped collection?
|
|
213
|
+
shouldUseVirtualFocus: true,
|
|
214
|
+
disallowTypeAhead: true
|
|
215
|
+
}),
|
|
216
|
+
collectionRef: mergedCollectionRef,
|
|
217
|
+
filterFn: filter != null ? filterFn : undefined
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=useAutocomplete.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+CM,SAAS,0CAAyB,KAA8B,EAAE,KAAwB;IAC/F,IAAI,iBACF,a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,SAAS,cAAc,CAAC,MAAM,aAAa;gBACtD,iBAAA,2BAAA,KAAM,aAAa,CACjB,IAAI,cAAc,EAAE,IAAI,EAAE;YAE9B;QACF;IACF;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,SAAS,gBAAgB,CAAC,SAAS,gBAAgB;QACnD,OAAO;YACL,SAAS,mBAAmB,CAAC,SAAS,gBAAgB;QACxD;IACF,GAAG;QAAC;KAAe;IAEnB,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,kBAAkB,CAAA,GAAA,+BAAQ,EAAE;QAC9B,IAAI;QACJ,cAAc,gBAAgB,MAAM,CAAC;IACvC;IAEA,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC1B,IAAI,QACF,OAAO,OAAO,eAAe,MAAM,UAAU;QAG/C,OAAO;IACT,GAAG;QAAC,MAAM,UAAU;QAAE;KAAO;QAYA;IAV7B,OAAO;QACL,gBAAgB;YACd,OAAO,MAAM,UAAU;sBACvB;uBACA;YACA,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,mFAAmF;YACnF,qBAAqB;YACrB,yBAAyB,CAAA,uBAAA,MAAM,aAAa,cAAnB,kCAAA,uBAAuB;YAChD,qGAAqG;YACrG,aAAa;YACb,gEAAgE;YAChE,YAAY;QACd;QACA,iBAAiB,CAAA,GAAA,gCAAS,EAAE,iBAAiB;YAC3C,wFAAwF;YACxF,uBAAuB;YACvB,mBAAmB;QACrB;QACA,eAAe;QACf,UAAU,UAAU,OAAO,WAAW;IACxC;AACF","sources":["packages/@react-aria/autocomplete/src/useAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, BaseEvent, DOMProps, RefObject} from '@react-types/shared';\nimport {AriaTextFieldProps} from '@react-aria/textfield';\nimport {AutocompleteProps, AutocompleteState} from '@react-stately/autocomplete';\nimport {CLEAR_FOCUS_EVENT, FOCUS_EVENT, isCtrlKeyPressed, mergeProps, mergeRefs, UPDATE_ACTIVEDESCENDANT, useEffectEvent, useId, useLabels, useObjectRef} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {KeyboardEvent as ReactKeyboardEvent, useCallback, useEffect, useMemo, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface CollectionOptions extends DOMProps, AriaLabelingProps {\n /** Whether the collection items should use virtual focus instead of being focused directly. */\n shouldUseVirtualFocus: boolean,\n /** Whether typeahead is disabled. */\n disallowTypeAhead: boolean\n}\nexport interface AriaAutocompleteProps extends AutocompleteProps {\n /**\n * An optional filter function used to determine if a option should be included in the autocomplete list.\n * Include this if the items you are providing to your wrapped collection aren't filtered by default.\n */\n filter?: (textValue: string, inputValue: string) => boolean\n}\n\nexport interface AriaAutocompleteOptions extends Omit<AriaAutocompleteProps, 'children'> {\n /** The ref for the wrapped collection element. */\n collectionRef: RefObject<HTMLElement | null>\n}\n\nexport interface AutocompleteAria {\n /** Props for the autocomplete textfield/searchfield element. These should be passed to the textfield/searchfield aria hooks respectively. */\n textFieldProps: AriaTextFieldProps,\n /** Props for the collection, to be passed to collection's respective aria hook (e.g. useMenu). */\n collectionProps: CollectionOptions,\n /** Ref to attach to the wrapped collection. */\n collectionRef: RefObject<HTMLElement | null>,\n /** A filter function that returns if the provided collection node should be filtered out of the collection. */\n filterFn?: (nodeTextValue: string) => boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a autocomplete component.\n * A autocomplete combines a text input with a collection, allowing users to filter the collection's contents match a query.\n * @param props - Props for the autocomplete.\n * @param state - State for the autocomplete, as returned by `useAutocompleteState`.\n */\nexport function UNSTABLE_useAutocomplete(props: AriaAutocompleteOptions, state: AutocompleteState): AutocompleteAria {\n let {\n collectionRef,\n filter\n } = props;\n\n let collectionId = useId();\n let timeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let delayNextActiveDescendant = useRef(false);\n let queuedActiveDescendant = useRef(null);\n let lastCollectionNode = useRef<HTMLElement>(null);\n\n let updateActiveDescendant = useEffectEvent((e) => {\n let {target} = e;\n if (queuedActiveDescendant.current === target.id) {\n return;\n }\n\n clearTimeout(timeout.current);\n e.stopPropagation();\n\n if (target !== collectionRef.current) {\n if (delayNextActiveDescendant.current) {\n queuedActiveDescendant.current = target.id;\n timeout.current = setTimeout(() => {\n state.setFocusedNodeId(target.id);\n queuedActiveDescendant.current = null;\n }, 500);\n } else {\n state.setFocusedNodeId(target.id);\n }\n } else {\n state.setFocusedNodeId(null);\n }\n\n delayNextActiveDescendant.current = false;\n });\n\n let callbackRef = useCallback((collectionNode) => {\n if (collectionNode != null) {\n // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement\n // of the letter you just typed. If we recieve another UPDATE_ACTIVEDESCENDANT call then we clear the queued update\n // We track lastCollectionNode to do proper cleanup since callbackRefs just pass null when unmounting. This also handles\n // React 19's extra call of the callback ref in strict mode\n lastCollectionNode.current?.removeEventListener(UPDATE_ACTIVEDESCENDANT, updateActiveDescendant);\n lastCollectionNode.current = collectionNode;\n collectionNode.addEventListener(UPDATE_ACTIVEDESCENDANT, updateActiveDescendant);\n } else {\n lastCollectionNode.current?.removeEventListener(UPDATE_ACTIVEDESCENDANT, updateActiveDescendant);\n }\n }, [updateActiveDescendant]);\n\n // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection\n let mergedCollectionRef = useObjectRef(useMemo(() => mergeRefs(collectionRef, callbackRef), [collectionRef, callbackRef]));\n\n let focusFirstItem = useEffectEvent(() => {\n delayNextActiveDescendant.current = true;\n collectionRef.current?.dispatchEvent(\n new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: {\n focusStrategy: 'first'\n }\n })\n );\n });\n\n let clearVirtualFocus = useEffectEvent(() => {\n state.setFocusedNodeId(null);\n let clearFocusEvent = new CustomEvent(CLEAR_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true\n });\n clearTimeout(timeout.current);\n delayNextActiveDescendant.current = false;\n collectionRef.current?.dispatchEvent(clearFocusEvent);\n });\n\n // TODO: update to see if we can tell what kind of event (paste vs backspace vs typing) is happening instead\n let onChange = (value: string) => {\n // Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when deleting text\n // for screen reader announcements\n if (state.inputValue !== value && state.inputValue.length <= value.length) {\n focusFirstItem();\n } else {\n clearVirtualFocus();\n }\n\n state.setInputValue(value);\n };\n\n let keyDownTarget = useRef<Element | null>(null);\n // For textfield specific keydown operations\n let onKeyDown = (e: BaseEvent<ReactKeyboardEvent<any>>) => {\n keyDownTarget.current = e.target as Element;\n if (e.nativeEvent.isComposing) {\n return;\n }\n\n switch (e.key) {\n case 'a':\n if (isCtrlKeyPressed(e)) {\n return;\n }\n break;\n case 'Escape':\n // Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and\n // close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check\n // for isPropagationStopped\n if (e.isDefaultPrevented()) {\n return;\n }\n break;\n case ' ':\n // Space shouldn't trigger onAction so early return.\n\n return;\n case 'Home':\n case 'End':\n case 'PageDown':\n case 'PageUp':\n case 'ArrowUp':\n case 'ArrowDown': {\n if ((e.key === 'Home' || e.key === 'End') && state.focusedNodeId == null && e.shiftKey) {\n return;\n }\n\n // Prevent these keys from moving the text cursor in the input\n e.preventDefault();\n // Move virtual focus into the wrapped collection\n let focusCollection = new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true\n });\n\n collectionRef.current?.dispatchEvent(focusCollection);\n break;\n }\n case 'ArrowLeft':\n case 'ArrowRight':\n // TODO: will need to special case this so it doesn't clear the focused key if we are currently\n // focused on a submenutrigger? May not need to since focus would\n // But what about wrapped grids where ArrowLeft and ArrowRight should navigate left/right\n clearVirtualFocus();\n break;\n }\n\n // Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter\n // or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events\n // like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble\n // as expected\n if (!e.isPropagationStopped()) {\n e.stopPropagation();\n }\n\n if (state.focusedNodeId == null) {\n collectionRef.current?.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n } else {\n let item = document.getElementById(state.focusedNodeId);\n item?.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n };\n\n let onKeyUpCapture = useEffectEvent((e) => {\n // Dispatch simulated key up events for things like triggering links in listbox\n // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair\n // is detected by usePress instead of the original keyup originating from the input\n if (e.target === keyDownTarget.current) {\n e.stopImmediatePropagation();\n if (state.focusedNodeId == null) {\n collectionRef.current?.dispatchEvent(\n new KeyboardEvent(e.type, e)\n );\n } else {\n let item = document.getElementById(state.focusedNodeId);\n item?.dispatchEvent(\n new KeyboardEvent(e.type, e)\n );\n }\n }\n });\n\n useEffect(() => {\n document.addEventListener('keyup', onKeyUpCapture, true);\n return () => {\n document.removeEventListener('keyup', onKeyUpCapture, true);\n };\n }, [onKeyUpCapture]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/autocomplete');\n let collectionProps = useLabels({\n id: collectionId,\n 'aria-label': stringFormatter.format('collectionLabel')\n });\n\n let filterFn = useCallback((nodeTextValue: string) => {\n if (filter) {\n return filter(nodeTextValue, state.inputValue);\n }\n\n return true;\n }, [state.inputValue, filter]);\n\n return {\n textFieldProps: {\n value: state.inputValue,\n onChange,\n onKeyDown,\n autoComplete: 'off',\n 'aria-haspopup': 'listbox',\n 'aria-controls': collectionId,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': state.focusedNodeId ?? undefined,\n // This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n },\n collectionProps: mergeProps(collectionProps, {\n // TODO: shouldFocusOnHover? shouldFocusWrap? Should it be up to the wrapped collection?\n shouldUseVirtualFocus: true,\n disallowTypeAhead: true\n }),\n collectionRef: mergedCollectionRef,\n filterFn: filter != null ? filterFn : undefined\n };\n}\n"],"names":[],"version":3,"file":"useAutocomplete.main.js.map"}
|