@economic/taco 2.21.2 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Report/Report.d.ts +21 -0
- package/dist/components/Report/components/Cell/Cell.d.ts +0 -1
- package/dist/components/Report/components/Cell/DisplayCell.d.ts +1 -1
- package/dist/components/Report/components/Cell/util.d.ts +1 -1
- package/dist/components/Report/components/Row/DisplayRow.d.ts +2 -9
- package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +5 -5
- package/dist/components/Report/listeners/useTableRowActiveListener.d.ts +3 -0
- package/dist/components/Report/styles/util.d.ts +2 -2
- package/dist/components/Report/types.d.ts +1 -3
- package/dist/components/Report/useReport.d.ts +2 -7
- package/dist/components/Table3/types.d.ts +1 -1
- package/dist/esm/index.css +501 -9
- package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Group/Group.js +1 -1
- package/dist/esm/packages/taco/src/components/Group/Group.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/Input.js +37 -7
- package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js +3 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +70 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +61 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/util.js +22 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js +32 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js +23 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js +58 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +69 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +34 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +39 -0
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js +194 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js +28 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js +150 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js +60 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js +41 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/util.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/components/Header/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js +90 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js +59 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +118 -0
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js +102 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js +10 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js +62 -0
- package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js +63 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js +50 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +136 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +95 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +49 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js +110 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js +118 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +41 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js +7 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +123 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js +88 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js +95 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js +105 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js +103 -0
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +24 -0
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js +44 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +54 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js +20 -0
- package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/styles/util.js +61 -0
- package/dist/esm/packages/taco/src/components/Report/styles/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/useReport.js +51 -0
- package/dist/esm/packages/taco/src/components/Report/useReport.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/rows.js +10 -0
- package/dist/esm/packages/taco/src/components/Report/util/rows.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +39 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js +162 -0
- package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +2 -1
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +2 -2
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +6 -7
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +6 -6
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +7 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +3 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +9 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +4 -8
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +19 -14
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +18 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js +8 -14
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +5 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +15 -15
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js +20 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/columns.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Textarea/Textarea.js +1 -1
- package/dist/esm/packages/taco/src/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +1 -1
- package/dist/esm/packages/taco/src/index.js +7 -6
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Button.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js +21 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js +8 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +16 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js +17 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js +9 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js +9 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js +38 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +28 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js +14 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js +15 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +26 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +117 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +30 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js +131 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +131 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +43 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +22 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js +270 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js +18 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js.map +1 -0
- package/dist/esm/packages/taco/src/utils/dom.js +5 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/keyboard.js +3 -5
- package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
- package/dist/index.css +501 -9
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/types.d.ts +2 -2
- package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +1 -1
- package/dist/primitives/Table/useTable/util/settings.d.ts +1 -1
- package/dist/primitives/Table/useTable/util/sorting.d.ts +1 -1
- package/dist/taco.cjs.development.js +6380 -2731
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/keyboard.d.ts +0 -1
- package/package.json +2 -2
- package/types.json +4682 -4776
- package/dist/components/Report/features/useReportExport.d.ts +0 -3
@@ -0,0 +1,34 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { flexRender } from '@tanstack/react-table';
|
3
|
+
|
4
|
+
function Footer(header) {
|
5
|
+
return /*#__PURE__*/React__default.createElement(MemoedFooter, {
|
6
|
+
key: header.id,
|
7
|
+
footer: header
|
8
|
+
});
|
9
|
+
}
|
10
|
+
const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
|
11
|
+
var _footer$subHeaders, _footer$subHeaders$fi;
|
12
|
+
const {
|
13
|
+
footer
|
14
|
+
} = props;
|
15
|
+
const columnMeta = footer.column.columnDef.meta;
|
16
|
+
// getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
|
17
|
+
const isHeaderGroup = !!((_footer$subHeaders = footer.subHeaders) !== null && _footer$subHeaders !== void 0 && _footer$subHeaders.length);
|
18
|
+
const isPinned = isHeaderGroup ? (_footer$subHeaders$fi = footer.subHeaders.find(x => x.column.getIsPinned())) === null || _footer$subHeaders$fi === void 0 ? void 0 : _footer$subHeaders$fi.column.getIsPinned() : footer.column.getIsPinned();
|
19
|
+
const style = {};
|
20
|
+
if (isPinned) {
|
21
|
+
// pinned columns should be offset from either the left or right
|
22
|
+
style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;
|
23
|
+
}
|
24
|
+
return /*#__PURE__*/React__default.createElement("td", {
|
25
|
+
key: footer.id,
|
26
|
+
"data-cell-align": columnMeta.align,
|
27
|
+
"data-cell-id": footer.id,
|
28
|
+
"data-cell-pinned": isPinned ? isPinned : undefined,
|
29
|
+
style: style
|
30
|
+
}, footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext()));
|
31
|
+
});
|
32
|
+
|
33
|
+
export { Footer };
|
34
|
+
//# sourceMappingURL=Footer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Footer.js","sources":["../../../../../../../../../src/components/Report/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport { Header as ReactTableHeader, ColumnMeta as ReactTableColumnMeta, flexRender } from '@tanstack/react-table';\n\nexport function Footer<TType = unknown>(header: ReactTableHeader<TType, unknown>) {\n return <MemoedFooter key={header.id} footer={header} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n};\n\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={columnMeta.align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext())}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Footer","header","React","MemoedFooter","key","id","footer","memo","props","columnMeta","column","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","align","undefined","isPlaceholder","flexRender","getContext"],"mappings":";;;SAGgBA,M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 'react';
|
2
|
+
import { useLocalization } from '../../../Provider/Localization.js';
|
3
|
+
|
4
|
+
function Summary(props) {
|
5
|
+
var _table$getState$colum;
|
6
|
+
const {
|
7
|
+
length,
|
8
|
+
table
|
9
|
+
} = props;
|
10
|
+
const {
|
11
|
+
locale,
|
12
|
+
texts
|
13
|
+
} = useLocalization();
|
14
|
+
const currentLength = table.getRowModel().rows.length;
|
15
|
+
let label;
|
16
|
+
let count;
|
17
|
+
// row selection
|
18
|
+
const rowsSelectedLength = table.getIsAllRowsSelected() ? length : table.getSelectedRowModel().rows.length;
|
19
|
+
if (rowsSelectedLength > 0) {
|
20
|
+
label = texts.table3.footer.summary.selected;
|
21
|
+
count = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(rowsSelectedLength)), "\u00A0", texts.table3.footer.summary.count, "\u00A0", /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
|
22
|
+
} else if ((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length ||
|
23
|
+
// filtered data
|
24
|
+
!!table.getState().globalFilter && table.options.enableGlobalFilter // search with hide enabled
|
25
|
+
) {
|
26
|
+
label = texts.table3.footer.summary.records;
|
27
|
+
count = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("strong", null, currentLength), "\u00A0", texts.table3.footer.summary.count, "\u00A0", /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
|
28
|
+
} else {
|
29
|
+
label = texts.table3.footer.summary.records;
|
30
|
+
count = /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length));
|
31
|
+
}
|
32
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
33
|
+
className: "border-grey-300 sticky z-20 -mt-[2.63rem] ml-px flex h-10 w-fit items-center whitespace-nowrap rounded-bl border-t-2 bg-white px-4 !pr-3",
|
34
|
+
"data-taco": "table2-footer-summary"
|
35
|
+
}, label, "\u00A0", count);
|
36
|
+
}
|
37
|
+
|
38
|
+
export { Summary };
|
39
|
+
//# sourceMappingURL=Summary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Summary.js","sources":["../../../../../../../../../src/components/Report/components/Footer/Summary.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { useLocalization } from '../../../Provider/Localization';\n\nexport type FooterSummaryProps<TType = unknown> = {\n length: number;\n table: ReactTable<TType>;\n};\n\nexport function Summary<TType = unknown>(props: FooterSummaryProps<TType>) {\n const { length, table } = props;\n const { locale, texts } = useLocalization();\n const currentLength = table.getRowModel().rows.length;\n\n let label;\n let count;\n\n // row selection\n const rowsSelectedLength = table.getIsAllRowsSelected() ? length : table.getSelectedRowModel().rows.length;\n\n if (rowsSelectedLength > 0) {\n label = texts.table3.footer.summary.selected;\n count = (\n <>\n <strong>{new Intl.NumberFormat(locale).format(rowsSelectedLength)}</strong> \n {texts.table3.footer.summary.count} \n <strong>{new Intl.NumberFormat(locale).format(length)}</strong>\n </>\n );\n } else if (\n table.getState().columnFilters?.length || // filtered data\n (!!table.getState().globalFilter && table.options.enableGlobalFilter) // search with hide enabled\n ) {\n label = texts.table3.footer.summary.records;\n count = (\n <>\n <strong>{currentLength}</strong> \n {texts.table3.footer.summary.count} \n <strong>{new Intl.NumberFormat(locale).format(length)}</strong>\n </>\n );\n } else {\n label = texts.table3.footer.summary.records;\n count = <strong>{new Intl.NumberFormat(locale).format(length)}</strong>;\n }\n\n return (\n <div\n className=\"border-grey-300 sticky z-20 -mt-[2.63rem] ml-px flex h-10 w-fit items-center whitespace-nowrap rounded-bl border-t-2 bg-white px-4 !pr-3\"\n data-taco=\"table2-footer-summary\">\n {label} {count}\n </div>\n );\n}\n"],"names":["Summary","props","length","table","locale","texts","useLocalization","currentLength","getRowModel","rows","label","count","rowsSelectedLength","getIsAllRowsSelected","getSelectedRowModel","table3","footer","summary","selected","React","Intl","NumberFormat","format","_table$getState$colum","getState","columnFilters","globalFilter","options","enableGlobalFilter","records","className"],"mappings":";;;SASgBA,OAAOA,CAAkBC,KAAgC;;EACrE,MAAM;IAAEC,MAAM;IAAEC;GAAO,GAAGF,KAAK;EAC/B,MAAM;IAAEG,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAC3C,MAAMC,aAAa,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACC,IAAI,CAACP,MAAM;EAErD,IAAIQ,KAAK;EACT,IAAIC,KAAK;;EAGT,MAAMC,kBAAkB,GAAGT,KAAK,CAACU,oBAAoB,EAAE,GAAGX,MAAM,GAAGC,KAAK,CAACW,mBAAmB,EAAE,CAACL,IAAI,CAACP,MAAM;EAE1G,IAAIU,kBAAkB,GAAG,CAAC,EAAE;IACxBF,KAAK,GAAGL,KAAK,CAACU,MAAM,CAACC,MAAM,CAACC,OAAO,CAACC,QAAQ;IAC5CP,KAAK,gBACDQ,yEACIA,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACjB,MAAM,CAAC,CAACkB,MAAM,CAACV,kBAAkB,CAAC,CAAU,YAC1EP,KAAK,CAACU,MAAM,CAACC,MAAM,CAACC,OAAO,CAACN,KAAK,yBAClCQ,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACjB,MAAM,CAAC,CAACkB,MAAM,CAACpB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM,IACH,CAAAqB,qBAAA,GAAApB,KAAK,CAACqB,QAAQ,EAAE,CAACC,aAAa,cAAAF,qBAAA,eAA9BA,qBAAA,CAAgCrB,MAAM;;EACrC,CAAC,CAACC,KAAK,CAACqB,QAAQ,EAAE,CAACE,YAAY,IAAIvB,KAAK,CAACwB,OAAO,CAACC,kBAAmB;IACvE;IACElB,KAAK,GAAGL,KAAK,CAACU,MAAM,CAACC,MAAM,CAACC,OAAO,CAACY,OAAO;IAC3ClB,KAAK,gBACDQ,yEACIA,6CAASZ,aAAa,CAAU,YAC/BF,KAAK,CAACU,MAAM,CAACC,MAAM,CAACC,OAAO,CAACN,KAAK,yBAClCQ,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACjB,MAAM,CAAC,CAACkB,MAAM,CAACpB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM;IACHQ,KAAK,GAAGL,KAAK,CAACU,MAAM,CAACC,MAAM,CAACC,OAAO,CAACY,OAAO;IAC3ClB,KAAK,gBAAGQ,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACjB,MAAM,CAAC,CAACkB,MAAM,CAACpB,MAAM,CAAC,CAAU;;EAG3E,oBACIiB;IACIW,SAAS,EAAC,0IAA0I;iBAC1I;KACTpB,KAAK,YAAQC,KAAK,CACjB;AAEd;;;;"}
|
@@ -0,0 +1,194 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import cn from 'clsx';
|
3
|
+
import { Tooltip } from '../../../Tooltip/Tooltip.js';
|
4
|
+
import { flexRender } from '@tanstack/react-table';
|
5
|
+
import { isInternalColumn, unfreezeAllExternalColumns, freezeUptoExternalColumn } from '../../../../primitives/Table/useTable/util/columns.js';
|
6
|
+
import { getSortAttributes, SortIndicator } from './components/SortIndicator.js';
|
7
|
+
import { Resizer } from './components/Resizer.js';
|
8
|
+
import { HeaderMenu } from './components/Menu.js';
|
9
|
+
import { getIsPinned, useSetInitialColumnSizing } from './util.js';
|
10
|
+
|
11
|
+
function Header(header) {
|
12
|
+
var _header$column$column;
|
13
|
+
if (header.column.getIsGrouped()) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
const {
|
17
|
+
table
|
18
|
+
} = header.getContext();
|
19
|
+
const tableMeta = table.options.meta;
|
20
|
+
const columnMeta = (_header$column$column = header.column.columnDef.meta) !== null && _header$column$column !== void 0 ? _header$column$column : {};
|
21
|
+
const isGroup = !!header.subHeaders.length;
|
22
|
+
const isPinned = getIsPinned(header);
|
23
|
+
const canHide = !header.isPlaceholder && !isGroup && header.column.getCanHide();
|
24
|
+
const canMeasureSize = !!table.getRowModel().rows.length;
|
25
|
+
const canPin = !header.isPlaceholder && !isGroup && header.column.getCanPin();
|
26
|
+
const canResize = !header.isPlaceholder && !isGroup && header.column.getCanResize();
|
27
|
+
const canSort = !header.isPlaceholder && !isGroup && header.column.getCanSort();
|
28
|
+
const canGoto = canSort && !header.isPlaceholder && !isGroup && tableMeta.rowGoto.isEnabled && !!header.column.getIsSorted();
|
29
|
+
const hasMenu = !isInternalColumn(header.id) && (canHide || canGoto || canPin || canSort || !!columnMeta.menu);
|
30
|
+
const sorting = table.getState().sorting;
|
31
|
+
const filters = table.getState().columnFilters;
|
32
|
+
const search = table.getState().globalFilter;
|
33
|
+
// passing header or column results in re-renders on scroll, so anything from those objects as memoed props
|
34
|
+
const memoedProps = {
|
35
|
+
align: columnMeta.align,
|
36
|
+
canHide,
|
37
|
+
canGoto,
|
38
|
+
canMeasureSize,
|
39
|
+
canPin,
|
40
|
+
canResize,
|
41
|
+
canSort,
|
42
|
+
className: cn('group/header', columnMeta.headerClassName),
|
43
|
+
children: flexRender(header.column.columnDef.header, header.getContext()),
|
44
|
+
colSpan: header.colSpan,
|
45
|
+
customMenu: columnMeta.menu,
|
46
|
+
defaultWidth: columnMeta.defaultWidth,
|
47
|
+
hasMenu,
|
48
|
+
id: header.id,
|
49
|
+
index: header.index,
|
50
|
+
isGroup,
|
51
|
+
isPinned,
|
52
|
+
isPlaceholder: header.isPlaceholder,
|
53
|
+
offset: header.column.getStart(isPinned),
|
54
|
+
setRowActiveIndex: tableMeta.rowActive.setRowActiveIndex,
|
55
|
+
setColumnSizing: table.setColumnSizing,
|
56
|
+
tooltip: columnMeta.tooltip,
|
57
|
+
width: table.getState().columnSizing[header.id]
|
58
|
+
};
|
59
|
+
if (header.isPlaceholder) {
|
60
|
+
const nextHeader = header.headerGroup.headers[header.index + 1];
|
61
|
+
memoedProps.className = cn('!bg-white before:!content-none', memoedProps.className, {
|
62
|
+
'after:!content-none': nextHeader === null || nextHeader === void 0 ? void 0 : nextHeader.isPlaceholder
|
63
|
+
});
|
64
|
+
}
|
65
|
+
if (canGoto) {
|
66
|
+
memoedProps.onGoto = query => {
|
67
|
+
var _tableMeta$rowGoto$ha, _tableMeta$rowGoto;
|
68
|
+
return (_tableMeta$rowGoto$ha = (_tableMeta$rowGoto = tableMeta.rowGoto).handleGoto) === null || _tableMeta$rowGoto$ha === void 0 ? void 0 : _tableMeta$rowGoto$ha.call(_tableMeta$rowGoto, header.id, query, sorting, filters, search);
|
69
|
+
};
|
70
|
+
}
|
71
|
+
if (canHide) {
|
72
|
+
memoedProps.onHide = header.column.getToggleVisibilityHandler();
|
73
|
+
}
|
74
|
+
if (canPin) {
|
75
|
+
memoedProps.onPin = index => {
|
76
|
+
// TODO: this can probably be moved to a feature hook
|
77
|
+
table.setColumnPinning(pinningState => {
|
78
|
+
return {
|
79
|
+
...pinningState,
|
80
|
+
left: index === undefined ? unfreezeAllExternalColumns(pinningState.left) : freezeUptoExternalColumn(index, table.getAllLeafColumns().map(column => column.id))
|
81
|
+
};
|
82
|
+
});
|
83
|
+
};
|
84
|
+
}
|
85
|
+
if (canResize) {
|
86
|
+
memoedProps.isResizing = header.column.getIsResizing();
|
87
|
+
memoedProps.onResize = header.getResizeHandler();
|
88
|
+
}
|
89
|
+
if (canSort) {
|
90
|
+
const handleSortToggle = sortDirection => {
|
91
|
+
if (sortDirection === false) {
|
92
|
+
header.column.clearSorting();
|
93
|
+
} else {
|
94
|
+
header.column.toggleSorting(sortDirection === 'desc');
|
95
|
+
}
|
96
|
+
};
|
97
|
+
memoedProps.onSort = header.column.getToggleSortingHandler();
|
98
|
+
memoedProps.onSortToggle = handleSortToggle;
|
99
|
+
memoedProps.sortDirection = header.column.getIsSorted();
|
100
|
+
}
|
101
|
+
return /*#__PURE__*/React__default.createElement(MemoedHeader, Object.assign({
|
102
|
+
key: header.id
|
103
|
+
}, memoedProps));
|
104
|
+
}
|
105
|
+
const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(props) {
|
106
|
+
const {
|
107
|
+
align,
|
108
|
+
canGoto,
|
109
|
+
canHide,
|
110
|
+
canMeasureSize,
|
111
|
+
canPin,
|
112
|
+
canResize,
|
113
|
+
canSort,
|
114
|
+
children,
|
115
|
+
className,
|
116
|
+
colSpan,
|
117
|
+
customMenu,
|
118
|
+
defaultWidth,
|
119
|
+
hasMenu,
|
120
|
+
id,
|
121
|
+
index,
|
122
|
+
isGroup,
|
123
|
+
isPinned,
|
124
|
+
isPlaceholder,
|
125
|
+
isResizing,
|
126
|
+
offset,
|
127
|
+
onGoto: handleGoto,
|
128
|
+
onHide: handleHide,
|
129
|
+
onPin: handlePin,
|
130
|
+
onResize: handleResize,
|
131
|
+
onSort: handleSort,
|
132
|
+
onSortToggle: handleSortToggle,
|
133
|
+
setRowActiveIndex,
|
134
|
+
setColumnSizing,
|
135
|
+
sortDirection,
|
136
|
+
tooltip,
|
137
|
+
width
|
138
|
+
} = props;
|
139
|
+
const [ref, setRef] = React__default.useState(null);
|
140
|
+
// save column width if none is set
|
141
|
+
useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);
|
142
|
+
// feature specific styles
|
143
|
+
const style = {};
|
144
|
+
// column groups often span multiple columns
|
145
|
+
if (colSpan > 1) {
|
146
|
+
style.gridColumn = `span ${colSpan}`;
|
147
|
+
}
|
148
|
+
// pinned columns should be offset from either the left or right
|
149
|
+
if (isPinned) {
|
150
|
+
style[isPinned] = `${offset}px`;
|
151
|
+
}
|
152
|
+
return /*#__PURE__*/React__default.createElement("th", Object.assign({}, getSortAttributes(canSort, handleSort, sortDirection), {
|
153
|
+
className: className,
|
154
|
+
"data-cell-align": isGroup ? 'center' : align,
|
155
|
+
"data-cell-id": id,
|
156
|
+
"data-cell-pinned": isPinned ? isPinned : undefined,
|
157
|
+
style: style,
|
158
|
+
ref: setRef
|
159
|
+
}), isPlaceholder ? null : isInternalColumn(id) ? children : ( /*#__PURE__*/React__default.createElement(Tooltip, {
|
160
|
+
title: String(tooltip !== null && tooltip !== void 0 ? tooltip : children),
|
161
|
+
placement: "top"
|
162
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
163
|
+
className: "truncate"
|
164
|
+
}, children))), sortDirection ? /*#__PURE__*/React__default.createElement(SortIndicator, {
|
165
|
+
direction: sortDirection
|
166
|
+
}) : null, hasMenu ? ( /*#__PURE__*/React__default.createElement(HeaderMenu, {
|
167
|
+
canGoto: canGoto,
|
168
|
+
canHide: canHide,
|
169
|
+
canPin: canPin,
|
170
|
+
canSort: canSort,
|
171
|
+
className: cn({
|
172
|
+
'ml-auto': align !== 'right',
|
173
|
+
'ml-0': align === 'right'
|
174
|
+
}),
|
175
|
+
customMenu: customMenu,
|
176
|
+
index: index,
|
177
|
+
onGoto: handleGoto,
|
178
|
+
onHide: handleHide,
|
179
|
+
onPin: handlePin,
|
180
|
+
onSortToggle: handleSortToggle,
|
181
|
+
setRowActiveIndex: setRowActiveIndex,
|
182
|
+
sortDirection: sortDirection
|
183
|
+
})) : null, canResize ? ( /*#__PURE__*/React__default.createElement(Resizer, {
|
184
|
+
headerRef: ref,
|
185
|
+
id: id,
|
186
|
+
isResizing: isResizing,
|
187
|
+
onResize: handleResize,
|
188
|
+
setColumnSizing: setColumnSizing,
|
189
|
+
width: width
|
190
|
+
})) : null);
|
191
|
+
});
|
192
|
+
|
193
|
+
export { Header };
|
194
|
+
//# sourceMappingURL=Header.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Header.js","sources":["../../../../../../../../../src/components/Report/components/Header/Header.tsx"],"sourcesContent":["import React from 'react';\nimport {\n TableMeta as ReactTableMeta,\n ColumnMeta as ReactTableColumnMeta,\n Header as ReactTableHeader,\n ColumnPinningPosition as ReactTableColumnPinningPosition,\n flexRender,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport {\n freezeUptoExternalColumn,\n isInternalColumn,\n unfreezeAllExternalColumns,\n} from '../../../../primitives/Table/useTable/util/columns';\nimport { Tooltip } from '../../../Tooltip/Tooltip';\nimport { SortIndicator, getSortAttributes } from './components/SortIndicator';\nimport {\n TableColumnAlignment,\n TableColumnMenu,\n TableColumnSortDirection,\n TableColumnWidth,\n} from '../../../../primitives/Table/types';\nimport { Resizer } from './components/Resizer';\nimport { HeaderMenu } from './components/Menu';\nimport { getIsPinned, useSetInitialColumnSizing } from './util';\n\nexport function Header<TType = unknown>(header: ReactTableHeader<TType, unknown>) {\n if (header.column.getIsGrouped()) {\n return null;\n }\n\n const { table } = header.getContext();\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = (header.column.columnDef.meta ?? {}) as ReactTableColumnMeta<TType, unknown>;\n\n const isGroup = !!header.subHeaders.length;\n const isPinned = getIsPinned(header);\n\n const canHide = !header.isPlaceholder && !isGroup && header.column.getCanHide();\n const canMeasureSize = !!table.getRowModel().rows.length;\n const canPin = !header.isPlaceholder && !isGroup && header.column.getCanPin();\n const canResize = !header.isPlaceholder && !isGroup && header.column.getCanResize();\n const canSort = !header.isPlaceholder && !isGroup && header.column.getCanSort();\n const canGoto = canSort && !header.isPlaceholder && !isGroup && tableMeta.rowGoto.isEnabled && !!header.column.getIsSorted();\n\n const hasMenu = !isInternalColumn(header.id) && (canHide || canGoto || canPin || canSort || !!columnMeta.menu);\n\n const sorting = table.getState().sorting;\n const filters = table.getState().columnFilters;\n const search = table.getState().globalFilter;\n\n // passing header or column results in re-renders on scroll, so anything from those objects as memoed props\n const memoedProps: MemoedHeaderProps = {\n align: columnMeta.align,\n canHide,\n canGoto,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n className: cn('group/header', columnMeta.headerClassName),\n children: flexRender(header.column.columnDef.header, header.getContext()),\n colSpan: header.colSpan,\n customMenu: columnMeta.menu,\n defaultWidth: columnMeta.defaultWidth,\n hasMenu,\n id: header.id,\n index: header.index,\n isGroup,\n isPinned,\n isPlaceholder: header.isPlaceholder,\n offset: header.column.getStart(isPinned),\n setRowActiveIndex: tableMeta.rowActive.setRowActiveIndex,\n setColumnSizing: table.setColumnSizing,\n tooltip: columnMeta.tooltip,\n width: table.getState().columnSizing[header.id],\n };\n\n if (header.isPlaceholder) {\n const nextHeader = header.headerGroup.headers[header.index + 1];\n memoedProps.className = cn('!bg-white before:!content-none', memoedProps.className, {\n 'after:!content-none': nextHeader?.isPlaceholder,\n });\n }\n\n if (canGoto) {\n memoedProps.onGoto = ((query: string) => tableMeta.rowGoto.handleGoto?.(header.id, query, sorting, filters, search)) as (\n query: string\n ) => Promise<number>;\n }\n\n if (canHide) {\n memoedProps.onHide = header.column.getToggleVisibilityHandler();\n }\n\n if (canPin) {\n memoedProps.onPin = (index: number | undefined) => {\n // TODO: this can probably be moved to a feature hook\n table.setColumnPinning(pinningState => {\n return {\n ...pinningState,\n left:\n index === undefined\n ? unfreezeAllExternalColumns(pinningState.left)\n : freezeUptoExternalColumn(\n index,\n table.getAllLeafColumns().map(column => column.id)\n ),\n };\n });\n };\n }\n\n if (canResize) {\n memoedProps.isResizing = header.column.getIsResizing();\n memoedProps.onResize = header.getResizeHandler();\n }\n\n if (canSort) {\n const handleSortToggle = (sortDirection: TableColumnSortDirection | false) => {\n if (sortDirection === false) {\n header.column.clearSorting();\n } else {\n header.column.toggleSorting(sortDirection === 'desc');\n }\n };\n\n memoedProps.onSort = header.column.getToggleSortingHandler();\n memoedProps.onSortToggle = handleSortToggle;\n memoedProps.sortDirection = header.column.getIsSorted();\n }\n\n return <MemoedHeader key={header.id} {...memoedProps} />;\n}\n\nexport type MemoedHeaderProps = {\n align?: TableColumnAlignment;\n canHide: boolean;\n canGoto: boolean;\n canMeasureSize: boolean;\n canPin: boolean;\n canResize: boolean;\n canSort: boolean;\n children: JSX.Element | React.ReactNode;\n className?: string;\n colSpan: number;\n customMenu?: TableColumnMenu;\n defaultWidth?: TableColumnWidth;\n hasMenu: boolean;\n id: string;\n index: number;\n isGroup: boolean;\n isPinned?: ReactTableColumnPinningPosition;\n isPlaceholder: boolean;\n isResizing?: boolean;\n offset?: number;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onResize?: (event: unknown) => void;\n onSort?: (event: unknown) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n setRowActiveIndex: (index: number) => void;\n setColumnSizing: any;\n sortDirection?: TableColumnSortDirection | false;\n tooltip?: string;\n width?: TableColumnWidth;\n};\n\nconst MemoedHeader = React.memo(function MemoedHeader(props: MemoedHeaderProps) {\n const {\n align,\n canGoto,\n canHide,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n children,\n className,\n colSpan,\n customMenu,\n defaultWidth,\n hasMenu,\n id,\n index,\n isGroup,\n isPinned,\n isPlaceholder,\n isResizing,\n offset,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onResize: handleResize,\n onSort: handleSort,\n onSortToggle: handleSortToggle,\n setRowActiveIndex,\n setColumnSizing,\n sortDirection,\n tooltip,\n width,\n } = props;\n const [ref, setRef] = React.useState<HTMLTableCellElement | null>(null);\n\n // save column width if none is set\n useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);\n\n // feature specific styles\n const style: React.CSSProperties = {};\n\n // column groups often span multiple columns\n if (colSpan > 1) {\n style.gridColumn = `span ${colSpan}`;\n }\n\n // pinned columns should be offset from either the left or right\n if (isPinned) {\n style[isPinned] = `${offset}px`;\n }\n\n return (\n <th\n {...getSortAttributes(canSort, handleSort, sortDirection)}\n className={className}\n data-cell-align={isGroup ? 'center' : align}\n data-cell-id={id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}\n ref={setRef}>\n {isPlaceholder ? null : isInternalColumn(id) ? (\n children\n ) : (\n <Tooltip title={String(tooltip ?? children)} placement=\"top\">\n <span className=\"truncate\">{children}</span>\n </Tooltip>\n )}\n {sortDirection ? <SortIndicator direction={sortDirection} /> : null}\n {hasMenu ? (\n <HeaderMenu\n canGoto={canGoto}\n canHide={canHide}\n canPin={canPin}\n canSort={canSort}\n className={cn({\n 'ml-auto': align !== 'right',\n 'ml-0': align === 'right',\n })}\n customMenu={customMenu}\n index={index}\n onGoto={handleGoto}\n onHide={handleHide}\n onPin={handlePin}\n onSortToggle={handleSortToggle}\n setRowActiveIndex={setRowActiveIndex}\n sortDirection={sortDirection}\n />\n ) : null}\n {canResize ? (\n <Resizer\n headerRef={ref}\n id={id}\n isResizing={isResizing as boolean}\n onResize={handleResize as (event: unknown) => void}\n setColumnSizing={setColumnSizing}\n width={width}\n />\n ) : null}\n </th>\n );\n});\n"],"names":["Header","header","column","getIsGrouped","table","getContext","tableMeta","options","meta","columnMeta","_header$column$column","columnDef","isGroup","subHeaders","length","isPinned","getIsPinned","canHide","isPlaceholder","getCanHide","canMeasureSize","getRowModel","rows","canPin","getCanPin","canResize","getCanResize","canSort","getCanSort","canGoto","rowGoto","isEnabled","getIsSorted","hasMenu","isInternalColumn","id","menu","sorting","getState","filters","columnFilters","search","globalFilter","memoedProps","align","className","cn","headerClassName","children","flexRender","colSpan","customMenu","defaultWidth","index","offset","getStart","setRowActiveIndex","rowActive","setColumnSizing","tooltip","width","columnSizing","nextHeader","headerGroup","headers","onGoto","query","_tableMeta$rowGoto$ha","_tableMeta$rowGoto","handleGoto","call","onHide","getToggleVisibilityHandler","onPin","setColumnPinning","pinningState","left","undefined","unfreezeAllExternalColumns","freezeUptoExternalColumn","getAllLeafColumns","map","isResizing","getIsResizing","onResize","getResizeHandler","handleSortToggle","sortDirection","clearSorting","toggleSorting","onSort","getToggleSortingHandler","onSortToggle","React","MemoedHeader","key","memo","props","handleHide","handlePin","handleResize","handleSort","ref","setRef","useState","useSetInitialColumnSizing","style","gridColumn","getSortAttributes","Tooltip","title","String","placement","SortIndicator","direction","HeaderMenu","Resizer","headerRef"],"mappings":";;;;;;;;;;SA0BgBA,MAAMA,CAAkBC,MAAwC;;EAC5E,IAAIA,MAAM,CAACC,MAAM,CAACC,YAAY,EAAE,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EI,UAAU;IAClBE,MAAM,EAAE2B,UAAU;IAClBzB,KAAK,EAAE0B,SAAS;IAChBP,YAAY,EAAEN,gBAAgB;IAC9B9B,iBAAiB,EAAEA,iBAAiB;IACpC+B,aAAa,EAAEA;IACjB,IACF,IAAI,EACP9D,SAAS,kBACNoE,6BAACuB,OAAO;IACJC,SAAS,EAAEf,GAAG;IACdnE,EAAE,EAAEA,EAAE;IACN+C,UAAU,EAAEA,UAAqB;IACjCE,QAAQ,EAAEgB,YAAwC;IAClD1C,eAAe,EAAEA,eAAe;IAChCE,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAAC;;;;"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { useLocalization } from '../../../../Provider/Localization.js';
|
3
|
+
import { Popover } from '../../../../Popover/Popover.js';
|
4
|
+
import { SearchInput } from '../../../../SearchInput/SearchInput.js';
|
5
|
+
|
6
|
+
function GotoPopover(props) {
|
7
|
+
const {
|
8
|
+
onGoto: handleGoto,
|
9
|
+
trigger,
|
10
|
+
...popoverProps
|
11
|
+
} = props;
|
12
|
+
const {
|
13
|
+
texts
|
14
|
+
} = useLocalization();
|
15
|
+
const handleSearch = value => handleGoto(value);
|
16
|
+
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
|
17
|
+
anchor: trigger
|
18
|
+
}), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement(SearchInput, {
|
19
|
+
"aria-label": texts.table3.columns.menu.gotoRow,
|
20
|
+
name: "query",
|
21
|
+
onSearch: handleSearch,
|
22
|
+
onKeyDown: event => event.stopPropagation(),
|
23
|
+
placeholder: `${texts.table3.columns.menu.gotoRow}...`
|
24
|
+
})));
|
25
|
+
}
|
26
|
+
|
27
|
+
export { GotoPopover };
|
28
|
+
//# sourceMappingURL=Goto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Goto.js","sources":["../../../../../../../../../../src/components/Report/components/Header/components/Goto.tsx"],"sourcesContent":["import React from 'react';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Popover, PopoverProps } from '../../../../Popover/Popover';\nimport { SearchInput } from '../../../../SearchInput/SearchInput';\n\nexport type GotoProps = PopoverProps & {\n onGoto: (query: string) => Promise<void>;\n};\n\nexport function GotoPopover(props: GotoProps) {\n const { onGoto: handleGoto, trigger, ...popoverProps } = props;\n const { texts } = useLocalization();\n\n const handleSearch = value => handleGoto(value);\n\n return (\n <Popover {...popoverProps} anchor={trigger}>\n <Popover.Content>\n <SearchInput\n aria-label={texts.table3.columns.menu.gotoRow}\n name=\"query\"\n onSearch={handleSearch}\n onKeyDown={event => event.stopPropagation()}\n placeholder={`${texts.table3.columns.menu.gotoRow}...`}\n />\n </Popover.Content>\n </Popover>\n );\n}\n"],"names":["GotoPopover","props","onGoto","handleGoto","trigger","popoverProps","texts","useLocalization","handleSearch","value","React","Popover","anchor","Content","SearchInput","table3","columns","menu","gotoRow","name","onSearch","onKeyDown","event","stopPropagation","placeholder"],"mappings":";;;;;SASgBA,WAAWA,CAACC,KAAgB;EACxC,MAAM;IAAEC,MAAM,EAAEC,UAAU;IAAEC,OAAO;IAAE,GAAGC;GAAc,GAAGJ,KAAK;EAC9D,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,YAAY,GAAGC,KAAK,IAAIN,UAAU,CAACM,KAAK,CAAC;EAE/C,oBACIC,6BAACC,OAAO,oBAAKN,YAAY;IAAEO,MAAM,EAAER;mBAC/BM,6BAACC,OAAO,CAACE,OAAO,qBACZH,6BAACI,WAAW;kBACIR,KAAK,CAACS,MAAM,CAACC,OAAO,CAACC,IAAI,CAACC,OAAO;IAC7CC,IAAI,EAAC,OAAO;IACZC,QAAQ,EAAEZ,YAAY;IACtBa,SAAS,EAAEC,KAAK,IAAIA,KAAK,CAACC,eAAe,EAAE;IAC3CC,WAAW,KAAKlB,KAAK,CAACS,MAAM,CAACC,OAAO,CAACC,IAAI,CAACC;IAC5C,CACY,CACZ;AAElB;;;;"}
|
@@ -0,0 +1,150 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import cn from 'clsx';
|
3
|
+
import { IconButton } from '../../../../IconButton/IconButton.js';
|
4
|
+
import { useLocalization } from '../../../../Provider/Localization.js';
|
5
|
+
import { Menu } from '../../../../Menu/Menu.js';
|
6
|
+
import { _finallyRethrows, _catch } from '../../../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
7
|
+
import { GotoPopover } from './Goto.js';
|
8
|
+
|
9
|
+
function HeaderMenu(props) {
|
10
|
+
const {
|
11
|
+
canGoto,
|
12
|
+
canHide,
|
13
|
+
canPin,
|
14
|
+
canSort,
|
15
|
+
customMenu,
|
16
|
+
index,
|
17
|
+
onGoto: handleGoto,
|
18
|
+
onHide: handleHide,
|
19
|
+
onPin: handlePin,
|
20
|
+
onSortToggle: handleSortToggle,
|
21
|
+
// scrollToIndex,
|
22
|
+
setRowActiveIndex,
|
23
|
+
sortDirection
|
24
|
+
} = props;
|
25
|
+
const {
|
26
|
+
texts
|
27
|
+
} = useLocalization();
|
28
|
+
const [popover, setPopover] = React__default.useState(undefined);
|
29
|
+
let popoverElement;
|
30
|
+
if (popover) {
|
31
|
+
const handleClosePopover = () => setPopover(undefined);
|
32
|
+
switch (popover) {
|
33
|
+
case 'goto':
|
34
|
+
{
|
35
|
+
if (handleGoto) {
|
36
|
+
const goto = function (query) {
|
37
|
+
try {
|
38
|
+
const _temp = _finallyRethrows(function () {
|
39
|
+
return _catch(function () {
|
40
|
+
return Promise.resolve(handleGoto(query)).then(function (index) {
|
41
|
+
// scroll to first, row active might not be enabled
|
42
|
+
//scrollToIndex(index + 2, { align: 'center' });
|
43
|
+
setRowActiveIndex(index);
|
44
|
+
});
|
45
|
+
}, function (e) {
|
46
|
+
console.error(e);
|
47
|
+
//
|
48
|
+
});
|
49
|
+
}, function (_wasThrown, _result) {
|
50
|
+
handleClosePopover();
|
51
|
+
if (_wasThrown) throw _result;
|
52
|
+
return _result;
|
53
|
+
});
|
54
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
55
|
+
} catch (e) {
|
56
|
+
return Promise.reject(e);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
popoverElement = props => /*#__PURE__*/React__default.createElement(GotoPopover, Object.assign({}, props, {
|
60
|
+
open: true,
|
61
|
+
onChange: handleClosePopover,
|
62
|
+
onGoto: goto
|
63
|
+
}));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
const memoedMenuItems = React__default.useMemo(() => {
|
69
|
+
const menuItems = [];
|
70
|
+
if (canHide && handleHide) {
|
71
|
+
// we do this in the next tick, otherwise the menu closes and react throws a "state update on unmounted component" error
|
72
|
+
const handleClick = event => setTimeout(() => handleHide(event), 1);
|
73
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
|
74
|
+
icon: "eye-off",
|
75
|
+
onClick: handleClick
|
76
|
+
}, texts.table3.columns.menu.hideColumn));
|
77
|
+
}
|
78
|
+
if (canSort) {
|
79
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
|
80
|
+
icon: "sort-by",
|
81
|
+
subMenu: () => ( /*#__PURE__*/React__default.createElement(Menu.SubMenu, null, /*#__PURE__*/React__default.createElement(Menu.RadioGroup, {
|
82
|
+
onChange: handleSortToggle,
|
83
|
+
value: sortDirection
|
84
|
+
}, /*#__PURE__*/React__default.createElement(Menu.RadioGroup.Item, {
|
85
|
+
value: "asc"
|
86
|
+
}, texts.table3.columns.menu.sortingOrder.ascending), /*#__PURE__*/React__default.createElement(Menu.RadioGroup.Item, {
|
87
|
+
value: "desc"
|
88
|
+
}, texts.table3.columns.menu.sortingOrder.descending), /*#__PURE__*/React__default.createElement(Menu.RadioGroup.Item, {
|
89
|
+
value: false
|
90
|
+
}, texts.table3.columns.menu.sortingOrder.unsorted))))
|
91
|
+
}, texts.table3.columns.menu.sorting));
|
92
|
+
}
|
93
|
+
if (canGoto) {
|
94
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
|
95
|
+
icon: "move",
|
96
|
+
onClick: () => setPopover('goto'),
|
97
|
+
shortcut: "g"
|
98
|
+
}, texts.table3.columns.menu.gotoRow, "..."));
|
99
|
+
}
|
100
|
+
if (canPin && handlePin) {
|
101
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
|
102
|
+
icon: "column-freeze",
|
103
|
+
onClick: () => handlePin(index)
|
104
|
+
}, index === 0 ? texts.table3.columns.menu.freezeFirstColumn : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(index + 1))));
|
105
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
|
106
|
+
icon: "column-unfreeze",
|
107
|
+
onClick: () => handlePin(undefined)
|
108
|
+
}, texts.table3.columns.menu.unfreezeColumns));
|
109
|
+
}
|
110
|
+
if (customMenu) {
|
111
|
+
const menu = customMenu({
|
112
|
+
trigger: undefined
|
113
|
+
});
|
114
|
+
const customItems = React__default.Children.toArray(menu.props.children.props.children);
|
115
|
+
if (customItems.length) {
|
116
|
+
if (menuItems.length) {
|
117
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Separator, null));
|
118
|
+
}
|
119
|
+
menuItems.push(...customItems);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
return menuItems.map((item, key) => /*#__PURE__*/React__default.cloneElement(item, {
|
123
|
+
key
|
124
|
+
}));
|
125
|
+
}, [canGoto, canHide, canPin, canSort, customMenu, handleGoto, handleSortToggle, index, sortDirection]);
|
126
|
+
// can't use display: none because the button needs to be focusable
|
127
|
+
const className = cn(
|
128
|
+
// positioning
|
129
|
+
'justify-end -mr-1 overflow-hidden',
|
130
|
+
// sizing
|
131
|
+
'!h-6 !w-0 !min-h-[theme(spacing.6)] !min-w-0',
|
132
|
+
// visible - hover
|
133
|
+
'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)]',
|
134
|
+
// visible - expanded
|
135
|
+
'aria-expanded:!w-6 aria-expanded:!min-w-[theme(spacing.6)]',
|
136
|
+
// visible - focus
|
137
|
+
'focus:!w-6 focus:!min-w-[theme(spacing.6)]', {
|
138
|
+
'!w-6 !min-w-[theme(spacing.6)]': !!popoverElement
|
139
|
+
}, props.className);
|
140
|
+
return /*#__PURE__*/React__default.createElement(IconButton, {
|
141
|
+
className: className,
|
142
|
+
icon: "more",
|
143
|
+
menu: popoverElement ? undefined : menuProps => ( /*#__PURE__*/React__default.createElement(Menu, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu.Content, null, memoedMenuItems))),
|
144
|
+
popover: popoverElement,
|
145
|
+
onClickCapture: event => event.preventDefault()
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
export { HeaderMenu };
|
150
|
+
//# sourceMappingURL=Menu.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Menu.js","sources":["../../../../../../../../../../src/components/Report/components/Header/components/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../Menu/Menu';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { GotoPopover } from './Goto';\nimport { TableColumnMenu, TableColumnSortDirection } from '../../../../../primitives/Table/types';\n\nexport type HeaderMenuProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canGoto: boolean;\n canHide: boolean;\n canPin: boolean;\n canSort: boolean;\n customMenu?: TableColumnMenu;\n index: number;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n // scrollToIndex: TableStrategy['scrollToIndex'];\n setRowActiveIndex: (index: number) => void;\n sortDirection?: TableColumnSortDirection | false;\n};\n\nexport function HeaderMenu(props: HeaderMenuProps) {\n const {\n canGoto,\n canHide,\n canPin,\n canSort,\n customMenu,\n index,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onSortToggle: handleSortToggle,\n // scrollToIndex,\n setRowActiveIndex,\n sortDirection,\n } = props;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'goto': {\n if (handleGoto) {\n const goto = async (query: string) => {\n try {\n const index = await handleGoto(query);\n // scroll to first, row active might not be enabled\n //scrollToIndex(index + 2, { align: 'center' });\n setRowActiveIndex(index);\n } catch (e) {\n console.error(e);\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide && handleHide) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = event => setTimeout(() => handleHide(event), 1);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table3.columns.menu.hideColumn}\n </MenuPrimitive.Item>\n );\n }\n\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortToggle as any} value={sortDirection}>\n <MenuPrimitive.RadioGroup.Item value=\"asc\">\n {texts.table3.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value=\"desc\">\n {texts.table3.columns.menu.sortingOrder.descending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={false}>\n {texts.table3.columns.menu.sortingOrder.unsorted}\n </MenuPrimitive.RadioGroup.Item>\n </MenuPrimitive.RadioGroup>\n </MenuPrimitive.SubMenu>\n )}>\n {texts.table3.columns.menu.sorting}\n </MenuPrimitive.Item>\n );\n }\n\n if (canGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut=\"g\">\n {texts.table3.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canPin && handlePin) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={() => handlePin(index)}>\n {index === 0\n ? texts.table3.columns.menu.freezeFirstColumn\n : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(index + 1))}\n </MenuPrimitive.Item>\n );\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={() => handlePin(undefined)}>\n {texts.table3.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n\n if (customMenu) {\n const menu = customMenu({ trigger: undefined });\n const customItems = React.Children.toArray(menu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<MenuPrimitive.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n return menuItems.map((item, key) => React.cloneElement(item, { key }));\n }, [canGoto, canHide, canPin, canSort, customMenu, handleGoto, handleSortToggle, index, sortDirection]);\n\n // can't use display: none because the button needs to be focusable\n const className = cn(\n // positioning\n 'justify-end -mr-1 overflow-hidden',\n // sizing\n '!h-6 !w-0 !min-h-[theme(spacing.6)] !min-w-0',\n // visible - hover\n 'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)]',\n // visible - expanded\n 'aria-expanded:!w-6 aria-expanded:!min-w-[theme(spacing.6)]',\n // visible - focus\n 'focus:!w-6 focus:!min-w-[theme(spacing.6)]',\n {\n '!w-6 !min-w-[theme(spacing.6)]': !!popoverElement,\n },\n props.className\n );\n\n return (\n <IconButton\n className={className}\n icon=\"more\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <MenuPrimitive {...menuProps}>\n <MenuPrimitive.Content>{memoedMenuItems}</MenuPrimitive.Content>\n </MenuPrimitive>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n />\n );\n}\n"],"names":["HeaderMenu","props","canGoto","canHide","canPin","canSort","customMenu","index","onGoto","handleGoto","onHide","handleHide","onPin","handlePin","onSortToggle","handleSortToggle","setRowActiveIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","e","console","error","_wasThrown","_result","_temp","reject","GotoPopover","open","onChange","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table3","columns","menu","hideColumn","subMenu","SubMenu","RadioGroup","value","sortingOrder","ascending","descending","unsorted","sorting","shortcut","gotoRow","freezeFirstColumn","freezeUptoColumn","replace","String","unfreezeColumns","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","className","cn","IconButton","menuProps","Content","onClickCapture","preventDefault"],"mappings":";;;;;;;;SAwBgBA,UAAUA,CAACC,KAAsB;EAC7C,MAAM;IACFC,OAAO;IACPC,OAAO;IACPC,MAAM;IACNC,OAAO;IACPC,UAAU;IACVC,KAAK;IACLC,MAAM,EAAEC,UAAU;IAClBC,MAAM,EAAEC,UAAU;IAClBC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAEC,gBAAgB;;IAE9BC,iBAAiB;IACjBC;GACH,GAAGhB,KAAK;EACT,MAAM;IAAEiB;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBC,SAAS,CAAC;EAE3E,IAAIC,cAAc;EAElB,IAAIL,OAAO,EAAE;IACT,MAAMM,kBAAkB,GAAGA,MAAML,UAAU,CAACG,SAAS,CAAC;IAEtD,QAAQJ,OAAO;MACX,KAAK,MAAM;QAAE;UACT,IAAIX,UAAU,EAAE;YACZ,MAAMkB,IAAI,aAAUC,KAAa;cAAA;;4CACzB;oB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,SAAS,EAAEA,SAAS;IACpBjC,IAAI,EAAC,MAAM;IACXI,IAAI,EACA9B,cAAc,GACRD,SAAS,GACT+D,SAAS,mBACLjE,6BAAC2B,IAAa,oBAAKsC,SAAS,gBACxBjE,6BAAC2B,IAAa,CAACuC,OAAO,QAAE9C,eAAe,CAAyB,CACpD,CACnB;IAEXtB,OAAO,EAAEK,cAAc;IACvBgE,cAAc,EAAE3C,KAAK,IAAIA,KAAK,CAAC4C,cAAc;IAC/C;AAEV;;;;"}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import cn from 'clsx';
|
3
|
+
import { Tooltip } from '../../../../Tooltip/Tooltip.js';
|
4
|
+
import { useLocalization } from '../../../../Provider/Localization.js';
|
5
|
+
|
6
|
+
function Resizer(props) {
|
7
|
+
const {
|
8
|
+
headerRef,
|
9
|
+
id,
|
10
|
+
isResizing,
|
11
|
+
onResize,
|
12
|
+
setColumnSizing,
|
13
|
+
width
|
14
|
+
} = props;
|
15
|
+
const {
|
16
|
+
texts
|
17
|
+
} = useLocalization();
|
18
|
+
// this prevents sort handlers being activated
|
19
|
+
const handleClick = event => {
|
20
|
+
event.stopPropagation();
|
21
|
+
event.preventDefault();
|
22
|
+
};
|
23
|
+
// columns set to "grow" don't set a width, so if resize is being triggered on a grow column make sure to set a size first
|
24
|
+
const handleResize = event => {
|
25
|
+
if (!Number.isInteger(width) && headerRef) {
|
26
|
+
setColumnSizing(sizes => ({
|
27
|
+
...sizes,
|
28
|
+
[id]: headerRef.getBoundingClientRect().width
|
29
|
+
}));
|
30
|
+
setTimeout(() => {
|
31
|
+
onResize === null || onResize === void 0 ? void 0 : onResize(event);
|
32
|
+
}, 1);
|
33
|
+
} else {
|
34
|
+
onResize === null || onResize === void 0 ? void 0 : onResize(event);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
const handle = /*#__PURE__*/React__default.createElement("div", {
|
38
|
+
className: cn('invisible absolute right-0 top-0 z-10 -mr-2 flex h-full w-4 cursor-col-resize touch-none select-none justify-center rounded py-0.5', 'group-hover/header:visible', '[th:last-child>&]:!mr-0 [th:last-child>&]:w-2', {
|
39
|
+
'!visible': isResizing
|
40
|
+
}),
|
41
|
+
onClick: handleClick,
|
42
|
+
onMouseDown: handleResize,
|
43
|
+
onTouchStart: handleResize
|
44
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
45
|
+
className: cn('h-full w-1 rounded', {
|
46
|
+
'!bg-blue-500': isResizing,
|
47
|
+
'bg-grey-500 hover:bg-grey-700': !isResizing
|
48
|
+
})
|
49
|
+
}));
|
50
|
+
if (isResizing) {
|
51
|
+
return handle;
|
52
|
+
}
|
53
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
54
|
+
placement: "top",
|
55
|
+
title: texts.table3.columns.resize.tooltip
|
56
|
+
}, handle);
|
57
|
+
}
|
58
|
+
|
59
|
+
export { Resizer };
|
60
|
+
//# sourceMappingURL=Resizer.js.map
|
package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Resizer.js","sources":["../../../../../../../../../../src/components/Report/components/Header/components/Resizer.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { TableColumnWidth } from '../../../../../primitives/Table/types';\n\ntype ResizerProps = {\n headerRef: HTMLTableCellElement | null;\n id: string;\n isResizing: boolean;\n onResize: (event: unknown) => void;\n setColumnSizing: any;\n width?: TableColumnWidth;\n};\n\nexport function Resizer(props: ResizerProps) {\n const { headerRef, id, isResizing, onResize, setColumnSizing, width } = props;\n const { texts } = useLocalization();\n\n // this prevents sort handlers being activated\n const handleClick = event => {\n event.stopPropagation();\n event.preventDefault();\n };\n\n // columns set to \"grow\" don't set a width, so if resize is being triggered on a grow column make sure to set a size first\n const handleResize = event => {\n if (!Number.isInteger(width) && headerRef) {\n setColumnSizing(sizes => ({\n ...sizes,\n [id]: headerRef.getBoundingClientRect().width,\n }));\n setTimeout(() => {\n onResize?.(event);\n }, 1);\n } else {\n onResize?.(event);\n }\n };\n\n const handle = (\n <div\n className={cn(\n 'invisible absolute right-0 top-0 z-10 -mr-2 flex h-full w-4 cursor-col-resize touch-none select-none justify-center rounded py-0.5',\n 'group-hover/header:visible',\n '[th:last-child>&]:!mr-0 [th:last-child>&]:w-2',\n {\n '!visible': isResizing,\n }\n )}\n onClick={handleClick}\n onMouseDown={handleResize}\n onTouchStart={handleResize}>\n <div\n className={cn('h-full w-1 rounded', {\n '!bg-blue-500': isResizing,\n 'bg-grey-500 hover:bg-grey-700': !isResizing,\n })}\n />\n </div>\n );\n\n if (isResizing) {\n return handle;\n }\n\n return (\n <Tooltip placement=\"top\" title={texts.table3.columns.resize.tooltip}>\n {handle}\n </Tooltip>\n );\n}\n"],"names":["Resizer","props","headerRef","id","isResizing","onResize","setColumnSizing","width","texts","useLocalization","handleClick","event","stopPropagation","preventDefault","handleResize","Number","isInteger","sizes","getBoundingClientRect","setTimeout","handle","React","className","cn","onClick","onMouseDown","onTouchStart","Tooltip","placement","title","table3","columns","resize","tooltip"],"mappings":";;;;;SAegBA,OAAOA,CAACC,KAAmB;EACvC,MAAM;IAAEC,SAAS;IAAEC,EAAE;IAAEC,UAAU;IAAEC,QAAQ;IAAEC,eAAe;IAAEC;GAAO,GAAGN,KAAK;EAC7E,MAAM;IAAEO;GAAO,GAAGC,eAAe,EAAE;;EAGnC,MAAMC,WAAW,GAAGC,KAAK;IACrBA,KAAK,CAACC,eAAe,EAAE;IACvBD,KAAK,CAACE,cAAc,EAAE;GACzB;;EAGD,MAAMC,YAAY,GAAGH,KAAK;IACtB,IAAI,CAACI,MAAM,CAACC,SAAS,CAACT,KAAK,CAAC,IAAIL,SAAS,EAAE;MACvCI,eAAe,CAACW,KAAK,KAAK;QACtB,GAAGA,KAAK;QACR,CAACd,EAAE,GAAGD,SAAS,CAACgB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