@react-stately/table 3.11.7-nightly.4555 → 3.11.7-nightly.4560
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 +284 -0
- package/dist/TableCollection.main.js.map +1 -0
- package/dist/TableCollection.mjs +278 -0
- package/dist/TableCollection.module.js +278 -0
- package/dist/TableCollection.module.js.map +1 -0
- package/dist/TableColumnLayout.main.js +162 -0
- package/dist/TableColumnLayout.main.js.map +1 -0
- package/dist/TableColumnLayout.mjs +157 -0
- package/dist/TableColumnLayout.module.js +157 -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 +184 -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 +11 -1216
- package/dist/main.js +21 -1230
- package/dist/main.js.map +1 -1
- package/dist/module.js +11 -1216
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/useTableColumnResizeState.main.js +113 -0
- package/dist/useTableColumnResizeState.main.js.map +1 -0
- package/dist/useTableColumnResizeState.mjs +108 -0
- package/dist/useTableColumnResizeState.module.js +108 -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 +10 -10
|
@@ -0,0 +1,162 @@
|
|
|
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(tableWidth, collection, controlledWidths, uncontrolledWidths, col = null, width) {
|
|
66
|
+
let prevColumnWidths = this.columnWidths;
|
|
67
|
+
// resizing a column
|
|
68
|
+
let resizeIndex = Infinity;
|
|
69
|
+
let resizingChanged = new Map([
|
|
70
|
+
...controlledWidths,
|
|
71
|
+
...uncontrolledWidths
|
|
72
|
+
]);
|
|
73
|
+
let percentKeys = new Map();
|
|
74
|
+
let frKeysToTheRight = new Map();
|
|
75
|
+
let minWidths = new Map();
|
|
76
|
+
// freeze columns to the left to their previous pixel value
|
|
77
|
+
collection.columns.forEach((column, i)=>{
|
|
78
|
+
var _column_props_width_endsWith, _column_props_width;
|
|
79
|
+
let frKey;
|
|
80
|
+
let frValue;
|
|
81
|
+
minWidths.set(column.key, this.getDefaultMinWidth(collection.columns[i]));
|
|
82
|
+
if (col !== column.key && !column.props.width && !(0, $9e5f6a0caf75716e$exports.isStatic)(uncontrolledWidths.get(column.key))) {
|
|
83
|
+
// uncontrolled don't have props.width for us, so instead get from our state
|
|
84
|
+
frKey = column.key;
|
|
85
|
+
frValue = (0, $9e5f6a0caf75716e$exports.parseFractionalUnit)(uncontrolledWidths.get(column.key));
|
|
86
|
+
} else if (col !== column.key && !(0, $9e5f6a0caf75716e$exports.isStatic)(column.props.width) && !uncontrolledWidths.get(column.key)) {
|
|
87
|
+
// controlledWidths will be the same in the collection
|
|
88
|
+
frKey = column.key;
|
|
89
|
+
frValue = (0, $9e5f6a0caf75716e$exports.parseFractionalUnit)(column.props.width);
|
|
90
|
+
} else if (col !== column.key && ((_column_props_width = column.props.width) === null || _column_props_width === void 0 ? void 0 : (_column_props_width_endsWith = _column_props_width.endsWith) === null || _column_props_width_endsWith === void 0 ? void 0 : _column_props_width_endsWith.call(_column_props_width, "%"))) percentKeys.set(column.key, column.props.width);
|
|
91
|
+
// don't freeze columns to the right of the resizing one
|
|
92
|
+
if (resizeIndex < i) {
|
|
93
|
+
if (frKey) frKeysToTheRight.set(frKey, frValue);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// we already know the new size of the resizing column
|
|
97
|
+
if (column.key === col) {
|
|
98
|
+
resizeIndex = i;
|
|
99
|
+
resizingChanged.set(column.key, Math.floor(width));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// freeze column to previous value
|
|
103
|
+
resizingChanged.set(column.key, prevColumnWidths.get(column.key));
|
|
104
|
+
});
|
|
105
|
+
// predict pixels sizes for all columns based on resize
|
|
106
|
+
let columnWidths = (0, $9e5f6a0caf75716e$exports.calculateColumnSizes)(tableWidth, collection.columns.map((col)=>({
|
|
107
|
+
...col.props,
|
|
108
|
+
key: col.key
|
|
109
|
+
})), resizingChanged, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
110
|
+
// set all new column widths for onResize event
|
|
111
|
+
// columns going in will be the same order as the columns coming out
|
|
112
|
+
let newWidths = new Map();
|
|
113
|
+
// set all column widths based on calculateColumnSize
|
|
114
|
+
columnWidths.forEach((width, index)=>{
|
|
115
|
+
let key = collection.columns[index].key;
|
|
116
|
+
newWidths.set(key, width);
|
|
117
|
+
});
|
|
118
|
+
// add FR's back as they were to columns to the right
|
|
119
|
+
Array.from(frKeysToTheRight).forEach(([key])=>{
|
|
120
|
+
newWidths.set(key, `${frKeysToTheRight.get(key)}fr`);
|
|
121
|
+
});
|
|
122
|
+
// put back in percents
|
|
123
|
+
Array.from(percentKeys).forEach(([key, width])=>{
|
|
124
|
+
// resizing locks a column to a px width
|
|
125
|
+
if (key === col) return;
|
|
126
|
+
newWidths.set(key, width);
|
|
127
|
+
});
|
|
128
|
+
return newWidths;
|
|
129
|
+
}
|
|
130
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
131
|
+
this.columnWidths = new Map();
|
|
132
|
+
this.columnMinWidths = new Map();
|
|
133
|
+
this.columnMaxWidths = new Map();
|
|
134
|
+
// initial layout or table/window resizing
|
|
135
|
+
let columnWidths = (0, $9e5f6a0caf75716e$exports.calculateColumnSizes)(tableWidth, collection.columns.map((col)=>({
|
|
136
|
+
...col.props,
|
|
137
|
+
key: col.key
|
|
138
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
139
|
+
// columns going in will be the same order as the columns coming out
|
|
140
|
+
columnWidths.forEach((width, index)=>{
|
|
141
|
+
let key = collection.columns[index].key;
|
|
142
|
+
let column = collection.columns[index];
|
|
143
|
+
this.columnWidths.set(key, width);
|
|
144
|
+
var _column_props_minWidth;
|
|
145
|
+
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));
|
|
146
|
+
this.columnMaxWidths.set(key, (0, $9e5f6a0caf75716e$exports.getMaxWidth)(column.props.maxWidth, tableWidth));
|
|
147
|
+
});
|
|
148
|
+
return this.columnWidths;
|
|
149
|
+
}
|
|
150
|
+
constructor(options){
|
|
151
|
+
this.columnWidths = new Map();
|
|
152
|
+
this.columnMinWidths = new Map();
|
|
153
|
+
this.columnMaxWidths = new Map();
|
|
154
|
+
var _options_getDefaultWidth;
|
|
155
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>"1fr";
|
|
156
|
+
var _options_getDefaultMinWidth;
|
|
157
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=TableColumnLayout.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAkBM,MAAM;IAYX,yHAAyH,GACzH,0CAA0C,OAA2B,EAAkD;QACrH,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK;YAC1B,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,MACrB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE;iBAEpB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE;YAEtB,OAAO;QACT,GAAG;YAAC,IAAI;YAAO,IAAI;SAAM;IAC3B;IAEA,+EAA+E,GAC/E,iBAAiB,OAA2B,EAAE,kBAAwC,EAAE,mBAA0C,EAAE,iBAAwC,EAAwB;QAClM,OAAO,IAAI,IAAI,QAAQ,GAAG,CAAC,CAAA;YACzB,IAAI,oBAAoB,GAAG,CAAC,IAAI,GAAG,GACjC,OAAO;gBAAC,IAAI,GAAG;gBAAE,mBAAmB,GAAG,CAAC,IAAI,GAAG;aAAE;iBAEjD,OAAO;gBAAC,IAAI,GAAG;gBAAE,kBAAkB,GAAG,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,KAAK;aAAC;QAEhE;IACF;IAEA,oFAAoF,GACpF,6BAA6B,mBAA0C,EAAwB;QAC7F,OAAO,IAAI,IAAI,MAAM,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;gBAC5B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AA1C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,qCAAU,EAAE,CAAA,yBAAA,OAAO,KAAK,CAAC,QAAQ,cAArB,oCAAA,yBAAyB,IAAI,CAAC,kBAAkB,CAAC,SAAS;YACpG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,qCAAU,EAAE,OAAO,KAAK,CAAC,QAAQ,EAAE;QACnE;QACA,OAAO,IAAI,CAAC,YAAY;IAC1B;IAjJA,YAAY,OAAoC,CAAE;aAJlD,eAAiC,IAAI;aACrC,kBAAoC,IAAI;aACxC,kBAAoC,IAAI;YAGf;QAAvB,IAAI,CAAC,eAAe,GAAG,CAAA,2BAAA,oBAAA,8BAAA,QAAS,eAAe,cAAxB,sCAAA,2BAA6B,IAAM;YAChC;QAA1B,IAAI,CAAC,kBAAkB,GAAG,CAAA,8BAAA,oBAAA,8BAAA,QAAS,kBAAkB,cAA3B,yCAAA,8BAAgC,IAAM;IAClE;AA+IF","sources":["packages/@react-stately/table/src/TableColumnLayout.ts"],"sourcesContent":["/*\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 isStatic,\n parseFractionalUnit\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(tableWidth: number, collection: TableCollection<T>, controlledWidths: Map<Key, ColumnSize>, uncontrolledWidths: Map<Key, ColumnSize>, col = null, width: number): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n // resizing a column\n let resizeIndex = Infinity;\n let resizingChanged = new Map<Key, ColumnSize>([...controlledWidths, ...uncontrolledWidths]);\n let percentKeys = new Map();\n let frKeysToTheRight = new Map();\n let minWidths = new Map();\n // freeze columns to the left to their previous pixel value\n collection.columns.forEach((column, i) => {\n let frKey;\n let frValue;\n minWidths.set(column.key, this.getDefaultMinWidth(collection.columns[i]));\n if (col !== column.key && !column.props.width && !isStatic(uncontrolledWidths.get(column.key))) {\n // uncontrolled don't have props.width for us, so instead get from our state\n frKey = column.key;\n frValue = parseFractionalUnit(uncontrolledWidths.get(column.key) as string);\n } else if (col !== column.key && !isStatic(column.props.width) && !uncontrolledWidths.get(column.key)) {\n // controlledWidths will be the same in the collection\n frKey = column.key;\n frValue = parseFractionalUnit(column.props.width);\n } else if (col !== column.key && column.props.width?.endsWith?.('%')) {\n percentKeys.set(column.key, column.props.width);\n }\n // don't freeze columns to the right of the resizing one\n if (resizeIndex < i) {\n if (frKey) {\n frKeysToTheRight.set(frKey, frValue);\n }\n return;\n }\n // we already know the new size of the resizing column\n if (column.key === col) {\n resizeIndex = i;\n resizingChanged.set(column.key, Math.floor(width));\n return;\n }\n // freeze column to previous value\n resizingChanged.set(column.key, prevColumnWidths.get(column.key));\n });\n\n // predict pixels sizes for all columns based on resize\n let columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map(col => ({...col.props, key: col.key})),\n resizingChanged,\n (i) => this.getDefaultWidth(collection.columns[i]),\n (i) => this.getDefaultMinWidth(collection.columns[i])\n );\n\n // set all new column widths for onResize event\n // columns going in will be the same order as the columns coming out\n let newWidths = new Map<Key, ColumnSize>();\n // set all column widths based on calculateColumnSize\n columnWidths.forEach((width, index) => {\n let key = collection.columns[index].key;\n newWidths.set(key, width);\n });\n\n // add FR's back as they were to columns to the right\n Array.from(frKeysToTheRight).forEach(([key]) => {\n newWidths.set(key, `${frKeysToTheRight.get(key)}fr`);\n });\n\n // put back in percents\n Array.from(percentKeys).forEach(([key, width]) => {\n // resizing locks a column to a px width\n if (key === col) {\n return;\n }\n newWidths.set(key, width);\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,157 @@
|
|
|
1
|
+
import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701, isStatic as $6818b1c4fc67028d$export$1994a077b98ee0d5, parseFractionalUnit as $6818b1c4fc67028d$export$9078bad4c3934604} 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(tableWidth, collection, controlledWidths, uncontrolledWidths, col = null, width) {
|
|
60
|
+
let prevColumnWidths = this.columnWidths;
|
|
61
|
+
// resizing a column
|
|
62
|
+
let resizeIndex = Infinity;
|
|
63
|
+
let resizingChanged = new Map([
|
|
64
|
+
...controlledWidths,
|
|
65
|
+
...uncontrolledWidths
|
|
66
|
+
]);
|
|
67
|
+
let percentKeys = new Map();
|
|
68
|
+
let frKeysToTheRight = new Map();
|
|
69
|
+
let minWidths = new Map();
|
|
70
|
+
// freeze columns to the left to their previous pixel value
|
|
71
|
+
collection.columns.forEach((column, i)=>{
|
|
72
|
+
var _column_props_width_endsWith, _column_props_width;
|
|
73
|
+
let frKey;
|
|
74
|
+
let frValue;
|
|
75
|
+
minWidths.set(column.key, this.getDefaultMinWidth(collection.columns[i]));
|
|
76
|
+
if (col !== column.key && !column.props.width && !(0, $6818b1c4fc67028d$export$1994a077b98ee0d5)(uncontrolledWidths.get(column.key))) {
|
|
77
|
+
// uncontrolled don't have props.width for us, so instead get from our state
|
|
78
|
+
frKey = column.key;
|
|
79
|
+
frValue = (0, $6818b1c4fc67028d$export$9078bad4c3934604)(uncontrolledWidths.get(column.key));
|
|
80
|
+
} else if (col !== column.key && !(0, $6818b1c4fc67028d$export$1994a077b98ee0d5)(column.props.width) && !uncontrolledWidths.get(column.key)) {
|
|
81
|
+
// controlledWidths will be the same in the collection
|
|
82
|
+
frKey = column.key;
|
|
83
|
+
frValue = (0, $6818b1c4fc67028d$export$9078bad4c3934604)(column.props.width);
|
|
84
|
+
} else if (col !== column.key && ((_column_props_width = column.props.width) === null || _column_props_width === void 0 ? void 0 : (_column_props_width_endsWith = _column_props_width.endsWith) === null || _column_props_width_endsWith === void 0 ? void 0 : _column_props_width_endsWith.call(_column_props_width, "%"))) percentKeys.set(column.key, column.props.width);
|
|
85
|
+
// don't freeze columns to the right of the resizing one
|
|
86
|
+
if (resizeIndex < i) {
|
|
87
|
+
if (frKey) frKeysToTheRight.set(frKey, frValue);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// we already know the new size of the resizing column
|
|
91
|
+
if (column.key === col) {
|
|
92
|
+
resizeIndex = i;
|
|
93
|
+
resizingChanged.set(column.key, Math.floor(width));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// freeze column to previous value
|
|
97
|
+
resizingChanged.set(column.key, prevColumnWidths.get(column.key));
|
|
98
|
+
});
|
|
99
|
+
// predict pixels sizes for all columns based on resize
|
|
100
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
101
|
+
...col.props,
|
|
102
|
+
key: col.key
|
|
103
|
+
})), resizingChanged, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
104
|
+
// set all new column widths for onResize event
|
|
105
|
+
// columns going in will be the same order as the columns coming out
|
|
106
|
+
let newWidths = new Map();
|
|
107
|
+
// set all column widths based on calculateColumnSize
|
|
108
|
+
columnWidths.forEach((width, index)=>{
|
|
109
|
+
let key = collection.columns[index].key;
|
|
110
|
+
newWidths.set(key, width);
|
|
111
|
+
});
|
|
112
|
+
// add FR's back as they were to columns to the right
|
|
113
|
+
Array.from(frKeysToTheRight).forEach(([key])=>{
|
|
114
|
+
newWidths.set(key, `${frKeysToTheRight.get(key)}fr`);
|
|
115
|
+
});
|
|
116
|
+
// put back in percents
|
|
117
|
+
Array.from(percentKeys).forEach(([key, width])=>{
|
|
118
|
+
// resizing locks a column to a px width
|
|
119
|
+
if (key === col) return;
|
|
120
|
+
newWidths.set(key, width);
|
|
121
|
+
});
|
|
122
|
+
return newWidths;
|
|
123
|
+
}
|
|
124
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
125
|
+
this.columnWidths = new Map();
|
|
126
|
+
this.columnMinWidths = new Map();
|
|
127
|
+
this.columnMaxWidths = new Map();
|
|
128
|
+
// initial layout or table/window resizing
|
|
129
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
130
|
+
...col.props,
|
|
131
|
+
key: col.key
|
|
132
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
133
|
+
// columns going in will be the same order as the columns coming out
|
|
134
|
+
columnWidths.forEach((width, index)=>{
|
|
135
|
+
let key = collection.columns[index].key;
|
|
136
|
+
let column = collection.columns[index];
|
|
137
|
+
this.columnWidths.set(key, width);
|
|
138
|
+
var _column_props_minWidth;
|
|
139
|
+
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));
|
|
140
|
+
this.columnMaxWidths.set(key, (0, $6818b1c4fc67028d$export$59185c62a7544aa0)(column.props.maxWidth, tableWidth));
|
|
141
|
+
});
|
|
142
|
+
return this.columnWidths;
|
|
143
|
+
}
|
|
144
|
+
constructor(options){
|
|
145
|
+
this.columnWidths = new Map();
|
|
146
|
+
this.columnMinWidths = new Map();
|
|
147
|
+
this.columnMaxWidths = new Map();
|
|
148
|
+
var _options_getDefaultWidth;
|
|
149
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>"1fr";
|
|
150
|
+
var _options_getDefaultMinWidth;
|
|
151
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export {$a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout};
|
|
157
|
+
//# sourceMappingURL=TableColumnLayout.mjs.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701, isStatic as $6818b1c4fc67028d$export$1994a077b98ee0d5, parseFractionalUnit as $6818b1c4fc67028d$export$9078bad4c3934604} 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(tableWidth, collection, controlledWidths, uncontrolledWidths, col = null, width) {
|
|
60
|
+
let prevColumnWidths = this.columnWidths;
|
|
61
|
+
// resizing a column
|
|
62
|
+
let resizeIndex = Infinity;
|
|
63
|
+
let resizingChanged = new Map([
|
|
64
|
+
...controlledWidths,
|
|
65
|
+
...uncontrolledWidths
|
|
66
|
+
]);
|
|
67
|
+
let percentKeys = new Map();
|
|
68
|
+
let frKeysToTheRight = new Map();
|
|
69
|
+
let minWidths = new Map();
|
|
70
|
+
// freeze columns to the left to their previous pixel value
|
|
71
|
+
collection.columns.forEach((column, i)=>{
|
|
72
|
+
var _column_props_width_endsWith, _column_props_width;
|
|
73
|
+
let frKey;
|
|
74
|
+
let frValue;
|
|
75
|
+
minWidths.set(column.key, this.getDefaultMinWidth(collection.columns[i]));
|
|
76
|
+
if (col !== column.key && !column.props.width && !(0, $6818b1c4fc67028d$export$1994a077b98ee0d5)(uncontrolledWidths.get(column.key))) {
|
|
77
|
+
// uncontrolled don't have props.width for us, so instead get from our state
|
|
78
|
+
frKey = column.key;
|
|
79
|
+
frValue = (0, $6818b1c4fc67028d$export$9078bad4c3934604)(uncontrolledWidths.get(column.key));
|
|
80
|
+
} else if (col !== column.key && !(0, $6818b1c4fc67028d$export$1994a077b98ee0d5)(column.props.width) && !uncontrolledWidths.get(column.key)) {
|
|
81
|
+
// controlledWidths will be the same in the collection
|
|
82
|
+
frKey = column.key;
|
|
83
|
+
frValue = (0, $6818b1c4fc67028d$export$9078bad4c3934604)(column.props.width);
|
|
84
|
+
} else if (col !== column.key && ((_column_props_width = column.props.width) === null || _column_props_width === void 0 ? void 0 : (_column_props_width_endsWith = _column_props_width.endsWith) === null || _column_props_width_endsWith === void 0 ? void 0 : _column_props_width_endsWith.call(_column_props_width, "%"))) percentKeys.set(column.key, column.props.width);
|
|
85
|
+
// don't freeze columns to the right of the resizing one
|
|
86
|
+
if (resizeIndex < i) {
|
|
87
|
+
if (frKey) frKeysToTheRight.set(frKey, frValue);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// we already know the new size of the resizing column
|
|
91
|
+
if (column.key === col) {
|
|
92
|
+
resizeIndex = i;
|
|
93
|
+
resizingChanged.set(column.key, Math.floor(width));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// freeze column to previous value
|
|
97
|
+
resizingChanged.set(column.key, prevColumnWidths.get(column.key));
|
|
98
|
+
});
|
|
99
|
+
// predict pixels sizes for all columns based on resize
|
|
100
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
101
|
+
...col.props,
|
|
102
|
+
key: col.key
|
|
103
|
+
})), resizingChanged, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
104
|
+
// set all new column widths for onResize event
|
|
105
|
+
// columns going in will be the same order as the columns coming out
|
|
106
|
+
let newWidths = new Map();
|
|
107
|
+
// set all column widths based on calculateColumnSize
|
|
108
|
+
columnWidths.forEach((width, index)=>{
|
|
109
|
+
let key = collection.columns[index].key;
|
|
110
|
+
newWidths.set(key, width);
|
|
111
|
+
});
|
|
112
|
+
// add FR's back as they were to columns to the right
|
|
113
|
+
Array.from(frKeysToTheRight).forEach(([key])=>{
|
|
114
|
+
newWidths.set(key, `${frKeysToTheRight.get(key)}fr`);
|
|
115
|
+
});
|
|
116
|
+
// put back in percents
|
|
117
|
+
Array.from(percentKeys).forEach(([key, width])=>{
|
|
118
|
+
// resizing locks a column to a px width
|
|
119
|
+
if (key === col) return;
|
|
120
|
+
newWidths.set(key, width);
|
|
121
|
+
});
|
|
122
|
+
return newWidths;
|
|
123
|
+
}
|
|
124
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
125
|
+
this.columnWidths = new Map();
|
|
126
|
+
this.columnMinWidths = new Map();
|
|
127
|
+
this.columnMaxWidths = new Map();
|
|
128
|
+
// initial layout or table/window resizing
|
|
129
|
+
let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
|
|
130
|
+
...col.props,
|
|
131
|
+
key: col.key
|
|
132
|
+
})), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
|
|
133
|
+
// columns going in will be the same order as the columns coming out
|
|
134
|
+
columnWidths.forEach((width, index)=>{
|
|
135
|
+
let key = collection.columns[index].key;
|
|
136
|
+
let column = collection.columns[index];
|
|
137
|
+
this.columnWidths.set(key, width);
|
|
138
|
+
var _column_props_minWidth;
|
|
139
|
+
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));
|
|
140
|
+
this.columnMaxWidths.set(key, (0, $6818b1c4fc67028d$export$59185c62a7544aa0)(column.props.maxWidth, tableWidth));
|
|
141
|
+
});
|
|
142
|
+
return this.columnWidths;
|
|
143
|
+
}
|
|
144
|
+
constructor(options){
|
|
145
|
+
this.columnWidths = new Map();
|
|
146
|
+
this.columnMinWidths = new Map();
|
|
147
|
+
this.columnMaxWidths = new Map();
|
|
148
|
+
var _options_getDefaultWidth;
|
|
149
|
+
this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>"1fr";
|
|
150
|
+
var _options_getDefaultMinWidth;
|
|
151
|
+
this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export {$a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout};
|
|
157
|
+
//# sourceMappingURL=TableColumnLayout.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAkBM,MAAM;IAYX,yHAAyH,GACzH,0CAA0C,OAA2B,EAAkD;QACrH,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK;YAC1B,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,MACrB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE;iBAEpB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE;YAEtB,OAAO;QACT,GAAG;YAAC,IAAI;YAAO,IAAI;SAAM;IAC3B;IAEA,+EAA+E,GAC/E,iBAAiB,OAA2B,EAAE,kBAAwC,EAAE,mBAA0C,EAAE,iBAAwC,EAAwB;QAClM,OAAO,IAAI,IAAI,QAAQ,GAAG,CAAC,CAAA;YACzB,IAAI,oBAAoB,GAAG,CAAC,IAAI,GAAG,GACjC,OAAO;gBAAC,IAAI,GAAG;gBAAE,mBAAmB,GAAG,CAAC,IAAI,GAAG;aAAE;iBAEjD,OAAO;gBAAC,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AAC,WAAW,OAAO,CAAC,EAAE;QAGtD,oEAAoE;QACpE,aAAa,OAAO,CAAC,CAAC,OAAO;YAC3B,IAAI,MAAM,WAAW,OAAO,CAAC,MAAM,CAAC,GAAG;YACvC,IAAI,SAAS,WAAW,OAAO,CAAC,MAAM;YACtC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK;gBACe;YAA1C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,yCAAU,EAAE,CAAA,yBAAA,OAAO,KAAK,CAAC,QAAQ,cAArB,oCAAA,yBAAyB,IAAI,CAAC,kBAAkB,CAAC,SAAS;YACpG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,yCAAU,EAAE,OAAO,KAAK,CAAC,QAAQ,EAAE;QACnE;QACA,OAAO,IAAI,CAAC,YAAY;IAC1B;IAjJA,YAAY,OAAoC,CAAE;aAJlD,eAAiC,IAAI;aACrC,kBAAoC,IAAI;aACxC,kBAAoC,IAAI;YAGf;QAAvB,IAAI,CAAC,eAAe,GAAG,CAAA,2BAAA,oBAAA,8BAAA,QAAS,eAAe,cAAxB,sCAAA,2BAA6B,IAAM;YAChC;QAA1B,IAAI,CAAC,kBAAkB,GAAG,CAAA,8BAAA,oBAAA,8BAAA,QAAS,kBAAkB,cAA3B,yCAAA,8BAAgC,IAAM;IAClE;AA+IF","sources":["packages/@react-stately/table/src/TableColumnLayout.ts"],"sourcesContent":["/*\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 isStatic,\n parseFractionalUnit\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(tableWidth: number, collection: TableCollection<T>, controlledWidths: Map<Key, ColumnSize>, uncontrolledWidths: Map<Key, ColumnSize>, col = null, width: number): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n // resizing a column\n let resizeIndex = Infinity;\n let resizingChanged = new Map<Key, ColumnSize>([...controlledWidths, ...uncontrolledWidths]);\n let percentKeys = new Map();\n let frKeysToTheRight = new Map();\n let minWidths = new Map();\n // freeze columns to the left to their previous pixel value\n collection.columns.forEach((column, i) => {\n let frKey;\n let frValue;\n minWidths.set(column.key, this.getDefaultMinWidth(collection.columns[i]));\n if (col !== column.key && !column.props.width && !isStatic(uncontrolledWidths.get(column.key))) {\n // uncontrolled don't have props.width for us, so instead get from our state\n frKey = column.key;\n frValue = parseFractionalUnit(uncontrolledWidths.get(column.key) as string);\n } else if (col !== column.key && !isStatic(column.props.width) && !uncontrolledWidths.get(column.key)) {\n // controlledWidths will be the same in the collection\n frKey = column.key;\n frValue = parseFractionalUnit(column.props.width);\n } else if (col !== column.key && column.props.width?.endsWith?.('%')) {\n percentKeys.set(column.key, column.props.width);\n }\n // don't freeze columns to the right of the resizing one\n if (resizeIndex < i) {\n if (frKey) {\n frKeysToTheRight.set(frKey, frValue);\n }\n return;\n }\n // we already know the new size of the resizing column\n if (column.key === col) {\n resizeIndex = i;\n resizingChanged.set(column.key, Math.floor(width));\n return;\n }\n // freeze column to previous value\n resizingChanged.set(column.key, prevColumnWidths.get(column.key));\n });\n\n // predict pixels sizes for all columns based on resize\n let columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map(col => ({...col.props, key: col.key})),\n resizingChanged,\n (i) => this.getDefaultWidth(collection.columns[i]),\n (i) => this.getDefaultMinWidth(collection.columns[i])\n );\n\n // set all new column widths for onResize event\n // columns going in will be the same order as the columns coming out\n let newWidths = new Map<Key, ColumnSize>();\n // set all column widths based on calculateColumnSize\n columnWidths.forEach((width, index) => {\n let key = collection.columns[index].key;\n newWidths.set(key, width);\n });\n\n // add FR's back as they were to columns to the right\n Array.from(frKeysToTheRight).forEach(([key]) => {\n newWidths.set(key, `${frKeysToTheRight.get(key)}fr`);\n });\n\n // put back in percents\n Array.from(percentKeys).forEach(([key, width]) => {\n // resizing locks a column to a px width\n if (key === col) {\n return;\n }\n newWidths.set(key, width);\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.mjs.map
|