@economic/taco 2.21.2 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Report/Report.d.ts +21 -0
- package/dist/components/Report/components/Cell/Cell.d.ts +0 -1
- package/dist/components/Report/components/Cell/DisplayCell.d.ts +1 -1
- package/dist/components/Report/components/Cell/util.d.ts +1 -1
- package/dist/components/Report/components/Row/DisplayRow.d.ts +2 -9
- package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +5 -5
- package/dist/components/Report/listeners/useTableRowActiveListener.d.ts +3 -0
- package/dist/components/Report/styles/util.d.ts +2 -2
- package/dist/components/Report/types.d.ts +1 -3
- package/dist/components/Report/useReport.d.ts +2 -7
- package/dist/components/Table3/types.d.ts +1 -1
- package/dist/esm/index.css +501 -9
- package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Group/Group.js +1 -1
- package/dist/esm/packages/taco/src/components/Group/Group.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/Input.js +37 -7
- package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js +3 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +70 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +61 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/util.js +22 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js +32 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js +23 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js +58 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +69 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +34 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +39 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js +194 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js +28 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js +150 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js +60 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js +41 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/util.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js +90 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js +59 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +118 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js +102 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js +10 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js +62 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js +63 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js +50 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +136 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +95 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +49 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js +110 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js +118 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +41 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js +7 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +123 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js +88 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js +95 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js +105 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js +103 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js +44 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +54 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js +20 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/util.js +61 -0
- package/dist/esm/packages/taco/src/components/Report/styles/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/useReport.js +51 -0
- package/dist/esm/packages/taco/src/components/Report/useReport.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/rows.js +10 -0
- package/dist/esm/packages/taco/src/components/Report/util/rows.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +39 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js +162 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +2 -1
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +2 -2
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +6 -7
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +6 -6
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +7 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +3 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +9 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +4 -8
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +19 -14
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +18 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js +8 -14
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +5 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +15 -15
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js +20 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/columns.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Textarea/Textarea.js +1 -1
- package/dist/esm/packages/taco/src/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +1 -1
- package/dist/esm/packages/taco/src/index.js +7 -6
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Button.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js +21 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js +8 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +16 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js +17 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js +9 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js +9 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js +38 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +28 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js +14 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js +15 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +26 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +117 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +30 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js +131 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +131 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +43 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +22 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js +270 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js +18 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js.map +1 -0
- package/dist/esm/packages/taco/src/utils/dom.js +5 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/keyboard.js +3 -5
- package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
- package/dist/index.css +501 -9
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/types.d.ts +2 -2
- package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +1 -1
- package/dist/primitives/Table/useTable/util/settings.d.ts +1 -1
- package/dist/primitives/Table/useTable/util/sorting.d.ts +1 -1
- package/dist/taco.cjs.development.js +6380 -2731
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/keyboard.d.ts +0 -1
- package/package.json +2 -2
- package/types.json +4682 -4776
- package/dist/components/Report/features/useReportExport.d.ts +0 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PrintIFrame.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintIFrame.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Table3 } from '../../../../..';\nimport { Table3Props } from '../../../types';\nimport { useParentStylesheets } from './hooks/useParentStylesheets';\n\nexport type PrintIFrameProps<TType = unknown> = {\n onAfterPrint?: () => void;\n onBeforePrint?: () => void;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintIFrame<TType = unknown>({ onAfterPrint, onBeforePrint, tableProps }: PrintIFrameProps<TType>) {\n const [contentRef, setContentRef] = React.useState<HTMLIFrameElement | null>(null);\n const [mountNode, setMountNode] = React.useState<HTMLElement | null>(null);\n\n const isFirefoxBrowser = React.useMemo(() => navigator.userAgent.toLowerCase().includes('firefox'), []);\n const isSafariBrowser = React.useMemo(\n () => navigator.userAgent.toLowerCase().includes('safari') && !navigator.userAgent.toLowerCase().includes('chrome'),\n []\n );\n\n const iframeWindow = contentRef?.contentWindow;\n\n const stylesReady = useParentStylesheets(iframeWindow);\n\n // Calls print method when table has loaded in the iframe.\n React.useEffect(() => {\n let intervalId: NodeJS.Timer;\n let timeoutId: NodeJS.Timer;\n\n // Invoke the print functionality on the window once the table has finished rendering and all print styles are\n // added.\n if (mountNode && stylesReady) {\n intervalId = setInterval(async () => {\n const tableWrapper = mountNode;\n const table = tableWrapper.querySelector('[role=\"table\"]') as HTMLElement;\n const hasTableRendered = !!table;\n\n if (hasTableRendered && intervalId) {\n clearInterval(intervalId);\n\n // Calling the onBeforePrint method here as a fallback because certain browsers, like Safari,\n // do not call the beforeprint event.\n // Bug - Even though onBeforePrint is called before printing, the execution doesn't finish before\n // the print dialog shows up, which results into having a visible loading toast.\n onBeforePrint?.();\n\n // By adding height to the tableWrapper, we make sure the content below absolutely positioned table\n // doesn't hide\n if (isFirefoxBrowser) {\n const tableHeight = `${table.offsetHeight}px`;\n tableWrapper.style.height = tableHeight;\n }\n\n contentRef?.contentWindow?.print();\n\n // Calling the onAfterPrint method here as a fallback to do the cleanup, as certain browsers,\n // like Safari, do not trigger the beforeprint or afterprint events when a confirmation dialog\n // asking if the user wants to print the document, is cancelled.\n\n // Added a setTimeout to prevent calling onAfterPrint immediately after the print function\n // to ensure that the print dialog doesn't close abruptly. Although this behavior is uncommon,\n // there are cases where the print function may not run synchronously, causing onAfterPrint to be\n // invoked right after it.\n timeoutId = setTimeout(() => {\n onAfterPrint?.();\n }, 0);\n }\n }, 1000);\n }\n\n return () => {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n };\n }, [mountNode, stylesReady]);\n\n React.useEffect(() => {\n if (!contentRef || !iframeWindow || !stylesReady) {\n return;\n }\n\n // get the closest parent/container of the table, and the table itself\n const parentElement = contentRef?.closest('[role=dialog], [data-taco=drawer], main') ?? iframeWindow.parent.document.body;\n\n const iframeDocument = iframeWindow.document;\n iframeDocument.body.innerHTML = parentElement?.innerHTML ?? '';\n\n const tableElement = iframeDocument.querySelector('[role=\"table\"]');\n const tableColumnFreezingStyles = iframeDocument.querySelector('[data-taco=\"table3-column-freezing-styles\"]');\n const tableWrapper = iframeDocument.createElement('div');\n\n tableWrapper.setAttribute('data-role', 'table-wrapper');\n // Adding h-fit class makes sure that table is rendered with the whole content.\n tableWrapper.classList.add('h-fit');\n tableWrapper.classList.add('[&>[role=\"table\"]]:!h-fit');\n\n if (isFirefoxBrowser) {\n // Fix for firefox bug which adds page-long whitespace between page's top content and table.\n tableWrapper.classList.add('[&>[role=\"table\"]]:!absolute');\n }\n\n // Makes sure table takes the full screen width.\n if (isSafariBrowser) {\n // Safari browser doesn't apply correct width to the columns when w-screen is used.\n tableWrapper.classList.add('w-full');\n } else {\n tableWrapper.classList.add('w-screen');\n }\n\n if (tableElement) {\n tableElement.parentNode?.insertBefore(tableWrapper, tableElement);\n tableElement.remove();\n } else {\n iframeDocument.body.append(tableWrapper);\n }\n\n // Remove the already existing column freezing styles.\n if (tableColumnFreezingStyles) {\n tableColumnFreezingStyles.remove();\n }\n\n let currentNode = tableWrapper.parentNode as HTMLElement | null;\n\n while (currentNode !== null && currentNode !== iframeDocument.body) {\n // Add the 'h-fit' class to the 'table-wrapper' element's parent chain.\n // This ensures that the table is not cropped and fits within its container.\n currentNode?.classList.add('!h-fit');\n currentNode = currentNode.parentNode as HTMLElement | null;\n }\n\n setMountNode(tableWrapper);\n }, [iframeWindow, stylesReady]);\n\n const printTableProps: Table3Props<TType> = {\n ...tableProps,\n actionsForRow: undefined,\n // Not the best way to remove the active/current row styles, but a temporary solution for now\n defaultCurrentRowIndex: -1,\n defaultSettings: {\n ...tableProps?.defaultSettings,\n rowHeight: 'short',\n },\n enableColumnFreezing: false,\n enableRowHeight: true,\n enableRowSelection: false,\n enableEditing: false,\n enablePrinting: false,\n enableRowDrag: false,\n enableRowDrop: false,\n enableRowSelectionSingle: false,\n preset: undefined,\n // The presence of the onChangeSettings prop ensures that settings won't be stored in local storage.\n onChangeSettings: () => undefined,\n };\n\n // -top-60 -left-60 styles make sure that iframe is added outside of the viewport\n return (\n <iframe\n className=\"fixed -left-[6000px] -top-[6000px] -z-50 !h-0 !w-0\"\n ref={setContentRef}\n // Temporary fix to support printing in firefox: Find another solution while upgrading React\n src=\"javascript:void(0);\">\n {mountNode && stylesReady ? ReactDOM.createPortal(<Table3 {...printTableProps} />, mountNode) : null}\n </iframe>\n );\n}\n"],"names":["PrintIFrame","onAfterPrint","onBeforePrint","tableProps","contentRef","setContentRef","React","useState","mountNode","setMountNode","isFirefoxBrowser","useMemo","navigator","userAgent","toLowerCase","includes","isSafariBrowser","iframeWindow","contentWindow","stylesReady","useParentStylesheets","useEffect","intervalId","timeoutId","setInterval","tableWrapper","table","querySelector","hasTableRendered","_contentRef$contentWi","clearInterval","tableHeight","offsetHeight","style","height","print","setTimeout","Promise","resolve","e","reject","clearTimeout","parentElement","_contentRef$closest","closest","parent","document","body","iframeDocument","innerHTML","_parentElement$innerH","tableElement","tableColumnFreezingStyles","createElement","setAttribute","classList","add","_tableElement$parentN","parentNode","insertBefore","remove","append","currentNode","_currentNode","printTableProps","actionsForRow","undefined","defaultCurrentRowIndex","defaultSettings","rowHeight","enableColumnFreezing","enableRowHeight","enableRowSelection","enableEditing","enablePrinting","enableRowDrag","enableRowDrop","enableRowSelectionSingle","preset","onChangeSettings","className","ref","src","ReactDOM","createPortal","Table3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAagBA,WAAWA,CAAkB;EAAEC,YAAY;EAAEC,aAAa;EAAEC;CAAqC;EAC7G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAA2B,IAAI,CAAC;EAClF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAqB,IAAI,CAAC;EAE1E,MAAMG,gBAAgB,GAAGJ,cAAK,CAACK,OAAO,CAAC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;EACvG,MAAMC,eAAe,GAAGV,cAAK,CAACK,OAAO,CACjC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAACH,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,EACnH,E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AAGgE,QAAQ,CAACC,YAAY,eAAC9E,6BAAC+E,MAAM,oBAAKrB,eAAe,EAAI,EAAExD,SAAS,CAAC,GAAG,IAAI,CAC/F;AAEjB;;;;"}
|
1
|
+
{"version":3,"file":"PrintIFrame.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintIFrame.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Table3 } from '../../../../..';\nimport { Table3Props } from '../../../types';\nimport { useParentStylesheets } from './hooks/useParentStylesheets';\n\nexport type PrintIFrameProps<TType = unknown> = {\n onAfterPrint?: () => void;\n onBeforePrint?: () => void;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintIFrame<TType = unknown>({ onAfterPrint, onBeforePrint, tableProps }: PrintIFrameProps<TType>) {\n const [contentRef, setContentRef] = React.useState<HTMLIFrameElement | null>(null);\n const [mountNode, setMountNode] = React.useState<HTMLElement | null>(null);\n\n const isFirefoxBrowser = React.useMemo(() => navigator.userAgent.toLowerCase().includes('firefox'), []);\n const isSafariBrowser = React.useMemo(\n () => navigator.userAgent.toLowerCase().includes('safari') && !navigator.userAgent.toLowerCase().includes('chrome'),\n []\n );\n\n const iframeWindow = contentRef?.contentWindow;\n\n const stylesReady = useParentStylesheets(iframeWindow);\n\n // Calls print method when table has loaded in the iframe.\n React.useEffect(() => {\n let intervalId: ReturnType<typeof setInterval>;\n let timeoutId: ReturnType<typeof setTimeout>;\n\n // Invoke the print functionality on the window once the table has finished rendering and all print styles are\n // added.\n if (mountNode && stylesReady) {\n intervalId = setInterval(async () => {\n const tableWrapper = mountNode;\n const table = tableWrapper.querySelector('[role=\"table\"]') as HTMLElement;\n const hasTableRendered = !!table;\n\n if (hasTableRendered && intervalId) {\n clearInterval(intervalId);\n\n // Calling the onBeforePrint method here as a fallback because certain browsers, like Safari,\n // do not call the beforeprint event.\n // Bug - Even though onBeforePrint is called before printing, the execution doesn't finish before\n // the print dialog shows up, which results into having a visible loading toast.\n onBeforePrint?.();\n\n // By adding height to the tableWrapper, we make sure the content below absolutely positioned table\n // doesn't hide\n if (isFirefoxBrowser) {\n const tableHeight = `${table.offsetHeight}px`;\n tableWrapper.style.height = tableHeight;\n }\n\n contentRef?.contentWindow?.print();\n\n // Calling the onAfterPrint method here as a fallback to do the cleanup, as certain browsers,\n // like Safari, do not trigger the beforeprint or afterprint events when a confirmation dialog\n // asking if the user wants to print the document, is cancelled.\n\n // Added a setTimeout to prevent calling onAfterPrint immediately after the print function\n // to ensure that the print dialog doesn't close abruptly. Although this behavior is uncommon,\n // there are cases where the print function may not run synchronously, causing onAfterPrint to be\n // invoked right after it.\n timeoutId = setTimeout(() => {\n onAfterPrint?.();\n }, 0);\n }\n }, 1000);\n }\n\n return () => {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n };\n }, [mountNode, stylesReady]);\n\n React.useEffect(() => {\n if (!contentRef || !iframeWindow || !stylesReady) {\n return;\n }\n\n // get the closest parent/container of the table, and the table itself\n const parentElement = contentRef?.closest('[role=dialog], [data-taco=drawer], main') ?? iframeWindow.parent.document.body;\n\n const iframeDocument = iframeWindow.document;\n iframeDocument.body.innerHTML = parentElement?.innerHTML ?? '';\n\n const tableElement = iframeDocument.querySelector('[role=\"table\"]');\n const tableColumnFreezingStyles = iframeDocument.querySelector('[data-taco=\"table3-column-freezing-styles\"]');\n const tableWrapper = iframeDocument.createElement('div');\n\n tableWrapper.setAttribute('data-role', 'table-wrapper');\n // Adding h-fit class makes sure that table is rendered with the whole content.\n tableWrapper.classList.add('h-fit');\n tableWrapper.classList.add('[&>[role=\"table\"]]:!h-fit');\n\n if (isFirefoxBrowser) {\n // Fix for firefox bug which adds page-long whitespace between page's top content and table.\n tableWrapper.classList.add('[&>[role=\"table\"]]:!absolute');\n }\n\n // Makes sure table takes the full screen width.\n if (isSafariBrowser) {\n // Safari browser doesn't apply correct width to the columns when w-screen is used.\n tableWrapper.classList.add('w-full');\n } else {\n tableWrapper.classList.add('w-screen');\n }\n\n if (tableElement) {\n tableElement.parentNode?.insertBefore(tableWrapper, tableElement);\n tableElement.remove();\n } else {\n iframeDocument.body.append(tableWrapper);\n }\n\n // Remove the already existing column freezing styles.\n if (tableColumnFreezingStyles) {\n tableColumnFreezingStyles.remove();\n }\n\n let currentNode = tableWrapper.parentNode as HTMLElement | null;\n\n while (currentNode !== null && currentNode !== iframeDocument.body) {\n // Add the 'h-fit' class to the 'table-wrapper' element's parent chain.\n // This ensures that the table is not cropped and fits within its container.\n currentNode?.classList.add('!h-fit');\n currentNode = currentNode.parentNode as HTMLElement | null;\n }\n\n setMountNode(tableWrapper);\n }, [iframeWindow, stylesReady]);\n\n const printTableProps: Table3Props<TType> = {\n ...tableProps,\n actionsForRow: undefined,\n // Not the best way to remove the active/current row styles, but a temporary solution for now\n defaultCurrentRowIndex: -1,\n defaultSettings: {\n ...tableProps?.defaultSettings,\n rowHeight: 'short',\n },\n enableColumnFreezing: false,\n enableRowHeight: true,\n enableRowSelection: false,\n enableEditing: false,\n enablePrinting: false,\n enableRowDrag: false,\n enableRowDrop: false,\n enableRowSelectionSingle: false,\n preset: undefined,\n // The presence of the onChangeSettings prop ensures that settings won't be stored in local storage.\n onChangeSettings: () => undefined,\n };\n\n // -top-60 -left-60 styles make sure that iframe is added outside of the viewport\n return (\n <iframe\n className=\"fixed -left-[6000px] -top-[6000px] -z-50 !h-0 !w-0\"\n ref={setContentRef}\n // Temporary fix to support printing in firefox: Find another solution while upgrading React\n src=\"javascript:void(0);\">\n {mountNode && stylesReady ? ReactDOM.createPortal(<Table3 {...printTableProps} />, mountNode) : null}\n </iframe>\n );\n}\n"],"names":["PrintIFrame","onAfterPrint","onBeforePrint","tableProps","contentRef","setContentRef","React","useState","mountNode","setMountNode","isFirefoxBrowser","useMemo","navigator","userAgent","toLowerCase","includes","isSafariBrowser","iframeWindow","contentWindow","stylesReady","useParentStylesheets","useEffect","intervalId","timeoutId","setInterval","tableWrapper","table","querySelector","hasTableRendered","_contentRef$contentWi","clearInterval","tableHeight","offsetHeight","style","height","print","setTimeout","Promise","resolve","e","reject","clearTimeout","parentElement","_contentRef$closest","closest","parent","document","body","iframeDocument","innerHTML","_parentElement$innerH","tableElement","tableColumnFreezingStyles","createElement","setAttribute","classList","add","_tableElement$parentN","parentNode","insertBefore","remove","append","currentNode","_currentNode","printTableProps","actionsForRow","undefined","defaultCurrentRowIndex","defaultSettings","rowHeight","enableColumnFreezing","enableRowHeight","enableRowSelection","enableEditing","enablePrinting","enableRowDrag","enableRowDrop","enableRowSelectionSingle","preset","onChangeSettings","className","ref","src","ReactDOM","createPortal","Table3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAagBA,WAAWA,CAAkB;EAAEC,YAAY;EAAEC,aAAa;EAAEC;CAAqC;EAC7G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAA2B,IAAI,CAAC;EAClF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAqB,IAAI,CAAC;EAE1E,MAAMG,gBAAgB,GAAGJ,cAAK,CAACK,OAAO,CAAC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;EACvG,MAAMC,eAAe,GAAGV,cAAK,CAACK,OAAO,CACjC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAACH,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,EACnH,EAAE,CACL;EAED,MAAME,YAAY,GAAGb,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEc,aAAa;EAE9C,MAAMC,WAAW,GAAGC,oBAAoB,CAACH,YAAY,CAAC;;EAGtDX,cAAK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search(props) {
|
|
23
23
|
} = useLocalization();
|
24
24
|
const ref = React__default.useRef(null);
|
25
25
|
const tableMeta = table.options.meta;
|
26
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
26
27
|
const [query, setQuery] = React__default.useState(tableMeta.search.query);
|
27
28
|
const [loading, setLoading] = React__default.useState(LoadingState.Incomplete);
|
28
29
|
const [rowIdToNavigate, setRowIdToNavigate] = React__default.useState(null);
|
@@ -32,20 +33,30 @@ function Search(props) {
|
|
32
33
|
// update the indexes if the row length changes (e.g. when filtering)
|
33
34
|
React__default.useEffect(() => {
|
34
35
|
var _ref$current;
|
36
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
35
37
|
const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.value, table);
|
36
38
|
if (firstRowIndex) {
|
37
39
|
scrollTo(firstRowIndex);
|
38
40
|
}
|
39
|
-
}, [
|
41
|
+
}, [
|
42
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
43
|
+
tableMeta.search.query,
|
44
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
45
|
+
tableMeta.search.excludeUnmatchedResults, table.getRowModel().rows.length, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), loading]);
|
40
46
|
// Reseting internal search state if search.query is changed from the outside.
|
41
47
|
React__default.useEffect(() => {
|
48
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
42
49
|
if (tableMeta.search.query !== query) {
|
50
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
43
51
|
setQuery(tableMeta.search.query);
|
44
52
|
}
|
53
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
45
54
|
}, [tableMeta.search.query]);
|
46
55
|
// update the table search and filtering on a debounce
|
47
56
|
useDebouncedEffect(() => {
|
57
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
48
58
|
tableMeta.search.setQuery(query);
|
59
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
49
60
|
if (tableMeta.search.excludeUnmatchedResults) {
|
50
61
|
if (query !== null && query !== void 0 && query.length) {
|
51
62
|
table.setGlobalFilter(query);
|
@@ -57,6 +68,7 @@ function Search(props) {
|
|
57
68
|
const handleFocus = function () {
|
58
69
|
try {
|
59
70
|
// While Search input is focused, we'll switch into searching mode
|
71
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
60
72
|
tableMeta.search.setIsSearching(true);
|
61
73
|
// load all data if that is possible
|
62
74
|
const _temp = function () {
|
@@ -75,6 +87,7 @@ function Search(props) {
|
|
75
87
|
};
|
76
88
|
const handleBlur = () => {
|
77
89
|
// As soon as search input loose a focus, we'll turn of searching mode.
|
90
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
78
91
|
tableMeta.search.setIsSearching(false);
|
79
92
|
};
|
80
93
|
const handleChange = query => {
|
@@ -86,6 +99,7 @@ function Search(props) {
|
|
86
99
|
const highlightedCell = (_tableMeta$search$hig = tableMeta.search.highlightedColumnIndexes[highlightedColumnIndex]) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : [];
|
87
100
|
const [rowIndex = null, columnIndex = null] = highlightedCell;
|
88
101
|
const rows = table.getRowModel().rows;
|
102
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
89
103
|
tableMeta.search.setQuery('');
|
90
104
|
// Need to save row id and cell index, to be able to find the row in the table with updated indexes, after global filter will be reset.
|
91
105
|
lastCellIndex.value = String(columnIndex);
|
@@ -109,6 +123,7 @@ function Search(props) {
|
|
109
123
|
if (rowIdToNavigate !== null && !globalFilter) {
|
110
124
|
const rows = table.getRowModel().rows;
|
111
125
|
const rowIndex = rows.findIndex(row => row.id === rowIdToNavigate);
|
126
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
112
127
|
tableMeta.search.setIsSearching(false);
|
113
128
|
tableMeta.rowActive.setRowActiveIndex(rowIndex);
|
114
129
|
scrollTo(rowIndex);
|
@@ -116,6 +131,7 @@ function Search(props) {
|
|
116
131
|
}
|
117
132
|
}, [rowIdToNavigate, globalFilter]);
|
118
133
|
const handleToggleExcludeUnmatchedResults = enabled => {
|
134
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
119
135
|
tableMeta.search.toggleExcludeUnmatchedResults(enabled);
|
120
136
|
if (enabled) {
|
121
137
|
var _ref$current2;
|
@@ -153,6 +169,7 @@ function Search(props) {
|
|
153
169
|
};
|
154
170
|
const settings = /*#__PURE__*/React__default.createElement(Switch, {
|
155
171
|
label: texts.table3.search.excludeUnmatchedResults,
|
172
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
156
173
|
checked: tableMeta.search.excludeUnmatchedResults,
|
157
174
|
onChange: handleToggleExcludeUnmatchedResults
|
158
175
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Switch } from '../../../Switch/Switch';\nimport { globalFilterFn } from '../../util/filtering';\nimport { SearchInput2 } from '../../../SearchInput2/SearchInput2';\nimport { useDebouncedEffect } from '../../../../hooks/useDebouncedEffect';\nimport { getCellValueAsString } from '../../util/columns';\nimport { lastCellIndex } from '../rows/Row';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: RTable<TType>;\n};\n\nenum LoadingState {\n Incomplete,\n Loading,\n Completed,\n}\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const [query, setQuery] = React.useState(tableMeta.search.query);\n const [loading, setLoading] = React.useState<LoadingState>(LoadingState.Incomplete);\n const [rowIdToNavigate, setRowIdToNavigate] = React.useState<string | null>(null);\n\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n // update the indexes if the row length changes (e.g. when filtering)\n React.useEffect(() => {\n const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, ref.current?.value, table);\n\n if (firstRowIndex) {\n scrollTo(firstRowIndex);\n }\n }, [\n tableMeta.search.query,\n tableMeta.search.excludeUnmatchedResults,\n table.getRowModel().rows.length,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n loading,\n ]);\n\n // Reseting internal search state if search.query is changed from the outside.\n React.useEffect(() => {\n if (tableMeta.search.query !== query) {\n setQuery(tableMeta.search.query);\n }\n }, [tableMeta.search.query]);\n\n // update the table search and filtering on a debounce\n useDebouncedEffect(() => {\n tableMeta.search.setQuery(query);\n\n if (tableMeta.search.excludeUnmatchedResults) {\n if (query?.length) {\n table.setGlobalFilter(query);\n } else {\n table.resetGlobalFilter();\n }\n }\n }, [query]);\n\n const handleFocus = async () => {\n // While Search input is focused, we'll switch into searching mode\n tableMeta.search.setIsSearching(true);\n // load all data if that is possible\n if (tableMeta.server.loadAll && loading === LoadingState.Incomplete) {\n setLoading(LoadingState.Loading);\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAll(table.getState().sorting, table.getState().columnFilters, undefined);\n setLoading(LoadingState.Completed);\n }\n };\n\n const handleBlur = () => {\n // As soon as search input loose a focus, we'll turn of searching mode.\n tableMeta.search.setIsSearching(false);\n };\n\n const handleChange = (query: any) => {\n setQuery(String(query ?? ''));\n };\n\n const handleClear = () => {\n const highlightedColumnIndex = tableMeta.search.currentHighlightColumnIndex ?? 0;\n const highlightedCell = tableMeta.search.highlightedColumnIndexes[highlightedColumnIndex] ?? [];\n const [rowIndex = null, columnIndex = null] = highlightedCell;\n const rows = table.getRowModel().rows;\n\n tableMeta.search.setQuery('');\n\n // Need to save row id and cell index, to be able to find the row in the table with updated indexes, after global filter will be reset.\n lastCellIndex.value = String(columnIndex);\n\n if (rowIndex !== null) {\n const rowId = rows[rowIndex]?.id || null;\n setRowIdToNavigate(rowId);\n }\n };\n\n const handleKeyDown = event => {\n if (event.key === 'Escape') {\n handleClear();\n event.preventDefault();\n }\n };\n\n const { globalFilter } = table.getState();\n\n React.useEffect(() => {\n // need to wait when table global filter will be reset and rows will be re-rendered\n if (rowIdToNavigate !== null && !globalFilter) {\n const rows = table.getRowModel().rows;\n const rowIndex = rows.findIndex(row => row.id === rowIdToNavigate);\n tableMeta.search.setIsSearching(false);\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollTo(rowIndex);\n setRowIdToNavigate(null);\n }\n }, [rowIdToNavigate, globalFilter]);\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.toggleExcludeUnmatchedResults(enabled);\n\n if (enabled) {\n if (ref.current?.value) {\n table.setGlobalFilter(ref.current?.value);\n } else {\n table.resetGlobalFilter();\n }\n } else {\n table.resetGlobalFilter();\n }\n\n requestAnimationFrame(() => ref.current?.focus());\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table3.search.excludeUnmatchedResults}\n checked={tableMeta.search.excludeUnmatchedResults}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes ? tableMeta.search.highlightedColumnIndexes.length : null}\n loading={loading === LoadingState.Loading}\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClear={handleClear}\n placeholder={texts.table3.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={query}\n />\n </>\n );\n}\n\nfunction resetHighlightedColumnIndexes<TType = unknown>(enabled: boolean, value: string | undefined, table: RTable<TType>) {\n const tableMeta = table.options.meta as TableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (enabled && value) {\n const rowIndexes: number[] = [];\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n if (column.getIsVisible() && column.columnDef.meta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original?.[column.id], column.columnDef.meta?.dataType);\n\n if (cellValue !== undefined && globalFilterFn(cellValue, value)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n\n if (indexes.length) {\n rowIndexes.push(rowIndex);\n }\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["LoadingState","Search","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","setQuery","useState","search","loading","setLoading","Incomplete","rowIdToNavigate","setRowIdToNavigate","scrollTo","rowIndex","align","useEffect","firstRowIndex","resetHighlightedColumnIndexes","isHighlightingEnabled","_ref$current","current","value","excludeUnmatchedResults","getRowModel","rows","length","JSON","stringify","getState","sorting","columnVisibility","useDebouncedEffect","setGlobalFilter","resetGlobalFilter","handleFocus","setIsSearching","_temp","server","loadAll","Loading","Promise","resolve","columnFilters","undefined","then","Completed","e","reject","handleBlur","handleChange","String","handleClear","highlightedColumnIndex","_tableMeta$search$cur","currentHighlightColumnIndex","highlightedCell","_tableMeta$search$hig","highlightedColumnIndexes","columnIndex","lastCellIndex","_rows$rowIndex","rowId","id","handleKeyDown","event","key","preventDefault","globalFilter","findIndex","row","rowActive","setRowActiveIndex","handleToggleExcludeUnmatchedResults","enabled","toggleExcludeUnmatchedResults","_ref$current2","_ref$current3","requestAnimationFrame","_ref$current4","focus","handleNextResult","nextIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","table3","checked","onChange","SearchInput2","findCurrent","findTotal","onClickFindPrevious","onClickFindNext","onFocus","onBlur","onKeyDown","onClear","placeholder","settingsContent","shortcut","shift","indexes","columns","getVisibleLeafColumns","forEach","column","_column$columnDef$met","getIsVisible","columnDef","enableSearch","_row$original","_column$columnDef$met2","cellValue","getCellVal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SAAS,CAAC;;EAG9D,IAAI3B,aAAa,KAAK2B,SAAS,EAAE;IAC7B3C,SAAS,CAACsE,SAAS,CAACC,iBAAiB,CAACvD,aAAa,CAAC;;EAGxD,OAAOA,aAAa;AACxB;;;;"}
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Switch } from '../../../Switch/Switch';\nimport { globalFilterFn } from '../../util/filtering';\nimport { SearchInput2 } from '../../../SearchInput2/SearchInput2';\nimport { useDebouncedEffect } from '../../../../hooks/useDebouncedEffect';\nimport { getCellValueAsString } from '../../util/columns';\nimport { lastCellIndex } from '../rows/Row';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: RTable<TType>;\n};\n\nenum LoadingState {\n Incomplete,\n Loading,\n Completed,\n}\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const [query, setQuery] = React.useState(tableMeta.search.query);\n const [loading, setLoading] = React.useState<LoadingState>(LoadingState.Incomplete);\n const [rowIdToNavigate, setRowIdToNavigate] = React.useState<string | null>(null);\n\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n // update the indexes if the row length changes (e.g. when filtering)\n React.useEffect(() => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, ref.current?.value, table);\n\n if (firstRowIndex) {\n scrollTo(firstRowIndex);\n }\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.query,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.excludeUnmatchedResults,\n table.getRowModel().rows.length,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n loading,\n ]);\n\n // Reseting internal search state if search.query is changed from the outside.\n React.useEffect(() => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n if (tableMeta.search.query !== query) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n setQuery(tableMeta.search.query);\n }\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n }, [tableMeta.search.query]);\n\n // update the table search and filtering on a debounce\n useDebouncedEffect(() => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.setQuery(query);\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n if (tableMeta.search.excludeUnmatchedResults) {\n if (query?.length) {\n table.setGlobalFilter(query);\n } else {\n table.resetGlobalFilter();\n }\n }\n }, [query]);\n\n const handleFocus = async () => {\n // While Search input is focused, we'll switch into searching mode\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.setIsSearching(true);\n // load all data if that is possible\n if (tableMeta.server.loadAll && loading === LoadingState.Incomplete) {\n setLoading(LoadingState.Loading);\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAll(table.getState().sorting, table.getState().columnFilters, undefined);\n setLoading(LoadingState.Completed);\n }\n };\n\n const handleBlur = () => {\n // As soon as search input loose a focus, we'll turn of searching mode.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.setIsSearching(false);\n };\n\n const handleChange = (query: any) => {\n setQuery(String(query ?? ''));\n };\n\n const handleClear = () => {\n const highlightedColumnIndex = tableMeta.search.currentHighlightColumnIndex ?? 0;\n const highlightedCell = tableMeta.search.highlightedColumnIndexes[highlightedColumnIndex] ?? [];\n const [rowIndex = null, columnIndex = null] = highlightedCell;\n const rows = table.getRowModel().rows;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.setQuery('');\n\n // Need to save row id and cell index, to be able to find the row in the table with updated indexes, after global filter will be reset.\n lastCellIndex.value = String(columnIndex);\n\n if (rowIndex !== null) {\n const rowId = rows[rowIndex]?.id || null;\n setRowIdToNavigate(rowId);\n }\n };\n\n const handleKeyDown = event => {\n if (event.key === 'Escape') {\n handleClear();\n event.preventDefault();\n }\n };\n\n const { globalFilter } = table.getState();\n\n React.useEffect(() => {\n // need to wait when table global filter will be reset and rows will be re-rendered\n if (rowIdToNavigate !== null && !globalFilter) {\n const rows = table.getRowModel().rows;\n const rowIndex = rows.findIndex(row => row.id === rowIdToNavigate);\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.setIsSearching(false);\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollTo(rowIndex);\n setRowIdToNavigate(null);\n }\n }, [rowIdToNavigate, globalFilter]);\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.toggleExcludeUnmatchedResults(enabled);\n\n if (enabled) {\n if (ref.current?.value) {\n table.setGlobalFilter(ref.current?.value);\n } else {\n table.resetGlobalFilter();\n }\n } else {\n table.resetGlobalFilter();\n }\n\n requestAnimationFrame(() => ref.current?.focus());\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table3.search.excludeUnmatchedResults}\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n checked={tableMeta.search.excludeUnmatchedResults}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes ? tableMeta.search.highlightedColumnIndexes.length : null}\n loading={loading === LoadingState.Loading}\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClear={handleClear}\n placeholder={texts.table3.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={query}\n />\n </>\n );\n}\n\nfunction resetHighlightedColumnIndexes<TType = unknown>(enabled: boolean, value: string | undefined, table: RTable<TType>) {\n const tableMeta = table.options.meta as TableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (enabled && value) {\n const rowIndexes: number[] = [];\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n if (column.getIsVisible() && column.columnDef.meta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original?.[column.id], column.columnDef.meta?.dataType);\n\n if (cellValue !== undefined && globalFilterFn(cellValue, value)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n\n if (indexes.length) {\n rowIndexes.push(rowIndex);\n }\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["LoadingState","Search","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","setQuery","useState","search","loading","setLoading","Incomplete","rowIdToNavigate","setRowIdToNavigate","scrollTo","rowIndex","align","useEffect","firstRowIndex","resetHighlightedColumnIndexes","isHighlightingEnabled","_ref$current","current","value","excludeUnmatchedResults","getRowModel","rows","length","JSON","stringify","getState","sorting","columnVisibility","useDebouncedEffect","setGlobalFilter","resetGlobalFilter","handleFocus","setIsSearching","_temp","server","loadAll","Loading","Promise","resolve","columnFilters","undefined","then","Completed","e","reject","handleBlur","handleChange","String","handleClear","highlightedColumnIndex","_tableMeta$search$cur","currentHighlightColumnIndex","highlightedCell","_tableMeta$search$hig","highlightedColumnIndexes","columnIndex","lastCellIndex","_rows$rowIndex","rowId","id","handleKeyDown","event","key","preventDefault","globalFilter","findIndex","row","rowActive","setRowActiveIndex","handleToggleExcludeUnmatchedResults","enabled","toggleExcludeUnmatchedResults","_ref$current2","_ref$current3","requestAnimationFrame","_ref$current4","focus","handleNextResult","nextIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","table3","checked","onChange","SearchInput2","findCurrent","findTotal","onClickFindPrevious","onClickFindNext","onFocus","onBlur","onKeyDown","onClear","placeholder","settingsContent","shortcut","shift","indexes","columns","getVisibleLeafColumns","forEach","column","_column$columnDef$met","getIsVisible","columnDef","enableSearch","_row$original","_column$columnDef$met2","cellValue","getCellValueAsString","original","dataType","globalFilterFn","push","setHighlightedColumnIndexes"],"mappings":";;;;;;;;;AAeA,IAAKA,YAIJ;AAJD,WAAKA,YAAY;EACbA,2DAAU;EACVA,qDAAO;EACPA,yDAAS;AACb,CAAC,EAJIA,YAAY,KAAZA,YAAY;SAMDC,MAAMA,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAAwB;;EAExD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGN,cAAK,CAACO,QAAQ,CAACL,SAAS,CAACM,MAAM,CAACH,KAAK,CAAC;EAChE,MAAM,CAACI,OAAO,EAAEC,UAAU,CAAC,GAAGV,cAAK,CAACO,QAAQ,CAAef,YAAY,CAACmB,UAAU,CAAC;EACnF,MAAM,CAACC,eAAe,EAAEC,kBAAkB,CAAC,GAAGb,cAAK,CAACO,QAAQ,CAAgB,IAAI,CAAC;EAEjF,MAAMO,QAAQ,GAAIC,QAAgB,IAAKpB,aAAa,CAACoB,QAAQ,EAAE;IAAEC,KAAK,EAAE;GAAU,CAAC;;EAGnFhB,cAAK,CAACiB,SAAS,CAAC;;;IAEZ,MAAMC,aAAa,GAAGC,6BAA6B,CAACjB,SAAS,CAACM,MAAM,CAACY,qBAAqB,GAAAC,YAAA,GAAEtB,GAAG,CAACuB,OAAO,cAAAD,YAAA,uBAAXA,YAAA,CAAaE,KAAK,EAAE3B,KAAK,CAAC;IAEtH,IAAIsB,aAAa,EAAE;MACfJ,QAAQ,CAACI,aAAa,CAAC;;GAE9B,EAAE;;EAEChB,S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AEjE,MAAM;IACH3C,SAAS,CAACM,MAAM,CAACkH,2BAA2B,CAAC,EAAE,CAAC;IAChDxH,SAAS,CAACM,MAAM,CAAC4E,8BAA8B,CAACvC,SAAS,CAAC;;EAG9D,IAAI3B,aAAa,KAAK2B,SAAS,EAAE;IAC7B3C,SAAS,CAACsE,SAAS,CAACC,iBAAiB,CAACvD,aAAa,CAAC;;EAGxD,OAAOA,aAAa;AACxB;;;;"}
|
@@ -53,9 +53,14 @@ function useColumnFreezingStyle(tableId, table) {
|
|
53
53
|
const tableMeta = table.options.meta;
|
54
54
|
const frozenColumnIndex =
|
55
55
|
// If column freezing is not enabled then only internal frozen column should be frozen.
|
56
|
-
|
56
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
57
|
+
(tableMeta.columnFreezing.isEnabled ? (_tableMeta$columnFree = tableMeta.columnFreezing.frozenColumnIndex) !== null && _tableMeta$columnFree !== void 0 ? _tableMeta$columnFree : -1 : -1) +
|
58
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
59
|
+
tableMeta.columnFreezing.frozenInternalColumnCount;
|
57
60
|
const style = React__default.useMemo(() => {
|
58
|
-
if (
|
61
|
+
if (
|
62
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
63
|
+
tableMeta.columnFreezing.frozenInternalColumnCount > 0 || tableMeta.columnFreezing.isEnabled && frozenColumnIndex !== undefined) {
|
59
64
|
var _visibleFrozenColumns;
|
60
65
|
const visibleFrozenColumns = table.getVisibleLeafColumns().slice(0, frozenColumnIndex + 1);
|
61
66
|
const visibleExternalFrozenColumns = visibleFrozenColumns.filter(column => !isInternalColumn(column.id));
|
@@ -63,18 +68,7 @@ function useColumnFreezingStyle(tableId, table) {
|
|
63
68
|
if (visibleExternalFrozenColumns.length && visibleExternalFrozenColumns.every(column => columnSizing[column.id] === undefined)) {
|
64
69
|
return undefined;
|
65
70
|
}
|
66
|
-
const
|
67
|
-
visibleFrozenColumns.reduce((offset, column) => {
|
68
|
-
const columnId = column.id;
|
69
|
-
offsets[columnId] = offset;
|
70
|
-
if (isInternalColumn(columnId)) {
|
71
|
-
// getSize method is used instead of columnSizing state because columnSizing state doesn't have
|
72
|
-
// sizes of internal columns.
|
73
|
-
return offset + column.getSize();
|
74
|
-
}
|
75
|
-
return offset + columnSizing[columnId];
|
76
|
-
}, 0);
|
77
|
-
const styles = [Object.values(offsets).map((offset, index) => `#${tableId} [role="row"] > :nth-child(${index + 1}) { left: ${offset}px }`).join('\n'), `#${tableId} [role="row"] > :not(:nth-child(n+${frozenColumnIndex + 2})) {
|
71
|
+
const styles = [visibleFrozenColumns.map((column, index) => `#${tableId} [role="row"] > :nth-child(${index + 1}) { left: ${column.getStart()}px }`).join('\n'), `#${tableId} [role="row"] > :not(:nth-child(n+${frozenColumnIndex + 2})) {
|
78
72
|
position: sticky;
|
79
73
|
z-index: 20;
|
80
74
|
}`, `#${tableId}[data-horizontally-scrolled="true"] [role="row"] > :nth-child(${frozenColumnIndex + 1}) {
|
package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useColumnFreezing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useColumnFreezing.ts"],"sourcesContent":["import { Table, TableMeta } from '@tanstack/react-table';\nimport React from 'react';\nimport { Table3Options } from '../../types';\nimport { isInternalColumn } from '../../util/columns';\n\nexport function getFrozenInternalColumnCount(options: Table3Options) {\n let index = 0;\n\n if (options.enableRowDrag) {\n index++;\n }\n\n if (options.enableRowSelection) {\n index++;\n }\n\n if (options.enableRowExpansion) {\n index++;\n }\n\n return index;\n}\n\n/*\nBecause of the desired behaviour of column freezing we use custom state and just an index.\nIf a frozen column is, for example, hidden, then the desired behaviour is that the next available column gets frozen.\nIf this behaviour were different we would just use the native column pinning functionality\n*/\nexport function useColumnFreezing(defaultFrozenIndex: number | undefined, options: Table3Options) {\n const [frozenColumnIndex, _setFrozenColumnIndex] = React.useState<number | undefined>(() => defaultFrozenIndex);\n const [horizontallyScrolled, setHorizontallyScrolled] = React.useState(false);\n\n const onScroll = (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.currentTarget.scrollLeft > 0 && !horizontallyScrolled) {\n setHorizontallyScrolled(true);\n } else if (event.currentTarget.scrollLeft === 0 && horizontallyScrolled) {\n setHorizontallyScrolled(false);\n }\n };\n\n const frozenInternalColumnCount = React.useMemo(() => getFrozenInternalColumnCount(options), []);\n\n // we must set a value when undefined is explicitly set, otherwise nothing is saved to settings\n // and the next time the table loads it will fall back to the initial value even though the user changed it\n const setFrozenColumnIndex = (index: number | undefined) => _setFrozenColumnIndex(index ?? -1);\n\n return {\n isEnabled: options.enableColumnFreezing,\n frozenInternalColumnCount,\n frozenColumnIndex,\n setFrozenColumnIndex,\n horizontallyScrolled,\n handleScroll: onScroll,\n };\n}\n\nexport function useColumnFreezingStyle<TType = unknown>(tableId: string, table: Table<TType>) {\n const { columnOrder, columnSizing, columnSizingInfo, columnVisibility } = table.getState();\n const tableMeta = table.options.meta as TableMeta<TType>;\n const frozenColumnIndex =\n // If column freezing is not enabled then only internal frozen column should be frozen.\n (tableMeta.columnFreezing.isEnabled ? tableMeta.columnFreezing.frozenColumnIndex ?? -1 : -1) +\n tableMeta.columnFreezing.frozenInternalColumnCount;\n\n const style = React.useMemo(() => {\n if (\n tableMeta.columnFreezing.frozenInternalColumnCount > 0 ||\n (tableMeta.columnFreezing.isEnabled && frozenColumnIndex !== undefined)\n ) {\n const visibleFrozenColumns = table.getVisibleLeafColumns().slice(0, frozenColumnIndex + 1);\n\n const visibleExternalFrozenColumns = visibleFrozenColumns.filter(column => !isInternalColumn(column.id));\n\n // if all external frozen columns haven't had their size set yet, then abort\n if (\n visibleExternalFrozenColumns.length &&\n visibleExternalFrozenColumns.every(column => columnSizing[column.id] === undefined)\n ) {\n return undefined;\n }\n\n const
|
1
|
+
{"version":3,"file":"useColumnFreezing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useColumnFreezing.ts"],"sourcesContent":["import { Table, TableMeta } from '@tanstack/react-table';\nimport React from 'react';\nimport { Table3Options } from '../../types';\nimport { isInternalColumn } from '../../util/columns';\n\nexport function getFrozenInternalColumnCount(options: Table3Options) {\n let index = 0;\n\n if (options.enableRowDrag) {\n index++;\n }\n\n if (options.enableRowSelection) {\n index++;\n }\n\n if (options.enableRowExpansion) {\n index++;\n }\n\n return index;\n}\n\n/*\nBecause of the desired behaviour of column freezing we use custom state and just an index.\nIf a frozen column is, for example, hidden, then the desired behaviour is that the next available column gets frozen.\nIf this behaviour were different we would just use the native column pinning functionality\n*/\nexport function useColumnFreezing(defaultFrozenIndex: number | undefined, options: Table3Options) {\n const [frozenColumnIndex, _setFrozenColumnIndex] = React.useState<number | undefined>(() => defaultFrozenIndex);\n const [horizontallyScrolled, setHorizontallyScrolled] = React.useState(false);\n\n const onScroll = (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.currentTarget.scrollLeft > 0 && !horizontallyScrolled) {\n setHorizontallyScrolled(true);\n } else if (event.currentTarget.scrollLeft === 0 && horizontallyScrolled) {\n setHorizontallyScrolled(false);\n }\n };\n\n const frozenInternalColumnCount = React.useMemo(() => getFrozenInternalColumnCount(options), []);\n\n // we must set a value when undefined is explicitly set, otherwise nothing is saved to settings\n // and the next time the table loads it will fall back to the initial value even though the user changed it\n const setFrozenColumnIndex = (index: number | undefined) => _setFrozenColumnIndex(index ?? -1);\n\n return {\n isEnabled: options.enableColumnFreezing,\n frozenInternalColumnCount,\n frozenColumnIndex,\n setFrozenColumnIndex,\n horizontallyScrolled,\n handleScroll: onScroll,\n };\n}\n\nexport function useColumnFreezingStyle<TType = unknown>(tableId: string, table: Table<TType>) {\n const { columnOrder, columnSizing, columnSizingInfo, columnVisibility } = table.getState();\n const tableMeta = table.options.meta as TableMeta<TType>;\n const frozenColumnIndex =\n // If column freezing is not enabled then only internal frozen column should be frozen.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n (tableMeta.columnFreezing.isEnabled ? tableMeta.columnFreezing.frozenColumnIndex ?? -1 : -1) +\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenInternalColumnCount;\n\n const style = React.useMemo(() => {\n if (\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenInternalColumnCount > 0 ||\n (tableMeta.columnFreezing.isEnabled && frozenColumnIndex !== undefined)\n ) {\n const visibleFrozenColumns = table.getVisibleLeafColumns().slice(0, frozenColumnIndex + 1);\n\n const visibleExternalFrozenColumns = visibleFrozenColumns.filter(column => !isInternalColumn(column.id));\n\n // if all external frozen columns haven't had their size set yet, then abort\n if (\n visibleExternalFrozenColumns.length &&\n visibleExternalFrozenColumns.every(column => columnSizing[column.id] === undefined)\n ) {\n return undefined;\n }\n\n const styles = [\n visibleFrozenColumns\n .map(\n (column, index) => `#${tableId} [role=\"row\"] > :nth-child(${index + 1}) { left: ${column.getStart()}px }`\n )\n .join('\\n'),\n `#${tableId} [role=\"row\"] > :not(:nth-child(n+${frozenColumnIndex + 2})) {\n position: sticky;\n z-index: 20;\n }`,\n `#${tableId}[data-horizontally-scrolled=\"true\"] [role=\"row\"] > :nth-child(${frozenColumnIndex + 1}) {\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), 6px 0px 6px rgb(0 0 0/8%), 1px 0px 0px #DDDDDD;\n }`,\n ];\n\n const columnId = visibleFrozenColumns[frozenColumnIndex]?.id;\n\n // frozenColumnIndex could not be in the visible frozen column so it is important to check if columnId\n // exists before checking if it is internal.\n //\n // only add a border to the edge column if it isn't an internal column\n if (columnId && !isInternalColumn(columnId)) {\n styles.push(`#${tableId}[data-horizontally-scrolled=\"false\"] [role=\"row\"] > :nth-child(${frozenColumnIndex + 1}) {\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), 1px 0px 0px #DDDDDD;\n }`);\n }\n\n return styles.join('\\n');\n }\n\n return undefined;\n }, [columnOrder, columnSizing, columnSizingInfo, columnVisibility, tableMeta.columnFreezing.isEnabled, frozenColumnIndex]);\n\n return style;\n}\n"],"names":["getFrozenInternalColumnCount","options","index","enableRowDrag","enableRowSelection","enableRowExpansion","useColumnFreezing","defaultFrozenIndex","frozenColumnIndex","_setFrozenColumnIndex","React","useState","horizontallyScrolled","setHorizontallyScrolled","onScroll","event","currentTarget","scrollLeft","frozenInternalColumnCount","useMemo","setFrozenColumnIndex","isEnabled","enableColumnFreezing","handleScroll","useColumnFreezingStyle","tableId","table","columnOrder","columnSizing","columnSizingInfo","columnVisibility","getState","tableMeta","meta","columnFreezing","_tableMeta$columnFree","style","undefined","_visibleFrozenColumns","visibleFrozenColumns","getVisibleLeafColumns","slice","visibleExternalFrozenColumns","filter","column","isInternalColumn","id","length","every","styles","map","getStart","join","columnId","push"],"mappings":";;;SAKgBA,4BAA4BA,CAACC,OAAsB;EAC/D,IAAIC,KAAK,GAAG,CAAC;EAEb,IAAID,OAAO,CAACE,aAAa,EAAE;IACvBD,KAAK,EAAE;;EAGX,IAAID,OAAO,CAACG,kBAAkB,EAAE;IAC5BF,KAAK,EAAE;;EAGX,IAAID,OAAO,CAACI,kBAAkB,EAAE;IAC5BH,KAAK,EAAE;;EAGX,OAAOA,KAAK;AAChB;AAEA;;;;;SAKgBI,iBAAiBA,CAACC,kBAAsC,EAAEN,OAAsB;EAC5F,MAAM,CAACO,iBAAiB,EAAEC,qBAAqB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqB,MAAMJ,kBAAkB,CAAC;EAC/G,MAAM,CAACK,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAE7E,MAAMG,QAAQ,GAAIC,KAAuC;IACrD,IAAIA,KAAK,CAACC,aAAa,CAACC,UAAU,GAAG,CAAC,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ldTriggerShortcut } from '../../../../utils/keyboard.js';
|
3
2
|
import { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom.js';
|
3
|
+
import { shouldTriggerShortcut } from '../../../../utils/keyboard.js';
|
4
4
|
import _ from 'lodash-es';
|
5
5
|
import { lastCellIndex } from '../../components/rows/Row.js';
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
2
1
|
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
3
2
|
import { useTacoSettings } from '../../../../hooks/useTacoSettings.js';
|
3
|
+
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
4
4
|
|
5
5
|
function useUniqueTableId(tableId) {
|
6
6
|
const tacoSettings = useTacoSettings();
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js
CHANGED
@@ -11,7 +11,11 @@ function useSettingsStateListener(table, onChangeSettings) {
|
|
11
11
|
}, 250);
|
12
12
|
}
|
13
13
|
return () => clearTimeout(handler);
|
14
|
-
}, [
|
14
|
+
}, [
|
15
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
16
|
+
meta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility,
|
17
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
18
|
+
meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height, meta.printing.isWarningVisibleForLargeDatasets, state.sorting]);
|
15
19
|
}
|
16
20
|
|
17
21
|
export { useSettingsStateListener };
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE,
|
1
|
+
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECN,IAAI,CAACU,cAAc,CAACC,iBAAiB,EACrCT,KAAK,CAACU,WAAW,EACjBV,KAAK,CAACW,YAAY,EAClBX,KAAK,CAACY,gBAAgB;;EAEtBd,IAAI,CAACe,MAAM,CAACC,uBAAuB,EACnChB,IAAI,CAACiB,QAAQ,CAACC,IAAI,EAClBlB,IAAI,CAACmB,SAAS,CAACC,MAAM,EACrBpB,IAAI,CAACqB,QAAQ,CAACC,gCAAgC,EAC9CpB,KAAK,CAACqB,OAAO,CAChB,CAAC;AACN;;;;"}
|
@@ -1,39 +1,39 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel } from '@tanstack/react-table';
|
3
|
-
import { COLUMN_ID } from '../components/columns/internal/Actions.js';
|
4
|
-
import { getCellValueAsString } from '../util/columns.js';
|
5
3
|
import { ensureOrdering } from '../../../primitives/Table/useTable/util/columns.js';
|
4
|
+
import { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering.js';
|
5
|
+
import { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize.js';
|
6
6
|
import { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive.js';
|
7
|
-
import {
|
7
|
+
import { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick.js';
|
8
|
+
import { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto.js';
|
8
9
|
import { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight.js';
|
9
|
-
import {
|
10
|
+
import { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection.js';
|
11
|
+
import { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading.js';
|
12
|
+
import { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener.js';
|
13
|
+
import { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener.js';
|
14
|
+
import { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener.js';
|
10
15
|
import { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener.js';
|
16
|
+
import { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener.js';
|
17
|
+
import { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener.js';
|
18
|
+
import { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener.js';
|
19
|
+
import { COLUMN_ID } from '../components/columns/internal/Actions.js';
|
20
|
+
import { getCellValueAsString } from '../util/columns.js';
|
21
|
+
import { useTablePreset } from './useTablePreset.js';
|
11
22
|
import { useRowDrag } from './features/useRowDrag.js';
|
12
23
|
import { useSettingsStateListener } from './listeners/useSettingsStateListener.js';
|
13
24
|
import { columnFilterFn, globalFilterFn } from '../util/filtering.js';
|
14
|
-
import { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener.js';
|
15
|
-
import { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener.js';
|
16
|
-
import { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener.js';
|
17
25
|
import { useColumnFreezing } from './features/useColumnFreezing.js';
|
18
|
-
import { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection.js';
|
19
|
-
import { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading.js';
|
20
|
-
import { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick.js';
|
21
|
-
import { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering.js';
|
22
26
|
import { useRowDrop } from './features/useRowDrop.js';
|
23
27
|
import { useEditing } from './features/useEditing.js';
|
24
28
|
import { COLUMN_ID as COLUMN_ID$1 } from '../components/columns/internal/EditingActions.js';
|
25
29
|
import { useConvertChildrenToColumns } from './useConvertChildrenToColumns.js';
|
26
30
|
import { usePrinting } from './features/usePrinting.js';
|
27
|
-
import { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener.js';
|
28
|
-
import { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto.js';
|
29
|
-
import { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener.js';
|
30
31
|
import { useEditingStateListener } from './listeners/useEditingStateListener.js';
|
31
32
|
import { useSearch } from './features/useSearch.js';
|
32
33
|
import { useRowActions } from './features/useRowActions.js';
|
33
34
|
import { useSettings } from './features/useSettings.js';
|
34
35
|
import { useValidation } from './features/useValidation.js';
|
35
36
|
import { usePauseShortcuts } from './features/usePauseShortcuts.js';
|
36
|
-
import { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener.js';
|
37
37
|
|
38
38
|
function useTable(props, ref) {
|
39
39
|
var _settings$columnFreez, _props$length;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, ref, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_props$length","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqHgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,WAAW,CAACJ,KAAK,CAACK,EAAE,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,gBAAgB,CAAC;;EAGpG,MAAMC,OAAO,GAAGC,cAAc,CAACT,KAAK,CAAC;;EAGrC,MAAMU,YAAY,GAAGC,0BAA0B,CAACX,KAAK,EAAEQ,OAAO,CAAC;;EAG/D,MAAMI,cAAc,GAAGC,iBAAiB,EAAAC,qBAAA,GAACZ,QAAQ,CAACa,mBAAmB,cAAAD,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACgB,0BAA0B,EAAER,OAAO,CAAC;;EAEnH,MAAMS,UAAU,GAAGC,aAAa,CAAQlB,KAAK,CAACmB,cAAc,EAAEnB,KAAK,CAACoB,aAAa,CAAC;;EAElF,MAAMC,OAAO,GAAGC,UAAU,CAAQd,OAAO,CAACe,aAAa,EAAEtB,GAAG,EAAEgB,UAAU,EAAEjB,KAAK,CAACwB,MAAM,CAAC;;EAEvF,MAAMC,QAAQ,GAAGC,WAAW,CAAClB,OAAO,CAACmB,cAAc,EAAEzB,QAAQ,CAAC0B,mCAAmC,EAAE5B,KAAK,CAACK,EAAE,CAAC;;EAE5G,MAAMwB,UAAU,GAAGC,aAAa,CAAQ9B,KAAK,CAAC+B,aAAa,EAAE/B,KAAK,CAACgC,mBAAmB,CAAC;;EAEvF,MAAMC,OAAO,GAAGC,UAAU,CAAC1B,OAAO,CAAC2B,aAAa,CAAC;;EAEjD,MAAMC,OAAO,GAAGC,UAAU,CAAC7B,OAAO,CAAC8B,aAAa,EAAEtC,KAAK,CAACuC,SA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;;EAIlF,IAAI9J,OAAO,CAACyI,aAAa,EAAE;IACvB,IAAIjJ,KAAK,CAACsI,MAAM,EAAE;MACd5H,YAAY,CAAC6J,aAAa,GAAG,IAAI;;KAEpC,MAAM;MACH7J,YAAY,CAAC8J,iBAAiB,GAAGA,iBAAiB,EAAE;;;EAI5D,OAAO9J,YAAY;AACvB;;;;"}
|
1
|
+
{"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n printing: ReturnType<typeof usePrinting>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, ref, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_props$length","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0HgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,WAAW,CAACJ,KAAK,CAACK,EAAE,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,gBAAgB,CAAC;;EAGpG,MAAMC,OAAO,GAAGC,cAAc,CAACT,KAAK,CAAC;;EAGrC,MAAMU,YAAY,GAAGC,0BAA0B,CAACX,KAAK,EAAEQ,OAAO,CAAC;;EAG/D,MAAMI,cAAc,GAAGC,iBAAiB,EAAAC,qBAAA,GAACZ,QAAQ,CAACa,mBAAmB,cAAAD,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACgB,0BAA0B,EAAER,OAAO,CAAC;;EAEnH,MAAMS,UAAU,GAAGC,aAAa,CAAQlB,KAAK,CAACmB,cAAc,EAAEnB,KAAK,CAACoB,aAAa,CAAC;;EAElF,MAAMC,OAAO,GAAGC,UAAU,CAAQd,OAAO,CAACe,aAAa,EAAEtB,GAAG,EAAEgB,UAAU,EAAEjB,KAAK,CAACwB,MAAM,CAAC;;EAEvF,MAAMC,QAAQ,GAAGC,WAAW,CAAClB,OAAO,CAACmB,cAAc,EAAEzB,QAAQ,CAAC0B,mCAAmC,EAAE5B,KAAK,CAACK,EAAE,CAAC;;EAE5G,MAAMwB,UAAU,GAAGC,aAAa,CAAQ9B,KAAK,CAAC+B,aAAa,EAAE/B,KAAK,CAACgC,mBAAmB,CAAC;;EAEvF,MAAMC,OAAO,GAAGC,UAAU,CAAC1B,OAAO,CAAC2B,aAAa,CAAC;;EAEjD,MAAMC,OAAO,GAAGC,UAAU,CAAC7B,OAAO,CAA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