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AK,IAAI,CAAC,eAAe,CAAC,WAAW,OAAO,CAAC,EAAE,GAC/C,CAAA,IAAK,IAAI,CAAC,kBAAkB,CAAC,WAAW,OAAO,CAAC,EAAE;QAGpD,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;YAC3B,IAAI,CAAC,eAAe,CAAC,GAAG,CACtB,KACA,CAAA,GAAA,yCAAU,EAAE,OAAO,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,kBAAkB,CAAC,SAAS;YAExE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,yCAAU,EAAE,OAAO,KAAK,CAAC,QAAQ,EAAE;QACnE;QACA,OAAO,IAAI,CAAC,YAAY;IAC1B;AACF","sources":["packages/react-stately/src/table/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 {calculateColumnSizes, getMaxWidth, getMinWidth} from './TableUtils';\nimport {ColumnSize} from './Column';\nimport {GridNode} from '../grid/GridCollection';\nimport {Key} from '@react-types/shared';\nimport {ITableCollection as TableCollection} from './TableCollection';\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 /**\n * Takes an array of columns and splits it into 2 maps of columns with controlled and columns with\n * uncontrolled widths.\n */\n splitColumnsIntoControlledAndUncontrolled(\n columns: Array<GridNode<T>>\n ): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>] {\n return columns.reduce(\n (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 },\n [new Map(), new Map()]\n );\n }\n\n /** Takes uncontrolled and controlled widths and joins them into a single Map. */\n recombineColumns(\n columns: Array<GridNode<T>>,\n uncontrolledWidths: Map<Key, ColumnSize>,\n uncontrolledColumns: Map<Key, GridNode<T>>,\n controlledColumns: Map<Key, GridNode<T>>\n ): Map<Key, ColumnSize> {\n return new Map(\n 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\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(\n Array.from(uncontrolledColumns).map(([key, col]) => [\n key,\n col.props.defaultWidth ?? this.getDefaultWidth?.(col) ?? '1fr'\n ])\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(\n collection: TableCollection<T>,\n uncontrolledWidths: Map<Key, ColumnSize>,\n col: Key,\n width: number\n ): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n let freeze = true;\n let newWidths = new Map<Key, ColumnSize>();\n\n width = Math.max(\n this.getColumnMinWidth(col),\n Math.min(this.getColumnMaxWidth(col), Math.floor(width))\n );\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) ?? 0);\n } else {\n newWidths.set(column.key, column.props.width ?? uncontrolledWidths.get(column.key));\n }\n });\n\n return newWidths;\n }\n\n buildColumnWidths(\n tableWidth: number,\n collection: TableCollection<T>,\n widths: Map<Key, ColumnSize>\n ): Map<Key, number> {\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(\n key,\n getMinWidth(column.props.minWidth ?? this.getDefaultMinWidth(column), tableWidth)\n );\n this.columnMaxWidths.set(key, getMaxWidth(column.props.maxWidth, tableWidth));\n });\n return this.columnWidths;\n }\n}\n"],"names":[],"version":3,"file":"TableColumnLayout.mjs.map"}