@react-aria/selection 3.0.0-alpha.1 → 3.0.0-nightly-4980928d3-240906
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/README.md +1 -1
- package/dist/DOMLayoutDelegate.main.js +53 -0
- package/dist/DOMLayoutDelegate.main.js.map +1 -0
- package/dist/DOMLayoutDelegate.mjs +48 -0
- package/dist/DOMLayoutDelegate.module.js +48 -0
- package/dist/DOMLayoutDelegate.module.js.map +1 -0
- package/dist/ListKeyboardDelegate.main.js +189 -0
- package/dist/ListKeyboardDelegate.main.js.map +1 -0
- package/dist/ListKeyboardDelegate.mjs +184 -0
- package/dist/ListKeyboardDelegate.module.js +184 -0
- package/dist/ListKeyboardDelegate.module.js.map +1 -0
- package/dist/import.mjs +27 -0
- package/dist/main.js +16 -608
- package/dist/main.js.map +1 -0
- package/dist/module.js +9 -563
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +218 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/useSelectableCollection.main.js +318 -0
- package/dist/useSelectableCollection.main.js.map +1 -0
- package/dist/useSelectableCollection.mjs +313 -0
- package/dist/useSelectableCollection.module.js +313 -0
- package/dist/useSelectableCollection.module.js.map +1 -0
- package/dist/useSelectableItem.main.js +213 -0
- package/dist/useSelectableItem.main.js.map +1 -0
- package/dist/useSelectableItem.mjs +208 -0
- package/dist/useSelectableItem.module.js +208 -0
- package/dist/useSelectableItem.module.js.map +1 -0
- package/dist/useSelectableList.main.js +63 -0
- package/dist/useSelectableList.main.js.map +1 -0
- package/dist/useSelectableList.mjs +58 -0
- package/dist/useSelectableList.module.js +58 -0
- package/dist/useSelectableList.module.js.map +1 -0
- package/dist/useTypeSelect.main.js +73 -0
- package/dist/useTypeSelect.main.js.map +1 -0
- package/dist/useTypeSelect.mjs +68 -0
- package/dist/useTypeSelect.module.js +68 -0
- package/dist/useTypeSelect.module.js.map +1 -0
- package/dist/utils.main.js +32 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +26 -0
- package/dist/utils.module.js +26 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +20 -13
- package/src/DOMLayoutDelegate.ts +57 -0
- package/src/ListKeyboardDelegate.ts +288 -0
- package/src/index.ts +23 -0
- package/src/useSelectableCollection.ts +490 -0
- package/src/useSelectableItem.ts +374 -0
- package/src/useSelectableList.ts +85 -0
- package/src/useTypeSelect.ts +114 -0
- package/src/utils.ts +33 -0
- package/LICENSE +0 -201
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {useSelectableCollection as $ae20dd8cbca75726$export$d6daf82dcd84e87c} from "./useSelectableCollection.module.js";
|
|
2
|
+
import {ListKeyboardDelegate as $2a25aae57d74318e$export$a05409b8bb224a5a} from "./ListKeyboardDelegate.module.js";
|
|
3
|
+
import {useCollator as $1aJk5$useCollator} from "@react-aria/i18n";
|
|
4
|
+
import {useMemo as $1aJk5$useMemo} from "react";
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
8
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
+
* governing permissions and limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function $982254629710d113$export$b95089534ab7c1fd(props) {
|
|
21
|
+
let { selectionManager: selectionManager, collection: collection, disabledKeys: disabledKeys, ref: ref, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate } = props;
|
|
22
|
+
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
23
|
+
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
24
|
+
let collator = (0, $1aJk5$useCollator)({
|
|
25
|
+
usage: 'search',
|
|
26
|
+
sensitivity: 'base'
|
|
27
|
+
});
|
|
28
|
+
let disabledBehavior = selectionManager.disabledBehavior;
|
|
29
|
+
let delegate = (0, $1aJk5$useMemo)(()=>keyboardDelegate || new (0, $2a25aae57d74318e$export$a05409b8bb224a5a)({
|
|
30
|
+
collection: collection,
|
|
31
|
+
disabledKeys: disabledKeys,
|
|
32
|
+
disabledBehavior: disabledBehavior,
|
|
33
|
+
ref: ref,
|
|
34
|
+
collator: collator,
|
|
35
|
+
layoutDelegate: layoutDelegate
|
|
36
|
+
}), [
|
|
37
|
+
keyboardDelegate,
|
|
38
|
+
layoutDelegate,
|
|
39
|
+
collection,
|
|
40
|
+
disabledKeys,
|
|
41
|
+
ref,
|
|
42
|
+
collator,
|
|
43
|
+
disabledBehavior
|
|
44
|
+
]);
|
|
45
|
+
let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
|
|
46
|
+
...props,
|
|
47
|
+
ref: ref,
|
|
48
|
+
selectionManager: selectionManager,
|
|
49
|
+
keyboardDelegate: delegate
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
listProps: collectionProps
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
export {$982254629710d113$export$b95089534ab7c1fd as useSelectableList};
|
|
58
|
+
//# sourceMappingURL=useSelectableList.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAuCM,SAAS,0CAAkB,KAAgC;IAChE,IAAI,oBACF,gBAAgB,cAChB,UAAU,gBACV,YAAY,OACZ,GAAG,oBACH,gBAAgB,kBAChB,cAAc,EACf,GAAG;IAEJ,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,mBAAmB,iBAAiB,gBAAgB;IACxD,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IACrB,oBAAoB,IAAI,CAAA,GAAA,yCAAmB,EAAE;wBAC3C;0BACA;8BACA;iBACA;sBACA;4BACA;QACF,IACC;QAAC;QAAkB;QAAgB;QAAY;QAAc;QAAK;QAAU;KAAiB;IAEhG,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,yCAAsB,EAAE;QAC9C,GAAG,KAAK;aACR;0BACA;QACA,kBAAkB;IACpB;IAEA,OAAO;QACL,WAAW;IACb;AACF","sources":["packages/@react-aria/selection/src/useSelectableList.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {AriaSelectableCollectionOptions, useSelectableCollection} from './useSelectableCollection';\nimport {Collection, DOMAttributes, Key, KeyboardDelegate, LayoutDelegate, Node} from '@react-types/shared';\nimport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nimport {useCollator} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\nexport interface AriaSelectableListOptions extends Omit<AriaSelectableCollectionOptions, 'keyboardDelegate'> {\n /**\n * State of the collection.\n */\n collection: Collection<Node<unknown>>,\n /**\n * A delegate object that implements behavior for keyboard focus movement.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate,\n /**\n * The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.\n */\n disabledKeys: Set<Key>\n}\n\nexport interface SelectableListAria {\n /**\n * Props for the option element.\n */\n listProps: DOMAttributes\n}\n\n/**\n * Handles interactions with a selectable list.\n */\nexport function useSelectableList(props: AriaSelectableListOptions): SelectableListAria {\n let {\n selectionManager,\n collection,\n disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate\n } = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let disabledBehavior = selectionManager.disabledBehavior;\n let delegate = useMemo(() => (\n keyboardDelegate || new ListKeyboardDelegate({\n collection,\n disabledKeys,\n disabledBehavior,\n ref,\n collator,\n layoutDelegate\n })\n ), [keyboardDelegate, layoutDelegate, collection, disabledKeys, ref, collator, disabledBehavior]);\n\n let {collectionProps} = useSelectableCollection({\n ...props,\n ref,\n selectionManager,\n keyboardDelegate: delegate\n });\n\n return {\n listProps: collectionProps\n };\n}\n"],"names":[],"version":3,"file":"useSelectableList.module.js.map"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var $3XJlT$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useTypeSelect", () => $a1189052f36475e8$export$e32c88dfddc6e1d8);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Controls how long to wait before clearing the typeahead buffer.
|
|
22
|
+
*/ const $a1189052f36475e8$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
|
|
23
|
+
function $a1189052f36475e8$export$e32c88dfddc6e1d8(options) {
|
|
24
|
+
let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
|
|
25
|
+
let state = (0, $3XJlT$react.useRef)({
|
|
26
|
+
search: '',
|
|
27
|
+
timeout: null
|
|
28
|
+
}).current;
|
|
29
|
+
let onKeyDown = (e)=>{
|
|
30
|
+
let character = $a1189052f36475e8$var$getStringForKey(e.key);
|
|
31
|
+
if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
|
|
32
|
+
// Do not propagate the Spacebar event if it's meant to be part of the search.
|
|
33
|
+
// When we time out, the search term becomes empty, hence the check on length.
|
|
34
|
+
// Trimming is to account for the case of pressing the Spacebar more than once,
|
|
35
|
+
// which should cycle through the selection/deselection of the focused item.
|
|
36
|
+
if (character === ' ' && state.search.trim().length > 0) {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
if (!('continuePropagation' in e)) e.stopPropagation();
|
|
39
|
+
}
|
|
40
|
+
state.search += character;
|
|
41
|
+
// Use the delegate to find a key to focus.
|
|
42
|
+
// Prioritize items after the currently focused item, falling back to searching the whole list.
|
|
43
|
+
let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
|
|
44
|
+
// If no key found, search from the top.
|
|
45
|
+
if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
|
|
46
|
+
if (key != null) {
|
|
47
|
+
selectionManager.setFocusedKey(key);
|
|
48
|
+
if (onTypeSelect) onTypeSelect(key);
|
|
49
|
+
}
|
|
50
|
+
clearTimeout(state.timeout);
|
|
51
|
+
state.timeout = setTimeout(()=>{
|
|
52
|
+
state.search = '';
|
|
53
|
+
}, $a1189052f36475e8$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
typeSelectProps: {
|
|
57
|
+
// Using a capturing listener to catch the keydown event before
|
|
58
|
+
// other hooks in order to handle the Spacebar event.
|
|
59
|
+
onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function $a1189052f36475e8$var$getStringForKey(key) {
|
|
64
|
+
// If the key is of length 1, it is an ASCII value.
|
|
65
|
+
// Otherwise, if there are no ASCII characters in the key name,
|
|
66
|
+
// it is a Unicode character.
|
|
67
|
+
// See https://www.w3.org/TR/uievents-key/
|
|
68
|
+
if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=useTypeSelect.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD;;CAEC,GACD,MAAM,mDAA6B,MAAM,WAAW;AA2B7C,SAAS,0CAAc,OAA8B;IAC1D,IAAI,oBAAC,gBAAgB,oBAAE,gBAAgB,gBAAE,YAAY,EAAC,GAAG;IACzD,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAAE;QACjB,QAAQ;QACR,SAAS;IACX,GAAG,OAAO;IAEV,IAAI,YAAY,CAAC;QACf,IAAI,YAAY,sCAAgB,EAAE,GAAG;QACrC,IAAI,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAC5E;QAGF,8EAA8E;QAC9E,8EAA8E;QAC9E,+EAA+E;QAC/E,4EAA4E;QAC5E,IAAI,cAAc,OAAO,MAAM,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,GAAG;YACvD,EAAE,cAAc;YAChB,IAAI,CAAE,CAAA,yBAAyB,CAAA,GAC7B,EAAE,eAAe;QAErB;QAEA,MAAM,MAAM,IAAI;QAEhB,2CAA2C;QAC3C,+FAA+F;QAC/F,IAAI,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM,EAAE,iBAAiB,UAAU;QAEpF,wCAAwC;QACxC,IAAI,OAAO,MACT,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM;QAGrD,IAAI,OAAO,MAAM;YACf,iBAAiB,aAAa,CAAC;YAC/B,IAAI,cACF,aAAa;QAEjB;QAEA,aAAa,MAAM,OAAO;QAC1B,MAAM,OAAO,GAAG,WAAW;YACzB,MAAM,MAAM,GAAG;QACjB,GAAG;IACL;IAEA,OAAO;QACL,iBAAiB;YACf,+DAA+D;YAC/D,qDAAqD;YACrD,kBAAkB,iBAAiB,eAAe,GAAG,YAAY;QACnE;IACF;AACF;AAEA,SAAS,sCAAgB,GAAW;IAClC,mDAAmD;IACnD,+DAA+D;IAC/D,6BAA6B;IAC7B,0CAA0C;IAC1C,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,UAAU,IAAI,CAAC,MACtC,OAAO;IAGT,OAAO;AACT","sources":["packages/@react-aria/selection/src/useTypeSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {DOMAttributes, Key, KeyboardDelegate} from '@react-types/shared';\nimport {KeyboardEvent, useRef} from 'react';\nimport {MultipleSelectionManager} from '@react-stately/selection';\n\n/**\n * Controls how long to wait before clearing the typeahead buffer.\n */\nconst TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second\n\nexport interface AriaTypeSelectOptions {\n /**\n * A delegate that returns collection item keys with respect to visual layout.\n */\n keyboardDelegate: KeyboardDelegate,\n /**\n * An interface for reading and updating multiple selection state.\n */\n selectionManager: MultipleSelectionManager,\n /**\n * Called when an item is focused by typing.\n */\n onTypeSelect?: (key: Key) => void\n}\n\nexport interface TypeSelectAria {\n /**\n * Props to be spread on the owner of the options.\n */\n typeSelectProps: DOMAttributes\n}\n\n/**\n * Handles typeahead interactions with collections.\n */\nexport function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria {\n let {keyboardDelegate, selectionManager, onTypeSelect} = options;\n let state = useRef({\n search: '',\n timeout: null\n }).current;\n\n let onKeyDown = (e: KeyboardEvent) => {\n let character = getStringForKey(e.key);\n if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target as HTMLElement)) {\n return;\n }\n\n // Do not propagate the Spacebar event if it's meant to be part of the search.\n // When we time out, the search term becomes empty, hence the check on length.\n // Trimming is to account for the case of pressing the Spacebar more than once,\n // which should cycle through the selection/deselection of the focused item.\n if (character === ' ' && state.search.trim().length > 0) {\n e.preventDefault();\n if (!('continuePropagation' in e)) {\n e.stopPropagation();\n }\n }\n\n state.search += character;\n\n // Use the delegate to find a key to focus.\n // Prioritize items after the currently focused item, falling back to searching the whole list.\n let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);\n\n // If no key found, search from the top.\n if (key == null) {\n key = keyboardDelegate.getKeyForSearch(state.search);\n }\n\n if (key != null) {\n selectionManager.setFocusedKey(key);\n if (onTypeSelect) {\n onTypeSelect(key);\n }\n }\n\n clearTimeout(state.timeout);\n state.timeout = setTimeout(() => {\n state.search = '';\n }, TYPEAHEAD_DEBOUNCE_WAIT_MS);\n };\n\n return {\n typeSelectProps: {\n // Using a capturing listener to catch the keydown event before\n // other hooks in order to handle the Spacebar event.\n onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null\n }\n };\n}\n\nfunction getStringForKey(key: string) {\n // If the key is of length 1, it is an ASCII value.\n // Otherwise, if there are no ASCII characters in the key name,\n // it is a Unicode character.\n // See https://www.w3.org/TR/uievents-key/\n if (key.length === 1 || !/^[A-Z]/i.test(key)) {\n return key;\n }\n\n return '';\n}\n"],"names":[],"version":3,"file":"useTypeSelect.main.js.map"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {useRef as $dAE4Y$useRef} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Controls how long to wait before clearing the typeahead buffer.
|
|
16
|
+
*/ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
|
|
17
|
+
function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
|
|
18
|
+
let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
|
|
19
|
+
let state = (0, $dAE4Y$useRef)({
|
|
20
|
+
search: '',
|
|
21
|
+
timeout: null
|
|
22
|
+
}).current;
|
|
23
|
+
let onKeyDown = (e)=>{
|
|
24
|
+
let character = $fb3050f43d946246$var$getStringForKey(e.key);
|
|
25
|
+
if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
|
|
26
|
+
// Do not propagate the Spacebar event if it's meant to be part of the search.
|
|
27
|
+
// When we time out, the search term becomes empty, hence the check on length.
|
|
28
|
+
// Trimming is to account for the case of pressing the Spacebar more than once,
|
|
29
|
+
// which should cycle through the selection/deselection of the focused item.
|
|
30
|
+
if (character === ' ' && state.search.trim().length > 0) {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
if (!('continuePropagation' in e)) e.stopPropagation();
|
|
33
|
+
}
|
|
34
|
+
state.search += character;
|
|
35
|
+
// Use the delegate to find a key to focus.
|
|
36
|
+
// Prioritize items after the currently focused item, falling back to searching the whole list.
|
|
37
|
+
let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
|
|
38
|
+
// If no key found, search from the top.
|
|
39
|
+
if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
|
|
40
|
+
if (key != null) {
|
|
41
|
+
selectionManager.setFocusedKey(key);
|
|
42
|
+
if (onTypeSelect) onTypeSelect(key);
|
|
43
|
+
}
|
|
44
|
+
clearTimeout(state.timeout);
|
|
45
|
+
state.timeout = setTimeout(()=>{
|
|
46
|
+
state.search = '';
|
|
47
|
+
}, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
typeSelectProps: {
|
|
51
|
+
// Using a capturing listener to catch the keydown event before
|
|
52
|
+
// other hooks in order to handle the Spacebar event.
|
|
53
|
+
onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function $fb3050f43d946246$var$getStringForKey(key) {
|
|
58
|
+
// If the key is of length 1, it is an ASCII value.
|
|
59
|
+
// Otherwise, if there are no ASCII characters in the key name,
|
|
60
|
+
// it is a Unicode character.
|
|
61
|
+
// See https://www.w3.org/TR/uievents-key/
|
|
62
|
+
if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
|
|
68
|
+
//# sourceMappingURL=useTypeSelect.module.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {useRef as $dAE4Y$useRef} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Controls how long to wait before clearing the typeahead buffer.
|
|
16
|
+
*/ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
|
|
17
|
+
function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
|
|
18
|
+
let { keyboardDelegate: keyboardDelegate, selectionManager: selectionManager, onTypeSelect: onTypeSelect } = options;
|
|
19
|
+
let state = (0, $dAE4Y$useRef)({
|
|
20
|
+
search: '',
|
|
21
|
+
timeout: null
|
|
22
|
+
}).current;
|
|
23
|
+
let onKeyDown = (e)=>{
|
|
24
|
+
let character = $fb3050f43d946246$var$getStringForKey(e.key);
|
|
25
|
+
if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
|
|
26
|
+
// Do not propagate the Spacebar event if it's meant to be part of the search.
|
|
27
|
+
// When we time out, the search term becomes empty, hence the check on length.
|
|
28
|
+
// Trimming is to account for the case of pressing the Spacebar more than once,
|
|
29
|
+
// which should cycle through the selection/deselection of the focused item.
|
|
30
|
+
if (character === ' ' && state.search.trim().length > 0) {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
if (!('continuePropagation' in e)) e.stopPropagation();
|
|
33
|
+
}
|
|
34
|
+
state.search += character;
|
|
35
|
+
// Use the delegate to find a key to focus.
|
|
36
|
+
// Prioritize items after the currently focused item, falling back to searching the whole list.
|
|
37
|
+
let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
|
|
38
|
+
// If no key found, search from the top.
|
|
39
|
+
if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
|
|
40
|
+
if (key != null) {
|
|
41
|
+
selectionManager.setFocusedKey(key);
|
|
42
|
+
if (onTypeSelect) onTypeSelect(key);
|
|
43
|
+
}
|
|
44
|
+
clearTimeout(state.timeout);
|
|
45
|
+
state.timeout = setTimeout(()=>{
|
|
46
|
+
state.search = '';
|
|
47
|
+
}, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
typeSelectProps: {
|
|
51
|
+
// Using a capturing listener to catch the keydown event before
|
|
52
|
+
// other hooks in order to handle the Spacebar event.
|
|
53
|
+
onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function $fb3050f43d946246$var$getStringForKey(key) {
|
|
58
|
+
// If the key is of length 1, it is an ASCII value.
|
|
59
|
+
// Otherwise, if there are no ASCII characters in the key name,
|
|
60
|
+
// it is a Unicode character.
|
|
61
|
+
// See https://www.w3.org/TR/uievents-key/
|
|
62
|
+
if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
|
|
68
|
+
//# sourceMappingURL=useTypeSelect.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD;;CAEC,GACD,MAAM,mDAA6B,MAAM,WAAW;AA2B7C,SAAS,0CAAc,OAA8B;IAC1D,IAAI,oBAAC,gBAAgB,oBAAE,gBAAgB,gBAAE,YAAY,EAAC,GAAG;IACzD,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;QACjB,QAAQ;QACR,SAAS;IACX,GAAG,OAAO;IAEV,IAAI,YAAY,CAAC;QACf,IAAI,YAAY,sCAAgB,EAAE,GAAG;QACrC,IAAI,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAC5E;QAGF,8EAA8E;QAC9E,8EAA8E;QAC9E,+EAA+E;QAC/E,4EAA4E;QAC5E,IAAI,cAAc,OAAO,MAAM,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,GAAG;YACvD,EAAE,cAAc;YAChB,IAAI,CAAE,CAAA,yBAAyB,CAAA,GAC7B,EAAE,eAAe;QAErB;QAEA,MAAM,MAAM,IAAI;QAEhB,2CAA2C;QAC3C,+FAA+F;QAC/F,IAAI,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM,EAAE,iBAAiB,UAAU;QAEpF,wCAAwC;QACxC,IAAI,OAAO,MACT,MAAM,iBAAiB,eAAe,CAAC,MAAM,MAAM;QAGrD,IAAI,OAAO,MAAM;YACf,iBAAiB,aAAa,CAAC;YAC/B,IAAI,cACF,aAAa;QAEjB;QAEA,aAAa,MAAM,OAAO;QAC1B,MAAM,OAAO,GAAG,WAAW;YACzB,MAAM,MAAM,GAAG;QACjB,GAAG;IACL;IAEA,OAAO;QACL,iBAAiB;YACf,+DAA+D;YAC/D,qDAAqD;YACrD,kBAAkB,iBAAiB,eAAe,GAAG,YAAY;QACnE;IACF;AACF;AAEA,SAAS,sCAAgB,GAAW;IAClC,mDAAmD;IACnD,+DAA+D;IAC/D,6BAA6B;IAC7B,0CAA0C;IAC1C,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,UAAU,IAAI,CAAC,MACtC,OAAO;IAGT,OAAO;AACT","sources":["packages/@react-aria/selection/src/useTypeSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {DOMAttributes, Key, KeyboardDelegate} from '@react-types/shared';\nimport {KeyboardEvent, useRef} from 'react';\nimport {MultipleSelectionManager} from '@react-stately/selection';\n\n/**\n * Controls how long to wait before clearing the typeahead buffer.\n */\nconst TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second\n\nexport interface AriaTypeSelectOptions {\n /**\n * A delegate that returns collection item keys with respect to visual layout.\n */\n keyboardDelegate: KeyboardDelegate,\n /**\n * An interface for reading and updating multiple selection state.\n */\n selectionManager: MultipleSelectionManager,\n /**\n * Called when an item is focused by typing.\n */\n onTypeSelect?: (key: Key) => void\n}\n\nexport interface TypeSelectAria {\n /**\n * Props to be spread on the owner of the options.\n */\n typeSelectProps: DOMAttributes\n}\n\n/**\n * Handles typeahead interactions with collections.\n */\nexport function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria {\n let {keyboardDelegate, selectionManager, onTypeSelect} = options;\n let state = useRef({\n search: '',\n timeout: null\n }).current;\n\n let onKeyDown = (e: KeyboardEvent) => {\n let character = getStringForKey(e.key);\n if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target as HTMLElement)) {\n return;\n }\n\n // Do not propagate the Spacebar event if it's meant to be part of the search.\n // When we time out, the search term becomes empty, hence the check on length.\n // Trimming is to account for the case of pressing the Spacebar more than once,\n // which should cycle through the selection/deselection of the focused item.\n if (character === ' ' && state.search.trim().length > 0) {\n e.preventDefault();\n if (!('continuePropagation' in e)) {\n e.stopPropagation();\n }\n }\n\n state.search += character;\n\n // Use the delegate to find a key to focus.\n // Prioritize items after the currently focused item, falling back to searching the whole list.\n let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);\n\n // If no key found, search from the top.\n if (key == null) {\n key = keyboardDelegate.getKeyForSearch(state.search);\n }\n\n if (key != null) {\n selectionManager.setFocusedKey(key);\n if (onTypeSelect) {\n onTypeSelect(key);\n }\n }\n\n clearTimeout(state.timeout);\n state.timeout = setTimeout(() => {\n state.search = '';\n }, TYPEAHEAD_DEBOUNCE_WAIT_MS);\n };\n\n return {\n typeSelectProps: {\n // Using a capturing listener to catch the keydown event before\n // other hooks in order to handle the Spacebar event.\n onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null\n }\n };\n}\n\nfunction getStringForKey(key: string) {\n // If the key is of length 1, it is an ASCII value.\n // Otherwise, if there are no ASCII characters in the key name,\n // it is a Unicode character.\n // See https://www.w3.org/TR/uievents-key/\n if (key.length === 1 || !/^[A-Z]/i.test(key)) {\n return key;\n }\n\n return '';\n}\n"],"names":[],"version":3,"file":"useTypeSelect.module.js.map"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var $gP8Dl$reactariautils = require("@react-aria/utils");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "isNonContiguousSelectionModifier", () => $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04);
|
|
9
|
+
$parcel$export(module.exports, "isCtrlKeyPressed", () => $ee0bdf4faa47f2a8$export$16792effe837dba3);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
function $ee0bdf4faa47f2a8$export$d3e3bd3e26688c04(e) {
|
|
22
|
+
// Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
|
|
23
|
+
// On Windows and Ubuntu, Alt + Space has a system wide meaning.
|
|
24
|
+
return (0, $gP8Dl$reactariautils.isAppleDevice)() ? e.altKey : e.ctrlKey;
|
|
25
|
+
}
|
|
26
|
+
function $ee0bdf4faa47f2a8$export$16792effe837dba3(e) {
|
|
27
|
+
if ((0, $gP8Dl$reactariautils.isMac)()) return e.metaKey;
|
|
28
|
+
return e.ctrlKey;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=utils.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAiC,CAAQ;IACvD,qFAAqF;IACrF,gEAAgE;IAChE,OAAO,CAAA,GAAA,mCAAY,MAAM,EAAE,MAAM,GAAG,EAAE,OAAO;AAC/C;AAEO,SAAS,0CAAiB,CAAQ;IACvC,IAAI,CAAA,GAAA,2BAAI,KACN,OAAO,EAAE,OAAO;IAGlB,OAAO,EAAE,OAAO;AAClB","sources":["packages/@react-aria/selection/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {isAppleDevice, isMac} from '@react-aria/utils';\n\ninterface Event {\n altKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean\n}\n\nexport function isNonContiguousSelectionModifier(e: Event) {\n // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.\n // On Windows and Ubuntu, Alt + Space has a system wide meaning.\n return isAppleDevice() ? e.altKey : e.ctrlKey;\n}\n\nexport function isCtrlKeyPressed(e: Event) {\n if (isMac()) {\n return e.metaKey;\n }\n\n return e.ctrlKey;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {isAppleDevice as $jUnAJ$isAppleDevice, isMac as $jUnAJ$isMac} from "@react-aria/utils";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
|
|
15
|
+
// Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
|
|
16
|
+
// On Windows and Ubuntu, Alt + Space has a system wide meaning.
|
|
17
|
+
return (0, $jUnAJ$isAppleDevice)() ? e.altKey : e.ctrlKey;
|
|
18
|
+
}
|
|
19
|
+
function $feb5ffebff200149$export$16792effe837dba3(e) {
|
|
20
|
+
if ((0, $jUnAJ$isMac)()) return e.metaKey;
|
|
21
|
+
return e.ctrlKey;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export {$feb5ffebff200149$export$d3e3bd3e26688c04 as isNonContiguousSelectionModifier, $feb5ffebff200149$export$16792effe837dba3 as isCtrlKeyPressed};
|
|
26
|
+
//# sourceMappingURL=utils.module.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {isAppleDevice as $jUnAJ$isAppleDevice, isMac as $jUnAJ$isMac} from "@react-aria/utils";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
|
|
15
|
+
// Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
|
|
16
|
+
// On Windows and Ubuntu, Alt + Space has a system wide meaning.
|
|
17
|
+
return (0, $jUnAJ$isAppleDevice)() ? e.altKey : e.ctrlKey;
|
|
18
|
+
}
|
|
19
|
+
function $feb5ffebff200149$export$16792effe837dba3(e) {
|
|
20
|
+
if ((0, $jUnAJ$isMac)()) return e.metaKey;
|
|
21
|
+
return e.ctrlKey;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export {$feb5ffebff200149$export$d3e3bd3e26688c04 as isNonContiguousSelectionModifier, $feb5ffebff200149$export$16792effe837dba3 as isCtrlKeyPressed};
|
|
26
|
+
//# sourceMappingURL=utils.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,SAAS,0CAAiC,CAAQ;IACvD,qFAAqF;IACrF,gEAAgE;IAChE,OAAO,CAAA,GAAA,oBAAY,MAAM,EAAE,MAAM,GAAG,EAAE,OAAO;AAC/C;AAEO,SAAS,0CAAiB,CAAQ;IACvC,IAAI,CAAA,GAAA,YAAI,KACN,OAAO,EAAE,OAAO;IAGlB,OAAO,EAAE,OAAO;AAClB","sources":["packages/@react-aria/selection/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {isAppleDevice, isMac} from '@react-aria/utils';\n\ninterface Event {\n altKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean\n}\n\nexport function isNonContiguousSelectionModifier(e: Event) {\n // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.\n // On Windows and Ubuntu, Alt + Space has a system wide meaning.\n return isAppleDevice() ? e.altKey : e.ctrlKey;\n}\n\nexport function isCtrlKeyPressed(e: Event) {\n if (isMac()) {\n return e.metaKey;\n }\n\n return e.ctrlKey;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/selection",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-nightly-4980928d3-240906",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
11
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
12
18
|
],
|
|
13
19
|
"sideEffects": false,
|
|
14
20
|
"repository": {
|
|
15
21
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/adobe
|
|
22
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
17
23
|
},
|
|
18
24
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@react-aria/i18n": "^3.0.0-
|
|
21
|
-
"@react-aria/interactions": "^3.0.0-
|
|
22
|
-
"@react-aria/utils": "^3.0.0-
|
|
23
|
-
"@react-stately/
|
|
24
|
-
"@react-
|
|
25
|
-
"@
|
|
25
|
+
"@react-aria/focus": "^3.0.0-nightly-4980928d3-240906",
|
|
26
|
+
"@react-aria/i18n": "^3.0.0-nightly-4980928d3-240906",
|
|
27
|
+
"@react-aria/interactions": "^3.0.0-nightly-4980928d3-240906",
|
|
28
|
+
"@react-aria/utils": "^3.0.0-nightly-4980928d3-240906",
|
|
29
|
+
"@react-stately/selection": "^3.0.0-nightly-4980928d3-240906",
|
|
30
|
+
"@react-types/shared": "^3.0.0-nightly-4980928d3-240906",
|
|
31
|
+
"@swc/helpers": "^0.5.0"
|
|
26
32
|
},
|
|
27
33
|
"peerDependencies": {
|
|
28
|
-
"react": "^16.8.0"
|
|
34
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
35
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
29
36
|
},
|
|
30
37
|
"publishConfig": {
|
|
31
38
|
"access": "public"
|
|
32
39
|
},
|
|
33
|
-
"
|
|
34
|
-
}
|
|
40
|
+
"stableVersion": "3.19.3"
|
|
41
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {Key, LayoutDelegate, Rect, RefObject, Size} from '@react-types/shared';
|
|
14
|
+
|
|
15
|
+
export class DOMLayoutDelegate implements LayoutDelegate {
|
|
16
|
+
private ref: RefObject<HTMLElement>;
|
|
17
|
+
|
|
18
|
+
constructor(ref: RefObject<HTMLElement>) {
|
|
19
|
+
this.ref = ref;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getItemRect(key: Key): Rect | null {
|
|
23
|
+
let container = this.ref.current;
|
|
24
|
+
let item = key != null ? container.querySelector(`[data-key="${CSS.escape(key.toString())}"]`) : null;
|
|
25
|
+
if (!item) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let containerRect = container.getBoundingClientRect();
|
|
30
|
+
let itemRect = item.getBoundingClientRect();
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
x: itemRect.left - containerRect.left + container.scrollLeft,
|
|
34
|
+
y: itemRect.top - containerRect.top + container.scrollTop,
|
|
35
|
+
width: itemRect.width,
|
|
36
|
+
height: itemRect.height
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getContentSize(): Size {
|
|
41
|
+
let container = this.ref.current;
|
|
42
|
+
return {
|
|
43
|
+
width: container.scrollWidth,
|
|
44
|
+
height: container.scrollHeight
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getVisibleRect(): Rect {
|
|
49
|
+
let container = this.ref.current;
|
|
50
|
+
return {
|
|
51
|
+
x: container.scrollLeft,
|
|
52
|
+
y: container.scrollTop,
|
|
53
|
+
width: container.offsetWidth,
|
|
54
|
+
height: container.offsetHeight
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|