@react-stately/table 3.12.3-nightly.5042 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cell.main.js.map +1 -1
- package/dist/Cell.module.js.map +1 -1
- package/dist/Column.main.js +1 -1
- package/dist/Column.main.js.map +1 -1
- package/dist/Column.mjs +1 -1
- package/dist/Column.module.js +1 -1
- package/dist/Column.module.js.map +1 -1
- package/dist/Row.main.js.map +1 -1
- package/dist/Row.module.js.map +1 -1
- package/dist/TableBody.main.js.map +1 -1
- package/dist/TableBody.module.js.map +1 -1
- package/dist/TableCollection.main.js +33 -17
- package/dist/TableCollection.main.js.map +1 -1
- package/dist/TableCollection.mjs +33 -17
- package/dist/TableCollection.module.js +33 -17
- package/dist/TableCollection.module.js.map +1 -1
- package/dist/TableColumnLayout.main.js +2 -2
- package/dist/TableColumnLayout.main.js.map +1 -1
- package/dist/TableColumnLayout.mjs +2 -2
- package/dist/TableColumnLayout.module.js +2 -2
- package/dist/TableColumnLayout.module.js.map +1 -1
- package/dist/TableHeader.main.js.map +1 -1
- package/dist/TableHeader.module.js.map +1 -1
- package/dist/TableUtils.main.js +1 -1
- package/dist/TableUtils.main.js.map +1 -1
- package/dist/TableUtils.mjs +1 -1
- package/dist/TableUtils.module.js +1 -1
- package/dist/TableUtils.module.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/useTableColumnResizeState.main.js.map +1 -1
- package/dist/useTableColumnResizeState.module.js.map +1 -1
- package/dist/useTableState.main.js +4 -3
- package/dist/useTableState.main.js.map +1 -1
- package/dist/useTableState.mjs +4 -3
- package/dist/useTableState.module.js +4 -3
- package/dist/useTableState.module.js.map +1 -1
- package/dist/useTreeGridState.main.js +5 -5
- package/dist/useTreeGridState.main.js.map +1 -1
- package/dist/useTreeGridState.mjs +5 -5
- package/dist/useTreeGridState.module.js +5 -5
- package/dist/useTreeGridState.module.js.map +1 -1
- package/package.json +11 -11
- package/src/Cell.ts +1 -1
- package/src/Column.ts +2 -2
- package/src/Row.ts +1 -1
- package/src/TableBody.ts +1 -1
- package/src/TableCollection.ts +23 -19
- package/src/TableColumnLayout.ts +2 -2
- package/src/TableHeader.ts +1 -1
- package/src/TableUtils.ts +17 -6
- package/src/useTableColumnResizeState.ts +1 -1
- package/src/useTableState.ts +3 -3
- package/src/useTreeGridState.ts +12 -11
package/dist/Cell.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAMD,SAAS,2BAAK,KAAgB;IAC5B,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAgB;IACtE,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAC5G,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;mBACV;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;IACjB;AACF;AAEA;;CAEC,GACD,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/table/src/Cell.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 {CellProps} from '@react-types/table';\nimport {JSX, ReactElement} from 'react';\nimport {PartialNode} from '@react-stately/collections';\n\nfunction Cell(props: CellProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nCell.getCollectionNode = function* getCollectionNode<T>(props: CellProps): Generator<PartialNode<T>> {\n let {children} = props;\n\n let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';\n yield {\n type: 'cell',\n props: props,\n rendered: children,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: false\n };\n};\n\n/**\n * A Cell represents the value of a single Column within a Table Row.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Cell = Cell as (props: CellProps) => JSX.Element;\nexport {_Cell as Cell};\n"],"names":[],"version":3,"file":"Cell.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAMD,SAAS,2BAAK,KAAgB;IAC5B,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAgB;IACtE,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAC5G,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;mBACV;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;IACjB;AACF;AAEA;;CAEC,GACD,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/table/src/Cell.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 {CellProps} from '@react-types/table';\nimport {JSX, ReactElement} from 'react';\nimport {PartialNode} from '@react-stately/collections';\n\nfunction Cell(props: CellProps): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nCell.getCollectionNode = function* getCollectionNode<T>(props: CellProps): Generator<PartialNode<T>> {\n let {children} = props;\n\n let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';\n yield {\n type: 'cell',\n props: props,\n rendered: children,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: false\n };\n};\n\n/**\n * A Cell represents the value of a single Column within a Table Row.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Cell = Cell as (props: CellProps) => JSX.Element;\nexport {_Cell as Cell};\n"],"names":[],"version":3,"file":"Cell.main.js.map"}
|
package/dist/Cell.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,SAAS,2BAAK,KAAgB;IAC5B,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAgB;IACtE,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAC5G,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;mBACV;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;IACjB;AACF;AAEA;;CAEC,GACD,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/table/src/Cell.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 {CellProps} from '@react-types/table';\nimport {JSX, ReactElement} from 'react';\nimport {PartialNode} from '@react-stately/collections';\n\nfunction Cell(props: CellProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nCell.getCollectionNode = function* getCollectionNode<T>(props: CellProps): Generator<PartialNode<T>> {\n let {children} = props;\n\n let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';\n yield {\n type: 'cell',\n props: props,\n rendered: children,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: false\n };\n};\n\n/**\n * A Cell represents the value of a single Column within a Table Row.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Cell = Cell as (props: CellProps) => JSX.Element;\nexport {_Cell as Cell};\n"],"names":[],"version":3,"file":"Cell.module.js.map"}
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,SAAS,2BAAK,KAAgB;IAC5B,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAgB;IACtE,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAC5G,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;mBACV;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;IACjB;AACF;AAEA;;CAEC,GACD,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/table/src/Cell.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 {CellProps} from '@react-types/table';\nimport {JSX, ReactElement} from 'react';\nimport {PartialNode} from '@react-stately/collections';\n\nfunction Cell(props: CellProps): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nCell.getCollectionNode = function* getCollectionNode<T>(props: CellProps): Generator<PartialNode<T>> {\n let {children} = props;\n\n let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';\n yield {\n type: 'cell',\n props: props,\n rendered: children,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: false\n };\n};\n\n/**\n * A Cell represents the value of a single Column within a Table Row.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Cell = Cell as (props: CellProps) => JSX.Element;\nexport {_Cell as Cell};\n"],"names":[],"version":3,"file":"Cell.module.js.map"}
|
package/dist/Column.main.js
CHANGED
|
@@ -30,7 +30,7 @@ $714483d9f6ca4c55$var$Column.getCollectionNode = function* getCollectionNode(pro
|
|
|
30
30
|
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'];
|
|
31
31
|
let fullNodes = yield {
|
|
32
32
|
type: 'column',
|
|
33
|
-
hasChildNodes: !!childColumns || title && (0, ($parcel$interopDefault($kykIu$react))).Children.count(children) > 0,
|
|
33
|
+
hasChildNodes: !!childColumns || !!title && (0, ($parcel$interopDefault($kykIu$react))).Children.count(children) > 0,
|
|
34
34
|
rendered: rendered,
|
|
35
35
|
textValue: textValue,
|
|
36
36
|
props: props,
|
package/dist/Column.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAQD,SAAS,6BAAU,KAAqB;IACtC,OAAO;AACT;AAEA,6BAAO,iBAAiB,GAAG,UAAU,kBAAqB,KAAqB,EAAE,OAAoC;IACnH,IAAI,SAAC,KAAK,YAAE,QAAQ,gBAAE,YAAY,EAAC,GAAG;IAEtC,IAAI,WAAW,SAAS;IACxB,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW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IC,GACD,oEAAoE;AACpE,IAAI,4CAAU","sources":["packages/@react-stately/table/src/Column.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 {ColumnProps} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Column<T>(props: ColumnProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nColumn.getCollectionNode = function* getCollectionNode<T>(props: ColumnProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>, void, GridNode<T>[]> {\n let {title, children, childColumns} = props;\n\n let rendered = title || children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'];\n\n let fullNodes = yield {\n type: 'column',\n hasChildNodes: !!childColumns || (!!title && React.Children.count(children) > 0),\n rendered,\n textValue,\n props,\n *childNodes() {\n if (childColumns) {\n for (let child of childColumns) {\n yield {\n type: 'column',\n value: child\n };\n }\n } else if (title) {\n let childColumns: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n childColumns.push({\n type: 'column',\n element: child as ReactElement<ColumnProps<T>>\n });\n });\n\n yield* childColumns;\n }\n },\n shouldInvalidate(newContext: CollectionBuilderContext<T>) {\n // This is a bit of a hack, but it works.\n // If this method is called, then there's a cached version of this node available.\n // But, we need to keep the list of columns in the new context up to date.\n updateContext(newContext);\n return false;\n }\n };\n\n let updateContext = (context: CollectionBuilderContext<T>) => {\n // register leaf columns on the context so that <Row> can access them\n for (let node of fullNodes) {\n if (!node.hasChildNodes) {\n context.columns.push(node);\n }\n }\n };\n\n updateContext(context);\n};\n\n/**\n * A Column represents a field of each item within a Table. Columns may also contain nested\n * Column elements to represent column groups. Nested columns can be statically defined as\n * children, or dynamically generated using a function based on the `childColumns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Column = Column as <T>(props: ColumnProps<T>) => JSX.Element;\nexport {_Column as Column};\n"],"names":[],"version":3,"file":"Column.main.js.map"}
|
package/dist/Column.mjs
CHANGED
|
@@ -20,7 +20,7 @@ $1cd244557c2f97d5$var$Column.getCollectionNode = function* getCollectionNode(pro
|
|
|
20
20
|
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'];
|
|
21
21
|
let fullNodes = yield {
|
|
22
22
|
type: 'column',
|
|
23
|
-
hasChildNodes: !!childColumns || title && (0, $kIQ5E$react).Children.count(children) > 0,
|
|
23
|
+
hasChildNodes: !!childColumns || !!title && (0, $kIQ5E$react).Children.count(children) > 0,
|
|
24
24
|
rendered: rendered,
|
|
25
25
|
textValue: textValue,
|
|
26
26
|
props: props,
|
package/dist/Column.module.js
CHANGED
|
@@ -20,7 +20,7 @@ $1cd244557c2f97d5$var$Column.getCollectionNode = function* getCollectionNode(pro
|
|
|
20
20
|
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'];
|
|
21
21
|
let fullNodes = yield {
|
|
22
22
|
type: 'column',
|
|
23
|
-
hasChildNodes: !!childColumns || title && (0, $kIQ5E$react).Children.count(children) > 0,
|
|
23
|
+
hasChildNodes: !!childColumns || !!title && (0, $kIQ5E$react).Children.count(children) > 0,
|
|
24
24
|
rendered: rendered,
|
|
25
25
|
textValue: textValue,
|
|
26
26
|
props: props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAQD,SAAS,6BAAU,KAAqB;IACtC,OAAO;AACT;AAEA,6BAAO,iBAAiB,GAAG,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A,IAAI,gBAAgB,CAAC;QACnB,qEAAqE;QACrE,KAAK,IAAI,QAAQ,UACf,IAAI,CAAC,KAAK,aAAa,EACrB,QAAQ,OAAO,CAAC,IAAI,CAAC;IAG3B;IAEA,cAAc;AAChB;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAU","sources":["packages/@react-stately/table/src/Column.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 {ColumnProps} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Column<T>(props: ColumnProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nColumn.getCollectionNode = function* getCollectionNode<T>(props: ColumnProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>, void, GridNode<T>[]> {\n let {title, children, childColumns} = props;\n\n let rendered = title || children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'];\n\n let fullNodes = yield {\n type: 'column',\n hasChildNodes: !!childColumns || (!!title && React.Children.count(children) > 0),\n rendered,\n textValue,\n props,\n *childNodes() {\n if (childColumns) {\n for (let child of childColumns) {\n yield {\n type: 'column',\n value: child\n };\n }\n } else if (title) {\n let childColumns: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n childColumns.push({\n type: 'column',\n element: child as ReactElement<ColumnProps<T>>\n });\n });\n\n yield* childColumns;\n }\n },\n shouldInvalidate(newContext: CollectionBuilderContext<T>) {\n // This is a bit of a hack, but it works.\n // If this method is called, then there's a cached version of this node available.\n // But, we need to keep the list of columns in the new context up to date.\n updateContext(newContext);\n return false;\n }\n };\n\n let updateContext = (context: CollectionBuilderContext<T>) => {\n // register leaf columns on the context so that <Row> can access them\n for (let node of fullNodes) {\n if (!node.hasChildNodes) {\n context.columns.push(node);\n }\n }\n };\n\n updateContext(context);\n};\n\n/**\n * A Column represents a field of each item within a Table. Columns may also contain nested\n * Column elements to represent column groups. Nested columns can be statically defined as\n * children, or dynamically generated using a function based on the `childColumns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _Column = Column as <T>(props: ColumnProps<T>) => JSX.Element;\nexport {_Column as Column};\n"],"names":[],"version":3,"file":"Column.module.js.map"}
|
package/dist/Row.main.js.map
CHANGED
|
@@ -1 +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;gBAClC,KAAK,IAAI,UAAU,QAAQ,OAAO,CAChC,MAAM;oBACJ,MAAM;oBACN,SAAS,SAAS,OAAO,GAAG;oBAC5B,KAAK,OAAO,GAAG,CAAC,yDAAyD;gBAC3E;gBAGF,IAAI,qBACF,KAAK,IAAI,SAAS,oBAChB,kKAAkK;gBAClK,iIAAiI;gBACjI,MAAM;oBACJ,MAAM;oBACN,OAAO;gBACT;YAGN,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,IAAI,YAA8B,EAAE;gBACpC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,IAAI,KAAK,IAAI,KAAK,2BAAK;wBACrB,IAAI,MAAM,MAAM,GAAG,QAAQ,OAAO,CAAC,MAAM,EACvC,MAAM,IAAI,MAAM;wBAGlB,UAAU,IAAI,CAAC;4BACb,MAAM;4BACN,SAAS;wBACX;oBACF,OACE,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBAEJ;gBAEA,IAAI,MAAM,MAAM,KAAK,QAAQ,OAAO,CAAC,MAAM,EACzC,MAAM,IAAI,MAAM,CAAC,0CAA0C,EAAE,MAAM,MAAM,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;gBAG1H,OAAO;gBACP,OAAO;YACT;QACF;QACA,kBAAiB,UAAuC;YACtD,8CAA8C;YAC9C,OAAO,WAAW,OAAO,CAAC,MAAM,KAAK,QAAQ,OAAO,CAAC,MAAM,IACzD,WAAW,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAM,EAAE,GAAG,KAAK,QAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,KAClE,WAAW,uBAAuB,KAAK,QAAQ,uBAAuB,IACtE,WAAW,eAAe,KAAK,QAAQ,eAAe,IACtD,WAAW,aAAa,KAAK,QAAQ,aAAa;QACtD;IACF;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAO","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.main.js.map"}
|
|
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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4CAAO","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 | null { // 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.main.js.map"}
|
package/dist/Row.module.js.map
CHANGED
|
@@ -1 +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,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AAK,QAAQ,uBAAuB,IACtE,WAAW,eAAe,KAAK,QAAQ,eAAe,IACtD,WAAW,aAAa,KAAK,QAAQ,aAAa;QACtD;IACF;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAO","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"}
|
|
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;YACt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I,CAAC,CAAC,GAAG,IAAM,EAAE,GAAG,KAAK,QAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,KAClE,WAAW,uBAAuB,KAAK,QAAQ,uBAAuB,IACtE,WAAW,eAAe,KAAK,QAAQ,eAAe,IACtD,WAAW,aAAa,KAAK,QAAQ,aAAa;QACtD;IACF;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAO","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 | null { // 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"}
|
|
@@ -1 +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"}
|
|
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 | null { // 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"}
|
|
@@ -1 +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"}
|
|
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 | null { // 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"}
|
|
@@ -40,6 +40,9 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
40
40
|
// than the previous column, than we need to shift the parent
|
|
41
41
|
// in the previous column so it's level with the current column.
|
|
42
42
|
if (seen.has(parent)) {
|
|
43
|
+
var _parent;
|
|
44
|
+
var _colspan;
|
|
45
|
+
(_colspan = (_parent = parent).colspan) !== null && _colspan !== void 0 ? _colspan : _parent.colspan = 0;
|
|
43
46
|
parent.colspan++;
|
|
44
47
|
let { column: column, index: index } = seen.get(parent);
|
|
45
48
|
if (index > col.length) break;
|
|
@@ -70,7 +73,10 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
70
73
|
if (item) {
|
|
71
74
|
// Fill the space up until the current column with a placeholder
|
|
72
75
|
let row = headerRows[i];
|
|
73
|
-
let rowLength = row.reduce((p, c)=>
|
|
76
|
+
let rowLength = row.reduce((p, c)=>{
|
|
77
|
+
var _c_colspan;
|
|
78
|
+
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1);
|
|
79
|
+
}, 0);
|
|
74
80
|
if (rowLength < colIndex) {
|
|
75
81
|
let placeholder = {
|
|
76
82
|
type: 'placeholder',
|
|
@@ -82,7 +88,7 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
82
88
|
level: i,
|
|
83
89
|
hasChildNodes: false,
|
|
84
90
|
childNodes: [],
|
|
85
|
-
textValue:
|
|
91
|
+
textValue: ''
|
|
86
92
|
};
|
|
87
93
|
// eslint-disable-next-line max-depth
|
|
88
94
|
if (row.length > 0) {
|
|
@@ -106,7 +112,10 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
106
112
|
// Add placeholders at the end of each row that is shorter than the maximum
|
|
107
113
|
let i = 0;
|
|
108
114
|
for (let row of headerRows){
|
|
109
|
-
let rowLength = row.reduce((p, c)=>
|
|
115
|
+
let rowLength = row.reduce((p, c)=>{
|
|
116
|
+
var _c_colspan;
|
|
117
|
+
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1);
|
|
118
|
+
}, 0);
|
|
110
119
|
if (rowLength < columnNodes.length) {
|
|
111
120
|
let placeholder = {
|
|
112
121
|
type: 'placeholder',
|
|
@@ -118,7 +127,7 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
118
127
|
level: i,
|
|
119
128
|
hasChildNodes: false,
|
|
120
129
|
childNodes: [],
|
|
121
|
-
textValue:
|
|
130
|
+
textValue: '',
|
|
122
131
|
prevKey: row[row.length - 1].key
|
|
123
132
|
};
|
|
124
133
|
row.push(placeholder);
|
|
@@ -135,7 +144,7 @@ function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
135
144
|
level: 0,
|
|
136
145
|
hasChildNodes: true,
|
|
137
146
|
childNodes: childNodes,
|
|
138
|
-
textValue:
|
|
147
|
+
textValue: ''
|
|
139
148
|
};
|
|
140
149
|
return row;
|
|
141
150
|
});
|
|
@@ -152,22 +161,27 @@ class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelyg
|
|
|
152
161
|
}
|
|
153
162
|
getKeyBefore(key) {
|
|
154
163
|
let node = this.keyMap.get(key);
|
|
155
|
-
|
|
164
|
+
var _node_prevKey;
|
|
165
|
+
return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null;
|
|
156
166
|
}
|
|
157
167
|
getKeyAfter(key) {
|
|
158
168
|
let node = this.keyMap.get(key);
|
|
159
|
-
|
|
169
|
+
var _node_nextKey;
|
|
170
|
+
return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null;
|
|
160
171
|
}
|
|
161
172
|
getFirstKey() {
|
|
162
173
|
var _getFirstItem;
|
|
163
|
-
|
|
174
|
+
var _getFirstItem_key;
|
|
175
|
+
return (_getFirstItem_key = (_getFirstItem = (0, $bkA0E$reactstatelycollections.getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
|
|
164
176
|
}
|
|
165
177
|
getLastKey() {
|
|
166
178
|
var _getLastItem;
|
|
167
|
-
|
|
179
|
+
var _getLastItem_key;
|
|
180
|
+
return (_getLastItem_key = (_getLastItem = (0, $bkA0E$reactstatelycollections.getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
|
|
168
181
|
}
|
|
169
182
|
getItem(key) {
|
|
170
|
-
|
|
183
|
+
var _this_keyMap_get;
|
|
184
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
171
185
|
}
|
|
172
186
|
at(idx) {
|
|
173
187
|
const keys = [
|
|
@@ -199,7 +213,7 @@ class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelyg
|
|
|
199
213
|
}
|
|
200
214
|
constructor(nodes, prev, opts){
|
|
201
215
|
let rowHeaderColumnKeys = new Set();
|
|
202
|
-
let body;
|
|
216
|
+
let body = null;
|
|
203
217
|
let columns = [];
|
|
204
218
|
// Add cell for selection checkboxes if needed.
|
|
205
219
|
if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) {
|
|
@@ -267,8 +281,7 @@ class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelyg
|
|
|
267
281
|
node.column = columns[node.index];
|
|
268
282
|
return node;
|
|
269
283
|
}
|
|
270
|
-
});
|
|
271
|
-
this._size = 0;
|
|
284
|
+
}), this._size = 0;
|
|
272
285
|
this.columns = columns;
|
|
273
286
|
this.rowHeaderColumnKeys = rowHeaderColumnKeys;
|
|
274
287
|
this.body = body;
|
|
@@ -277,10 +290,13 @@ class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelyg
|
|
|
277
290
|
...body.childNodes
|
|
278
291
|
].length;
|
|
279
292
|
// Default row header column to the first one.
|
|
280
|
-
if (this.rowHeaderColumnKeys.size === 0)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
293
|
+
if (this.rowHeaderColumnKeys.size === 0) {
|
|
294
|
+
let col = this.columns.find((column)=>{
|
|
295
|
+
var _column_props, _column_props1;
|
|
296
|
+
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);
|
|
297
|
+
});
|
|
298
|
+
if (col) this.rowHeaderColumnKeys.add(col.key);
|
|
299
|
+
}
|
|
284
300
|
}
|
|
285
301
|
}
|
|
286
302
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAaD,MAAM,8CAAwB,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC;AACtF,IAAI,mDAA6B,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IA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,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;AAgFF","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 getChildren(key: Key): Iterable<GridNode<T>> {\n if (key === this.body.key) {\n return this.body.childNodes;\n }\n\n return super.getChildren(key);\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"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAaD,MAAM,8CAAwB,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC;AACtF,IAAI,mDAA6B,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC;AACzF,MAAO,gDAA0B,iDAC/B,mDAA6B,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC;AAIhF,SAAS,0CAAmB,MAA6B,EAAE,WAA0B;IAC1F,IAAI,YAAY,MAAM,KAAK,GACzB,OAAO,EAAE;IAGX,IAAI,UAA2B,EAAE;IACjC,IAAI,OAAO,IAAI;IACf,KAAK,IAAI,UAAU,YAAa;QAC9B,IAAI,YAAY,OAAO,SAAS;QAChC,IAAI,MAAM;YAAC;SAAO;QAElB,MAAO,UAAW;YAChB,IAAI,SAAkC,OAAO,GAAG,CAAC;YACjD,IAAI,CAAC,QACH;YAGF,uDAAuD;YACvD,0D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ACT;QACF,SAtFF,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,KAAM,UAAU;SAAC,CAAC,MAAM;QAEzC,8CAA8C;QAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,KAAK,GAAG;YACvC,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;oBAAW,eAAmC;uBAApC,GAAC,gBAAA,OAAO,KAAK,cAAZ,oCAAA,cAAc,gBAAgB,KAAI,GAAC,iBAAA,OAAO,KAAK,cAAZ,qCAAA,eAAc,eAAe;;YACvG,IAAI,KACF,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,GAAG;QAExC;IACF;AAgFF","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> | undefined = 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 ??= 0;\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: GridNode<T>[][] = 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 ?? 1), 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: ''\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 ?? 1), 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: '',\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: ''\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> | null, opts?: GridCollectionOptions) {\n let rowHeaderColumnKeys: Set<Key> = new Set();\n let body: GridNode<T> | null = null;\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: GridNode<T>[] = [];\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 let col = this.columns.find(column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell);\n if (col) {\n this.rowHeaderColumnKeys.add(col.key);\n }\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?.prevKey ?? null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node?.nextKey ?? null;\n }\n\n getFirstKey() {\n return getFirstItem(this.body.childNodes)?.key ?? null;\n }\n\n getLastKey() {\n return getLastItem(this.body.childNodes)?.key ?? null;\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 if (key === this.body.key) {\n return this.body.childNodes;\n }\n\n return super.getChildren(key);\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: string[] = [];\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"}
|
package/dist/TableCollection.mjs
CHANGED
|
@@ -33,6 +33,9 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
33
33
|
// than the previous column, than we need to shift the parent
|
|
34
34
|
// in the previous column so it's level with the current column.
|
|
35
35
|
if (seen.has(parent)) {
|
|
36
|
+
var _parent;
|
|
37
|
+
var _colspan;
|
|
38
|
+
(_colspan = (_parent = parent).colspan) !== null && _colspan !== void 0 ? _colspan : _parent.colspan = 0;
|
|
36
39
|
parent.colspan++;
|
|
37
40
|
let { column: column, index: index } = seen.get(parent);
|
|
38
41
|
if (index > col.length) break;
|
|
@@ -63,7 +66,10 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
63
66
|
if (item) {
|
|
64
67
|
// Fill the space up until the current column with a placeholder
|
|
65
68
|
let row = headerRows[i];
|
|
66
|
-
let rowLength = row.reduce((p, c)=>
|
|
69
|
+
let rowLength = row.reduce((p, c)=>{
|
|
70
|
+
var _c_colspan;
|
|
71
|
+
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1);
|
|
72
|
+
}, 0);
|
|
67
73
|
if (rowLength < colIndex) {
|
|
68
74
|
let placeholder = {
|
|
69
75
|
type: 'placeholder',
|
|
@@ -75,7 +81,7 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
75
81
|
level: i,
|
|
76
82
|
hasChildNodes: false,
|
|
77
83
|
childNodes: [],
|
|
78
|
-
textValue:
|
|
84
|
+
textValue: ''
|
|
79
85
|
};
|
|
80
86
|
// eslint-disable-next-line max-depth
|
|
81
87
|
if (row.length > 0) {
|
|
@@ -99,7 +105,10 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
99
105
|
// Add placeholders at the end of each row that is shorter than the maximum
|
|
100
106
|
let i = 0;
|
|
101
107
|
for (let row of headerRows){
|
|
102
|
-
let rowLength = row.reduce((p, c)=>
|
|
108
|
+
let rowLength = row.reduce((p, c)=>{
|
|
109
|
+
var _c_colspan;
|
|
110
|
+
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1);
|
|
111
|
+
}, 0);
|
|
103
112
|
if (rowLength < columnNodes.length) {
|
|
104
113
|
let placeholder = {
|
|
105
114
|
type: 'placeholder',
|
|
@@ -111,7 +120,7 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
111
120
|
level: i,
|
|
112
121
|
hasChildNodes: false,
|
|
113
122
|
childNodes: [],
|
|
114
|
-
textValue:
|
|
123
|
+
textValue: '',
|
|
115
124
|
prevKey: row[row.length - 1].key
|
|
116
125
|
};
|
|
117
126
|
row.push(placeholder);
|
|
@@ -128,7 +137,7 @@ function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
|
|
|
128
137
|
level: 0,
|
|
129
138
|
hasChildNodes: true,
|
|
130
139
|
childNodes: childNodes,
|
|
131
|
-
textValue:
|
|
140
|
+
textValue: ''
|
|
132
141
|
};
|
|
133
142
|
return row;
|
|
134
143
|
});
|
|
@@ -145,22 +154,27 @@ class $788781baa30117fa$export$596e1b2e2cf93690 extends (0, $iLnZt$GridCollectio
|
|
|
145
154
|
}
|
|
146
155
|
getKeyBefore(key) {
|
|
147
156
|
let node = this.keyMap.get(key);
|
|
148
|
-
|
|
157
|
+
var _node_prevKey;
|
|
158
|
+
return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null;
|
|
149
159
|
}
|
|
150
160
|
getKeyAfter(key) {
|
|
151
161
|
let node = this.keyMap.get(key);
|
|
152
|
-
|
|
162
|
+
var _node_nextKey;
|
|
163
|
+
return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null;
|
|
153
164
|
}
|
|
154
165
|
getFirstKey() {
|
|
155
166
|
var _getFirstItem;
|
|
156
|
-
|
|
167
|
+
var _getFirstItem_key;
|
|
168
|
+
return (_getFirstItem_key = (_getFirstItem = (0, $iLnZt$getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
|
|
157
169
|
}
|
|
158
170
|
getLastKey() {
|
|
159
171
|
var _getLastItem;
|
|
160
|
-
|
|
172
|
+
var _getLastItem_key;
|
|
173
|
+
return (_getLastItem_key = (_getLastItem = (0, $iLnZt$getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
|
|
161
174
|
}
|
|
162
175
|
getItem(key) {
|
|
163
|
-
|
|
176
|
+
var _this_keyMap_get;
|
|
177
|
+
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
|
|
164
178
|
}
|
|
165
179
|
at(idx) {
|
|
166
180
|
const keys = [
|
|
@@ -192,7 +206,7 @@ class $788781baa30117fa$export$596e1b2e2cf93690 extends (0, $iLnZt$GridCollectio
|
|
|
192
206
|
}
|
|
193
207
|
constructor(nodes, prev, opts){
|
|
194
208
|
let rowHeaderColumnKeys = new Set();
|
|
195
|
-
let body;
|
|
209
|
+
let body = null;
|
|
196
210
|
let columns = [];
|
|
197
211
|
// Add cell for selection checkboxes if needed.
|
|
198
212
|
if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) {
|
|
@@ -260,8 +274,7 @@ class $788781baa30117fa$export$596e1b2e2cf93690 extends (0, $iLnZt$GridCollectio
|
|
|
260
274
|
node.column = columns[node.index];
|
|
261
275
|
return node;
|
|
262
276
|
}
|
|
263
|
-
});
|
|
264
|
-
this._size = 0;
|
|
277
|
+
}), this._size = 0;
|
|
265
278
|
this.columns = columns;
|
|
266
279
|
this.rowHeaderColumnKeys = rowHeaderColumnKeys;
|
|
267
280
|
this.body = body;
|
|
@@ -270,10 +283,13 @@ class $788781baa30117fa$export$596e1b2e2cf93690 extends (0, $iLnZt$GridCollectio
|
|
|
270
283
|
...body.childNodes
|
|
271
284
|
].length;
|
|
272
285
|
// Default row header column to the first one.
|
|
273
|
-
if (this.rowHeaderColumnKeys.size === 0)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
if (this.rowHeaderColumnKeys.size === 0) {
|
|
287
|
+
let col = this.columns.find((column)=>{
|
|
288
|
+
var _column_props, _column_props1;
|
|
289
|
+
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);
|
|
290
|
+
});
|
|
291
|
+
if (col) this.rowHeaderColumnKeys.add(col.key);
|
|
292
|
+
}
|
|
277
293
|
}
|
|
278
294
|
}
|
|
279
295
|
|