@react-stately/grid 3.11.9 → 3.12.1

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
@@ -1,5 +1,5 @@
1
- import {useGridState as $62967d126f3aa823$export$4007ac09ff9c68ed} from "./useGridState.mjs";
2
- import {GridCollection as $16805b1b18093c5f$export$de3fdf6493c353d} from "./GridCollection.mjs";
1
+ import {useGridState as $f30cc900230da60a$re_export$useGridState} from "react-stately/private/grid/useGridState";
2
+ import {GridCollection as $f30cc900230da60a$re_export$GridCollection} from "react-stately/private/grid/GridCollection";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {GridCollection as $16805b1b18093c5f$export$de3fdf6493c353d} from "./Grid
15
15
 
16
16
 
17
17
 
18
- export {$62967d126f3aa823$export$4007ac09ff9c68ed as useGridState, $16805b1b18093c5f$export$de3fdf6493c353d as GridCollection};
18
+ export {$f30cc900230da60a$re_export$useGridState as useGridState, $f30cc900230da60a$re_export$GridCollection as GridCollection};
19
19
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,13 +1,13 @@
1
- var $38009b28e45912ea$exports = require("./useGridState.main.js");
2
- var $8bb6a9101b052a66$exports = require("./GridCollection.main.js");
1
+ var $5ByT5$reactstatelyprivategriduseGridState = require("react-stately/private/grid/useGridState");
2
+ var $5ByT5$reactstatelyprivategridGridCollection = require("react-stately/private/grid/GridCollection");
3
3
 
4
4
 
5
5
  function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
