@react-stately/table 3.0.0-beta.0 → 3.0.0-nightly-641446f65-240905
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 +38 -0
- package/dist/Cell.main.js.map +1 -0
- package/dist/Cell.mjs +33 -0
- package/dist/Cell.module.js +33 -0
- package/dist/Cell.module.js.map +1 -0
- package/dist/Column.main.js +75 -0
- package/dist/Column.main.js.map +1 -0
- package/dist/Column.mjs +66 -0
- package/dist/Column.module.js +66 -0
- package/dist/Column.module.js.map +1 -0
- package/dist/Row.main.js +97 -0
- package/dist/Row.main.js.map +1 -0
- package/dist/Row.mjs +88 -0
- package/dist/Row.module.js +88 -0
- package/dist/Row.module.js.map +1 -0
- package/dist/TableBody.main.js +61 -0
- package/dist/TableBody.main.js.map +1 -0
- package/dist/TableBody.mjs +52 -0
- package/dist/TableBody.module.js +52 -0
- package/dist/TableBody.module.js.map +1 -0
- package/dist/TableCollection.main.js +288 -0
- package/dist/TableCollection.main.js.map +1 -0
- package/dist/TableCollection.mjs +282 -0
- package/dist/TableCollection.module.js +282 -0
- package/dist/TableCollection.module.js.map +1 -0
- package/dist/TableColumnLayout.main.js +113 -0
- package/dist/TableColumnLayout.main.js.map +1 -0
- package/dist/TableColumnLayout.mjs +108 -0
- package/dist/TableColumnLayout.module.js +108 -0
- package/dist/TableColumnLayout.module.js.map +1 -0
- package/dist/TableHeader.main.js +56 -0
- package/dist/TableHeader.main.js.map +1 -0
- package/dist/TableHeader.mjs +47 -0
- package/dist/TableHeader.module.js +47 -0
- package/dist/TableHeader.module.js.map +1 -0
- package/dist/TableUtils.main.js +182 -0
- package/dist/TableUtils.main.js.map +1 -0
- package/dist/TableUtils.mjs +175 -0
- package/dist/TableUtils.module.js +175 -0
- package/dist/TableUtils.module.js.map +1 -0
- package/dist/import.mjs +37 -0
- package/dist/main.js +39 -593
- package/dist/main.js.map +1 -1
- package/dist/module.js +22 -564
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +163 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/useTableColumnResizeState.main.js +109 -0
- package/dist/useTableColumnResizeState.main.js.map +1 -0
- package/dist/useTableColumnResizeState.mjs +104 -0
- package/dist/useTableColumnResizeState.module.js +104 -0
- package/dist/useTableColumnResizeState.module.js.map +1 -0
- package/dist/useTableState.main.js +71 -0
- package/dist/useTableState.main.js.map +1 -0
- package/dist/useTableState.mjs +66 -0
- package/dist/useTableState.module.js +66 -0
- package/dist/useTableState.module.js.map +1 -0
- package/dist/useTreeGridState.main.js +207 -0
- package/dist/useTreeGridState.main.js.map +1 -0
- package/dist/useTreeGridState.mjs +202 -0
- package/dist/useTreeGridState.module.js +202 -0
- package/dist/useTreeGridState.module.js.map +1 -0
- package/package.json +18 -10
- package/src/Cell.ts +4 -1
- package/src/Column.ts +12 -2
- package/src/Row.ts +50 -10
- package/src/TableBody.ts +6 -2
- package/src/TableCollection.ts +99 -15
- package/src/TableColumnLayout.ts +127 -0
- package/src/TableHeader.ts +11 -2
- package/src/TableUtils.ts +253 -0
- package/src/index.ts +15 -6
- package/src/useTableColumnResizeState.ts +147 -0
- package/src/useTableState.ts +43 -16
- package/src/useTreeGridState.ts +277 -0
- package/LICENSE +0 -201
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var $9e5f6a0caf75716e$exports = require("./TableUtils.main.js");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "TableColumnLayout", () => $2240a72410c17d51$export$7ff77a162970b30e);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
class $2240a72410c17d51$export$7ff77a162970b30e {
|
|
21
|
+
/** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns) {
|
|
22
|
+
return columns.reduce((acc, col)=>{
|
|
23
|
+
if (col.props.width != null) acc[0].set(col.key, col);
|
|
24
|
+
else acc[1].set(col.key, col);
|
|
25
|
+
return acc;
|
|
26
|
+
}, [
|
|
27
|
+
new Map(),
|
|
28
|
+
new Map()
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
|
|
32
|
+
return new Map(columns.map((col)=>{
|
|
33
|
+
if (uncontrolledColumns.has(col.key)) return [
|
|
34
|
+
col.key,
|
|
35
|
+
uncontrolledWidths.get(col.key)
|
|
36
|
+
];
|
|
37
|
+
else return [
|
|
38
|
+
col.key,
|
|
39
|
+
controlledColumns.get(col.key).props.width
|
|
40
|
+
];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns) {
|
|
44
|
+
return new Map(Array.from(uncontrolledColumns).map(([key, col])=>{
|
|
45
|
+
var _this_getDefaultWidth, _this;
|
|
46
|
+
var _col_props_defaultWidth, _ref;
|
|
47
|
+
return [
|
|
48
|
+
key,
|
|
49
|
+
(_ref = (_col_props_defaultWidth = col.props.defaultWidth) !== null && _col_props_defaultWidth !== void 0 ? _col_props_defaultWidth : (_this_getDefaultWidth = (_this = this).getDefaultWidth) === null || _this_getDefaultWidth === void 0 ? void 0 : _this_getDefaultWidth.call(_this, col)) !== null && _ref !== void 0 ? _ref : '1fr'
|
|
50
|
+
];
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
getColumnWidth(key) {
|
|
54
|
+
var _this_columnWidths_get;
|
|
55
|
+
return (_this_columnWidths_get = this.columnWidths.get(key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
|
|
56
|
+
}
|
|
57
|
+
getColumnMinWidth(key) {
|
|
58
|
+
var _this_columnMinWidths_get;
|
|
59
|
+
return (_this_columnMinWidths_get = this.columnMinWidths.get(key)) !== null && _this_columnMinWidths_get !== void 0 ? _this_columnMinWidths_get : 0;
|
|
60
|
+
}
|
|
61
|
+
getColumnMaxWidth(key) {
|
|
62
|
+
var _this_columnMaxWidths_get;
|
|
63
|
+
return (_this_columnMaxWidths_get = this.columnMaxWidths.get(key)) !== null && _this_columnMaxWidths_get !== void 0 ? _this_columnMaxWidths_get : 0;
|
|
64
|
+
}
|
|
65
|
+
resizeColumnWidth(collection, uncontrolledWidths, col, width) {
|
|
66
|
+
let prevColumnWidths = this.columnWidths;
|
|
67
|
+
let freeze = true;
|
|
68
|
+
let newWidths = new Map();
|
|
69
|
+
width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
|
|
70
|
+
collection.columns.forEach((column)=>{
|
|
71
|
+
var _column_props_width;
|
|
72
|
+
if (column.key === col) {
|
|
73
|
+
newWidths.set(column.key, width);
|
|
74
|
+
freeze = false;
|
|
75
|
+
} else if (freeze) // freeze columns to the left to their previous pixel value
|
|
76
|
+
newWidths.set(column.key, prevColumnWidths.get(column.key));
|
|
77
|
+
else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key));
|
|
78
|
+
});
|
|
79
|
+
return newWidths;
|
|
80
|
+
}
|
|
81
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
82
|
+
this.columnWidths = new Map();
|
|
83
|
+
this.columnMinWidths = new Map();
|
|
84
|
+
this.columnMaxWidths = new Map();
|
|
85
|
+
// initial layout or table/window resizing
|
|
86
|
+
let columnWidths = (0, $9e5f6a0caf75716e$exports.calculateColumnSizes)(tableWidth, collection.columns.map((col)=>({
|
|
87
|
+
...col.props,
|
|
88
|
+
key: col.key
|
|
89
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
90
|
+
// columns going in will be the same order as the columns coming out
|
|
91
|
+
columnWidths.forEach((width, index)=>{
|
|
92
|
+
let key = collection.columns[index].key;
|
|
93
|
+
let column = collection.columns[index];
|
|
94
|
+
this.columnWidths.set(key, width);
|
|
95
|
+
var _column_props_minWidth;
|
|
96
|
+
this.columnMinWidths.set(key, (0, $9e5f6a0caf75716e$exports.getMinWidth)((_column_props_minWidth = column.props.minWidth) !== null && _column_props_minWidth !== void 0 ? _column_props_minWidth : this.getDefaultMinWidth(column), tableWidth));
|
|
97
|
+
this.columnMaxWidths.set(key, (0, $9e5f6a0caf75716e$exports.getMaxWidth)(column.props.maxWidth, tableWidth));
|
|
98
|
+
});
|
|
99
|
+
return this.columnWidths;
|
|
100
|
+
}
|
|
101
|
+
constructor(options){
|
|
102
|
+
this.columnWidths = new Map();
|
|
103
|
+
this.columnMinWidths = new Map();
|
|
104
|
+
this.columnMaxWidths = new Map();
|
|
105
|
+
var _options_getDefaultWidth;
|
|
106
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>'1fr';
|
|
107
|
+
var _options_getDefaultMinWidth;
|
|
108
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 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esContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n calculateColumnSizes,\n getMaxWidth,\n getMinWidth\n} from './TableUtils';\nimport {ColumnSize, TableCollection} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\nexport interface TableColumnLayoutOptions<T> {\n getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined,\n getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined\n}\n\nexport class TableColumnLayout<T> {\n getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n columnWidths: Map<Key, number> = new Map();\n columnMinWidths: Map<Key, number> = new Map();\n columnMaxWidths: Map<Key, number> = new Map();\n\n constructor(options: TableColumnLayoutOptions<T>) {\n this.getDefaultWidth = options?.getDefaultWidth ?? (() => '1fr');\n this.getDefaultMinWidth = options?.getDefaultMinWidth ?? (() => 75);\n }\n\n /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */\n splitColumnsIntoControlledAndUncontrolled(columns: Array<GridNode<T>>): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>] {\n return columns.reduce((acc, col) => {\n if (col.props.width != null) {\n acc[0].set(col.key, col);\n } else {\n acc[1].set(col.key, col);\n }\n return acc;\n }, [new Map(), new Map()]);\n }\n\n /** Takes uncontrolled and controlled widths and joins them into a single Map. */\n recombineColumns(columns: Array<GridNode<T>>, uncontrolledWidths: Map<Key, ColumnSize>, uncontrolledColumns: Map<Key, GridNode<T>>, controlledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(columns.map(col => {\n if (uncontrolledColumns.has(col.key)) {\n return [col.key, uncontrolledWidths.get(col.key)];\n } else {\n return [col.key, controlledColumns.get(col.key).props.width];\n }\n }));\n }\n\n /** Used to make an initial Map of the uncontrolled widths based on default widths. */\n getInitialUncontrolledWidths(uncontrolledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(Array.from(uncontrolledColumns).map(([key, col]) =>\n [key, col.props.defaultWidth ?? this.getDefaultWidth?.(col) ?? '1fr']\n ));\n }\n\n getColumnWidth(key: Key): number {\n return this.columnWidths.get(key) ?? 0;\n }\n\n getColumnMinWidth(key: Key): number {\n return this.columnMinWidths.get(key) ?? 0;\n }\n\n getColumnMaxWidth(key: Key): number {\n return this.columnMaxWidths.get(key) ?? 0;\n }\n\n resizeColumnWidth(collection: TableCollection<T>, uncontrolledWidths: Map<Key, ColumnSize>, col: Key, width: number): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n let freeze = true;\n let newWidths = new Map<Key, ColumnSize>();\n\n width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));\n\n collection.columns.forEach(column => {\n if (column.key === col) {\n newWidths.set(column.key, width);\n freeze = false;\n } else if (freeze) {\n // freeze columns to the left to their previous pixel value\n newWidths.set(column.key, prevColumnWidths.get(column.key));\n } else {\n newWidths.set(column.key, column.props.width ?? uncontrolledWidths.get(column.key));\n }\n });\n\n return newWidths;\n }\n\n buildColumnWidths(tableWidth: number, collection: TableCollection<T>, widths: Map<Key, ColumnSize>) {\n this.columnWidths = new Map();\n this.columnMinWidths = new Map();\n this.columnMaxWidths = new Map();\n\n // initial layout or table/window resizing\n let columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map(col => ({...col.props, key: col.key})),\n widths,\n (i) => this.getDefaultWidth(collection.columns[i]),\n (i) => this.getDefaultMinWidth(collection.columns[i])\n );\n\n // columns going in will be the same order as the columns coming out\n columnWidths.forEach((width, index) => {\n let key = collection.columns[index].key;\n let column = collection.columns[index];\n this.columnWidths.set(key, width);\n this.columnMinWidths.set(key, getMinWidth(column.props.minWidth ?? this.getDefaultMinWidth(column), tableWidth));\n this.columnMaxWidths.set(key, getMaxWidth(column.props.maxWidth, tableWidth));\n });\n return this.columnWidths;\n }\n}\n"],"names":[],"version":3,"file":"TableColumnLayout.main.js.map"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701} from "./TableUtils.mjs";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2022 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
|
+
class $a9e7ae544a4e41dd$export$7ff77a162970b30e {
|
|
15
|
+
/** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns) {
|
|
16
|
+
return columns.reduce((acc, col)=>{
|
|
17
|
+
if (col.props.width != null) acc[0].set(col.key, col);
|
|
18
|
+
else acc[1].set(col.key, col);
|
|
19
|
+
return acc;
|
|
20
|
+
}, [
|
|
21
|
+
new Map(),
|
|
22
|
+
new Map()
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
|
|
26
|
+
return new Map(columns.map((col)=>{
|
|
27
|
+
if (uncontrolledColumns.has(col.key)) return [
|
|
28
|
+
col.key,
|
|
29
|
+
uncontrolledWidths.get(col.key)
|
|
30
|
+
];
|
|
31
|
+
else return [
|
|
32
|
+
col.key,
|
|
33
|
+
controlledColumns.get(col.key).props.width
|
|
34
|
+
];
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns) {
|
|
38
|
+
return new Map(Array.from(uncontrolledColumns).map(([key, col])=>{
|
|
39
|
+
var _this_getDefaultWidth, _this;
|
|
40
|
+
var _col_props_defaultWidth, _ref;
|
|
41
|
+
return [
|
|
42
|
+
key,
|
|
43
|
+
(_ref = (_col_props_defaultWidth = col.props.defaultWidth) !== null && _col_props_defaultWidth !== void 0 ? _col_props_defaultWidth : (_this_getDefaultWidth = (_this = this).getDefaultWidth) === null || _this_getDefaultWidth === void 0 ? void 0 : _this_getDefaultWidth.call(_this, col)) !== null && _ref !== void 0 ? _ref : '1fr'
|
|
44
|
+
];
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
getColumnWidth(key) {
|
|
48
|
+
var _this_columnWidths_get;
|
|
49
|
+
return (_this_columnWidths_get = this.columnWidths.get(key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
|
|
50
|
+
}
|
|
51
|
+
getColumnMinWidth(key) {
|
|
52
|
+
var _this_columnMinWidths_get;
|
|
53
|
+
return (_this_columnMinWidths_get = this.columnMinWidths.get(key)) !== null && _this_columnMinWidths_get !== void 0 ? _this_columnMinWidths_get : 0;
|
|
54
|
+
}
|
|
55
|
+
getColumnMaxWidth(key) {
|
|
56
|
+
var _this_columnMaxWidths_get;
|
|
57
|
+
return (_this_columnMaxWidths_get = this.columnMaxWidths.get(key)) !== null && _this_columnMaxWidths_get !== void 0 ? _this_columnMaxWidths_get : 0;
|
|
58
|
+
}
|
|
59
|
+
resizeColumnWidth(collection, uncontrolledWidths, col, width) {
|
|
60
|
+
let prevColumnWidths = this.columnWidths;
|
|
61
|
+
let freeze = true;
|
|
62
|
+
let newWidths = new Map();
|
|
63
|
+
width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
|
|
64
|
+
collection.columns.forEach((column)=>{
|
|
65
|
+
var _column_props_width;
|
|
66
|
+
if (column.key === col) {
|
|
67
|
+
newWidths.set(column.key, width);
|
|
68
|
+
freeze = false;
|
|
69
|
+
} else if (freeze) // freeze columns to the left to their previous pixel value
|
|
70
|
+
newWidths.set(column.key, prevColumnWidths.get(column.key));
|
|
71
|
+
else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key));
|
|
72
|
+
});
|
|
73
|
+
return newWidths;
|
|
74
|
+
}
|
|
75
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
76
|
+
this.columnWidths = new Map();
|
|
77
|
+
this.columnMinWidths = new Map();
|
|
78
|
+
this.columnMaxWidths = new Map();
|
|
79
|
+
// initial layout or table/window resizing
|
|
80
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
81
|
+
...col.props,
|
|
82
|
+
key: col.key
|
|
83
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
84
|
+
// columns going in will be the same order as the columns coming out
|
|
85
|
+
columnWidths.forEach((width, index)=>{
|
|
86
|
+
let key = collection.columns[index].key;
|
|
87
|
+
let column = collection.columns[index];
|
|
88
|
+
this.columnWidths.set(key, width);
|
|
89
|
+
var _column_props_minWidth;
|
|
90
|
+
this.columnMinWidths.set(key, (0, $6818b1c4fc67028d$export$f556054ce4358701)((_column_props_minWidth = column.props.minWidth) !== null && _column_props_minWidth !== void 0 ? _column_props_minWidth : this.getDefaultMinWidth(column), tableWidth));
|
|
91
|
+
this.columnMaxWidths.set(key, (0, $6818b1c4fc67028d$export$59185c62a7544aa0)(column.props.maxWidth, tableWidth));
|
|
92
|
+
});
|
|
93
|
+
return this.columnWidths;
|
|
94
|
+
}
|
|
95
|
+
constructor(options){
|
|
96
|
+
this.columnWidths = new Map();
|
|
97
|
+
this.columnMinWidths = new Map();
|
|
98
|
+
this.columnMaxWidths = new Map();
|
|
99
|
+
var _options_getDefaultWidth;
|
|
100
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>'1fr';
|
|
101
|
+
var _options_getDefaultMinWidth;
|
|
102
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
export {$a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout};
|
|
108
|
+
//# sourceMappingURL=TableColumnLayout.module.js.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701} from "./TableUtils.module.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2022 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
|
+
class $a9e7ae544a4e41dd$export$7ff77a162970b30e {
|
|
15
|
+
/** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns) {
|
|
16
|
+
return columns.reduce((acc, col)=>{
|
|
17
|
+
if (col.props.width != null) acc[0].set(col.key, col);
|
|
18
|
+
else acc[1].set(col.key, col);
|
|
19
|
+
return acc;
|
|
20
|
+
}, [
|
|
21
|
+
new Map(),
|
|
22
|
+
new Map()
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
|
|
26
|
+
return new Map(columns.map((col)=>{
|
|
27
|
+
if (uncontrolledColumns.has(col.key)) return [
|
|
28
|
+
col.key,
|
|
29
|
+
uncontrolledWidths.get(col.key)
|
|
30
|
+
];
|
|
31
|
+
else return [
|
|
32
|
+
col.key,
|
|
33
|
+
controlledColumns.get(col.key).props.width
|
|
34
|
+
];
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns) {
|
|
38
|
+
return new Map(Array.from(uncontrolledColumns).map(([key, col])=>{
|
|
39
|
+
var _this_getDefaultWidth, _this;
|
|
40
|
+
var _col_props_defaultWidth, _ref;
|
|
41
|
+
return [
|
|
42
|
+
key,
|
|
43
|
+
(_ref = (_col_props_defaultWidth = col.props.defaultWidth) !== null && _col_props_defaultWidth !== void 0 ? _col_props_defaultWidth : (_this_getDefaultWidth = (_this = this).getDefaultWidth) === null || _this_getDefaultWidth === void 0 ? void 0 : _this_getDefaultWidth.call(_this, col)) !== null && _ref !== void 0 ? _ref : '1fr'
|
|
44
|
+
];
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
getColumnWidth(key) {
|
|
48
|
+
var _this_columnWidths_get;
|
|
49
|
+
return (_this_columnWidths_get = this.columnWidths.get(key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
|
|
50
|
+
}
|
|
51
|
+
getColumnMinWidth(key) {
|
|
52
|
+
var _this_columnMinWidths_get;
|
|
53
|
+
return (_this_columnMinWidths_get = this.columnMinWidths.get(key)) !== null && _this_columnMinWidths_get !== void 0 ? _this_columnMinWidths_get : 0;
|
|
54
|
+
}
|
|
55
|
+
getColumnMaxWidth(key) {
|
|
56
|
+
var _this_columnMaxWidths_get;
|
|
57
|
+
return (_this_columnMaxWidths_get = this.columnMaxWidths.get(key)) !== null && _this_columnMaxWidths_get !== void 0 ? _this_columnMaxWidths_get : 0;
|
|
58
|
+
}
|
|
59
|
+
resizeColumnWidth(collection, uncontrolledWidths, col, width) {
|
|
60
|
+
let prevColumnWidths = this.columnWidths;
|
|
61
|
+
let freeze = true;
|
|
62
|
+
let newWidths = new Map();
|
|
63
|
+
width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
|
|
64
|
+
collection.columns.forEach((column)=>{
|
|
65
|
+
var _column_props_width;
|
|
66
|
+
if (column.key === col) {
|
|
67
|
+
newWidths.set(column.key, width);
|
|
68
|
+
freeze = false;
|
|
69
|
+
} else if (freeze) // freeze columns to the left to their previous pixel value
|
|
70
|
+
newWidths.set(column.key, prevColumnWidths.get(column.key));
|
|
71
|
+
else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key));
|
|
72
|
+
});
|
|
73
|
+
return newWidths;
|
|
74
|
+
}
|
|
75
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
76
|
+
this.columnWidths = new Map();
|
|
77
|
+
this.columnMinWidths = new Map();
|
|
78
|
+
this.columnMaxWidths = new Map();
|
|
79
|
+
// initial layout or table/window resizing
|
|
80
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
81
|
+
...col.props,
|
|
82
|
+
key: col.key
|
|
83
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
84
|
+
// columns going in will be the same order as the columns coming out
|
|
85
|
+
columnWidths.forEach((width, index)=>{
|
|
86
|
+
let key = collection.columns[index].key;
|
|
87
|
+
let column = collection.columns[index];
|
|
88
|
+
this.columnWidths.set(key, width);
|
|
89
|
+
var _column_props_minWidth;
|
|
90
|
+
this.columnMinWidths.set(key, (0, $6818b1c4fc67028d$export$f556054ce4358701)((_column_props_minWidth = column.props.minWidth) !== null && _column_props_minWidth !== void 0 ? _column_props_minWidth : this.getDefaultMinWidth(column), tableWidth));
|
|
91
|
+
this.columnMaxWidths.set(key, (0, $6818b1c4fc67028d$export$59185c62a7544aa0)(column.props.maxWidth, tableWidth));
|
|
92
|
+
});
|
|
93
|
+
return this.columnWidths;
|
|
94
|
+
}
|
|
95
|
+
constructor(options){
|
|
96
|
+
this.columnWidths = new Map();
|
|
97
|
+
this.columnMinWidths = new Map();
|
|
98
|
+
this.columnMaxWidths = new Map();
|
|
99
|
+
var _options_getDefaultWidth;
|
|
100
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>'1fr';
|
|
101
|
+
var _options_getDefaultMinWidth;
|
|
102
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
|
|
103
|
+
}
|
|
104
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cesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n calculateColumnSizes,\n getMaxWidth,\n getMinWidth\n} from './TableUtils';\nimport {ColumnSize, TableCollection} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\nexport interface TableColumnLayoutOptions<T> {\n getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined,\n getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined\n}\n\nexport class TableColumnLayout<T> {\n getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n columnWidths: Map<Key, number> = new Map();\n columnMinWidths: Map<Key, number> = new Map();\n columnMaxWidths: Map<Key, number> = new Map();\n\n constructor(options: TableColumnLayoutOptions<T>) {\n this.getDefaultWidth = options?.getDefaultWidth ?? (() => '1fr');\n this.getDefaultMinWidth = options?.getDefaultMinWidth ?? (() => 75);\n }\n\n /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */\n splitColumnsIntoControlledAndUncontrolled(columns: Array<GridNode<T>>): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>] {\n return columns.reduce((acc, col) => {\n if (col.props.width != null) {\n acc[0].set(col.key, col);\n } else {\n acc[1].set(col.key, col);\n }\n return acc;\n }, [new Map(), new Map()]);\n }\n\n /** Takes uncontrolled and controlled widths and joins them into a single Map. */\n recombineColumns(columns: Array<GridNode<T>>, uncontrolledWidths: Map<Key, ColumnSize>, uncontrolledColumns: Map<Key, GridNode<T>>, controlledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(columns.map(col => {\n if (uncontrolledColumns.has(col.key)) {\n return [col.key, uncontrolledWidths.get(col.key)];\n } else {\n return [col.key, controlledColumns.get(col.key).props.width];\n }\n }));\n }\n\n /** Used to make an initial Map of the uncontrolled widths based on default widths. */\n getInitialUncontrolledWidths(uncontrolledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(Array.from(uncontrolledColumns).map(([key, col]) =>\n [key, col.props.defaultWidth ?? this.getDefaultWidth?.(col) ?? '1fr']\n ));\n }\n\n getColumnWidth(key: Key): number {\n return this.columnWidths.get(key) ?? 0;\n }\n\n getColumnMinWidth(key: Key): number {\n return this.columnMinWidths.get(key) ?? 0;\n }\n\n getColumnMaxWidth(key: Key): number {\n return this.columnMaxWidths.get(key) ?? 0;\n }\n\n resizeColumnWidth(collection: TableCollection<T>, uncontrolledWidths: Map<Key, ColumnSize>, col: Key, width: number): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n let freeze = true;\n let newWidths = new Map<Key, ColumnSize>();\n\n width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));\n\n collection.columns.forEach(column => {\n if (column.key === col) {\n newWidths.set(column.key, width);\n freeze = false;\n } else if (freeze) {\n // freeze columns to the left to their previous pixel value\n newWidths.set(column.key, prevColumnWidths.get(column.key));\n } else {\n newWidths.set(column.key, column.props.width ?? uncontrolledWidths.get(column.key));\n }\n });\n\n return newWidths;\n }\n\n buildColumnWidths(tableWidth: number, collection: TableCollection<T>, widths: Map<Key, ColumnSize>) {\n this.columnWidths = new Map();\n this.columnMinWidths = new Map();\n this.columnMaxWidths = new Map();\n\n // initial layout or table/window resizing\n let columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map(col => ({...col.props, key: col.key})),\n widths,\n (i) => this.getDefaultWidth(collection.columns[i]),\n (i) => this.getDefaultMinWidth(collection.columns[i])\n );\n\n // columns going in will be the same order as the columns coming out\n columnWidths.forEach((width, index) => {\n let key = collection.columns[index].key;\n let column = collection.columns[index];\n this.columnWidths.set(key, width);\n this.columnMinWidths.set(key, getMinWidth(column.props.minWidth ?? this.getDefaultMinWidth(column), tableWidth));\n this.columnMaxWidths.set(key, getMaxWidth(column.props.maxWidth, tableWidth));\n });\n return this.columnWidths;\n }\n}\n"],"names":[],"version":3,"file":"TableColumnLayout.module.js.map"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var $kcTb5$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, "TableHeader", () => $f45775f5d6f744fa$export$f850895b287ef28e);
|
|
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 $f45775f5d6f744fa$var$TableHeader(props) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
$f45775f5d6f744fa$var$TableHeader.getCollectionNode = function* getCollectionNode(props, context) {
|
|
28
|
+
let { children: children, columns: columns } = props;
|
|
29
|
+
// Clear columns so they aren't double added in strict mode.
|
|
30
|
+
context.columns = [];
|
|
31
|
+
if (typeof children === 'function') {
|
|
32
|
+
if (!columns) throw new Error('props.children was a function but props.columns is missing');
|
|
33
|
+
for (let column of columns)yield {
|
|
34
|
+
type: 'column',
|
|
35
|
+
value: column,
|
|
36
|
+
renderer: children
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
let columns = [];
|
|
40
|
+
(0, ($parcel$interopDefault($kcTb5$react))).Children.forEach(children, (column)=>{
|
|
41
|
+
columns.push({
|
|
42
|
+
type: 'column',
|
|
43
|
+
element: column
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
yield* columns;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A TableHeader is a container for the Column elements in a Table. Columns can be statically defined
|
|
51
|
+
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
52
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
|
53
|
+
let $f45775f5d6f744fa$export$f850895b287ef28e = $f45775f5d6f744fa$var$TableHeader;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=TableHeader.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAOD,SAAS,kCAAe,KAA0B;IAChD,OAAO;AACT;AAEA,kCAAY,iBAAiB,GAAG,UAAU,kBAAqB,KAA0B,EAAE,OAAoC;IAC7H,IAAI,YAAC,QAAQ,WAAE,OAAO,EAAC,GAAG;IAE1B,4DAA4D;IAC5D,QAAQ,OAAO,GAAG,EAAE;IAEpB,IAAI,OAAO,aAAa,YAAY;QAClC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM;QAGlB,KAAK,IAAI,UAAU,QACjB,MAAM;YACJ,MAAM;YACN,OAAO;YACP,UAAU;QACZ;IAEJ,OAAO;QACL,IAAI,UAA4B,EAAE;QAClC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;YAC/B,QAAQ,IAAI,CAAC;gBACX,MAAM;gBACN,SAAS;YACX;QACF;QAEA,OAAO;IACT;AACF;AAEA;;;CAGC,GACD,oEAAoE;AACpE,IAAI,4CAAe","sources":["packages/@react-stately/table/src/TableHeader.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 {TableHeaderProps} from '@react-types/table';\n\nfunction TableHeader<T>(props: TableHeaderProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableHeader.getCollectionNode = function* getCollectionNode<T>(props: TableHeaderProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>, void, any> {\n let {children, columns} = props;\n\n // Clear columns so they aren't double added in strict mode.\n context.columns = [];\n\n if (typeof children === 'function') {\n if (!columns) {\n throw new Error('props.children was a function but props.columns is missing');\n }\n\n for (let column of columns) {\n yield {\n type: 'column',\n value: column,\n renderer: children\n };\n }\n } else {\n let columns: PartialNode<T>[] = [];\n React.Children.forEach(children, column => {\n columns.push({\n type: 'column',\n element: column\n });\n });\n\n yield* columns;\n }\n};\n\n/**\n * A TableHeader is a container for the Column elements in a Table. Columns can be statically defined\n * as children, or generated dynamically using a function based on the data passed to the `columns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TableHeader = TableHeader as <T>(props: TableHeaderProps<T>) => JSX.Element;\nexport {_TableHeader as TableHeader};\n"],"names":[],"version":3,"file":"TableHeader.main.js.map"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import $20k3Y$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 $312ae3b56a94a86e$var$TableHeader(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$312ae3b56a94a86e$var$TableHeader.getCollectionNode = function* getCollectionNode(props, context) {
|
|
18
|
+
let { children: children, columns: columns } = props;
|
|
19
|
+
// Clear columns so they aren't double added in strict mode.
|
|
20
|
+
context.columns = [];
|
|
21
|
+
if (typeof children === 'function') {
|
|
22
|
+
if (!columns) throw new Error('props.children was a function but props.columns is missing');
|
|
23
|
+
for (let column of columns)yield {
|
|
24
|
+
type: 'column',
|
|
25
|
+
value: column,
|
|
26
|
+
renderer: children
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
let columns = [];
|
|
30
|
+
(0, $20k3Y$react).Children.forEach(children, (column)=>{
|
|
31
|
+
columns.push({
|
|
32
|
+
type: 'column',
|
|
33
|
+
element: column
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
yield* columns;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A TableHeader is a container for the Column elements in a Table. Columns can be statically defined
|
|
41
|
+
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
42
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
|
43
|
+
let $312ae3b56a94a86e$export$f850895b287ef28e = $312ae3b56a94a86e$var$TableHeader;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export {$312ae3b56a94a86e$export$f850895b287ef28e as TableHeader};
|
|
47
|
+
//# sourceMappingURL=TableHeader.module.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import $20k3Y$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 $312ae3b56a94a86e$var$TableHeader(props) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
$312ae3b56a94a86e$var$TableHeader.getCollectionNode = function* getCollectionNode(props, context) {
|
|
18
|
+
let { children: children, columns: columns } = props;
|
|
19
|
+
// Clear columns so they aren't double added in strict mode.
|
|
20
|
+
context.columns = [];
|
|
21
|
+
if (typeof children === 'function') {
|
|
22
|
+
if (!columns) throw new Error('props.children was a function but props.columns is missing');
|
|
23
|
+
for (let column of columns)yield {
|
|
24
|
+
type: 'column',
|
|
25
|
+
value: column,
|
|
26
|
+
renderer: children
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
let columns = [];
|
|
30
|
+
(0, $20k3Y$react).Children.forEach(children, (column)=>{
|
|
31
|
+
columns.push({
|
|
32
|
+
type: 'column',
|
|
33
|
+
element: column
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
yield* columns;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A TableHeader is a container for the Column elements in a Table. Columns can be statically defined
|
|
41
|
+
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
42
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
|
43
|
+
let $312ae3b56a94a86e$export$f850895b287ef28e = $312ae3b56a94a86e$var$TableHeader;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export {$312ae3b56a94a86e$export$f850895b287ef28e as TableHeader};
|
|
47
|
+
//# sourceMappingURL=TableHeader.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAOD,SAAS,kCAAe,KAA0B;IAChD,OAAO;AACT;AAEA,kCAAY,iBAAiB,GAAG,UAAU,kBAAqB,KAA0B,EAAE,OAAoC;IAC7H,IAAI,YAAC,QAAQ,WAAE,OAAO,EAAC,GAAG;IAE1B,4DAA4D;IAC5D,QAAQ,OAAO,GAAG,EAAE;IAEpB,IAAI,OAAO,aAAa,YAAY;QAClC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM;QAGlB,KAAK,IAAI,UAAU,QACjB,MAAM;YACJ,MAAM;YACN,OAAO;YACP,UAAU;QACZ;IAEJ,OAAO;QACL,IAAI,UAA4B,EAAE;QAClC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;YAC/B,QAAQ,IAAI,CAAC;gBACX,MAAM;gBACN,SAAS;YACX;QACF;QAEA,OAAO;IACT;AACF;AAEA;;;CAGC,GACD,oEAAoE;AACpE,IAAI,4CAAe","sources":["packages/@react-stately/table/src/TableHeader.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 {TableHeaderProps} from '@react-types/table';\n\nfunction TableHeader<T>(props: TableHeaderProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableHeader.getCollectionNode = function* getCollectionNode<T>(props: TableHeaderProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>, void, any> {\n let {children, columns} = props;\n\n // Clear columns so they aren't double added in strict mode.\n context.columns = [];\n\n if (typeof children === 'function') {\n if (!columns) {\n throw new Error('props.children was a function but props.columns is missing');\n }\n\n for (let column of columns) {\n yield {\n type: 'column',\n value: column,\n renderer: children\n };\n }\n } else {\n let columns: PartialNode<T>[] = [];\n React.Children.forEach(children, column => {\n columns.push({\n type: 'column',\n element: column\n });\n });\n\n yield* columns;\n }\n};\n\n/**\n * A TableHeader is a container for the Column elements in a Table. Columns can be statically defined\n * as children, or generated dynamically using a function based on the data passed to the `columns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TableHeader = TableHeader as <T>(props: TableHeaderProps<T>) => JSX.Element;\nexport {_TableHeader as TableHeader};\n"],"names":[],"version":3,"file":"TableHeader.module.js.map"}
|