@economic/taco 2.9.1 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +2 -3
- 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/EditingCell.js +2 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +2 -5
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +1 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +4 -8
- 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/useShortcutsListener.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +1 -1
- package/dist/taco.cjs.development.js +14 -24
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/types.json +6 -23
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { TableStrategy } from '../../types';
|
3
3
|
declare type CurrentRowHandlerCallback = TableStrategy['scrollToIndex'];
|
4
|
-
export declare function useCurrentRow(defaultCurrentRowIndex
|
5
|
-
currentRowIndex: number
|
6
|
-
setCurrentRowIndex: React.Dispatch<React.SetStateAction<number
|
4
|
+
export declare function useCurrentRow(defaultCurrentRowIndex?: number | undefined): {
|
5
|
+
currentRowIndex: number;
|
6
|
+
setCurrentRowIndex: React.Dispatch<React.SetStateAction<number>>;
|
7
7
|
handleKeyDown: (event: KeyboardEvent, length: number, scrollToIndex: CurrentRowHandlerCallback) => void;
|
8
8
|
};
|
9
9
|
export {};
|
@@ -4,7 +4,7 @@ import { DisplayCell } from './DisplayCell.js';
|
|
4
4
|
import { EditingCell } from './EditingCell.js';
|
5
5
|
|
6
6
|
function Cell(props) {
|
7
|
-
var _rows$
|
7
|
+
var _rows$tableMeta$curre;
|
8
8
|
const {
|
9
9
|
column,
|
10
10
|
row,
|
@@ -16,8 +16,7 @@ function Cell(props) {
|
|
16
16
|
const rows = table.getRowModel().rows;
|
17
17
|
const tableMeta = table.options.meta;
|
18
18
|
const columnMeta = column.columnDef.meta;
|
19
|
-
const
|
20
|
-
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
19
|
+
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
21
20
|
if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
|
22
21
|
return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props));
|
23
22
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport { useRowContext } from '../../rows/RowContext';\n\nexport type CellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function Cell<TType = unknown>(props: CellProps<TType>) {\n const { column, row, table } = props;\n const { isHovered: isHoveredRow } = useRowContext();\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const
|
1
|
+
{"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport { useRowContext } from '../../rows/RowContext';\n\nexport type CellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function Cell<TType = unknown>(props: CellProps<TType>) {\n const { column, row, table } = props;\n const { isHovered: isHoveredRow } = useRowContext();\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const isCurrentRow = rows[tableMeta.currentRow.currentRowIndex]?.id === row.id;\n\n if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || (isHoveredRow && !tableMeta.hoverState.isPaused))) {\n return <EditingCell {...props} />;\n }\n\n return <DisplayCell {...props} />;\n}\n"],"names":["Cell","props","column","row","table","isHovered","isHoveredRow","useRowContext","rows","getRowModel","tableMeta","options","meta","columnMeta","columnDef","isCurrentRow","_rows$tableMeta$curre","currentRow","currentRowIndex","id","editing","isEditing","control","hoverState","isPaused","React","EditingCell","DisplayCell"],"mappings":";;;;;SAUgBA,IAAIA,CAAkBC,KAAuB;;EACzD,MAAM;IAAEC,MAAM;IAAEC,GAAG;IAAEC;GAAO,GAAGH,KAAK;EACpC,MAAM;IAAEI,SAAS,EAAEC;GAAc,GAAGC,aAAa,EAAE;EACnD,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA0B;EAC1D,MAAMC,UAAU,GAAGX,MAAM,CAACY,SAAS,CAACF,IAAkC;EAEtE,MAAMG,YAAY,GAAG,EAAAC,qBAAA,GAAAR,IAAI,CAACE,SAAS,CAACO,UAAU,CAACC,eAAe,CAAC,cAAAF,qBAAA,uBAA1CA,qBAAA,CAA4CG,EAAE,MAAKhB,GAAG,CAACgB,EAAE;EAE9E,IAAIT,SAAS,CAACU,OAAO,CAACC,SAAS,IAAIR,UAAU,CAACS,OAAO,KAAKP,YAAY,IAAKT,YAAY,IAAI,CAACI,SAAS,CAACa,UAAU,CAACC,QAAS,CAAC,EAAE;IACzH,oBAAOC,6BAACC,WAAW,oBAAKzB,KAAK,EAAI;;EAGrC,oBAAOwB,6BAACE,WAAW,oBAAK1B,KAAK,EAAI;AACrC;;;;"}
|
@@ -20,7 +20,7 @@ function EditingCell(props) {
|
|
20
20
|
}));
|
21
21
|
}
|
22
22
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
23
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$
|
23
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$curre, _column$columnDef$met;
|
24
24
|
const {
|
25
25
|
cell,
|
26
26
|
column,
|
@@ -72,8 +72,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
72
72
|
// row move indicator
|
73
73
|
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
74
74
|
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;
|
75
|
+
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
77
76
|
const mountNode = React__default.useMemo(() => {
|
78
77
|
if (moveReason) {
|
79
78
|
var _cellRef$current2, _cellRef$current2$par;
|
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 =\n 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 '!px-[0.4375rem] py-[calc(var(--table3-row-padding)_-_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 // we alias to any because className conflicts with the Table2 definition,\n // when Table2 is gone, remove this as any\n typeof columnMeta.className === 'function' ? (columnMeta.className as any)(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 className={className} data-align={columnMeta.align} data-column-index={index} role=\"cell\" 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,KAAoC;;EACjH,MAAM;IAAEU,IAAI;IAAEC,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAET,KAAK;IAAEU,QAAQ;IAAEC,GAAG;IAAEd,SAAS;IAAEE;GAAW,GAAGH,KAAK;EAC3F,MAAMgB,UAAU,GAAGL,MAAM,CAACM,SAAS,CAACX,IAAkC;EAEtE,MAAMY,OAAO,GAAGX,cAAK,CAACY,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,UAAU,GAAGb,cAAK,CAACY,MAAM,CAAc,IAAI,CAAC;EAElD,MAAME,YAAY,GAAIC,KAAc,IAAKnB,SAAS,CAACoB,OAAO,CAACC,YAAY,CAACd,IAAI,EAAEY,KAAK,CAAC;EACpF,MAAMA,KAAK,IAAAG,qBAAA,GAAGtB,SAAS,CAACoB,OAAO,CAACG,YAAY,CAAChB,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,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 { 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 isCurrentRow = rows[tableMeta.currentRow.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 '!px-[0.4375rem] py-[calc(var(--table3-row-padding)_-_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 // we alias to any because className conflicts with the Table2 definition,\n // when Table2 is gone, remove this as any\n typeof columnMeta.className === 'function' ? (columnMeta.className as any)(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 className={className} data-align={columnMeta.align} data-column-index={index} role=\"cell\" 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","isCurrentRow","_rows$tableMeta$curre","currentRow","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,KAAoC;;EACjH,MAAM;IAAEU,IAAI;IAAEC,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAET,KAAK;IAAEU,QAAQ;IAAEC,GAAG;IAAEd,SAAS;IAAEE;GAAW,GAAGH,KAAK;EAC3F,MAAMgB,UAAU,GAAGL,MAAM,CAACM,SAAS,CAACX,IAAkC;EAEtE,MAAMY,OAAO,GAAGX,cAAK,CAACY,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,UAAU,GAAGb,cAAK,CAACY,MAAM,CAAc,IAAI,CAAC;EAElD,MAAME,YAAY,GAAIC,KAAc,IAAKnB,SAAS,CAACoB,OAAO,CAACC,YAAY,CAACd,IAAI,EAA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AC,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,6 +1,6 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
|
3
|
-
function useCurrentRow(defaultCurrentRowIndex) {
|
3
|
+
function useCurrentRow(defaultCurrentRowIndex = 0) {
|
4
4
|
const [currentRowIndex, setCurrentRowIndex] = React__default.useState(defaultCurrentRowIndex);
|
5
5
|
const move = (direction, length, scrollToIndex) => setCurrentRowIndex(currentIndex => {
|
6
6
|
const nextIndex = currentIndex !== undefined ? getNextIndex(direction, currentIndex, length) : 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCurrentRow.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useCurrentRow.ts"],"sourcesContent":["import React from 'react';\nimport { TableStrategy } from '../../types';\n\ntype CurrentRowHandlerCallback = TableStrategy['scrollToIndex'];\n\nexport function useCurrentRow(defaultCurrentRowIndex: number | undefined) {\n const [currentRowIndex, setCurrentRowIndex] = React.useState<number
|
1
|
+
{"version":3,"file":"useCurrentRow.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useCurrentRow.ts"],"sourcesContent":["import React from 'react';\nimport { TableStrategy } from '../../types';\n\ntype CurrentRowHandlerCallback = TableStrategy['scrollToIndex'];\n\nexport function useCurrentRow(defaultCurrentRowIndex: number | undefined = 0) {\n const [currentRowIndex, setCurrentRowIndex] = React.useState<number>(defaultCurrentRowIndex);\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: CurrentRowHandlerCallback) =>\n setCurrentRowIndex(currentIndex => {\n const nextIndex = currentIndex !== undefined ? getNextIndex(direction, currentIndex, length) : 0;\n scrollToIndex(direction === -1 ? nextIndex : nextIndex + 3);\n return nextIndex;\n });\n const moveUp = (length: number, callback: CurrentRowHandlerCallback) => move(-1, length, callback);\n const moveDown = (length: number, callback: CurrentRowHandlerCallback) => move(1, length, callback);\n\n const onKeyDown = React.useCallback((event: KeyboardEvent, length: number, scrollToIndex: CurrentRowHandlerCallback) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveUp(length, scrollToIndex);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveDown(length, scrollToIndex);\n }\n\n return;\n }\n }, []);\n\n return {\n currentRowIndex,\n setCurrentRowIndex,\n handleKeyDown: onKeyDown,\n };\n}\n\nconst getNextIndex = (direction: -1 | 1, currentIndex: number, length: number) => {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n};\n"],"names":["useCurrentRow","defaultCurrentRowIndex","currentRowIndex","setCurrentRowIndex","React","useState","move","direction","length","scrollToIndex","currentIndex","nextIndex","undefined","getNextIndex","moveUp","callback","moveDown","onKeyDown","useCallback","event","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex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AAK,CAACG,cAAc,EAAE;MAEtB,IAAIH,KAAK,CAACI,OAAO,IAAIJ,KAAK,CAACK,OAAO,EAAE;QAChC,MAAMC,QAAQ,GAAGjB,MAAM,GAAG,CAAC;QAC3BL,kBAAkB,CAACsB,QAAQ,CAAC;QAC5BhB,aAAa,CAACgB,QAAQ,CAAC;OAC1B,MAAM;QACHT,QAAQ,CAACR,MAAM,EAAEC,aAAa,CAAC;;MAGnC;;GAEP,EAAE,EAAE,CAAC;EAEN,OAAO;IACHP,eAAe;IACfC,kBAAkB;IAClBuB,aAAa,EAAET;GAClB;AACL;AAEA,MAAMJ,YAAY,GAAGA,CAACN,SAAiB,EAAEG,YAAoB,EAAEF,MAAc;EACzE,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOG,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGF,MAAM,GAAGE,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE,CAAC;;;;"}
|
@@ -9,7 +9,7 @@ function useRowClick(onRowClick) {
|
|
9
9
|
const tableMeta = table.options.meta;
|
10
10
|
if (event.key === 'Enter') {
|
11
11
|
event.preventDefault();
|
12
|
-
if (onRowClick
|
12
|
+
if (onRowClick) {
|
13
13
|
onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
|
14
14
|
}
|
15
15
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRowClick.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowClick.ts"],"sourcesContent":["import React from 'react';\nimport { Table3RowClickHandler } from '../../types';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowClick<TType = unknown>(onRowClick?: Table3RowClickHandler<TType>) {\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, table: RTable<TType>) => {\n if (typeof onRowClick !== 'function' || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (onRowClick
|
1
|
+
{"version":3,"file":"useRowClick.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowClick.ts"],"sourcesContent":["import React from 'react';\nimport { Table3RowClickHandler } from '../../types';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowClick<TType = unknown>(onRowClick?: Table3RowClickHandler<TType>) {\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, table: RTable<TType>) => {\n if (typeof onRowClick !== 'function' || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (onRowClick) {\n onRowClick(rows[tableMeta.currentRow.currentRowIndex].original as TType);\n }\n\n return;\n }\n },\n [onRowClick]\n ) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n handleClick: onRowClick,\n };\n}\n"],"names":["useRowClick","onRowClick","onKeyDown","React","useCallback","event","table","defaultPrevented","rows","getRowModel","tableMeta","options","meta","key","preventDefault","currentRow","currentRowIndex","original","handleKeyDown","handleClick"],"mappings":";;SAIgBA,WAAWA,CAAkBC,UAAyC;EAClF,MAAMC,SAAS,GAAGC,cAAK,CAACC,WAAW,CAC/B,CAACC,KAAoB,EAAEC,KAAoB;IACvC,IAAI,OAAOL,UAAU,KAAK,UAAU,IAAII,KAAK,CAACE,gBAAgB,EAAE;MAC5D;;IAGJ,MAAMC,IAAI,GAAGF,KAAK,CAACG,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;IAExD,IAAIP,KAAK,CAACQ,GAAG,KAAK,OAAO,EAAE;MACvBR,KAAK,CAACS,cAAc,EAAE;MAEtB,IAAIb,UAAU,EAAE;QACZA,UAAU,CAACO,IAAI,CAACE,SAAS,CAACK,UAAU,CAACC,eAAe,CAAC,CAACC,QAAiB,CAAC;;MAG5E;;GAEP,EACD,CAAChB,UAAU,CAAC,CAC0D;EAE1E,OAAO;IACHiB,aAAa,EAAEhB,SAAS;IACxBiB,WAAW,EAAElB;GAChB;AACL;;;;"}
|
@@ -9,12 +9,9 @@ function useRowSelection() {
|
|
9
9
|
const rows = table.getRowModel().rows;
|
10
10
|
const tableMeta = table.options.meta;
|
11
11
|
if (event.key === ' ') {
|
12
|
+
var _rows$tableMeta$curre;
|
12
13
|
event.preventDefault();
|
13
|
-
|
14
|
-
if (currentRowIndex !== undefined) {
|
15
|
-
var _rows$currentRowIndex;
|
16
|
-
(_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
|
17
|
-
}
|
14
|
+
(_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.toggleSelected();
|
18
15
|
return;
|
19
16
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
20
17
|
event.preventDefault();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRowSelection.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowSelection() {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(<TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => {\n if (!table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n
|
1
|
+
{"version":3,"file":"useRowSelection.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowSelection() {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(<TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => {\n if (!table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n rows[tableMeta.currentRow.currentRowIndex]?.toggleSelected();\n return;\n } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {\n event.preventDefault();\n table.toggleAllRowsSelected();\n return;\n }\n }, []) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n lastSelectedRowIndex,\n };\n}\n"],"names":["useRowSelection","lastSelectedRowIndex","React","useRef","onKeyDown","useCallback","event","table","options","enableRowSelection","defaultPrevented","rows","getRowModel","tableMeta","meta","key","_rows$tableMeta$curre","preventDefault","currentRow","currentRowIndex","toggleSelected","ctrlKey","metaKey","toggleAllRowsSelected","handleKeyDown"],"mappings":";;SAGgBA,eAAeA;EAC3B,MAAMC,oBAAoB,GAAGC,cAAK,CAACC,MAAM,EAAU;EAEnD,MAAMC,SAAS,GAAGF,cAAK,CAACG,WAAW,CAAC,CAAkBC,KAAoB,EAAEC,KAAoB;IAC5F,IAAI,CAACA,KAAK,CAACC,OAAO,CAACC,kBAAkB,IAAIH,KAAK,CAACI,gBAAgB,EAAE;MAC7D;;IAGJ,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGN,KAAK,CAACC,OAAO,CAACM,IAAwB;IAExD,IAAIR,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAAA,IAAAC,qBAAA;MACnBV,KAAK,CAACW,cAAc,EAAE;MACtB,CAAAD,qBAAA,GAAAL,IAAI,CAACE,SAAS,CAACK,UAAU,CAACC,eAAe,CAAC,cAAAH,qBAAA,uBAA1CA,qBAAA,CAA4CI,cAAc,EAAE;MAC5D;KACH,MAAM,IAAI,CAACd,KAAK,CAACe,OAAO,IAAIf,KAAK,CAACgB,OAAO,KAAKhB,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAC9DT,KAAK,CAACW,cAAc,EAAE;MACtBV,KAAK,CAACgB,qBAAqB,EAAE;MAC7B;;GAEP,EAAE,EAAE,CAA0E;EAE/E,OAAO;IACHC,aAAa,EAAEpB,SAAS;IACxBH;GACH;AACL;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js
CHANGED
@@ -4,8 +4,7 @@ function useCurrentRowListener(table) {
|
|
4
4
|
const meta = table.options.meta;
|
5
5
|
const rows = table.getRowModel().rows;
|
6
6
|
React__default.useEffect(() => {
|
7
|
-
|
8
|
-
if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
|
7
|
+
if (meta.currentRow.currentRowIndex > rows.length) {
|
9
8
|
meta.currentRow.setCurrentRowIndex(0);
|
10
9
|
}
|
11
10
|
}, [rows.length]);
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCurrentRowListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useCurrentRowListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useCurrentRowListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n
|
1
|
+
{"version":3,"file":"useCurrentRowListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useCurrentRowListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useCurrentRowListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n if (meta.currentRow.currentRowIndex > rows.length) {\n meta.currentRow.setCurrentRowIndex(0);\n }\n }, [rows.length]);\n}\n"],"names":["useCurrentRowListener","table","meta","options","rows","getRowModel","React","useEffect","currentRow","currentRowIndex","length","setCurrentRowIndex"],"mappings":";;SAGgBA,qBAAqBA,CAAkBC,KAAoB;EACvE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;EACnD,MAAME,IAAI,GAAGH,KAAK,CAACI,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIL,IAAI,CAACM,UAAU,CAACC,eAAe,GAAGL,IAAI,CAACM,MAAM,EAAE;MAC/CR,IAAI,CAACM,UAAU,CAACG,kBAAkB,CAAC,CAAC,CAAC;;GAE5C,EAAE,CAACP,IAAI,CAACM,MAAM,CAAC,CAAC;AACrB;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js
CHANGED
@@ -12,14 +12,10 @@ function useEditingStateListener(table) {
|
|
12
12
|
}, [meta.currentRow.currentRowIndex]);
|
13
13
|
// save if editing gets toggled off
|
14
14
|
React__default.useEffect(() => {
|
15
|
-
if (meta.editing.isEnabled) {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
});
|
20
|
-
} else if (meta.currentRow.currentRowIndex === undefined) {
|
21
|
-
meta.currentRow.setCurrentRowIndex(0);
|
22
|
-
}
|
15
|
+
if (meta.editing.isEnabled && !meta.editing.isEditing) {
|
16
|
+
requestAnimationFrame(() => {
|
17
|
+
meta.editing.saveChangesIfNeeded();
|
18
|
+
});
|
23
19
|
}
|
24
20
|
}, [meta.editing.isEditing]);
|
25
21
|
}
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useEditingStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useEditingStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useEditingStateListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n\n // save when the row changes\n React.useEffect(() => {\n if (meta.editing.isEnabled && meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.currentRow.currentRowIndex]);\n\n // save if editing gets toggled off\n React.useEffect(() => {\n if (meta.editing.isEnabled
|
1
|
+
{"version":3,"file":"useEditingStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useEditingStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useEditingStateListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n\n // save when the row changes\n React.useEffect(() => {\n if (meta.editing.isEnabled && meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.currentRow.currentRowIndex]);\n\n // save if editing gets toggled off\n React.useEffect(() => {\n if (meta.editing.isEnabled && !meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.editing.isEditing]);\n}\n"],"names":["useEditingStateListener","table","meta","options","React","useEffect","editing","isEnabled","isEditing","requestAnimationFrame","saveChangesIfNeeded","currentRow","currentRowIndex"],"mappings":";;SAGgBA,uBAAuBA,CAAkBC,KAAoB;EACzE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;;EAGnDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,IAAIL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;MAClDC,qBAAqB,CAAC;QAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;OACrC,CAAC;;GAET,EAAE,CAACR,IAAI,CAACS,UAAU,CAACC,eAAe,CAAC,CAAC;;EAGrCR,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,IAAI,CAACL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;MACnDC,qBAAqB,CAAC;QAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;OACrC,CAAC;;GAET,EAAE,CAACR,IAAI,CAACI,OAAO,CAACE,SAAS,CAAC,CAAC;AAChC;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js
CHANGED
@@ -8,7 +8,7 @@ function useShortcutsListener(table, shortcuts) {
|
|
8
8
|
const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
|
9
9
|
const globalHandlers = [];
|
10
10
|
// convert the shortcut into the correct format to register it
|
11
|
-
if (shortcuts && shortcutKeys.length
|
11
|
+
if (shortcuts && shortcutKeys.length) {
|
12
12
|
const currentRow = rows[meta.currentRow.currentRowIndex];
|
13
13
|
shortcutKeys.forEach(key => {
|
14
14
|
const handler = shortcuts[key];
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useShortcutsListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta, Table as RTable } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { Table3ShortcutHandlerObject, Table3Shortcuts } from '../../types';\n\nexport function useShortcutsListener<TType = unknown>(table: RTable<TType>, shortcuts: Table3Shortcuts<TType> | undefined) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length
|
1
|
+
{"version":3,"file":"useShortcutsListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta, Table as RTable } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { Table3ShortcutHandlerObject, Table3Shortcuts } from '../../types';\n\nexport function useShortcutsListener<TType = unknown>(table: RTable<TType>, shortcuts: Table3Shortcuts<TType> | undefined) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length) {\n const currentRow = rows[meta.currentRow.currentRowIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as Table3ShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(currentRow?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.currentRow.currentRowIndex, rows.length]);\n}\n"],"names":["useShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","currentRow","currentRowIndex","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,oBAAoBA,CAAkBC,KAAoB,EAAEC,SAA6C;EACrH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IACjD,MAAMU,cAAc,GAA0C,EAAE;;IAGhE,IAAIV,SAAS,IAAIO,YAAY,CAACI,MAAM,EAAE;MAClC,MAAMC,UAAU,GAAGT,IAAI,CAACF,IAAI,CAACW,UAAU,CAACC,eAAe,CAAC;MAExDN,YAAY,CAACO,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGhB,SAAS,CAACe,GAAG,CAAC;QAE9B,IAAIE,cAAc;QAClB,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA6C;UACnEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHd,IAAI,EAAEkB,aAAa,CAAClB,IAAI;YACxBmB,KAAK,EAAED,aAAa,CAACC;WACxB;;QAGLV,cAAc,CAACW,IAAI,CACfC,4BAA4B,CAACJ,qBAAqB,EAAEK,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBP,cAAc,CAACL,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEa,QAAQ,CAAC;SACvC,CAAC,CACL;OACJ,CAAC;;IAGNf,cAAc,CAACI,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHN,cAAc,CAACI,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAAChB,SAAS,EAAEC,IAAI,CAACW,UAAU,CAACC,eAAe,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AACjE;;;;"}
|
@@ -16652,7 +16652,7 @@ const useCssGrid = (table, isPrintTable = false) => {
|
|
16652
16652
|
};
|
16653
16653
|
};
|
16654
16654
|
|
16655
|
-
function useCurrentRow(defaultCurrentRowIndex) {
|
16655
|
+
function useCurrentRow(defaultCurrentRowIndex = 0) {
|
16656
16656
|
const [currentRowIndex, setCurrentRowIndex] = React__default.useState(defaultCurrentRowIndex);
|
16657
16657
|
const move = (direction, length, scrollToIndex) => setCurrentRowIndex(currentIndex => {
|
16658
16658
|
const nextIndex = currentIndex !== undefined ? getNextIndex$2(direction, currentIndex, length) : 0;
|
@@ -17072,8 +17072,7 @@ function useCurrentRowListener(table) {
|
|
17072
17072
|
const meta = table.options.meta;
|
17073
17073
|
const rows = table.getRowModel().rows;
|
17074
17074
|
React__default.useEffect(() => {
|
17075
|
-
|
17076
|
-
if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
|
17075
|
+
if (meta.currentRow.currentRowIndex > rows.length) {
|
17077
17076
|
meta.currentRow.setCurrentRowIndex(0);
|
17078
17077
|
}
|
17079
17078
|
}, [rows.length]);
|
@@ -17184,12 +17183,9 @@ function useRowSelection() {
|
|
17184
17183
|
const rows = table.getRowModel().rows;
|
17185
17184
|
const tableMeta = table.options.meta;
|
17186
17185
|
if (event.key === ' ') {
|
17186
|
+
var _rows$tableMeta$curre;
|
17187
17187
|
event.preventDefault();
|
17188
|
-
|
17189
|
-
if (currentRowIndex !== undefined) {
|
17190
|
-
var _rows$currentRowIndex;
|
17191
|
-
(_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
|
17192
|
-
}
|
17188
|
+
(_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.toggleSelected();
|
17193
17189
|
return;
|
17194
17190
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
17195
17191
|
event.preventDefault();
|
@@ -17212,7 +17208,7 @@ function useRowClick(onRowClick) {
|
|
17212
17208
|
const tableMeta = table.options.meta;
|
17213
17209
|
if (event.key === 'Enter') {
|
17214
17210
|
event.preventDefault();
|
17215
|
-
if (onRowClick
|
17211
|
+
if (onRowClick) {
|
17216
17212
|
onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
|
17217
17213
|
}
|
17218
17214
|
return;
|
@@ -17991,7 +17987,7 @@ function EditingCell$1(props) {
|
|
17991
17987
|
}));
|
17992
17988
|
}
|
17993
17989
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
17994
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$
|
17990
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$curre, _column$columnDef$met;
|
17995
17991
|
const {
|
17996
17992
|
cell,
|
17997
17993
|
column,
|
@@ -18043,8 +18039,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18043
18039
|
// row move indicator
|
18044
18040
|
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
18045
18041
|
const rows = table.getRowModel().rows;
|
18046
|
-
const
|
18047
|
-
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18042
|
+
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
18048
18043
|
const mountNode = React__default.useMemo(() => {
|
18049
18044
|
if (moveReason) {
|
18050
18045
|
var _cellRef$current2, _cellRef$current2$par;
|
@@ -18134,7 +18129,7 @@ function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
|
|
18134
18129
|
}
|
18135
18130
|
|
18136
18131
|
function Cell$3(props) {
|
18137
|
-
var _rows$
|
18132
|
+
var _rows$tableMeta$curre;
|
18138
18133
|
const {
|
18139
18134
|
column,
|
18140
18135
|
row,
|
@@ -18146,8 +18141,7 @@ function Cell$3(props) {
|
|
18146
18141
|
const rows = table.getRowModel().rows;
|
18147
18142
|
const tableMeta = table.options.meta;
|
18148
18143
|
const columnMeta = column.columnDef.meta;
|
18149
|
-
const
|
18150
|
-
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18144
|
+
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
18151
18145
|
if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
|
18152
18146
|
return /*#__PURE__*/React__default.createElement(EditingCell$1, Object.assign({}, props));
|
18153
18147
|
}
|
@@ -18566,7 +18560,7 @@ function useShortcutsListener(table, shortcuts) {
|
|
18566
18560
|
const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
|
18567
18561
|
const globalHandlers = [];
|
18568
18562
|
// convert the shortcut into the correct format to register it
|
18569
|
-
if (shortcuts && shortcutKeys.length
|
18563
|
+
if (shortcuts && shortcutKeys.length) {
|
18570
18564
|
const currentRow = rows[meta.currentRow.currentRowIndex];
|
18571
18565
|
shortcutKeys.forEach(key => {
|
18572
18566
|
const handler = shortcuts[key];
|
@@ -18634,14 +18628,10 @@ function useEditingStateListener(table) {
|
|
18634
18628
|
}, [meta.currentRow.currentRowIndex]);
|
18635
18629
|
// save if editing gets toggled off
|
18636
18630
|
React__default.useEffect(() => {
|
18637
|
-
if (meta.editing.isEnabled) {
|
18638
|
-
|
18639
|
-
|
18640
|
-
|
18641
|
-
});
|
18642
|
-
} else if (meta.currentRow.currentRowIndex === undefined) {
|
18643
|
-
meta.currentRow.setCurrentRowIndex(0);
|
18644
|
-
}
|
18631
|
+
if (meta.editing.isEnabled && !meta.editing.isEditing) {
|
18632
|
+
requestAnimationFrame(() => {
|
18633
|
+
meta.editing.saveChangesIfNeeded();
|
18634
|
+
});
|
18645
18635
|
}
|
18646
18636
|
}, [meta.editing.isEditing]);
|
18647
18637
|
}
|