d2coreui 23.0.13 → 23.0.15
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/components/clipboard/clipboardUtils.ts +53 -0
- package/components/codemirror/SyntaxHighlighter.tsx +58 -0
- package/components/collapse/expandable.tsx +48 -0
- package/components/color/colorPicker.tsx +121 -0
- package/components/color/colorSwatch.d.ts +18 -13
- package/components/color/colorSwatch.jsx +87 -0
- package/components/color/colorUtils.ts +60 -0
- package/components/date/dateRangeInput.tsx +468 -0
- package/components/date/dateRangeInputAdvancedPanel.tsx +238 -0
- package/components/date/dateRangeInputConfirm.tsx +200 -0
- package/components/date/dateTimeInput.tsx +633 -0
- package/components/date/durationInput.tsx +375 -0
- package/components/form/NiceFormItem.tsx +32 -0
- package/components/grid/cell/beanAccessor.ts +17 -0
- package/components/grid/cell/cellEditorUtils.ts +12 -0
- package/components/grid/cell/customEnumCellEditor.tsx +130 -0
- package/components/grid/cell/dataGridCellEditorComponent.tsx +61 -0
- package/components/grid/cell/dateCellEditor.tsx +83 -0
- package/components/grid/cell/durationCellEditor.tsx +105 -0
- package/components/grid/cell/hexaOctetStringCellEditor.tsx +101 -0
- package/components/grid/cell/hexaValueCellEditor.tsx +92 -0
- package/components/grid/cell/numberCellEditor.tsx +115 -0
- package/components/grid/cell/rangeSelector.d.ts +9 -78
- package/components/grid/cell/rangeSelector.js +674 -527
- package/components/grid/cell/simpleStatusTextCellEditor.tsx +168 -0
- package/components/grid/cell/statusTextCellEditor.tsx +198 -0
- package/components/grid/cell/tableDefaultRowStyleRules.ts +51 -0
- package/components/grid/cell/textCellEditor.tsx +94 -0
- package/components/grid/cell/withAgGridHooks.tsx +15 -0
- package/components/grid/columnUtils.ts +29 -0
- package/components/grid/config/columnTransfer.tsx +258 -0
- package/components/grid/config/dataGridEditor.tsx +328 -0
- package/components/grid/config/rowHeightCalculator.tsx +29 -0
- package/components/grid/config/rowStylePicker.tsx +196 -0
- package/components/grid/dataGrid.tsx +2183 -0
- package/components/grid/detail/detailHeaderPanel.tsx +59 -0
- package/components/grid/export/contextMenu.tsx +154 -0
- package/components/grid/export/progressPopup.tsx +106 -0
- package/components/grid/export/worker/clipboardExport.ts +10 -0
- package/components/grid/export/worker/csvExport.ts +10 -0
- package/components/grid/export/worker/pdfExport.ts +98 -0
- package/components/grid/export/worker/txtExport.ts +21 -0
- package/components/grid/extendedDataGrid.tsx +974 -0
- package/components/grid/filter/customColumnFilter.tsx +14 -0
- package/components/grid/filter/dataGridColumnFilter.tsx +70 -0
- package/components/grid/filter/dateColumnFilter.tsx +34 -0
- package/components/grid/filter/textColumnFilter.tsx +37 -0
- package/components/grid/filter/wildcardQuickFilterEngine.ts +50 -0
- package/components/grid/header/simpleHeader.tsx +270 -0
- package/components/grid/panel/dataGridPagination.tsx +123 -0
- package/components/grid/panel/loadingOverlay.tsx +14 -0
- package/components/grid/panel/noRecordsOverlay.tsx +16 -0
- package/components/grid/panel/tablePagination.tsx +77 -0
- package/components/icons/ant-design-double-right-outline.svg +5 -5
- package/components/icons/ant-design_close-outline.svg +5 -5
- package/components/icons/dropdownArrow.tsx +67 -0
- package/components/icons/undoIcon.tsx +16 -0
- package/components/input/autoCompleteInput.tsx +174 -0
- package/components/input/draftUtils.tsx +62 -0
- package/components/input/draftail.d.ts +186 -1
- package/components/input/draftail.js +1 -2
- package/components/input/hexaFormattedInput.tsx +64 -0
- package/components/input/mask/helpers.ts +154 -0
- package/components/input/mask/inputMaskCore.ts +452 -0
- package/components/input/mask/pattern.ts +122 -0
- package/components/input/maskedInput.tsx +275 -0
- package/components/input/passwordInput.tsx +62 -0
- package/components/input/simpleAutoComplete.tsx +60 -0
- package/components/input/textarea/extractSpansOfClasses.tsx +125 -0
- package/components/input/textarea/getRanges.ts +82 -0
- package/components/input/textarea/getType.ts +23 -0
- package/components/input/textarea/highlighedContents.tsx +20 -0
- package/components/input/textarea/highlightedTextarea.css +61 -0
- package/components/input/textarea/mentionsWithHighlighting.tsx +95 -0
- package/components/keyboard/keyboardUtils.ts +42 -0
- package/components/modal/draggableModalProvider.tsx +37 -0
- package/components/modal/impl/clamp.ts +4 -0
- package/components/modal/impl/draggableModal.tsx +36 -0
- package/components/modal/impl/draggableModalContext.ts +14 -0
- package/components/modal/impl/draggableModalInner.tsx +114 -0
- package/components/modal/impl/draggableModalReducer.ts +285 -0
- package/components/modal/impl/getWindowSize.ts +6 -0
- package/components/modal/impl/index.ts +5 -0
- package/components/modal/impl/resizeHandle.tsx +12 -0
- package/components/modal/impl/useDrag.ts +57 -0
- package/components/modal/impl/usePrevious.ts +11 -0
- package/components/modal/impl/useResize.ts +79 -0
- package/components/modal/modalDialog.tsx +172 -0
- package/components/picker/enumValuePicker.tsx +48 -0
- package/components/platformSpecific.ts +39 -0
- package/components/scrollTo/dom-scroll-into-view.d.ts +1 -0
- package/components/scrollTo/onlyText.ts +36 -0
- package/components/scrollTo/scrollTo.tsx +324 -0
- package/components/style/withCss.tsx +14 -0
- package/components/style/withInputNumberCss.tsx +18 -0
- package/components/svg.d.ts +1 -0
- package/components/table/dragSortingTable.tsx +123 -0
- package/components/text/impl/innerSize.ts +15 -0
- package/components/text/impl/series.ts +37 -0
- package/components/text/impl/shallowEqual.ts +19 -0
- package/components/text/impl/uniqueId.ts +5 -0
- package/components/text/impl/whilst.ts +25 -0
- package/components/text/textFit.tsx +229 -0
- package/i18n/components.cs.json +101 -101
- package/i18n/components.sk.json +101 -101
- package/i18n/components.uk.json +101 -101
- package/i18n/componentsLocaleHolder.js +24 -29
- package/i18n/componentsLocaleLoader.d.ts +9 -0
- package/lib/esm/components/codemirror/SyntaxHighlighter.js.map +1 -0
- package/lib/esm/components/color/colorSwatch.d.ts +13 -0
- package/lib/esm/components/color/colorSwatch.js.map +1 -0
- package/{components → lib/esm/components}/grid/cell/cellEditorUtils.js.map +1 -1
- package/lib/esm/components/grid/cell/rangeSelector.d.ts +78 -0
- package/lib/esm/components/grid/cell/rangeSelector.js +527 -0
- package/lib/esm/components/grid/columnUtils.js.map +1 -0
- package/{components → lib/esm/components}/grid/export/contextMenu.js +4 -4
- package/lib/esm/components/grid/export/progressPopup.js.map +1 -0
- package/{components → lib/esm/components}/grid/export/worker/clipboardExport.js.map +1 -1
- package/{components → lib/esm/components}/grid/export/worker/csvExport.js.map +1 -1
- package/{components → lib/esm/components}/grid/export/worker/txtExport.js.map +1 -1
- package/lib/esm/components/icons/undoIcon.js.map +1 -0
- package/lib/esm/components/input/draftUtils.js.map +1 -0
- package/lib/esm/components/input/draftail.d.ts +1 -0
- package/lib/esm/components/input/draftail.js +2 -0
- package/{components → lib/esm/components}/input/draftail.js.map +1 -1
- package/lib/esm/components/input/mask/inputMaskCore.js.map +1 -0
- package/lib/esm/components/input/mask/pattern.js.map +1 -0
- package/lib/esm/components/input/passwordInput.js.map +1 -0
- package/lib/esm/components/input/textarea/extractSpansOfClasses.js.map +1 -0
- package/lib/esm/components/input/textarea/getRanges.js.map +1 -0
- package/{components → lib/esm/components}/input/textarea/getType.js.map +1 -1
- package/{components → lib/esm/components}/input/textarea/highlighedContents.js.map +1 -1
- package/lib/esm/components/input/textarea/mentionsWithHighlighting.js.map +1 -0
- package/{components → lib/esm/components}/keyboard/keyboardUtils.js.map +1 -1
- package/lib/esm/components/platformSpecific.js.map +1 -0
- package/{components → lib/esm/components}/text/impl/innerSize.js.map +1 -1
- package/lib/esm/components/text/impl/series.js.map +1 -0
- package/{components → lib/esm/components}/text/impl/shallowEqual.js.map +1 -1
- package/{components → lib/esm/components}/text/impl/uniqueId.js.map +1 -1
- package/lib/esm/components/text/impl/whilst.js.map +1 -0
- package/lib/esm/i18n/components.cs.json +101 -0
- package/lib/esm/i18n/components.sk.json +101 -0
- package/lib/esm/i18n/components.uk.json +101 -0
- package/lib/esm/i18n/componentsLocaleHolder.js +29 -0
- package/lib/esm/i18n/componentsLocaleHolder.js.map +1 -0
- package/lib/esm/package.json +70 -0
- package/lib/esm/tsconfig.build.json +24 -0
- package/lib/esm/tsconfig.json +11 -0
- package/package.json +3 -3
- package/style/ag-grid/_ag-theme-antd-vars.scss +194 -194
- package/style/ag-grid/ag-theme-antd.scss +87 -87
- package/style/ag-grid/aggrid-adaptations.css +42 -42
- package/style/ag-grid/aggrid.scss +11 -11
- package/style/flexLayout/flexLayout.scss +130 -130
- package/style/flexLayout/flexLayoutBase.scss +623 -623
- package/style/flexLayout/new/_base.scss +616 -616
- package/style/flexLayout/new/flexLayoutBase.scss +621 -621
- package/style/flexLayout/new/light.scss +107 -107
- package/style/flexLayout/old/_base.scss +551 -551
- package/style/flexLayout/old/light.scss +16 -16
- package/style/form/niceFormItem.css +38 -38
- package/style/loading.css +31 -31
- package/style/splitPane/splitPane.css +48 -48
- package/tsconfig.build.json +24 -24
- package/tsconfig.json +11 -11
- package/components/codemirror/SyntaxHighlighter.js.map +0 -1
- package/components/color/colorSwatch.js.map +0 -1
- package/components/grid/columnUtils.js.map +0 -1
- package/components/grid/export/progressPopup.js.map +0 -1
- package/components/icons/undoIcon.js.map +0 -1
- package/components/input/draftUtils.js.map +0 -1
- package/components/input/mask/inputMaskCore.js.map +0 -1
- package/components/input/mask/pattern.js.map +0 -1
- package/components/input/passwordInput.js.map +0 -1
- package/components/input/textarea/extractSpansOfClasses.js.map +0 -1
- package/components/input/textarea/getRanges.js.map +0 -1
- package/components/input/textarea/mentionsWithHighlighting.js.map +0 -1
- package/components/platformSpecific.js.map +0 -1
- package/components/text/impl/series.js.map +0 -1
- package/components/text/impl/whilst.js.map +0 -1
- package/i18n/componentsLocaleHolder.js.map +0 -1
- /package/{components → lib/esm/components}/clipboard/clipboardUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/clipboard/clipboardUtils.js +0 -0
- /package/{components → lib/esm/components}/clipboard/clipboardUtils.js.map +0 -0
- /package/{components → lib/esm/components}/codemirror/SyntaxHighlighter.d.ts +0 -0
- /package/{components → lib/esm/components}/codemirror/SyntaxHighlighter.js +0 -0
- /package/{components → lib/esm/components}/collapse/expandable.d.ts +0 -0
- /package/{components → lib/esm/components}/collapse/expandable.js +0 -0
- /package/{components → lib/esm/components}/collapse/expandable.js.map +0 -0
- /package/{components → lib/esm/components}/color/colorPicker.d.ts +0 -0
- /package/{components → lib/esm/components}/color/colorPicker.js +0 -0
- /package/{components → lib/esm/components}/color/colorPicker.js.map +0 -0
- /package/{components → lib/esm/components}/color/colorSwatch.js +0 -0
- /package/{components → lib/esm/components}/color/colorUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/color/colorUtils.js +0 -0
- /package/{components → lib/esm/components}/color/colorUtils.js.map +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInput.d.ts +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInput.js +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInput.js.map +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.d.ts +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.js +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputAdvancedPanel.js.map +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputConfirm.d.ts +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputConfirm.js +0 -0
- /package/{components → lib/esm/components}/date/dateRangeInputConfirm.js.map +0 -0
- /package/{components → lib/esm/components}/date/dateTimeInput.d.ts +0 -0
- /package/{components → lib/esm/components}/date/dateTimeInput.js +0 -0
- /package/{components → lib/esm/components}/date/dateTimeInput.js.map +0 -0
- /package/{components → lib/esm/components}/date/durationInput.d.ts +0 -0
- /package/{components → lib/esm/components}/date/durationInput.js +0 -0
- /package/{components → lib/esm/components}/date/durationInput.js.map +0 -0
- /package/{components → lib/esm/components}/form/NiceFormItem.d.ts +0 -0
- /package/{components → lib/esm/components}/form/NiceFormItem.js +0 -0
- /package/{components → lib/esm/components}/form/NiceFormItem.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/beanAccessor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/beanAccessor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/beanAccessor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/cellEditorUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/cellEditorUtils.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/customEnumCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/dataGridCellEditorComponent.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/dateCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/dateCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/dateCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/durationCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/durationCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/durationCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaOctetStringCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/hexaValueCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/numberCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/numberCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/numberCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/rangeSelector.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/simpleStatusTextCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/statusTextCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/tableDefaultRowStyleRules.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/textCellEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/textCellEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/textCellEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.js +0 -0
- /package/{components → lib/esm/components}/grid/cell/withAgGridHooks.js.map +0 -0
- /package/{components → lib/esm/components}/grid/columnUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/columnUtils.js +0 -0
- /package/{components → lib/esm/components}/grid/config/columnTransfer.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/config/columnTransfer.js +0 -0
- /package/{components → lib/esm/components}/grid/config/columnTransfer.js.map +0 -0
- /package/{components → lib/esm/components}/grid/config/dataGridEditor.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/config/dataGridEditor.js +0 -0
- /package/{components → lib/esm/components}/grid/config/dataGridEditor.js.map +0 -0
- /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.js +0 -0
- /package/{components → lib/esm/components}/grid/config/rowHeightCalculator.js.map +0 -0
- /package/{components → lib/esm/components}/grid/config/rowStylePicker.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/config/rowStylePicker.js +0 -0
- /package/{components → lib/esm/components}/grid/config/rowStylePicker.js.map +0 -0
- /package/{components → lib/esm/components}/grid/dataGrid.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/dataGrid.js +0 -0
- /package/{components → lib/esm/components}/grid/dataGrid.js.map +0 -0
- /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.js +0 -0
- /package/{components → lib/esm/components}/grid/detail/detailHeaderPanel.js.map +0 -0
- /package/{components → lib/esm/components}/grid/export/contextMenu.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/contextMenu.js.map +0 -0
- /package/{components → lib/esm/components}/grid/export/progressPopup.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/progressPopup.js +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/clipboardExport.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/clipboardExport.js +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/csvExport.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/csvExport.js +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/pdfExport.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/pdfExport.js +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/pdfExport.js.map +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/txtExport.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/export/worker/txtExport.js +0 -0
- /package/{components → lib/esm/components}/grid/extendedDataGrid.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/extendedDataGrid.js +0 -0
- /package/{components → lib/esm/components}/grid/extendedDataGrid.js.map +0 -0
- /package/{components → lib/esm/components}/grid/filter/customColumnFilter.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/filter/customColumnFilter.js +0 -0
- /package/{components → lib/esm/components}/grid/filter/customColumnFilter.js.map +0 -0
- /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.js +0 -0
- /package/{components → lib/esm/components}/grid/filter/dataGridColumnFilter.js.map +0 -0
- /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.js +0 -0
- /package/{components → lib/esm/components}/grid/filter/dateColumnFilter.js.map +0 -0
- /package/{components → lib/esm/components}/grid/filter/textColumnFilter.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/filter/textColumnFilter.js +0 -0
- /package/{components → lib/esm/components}/grid/filter/textColumnFilter.js.map +0 -0
- /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.js +0 -0
- /package/{components → lib/esm/components}/grid/filter/wildcardQuickFilterEngine.js.map +0 -0
- /package/{components → lib/esm/components}/grid/header/simpleHeader.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/header/simpleHeader.js +0 -0
- /package/{components → lib/esm/components}/grid/header/simpleHeader.js.map +0 -0
- /package/{components → lib/esm/components}/grid/panel/dataGridPagination.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/panel/dataGridPagination.js +0 -0
- /package/{components → lib/esm/components}/grid/panel/dataGridPagination.js.map +0 -0
- /package/{components → lib/esm/components}/grid/panel/loadingOverlay.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/panel/loadingOverlay.js +0 -0
- /package/{components → lib/esm/components}/grid/panel/loadingOverlay.js.map +0 -0
- /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.js +0 -0
- /package/{components → lib/esm/components}/grid/panel/noRecordsOverlay.js.map +0 -0
- /package/{components → lib/esm/components}/grid/panel/tablePagination.d.ts +0 -0
- /package/{components → lib/esm/components}/grid/panel/tablePagination.js +0 -0
- /package/{components → lib/esm/components}/grid/panel/tablePagination.js.map +0 -0
- /package/{components → lib/esm/components}/icons/dropdownArrow.d.ts +0 -0
- /package/{components → lib/esm/components}/icons/dropdownArrow.js +0 -0
- /package/{components → lib/esm/components}/icons/dropdownArrow.js.map +0 -0
- /package/{components → lib/esm/components}/icons/undoIcon.d.ts +0 -0
- /package/{components → lib/esm/components}/icons/undoIcon.js +0 -0
- /package/{components → lib/esm/components}/input/autoCompleteInput.d.ts +0 -0
- /package/{components → lib/esm/components}/input/autoCompleteInput.js +0 -0
- /package/{components → lib/esm/components}/input/autoCompleteInput.js.map +0 -0
- /package/{components → lib/esm/components}/input/draftUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/input/draftUtils.js +0 -0
- /package/{components → lib/esm/components}/input/hexaFormattedInput.d.ts +0 -0
- /package/{components → lib/esm/components}/input/hexaFormattedInput.js +0 -0
- /package/{components → lib/esm/components}/input/hexaFormattedInput.js.map +0 -0
- /package/{components → lib/esm/components}/input/mask/helpers.d.ts +0 -0
- /package/{components → lib/esm/components}/input/mask/helpers.js +0 -0
- /package/{components → lib/esm/components}/input/mask/helpers.js.map +0 -0
- /package/{components → lib/esm/components}/input/mask/inputMaskCore.d.ts +0 -0
- /package/{components → lib/esm/components}/input/mask/inputMaskCore.js +0 -0
- /package/{components → lib/esm/components}/input/mask/pattern.d.ts +0 -0
- /package/{components → lib/esm/components}/input/mask/pattern.js +0 -0
- /package/{components → lib/esm/components}/input/maskedInput.d.ts +0 -0
- /package/{components → lib/esm/components}/input/maskedInput.js +0 -0
- /package/{components → lib/esm/components}/input/maskedInput.js.map +0 -0
- /package/{components → lib/esm/components}/input/passwordInput.d.ts +0 -0
- /package/{components → lib/esm/components}/input/passwordInput.js +0 -0
- /package/{components → lib/esm/components}/input/simpleAutoComplete.d.ts +0 -0
- /package/{components → lib/esm/components}/input/simpleAutoComplete.js +0 -0
- /package/{components → lib/esm/components}/input/simpleAutoComplete.js.map +0 -0
- /package/{components → lib/esm/components}/input/textarea/extractSpansOfClasses.d.ts +0 -0
- /package/{components → lib/esm/components}/input/textarea/extractSpansOfClasses.js +0 -0
- /package/{components → lib/esm/components}/input/textarea/getRanges.d.ts +0 -0
- /package/{components → lib/esm/components}/input/textarea/getRanges.js +0 -0
- /package/{components → lib/esm/components}/input/textarea/getType.d.ts +0 -0
- /package/{components → lib/esm/components}/input/textarea/getType.js +0 -0
- /package/{components → lib/esm/components}/input/textarea/highlighedContents.d.ts +0 -0
- /package/{components → lib/esm/components}/input/textarea/highlighedContents.js +0 -0
- /package/{components → lib/esm/components}/input/textarea/mentionsWithHighlighting.d.ts +0 -0
- /package/{components → lib/esm/components}/input/textarea/mentionsWithHighlighting.js +0 -0
- /package/{components → lib/esm/components}/keyboard/keyboardUtils.d.ts +0 -0
- /package/{components → lib/esm/components}/keyboard/keyboardUtils.js +0 -0
- /package/{components → lib/esm/components}/modal/draggableModalProvider.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/draggableModalProvider.js +0 -0
- /package/{components → lib/esm/components}/modal/draggableModalProvider.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/clamp.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/clamp.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/clamp.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModal.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModal.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModal.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalContext.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalContext.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalContext.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalInner.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalInner.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalInner.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/draggableModalReducer.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/getWindowSize.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/getWindowSize.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/getWindowSize.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/index.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/index.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/index.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/resizeHandle.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/resizeHandle.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/resizeHandle.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/useDrag.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/useDrag.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/useDrag.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/usePrevious.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/usePrevious.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/usePrevious.js.map +0 -0
- /package/{components → lib/esm/components}/modal/impl/useResize.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/impl/useResize.js +0 -0
- /package/{components → lib/esm/components}/modal/impl/useResize.js.map +0 -0
- /package/{components → lib/esm/components}/modal/modalDialog.d.ts +0 -0
- /package/{components → lib/esm/components}/modal/modalDialog.js +0 -0
- /package/{components → lib/esm/components}/modal/modalDialog.js.map +0 -0
- /package/{components → lib/esm/components}/picker/enumValuePicker.d.ts +0 -0
- /package/{components → lib/esm/components}/picker/enumValuePicker.js +0 -0
- /package/{components → lib/esm/components}/picker/enumValuePicker.js.map +0 -0
- /package/{components → lib/esm/components}/platformSpecific.d.ts +0 -0
- /package/{components → lib/esm/components}/platformSpecific.js +0 -0
- /package/{components → lib/esm/components}/scrollTo/onlyText.d.ts +0 -0
- /package/{components → lib/esm/components}/scrollTo/onlyText.js +0 -0
- /package/{components → lib/esm/components}/scrollTo/onlyText.js.map +0 -0
- /package/{components → lib/esm/components}/scrollTo/scrollTo.d.ts +0 -0
- /package/{components → lib/esm/components}/scrollTo/scrollTo.js +0 -0
- /package/{components → lib/esm/components}/scrollTo/scrollTo.js.map +0 -0
- /package/{components → lib/esm/components}/style/withCss.d.ts +0 -0
- /package/{components → lib/esm/components}/style/withCss.js +0 -0
- /package/{components → lib/esm/components}/style/withCss.js.map +0 -0
- /package/{components → lib/esm/components}/style/withInputNumberCss.d.ts +0 -0
- /package/{components → lib/esm/components}/style/withInputNumberCss.js +0 -0
- /package/{components → lib/esm/components}/style/withInputNumberCss.js.map +0 -0
- /package/{components → lib/esm/components}/table/dragSortingTable.d.ts +0 -0
- /package/{components → lib/esm/components}/table/dragSortingTable.js +0 -0
- /package/{components → lib/esm/components}/table/dragSortingTable.js.map +0 -0
- /package/{components → lib/esm/components}/text/impl/innerSize.d.ts +0 -0
- /package/{components → lib/esm/components}/text/impl/innerSize.js +0 -0
- /package/{components → lib/esm/components}/text/impl/series.d.ts +0 -0
- /package/{components → lib/esm/components}/text/impl/series.js +0 -0
- /package/{components → lib/esm/components}/text/impl/shallowEqual.d.ts +0 -0
- /package/{components → lib/esm/components}/text/impl/shallowEqual.js +0 -0
- /package/{components → lib/esm/components}/text/impl/uniqueId.d.ts +0 -0
- /package/{components → lib/esm/components}/text/impl/uniqueId.js +0 -0
- /package/{components → lib/esm/components}/text/impl/whilst.d.ts +0 -0
- /package/{components → lib/esm/components}/text/impl/whilst.js +0 -0
- /package/{components → lib/esm/components}/text/textFit.d.ts +0 -0
- /package/{components → lib/esm/components}/text/textFit.js +0 -0
- /package/{components → lib/esm/components}/text/textFit.js.map +0 -0
- /package/{i18n → lib/esm/i18n}/componentsLocaleHolder.d.ts +0 -0
|
@@ -0,0 +1,2183 @@
|
|
|
1
|
+
import React, {ReactElement} from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ColumnWidthOutlined,
|
|
5
|
+
ControlOutlined,
|
|
6
|
+
DownloadOutlined,
|
|
7
|
+
FileSearchOutlined,
|
|
8
|
+
LoadingOutlined,
|
|
9
|
+
ReloadOutlined,
|
|
10
|
+
SearchOutlined,
|
|
11
|
+
SettingOutlined,
|
|
12
|
+
TableOutlined
|
|
13
|
+
} from "@ant-design/icons";
|
|
14
|
+
import {Button, Card, Dropdown, Empty, MenuProps, Space} from "antd";
|
|
15
|
+
import {AgGridReact} from "ag-grid-react";
|
|
16
|
+
import 'ag-grid-community/styles/ag-grid.css';
|
|
17
|
+
import 'ag-grid-community/styles/ag-theme-balham.css';
|
|
18
|
+
import 'd2coreui/style/ag-grid/aggrid-adaptations.css'
|
|
19
|
+
import TextColumnFilter from "d2coreui/components/grid/filter/textColumnFilter"
|
|
20
|
+
import CustomColumnFilter from "d2coreui/components/grid/filter/customColumnFilter"
|
|
21
|
+
import SimpleHeader from "d2coreui/components/grid/header/simpleHeader"
|
|
22
|
+
import DataGridEditor from "d2coreui/components/grid/config/dataGridEditor";
|
|
23
|
+
import i18n from "d2core/i18n/i18n";
|
|
24
|
+
import AutoCompleteInput from "d2coreui/components/input/autoCompleteInput";
|
|
25
|
+
import isEqual from "lodash/isEqual"
|
|
26
|
+
import getContextMenu, {ContextMenuProps, PageOrientation} from "d2coreui/components/grid/export/contextMenu";
|
|
27
|
+
import LoadingOverlay from "d2coreui/components/grid/panel/loadingOverlay";
|
|
28
|
+
import NoRecordsOverlay from "d2coreui/components/grid/panel/noRecordsOverlay";
|
|
29
|
+
import at from "lodash/at"
|
|
30
|
+
import ColumnTransfer from "d2coreui/components/grid/config/columnTransfer";
|
|
31
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
32
|
+
import escape from "lodash/escape";
|
|
33
|
+
import {RangeSelector} from "d2coreui/components/grid/cell/rangeSelector"
|
|
34
|
+
import {
|
|
35
|
+
_defineModule,
|
|
36
|
+
CellClassParams,
|
|
37
|
+
CellContextMenuEvent,
|
|
38
|
+
CellCtrl,
|
|
39
|
+
CellFocusedEvent,
|
|
40
|
+
CellMouseDownEvent,
|
|
41
|
+
CellPosition,
|
|
42
|
+
ColDef,
|
|
43
|
+
Column,
|
|
44
|
+
ColumnEvent,
|
|
45
|
+
ColumnState,
|
|
46
|
+
FilterChangedEvent,
|
|
47
|
+
FilterModifiedEvent,
|
|
48
|
+
GetQuickFilterTextParams,
|
|
49
|
+
GetRowIdParams,
|
|
50
|
+
GridApi,
|
|
51
|
+
GridOptions,
|
|
52
|
+
GridReadyEvent,
|
|
53
|
+
ICellRendererParams,
|
|
54
|
+
IRowModel,
|
|
55
|
+
IRowNode,
|
|
56
|
+
ModuleRegistry,
|
|
57
|
+
NavigateToNextCellParams,
|
|
58
|
+
PaginationChangedEvent,
|
|
59
|
+
RowClassParams,
|
|
60
|
+
RowDataUpdatedEvent,
|
|
61
|
+
RowNode,
|
|
62
|
+
RowPinnedType,
|
|
63
|
+
RowStyle,
|
|
64
|
+
SortChangedEvent,
|
|
65
|
+
SuppressKeyboardEventParams,
|
|
66
|
+
ValueFormatterParams,
|
|
67
|
+
ValueGetterParams,
|
|
68
|
+
ViewportChangedEvent
|
|
69
|
+
} from "ag-grid-community";
|
|
70
|
+
import {LocaleHolder} from "d2core/i18n/localeHolder";
|
|
71
|
+
import tableDefaultRowStyleRules, {
|
|
72
|
+
GridRowStyle,
|
|
73
|
+
RowStyleRule
|
|
74
|
+
} from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
|
|
75
|
+
import {ModalDialog, ModalDialogMode} from "d2coreui/components/modal/modalDialog";
|
|
76
|
+
import debounce from "lodash/debounce";
|
|
77
|
+
import {Key} from "ts-key-enum";
|
|
78
|
+
import {ClipboardUtils} from "d2coreui/components/clipboard/clipboardUtils";
|
|
79
|
+
import ProgressPopup from "d2coreui/components/grid/export/progressPopup";
|
|
80
|
+
import TimeUtils from "d2core/utils/timeUtils";
|
|
81
|
+
import KeyboardUtils from "d2coreui/components/keyboard/keyboardUtils";
|
|
82
|
+
import NumberCellEditor from "d2coreui/components/grid/cell/numberCellEditor";
|
|
83
|
+
import TextCellEditor from "d2coreui/components/grid/cell/textCellEditor";
|
|
84
|
+
import StatusTextCellEditor from "d2coreui/components/grid/cell/statusTextCellEditor";
|
|
85
|
+
import DateCellEditor from "d2coreui/components/grid/cell/dateCellEditor";
|
|
86
|
+
import memoizeOne from "memoize-one";
|
|
87
|
+
import SimpleStatusTextCellEditor from "d2coreui/components/grid/cell/simpleStatusTextCellEditor";
|
|
88
|
+
import DurationCellEditor from "d2coreui/components/grid/cell/durationCellEditor";
|
|
89
|
+
import CustomEnumCellEditor from "d2coreui/components/grid/cell/customEnumCellEditor";
|
|
90
|
+
import HexaValueCellEditor from "d2coreui/components/grid/cell/hexaValueCellEditor";
|
|
91
|
+
import HexaOctetStringCellEditor from "d2coreui/components/grid/cell/hexaOctetStringCellEditor";
|
|
92
|
+
import ReactDOM from "react-dom";
|
|
93
|
+
import {D2000UnixTimeNullValue, unixTimeToMoment} from "d2core/types/unixTimeUtils";
|
|
94
|
+
import {compileExpression} from "filtrex";
|
|
95
|
+
import DataGridPagination from "./panel/dataGridPagination";
|
|
96
|
+
import {
|
|
97
|
+
calculateLineHeight,
|
|
98
|
+
calculateRowHeight,
|
|
99
|
+
getFontSize,
|
|
100
|
+
getLineHeight,
|
|
101
|
+
getRowHeightDelta,
|
|
102
|
+
GRID_DEFAULT_FONT_SIZE,
|
|
103
|
+
GRID_DEFAULT_ROW_HEIGHT_DELTA
|
|
104
|
+
} from "./config/rowHeightCalculator";
|
|
105
|
+
import BeanAccessor, {GridApiWithPrivateAccess} from "./cell/beanAccessor";
|
|
106
|
+
import WildcardQuickFilterEngine from "./filter/wildcardQuickFilterEngine";
|
|
107
|
+
|
|
108
|
+
const gridFrameworkComponents = {
|
|
109
|
+
customColumnFilter: CustomColumnFilter,
|
|
110
|
+
textColumnFilter: TextColumnFilter,
|
|
111
|
+
numberCellEditor: NumberCellEditor,
|
|
112
|
+
textCellEditor: TextCellEditor,
|
|
113
|
+
simpleStatusTextCellEditor: SimpleStatusTextCellEditor,
|
|
114
|
+
statusTextCellEditor: StatusTextCellEditor,
|
|
115
|
+
dateCellEditor: DateCellEditor,
|
|
116
|
+
durationCellEditor: DurationCellEditor,
|
|
117
|
+
customEnumCellEditor: CustomEnumCellEditor,
|
|
118
|
+
hexaValueCellEditor: HexaValueCellEditor,
|
|
119
|
+
hexaOctetStringCellEditor: HexaOctetStringCellEditor,
|
|
120
|
+
simpleHeader: SimpleHeader,
|
|
121
|
+
loadingOverlay: LoadingOverlay,
|
|
122
|
+
noRecordsOverlay: NoRecordsOverlay
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
const DataGridModule = _defineModule({
|
|
127
|
+
version: "32.2.0",
|
|
128
|
+
moduleName: `dataGridModule`,
|
|
129
|
+
beans: [RangeSelector, BeanAccessor],
|
|
130
|
+
dependantModules: [],
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
ModuleRegistry.__register(DataGridModule, false, undefined)
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
* Ag Grid cell editing enter key navigation bug fix in case of enabled enterMovesDownAfterEdit property
|
|
137
|
+
* buggy Ag Grid implementation causes that not only pressing enter, but also losing focus of the cell (e.g. clicking outside the grid) moves focus to the next cell
|
|
138
|
+
* This code fixes CellCtrl prototype implementation of onPopupEditorClosed method to prevent this behavior by adding property true to stopEditingAndFocus method
|
|
139
|
+
*/
|
|
140
|
+
CellCtrl.prototype.onPopupEditorClosed = function () {
|
|
141
|
+
if (!this.isEditing()) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// note: this happens because of a click outside of the grid or if the popupEditor
|
|
145
|
+
// is closed with `Escape` key. if another cell was clicked, then the editing will
|
|
146
|
+
// have already stopped and returned on the conditional above.
|
|
147
|
+
this.stopEditingAndFocus(true);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
function getRowId(item: GetRowIdParams): string {
|
|
151
|
+
return item.data.id + "";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const rowStyleRuleCompiledExpressions: { [key: string]: (parameters: any) => any } = {};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Special separator for part of the column which should be exported
|
|
158
|
+
*/
|
|
159
|
+
export const EXPORT_SEPARATOR = "\n";
|
|
160
|
+
|
|
161
|
+
export type MenuElement = Exclude<Exclude<MenuProps["items"], undefined>[number], null>;
|
|
162
|
+
|
|
163
|
+
const enum NavigationEventEnum {
|
|
164
|
+
KEYBOARD,
|
|
165
|
+
MOUSE
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Extended viewport change event
|
|
170
|
+
*/
|
|
171
|
+
export interface DataGridViewportChangedEvent extends ViewportChangedEvent {
|
|
172
|
+
// delta number of rows table moved during paging/scrolling of the table
|
|
173
|
+
// negative number when paged/scrolled backwards to first record, positive number when paged/scrolled forwards to last record
|
|
174
|
+
rowsScrollingDelta: number
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export type SortMode = "asc" | "desc"
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Represents sorting definition for one column
|
|
181
|
+
*/
|
|
182
|
+
export interface SortItem {
|
|
183
|
+
colId: string;
|
|
184
|
+
sort: SortMode;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export type FilterRenderer = (value: string, changeValue: (newValue: string) => void, onSearch: () => void) => React.ReactNode
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* Extended table column definition
|
|
191
|
+
*/
|
|
192
|
+
export interface DataGridColDef extends Omit<ColDef, "cellStyle"> {
|
|
193
|
+
// localized name of group of columns to which column belongs to
|
|
194
|
+
group: string
|
|
195
|
+
// context of column definition
|
|
196
|
+
context?: any
|
|
197
|
+
|
|
198
|
+
// override of ag-grid api with undefined styles
|
|
199
|
+
cellStyle?: { [cssProperty: string]: string | number | null } | ((cellClassParams: CellClassParams) => {
|
|
200
|
+
[cssProperty: string]: string | number | null
|
|
201
|
+
} | undefined);
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
// custom filter render method
|
|
205
|
+
renderFilter?: FilterRenderer
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// removal of console warnings of our properties
|
|
209
|
+
// COL_DEF_VALIDATORS.allProperties?.push("group", "context", "cellStyle", "renderFilter");
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
export interface DataGridFilterProps {
|
|
213
|
+
// flag if floating filters (beneath column headers) are visible
|
|
214
|
+
columnSearchVisible?: boolean
|
|
215
|
+
// visibility handler for floating filters
|
|
216
|
+
onColumnSearchVisible?: (visible: boolean) => void
|
|
217
|
+
|
|
218
|
+
// returns floating filters (beneath column headers) current model (essential when filters should be pre-filled when shown from e.g. searchbox)
|
|
219
|
+
getFilterModel?(): any
|
|
220
|
+
|
|
221
|
+
// floating filter changed event (e.g. when pressing enter in floating filter textbox)
|
|
222
|
+
onFilterChanged?(event: FilterChangedEvent): void;
|
|
223
|
+
|
|
224
|
+
// floating filter modify event (e.g. when modifying value in floating filter textbox)
|
|
225
|
+
onFilterModified?(event: FilterModifiedEvent): void;
|
|
226
|
+
|
|
227
|
+
// method called when enter is pressed in the floating filter
|
|
228
|
+
onFilterConfirmed?(): void
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface DataGridSearchProps {
|
|
232
|
+
// placeholder to show in search field when no value is entered
|
|
233
|
+
placeholder?: string
|
|
234
|
+
// current search string
|
|
235
|
+
searchString?: string
|
|
236
|
+
// current search history available for search field popup
|
|
237
|
+
searchHistory?: string[]
|
|
238
|
+
// custom search button class name
|
|
239
|
+
searchButtonClassName?: string
|
|
240
|
+
// search button disabled
|
|
241
|
+
searchButtonDisabled?: boolean
|
|
242
|
+
// search button hidden
|
|
243
|
+
searchButtonHidden?: boolean
|
|
244
|
+
// hide searchbox
|
|
245
|
+
hidden?: boolean
|
|
246
|
+
|
|
247
|
+
// custom search field renderer
|
|
248
|
+
searchRenderer?(): React.ReactNode
|
|
249
|
+
|
|
250
|
+
// formatting showed strings in search and history
|
|
251
|
+
stringFormatter?(rawString: string): string
|
|
252
|
+
|
|
253
|
+
// search field value changed
|
|
254
|
+
onChange?(searchString: string): void
|
|
255
|
+
|
|
256
|
+
// called when new search is invoked by pressing search button or enter in the search field
|
|
257
|
+
onSearch?(): void
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// callback called when data are loaded from backend
|
|
261
|
+
export type OnLoadDataCallback = (totalRecords: number) => void
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Data Grid properties, differences to AgGrid:
|
|
265
|
+
* columnDefinitions (columnDefs) does not support column groups for now
|
|
266
|
+
* paginationPageSize for defining size of page is not available, use paging.pageSize instead
|
|
267
|
+
*/
|
|
268
|
+
export interface DataGridProps extends Omit<GridOptions, "columnDefs" | "paginationPageSize" | "getRowStyle" | "cellStyle"> {
|
|
269
|
+
// linking grid options (used for aligned grids feature: https://www.ag-grid.com/javascript-grid-aligned-grids/)
|
|
270
|
+
gridOptions?: GridOptions
|
|
271
|
+
// column definitions
|
|
272
|
+
columnDefs: DataGridColDef[]
|
|
273
|
+
// for aligned grids functionality
|
|
274
|
+
disableColumnDefsPreprocessing?: boolean
|
|
275
|
+
|
|
276
|
+
// realColumnDefs building handler
|
|
277
|
+
onColumnDefsAdapted?(columnDefs: ColDef[]): void
|
|
278
|
+
|
|
279
|
+
// shows table configuration panel
|
|
280
|
+
tableConfigVisible?: boolean,
|
|
281
|
+
// shows column configuration panel
|
|
282
|
+
columnsConfigVisible?: boolean,
|
|
283
|
+
// style of panel surrounding datagrid
|
|
284
|
+
panelStyle?: React.CSSProperties,
|
|
285
|
+
// style of panel surrounding table part
|
|
286
|
+
tablePanelStyle?: React.CSSProperties,
|
|
287
|
+
// floating filter configuration
|
|
288
|
+
filter?: DataGridFilterProps
|
|
289
|
+
// search bar configuration
|
|
290
|
+
search?: DataGridSearchProps
|
|
291
|
+
// table paging configuration
|
|
292
|
+
paging: {
|
|
293
|
+
/* current size of table page:
|
|
294
|
+
- value -1 means no paging at all (scrollbar only)
|
|
295
|
+
- value 0 means automatic paging (page size automatically adjusted based on available height for table)
|
|
296
|
+
- value >0 defines statically defined page size (number of rows) for the table
|
|
297
|
+
*/
|
|
298
|
+
pageSize: number,
|
|
299
|
+
// default size used when configuration is reverted
|
|
300
|
+
defaultPageSize?: number,
|
|
301
|
+
/**
|
|
302
|
+
* Page size change handler
|
|
303
|
+
* @param currentPageSize - current page size represents number rows available
|
|
304
|
+
* @param definedPageSize -
|
|
305
|
+
*/
|
|
306
|
+
onPaginationChanged?: (currentPageSize: number | null, definedPageSize: number) => void;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// flag if row data could be passed only by transaction or setRowData method (optimization for big data lists, where deep comparison is not performed on rowData react property)
|
|
310
|
+
rowDataManualMode?: boolean
|
|
311
|
+
|
|
312
|
+
// load data handler - called by grid always when it needs data
|
|
313
|
+
onLoadData(callback: OnLoadDataCallback): void
|
|
314
|
+
|
|
315
|
+
// automatic focus to first cell of selected row after loading of data is complete
|
|
316
|
+
autofocus?: boolean
|
|
317
|
+
|
|
318
|
+
// handler for keys pressed in data grid
|
|
319
|
+
onKeyPressed?(event: KeyboardEvent): void
|
|
320
|
+
|
|
321
|
+
// enter handler
|
|
322
|
+
onEnter?: () => void;
|
|
323
|
+
|
|
324
|
+
// ids of currently selected rows
|
|
325
|
+
selectedIds?: (number | string)[]
|
|
326
|
+
|
|
327
|
+
// rules for styling table rows
|
|
328
|
+
rowStyleRules: RowStyleRule[]
|
|
329
|
+
|
|
330
|
+
// default rules for styling table rows, used when configuration is reverted
|
|
331
|
+
defaultRowStyleRules?: RowStyleRule[]
|
|
332
|
+
|
|
333
|
+
// row styles change handler
|
|
334
|
+
onChangeRowStyleRules?(rowStyleRules: RowStyleRule[]): void
|
|
335
|
+
|
|
336
|
+
// extra buttons rendered before the search bar
|
|
337
|
+
toolbar?: {
|
|
338
|
+
// custom renderer for the whole toolbar panel
|
|
339
|
+
renderToolbar?(originalSearchBar: ReactElement): ReactElement
|
|
340
|
+
|
|
341
|
+
// extra buttons rendered in toolbar
|
|
342
|
+
toolbarButtons?: ReactElement
|
|
343
|
+
|
|
344
|
+
// hide records count
|
|
345
|
+
hideRecordCount?: boolean
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// row height change handler (height is changed from table configuration screen)
|
|
349
|
+
onRowHeightChanged?(rowHeight: number): void
|
|
350
|
+
|
|
351
|
+
// columns state change handler
|
|
352
|
+
onColumnsChanged?(columnModel: ColumnState[], event: ColumnEvent): void
|
|
353
|
+
|
|
354
|
+
// table configuration panel visibility change handler
|
|
355
|
+
onTableConfigVisible?(visible: boolean): void
|
|
356
|
+
|
|
357
|
+
// column configuration panel visibility change handler
|
|
358
|
+
onColumnsConfigVisible?(visible: boolean): void
|
|
359
|
+
|
|
360
|
+
// customized renderer for displaying loading progress
|
|
361
|
+
loadingOverlayRenderer?(): ReactElement | null
|
|
362
|
+
|
|
363
|
+
// customized renderer for displaying no records information
|
|
364
|
+
noRecordsOverlayRenderer?(): ReactElement | null
|
|
365
|
+
|
|
366
|
+
// customized renderer for displaying data over table
|
|
367
|
+
tableOverlayRenderer?(): ReactElement | null
|
|
368
|
+
|
|
369
|
+
showMilliseconds?: boolean
|
|
370
|
+
|
|
371
|
+
defaultShowMilliseconds?: boolean
|
|
372
|
+
|
|
373
|
+
onShowMilliseconds?(show: boolean, callback: () => void): void
|
|
374
|
+
|
|
375
|
+
hideYear?: boolean
|
|
376
|
+
|
|
377
|
+
defaultHideYear?: boolean
|
|
378
|
+
|
|
379
|
+
onShowYear?(show: boolean, callback: () => void): void
|
|
380
|
+
|
|
381
|
+
// export menu configuration
|
|
382
|
+
exportMenu?: {
|
|
383
|
+
// overides export menu rendering
|
|
384
|
+
renderer?(menuElements: MenuElement[]): MenuElement[]
|
|
385
|
+
// handler for custom export menu items click
|
|
386
|
+
onClick?(key: string): void
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// settings menu configuration
|
|
390
|
+
settingsMenu?: {
|
|
391
|
+
// overides setting menu rendering
|
|
392
|
+
renderer?(menuElements: MenuElement[]): MenuElement[]
|
|
393
|
+
// handler for custom settings menu items click
|
|
394
|
+
onClick?(key: string): void
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// context menu configuration (right click on the table rows)
|
|
398
|
+
contextMenu?: {
|
|
399
|
+
// overides context menu rendering
|
|
400
|
+
renderer?(menuElements: MenuElement[]): MenuElement[]
|
|
401
|
+
// handler for custom context menu items click
|
|
402
|
+
onClick?(key: string): void
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// override of ag-grid api with undefined styles
|
|
406
|
+
getRowStyle?(params: any): GridRowStyle | undefined
|
|
407
|
+
|
|
408
|
+
// hook reference to AgGridReact component
|
|
409
|
+
gridRef?: React.RefObject<AgGridReact>
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
interface DataGridState {
|
|
413
|
+
pageIndex: number
|
|
414
|
+
pageSize: number | null
|
|
415
|
+
recordsCount?: number
|
|
416
|
+
columnModel: ColumnState[]
|
|
417
|
+
sortModel: SortItem[]
|
|
418
|
+
tableConfigVisible: boolean
|
|
419
|
+
columnsConfigVisible: boolean
|
|
420
|
+
fontSize: number
|
|
421
|
+
rowHeight: number
|
|
422
|
+
// interval of record's indexes currently shown (first record has index 1)
|
|
423
|
+
viewport: [number, number]
|
|
424
|
+
contextMenuVisible: boolean
|
|
425
|
+
firstLoadDone: boolean
|
|
426
|
+
loading: boolean
|
|
427
|
+
columnTransferHeight: number
|
|
428
|
+
pageOrientation: PageOrientation
|
|
429
|
+
exporting: boolean
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
export default class DataGrid extends React.Component<DataGridProps, DataGridState> {
|
|
434
|
+
public static defaultProps = {
|
|
435
|
+
paging: {
|
|
436
|
+
pageSize: 0,
|
|
437
|
+
defaultPageSize: 0
|
|
438
|
+
},
|
|
439
|
+
rowStyleRules: tableDefaultRowStyleRules()
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
wildcardQuickFilter: WildcardQuickFilterEngine;
|
|
443
|
+
columnTypes: { [key: string]: ColDef };
|
|
444
|
+
gridApi?: GridApi;
|
|
445
|
+
// deep copy of columns state before opening editation of columns and its order
|
|
446
|
+
// used in "cancel changes" functionality
|
|
447
|
+
columnModelBeforeEdit?: ColumnState[];
|
|
448
|
+
indexToJump: number | null;
|
|
449
|
+
columnToJump: Column | null;
|
|
450
|
+
lastCellFocus?: CellFocusedEvent;
|
|
451
|
+
lastNavigationEvent?: NavigationEventEnum;
|
|
452
|
+
lastPaginationEvent?: PaginationChangedEvent | null = null;
|
|
453
|
+
table_context: any;
|
|
454
|
+
|
|
455
|
+
// @ts-ignore (was used in RangeSelector, not used now but probably will be fixed in future)
|
|
456
|
+
private wrappingDiv: HTMLDivElement | null = null;
|
|
457
|
+
|
|
458
|
+
constructor(props: Readonly<DataGridProps>) {
|
|
459
|
+
super(props);
|
|
460
|
+
this.state = {
|
|
461
|
+
pageIndex: 0,
|
|
462
|
+
pageSize: null,
|
|
463
|
+
recordsCount: undefined,
|
|
464
|
+
columnModel: [],
|
|
465
|
+
sortModel: [],
|
|
466
|
+
tableConfigVisible: !!this.props.tableConfigVisible,
|
|
467
|
+
columnsConfigVisible: !!this.props.columnsConfigVisible,
|
|
468
|
+
fontSize: GRID_DEFAULT_FONT_SIZE,
|
|
469
|
+
rowHeight: calculateRowHeight(GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA),
|
|
470
|
+
viewport: [0, 0],
|
|
471
|
+
contextMenuVisible: false,
|
|
472
|
+
firstLoadDone: false,
|
|
473
|
+
loading: false,
|
|
474
|
+
columnTransferHeight: 500,
|
|
475
|
+
pageOrientation: "PORTRAIT",
|
|
476
|
+
exporting: false
|
|
477
|
+
};
|
|
478
|
+
this.indexToJump = null;
|
|
479
|
+
this.columnToJump = null;
|
|
480
|
+
|
|
481
|
+
this.onGridReady = this.onGridReady.bind(this);
|
|
482
|
+
this.onPaginationChanged = this.onPaginationChanged.bind(this);
|
|
483
|
+
this.onViewportChanged = this.onViewportChanged.bind(this);
|
|
484
|
+
this.onCellContextMenu = this.onCellContextMenu.bind(this);
|
|
485
|
+
this.onCellFocused = this.onCellFocused.bind(this);
|
|
486
|
+
this.onCellMouseDown = this.onCellMouseDown.bind(this);
|
|
487
|
+
this.setFocusedCellDebounced = debounce(this.setFocusedCellDebounced.bind(this), 200);
|
|
488
|
+
this.noRecordsOverlayRenderer = this.noRecordsOverlayRenderer.bind(this);
|
|
489
|
+
this.loadingOverlayRenderer = this.loadingOverlayRenderer.bind(this);
|
|
490
|
+
this.changePagination = this.changePagination.bind(this);
|
|
491
|
+
this.onColumnsChanged = this.onColumnsChanged.bind(this);
|
|
492
|
+
this.onFilterModified = this.onFilterModified.bind(this);
|
|
493
|
+
this.onFilterChanged = this.onFilterChanged.bind(this);
|
|
494
|
+
this.onFilterConfirmed = this.onFilterConfirmed.bind(this);
|
|
495
|
+
this.onSortChanged = this.onSortChanged.bind(this);
|
|
496
|
+
this.showTableConfiguration = this.showTableConfiguration.bind(this);
|
|
497
|
+
this.showColumnsConfig = this.showColumnsConfig.bind(this);
|
|
498
|
+
this.navigateToNextCell = this.navigateToNextCell.bind(this);
|
|
499
|
+
this.suppressKeyboardEvent = this.suppressKeyboardEvent.bind(this);
|
|
500
|
+
this.onRowDataUpdated = this.onRowDataUpdated.bind(this);
|
|
501
|
+
this._getRowStyle = this._getRowStyle.bind(this);
|
|
502
|
+
this._getRowHeight = this._getRowHeight.bind(this);
|
|
503
|
+
this._getCellStyle = this._getCellStyle.bind(this);
|
|
504
|
+
this.textCustomComparator = this.textCustomComparator.bind(this);
|
|
505
|
+
this.onPageOrientationChange = this.onPageOrientationChange.bind(this);
|
|
506
|
+
this.onExport = this.onExport.bind(this);
|
|
507
|
+
this.getExportContent = this.getExportContent.bind(this);
|
|
508
|
+
this.getDefaultColDefinition = memoizeOne(this.getDefaultColDefinition.bind(this));
|
|
509
|
+
this.getAdaptedColumnDefs = memoizeOne(this.getAdaptedColumnDefs.bind(this));
|
|
510
|
+
this.getCustomComponents = memoizeOne(this.getCustomComponents.bind(this));
|
|
511
|
+
|
|
512
|
+
this.table_context = {
|
|
513
|
+
loadingOverlayRenderer: this.loadingOverlayRenderer,
|
|
514
|
+
noRecordsOverlayRenderer: this.noRecordsOverlayRenderer,
|
|
515
|
+
onFilterConfirmed: this.onFilterConfirmed,
|
|
516
|
+
fontSize: this.state.fontSize,
|
|
517
|
+
lineHeight: getLineHeight(this.state.rowHeight)
|
|
518
|
+
};
|
|
519
|
+
this.wildcardQuickFilter = new WildcardQuickFilterEngine();
|
|
520
|
+
|
|
521
|
+
this.columnTypes = {
|
|
522
|
+
"localizedArrayColumn": {
|
|
523
|
+
cellRenderer: (params: ICellRendererParams): string => {
|
|
524
|
+
const value = DataGrid.getCellValue<string[]>(params);
|
|
525
|
+
if (value !== undefined) {
|
|
526
|
+
return value.map((s) => i18n(s)).join(",");
|
|
527
|
+
} else {
|
|
528
|
+
return "";
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
filterParams: {
|
|
532
|
+
textCustomComparator: this.textCustomComparator
|
|
533
|
+
},
|
|
534
|
+
filterValueGetter: function (params: ValueGetterParams): string | null {
|
|
535
|
+
const value = DataGrid.getCellValue<string[]>(params);
|
|
536
|
+
if (value !== undefined) {
|
|
537
|
+
return value.map((s) => i18n(s)).join(",");
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
},
|
|
541
|
+
getQuickFilterText: function (params: GetQuickFilterTextParams): string {
|
|
542
|
+
const value = DataGrid.getCellValue<string[]>(params);
|
|
543
|
+
if (value !== undefined) {
|
|
544
|
+
return value.map((s) => i18n(s)).join(",");
|
|
545
|
+
}
|
|
546
|
+
return "";
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
"numberColumn": {
|
|
550
|
+
cellRenderer: (params: ICellRendererParams): string => {
|
|
551
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
552
|
+
if (value !== undefined && value !== null) {
|
|
553
|
+
return LocaleHolder.formatNumber(value, params.colDef?.cellRendererParams?.fractionDigits);
|
|
554
|
+
} else {
|
|
555
|
+
return "";
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
filterParams: {
|
|
559
|
+
textCustomComparator: this.textCustomComparator
|
|
560
|
+
},
|
|
561
|
+
filterValueGetter: function (params: ValueGetterParams): string | null {
|
|
562
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
563
|
+
if (value) {
|
|
564
|
+
return LocaleHolder.formatNumber(value, params.colDef?.cellRendererParams?.fractionDigits);
|
|
565
|
+
} else {
|
|
566
|
+
return "";
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
getQuickFilterText: function (params: GetQuickFilterTextParams): string {
|
|
570
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
571
|
+
if (value !== undefined) {
|
|
572
|
+
return LocaleHolder.formatNumber(value, params.colDef?.cellRendererParams?.fractionDigits);
|
|
573
|
+
} else {
|
|
574
|
+
return "";
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
"dateColumn": {
|
|
579
|
+
cellRenderer: (params: ICellRendererParams) => {
|
|
580
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
581
|
+
if (value !== undefined) {
|
|
582
|
+
if (value === D2000UnixTimeNullValue) {
|
|
583
|
+
return "---";
|
|
584
|
+
}
|
|
585
|
+
let tooltipValue: string;
|
|
586
|
+
tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
|
|
587
|
+
return <span
|
|
588
|
+
title={tooltipValue}>{unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear))}</span>
|
|
589
|
+
} else {
|
|
590
|
+
return "---";
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
valueFormatter: (params: ValueFormatterParams): string => {
|
|
594
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
595
|
+
if (value !== undefined) {
|
|
596
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
|
|
597
|
+
}
|
|
598
|
+
return "---";
|
|
599
|
+
},
|
|
600
|
+
filterParams: {
|
|
601
|
+
textCustomComparator: this.textCustomComparator
|
|
602
|
+
},
|
|
603
|
+
filterValueGetter: (params: ValueGetterParams): string | null => {
|
|
604
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
605
|
+
if (value !== undefined) {
|
|
606
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
|
|
607
|
+
}
|
|
608
|
+
return null;
|
|
609
|
+
},
|
|
610
|
+
getQuickFilterText: (params: GetQuickFilterTextParams): string => {
|
|
611
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
612
|
+
if (value !== undefined) {
|
|
613
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
|
|
614
|
+
}
|
|
615
|
+
return "";
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
"dateTimeColumn": {
|
|
619
|
+
cellRenderer: (params: ICellRendererParams) => {
|
|
620
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
621
|
+
if (value) {
|
|
622
|
+
if (value === D2000UnixTimeNullValue) {
|
|
623
|
+
return "Null Time";
|
|
624
|
+
}
|
|
625
|
+
let tooltipValue: string;
|
|
626
|
+
tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
|
|
627
|
+
return <span
|
|
628
|
+
title={tooltipValue}>{unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds))}</span>;
|
|
629
|
+
} else {
|
|
630
|
+
return "---";
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
valueFormatter: (params: ValueFormatterParams): string => {
|
|
634
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
635
|
+
if (value !== undefined) {
|
|
636
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
637
|
+
}
|
|
638
|
+
return "---";
|
|
639
|
+
},
|
|
640
|
+
filterParams: {
|
|
641
|
+
textCustomComparator: this.textCustomComparator
|
|
642
|
+
},
|
|
643
|
+
filterValueGetter: (params: ValueGetterParams): string | null => {
|
|
644
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
645
|
+
if (value !== undefined) {
|
|
646
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
649
|
+
},
|
|
650
|
+
getQuickFilterText: (params: GetQuickFilterTextParams): string => {
|
|
651
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
652
|
+
if (value !== undefined) {
|
|
653
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
654
|
+
}
|
|
655
|
+
return "";
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
"fromNowDateTimeColumn": {
|
|
659
|
+
cellRenderer: (params: ICellRendererParams) => {
|
|
660
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
661
|
+
if (value !== undefined) {
|
|
662
|
+
let tooltipValue: string;
|
|
663
|
+
tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
|
|
664
|
+
return <span title={tooltipValue}>{unixTimeToMoment(value).fromNow()}</span>;
|
|
665
|
+
} else {
|
|
666
|
+
return "---";
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
valueFormatter: (params: ValueFormatterParams): string => {
|
|
670
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
671
|
+
if (value !== undefined) {
|
|
672
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
673
|
+
}
|
|
674
|
+
return "---";
|
|
675
|
+
},
|
|
676
|
+
filterParams: {
|
|
677
|
+
textCustomComparator: this.textCustomComparator
|
|
678
|
+
},
|
|
679
|
+
filterValueGetter: (params: ValueGetterParams): string | null => {
|
|
680
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
681
|
+
if (value !== undefined) {
|
|
682
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
683
|
+
}
|
|
684
|
+
return null;
|
|
685
|
+
},
|
|
686
|
+
getQuickFilterText: (params: GetQuickFilterTextParams): string => {
|
|
687
|
+
const value = DataGrid.getCellValue<number>(params);
|
|
688
|
+
if (value !== undefined) {
|
|
689
|
+
return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
|
|
690
|
+
}
|
|
691
|
+
return "";
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
"escapedValueColumn": {
|
|
695
|
+
cellRenderer: (params: ICellRendererParams) => {
|
|
696
|
+
const value = DataGrid.getCellValue<any>(params);
|
|
697
|
+
if (value !== undefined) {
|
|
698
|
+
return <span style={{whiteSpace: "pre"}}
|
|
699
|
+
title={escape(value)}>{typeof value === "string" ? escape(value.replace(/[\r\n]+/g, ' ')) : value}</span>;
|
|
700
|
+
} else {
|
|
701
|
+
return "";
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
valueFormatter: (params: ValueFormatterParams): string => {
|
|
705
|
+
const value = DataGrid.getCellValue<any>(params);
|
|
706
|
+
if (value !== undefined) {
|
|
707
|
+
return typeof value === "string" ? value.replace(/[\r\n]+/g, ' ') : value;
|
|
708
|
+
} else {
|
|
709
|
+
return "";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
"textColumnFilter": {
|
|
714
|
+
filter: "agTextColumnFilter",
|
|
715
|
+
floatingFilter: true,
|
|
716
|
+
floatingFilterComponent: "textColumnFilter",
|
|
717
|
+
filterParams: {
|
|
718
|
+
textCustomComparator: this.textCustomComparator
|
|
719
|
+
},
|
|
720
|
+
suppressFloatingFilterButton: true,
|
|
721
|
+
},
|
|
722
|
+
"textColumnServerFilter": {
|
|
723
|
+
filter: "agTextColumnFilter",
|
|
724
|
+
floatingFilter: true,
|
|
725
|
+
floatingFilterComponent: "textColumnFilter",
|
|
726
|
+
filterParams: {
|
|
727
|
+
buttons: ['apply'],
|
|
728
|
+
textCustomComparator: this.textCustomComparator
|
|
729
|
+
},
|
|
730
|
+
suppressFloatingFilterButton: true,
|
|
731
|
+
},
|
|
732
|
+
"customColumnServerFilter": {
|
|
733
|
+
filter: "agTextColumnFilter",
|
|
734
|
+
floatingFilter: true,
|
|
735
|
+
floatingFilterComponent: "customColumnFilter",
|
|
736
|
+
filterParams: {
|
|
737
|
+
buttons: ['apply'],
|
|
738
|
+
textCustomComparator: this.textCustomComparator
|
|
739
|
+
},
|
|
740
|
+
suppressFloatingFilterButton: true,
|
|
741
|
+
},
|
|
742
|
+
"alignRight": {}
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
private static getCellValue<V>(props: any): V | undefined {
|
|
747
|
+
if (props) {
|
|
748
|
+
if (props.colDef.field && typeof props.getValue === "function") {
|
|
749
|
+
return props.getValue(props.colDef.field);
|
|
750
|
+
}
|
|
751
|
+
if (props.data && props.colDef && props.colDef.field) {
|
|
752
|
+
return at<V>(props.data, props.colDef.field)[0];
|
|
753
|
+
}
|
|
754
|
+
if (props.value !== undefined) {
|
|
755
|
+
return props.value;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
textCustomComparator(filter: string, value: any, filterText: string) {
|
|
763
|
+
const filterTextLowerCase = filterText.toLowerCase();
|
|
764
|
+
const valueLowerCase = value.toString().toLowerCase();
|
|
765
|
+
switch (filter) {
|
|
766
|
+
case 'contains':
|
|
767
|
+
if (filterTextLowerCase.indexOf("*") >= 0 || filterTextLowerCase.indexOf("?") >= 0) {
|
|
768
|
+
const wildcardFilterRegExp = this.wildcardQuickFilter.getWildcardFilterRegExp(filterTextLowerCase);
|
|
769
|
+
if (typeof wildcardFilterRegExp == "string") {
|
|
770
|
+
return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
|
|
771
|
+
} else {
|
|
772
|
+
return wildcardFilterRegExp.test(valueLowerCase);
|
|
773
|
+
}
|
|
774
|
+
} else {
|
|
775
|
+
return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
|
|
776
|
+
}
|
|
777
|
+
case 'notContains':
|
|
778
|
+
return valueLowerCase.indexOf(filterTextLowerCase) === -1;
|
|
779
|
+
case 'equals':
|
|
780
|
+
return valueLowerCase === filterTextLowerCase;
|
|
781
|
+
case 'notEqual':
|
|
782
|
+
// noinspection EqualityComparisonWithCoercionJS
|
|
783
|
+
return valueLowerCase != filterTextLowerCase;
|
|
784
|
+
case 'startsWith':
|
|
785
|
+
return valueLowerCase.indexOf(filterTextLowerCase) === 0;
|
|
786
|
+
case 'endsWith':
|
|
787
|
+
var index = valueLowerCase.lastIndexOf(filterTextLowerCase);
|
|
788
|
+
return index >= 0 && index === (valueLowerCase.length - filterTextLowerCase.length);
|
|
789
|
+
default:
|
|
790
|
+
// should never happen
|
|
791
|
+
console.warn('invalid filter type ' + filter);
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
componentDidUpdate(prevProps: DataGridProps) {
|
|
797
|
+
if (!this.gridApi) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
if (this.props.filter && prevProps.filter && this.props.filter.columnSearchVisible !== prevProps.filter.columnSearchVisible) {
|
|
801
|
+
setTimeout(() => {
|
|
802
|
+
if (this.gridApi) {
|
|
803
|
+
this.gridApi.refreshHeader();
|
|
804
|
+
if (this.props.filter && !this.props.filter.columnSearchVisible) {
|
|
805
|
+
this.gridApi.setFilterModel(null);
|
|
806
|
+
this.gridApi.onFilterChanged();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}, 0);
|
|
810
|
+
}
|
|
811
|
+
// functionality when all data are loaded to table
|
|
812
|
+
if (this.props.rowData && this.props.rowData !== prevProps.rowData) {
|
|
813
|
+
// keep filter model when data are changed
|
|
814
|
+
if (this.props.filter && this.props.filter.getFilterModel) {
|
|
815
|
+
this.gridApi.setFilterModel(this.props.filter.getFilterModel());
|
|
816
|
+
this.gridApi.onFilterChanged();
|
|
817
|
+
}
|
|
818
|
+
// keep sorting model when data are changed
|
|
819
|
+
this.setSortModel(this.state.sortModel);
|
|
820
|
+
this.gridApi.refreshClientSideRowModel("group");
|
|
821
|
+
this.gridApi.redrawRows();
|
|
822
|
+
|
|
823
|
+
// keep selected rows when data are changed and rows are still present
|
|
824
|
+
const selectedObjectsVisibleInGrid = this.props.rowData.filter((object) => {
|
|
825
|
+
return this.props.selectedIds ? this.props.selectedIds.indexOf(object.id) >= 0 : false;
|
|
826
|
+
});
|
|
827
|
+
if (selectedObjectsVisibleInGrid.length > 0) {
|
|
828
|
+
selectedObjectsVisibleInGrid.forEach((object) => {
|
|
829
|
+
const rowNode = this.gridApi ? this.gridApi.getRowNode(object.id + "") : null;
|
|
830
|
+
if (rowNode && !rowNode.isSelected()) {
|
|
831
|
+
rowNode.setSelected(true, true);
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
} else {
|
|
835
|
+
this.gridApi.deselectAll();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
// functionality when chunks of data are dynamically loaded from server
|
|
839
|
+
if (this.props.datasource && this.props.datasource !== prevProps.datasource) {
|
|
840
|
+
// resets grid data
|
|
841
|
+
this.gridApi.updateGridOptions({datasource: this.props.datasource});
|
|
842
|
+
}
|
|
843
|
+
this.updateRowHeight();
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
public setColumnState(columnModel: ColumnState[]) {
|
|
847
|
+
const columnStates: ColumnState[] = [];
|
|
848
|
+
if (columnModel) {
|
|
849
|
+
columnModel.forEach((item: ColumnState) => {
|
|
850
|
+
const columnState = {...item};
|
|
851
|
+
item.sortIndex = undefined;
|
|
852
|
+
item.sort = undefined
|
|
853
|
+
columnStates.push(columnState);
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
this.gridApi?.applyColumnState({state: columnStates, defaultState: {sort: null}, applyOrder: true});
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
public setSortModel(sortModel: SortItem[]) {
|
|
860
|
+
const columnState: ColumnState[] = [];
|
|
861
|
+
if (sortModel) {
|
|
862
|
+
sortModel.forEach((item: any, index: number) => {
|
|
863
|
+
columnState.push({
|
|
864
|
+
colId: item.colId,
|
|
865
|
+
sort: item.sort,
|
|
866
|
+
sortIndex: index
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
this.gridApi?.applyColumnState({state: columnState, defaultState: {sort: null}, applyOrder: true});
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
public getSortModel(): SortItem[] {
|
|
874
|
+
const columnState = this.gridApi?.getColumnState() ?? [];
|
|
875
|
+
const filteredStates = columnState?.filter(item => item.sort != null);
|
|
876
|
+
const indexes: { [colId: string]: number; } = {};
|
|
877
|
+
filteredStates.forEach((state) => {
|
|
878
|
+
if (state.colId) {
|
|
879
|
+
indexes[state.colId] = state.sortIndex as number;
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
const res = filteredStates.map(s => {
|
|
883
|
+
return {colId: s.colId, sort: s.sort} as SortItem;
|
|
884
|
+
});
|
|
885
|
+
res.sort((a: any, b: any) => indexes[a.colId] - indexes[b.colId]);
|
|
886
|
+
return res;
|
|
887
|
+
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
updateRowHeight() {
|
|
891
|
+
let rowAndFontHeight = this.calculateRowAndFontHeight(this.props.rowStyleRules);
|
|
892
|
+
if (rowAndFontHeight.rowHeight !== this.state.rowHeight) {
|
|
893
|
+
this.changeRowHeight(rowAndFontHeight.fontSize, rowAndFontHeight.rowHeight);
|
|
894
|
+
}
|
|
895
|
+
if (rowAndFontHeight.fontSize !== this.state.fontSize) {
|
|
896
|
+
this.setState({fontSize: rowAndFontHeight.fontSize});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
calculateRowAndFontHeight(rowStyleRules?: RowStyleRule[]): { fontSize: number, rowHeight: number } {
|
|
901
|
+
let rowHeightDelta = GRID_DEFAULT_ROW_HEIGHT_DELTA;
|
|
902
|
+
let fontSize = GRID_DEFAULT_FONT_SIZE;
|
|
903
|
+
let rowHeight = calculateRowHeight(fontSize, rowHeightDelta);
|
|
904
|
+
if (rowStyleRules) {
|
|
905
|
+
for (let i = 0; i < rowStyleRules.length; i++) {
|
|
906
|
+
if (rowStyleRules[i].key === "table-font-size") {
|
|
907
|
+
const currentFontSize = rowStyleRules[i].style.fontSize;
|
|
908
|
+
fontSize = getFontSize(currentFontSize);
|
|
909
|
+
rowHeight = calculateRowHeight(currentFontSize, rowHeightDelta);
|
|
910
|
+
}
|
|
911
|
+
if (rowStyleRules[i].key === "table-line-indentation") {
|
|
912
|
+
const currentRowHeightDelta = rowStyleRules[i].style.rowHeightDelta;
|
|
913
|
+
rowHeightDelta = getRowHeightDelta(currentRowHeightDelta);
|
|
914
|
+
rowHeight = calculateRowHeight(fontSize, currentRowHeightDelta);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return {rowHeight: rowHeight, fontSize: fontSize};
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Handling setting table gridEditor
|
|
923
|
+
*/
|
|
924
|
+
static getDerivedStateFromProps(props: DataGridProps, state: DataGridState) {
|
|
925
|
+
const newState: Partial<DataGridState> = {};
|
|
926
|
+
if (props.tableConfigVisible === true || props.tableConfigVisible === false) {
|
|
927
|
+
if (props.tableConfigVisible !== state.tableConfigVisible) {
|
|
928
|
+
newState.tableConfigVisible = props.tableConfigVisible;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return newState;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
onGridReady(gridReadyEvent: GridReadyEvent): void {
|
|
935
|
+
const gridApi = gridReadyEvent.api;
|
|
936
|
+
if (!this.gridApi || this.gridApi !== gridApi) {
|
|
937
|
+
this.gridApi = gridApi;
|
|
938
|
+
if (this.props.onGridReady) {
|
|
939
|
+
this.props.onGridReady(gridReadyEvent);
|
|
940
|
+
}
|
|
941
|
+
this.setState({
|
|
942
|
+
sortModel: this.getSortModel(),
|
|
943
|
+
columnModel: this.gridApi.getColumnState(),
|
|
944
|
+
});
|
|
945
|
+
this.updateRowHeight();
|
|
946
|
+
}
|
|
947
|
+
// fixing some cases when after onGridReady callback no onPaginationChanged callback is called
|
|
948
|
+
// and therefore no initial data loading (loadData()) occurs
|
|
949
|
+
setTimeout(() => {
|
|
950
|
+
if (!!this.lastPaginationEvent) {
|
|
951
|
+
this.onPaginationChanged(this.lastPaginationEvent);
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
onPaginationChanged(event: PaginationChangedEvent) {
|
|
957
|
+
if (this.gridApi) {
|
|
958
|
+
const currentPage = this.gridApi.paginationGetCurrentPage();
|
|
959
|
+
const currentPageSize = this.gridApi.paginationGetPageSize();
|
|
960
|
+
let recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
|
|
961
|
+
// process only when onGridReady passed
|
|
962
|
+
if (this.state.pageSize !== currentPageSize) {
|
|
963
|
+
if (this.props.paging.onPaginationChanged) {
|
|
964
|
+
this.props.paging.onPaginationChanged(currentPageSize, this.props.paging.pageSize);
|
|
965
|
+
}
|
|
966
|
+
if (!this.state.firstLoadDone) {
|
|
967
|
+
this.loadData();
|
|
968
|
+
this.setState({firstLoadDone: true});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
this.setState({pageSize: currentPageSize, recordsCount: recordsCount, pageIndex: currentPage});
|
|
972
|
+
if (this.indexToJump !== null && this.columnToJump !== null) {
|
|
973
|
+
this.gridApi.setFocusedCell(this.indexToJump, this.columnToJump);
|
|
974
|
+
this.indexToJump = null;
|
|
975
|
+
}
|
|
976
|
+
this.lastPaginationEvent = null;
|
|
977
|
+
} else {
|
|
978
|
+
this.lastPaginationEvent = event;
|
|
979
|
+
}
|
|
980
|
+
if (this.props.onPaginationChanged) {
|
|
981
|
+
this.props.onPaginationChanged(event);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
onViewportChanged(event: ViewportChangedEvent) {
|
|
986
|
+
const dataGridEvent = event as DataGridViewportChangedEvent;
|
|
987
|
+
// calculation of the flag that last record is shown
|
|
988
|
+
const rowsScrollingDelta = this.state.viewport[1] ? event.lastRow + 1 - this.state.viewport[1] : event.lastRow + 1;
|
|
989
|
+
dataGridEvent.rowsScrollingDelta = rowsScrollingDelta;
|
|
990
|
+
this.setState({viewport: [event.firstRow + 1, event.lastRow + 1]});
|
|
991
|
+
if (this.props.onViewportChanged) {
|
|
992
|
+
this.props.onViewportChanged(event);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
changePagination(pageSize: number): void {
|
|
997
|
+
if (!this.gridApi) {
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
const gridApiWithPrivateAccess = this.gridApi as GridApiWithPrivateAccess;
|
|
1001
|
+
if (pageSize > 0) {
|
|
1002
|
+
this.gridApi.updateGridOptions({
|
|
1003
|
+
pagination: true,
|
|
1004
|
+
paginationAutoPageSize: false,
|
|
1005
|
+
paginationPageSize: pageSize
|
|
1006
|
+
});
|
|
1007
|
+
if (this.props.paging.onPaginationChanged) {
|
|
1008
|
+
this.props.paging.onPaginationChanged(pageSize, pageSize);
|
|
1009
|
+
}
|
|
1010
|
+
} else if (pageSize === 0) {
|
|
1011
|
+
this.gridApi.updateGridOptions({pagination: true, paginationAutoPageSize: true});
|
|
1012
|
+
// handling AG-Grid bug caused by different previous pageSize state
|
|
1013
|
+
const rowHeight = (gridApiWithPrivateAccess.beans.gos as any).getRowHeightAsNumber?.() ?? 1;
|
|
1014
|
+
// @ts-ignore
|
|
1015
|
+
const bodyHeight = (gridApiWithPrivateAccess.beans.ctrlsService as any).params.center.viewportSizeFeature.getBodyHeight();
|
|
1016
|
+
let availablePageSize = 1000;
|
|
1017
|
+
if (bodyHeight > 0) {
|
|
1018
|
+
availablePageSize = Math.floor(bodyHeight / rowHeight);
|
|
1019
|
+
}
|
|
1020
|
+
if (this.props.paging.pageSize > availablePageSize) {
|
|
1021
|
+
this.gridApi.updateGridOptions({paginationPageSize: 1});
|
|
1022
|
+
} else {
|
|
1023
|
+
// special hack to remove setting page size
|
|
1024
|
+
this.gridApi.updateGridOptions({paginationPageSize: null as unknown as number});
|
|
1025
|
+
}
|
|
1026
|
+
if (this.props.paging && this.props.paging.onPaginationChanged) {
|
|
1027
|
+
this.props.paging.onPaginationChanged(this.state.pageSize, 0);
|
|
1028
|
+
}
|
|
1029
|
+
} else {
|
|
1030
|
+
this.gridApi.updateGridOptions({pagination: false, paginationAutoPageSize: false});
|
|
1031
|
+
if (this.props.paging && this.props.paging.onPaginationChanged) {
|
|
1032
|
+
this.props.paging.onPaginationChanged(this.state.pageSize, -1);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
showMilliseconds(showMilis: boolean) {
|
|
1038
|
+
this.props.onShowMilliseconds?.(showMilis, () => {
|
|
1039
|
+
if (!this.gridApi) {
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
|
|
1043
|
+
// table is shown
|
|
1044
|
+
this.gridApi.refreshClientSideRowModel("group");
|
|
1045
|
+
}
|
|
1046
|
+
this.gridApi.redrawRows();
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
showYear(showYear: boolean) {
|
|
1051
|
+
this.props.onShowYear?.(showYear, () => {
|
|
1052
|
+
if (!this.gridApi) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
|
|
1056
|
+
// table is shown
|
|
1057
|
+
this.gridApi.refreshClientSideRowModel("group");
|
|
1058
|
+
}
|
|
1059
|
+
this.gridApi.redrawRows();
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
changeRowHeight(fontSize: number, rowHeight: number) {
|
|
1064
|
+
this.setState({rowHeight: rowHeight}, () => {
|
|
1065
|
+
if (this.gridApi) {
|
|
1066
|
+
if (this.props.headerHeight === undefined) {
|
|
1067
|
+
this.gridApi.updateGridOptions({headerHeight: calculateRowHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2)});
|
|
1068
|
+
}
|
|
1069
|
+
if (this.props.floatingFiltersHeight === undefined) {
|
|
1070
|
+
this.gridApi.updateGridOptions({floatingFiltersHeight: calculateRowHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2)});
|
|
1071
|
+
}
|
|
1072
|
+
this.gridApi.updateGridOptions({rowHeight: rowHeight})
|
|
1073
|
+
this.gridApi.resetRowHeights();
|
|
1074
|
+
this.gridApi.refreshHeader();
|
|
1075
|
+
this.gridApi.redrawRows();
|
|
1076
|
+
if (this.props.rowModelType === "infinite" && this.props.datasource) {
|
|
1077
|
+
(this.gridApi.getModel() as any).rowHeight = rowHeight;
|
|
1078
|
+
// redraws all server side loaded table data
|
|
1079
|
+
this.gridApi.updateGridOptions({datasource: this.props.datasource});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (this.props.onRowHeightChanged) {
|
|
1083
|
+
this.props.onRowHeightChanged(rowHeight);
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
onGoToPage(pageIndex: number) {
|
|
1089
|
+
if (this.gridApi) {
|
|
1090
|
+
this.gridApi.paginationGoToPage(pageIndex);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
loadData(callback?: () => void) {
|
|
1095
|
+
if (!this.gridApi) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
this.setState({loading: true});
|
|
1099
|
+
if (!this.props.loadingOverlayRenderer) {
|
|
1100
|
+
this.gridApi.setGridOption("loading", true);
|
|
1101
|
+
}
|
|
1102
|
+
this.props.onLoadData((totalRecords) => {
|
|
1103
|
+
if (!this.gridApi) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
this.gridApi.setGridOption("loading", false);
|
|
1107
|
+
this.gridApi.hideOverlay();
|
|
1108
|
+
this.setState({loading: false});
|
|
1109
|
+
if (callback) {
|
|
1110
|
+
callback();
|
|
1111
|
+
}
|
|
1112
|
+
if (totalRecords === 0) {
|
|
1113
|
+
setTimeout(() => {
|
|
1114
|
+
if (!this.isActive()) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
this.gridApi?.showNoRowsOverlay();
|
|
1118
|
+
}, 400);
|
|
1119
|
+
}
|
|
1120
|
+
if (this.props.autofocus) {
|
|
1121
|
+
this.focus();
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
public focus() {
|
|
1127
|
+
setTimeout(() => {
|
|
1128
|
+
if (!this.isActive()) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
const columnModel = this.gridApi?.getColumnState();
|
|
1132
|
+
let columnIdToFocus = columnModel?.[0]?.colId || "name";
|
|
1133
|
+
const selectedNodes = this.gridApi?.getSelectedNodes();
|
|
1134
|
+
const selectedRowIndex: number = (selectedNodes && selectedNodes.length > 0 && selectedNodes[selectedNodes.length - 1].rowIndex) || 0;
|
|
1135
|
+
this.gridApi?.setFocusedCell(selectedRowIndex, columnIdToFocus);
|
|
1136
|
+
}, 200);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
isActive(): boolean {
|
|
1140
|
+
return !!this.gridApi && !this.gridApi.isDestroyed();
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
onColumnsChanged(event: ColumnEvent) {
|
|
1144
|
+
const columnModel = event.api.getColumnState();
|
|
1145
|
+
if (this.props.onColumnsChanged) {
|
|
1146
|
+
this.props.onColumnsChanged(columnModel, event);
|
|
1147
|
+
}
|
|
1148
|
+
this.setState({columnModel: columnModel});
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
setColumnSearchVisible(visible: boolean) {
|
|
1152
|
+
if (this.gridApi && this.props.filter && this.props.filter.getFilterModel) {
|
|
1153
|
+
this.gridApi.setFilterModel(this.props.filter.getFilterModel());
|
|
1154
|
+
}
|
|
1155
|
+
if (this.props.filter && this.props.filter.onColumnSearchVisible) {
|
|
1156
|
+
this.props.filter.onColumnSearchVisible(visible);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
private onFilterModified(event: FilterModifiedEvent) {
|
|
1161
|
+
if (this.props.filter && this.props.filter.onFilterModified) {
|
|
1162
|
+
this.props.filter.onFilterModified(event);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
private onFilterChanged(event: FilterChangedEvent) {
|
|
1167
|
+
if (this.props.filter && this.props.filter.onFilterChanged) {
|
|
1168
|
+
this.props.filter.onFilterChanged(event);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
private onFilterConfirmed() {
|
|
1173
|
+
if (this.props.filter && this.props.filter.onFilterConfirmed) {
|
|
1174
|
+
this.props.filter.onFilterConfirmed();
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
private onSortChanged(event: SortChangedEvent) {
|
|
1179
|
+
if (this.props.onSortChanged && this.gridApi) {
|
|
1180
|
+
const currentSortModel = this.getSortModel() as SortItem[];
|
|
1181
|
+
if (!isEqual(this.state.sortModel, currentSortModel)) {
|
|
1182
|
+
// propagate only changes to sorting
|
|
1183
|
+
this.setState({sortModel: currentSortModel}, () => {
|
|
1184
|
+
if (this.props.onSortChanged) {
|
|
1185
|
+
this.props.onSortChanged(event);
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
showTableConfiguration(show: boolean) {
|
|
1193
|
+
if (this.props.onTableConfigVisible) {
|
|
1194
|
+
this.props.onTableConfigVisible(show);
|
|
1195
|
+
}
|
|
1196
|
+
this.setState({tableConfigVisible: show}, () => {
|
|
1197
|
+
if (this.gridApi && !this.state.tableConfigVisible) {
|
|
1198
|
+
// redrawing rows after closing table configuration panel, probably not required any more,
|
|
1199
|
+
// because config panel and table is shown simultaneously
|
|
1200
|
+
if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
|
|
1201
|
+
// table is shown
|
|
1202
|
+
this.gridApi.refreshClientSideRowModel("group");
|
|
1203
|
+
}
|
|
1204
|
+
this.gridApi.redrawRows();
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
showColumnsConfig(show: boolean) {
|
|
1210
|
+
if (this.props.onColumnsConfigVisible) {
|
|
1211
|
+
this.props.onColumnsConfigVisible(show);
|
|
1212
|
+
}
|
|
1213
|
+
this.columnModelBeforeEdit = cloneDeep(this.state.columnModel);
|
|
1214
|
+
this.setState({columnsConfigVisible: show});
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
private navigateToNextCell(params: NavigateToNextCellParams): CellPosition {
|
|
1218
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1219
|
+
var suggestedNextCell = params.nextCellPosition;
|
|
1220
|
+
if (!this.gridApi) {
|
|
1221
|
+
return suggestedNextCell ?? params.previousCellPosition;
|
|
1222
|
+
}
|
|
1223
|
+
const pageIndex = this.gridApi.paginationGetCurrentPage();
|
|
1224
|
+
const totalPages = this.gridApi.paginationGetTotalPages();
|
|
1225
|
+
var previousCell = params.previousCellPosition;
|
|
1226
|
+
switch (params.event?.code) {
|
|
1227
|
+
case Key.ArrowDown:
|
|
1228
|
+
if ((previousCell.rowIndex + 1) >= this.gridApi.getModel().getRowCount()) {
|
|
1229
|
+
if (pageIndex < (totalPages - 1)) {
|
|
1230
|
+
this.onGoToPage(pageIndex + 1);
|
|
1231
|
+
return {
|
|
1232
|
+
rowIndex: 0,
|
|
1233
|
+
column: previousCell.column,
|
|
1234
|
+
rowPinned: previousCell.rowPinned
|
|
1235
|
+
};
|
|
1236
|
+
} else {
|
|
1237
|
+
return {
|
|
1238
|
+
rowIndex: previousCell.rowIndex,
|
|
1239
|
+
column: previousCell.column,
|
|
1240
|
+
rowPinned: previousCell.rowPinned
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
}
|
|
1245
|
+
break;
|
|
1246
|
+
case Key.ArrowUp:
|
|
1247
|
+
if ((previousCell.rowIndex - 1) < 0) {
|
|
1248
|
+
if (pageIndex > 0) {
|
|
1249
|
+
this.onGoToPage(pageIndex - 1);
|
|
1250
|
+
return {
|
|
1251
|
+
rowIndex: this.gridApi.getModel().getRowCount() - 1,
|
|
1252
|
+
column: previousCell.column,
|
|
1253
|
+
rowPinned: previousCell.rowPinned
|
|
1254
|
+
};
|
|
1255
|
+
} else {
|
|
1256
|
+
return {
|
|
1257
|
+
rowIndex: previousCell.rowIndex,
|
|
1258
|
+
column: previousCell.column,
|
|
1259
|
+
rowPinned: previousCell.rowPinned
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
break;
|
|
1264
|
+
}
|
|
1265
|
+
return suggestedNextCell ?? params.previousCellPosition;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
private suppressKeyboardEvent(params: SuppressKeyboardEventParams): boolean {
|
|
1269
|
+
if (!this.gridApi || params.event.type === "keypress") {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
const pageIndex = this.gridApi.paginationGetCurrentPage();
|
|
1273
|
+
const totalPages = this.gridApi.paginationGetTotalPages();
|
|
1274
|
+
switch (params.event.code) {
|
|
1275
|
+
case Key.ArrowDown:
|
|
1276
|
+
case Key.ArrowUp:
|
|
1277
|
+
case Key.ArrowLeft:
|
|
1278
|
+
case Key.ArrowRight:
|
|
1279
|
+
if (params.editing && params.event.altKey) {
|
|
1280
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1281
|
+
if (focusedCell) {
|
|
1282
|
+
let indexToJump: number;
|
|
1283
|
+
let columnToJump: Column;
|
|
1284
|
+
if (params.event.code === Key.ArrowDown) {
|
|
1285
|
+
indexToJump = focusedCell.rowIndex + 1;
|
|
1286
|
+
columnToJump = focusedCell.column;
|
|
1287
|
+
if (indexToJump >= this.gridApi.getModel().getRowCount()) {
|
|
1288
|
+
if (pageIndex < (totalPages - 1)) {
|
|
1289
|
+
this.onGoToPage(pageIndex + 1);
|
|
1290
|
+
indexToJump = 0
|
|
1291
|
+
} else {
|
|
1292
|
+
indexToJump = focusedCell.rowIndex;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1296
|
+
this.indexToJump = indexToJump;
|
|
1297
|
+
this.columnToJump = columnToJump;
|
|
1298
|
+
setTimeout(() => {
|
|
1299
|
+
this.gridApi?.startEditingCell({
|
|
1300
|
+
rowIndex: indexToJump,
|
|
1301
|
+
colKey: columnToJump,
|
|
1302
|
+
key: Key.Enter
|
|
1303
|
+
});
|
|
1304
|
+
}, 0);
|
|
1305
|
+
return true;
|
|
1306
|
+
} else if (params.event.code === Key.ArrowUp) {
|
|
1307
|
+
indexToJump = focusedCell.rowIndex - 1;
|
|
1308
|
+
columnToJump = focusedCell.column;
|
|
1309
|
+
if (indexToJump < 0) {
|
|
1310
|
+
if (pageIndex > 0) {
|
|
1311
|
+
this.onGoToPage(pageIndex - 1);
|
|
1312
|
+
indexToJump = this.gridApi.getModel().getRowCount() - 1;
|
|
1313
|
+
} else {
|
|
1314
|
+
indexToJump = focusedCell.rowIndex;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1318
|
+
this.indexToJump = indexToJump;
|
|
1319
|
+
this.columnToJump = columnToJump;
|
|
1320
|
+
setTimeout(() => {
|
|
1321
|
+
this.gridApi?.startEditingCell({
|
|
1322
|
+
rowIndex: indexToJump,
|
|
1323
|
+
colKey: columnToJump,
|
|
1324
|
+
key: Key.Enter
|
|
1325
|
+
});
|
|
1326
|
+
}, 0);
|
|
1327
|
+
return true;
|
|
1328
|
+
} else if (params.event.code === Key.ArrowLeft) {
|
|
1329
|
+
this.gridApi.tabToPreviousCell();
|
|
1330
|
+
break;
|
|
1331
|
+
} else /*Key.ArrowRight*/ {
|
|
1332
|
+
this.gridApi.tabToNextCell();
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
break;
|
|
1338
|
+
case Key.PageDown:
|
|
1339
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1340
|
+
if (pageIndex < (totalPages - 1)) {
|
|
1341
|
+
this.gridApi.paginationGoToNextPage();
|
|
1342
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1343
|
+
if (focusedCell) {
|
|
1344
|
+
this.indexToJump = Math.min(focusedCell.rowIndex + this.gridApi.paginationGetPageSize(), this.gridApi.paginationGetRowCount());
|
|
1345
|
+
this.columnToJump = focusedCell.column;
|
|
1346
|
+
return true;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
break;
|
|
1350
|
+
case Key.PageUp:
|
|
1351
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1352
|
+
if (pageIndex > 0) {
|
|
1353
|
+
this.gridApi.paginationGoToPreviousPage();
|
|
1354
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1355
|
+
if (focusedCell) {
|
|
1356
|
+
this.indexToJump = Math.max(focusedCell.rowIndex - this.gridApi.paginationGetPageSize(), 0);
|
|
1357
|
+
this.columnToJump = focusedCell.column;
|
|
1358
|
+
return true;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
break;
|
|
1362
|
+
case Key.End:
|
|
1363
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1364
|
+
if (pageIndex < (totalPages - 1)) {
|
|
1365
|
+
this.gridApi.paginationGoToLastPage();
|
|
1366
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1367
|
+
if (focusedCell) {
|
|
1368
|
+
this.indexToJump = this.gridApi.paginationGetRowCount() - 1;
|
|
1369
|
+
this.columnToJump = focusedCell.column;
|
|
1370
|
+
return true;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
break;
|
|
1374
|
+
case Key.Home:
|
|
1375
|
+
this.lastNavigationEvent = NavigationEventEnum.KEYBOARD;
|
|
1376
|
+
if (pageIndex > 0) {
|
|
1377
|
+
this.gridApi.paginationGoToFirstPage();
|
|
1378
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1379
|
+
if (focusedCell) {
|
|
1380
|
+
this.indexToJump = 0;
|
|
1381
|
+
this.columnToJump = focusedCell.column;
|
|
1382
|
+
return true;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
break;
|
|
1386
|
+
case "KeyA":
|
|
1387
|
+
if (params.event.ctrlKey && !params.editing) {
|
|
1388
|
+
var firstRow = this.gridApi.getFirstDisplayedRowIndex();
|
|
1389
|
+
var lastRow = this.gridApi.getLastDisplayedRowIndex();
|
|
1390
|
+
this.gridApi.deselectAll();
|
|
1391
|
+
if (this.props.rowModelType === "infinite") {
|
|
1392
|
+
for (let i = firstRow; i <= lastRow; i++) {
|
|
1393
|
+
this.gridApi.getDisplayedRowAtIndex(i)?.setSelected(true);
|
|
1394
|
+
}
|
|
1395
|
+
} else {
|
|
1396
|
+
this.gridApi.forEachNodeAfterFilter(function (node, index) {
|
|
1397
|
+
if (index >= firstRow && index <= lastRow) {
|
|
1398
|
+
node.setSelected(true);
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
break;
|
|
1404
|
+
case "KeyI":
|
|
1405
|
+
if (params.event.ctrlKey) {
|
|
1406
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1407
|
+
const column = this.gridApi?.getColumn("objectId") ?? this.gridApi?.getColumn("id");
|
|
1408
|
+
if (focusedCell && column) {
|
|
1409
|
+
const displayedRowAtIndex = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
|
|
1410
|
+
if (displayedRowAtIndex) {
|
|
1411
|
+
ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex));
|
|
1412
|
+
}
|
|
1413
|
+
this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
break;
|
|
1417
|
+
case "KeyB":
|
|
1418
|
+
if (params.event.ctrlKey) {
|
|
1419
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1420
|
+
const column = this.gridApi?.getColumn("objectName") ?? this.gridApi?.getColumn("name");
|
|
1421
|
+
if (focusedCell && column) {
|
|
1422
|
+
const displayedRowAtIndex1 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
|
|
1423
|
+
if (displayedRowAtIndex1) {
|
|
1424
|
+
ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex1));
|
|
1425
|
+
}
|
|
1426
|
+
this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
break;
|
|
1430
|
+
case "KeyC":
|
|
1431
|
+
if (params.event.ctrlKey && !params.editing) {
|
|
1432
|
+
const focusedCell = this.gridApi.getFocusedCell();
|
|
1433
|
+
if (focusedCell) {
|
|
1434
|
+
const displayedRowAtIndex2 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
|
|
1435
|
+
if (displayedRowAtIndex2) {
|
|
1436
|
+
ClipboardUtils.copyToClipboard(this.getValue(focusedCell.column, displayedRowAtIndex2, true));
|
|
1437
|
+
}
|
|
1438
|
+
this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
break;
|
|
1442
|
+
case Key.Enter:
|
|
1443
|
+
this.props.onEnter?.();
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
this.props.onKeyPressed?.(params.event);
|
|
1447
|
+
return false;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
getValue(column: Column, row: IRowNode, doNotReplaceNewline?: boolean): string {
|
|
1451
|
+
let formattedValue = this.gridApi?.getCellValue({rowNode: row, colKey: column});
|
|
1452
|
+
if (formattedValue && typeof formattedValue === "string" && formattedValue.indexOf(EXPORT_SEPARATOR) > 0 && !doNotReplaceNewline) {
|
|
1453
|
+
formattedValue = formattedValue.replace(/[\n\r]+/, ' ');
|
|
1454
|
+
}
|
|
1455
|
+
const valueFormatter = column.getColDef().valueFormatter;
|
|
1456
|
+
if (valueFormatter) {
|
|
1457
|
+
const params: ValueFormatterParams = {
|
|
1458
|
+
data: row.data,
|
|
1459
|
+
node: row,
|
|
1460
|
+
column: column,
|
|
1461
|
+
colDef: column.getColDef(),
|
|
1462
|
+
api: this.gridApi as GridApi,
|
|
1463
|
+
context: this.gridApi?.getGridOption('context'),
|
|
1464
|
+
value: formattedValue
|
|
1465
|
+
};
|
|
1466
|
+
if (typeof valueFormatter === 'function') {
|
|
1467
|
+
formattedValue = valueFormatter?.(params);
|
|
1468
|
+
} else if (typeof valueFormatter === 'string') {
|
|
1469
|
+
formattedValue = at(row.data, valueFormatter)[0];
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return formattedValue;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
async getExportContent(progressPopup: ProgressPopup | null, props: ContextMenuProps): Promise<string[][]> {
|
|
1476
|
+
if (!this.gridApi) {
|
|
1477
|
+
return [];
|
|
1478
|
+
}
|
|
1479
|
+
const model: IRowModel = this.gridApi.getModel();
|
|
1480
|
+
const tableContent: string[][] = [];
|
|
1481
|
+
const columns = this.gridApi.getAllDisplayedColumns().map((column: Column) => {
|
|
1482
|
+
const columnTypes = column.getColDef().type;
|
|
1483
|
+
return {
|
|
1484
|
+
column: column,
|
|
1485
|
+
displayName: column.getColDef().headerName,
|
|
1486
|
+
isDateField: columnTypes && columnTypes.indexOf("dateColumn") >= 0,
|
|
1487
|
+
isDateTimeField: columnTypes && columnTypes.indexOf("dateTimeColumn") >= 0
|
|
1488
|
+
};
|
|
1489
|
+
});
|
|
1490
|
+
if (columns.length === 0) {
|
|
1491
|
+
return tableContent;
|
|
1492
|
+
}
|
|
1493
|
+
tableContent.push(columns.map((column) => column.displayName ?? ""));
|
|
1494
|
+
|
|
1495
|
+
let rowCount: number;
|
|
1496
|
+
let tableNodes: IRowNode[] = [];
|
|
1497
|
+
if (model.getType() === "clientSide") {
|
|
1498
|
+
if (props.onlySelectedNodes) {
|
|
1499
|
+
rowCount = 0;
|
|
1500
|
+
this.gridApi.forEachNodeAfterFilterAndSort((node) => {
|
|
1501
|
+
if (node.isSelected()) {
|
|
1502
|
+
tableNodes.push(node);
|
|
1503
|
+
rowCount++;
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
} else {
|
|
1507
|
+
rowCount = model.getRowCount();
|
|
1508
|
+
this.gridApi.forEachNodeAfterFilterAndSort((node) => {
|
|
1509
|
+
tableNodes.push(node);
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
} else {
|
|
1513
|
+
if (props.onlySelectedNodes) {
|
|
1514
|
+
const selectedNodes = this.gridApi.getSelectedNodes();
|
|
1515
|
+
rowCount = selectedNodes.length;
|
|
1516
|
+
selectedNodes.forEach((node) => {
|
|
1517
|
+
tableNodes.push(node);
|
|
1518
|
+
});
|
|
1519
|
+
tableNodes.sort((a, b) => (a.rowIndex ?? 0) > (b.rowIndex ?? 0) ? 1 : (a.rowIndex === b.rowIndex) ? 0 : -1);
|
|
1520
|
+
} else {
|
|
1521
|
+
const virtualRowCount = model.getRowCount();
|
|
1522
|
+
rowCount = virtualRowCount ? virtualRowCount : 0;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
progressPopup?.setRecordCount(rowCount);
|
|
1526
|
+
|
|
1527
|
+
let percentStep = Math.floor(rowCount / 100);
|
|
1528
|
+
if (percentStep < 100) {
|
|
1529
|
+
percentStep = 100;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
if (model.getType() === "clientSide" || props.onlySelectedNodes) {
|
|
1533
|
+
for (let index = 0; index < tableNodes.length; index++) {
|
|
1534
|
+
const record: string[] = [];
|
|
1535
|
+
columns.forEach((column) => {
|
|
1536
|
+
let value = this.getValue(column.column, tableNodes[index]);
|
|
1537
|
+
record.push(value);
|
|
1538
|
+
});
|
|
1539
|
+
tableContent.push(record);
|
|
1540
|
+
if (index % percentStep === 0) {
|
|
1541
|
+
progressPopup?.update(Math.floor(index / rowCount * 100) - 1);
|
|
1542
|
+
await TimeUtils.sleep(100);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
} else {
|
|
1546
|
+
for (let index = 0; index < rowCount; index++) {
|
|
1547
|
+
let row: RowNode | undefined = undefined;
|
|
1548
|
+
let record: any[] = [];
|
|
1549
|
+
do {
|
|
1550
|
+
record = [];
|
|
1551
|
+
do {
|
|
1552
|
+
row = model.getRow(index);
|
|
1553
|
+
if (!row || !row.data) {
|
|
1554
|
+
await TimeUtils.sleep(100);
|
|
1555
|
+
}
|
|
1556
|
+
} while (!row || !row.data);
|
|
1557
|
+
columns.forEach((column) => {
|
|
1558
|
+
record.push(this.getValue(column.column, row as RowNode));
|
|
1559
|
+
});
|
|
1560
|
+
if (record.filter((cell) => !!cell).length === 0) {
|
|
1561
|
+
await TimeUtils.sleep(100);
|
|
1562
|
+
}
|
|
1563
|
+
} while (record.filter((cell) => !!cell).length === 0);
|
|
1564
|
+
tableContent.push(record);
|
|
1565
|
+
if (index % percentStep === 0) {
|
|
1566
|
+
// noinspection ES6MissingAwait
|
|
1567
|
+
progressPopup?.update(Math.floor(index / rowCount * 100) - 1);
|
|
1568
|
+
await TimeUtils.sleep(100);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
// noinspection ES6MissingAwait
|
|
1573
|
+
progressPopup?.update(99);
|
|
1574
|
+
await TimeUtils.sleep(300);
|
|
1575
|
+
return tableContent;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
onCellFocused(event: CellFocusedEvent) {
|
|
1579
|
+
const row: IRowNode | undefined = event.rowIndex !== null ? this.gridApi?.getDisplayedRowAtIndex(event.rowIndex) : undefined;
|
|
1580
|
+
if (row) {
|
|
1581
|
+
if (this.lastNavigationEvent === NavigationEventEnum.KEYBOARD && KeyboardUtils.isKeyPressed(Key.Shift) && this.lastCellFocus && this.lastCellFocus.rowIndex !== event.rowIndex) {
|
|
1582
|
+
// focusing new row with SHIFT key pressed
|
|
1583
|
+
if (!row.isSelected()) {
|
|
1584
|
+
// add to selection
|
|
1585
|
+
row.setSelected(true, false);
|
|
1586
|
+
} else if (this.lastCellFocus?.rowIndex !== null) {
|
|
1587
|
+
const lastFocusedRow: IRowNode | undefined = this.gridApi?.getDisplayedRowAtIndex(this.lastCellFocus.rowIndex);
|
|
1588
|
+
if (lastFocusedRow?.isSelected()) {
|
|
1589
|
+
lastFocusedRow.setSelected(false, false);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
} else if (!row.isSelected() && !KeyboardUtils.isKeyPressed(Key.Control) && !KeyboardUtils.isKeyPressed(Key.Shift)) {
|
|
1593
|
+
row.setSelected(true, true);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
this.props.onCellFocused?.(event);
|
|
1597
|
+
this.lastCellFocus = event;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
onCellMouseDown(e: CellMouseDownEvent) {
|
|
1601
|
+
this.lastNavigationEvent = NavigationEventEnum.MOUSE;
|
|
1602
|
+
// always focus clicked cell (also when using shift key)
|
|
1603
|
+
if (e.rowIndex !== null) {
|
|
1604
|
+
this.setFocusedCellDebounced(e.rowIndex, e.column, e.rowPinned !== null ? e.rowPinned : undefined);
|
|
1605
|
+
}
|
|
1606
|
+
this.props.onCellMouseDown?.(e);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
setFocusedCellDebounced(rowIndex: number, column: string | Column, rowPinned: RowPinnedType) {
|
|
1610
|
+
this.gridApi?.setFocusedCell(rowIndex, column, rowPinned);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
private onCellContextMenu(event: CellContextMenuEvent) {
|
|
1614
|
+
this.setState({contextMenuVisible: !!event});
|
|
1615
|
+
if (event.node) {
|
|
1616
|
+
if (!event.node.isSelected()) {
|
|
1617
|
+
event.node.setSelected(true, true);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
private loadingOverlayRenderer(): ReactElement {
|
|
1623
|
+
if (this.props.loadingOverlayRenderer) {
|
|
1624
|
+
const loadingOverlay = this.props.loadingOverlayRenderer();
|
|
1625
|
+
if (loadingOverlay) {
|
|
1626
|
+
return loadingOverlay;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
return <div><LoadingOutlined style={{fontSize: 40, color: "#1890ff"}}/></div>;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
private noRecordsOverlayRenderer(): ReactElement {
|
|
1633
|
+
if (this.props.noRecordsOverlayRenderer) {
|
|
1634
|
+
const noRecordsOverlay = this.props.noRecordsOverlayRenderer();
|
|
1635
|
+
if (noRecordsOverlay) {
|
|
1636
|
+
return noRecordsOverlay;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return (
|
|
1640
|
+
<Empty description={i18n("No records found.")} imageStyle={{height: "8vh"}}>
|
|
1641
|
+
<Button type="primary" onClick={() => {
|
|
1642
|
+
if (this.props.search && this.props.search.onSearch) {
|
|
1643
|
+
this.props.search.onSearch();
|
|
1644
|
+
}
|
|
1645
|
+
}}>
|
|
1646
|
+
<SearchOutlined/> {i18n("Search")}
|
|
1647
|
+
</Button>
|
|
1648
|
+
</Empty>
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/** Set new data to the grid */
|
|
1653
|
+
public setRowData(dataArray: any[]): void {
|
|
1654
|
+
this.gridApi?.updateGridOptions({rowData: dataArray});
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
private onRowDataUpdated(event: RowDataUpdatedEvent) {
|
|
1658
|
+
if (!this.gridApi) {
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
const currentPage = this.gridApi.paginationGetCurrentPage();
|
|
1662
|
+
const recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
|
|
1663
|
+
this.setState({recordsCount: recordsCount, pageIndex: currentPage});
|
|
1664
|
+
if (this.props.onRowDataUpdated) {
|
|
1665
|
+
this.props.onRowDataUpdated(event);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
private static EMPTY_STYLE: RowStyle = {}
|
|
1670
|
+
|
|
1671
|
+
_getRowStyle(params: RowClassParams): RowStyle {
|
|
1672
|
+
const rowStyleRules = this.props.rowStyleRules;
|
|
1673
|
+
if (rowStyleRules) {
|
|
1674
|
+
const style: any = {};
|
|
1675
|
+
rowStyleRules.forEach((rowStyleRule) => {
|
|
1676
|
+
if (rowStyleRule.expression) {
|
|
1677
|
+
if (!rowStyleRuleCompiledExpressions[rowStyleRule.expression]) {
|
|
1678
|
+
rowStyleRuleCompiledExpressions[rowStyleRule.expression] = compileExpression(rowStyleRule.expression);
|
|
1679
|
+
}
|
|
1680
|
+
if (rowStyleRuleCompiledExpressions[rowStyleRule.expression](params.node.data)) {
|
|
1681
|
+
Object.assign(style, rowStyleRule.style);
|
|
1682
|
+
}
|
|
1683
|
+
} else {
|
|
1684
|
+
Object.assign(style, rowStyleRule.style);
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
if (!style.color) {
|
|
1688
|
+
style.color = null;
|
|
1689
|
+
} else if (typeof style.color === "object") {
|
|
1690
|
+
style.color = `rgba(${style.color.r},${style.color.g},${style.color.b},${style.color.a})`;
|
|
1691
|
+
}
|
|
1692
|
+
if (!style.backgroundColor) {
|
|
1693
|
+
style.backgroundColor = "inherit";
|
|
1694
|
+
} else if (typeof style.backgroundColor === "object") {
|
|
1695
|
+
style.backgroundColor = `rgba(${style.backgroundColor.r},${style.backgroundColor.g},${style.backgroundColor.b},${style.backgroundColor.a})`;
|
|
1696
|
+
}
|
|
1697
|
+
if (!style.fontWeight) {
|
|
1698
|
+
style.fontWeight = "inherit";
|
|
1699
|
+
}
|
|
1700
|
+
const fontSize = style.fontSize;
|
|
1701
|
+
if (style.fontSize) {
|
|
1702
|
+
style.fontSize = style.fontSize + "px";
|
|
1703
|
+
} else {
|
|
1704
|
+
style.fontSize = "inherit";
|
|
1705
|
+
}
|
|
1706
|
+
if (style.rowHeightDelta) {
|
|
1707
|
+
const lineHeight = calculateLineHeight(fontSize, style.rowHeightDelta);
|
|
1708
|
+
if (style.rowHeightDelta) {
|
|
1709
|
+
delete style.rowHeightDelta;
|
|
1710
|
+
}
|
|
1711
|
+
style.lineHeight = lineHeight + "px";
|
|
1712
|
+
} else {
|
|
1713
|
+
const lineHeight = calculateLineHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA);
|
|
1714
|
+
style.lineHeight = lineHeight + "px";
|
|
1715
|
+
}
|
|
1716
|
+
if (this.props.getRowStyle) {
|
|
1717
|
+
const rowStyle = this.props.getRowStyle(params);
|
|
1718
|
+
if (rowStyle) {
|
|
1719
|
+
return Object.assign(style, rowStyle) as RowStyle;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return style as RowStyle;
|
|
1723
|
+
}
|
|
1724
|
+
return DataGrid.EMPTY_STYLE;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
_getRowHeight(): number {
|
|
1728
|
+
return this.state.rowHeight;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
_getCellStyle(params: { colDef: ColDef }) {
|
|
1732
|
+
const fontSize = this.state.fontSize;
|
|
1733
|
+
const cellStyles: { [key: string]: any } = {"fontSize": fontSize + "px"};
|
|
1734
|
+
if (params.colDef.type && params.colDef.type.indexOf("alignRight") >= 0) {
|
|
1735
|
+
cellStyles["textAlign"] = "right";
|
|
1736
|
+
}
|
|
1737
|
+
if (params.colDef.cellRendererParams?.originalCellStyle) {
|
|
1738
|
+
const originalCellStylesOrHandler = params.colDef.cellRendererParams.originalCellStyle as {} | ((params: any) => {});
|
|
1739
|
+
if (typeof originalCellStylesOrHandler === "object") {
|
|
1740
|
+
Object.assign(cellStyles, originalCellStylesOrHandler);
|
|
1741
|
+
} else if (typeof originalCellStylesOrHandler === "function") {
|
|
1742
|
+
const originalCellStyles = originalCellStylesOrHandler(params);
|
|
1743
|
+
if (originalCellStyles) {
|
|
1744
|
+
Object.assign(cellStyles, originalCellStyles);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return cellStyles;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
getDefaultColDefinition(colDef: ColDef | undefined): ColDef {
|
|
1752
|
+
if (colDef) {
|
|
1753
|
+
return {...colDef, suppressKeyboardEvent: this.suppressKeyboardEvent} as ColDef;
|
|
1754
|
+
} else {
|
|
1755
|
+
return {suppressKeyboardEvent: this.suppressKeyboardEvent} as ColDef;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
private getCustomComponents(components: any) {
|
|
1760
|
+
let customComponents = gridFrameworkComponents;
|
|
1761
|
+
if (components) {
|
|
1762
|
+
customComponents = Object.assign(gridFrameworkComponents, components);
|
|
1763
|
+
}
|
|
1764
|
+
return customComponents;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
private onPageOrientationChange(pageOrientation: PageOrientation) {
|
|
1768
|
+
this.setState({pageOrientation: pageOrientation});
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
private onExport(start: boolean) {
|
|
1772
|
+
this.setState({exporting: start});
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
renderNavigationPanel(): ReactElement {
|
|
1776
|
+
return (
|
|
1777
|
+
<React.Fragment>
|
|
1778
|
+
{this.props.toolbar && this.props.toolbar.renderToolbar ? this.props.toolbar.renderToolbar(this.renderToolBarWithSearch()) : this.renderToolBarWithSearch()}
|
|
1779
|
+
{this.props.paging.pageSize >= 0 &&
|
|
1780
|
+
<DataGridPagination
|
|
1781
|
+
disabled={this.state.loading}
|
|
1782
|
+
current={this.state.pageIndex ? this.state.pageIndex + 1 : 1}
|
|
1783
|
+
pageSize={this.state.pageSize ? this.state.pageSize : 20}
|
|
1784
|
+
total={this.state.recordsCount ?? 1}
|
|
1785
|
+
onGoToPage={page => {
|
|
1786
|
+
this.onGoToPage(page - 1);
|
|
1787
|
+
}}
|
|
1788
|
+
/>}
|
|
1789
|
+
{this.props.paging.pageSize < 0 && this.state.recordsCount && !this.props.toolbar?.hideRecordCount ?
|
|
1790
|
+
<span style={{
|
|
1791
|
+
flex: "0 1 auto",
|
|
1792
|
+
textAlign: "right",
|
|
1793
|
+
whiteSpace: "nowrap",
|
|
1794
|
+
margin: "0 12px",
|
|
1795
|
+
lineHeight: "32px",
|
|
1796
|
+
}}>{`${this.state.viewport[0]}-${this.state.viewport[1]} ${i18n('of')} ${this.state.recordsCount}`}</span>
|
|
1797
|
+
: undefined}
|
|
1798
|
+
</React.Fragment>
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
renderToolBarWithSearch(): ReactElement {
|
|
1803
|
+
return (
|
|
1804
|
+
<Space.Compact key="filter-panel"
|
|
1805
|
+
className="datagrid-autocomplete-input-group"
|
|
1806
|
+
style={{whiteSpace: "nowrap", flexGrow: 1, display: "flex"}}>
|
|
1807
|
+
{this.props.toolbar?.toolbarButtons}
|
|
1808
|
+
<Dropdown trigger={["click"]}
|
|
1809
|
+
menu={getContextMenu({
|
|
1810
|
+
showMilliseconds: !!this.props.showMilliseconds,
|
|
1811
|
+
showYear: !this.props.hideYear,
|
|
1812
|
+
renderer: this.props.exportMenu?.renderer,
|
|
1813
|
+
onClick: this.props.exportMenu?.onClick,
|
|
1814
|
+
getExportContent: this.getExportContent,
|
|
1815
|
+
pageOrientation: this.state.pageOrientation,
|
|
1816
|
+
exporting: this.state.exporting,
|
|
1817
|
+
onPageOrientationChange: this.onPageOrientationChange,
|
|
1818
|
+
onExport: this.onExport
|
|
1819
|
+
})}
|
|
1820
|
+
disabled={this.state.loading}>
|
|
1821
|
+
<Button title={i18n("Export")}>
|
|
1822
|
+
<DownloadOutlined/>
|
|
1823
|
+
</Button>
|
|
1824
|
+
</Dropdown>
|
|
1825
|
+
|
|
1826
|
+
<Dropdown trigger={["click"]}
|
|
1827
|
+
menu={this.getSettingsMenu()}>
|
|
1828
|
+
<Button
|
|
1829
|
+
title={i18n("Extended table features")}
|
|
1830
|
+
disabled={this.state.loading}>
|
|
1831
|
+
<TableOutlined/>
|
|
1832
|
+
</Button>
|
|
1833
|
+
</Dropdown>
|
|
1834
|
+
{!this.props.search?.hidden && !this.props.search?.searchRenderer && <AutoCompleteInput
|
|
1835
|
+
style={{minWidth: 100, flexGrow: 1}}
|
|
1836
|
+
placeholder={this.props.search ? this.props.search.placeholder : undefined}
|
|
1837
|
+
stringFormatter={this.props.search ? this.props.search.stringFormatter : undefined}
|
|
1838
|
+
value={this.props.search ? this.props.search.searchString : undefined}
|
|
1839
|
+
options={this.props.search ? this.props.search.searchHistory : undefined}
|
|
1840
|
+
onChange={this.props.search ? this.props.search.onChange : undefined}
|
|
1841
|
+
onSearch={this.props.search ? this.props.search.onSearch : undefined}
|
|
1842
|
+
disabled={this.state.loading || (this.props.filter && this.props.filter.columnSearchVisible)}
|
|
1843
|
+
/>}
|
|
1844
|
+
{this.props.search?.searchRenderer?.()}
|
|
1845
|
+
{!this.props.search?.searchButtonHidden &&
|
|
1846
|
+
<Button title={this.props.search?.hidden ? i18n("Refresh") : i18n("Search")}
|
|
1847
|
+
className={"search-btn " + (this.props.search && this.props.search.searchButtonClassName ? this.props.search.searchButtonClassName : "")}
|
|
1848
|
+
disabled={this.props.search?.searchButtonDisabled}
|
|
1849
|
+
type="primary"
|
|
1850
|
+
onClick={() => {
|
|
1851
|
+
if (this.props.search && this.props.search.onSearch) {
|
|
1852
|
+
this.props.search.onSearch();
|
|
1853
|
+
}
|
|
1854
|
+
}}>
|
|
1855
|
+
{this.state.loading ? <LoadingOutlined/> : (this.props.search?.hidden ? <ReloadOutlined/> :
|
|
1856
|
+
<SearchOutlined/>)}
|
|
1857
|
+
</Button>
|
|
1858
|
+
}
|
|
1859
|
+
</Space.Compact>
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
getSettingsMenu(): MenuProps {
|
|
1864
|
+
let menuItems: MenuElement[] = [
|
|
1865
|
+
{
|
|
1866
|
+
key: "columnFilter",
|
|
1867
|
+
icon: <FileSearchOutlined/>,
|
|
1868
|
+
className: this.props.filter && this.props.filter.columnSearchVisible ? "ant-dropdown-menu-item-selected" : "",
|
|
1869
|
+
title: i18n("Turn on/off column filter"),
|
|
1870
|
+
label: i18n("Column Filter"),
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
key: "autosizeAllColumns",
|
|
1874
|
+
icon: <ColumnWidthOutlined/>,
|
|
1875
|
+
label: i18n("Autosize All Columns"),
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
key: "columnsConfig",
|
|
1879
|
+
icon: <ControlOutlined/>,
|
|
1880
|
+
label: i18n("Columns Configuration"),
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
key: "columnsAndAdvancedConfigDivider",
|
|
1884
|
+
type: "divider"
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
key: "advancedConfig",
|
|
1888
|
+
icon: <SettingOutlined/>,
|
|
1889
|
+
label: i18n("Advanced Settings"),
|
|
1890
|
+
}
|
|
1891
|
+
];
|
|
1892
|
+
|
|
1893
|
+
if (this.props.settingsMenu?.renderer) {
|
|
1894
|
+
menuItems = this.props.settingsMenu.renderer(menuItems);
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
return {
|
|
1898
|
+
items: menuItems,
|
|
1899
|
+
onClick: (menuInfo) => {
|
|
1900
|
+
switch (menuInfo.key) {
|
|
1901
|
+
case "columnFilter":
|
|
1902
|
+
const visible = !(this.props.filter && this.props.filter.columnSearchVisible);
|
|
1903
|
+
this.setColumnSearchVisible(visible);
|
|
1904
|
+
break;
|
|
1905
|
+
case "autosizeAllColumns":
|
|
1906
|
+
this.gridApi?.autoSizeAllColumns();
|
|
1907
|
+
break;
|
|
1908
|
+
case "columnsConfig":
|
|
1909
|
+
this.showColumnsConfig(true);
|
|
1910
|
+
break;
|
|
1911
|
+
case "advancedConfig":
|
|
1912
|
+
this.showTableConfiguration(true);
|
|
1913
|
+
break;
|
|
1914
|
+
default:
|
|
1915
|
+
if (this.props.settingsMenu?.onClick) {
|
|
1916
|
+
this.props.settingsMenu.onClick(menuInfo.key + "");
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
private getAdaptedColumnDefs(columnDefs: DataGridColDef[], floatingFilterEnabled: boolean | undefined, disableColumnDefsPreprocessing: boolean) {
|
|
1924
|
+
if (columnDefs.length === 0) {
|
|
1925
|
+
return undefined;
|
|
1926
|
+
}
|
|
1927
|
+
if (disableColumnDefsPreprocessing) {
|
|
1928
|
+
return columnDefs;
|
|
1929
|
+
}
|
|
1930
|
+
const adaptedColumnDefs = columnDefs ? columnDefs.map((columnDef) => {
|
|
1931
|
+
const {group, floatingFilter, hide, cellEditorPopup, editable, ...rest} = columnDef as DataGridColDef;
|
|
1932
|
+
let floatingFilterEnabledForColumn = !!floatingFilter;
|
|
1933
|
+
if (typeof columnDef.type === "string") {
|
|
1934
|
+
if (!!(this.columnTypes[columnDef.type]?.floatingFilter)) {
|
|
1935
|
+
floatingFilterEnabledForColumn = true;
|
|
1936
|
+
}
|
|
1937
|
+
} else {
|
|
1938
|
+
columnDef.type?.forEach((type) => {
|
|
1939
|
+
if (!!(this.columnTypes[type]?.floatingFilter)) {
|
|
1940
|
+
floatingFilterEnabledForColumn = true;
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
|
|
1944
|
+
}
|
|
1945
|
+
return {
|
|
1946
|
+
...rest,
|
|
1947
|
+
floatingFilter: floatingFilterEnabledForColumn && floatingFilterEnabled,
|
|
1948
|
+
resizable: true,
|
|
1949
|
+
headerComponent: "simpleHeader",
|
|
1950
|
+
headerComponentParams: {
|
|
1951
|
+
onColumnsConfigVisible: this.showColumnsConfig
|
|
1952
|
+
},
|
|
1953
|
+
hide: hide === undefined ? rest.initialHide : hide,
|
|
1954
|
+
cellStyle: this._getCellStyle,
|
|
1955
|
+
cellRendererParams: columnDef.cellStyle ? Object.assign(columnDef.cellRendererParams !== undefined ? columnDef.cellRendererParams : {}, {originalCellStyle: columnDef.cellStyle}) : columnDef.cellRendererParams,
|
|
1956
|
+
editable: editable,
|
|
1957
|
+
cellEditorPopup: !editable ? undefined : cellEditorPopup !== false
|
|
1958
|
+
};
|
|
1959
|
+
}) : undefined;
|
|
1960
|
+
if (adaptedColumnDefs) {
|
|
1961
|
+
setTimeout(() => {
|
|
1962
|
+
this.props.onColumnDefsAdapted?.(adaptedColumnDefs);
|
|
1963
|
+
}, 0);
|
|
1964
|
+
}
|
|
1965
|
+
return adaptedColumnDefs;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
render() {
|
|
1969
|
+
const {
|
|
1970
|
+
onGridReady,
|
|
1971
|
+
columnDefs, disableColumnDefsPreprocessing, onColumnsChanged,
|
|
1972
|
+
paging, onPaginationChanged, onViewportChanged,
|
|
1973
|
+
selectedIds,
|
|
1974
|
+
search, toolbar,
|
|
1975
|
+
filter, onFilterChanged, onFilterModified, onCellFocused,
|
|
1976
|
+
onSortChanged, components,
|
|
1977
|
+
tableConfigVisible, onTableConfigVisible,
|
|
1978
|
+
noRecordsOverlayRenderer, loadingOverlayRenderer, onRowDataUpdated,
|
|
1979
|
+
rowStyleRules, onChangeRowStyleRules,
|
|
1980
|
+
defaultShowMilliseconds, onShowMilliseconds, defaultHideYear, onShowYear,
|
|
1981
|
+
suppressLoadingOverlay, defaultColDef, headerHeight,
|
|
1982
|
+
rowData,
|
|
1983
|
+
rowDataManualMode,
|
|
1984
|
+
gridRef,
|
|
1985
|
+
quickFilterParser, quickFilterMatcher,
|
|
1986
|
+
...passedProperties
|
|
1987
|
+
} = this.props;
|
|
1988
|
+
let key: string;
|
|
1989
|
+
let paginationPageSize: number | undefined = undefined;
|
|
1990
|
+
if (paging.pageSize > 0) {
|
|
1991
|
+
paginationPageSize = paging.pageSize;
|
|
1992
|
+
passedProperties.pagination = true;
|
|
1993
|
+
key = "paginated-table";
|
|
1994
|
+
} else if (paging.pageSize === 0) {
|
|
1995
|
+
passedProperties.paginationAutoPageSize = true;
|
|
1996
|
+
passedProperties.pagination = true;
|
|
1997
|
+
key = "paginated-table";
|
|
1998
|
+
} else {
|
|
1999
|
+
// pagination is disabled
|
|
2000
|
+
passedProperties.pagination = false;
|
|
2001
|
+
key = "non-paginated-table";
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
// nejde
|
|
2005
|
+
const floatingFilterEnabled = !!filter && !!filter.columnSearchVisible;
|
|
2006
|
+
const adaptedColumnDefs = this.getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, !!disableColumnDefsPreprocessing);
|
|
2007
|
+
|
|
2008
|
+
const customComponents = this.getCustomComponents(components);
|
|
2009
|
+
const debugMode = process.env.NODE_ENV === 'development';
|
|
2010
|
+
const panelStyle = {
|
|
2011
|
+
display: "flex",
|
|
2012
|
+
flexFlow: "column",
|
|
2013
|
+
height: "100%",
|
|
2014
|
+
width: "100%",
|
|
2015
|
+
paddingBottom: 8,
|
|
2016
|
+
};
|
|
2017
|
+
if (this.props.panelStyle) {
|
|
2018
|
+
Object.assign(panelStyle, this.props.panelStyle);
|
|
2019
|
+
}
|
|
2020
|
+
const tablePanelStyle = {flex: "1 1 auto", marginTop: 16, overflow: "auto"};
|
|
2021
|
+
if (this.props.tablePanelStyle) {
|
|
2022
|
+
Object.assign(tablePanelStyle, this.props.tablePanelStyle);
|
|
2023
|
+
}
|
|
2024
|
+
const headerFilterRowHeight = calculateRowHeight(this.state.fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2);
|
|
2025
|
+
|
|
2026
|
+
return (
|
|
2027
|
+
<React.Fragment>
|
|
2028
|
+
<Card size="small" bordered={false}
|
|
2029
|
+
style={{height: "100%"}}
|
|
2030
|
+
styles={{body: panelStyle}}>
|
|
2031
|
+
<div style={{display: "flex"}}>
|
|
2032
|
+
{this.renderNavigationPanel()}
|
|
2033
|
+
</div>
|
|
2034
|
+
<div style={tablePanelStyle}>
|
|
2035
|
+
<Dropdown trigger={["contextMenu"]}
|
|
2036
|
+
getPopupContainer={() => {
|
|
2037
|
+
// very nasty trick how remove error of ResizeObservers infinite cycling - because popover (with dynamic size) is placed in in resizable panel
|
|
2038
|
+
const parentNode = (ReactDOM.findDOMNode(this)?.parentNode ?? document.body) as HTMLElement;
|
|
2039
|
+
return parentNode;
|
|
2040
|
+
}}
|
|
2041
|
+
menu={getContextMenu({
|
|
2042
|
+
onlySelectedNodes: true,
|
|
2043
|
+
showMilliseconds: !!this.props.showMilliseconds,
|
|
2044
|
+
showYear: !this.props.hideYear,
|
|
2045
|
+
renderer: this.props.contextMenu?.renderer,
|
|
2046
|
+
onClick: this.props.contextMenu?.onClick,
|
|
2047
|
+
getExportContent: this.getExportContent,
|
|
2048
|
+
hideNotificationOnClipboardCopy: true,
|
|
2049
|
+
pageOrientation: this.state.pageOrientation,
|
|
2050
|
+
exporting: this.state.exporting,
|
|
2051
|
+
onPageOrientationChange: this.onPageOrientationChange,
|
|
2052
|
+
onExport: this.onExport
|
|
2053
|
+
})}
|
|
2054
|
+
open={this.state.contextMenuVisible}
|
|
2055
|
+
onOpenChange={(visible) => {
|
|
2056
|
+
if (!visible) {
|
|
2057
|
+
this.setState({contextMenuVisible: false});
|
|
2058
|
+
}
|
|
2059
|
+
}}
|
|
2060
|
+
>
|
|
2061
|
+
<div className="ag-theme-balham" style={{width: "100%", height: "100%"}}
|
|
2062
|
+
ref={(wrapingDiv) => {
|
|
2063
|
+
this.wrappingDiv = wrapingDiv;
|
|
2064
|
+
}}>
|
|
2065
|
+
<AgGridReact
|
|
2066
|
+
key={key}
|
|
2067
|
+
debug={debugMode}
|
|
2068
|
+
ref={gridRef}
|
|
2069
|
+
paginationPageSize={paginationPageSize}
|
|
2070
|
+
maxConcurrentDatasourceRequests={this.props.rowModelType === "infinite" ? 1 : undefined}
|
|
2071
|
+
onGridReady={this.onGridReady}
|
|
2072
|
+
onPaginationChanged={this.onPaginationChanged}
|
|
2073
|
+
onFilterModified={this.onFilterModified}
|
|
2074
|
+
onFilterChanged={this.onFilterChanged}
|
|
2075
|
+
onSortChanged={this.onSortChanged}
|
|
2076
|
+
defaultColDef={this.getDefaultColDefinition(defaultColDef)}
|
|
2077
|
+
columnDefs={adaptedColumnDefs as ColDef[]}
|
|
2078
|
+
rowData={!rowDataManualMode ? rowData : undefined}
|
|
2079
|
+
{...passedProperties}
|
|
2080
|
+
onCellFocused={this.onCellFocused}
|
|
2081
|
+
suppressPaginationPanel={true}
|
|
2082
|
+
getRowId={getRowId}
|
|
2083
|
+
components={customComponents}
|
|
2084
|
+
columnTypes={this.columnTypes}
|
|
2085
|
+
onColumnVisible={this.onColumnsChanged}
|
|
2086
|
+
onColumnPinned={this.onColumnsChanged}
|
|
2087
|
+
onColumnResized={this.onColumnsChanged}
|
|
2088
|
+
onColumnMoved={this.onColumnsChanged}
|
|
2089
|
+
onCellMouseDown={this.onCellMouseDown}
|
|
2090
|
+
navigateToNextCell={this.navigateToNextCell}
|
|
2091
|
+
onViewportChanged={this.onViewportChanged}
|
|
2092
|
+
onCellContextMenu={this.onCellContextMenu}
|
|
2093
|
+
loadingOverlayComponent='loadingOverlay'
|
|
2094
|
+
noRowsOverlayComponent='noRecordsOverlay'
|
|
2095
|
+
onRowDataUpdated={this.onRowDataUpdated}
|
|
2096
|
+
context={this.table_context}
|
|
2097
|
+
rowHeight={this.state.rowHeight}
|
|
2098
|
+
getRowStyle={this._getRowStyle}
|
|
2099
|
+
getRowHeight={this._getRowHeight}
|
|
2100
|
+
headerHeight={headerHeight !== undefined ? headerHeight : headerFilterRowHeight}
|
|
2101
|
+
floatingFiltersHeight={headerFilterRowHeight}
|
|
2102
|
+
suppressLoadingOverlay={this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay}
|
|
2103
|
+
quickFilterParser={this.wildcardQuickFilter.quickFilterParser}
|
|
2104
|
+
quickFilterMatcher={this.wildcardQuickFilter.quickFilterMatcher}
|
|
2105
|
+
>
|
|
2106
|
+
</AgGridReact>
|
|
2107
|
+
{this.state.loading && this.props.loadingOverlayRenderer &&
|
|
2108
|
+
<div className="ag-overlay" aria-hidden="true" ref="overlayWrapper">
|
|
2109
|
+
<div className="ag-overlay-panel">
|
|
2110
|
+
<div
|
|
2111
|
+
className="ag-overlay-wrapper ag-layout-normal ag-overlay-loading-wrapper">
|
|
2112
|
+
<div className="ag-react-container">
|
|
2113
|
+
{this.props.loadingOverlayRenderer?.()}
|
|
2114
|
+
</div>
|
|
2115
|
+
</div>
|
|
2116
|
+
</div>
|
|
2117
|
+
</div>
|
|
2118
|
+
}
|
|
2119
|
+
</div>
|
|
2120
|
+
</Dropdown>
|
|
2121
|
+
{this.props.tableOverlayRenderer?.()}
|
|
2122
|
+
</div>
|
|
2123
|
+
</Card>
|
|
2124
|
+
|
|
2125
|
+
{!!this.gridApi && !!this.gridApi && this.state.pageSize !== null &&
|
|
2126
|
+
<DataGridEditor dataGrid={this}
|
|
2127
|
+
gridApi={this.gridApi}
|
|
2128
|
+
columnDefinitions={columnDefs}
|
|
2129
|
+
columnModel={this.state.columnModel}
|
|
2130
|
+
visible={!!this.props.tableConfigVisible}
|
|
2131
|
+
onTableConfigVisible={this.showTableConfiguration}
|
|
2132
|
+
paginationPageSize={paging.pageSize}
|
|
2133
|
+
paginationDefaultPageSize={paging.defaultPageSize}
|
|
2134
|
+
currentPageSize={this.state.pageSize}
|
|
2135
|
+
showMilliseconds={!!this.props.showMilliseconds}
|
|
2136
|
+
defaultShowMilliseconds={!!this.props.defaultShowMilliseconds}
|
|
2137
|
+
showYear={!this.props.hideYear}
|
|
2138
|
+
defaultShowYear={!this.props.defaultHideYear}
|
|
2139
|
+
rowStyleRules={this.props.rowStyleRules}
|
|
2140
|
+
defaultRowStyleRules={this.props.defaultRowStyleRules}
|
|
2141
|
+
onChangeRowStyleRules={onChangeRowStyleRules}
|
|
2142
|
+
/>}
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
{!!this.gridApi && <ModalDialog
|
|
2146
|
+
mode={ModalDialogMode.OK_CANCEL}
|
|
2147
|
+
open={this.state.columnsConfigVisible}
|
|
2148
|
+
initialWidth={700}
|
|
2149
|
+
initialHeight={this.state.columnTransferHeight}
|
|
2150
|
+
title={<span><ControlOutlined style={{
|
|
2151
|
+
color: "#faad14",
|
|
2152
|
+
fontSize: 22,
|
|
2153
|
+
marginRight: 16
|
|
2154
|
+
}}/>{i18n("Columns Configuration")}</span>}
|
|
2155
|
+
cancelText={i18n("Cancel")}
|
|
2156
|
+
onCancel={() => {
|
|
2157
|
+
if (this.gridApi && this.columnModelBeforeEdit) {
|
|
2158
|
+
this.gridApi.applyColumnState({state: this.columnModelBeforeEdit, applyOrder: true});
|
|
2159
|
+
delete this.columnModelBeforeEdit;
|
|
2160
|
+
this.showColumnsConfig(false);
|
|
2161
|
+
}
|
|
2162
|
+
}}
|
|
2163
|
+
onOk={() => {
|
|
2164
|
+
delete this.columnModelBeforeEdit;
|
|
2165
|
+
this.showColumnsConfig(false);
|
|
2166
|
+
}}
|
|
2167
|
+
onResize={({height}) => {
|
|
2168
|
+
this.setState({columnTransferHeight: height});
|
|
2169
|
+
}}
|
|
2170
|
+
zIndex={100}
|
|
2171
|
+
>
|
|
2172
|
+
<ColumnTransfer
|
|
2173
|
+
columnDefinitions={columnDefs as ColDef[]}
|
|
2174
|
+
columnModel={this.state.columnModel}
|
|
2175
|
+
gridApi={this.gridApi}
|
|
2176
|
+
height={this.state.columnTransferHeight - 154}
|
|
2177
|
+
/>
|
|
2178
|
+
</ModalDialog>}
|
|
2179
|
+
|
|
2180
|
+
</React.Fragment>
|
|
2181
|
+
);
|
|
2182
|
+
}
|
|
2183
|
+
}
|