@economic/taco 2.12.1 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Icon/components/Location.d.ts +3 -0
- package/dist/components/Icon/components/index.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Menu/components/Item.d.ts +1 -1
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Navigation2/components/Link.d.ts +1 -1
- package/dist/components/Provider/Localization.d.ts +1 -113
- package/dist/components/Select2/components/Option.d.ts +7 -5
- package/dist/components/Select2/components/Search.d.ts +1 -1
- package/dist/components/Table3/Table3.d.ts +9 -1
- package/dist/components/Table3/components/columns/header/Group.d.ts +15 -0
- package/dist/components/Table3/components/columns/header/Header.d.ts +5 -0
- package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
- package/dist/components/Table3/components/columns/styles.d.ts +2 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +4 -4
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/FontSize.d.ts +4 -0
- package/dist/components/Table3/hooks/features/useHeaderOffsetStyle.d.ts +3 -0
- package/dist/components/Table3/hooks/useCssGrid.d.ts +2 -1
- package/dist/components/Table3/hooks/useTable.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +8 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/esm/index.css +24 -6
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +6 -4
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js +17 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +1 -110
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +13 -6
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +7 -6
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +29 -11
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -5
- 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 +1 -4
- 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.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js +70 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +26 -8
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +6 -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 +3 -2
- 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/columns/internal/EditingActions.js +13 -9
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +14 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +10 -7
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +15 -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/Filter.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +25 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +0 -1
- 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/Filter/filters/components/FilterValue.js +5 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +9 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -3
- 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/RowHeight.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js +24 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +6 -7
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +48 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +34 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +11 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -2
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +1 -2
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.css +24 -6
- package/dist/index.d.ts +0 -1
- package/dist/taco.cjs.development.js +697 -4100
- 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/package.json +2 -2
- package/tailwind.config.js +3 -0
- package/types.json +14334 -32345
- package/dist/components/Table2/Table2.d.ts +0 -130
- package/dist/components/Table2/components/BatchActionsMenu.d.ts +0 -10
- package/dist/components/Table2/components/ColumnSettingsButton.d.ts +0 -6
- package/dist/components/Table2/components/EditModeButton.d.ts +0 -8
- package/dist/components/Table2/components/RowDensityButton.d.ts +0 -7
- package/dist/components/Table2/components/Search.d.ts +0 -3
- package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +0 -7
- package/dist/components/Table2/components/column/Base.d.ts +0 -14
- package/dist/components/Table2/components/column/Cell.d.ts +0 -15
- package/dist/components/Table2/components/column/Footer.d.ts +0 -9
- package/dist/components/Table2/components/column/Header.d.ts +0 -11
- package/dist/components/Table2/components/column/Indicator.d.ts +0 -17
- package/dist/components/Table2/components/column/ValidationError.d.ts +0 -5
- package/dist/components/Table2/components/column/utils.d.ts +0 -3
- package/dist/components/Table2/components/filters/FiltersButton.d.ts +0 -7
- package/dist/components/Table2/components/filters/components/Column.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +0 -10
- package/dist/components/Table2/components/filters/components/Comparator.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +0 -13
- package/dist/components/Table2/components/filters/components/InferredControl.d.ts +0 -10
- package/dist/components/Table2/components/row/Context.d.ts +0 -24
- package/dist/components/Table2/components/row/ExpandedRow.d.ts +0 -6
- package/dist/components/Table2/components/row/Row.d.ts +0 -2
- package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/useActiveCell.d.ts +0 -26
- package/dist/components/Table2/hooks/useActiveRow.d.ts +0 -10
- package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +0 -37
- package/dist/components/Table2/hooks/useEditMode.d.ts +0 -28
- package/dist/components/Table2/hooks/useGridTemplate.d.ts +0 -2
- package/dist/components/Table2/hooks/useTable.d.ts +0 -46
- package/dist/components/Table2/hooks/useTableShortcuts.d.ts +0 -2
- package/dist/components/Table2/hooks/useVirtualiser.d.ts +0 -23
- package/dist/components/Table2/types.d.ts +0 -148
- package/dist/components/Table2/utilities/cell.d.ts +0 -14
- package/dist/components/Table2/utilities/columns.d.ts +0 -16
- package/dist/components/Table2/utilities/filterFn.d.ts +0 -3
- package/dist/esm/packages/taco/src/components/Table2/Table2.js +0 -422
- package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +0 -83
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +0 -116
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +0 -81
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +0 -47
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +0 -62
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +0 -605
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +0 -243
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +0 -73
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +0 -30
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +0 -39
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +0 -155
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +0 -31
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +0 -129
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +0 -68
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +0 -63
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +0 -99
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +0 -58
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +0 -36
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +0 -44
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +0 -19
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +0 -28
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +0 -12
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +0 -25
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +0 -33
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +0 -122
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +0 -112
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +0 -34
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +0 -222
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +0 -46
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +0 -48
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/types.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/types.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +0 -41
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +0 -387
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +0 -100
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +0 -32
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +0 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +0 -20
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +0 -1
@@ -3,12 +3,13 @@ import { createColumnHelper } from '@tanstack/react-table';
|
|
3
3
|
import { Header } from '../components/columns/header/Header.js';
|
4
4
|
import { Footer } from '../components/columns/footer/Footer.js';
|
5
5
|
import { createRowActionsColumn } from '../components/columns/internal/Actions.js';
|
6
|
-
import {
|
6
|
+
import { getFontBasedMinColumnSize } from '../components/columns/styles.js';
|
7
7
|
import { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions.js';
|
8
8
|
import { Cell } from '../components/columns/cell/Cell.js';
|
9
9
|
import { createRowSelectionColumn } from '../components/columns/internal/Selection.js';
|
10
10
|
import { createRowExpansionColumn } from '../components/columns/internal/Expansion.js';
|
11
11
|
import { createRowDragColumn } from '../components/columns/internal/Drag.js';
|
12
|
+
import { Group } from '../components/columns/header/Group.js';
|
12
13
|
|
13
14
|
function getSortingFn(dataType, customFnOrBuiltIn) {
|
14
15
|
if (typeof customFnOrBuiltIn === 'function') {
|
@@ -26,18 +27,19 @@ function getSortingFn(dataType, customFnOrBuiltIn) {
|
|
26
27
|
return 'auto';
|
27
28
|
}
|
28
29
|
function useConvertChildrenToColumns(props, options, editing) {
|
30
|
+
var _props$defaultSetting;
|
31
|
+
const minColumnSize = getFontBasedMinColumnSize(props === null || props === void 0 ? void 0 : (_props$defaultSetting = props.defaultSettings) === null || _props$defaultSetting === void 0 ? void 0 : _props$defaultSetting.fontSize);
|
29
32
|
// It's important to memoise column definitions, because it prevents columns like "Drag column" to re-render on every state change,
|
30
33
|
// and break dragging at the moment it happens.
|
31
34
|
return React__default.useMemo(() => {
|
32
35
|
var _props$actionsForRow;
|
33
36
|
const columnHelper = createColumnHelper();
|
34
|
-
const columns = [];
|
35
37
|
const defaultColumnSizing = {};
|
36
38
|
const defaultColumnVisibility = {};
|
37
39
|
const defaultSorting = [];
|
38
|
-
|
39
|
-
|
40
|
-
if ( /*#__PURE__*/React__default.isValidElement(child) && child.props.accessor) {
|
40
|
+
function processChild(child) {
|
41
|
+
var _child$type, _child$type2;
|
42
|
+
if ( /*#__PURE__*/React__default.isValidElement(child) && ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === 'Table3Column' && child.props.accessor) {
|
41
43
|
var _child$props$enableRe, _child$props$enableFi, _child$props$enableSo, _child$props$enableHi, _child$props$enableOr, _child$props$enablePr, _child$props$enableSe, _child$props$enableTr;
|
42
44
|
if (child.props.defaultWidth) {
|
43
45
|
defaultColumnSizing[child.props.accessor] = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
|
@@ -51,14 +53,15 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
51
53
|
desc: child.props.sort === 'desc'
|
52
54
|
});
|
53
55
|
}
|
54
|
-
|
56
|
+
// return regular column definition
|
57
|
+
return {
|
55
58
|
accessorKey: child.props.accessor,
|
56
59
|
id: child.props.accessor,
|
57
60
|
header: Header,
|
58
61
|
cell: Cell,
|
59
62
|
footer: Footer,
|
60
63
|
// sizing
|
61
|
-
minSize:
|
64
|
+
minSize: minColumnSize,
|
62
65
|
enableResizing: (_child$props$enableRe = child.props.enableResizing) !== null && _child$props$enableRe !== void 0 ? _child$props$enableRe : true,
|
63
66
|
// filtering
|
64
67
|
enableColumnFilter: (_child$props$enableFi = child.props.enableFiltering) !== null && _child$props$enableFi !== void 0 ? _child$props$enableFi : true,
|
@@ -88,9 +91,31 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
88
91
|
renderer: child.props.renderer,
|
89
92
|
tooltip: child.props.tooltip
|
90
93
|
}
|
94
|
+
};
|
95
|
+
} else if ( /*#__PURE__*/React__default.isValidElement(child) && ((_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === 'Table3Group' && child.props.children) {
|
96
|
+
// return column group definition
|
97
|
+
return columnHelper.group({
|
98
|
+
id: child.props.id,
|
99
|
+
header: Group,
|
100
|
+
columns: processChildren(child.props.children),
|
101
|
+
meta: {
|
102
|
+
align: 'center',
|
103
|
+
enableOrdering: false,
|
104
|
+
enableSearch: false,
|
105
|
+
enableTruncate: false,
|
106
|
+
header: child.props.header
|
107
|
+
}
|
91
108
|
});
|
92
109
|
}
|
93
|
-
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
function processChildren(children) {
|
113
|
+
return React__default.Children.toArray(children).map(processChild)
|
114
|
+
// compiler cannot get filtering out undefined items, so using the type casting here
|
115
|
+
.filter(child => !!child); // need to remove undefined array items after processing the children
|
116
|
+
}
|
117
|
+
|
118
|
+
const columns = processChildren(props.children);
|
94
119
|
if (options.enableRowExpansion && props.expandedRowRenderer) {
|
95
120
|
columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));
|
96
121
|
}
|
@@ -112,7 +137,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
112
137
|
defaultColumnVisibility,
|
113
138
|
defaultSorting
|
114
139
|
};
|
115
|
-
}, []);
|
140
|
+
}, [editing.isEditing]);
|
116
141
|
}
|
117
142
|
|
118
143
|
export { useConvertChildrenToColumns };
|
package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnDef, ColumnSizingState, createColumnHelper, ColumnSort, VisibilityState } from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const columns: ColumnDef<TType>[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n (React.Children.toArray(props.children) as React.ReactElement<Table3ColumnProps<TType>>[])\n .filter(child => !!child) // remove falsey children\n .forEach(child => {\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && child.props.accessor) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: MIN_COLUMN_SIZE,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enablePrinting: child.props.enablePrinting ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n });\n }\n });\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, []);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","React","useMemo","columnHelper","createColumnHelper","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","Children","toArray","children","filter","child","forEach","isValidElement","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enablePr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","MIN_COLUMN_SIZE","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enablePrinting","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;AAcA,SAASA,Y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AAK,CAACoE,mBAAmB,EAAE;MACzD7D,OAAO,CAAC8D,OAAO,CAAChE,YAAY,CAACiE,OAAO,CAACC,wBAAwB,CAACvE,KAAK,CAACoE,mBAAmB,CAAC,CAAC,CAAC;;IAG9F,IAAInE,OAAO,CAACuE,kBAAkB,EAAE;MAC5BjE,OAAO,CAAC8D,OAAO,CACXhE,YAAY,CAACiE,OAAO,CAChBG,wBAAwB,CAAQ,CAAC,EAAExE,OAAO,CAACyE,aAAa,IAAI1E,KAAK,CAAC2E,SAAS,CAAC,EAAE,CAAC,CAAC3E,KAAK,CAACoE,mBAAmB,CAAC,CAC7G,CACJ;;IAGL,IAAInE,OAAO,CAACyE,aAAa,IAAI1E,KAAK,CAAC2E,SAAS,EAAE;MAC1CpE,OAAO,CAAC8D,OAAO,CAAChE,YAAY,CAACiE,OAAO,CAACM,mBAAmB,CAAC5E,KAAK,CAAC2E,SAAS,CAAC,CAAC,CAAC;;IAG/E,KAAAE,oBAAA,GAAI7E,KAAK,CAAC8E,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,MAAM,EAAE;MAC7BxE,OAAO,CAACyB,IAAI,CAAC3B,YAAY,CAACiE,OAAO,CAACU,sBAAsB,EAAS,CAAC,CAAC;;IAGvE,IAAI9E,OAAO,CAAC+E,SAAS,IAAI/E,OAAO,CAACgF,SAAS,EAAE;MACxC3E,OAAO,CAACyB,IAAI,CAAC3B,YAAY,CAACiE,OAAO,CAACa,6BAA6B,EAAS,CAAC,CAAC;;IAG9E,OAAO;MAAE5E,OAAO;MAAEC,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,EAAE,CAAC;AACV;;;;"}
|
1
|
+
{"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport {\n ColumnDef,\n ColumnSizingState,\n createColumnHelper,\n ColumnSort,\n VisibilityState,\n GroupColumnDef,\n} from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn, Table3GroupProps } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { getFontBasedMinColumnSize } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\nimport { Group } from '../components/columns/header/Group';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n const minColumnSize = getFontBasedMinColumnSize(props?.defaultSettings?.fontSize);\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n function processChild<TType>(child: React.ReactChild | React.ReactFragment | React.ReactPortal) {\n if (\n React.isValidElement<Table3ColumnProps<TType>>(child) &&\n (child as any).type?.displayName === 'Table3Column' &&\n child.props.accessor\n ) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n // return regular column definition\n return {\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: minColumnSize,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enablePrinting: child.props.enablePrinting ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n };\n } else if (\n React.isValidElement<Table3GroupProps>(child) &&\n (child as any).type?.displayName === 'Table3Group' &&\n child.props.children\n ) {\n // return column group definition\n return columnHelper.group({\n id: child.props.id,\n header: Group,\n columns: processChildren(child.props.children),\n meta: {\n align: 'center',\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: child.props.header,\n },\n });\n }\n return;\n }\n\n function processChildren<TType = unknown>(\n children: (JSX.Element | boolean | null | undefined)[]\n ): Array<ColumnDef<TType> | GroupColumnDef<TType>> {\n return (\n React.Children.toArray(children)\n .map(processChild)\n // compiler cannot get filtering out undefined items, so using the type casting here\n .filter(child => !!child) as Array<ColumnDef<TType> | GroupColumnDef<TType>>\n ); // need to remove undefined array items after processing the children\n }\n\n const columns: ColumnDef<TType>[] = processChildren(props.children);\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, [editing.isEditing]);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","minColumnSize","getFontBasedMinColumnSize","_props$defaultSetting","defaultSettings","fontSize","React","useMemo","columnHelper","createColumnHelper","defaultColumnSizing","defaultColumnVisibility","defaultSorting","processChild","child","isValidElement","_child$type","type","displayName","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enablePr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enablePrinting","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","_child$type2","children","group","Group","columns","processChildren","Children","toArray","map","filter","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;;AAsBA,SAASA,YAAYA,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;;EAI5B,IAAID,QAAQ,IAAIA,QAAQ,KAAK,SAAS,IAAIA,QAAQ,KAAK,QAAQ,EAAE;IAC7D,OAAOA,QAAQ;;;EAInB,OAAO,MAAM;AACjB;SAEgBM,2BAA2BA,CACvCC,KAAyB,EACzBC,OAAsB,EACtBC,OAAsC;;EAEtC,MAAMC,aAAa,GAAGC,yBAAyB,CAACJ,KAAK,aAALA,KAAK,wBAAAK,qBAAA,GAALL,KAAK,CAAEM,eAAe,cAAAD,qBAAA,uBAAtBA,qBAAA,CAAwBE,QAAQ,CAAC;;;EAGjF,OAAOC,cAAK,CAACC,OAAO,CAAC;;IACjB,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;IAEhD,MAAMC,mBAAmB,GAAsB,EAAE;IACjD,MAAMC,uBAAuB,GAAoB,EAAE;IACnD,MAAMC,cAAc,GAAiB,EAAE;IAEvC,SAASC,YAAYA,CAAQC,KAAiE;;MAC1F,kBACIR,cAAK,CAACS,cAAc,CAA2BD,KAAK,CAAC,IACpD,EAAAE,WAAA,GAAAF,KAAa,CAACG,IAAI,cAAAD,WAAA,uBAAlBA,WAAA,CAAoBE,WAAW,MAAK,cAAc,IACnDJ,KAAK,CAAChB,KAAK,CAACqB,QAAQ,EACtB;QAAA,IAA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,OAAO,CAACC,wBAAwB,CAACnF,KAAK,CAACgF,mBAAmB,CAAC,CAAC,CAAC;;IAG9F,IAAI/E,OAAO,CAACmF,kBAAkB,EAAE;MAC5BX,OAAO,CAACQ,OAAO,CACXvE,YAAY,CAACwE,OAAO,CAChBG,wBAAwB,CAAQ,CAAC,EAAEpF,OAAO,CAACqF,aAAa,IAAItF,KAAK,CAACuF,SAAS,CAAC,EAAE,CAAC,CAACvF,KAAK,CAACgF,mBAAmB,CAAC,CAC7G,CACJ;;IAGL,IAAI/E,OAAO,CAACqF,aAAa,IAAItF,KAAK,CAACuF,SAAS,EAAE;MAC1Cd,OAAO,CAACQ,OAAO,CAACvE,YAAY,CAACwE,OAAO,CAACM,mBAAmB,CAACxF,KAAK,CAACuF,SAAS,CAAC,CAAC,CAAC;;IAG/E,KAAAE,oBAAA,GAAIzF,KAAK,CAAC0F,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,MAAM,EAAE;MAC7BlB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACU,sBAAsB,EAAS,CAAC,CAAC;;IAGvE,IAAI1F,OAAO,CAAC2F,SAAS,IAAI3F,OAAO,CAAC4F,SAAS,EAAE;MACxCrB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACa,6BAA6B,EAAS,CAAC,CAAC;;IAG9E,OAAO;MAAEtB,OAAO;MAAE7D,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,CAACZ,OAAO,CAAC4F,SAAS,CAAC,CAAC;AAC3B;;;;"}
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { COLUMN_ID } from '../components/columns/internal/Actions.js';
|
3
3
|
import { isInternalColumn } from '../util/columns.js';
|
4
|
-
import {
|
4
|
+
import { getFontBasedMinColumnSize, PRINT_MIN_COLUMN_SIZE } from '../components/columns/styles.js';
|
5
5
|
|
6
|
-
const useCssGrid = (table, isPrintTable = false, actionsForRowLength = 0) => {
|
6
|
+
const useCssGrid = (table, isPrintTable = false, actionsForRowLength = 0, fontSize) => {
|
7
7
|
const allVisibleColumns = table.getVisibleLeafColumns();
|
8
8
|
const columnSizing = table.getState().columnSizing;
|
9
9
|
const rowsLength = table.getRowModel().rows.length;
|
10
10
|
const expandedRowsLength = Object.keys(table.getState().expanded).length;
|
11
11
|
const length = rowsLength + expandedRowsLength;
|
12
|
+
const minColumnSize = getFontBasedMinColumnSize(fontSize);
|
12
13
|
const gridTemplateColumns = React__default.useMemo(() => {
|
13
14
|
return allVisibleColumns.reduce((accum, column, index) => {
|
14
15
|
let size;
|
@@ -34,10 +35,10 @@ const useCssGrid = (table, isPrintTable = false, actionsForRowLength = 0) => {
|
|
34
35
|
size = 'minmax(max-content, 1fr)';
|
35
36
|
} else if (isLastColumn) {
|
36
37
|
size = `minmax(${width}px, auto)`;
|
37
|
-
} else if (width <
|
38
|
+
} else if (width < minColumnSize) {
|
38
39
|
// the react-table getResizeHandler function does not respect the minSize property on columns, it is possible
|
39
40
|
// to go below the minSize - so we have to prevent it entirely on the grid layout
|
40
|
-
size = `${
|
41
|
+
size = `${minColumnSize}px`;
|
41
42
|
} else {
|
42
43
|
size = `${width}px`;
|
43
44
|
}
|
@@ -46,7 +47,7 @@ const useCssGrid = (table, isPrintTable = false, actionsForRowLength = 0) => {
|
|
46
47
|
}
|
47
48
|
return `${accum} ${size}`.trim();
|
48
49
|
}, '');
|
49
|
-
}, [allVisibleColumns, columnSizing]);
|
50
|
+
}, [allVisibleColumns, columnSizing, minColumnSize]);
|
50
51
|
const gridTemplateRows = React__default.useMemo(() => {
|
51
52
|
// 1fr makes sure that there is always a free space between the rows and footer when table height exceeds the
|
52
53
|
// cumulative height of all rows
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCssGrid.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable } from '@tanstack/react-table';\nimport { isInternalColumn } from '../util/columns';\nimport {
|
1
|
+
{"version":3,"file":"useCssGrid.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable } from '@tanstack/react-table';\n\nimport { isInternalColumn } from '../util/columns';\nimport { getFontBasedMinColumnSize, PRINT_MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { Table3FontSize } from '../types';\n\nexport const useCssGrid = <TType = unknown>(\n table: RTable<TType>,\n isPrintTable = false,\n actionsForRowLength = 0,\n fontSize: Table3FontSize\n) => {\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const rowsLength = table.getRowModel().rows.length;\n const expandedRowsLength = Object.keys(table.getState().expanded).length;\n const length = rowsLength + expandedRowsLength;\n const minColumnSize = getFontBasedMinColumnSize(fontSize);\n const gridTemplateColumns = React.useMemo(() => {\n return allVisibleColumns.reduce((accum, column, index) => {\n let size;\n const isLastColumn = index === allVisibleColumns.length - 1;\n // column has a getSize function, but it always returns a default value (150), and we want the\n // first render to use auto layout - so we get the size directly from table state where it is undefined\n const width = columnSizing[column.id] as number | '1fr';\n const isColumnInternal = isInternalColumn(column.id);\n\n if (isPrintTable) {\n const maxWidth = isColumnInternal ? `${column.getSize()}px` : '1fr';\n\n size = `minmax(${PRINT_MIN_COLUMN_SIZE}px, ${maxWidth})`;\n } else if (isColumnInternal) {\n if (column.id === ACTIONS_COLUMN_ID) {\n const minWidth = actionsForRowLength * 32 + 8 /* button margins l+r */ + 8; /* cell padding l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else {\n // getSize method is used instead of columnSizing state because columnSizing state doesn't have\n // sizes of internal columns.\n size = `${column.getSize()}px`;\n }\n } else if (width !== undefined) {\n if (width === '1fr') {\n size = 'minmax(max-content, 1fr)';\n } else if (isLastColumn) {\n size = `minmax(${width}px, auto)`;\n } else if (width < minColumnSize) {\n // the react-table getResizeHandler function does not respect the minSize property on columns, it is possible\n // to go below the minSize - so we have to prevent it entirely on the grid layout\n size = `${minColumnSize}px`;\n } else {\n size = `${width}px`;\n }\n } else {\n size = 'minmax(max-content, auto)';\n }\n\n return `${accum} ${size}`.trim();\n }, '');\n }, [allVisibleColumns, columnSizing, minColumnSize]);\n\n const gridTemplateRows = React.useMemo(() => {\n // 1fr makes sure that there is always a free space between the rows and footer when table height exceeds the\n // cumulative height of all rows\n return `min-content repeat(${length}, min-content) 1fr min-content`;\n }, [length]);\n\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n return { style };\n};\n"],"names":["useCssGrid","table","isPrintTable","actionsForRowLength","fontSize","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","rowsLength","getRowModel","rows","length","expandedRowsLength","Object","keys","expanded","minColumnSize","getFontBasedMinColumnSize","gridTemplateColumns","React","useMemo","reduce","accum","column","index","size","isLastColumn","width","id","isColumnInternal","isInternalColumn","maxWidth","getSize","PRINT_MIN_COLUMN_SIZE","ACTIONS_COLUMN_ID","minWidth","undefined","trim","gridTemplateRows","style"],"mappings":";;;;;MAQaA,UAAU,GAAGA,CACtBC,KAAoB,EACpBC,YAAY,GAAG,KAAK,EACpBC,mBAAmB,GAAG,CAAC,EACvBC,QAAwB;EAExB,MAAMC,iBAAiB,GAAGJ,KAAK,CAACK,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGN,KAAK,CAACO,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,UAAU,GAAGR,KAAK,CAACS,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM;EAClD,MAAMC,kBAAkB,GAAGC,MAAM,CAACC,IAAI,CAACd,KAAK,CAACO,QAAQ,EAAE,CAACQ,QAAQ,CAAC,CAACJ,MAAM;EACxE,MAAMA,MAAM,GAAGH,UAAU,GAAGI,kBAAkB;EAC9C,MAAMI,aAAa,GAAGC,yBAAyB,CAACd,QAAQ,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AC;EAEpD,MAAMsB,gBAAgB,GAAGnB,cAAK,CAACC,OAAO,CAAC;;;IAGnC,6BAA6BT,sCAAsC;GACtE,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAM4B,KAAK,GAAwB;IAC/BrB,mBAAmB;IACnBoB;GACH;EAED,OAAO;IAAEC;GAAO;AACpB;;;;"}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { FONT_SIZE } from '../components/toolbar/FontSize.js';
|
2
|
+
|
1
3
|
// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)
|
2
4
|
const getCellHeightPadding = (height, fontSize) => {
|
3
5
|
// TODO: can we get the rem values from tailwind
|
@@ -5,7 +7,7 @@ const getCellHeightPadding = (height, fontSize) => {
|
|
5
7
|
case 'short':
|
6
8
|
{
|
7
9
|
switch (fontSize) {
|
8
|
-
case
|
10
|
+
case FONT_SIZE.small:
|
9
11
|
return '8px';
|
10
12
|
default:
|
11
13
|
return '6px';
|
@@ -16,9 +18,9 @@ const getCellHeightPadding = (height, fontSize) => {
|
|
16
18
|
case 'tall':
|
17
19
|
{
|
18
20
|
switch (fontSize) {
|
19
|
-
case
|
21
|
+
case FONT_SIZE.small:
|
20
22
|
return '16px';
|
21
|
-
case
|
23
|
+
case FONT_SIZE.large:
|
22
24
|
return '12px';
|
23
25
|
default:
|
24
26
|
return '14px';
|
@@ -27,9 +29,9 @@ const getCellHeightPadding = (height, fontSize) => {
|
|
27
29
|
case 'extra-tall':
|
28
30
|
{
|
29
31
|
switch (fontSize) {
|
30
|
-
case
|
32
|
+
case FONT_SIZE.small:
|
31
33
|
return '22px';
|
32
|
-
case
|
34
|
+
case FONT_SIZE.large:
|
33
35
|
return '18px';
|
34
36
|
default:
|
35
37
|
return '20px';
|
@@ -38,9 +40,9 @@ const getCellHeightPadding = (height, fontSize) => {
|
|
38
40
|
default:
|
39
41
|
{
|
40
42
|
switch (fontSize) {
|
41
|
-
case
|
43
|
+
case FONT_SIZE.small:
|
42
44
|
return '12px';
|
43
|
-
case
|
45
|
+
case FONT_SIZE.large:
|
44
46
|
return '8px';
|
45
47
|
default:
|
46
48
|
return '10px';
|
@@ -50,9 +52,9 @@ const getCellHeightPadding = (height, fontSize) => {
|
|
50
52
|
};
|
51
53
|
const getCellWidthPadding = fontSize => {
|
52
54
|
switch (fontSize) {
|
53
|
-
case
|
55
|
+
case FONT_SIZE.small:
|
54
56
|
return '8px';
|
55
|
-
case
|
57
|
+
case FONT_SIZE.medium:
|
56
58
|
return '12px';
|
57
59
|
default:
|
58
60
|
return '16px';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCssVars.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssVars.ts"],"sourcesContent":["import { Table3FontSize, Table3RowHeight } from '../types';\n\n// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)\nconst getCellHeightPadding = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n // TODO: can we get the rem values from tailwind\n switch (height) {\n case 'short': {\n switch (fontSize) {\n case
|
1
|
+
{"version":3,"file":"useCssVars.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssVars.ts"],"sourcesContent":["import { FONT_SIZE } from '../components/toolbar/FontSize';\nimport { Table3FontSize, Table3RowHeight } from '../types';\n\n// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)\nconst getCellHeightPadding = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n // TODO: can we get the rem values from tailwind\n switch (height) {\n case 'short': {\n switch (fontSize) {\n case FONT_SIZE.small:\n return '8px';\n\n default:\n return '6px'; // py-1.5\n }\n }\n\n case 'tall': {\n switch (fontSize) {\n case FONT_SIZE.small:\n return '16px';\n\n case FONT_SIZE.large:\n return '12px';\n\n default:\n return '14px';\n }\n }\n\n case 'extra-tall': {\n switch (fontSize) {\n case FONT_SIZE.small:\n return '22px';\n\n case FONT_SIZE.large:\n return '18px';\n\n default:\n return '20px';\n }\n }\n\n default: {\n switch (fontSize) {\n case FONT_SIZE.small:\n return '12px';\n\n case FONT_SIZE.large:\n return '8px';\n\n default:\n return '10px';\n }\n }\n }\n};\n\nconst getCellWidthPadding = (fontSize: Table3FontSize) => {\n switch (fontSize) {\n case FONT_SIZE.small:\n return '8px';\n\n case FONT_SIZE.medium:\n return '12px';\n\n default:\n return '16px'; // py-1.5\n }\n};\n\nexport const useCssVars = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n const style = {\n '--table3-cell-padding-x': getCellWidthPadding(fontSize),\n '--table3-cell-padding-y': getCellHeightPadding(height, fontSize),\n };\n\n return { style };\n};\n"],"names":["getCellHeightPadding","height","fontSize","FONT_SIZE","small","large","getCellWidthPadding","medium","useCssVars","style"],"mappings":";;AAGA;AACA,MAAMA,oBAAoB,GAAGA,CAACC,MAAuB,EAAEC,QAAwB;;EAE3E,QAAQD,MAAM;IACV,KAAK,OAAO;MAAE;QACV,QAAQC,QAAQ;UACZ,KAAKC,SAAS,CAACC,KAAK;YAChB,OAAO,KAAK;UAEhB;YACI,OAAO,KAAK;;;;;IAIxB,KAAK,MAAM;MAAE;QACT,QAAQF,QAAQ;UACZ,KAAKC,SAAS,CAACC,KAAK;YAChB,OAAO,MAAM;UAEjB,KAAKD,SAAS,CAACE,KAAK;YAChB,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB,KAAK,YAAY;MAAE;QACf,QAAQH,QAAQ;UACZ,KAAKC,SAAS,CAACC,KAAK;YAChB,OAAO,MAAM;UAEjB,KAAKD,SAAS,CAACE,KAAK;YAChB,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB;MAAS;QACL,QAAQH,QAAQ;UACZ,KAAKC,SAAS,CAACC,KAAK;YAChB,OAAO,MAAM;UAEjB,KAAKD,SAAS,CAACE,KAAK;YAChB,OAAO,KAAK;UAEhB;YACI,OAAO,MAAM;;;;AAIjC,CAAC;AAED,MAAMC,mBAAmB,GAAIJ,QAAwB;EACjD,QAAQA,QAAQ;IACZ,KAAKC,SAAS,CAACC,KAAK;MAChB,OAAO,KAAK;IAEhB,KAAKD,SAAS,CAACI,MAAM;MACjB,OAAO,MAAM;IAEjB;MACI,OAAO,MAAM;;;AAEzB,CAAC;;MAEYC,UAAU,GAAGA,CAACP,MAAuB,EAAEC,QAAwB;EACxE,MAAMO,KAAK,GAAG;IACV,yBAAyB,EAAEH,mBAAmB,CAACJ,QAAQ,CAAC;IACxD,yBAAyB,EAAEF,oBAAoB,CAACC,MAAM,EAAEC,QAAQ;GACnE;EAED,OAAO;IAAEO;GAAO;AACpB;;;;"}
|
@@ -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} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\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';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useFontSize>;\n getSettings: () => Table3Settings;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n className?: Table3ColumnClassNameHandler<TData>;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n control?: Table3ColumnControlRenderer<TData>;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n dataType?: Table3ColumnDataType;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\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>) {\n // options\n const options = useTablePreset(props);\n\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 const [defaultSettings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n defaultSettings.columnFreezingIndex ?? (defaultSettings as any)?.frozenColumnCount ?? props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, defaultSettings.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(options.enablePrinting, props.loadAll, defaultSettings.showWarningWhenPrintingLargeDataset);\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n defaultSettings.rowHeight ?? (defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, defaultSettings.excludeUnmatchedRecordsInSearch, 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, defaultSettings.columnOrder),\n columnSizing: defaultSettings.columnSizing ?? defaultColumnSizing,\n columnVisibility: defaultSettings.columnVisibility ?? defaultColumnVisibility,\n sorting: defaultSettings.sorting ? defaultSettings.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.printWarningDialogVisibility,\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 currentRow,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n hoverState,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSettingsStateListener(table, setSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","find","column","id","columnMeta","columnDef","meta","getIsVisible","cellValue","getCellValueAsString","dataType","undefined","getColumnCanGlobalFilter","_column$columnDef$met","onSort","manualSorting","getSortedRowModel","defaultSettings","setSettings","useSettings","onChangeSettings","columnFreezing","useColumnFreezing","_ref","_defaultSettings$colu","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","_defaultSettings$rowH","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","definedColumn","state","columnOrder","ensureOrdering","columnSizing","_defaultSettings$colu2","columnVisibility","_defaultSettings$colu3","sorting","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","excludeUnmatchedResults","size","height","printWarningDialogVisibility","useReactTable","data","getCoreRowModel","enableFooter","isPrinting","endsWith","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSettingsStateListener","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length","_props$length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8GgBA,QAAQA,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI9C,IAAId,YAAY,CAACC,mBAAmB,EAAE;IAClC,IAAI,CAACJ,KAAK,CAACkB,QAAQ,EAAE;MACjBf,YAAY,CAACgB,SAAS,GAAG;QACrBC,UAAU,EAAEA,CAACC,GAAiB,EAAEC,QAAgB,EAAEC,MAAW,KAAKC,cAAc,CAACH,GAAG,CAACI,QAAQ,CAACH,QAAQ,CAAC,EAAEC,MAAM;OAClH;MACDpB,YAAY,CAACuB,mBAAmB,GAAGA,mBAAmB,EAAE;;;;;EAOhE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
|
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} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\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';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useFontSize>;\n getSettings: () => Table3Settings;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\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>) {\n // options\n const options = useTablePreset(props);\n\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 const [defaultSettings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n defaultSettings.columnFreezingIndex ?? (defaultSettings as any)?.frozenColumnCount ?? props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, defaultSettings.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(options.enablePrinting, props.loadAll, defaultSettings.showWarningWhenPrintingLargeDataset);\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n defaultSettings.rowHeight ?? (defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, defaultSettings.excludeUnmatchedRecordsInSearch, 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, defaultSettings.columnOrder),\n columnSizing: defaultSettings.columnSizing ?? defaultColumnSizing,\n columnVisibility: defaultSettings.columnVisibility ?? defaultColumnVisibility,\n sorting: defaultSettings.sorting ? defaultSettings.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.printWarningDialogVisibility,\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 currentRow,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n hoverState,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSettingsStateListener(table, setSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","find","column","id","columnMeta","columnDef","meta","getIsVisible","cellValue","getCellValueAsString","dataType","undefined","getColumnCanGlobalFilter","_column$columnDef$met","onSort","manualSorting","getSortedRowModel","defaultSettings","setSettings","useSettings","onChangeSettings","columnFreezing","useColumnFreezing","_ref","_defaultSettings$colu","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","_defaultSettings$rowH","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","definedColumn","state","columnOrder","ensureOrdering","columnSizing","_defaultSettings$colu2","columnVisibility","_defaultSettings$colu3","sorting","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","excludeUnmatchedResults","size","height","printWarningDialogVisibility","useReactTable","data","getCoreRowModel","enableFooter","isPrinting","endsWith","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSettingsStateListener","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length","_props$length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0GgBA,QAAQA,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAA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G,OAAO;MACPI,OAAO;MACPI,SAAS;MACTK,YAAY;MACZE;;GAEP,CAAC;;EAGF4C,qBAAqB,CAAChB,KAAK,CAAC;EAC5BiB,uBAAuB,CAACjB,KAAK,CAAC;EAC9BkB,yBAAyB,CAAClB,KAAK,EAAEnI,KAAK,CAACkB,QAAQ,CAAC;EAChDoI,uBAAuB,CAACnB,KAAK,EAAEnI,KAAK,CAACuJ,WAAW,CAAC;EACjDC,wBAAwB,CAACrB,KAAK,EAAElF,WAAW,CAAC;EAC5CwG,oBAAoB,CAACtB,KAAK,EAAEnI,KAAK,CAAC0J,SAAS,CAAC;EAC5CC,wBAAwB,CAACxB,KAAK,EAAEnI,KAAK,CAACkJ,QAAQ,CAAC;EAC/CU,uBAAuB,CAACzB,KAAK,EAAEnI,KAAK,CAAC6C,MAAM,CAAC;EAE5C,OAAO;IAAEsF,KAAK;IAAE0B,MAAM,GAAAC,aAAA,GAAE9J,KAAK,CAAC6J,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAI9J,KAAK,CAAC4I,IAAI,CAACiB;GAAQ;AAC/D;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import {\n ColumnFilter as RTColumnFilter,\n ColumnOrderState,\n ColumnSizingState,\n ColumnSort as RTTableColumnSort,\n SortingState,\n VisibilityState,\n BuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = {\n className?: string;\n disabled?: boolean;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement>;\n setValue: (value: any) => void;\n value: any;\n};\nexport type Table3ColumnControlRenderer<TType = unknown> =\n | ((props: Table3ColumnControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\n\ntype ValueOf<T> = T[keyof T];\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type Table3FontSize = 'small' | 'medium' | 'large';\nexport type Table3RowClickHandler<TType = unknown> = (row: TType) => void;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = (rows: TType[]) => void;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: Table3FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator;\n value: any;\n};\n\nexport type Table3Filter = { id: string; value: Table3FilterValue };\n\nexport type ColumnFilter = RTColumnFilter;\nexport type Table3FilterHandler = (filters: ColumnFilter[]) => void;\nexport type Table3LoadPageHandler = (\n pageIndex: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3LoadAllHandler = (\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3RowGotoHandler = (\n column: string,\n query: string,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type Table3ColumnSort = RTTableColumnSort;\nexport type Table3SortHandler = (sorting: Table3ColumnSort[]) => void;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = HTMLDivElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IA8GYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import {\n ColumnFilter as RTColumnFilter,\n ColumnOrderState,\n ColumnSizingState,\n ColumnSort as RTTableColumnSort,\n SortingState,\n VisibilityState,\n BuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = {\n className?: string;\n disabled?: boolean;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement>;\n setValue: (value: any) => void;\n value: any;\n};\nexport type Table3ColumnControlRenderer<TType = unknown> =\n | ((props: Table3ColumnControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\n\ntype ValueOf<T> = T[keyof T];\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type Table3GroupProps = {\n id: string;\n header: string;\n colSpan?: number;\n children: (JSX.Element | boolean | null | undefined)[];\n};\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type Table3FontSize = 'small' | 'medium' | 'large';\nexport type Table3RowClickHandler<TType = unknown> = (row: TType) => void;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = (rows: TType[]) => void;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: Table3FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator;\n value: any;\n};\n\nexport type Table3Filter = { id: string | null; value: Table3FilterValue };\n\nexport type ColumnFilter = RTColumnFilter;\nexport type Table3FilterHandler = (filters: ColumnFilter[]) => void;\nexport type Table3LoadPageHandler = (\n pageIndex: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3LoadAllHandler = (\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3RowGotoHandler = (\n column: string,\n query: string,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type Table3ColumnSort = RTTableColumnSort;\nexport type Table3SortHandler = (sorting: Table3ColumnSort[]) => void;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = HTMLDivElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IAqHYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
|
@@ -62,8 +62,6 @@ export { PaginatedTable } from './components/Table/components/PaginatedTable.js'
|
|
62
62
|
export { WindowedTable } from './components/Table/components/WindowedTable.js';
|
63
63
|
export { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath, setByRowIndexPath } from './components/Table/util/rowIndexPath.js';
|
64
64
|
export { insertChildTableRow, removeChildTableRow, useTableRowCreation } from './components/Table/hooks/useRowCreation.js';
|
65
|
-
export { useBoundaryOverflowDetection } from './hooks/useBoundaryOverflowDetection.js';
|
66
|
-
export { Table2 } from './components/Table2/Table2.js';
|
67
65
|
export { useLazyEffect } from './hooks/useLazyEffect.js';
|
68
66
|
export { Textarea } from './components/Textarea/Textarea.js';
|
69
67
|
export { useMatchMedia } from './hooks/useMatchMedia.js';
|
@@ -76,5 +74,6 @@ export { Header } from './components/Header/Header.js';
|
|
76
74
|
export { Layout } from './components/Layout/Layout.js';
|
77
75
|
export { getNavigationLinkClasses } from './components/Navigation2/components/Link.js';
|
78
76
|
export { Navigation2 } from './components/Navigation2/Navigation2.js';
|
77
|
+
export { useBoundaryOverflowDetection } from './hooks/useBoundaryOverflowDetection.js';
|
79
78
|
export { useOnClickOutside } from './utils/hooks/useOnClickOutside.js';
|
80
79
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const isOverflowing = element => element !== null ? element.scrollWidth > element.offsetWidth : false;
|
2
1
|
const getIndexOfFirstChildOverflowingParent = (element, overscan = 0) => {
|
3
2
|
let index = 0;
|
4
3
|
let boundaryChildIndex = null;
|
@@ -15,5 +14,5 @@ const getIndexOfFirstChildOverflowingParent = (element, overscan = 0) => {
|
|
15
14
|
return boundaryChildIndex;
|
16
15
|
};
|
17
16
|
|
18
|
-
export { getIndexOfFirstChildOverflowingParent
|
17
|
+
export { getIndexOfFirstChildOverflowingParent };
|
19
18
|
//# sourceMappingURL=dom.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["export const isOverflowing = (element: HTMLElement | null) =>\n element !== null ? element.scrollWidth > element.offsetWidth : false;\n\nexport const getIndexOfFirstChildOverflowingParent = (element: HTMLElement, overscan = 0) => {\n let index = 0;\n let boundaryChildIndex: number | null = null;\n const clientRect = element.getBoundingClientRect();\n\n for (const child of Array.from(element.children)) {\n const right = child.getBoundingClientRect().right - clientRect.left;\n const width = clientRect.width - overscan;\n\n if (right > width) {\n boundaryChildIndex = index;\n break;\n }\n index++;\n }\n\n return boundaryChildIndex;\n};\n"],"names":["
|
1
|
+
{"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["export const isOverflowing = (element: HTMLElement | null) =>\n element !== null ? element.scrollWidth > element.offsetWidth : false;\n\nexport const getIndexOfFirstChildOverflowingParent = (element: HTMLElement, overscan = 0) => {\n let index = 0;\n let boundaryChildIndex: number | null = null;\n const clientRect = element.getBoundingClientRect();\n\n for (const child of Array.from(element.children)) {\n const right = child.getBoundingClientRect().right - clientRect.left;\n const width = clientRect.width - overscan;\n\n if (right > width) {\n boundaryChildIndex = index;\n break;\n }\n index++;\n }\n\n return boundaryChildIndex;\n};\n"],"names":["getIndexOfFirstChildOverflowingParent","element","overscan","index","boundaryChildIndex","clientRect","getBoundingClientRect","child","Array","from","children","right","left","width"],"mappings":"MAGaA,qCAAqC,GAAGA,CAACC,OAAoB,EAAEC,QAAQ,GAAG,CAAC;EACpF,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,kBAAkB,GAAkB,IAAI;EAC5C,MAAMC,UAAU,GAAGJ,OAAO,CAACK,qBAAqB,EAAE;EAElD,KAAK,MAAMC,KAAK,IAAIC,KAAK,CAACC,IAAI,CAACR,OAAO,CAACS,QAAQ,CAAC,EAAE;IAC9C,MAAMC,KAAK,GAAGJ,KAAK,CAACD,qBAAqB,EAAE,CAACK,KAAK,GAAGN,UAAU,CAACO,IAAI;IACnE,MAAMC,KAAK,GAAGR,UAAU,CAACQ,KAAK,GAAGX,QAAQ;IAEzC,IAAIS,KAAK,GAAGE,KAAK,EAAE;MACfT,kBAAkB,GAAGD,KAAK;MAC1B;;IAEJA,KAAK,EAAE;;EAGX,OAAOC,kBAAkB;AAC7B;;;;"}
|