@economic/taco 2.15.0 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Drawer/Drawer.d.ts +5 -1
- package/dist/components/Provider/Localization.d.ts +19 -0
- package/dist/components/SearchInput2/SearchInput2.d.ts +1 -0
- package/dist/components/Table3/Table3.d.ts +0 -2
- package/dist/components/Table3/components/alert/ErrorAlert.d.ts +10 -0
- package/dist/components/Table3/components/columns/cell/DisplayCell.d.ts +5 -2
- package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +3 -0
- package/dist/components/Table3/components/columns/cell/EditingControl.d.ts +1 -1
- package/dist/components/Table3/components/columns/cell/Highlight.d.ts +2 -0
- package/dist/components/Table3/components/columns/header/Header.d.ts +1 -1
- package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
- package/dist/components/Table3/components/columns/styles.d.ts +2 -2
- package/dist/components/Table3/components/rows/Row.d.ts +5 -1
- package/dist/components/Table3/components/rows/RowContext.d.ts +1 -0
- package/dist/components/Table3/hooks/features/useEditing.d.ts +12 -11
- package/dist/components/Table3/hooks/features/{usePauseHoverState.d.ts → usePauseShortcuts.d.ts} +1 -2
- package/dist/components/Table3/hooks/features/useSearch.d.ts +3 -3
- package/dist/components/Table3/hooks/features/useValidation.d.ts +13 -0
- package/dist/components/Table3/hooks/useTable.d.ts +25 -20
- package/dist/components/Table3/types.d.ts +41 -19
- package/dist/components/Table3/util/editing.d.ts +6 -0
- package/dist/components/Table3/util/scrolling.d.ts +2 -0
- package/dist/esm/index.css +108 -33
- package/dist/esm/packages/taco/src/components/Banner/Banner.js +2 -2
- package/dist/esm/packages/taco/src/components/Banner/Banner.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Calendar/Calendar.js +4 -4
- package/dist/esm/packages/taco/src/components/Calendar/Calendar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/Combobox.js +3 -3
- package/dist/esm/packages/taco/src/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +2 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +6 -6
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +3 -3
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +7 -2
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +7 -7
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +2 -2
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js +2 -2
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +4 -4
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Link.js +2 -2
- package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/Icon.js +2 -2
- package/dist/esm/packages/taco/src/components/Icon/Icon.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +2 -2
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +6 -6
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js +4 -4
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation/Navigation.js +2 -2
- package/dist/esm/packages/taco/src/components/Navigation/Navigation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +3 -3
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +2 -2
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js +2 -2
- package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Pagination/Pagination.js +5 -5
- package/dist/esm/packages/taco/src/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js +2 -2
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +19 -0
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +2 -2
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +12 -8
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/useSelect.js +2 -2
- package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +7 -7
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +8 -8
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +5 -5
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +10 -10
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +2 -2
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js +3 -3
- package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js +2 -2
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +10 -10
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js +2 -2
- package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +37 -30
- 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 +154 -0
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +54 -9
- 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 +9 -57
- 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 +72 -41
- 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 +41 -17
- 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/Highlight.js +41 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Highlight.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +23 -14
- 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/Footer.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +9 -9
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +37 -6
- 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 +12 -12
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +63 -23
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +2 -13
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +67 -57
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js +2 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/SkeletonRow.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/rows/SkeletonRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +8 -6
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +23 -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/FilterColumn.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +2 -2
- 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 +16 -16
- 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 +1 -0
- 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 +53 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +8 -8
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +185 -101
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js +12 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js +4 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js +178 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +1 -49
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +1 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +0 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +135 -111
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js +4 -4
- package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.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/editing.js +21 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/scrolling.js +53 -0
- package/dist/esm/packages/taco/src/components/Table3/util/scrolling.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Tag/Tag.js +4 -4
- package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js +2 -2
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tour/Tour.js +4 -4
- package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Treeview/Treeview.js +2 -2
- package/dist/esm/packages/taco/src/components/Treeview/Treeview.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +2 -1
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js +10 -0
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnOrdering.js +8 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnOrdering.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/features/useFontSize.js → primitives/Table/useTable/features/useTableFontSize.js} +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFontSize.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +14 -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/useTableRowActive.js +100 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActive.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowClick.js +30 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowClick.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGoto.js +9 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGoto.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowHeight.js +13 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowHeight.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowSelection.js +32 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowSelection.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableServerLoading.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableServerLoading.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableDataListener.js +15 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableDataListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/listeners/useFilteringStateListener.js → primitives/Table/useTable/listeners/useTableFilterListener.js} +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableFilterListener.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableFontSizeListener.js +40 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableFontSizeListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/listeners/useRowSelectionListener.js → primitives/Table/useTable/listeners/useTableRowSelectionListener.js} +5 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/listeners/useServerLoadingListener.js → primitives/Table/useTable/listeners/useTableServerLoadingListener.js} +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableServerLoadingListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/listeners/useShortcutsListener.js → primitives/Table/useTable/listeners/useTableShortcutsListener.js} +7 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableShortcutsListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/listeners/useSortingStateListener.js → primitives/Table/useTable/listeners/useTableSortingListener.js} +6 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSortingListener.js.map +1 -0
- package/dist/esm/packages/taco/src/{components/Table3/hooks/features/useColumnOrdering.js → primitives/Table/useTable/util/columns.js} +24 -15
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -0
- package/dist/esm/packages/taco/src/types.js +6 -0
- package/dist/esm/packages/taco/src/types.js.map +1 -0
- package/dist/esm/packages/taco/src/utils/date.js +0 -1
- package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
- package/dist/index.css +108 -33
- package/dist/primitives/Table/types.d.ts +35 -0
- package/dist/primitives/Table/useTable/features/useTableColumnOrdering.d.ts +3 -0
- package/dist/primitives/Table/useTable/features/useTableFontSize.d.ts +7 -0
- package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +7 -0
- package/dist/primitives/Table/useTable/features/useTableRowActive.d.ts +12 -0
- package/dist/primitives/Table/useTable/features/useTableRowClick.d.ts +7 -0
- package/dist/primitives/Table/useTable/features/useTableRowGoto.d.ts +5 -0
- package/dist/primitives/Table/useTable/features/useTableRowHeight.d.ts +7 -0
- package/dist/primitives/Table/useTable/features/useTableRowSelection.d.ts +6 -0
- package/dist/primitives/Table/useTable/features/useTableServerLoading.d.ts +6 -0
- package/dist/primitives/Table/useTable/listeners/useTableDataListener.d.ts +2 -0
- package/dist/primitives/Table/useTable/listeners/useTableFilterListener.d.ts +3 -0
- package/dist/primitives/Table/useTable/listeners/useTableFontSizeListener.d.ts +2 -0
- package/dist/primitives/Table/useTable/listeners/useTableRowSelectionListener.d.ts +3 -0
- package/dist/primitives/Table/useTable/listeners/useTableServerLoadingListener.d.ts +3 -0
- package/dist/primitives/Table/useTable/listeners/useTableShortcutsListener.d.ts +3 -0
- package/dist/primitives/Table/useTable/listeners/useTableSortingListener.d.ts +3 -0
- package/dist/primitives/Table/useTable/util/columns.d.ts +4 -0
- package/dist/taco.cjs.development.js +2294 -1543
- 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/types.d.ts +5 -0
- package/package.json +3 -3
- package/types.json +13547 -12953
- package/dist/components/Table3/hooks/features/useColumnOrdering.d.ts +0 -6
- package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +0 -11
- package/dist/components/Table3/hooks/features/useFontSize.d.ts +0 -7
- package/dist/components/Table3/hooks/features/usePrinting.d.ts +0 -8
- package/dist/components/Table3/hooks/features/useRowClick.d.ts +0 -6
- package/dist/components/Table3/hooks/features/useRowGoto.d.ts +0 -5
- package/dist/components/Table3/hooks/features/useRowHeight.d.ts +0 -7
- package/dist/components/Table3/hooks/features/useRowSelection.d.ts +0 -6
- package/dist/components/Table3/hooks/listeners/useCurrentRowListener.d.ts +0 -2
- package/dist/components/Table3/hooks/listeners/useFilteringStateListener.d.ts +0 -3
- package/dist/components/Table3/hooks/listeners/useRowSelectionListener.d.ts +0 -3
- package/dist/components/Table3/hooks/listeners/useServerLoadingListener.d.ts +0 -3
- package/dist/components/Table3/hooks/listeners/useShortcutsListener.d.ts +0 -3
- package/dist/components/Table3/hooks/listeners/useSortingStateListener.d.ts +0 -3
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnOrdering.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +0 -93
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useFontSize.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseHoverState.js +0 -22
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseHoverState.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePrinting.js +0 -14
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePrinting.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +0 -25
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowGoto.js +0 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowGoto.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowHeight.js +0 -27
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowHeight.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +0 -32
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +0 -15
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useFilteringStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useRowSelectionListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useServerLoadingListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSortingStateListener.js.map +0 -1
@@ -1,25 +1,22 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import cn from 'classnames';
|
3
|
-
import {
|
4
|
-
import { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns.js';
|
3
|
+
import { Highlight } from './Highlight.js';
|
5
4
|
|
6
5
|
function DisplayCell(props) {
|
7
6
|
const {
|
8
7
|
cell,
|
9
8
|
className,
|
10
9
|
column,
|
11
|
-
|
10
|
+
value,
|
12
11
|
index,
|
13
12
|
row,
|
14
13
|
table,
|
15
|
-
tableRef
|
14
|
+
tableRef,
|
15
|
+
highlighted,
|
16
|
+
highlightedAsCurrent
|
16
17
|
} = props;
|
17
18
|
const columnMeta = React__default.useMemo(() => column.columnDef.meta, []);
|
18
19
|
const tableMeta = table.options.meta;
|
19
|
-
const {
|
20
|
-
rowIndex
|
21
|
-
} = React__default.useContext(RowContext);
|
22
|
-
const value = getValue();
|
23
20
|
// cells are heavily memoized because performance in our table is critical
|
24
21
|
// be careful and selective about props that you pass to the cell
|
25
22
|
const memoedProps = React__default.useMemo(() => {
|
@@ -37,29 +34,9 @@ function DisplayCell(props) {
|
|
37
34
|
tableRef
|
38
35
|
};
|
39
36
|
}, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);
|
40
|
-
const memoedHighlight = React__default.useMemo(() => {
|
41
|
-
var _tableMeta$search$que;
|
42
|
-
if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
|
43
|
-
return false;
|
44
|
-
}
|
45
|
-
if ((_tableMeta$search$que = tableMeta.search.query) !== null && _tableMeta$search$que !== void 0 && _tableMeta$search$que.length) {
|
46
|
-
return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);
|
47
|
-
}
|
48
|
-
return false;
|
49
|
-
}, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);
|
50
|
-
const memoedHighlightCurrent = React__default.useMemo(() => {
|
51
|
-
if (!tableMeta.search.isHighlightingEnabled || !memoedHighlight || tableMeta.search.currentHighlightColumnIndex === undefined) {
|
52
|
-
return false;
|
53
|
-
}
|
54
|
-
const [currentRowIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
|
55
|
-
if (currentRowIndex === rowIndex && currentColumnIndex === index) {
|
56
|
-
return true;
|
57
|
-
}
|
58
|
-
return false;
|
59
|
-
}, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);
|
60
37
|
return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, memoedProps, {
|
61
|
-
highlighted:
|
62
|
-
highlightedAsCurrent:
|
38
|
+
highlighted: highlighted,
|
39
|
+
highlightedAsCurrent: highlightedAsCurrent
|
63
40
|
}));
|
64
41
|
}
|
65
42
|
const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDisplayCell(props) {
|
@@ -92,39 +69,14 @@ const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDispla
|
|
92
69
|
role: "cell",
|
93
70
|
// cells must be focusable (but not included in tabbing - hence -1)
|
94
71
|
tabIndex: -1
|
95
|
-
}, highlighted ? /*#__PURE__*/React__default.createElement(Highlight, {
|
72
|
+
}, highlighted ? ( /*#__PURE__*/React__default.createElement(Highlight, {
|
96
73
|
className: layoutClassName,
|
97
74
|
current: highlightedAsCurrent,
|
98
75
|
frozenColumnIndex: frozenColumnIndex,
|
99
76
|
index: index,
|
100
77
|
tableRef: tableRef
|
101
|
-
}, content) : content);
|
78
|
+
}, content)) : content);
|
102
79
|
});
|
103
|
-
const Highlight = props => {
|
104
|
-
const {
|
105
|
-
current,
|
106
|
-
frozenColumnIndex,
|
107
|
-
index,
|
108
|
-
tableRef,
|
109
|
-
...attributes
|
110
|
-
} = props;
|
111
|
-
const ref = React__default.useRef(null);
|
112
|
-
const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {
|
113
|
-
// normal row
|
114
|
-
'bg-blue-200/25': !current,
|
115
|
-
// current row
|
116
|
-
'bg-blue-200/75': current
|
117
|
-
});
|
118
|
-
React__default.useEffect(() => {
|
119
|
-
if (ref.current && current) {
|
120
|
-
scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);
|
121
|
-
}
|
122
|
-
}, [current]);
|
123
|
-
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
124
|
-
className: className,
|
125
|
-
ref: ref
|
126
|
-
}));
|
127
|
-
};
|
128
80
|
|
129
81
|
export { DisplayCell };
|
130
82
|
//# sourceMappingURL=DisplayCell.js.map
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, getValue, index, row, table, tableRef } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { rowIndex } = React.useContext(RowContext);\n\n const value = getValue();\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [currentRowIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (currentRowIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n return (\n <MemoedDisplayCell<TType> {...memoedProps} highlighted={memoedHighlight} highlightedAsCurrent={memoedHighlightCurrent} />\n );\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted: boolean;\n highlightedAsCurrent: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n\nconst Highlight = props => {\n const { current, frozenColumnIndex, index, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {\n // normal row\n 'bg-blue-200/25': !current,\n // current row\n 'bg-blue-200/75': current,\n });\n\n React.useEffect(() => {\n if (ref.current && current) {\n scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);\n }\n }, [current]);\n\n return <div {...attributes} className={className} ref={ref} />;\n};\n"],"names":["DisplayCell","props","cell","className","column","getValue","index","row","table","tableRef","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","rowIndex","useContext","RowContext","value","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","memoedHighlight","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","length","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","undefined","currentRowIndex","currentColumnIndex","highlightedColumnIndexes","MemoedDisplayCell","highlighted","highlightedAsCurrent","memo","customClassName","layoutClassName","content","console","log","role","tabIndex","Highlight","current","attributes","ref","useRef","useEffect","scrollColumnIntoView"],"mappings":";;;;;SAYgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAU,GAAGR,KAAK;EAChF,MAAMS,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMR,MAAM,CAACS,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACF,IAAwB;EACxD,MAAM;IAAEG;GAAU,GAAGN,cAAK,CAACO,UAAU,CAACC,UAAU,CAAC;EAEjD,MAAMC,KAAK,GAAGf,QAAQ,EAAE;;;EAIxB,MAAMgB,WAAW,GAA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BAAoB,CAAClE,KAAK,EAAE8B,iBAAiB,EAAEiC,GAAG,CAACF,OAAO,EAAE1D,QAAQ,CAAC0D,OAAO,CAAC;;GAEpF,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,oBAAOxD,sDAASyD,UAAU;IAAEjE,SAAS,EAAEA,SAAS;IAAEkE,GAAG,EAAEA;KAAO;AAClE,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Highlight } from './Highlight';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n value?: any;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, value, index, row, table, tableRef, highlighted, highlightedAsCurrent } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n return <MemoedDisplayCell<TType> {...memoedProps} highlighted={highlighted} highlightedAsCurrent={highlightedAsCurrent} />;\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n"],"names":["DisplayCell","props","cell","className","column","value","index","row","table","tableRef","highlighted","highlightedAsCurrent","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","MemoedDisplayCell","memo","customClassName","layoutClassName","undefined","content","console","log","role","tabIndex","Highlight","current"],"mappings":";;;;SAcgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;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|
2
2
|
import cn from 'classnames';
|
3
|
+
import { Field } from '../../../../Field/Field.js';
|
3
4
|
import { useRowContext } from '../../rows/RowContext.js';
|
5
|
+
import { Highlight } from './Highlight.js';
|
4
6
|
import { getCurrentRowCellElement } from '../../../util/columns.js';
|
5
7
|
import { globalFilterFn, columnFilterFn } from '../../../util/filtering.js';
|
6
|
-
import { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions.js';
|
7
8
|
import { Indicator, IndicatorReason } from './Indicator.js';
|
8
9
|
import { hasChanged, willRowMoveAfterSorting } from '../../../util/editing.js';
|
10
|
+
import { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions.js';
|
9
11
|
import { EditingControl } from './EditingControl.js';
|
10
12
|
|
11
13
|
function EditingCell(props) {
|
14
|
+
const {
|
15
|
+
cell,
|
16
|
+
table
|
17
|
+
} = props;
|
12
18
|
const {
|
13
19
|
isHovered
|
14
20
|
} = useRowContext();
|
15
21
|
// Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.
|
16
|
-
const tableMeta =
|
22
|
+
const tableMeta = table.options.meta;
|
23
|
+
const error = tableMeta.validation.getCellError(cell);
|
17
24
|
return /*#__PURE__*/React__default.createElement(MemoedEditingCell, Object.assign({}, props, {
|
25
|
+
error: error,
|
18
26
|
isHovered: isHovered,
|
19
27
|
tableMeta: tableMeta
|
20
28
|
}));
|
21
29
|
}
|
22
30
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
23
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$
|
31
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met;
|
24
32
|
const {
|
25
33
|
cell,
|
26
34
|
column,
|
@@ -29,8 +37,10 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
29
37
|
table,
|
30
38
|
tableRef,
|
31
39
|
row,
|
32
|
-
|
33
|
-
|
40
|
+
tableMeta,
|
41
|
+
error,
|
42
|
+
highlighted,
|
43
|
+
highlightedAsCurrent
|
34
44
|
} = props;
|
35
45
|
const columnMeta = column.columnDef.meta;
|
36
46
|
const cellRef = React__default.useRef(null);
|
@@ -67,31 +77,37 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
67
77
|
}
|
68
78
|
};
|
69
79
|
const handleBlur = () => {
|
80
|
+
var _tableMeta$editing$ch;
|
70
81
|
tableMeta.editing.setDetailModeEditing(false);
|
82
|
+
if ((_tableMeta$editing$ch = tableMeta.editing.changes) !== null && _tableMeta$editing$ch !== void 0 && _tableMeta$editing$ch[cell.row.id]) {
|
83
|
+
tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id], cell.column.id);
|
84
|
+
}
|
71
85
|
};
|
72
86
|
// row move indicator
|
73
|
-
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason
|
87
|
+
const moveReason = ((_tableMeta$editing$ro = tableMeta.editing.rowMoveReason) === null || _tableMeta$editing$ro === void 0 ? void 0 : _tableMeta$editing$ro[cell.column.id]) || null;
|
74
88
|
const rows = table.getRowModel().rows;
|
75
|
-
const
|
76
|
-
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
89
|
+
const isActiveRow = tableMeta.rowActive.rowActiveIndex !== undefined && ((_rows$tableMeta$rowAc = rows[tableMeta.rowActive.rowActiveIndex]) === null || _rows$tableMeta$rowAc === void 0 ? void 0 : _rows$tableMeta$rowAc.id) === row.id;
|
77
90
|
const mountNode = React__default.useMemo(() => {
|
78
|
-
if (moveReason) {
|
91
|
+
if (moveReason !== null && isActiveRow && !error) {
|
79
92
|
var _cellRef$current2, _cellRef$current2$par;
|
80
93
|
return (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.firstChild;
|
81
94
|
}
|
82
95
|
return null;
|
83
|
-
}, [moveReason, cellRef]);
|
96
|
+
}, [moveReason, isActiveRow, error, cellRef]);
|
84
97
|
const removeMoveReason = () => {
|
85
|
-
tableMeta.editing.removeRowMoveReason(
|
98
|
+
tableMeta.editing.removeRowMoveReason();
|
86
99
|
};
|
87
100
|
React__default.useEffect(() => {
|
88
101
|
// To avoid reseting move reason on another row hover,
|
89
102
|
// we need to check for changes only if value got changed in the current row.
|
90
|
-
if (!
|
103
|
+
if (!isActiveRow || error) {
|
104
|
+
if (tableMeta.editing.rowMoveReason) {
|
105
|
+
removeMoveReason();
|
106
|
+
}
|
91
107
|
return;
|
92
108
|
}
|
93
109
|
if (hasChanged(getValue(), value)) {
|
94
|
-
const moveReason = getRowMoveReason(table, row.index, row.original, cell, value);
|
110
|
+
const moveReason = getRowMoveReason(table, row.index, row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
|
95
111
|
tableMeta.editing.setRowMoveReason({
|
96
112
|
[cell.column.id]: moveReason
|
97
113
|
});
|
@@ -99,28 +115,19 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
99
115
|
removeMoveReason();
|
100
116
|
}
|
101
117
|
return removeMoveReason;
|
102
|
-
}, [value]);
|
118
|
+
}, [value, tableMeta.rowActive.rowActiveIndex, tableMeta.search.excludeUnmatchedResults, error]);
|
103
119
|
const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
|
104
120
|
const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
mountNode: mountNode,
|
116
|
-
validationErrors: []
|
117
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
118
|
-
className: className,
|
119
|
-
"data-align": columnMeta.align,
|
120
|
-
"data-column-index": index,
|
121
|
-
"data-editable": true,
|
122
|
-
role: "cell",
|
123
|
-
ref: cellRef
|
121
|
+
// Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative
|
122
|
+
relative: controlRenderer === 'textarea' && columnMeta.enableTruncate
|
123
|
+
}, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
124
|
+
const fieldClassName = cn('!min-h-0 w-full !pb-0', {
|
125
|
+
'!pb-3': !!error
|
126
|
+
});
|
127
|
+
const content = /*#__PURE__*/React__default.createElement(Field, {
|
128
|
+
message: error,
|
129
|
+
invalid: !!error,
|
130
|
+
className: fieldClassName
|
124
131
|
}, /*#__PURE__*/React__default.createElement(EditingControl, {
|
125
132
|
align: columnMeta.align,
|
126
133
|
column: cell.column,
|
@@ -134,22 +141,46 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
134
141
|
tableRef: tableRef,
|
135
142
|
value: value,
|
136
143
|
cell: cell,
|
137
|
-
|
138
|
-
|
144
|
+
error: error,
|
145
|
+
tabIndex: isActiveRow ? 0 : -1,
|
146
|
+
isActiveRow: isActiveRow
|
147
|
+
}));
|
148
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && !error ? ( /*#__PURE__*/React__default.createElement(Indicator, {
|
149
|
+
reason: moveReason,
|
150
|
+
columnName: String(cell.column.columnDef.header),
|
151
|
+
mountNode: mountNode,
|
152
|
+
validationErrors: []
|
153
|
+
})) : null, /*#__PURE__*/React__default.createElement("div", {
|
154
|
+
className: !highlighted ? className : undefined,
|
155
|
+
"data-align": columnMeta.align,
|
156
|
+
"data-column-index": index,
|
157
|
+
role: "cell",
|
158
|
+
"data-editable": true,
|
159
|
+
ref: cellRef,
|
160
|
+
"data-invalid": !!error,
|
161
|
+
"data-highlighted": highlighted
|
162
|
+
}, highlighted ? ( /*#__PURE__*/React__default.createElement(Highlight, {
|
163
|
+
current: highlightedAsCurrent,
|
164
|
+
className: className,
|
165
|
+
frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,
|
166
|
+
index: index,
|
167
|
+
tableRef: tableRef
|
168
|
+
}, content)) : content));
|
139
169
|
});
|
140
|
-
function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
|
170
|
+
function getRowMoveReason(table, rowIndex, rowValues, cell, newValue, excludeUnmatchedResults) {
|
141
171
|
var _table$getState$sorti;
|
142
172
|
let rowMoveReason = null;
|
143
173
|
const {
|
144
174
|
globalFilter
|
145
175
|
} = table.getState();
|
146
|
-
const isFilteredByGlobalFilter = Object.values({
|
176
|
+
const isFilteredByGlobalFilter = excludeUnmatchedResults ? Object.values({
|
147
177
|
...rowValues,
|
148
178
|
[cell.id]: newValue
|
149
|
-
}).some(
|
150
|
-
|
151
|
-
|
152
|
-
|
179
|
+
}).some(() => {
|
180
|
+
// Global filter can be undefined when there is no text being searched so we pass an empty string to
|
181
|
+
// globalFilterFn as query in that case.
|
182
|
+
return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');
|
183
|
+
}) : true;
|
153
184
|
if (!isFilteredByGlobalFilter) {
|
154
185
|
rowMoveReason = IndicatorReason.SEARCH;
|
155
186
|
} else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue())) {
|
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 'classnames';\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 { 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 { useRowContext } from '../../rows/RowContext';\n\nexport type EditingCellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function EditingCell<TType = unknown>(props: EditingCellProps<TType>) {\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 = props.table.options.meta as TableMeta<TType>;\n return <MemoedEditingCell<TType> {...props} isHovered={isHovered} tableMeta={tableMeta} />;\n}\n\n// Memoization\nexport type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {\n isHovered: boolean;\n tableMeta: TableMeta<TType>;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const { cell, column, index, getValue, table, tableRef, row, isHovered, tableMeta } = props;\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 };\n\n // row move indicator\n const moveReason = tableMeta.editing.rowMoveReason[cell.column.id] ?? null;\n const rows = table.getRowModel().rows;\n const currentRowIndex = tableMeta.currentRow.currentRowIndex;\n const isCurrentRow = currentRowIndex !== undefined && rows[currentRowIndex]?.id === row.id;\n const mountNode = React.useMemo(() => {\n if (moveReason) {\n return cellRef.current?.parentElement?.firstChild as Element | null;\n }\n return null;\n }, [moveReason, cellRef]);\n\n const removeMoveReason = () => {\n tableMeta.editing.removeRowMoveReason(cell.column.id);\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 (!isCurrentRow) {\n return;\n }\n\n if (hasChanged(getValue(), value)) {\n const moveReason = getRowMoveReason(table, row.index, row.original, cell, value);\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\n } else {\n removeMoveReason();\n }\n return removeMoveReason;\n }, [value]);\n\n const controlRenderer = column.columnDef.meta?.control;\n\n const className = cn(\n 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]',\n {\n relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',\n // Need to set higher z-index, so that the current row textarea (in expanded state, when positioned absolute) overlaps rows below,\n // but at the same time it should not overlap the table headers which has z-10.\n 'z-[9]': isCurrentRow && controlRenderer === 'textarea',\n },\n\n // component overrides - grayscale for editing hover\n '[[role=\"row\"][data-current=\"false\"]:hover_&>*]:!grayscale [[role=\"row\"][data-current=\"false\"]:hover_&_.bg-white]:!bg-grey-100',\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n );\n\n return (\n <>\n {moveReason !== null && mountNode && (\n <Indicator\n reason={moveReason}\n columnName={String(cell.column.columnDef.header)}\n mountNode={mountNode}\n validationErrors={[]}\n />\n )}\n <div\n className={className}\n data-align={columnMeta.align}\n data-column-index={index}\n data-editable\n role=\"cell\"\n ref={cellRef}>\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 isCurrentRow={isCurrentRow}\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) {\n let rowMoveReason: IndicatorReason | null = null;\n const { globalFilter } = table.getState();\n\n const isFilteredByGlobalFilter = Object.values<unknown>({ ...rowValues, [cell.id]: newValue }).some(cellValue =>\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 globalFilterFn(String(cellValue), globalFilter ? String(globalFilter) : '')\n );\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","isHovered","useRowContext","tableMeta","table","options","meta","React","MemoedEditingCell","memo","cell","column","index","getValue","tableRef","row","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","moveReason","_tableMeta$editing$ro","rowMoveReason","id","rows","getRowModel","currentRowIndex","currentRow","isCurrentRow","_rows$currentRowIndex","mountNode","useMemo","_cellRef$current2","_cellRef$current2$par","parentElement","firstChild","removeMoveReason","removeRowMoveReason","useEffect","hasChanged","getRowMoveReason","original","setRowMoveReason","controlRenderer","_column$columnDef$met","control","className","cn","relative","Indicator","reason","columnName","String","header","validationErrors","align","role","ref","EditingControl","data","initialValue","onBlur","onFocus","onChange","rowIndex","rowValues","newValue","globalFilter","getState","isFilteredByGlobalFilter","Object","values","some","cellValue","globalFilterFn","IndicatorReason","SEARCH","getIsFiltered","columnFilterFn","getFilterValue","FILTER","getIsSorted","willRowMoveAfterSorting","_table$getState$sorti","sorting","find","s","desc","SORTING"],"mappings":";;;;;;;;;;SAiBgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC;GAAW,GAAGC,aAAa,EAAE;;EAErC,MAAMC,SAAS,GAAGH,KAAK,CAACI,KAAK,CAACC,OAAO,CAACC,IAAwB;EAC9D,oBAAOC,6BAACC,iBAAiB,oBAAYR,KAAK;IAAEC,SAAS,EAAEA,SAAS;IAAEE,SAAS,EAAEA;KAAa;AAC9F;AAQA,MAAMK,iBAAiB,gBAAGD,cAAK,CAACE,IAAI,CAAC,SAASD,iBAAiBA,CAAkBR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C,MAAMC,wBAAwB,GAAGC,MAAM,CAACC,MAAM,CAAU;IAAE,GAAGN,SAAS;IAAE,CAAC3F,IAAI,CAACiD,EAAE,GAAG2C;GAAU,CAAC,CAACM,IAAI,CAACC,SAAS;;;EAGzGC,cAAc,CAACtB,MAAM,CAACqB,SAAS,CAAC,EAAEN,YAAY,GAAGf,MAAM,CAACe,YAAY,CAAC,GAAG,EAAE,CAAC,CAC9E;EAED,IAAI,CAACE,wBAAwB,EAAE;IAC3B/C,aAAa,GAAGqD,eAAe,CAACC,MAAM;GACzC,MAAM,IAAItG,IAAI,CAACC,MAAM,CAACsG,aAAa,EAAE,IAAI,CAACC,cAAc,CAACZ,QAAQ,EAAE5F,IAAI,CAACC,MAAM,CAACwG,cAAc,EAAuB,CAAC,EAAE;IACpHzD,aAAa,GAAGqD,eAAe,CAACK,MAAM;GACzC,MAAM,IACH,CAAC1D,aAAa,IACdhD,IAAI,CAACC,MAAM,CAAC0G,WAAW,EAAE,IACzBC,uBAAuB,CACnBhB,QAAQ,EACR5F,IAAI,EACJ0F,QAAQ,EACRhG,KAAK,CAACyD,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAA2D,qBAAA,GAACnH,KAAK,CAACoG,QAAQ,EAAE,CAACgB,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC/D,EAAE,KAAKjD,IAAI,CAACC,MAAM,CAACgD,EAAE,CAAC,cAAA4D,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACEjE,aAAa,GAAGqD,eAAe,CAACa,OAAO;;EAG3C,OAAOlE,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 'classnames';\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 { 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};\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\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 || 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 row.index,\n row.original,\n cell,\n value,\n tableMeta.search.excludeUnmatchedResults\n );\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\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 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]',\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 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","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","rowIndex","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":";;;;;;;;;;;;SAqBgBA,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;EAE1H,MAAMqB,UAAU,GAAGP,MAAM,CAACQ,SAAS,CAACf,IAAkC;EAEtE,MAAMgB,OAAO,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R,MAAM,CAACQ,YAAY,CAAC,GAAG,EAAE,CAAC;GACpF,CAAC,GACF,IAAI;EAEV,IAAI,CAACE,wBAAwB,EAAE;IAC3BxD,aAAa,GAAG6D,eAAe,CAACC,MAAM;GACzC,MAAM,IAAIhI,IAAI,CAACa,MAAM,CAACoH,aAAa,EAAE,IAAI,CAACC,cAAc,CAACX,QAAQ,EAAEvH,IAAI,CAACa,MAAM,CAACsH,cAAc,EAAuB,CAAC,EAAE;IACpHjE,aAAa,GAAG6D,eAAe,CAACK,MAAM;GACzC,MAAM,IACH,CAAClE,aAAa,IACdlE,IAAI,CAACa,MAAM,CAACwH,WAAW,EAAE,IACzBC,uBAAuB,CACnBf,QAAQ,EACRvH,IAAI,EACJqH,QAAQ,EACRpH,KAAK,CAACmE,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAAoE,qBAAA,GAACtI,KAAK,CAACwH,QAAQ,EAAE,CAACe,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC5E,EAAE,KAAK9D,IAAI,CAACa,MAAM,CAACiD,EAAE,CAAC,cAAAyE,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACEzE,aAAa,GAAG6D,eAAe,CAACa,OAAO;;EAG3C,OAAO1E,aAAa;AACxB;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js
CHANGED
@@ -6,9 +6,10 @@ import { Input } from '../../../../Input/Input.js';
|
|
6
6
|
import { deselectInputValue } from '../../../../../utils/input.js';
|
7
7
|
import { Datepicker } from '../../../../Datepicker/Datepicker.js';
|
8
8
|
import { Switch } from '../../../../Switch/Switch.js';
|
9
|
+
import { getTableLeftScrollDistance } from '../../../util/scrolling.js';
|
9
10
|
import { getInputAppearanceClassnames, getCellAlignmentClasses } from '../styles.js';
|
10
|
-
import _ from 'lodash-es';
|
11
11
|
import { hasChanged } from '../../../util/editing.js';
|
12
|
+
import _ from 'lodash-es';
|
12
13
|
import { TextareaControl } from './controls/TextareaControl.js';
|
13
14
|
|
14
15
|
const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(props, externalRef) {
|
@@ -23,7 +24,8 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
23
24
|
tableRef,
|
24
25
|
value,
|
25
26
|
cell,
|
26
|
-
|
27
|
+
error,
|
28
|
+
isActiveRow,
|
27
29
|
...attributes
|
28
30
|
} = props;
|
29
31
|
const tableMeta = table.options.meta;
|
@@ -32,6 +34,8 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
32
34
|
const columnMeta = column.columnDef.meta;
|
33
35
|
const controlRenderer = columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.control;
|
34
36
|
const isCellInDetailMode = tableMeta.editing.detailModeEditing && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(document.activeElement));
|
37
|
+
const originalRow = cell.row.original;
|
38
|
+
// Revert to initial value if escape was pressed
|
35
39
|
const handleKeyDown = event => {
|
36
40
|
// For some reason keydown event handler is not propogated to the table when input or other control element is
|
37
41
|
// in focus so we need to check for shortcut that toggles the editing.
|
@@ -91,7 +95,7 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
91
95
|
return;
|
92
96
|
}
|
93
97
|
};
|
94
|
-
const isNumber =
|
98
|
+
const isNumber = (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.dataType) === 'number';
|
95
99
|
const handleInputKeyDown = event => {
|
96
100
|
handleKeyDown(event);
|
97
101
|
// Switching to editing mode, when key pressed any alphabetical character or number
|
@@ -99,19 +103,30 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
99
103
|
tableMeta.editing.setDetailModeEditing(true);
|
100
104
|
}
|
101
105
|
};
|
102
|
-
const
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
const handleFocus = event => {
|
107
|
+
var _event$target;
|
108
|
+
const {
|
109
|
+
frozenColumnIndex: externalFrozenColumnIndex = -1,
|
110
|
+
frozenInternalColumnCount = 0
|
111
|
+
} = tableMeta.columnFreezing;
|
112
|
+
const tableElement = tableMeta.tableRef.current;
|
113
|
+
const frozenColumnIndex = externalFrozenColumnIndex > -1 ? externalFrozenColumnIndex + frozenInternalColumnCount : frozenInternalColumnCount - 1;
|
114
|
+
const cell = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[role="cell"]');
|
115
|
+
if (!tableElement || !cell) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
const isEditing = true;
|
119
|
+
const leftScrollDistance = getTableLeftScrollDistance(tableElement, cell, frozenColumnIndex, isEditing);
|
120
|
+
if (leftScrollDistance !== null) {
|
121
|
+
tableElement.scrollLeft = leftScrollDistance;
|
109
122
|
}
|
110
123
|
};
|
111
124
|
if (typeof controlRenderer === 'function') {
|
112
125
|
return controlRenderer({
|
113
126
|
...attributes,
|
114
|
-
|
127
|
+
invalid: !!error,
|
128
|
+
onFocus: handleFocus,
|
129
|
+
ref: refCallback,
|
115
130
|
setValue: nextValue => {
|
116
131
|
if (nextValue !== value) {
|
117
132
|
handleChange(nextValue);
|
@@ -120,19 +135,23 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
120
135
|
value
|
121
136
|
}, data);
|
122
137
|
} else if (controlRenderer === 'datepicker') {
|
123
|
-
const
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
138
|
+
const handleDatepickerChange = event => {
|
139
|
+
// When datepicker looses focus, it triggers change event, even if date wasn't changed,
|
140
|
+
// so adding additional check here to prevent adding change to the edititng state.
|
141
|
+
const originalDate = originalRow[cell.column.id];
|
142
|
+
const changedDate = event.detail;
|
143
|
+
if (hasChanged(originalDate, changedDate)) {
|
144
|
+
handleChange(changedDate);
|
128
145
|
}
|
129
146
|
};
|
130
147
|
return /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, attributes, {
|
148
|
+
invalid: !!error,
|
131
149
|
className: cn({
|
132
150
|
'[&_input]:!yt-focus-dark': isCellInDetailMode
|
133
151
|
}),
|
134
152
|
onChange: handleDatepickerChange,
|
135
|
-
|
153
|
+
onFocus: handleFocus,
|
154
|
+
onKeyDown: handleInputKeyDown,
|
136
155
|
ref: refCallback,
|
137
156
|
value: value
|
138
157
|
}));
|
@@ -140,23 +159,28 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
140
159
|
return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
|
141
160
|
checked: Boolean(value),
|
142
161
|
onChange: handleChange,
|
162
|
+
onFocus: handleFocus,
|
143
163
|
ref: refCallback
|
144
164
|
}));
|
145
165
|
} else if (controlRenderer === 'textarea') {
|
146
166
|
return /*#__PURE__*/React__default.createElement(TextareaControl, Object.assign({}, props, {
|
167
|
+
invalid: !!error,
|
147
168
|
isCellInDetailMode: isCellInDetailMode,
|
169
|
+
onFocus: handleFocus,
|
148
170
|
onKeyDown: handleInputKeyDown,
|
149
171
|
ref: refCallback,
|
150
172
|
fontSize: tableMeta.fontSize.size
|
151
173
|
}));
|
152
174
|
}
|
153
175
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
|
176
|
+
invalid: !!error,
|
154
177
|
className: cn(getInputAppearanceClassnames(), getCellAlignmentClasses(align), {
|
155
178
|
'!yt-focus-dark': isCellInDetailMode
|
156
179
|
}),
|
157
180
|
onChange: event => {
|
158
181
|
handleChange(event.target.value);
|
159
182
|
},
|
183
|
+
onFocus: handleFocus,
|
160
184
|
onKeyDown: handleInputKeyDown,
|
161
185
|
ref: refCallback,
|
162
186
|
type: isNumber ? 'number' : undefined,
|