@react-stately/selection 3.16.2 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Selection.main.js +2 -2
- package/dist/Selection.main.js.map +1 -1
- package/dist/Selection.mjs +2 -2
- package/dist/Selection.module.js +2 -2
- package/dist/Selection.module.js.map +1 -1
- package/dist/SelectionManager.main.js +8 -3
- package/dist/SelectionManager.main.js.map +1 -1
- package/dist/SelectionManager.mjs +8 -3
- package/dist/SelectionManager.module.js +8 -3
- package/dist/SelectionManager.module.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/Selection.ts +2 -2
- package/src/SelectionManager.ts +12 -4
- package/src/types.ts +1 -1
- package/LICENSE +0 -201
package/dist/Selection.main.js
CHANGED
|
@@ -18,8 +18,8 @@ $parcel$export(module.exports, "Selection", () => $21c847070f1f9569$export$52baa
|
|
|
18
18
|
constructor(keys, anchorKey, currentKey){
|
|
19
19
|
super(keys);
|
|
20
20
|
if (keys instanceof $21c847070f1f9569$export$52baac22726c72bf) {
|
|
21
|
-
this.anchorKey = anchorKey
|
|
22
|
-
this.currentKey = currentKey
|
|
21
|
+
this.anchorKey = anchorKey !== null && anchorKey !== void 0 ? anchorKey : keys.anchorKey;
|
|
22
|
+
this.currentKey = currentKey !== null && currentKey !== void 0 ? currentKey : keys.currentKey;
|
|
23
23
|
} else {
|
|
24
24
|
this.anchorKey = anchorKey;
|
|
25
25
|
this.currentKey = currentKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,SAAS,GAAG,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,SAAS,GAAG,sBAAA,uBAAA,YAAa,KAAK,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,uBAAA,wBAAA,aAAc,KAAK,UAAU;QACjD,OAAO;YACL,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,UAAU,GAAG;QACpB;IACF;AACF","sources":["packages/@react-stately/selection/src/Selection.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 {Key} from '@react-types/shared';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey ?? keys.anchorKey;\n this.currentKey = currentKey ?? keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\n }\n}\n"],"names":[],"version":3,"file":"Selection.main.js.map"}
|
package/dist/Selection.mjs
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
constructor(keys, anchorKey, currentKey){
|
|
13
13
|
super(keys);
|
|
14
14
|
if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) {
|
|
15
|
-
this.anchorKey = anchorKey
|
|
16
|
-
this.currentKey = currentKey
|
|
15
|
+
this.anchorKey = anchorKey !== null && anchorKey !== void 0 ? anchorKey : keys.anchorKey;
|
|
16
|
+
this.currentKey = currentKey !== null && currentKey !== void 0 ? currentKey : keys.currentKey;
|
|
17
17
|
} else {
|
|
18
18
|
this.anchorKey = anchorKey;
|
|
19
19
|
this.currentKey = currentKey;
|
package/dist/Selection.module.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
constructor(keys, anchorKey, currentKey){
|
|
13
13
|
super(keys);
|
|
14
14
|
if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) {
|
|
15
|
-
this.anchorKey = anchorKey
|
|
16
|
-
this.currentKey = currentKey
|
|
15
|
+
this.anchorKey = anchorKey !== null && anchorKey !== void 0 ? anchorKey : keys.anchorKey;
|
|
16
|
+
this.currentKey = currentKey !== null && currentKey !== void 0 ? currentKey : keys.currentKey;
|
|
17
17
|
} else {
|
|
18
18
|
this.anchorKey = anchorKey;
|
|
19
19
|
this.currentKey = currentKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,SAAS,GAAG,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,SAAS,GAAG,sBAAA,uBAAA,YAAa,KAAK,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,uBAAA,wBAAA,aAAc,KAAK,UAAU;QACjD,OAAO;YACL,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,UAAU,GAAG;QACpB;IACF;AACF","sources":["packages/@react-stately/selection/src/Selection.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 {Key} from '@react-types/shared';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey ?? keys.anchorKey;\n this.currentKey = currentKey ?? keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\n }\n}\n"],"names":[],"version":3,"file":"Selection.module.js.map"}
|
|
@@ -135,9 +135,11 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
|
|
|
135
135
|
], toKey, toKey);
|
|
136
136
|
else {
|
|
137
137
|
let selectedKeys = this.state.selectedKeys;
|
|
138
|
-
|
|
138
|
+
var _selectedKeys_anchorKey;
|
|
139
|
+
let anchorKey = (_selectedKeys_anchorKey = selectedKeys.anchorKey) !== null && _selectedKeys_anchorKey !== void 0 ? _selectedKeys_anchorKey : toKey;
|
|
139
140
|
selection = new (0, $21c847070f1f9569$exports.Selection)(selectedKeys, anchorKey, toKey);
|
|
140
|
-
|
|
141
|
+
var _selectedKeys_currentKey;
|
|
142
|
+
for (let key of this.getKeyRange(anchorKey, (_selectedKeys_currentKey = selectedKeys.currentKey) !== null && _selectedKeys_currentKey !== void 0 ? _selectedKeys_currentKey : toKey))selection.delete(key);
|
|
141
143
|
for (let key of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key)) selection.add(key);
|
|
142
144
|
}
|
|
143
145
|
this.state.setSelectedKeys(selection);
|
|
@@ -152,9 +154,11 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
|
|
|
152
154
|
return [];
|
|
153
155
|
}
|
|
154
156
|
getKeyRangeInternal(from, to) {
|
|
157
|
+
var _this_layoutDelegate;
|
|
158
|
+
if ((_this_layoutDelegate = this.layoutDelegate) === null || _this_layoutDelegate === void 0 ? void 0 : _this_layoutDelegate.getKeyRange) return this.layoutDelegate.getKeyRange(from, to);
|
|
155
159
|
let keys = [];
|
|
156
160
|
let key = from;
|
|
157
|
-
while(key){
|
|
161
|
+
while(key != null){
|
|
158
162
|
let item = this.collection.getItem(key);
|
|
159
163
|
if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
|
|
160
164
|
if (key === to) return keys;
|
|
@@ -299,6 +303,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
|
|
|
299
303
|
var _options_allowsCellSelection;
|
|
300
304
|
this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
|
|
301
305
|
this._isSelectAll = null;
|
|
306
|
+
this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null;
|
|
302
307
|
}
|
|
303
308
|
}
|
|
304
309
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM;IAaX;;GAEC,GACD,IAAI,gBAA+B;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa;IACjC;IAEA;;GAEC,GACD,IAAI,yBAAkC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB;IAC1C;IAEA;;GAEC,GACD,IAAI,oBAAuC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB;IACrC;IAEA;;GAEC,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AAE;QACnH,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;YACc;QAA3B,IAAI,CAAC,mBAAmB,GAAG,CAAA,+BAAA,oBAAA,8BAAA,QAAS,mBAAmB,cAA5B,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,YAAY,GAAG;IACtB;AAucF","sources":["packages/@react-stately/selection/src/SelectionManager.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 {\n Collection, DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n Key,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy) {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? this.canSelectItem(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else if (this.canSelectItem(key)) {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key != null) {\n if (this.canSelectItem(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys(getFirstItem(getChildNodes(item, this.collection)).key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (!this.isSelectAll && this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || item?.props?.isDisabled || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key) {\n return this.collection.getItem(key)?.props;\n }\n}\n"],"names":[],"version":3,"file":"SelectionManager.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA0BM,MAAM;IAeX;;GAEC,GACD,IAAI,gBAA+B;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa;IACjC;IAEA;;GAEC,GACD,IAAI,yBAAkC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB;IAC1C;IAEA;;GAEC,GACD,IAAI,oBAAuC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB;IACrC;IAEA;;GAEC,GACD,qBAAqB,iBAAoC,EAAE;QACzD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAClC;IAEA;;GAEC,GACD,IAAI,YAAqB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;IAC7B;IAEA;;GAEC,GACD,WAAW,SAAkB,EAAE;QAC7B,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;IACxB;IAEA;;GAEC,GACD,IAAI,aAAkB;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU;IAC9B;IAEA,6EAA6E,GAC7E,IAAI,qBAAoC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACtC;IAEA;;GAEC,GACD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cAAc,GAAG,CAAA,oBAAA,8BAAA,QAAS,cAAc,KAAI;IACnD;AA2cF","sources":["packages/@react-stately/selection/src/SelectionManager.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 {\n Collection, DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n Key,\n LayoutDelegate,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean,\n layoutDelegate?: LayoutDelegate\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n private layoutDelegate: LayoutDelegate | null;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n this.layoutDelegate = options?.layoutDelegate || null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy) {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? this.canSelectItem(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey ?? toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n if (this.layoutDelegate?.getKeyRange) {\n return this.layoutDelegate.getKeyRange(from, to);\n }\n\n let keys: Key[] = [];\n let key = from;\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else if (this.canSelectItem(key)) {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key != null) {\n if (this.canSelectItem(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys(getFirstItem(getChildNodes(item, this.collection)).key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (!this.isSelectAll && this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || item?.props?.isDisabled || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key) {\n return this.collection.getItem(key)?.props;\n }\n}\n"],"names":[],"version":3,"file":"SelectionManager.main.js.map"}
|
|
@@ -129,9 +129,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
129
129
|
], toKey, toKey);
|
|
130
130
|
else {
|
|
131
131
|
let selectedKeys = this.state.selectedKeys;
|
|
132
|
-
|
|
132
|
+
var _selectedKeys_anchorKey;
|
|
133
|
+
let anchorKey = (_selectedKeys_anchorKey = selectedKeys.anchorKey) !== null && _selectedKeys_anchorKey !== void 0 ? _selectedKeys_anchorKey : toKey;
|
|
133
134
|
selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selectedKeys, anchorKey, toKey);
|
|
134
|
-
|
|
135
|
+
var _selectedKeys_currentKey;
|
|
136
|
+
for (let key of this.getKeyRange(anchorKey, (_selectedKeys_currentKey = selectedKeys.currentKey) !== null && _selectedKeys_currentKey !== void 0 ? _selectedKeys_currentKey : toKey))selection.delete(key);
|
|
135
137
|
for (let key of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key)) selection.add(key);
|
|
136
138
|
}
|
|
137
139
|
this.state.setSelectedKeys(selection);
|
|
@@ -146,9 +148,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
146
148
|
return [];
|
|
147
149
|
}
|
|
148
150
|
getKeyRangeInternal(from, to) {
|
|
151
|
+
var _this_layoutDelegate;
|
|
152
|
+
if ((_this_layoutDelegate = this.layoutDelegate) === null || _this_layoutDelegate === void 0 ? void 0 : _this_layoutDelegate.getKeyRange) return this.layoutDelegate.getKeyRange(from, to);
|
|
149
153
|
let keys = [];
|
|
150
154
|
let key = from;
|
|
151
|
-
while(key){
|
|
155
|
+
while(key != null){
|
|
152
156
|
let item = this.collection.getItem(key);
|
|
153
157
|
if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
|
|
154
158
|
if (key === to) return keys;
|
|
@@ -293,6 +297,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
293
297
|
var _options_allowsCellSelection;
|
|
294
298
|
this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
|
|
295
299
|
this._isSelectAll = null;
|
|
300
|
+
this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null;
|
|
296
301
|
}
|
|
297
302
|
}
|
|
298
303
|
|
|
@@ -129,9 +129,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
129
129
|
], toKey, toKey);
|
|
130
130
|
else {
|
|
131
131
|
let selectedKeys = this.state.selectedKeys;
|
|
132
|
-
|
|
132
|
+
var _selectedKeys_anchorKey;
|
|
133
|
+
let anchorKey = (_selectedKeys_anchorKey = selectedKeys.anchorKey) !== null && _selectedKeys_anchorKey !== void 0 ? _selectedKeys_anchorKey : toKey;
|
|
133
134
|
selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selectedKeys, anchorKey, toKey);
|
|
134
|
-
|
|
135
|
+
var _selectedKeys_currentKey;
|
|
136
|
+
for (let key of this.getKeyRange(anchorKey, (_selectedKeys_currentKey = selectedKeys.currentKey) !== null && _selectedKeys_currentKey !== void 0 ? _selectedKeys_currentKey : toKey))selection.delete(key);
|
|
135
137
|
for (let key of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key)) selection.add(key);
|
|
136
138
|
}
|
|
137
139
|
this.state.setSelectedKeys(selection);
|
|
@@ -146,9 +148,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
146
148
|
return [];
|
|
147
149
|
}
|
|
148
150
|
getKeyRangeInternal(from, to) {
|
|
151
|
+
var _this_layoutDelegate;
|
|
152
|
+
if ((_this_layoutDelegate = this.layoutDelegate) === null || _this_layoutDelegate === void 0 ? void 0 : _this_layoutDelegate.getKeyRange) return this.layoutDelegate.getKeyRange(from, to);
|
|
149
153
|
let keys = [];
|
|
150
154
|
let key = from;
|
|
151
|
-
while(key){
|
|
155
|
+
while(key != null){
|
|
152
156
|
let item = this.collection.getItem(key);
|
|
153
157
|
if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
|
|
154
158
|
if (key === to) return keys;
|
|
@@ -293,6 +297,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
|
293
297
|
var _options_allowsCellSelection;
|
|
294
298
|
this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
|
|
295
299
|
this._isSelectAll = null;
|
|
300
|
+
this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null;
|
|
296
301
|
}
|
|
297
302
|
}
|
|
298
303
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM;IAaX;;GAEC,GACD,IAAI,gBAA+B;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa;IACjC;IAEA;;GAEC,GACD,IAAI,yBAAkC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB;IAC1C;IAEA;;GAEC,GACD,IAAI,oBAAuC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8B,KAAK;IAC5C;IA3cA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;YACc;QAA3B,IAAI,CAAC,mBAAmB,GAAG,CAAA,+BAAA,oBAAA,8BAAA,QAAS,mBAAmB,cAA5B,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,YAAY,GAAG;IACtB;AAucF","sources":["packages/@react-stately/selection/src/SelectionManager.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 {\n Collection, DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n Key,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy) {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? this.canSelectItem(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else if (this.canSelectItem(key)) {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key != null) {\n if (this.canSelectItem(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys(getFirstItem(getChildNodes(item, this.collection)).key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (!this.isSelectAll && this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || item?.props?.isDisabled || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key) {\n return this.collection.getItem(key)?.props;\n }\n}\n"],"names":[],"version":3,"file":"SelectionManager.module.js.map"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA0BM,MAAM;IAeX;;GAEC,GACD,IAAI,gBAA+B;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa;IACjC;IAEA;;GAEC,GACD,IAAI,yBAAkC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB;IAC1C;IAEA;;GAEC,GACD,IAAI,oBAAuC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB;IACrC;IAEA;;GAEC,GACD,qBAAqB,iBAAoC,EAAE;QACzD,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAClC;IAEA;;GAEC,GACD,IAAI,YAAqB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;IAC7B;IAEA;;GAEC,GACD,WAAW,SAAkB,EAAE;QAC7B,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;IACxB;IAEA;;GAEC,GACD,IAAI,aAAkB;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU;IAC9B;IAEA,6EAA6E,GAC7E,IAAI,qBAAoC;QACtC,OAA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+BAAgC;QAC3D,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,cAAc,GAAG,CAAA,oBAAA,8BAAA,QAAS,cAAc,KAAI;IACnD;AA2cF","sources":["packages/@react-stately/selection/src/SelectionManager.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 {\n Collection, DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n Key,\n LayoutDelegate,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean,\n layoutDelegate?: LayoutDelegate\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n private layoutDelegate: LayoutDelegate | null;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n this.layoutDelegate = options?.layoutDelegate || null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy) {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? this.canSelectItem(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey ?? toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n if (this.layoutDelegate?.getKeyRange) {\n return this.layoutDelegate.getKeyRange(from, to);\n }\n\n let keys: Key[] = [];\n let key = from;\n while (key != null) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else if (this.canSelectItem(key)) {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key != null) {\n if (this.canSelectItem(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys(getFirstItem(getChildNodes(item, this.collection)).key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (!this.isSelectAll && this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || item?.props?.isDisabled || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key) {\n return this.collection.getItem(key)?.props;\n }\n}\n"],"names":[],"version":3,"file":"SelectionManager.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, Collection, Node } from "@react-types/shared";
|
|
1
|
+
import { DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, Collection, LayoutDelegate, Node } from "@react-types/shared";
|
|
2
2
|
export interface FocusState {
|
|
3
3
|
/** Whether the collection is currently focused. */
|
|
4
4
|
readonly isFocused: boolean;
|
|
@@ -9,7 +9,7 @@ export interface FocusState {
|
|
|
9
9
|
/** Whether the first or last child of the focused key should receive focus. */
|
|
10
10
|
readonly childFocusStrategy: FocusStrategy;
|
|
11
11
|
/** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */
|
|
12
|
-
setFocusedKey(key: Key, child?: FocusStrategy): void;
|
|
12
|
+
setFocusedKey(key: Key | null, child?: FocusStrategy): void;
|
|
13
13
|
}
|
|
14
14
|
export interface SingleSelectionState extends FocusState {
|
|
15
15
|
/** Whether the collection allows empty selection. */
|
|
@@ -106,6 +106,7 @@ export interface MultipleSelectionStateProps extends MultipleSelection {
|
|
|
106
106
|
export function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState;
|
|
107
107
|
interface SelectionManagerOptions {
|
|
108
108
|
allowsCellSelection?: boolean;
|
|
109
|
+
layoutDelegate?: LayoutDelegate;
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
112
|
* An interface for reading and updating multiple selection state.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AAeA;IACE,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8CAA8C;IAC9C,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAC;IAC3C,8GAA8G;IAC9G,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;
|
|
1
|
+
{"mappings":";AAeA;IACE,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8CAA8C;IAC9C,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAC;IAC3C,8GAA8G;IAC9G,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;CAC5D;AAED,qCAAsC,SAAQ,UAAU;IACtD,qDAAqD;IACrD,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,oDAAoD;IACpD,QAAQ,CAAC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,IAAI,OAAO,CAiBzB;IAED,IAAI,gBAAgB,IAAI,GAAG,GAAG,IAAI,CAUjC;IAED,IAAI,eAAe,IAAI,GAAG,GAAG,IAAI,CAUhC;IAED,IAAI,YAAY,IAAI,GAAG,CAAC,GAAG,CAAC,CAE3B;IAED,IAAI,gBAAgB,IAAI,gBAAgB,CAEvC;IAED;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,GAAG;IAgG1B;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,GAAG;IAiCxB;;OAEG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG;IAiBzB;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC;IA2CnC;;OAEG;IACH,SAAS;IAMT;;OAEG;IACH,cAAc;IAMd;;OAEG;IACH,eAAe;IAQf,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,GAAG,cAAc,GAAG,YAAY;IAmB/D;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC;IA0BpC,aAAa,CAAC,GAAG,EAAE,GAAG;IAatB,UAAU,CAAC,GAAG,EAAE,GAAG;IAInB,MAAM,CAAC,GAAG,EAAE,GAAG;IAIf,YAAY,CAAC,GAAG,EAAE,GAAG;CAGtB","sources":["packages/@react-stately/selection/src/packages/@react-stately/selection/src/types.ts","packages/@react-stately/selection/src/packages/@react-stately/selection/src/Selection.ts","packages/@react-stately/selection/src/packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/packages/@react-stately/selection/src/SelectionManager.ts","packages/@react-stately/selection/src/packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\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\nexport type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/selection",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-stately/collections": "^3.
|
|
26
|
-
"@react-stately/utils": "^3.10.
|
|
27
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-stately/collections": "^3.11.0",
|
|
26
|
+
"@react-stately/utils": "^3.10.4",
|
|
27
|
+
"@react-types/shared": "^3.25.0",
|
|
28
28
|
"@swc/helpers": "^0.5.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -32,6 +32,5 @@
|
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/Selection.ts
CHANGED
|
@@ -23,8 +23,8 @@ export class Selection extends Set<Key> {
|
|
|
23
23
|
constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {
|
|
24
24
|
super(keys);
|
|
25
25
|
if (keys instanceof Selection) {
|
|
26
|
-
this.anchorKey = anchorKey
|
|
27
|
-
this.currentKey = currentKey
|
|
26
|
+
this.anchorKey = anchorKey ?? keys.anchorKey;
|
|
27
|
+
this.currentKey = currentKey ?? keys.currentKey;
|
|
28
28
|
} else {
|
|
29
29
|
this.anchorKey = anchorKey;
|
|
30
30
|
this.currentKey = currentKey;
|
package/src/SelectionManager.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
FocusStrategy,
|
|
16
16
|
Selection as ISelection,
|
|
17
17
|
Key,
|
|
18
|
+
LayoutDelegate,
|
|
18
19
|
LongPressEvent,
|
|
19
20
|
Node,
|
|
20
21
|
PressEvent,
|
|
@@ -26,7 +27,8 @@ import {MultipleSelectionManager, MultipleSelectionState} from './types';
|
|
|
26
27
|
import {Selection} from './Selection';
|
|
27
28
|
|
|
28
29
|
interface SelectionManagerOptions {
|
|
29
|
-
allowsCellSelection?: boolean
|
|
30
|
+
allowsCellSelection?: boolean,
|
|
31
|
+
layoutDelegate?: LayoutDelegate
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -37,12 +39,14 @@ export class SelectionManager implements MultipleSelectionManager {
|
|
|
37
39
|
private state: MultipleSelectionState;
|
|
38
40
|
private allowsCellSelection: boolean;
|
|
39
41
|
private _isSelectAll: boolean;
|
|
42
|
+
private layoutDelegate: LayoutDelegate | null;
|
|
40
43
|
|
|
41
44
|
constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {
|
|
42
45
|
this.collection = collection;
|
|
43
46
|
this.state = state;
|
|
44
47
|
this.allowsCellSelection = options?.allowsCellSelection ?? false;
|
|
45
48
|
this._isSelectAll = null;
|
|
49
|
+
this.layoutDelegate = options?.layoutDelegate || null;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/**
|
|
@@ -222,9 +226,9 @@ export class SelectionManager implements MultipleSelectionManager {
|
|
|
222
226
|
selection = new Selection([toKey], toKey, toKey);
|
|
223
227
|
} else {
|
|
224
228
|
let selectedKeys = this.state.selectedKeys as Selection;
|
|
225
|
-
let anchorKey = selectedKeys.anchorKey
|
|
229
|
+
let anchorKey = selectedKeys.anchorKey ?? toKey;
|
|
226
230
|
selection = new Selection(selectedKeys, anchorKey, toKey);
|
|
227
|
-
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey
|
|
231
|
+
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? toKey)) {
|
|
228
232
|
selection.delete(key);
|
|
229
233
|
}
|
|
230
234
|
|
|
@@ -253,9 +257,13 @@ export class SelectionManager implements MultipleSelectionManager {
|
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
private getKeyRangeInternal(from: Key, to: Key) {
|
|
260
|
+
if (this.layoutDelegate?.getKeyRange) {
|
|
261
|
+
return this.layoutDelegate.getKeyRange(from, to);
|
|
262
|
+
}
|
|
263
|
+
|
|
256
264
|
let keys: Key[] = [];
|
|
257
265
|
let key = from;
|
|
258
|
-
while (key) {
|
|
266
|
+
while (key != null) {
|
|
259
267
|
let item = this.collection.getItem(key);
|
|
260
268
|
if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {
|
|
261
269
|
keys.push(key);
|
package/src/types.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface FocusState {
|
|
|
23
23
|
/** Whether the first or last child of the focused key should receive focus. */
|
|
24
24
|
readonly childFocusStrategy: FocusStrategy,
|
|
25
25
|
/** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */
|
|
26
|
-
setFocusedKey(key: Key, child?: FocusStrategy): void
|
|
26
|
+
setFocusedKey(key: Key | null, child?: FocusStrategy): void
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface SingleSelectionState extends FocusState {
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2019 Adobe
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|