@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
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditingCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport _ from 'lodash';\nimport { TableMeta, CellContext, ColumnMeta, Cell as RTCell, Table as RTTable } from '@tanstack/react-table';\nimport { Indicator, IndicatorReason } from './Indicator';\nimport { columnFilterFn, globalFilterFn } from '../../../util/filtering';\nimport { Table3ColumnControlRenderer, Table3FilterValue } from '../../../types';\nimport { hasChanged, willRowMoveAfterSorting } from '../../../util/editing';\nimport { getCurrentRowCellElement } from '../../../util/columns';\nimport { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions';\nimport { EditingControl } from './EditingControl';\nimport { RowContext, useRowContext } from '../../rows/RowContext';\nimport { Field } from '../../../../Field/Field';\nimport { Highlight } from './Highlight';\n\nexport type EditingCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function EditingCell<TType = unknown>(props: EditingCellProps<TType>) {\n const { cell, table } = props;\n const { isHovered } = useRowContext();\n // Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.\n const tableMeta = table.options.meta as TableMeta<TType>;\n const error = tableMeta.validation.getCellError(cell);\n return <MemoedEditingCell<TType> {...props} error={error} isHovered={isHovered} tableMeta={tableMeta} />;\n}\n\n// Memoization\nexport type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {\n isHovered: boolean;\n tableMeta: TableMeta<TType>;\n error?: string;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const { cell, column, index, getValue, table, tableRef, row, tableMeta, error, highlighted, highlightedAsCurrent } = props;\n const { rowIndex } = React.useContext(RowContext);\n\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const cellRef = React.useRef<HTMLDivElement>(null);\n const controlRef = React.useRef<HTMLElement>(null);\n\n const handleChange = (value: unknown) => tableMeta.editing.setCellValue(cell, value);\n const value = tableMeta.editing.getCellValue(cell) ?? getValue();\n\n const handleFocus = event => {\n // Check if cell is hidden behind pinned columns or edititng actions, and scroll to it.\n const frozenColumnIndex = tableMeta.columnFreezing.frozenColumnIndex;\n const tableElement = tableRef.current;\n\n if (tableElement && frozenColumnIndex !== undefined && index > frozenColumnIndex) {\n const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableElement);\n const cellRect = cellRef.current?.getBoundingClientRect();\n const lastFrozenRect = lastFrozenColumnElement?.getBoundingClientRect();\n const tableRect = tableElement.getBoundingClientRect();\n\n // Check for pinned columns overlap\n if (cellRect && lastFrozenRect && cellRect.left < lastFrozenRect.left + lastFrozenRect.width) {\n const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;\n tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);\n // Check for editing actions overlap\n } else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {\n const spaceBetweenCellAndEditingActions = 10;\n tableElement.scrollTo(\n // Need to take into account if table has been already scrolled.\n tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions,\n tableElement.scrollTop\n );\n }\n }\n\n if (event.target?.select) {\n requestAnimationFrame(() => {\n event.target.select();\n });\n }\n };\n\n const handleBlur = () => {\n tableMeta.editing.setDetailModeEditing(false);\n if (tableMeta.editing.changes?.[cell.row.id]) {\n tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id] as TType, cell.column.id);\n }\n };\n\n // row move indicator\n const moveReason = tableMeta.editing.rowMoveReason?.[cell.column.id] || null;\n const rows = table.getRowModel().rows;\n const isActiveRow =\n tableMeta.rowActive.rowActiveIndex !== undefined && rows[tableMeta.rowActive.rowActiveIndex]?.id === row.id;\n const mountNode = React.useMemo(() => {\n if (moveReason !== null && isActiveRow && !error) {\n return cellRef.current?.parentElement?.firstChild as Element | null;\n }\n return null;\n }, [moveReason, isActiveRow, error, cellRef]);\n\n const removeMoveReason = () => {\n tableMeta.editing.removeRowMoveReason();\n };\n\n React.useEffect(() => {\n // To avoid reseting move reason on another row hover,\n // we need to check for changes only if value got changed in the current row.\n if (!isActiveRow) {\n return;\n }\n\n if (error) {\n if (tableMeta.editing.rowMoveReason) {\n removeMoveReason();\n }\n return;\n }\n\n if (hasChanged(getValue(), value)) {\n const moveReason = getRowMoveReason(\n table,\n rowIndex, // cannot use row.index, as this is not kept in sync once a column is sorted.\n row.original,\n cell,\n value,\n tableMeta.search.excludeUnmatchedResults\n );\n if (moveReason) {\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\n }\n } else {\n removeMoveReason();\n }\n return removeMoveReason;\n }, [value, tableMeta.rowActive.rowActiveIndex, tableMeta.search.excludeUnmatchedResults, error]);\n\n const controlRenderer = column.columnDef.meta?.control as Table3ColumnControlRenderer;\n\n const className = cn(\n // Removing a pixel border width in the padding to avoid a pixel jump when control element is rendered.\n 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem_-_1px)]',\n {\n // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative\n relative: controlRenderer === 'textarea' && columnMeta.enableTruncate,\n },\n props.className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n );\n\n const fieldClassName = cn('!min-h-0 w-full !pb-0', {\n '!pb-3': !!error,\n });\n\n const content = (\n <Field message={error} invalid={!!error} className={fieldClassName}>\n <EditingControl\n align={columnMeta.align}\n column={cell.column}\n data={cell.row.original}\n initialValue={getValue()}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onChange={handleChange}\n ref={controlRef}\n table={table}\n tableRef={tableRef}\n value={value}\n cell={cell}\n error={error}\n tabIndex={isActiveRow ? 0 : -1}\n isActiveRow={isActiveRow}\n />\n </Field>\n );\n\n return (\n <>\n {moveReason !== null && mountNode && !error ? (\n <Indicator\n reason={moveReason}\n columnName={String(cell.column.columnDef.header)}\n mountNode={mountNode}\n validationErrors={[]}\n />\n ) : null}\n <div\n className={!highlighted ? className : undefined}\n data-align={columnMeta.align}\n data-column-index={index}\n role=\"cell\"\n data-editable\n ref={cellRef}\n data-invalid={!!error}\n data-highlighted={highlighted}>\n {highlighted ? (\n <Highlight\n current={highlightedAsCurrent}\n className={className}\n frozenColumnIndex={tableMeta.columnFreezing.frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n </>\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n\nfunction getRowMoveReason<TType>(\n table: RTTable<any>,\n rowIndex: number,\n rowValues: TType,\n cell: RTCell<any, unknown>,\n newValue: any,\n excludeUnmatchedResults: boolean\n) {\n let rowMoveReason: IndicatorReason | null = null;\n const { globalFilter } = table.getState();\n\n const isFilteredByGlobalFilter = excludeUnmatchedResults\n ? Object.values<unknown>({ ...rowValues, [cell.id]: newValue }).some(() => {\n // Global filter can be undefined when there is no text being searched so we pass an empty string to\n // globalFilterFn as query in that case.\n return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');\n })\n : true;\n\n if (!isFilteredByGlobalFilter) {\n rowMoveReason = IndicatorReason.SEARCH;\n } else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue() as Table3FilterValue)) {\n rowMoveReason = IndicatorReason.FILTER;\n } else if (\n !rowMoveReason &&\n cell.column.getIsSorted() &&\n willRowMoveAfterSorting(\n newValue,\n cell,\n rowIndex,\n table.getRowModel().rows,\n !!table.getState().sorting.find(s => s.id === cell.column.id)?.desc\n )\n ) {\n rowMoveReason = IndicatorReason.SORTING;\n }\n\n return rowMoveReason;\n}\n"],"names":["EditingCell","props","cell","table","isHovered","useRowContext","tableMeta","options","meta","error","validation","getCellError","React","MemoedEditingCell","memo","column","index","getValue","tableRef","row","highlighted","highlightedAsCurrent","rowIndex","useContext","RowContext","columnMeta","columnDef","cellRef","useRef","controlRef","handleChange","value","editing","setCellValue","_tableMeta$editing$ge","getCellValue","handleFocus","event","frozenColumnIndex","columnFreezing","tableElement","current","undefined","_cellRef$current","lastFrozenColumnElement","getCurrentRowCellElement","cellRect","getBoundingClientRect","lastFrozenRect","tableRect","left","width","pinnedColumnsWidth","scrollTo","scrollTop","right","EDITING_ACTIONS_WIDTH","spaceBetweenCellAndEditingActions","scrollLeft","_event$target","target","select","requestAnimationFrame","handleBlur","setDetailModeEditing","_tableMeta$editing$ch","changes","id","validate","moveReason","_tableMeta$editing$ro","rowMoveReason","rows","getRowModel","isActiveRow","rowActive","rowActiveIndex","_rows$tableMeta$rowAc","mountNode","useMemo","_cellRef$current2","_cellRef$current2$par","parentElement","firstChild","removeMoveReason","removeRowMoveReason","useEffect","hasChanged","getRowMoveReason","original","search","excludeUnmatchedResults","setRowMoveReason","controlRenderer","_column$columnDef$met","control","className","cn","relative","enableTruncate","fieldClassName","content","Field","message","invalid","EditingControl","align","data","initialValue","onBlur","onFocus","onChange","ref","tabIndex","Indicator","reason","columnName","String","header","validationErrors","role","Highlight","rowValues","newValue","globalFilter","getState","isFilteredByGlobalFilter","Object","values","some","globalFilterFn","IndicatorReason","SEARCH","getIsFiltered","columnFilterFn","getFilterValue","FILTER","getIsSorted","willRowMoveAfterSorting","_table$getState$sorti","sorting","find","s","desc","SORTING"],"mappings":";;;;;;;;;;;;SAsBgBA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CAACjE,aAAa,IACdrE,IAAI,CAACa,MAAM,CAAC0H,WAAW,EAAE,IACzBC,uBAAuB,CACnBf,QAAQ,EACRzH,IAAI,EACJoB,QAAQ,EACRnB,KAAK,CAACsE,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAAmE,qBAAA,GAACxI,KAAK,CAAC0H,QAAQ,EAAE,CAACe,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC3E,EAAE,KAAKjE,IAAI,CAACa,MAAM,CAACoD,EAAE,CAAC,cAAAwE,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACExE,aAAa,GAAG4D,eAAe,CAACa,OAAO;;EAG3C,OAAOzE,aAAa;AACxB;;;;"}
|
1
|
+
{"version":3,"file":"EditingCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport _ from 'lodash';\nimport { TableMeta, CellContext, ColumnMeta, Cell as RTCell, Table as RTTable } from '@tanstack/react-table';\nimport { Indicator, IndicatorReason } from './Indicator';\nimport { columnFilterFn, globalFilterFn } from '../../../util/filtering';\nimport { Table3ColumnControlRenderer, Table3FilterValue } from '../../../types';\nimport { hasChanged, willRowMoveAfterSorting } from '../../../util/editing';\nimport { getCurrentRowCellElement } from '../../../util/columns';\nimport { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions';\nimport { EditingControl } from './EditingControl';\nimport { RowContext, useRowContext } from '../../rows/RowContext';\nimport { Field } from '../../../../Field/Field';\nimport { Highlight } from './Highlight';\n\nexport type EditingCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function EditingCell<TType = unknown>(props: EditingCellProps<TType>) {\n const { cell, table } = props;\n const { isHovered } = useRowContext();\n // Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.\n const tableMeta = table.options.meta as TableMeta<TType>;\n const error = tableMeta.validation.getCellError(cell);\n return <MemoedEditingCell<TType> {...props} error={error} isHovered={isHovered} tableMeta={tableMeta} />;\n}\n\n// Memoization\nexport type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {\n isHovered: boolean;\n tableMeta: TableMeta<TType>;\n error?: string;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const { cell, column, index, getValue, table, tableRef, row, tableMeta, error, highlighted, highlightedAsCurrent } = props;\n const { rowIndex } = React.useContext(RowContext);\n\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const cellRef = React.useRef<HTMLDivElement>(null);\n const controlRef = React.useRef<HTMLElement>(null);\n\n const handleChange = (value: unknown) => tableMeta.editing.setCellValue(cell, value);\n const value = tableMeta.editing.getCellValue(cell) ?? getValue();\n\n const handleFocus = event => {\n // Check if cell is hidden behind pinned columns or edititng actions, and scroll to it.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const frozenColumnIndex = tableMeta.columnFreezing.frozenColumnIndex;\n const tableElement = tableRef.current;\n\n if (tableElement && frozenColumnIndex !== undefined && index > frozenColumnIndex) {\n const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableElement);\n const cellRect = cellRef.current?.getBoundingClientRect();\n const lastFrozenRect = lastFrozenColumnElement?.getBoundingClientRect();\n const tableRect = tableElement.getBoundingClientRect();\n\n // Check for pinned columns overlap\n if (cellRect && lastFrozenRect && cellRect.left < lastFrozenRect.left + lastFrozenRect.width) {\n const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;\n tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);\n // Check for editing actions overlap\n } else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {\n const spaceBetweenCellAndEditingActions = 10;\n tableElement.scrollTo(\n // Need to take into account if table has been already scrolled.\n tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions,\n tableElement.scrollTop\n );\n }\n }\n\n if (event.target?.select) {\n requestAnimationFrame(() => {\n event.target.select();\n });\n }\n };\n\n const handleBlur = () => {\n tableMeta.editing.setDetailModeEditing(false);\n if (tableMeta.editing.changes?.[cell.row.id]) {\n tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id] as TType, cell.column.id);\n }\n };\n\n // row move indicator\n const moveReason = tableMeta.editing.rowMoveReason?.[cell.column.id] || null;\n const rows = table.getRowModel().rows;\n const isActiveRow =\n tableMeta.rowActive.rowActiveIndex !== undefined && rows[tableMeta.rowActive.rowActiveIndex]?.id === row.id;\n const mountNode = React.useMemo(() => {\n if (moveReason !== null && isActiveRow && !error) {\n return cellRef.current?.parentElement?.firstChild as Element | null;\n }\n return null;\n }, [moveReason, isActiveRow, error, cellRef]);\n\n const removeMoveReason = () => {\n tableMeta.editing.removeRowMoveReason();\n };\n\n React.useEffect(() => {\n // To avoid reseting move reason on another row hover,\n // we need to check for changes only if value got changed in the current row.\n if (!isActiveRow) {\n return;\n }\n\n if (error) {\n if (tableMeta.editing.rowMoveReason) {\n removeMoveReason();\n }\n return;\n }\n\n if (hasChanged(getValue(), value)) {\n const moveReason = getRowMoveReason(\n table,\n rowIndex, // cannot use row.index, as this is not kept in sync once a column is sorted.\n row.original,\n cell,\n value,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.search.excludeUnmatchedResults\n );\n if (moveReason) {\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\n }\n } else {\n removeMoveReason();\n }\n return removeMoveReason;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n }, [value, tableMeta.rowActive.rowActiveIndex, tableMeta.search.excludeUnmatchedResults, error]);\n\n const controlRenderer = column.columnDef.meta?.control as Table3ColumnControlRenderer;\n\n const className = cn(\n // Removing a pixel border width in the padding to avoid a pixel jump when control element is rendered.\n 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem_-_1px)]',\n {\n // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative\n relative: controlRenderer === 'textarea' && columnMeta.enableTruncate,\n },\n props.className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n );\n\n const fieldClassName = cn('!min-h-0 w-full !pb-0', {\n '!pb-3': !!error,\n });\n\n const content = (\n <Field message={error} invalid={!!error} className={fieldClassName}>\n <EditingControl\n align={columnMeta.align}\n column={cell.column}\n data={cell.row.original}\n initialValue={getValue()}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onChange={handleChange}\n ref={controlRef}\n table={table}\n tableRef={tableRef}\n value={value}\n cell={cell}\n error={error}\n tabIndex={isActiveRow ? 0 : -1}\n isActiveRow={isActiveRow}\n />\n </Field>\n );\n\n return (\n <>\n {moveReason !== null && mountNode && !error ? (\n <Indicator\n reason={moveReason}\n columnName={String(cell.column.columnDef.header)}\n mountNode={mountNode}\n validationErrors={[]}\n />\n ) : null}\n <div\n className={!highlighted ? className : undefined}\n data-align={columnMeta.align}\n data-column-index={index}\n role=\"cell\"\n data-editable\n ref={cellRef}\n data-invalid={!!error}\n data-highlighted={highlighted}>\n {highlighted ? (\n <Highlight\n current={highlightedAsCurrent}\n className={className}\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n frozenColumnIndex={tableMeta.columnFreezing.frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n </>\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n\nfunction getRowMoveReason<TType>(\n table: RTTable<any>,\n rowIndex: number,\n rowValues: TType,\n cell: RTCell<any, unknown>,\n newValue: any,\n excludeUnmatchedResults: boolean\n) {\n let rowMoveReason: IndicatorReason | null = null;\n const { globalFilter } = table.getState();\n\n const isFilteredByGlobalFilter = excludeUnmatchedResults\n ? Object.values<unknown>({ ...rowValues, [cell.id]: newValue }).some(() => {\n // Global filter can be undefined when there is no text being searched so we pass an empty string to\n // globalFilterFn as query in that case.\n return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');\n })\n : true;\n\n if (!isFilteredByGlobalFilter) {\n rowMoveReason = IndicatorReason.SEARCH;\n } else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue() as Table3FilterValue)) {\n rowMoveReason = IndicatorReason.FILTER;\n } else if (\n !rowMoveReason &&\n cell.column.getIsSorted() &&\n willRowMoveAfterSorting(\n newValue,\n cell,\n rowIndex,\n table.getRowModel().rows,\n !!table.getState().sorting.find(s => s.id === cell.column.id)?.desc\n )\n ) {\n rowMoveReason = IndicatorReason.SORTING;\n }\n\n return rowMoveReason;\n}\n"],"names":["EditingCell","props","cell","table","isHovered","useRowContext","tableMeta","options","meta","error","validation","getCellError","React","MemoedEditingCell","memo","column","index","getValue","tableRef","row","highlighted","highlightedAsCurrent","rowIndex","useContext","RowContext","columnMeta","columnDef","cellRef","useRef","controlRef","handleChange","value","editing","setCellValue","_tableMeta$editing$ge","getCellValue","handleFocus","event","frozenColumnIndex","columnFreezing","tableElement","current","undefined","_cellRef$current","lastFrozenColumnElement","getCurrentRowCellElement","cellRect","getBoundingClientRect","lastFrozenRect","tableRect","left","width","pinnedColumnsWidth","scrollTo","scrollTop","right","EDITING_ACTIONS_WIDTH","spaceBetweenCellAndEditingActions","scrollLeft","_event$target","target","select","requestAnimationFrame","handleBlur","setDetailModeEditing","_tableMeta$editing$ch","changes","id","validate","moveReason","_tableMeta$editing$ro","rowMoveReason","rows","getRowModel","isActiveRow","rowActive","rowActiveIndex","_rows$tableMeta$rowAc","mountNode","useMemo","_cellRef$current2","_cellRef$current2$par","parentElement","firstChild","removeMoveReason","removeRowMoveReason","useEffect","hasChanged","getRowMoveReason","original","search","excludeUnmatchedResults","setRowMoveReason","controlRenderer","_column$columnDef$met","control","className","cn","relative","enableTruncate","fieldClassName","content","Field","message","invalid","EditingControl","align","data","initialValue","onBlur","onFocus","onChange","ref","tabIndex","Indicator","reason","columnName","String","header","validationErrors","role","Highlight","rowValues","newValue","globalFilter","getState","isFilteredByGlobalFilter","Object","values","some","globalFilterFn","IndicatorReason","SEARCH","getIsFiltered","columnFilterFn","getFilterValue","FILTER","getIsSorted","willRowMoveAfterSorting","_table$getState$sorti","sorting","find","s","desc","SORTING"],"mappings":";;;;;;;;;;;;SAsBgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC;GAAO,GAAGF,KAAK;EAC7B,MAAM;IAAEG;GAAW,GAAGC,aAAa,EAAE;;EAErC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGH,SAAS,CAACI,UAAU,CAACC,YAAY,CAACT,IAAI,CAAC;EACrD,oBAAOU,6BAACC,iBAAiB,oBAAYZ,KAAK;IAAEQ,KAAK,EAAEA,KAAK;IAAEL,SAAS,EAAEA,SAAS;IAAEE,SAAS,EAAEA;KAAa;AAC5G;AASA,MAAMO,iBAAiB,gBAAGD,cAAK,CAACE,IAAI,CAAC,SAASD,iBAAiBA,CAAkBZ,KAAoC;;EACjH,MAAM;IAAEC,IAAI;IAAEa,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEd,KAAK;IAAEe,QAAQ;IAAEC,GAAG;IAAEb,SAAS;IAAEG,KAAK;IAAEW,WAAW;IAAEC;GAAsB,GAAGpB,KAAK;EAC1H,MAAM;IAAEqB;GAAU,GAAGV,cAAK,CAACW,UAAU,CAACC,UAAU,CAAC;EAEjD,MAAMC,UAAU,GAAGV,MAAM,CAACW,SAAS,CAAClB,IAAkC;EAEtE,MAAMmB,OAAO,GAAGf,cAAK,CAACgB,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,UAAU,GAAGjB,cAAK,CAACgB,MAAM,CAAc,IAAI,CAAC;EAElD,MAAME,YAAY,G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C;GACpF,CAAC,GACF,IAAI;EAEV,IAAI,CAACE,wBAAwB,EAAE;IAC3BvD,aAAa,GAAG4D,eAAe,CAACC,MAAM;GACzC,MAAM,IAAIlI,IAAI,CAACa,MAAM,CAACsH,aAAa,EAAE,IAAI,CAACC,cAAc,CAACX,QAAQ,EAAEzH,IAAI,CAACa,MAAM,CAACwH,cAAc,EAAuB,CAAC,EAAE;IACpHhE,aAAa,GAAG4D,eAAe,CAACK,MAAM;GACzC,MAAM,IACH,CAACjE,aAAa,IACdrE,IAAI,CAACa,MAAM,CAAC0H,WAAW,EAAE,IACzBC,uBAAuB,CACnBf,QAAQ,EACRzH,IAAI,EACJoB,QAAQ,EACRnB,KAAK,CAACsE,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAAmE,qBAAA,GAACxI,KAAK,CAAC0H,QAAQ,EAAE,CAACe,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC3E,EAAE,KAAKjE,IAAI,CAACa,MAAM,CAACoD,EAAE,CAAC,cAAAwE,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACExE,aAAa,GAAG4D,eAAe,CAACa,OAAO;;EAG3C,OAAOzE,aAAa;AACxB;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js
CHANGED
@@ -105,6 +105,7 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
105
105
|
};
|
106
106
|
const handleFocus = event => {
|
107
107
|
var _event$target;
|
108
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
108
109
|
const {
|
109
110
|
frozenColumnIndex: externalFrozenColumnIndex = -1,
|
110
111
|
frozenInternalColumnCount = 0
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditingControl.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Cell as RTCell, Column as RTColumn, Table as RTTable, TableMeta } from '@tanstack/react-table';\nimport _ from 'lodash';\n\nimport { deselectInputValue } from '../../../../../utils/input';\nimport { hasChanged } from '../../../util/editing';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { getCellAlignmentClasses, getInputAppearanceClassnames } from '../styles';\nimport { mergeRefs } from '../../../../../utils/mergeRefs';\nimport { Table3ColumnAlignment, Table3ColumnDataType } from '../../../types';\nimport { TextareaControl } from './controls/TextareaControl';\nimport { shouldTriggerShortcut } from '../../../../../utils/keyboard';\nimport { getTableLeftScrollDistance } from '../../../util/scrolling';\n\nexport type EditingControlProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n column: RTColumn<TType, unknown>;\n data: TType;\n initialValue: any;\n value: any;\n onBlur: (event: React.FocusEvent) => void;\n onFocus: (event: React.FocusEvent) => void;\n onChange: (value: any) => void;\n ref: React.Ref<HTMLElement>;\n table: RTTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n cell: RTCell<TType, unknown>;\n error?: string;\n tabIndex?: number;\n isActiveRow?: boolean;\n};\n\nexport const EditingControl = React.forwardRef<HTMLElement, any>(function Control<TType = unknown>(\n props: EditingControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n align,\n column,\n data,\n initialValue,\n onChange: handleChange,\n table,\n tableRef,\n value,\n cell,\n error,\n isActiveRow,\n ...attributes\n } = props;\n\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const ref = React.useRef<HTMLElement>();\n const refCallback = mergeRefs([ref, externalRef]);\n\n const columnMeta = column.columnDef.meta;\n const controlRenderer = columnMeta?.control;\n\n const isCellInDetailMode =\n tableMeta.editing.detailModeEditing && (ref as React.RefObject<HTMLElement>)?.current?.contains(document.activeElement);\n\n const originalRow = cell.row.original as TType;\n\n // Revert to initial value if escape was pressed\n const handleKeyDown = (event: React.KeyboardEvent) => {\n // For some reason keydown event handler is not propogated to the table when input or other control element is\n // in focus so we need to check for shortcut that toggles the editing.\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n tableMeta.editing.toggleEditing(false);\n return;\n }\n\n const target = event.target as HTMLInputElement;\n\n if (target.readOnly) {\n return;\n }\n\n // Prevent row arrow shortcuts triggering when in detail mode\n if (tableMeta.editing.detailModeEditing && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {\n event.stopPropagation();\n }\n\n // Revert to initial value if escape was pressed\n if (event.key === 'Escape') {\n event.preventDefault();\n\n if (tableMeta.editing.detailModeEditing) {\n tableMeta.editing.setDetailModeEditing(false);\n\n if (value !== initialValue) {\n // Before reseting to initial value, we need to check if edited row with cell initial value is the same as original row,\n // and in this case we need to completely remove row from editing state to avoid saving the same data as original.\n const changedRow: any = tableMeta.editing.changes ? tableMeta.editing.changes[cell.row.id] : {};\n const rowEdtitingDataWithInitialValue = { ...changedRow, [cell.column.id]: initialValue };\n if (_.isEqual(cell.row.original, rowEdtitingDataWithInitialValue)) {\n tableMeta.editing.resetChange(cell.row.id);\n } else {\n handleChange(initialValue);\n }\n }\n } else {\n tableMeta.editing.toggleEditing(false);\n tableRef.current?.focus();\n }\n\n return;\n }\n\n // Should enable/disable editing mode if Enter was clicked\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (!tableMeta.editing.detailModeEditing) {\n deselectInputValue(target);\n } else {\n target?.select?.();\n }\n\n // Ketydown \"Enter\" should toggle edititng mode\n tableMeta.editing.setDetailModeEditing(!tableMeta.editing.detailModeEditing);\n\n return;\n }\n };\n\n const isNumber = columnMeta?.dataType === ('number' as Table3ColumnDataType);\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleKeyDown(event);\n\n // Switching to editing mode, when key pressed any alphabetical character or number\n if (/^[a-z0-9]$/i.test(event.key)) {\n tableMeta.editing.setDetailModeEditing(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n const { frozenColumnIndex: externalFrozenColumnIndex = -1, frozenInternalColumnCount = 0 } = tableMeta.columnFreezing;\n const tableElement = tableMeta.tableRef.current;\n const frozenColumnIndex =\n externalFrozenColumnIndex > -1\n ? externalFrozenColumnIndex + frozenInternalColumnCount\n : frozenInternalColumnCount - 1;\n const cell = event.target?.closest('[role=\"cell\"]');\n\n if (!tableElement || !cell) {\n return;\n }\n\n const isEditing = true;\n const leftScrollDistance = getTableLeftScrollDistance(tableElement, cell, frozenColumnIndex, isEditing);\n\n if (leftScrollDistance !== null) {\n tableElement.scrollLeft = leftScrollDistance;\n }\n };\n\n if (typeof controlRenderer === 'function') {\n return controlRenderer(\n {\n ...attributes,\n invalid: !!error,\n onFocus: handleFocus,\n ref: refCallback,\n setValue: nextValue => {\n if (nextValue !== value) {\n handleChange(nextValue);\n }\n },\n fontSize: tableMeta.fontSize.size,\n value,\n },\n data\n );\n } else if (controlRenderer === 'datepicker') {\n const handleDatepickerChange = event => {\n // When datepicker looses focus, it triggers change event, even if date wasn't changed,\n // so adding additional check here to prevent adding change to the edititng state.\n const originalDate = originalRow[cell.column.id];\n const changedDate = (event as any).detail;\n if (hasChanged(originalDate, changedDate)) {\n handleChange(changedDate);\n }\n };\n\n return (\n <Datepicker\n {...attributes}\n invalid={!!error}\n className={cn({\n '[&_input]:!yt-focus-dark': isCellInDetailMode,\n })}\n onChange={handleDatepickerChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n value={value as Date}\n />\n );\n } else if (controlRenderer === 'switch') {\n return (\n <Switch {...attributes} checked={Boolean(value)} onChange={handleChange} onFocus={handleFocus} ref={refCallback} />\n );\n } else if (controlRenderer === 'textarea') {\n return (\n <TextareaControl\n {...props}\n invalid={!!error}\n isCellInDetailMode={isCellInDetailMode}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n fontSize={tableMeta.fontSize.size}\n />\n );\n }\n\n return (\n <Input\n {...attributes}\n invalid={!!error}\n className={cn(getInputAppearanceClassnames(), getCellAlignmentClasses(align), {\n '!yt-focus-dark': isCellInDetailMode,\n })}\n onChange={event => {\n handleChange(event.target.value);\n }}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n type={isNumber ? 'number' : undefined}\n value={isNumber ? value : String(value ?? '')}\n />\n );\n});\n"],"names":["EditingControl","React","forwardRef","Control","props","externalRef","align","column","data","initialValue","onChange","handleChange","table","tableRef","value","cell","error","isActiveRow","attributes","tableMeta","options","meta","ref","useRef","refCallback","mergeRefs","columnMeta","columnDef","controlRenderer","control","isCellInDetailMode","editing","detailModeEditing","_ref$current","current","contains","document","activeElement","originalRow","row","original","handleKeyDown","event","shouldTriggerShortcut","key","shift","toggleEditing","target","readOnly","stopPropagation","preventDefault","setDetailModeEditing","changedRow","changes","id","rowEdtitingDataWithInitialValue","_","isEqual","resetChange","_tableRef$current","focus","deselectInputValue","_target$select","select","call","isNumber","dataType","handleInputKeyDown","test","handleFocus","frozenColumnIndex","externalFrozenColumnIndex","frozenInternalColumnCount","columnFreezing","tableElement","_event$target","closest","isEditing","leftScrollDistance","getTableLeftScrollDistance","scrollLeft","invalid","onFocus","setValue","nextValue","fontSize","size","handleDatepickerChange","originalDate","changedDate","detail","hasChanged","Datepicker","className","cn","onKeyDown","Switch","checked","Boolean","TextareaControl","Input","getInputAppearanceClassnames","getCellAlignmentClasses","type","undefined","String"],"mappings":";;;;;;;;;;;;;;MAmCaA,cAAc,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASC,OAAOA,CAC7EC,KAAiC,EACjCC,WAAmC;;EAEnC,MAAM;IACFC,KAAK;IACLC,MAAM;IACNC,IAAI;IACJC,YAAY;IACZC,QAAQ,EAAEC,YAAY;IACtBC,KAAK;IACLC,QAAQ;IACRC,KAAK;IACLC,IAAI;IACJC,KAAK;IACLC,WAAW;IACX,GAAGC;GACN,GAAGd,KAAK;EA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AAE5B,kBAAkB;MAC7B7C,GAAG,EAAEE,WAAW;MAChB6D,QAAQ,EAAElE,SAAS,CAACkE,QAAQ,CAACC;OAC/B;;EAIV,oBACIrF,6BAACmG,KAAK,oBACElF,UAAU;IACd+D,OAAO,EAAE,CAAC,CAACjE,KAAK;IAChB6E,SAAS,EAAEC,EAAE,CAACO,4BAA4B,EAAE,EAAEC,uBAAuB,CAAChG,KAAK,CAAC,EAAE;MAC1E,gBAAgB,EAAEwB;KACrB,CAAC;IACFpB,QAAQ,EAAEgC,KAAK;MACX/B,YAAY,CAAC+B,KAAK,CAACK,MAAM,CAACjC,KAAK,CAAC;KACnC;IACDoE,OAAO,EAAEb,WAAW;IACpB0B,SAAS,EAAE5B,kBAAkB;IAC7B7C,GAAG,EAAEE,WAAW;IAChB+E,IAAI,EAAEtC,QAAQ,GAAG,QAAQ,GAAGuC,SAAS;IACrC1F,KAAK,EAAEmD,QAAQ,GAAGnD,KAAK,GAAG2F,MAAM,CAAC3F,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC9C;AAEV,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"EditingControl.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Cell as RTCell, Column as RTColumn, Table as RTTable, TableMeta } from '@tanstack/react-table';\nimport _ from 'lodash';\n\nimport { deselectInputValue } from '../../../../../utils/input';\nimport { hasChanged } from '../../../util/editing';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { getCellAlignmentClasses, getInputAppearanceClassnames } from '../styles';\nimport { mergeRefs } from '../../../../../utils/mergeRefs';\nimport { Table3ColumnAlignment, Table3ColumnDataType } from '../../../types';\nimport { TextareaControl } from './controls/TextareaControl';\nimport { shouldTriggerShortcut } from '../../../../../utils/keyboard';\nimport { getTableLeftScrollDistance } from '../../../util/scrolling';\n\nexport type EditingControlProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n column: RTColumn<TType, unknown>;\n data: TType;\n initialValue: any;\n value: any;\n onBlur: (event: React.FocusEvent) => void;\n onFocus: (event: React.FocusEvent) => void;\n onChange: (value: any) => void;\n ref: React.Ref<HTMLElement>;\n table: RTTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n cell: RTCell<TType, unknown>;\n error?: string;\n tabIndex?: number;\n isActiveRow?: boolean;\n};\n\nexport const EditingControl = React.forwardRef<HTMLElement, any>(function Control<TType = unknown>(\n props: EditingControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n align,\n column,\n data,\n initialValue,\n onChange: handleChange,\n table,\n tableRef,\n value,\n cell,\n error,\n isActiveRow,\n ...attributes\n } = props;\n\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const ref = React.useRef<HTMLElement>();\n const refCallback = mergeRefs([ref, externalRef]);\n\n const columnMeta = column.columnDef.meta;\n const controlRenderer = columnMeta?.control;\n\n const isCellInDetailMode =\n tableMeta.editing.detailModeEditing && (ref as React.RefObject<HTMLElement>)?.current?.contains(document.activeElement);\n\n const originalRow = cell.row.original as TType;\n\n // Revert to initial value if escape was pressed\n const handleKeyDown = (event: React.KeyboardEvent) => {\n // For some reason keydown event handler is not propogated to the table when input or other control element is\n // in focus so we need to check for shortcut that toggles the editing.\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n tableMeta.editing.toggleEditing(false);\n return;\n }\n\n const target = event.target as HTMLInputElement;\n\n if (target.readOnly) {\n return;\n }\n\n // Prevent row arrow shortcuts triggering when in detail mode\n if (tableMeta.editing.detailModeEditing && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {\n event.stopPropagation();\n }\n\n // Revert to initial value if escape was pressed\n if (event.key === 'Escape') {\n event.preventDefault();\n\n if (tableMeta.editing.detailModeEditing) {\n tableMeta.editing.setDetailModeEditing(false);\n\n if (value !== initialValue) {\n // Before reseting to initial value, we need to check if edited row with cell initial value is the same as original row,\n // and in this case we need to completely remove row from editing state to avoid saving the same data as original.\n const changedRow: any = tableMeta.editing.changes ? tableMeta.editing.changes[cell.row.id] : {};\n const rowEdtitingDataWithInitialValue = { ...changedRow, [cell.column.id]: initialValue };\n if (_.isEqual(cell.row.original, rowEdtitingDataWithInitialValue)) {\n tableMeta.editing.resetChange(cell.row.id);\n } else {\n handleChange(initialValue);\n }\n }\n } else {\n tableMeta.editing.toggleEditing(false);\n tableRef.current?.focus();\n }\n\n return;\n }\n\n // Should enable/disable editing mode if Enter was clicked\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (!tableMeta.editing.detailModeEditing) {\n deselectInputValue(target);\n } else {\n target?.select?.();\n }\n\n // Ketydown \"Enter\" should toggle edititng mode\n tableMeta.editing.setDetailModeEditing(!tableMeta.editing.detailModeEditing);\n\n return;\n }\n };\n\n const isNumber = columnMeta?.dataType === ('number' as Table3ColumnDataType);\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleKeyDown(event);\n\n // Switching to editing mode, when key pressed any alphabetical character or number\n if (/^[a-z0-9]$/i.test(event.key)) {\n tableMeta.editing.setDetailModeEditing(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const { frozenColumnIndex: externalFrozenColumnIndex = -1, frozenInternalColumnCount = 0 } = tableMeta.columnFreezing;\n const tableElement = tableMeta.tableRef.current;\n const frozenColumnIndex =\n externalFrozenColumnIndex > -1\n ? externalFrozenColumnIndex + frozenInternalColumnCount\n : frozenInternalColumnCount - 1;\n const cell = event.target?.closest('[role=\"cell\"]');\n\n if (!tableElement || !cell) {\n return;\n }\n\n const isEditing = true;\n const leftScrollDistance = getTableLeftScrollDistance(tableElement, cell, frozenColumnIndex, isEditing);\n\n if (leftScrollDistance !== null) {\n tableElement.scrollLeft = leftScrollDistance;\n }\n };\n\n if (typeof controlRenderer === 'function') {\n return controlRenderer(\n {\n ...attributes,\n invalid: !!error,\n onFocus: handleFocus,\n ref: refCallback,\n setValue: nextValue => {\n if (nextValue !== value) {\n handleChange(nextValue);\n }\n },\n fontSize: tableMeta.fontSize.size,\n value,\n },\n data\n );\n } else if (controlRenderer === 'datepicker') {\n const handleDatepickerChange = event => {\n // When datepicker looses focus, it triggers change event, even if date wasn't changed,\n // so adding additional check here to prevent adding change to the edititng state.\n const originalDate = originalRow[cell.column.id];\n const changedDate = (event as any).detail;\n if (hasChanged(originalDate, changedDate)) {\n handleChange(changedDate);\n }\n };\n\n return (\n <Datepicker\n {...attributes}\n invalid={!!error}\n className={cn({\n '[&_input]:!yt-focus-dark': isCellInDetailMode,\n })}\n onChange={handleDatepickerChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n value={value as Date}\n />\n );\n } else if (controlRenderer === 'switch') {\n return (\n <Switch {...attributes} checked={Boolean(value)} onChange={handleChange} onFocus={handleFocus} ref={refCallback} />\n );\n } else if (controlRenderer === 'textarea') {\n return (\n <TextareaControl\n {...props}\n invalid={!!error}\n isCellInDetailMode={isCellInDetailMode}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n fontSize={tableMeta.fontSize.size}\n />\n );\n }\n\n return (\n <Input\n {...attributes}\n invalid={!!error}\n className={cn(getInputAppearanceClassnames(), getCellAlignmentClasses(align), {\n '!yt-focus-dark': isCellInDetailMode,\n })}\n onChange={event => {\n handleChange(event.target.value);\n }}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={refCallback}\n type={isNumber ? 'number' : undefined}\n value={isNumber ? value : String(value ?? '')}\n />\n );\n});\n"],"names":["EditingControl","React","forwardRef","Control","props","externalRef","align","column","data","initialValue","onChange","handleChange","table","tableRef","value","cell","error","isActiveRow","attributes","tableMeta","options","meta","ref","useRef","refCallback","mergeRefs","columnMeta","columnDef","controlRenderer","control","isCellInDetailMode","editing","detailModeEditing","_ref$current","current","contains","document","activeElement","originalRow","row","original","handleKeyDown","event","shouldTriggerShortcut","key","shift","toggleEditing","target","readOnly","stopPropagation","preventDefault","setDetailModeEditing","changedRow","changes","id","rowEdtitingDataWithInitialValue","_","isEqual","resetChange","_tableRef$current","focus","deselectInputValue","_target$select","select","call","isNumber","dataType","handleInputKeyDown","test","handleFocus","frozenColumnIndex","externalFrozenColumnIndex","frozenInternalColumnCount","columnFreezing","tableElement","_event$target","closest","isEditing","leftScrollDistance","getTableLeftScrollDistance","scrollLeft","invalid","onFocus","setValue","nextValue","fontSize","size","handleDatepickerChange","originalDate","changedDate","detail","hasChanged","Datepicker","className","cn","onKeyDown","Switch","checked","Boolean","TextareaControl","Input","getInputAppearanceClassnames","getCellAlignmentClasses","type","undefined","String"],"mappings":";;;;;;;;;;;;;;MAmCaA,cAAc,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASC,OAAOA,CAC7EC,KAAiC,EACjCC,WAAmC;;EAEnC,MAAM;IACFC,KAAK;IACLC,MAAM;IACNC,IAAI;IACJC,YAAY;IACZC,QAAQ,EAAEC,YAAY;IACtBC,KAAK;IACLC,QAAQ;IACRC,KAAK;IACLC,IAAI;IACJC,KAAK;IACLC,WAAW;IACX,GAAGC;GACN,GAAGd,KAAK;EAET,MAAMe,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACC,IAA0B;EAC1D,MAAMC,GAAG,GAAGrB,cAAK,CAACsB,MAAM,EAAe;EACvC,MAAMC,WAAW,GAAGC,SAAS,CAAC,CAACH,GAAG,EAAEjB,WAAW,CAAC,CAAC;EAEjD,MAAMqB,UAAU,GAAGnB,MAAM,CAACoB,SAAS,CAACN,IAAI;EACxC,MAAMO,eAAe,GAAGF,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEG,OAAO;EAE3C,MAAMC,kBAAkB,GACpBX,SAAS,CAACY,OAAO,CAACC,iBAAiB,KAAKV,GAAoC,aAApCA,GAAoC,wBAAAW,YA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WAAW;IACpB0B,SAAS,EAAE5B,kBAAkB;IAC7B7C,GAAG,EAAEE,WAAW;IAChB+E,IAAI,EAAEtC,QAAQ,GAAG,QAAQ,GAAGuC,SAAS;IACrC1F,KAAK,EAAEmD,QAAQ,GAAGnD,KAAK,GAAG2F,MAAM,CAAC3F,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC9C;AAEV,CAAC;;;;"}
|
@@ -32,6 +32,8 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
|
|
32
32
|
isActiveRow,
|
33
33
|
value,
|
34
34
|
fontSize,
|
35
|
+
tableRef: _1,
|
36
|
+
initialValue: _2,
|
35
37
|
...attributes
|
36
38
|
} = props;
|
37
39
|
const minMaxHeight = heights[fontSize];
|
@@ -126,7 +128,7 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
|
|
126
128
|
},
|
127
129
|
onBlur: handleBlur,
|
128
130
|
onFocus: handleFocus,
|
129
|
-
className: cn(getCellAlignmentClasses(align), `h-fit resize-none overflow-
|
131
|
+
className: cn(getCellAlignmentClasses(align), `h-fit resize-none overflow-hidden focus:overflow-auto [&:not(:focus)]:whitespace-nowrap`, {
|
130
132
|
[`!min-h-[${minMaxHeight.min}px]`]: columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate,
|
131
133
|
'!yt-focus-dark': isCellInDetailMode,
|
132
134
|
[`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextareaControl.js","sources":["../../../../../../../../../../../src/components/Table3/components/columns/cell/controls/TextareaControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Textarea } from '../../../../../Textarea/Textarea';\nimport { EditingControlProps } from '../EditingControl';\nimport { getCellAlignmentClasses } from '../../styles';\nimport { useMergedRef } from '../../../../../../hooks/useMergedRef';\nimport { FontSize } from '../../../../../../types';\n\ntype TextareaHeight = {\n min: number;\n max: number;\n};\n// By UX design, textarea should fold to min size when blured and extend to max 5 lines height when edited in enableTruncate mode,\n// for this reason we need to set min/max height limits for each font size value.\nconst heights: Record<FontSize, TextareaHeight> = {\n small: {\n min: 24,\n max: 86,\n },\n medium: {\n min: 32,\n max: 100,\n },\n large: {\n min: 40,\n max: 140,\n },\n};\n\ntype TextareaControlProps<TType = unknown> = EditingControlProps<TType> & {\n onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n fontSize: FontSize;\n invalid: boolean;\n isCellInDetailMode?: boolean;\n};\n\nexport const TextareaControl = React.forwardRef<HTMLElement, any>(function TextareaControl<TType = unknown>(\n props: TextareaControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n onBlur,\n onFocus,\n column,\n isCellInDetailMode,\n align,\n isActiveRow,\n value,\n fontSize,\n ...attributes\n } = props;\n\n const minMaxHeight = heights[fontSize];\n\n const columnMeta = column.columnDef.meta;\n\n const ref = useMergedRef<HTMLTextAreaElement>(externalRef);\n\n React.useEffect(() => {\n if (ref?.current) {\n // Need to reset textarea to min height when font size got changed and if column in enable truncate mode.\n if (columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n\n // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized or fonsSize got changed.\n } else {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n resizeTextArea(textareaElement);\n }\n }\n }, [fontSize]);\n\n React.useEffect(() => {\n // If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.\n // Otherwise it should collapse to minimal height.\n if (ref?.current && columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n\n if (isCellInDetailMode) {\n resizeTextArea(textareaElement);\n } else {\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n }\n }, [isCellInDetailMode]);\n\n const resizeTextArea = (textareaElement: HTMLTextAreaElement) => {\n // Need to set inherit before calculating height, so that browser sets the scrollHeight properly,\n // depending on text inside.\n const textareaRect = textareaElement.getBoundingClientRect();\n const prevHeight = textareaRect.height;\n if (columnMeta?.enableTruncate) {\n if (prevHeight < minMaxHeight.max) {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, minMaxHeight.max)}px`;\n }\n } else {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${textareaElement.scrollHeight}px`;\n }\n };\n\n const handleTextareaChange = e => {\n resizeTextArea(e.target);\n };\n\n const textareaContainerClassName = cn('w-full', {\n 'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-[9]': columnMeta?.enableTruncate,\n });\n const handleTextareaKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // By default Shift + Enter in textarea makes a new line, we want to keep this behaviour\n if (event.shiftKey && event.key === 'Enter') {\n return;\n } else {\n handleKeyDown(event);\n }\n };\n\n const handleBlur = event => {\n // If truncation is enabled, then textarea should shring back to min height, when loosing focus.\n if (columnMeta?.enableTruncate) {\n const textareaElement = event.currentTarget;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n onBlur(event);\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n const textareaElement = ref?.current;\n\n if (textareaElement) {\n resizeTextArea(textareaElement);\n }\n\n onFocus(event);\n };\n\n return (\n <div data-taco=\"input-container\">\n {/**\n * Textarea should have min height placeholder, because it becomes absolute positioned when focused,\n * which leads to overlapping of validation message rendered bellow.\n * Somehow tailwind cannot dynamically assign min height when arbitary value has been used(in this particular case),\n * so assigning it through style prop here\n **/}\n <div style={{ minHeight: `${minMaxHeight.min}px` }} className=\"relative\">\n <div className={textareaContainerClassName}>\n <Textarea\n {...attributes}\n onChange={event => {\n handleChange(event.target.value);\n handleTextareaChange(event);\n }}\n rows={1}\n onKeyDown={e => {\n handleTextareaKeyDown(e);\n }}\n onBlur={handleBlur}\n onFocus={handleFocus}\n className={cn(\n getCellAlignmentClasses(align),\n `h-fit resize-none overflow-y-hidden focus:overflow-y-auto [&:not(:focus)]:whitespace-nowrap`,\n {\n [`!min-h-[${minMaxHeight.min}px]`]: columnMeta?.enableTruncate,\n '!yt-focus-dark': isCellInDetailMode,\n [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && columnMeta?.enableTruncate,\n // Only allow resizing when focused and truncation enabled\n 'focus:resize-y': isActiveRow && columnMeta?.enableTruncate,\n }\n )}\n ref={ref}\n value={String(value ?? '')}\n />\n </div>\n </div>\n </div>\n );\n});\n"],"names":["heights","small","min","max","medium","large","TextareaControl","React","forwardRef","props","externalRef","onKeyDown","handleKeyDown","onChange","handleChange","onBlur","onFocus","column","isCellInDetailMode","align","isActiveRow","value","fontSize","attributes","minMaxHeight","columnMeta","columnDef","meta","ref","useMergedRef","useEffect","current","enableTruncate","textareaElement","style","height","resizeTextArea","textareaRect","getBoundingClientRect","prevHeight","Math","scrollHeight","handleTextareaChange","e","target","textareaContainerClassName","cn","handleTextareaKeyDown","event","shiftKey","key","handleBlur","currentTarget","handleFocus","minHeight","className","Textarea","rows","getCellAlignmentClasses","String"],"mappings":";;;;;;AAYA;AACA;AACA,MAAMA,OAAO,GAAqC;EAC9CC,KAAK,EAAE;IACHC,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJF,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDE,KAAK,EAAE;IACHH,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;;CAEZ;MASYG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASF,eAAeA,CACtFG,KAAkC,EAClCC,WAAmC;EAEnC,MAAM;IACFC,SAAS,EAAEC,aAAa;IACxBC,QAAQ,EAAEC,YAAY;IACtBC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,kBAAkB;IAClBC,KAAK;I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H,eAAe,CAAC;;IAGnCjB,OAAO,CAACgC,KAAK,CAAC;GACjB;EAED,oBACIzC;iBAAe;kBAOXA;IAAK2B,KAAK,EAAE;MAAEoB,SAAS,KAAK9B,YAAY,CAACtB;KAAS;IAAEqD,SAAS,EAAC;kBAC1DhD;IAAKgD,SAAS,EAAEV;kBACZtC,6BAACiD,QAAQ,oBACDjC,UAAU;IACdV,QAAQ,EAAEmC,KAAK;MACXlC,YAAY,CAACkC,KAAK,CAACJ,MAAM,CAACvB,KAAK,CAAC;MAChCqB,oBAAoB,CAACM,KAAK,CAAC;KAC9B;IACDS,IAAI,EAAE,CAAC;IACP9C,SAAS,EAAEgC,CAAC;MACRI,qBAAqB,CAACJ,CAAC,CAAC;KAC3B;IACD5B,MAAM,EAAEoC,UAAU;IAClBnC,OAAO,EAAEqC,WAAW;IACpBE,SAAS,EAAET,EAAE,CACTY,uBAAuB,CAACvC,KAAK,CAAC,+FAC+D,EAC7F;MACI,YAAYK,YAAY,CAACtB,QAAQ,GAAGuB,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;MAC9D,gBAAgB,EAAEd,kBAAkB;MACpC,OAAOM,YAAY,CAACtB,QAAQ,GAAG,CAACgB,kBAAkB,KAAIO,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;;MAEhF,gBAAgB,EAAEZ,WAAW,KAAIK,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;KAC9D,CACJ;IACDJ,GAAG,EAAEA,GAAG;IACRP,KAAK,EAAEsC,MAAM,CAACtC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC3B,CACA,CACJ,CACJ;AAEd,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"TextareaControl.js","sources":["../../../../../../../../../../../src/components/Table3/components/columns/cell/controls/TextareaControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Textarea } from '../../../../../Textarea/Textarea';\nimport { EditingControlProps } from '../EditingControl';\nimport { getCellAlignmentClasses } from '../../styles';\nimport { useMergedRef } from '../../../../../../hooks/useMergedRef';\nimport { FontSize } from '../../../../../../types';\n\ntype TextareaHeight = {\n min: number;\n max: number;\n};\n// By UX design, textarea should fold to min size when blured and extend to max 5 lines height when edited in enableTruncate mode,\n// for this reason we need to set min/max height limits for each font size value.\nconst heights: Record<FontSize, TextareaHeight> = {\n small: {\n min: 24,\n max: 86,\n },\n medium: {\n min: 32,\n max: 100,\n },\n large: {\n min: 40,\n max: 140,\n },\n};\n\ntype TextareaControlProps<TType = unknown> = EditingControlProps<TType> & {\n onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n fontSize: FontSize;\n invalid: boolean;\n isCellInDetailMode?: boolean;\n};\n\nexport const TextareaControl = React.forwardRef<HTMLElement, any>(function TextareaControl<TType = unknown>(\n props: TextareaControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n onBlur,\n onFocus,\n column,\n isCellInDetailMode,\n align,\n isActiveRow,\n value,\n fontSize,\n tableRef: _1,\n initialValue: _2,\n ...attributes\n } = props;\n\n const minMaxHeight = heights[fontSize];\n\n const columnMeta = column.columnDef.meta;\n\n const ref = useMergedRef<HTMLTextAreaElement>(externalRef);\n\n React.useEffect(() => {\n if (ref?.current) {\n // Need to reset textarea to min height when font size got changed and if column in enable truncate mode.\n if (columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n\n // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized or fonsSize got changed.\n } else {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n resizeTextArea(textareaElement);\n }\n }\n }, [fontSize]);\n\n React.useEffect(() => {\n // If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.\n // Otherwise it should collapse to minimal height.\n if (ref?.current && columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n\n if (isCellInDetailMode) {\n resizeTextArea(textareaElement);\n } else {\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n }\n }, [isCellInDetailMode]);\n\n const resizeTextArea = (textareaElement: HTMLTextAreaElement) => {\n // Need to set inherit before calculating height, so that browser sets the scrollHeight properly,\n // depending on text inside.\n const textareaRect = textareaElement.getBoundingClientRect();\n const prevHeight = textareaRect.height;\n if (columnMeta?.enableTruncate) {\n if (prevHeight < minMaxHeight.max) {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, minMaxHeight.max)}px`;\n }\n } else {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${textareaElement.scrollHeight}px`;\n }\n };\n\n const handleTextareaChange = e => {\n resizeTextArea(e.target);\n };\n\n const textareaContainerClassName = cn('w-full', {\n 'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-[9]': columnMeta?.enableTruncate,\n });\n const handleTextareaKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // By default Shift + Enter in textarea makes a new line, we want to keep this behaviour\n if (event.shiftKey && event.key === 'Enter') {\n return;\n } else {\n handleKeyDown(event);\n }\n };\n\n const handleBlur = event => {\n // If truncation is enabled, then textarea should shring back to min height, when loosing focus.\n if (columnMeta?.enableTruncate) {\n const textareaElement = event.currentTarget;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n onBlur(event);\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n const textareaElement = ref?.current;\n\n if (textareaElement) {\n resizeTextArea(textareaElement);\n }\n\n onFocus(event);\n };\n\n return (\n <div data-taco=\"input-container\">\n {/**\n * Textarea should have min height placeholder, because it becomes absolute positioned when focused,\n * which leads to overlapping of validation message rendered bellow.\n * Somehow tailwind cannot dynamically assign min height when arbitary value has been used(in this particular case),\n * so assigning it through style prop here\n **/}\n <div style={{ minHeight: `${minMaxHeight.min}px` }} className=\"relative\">\n <div className={textareaContainerClassName}>\n <Textarea\n {...attributes}\n onChange={event => {\n handleChange(event.target.value);\n handleTextareaChange(event);\n }}\n rows={1}\n onKeyDown={e => {\n handleTextareaKeyDown(e);\n }}\n onBlur={handleBlur}\n onFocus={handleFocus}\n className={cn(\n getCellAlignmentClasses(align),\n `h-fit resize-none overflow-hidden focus:overflow-auto [&:not(:focus)]:whitespace-nowrap`,\n {\n [`!min-h-[${minMaxHeight.min}px]`]: columnMeta?.enableTruncate,\n '!yt-focus-dark': isCellInDetailMode,\n [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && columnMeta?.enableTruncate,\n // Only allow resizing when focused and truncation enabled\n 'focus:resize-y': isActiveRow && columnMeta?.enableTruncate,\n }\n )}\n ref={ref}\n value={String(value ?? '')}\n />\n </div>\n </div>\n </div>\n );\n});\n"],"names":["heights","small","min","max","medium","large","TextareaControl","React","forwardRef","props","externalRef","onKeyDown","handleKeyDown","onChange","handleChange","onBlur","onFocus","column","isCellInDetailMode","align","isActiveRow","value","fontSize","tableRef","_1","initialValue","_2","attributes","minMaxHeight","columnMeta","columnDef","meta","ref","useMergedRef","useEffect","current","enableTruncate","textareaElement","style","height","resizeTextArea","textareaRect","getBoundingClientRect","prevHeight","Math","scrollHeight","handleTextareaChange","e","target","textareaContainerClassName","cn","handleTextareaKeyDown","event","shiftKey","key","handleBlur","currentTarget","handleFocus","minHeight","className","Textarea","rows","getCellAlignmentClasses","String"],"mappings":";;;;;;AAYA;AACA;AACA,MAAMA,OAAO,GAAqC;EAC9CC,KAAK,EAAE;IACHC,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJF,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDE,KAAK,EAAE;IACHH,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;;CAEZ;MASYG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASF,eAAeA,CACtFG,KAAkC,EAClCC,WAAmC;EAEnC,MA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,CACJ;AAEd,CAAC;;;;"}
|
@@ -22,6 +22,7 @@ function Summary(props) {
|
|
22
22
|
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)));
|
23
23
|
} else if ((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length ||
|
24
24
|
// filtered data
|
25
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
25
26
|
!!table.getState().globalFilter && tableMeta.search.excludeUnmatchedResults // search with hide enabled
|
26
27
|
) {
|
27
28
|
label = texts.table3.footer.summary.records;
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Summary.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/footer/Summary.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\n\nexport type FooterSummaryProps<TType = unknown> = {\n currentLength: number;\n length: number;\n table: RTable<TType>;\n};\n\nexport function Summary<TType = unknown>(props: FooterSummaryProps<TType>) {\n const { currentLength, length, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { locale, texts } = useLocalization();\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 && tableMeta.search.excludeUnmatchedResults) // 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=\"sticky bottom-0 left-0 z-40 -mt-10 flex h-10 w-fit items-center whitespace-nowrap bg-white px-4 !pr-3 shadow-[6px_0px_6px_theme(colors.white)]\"\n data-taco=\"table2-footer-summary\">\n {label} {count}\n </div>\n );\n}\n"],"names":["Summary","props","currentLength","length","table","tableMeta","options","meta","locale","texts","useLocalization","label","count","rowsSelectedLength","getIsAllRowsSelected","getSelectedRowModel","rows","table3","footer","summary","selected","React","Intl","NumberFormat","format","_table$getState$colum","getState","columnFilters","globalFilter","search","excludeUnmatchedResults","records","className"],"mappings":";;;SAUgBA,OAAOA,CAAkBC,KAAgC;;EACrE,MAAM;IAAEC,aAAa;IAAEC,MAAM;IAAEC;GAAO,GAAGH,KAAK;EAC9C,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAwB;EACxD,MAAM;IAAEC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAE3C,IAAIC,KAAK;EACT,IAAIC,KAAK;;EAGT,MAAMC,kBAAkB,GAAGT,KAAK,CAACU,oBAAoB,EAAE,GAAGX,MAAM,GAAGC,KAAK,CAACW,mBAAmB,EAAE,CAACC,IAAI,CAACb,MAAM;EAE1G,IAAIU,kBAAkB,GAAG,CAAC,EAAE;IACxBF,KAAK,GAAGF,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACC,QAAQ;IAC5CR,KAAK,gBACDS,yEACIA,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACX,kBAAkB,CAAC,CAAU,YAC1EJ,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACP,KAAK,yBAClCS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACrB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM,IACH,CAAAsB,qBAAA,GAAArB,KAAK,CAACsB,QAAQ,EAAE,CAACC,aAAa,cAAAF,qBAAA,eAA9BA,qBAAA,CAAgCtB,MAAM
|
1
|
+
{"version":3,"file":"Summary.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/footer/Summary.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\n\nexport type FooterSummaryProps<TType = unknown> = {\n currentLength: number;\n length: number;\n table: RTable<TType>;\n};\n\nexport function Summary<TType = unknown>(props: FooterSummaryProps<TType>) {\n const { currentLength, length, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { locale, texts } = useLocalization();\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 // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n (!!table.getState().globalFilter && tableMeta.search.excludeUnmatchedResults) // 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=\"sticky bottom-0 left-0 z-40 -mt-10 flex h-10 w-fit items-center whitespace-nowrap bg-white px-4 !pr-3 shadow-[6px_0px_6px_theme(colors.white)]\"\n data-taco=\"table2-footer-summary\">\n {label} {count}\n </div>\n );\n}\n"],"names":["Summary","props","currentLength","length","table","tableMeta","options","meta","locale","texts","useLocalization","label","count","rowsSelectedLength","getIsAllRowsSelected","getSelectedRowModel","rows","table3","footer","summary","selected","React","Intl","NumberFormat","format","_table$getState$colum","getState","columnFilters","globalFilter","search","excludeUnmatchedResults","records","className"],"mappings":";;;SAUgBA,OAAOA,CAAkBC,KAAgC;;EACrE,MAAM;IAAEC,aAAa;IAAEC,MAAM;IAAEC;GAAO,GAAGH,KAAK;EAC9C,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAwB;EACxD,MAAM;IAAEC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAE3C,IAAIC,KAAK;EACT,IAAIC,KAAK;;EAGT,MAAMC,kBAAkB,GAAGT,KAAK,CAACU,oBAAoB,EAAE,GAAGX,MAAM,GAAGC,KAAK,CAACW,mBAAmB,EAAE,CAACC,IAAI,CAACb,MAAM;EAE1G,IAAIU,kBAAkB,GAAG,CAAC,EAAE;IACxBF,KAAK,GAAGF,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACC,QAAQ;IAC5CR,KAAK,gBACDS,yEACIA,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACX,kBAAkB,CAAC,CAAU,YAC1EJ,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACP,KAAK,yBAClCS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACrB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM,IACH,CAAAsB,qBAAA,GAAArB,KAAK,CAACsB,QAAQ,EAAE,CAACC,aAAa,cAAAF,qBAAA,eAA9BA,qBAAA,CAAgCtB,MAAM;;;EAErC,CAAC,CAACC,KAAK,CAACsB,QAAQ,EAAE,CAACE,YAAY,IAAIvB,SAAS,CAACwB,MAAM,CAACC,uBAAwB;IAC/E;IACEnB,KAAK,GAAGF,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACY,OAAO;IAC3CnB,KAAK,gBACDS,yEACIA,6CAASnB,aAAa,CAAU,YAC/BO,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACP,KAAK,yBAClCS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACrB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM;IACHQ,KAAK,GAAGF,KAAK,CAACQ,MAAM,CAACC,MAAM,CAACC,OAAO,CAACY,OAAO;IAC3CnB,KAAK,gBAAGS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACf,MAAM,CAAC,CAACgB,MAAM,CAACrB,MAAM,CAAC,CAAU;;EAG3E,oBACIkB;IACIW,SAAS,EAAC,gJAAgJ;iBAChJ;KACTrB,KAAK,YAAQC,KAAK,CACjB;AAEd;;;;"}
|
@@ -48,6 +48,7 @@ function Menu(props) {
|
|
48
48
|
const ref = React__default.useRef(null);
|
49
49
|
const gotoShortcut = 'g';
|
50
50
|
React__default.useEffect(() => {
|
51
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
51
52
|
const {
|
52
53
|
frozenColumnIndex: externalFrozenColumnIndex = -1,
|
53
54
|
frozenInternalColumnCount = 0
|
@@ -72,6 +73,7 @@ function Menu(props) {
|
|
72
73
|
false);
|
73
74
|
document.addEventListener('keydown', handler);
|
74
75
|
return () => document.removeEventListener('keydown', handler);
|
76
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
75
77
|
}, [tableMeta.columnFreezing.frozenColumnIndex, handleGoto]);
|
76
78
|
const handleSortMenuRadioGroupChange = newSortDirection => {
|
77
79
|
setSortDirectionState(newSortDirection);
|
@@ -152,14 +154,18 @@ function Menu(props) {
|
|
152
154
|
}, texts.table3.columns.menu.gotoRow, "..."));
|
153
155
|
}
|
154
156
|
if (canFreeze) {
|
157
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
155
158
|
const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;
|
159
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
156
160
|
const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);
|
157
161
|
menuItems.push( /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
158
162
|
icon: "column-freeze",
|
159
163
|
onClick: handleClick
|
160
164
|
}, frozenIndex === 0 ? texts.table3.columns.menu.freezeFirstColumn : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(frozenIndex + 1))));
|
165
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
161
166
|
if (tableMeta.columnFreezing.frozenColumnIndex !== undefined) {
|
162
167
|
const handleClick = () => {
|
168
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
163
169
|
tableMeta.columnFreezing.setFrozenColumnIndex(undefined);
|
164
170
|
};
|
165
171
|
menuItems.push( /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
@@ -183,7 +189,9 @@ function Menu(props) {
|
|
183
189
|
return menuItems.map((item, key) => /*#__PURE__*/React__default.cloneElement(item, {
|
184
190
|
key
|
185
191
|
}));
|
186
|
-
}, [menu, index, canFreeze, canHide, canSort, handleGoto, handleSortToggle, sortDirection,
|
192
|
+
}, [menu, index, canFreeze, canHide, canSort, handleGoto, handleSortToggle, sortDirection,
|
193
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
194
|
+
tableMeta.columnFreezing.frozenColumnIndex]);
|
187
195
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
188
196
|
className: className,
|
189
197
|
icon: "more",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Menu.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Header as RTHeader, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../Menu/Menu';\nimport { isInternalColumn } from '../../../util/columns';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Table3ColumnHeaderMenu, TableStrategy } from '../../../types';\nimport { GotoPopover } from './Goto';\nimport { HeaderSortDirection, SORT_DIRECTION, SortToggleHandler } from './Header';\nimport { RadioGroupItemValue } from '../../../../RadioGroup/RadioGroup';\nimport { createShortcutKeyDownHandler } from '../../../../../utils/keyboard';\nimport { getTableLeftScrollDistance } from '../../../util/scrolling';\n\nexport function isGotoAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>) {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return !!(tableMeta.rowGoto.isEnabled && header.column.getCanSort() && header.column.getIsSorted());\n}\n\nexport function isMenuAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>): boolean {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return (\n !!header.column.columnDef.meta?.menu ||\n !!tableMeta.columnFreezing.isEnabled ||\n (!!table.options.enableHiding && !!header.column.getCanHide()) ||\n isGotoAvailable(table, header)\n );\n}\n\nexport type MenuProps<TType = unknown> = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFreeze: boolean;\n canHide: boolean;\n canSort: boolean;\n index: number;\n menu?: Table3ColumnHeaderMenu;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n table: RTable<TType>;\n};\n\nexport function Menu<TType = unknown>(props: MenuProps<TType>) {\n const {\n canFreeze,\n canHide,\n canSort,\n index,\n menu,\n onGoto: handleGoto,\n onHide: handleHide,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n const [sortDirectionState, setSortDirectionState] = React.useState<HeaderSortDirection>(sortDirection);\n const ref = React.useRef<HTMLButtonElement>(null);\n\n const gotoShortcut = 'g';\n\n React.useEffect(() => {\n const { frozenColumnIndex: externalFrozenColumnIndex = -1, frozenInternalColumnCount = 0 } = tableMeta.columnFreezing;\n\n const handler = createShortcutKeyDownHandler(\n gotoShortcut,\n () => {\n // Only execute the below code if the header menu has goto menu item\n if (handleGoto) {\n const tableElement = tableMeta.tableRef.current;\n const frozenColumnIndex =\n externalFrozenColumnIndex > -1\n ? externalFrozenColumnIndex + frozenInternalColumnCount\n : frozenInternalColumnCount - 1;\n const parentHeader = ref.current?.closest('[role=\"columnheader\"]');\n\n if (!tableElement || !parentHeader) {\n return;\n }\n\n const leftScrollDistance = getTableLeftScrollDistance(tableElement, parentHeader, frozenColumnIndex);\n\n if (leftScrollDistance !== null) {\n tableElement.scrollLeft = leftScrollDistance;\n }\n }\n },\n // Prevents the stopping of event propagation\n false\n );\n\n document.addEventListener('keydown', handler);\n\n return () => document.removeEventListener('keydown', handler);\n }, [tableMeta.columnFreezing.frozenColumnIndex, handleGoto]);\n\n const handleSortMenuRadioGroupChange = (newSortDirection: RadioGroupItemValue) => {\n setSortDirectionState(newSortDirection as HeaderSortDirection);\n handleSortToggle(newSortDirection as HeaderSortDirection);\n };\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 tableMeta.rowActive.setRowActiveIndex(index);\n scrollToIndex(index + 2, { align: 'center' });\n } catch {\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden',\n 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto',\n 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto',\n 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto',\n {\n '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement,\n },\n props.className\n );\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide) {\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 // We rely on canSort value instead of onSort function's value because some columns might have sorting disabled,\n // so even though onSort is truthy, we don't want to show sorting menu.\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortMenuRadioGroupChange} value={sortDirectionState}>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.ASC}>\n {texts.table3.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.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 (handleGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut={gotoShortcut}>\n {texts.table3.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canFreeze) {\n const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;\n const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={handleClick}>\n {frozenIndex === 0\n ? texts.table3.columns.menu.freezeFirstColumn\n : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(frozenIndex + 1))}\n </MenuPrimitive.Item>\n );\n\n if (tableMeta.columnFreezing.frozenColumnIndex !== undefined) {\n const handleClick = () => {\n tableMeta.columnFreezing.setFrozenColumnIndex(undefined);\n };\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={handleClick}>\n {texts.table3.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n }\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.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 }, [\n menu,\n index,\n canFreeze,\n canHide,\n canSort,\n handleGoto,\n handleSortToggle,\n sortDirection,\n tableMeta.columnFreezing.frozenColumnIndex,\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 ref={ref}\n />\n );\n}\n"],"names":["isGotoAvailable","table","header","isInternalColumn","id","tableMeta","options","meta","rowGoto","isEnabled","column","getCanSort","getIsSorted","isMenuAvailable","_header$column$column","columnDef","menu","columnFreezing","enableHiding","getCanHide","Menu","props","canFreeze","canHide","canSort","index","onGoto","handleGoto","onHide","handleHide","onSortToggle","handleSortToggle","scrollToIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","sortDirectionState","setSortDirectionState","ref","useRef","gotoShortcut","useEffect","frozenColumnIndex","externalFrozenColumnIndex","frozenInternalColumnCount","handler","createShortcutKeyDownHandler","_ref$current","tableElement","tableRef","current","parentHeader","closest","leftScrollDistance","getTableLeftScrollDistance","scrollLeft","document","addEventListener","removeEventListener","handleSortMenuRadioGroupChange","newSortDirection","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","rowActive","setRowActiveIndex","align","_wasThrown","_result","_temp","e","reject","GotoPopover","open","onChange","className","cn","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table3","columns","hideColumn","subMenu","SubMenu","RadioGroup","value","SORT_DIRECTION","ASC","sortingOrder","ascending","DESC","descending","unsorted","sorting","shortcut","gotoRow","frozenIndex","setFrozenColumnIndex","freezeFirstColumn","freezeUptoColumn","replace","String","unfreezeColumns","customMenu","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","IconButton","menuProps","Content","onClickCapture","preventDefault"],"mappings":";;;;;;;;;;;;SAcgBA,eAAeA,CAAkBC,KAAoB,EAAEC,MAAgC;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC7B,OAAO,KAAK;;EAGhB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EAExD,OAAO,CAAC,EAAEF,SAAS,CAACG,OAAO,CAACC,SAAS,IAAIP,MAAM,CAACQ,MAAM,CAACC,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AAI,eAACtD,6BAACuD,MAAa,CAACmC,SAAS,OAAG,CAAC;;QAG/CxC,SAAS,CAACI,IAAI,CAAC,GAAG+B,WAAW,CAAC;;;IAItC,OAAOnC,SAAS,CAACyC,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,kBAAK7F,cAAK,CAAC8F,YAAY,CAACF,IAAI,EAAE;MAAEC;KAAK,CAAC,CAAC;GACzE,EAAE,CACCnH,IAAI,EACJS,KAAK,EACLH,SAAS,EACTC,OAAO,EACPC,OAAO,EACPG,UAAU,EACVI,gBAAgB,EAChBE,aAAa,EACb5B,SAAS,CAACY,cAAc,CAAC8B,iBAAiB,CAC7C,CAAC;EAEF,oBACIT,6BAAC+F,UAAU;IACPjD,SAAS,EAAEA,SAAS;IACpBW,IAAI,EAAC,MAAM;IACX/E,IAAI,EACAkD,cAAc,GACR1B,SAAS,GACT8F,SAAS,mBACLhG,6BAACuD,MAAa,oBAAKyC,SAAS,gBACxBhG,6BAACuD,MAAa,CAAC0C,OAAO,QAAEjD,eAAe,CAAyB,CACpD,CACnB;IAEXlD,OAAO,EAAE8B,cAAc;IACvBsE,cAAc,EAAE9C,KAAK,IAAIA,KAAK,CAAC+C,cAAc,EAAE;IAC/C9F,GAAG,EAAEA;IACP;AAEV;;;;"}
|
1
|
+
{"version":3,"file":"Menu.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Header as RTHeader, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../Menu/Menu';\nimport { isInternalColumn } from '../../../util/columns';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Table3ColumnHeaderMenu, TableStrategy } from '../../../types';\nimport { GotoPopover } from './Goto';\nimport { HeaderSortDirection, SORT_DIRECTION, SortToggleHandler } from './Header';\nimport { RadioGroupItemValue } from '../../../../RadioGroup/RadioGroup';\nimport { createShortcutKeyDownHandler } from '../../../../../utils/keyboard';\nimport { getTableLeftScrollDistance } from '../../../util/scrolling';\n\nexport function isGotoAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>) {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return !!(tableMeta.rowGoto.isEnabled && header.column.getCanSort() && header.column.getIsSorted());\n}\n\nexport function isMenuAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>): boolean {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return (\n !!header.column.columnDef.meta?.menu ||\n !!tableMeta.columnFreezing.isEnabled ||\n (!!table.options.enableHiding && !!header.column.getCanHide()) ||\n isGotoAvailable(table, header)\n );\n}\n\nexport type MenuProps<TType = unknown> = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFreeze: boolean;\n canHide: boolean;\n canSort: boolean;\n index: number;\n menu?: Table3ColumnHeaderMenu;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n table: RTable<TType>;\n};\n\nexport function Menu<TType = unknown>(props: MenuProps<TType>) {\n const {\n canFreeze,\n canHide,\n canSort,\n index,\n menu,\n onGoto: handleGoto,\n onHide: handleHide,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n const [sortDirectionState, setSortDirectionState] = React.useState<HeaderSortDirection>(sortDirection);\n const ref = React.useRef<HTMLButtonElement>(null);\n\n const gotoShortcut = 'g';\n\n React.useEffect(() => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const { frozenColumnIndex: externalFrozenColumnIndex = -1, frozenInternalColumnCount = 0 } = tableMeta.columnFreezing;\n\n const handler = createShortcutKeyDownHandler(\n gotoShortcut,\n () => {\n // Only execute the below code if the header menu has goto menu item\n if (handleGoto) {\n const tableElement = tableMeta.tableRef.current;\n const frozenColumnIndex =\n externalFrozenColumnIndex > -1\n ? externalFrozenColumnIndex + frozenInternalColumnCount\n : frozenInternalColumnCount - 1;\n const parentHeader = ref.current?.closest('[role=\"columnheader\"]');\n\n if (!tableElement || !parentHeader) {\n return;\n }\n\n const leftScrollDistance = getTableLeftScrollDistance(tableElement, parentHeader, frozenColumnIndex);\n\n if (leftScrollDistance !== null) {\n tableElement.scrollLeft = leftScrollDistance;\n }\n }\n },\n // Prevents the stopping of event propagation\n false\n );\n\n document.addEventListener('keydown', handler);\n\n return () => document.removeEventListener('keydown', handler);\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n }, [tableMeta.columnFreezing.frozenColumnIndex, handleGoto]);\n\n const handleSortMenuRadioGroupChange = (newSortDirection: RadioGroupItemValue) => {\n setSortDirectionState(newSortDirection as HeaderSortDirection);\n handleSortToggle(newSortDirection as HeaderSortDirection);\n };\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 tableMeta.rowActive.setRowActiveIndex(index);\n scrollToIndex(index + 2, { align: 'center' });\n } catch {\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden',\n 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto',\n 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto',\n 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto',\n {\n '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement,\n },\n props.className\n );\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide) {\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 // We rely on canSort value instead of onSort function's value because some columns might have sorting disabled,\n // so even though onSort is truthy, we don't want to show sorting menu.\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortMenuRadioGroupChange} value={sortDirectionState}>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.ASC}>\n {texts.table3.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.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 (handleGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut={gotoShortcut}>\n {texts.table3.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canFreeze) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={handleClick}>\n {frozenIndex === 0\n ? texts.table3.columns.menu.freezeFirstColumn\n : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(frozenIndex + 1))}\n </MenuPrimitive.Item>\n );\n\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n if (tableMeta.columnFreezing.frozenColumnIndex !== undefined) {\n const handleClick = () => {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.setFrozenColumnIndex(undefined);\n };\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={handleClick}>\n {texts.table3.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n }\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.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 }, [\n menu,\n index,\n canFreeze,\n canHide,\n canSort,\n handleGoto,\n handleSortToggle,\n sortDirection,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenColumnIndex,\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 ref={ref}\n />\n );\n}\n"],"names":["isGotoAvailable","table","header","isInternalColumn","id","tableMeta","options","meta","rowGoto","isEnabled","column","getCanSort","getIsSorted","isMenuAvailable","_header$column$column","columnDef","menu","columnFreezing","enableHiding","getCanHide","Menu","props","canFreeze","canHide","canSort","index","onGoto","handleGoto","onHide","handleHide","onSortToggle","handleSortToggle","scrollToIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","sortDirectionState","setSortDirectionState","ref","useRef","gotoShortcut","useEffect","frozenColumnIndex","externalFrozenColumnIndex","frozenInternalColumnCount","handler","createShortcutKeyDownHandler","_ref$current","tableElement","tableRef","current","parentHeader","closest","leftScrollDistance","getTableLeftScrollDistance","scrollLeft","document","addEventListener","removeEventListener","handleSortMenuRadioGroupChange","newSortDirection","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","rowActive","setRowActiveIndex","align","_wasThrown","_result","_temp","e","reject","GotoPopover","open","onChange","className","cn","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table3","columns","hideColumn","subMenu","SubMenu","RadioGroup","value","SORT_DIRECTION","ASC","sortingOrder","ascending","DESC","descending","unsorted","sorting","shortcut","gotoRow","frozenIndex","setFrozenColumnIndex","freezeFirstColumn","freezeUptoColumn","replace","String","unfreezeColumns","customMenu","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","IconButton","menuProps","Content","onClickCapture","preventDefault"],"mappings":";;;;;;;;;;;;SAcgBA,eAAeA,CAAkBC,KAAoB,EAAEC,MAAgC;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC7B,OAAO,KAAK;;EAGhB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EAExD,OAAO,CAAC,EAAEF,SAAS,CAACG,OAAO,CAACC,SAAS,IAAIP,MAAM,CAACQ,MAAM,CAACC,UAAU,EAAE,IAAIT,MAAM,CAACQ,MAAM,CAACE,WAAW,EAAE,CAAC;AACvG;SAEgBC,eAAeA,CAAkBZ,KAAoB,EAAEC,MAAgC;;EACnG,IAAIC,gBAAgB,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AAS,CAACyC,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,kBAAK7F,cAAK,CAAC8F,YAAY,CAACF,IAAI,EAAE;MAAEC;KAAK,CAAC,CAAC;GACzE,EAAE,CACCnH,IAAI,EACJS,KAAK,EACLH,SAAS,EACTC,OAAO,EACPC,OAAO,EACPG,UAAU,EACVI,gBAAgB,EAChBE,aAAa;;EAEb5B,SAAS,CAACY,cAAc,CAAC8B,iBAAiB,CAC7C,CAAC;EAEF,oBACIT,6BAAC+F,UAAU;IACPjD,SAAS,EAAEA,SAAS;IACpBW,IAAI,EAAC,MAAM;IACX/E,IAAI,EACAkD,cAAc,GACR1B,SAAS,GACT8F,SAAS,mBACLhG,6BAACuD,MAAa,oBAAKyC,SAAS,gBACxBhG,6BAACuD,MAAa,CAAC0C,OAAO,QAAEjD,eAAe,CAAyB,CACpD,CACnB;IAEXlD,OAAO,EAAE8B,cAAc;IACvBsE,cAAc,EAAE9C,KAAK,IAAIA,KAAK,CAAC+C,cAAc,EAAE;IAC/C9F,GAAG,EAAEA;IACP;AAEV;;;;"}
|
@@ -95,6 +95,7 @@ function Cell(context) {
|
|
95
95
|
const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(context.index, lastColumnIndex) : undefined;
|
96
96
|
return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, context, {
|
97
97
|
actions: tableMeta.rowActions.actionsForRow,
|
98
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
98
99
|
actionsLength: tableMeta.rowActions.actionsForRowLength,
|
99
100
|
className: className,
|
100
101
|
fontSize: tableMeta.fontSize.size,
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3RowActionRenderer } from '../../../types';\nimport { FontSize, FontSizes } from '../../../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\nimport { getIndicatorCellClassName, isIndicatorVisible } from '../cell/Indicator';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n className?: string;\n fontSize: FontSize;\n isActiveRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isActiveRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n '-mb-2 flex justify-end pl-2 text-right',\n {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FontSizes.small,\n '-mt-1.5': fontSize !== FontSizes.small,\n },\n props.className\n );\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n const allVisibleColumns = context.table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(context.index, lastColumnIndex)\n : undefined;\n\n return (\n <MemoedCell<TType>\n {...context}\n actions={tableMeta.rowActions.actionsForRow}\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n className={className}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.rowActive.isHoverStatePaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isActiveRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","FontSizes","small","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","isIndicatorVisible","rowActive","rowActiveIndex","editing","rowMoveReason","getIndicatorCellClassName","undefined","rowActions","actionsForRow","actionsForRowLength","size","getState","columnSizingInfo","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;;;MAeaA,SAAS,GAAG;AAazB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,SAAS;IAAEC,gBAAgB;IAAEC,kBAAkB;IAAEC;GAAK,GAAGR,KAAK;EACrH,MAAM;IAAES;GAAW,GAAGX,cAAK,CAACY,UAAU,CAACC,UAAU,CAAC;EAClD,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGhB,cAAK,CAACiB,MAAM,CAAyB,IAAI,CAAC;;;;;;;;;;;;;;;EAkBtD,IAAIC,OAAO;;;EAIX,IAAIf,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEgB,MAAM,IAAI,CAACZ,SAAS,KAAKD,WAAW,IAAKK,SAAS,IAAI,CAACF,kBAAkB,IAAI,CAACD,gBAAiB,CAAC,EAAE;IAC3G,MAAMY,cAAc,GAAGjB,OAAO,CAACkB,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACZ,GAAG,CAACa,QAAQ,CAAC,CAAC,CAACC,MAAM,CAACF,MAAM,IAAI,CAAC,CAACA,MAAM,CAAkB;IAE9G,MAAMG,YAAY,GACdL,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGgB,cAAc,GAAGA,cAAc,CAACM,KAAK,CAAC,CAAC,EAAEtB,aAAa,GAAG,CAAC,CAAC;IACzG,MAAMuB,aAAa,GAAGP,cAAc,CAACM,KAAK,CAACN,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGA,aAAa,GAAGA,aAAa,GAAG,CA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AW,EAAEqD,SAAS,CAACQ,SAAS,CAACC,cAAc,KAAKV,QAAQ;IAC5DnD,SAAS,EAAEoD,SAAS,CAACU,OAAO,CAAC9D,SAAS;IACtCC,gBAAgB,EAAE,CAAC,CAACiD,OAAO,CAACG,KAAK,CAACiB,QAAQ,EAAE,CAACC,gBAAgB,CAACtE,gBAAgB;IAC9EC,kBAAkB,EAAE,CAAC,CAACkD,SAAS,CAACQ,SAAS,CAAC1D;KAC5C;AAEV;SAEgBsE,sBAAsBA;EAClC,OAAO;IACHC,EAAE,EAAElF,SAAS;IACbmF,MAAM,EAAEC,MAAY;IACpBC,IAAI,EAAE3B,IAAI;IACV4B,MAAM,EAAEC,MAAM;IACdvB,IAAI,EAAE;MACFwB,KAAK,EAAE,OAAO;MACd1D,SAAS,EAAEC,EAAE,CACT,oPAAoP,EACpP,wDAAwD,EACxD,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACD0D,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3RowActionRenderer } from '../../../types';\nimport { FontSize, FontSizes } from '../../../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\nimport { getIndicatorCellClassName, isIndicatorVisible } from '../cell/Indicator';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n className?: string;\n fontSize: FontSize;\n isActiveRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isActiveRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n '-mb-2 flex justify-end pl-2 text-right',\n {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FontSizes.small,\n '-mt-1.5': fontSize !== FontSizes.small,\n },\n props.className\n );\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n const allVisibleColumns = context.table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(context.index, lastColumnIndex)\n : undefined;\n\n return (\n <MemoedCell<TType>\n {...context} // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n actions={tableMeta.rowActions.actionsForRow}\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n className={className}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.rowActive.isHoverStatePaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isActiveRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","FontSizes","small","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","isIndicatorVisible","rowActive","rowActiveIndex","editing","rowMoveReason","getIndicatorCellClassName","undefined","rowActions","actionsForRow","actionsForRowLength","size","getState","columnSizingInfo","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;;;MAeaA,SAAS,GAAG;AAazB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,M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AEgBsE,sBAAsBA;EAClC,OAAO;IACHC,EAAE,EAAElF,SAAS;IACbmF,MAAM,EAAEC,MAAY;IACpBC,IAAI,EAAE3B,IAAI;IACV4B,MAAM,EAAEC,MAAM;IACdvB,IAAI,EAAE;MACFwB,KAAK,EAAE,OAAO;MACd1D,SAAS,EAAEC,EAAE,CACT,oPAAoP,EACpP,wDAAwD,EACxD,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACD0D,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
|
@@ -208,6 +208,7 @@ function EditingRow(props) {
|
|
208
208
|
// this ensures we focus either on a field or on the same column when keyboard navigating up/down
|
209
209
|
React__default.useEffect(() => {
|
210
210
|
// When table in searching state, whe should prevent editing control to be focused, because it will cause search field to loose focus.
|
211
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
211
212
|
if (tableMeta.rowActive.rowActiveIndex === props.index && !tableMeta.search.isSearching) {
|
212
213
|
if (lastCellIndex.value !== null) {
|
213
214
|
var _props$tableRef$curre;
|
@@ -228,6 +229,7 @@ function EditingRow(props) {
|
|
228
229
|
// Need to subscribe to current row index and check is it a current row,
|
229
230
|
// for a situation where hovered row is the next row after current row...
|
230
231
|
// In this case row will not be re-rendered if user switch to next row, because hovered row also renders EditingRow.
|
232
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
231
233
|
}, [tableMeta.rowActive.rowActiveIndex, tableMeta.search.isSearching]);
|
232
234
|
return /*#__PURE__*/React__default.createElement(MemoedRow, Object.assign({}, attributes, {
|
233
235
|
onClickCapture: handleClickCapture,
|