- $parcel$export(module.exports, "useGridState", () => $38009b28e45912ea$exports.useGridState);
10
- $parcel$export(module.exports, "GridCollection", () => $8bb6a9101b052a66$exports.GridCollection);
9
+ $parcel$export(module.exports, "useGridState", function () { return $5ByT5$reactstatelyprivategriduseGridState.useGridState; });
10
+ $parcel$export(module.exports, "GridCollection", function () { return $5ByT5$reactstatelyprivategridGridCollection.GridCollection; });
11
11
  /*
12
12
  * Copyright 2020 Adobe. All rights reserved.
13
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/grid/src/index.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 {useGridState} from './useGridState';\nexport {GridCollection} from './GridCollection';\n\nexport type {GridStateOptions, GridState} from './useGridState';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/grid/src/index.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 {useGridState} from 'react-stately/private/grid/useGridState';\n\nexport {GridCollection} from 'react-stately/private/grid/GridCollection';\nexport type {GridStateOptions, GridState} from 'react-stately/private/grid/useGridState';\nexport type {IGridCollection, GridNode, GridRow} from 'react-stately/private/grid/GridCollection';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,5 +1,5 @@
1
- import {useGridState as $62967d126f3aa823$export$4007ac09ff9c68ed} from "./useGridState.module.js";
2
- import {GridCollection as $16805b1b18093c5f$export$de3fdf6493c353d} from "./GridCollection.module.js";
1
+ import {useGridState as $f30cc900230da60a$re_export$useGridState} from "react-stately/private/grid/useGridState";
2
+ import {GridCollection as $f30cc900230da60a$re_export$GridCollection} from "react-stately/private/grid/GridCollection";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {GridCollection as $16805b1b18093c5f$export$de3fdf6493c353d} from "./Grid
15
15
 
16
16
 
17
17
 
18
- export {$62967d126f3aa823$export$4007ac09ff9c68ed as useGridState, $16805b1b18093c5f$export$de3fdf6493c353d as GridCollection};
18
+ export {$f30cc900230da60a$re_export$useGridState as useGridState, $f30cc900230da60a$re_export$GridCollection as GridCollection};
19
19
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/grid/src/index.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 {useGridState} from './useGridState';\nexport {GridCollection} from './GridCollection';\n\nexport type {GridStateOptions, GridState} from './useGridState';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/grid/src/index.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 {useGridState} from 'react-stately/private/grid/useGridState';\n\nexport {GridCollection} from 'react-stately/private/grid/GridCollection';\nexport type {GridStateOptions, GridState} from 'react-stately/private/grid/useGridState';\nexport type {IGridCollection, GridNode, GridRow} from 'react-stately/private/grid/GridCollection';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,4 @@
1
+ export { useGridState } from 'react-stately/private/grid/useGridState';
2
+ export { GridCollection } from 'react-stately/private/grid/GridCollection';
3
+ export type { GridStateOptions, GridState } from 'react-stately/private/grid/useGridState';
4
+ export type { IGridCollection, GridNode, GridRow } from 'react-stately/private/grid/GridCollection';
package/package.json CHANGED
@@ -1,42 +1,47 @@
1
1
  {
2
2
  "name": "@react-stately/grid",
3
- "version": "3.11.9",
3
+ "version": "3.12.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
- "main": "dist/main.js",
7
- "module": "dist/module.js",
8
- "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/adobe/react-spectrum"
16
9
  },
17
- "types": "dist/types.d.ts",
18
10
  "source": "src/index.ts",
19
11
  "files": [
20
12
  "dist",
21
13
  "src"
22
14
  ],
23
15
  "sideEffects": false,
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/adobe/react-spectrum"
16
+ "main": "dist/main.js",
17
+ "module": "dist/module.js",
18
+ "types": "dist/types/src/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "source": "./src/index.ts",
22
+ "types": "./dist/types/src/index.d.ts",
23
+ "import": "./dist/import.mjs",
24
+ "require": "./dist/main.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
27
30
  },
28
31
  "dependencies": {
29
- "@react-stately/collections": "^3.12.10",
30
- "@react-stately/selection": "^3.20.9",
31
- "@react-types/grid": "^3.3.8",
32
- "@react-types/shared": "^3.33.1",
33
- "@swc/helpers": "^0.5.0"
32
+ "@swc/helpers": "^0.5.0",
33
+ "react-stately": "^3.46.0"
34
+ },
35
+ "devDependencies": {
36
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
37
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
34
38
  },
35
39
  "peerDependencies": {
36
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
40
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
41
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
37
42
  },
38
- "publishConfig": {
39
- "access": "public"
43
+ "targets": {
44
+ "types": false
40
45
  },
41
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
46
+ "gitHead": "3577a20859b9585a000010c720f6ee39c1c588cc"
42
47
  }
package/src/index.ts CHANGED
@@ -10,7 +10,8 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export {useGridState} from './useGridState';
14
- export {GridCollection} from './GridCollection';
13
+ export {useGridState} from 'react-stately/private/grid/useGridState';
15
14
 
16
- export type {GridStateOptions, GridState} from './useGridState';
15
+ export {GridCollection} from 'react-stately/private/grid/GridCollection';
16
+ export type {GridStateOptions, GridState} from 'react-stately/private/grid/useGridState';
17
+ export type {IGridCollection, GridNode, GridRow} from 'react-stately/private/grid/GridCollection';
@@ -1,148 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
-
6
- $parcel$export(module.exports, "GridCollection", () => $8bb6a9101b052a66$export$de3fdf6493c353d);
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */ class $8bb6a9101b052a66$export$de3fdf6493c353d {
18
- *[Symbol.iterator]() {
19
- yield* [
20
- ...this.rows
21
- ];
22
- }
23
- get size() {
24
- return [
25
- ...this.rows
26
- ].length;
27
- }
28
- getKeys() {
29
- return this.keyMap.keys();
30
- }
31
- getKeyBefore(key) {
32
- let node = this.keyMap.get(key);
33
- var _node_prevKey;
34
- return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
35
- }
36
- getKeyAfter(key) {
37
- let node = this.keyMap.get(key);
38
- var _node_nextKey;
39
- return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
40
- }
41
- getFirstKey() {
42
- var _;
43
- return (_ = [
44
- ...this.rows
45
- ][0]) === null || _ === void 0 ? void 0 : _.key;
46
- }
47
- getLastKey() {
48
- var _rows_;
49
- let rows = [
50
- ...this.rows
51
- ];
52
- return (_rows_ = rows[rows.length - 1]) === null || _rows_ === void 0 ? void 0 : _rows_.key;
53
- }
54
- getItem(key) {
55
- var _this_keyMap_get;
56
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
57
- }
58
- at(idx) {
59
- const keys = [
60
- ...this.getKeys()
61
- ];
62
- return this.getItem(keys[idx]);
63
- }
64
- getChildren(key) {
65
- let node = this.keyMap.get(key);
66
- return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
67
- }
68
- constructor(opts){
69
- this.keyMap = new Map();
70
- this.keyMap = new Map();
71
- this.columnCount = opts === null || opts === void 0 ? void 0 : opts.columnCount;
72
- this.rows = [];
73
- let visit = (node)=>{
74
- // If the node is the same object as the previous node for the same key,
75
- // we can skip this node and its children. We always visit columns though,
76
- // because we depend on order to build the columns array.
77
- let prevNode = this.keyMap.get(node.key);
78
- if (opts.visitNode) node = opts.visitNode(node);
79
- this.keyMap.set(node.key, node);
80
- let childKeys = new Set();
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
- }
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
- }
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
99
- child.parentKey = node.key;
100
- childKeys.add(child.key);
101
- if (last) {
102
- last.nextKey = child.key;
103
- child.prevKey = last.key;
104
- } else child.prevKey = null;
105
- visit(child);
106
- last = child;
107
- }
108
- if (last) last.nextKey = null;
109
- // Remove deleted nodes and their children from the key map
110
- if (prevNode) {
111
- for (let child of prevNode.childNodes)if (!childKeys.has(child.key)) remove(child);
112
- }
113
- };
114
- let remove = (node)=>{
115
- this.keyMap.delete(node.key);
116
- for (let child of node.childNodes)if (this.keyMap.get(child.key) === child) remove(child);
117
- };
118
- let last = null;
119
- for (let [i, node] of opts.items.entries()){
120
- var _node_level, _node_key, _node_type, _node_value, _node_textValue, _node_index;
121
- let rowNode = {
122
- ...node,
123
- level: (_node_level = node.level) !== null && _node_level !== void 0 ? _node_level : 0,
124
- key: (_node_key = node.key) !== null && _node_key !== void 0 ? _node_key : 'row-' + i,
125
- type: (_node_type = node.type) !== null && _node_type !== void 0 ? _node_type : 'row',
126
- value: (_node_value = node.value) !== null && _node_value !== void 0 ? _node_value : null,
127
- hasChildNodes: true,
128
- childNodes: [
129
- ...node.childNodes
130
- ],
131
- rendered: node.rendered,
132
- textValue: (_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '',
133
- index: (_node_index = node.index) !== null && _node_index !== void 0 ? _node_index : i
134
- };
135
- if (last) {
136
- last.nextKey = rowNode.key;
137
- rowNode.prevKey = last.key;
138
- } else rowNode.prevKey = null;
139
- this.rows.push(rowNode);
140
- visit(rowNode);
141
- last = rowNode;
142
- }
143
- if (last) last.nextKey = null;
144
- }
145
- }
146
-
147
-
148
- //# sourceMappingURL=GridCollection.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAkHX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAkC;QAClD,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAe;QACjB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CA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nC,IAAI,CAAC,UAAU,GAAG,CAAC,MAAM,GAAG,GAC1B,OAAO;YAGb;QACF;QAEA,IAAI,SAAS,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG;YAC3B,KAAK,IAAI,SAAS,KAAK,UAAU,CAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,OACjC,OAAO;QAGb;QAEA,IAAI,OAA2B;QAC/B,KAAK,IAAI,CAAC,GAAG,KAAK,IAAI,KAAK,KAAK,CAAC,OAAO,GAAI;gBAGjC,aACF,WACC,YACC,aAII,iBACJ;YAVT,IAAI,UAAuB;gBACzB,GAAG,IAAI;gBACP,OAAO,CAAA,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAc;gBACrB,KAAK,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](): IterableIterator<GridNode<T>> {\n yield* [...this.rows];\n }\n\n get size(): number {\n return [...this.rows].length;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\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): GridNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): GridNode<T> | null {\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,143 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ class $16805b1b18093c5f$export$de3fdf6493c353d {
12
- *[Symbol.iterator]() {
13
- yield* [
14
- ...this.rows
15
- ];
16
- }
17
- get size() {
18
- return [
19
- ...this.rows
20
- ].length;
21
- }
22
- getKeys() {
23
- return this.keyMap.keys();
24
- }
25
- getKeyBefore(key) {
26
- let node = this.keyMap.get(key);
27
- var _node_prevKey;
28
- return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
29
- }
30
- getKeyAfter(key) {
31
- let node = this.keyMap.get(key);
32
- var _node_nextKey;
33
- return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
34
- }
35
- getFirstKey() {
36
- var _;
37
- return (_ = [
38
- ...this.rows
39
- ][0]) === null || _ === void 0 ? void 0 : _.key;
40
- }
41
- getLastKey() {
42
- var _rows_;
43
- let rows = [
44
- ...this.rows
45
- ];
46
- return (_rows_ = rows[rows.length - 1]) === null || _rows_ === void 0 ? void 0 : _rows_.key;
47
- }
48
- getItem(key) {
49
- var _this_keyMap_get;
50
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
51
- }
52
- at(idx) {
53
- const keys = [
54
- ...this.getKeys()
55
- ];
56
- return this.getItem(keys[idx]);
57
- }
58
- getChildren(key) {
59
- let node = this.keyMap.get(key);
60
- return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
61
- }
62
- constructor(opts){
63
- this.keyMap = new Map();
64
- this.keyMap = new Map();
65
- this.columnCount = opts === null || opts === void 0 ? void 0 : opts.columnCount;
66
- this.rows = [];
67
- let visit = (node)=>{
68
- // If the node is the same object as the previous node for the same key,
69
- // we can skip this node and its children. We always visit columns though,
70
- // because we depend on order to build the columns array.
71
- let prevNode = this.keyMap.get(node.key);
72
- if (opts.visitNode) node = opts.visitNode(node);
73
- this.keyMap.set(node.key, node);
74
- let childKeys = new Set();
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
- }
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
- }
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
93
- child.parentKey = node.key;
94
- childKeys.add(child.key);
95
- if (last) {
96
- last.nextKey = child.key;
97
- child.prevKey = last.key;
98
- } else child.prevKey = null;
99
- visit(child);
100
- last = child;
101
- }
102
- if (last) last.nextKey = null;
103
- // Remove deleted nodes and their children from the key map
104
- if (prevNode) {
105
- for (let child of prevNode.childNodes)if (!childKeys.has(child.key)) remove(child);
106
- }
107
- };
108
- let remove = (node)=>{
109
- this.keyMap.delete(node.key);
110
- for (let child of node.childNodes)if (this.keyMap.get(child.key) === child) remove(child);
111
- };
112
- let last = null;
113
- for (let [i, node] of opts.items.entries()){
114
- var _node_level, _node_key, _node_type, _node_value, _node_textValue, _node_index;
115
- let rowNode = {
116
- ...node,
117
- level: (_node_level = node.level) !== null && _node_level !== void 0 ? _node_level : 0,
118
- key: (_node_key = node.key) !== null && _node_key !== void 0 ? _node_key : 'row-' + i,
119
- type: (_node_type = node.type) !== null && _node_type !== void 0 ? _node_type : 'row',
120
- value: (_node_value = node.value) !== null && _node_value !== void 0 ? _node_value : null,
121
- hasChildNodes: true,
122
- childNodes: [
123
- ...node.childNodes
124
- ],
125
- rendered: node.rendered,
126
- textValue: (_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '',
127
- index: (_node_index = node.index) !== null && _node_index !== void 0 ? _node_index : i
128
- };
129
- if (last) {
130
- last.nextKey = rowNode.key;
131
- rowNode.prevKey = last.key;
132
- } else rowNode.prevKey = null;
133
- this.rows.push(rowNode);
134
- visit(rowNode);
135
- last = rowNode;
136
- }
137
- if (last) last.nextKey = null;
138
- }
139
- }
140
-
141
-
142
- export {$16805b1b18093c5f$export$de3fdf6493c353d as GridCollection};
143
- //# sourceMappingURL=GridCollection.module.js.map
@@ -1,143 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ class $16805b1b18093c5f$export$de3fdf6493c353d {
12
- *[Symbol.iterator]() {
13
- yield* [
14
- ...this.rows
15
- ];
16
- }
17
- get size() {
18
- return [
19
- ...this.rows
20
- ].length;
21
- }
22
- getKeys() {
23
- return this.keyMap.keys();
24
- }
25
- getKeyBefore(key) {
26
- let node = this.keyMap.get(key);
27
- var _node_prevKey;
28
- return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
29
- }
30
- getKeyAfter(key) {
31
- let node = this.keyMap.get(key);
32
- var _node_nextKey;
33
- return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
34
- }
35
- getFirstKey() {
36
- var _;
37
- return (_ = [
38
- ...this.rows
39
- ][0]) === null || _ === void 0 ? void 0 : _.key;
40
- }
41
- getLastKey() {
42
- var _rows_;
43
- let rows = [
44
- ...this.rows
45
- ];
46
- return (_rows_ = rows[rows.length - 1]) === null || _rows_ === void 0 ? void 0 : _rows_.key;
47
- }
48
- getItem(key) {
49
- var _this_keyMap_get;
50
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
51
- }
52
- at(idx) {
53
- const keys = [
54
- ...this.getKeys()
55
- ];
56
- return this.getItem(keys[idx]);
57
- }
58
- getChildren(key) {
59
- let node = this.keyMap.get(key);
60
- return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
61
- }
62
- constructor(opts){
63
- this.keyMap = new Map();
64
- this.keyMap = new Map();
65
- this.columnCount = opts === null || opts === void 0 ? void 0 : opts.columnCount;
66
- this.rows = [];
67
- let visit = (node)=>{
68
- // If the node is the same object as the previous node for the same key,
69
- // we can skip this node and its children. We always visit columns though,
70
- // because we depend on order to build the columns array.
71
- let prevNode = this.keyMap.get(node.key);
72
- if (opts.visitNode) node = opts.visitNode(node);
73
- this.keyMap.set(node.key, node);
74
- let childKeys = new Set();
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
- }
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
- }
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
93
- child.parentKey = node.key;
94
- childKeys.add(child.key);
95
- if (last) {
96
- last.nextKey = child.key;
97
- child.prevKey = last.key;
98
- } else child.prevKey = null;
99
- visit(child);
100
- last = child;
101
- }
102
- if (last) last.nextKey = null;
103
- // Remove deleted nodes and their children from the key map
104
- if (prevNode) {
105
- for (let child of prevNode.childNodes)if (!childKeys.has(child.key)) remove(child);
106
- }
107
- };
108
- let remove = (node)=>{
109
- this.keyMap.delete(node.key);
110
- for (let child of node.childNodes)if (this.keyMap.get(child.key) === child) remove(child);
111
- };
112
- let last = null;
113
- for (let [i, node] of opts.items.entries()){
114
- var _node_level, _node_key, _node_type, _node_value, _node_textValue, _node_index;
115
- let rowNode = {
116
- ...node,
117
- level: (_node_level = node.level) !== null && _node_level !== void 0 ? _node_level : 0,
118
- key: (_node_key = node.key) !== null && _node_key !== void 0 ? _node_key : 'row-' + i,
119
- type: (_node_type = node.type) !== null && _node_type !== void 0 ? _node_type : 'row',
120
- value: (_node_value = node.value) !== null && _node_value !== void 0 ? _node_value : null,
121
- hasChildNodes: true,
122
- childNodes: [
123
- ...node.childNodes
124
- ],
125
- rendered: node.rendered,
126
- textValue: (_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '',
127
- index: (_node_index = node.index) !== null && _node_index !== void 0 ? _node_index : i
128
- };
129
- if (last) {
130
- last.nextKey = rowNode.key;
131
- rowNode.prevKey = last.key;
132
- } else rowNode.prevKey = null;
133
- this.rows.push(rowNode);
134
- visit(rowNode);
135
- last = rowNode;
136
- }
137
- if (last) last.nextKey = null;
138
- }
139
- }
140
-
141
-
142
- export {$16805b1b18093c5f$export$de3fdf6493c353d as GridCollection};
143
- //# sourceMappingURL=GridCollection.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAWM,MAAM;IAkHX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAkC;QAClD,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC;IACvB;IAEA,IAAI,OAAe;QACjB,OAAO;eAAI,IAAI,CAAC,IAAI;SAAC,CAAC,MAAM;IAC9B;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAc;QAChC,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,EAAsB;YAC7B;QAAP,OAAO,CAAA,mBAAA,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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 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](): IterableIterator<GridNode<T>> {\n yield* [...this.rows];\n }\n\n get size(): number {\n return [...this.rows].length;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\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): GridNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): GridNode<T> | null {\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"}