d2coreui 23.0.53 → 23.0.55
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/CHANGELOG.md +47 -27
- package/README.md +154 -154
- package/components/date/dateRangeInput.d.ts +5 -0
- package/components/date/dateRangeInput.js +17 -8
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +12 -0
- package/components/date/dateTimeInput.js +36 -4
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/grid/columnUtils.d.ts +3 -1
- package/components/grid/columnUtils.js +4 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.js +31 -26
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/dataGrid.d.ts +32 -14
- package/components/grid/dataGrid.js +30 -14
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +9 -4
- package/components/grid/extendedDataGrid.js +36 -9
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.js +126 -126
- package/components/modal/impl/draggableModalStyles.js.map +1 -1
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/package.json +1 -1
- package/style/index.less +240 -240
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnTransfer.js","sourceRoot":"","sources":["../../../../../components/grid/config/columnTransfer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAe,MAAM,MAAM,CAAA;AACjD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAI1E,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAE3C,gCAAgC;AAChC,MAAM,SAAS,GAAG,CAAC,YAAyB,EAAE,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import React from \"react\";\r\nimport {Transfer, Tree, TreeDataNode} from 'antd'\r\nimport _head from \"lodash/head\";\r\nimport i18n from \"d2core/i18n/i18n\"\r\nimport DragSortingTable from \"d2coreui/components/table/dragSortingTable\";\r\nimport {ColDef, ColumnState, GridApi} from \"ag-grid-community\";\r\nimport {TableRowSelection} from \"antd/es/table/interface\";\r\nimport {TransferItem} from \"antd/lib/transfer\";\r\nimport difference from \"lodash/difference\";\r\n\r\n// Customize ColumnNode Transfer\r\nconst isChecked = (selectedKeys: React.Key[], eventKey: string) => {\r\n return selectedKeys.indexOf(eventKey) !== -1;\r\n};\r\n\r\ntype TreeNodeType = TreeDataNode & ColumnNode;\r\n\r\nfunction generateTree(treeNodes: ColumnNode[] = [], checkedKeys: string[] = []): TreeNodeType[] {\r\n return treeNodes.map(({children, ...props}): TreeNodeType => ({\r\n ...props,\r\n key: props.key as string,\r\n disabled: checkedKeys.includes(props.key as string),\r\n children: generateTree(children, checkedKeys),\r\n }));\r\n}\r\n\r\nfunction generateSimpleTree(treeNodes: ColumnNode[] = []): TreeNodeType[] {\r\n return treeNodes.map(({children, ...props}) => ({\r\n ...props,\r\n key: props.key as string,\r\n children: generateSimpleTree(children)\r\n }));\r\n}\r\n\r\nfunction getColumns(columnDefinitions: ColDef[]): ColumnNode[] {\r\n // noinspection UnnecessaryLocalVariableJS\r\n const columns = columnDefinitions.map((columnDef) => {\r\n const id = columnDef.colId ? columnDef.colId : (columnDef.field ? columnDef.field : \"\");\r\n const group = (columnDef as any).group;\r\n return {\r\n key: id,\r\n title: columnDef.headerName ? columnDef.headerName : \"unknown\",\r\n description: columnDef.headerTooltip,\r\n group: group\r\n };\r\n });\r\n return columns;\r\n}\r\n\r\nfunction getColumnsTree(columns: ColumnNode[], filteredItems: ColumnNode[] | undefined = undefined): ColumnNode[] {\r\n const columnsDefinitionTree: ColumnNode[] = [];\r\n columns.forEach((column) => {\r\n const itemPresent = filteredItems ? (filteredItems.filter((filteredItem) => {\r\n return filteredItem.key === column.key\r\n }).length > 0) : true;\r\n if (!itemPresent) {\r\n return;\r\n }\r\n let parent = _head(columnsDefinitionTree.filter((parentNode) => parentNode.key === (\"_group_\" + column.group)));\r\n if (!parent) {\r\n parent = {key: \"_group_\" + column.group, title: column.group ? column.group : \"unknown\"};\r\n columnsDefinitionTree.push(parent)\r\n }\r\n if (!parent.children) {\r\n parent.children = [];\r\n }\r\n parent.children.push({key: column.key, title: column.title});\r\n });\r\n return columnsDefinitionTree;\r\n}\r\n\r\ninterface ColumnNode extends TransferItem {\r\n group?: string\r\n children?: ColumnNode[]\r\n}\r\n\r\n/** Layout of {@link ColumnTransfer}. */\r\nexport const enum ColumnTransferType {\r\n /** Checkable tree of columns grouped by `DataGridColDef.group`; checking a column shows it. Column order cannot be changed. */\r\n SIMPLE = \"simple\",\r\n /** Two-list transfer: hidden columns as a grouped tree on the left, shown columns on the right, where they can be reordered by drag and drop. */\r\n FULL = \"full\"\r\n}\r\n\r\n/** Properties of {@link ColumnTransfer}. */\r\nexport interface ColumnTransferProps {\r\n /** Column definitions of the grid; a column is identified by `colId`, or by `field` when `colId` is not set, and grouped by its `group` (see `DataGridColDef`). */\r\n columnDefinitions: ColDef[]\r\n /** Current column state of the grid; columns without `hide` are shown as visible. */\r\n columnModel: ColumnState[]\r\n /** API of the grid whose columns are edited; every change is applied to it immediately. */\r\n gridApi: GridApi\r\n /**\r\n * Layout of the editor.\r\n * @default ColumnTransferType.FULL\r\n */\r\n type?: ColumnTransferType,\r\n /** Height in pixels of the {@link ColumnTransferType.FULL} layout; the lists get 100 pixels less. Also forwarded to the antd `Transfer`. */\r\n height?: number\r\n}\r\n\r\n/**\r\n * Editor of the visibility and order of ag-grid columns, used by the grid's column configuration dialog and settings drawer.\r\n * It does not keep its own copy of the changes: showing, hiding and moving a column is applied to `gridApi` at once,\r\n * so the caller re-renders it with the new `columnModel` (e.g. from ag-grid column events).\r\n */\r\nexport default class ColumnTransfer extends React.Component<ColumnTransferProps> {\r\n public static defaultProps = {\r\n type: ColumnTransferType.FULL\r\n };\r\n\r\n constructor(props: Readonly<ColumnTransferProps>) {\r\n super(props);\r\n this.onChange = this.onChange.bind(this);\r\n }\r\n\r\n /** antd `Transfer` change handler: shows (`direction` `\"right\"`) or hides the moved columns; a moved group key applies to all columns of the group. */\r\n onChange(_: React.Key[], direction: string, moveKeys: React.Key[]) {\r\n moveKeys.forEach((columnKey) => {\r\n if (typeof columnKey === \"string\") {\r\n if (columnKey.indexOf(\"_group_\") >= 0) {\r\n const columnsTree: ColumnNode[] = getColumnsTree(getColumns(this.props.columnDefinitions));\r\n const columnGroup: ColumnNode | undefined = _head(columnsTree.filter((columnGroup) => {\r\n return columnGroup.key === columnKey;\r\n }));\r\n if (columnGroup && columnGroup.children) {\r\n columnGroup.children.forEach((column) => {\r\n this.props.gridApi.setColumnsVisible([column.key as string], direction === \"right\");\r\n });\r\n }\r\n } else {\r\n this.props.gridApi.setColumnsVisible([columnKey], direction === \"right\");\r\n }\r\n }\r\n });\r\n };\r\n\r\n render() {\r\n const {columnDefinitions, columnModel, gridApi, type, ...restProps} = this.props;\r\n const columns = getColumns(columnDefinitions);\r\n const visibleColumnIds = columnModel.filter((column) => !column.hide).map((column) => column.colId) as string[];\r\n if (type === ColumnTransferType.SIMPLE) {\r\n const columnsTree = getColumnsTree(columns);\r\n return (<Tree<TreeNodeType>\r\n blockNode\r\n checkable\r\n defaultExpandAll\r\n checkedKeys={visibleColumnIds}\r\n onCheck={(selectedKeys, {node,},) => {\r\n const selectedColumnId: string = (node as any).props?.eventKey ? (node as any).props.eventKey : \"\";\r\n const visible = Array.isArray(selectedKeys) && selectedKeys.indexOf(selectedColumnId) >= 0;\r\n if (selectedColumnId.indexOf(\"_group_\") >= 0) {\r\n const columnGroup: ColumnNode | undefined = _head(columnsTree.filter((columnGroup) => {\r\n return columnGroup.key === selectedColumnId;\r\n }));\r\n if (columnGroup && columnGroup.children) {\r\n columnGroup.children.forEach((column) => {\r\n this.props.gridApi.setColumnsVisible([column.key as string], visible);\r\n });\r\n }\r\n } else {\r\n this.props.gridApi.setColumnsVisible([selectedColumnId], visible);\r\n }\r\n }}\r\n treeData={generateSimpleTree(columnsTree)}\r\n />);\r\n } else {\r\n const titles = [<b>{i18n(\"Hidden Columns\")}:</b>, <b>{i18n(\"Shown Columns\")}:</b>] as unknown as string[]; // special hack to overcome typescript titles attribute in Transfer component could be also [ReactElement, ReactElement]\r\n return (\r\n <Transfer {...restProps}\r\n style={{height: this.props.height, minHeight: 100}}\r\n locale={{\r\n itemUnit: \"\",\r\n itemsUnit: \"\",\r\n notFoundContent: i18n('The column list is empty'),\r\n searchPlaceholder: i18n('Column Name')\r\n }}\r\n targetKeys={visibleColumnIds}\r\n dataSource={columns}\r\n className=\"tree-transfer\"\r\n render={item => item.title ? item.title : null}\r\n showSelectAll={true}\r\n titles={titles}\r\n filterOption={(inputValue, item) => !!item.title && item.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1}\r\n showSearch\r\n onChange={this.onChange}>\r\n {({direction, onItemSelect, selectedKeys, filteredItems, onItemSelectAll}) => {\r\n if (direction === 'left') {\r\n const checkedKeys = [...selectedKeys];\r\n const columnsTree = getColumnsTree(columns, filteredItems);\r\n return (\r\n <div style={{\r\n overflowY: \"auto\",\r\n height: (this.props.height ? this.props.height : 100) - 100\r\n }}>\r\n <Tree<TreeNodeType>\r\n blockNode\r\n checkable\r\n defaultExpandAll\r\n checkedKeys={checkedKeys}\r\n onCheck={(_, {node,},) => {\r\n if ((node as any).props?.eventKey) {\r\n onItemSelect((node as any).props.eventKey, !isChecked(checkedKeys, (node as any).props.eventKey));\r\n }\r\n }}\r\n onSelect={(_, {node},) => {\r\n if ((node as any).props?.eventKey) {\r\n onItemSelect((node as any).props.eventKey, !isChecked(checkedKeys, (node as any).props.eventKey));\r\n }\r\n }}\r\n treeData={generateTree(columnsTree, visibleColumnIds)}\r\n />\r\n </div>\r\n );\r\n } else {\r\n const rowSelection: TableRowSelection<ColumnNode> = {\r\n getCheckboxProps: item => {\r\n return {disabled: !!item.disabled};\r\n },\r\n onSelectAll(selected, selectedRows) {\r\n const treeSelectedKeys = selectedRows\r\n .filter(item => !item.disabled)\r\n .map(({key}) => key);\r\n let diffKeys: any;\r\n if (selected) {\r\n diffKeys = difference(treeSelectedKeys, selectedKeys);\r\n } else {\r\n diffKeys = difference(selectedKeys, treeSelectedKeys);\r\n }\r\n onItemSelectAll(diffKeys, selected);\r\n },\r\n onSelect({key}, selected) {\r\n onItemSelect(key as string, selected);\r\n },\r\n selectedRowKeys: selectedKeys,\r\n };\r\n\r\n return (\r\n <div style={{\r\n overflowY: \"auto\",\r\n height: (this.props.height ? this.props.height : 100) - 100\r\n }}>\r\n <DragSortingTable<ColumnNode>\r\n showHeader={false}\r\n pagination={false}\r\n rowSelection={rowSelection}\r\n columns={[\r\n {\r\n dataIndex: 'title',\r\n title: 'Name',\r\n },\r\n ]}\r\n dataSource={filteredItems}\r\n size=\"small\"\r\n onRow={({key, disabled: itemDisabled}) => ({\r\n onClick: () => {\r\n if (itemDisabled) {\r\n return;\r\n }\r\n onItemSelect(key as string, !selectedKeys.includes(key as string));\r\n },\r\n })}\r\n onMoveRow={(column: ColumnNode, _: number, toIndex: number) => {\r\n this.props.gridApi.moveColumns([column.key as string], toIndex);\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n }}\r\n </Transfer>\r\n );\r\n }\r\n };\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"columnTransfer.js","sourceRoot":"","sources":["../../../../../components/grid/config/columnTransfer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAe,MAAM,MAAM,CAAA;AACjD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAI1E,OAAO,UAAU,MAAM,mBAAm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,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE;gCACL;oCACI,SAAS,EAAE,OAAO;oCAClB,KAAK,EAAE,MAAM;iCAChB;6BACJ,EACD,UAAU,EAAE,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,CAAC,EAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAC,EAAE,EAAE,CAAC,CAAC;gCACvC,OAAO,EAAE,GAAG,EAAE;oCACV,IAAI,YAAY,EAAE,CAAC;wCACf,OAAO;oCACX,CAAC;oCACD,YAAY,CAAC,GAAa,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAa,CAAC,CAAC,CAAC;gCACvE,CAAC;6BACJ,CAAC,EACF,SAAS,EAAE,CAAC,MAAkB,EAAE,CAAS,EAAE,OAAe,EAAE,EAAE;gCAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,GAAa,CAAC,EAAE,OAAO,CAAC,CAAC;4BACpE,CAAC,GACH,CACA,CACT,CAAC;gBACN,CAAC;YACL,CAAC,CACM,CACd,CAAC;QACN,CAAC;IACL,CAAC;IAAA,CAAC;;AAvKY,2BAAY,GAAG;IACzB,IAAI,sCAAyB;CAChC,CAAC;eAHe,cAAc","sourcesContent":["import React from \"react\";\r\nimport {Transfer, Tree, TreeDataNode} from 'antd'\r\nimport _head from \"lodash/head\";\r\nimport i18n from \"d2core/i18n/i18n\"\r\nimport DragSortingTable from \"d2coreui/components/table/dragSortingTable\";\r\nimport {ColDef, ColumnState, GridApi} from \"ag-grid-community\";\r\nimport {TableRowSelection} from \"antd/es/table/interface\";\r\nimport {TransferItem} from \"antd/lib/transfer\";\r\nimport difference from \"lodash/difference\";\r\n\r\n// Customize ColumnNode Transfer\r\nconst isChecked = (selectedKeys: React.Key[], eventKey: string) => {\r\n return selectedKeys.indexOf(eventKey) !== -1;\r\n};\r\n\r\ntype TreeNodeType = TreeDataNode & ColumnNode;\r\n\r\nfunction generateTree(treeNodes: ColumnNode[] = [], checkedKeys: string[] = []): TreeNodeType[] {\r\n return treeNodes.map(({children, ...props}): TreeNodeType => ({\r\n ...props,\r\n key: props.key as string,\r\n disabled: checkedKeys.includes(props.key as string),\r\n children: generateTree(children, checkedKeys),\r\n }));\r\n}\r\n\r\nfunction generateSimpleTree(treeNodes: ColumnNode[] = []): TreeNodeType[] {\r\n return treeNodes.map(({children, ...props}) => ({\r\n ...props,\r\n key: props.key as string,\r\n children: generateSimpleTree(children)\r\n }));\r\n}\r\n\r\nfunction getColumns(columnDefinitions: ColDef[], gridApi: GridApi): ColumnNode[] {\r\n // noinspection UnnecessaryLocalVariableJS\r\n const columns = columnDefinitions.map((columnDef) => {\r\n const id = columnDef.colId ? columnDef.colId : (columnDef.field ? columnDef.field : \"\");\r\n const group = (columnDef as any).group;\r\n const column = id ? gridApi.getColumn(id) : null;\r\n return {\r\n key: id,\r\n title: (column && gridApi.getDisplayNameForColumn(column, \"columnToolPanel\")) || columnDef.headerName || id,\r\n description: columnDef.headerTooltip,\r\n group: group\r\n };\r\n });\r\n return columns;\r\n}\r\n\r\nfunction getColumnsTree(columns: ColumnNode[], filteredItems: ColumnNode[] | undefined = undefined): ColumnNode[] {\r\n const columnsDefinitionTree: ColumnNode[] = [];\r\n columns.forEach((column) => {\r\n const itemPresent = filteredItems ? (filteredItems.filter((filteredItem) => {\r\n return filteredItem.key === column.key\r\n }).length > 0) : true;\r\n if (!itemPresent) {\r\n return;\r\n }\r\n if (!column.group) {\r\n columnsDefinitionTree.push({key: column.key, title: column.title});\r\n return;\r\n }\r\n let parent = _head(columnsDefinitionTree.filter((parentNode) => parentNode.key === (\"_group_\" + column.group)));\r\n if (!parent) {\r\n parent = {key: \"_group_\" + column.group, title: column.group};\r\n columnsDefinitionTree.push(parent)\r\n }\r\n if (!parent.children) {\r\n parent.children = [];\r\n }\r\n parent.children.push({key: column.key, title: column.title});\r\n });\r\n return columnsDefinitionTree;\r\n}\r\n\r\ninterface ColumnNode extends TransferItem {\r\n group?: string\r\n children?: ColumnNode[]\r\n}\r\n\r\n/** Layout of {@link ColumnTransfer}. */\r\nexport const enum ColumnTransferType {\r\n /** Checkable tree of columns grouped by `DataGridColDef.group`; checking a column shows it. Column order cannot be changed. */\r\n SIMPLE = \"simple\",\r\n /** Two-list transfer: hidden columns as a grouped tree on the left, shown columns on the right, where they can be reordered by drag and drop. */\r\n FULL = \"full\"\r\n}\r\n\r\n/** Properties of {@link ColumnTransfer}. */\r\nexport interface ColumnTransferProps {\r\n /** Column definitions of the grid; a column is identified by `colId`, or by `field` when `colId` is not set, and grouped by its `group` (see `DataGridColDef`). */\r\n columnDefinitions: ColDef[]\r\n /** Current column state of the grid; columns without `hide` are shown as visible. */\r\n columnModel: ColumnState[]\r\n /** API of the grid whose columns are edited; every change is applied to it immediately. */\r\n gridApi: GridApi\r\n /**\r\n * Layout of the editor.\r\n * @default ColumnTransferType.FULL\r\n */\r\n type?: ColumnTransferType,\r\n /** Height in pixels of the {@link ColumnTransferType.FULL} layout; the lists get 100 pixels less. Also forwarded to the antd `Transfer`. */\r\n height?: number\r\n}\r\n\r\n/**\r\n * Editor of the visibility and order of ag-grid columns, used by the grid's column configuration dialog and settings drawer.\r\n * It does not keep its own copy of the changes: showing, hiding and moving a column is applied to `gridApi` at once,\r\n * so the caller re-renders it with the new `columnModel` (e.g. from ag-grid column events).\r\n */\r\nexport default class ColumnTransfer extends React.Component<ColumnTransferProps> {\r\n public static defaultProps = {\r\n type: ColumnTransferType.FULL\r\n };\r\n\r\n constructor(props: Readonly<ColumnTransferProps>) {\r\n super(props);\r\n this.onChange = this.onChange.bind(this);\r\n }\r\n\r\n /** antd `Transfer` change handler: shows (`direction` `\"right\"`) or hides the moved columns; a moved group key applies to all columns of the group. */\r\n onChange(_: React.Key[], direction: string, moveKeys: React.Key[]) {\r\n moveKeys.forEach((columnKey) => {\r\n if (typeof columnKey === \"string\") {\r\n if (columnKey.indexOf(\"_group_\") >= 0) {\r\n const columnsTree: ColumnNode[] = getColumnsTree(getColumns(this.props.columnDefinitions, this.props.gridApi));\r\n const columnGroup: ColumnNode | undefined = _head(columnsTree.filter((columnGroup) => {\r\n return columnGroup.key === columnKey;\r\n }));\r\n if (columnGroup && columnGroup.children) {\r\n columnGroup.children.forEach((column) => {\r\n this.props.gridApi.setColumnsVisible([column.key as string], direction === \"right\");\r\n });\r\n }\r\n } else {\r\n this.props.gridApi.setColumnsVisible([columnKey], direction === \"right\");\r\n }\r\n }\r\n });\r\n };\r\n\r\n render() {\r\n const {columnDefinitions, columnModel, gridApi, type, ...restProps} = this.props;\r\n const columns = getColumns(columnDefinitions, gridApi);\r\n const visibleColumnIds = columnModel.filter((column) => !column.hide).map((column) => column.colId) as string[];\r\n if (type === ColumnTransferType.SIMPLE) {\r\n const columnsTree = getColumnsTree(columns);\r\n return (<Tree<TreeNodeType>\r\n blockNode\r\n checkable\r\n defaultExpandAll\r\n checkedKeys={visibleColumnIds}\r\n onCheck={(selectedKeys, {node,},) => {\r\n const selectedColumnId: string = (node as any).props?.eventKey ? (node as any).props.eventKey : \"\";\r\n const visible = Array.isArray(selectedKeys) && selectedKeys.indexOf(selectedColumnId) >= 0;\r\n if (selectedColumnId.indexOf(\"_group_\") >= 0) {\r\n const columnGroup: ColumnNode | undefined = _head(columnsTree.filter((columnGroup) => {\r\n return columnGroup.key === selectedColumnId;\r\n }));\r\n if (columnGroup && columnGroup.children) {\r\n columnGroup.children.forEach((column) => {\r\n this.props.gridApi.setColumnsVisible([column.key as string], visible);\r\n });\r\n }\r\n } else {\r\n this.props.gridApi.setColumnsVisible([selectedColumnId], visible);\r\n }\r\n }}\r\n treeData={generateSimpleTree(columnsTree)}\r\n />);\r\n } else {\r\n const titles = [<b>{i18n(\"Hidden Columns\")}:</b>, <b>{i18n(\"Shown Columns\")}:</b>] as unknown as string[]; // special hack to overcome typescript titles attribute in Transfer component could be also [ReactElement, ReactElement]\r\n return (\r\n <Transfer {...restProps}\r\n style={{height: this.props.height, minHeight: 100}}\r\n locale={{\r\n itemUnit: \"\",\r\n itemsUnit: \"\",\r\n notFoundContent: i18n('The column list is empty'),\r\n searchPlaceholder: i18n('Column Name')\r\n }}\r\n targetKeys={visibleColumnIds}\r\n dataSource={columns}\r\n className=\"tree-transfer\"\r\n render={item => item.title ? item.title : null}\r\n showSelectAll={true}\r\n titles={titles}\r\n filterOption={(inputValue, item) => !!item.title && item.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1}\r\n showSearch\r\n onChange={this.onChange}>\r\n {({direction, onItemSelect, selectedKeys, filteredItems, onItemSelectAll}) => {\r\n if (direction === 'left') {\r\n const checkedKeys = [...selectedKeys];\r\n const columnsTree = getColumnsTree(columns, filteredItems);\r\n const selectNode = (node: ColumnNode, checked: boolean) => {\r\n if (node.children?.length) {\r\n onItemSelectAll(node.children.map((child) => child.key as string), checked);\r\n } else {\r\n onItemSelect(node.key as string, checked);\r\n }\r\n };\r\n return (\r\n <div style={{\r\n overflowY: \"auto\",\r\n height: (this.props.height ? this.props.height : 100) - 100\r\n }}>\r\n <Tree<TreeNodeType>\r\n key={columnsTree.filter((node) => node.children).map((node) => node.key).join()}\r\n blockNode\r\n checkable\r\n defaultExpandAll\r\n checkedKeys={checkedKeys}\r\n onCheck={(_, {node, checked}) => {\r\n selectNode(node, checked);\r\n }}\r\n onSelect={(_, {node}) => {\r\n const keys = node.children?.length ? node.children.map((child) => child.key as string) : [node.key as string];\r\n selectNode(node, !keys.every((key) => isChecked(checkedKeys, key)));\r\n }}\r\n treeData={generateTree(columnsTree, visibleColumnIds)}\r\n />\r\n </div>\r\n );\r\n } else {\r\n const rowSelection: TableRowSelection<ColumnNode> = {\r\n getCheckboxProps: item => {\r\n return {disabled: !!item.disabled};\r\n },\r\n onChange(selectedRowKeys) {\r\n const addedKeys = difference(selectedRowKeys, selectedKeys) as string[];\r\n const removedKeys = difference(selectedKeys, selectedRowKeys) as string[];\r\n if (addedKeys.length > 0) {\r\n onItemSelectAll(addedKeys, true);\r\n }\r\n if (removedKeys.length > 0) {\r\n onItemSelectAll(removedKeys, false);\r\n }\r\n },\r\n preserveSelectedRowKeys: true,\r\n selectedRowKeys: selectedKeys,\r\n };\r\n\r\n return (\r\n <div style={{\r\n overflowY: \"auto\",\r\n height: (this.props.height ? this.props.height : 100) - 100\r\n }}>\r\n <DragSortingTable<ColumnNode>\r\n showHeader={false}\r\n pagination={false}\r\n rowSelection={rowSelection}\r\n columns={[\r\n {\r\n dataIndex: 'title',\r\n title: 'Name',\r\n },\r\n ]}\r\n dataSource={filteredItems}\r\n size=\"small\"\r\n onRow={({key, disabled: itemDisabled}) => ({\r\n onClick: () => {\r\n if (itemDisabled) {\r\n return;\r\n }\r\n onItemSelect(key as string, !selectedKeys.includes(key as string));\r\n },\r\n })}\r\n onMoveRow={(column: ColumnNode, _: number, toIndex: number) => {\r\n this.props.gridApi.moveColumns([column.key as string], toIndex);\r\n }}\r\n />\r\n </div>\r\n );\r\n }\r\n }}\r\n </Transfer>\r\n );\r\n }\r\n };\r\n}\r\n\r\n"]}
|
|
@@ -3,7 +3,7 @@ import { MenuProps } from "antd";
|
|
|
3
3
|
import { AgGridReact } from "ag-grid-react";
|
|
4
4
|
import 'd2coreui/style/ag-grid/aggrid-adaptations.css';
|
|
5
5
|
import { ContextMenuProps, PageOrientation } from "d2coreui/components/grid/export/contextMenu";
|
|
6
|
-
import { CellClassParams, CellFocusedEvent, CellMouseDownEvent, CellMouseOverEvent, ColDef, Column, ColumnEvent, ColumnState, FilterChangedEvent, FilterModifiedEvent, GridApi, GridOptions, GridReadyEvent, IRowNode, PaginationChangedEvent, RowClassParams, RowPinnedType, RowStyle, ViewportChangedEvent } from "ag-grid-community";
|
|
6
|
+
import { CellClassParams, CellFocusedEvent, CellMouseDownEvent, CellMouseOverEvent, ColDef, ColTypeDef, ColGroupDef, Column, ColumnEvent, NewColumnsLoadedEvent, ColumnState, FilterChangedEvent, FilterModifiedEvent, GridApi, GridOptions, GridReadyEvent, IRowNode, PaginationChangedEvent, RowClassParams, RowPinnedType, RowStyle, ViewportChangedEvent } from "ag-grid-community";
|
|
7
7
|
import { GridRowStyle, RowStyleRule } from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
|
|
8
8
|
import ProgressPopup from "d2coreui/components/grid/export/progressPopup";
|
|
9
9
|
import WildcardQuickFilterEngine from "./filter/wildcardQuickFilterEngine";
|
|
@@ -83,6 +83,13 @@ export interface DataGridColDef extends Omit<ColDef, "cellStyle"> {
|
|
|
83
83
|
/** Custom floating filter renderer; used by columns of type `customColumnServerFilter`. */
|
|
84
84
|
renderFilter?: FilterRenderer;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Column group of {@link DataGrid}: a common header above its children, which are adapted like top-level columns.
|
|
88
|
+
* Not to be confused with {@link DataGridColDef.group}, which is the column's category in the columns configuration dialog.
|
|
89
|
+
*/
|
|
90
|
+
export interface DataGridColGroupDef extends Omit<ColGroupDef, "children"> {
|
|
91
|
+
children: (DataGridColDef | DataGridColGroupDef)[];
|
|
92
|
+
}
|
|
86
93
|
/** Column (floating) filter configuration of {@link DataGrid}, see `DataGridProps.filter`. */
|
|
87
94
|
export interface DataGridFilterProps {
|
|
88
95
|
/**
|
|
@@ -143,22 +150,24 @@ export interface DataGridSearchProps {
|
|
|
143
150
|
export type OnLoadDataCallback = (totalRecords: number) => void;
|
|
144
151
|
/**
|
|
145
152
|
* Props of {@link DataGrid}. All other ag-grid `GridOptions` are passed through to `AgGridReact`, with these differences:
|
|
146
|
-
* - `columnDefs` are {@link DataGridColDef}s
|
|
153
|
+
* - `columnDefs` are {@link DataGridColDef}s, optionally wrapped in {@link DataGridColGroupDef}s;
|
|
147
154
|
* - `paginationPageSize` is not available, use `paging.pageSize`;
|
|
148
155
|
* - `getRowStyle` is combined with {@link DataGridProps.rowStyleRules};
|
|
149
156
|
* - `getRowId` is fixed to `String(data.id)`, so every row object must have a unique `id`;
|
|
150
157
|
* - the pagination panel, overlays, header component, column types, `context` and several event handlers are provided
|
|
151
158
|
* by DataGrid (the handlers listed here are still called).
|
|
159
|
+
*
|
|
160
|
+
* @typeParam TData - row data type, passed to the ag-grid `GridOptions` (`rowData`, `getRowId`, events, ...)
|
|
152
161
|
*/
|
|
153
|
-
export interface DataGridProps extends Omit<GridOptions
|
|
162
|
+
export interface DataGridProps<TData = any> extends Omit<GridOptions<TData>, "columnDefs" | "paginationPageSize" | "getRowStyle" | "cellStyle"> {
|
|
154
163
|
/** ag-grid options object passed to `AgGridReact`, e.g. to link grids for the aligned grids feature. */
|
|
155
|
-
gridOptions?: GridOptions
|
|
156
|
-
/** Column definitions; see {@link DataGridColDef} for how they are adapted. */
|
|
157
|
-
columnDefs: DataGridColDef[];
|
|
164
|
+
gridOptions?: GridOptions<TData>;
|
|
165
|
+
/** Column definitions; see {@link DataGridColDef} for how they are adapted. Columns may be wrapped in {@link DataGridColGroupDef}s. */
|
|
166
|
+
columnDefs: (DataGridColDef | DataGridColGroupDef)[];
|
|
158
167
|
/** Passes `columnDefs` to ag-grid unchanged (no header component, cell style or floating filter adaptation); used for aligned grids. */
|
|
159
168
|
disableColumnDefsPreprocessing?: boolean;
|
|
160
169
|
/** Called asynchronously with the adapted column definitions each time they are rebuilt (not called when preprocessing is disabled). */
|
|
161
|
-
onColumnDefsAdapted?(columnDefs: ColDef[]): void;
|
|
170
|
+
onColumnDefsAdapted?(columnDefs: (ColDef | ColGroupDef)[]): void;
|
|
162
171
|
/**
|
|
163
172
|
* Visibility of the advanced table configuration panel (page size, date format, row styles). Controlled: the panel
|
|
164
173
|
* is shown only while this is `true`; update it from {@link DataGridProps.onTableConfigVisible}.
|
|
@@ -308,7 +317,7 @@ export interface DataGridProps extends Omit<GridOptions, "columnDefs" | "paginat
|
|
|
308
317
|
/** Additional row style merged over the style computed from {@link DataGridProps.rowStyleRules}; may return `undefined`. */
|
|
309
318
|
getRowStyle?(params: any): GridRowStyle | undefined;
|
|
310
319
|
/** Ref receiving the underlying `AgGridReact` instance. */
|
|
311
|
-
gridRef?: React.RefObject<AgGridReact
|
|
320
|
+
gridRef?: React.RefObject<AgGridReact<TData>>;
|
|
312
321
|
/**
|
|
313
322
|
* Enables an Excel-like fill handle on the focused cell: dragging from its bottom-right corner selects a cell range
|
|
314
323
|
* and reports it through {@link DataGridProps.onFillHandleComplete}. The grid does not modify any data itself.
|
|
@@ -374,8 +383,12 @@ interface DataGridState {
|
|
|
374
383
|
* onChangeRowStyleRules={setRowStyleRules}
|
|
375
384
|
* onLoadData={(callback) => loadRows().then((rows) => { setRows(rows); callback(rows.length); })}
|
|
376
385
|
* />
|
|
386
|
+
*
|
|
387
|
+
* @typeParam TData - row data type, see {@link DataGridProps}
|
|
377
388
|
*/
|
|
378
|
-
export default class DataGrid extends
|
|
389
|
+
export default class DataGrid<TData extends {
|
|
390
|
+
id: number | string;
|
|
391
|
+
} = any> extends React.Component<DataGridProps<TData>, DataGridState> {
|
|
379
392
|
/** Default `paging` (automatic page size) and `rowStyleRules` ({@link tableDefaultRowStyleRules}). */
|
|
380
393
|
static defaultProps: {
|
|
381
394
|
paging: {
|
|
@@ -390,10 +403,10 @@ export default class DataGrid extends React.Component<DataGridProps, DataGridSta
|
|
|
390
403
|
wildcardQuickFilter: WildcardQuickFilterEngine;
|
|
391
404
|
/** Custom ag-grid column types registered by the grid (see {@link DataGridColDef}). */
|
|
392
405
|
columnTypes: {
|
|
393
|
-
[key: string]:
|
|
406
|
+
[key: string]: ColTypeDef<TData>;
|
|
394
407
|
};
|
|
395
408
|
/** ag-grid API; `undefined` until the grid is ready. */
|
|
396
|
-
gridApi?: GridApi
|
|
409
|
+
gridApi?: GridApi<TData>;
|
|
397
410
|
/** Column state saved when the columns configuration dialog opens, restored when it is cancelled. */
|
|
398
411
|
columnModelBeforeEdit?: ColumnState[];
|
|
399
412
|
/** Row index to focus after the pending page change. */
|
|
@@ -412,7 +425,7 @@ export default class DataGrid extends React.Component<DataGridProps, DataGridSta
|
|
|
412
425
|
*/
|
|
413
426
|
table_context: any;
|
|
414
427
|
private readonly getTheme;
|
|
415
|
-
constructor(props: Readonly<DataGridProps
|
|
428
|
+
constructor(props: Readonly<DataGridProps<TData>>);
|
|
416
429
|
private static getCellValue;
|
|
417
430
|
/**
|
|
418
431
|
* Case-insensitive `textCustomComparator` used by the grid's text filters; `contains` supports `*` and `?` wildcards.
|
|
@@ -420,7 +433,7 @@ export default class DataGrid extends React.Component<DataGridProps, DataGridSta
|
|
|
420
433
|
* @returns whether `value` passes the filter
|
|
421
434
|
*/
|
|
422
435
|
textCustomComparator(filter: string, value: any, filterText: string): boolean;
|
|
423
|
-
componentDidUpdate(prevProps: DataGridProps): void;
|
|
436
|
+
componentDidUpdate(prevProps: DataGridProps<TData>): void;
|
|
424
437
|
componentWillUnmount(): void;
|
|
425
438
|
/**
|
|
426
439
|
* Applies a column state (order, width, visibility, pinning, sorting) to the grid, e.g. one saved from
|
|
@@ -448,7 +461,7 @@ export default class DataGrid extends React.Component<DataGridProps, DataGridSta
|
|
|
448
461
|
/** Synchronizes the table configuration panel visibility with the `tableConfigVisible` prop when it is set. */
|
|
449
462
|
static getDerivedStateFromProps(props: DataGridProps, state: DataGridState): Partial<DataGridState>;
|
|
450
463
|
/** ag-grid `gridReady` handler: stores the grid API, forwards the event to `props.onGridReady` and initializes sort/column state. */
|
|
451
|
-
onGridReady(gridReadyEvent: GridReadyEvent): void;
|
|
464
|
+
onGridReady(gridReadyEvent: GridReadyEvent<TData>): void;
|
|
452
465
|
/**
|
|
453
466
|
* ag-grid `paginationChanged` handler: updates the pager, reports page size changes through
|
|
454
467
|
* `paging.onPaginationChanged`, triggers the initial data load and forwards the event to `props.onPaginationChanged`.
|
|
@@ -486,6 +499,11 @@ export default class DataGrid extends React.Component<DataGridProps, DataGridSta
|
|
|
486
499
|
isActive(): boolean;
|
|
487
500
|
/** Handler of ag-grid column visible/pinned/resized/moved events; stores the column state and calls `props.onColumnsChanged`. */
|
|
488
501
|
onColumnsChanged(event: ColumnEvent): void;
|
|
502
|
+
/**
|
|
503
|
+
* ag-grid `newColumnsLoaded` handler: refreshes the stored column state after `columnDefs` change, without calling
|
|
504
|
+
* `props.onColumnsChanged`, and forwards the event to `props.onNewColumnsLoaded`.
|
|
505
|
+
*/
|
|
506
|
+
onNewColumnsLoaded(event: NewColumnsLoadedEvent): void;
|
|
489
507
|
/**
|
|
490
508
|
* Requests showing/hiding the floating column filters: re-applies `filter.getFilterModel()` and calls
|
|
491
509
|
* `filter.onColumnSearchVisible`; the actual visibility follows `filter.columnSearchVisible`.
|
|
@@ -26,6 +26,7 @@ import LoadingOverlay from "d2coreui/components/grid/panel/loadingOverlay";
|
|
|
26
26
|
import NoRecordsOverlay from "d2coreui/components/grid/panel/noRecordsOverlay";
|
|
27
27
|
import at from "lodash/at";
|
|
28
28
|
import ColumnTransfer from "d2coreui/components/grid/config/columnTransfer";
|
|
29
|
+
import { ColumnUtils } from "d2coreui/components/grid/columnUtils";
|
|
29
30
|
import cloneDeep from "lodash/cloneDeep";
|
|
30
31
|
import { RangeSelector } from "d2coreui/components/grid/cell/rangeSelector";
|
|
31
32
|
import { CellControl } from "d2coreui/components/grid/cell/cellControl";
|
|
@@ -136,6 +137,8 @@ var NavigationEventEnum;
|
|
|
136
137
|
* onChangeRowStyleRules={setRowStyleRules}
|
|
137
138
|
* onLoadData={(callback) => loadRows().then((rows) => { setRows(rows); callback(rows.length); })}
|
|
138
139
|
* />
|
|
140
|
+
*
|
|
141
|
+
* @typeParam TData - row data type, see {@link DataGridProps}
|
|
139
142
|
*/
|
|
140
143
|
class DataGrid extends React.Component {
|
|
141
144
|
constructor(props) {
|
|
@@ -180,6 +183,7 @@ class DataGrid extends React.Component {
|
|
|
180
183
|
this.loadingOverlayRenderer = this.loadingOverlayRenderer.bind(this);
|
|
181
184
|
this.changePagination = this.changePagination.bind(this);
|
|
182
185
|
this.onColumnsChanged = this.onColumnsChanged.bind(this);
|
|
186
|
+
this.onNewColumnsLoaded = this.onNewColumnsLoaded.bind(this);
|
|
183
187
|
this.onFilterModified = this.onFilterModified.bind(this);
|
|
184
188
|
this.onFilterChanged = this.onFilterChanged.bind(this);
|
|
185
189
|
this.onFilterConfirmed = this.onFilterConfirmed.bind(this);
|
|
@@ -910,6 +914,15 @@ class DataGrid extends React.Component {
|
|
|
910
914
|
}
|
|
911
915
|
this.setState({ columnModel: columnModel });
|
|
912
916
|
}
|
|
917
|
+
/**
|
|
918
|
+
* ag-grid `newColumnsLoaded` handler: refreshes the stored column state after `columnDefs` change, without calling
|
|
919
|
+
* `props.onColumnsChanged`, and forwards the event to `props.onNewColumnsLoaded`.
|
|
920
|
+
*/
|
|
921
|
+
onNewColumnsLoaded(event) {
|
|
922
|
+
var _a, _b;
|
|
923
|
+
this.setState({ columnModel: event.api.getColumnState() });
|
|
924
|
+
(_b = (_a = this.props).onNewColumnsLoaded) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
925
|
+
}
|
|
913
926
|
/**
|
|
914
927
|
* Requests showing/hiding the floating column filters: re-applies `filter.getFilterModel()` and calls
|
|
915
928
|
* `filter.onColumnSearchVisible`; the actual visibility follows `filter.columnSearchVisible`.
|
|
@@ -1771,9 +1784,12 @@ class DataGrid extends React.Component {
|
|
|
1771
1784
|
if (disableColumnDefsPreprocessing) {
|
|
1772
1785
|
return columnDefs;
|
|
1773
1786
|
}
|
|
1774
|
-
const
|
|
1787
|
+
const adaptColumnDefs = (columnDefs) => columnDefs.map((columnDef) => {
|
|
1775
1788
|
var _a, _b, _c, _d;
|
|
1776
|
-
|
|
1789
|
+
if ("children" in columnDef) {
|
|
1790
|
+
return Object.assign(Object.assign({}, columnDef), { children: adaptColumnDefs(columnDef.children) });
|
|
1791
|
+
}
|
|
1792
|
+
const { group, floatingFilter, hide, cellEditorPopup, editable, headerComponent, headerComponentParams } = columnDef, rest = __rest(columnDef, ["group", "floatingFilter", "hide", "cellEditorPopup", "editable", "headerComponent", "headerComponentParams"]);
|
|
1777
1793
|
let floatingFilterEnabledForColumn = !!floatingFilter;
|
|
1778
1794
|
if (typeof columnDef.type === "string") {
|
|
1779
1795
|
if (!!((_a = this.columnTypes[columnDef.type]) === null || _a === void 0 ? void 0 : _a.floatingFilter)) {
|
|
@@ -1794,21 +1810,19 @@ class DataGrid extends React.Component {
|
|
|
1794
1810
|
'cell-has-handle': (p) => { var _a, _b; return ((_a = this.state.focusedCell) === null || _a === void 0 ? void 0 : _a.rowIndex) === p.rowIndex && ((_b = this.state.focusedCell) === null || _b === void 0 ? void 0 : _b.colId) === p.colDef.colId && !this.state.isDragging; },
|
|
1795
1811
|
'cell-drag-selected': (params) => (this.state.startCoord !== null && this.state.endCoord !== null) ? this.isInRange(params.rowIndex, params.colDef.colId) : false,
|
|
1796
1812
|
} });
|
|
1797
|
-
})
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1813
|
+
});
|
|
1814
|
+
const adaptedColumnDefs = adaptColumnDefs(columnDefs);
|
|
1815
|
+
setTimeout(() => {
|
|
1816
|
+
var _a, _b;
|
|
1817
|
+
(_b = (_a = this.props).onColumnDefsAdapted) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedColumnDefs);
|
|
1818
|
+
}, 0);
|
|
1804
1819
|
return adaptedColumnDefs;
|
|
1805
1820
|
}
|
|
1806
1821
|
isInRange(rowIndex, colId) {
|
|
1807
|
-
var _a;
|
|
1808
1822
|
const { startCoord, endCoord } = this.state;
|
|
1809
1823
|
if (startCoord === null || endCoord === null)
|
|
1810
1824
|
return false;
|
|
1811
|
-
const allCols =
|
|
1825
|
+
const allCols = this.gridApi.getAllDisplayedColumns().map(c => c.getColId());
|
|
1812
1826
|
const startColIdx = allCols.indexOf(startCoord.colId);
|
|
1813
1827
|
const endColIdx = allCols.indexOf(endCoord.colId);
|
|
1814
1828
|
const currentColIdx = allCols.indexOf(colId);
|
|
@@ -1841,6 +1855,8 @@ class DataGrid extends React.Component {
|
|
|
1841
1855
|
// nejde
|
|
1842
1856
|
const floatingFilterEnabled = !!filter && !!filter.columnSearchVisible;
|
|
1843
1857
|
const adaptedColumnDefs = this.getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, !!disableColumnDefsPreprocessing);
|
|
1858
|
+
// the configuration dialogs list columns only, groups are just headers in the grid
|
|
1859
|
+
const leafColumnDefs = ColumnUtils.getLeafColumnDefs(columnDefs);
|
|
1844
1860
|
const customComponents = this.getCustomComponents(components);
|
|
1845
1861
|
const debugMode = process.env.NODE_ENV === 'development';
|
|
1846
1862
|
const bodyStyle = {
|
|
@@ -1891,7 +1907,7 @@ class DataGrid extends React.Component {
|
|
|
1891
1907
|
React.createElement(ConfigProvider.ConfigContext.Consumer, null, (context) => {
|
|
1892
1908
|
var _a;
|
|
1893
1909
|
const defaultTheme = theme !== null && theme !== void 0 ? theme : this.getTheme((_a = context.theme) === null || _a === void 0 ? void 0 : _a.algorithm, styles.theme);
|
|
1894
|
-
return (React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, ref: gridRef, theme: defaultTheme, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs, rowData: !rowDataManualMode ? rowData : undefined }, passedProperties, { onCellFocused: this.onCellFocused, cellSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", rowSelection: rowSelection, suppressRowClickSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressRowDeselection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressPaginationPanel: true, getRowId: getRowId, maintainColumnOrder: true, components: customComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onCellMouseOver: this.onCellMouseOver, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : headerFilterRowHeight, floatingFiltersHeight: headerFilterRowHeight, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay, quickFilterParser: this.wildcardQuickFilter.quickFilterParser, quickFilterMatcher: this.wildcardQuickFilter.quickFilterMatcher })));
|
|
1910
|
+
return (React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, ref: gridRef, theme: defaultTheme, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs, rowData: !rowDataManualMode ? rowData : undefined }, passedProperties, { onCellFocused: this.onCellFocused, cellSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", rowSelection: rowSelection, suppressRowClickSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressRowDeselection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressPaginationPanel: true, getRowId: getRowId, maintainColumnOrder: true, components: customComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onNewColumnsLoaded: this.onNewColumnsLoaded, onCellMouseOver: this.onCellMouseOver, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : headerFilterRowHeight, floatingFiltersHeight: headerFilterRowHeight, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay, quickFilterParser: this.wildcardQuickFilter.quickFilterParser, quickFilterMatcher: this.wildcardQuickFilter.quickFilterMatcher })));
|
|
1895
1911
|
}),
|
|
1896
1912
|
this.state.loading && this.props.loadingOverlayRenderer &&
|
|
1897
1913
|
React.createElement("div", { className: "ag-overlay", "aria-hidden": "true" },
|
|
@@ -1901,7 +1917,7 @@ class DataGrid extends React.Component {
|
|
|
1901
1917
|
}), tableOverlayRenderer === null || tableOverlayRenderer === void 0 ? void 0 :
|
|
1902
1918
|
tableOverlayRenderer())),
|
|
1903
1919
|
!!this.gridApi && !!this.gridApi && this.state.pageSize !== null &&
|
|
1904
|
-
React.createElement(DataGridEditor, { dataGrid: this, gridApi: this.gridApi, columnDefinitions:
|
|
1920
|
+
React.createElement(DataGridEditor, { dataGrid: this, gridApi: this.gridApi, columnDefinitions: leafColumnDefs, columnModel: this.state.columnModel, visible: !!this.props.tableConfigVisible, onTableConfigVisible: this.showTableConfiguration, paginationPageSize: paging.pageSize, paginationDefaultPageSize: paging.defaultPageSize, currentPageSize: this.state.pageSize, showMilliseconds: !!this.props.showMilliseconds, defaultShowMilliseconds: !!this.props.defaultShowMilliseconds, showYear: !this.props.hideYear, defaultShowYear: !this.props.defaultHideYear, showUtcOffset: !!this.props.showUtcOffset, defaultShowUtcOffset: !!this.props.defaultShowUtcOffset, rowStyleRules: this.props.rowStyleRules, defaultRowStyleRules: this.props.defaultRowStyleRules, onChangeRowStyleRules: onChangeRowStyleRules }),
|
|
1905
1921
|
!!this.gridApi && React.createElement(ModalDialog, { mode: "OK_CANCEL" /* ModalDialogMode.OK_CANCEL */, open: this.state.columnsConfigVisible, initialWidth: 700, initialHeight: this.state.columnTransferHeight, title: React.createElement("span", null,
|
|
1906
1922
|
React.createElement(ControlOutlined, { style: {
|
|
1907
1923
|
color: "#faad14",
|
|
@@ -1920,7 +1936,7 @@ class DataGrid extends React.Component {
|
|
|
1920
1936
|
}, onResize: ({ height }) => {
|
|
1921
1937
|
this.setState({ columnTransferHeight: height });
|
|
1922
1938
|
} },
|
|
1923
|
-
React.createElement(ColumnTransfer, { columnDefinitions:
|
|
1939
|
+
React.createElement(ColumnTransfer, { columnDefinitions: leafColumnDefs, columnModel: this.state.columnModel, gridApi: this.gridApi, height: this.state.columnTransferHeight - 154 }))));
|
|
1924
1940
|
}
|
|
1925
1941
|
}
|
|
1926
1942
|
/** Default `paging` (automatic page size) and `rowStyleRules` ({@link tableDefaultRowStyleRules}). */
|