@react-stately/grid 3.10.0 → 3.11.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.
@@ -79,7 +79,22 @@ $parcel$export(module.exports, "GridCollection", () => $8bb6a9101b052a66$export$
79
79
  this.keyMap.set(node.key, node);
80
80
  let childKeys = new Set();
81
81
  let last = null;
82
+ let rowHasCellWithColSpan = false;
83
+ if (node.type === 'item') {
84
+ var _child_props;
85
+ for (let child of node.childNodes)if (((_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.colSpan) !== undefined) {
86
+ rowHasCellWithColSpan = true;
87
+ break;
88
+ }
89
+ }
82
90
  for (let child of node.childNodes){
91
+ if (child.type === 'cell' && rowHasCellWithColSpan) {
92
+ var _child_props1, _child_props2;
93
+ child.colspan = (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.colSpan;
94
+ child.colSpan = (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.colSpan;
95
+ var _last_colIndex, _last_colSpan;
96
+ child.colIndex = !last ? child.index : ((_last_colIndex = last.colIndex) !== null && _last_colIndex !== void 0 ? _last_colIndex : last.index) + ((_last_colSpan = last.colSpan) !== null && _last_colSpan !== void 0 ? _last_colSpan : 1);
97
+ }
83
98
  if (child.type === 'cell' && child.parentKey == null) // if child is a cell parent key isn't already established by the collection, match child node to parent row
84
99
  child.parentKey = node.key;
85
100
  childKeys.add(child.key);
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAiGX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAO;QACT,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;Q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AM,CAAA,aAAA,KAAK,IAAI,cAAT,wBAAA,aAAa;gBACnB,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;gBACrB,eAAe;gBACf,YAAY;uBAAI,KAAK,UAAU;iBAAC;gBAChC,UAAU,KAAK,QAAQ;gBACvB,WAAW,CAAA,kBAAA,KAAK,SAAS,cAAd,6BAAA,kBAAkB;gBAC7B,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;YACvB;YAEA,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG,QAAQ,GAAG;gBAC1B,QAAQ,OAAO,GAAG,KAAK,GAAG;YAC5B,OACE,QAAQ,OAAO,GAAG;YAGpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACf,MAAM;YAEN,OAAO;QACT;QAEA,IAAI,MACF,KAAK,OAAO,GAAG;IAEnB;AA8CF","sources":["packages/@react-stately/grid/src/GridCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions<T> {\n columnCount: number,\n items: GridRow<T>[],\n visitNode?: (cell: GridNode<T>) => GridNode<T>\n}\n\nexport class GridCollection<T> implements IGridCollection<T> {\n keyMap: Map<Key, GridNode<T>> = new Map();\n columnCount: number;\n rows: GridNode<T>[];\n\n constructor(opts: GridCollectionOptions<T>) {\n this.keyMap = new Map();\n this.columnCount = opts?.columnCount;\n this.rows = [];\n\n let visit = (node: GridNode<T>) => {\n // If the node is the same object as the previous node for the same key,\n // we can skip this node and its children. We always visit columns though,\n // because we depend on order to build the columns array.\n let prevNode = this.keyMap.get(node.key);\n if (opts.visitNode) {\n node = opts.visitNode(node);\n }\n\n this.keyMap.set(node.key, node);\n\n let childKeys = new Set();\n let last: GridNode<T> | null = null;\n for (let child of node.childNodes) {\n if (child.type === 'cell' && child.parentKey == null) {\n // if child is a cell parent key isn't already established by the collection, match child node to parent row\n child.parentKey = node.key;\n }\n childKeys.add(child.key);\n\n if (last) {\n last.nextKey = child.key;\n child.prevKey = last.key;\n } else {\n child.prevKey = null;\n }\n\n visit(child);\n last = child;\n }\n\n if (last) {\n last.nextKey = null;\n }\n\n // Remove deleted nodes and their children from the key map\n if (prevNode) {\n for (let child of prevNode.childNodes) {\n if (!childKeys.has(child.key)) {\n remove(child);\n }\n }\n }\n };\n\n let remove = (node: GridNode<T>) => {\n this.keyMap.delete(node.key);\n for (let child of node.childNodes) {\n if (this.keyMap.get(child.key) === child) {\n remove(child);\n }\n }\n };\n\n let last: GridNode<T> | null = null;\n for (let [i, node] of opts.items.entries()) {\n let rowNode: GridNode<T> = {\n ...node,\n level: node.level ?? 0,\n key: node.key ?? 'row-' + i,\n type: node.type ?? 'row',\n value: node.value ?? null,\n hasChildNodes: true,\n childNodes: [...node.childNodes],\n rendered: node.rendered,\n textValue: node.textValue ?? '',\n index: node.index ?? i\n };\n\n if (last) {\n last.nextKey = rowNode.key;\n rowNode.prevKey = last.key;\n } else {\n rowNode.prevKey = null;\n }\n\n this.rows.push(rowNode);\n visit(rowNode);\n\n last = rowNode;\n }\n\n if (last) {\n last.nextKey = null;\n }\n }\n\n *[Symbol.iterator]() {\n yield* [...this.rows];\n }\n\n get size() {\n return [...this.rows].length;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return [...this.rows][0]?.key;\n }\n\n getLastKey(): Key | null {\n let rows = [...this.rows];\n return rows[rows.length - 1]?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"GridCollection.main.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAkHX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAO;QACT,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,cAA0B;YACjB;QAAP,QAAO,IAAA;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,EAAE,cAAjB,wBAAA,EAAmB,GAAG;IAC/B;IAEA,aAAyB;YAEhB;QADP,IAAI,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;QACzB,QAAO,SAAA,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE,cAArB,6BAAA,OAAuB,GAAG;IACnC;IAEA,QAAQ,GAAQ,E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,KAAK,GAAG,cAAR,uBAAA,YAAY,SAAS;gBAC1B,MAAM,CAAA,aAAA,KAAK,IAAI,cAAT,wBAAA,aAAa;gBACnB,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;gBACrB,eAAe;gBACf,YAAY;uBAAI,KAAK,UAAU;iBAAC;gBAChC,UAAU,KAAK,QAAQ;gBACvB,WAAW,CAAA,kBAAA,KAAK,SAAS,cAAd,6BAAA,kBAAkB;gBAC7B,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;YACvB;YAEA,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG,QAAQ,GAAG;gBAC1B,QAAQ,OAAO,GAAG,KAAK,GAAG;YAC5B,OACE,QAAQ,OAAO,GAAG;YAGpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACf,MAAM;YAEN,OAAO;QACT;QAEA,IAAI,MACF,KAAK,OAAO,GAAG;IAEnB;AA8CF","sources":["packages/@react-stately/grid/src/GridCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions<T> {\n columnCount: number,\n items: GridRow<T>[],\n visitNode?: (cell: GridNode<T>) => GridNode<T>\n}\n\nexport class GridCollection<T> implements IGridCollection<T> {\n keyMap: Map<Key, GridNode<T>> = new Map();\n columnCount: number;\n rows: GridNode<T>[];\n\n constructor(opts: GridCollectionOptions<T>) {\n this.keyMap = new Map();\n this.columnCount = opts?.columnCount;\n this.rows = [];\n\n let visit = (node: GridNode<T>) => {\n // If the node is the same object as the previous node for the same key,\n // we can skip this node and its children. We always visit columns though,\n // because we depend on order to build the columns array.\n let prevNode = this.keyMap.get(node.key);\n if (opts.visitNode) {\n node = opts.visitNode(node);\n }\n\n this.keyMap.set(node.key, node);\n\n let childKeys = new Set();\n let last: GridNode<T> | null = null;\n let rowHasCellWithColSpan = false;\n\n if (node.type === 'item') {\n for (let child of node.childNodes) {\n if (child.props?.colSpan !== undefined) {\n rowHasCellWithColSpan = true;\n break;\n }\n }\n }\n\n for (let child of node.childNodes as Iterable<GridNode<T>>) {\n if (child.type === 'cell' && rowHasCellWithColSpan) {\n child.colspan = child.props?.colSpan;\n child.colSpan = child.props?.colSpan;\n child.colIndex = !last ? child.index : (last.colIndex ?? last.index) + (last.colSpan ?? 1);\n }\n\n if (child.type === 'cell' && child.parentKey == null) {\n // if child is a cell parent key isn't already established by the collection, match child node to parent row\n child.parentKey = node.key;\n }\n childKeys.add(child.key);\n\n if (last) {\n last.nextKey = child.key;\n child.prevKey = last.key;\n } else {\n child.prevKey = null;\n }\n\n visit(child);\n last = child;\n }\n\n if (last) {\n last.nextKey = null;\n }\n\n // Remove deleted nodes and their children from the key map\n if (prevNode) {\n for (let child of prevNode.childNodes) {\n if (!childKeys.has(child.key)) {\n remove(child);\n }\n }\n }\n };\n\n let remove = (node: GridNode<T>) => {\n this.keyMap.delete(node.key);\n for (let child of node.childNodes) {\n if (this.keyMap.get(child.key) === child) {\n remove(child);\n }\n }\n };\n\n let last: GridNode<T> | null = null;\n for (let [i, node] of opts.items.entries()) {\n let rowNode: GridNode<T> = {\n ...node,\n level: node.level ?? 0,\n key: node.key ?? 'row-' + i,\n type: node.type ?? 'row',\n value: node.value ?? null,\n hasChildNodes: true,\n childNodes: [...node.childNodes],\n rendered: node.rendered,\n textValue: node.textValue ?? '',\n index: node.index ?? i\n };\n\n if (last) {\n last.nextKey = rowNode.key;\n rowNode.prevKey = last.key;\n } else {\n rowNode.prevKey = null;\n }\n\n this.rows.push(rowNode);\n visit(rowNode);\n\n last = rowNode;\n }\n\n if (last) {\n last.nextKey = null;\n }\n }\n\n *[Symbol.iterator]() {\n yield* [...this.rows];\n }\n\n get size() {\n return [...this.rows].length;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return [...this.rows][0]?.key;\n }\n\n getLastKey(): Key | null {\n let rows = [...this.rows];\n return rows[rows.length - 1]?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"GridCollection.main.js.map"}
@@ -73,7 +73,22 @@
73
73
  this.keyMap.set(node.key, node);
74
74
  let childKeys = new Set();
75
75
  let last = null;
76
+ let rowHasCellWithColSpan = false;
77
+ if (node.type === 'item') {
78
+ var _child_props;
79
+ for (let child of node.childNodes)if (((_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.colSpan) !== undefined) {
80
+ rowHasCellWithColSpan = true;
81
+ break;
82
+ }
83
+ }
76
84
  for (let child of node.childNodes){
85
+ if (child.type === 'cell' && rowHasCellWithColSpan) {
86
+ var _child_props1, _child_props2;
87
+ child.colspan = (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.colSpan;
88
+ child.colSpan = (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.colSpan;
89
+ var _last_colIndex, _last_colSpan;
90
+ child.colIndex = !last ? child.index : ((_last_colIndex = last.colIndex) !== null && _last_colIndex !== void 0 ? _last_colIndex : last.index) + ((_last_colSpan = last.colSpan) !== null && _last_colSpan !== void 0 ? _last_colSpan : 1);
91
+ }
77
92
  if (child.type === 'cell' && child.parentKey == null) // if child is a cell parent key isn't already established by the collection, match child node to parent row
78
93
  child.parentKey = node.key;
79
94
  childKeys.add(child.key);
@@ -73,7 +73,22 @@
73
73
  this.keyMap.set(node.key, node);
74
74
  let childKeys = new Set();
75
75
  let last = null;
76
+ let rowHasCellWithColSpan = false;
77
+ if (node.type === 'item') {
78
+ var _child_props;
79
+ for (let child of node.childNodes)if (((_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.colSpan) !== undefined) {
80
+ rowHasCellWithColSpan = true;
81
+ break;
82
+ }
83
+ }
76
84
  for (let child of node.childNodes){
85
+ if (child.type === 'cell' && rowHasCellWithColSpan) {
86
+ var _child_props1, _child_props2;
87
+ child.colspan = (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.colSpan;
88
+ child.colSpan = (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.colSpan;
89
+ var _last_colIndex, _last_colSpan;
90
+ child.colIndex = !last ? child.index : ((_last_colIndex = last.colIndex) !== null && _last_colIndex !== void 0 ? _last_colIndex : last.index) + ((_last_colSpan = last.colSpan) !== null && _last_colSpan !== void 0 ? _last_colSpan : 1);
91
+ }
77
92
  if (child.type === 'cell' && child.parentKey == null) // if child is a cell parent key isn't already established by the collection, match child node to parent row
78
93
  child.parentKey = node.key;
79
94
  childKeys.add(child.key);
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAiGX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAO;QACT,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aA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,SAAS;gBAC1B,MAAM,CAAA,aAAA,KAAK,IAAI,cAAT,wBAAA,aAAa;gBACnB,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;gBACrB,eAAe;gBACf,YAAY;uBAAI,KAAK,UAAU;iBAAC;gBAChC,UAAU,KAAK,QAAQ;gBACvB,WAAW,CAAA,kBAAA,KAAK,SAAS,cAAd,6BAAA,kBAAkB;gBAC7B,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;YACvB;YAEA,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG,QAAQ,GAAG;gBAC1B,QAAQ,OAAO,GAAG,KAAK,GAAG;YAC5B,OACE,QAAQ,OAAO,GAAG;YAGpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACf,MAAM;YAEN,OAAO;QACT;QAEA,IAAI,MACF,KAAK,OAAO,GAAG;IAEnB;AA8CF","sources":["packages/@react-stately/grid/src/GridCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions<T> {\n columnCount: number,\n items: GridRow<T>[],\n visitNode?: (cell: GridNode<T>) => GridNode<T>\n}\n\nexport class GridCollection<T> implements IGridCollection<T> {\n keyMap: Map<Key, GridNode<T>> = new Map();\n columnCount: number;\n rows: GridNode<T>[];\n\n constructor(opts: GridCollectionOptions<T>) {\n this.keyMap = new Map();\n this.columnCount = opts?.columnCount;\n this.rows = [];\n\n let visit = (node: GridNode<T>) => {\n // If the node is the same object as the previous node for the same key,\n // we can skip this node and its children. We always visit columns though,\n // because we depend on order to build the columns array.\n let prevNode = this.keyMap.get(node.key);\n if (opts.visitNode) {\n node = opts.visitNode(node);\n }\n\n this.keyMap.set(node.key, node);\n\n let childKeys = new Set();\n let last: GridNode<T> | null = null;\n for (let child of node.childNodes) {\n if (child.type === 'cell' && child.parentKey == null) {\n // if child is a cell parent key isn't already established by the collection, match child node to parent row\n child.parentKey = node.key;\n }\n childKeys.add(child.key);\n\n if (last) {\n last.nextKey = child.key;\n child.prevKey = last.key;\n } else {\n child.prevKey = null;\n }\n\n visit(child);\n last = child;\n }\n\n if (last) {\n last.nextKey = null;\n }\n\n // Remove deleted nodes and their children from the key map\n if (prevNode) {\n for (let child of prevNode.childNodes) {\n if (!childKeys.has(child.key)) {\n remove(child);\n }\n }\n }\n };\n\n let remove = (node: GridNode<T>) => {\n this.keyMap.delete(node.key);\n for (let child of node.childNodes) {\n if (this.keyMap.get(child.key) === child) {\n remove(child);\n }\n }\n };\n\n let last: GridNode<T> | null = null;\n for (let [i, node] of opts.items.entries()) {\n let rowNode: GridNode<T> = {\n ...node,\n level: node.level ?? 0,\n key: node.key ?? 'row-' + i,\n type: node.type ?? 'row',\n value: node.value ?? null,\n hasChildNodes: true,\n childNodes: [...node.childNodes],\n rendered: node.rendered,\n textValue: node.textValue ?? '',\n index: node.index ?? i\n };\n\n if (last) {\n last.nextKey = rowNode.key;\n rowNode.prevKey = last.key;\n } else {\n rowNode.prevKey = null;\n }\n\n this.rows.push(rowNode);\n visit(rowNode);\n\n last = rowNode;\n }\n\n if (last) {\n last.nextKey = null;\n }\n }\n\n *[Symbol.iterator]() {\n yield* [...this.rows];\n }\n\n get size() {\n return [...this.rows].length;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return [...this.rows][0]?.key;\n }\n\n getLastKey(): Key | null {\n let rows = [...this.rows];\n return rows[rows.length - 1]?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"GridCollection.module.js.map"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAkHX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAO;QACT,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,cAA0B;YACjB;QAAP,QAAO,IAAA;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,EAAE,cAAjB,wBAAA,EAAmB,GAAG;IAC/B;IAEA,aAAyB;YAEhB;QADP,IAAI,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;QACzB,QAAO,SAAA,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE,cAArB,6BAAA,OAAuB,GAAG;IACnC;IAEA,QAA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,CAAA,YAAA,KAAK,GAAG,cAAR,uBAAA,YAAY,SAAS;gBAC1B,MAAM,CAAA,aAAA,KAAK,IAAI,cAAT,wBAAA,aAAa;gBACnB,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;gBACrB,eAAe;gBACf,YAAY;uBAAI,KAAK,UAAU;iBAAC;gBAChC,UAAU,KAAK,QAAQ;gBACvB,WAAW,CAAA,kBAAA,KAAK,SAAS,cAAd,6BAAA,kBAAkB;gBAC7B,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;YACvB;YAEA,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG,QAAQ,GAAG;gBAC1B,QAAQ,OAAO,GAAG,KAAK,GAAG;YAC5B,OACE,QAAQ,OAAO,GAAG;YAGpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACf,MAAM;YAEN,OAAO;QACT;QAEA,IAAI,MACF,KAAK,OAAO,GAAG;IAEnB;AA8CF","sources":["packages/@react-stately/grid/src/GridCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions<T> {\n columnCount: number,\n items: GridRow<T>[],\n visitNode?: (cell: GridNode<T>) => GridNode<T>\n}\n\nexport class GridCollection<T> implements IGridCollection<T> {\n keyMap: Map<Key, GridNode<T>> = new Map();\n columnCount: number;\n rows: GridNode<T>[];\n\n constructor(opts: GridCollectionOptions<T>) {\n this.keyMap = new Map();\n this.columnCount = opts?.columnCount;\n this.rows = [];\n\n let visit = (node: GridNode<T>) => {\n // If the node is the same object as the previous node for the same key,\n // we can skip this node and its children. We always visit columns though,\n // because we depend on order to build the columns array.\n let prevNode = this.keyMap.get(node.key);\n if (opts.visitNode) {\n node = opts.visitNode(node);\n }\n\n this.keyMap.set(node.key, node);\n\n let childKeys = new Set();\n let last: GridNode<T> | null = null;\n let rowHasCellWithColSpan = false;\n\n if (node.type === 'item') {\n for (let child of node.childNodes) {\n if (child.props?.colSpan !== undefined) {\n rowHasCellWithColSpan = true;\n break;\n }\n }\n }\n\n for (let child of node.childNodes as Iterable<GridNode<T>>) {\n if (child.type === 'cell' && rowHasCellWithColSpan) {\n child.colspan = child.props?.colSpan;\n child.colSpan = child.props?.colSpan;\n child.colIndex = !last ? child.index : (last.colIndex ?? last.index) + (last.colSpan ?? 1);\n }\n\n if (child.type === 'cell' && child.parentKey == null) {\n // if child is a cell parent key isn't already established by the collection, match child node to parent row\n child.parentKey = node.key;\n }\n childKeys.add(child.key);\n\n if (last) {\n last.nextKey = child.key;\n child.prevKey = last.key;\n } else {\n child.prevKey = null;\n }\n\n visit(child);\n last = child;\n }\n\n if (last) {\n last.nextKey = null;\n }\n\n // Remove deleted nodes and their children from the key map\n if (prevNode) {\n for (let child of prevNode.childNodes) {\n if (!childKeys.has(child.key)) {\n remove(child);\n }\n }\n }\n };\n\n let remove = (node: GridNode<T>) => {\n this.keyMap.delete(node.key);\n for (let child of node.childNodes) {\n if (this.keyMap.get(child.key) === child) {\n remove(child);\n }\n }\n };\n\n let last: GridNode<T> | null = null;\n for (let [i, node] of opts.items.entries()) {\n let rowNode: GridNode<T> = {\n ...node,\n level: node.level ?? 0,\n key: node.key ?? 'row-' + i,\n type: node.type ?? 'row',\n value: node.value ?? null,\n hasChildNodes: true,\n childNodes: [...node.childNodes],\n rendered: node.rendered,\n textValue: node.textValue ?? '',\n index: node.index ?? i\n };\n\n if (last) {\n last.nextKey = rowNode.key;\n rowNode.prevKey = last.key;\n } else {\n rowNode.prevKey = null;\n }\n\n this.rows.push(rowNode);\n visit(rowNode);\n\n last = rowNode;\n }\n\n if (last) {\n last.nextKey = null;\n }\n }\n\n *[Symbol.iterator]() {\n yield* [...this.rows];\n }\n\n get size() {\n return [...this.rows].length;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return [...this.rows][0]?.key;\n }\n\n getLastKey(): Key | null {\n let rows = [...this.rows];\n return rows[rows.length - 1]?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"GridCollection.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAMA,2BAA2B,CAAC,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,CAAC;IACd,gDAAgD;IAChD,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,kEAAkE;IAClE,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,2HAA2H;IAC3H,4BAA4B,EAAE,OAAO,CAAA;CACtC;AAED,kCAAkC,CAAC,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC,CAAE,SAAQ,2BAA2B;IACnG,UAAU,EAAE,CAAC,CAAC;IACd,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,sBAAsB,CAAA;CAC/C;AAED;;GAEG;AACH,6BAA6B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CA8F1H;AC1GD,gCAAgC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAA;CAC/C;AAED,4BAA4B,CAAC,CAAE,YAAW,iBAAgB,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAa;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;gBAER,IAAI,EAAE,sBAAsB,CAAC,CAAC;IA4FzC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlB,IAAI,IAAI,WAEP;IAED,OAAO;IAIP,YAAY,CAAC,GAAG,EAAE,GAAG;IAKrB,WAAW,CAAC,GAAG,EAAE,GAAG;IAKpB,WAAW,IAAI,GAAG,GAAG,IAAI;IAIzB,UAAU,IAAI,GAAG,GAAG,IAAI;IAKxB,OAAO,CAAC,GAAG,EAAE,GAAG;IAIhB,EAAE,CAAC,GAAG,EAAE,MAAM;IAKd,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;CAI7C","sources":["packages/@react-stately/grid/src/packages/@react-stately/grid/src/useGridState.ts","packages/@react-stately/grid/src/packages/@react-stately/grid/src/GridCollection.ts","packages/@react-stately/grid/src/packages/@react-stately/grid/src/index.ts","packages/@react-stately/grid/src/index.ts"],"sourcesContent":[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 {useGridState} from './useGridState';\nexport {GridCollection} from './GridCollection';\n\nexport type {GridStateOptions, GridState} from './useGridState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAMA,2BAA2B,CAAC,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,CAAC;IACd,gDAAgD;IAChD,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,kEAAkE;IAClE,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,2HAA2H;IAC3H,4BAA4B,EAAE,OAAO,CAAA;CACtC;AAED,kCAAkC,CAAC,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC,CAAE,SAAQ,2BAA2B;IACnG,UAAU,EAAE,CAAC,CAAC;IACd,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,sBAAsB,CAAA;CAC/C;AAED;;GAEG;AACH,6BAA6B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,iBAAe,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CA8F1H;AC1GD,gCAAgC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAA;CAC/C;AAED,4BAA4B,CAAC,CAAE,YAAW,iBAAgB,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAa;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;gBAER,IAAI,EAAE,sBAAsB,CAAC,CAAC;IA6GzC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlB,IAAI,IAAI,WAEP;IAED,OAAO;IAIP,YAAY,CAAC,GAAG,EAAE,GAAG;IAKrB,WAAW,CAAC,GAAG,EAAE,GAAG;IAKpB,WAAW,IAAI,GAAG,GAAG,IAAI;IAIzB,UAAU,IAAI,GAAG,GAAG,IAAI;IAKxB,OAAO,CAAC,GAAG,EAAE,GAAG;IAIhB,EAAE,CAAC,GAAG,EAAE,MAAM;IAKd,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;CAI7C","sources":["packages/@react-stately/grid/src/packages/@react-stately/grid/src/useGridState.ts","packages/@react-stately/grid/src/packages/@react-stately/grid/src/GridCollection.ts","packages/@react-stately/grid/src/packages/@react-stately/grid/src/index.ts","packages/@react-stately/grid/src/index.ts"],"sourcesContent":[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 {useGridState} from './useGridState';\nexport {GridCollection} from './GridCollection';\n\nexport type {GridStateOptions, GridState} from './useGridState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/grid",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/collections": "^3.12.0",
26
- "@react-stately/selection": "^3.18.0",
27
- "@react-types/grid": "^3.2.10",
28
- "@react-types/shared": "^3.26.0",
25
+ "@react-stately/collections": "^3.12.2",
26
+ "@react-stately/selection": "^3.20.0",
27
+ "@react-types/grid": "^3.3.0",
28
+ "@react-types/shared": "^3.28.0",
29
29
  "@swc/helpers": "^0.5.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
37
+ "gitHead": "4d3c72c94eea2d72eb3a0e7d56000c6ef7e39726"
38
38
  }
@@ -42,7 +42,24 @@ export class GridCollection<T> implements IGridCollection<T> {
42
42
 
43
43
  let childKeys = new Set();
44
44
  let last: GridNode<T> | null = null;
45
- for (let child of node.childNodes) {
45
+ let rowHasCellWithColSpan = false;
46
+
47
+ if (node.type === 'item') {
48
+ for (let child of node.childNodes) {
49
+ if (child.props?.colSpan !== undefined) {
50
+ rowHasCellWithColSpan = true;
51
+ break;
52
+ }
53
+ }
54
+ }
55
+
56
+ for (let child of node.childNodes as Iterable<GridNode<T>>) {
57
+ if (child.type === 'cell' && rowHasCellWithColSpan) {
58
+ child.colspan = child.props?.colSpan;
59
+ child.colSpan = child.props?.colSpan;
60
+ child.colIndex = !last ? child.index : (last.colIndex ?? last.index) + (last.colSpan ?? 1);
61
+ }
62
+
46
63
  if (child.type === 'cell' && child.parentKey == null) {
47
64
  // if child is a cell parent key isn't already established by the collection, match child node to parent row
48
65
  child.parentKey = node.key;