@react-stately/table 3.11.7-nightly.4555 → 3.11.7-nightly.4558

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.
Files changed (62) hide show
  1. package/dist/Cell.main.js +38 -0
  2. package/dist/Cell.main.js.map +1 -0
  3. package/dist/Cell.mjs +33 -0
  4. package/dist/Cell.module.js +33 -0
  5. package/dist/Cell.module.js.map +1 -0
  6. package/dist/Column.main.js +75 -0
  7. package/dist/Column.main.js.map +1 -0
  8. package/dist/Column.mjs +66 -0
  9. package/dist/Column.module.js +66 -0
  10. package/dist/Column.module.js.map +1 -0
  11. package/dist/Row.main.js +97 -0
  12. package/dist/Row.main.js.map +1 -0
  13. package/dist/Row.mjs +88 -0
  14. package/dist/Row.module.js +88 -0
  15. package/dist/Row.module.js.map +1 -0
  16. package/dist/TableBody.main.js +61 -0
  17. package/dist/TableBody.main.js.map +1 -0
  18. package/dist/TableBody.mjs +52 -0
  19. package/dist/TableBody.module.js +52 -0
  20. package/dist/TableBody.module.js.map +1 -0
  21. package/dist/TableCollection.main.js +284 -0
  22. package/dist/TableCollection.main.js.map +1 -0
  23. package/dist/TableCollection.mjs +278 -0
  24. package/dist/TableCollection.module.js +278 -0
  25. package/dist/TableCollection.module.js.map +1 -0
  26. package/dist/TableColumnLayout.main.js +162 -0
  27. package/dist/TableColumnLayout.main.js.map +1 -0
  28. package/dist/TableColumnLayout.mjs +157 -0
  29. package/dist/TableColumnLayout.module.js +157 -0
  30. package/dist/TableColumnLayout.module.js.map +1 -0
  31. package/dist/TableHeader.main.js +56 -0
  32. package/dist/TableHeader.main.js.map +1 -0
  33. package/dist/TableHeader.mjs +47 -0
  34. package/dist/TableHeader.module.js +47 -0
  35. package/dist/TableHeader.module.js.map +1 -0
  36. package/dist/TableUtils.main.js +184 -0
  37. package/dist/TableUtils.main.js.map +1 -0
  38. package/dist/TableUtils.mjs +175 -0
  39. package/dist/TableUtils.module.js +175 -0
  40. package/dist/TableUtils.module.js.map +1 -0
  41. package/dist/import.mjs +11 -1216
  42. package/dist/main.js +21 -1230
  43. package/dist/main.js.map +1 -1
  44. package/dist/module.js +11 -1216
  45. package/dist/module.js.map +1 -1
  46. package/dist/types.d.ts +1 -1
  47. package/dist/useTableColumnResizeState.main.js +113 -0
  48. package/dist/useTableColumnResizeState.main.js.map +1 -0
  49. package/dist/useTableColumnResizeState.mjs +108 -0
  50. package/dist/useTableColumnResizeState.module.js +108 -0
  51. package/dist/useTableColumnResizeState.module.js.map +1 -0
  52. package/dist/useTableState.main.js +71 -0
  53. package/dist/useTableState.main.js.map +1 -0
  54. package/dist/useTableState.mjs +66 -0
  55. package/dist/useTableState.module.js +66 -0
  56. package/dist/useTableState.module.js.map +1 -0
  57. package/dist/useTreeGridState.main.js +207 -0
  58. package/dist/useTreeGridState.main.js.map +1 -0
  59. package/dist/useTreeGridState.mjs +202 -0
  60. package/dist/useTreeGridState.module.js +202 -0
  61. package/dist/useTreeGridState.module.js.map +1 -0
  62. package/package.json +10 -10
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAOD,SAAS,0BAAO,KAAkB;IAChC,OAAO;AACT;AAEA,0BAAI,iBAAiB,GAAG,UAAU,kBAAqB,KAAkB,EAAE,OAAoC;IAC7G,IAAI,YAAC,QAAQ,aAAE,SAAS,uBAAE,mBAAmB,EAAC,GAAG;IAEjD,MAAM;QACJ,MAAM;QACN,OAAO;mBACP;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;QACf,CAAC;YACC,sBAAsB;YACtB,IAAI,QAAQ,eAAe,EACzB,MAAM;gBACJ,MAAM;gBACN,KAAK;gBACL,OAAO;oBACL,kBAAkB;gBACpB;YACF;YAGF,IAAI,QAAQ,uBAAuB,IAAI,QAAQ,aAAa,KAAK,QAC/D,MAAM;gBACJ,MAAM;gBACN,KAAK;gBACL,OAAO;oBACL,iBAAiB;gBACnB;YACF;YAGF,IAAI,OAAO,aAAa,YAAY;g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AO","sources":["packages/@react-stately/table/src/Row.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 {CollectionBuilderContext} from './useTableState';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {JSX, ReactElement} from 'react';\nimport {RowProps} from '@react-types/table';\n\nfunction Row<T>(props: RowProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nRow.getCollectionNode = function* getCollectionNode<T>(props: RowProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>> {\n let {children, textValue, UNSTABLE_childItems} = props;\n\n yield {\n type: 'item',\n props: props,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: true,\n *childNodes() {\n // Process cells first\n if (context.showDragButtons) {\n yield {\n type: 'cell',\n key: 'header-drag', // this is combined with the row key by CollectionBuilder\n props: {\n isDragButtonCell: true\n }\n };\n }\n\n if (context.showSelectionCheckboxes && context.selectionMode !== 'none') {\n yield {\n type: 'cell',\n key: 'header', // this is combined with the row key by CollectionBuilder\n props: {\n isSelectionCell: true\n }\n };\n }\n\n if (typeof children === 'function') {\n for (let column of context.columns) {\n yield {\n type: 'cell',\n element: children(column.key),\n key: column.key // this is combined with the row key by CollectionBuilder\n };\n }\n\n if (UNSTABLE_childItems) {\n for (let child of UNSTABLE_childItems) {\n // Note: in order to reuse the render function of TableBody for our child rows, we just need to yield a type and a value here. CollectionBuilder will then look up\n // the parent renderer and use that to build the full node of this child row, using the value provided here to generate the cells\n yield {\n type: 'item',\n value: child\n };\n }\n }\n } else {\n let cells: PartialNode<T>[] = [];\n let childRows: PartialNode<T>[] = [];\n React.Children.forEach(children, node => {\n if (node.type === Row) {\n if (cells.length < context.columns.length) {\n throw new Error('All of a Row\\'s child Cells must be positioned before any child Rows.');\n }\n\n childRows.push({\n type: 'item',\n element: node\n });\n } else {\n cells.push({\n type: 'cell',\n element: node\n });\n }\n });\n\n if (cells.length !== context.columns.length) {\n throw new Error(`Cell count must match column count. Found ${cells.length} cells and ${context.columns.length} columns.`);\n }\n\n yield* cells;\n yield* childRows;\n }\n },\n shouldInvalidate(newContext: CollectionBuilderContext<T>) {\n // Invalidate all rows if the columns changed.\n return newContext.columns.length !== context.columns.length ||\n newContext.columns.some((c, i) => c.key !== context.columns[i].key) ||\n newContext.showSelectionCheckboxes !== context.showSelectionCheckboxes ||\n newContext.showDragButtons !== context.showDragButtons ||\n newContext.selectionMode !== context.selectionMode;\n }\n };\n};\n\n/**\n * A Row represents a single item in a Table and contains Cell elements for each column.\n * Cells can be statically defined as children, or generated dynamically using a function\n * based on the columns defined in the TableHeader.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Row = Row as <T>(props: RowProps<T>) => JSX.Element;\nexport {_Row as Row};\n"],"names":[],"version":3,"file":"Row.module.js.map"}
@@ -0,0 +1,61 @@
1
+ var $ablJS$react = require("react");
2
+
3
+
4
+ function $parcel$interopDefault(a) {
5
+ return a && a.__esModule ? a.default : a;
6
+ }
7
+
8
+ function $parcel$export(e, n, v, s) {
9
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
+ }
11
+
12
+ $parcel$export(module.exports, "TableBody", () => $6ec527db6a3a5692$export$76ccd210b9029917);
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
24
+ function $6ec527db6a3a5692$var$TableBody(props) {
25
+ return null;
26
+ }
27
+ $6ec527db6a3a5692$var$TableBody.getCollectionNode = function* getCollectionNode(props) {
28
+ let { children: children, items: items } = props;
29
+ yield {
30
+ type: "body",
31
+ hasChildNodes: true,
32
+ props: props,
33
+ *childNodes () {
34
+ if (typeof children === "function") {
35
+ if (!items) throw new Error("props.children was a function but props.items is missing");
36
+ for (let item of items)yield {
37
+ type: "item",
38
+ value: item,
39
+ renderer: children
40
+ };
41
+ } else {
42
+ let items = [];
43
+ (0, ($parcel$interopDefault($ablJS$react))).Children.forEach(children, (item)=>{
44
+ items.push({
45
+ type: "item",
46
+ element: item
47
+ });
48
+ });
49
+ yield* items;
50
+ }
51
+ }
52
+ };
53
+ };
54
+ /**
55
+ * A TableBody is a container for the Row elements of a Table. Rows can be statically defined
56
+ * as children, or generated dynamically using a function based on the data passed to the `items` prop.
57
+ */ // We don't want getCollectionNode to show up in the type definition
58
+ let $6ec527db6a3a5692$export$76ccd210b9029917 = $6ec527db6a3a5692$var$TableBody;
59
+
60
+
61
+ //# sourceMappingURL=TableBody.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,gCAAa,KAAwB;IAC5C,OAAO;AACT;AAEA,gCAAU,iBAAiB,GAAG,UAAU,kBAAqB,KAAwB;IACnF,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;IACxB,MAAM;QACJ,MAAM;QACN,eAAe;eACf;QACA,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA;;;CAGC,GACD,oEAAoE;AACpE,IAAI,4CAAa","sources":["packages/@react-stately/table/src/TableBody.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 {PartialNode} from '@react-stately/collections';\nimport React, {JSX, ReactElement} from 'react';\nimport {TableBodyProps} from '@react-types/table';\n\nfunction TableBody<T>(props: TableBodyProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableBody.getCollectionNode = function* getCollectionNode<T>(props: TableBodyProps<T>): Generator<PartialNode<T>> {\n let {children, items} = props;\n yield {\n type: 'body',\n hasChildNodes: true,\n props,\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, item => {\n items.push({\n type: 'item',\n element: item\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n/**\n * A TableBody is a container for the Row elements of a Table. Rows can be statically defined\n * as children, or generated dynamically using a function based on the data passed to the `items` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TableBody = TableBody as <T>(props: TableBodyProps<T>) => JSX.Element;\nexport {_TableBody as TableBody};\n"],"names":[],"version":3,"file":"TableBody.main.js.map"}
@@ -0,0 +1,52 @@
1
+ import $6tF2U$react from "react";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $4ae5314bf50db1a3$var$TableBody(props) {
15
+ return null;
16
+ }
17
+ $4ae5314bf50db1a3$var$TableBody.getCollectionNode = function* getCollectionNode(props) {
18
+ let { children: children, items: items } = props;
19
+ yield {
20
+ type: "body",
21
+ hasChildNodes: true,
22
+ props: props,
23
+ *childNodes () {
24
+ if (typeof children === "function") {
25
+ if (!items) throw new Error("props.children was a function but props.items is missing");
26
+ for (let item of items)yield {
27
+ type: "item",
28
+ value: item,
29
+ renderer: children
30
+ };
31
+ } else {
32
+ let items = [];
33
+ (0, $6tF2U$react).Children.forEach(children, (item)=>{
34
+ items.push({
35
+ type: "item",
36
+ element: item
37
+ });
38
+ });
39
+ yield* items;
40
+ }
41
+ }
42
+ };
43
+ };
44
+ /**
45
+ * A TableBody is a container for the Row elements of a Table. Rows can be statically defined
46
+ * as children, or generated dynamically using a function based on the data passed to the `items` prop.
47
+ */ // We don't want getCollectionNode to show up in the type definition
48
+ let $4ae5314bf50db1a3$export$76ccd210b9029917 = $4ae5314bf50db1a3$var$TableBody;
49
+
50
+
51
+ export {$4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody};
52
+ //# sourceMappingURL=TableBody.mjs.map
@@ -0,0 +1,52 @@
1
+ import $6tF2U$react from "react";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $4ae5314bf50db1a3$var$TableBody(props) {
15
+ return null;
16
+ }
17
+ $4ae5314bf50db1a3$var$TableBody.getCollectionNode = function* getCollectionNode(props) {
18
+ let { children: children, items: items } = props;
19
+ yield {
20
+ type: "body",
21
+ hasChildNodes: true,
22
+ props: props,
23
+ *childNodes () {
24
+ if (typeof children === "function") {
25
+ if (!items) throw new Error("props.children was a function but props.items is missing");
26
+ for (let item of items)yield {
27
+ type: "item",
28
+ value: item,
29
+ renderer: children
30
+ };
31
+ } else {
32
+ let items = [];
33
+ (0, $6tF2U$react).Children.forEach(children, (item)=>{
34
+ items.push({
35
+ type: "item",
36
+ element: item
37
+ });
38
+ });
39
+ yield* items;
40
+ }
41
+ }
42
+ };
43
+ };
44
+ /**
45
+ * A TableBody is a container for the Row elements of a Table. Rows can be statically defined
46
+ * as children, or generated dynamically using a function based on the data passed to the `items` prop.
47
+ */ // We don't want getCollectionNode to show up in the type definition
48
+ let $4ae5314bf50db1a3$export$76ccd210b9029917 = $4ae5314bf50db1a3$var$TableBody;
49
+
50
+
51
+ export {$4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody};
52
+ //# sourceMappingURL=TableBody.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,gCAAa,KAAwB;IAC5C,OAAO;AACT;AAEA,gCAAU,iBAAiB,GAAG,UAAU,kBAAqB,KAAwB;IACnF,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;IACxB,MAAM;QACJ,MAAM;QACN,eAAe;eACf;QACA,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA;;;CAGC,GACD,oEAAoE;AACpE,IAAI,4CAAa","sources":["packages/@react-stately/table/src/TableBody.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 {PartialNode} from '@react-stately/collections';\nimport React, {JSX, ReactElement} from 'react';\nimport {TableBodyProps} from '@react-types/table';\n\nfunction TableBody<T>(props: TableBodyProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableBody.getCollectionNode = function* getCollectionNode<T>(props: TableBodyProps<T>): Generator<PartialNode<T>> {\n let {children, items} = props;\n yield {\n type: 'body',\n hasChildNodes: true,\n props,\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, item => {\n items.push({\n type: 'item',\n element: item\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n/**\n * A TableBody is a container for the Row elements of a Table. Rows can be statically defined\n * as children, or generated dynamically using a function based on the data passed to the `items` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TableBody = TableBody as <T>(props: TableBodyProps<T>) => JSX.Element;\nexport {_TableBody as TableBody};\n"],"names":[],"version":3,"file":"TableBody.module.js.map"}
@@ -0,0 +1,284 @@
1
+ var $bkA0E$reactstatelycollections = require("@react-stately/collections");
2
+ var $bkA0E$reactstatelygrid = require("@react-stately/grid");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "buildHeaderRows", () => $7f5a58334d8866a5$export$7c127db850d4e81e);
10
+ $parcel$export(module.exports, "TableCollection", () => $7f5a58334d8866a5$export$596e1b2e2cf93690);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+ const $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY = "row-header-column-" + Math.random().toString(36).slice(2);
24
+ let $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG = "row-header-column-" + Math.random().toString(36).slice(2);
25
+ while($7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY === $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG)$7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG = "row-header-column-" + Math.random().toString(36).slice(2);
26
+ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
27
+ if (columnNodes.length === 0) return [];
28
+ let columns = [];
29
+ let seen = new Map();
30
+ for (let column of columnNodes){
31
+ let parentKey = column.parentKey;
32
+ let col = [
33
+ column
34
+ ];
35
+ while(parentKey){
36
+ let parent = keyMap.get(parentKey);
37
+ if (!parent) break;
38
+ // If we've already seen this parent, than it is shared
39
+ // with a previous column. If the current column is taller
40
+ // than the previous column, than we need to shift the parent
41
+ // in the previous column so it's level with the current column.
42
+ if (seen.has(parent)) {
43
+ parent.colspan++;
44
+ let { column: column, index: index } = seen.get(parent);
45
+ if (index > col.length) break;
46
+ for(let i = index; i < col.length; i++)column.splice(i, 0, null);
47
+ // Adjust shifted indices
48
+ for(let i = col.length; i < column.length; i++)// eslint-disable-next-line max-depth
49
+ if (column[i] && seen.has(column[i])) seen.get(column[i]).index = i;
50
+ } else {
51
+ parent.colspan = 1;
52
+ col.push(parent);
53
+ seen.set(parent, {
54
+ column: col,
55
+ index: col.length - 1
56
+ });
57
+ }
58
+ parentKey = parent.parentKey;
59
+ }
60
+ columns.push(col);
61
+ column.index = columns.length - 1;
62
+ }
63
+ let maxLength = Math.max(...columns.map((c)=>c.length));
64
+ let headerRows = Array(maxLength).fill(0).map(()=>[]);
65
+ // Convert columns into rows.
66
+ let colIndex = 0;
67
+ for (let column of columns){
68
+ let i = maxLength - 1;
69
+ for (let item of column){
70
+ if (item) {
71
+ // Fill the space up until the current column with a placeholder
72
+ let row = headerRows[i];
73
+ let rowLength = row.reduce((p, c)=>p + c.colspan, 0);
74
+ if (rowLength < colIndex) {
75
+ let placeholder = {
76
+ type: "placeholder",
77
+ key: "placeholder-" + item.key,
78
+ colspan: colIndex - rowLength,
79
+ index: rowLength,
80
+ value: null,
81
+ rendered: null,
82
+ level: i,
83
+ hasChildNodes: false,
84
+ childNodes: [],
85
+ textValue: null
86
+ };
87
+ // eslint-disable-next-line max-depth
88
+ if (row.length > 0) {
89
+ row[row.length - 1].nextKey = placeholder.key;
90
+ placeholder.prevKey = row[row.length - 1].key;
91
+ }
92
+ row.push(placeholder);
93
+ }
94
+ if (row.length > 0) {
95
+ row[row.length - 1].nextKey = item.key;
96
+ item.prevKey = row[row.length - 1].key;
97
+ }
98
+ item.level = i;
99
+ item.colIndex = colIndex;
100
+ row.push(item);
101
+ }
102
+ i--;
103
+ }
104
+ colIndex++;
105
+ }
106
+ // Add placeholders at the end of each row that is shorter than the maximum
107
+ let i = 0;
108
+ for (let row of headerRows){
109
+ let rowLength = row.reduce((p, c)=>p + c.colspan, 0);
110
+ if (rowLength < columnNodes.length) {
111
+ let placeholder = {
112
+ type: "placeholder",
113
+ key: "placeholder-" + row[row.length - 1].key,
114
+ colspan: columnNodes.length - rowLength,
115
+ index: rowLength,
116
+ value: null,
117
+ rendered: null,
118
+ level: i,
119
+ hasChildNodes: false,
120
+ childNodes: [],
121
+ textValue: null,
122
+ prevKey: row[row.length - 1].key
123
+ };
124
+ row.push(placeholder);
125
+ }
126
+ i++;
127
+ }
128
+ return headerRows.map((childNodes, index)=>{
129
+ let row = {
130
+ type: "headerrow",
131
+ key: "headerrow-" + index,
132
+ index: index,
133
+ value: null,
134
+ rendered: null,
135
+ level: 0,
136
+ hasChildNodes: true,
137
+ childNodes: childNodes,
138
+ textValue: null
139
+ };
140
+ return row;
141
+ });
142
+ }
143
+ class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelygrid.GridCollection) {
144
+ *[Symbol.iterator]() {
145
+ yield* this.body.childNodes;
146
+ }
147
+ get size() {
148
+ return this._size;
149
+ }
150
+ getKeys() {
151
+ return this.keyMap.keys();
152
+ }
153
+ getKeyBefore(key) {
154
+ let node = this.keyMap.get(key);
155
+ return node ? node.prevKey : null;
156
+ }
157
+ getKeyAfter(key) {
158
+ let node = this.keyMap.get(key);
159
+ return node ? node.nextKey : null;
160
+ }
161
+ getFirstKey() {
162
+ var _getFirstItem;
163
+ return (_getFirstItem = (0, $bkA0E$reactstatelycollections.getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
164
+ }
165
+ getLastKey() {
166
+ var _getLastItem;
167
+ return (_getLastItem = (0, $bkA0E$reactstatelycollections.getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key;
168
+ }
169
+ getItem(key) {
170
+ return this.keyMap.get(key);
171
+ }
172
+ at(idx) {
173
+ const keys = [
174
+ ...this.getKeys()
175
+ ];
176
+ return this.getItem(keys[idx]);
177
+ }
178
+ getTextValue(key) {
179
+ let row = this.getItem(key);
180
+ if (!row) return "";
181
+ // If the row has a textValue, use that.
182
+ if (row.textValue) return row.textValue;
183
+ // Otherwise combine the text of each of the row header columns.
184
+ let rowHeaderColumnKeys = this.rowHeaderColumnKeys;
185
+ if (rowHeaderColumnKeys) {
186
+ let text = [];
187
+ for (let cell of row.childNodes){
188
+ let column = this.columns[cell.index];
189
+ if (rowHeaderColumnKeys.has(column.key) && cell.textValue) text.push(cell.textValue);
190
+ if (text.length === rowHeaderColumnKeys.size) break;
191
+ }
192
+ return text.join(" ");
193
+ }
194
+ return "";
195
+ }
196
+ constructor(nodes, prev, opts){
197
+ let rowHeaderColumnKeys = new Set();
198
+ let body;
199
+ let columns = [];
200
+ // Add cell for selection checkboxes if needed.
201
+ if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) {
202
+ let rowHeaderColumn = {
203
+ type: "column",
204
+ key: $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY,
205
+ value: null,
206
+ textValue: "",
207
+ level: 0,
208
+ index: (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) ? 1 : 0,
209
+ hasChildNodes: false,
210
+ rendered: null,
211
+ childNodes: [],
212
+ props: {
213
+ isSelectionCell: true
214
+ }
215
+ };
216
+ columns.unshift(rowHeaderColumn);
217
+ }
218
+ // Add cell for drag buttons if needed.
219
+ if (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) {
220
+ let rowHeaderColumn = {
221
+ type: "column",
222
+ key: $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG,
223
+ value: null,
224
+ textValue: "",
225
+ level: 0,
226
+ index: 0,
227
+ hasChildNodes: false,
228
+ rendered: null,
229
+ childNodes: [],
230
+ props: {
231
+ isDragButtonCell: true
232
+ }
233
+ };
234
+ columns.unshift(rowHeaderColumn);
235
+ }
236
+ let rows = [];
237
+ let columnKeyMap = new Map();
238
+ let visit = (node)=>{
239
+ switch(node.type){
240
+ case "body":
241
+ body = node;
242
+ break;
243
+ case "column":
244
+ columnKeyMap.set(node.key, node);
245
+ if (!node.hasChildNodes) {
246
+ columns.push(node);
247
+ if (node.props.isRowHeader) rowHeaderColumnKeys.add(node.key);
248
+ }
249
+ break;
250
+ case "item":
251
+ rows.push(node);
252
+ return; // do not go into childNodes
253
+ }
254
+ for (let child of node.childNodes)visit(child);
255
+ };
256
+ for (let node of nodes)visit(node);
257
+ let headerRows = $7f5a58334d8866a5$export$7c127db850d4e81e(columnKeyMap, columns);
258
+ headerRows.forEach((row, i)=>rows.splice(i, 0, row));
259
+ super({
260
+ columnCount: columns.length,
261
+ items: rows,
262
+ visitNode: (node)=>{
263
+ node.column = columns[node.index];
264
+ return node;
265
+ }
266
+ });
267
+ this._size = 0;
268
+ this.columns = columns;
269
+ this.rowHeaderColumnKeys = rowHeaderColumnKeys;
270
+ this.body = body;
271
+ this.headerRows = headerRows;
272
+ this._size = [
273
+ ...body.childNodes
274
+ ].length;
275
+ // Default row header column to the first one.
276
+ if (this.rowHeaderColumnKeys.size === 0) this.rowHeaderColumnKeys.add(this.columns.find((column)=>{
277
+ var _column_props, _column_props1;
278
+ return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell);
279
+ }).key);
280
+ }
281
+ }
282
+
283
+
284
+ //# sourceMappingURL=TableCollection.main.js.map
@@ -0,0 +1 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,OAAO;YACP,WAAW,CAAA;gBACT,KAAK,MAAM,GAAG,OAAO,CAAC,KAAK,KAAK,CAAC;gBACjC,OAAO;YACT;QACF;aAtFF,QAAgB;QAuFd,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;eAAI,KAAK,UAAU;SAAC,CAAC,MAAM;QAExC,8CAA8C;QAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,KAAK,GACpC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAAW,eAAmC;mBAApC,GAAC,gBAAA,OAAO,KAAK,cAAZ,oCAAA,cAAc,gBAAgB,KAAI,GAAC,iBAAA,OAAO,KAAK,cAAZ,qCAAA,eAAc,eAAe;WAAE,GAAG;IAEnI;AAwEF","sources":["packages/@react-stately/table/src/TableCollection.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 {getFirstItem, getLastItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {GridNode} from '@react-types/grid';\nimport {TableCollection as ITableCollection} from '@react-types/table';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions {\n showSelectionCheckboxes?: boolean,\n showDragButtons?: boolean\n}\n\nconst ROW_HEADER_COLUMN_KEY = 'row-header-column-' + Math.random().toString(36).slice(2);\nlet ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);\nwhile (ROW_HEADER_COLUMN_KEY === ROW_HEADER_COLUMN_KEY_DRAG) {\n ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);\n}\n\n/** @private */\nexport function buildHeaderRows<T>(keyMap: Map<Key, GridNode<T>>, columnNodes: GridNode<T>[]): GridNode<T>[] {\n if (columnNodes.length === 0) {\n return [];\n }\n\n let columns: GridNode<T>[][] = [];\n let seen = new Map();\n for (let column of columnNodes) {\n let parentKey = column.parentKey;\n let col = [column];\n\n while (parentKey) {\n let parent: GridNode<T> = keyMap.get(parentKey);\n if (!parent) {\n break;\n }\n\n // If we've already seen this parent, than it is shared\n // with a previous column. If the current column is taller\n // than the previous column, than we need to shift the parent\n // in the previous column so it's level with the current column.\n if (seen.has(parent)) {\n parent.colspan++;\n\n let {column, index} = seen.get(parent);\n if (index > col.length) {\n break;\n }\n\n for (let i = index; i < col.length; i++) {\n column.splice(i, 0, null);\n }\n\n // Adjust shifted indices\n for (let i = col.length; i < column.length; i++) {\n // eslint-disable-next-line max-depth\n if (column[i] && seen.has(column[i])) {\n seen.get(column[i]).index = i;\n }\n }\n } else {\n parent.colspan = 1;\n col.push(parent);\n seen.set(parent, {column: col, index: col.length - 1});\n }\n\n parentKey = parent.parentKey;\n }\n\n columns.push(col);\n column.index = columns.length - 1;\n }\n\n let maxLength = Math.max(...columns.map(c => c.length));\n let headerRows = Array(maxLength).fill(0).map(() => []);\n\n // Convert columns into rows.\n let colIndex = 0;\n for (let column of columns) {\n let i = maxLength - 1;\n for (let item of column) {\n if (item) {\n // Fill the space up until the current column with a placeholder\n let row = headerRows[i];\n let rowLength = row.reduce((p, c) => p + c.colspan, 0);\n if (rowLength < colIndex) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + item.key,\n colspan: colIndex - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: null\n };\n\n // eslint-disable-next-line max-depth\n if (row.length > 0) {\n row[row.length - 1].nextKey = placeholder.key;\n placeholder.prevKey = row[row.length - 1].key;\n }\n\n row.push(placeholder);\n }\n\n if (row.length > 0) {\n row[row.length - 1].nextKey = item.key;\n item.prevKey = row[row.length - 1].key;\n }\n\n item.level = i;\n item.colIndex = colIndex;\n row.push(item);\n }\n\n i--;\n }\n\n colIndex++;\n }\n\n // Add placeholders at the end of each row that is shorter than the maximum\n let i = 0;\n for (let row of headerRows) {\n let rowLength = row.reduce((p, c) => p + c.colspan, 0);\n if (rowLength < columnNodes.length) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + row[row.length - 1].key,\n colspan: columnNodes.length - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: null,\n prevKey: row[row.length - 1].key\n };\n\n row.push(placeholder);\n }\n\n i++;\n }\n\n return headerRows.map((childNodes, index) => {\n let row: GridNode<T> = {\n type: 'headerrow',\n key: 'headerrow-' + index,\n index,\n value: null,\n rendered: null,\n level: 0,\n hasChildNodes: true,\n childNodes,\n textValue: null\n };\n\n return row;\n });\n}\n\nexport class TableCollection<T> extends GridCollection<T> implements ITableCollection<T> {\n headerRows: GridNode<T>[];\n columns: GridNode<T>[];\n rowHeaderColumnKeys: Set<Key>;\n body: GridNode<T>;\n _size: number = 0;\n\n constructor(nodes: Iterable<GridNode<T>>, prev?: ITableCollection<T>, opts?: GridCollectionOptions) {\n let rowHeaderColumnKeys: Set<Key> = new Set();\n let body: GridNode<T>;\n let columns: GridNode<T>[] = [];\n // Add cell for selection checkboxes if needed.\n if (opts?.showSelectionCheckboxes) {\n let rowHeaderColumn: GridNode<T> = {\n type: 'column',\n key: ROW_HEADER_COLUMN_KEY,\n value: null,\n textValue: '',\n level: 0,\n index: opts?.showDragButtons ? 1 : 0,\n hasChildNodes: false,\n rendered: null,\n childNodes: [],\n props: {\n isSelectionCell: true\n }\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n // Add cell for drag buttons if needed.\n if (opts?.showDragButtons) {\n let rowHeaderColumn: GridNode<T> = {\n type: 'column',\n key: ROW_HEADER_COLUMN_KEY_DRAG,\n value: null,\n textValue: '',\n level: 0,\n index: 0,\n hasChildNodes: false,\n rendered: null,\n childNodes: [],\n props: {\n isDragButtonCell: true\n }\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n let rows = [];\n let columnKeyMap = new Map();\n let visit = (node: GridNode<T>) => {\n switch (node.type) {\n case 'body':\n body = node;\n break;\n case 'column':\n columnKeyMap.set(node.key, node);\n if (!node.hasChildNodes) {\n columns.push(node);\n\n if (node.props.isRowHeader) {\n rowHeaderColumnKeys.add(node.key);\n }\n }\n break;\n case 'item':\n rows.push(node);\n return; // do not go into childNodes\n }\n for (let child of node.childNodes) {\n visit(child);\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let headerRows = buildHeaderRows(columnKeyMap, columns) as GridNode<T>[];\n headerRows.forEach((row, i) => rows.splice(i, 0, row));\n\n super({\n columnCount: columns.length,\n items: rows,\n visitNode: node => {\n node.column = columns[node.index];\n return node;\n }\n });\n this.columns = columns;\n this.rowHeaderColumnKeys = rowHeaderColumnKeys;\n this.body = body;\n this.headerRows = headerRows;\n this._size = [...body.childNodes].length;\n\n // Default row header column to the first one.\n if (this.rowHeaderColumnKeys.size === 0) {\n this.rowHeaderColumnKeys.add(this.columns.find(column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell).key);\n }\n }\n\n *[Symbol.iterator]() {\n yield* this.body.childNodes;\n }\n\n get size() {\n return this._size;\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;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return getFirstItem(this.body.childNodes)?.key;\n }\n\n getLastKey() {\n return getLastItem(this.body.childNodes)?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getTextValue(key: Key): string {\n let row = this.getItem(key);\n if (!row) {\n return '';\n }\n\n // If the row has a textValue, use that.\n if (row.textValue) {\n return row.textValue;\n }\n\n // Otherwise combine the text of each of the row header columns.\n let rowHeaderColumnKeys = this.rowHeaderColumnKeys;\n if (rowHeaderColumnKeys) {\n let text = [];\n for (let cell of row.childNodes) {\n let column = this.columns[cell.index];\n if (rowHeaderColumnKeys.has(column.key) && cell.textValue) {\n text.push(cell.textValue);\n }\n\n if (text.length === rowHeaderColumnKeys.size) {\n break;\n }\n }\n\n return text.join(' ');\n }\n\n return '';\n }\n}\n"],"names":[],"version":3,"file":"TableCollection.main.js.map"}