@react-stately/selection 3.13.3 → 3.14.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/import.mjs CHANGED
@@ -56,7 +56,7 @@ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
56
56
  return true;
57
57
  }
58
58
  function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
59
- let { selectionMode: selectionMode = "none" , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = "toggle" , disabledBehavior: disabledBehavior = "all" } = props;
59
+ let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
60
60
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
61
61
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
62
62
  let isFocusedRef = (0, $Qsto2$useRef)(false);
@@ -401,6 +401,10 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
401
401
  isDisabled(key) {
402
402
  return this.state.disabledKeys.has(key) && this.state.disabledBehavior === "all";
403
403
  }
404
+ isLink(key) {
405
+ var _this_collection_getItem, _this_collection_getItem_props;
406
+ return !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.href);
407
+ }
404
408
  constructor(collection, state, options){
405
409
  this.collection = collection;
406
410
  this.state = state;
package/dist/main.js CHANGED
@@ -62,7 +62,7 @@ function $1adc19da2128bba9$var$equalSets(setA, setB) {
62
62
  return true;
63
63
  }
64
64
  function $1adc19da2128bba9$export$253fe78d46329472(props) {
65
- let { selectionMode: selectionMode = "none" , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = "toggle" , disabledBehavior: disabledBehavior = "all" } = props;
65
+ let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
66
66
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
67
67
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
68
68
  let isFocusedRef = (0, $83d9f$react.useRef)(false);
@@ -407,6 +407,10 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
407
407
  isDisabled(key) {
408
408
  return this.state.disabledKeys.has(key) && this.state.disabledBehavior === "all";
409
409
  }
410
+ isLink(key) {
411
+ var _this_collection_getItem, _this_collection_getItem_props;
412
+ return !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.href);
413
+ }
410
414
  constructor(collection, state, options){
411
415
  this.collection = collection;
412
416
  this.state = state;
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,YAAY,aAAa,KAAK;YACnC,IAAI,CAAC,aAAa,cAAc,KAAK;QACvC,OAAO;YACL,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,aAAa;QACpB;IACF;AACF;;;;ADdA,SAAS,gCAAU,IAAI,EAAE,IAAI;IAC3B,IAAI,KAAK,SAAS,KAAK,MACrB,OAAO;IAGT,KAAK,IAAI,QAAQ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KAAK,IAAI,OAAO,aAAc;YAC5B,IAAI,CAAC,UAAU,IAAI,MACjB,OAAO;QAEX;QAEA,OAAO;IACT;IAEA,cAAc,GAAQ,EAAE;QACtB,IAAI,IAAI,CAAC,MAAM,kBAAkB,UAAU,IAAI,CAAC,MAAM,aAAa,IAAI,MACrE,OAAO;QAGT,IAAI,OAAO,IAAI,CAAC,WAAW,QAAQ;QACnC,IAAI,CAAC,QAAS,KAAK,SAAS,UAAU,CAAC,IAAI,CAAC,qBAC1C,OAAO;QAGT,OAAO;IACT;IAEA,WAAW,GAAQ,EAAE;QACnB,OAAO,IAAI,CAAC,MAAM,aAAa,IAAI,QAAQ,IAAI,CAAC,MAAM,qBAAqB;IAC7E;IAncA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,QAAQ;YACc;QAA3B,IAAI,CAAC,sBAAsB,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,iCAAT,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,eAAe;IACtB;AA+bF;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","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\nexport type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\n","/*\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents,\n selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(selectionBehaviorProp);\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp,\n disabledBehavior\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\n}\n","/*\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';\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","/*\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,\n DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key} from 'react';\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) {\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.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,YAAY,aAAa,KAAK;YACnC,IAAI,CAAC,aAAa,cAAc,KAAK;QACvC,OAAO;YACL,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,aAAa;QACpB;IACF;AACF;;;;ADdA,SAAS,gCAAU,IAAI,EAAE,IAAI;IAC3B,IAAI,KAAK,SAAS,KAAK,MACrB,OAAO;IAGT,KAAK,IAAI,QAAQ,KAAM;QACrB,IAAI,CAAC,KAAK,IAAI,OACZ,OAAO;IAEX;IAEA,OAAO;AACT;AAcO,SAAS,0CAA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,cAAc,GAAQ,EAAE;QACtB,IAAI,IAAI,CAAC,MAAM,kBAAkB,UAAU,IAAI,CAAC,MAAM,aAAa,IAAI,MACrE,OAAO;QAGT,IAAI,OAAO,IAAI,CAAC,WAAW,QAAQ;QACnC,IAAI,CAAC,QAAS,KAAK,SAAS,UAAU,CAAC,IAAI,CAAC,qBAC1C,OAAO;QAGT,OAAO;IACT;IAEA,WAAW,GAAQ,EAAE;QACnB,OAAO,IAAI,CAAC,MAAM,aAAa,IAAI,QAAQ,IAAI,CAAC,MAAM,qBAAqB;IAC7E;IAEA,OAAO,GAAQ,EAAE;YACN;QAAT,OAAO,CAAC,CAAC,CAAA,CAAA,2BAAA,IAAI,CAAC,WAAW,QAAQ,kBAAxB,sCAAA,KAAA,IAAA,kCAAA,yBAA8B,+DAA9B,KAAA,mCAAqC,IAAH;IAC7C;IAvcA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,QAAQ;YACc;QAA3B,IAAI,CAAC,sBAAsB,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,iCAAT,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,eAAe;IACtB;AAmcF;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","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\nexport type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\n","/*\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents,\n selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(selectionBehaviorProp);\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp,\n disabledBehavior\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Set<Key> {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\n}\n","/*\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';\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","/*\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,\n DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key} from 'react';\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) {\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.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -56,7 +56,7 @@ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
56
56
  return true;
57
57
  }
58
58
  function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
59
- let { selectionMode: selectionMode = "none" , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = "toggle" , disabledBehavior: disabledBehavior = "all" } = props;
59
+ let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
60
60
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
61
61
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
62
62
  let isFocusedRef = (0, $Qsto2$useRef)(false);
@@ -401,6 +401,10 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
401
401
  isDisabled(key) {
402
402
  return this.state.disabledKeys.has(key) && this.state.disabledBehavior === "all";
403
403
  }
404
+ isLink(key) {
405
+ var _this_collection_getItem, _this_collection_getItem_props;
406
+ return !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.href);
407
+ }
404
408
  constructor(collection, state, options){
405
409
  this.collection = collection;
406
410
  this.state = state;
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,YAAY,aAAa,KAAK;YACnC,IAAI,CAAC,aAAa,cAAc,KAAK;QACvC,OAAO;YACL,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,aAAa;QACpB;IACF;AACF;;;;ADdA,SAAS,gCAAU,IAAI,EAAE,IAAI;IAC3B,IAAI,KAAK,SAAS,KAAK,MACrB,OAAO;IAGT,KAAK,IAAI,QAAQ,KAAM;QACrB,IAAI,CAAC,KAAK,IAAI,OACZ,OAAO;IAEX;IAEA,OAAO;AACT;AAcO,SAAS,0CAA0B,KAAkC;IAC1E,IAAI,iBACF,gBAAgB,iCAChB,uBAAsB,iCACtB,8BAA6B,EAC7B,mBAAmB,wBAAwB,QAAQ,CAAA,oBACnD,mBAAmB,QACpB,GAAG;IAEJ,8FAA8F;IAC9F,k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AC,QAAS,KAAK,SAAS,UAAU,CAAC,IAAI,CAAC,qBAC1C,OAAO;QAGT,OAAO;IACT;IAEA,WAAW,GAAQ,EAAE;QACnB,OAAO,IAAI,CAAC,MAAM,aAAa,IAAI,QAAQ,IAAI,CAAC,MAAM,qBAAqB;IAC7E;IAncA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,QAAQ;YACc;QAA3B,IAAI,CAAC,sBAAsB,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,iCAAT,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,eAAe;IACtB;AA+bF;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","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\nexport type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\n","/*\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents,\n selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(selectionBehaviorProp);\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp,\n disabledBehavior\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\n}\n","/*\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';\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","/*\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,\n DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key} from 'react';\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) {\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.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAQM,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,YAAY,aAAa,KAAK;YACnC,IAAI,CAAC,aAAa,cAAc,KAAK;QACvC,OAAO;YACL,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,aAAa;QACpB;IACF;AACF;;;;ADdA,SAAS,gCAAU,IAAI,EAAE,IAAI;IAC3B,IAAI,KAAK,SAAS,KAAK,MACrB,OAAO;IAGT,KAAK,IAAI,QAAQ,KAAM;QACrB,IAAI,CAAC,KAAK,IAAI,OACZ,OAAO;IAEX;IAEA,OAAO;AACT;AAcO,SAAS,0CAA0B,KAAkC;IAC1E,IAAI,iBACF,gBAAgB,gCAChB,sBAAsB,iCACtB,6BAA6B,EAC7B,mBAAmB,wBAAwB,QAAQ,oBACnD,mBAAmB,OACpB,GAAG;IAEJ,8FAA8F;IAC9F,kGAAkG;IAClG,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,IAAI,GAAG,WAAW,GAAG,CAAA,GAAA,eAAO,EAAE;IAC9B,IA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IAAI,CAAC,MAAM,aAAa,IAAI,QAAQ,IAAI,CAAC,MAAM,qBAAqB;IAC7E;IAEA,OAAO,GAAQ,EAAE;YACN;QAAT,OAAO,CAAC,CAAC,CAAA,CAAA,2BAAA,IAAI,CAAC,WAAW,QAAQ,kBAAxB,sCAAA,KAAA,IAAA,kCAAA,yBAA8B,+DAA9B,KAAA,mCAAqC,IAAH;IAC7C;IAvcA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,QAAQ;YACc;QAA3B,IAAI,CAAC,sBAAsB,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,iCAAT,0CAAA,+BAAgC;QAC3D,IAAI,CAAC,eAAe;IACtB;AAmcF;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","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\nexport type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\n","/*\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents,\n selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(selectionBehaviorProp);\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp,\n disabledBehavior\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Set<Key> {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\n}\n","/*\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';\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","/*\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,\n DisabledBehavior,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key} from 'react';\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) {\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.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n\n isLink(key: Key) {\n return !!this.collection.getItem(key)?.props?.href;\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface SingleSelectionState extends FocusState {
18
18
  /** The currently selected key in the collection. */
19
19
  readonly selectedKey: Key;
20
20
  /** Sets the selected key in the collection. */
21
- setSelectedKey(key: Key): void;
21
+ setSelectedKey(key: Key | null): void;
22
22
  }
23
23
  export interface MultipleSelectionState extends FocusState {
24
24
  /** The type of selection that is allowed in the collection. */
@@ -88,6 +88,8 @@ export interface MultipleSelectionManager extends FocusState {
88
88
  isDisabled(key: Key): boolean;
89
89
  /** Sets the selection behavior for the collection. */
90
90
  setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
91
+ /** Returns whether the given key is a hyperlink. */
92
+ isLink(key: Key): boolean;
91
93
  }
92
94
  export interface MultipleSelectionStateProps extends MultipleSelection {
93
95
  /** How multiple selection should behave in the collection. */
@@ -203,6 +205,7 @@ export class SelectionManager implements MultipleSelectionManager {
203
205
  isSelectionEqual(selection: Set<Key>): boolean;
204
206
  canSelectItem(key: Key): boolean;
205
207
  isDisabled(key: Key): boolean;
208
+ isLink(key: Key): boolean;
206
209
  }
207
210
 
208
211
  //# s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aAAa,CAEtC;IAED;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,aAAa;IAMjE;;OAEG;IACH,IAAI,YAAY,IAAI,GAAG,CAAC,GAAG,CAAC,CAI3B;IAED;;;OAGG;IACH,IAAI,YAAY,IAAI,SAAU,CAE7B;IAED;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG;IAWnB;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,WAAW,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;IA4F1B;;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;CAGpB","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"}
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;CACrD;AAED,qCAAsC,SAAQ,UAAU;IACtD,qDAAqD;IACrD,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;IAC1B,+CAA+C;IAC/C,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;CACtC;AAED,u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IACH,eAAe,CAAC,KAAK,EAAE,GAAG;IA4F1B;;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;CAGhB","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.13.3",
3
+ "version": "3.14.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.10.0",
26
- "@react-stately/utils": "^3.7.0",
27
- "@react-types/shared": "^3.19.0",
25
+ "@react-stately/collections": "^3.10.2",
26
+ "@react-stately/utils": "^3.8.0",
27
+ "@react-types/shared": "^3.21.0",
28
28
  "@swc/helpers": "^0.5.0"
29
29
  },
30
30
  "peerDependencies": {
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "d4dfe4bb842a914f10045ee63fc6b92f034c5b30"
36
+ "gitHead": "4122e44d1991c90507d630d35ed297f89db435d3"
37
37
  }
@@ -491,4 +491,8 @@ export class SelectionManager implements MultipleSelectionManager {
491
491
  isDisabled(key: Key) {
492
492
  return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';
493
493
  }
494
+
495
+ isLink(key: Key) {
496
+ return !!this.collection.getItem(key)?.props?.href;
497
+ }
494
498
  }
package/src/types.ts CHANGED
@@ -32,7 +32,7 @@ export interface SingleSelectionState extends FocusState {
32
32
  /** The currently selected key in the collection. */
33
33
  readonly selectedKey: Key,
34
34
  /** Sets the selected key in the collection. */
35
- setSelectedKey(key: Key): void
35
+ setSelectedKey(key: Key | null): void
36
36
  }
37
37
 
38
38
  export interface MultipleSelectionState extends FocusState {
@@ -103,5 +103,7 @@ export interface MultipleSelectionManager extends FocusState {
103
103
  /** Returns whether the given key is non-interactive, i.e. both selection and actions are disabled. */
104
104
  isDisabled(key: Key): boolean,
105
105
  /** Sets the selection behavior for the collection. */
106
- setSelectionBehavior(selectionBehavior: SelectionBehavior): void
106
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void,
107
+ /** Returns whether the given key is a hyperlink. */
108
+ isLink(key: Key): boolean
107
109
  }
@@ -119,7 +119,7 @@ export function useMultipleSelectionState(props: MultipleSelectionStateProps): M
119
119
  };
120
120
  }
121
121
 
122
- function convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {
122
+ function convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Set<Key> {
123
123
  if (!selection) {
124
124
  return defaultValue;
125
125
  }