@economic/taco 2.20.1 → 2.20.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Cell as RTCell } from '@tanstack/react-table';
3
- import { Table3SaveHandler } from '../../types';
3
+ import { Table3Ref, Table3SaveHandler } from '../../types';
4
4
  import { IndicatorReason } from '../../components/columns/cell/Indicator';
5
5
  import { Table3Validation } from './useValidation';
6
6
  export declare enum SavingStatusValue {
@@ -8,7 +8,7 @@ export declare enum SavingStatusValue {
8
8
  Saved = "saved",
9
9
  Error = "error"
10
10
  }
11
- export declare function useEditing<TType = unknown>(isEnabled: boolean, validation: Table3Validation<TType>, onSave?: Table3SaveHandler<TType>): {
11
+ export declare function useEditing<TType = unknown>(isEnabled: boolean, tableRef: React.RefObject<Table3Ref>, validation: Table3Validation<TType>, onSave?: Table3SaveHandler<TType>): {
12
12
  isEnabled: boolean;
13
13
  isEditing: boolean;
14
14
  toggleEditing: React.Dispatch<React.SetStateAction<boolean>>;
@@ -2,7 +2,7 @@
2
2
  import { ColumnOrderState, ColumnSizingState, SortingState, VisibilityState, BuiltInSortingFn } from '@tanstack/react-table';
3
3
  import { MenuProps } from '../Menu/Menu';
4
4
  import { MenuItemProps } from '../Menu/components/Item';
5
- import { TableColumnFilter, TableColumnRendererControl, TableColumnSort, TableFilterHandler, TableRef, TableRowClickHandler, TableRowGotoHandler, TableRowHeight, TableRowSelectHandler, TableServerLoadAllHandler, TableServerLoadPageHandler, TableSortHandler } from '../../primitives/Table/types';
5
+ import { TableColumnFilter, TableColumnRendererControl, TableColumnRendererControlProps, TableColumnSort, TableFilterHandler, TableRef, TableRowClickHandler, TableRowGotoHandler, TableRowHeight, TableRowSelectHandler, TableServerLoadAllHandler, TableServerLoadPageHandler, TableSortHandler } from '../../primitives/Table/types';
6
6
  import { FontSize, ValueOf } from '../../types';
7
7
  export declare type Table3SortDirection = 'asc' | 'desc';
8
8
  export declare type Table3SortFn<TType = unknown> = ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1) | BuiltInSortingFn | 'auto';
@@ -12,18 +12,7 @@ export declare type Table3ColumnClassNameHandler<TType = unknown> = string | ((r
12
12
  export declare type Table3ColumnAlignment = 'left' | 'center' | 'right';
13
13
  export declare type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';
14
14
  export declare type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;
15
- export declare type Table3ColumnControlProps = {
16
- className?: string;
17
- disabled?: boolean;
18
- fontSize?: FontSize;
19
- invalid?: boolean;
20
- onBlur?: (value: any) => void;
21
- onFocus?: React.FocusEventHandler;
22
- readOnly?: boolean;
23
- ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);
24
- setValue: (value: any) => void;
25
- value: any;
26
- };
15
+ export declare type Table3ColumnControlProps = TableColumnRendererControlProps;
27
16
  export declare type Table3ColumnControlRenderer<TType = unknown> = TableColumnRendererControl<TType>;
28
17
  export declare type Table3ColumnProps<TType = unknown> = ValueOf<{
29
18
  [K in keyof TType]: {
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { shouldTriggerShortcut } from '../../../../utils/keyboard.js';
3
+ import { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom.js';
3
4
  import _ from 'lodash-es';
4
5
  import { lastCellIndex } from '../../components/rows/Row.js';
5
6
 
@@ -9,7 +10,7 @@ var SavingStatusValue;
9
10
  SavingStatusValue["Saved"] = "saved";
10
11
  SavingStatusValue["Error"] = "error";
11
12
  })(SavingStatusValue || (SavingStatusValue = {}));
12
- function useEditing(isEnabled, validation, onSave) {
13
+ function useEditing(isEnabled, tableRef, validation, onSave) {
13
14
  // used to switch the table into editing mode
14
15
  const [isEditing, setIsEditing] = React__default.useState(false);
15
16
  // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',
@@ -176,6 +177,20 @@ function useEditing(isEnabled, validation, onSave) {
176
177
  }
177
178
  return false;
178
179
  }, [isEditing, editingState]);
180
+ React__default.useEffect(() => {
181
+ const handleClickOutside = event => {
182
+ const target = event.target;
183
+ const closestPopup = target.closest('[role="dialog"], [role="menu"]');
184
+ // Need to check that neither target itself nor closest popup is inside or triggetred from the table.
185
+ if (!isElementInsideOrTriggeredFromContainer(target, tableRef.current) && !isElementInsideOrTriggeredFromContainer(closestPopup, tableRef.current)) {
186
+ saveChangesIfNeeded();
187
+ }
188
+ };
189
+ document.addEventListener('click', handleClickOutside);
190
+ return () => {
191
+ document.removeEventListener('click', handleClickOutside);
192
+ };
193
+ }, [saveChangesIfNeeded]);
179
194
  function getSavingStatus(rowId) {
180
195
  return savingStatuses && savingStatuses[rowId];
181
196
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useEditing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useEditing.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { Cell as RTCell } from '@tanstack/react-table';\n\nimport { Table3SaveHandler } from '../../types';\nimport { IndicatorReason } from '../../components/columns/cell/Indicator';\nimport { shouldTriggerShortcut } from '../../../../utils/keyboard';\nimport { Table3Validation } from './useValidation';\nimport { lastCellIndex } from '../../components/rows/Row';\n\nexport enum SavingStatusValue {\n Saving = 'saving',\n Saved = 'saved',\n Error = 'error',\n}\n\nexport function useEditing<TType = unknown>(\n isEnabled: boolean,\n validation: Table3Validation<TType>,\n onSave?: Table3SaveHandler<TType>\n) {\n // used to switch the table into editing mode\n const [isEditing, setIsEditing] = React.useState(false);\n // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',\n // 'saved' should remain for a few seconds to show tick icon after row has been saved.\n const [savingStatuses, dispatchSavingStatusAction] = React.useReducer(savingStatusesReducer, null);\n\n // sets of row changes pending save, either they have not saved yet or they have errors\n const [editingState, dispatchEditingAction] = React.useReducer((state: EditingState<TType>, action) => editingReducer<TType>(state, action), null);\n\n const [detailModeEditing, setDetailModeEditing] = React.useState(false);\n\n function getCellValue<T extends TType>(cell: RTCell<T, unknown>) {\n return editingState ? editingState[cell.row.id]?.[cell.column.id] : undefined;\n }\n\n // Saves editing cell value into editing state.\n function setCellValue<T extends TType>(cell: RTCell<T, unknown>, value: unknown) {\n dispatchEditingAction({\n type: EditingActionType.SET_CELL_VALUE,\n payload: { rowId: cell.row.id, cellId: cell.column.id, value, originalValues: cell.row.original },\n });\n }\n\n // Removes changes from editing state by row id\n function resetChange(rowId: string) {\n dispatchEditingAction({\n type: EditingActionType.RESET_CHANGE,\n payload: { rowId },\n });\n validation.resetErrors(rowId);\n }\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n setIsEditing(editing => !editing);\n } else if (shouldTriggerShortcut(event, { key: 's', meta: true, shift: false })) {\n // Prevent default browser save\n event.preventDefault();\n saveChangesIfNeeded();\n }\n },\n [isEditing]\n );\n\n const handleBlur = React.useCallback((event: React.FocusEvent) => {\n if (event.target === event.currentTarget) {\n saveChangesIfNeeded();\n }\n }, []);\n\n // Creates initial saving statuses from changes object\n const addSavingStatuses = () => {\n const changeset = Object.keys(editingState || {});\n const additionalSavingStatuses = _.reduce(\n changeset,\n (result, rowId) => {\n return { ...result, [rowId]: SavingStatusValue.Saving };\n },\n {}\n );\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUSES,\n payload: { states: additionalSavingStatuses },\n });\n };\n\n // Resets/removes saving status by row id. Used in delayed saving indicator.\n const resetSavingStatus = (rowId: string) => {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.RESET_SAVING_STATUS,\n payload: { rowId },\n });\n };\n\n // Checks if we have changes, then saves them\n const saveChangesIfNeeded = async () => {\n if (!editingState) {\n return;\n }\n\n const changeset = Object.keys(editingState);\n if (onSave && changeset.length) {\n addSavingStatuses();\n\n const responses = await Promise.allSettled(\n changeset.map(rowId => {\n const validationSavePromise = new Promise<void>((resolve, reject) => {\n const changedRow = editingState?.[rowId];\n if (changedRow) {\n validation\n .validate(rowId, changedRow)\n ?.then(() => {\n const savePromise = onSave(changedRow);\n savePromise\n .then(() => {\n resolve();\n })\n .catch(reason => {\n if (reason.errors) {\n validation.setRowErrors(rowId, reason.errors);\n }\n\n reject(reason);\n });\n })\n .catch(() => {\n validation.confirmErrors(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n reject();\n });\n } else {\n reject();\n }\n });\n return validationSavePromise;\n })\n );\n\n responses.forEach((response, index) => {\n const rowId = changeset[index];\n\n if (response.status === 'fulfilled') {\n resetChange(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Saved },\n });\n } else {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n }\n });\n }\n };\n\n const [rowMoveReason, setRowMoveReason] = React.useState<Record<string, IndicatorReason | null> | null>(null);\n\n const removeRowMoveReason = () => {\n setRowMoveReason(null);\n };\n\n const showWarning = React.useCallback(\n event => {\n if (isEditing && editingState && Object.keys(editingState).length > 0) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n },\n [isEditing, editingState]\n );\n\n function getSavingStatus(rowId: string) {\n return savingStatuses && savingStatuses[rowId];\n }\n\n React.useEffect(() => {\n window.addEventListener('beforeunload', showWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showWarning);\n };\n }, [showWarning]);\n\n React.useEffect(() => {\n if (!isEditing) {\n setDetailModeEditing(false);\n lastCellIndex.value = null;\n }\n }, [isEditing]);\n\n return {\n isEnabled,\n isEditing,\n toggleEditing: setIsEditing,\n changes: editingState,\n getCellValue,\n setCellValue,\n saveChangesIfNeeded,\n detailModeEditing,\n setDetailModeEditing,\n rowMoveReason,\n setRowMoveReason,\n removeRowMoveReason,\n handleKeyDown,\n handleBlur,\n resetChange,\n getSavingStatus,\n resetSavingStatus,\n };\n}\n\nenum EditingActionType {\n SET_CELL_VALUE,\n RESET_CHANGE,\n}\n\ntype EditingState<TType = unknown> = Record<string, TType> | null;\n\ntype EditingAction =\n | { type: EditingActionType.SET_CELL_VALUE; payload: { rowId: string; cellId: string; value: unknown; originalValues } }\n | {\n type: EditingActionType.RESET_CHANGE;\n payload: { rowId: string };\n };\n\nfunction editingReducer<TType = unknown>(state: EditingState<TType>, action: EditingAction): EditingState<TType> {\n switch (action.type) {\n // Set cell value of the row\n case EditingActionType.SET_CELL_VALUE:\n return {\n ...state,\n [action.payload.rowId]: {\n ...(state?.[action.payload.rowId] || action.payload.originalValues),\n [action.payload.cellId]: action.payload.value,\n },\n };\n\n // Reset changes for the row\n case EditingActionType.RESET_CHANGE: {\n let currentChanges: Record<string, TType> | null = { ...state };\n if (currentChanges) {\n delete currentChanges[action.payload.rowId];\n }\n const changeset = Object.keys(currentChanges);\n if (changeset.length === 0) {\n currentChanges = null;\n }\n return currentChanges;\n }\n\n default:\n return state;\n }\n}\n\nenum SavingStatusActionType {\n SET_SAVING_STATUS,\n SET_SAVING_STATUSES,\n RESET_SAVING_STATUS,\n}\n\ntype SavingStatus = Record<string, SavingStatusValue> | null;\n\ntype SavingStatusAction =\n | { type: SavingStatusActionType.SET_SAVING_STATUS; payload: { rowId: string; state: SavingStatusValue } }\n | { type: SavingStatusActionType.SET_SAVING_STATUSES; payload: { states: Record<string, SavingStatusValue> } }\n | { type: SavingStatusActionType.RESET_SAVING_STATUS; payload: { rowId: string } };\n\nfunction savingStatusesReducer(state: SavingStatus, action: SavingStatusAction): SavingStatus {\n switch (action.type) {\n // Set single saving status for the row\n case SavingStatusActionType.SET_SAVING_STATUS:\n return {\n ...state,\n [action.payload.rowId]: action.payload.state,\n };\n // Set multiple saving statuses for multiple rows at the same time\n case SavingStatusActionType.SET_SAVING_STATUSES:\n return {\n ...state,\n ...action.payload.states,\n };\n // Reset/remove saving status for particular row\n case SavingStatusActionType.RESET_SAVING_STATUS: {\n const newSavingStatus = { ...state };\n delete newSavingStatus?.[action.payload.rowId];\n return newSavingStatus;\n }\n\n default:\n return state;\n }\n}\n"],"names":["SavingStatusValue","useEditing","isEnabled","validation","onSave","isEditing","setIsEditing","React","useState","savingStatuses","dispatchSavingStatusAction","useReducer","savingStatusesReducer","editingState","dispatchEditingAction","state","action","editingReducer","detailModeEditing","setDetailModeEditing","getCellValue","cell","_editingState$cell$ro","row","id","column","undefined","setCellValue","value","type","EditingActionType","SET_CELL_VALUE","payload","rowId","cellId","originalValues","original","resetChange","RESET_CHANGE","resetErrors","handleKeyDown","useCallback","event","defaultPrevented","shouldTriggerShortcut","key","meta","shift","editing","preventDefault","saveChangesIfNeeded","handleBlur","target","currentTarget","addSavingStatuses","changeset","Object","keys","additionalSavingStatuses","_","reduce","result","Saving","SavingStatusActionType","SET_SAVING_STATUSES","states","resetSavingStatus","RESET_SAVING_STATUS","Promise","resolve","_temp","length","allSettled","map","validationSavePromise","reject","changedRow","_validation$validate","validate","then","savePromise","catch","reason","errors","setRowErrors","confirmErrors","SET_SAVING_STATUS","Error","responses","forEach","response","index","status","Saved","e","rowMoveReason","setRowMoveReason","removeRowMoveReason","showWarning","returnValue","getSavingStatus","useEffect","window","addEventListener","removeEventListener","lastCellIndex","toggleEditing","changes","currentChanges","newSavingStatus"],"mappings":";;;;;IAUYA;AAAZ,WAAYA,iBAAiB;EACzBA,sCAAiB;EACjBA,oCAAe;EACfA,oCAAe;AACnB,CAAC,EAJWA,iBAAiB,KAAjBA,iBAAiB;SAMbC,UAAUA,CACtBC,SAAkB,EAClBC,UAAmC,EACnCC,MAAiC;;EAGjC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAGvD,MAAM,CAACC,cAAc,EAAEC,0BAA0B,CAAC,GAAGH,cAAK,CAACI,UAAU,CAACC,qBAAqB,EAAE,IAAI,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IsE,cAAc,GAAiC;UAAE,GAAG7F;SAAO;QAC/D,IAAI6F,cAAc,EAAE;UAChB,OAAOA,cAAc,CAAC5F,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;;QAE/C,MAAMsB,SAAS,GAAGC,MAAM,CAACC,IAAI,CAACmD,cAAc,CAAC;QAC7C,IAAIrD,SAAS,CAACgB,MAAM,KAAK,CAAC,EAAE;UACxBqC,cAAc,GAAG,IAAI;;QAEzB,OAAOA,cAAc;;IAGzB;MACI,OAAO7F,KAAK;;AAExB;AAEA,IAAKgD,sBAIJ;AAJD,WAAKA,sBAAsB;EACvBA,6FAAiB;EACjBA,iGAAmB;EACnBA,iGAAmB;AACvB,CAAC,EAJIA,sBAAsB,KAAtBA,sBAAsB;AAa3B,SAASnD,qBAAqBA,CAACG,KAAmB,EAAEC,MAA0B;EAC1E,QAAQA,MAAM,CAACa,IAAI;;IAEf,KAAKkC,sBAAsB,CAACuB,iBAAiB;MACzC,OAAO;QACH,GAAGvE,KAAK;QACR,CAACC,MAAM,CAACgB,OAAO,CAACC,KAAK,GAAGjB,MAAM,CAACgB,OAAO,CAACjB;OAC1C;;IAEL,KAAKgD,sBAAsB,CAACC,mBAAmB;MAC3C,OAAO;QACH,GAAGjD,KAAK;QACR,GAAGC,MAAM,CAACgB,OAAO,CAACiC;OACrB;;IAEL,KAAKF,sBAAsB,CAACI,mBAAmB;MAAE;QAC7C,MAAM0C,eAAe,GAAG;UAAE,GAAG9F;SAAO;QAC7B8F,eAAe,aAAfA,eAAe,qBAAtB,OAAOA,eAAe,CAAG7F,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;QAC9C,OAAO4E,eAAe;;IAG1B;MACI,OAAO9F,KAAK;;AAExB;;;;"}
1
+ {"version":3,"file":"useEditing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useEditing.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { Cell as RTCell } from '@tanstack/react-table';\n\nimport { Table3Ref, Table3SaveHandler } from '../../types';\nimport { IndicatorReason } from '../../components/columns/cell/Indicator';\nimport { shouldTriggerShortcut } from '../../../../utils/keyboard';\nimport { Table3Validation } from './useValidation';\nimport { lastCellIndex } from '../../components/rows/Row';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport enum SavingStatusValue {\n Saving = 'saving',\n Saved = 'saved',\n Error = 'error',\n}\n\nexport function useEditing<TType = unknown>(\n isEnabled: boolean,\n tableRef: React.RefObject<Table3Ref>,\n validation: Table3Validation<TType>,\n onSave?: Table3SaveHandler<TType>\n) {\n // used to switch the table into editing mode\n const [isEditing, setIsEditing] = React.useState(false);\n // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',\n // 'saved' should remain for a few seconds to show tick icon after row has been saved.\n const [savingStatuses, dispatchSavingStatusAction] = React.useReducer(savingStatusesReducer, null);\n\n // sets of row changes pending save, either they have not saved yet or they have errors\n const [editingState, dispatchEditingAction] = React.useReducer(\n (state: EditingState<TType>, action) => editingReducer<TType>(state, action),\n null\n );\n\n const [detailModeEditing, setDetailModeEditing] = React.useState(false);\n\n function getCellValue<T extends TType>(cell: RTCell<T, unknown>) {\n return editingState ? editingState[cell.row.id]?.[cell.column.id] : undefined;\n }\n\n // Saves editing cell value into editing state.\n function setCellValue<T extends TType>(cell: RTCell<T, unknown>, value: unknown) {\n dispatchEditingAction({\n type: EditingActionType.SET_CELL_VALUE,\n payload: { rowId: cell.row.id, cellId: cell.column.id, value, originalValues: cell.row.original },\n });\n }\n\n // Removes changes from editing state by row id\n function resetChange(rowId: string) {\n dispatchEditingAction({\n type: EditingActionType.RESET_CHANGE,\n payload: { rowId },\n });\n validation.resetErrors(rowId);\n }\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n setIsEditing(editing => !editing);\n } else if (shouldTriggerShortcut(event, { key: 's', meta: true, shift: false })) {\n // Prevent default browser save\n event.preventDefault();\n saveChangesIfNeeded();\n }\n },\n [isEditing]\n );\n\n const handleBlur = React.useCallback((event: React.FocusEvent) => {\n if (event.target === event.currentTarget) {\n saveChangesIfNeeded();\n }\n }, []);\n\n // Creates initial saving statuses from changes object\n const addSavingStatuses = () => {\n const changeset = Object.keys(editingState || {});\n const additionalSavingStatuses = _.reduce(\n changeset,\n (result, rowId) => {\n return { ...result, [rowId]: SavingStatusValue.Saving };\n },\n {}\n );\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUSES,\n payload: { states: additionalSavingStatuses },\n });\n };\n\n // Resets/removes saving status by row id. Used in delayed saving indicator.\n const resetSavingStatus = (rowId: string) => {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.RESET_SAVING_STATUS,\n payload: { rowId },\n });\n };\n\n // Checks if we have changes, then saves them\n const saveChangesIfNeeded = async () => {\n if (!editingState) {\n return;\n }\n\n const changeset = Object.keys(editingState);\n if (onSave && changeset.length) {\n addSavingStatuses();\n\n const responses = await Promise.allSettled(\n changeset.map(rowId => {\n const validationSavePromise = new Promise<void>((resolve, reject) => {\n const changedRow = editingState?.[rowId];\n if (changedRow) {\n validation\n .validate(rowId, changedRow)\n ?.then(() => {\n const savePromise = onSave(changedRow);\n savePromise\n .then(() => {\n resolve();\n })\n .catch(reason => {\n if (reason.errors) {\n validation.setRowErrors(rowId, reason.errors);\n }\n\n reject(reason);\n });\n })\n .catch(() => {\n validation.confirmErrors(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n reject();\n });\n } else {\n reject();\n }\n });\n return validationSavePromise;\n })\n );\n\n responses.forEach((response, index) => {\n const rowId = changeset[index];\n\n if (response.status === 'fulfilled') {\n resetChange(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Saved },\n });\n } else {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n }\n });\n }\n };\n\n const [rowMoveReason, setRowMoveReason] = React.useState<Record<string, IndicatorReason | null> | null>(null);\n\n const removeRowMoveReason = () => {\n setRowMoveReason(null);\n };\n\n const showWarning = React.useCallback(\n event => {\n if (isEditing && editingState && Object.keys(editingState).length > 0) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n },\n [isEditing, editingState]\n );\n\n React.useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const closestPopup = target.closest('[role=\"dialog\"], [role=\"menu\"]');\n\n // Need to check that neither target itself nor closest popup is inside or triggetred from the table.\n if (\n !isElementInsideOrTriggeredFromContainer(target, tableRef.current) &&\n !isElementInsideOrTriggeredFromContainer(closestPopup, tableRef.current)\n ) {\n saveChangesIfNeeded();\n }\n };\n\n document.addEventListener('click', handleClickOutside);\n\n return () => {\n document.removeEventListener('click', handleClickOutside);\n };\n }, [saveChangesIfNeeded]);\n\n function getSavingStatus(rowId: string) {\n return savingStatuses && savingStatuses[rowId];\n }\n\n React.useEffect(() => {\n window.addEventListener('beforeunload', showWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showWarning);\n };\n }, [showWarning]);\n\n React.useEffect(() => {\n if (!isEditing) {\n setDetailModeEditing(false);\n lastCellIndex.value = null;\n }\n }, [isEditing]);\n\n return {\n isEnabled,\n isEditing,\n toggleEditing: setIsEditing,\n changes: editingState,\n getCellValue,\n setCellValue,\n saveChangesIfNeeded,\n detailModeEditing,\n setDetailModeEditing,\n rowMoveReason,\n setRowMoveReason,\n removeRowMoveReason,\n handleKeyDown,\n handleBlur,\n resetChange,\n getSavingStatus,\n resetSavingStatus,\n };\n}\n\nenum EditingActionType {\n SET_CELL_VALUE,\n RESET_CHANGE,\n}\n\ntype EditingState<TType = unknown> = Record<string, TType> | null;\n\ntype EditingAction =\n | { type: EditingActionType.SET_CELL_VALUE; payload: { rowId: string; cellId: string; value: unknown; originalValues } }\n | {\n type: EditingActionType.RESET_CHANGE;\n payload: { rowId: string };\n };\n\nfunction editingReducer<TType = unknown>(state: EditingState<TType>, action: EditingAction): EditingState<TType> {\n switch (action.type) {\n // Set cell value of the row\n case EditingActionType.SET_CELL_VALUE:\n return {\n ...state,\n [action.payload.rowId]: {\n ...(state?.[action.payload.rowId] || action.payload.originalValues),\n [action.payload.cellId]: action.payload.value,\n },\n };\n\n // Reset changes for the row\n case EditingActionType.RESET_CHANGE: {\n let currentChanges: Record<string, TType> | null = { ...state };\n if (currentChanges) {\n delete currentChanges[action.payload.rowId];\n }\n const changeset = Object.keys(currentChanges);\n if (changeset.length === 0) {\n currentChanges = null;\n }\n return currentChanges;\n }\n\n default:\n return state;\n }\n}\n\nenum SavingStatusActionType {\n SET_SAVING_STATUS,\n SET_SAVING_STATUSES,\n RESET_SAVING_STATUS,\n}\n\ntype SavingStatus = Record<string, SavingStatusValue> | null;\n\ntype SavingStatusAction =\n | { type: SavingStatusActionType.SET_SAVING_STATUS; payload: { rowId: string; state: SavingStatusValue } }\n | { type: SavingStatusActionType.SET_SAVING_STATUSES; payload: { states: Record<string, SavingStatusValue> } }\n | { type: SavingStatusActionType.RESET_SAVING_STATUS; payload: { rowId: string } };\n\nfunction savingStatusesReducer(state: SavingStatus, action: SavingStatusAction): SavingStatus {\n switch (action.type) {\n // Set single saving status for the row\n case SavingStatusActionType.SET_SAVING_STATUS:\n return {\n ...state,\n [action.payload.rowId]: action.payload.state,\n };\n // Set multiple saving statuses for multiple rows at the same time\n case SavingStatusActionType.SET_SAVING_STATUSES:\n return {\n ...state,\n ...action.payload.states,\n };\n // Reset/remove saving status for particular row\n case SavingStatusActionType.RESET_SAVING_STATUS: {\n const newSavingStatus = { ...state };\n delete newSavingStatus?.[action.payload.rowId];\n return newSavingStatus;\n }\n\n default:\n return state;\n }\n}\n"],"names":["SavingStatusValue","useEditing","isEnabled","tableRef","validation","onSave","isEditing","setIsEditing","React","useState","savingStatuses","dispatchSavingStatusAction","useReducer","savingStatusesReducer","editingState","dispatchEditingAction","state","action","editingReducer","detailModeEditing","setDetailModeEditing","getCellValue","cell","_editingState$cell$ro","row","id","column","undefined","setCellValue","value","type","EditingActionType","SET_CELL_VALUE","payload","rowId","cellId","originalValues","original","resetChange","RESET_CHANGE","resetErrors","handleKeyDown","useCallback","event","defaultPrevented","shouldTriggerShortcut","key","meta","shift","editing","preventDefault","saveChangesIfNeeded","handleBlur","target","currentTarget","addSavingStatuses","changeset","Object","keys","additionalSavingStatuses","_","reduce","result","Saving","SavingStatusActionType","SET_SAVING_STATUSES","states","resetSavingStatus","RESET_SAVING_STATUS","Promise","resolve","_temp","length","allSettled","map","validationSavePromise","reject","changedRow","_validation$validate","validate","then","savePromise","catch","reason","errors","setRowErrors","confirmErrors","SET_SAVING_STATUS","Error","responses","forEach","response","index","status","Saved","e","rowMoveReason","setRowMoveReason","removeRowMoveReason","showWarning","returnValue","useEffect","handleClickOutside","closestPopup","closest","isElementInsideOrTriggeredFromContainer","current","document","addEventListener","removeEventListener","getSavingStatus","window","lastCellIndex","toggleEditing","changes","currentChanges","newSavingStatus"],"mappings":";;;;;;IAWYA;AAAZ,WAAYA,iBAAiB;EACzBA,sCAAiB;EACjBA,oCAAe;EACfA,oCAAe;AACnB,CAAC,EAJWA,iBAAiB,KAAjBA,iBAAiB;SAMbC,UAAUA,CACtBC,SAAkB,EAClBC,QAAoC,EACpCC,UAAmC,EACnCC,MAAiC;;EAGjC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAGvD,MAAM,CAACC,cAAc,EAAEC,0BAA0B,CAAC,GAAGH,cAAK,CAACI,UAAU,CAACC,qBAAqB,EAAE,IAAI,CAAC;;EAGlG,MAAM,CAACC,YAAY,EAAEC,qBAAqB,CAAC,GAAGP,cAAK,CAACI,UAAU,CAC1D,CAACI,KAA0B,EAAEC,M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R,GAAGC,MAAM,CAACgB,OAAO,CAACiC;OACrB;;IAEL,KAAKF,sBAAsB,CAACI,mBAAmB;MAAE;QAC7C,MAAMgD,eAAe,GAAG;UAAE,GAAGpG;SAAO;QAC7BoG,eAAe,aAAfA,eAAe,qBAAtB,OAAOA,eAAe,CAAGnG,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;QAC9C,OAAOkF,eAAe;;IAG1B;MACI,OAAOpG,KAAK;;AAExB;;;;"}
@@ -48,7 +48,7 @@ function useTable(props, ref) {
48
48
  // can't change due to rename to "active row"
49
49
  const validation = useValidation(props.onCellValidate, props.onRowValidate);
50
50
  // not relevant to common table
51
- const editing = useEditing(options.enableEditing, validation, props.onSave);
51
+ const editing = useEditing(options.enableEditing, ref, validation, props.onSave);
52
52
  // we changed how printing works, so this shouldn't be migrated
53
53
  const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);
54
54
  // needs to be moved
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_props$length","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqHgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,WAAW,CAACJ,KAAK,CAACK,EAAE,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,gBAAgB,CAAC;;EAGpG,MAAMC,OAAO,GAAGC,cAAc,CAACT,KAAK,CAAC;;EAGrC,MAAMU,YAAY,GAAGC,0BAA0B,CAACX,KAAK,EAAEQ,OAAO,CAAC;;EAG/D,MAAMI,cAAc,GAAGC,iBAAiB,EAAAC,qBAAA,GAACZ,QAAQ,CAACa,mBAAmB,cAAAD,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACgB,0BAA0B,EAAER,OAAO,CAAC;;EAEnH,MAAMS,UAAU,GAAGC,aAAa,CAAQlB,KAAK,CAACmB,cAAc,EAAEnB,KAAK,CAACoB,aAAa,CAAC;;EAElF,MAAMC,OAAO,GAAGC,UAAU,CAAQd,OAAO,CAACe,aAAa,EAAEN,UAAU,EAAEjB,KAAK,CAACwB,MAAM,CAAC;;EAElF,MAAMC,QAAQ,GAAGC,WAAW,CAAClB,OAAO,CAACmB,cAAc,EAAEzB,QAAQ,CAAC0B,mCAAmC,EAAE5B,KAAK,CAACK,EAAE,CAAC;;EAE5G,MAAMwB,UAAU,GAAGC,aAAa,CAAQ9B,KAAK,CAAC+B,aAAa,EAAE/B,KAAK,CAACgC,mBAAmB,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B,GAAIpF,MAAuB;MAAA,IAAAqF,qBAAA;MAAA,QAAAA,qBAAA,GAC3DrF,MAAM,CAAC+E,SAAS,CAAC5C,IAAmC,CAAC1E,YAAY,cAAA4H,qBAAA,cAAAA,qBAAA,GAAI,IAAI;;;;EAIlF,IAAI9J,OAAO,CAACyI,aAAa,EAAE;IACvB,IAAIjJ,KAAK,CAACsI,MAAM,EAAE;MACd5H,YAAY,CAAC6J,aAAa,GAAG,IAAI;;KAEpC,MAAM;MACH7J,YAAY,CAAC8J,iBAAiB,GAAGA,iBAAiB,EAAE;;;EAI5D,OAAO9J,YAAY;AACvB;;;;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, ref, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_props$length","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqHgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,WAAW,CAACJ,KAAK,CAACK,EAAE,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,gBAAgB,CAAC;;EAGpG,MAAMC,OAAO,GAAGC,cAAc,CAACT,KAAK,CAAC;;EAGrC,MAAMU,YAAY,GAAGC,0BAA0B,CAACX,KAAK,EAAEQ,OAAO,CAAC;;EAG/D,MAAMI,cAAc,GAAGC,iBAAiB,EAAAC,qBAAA,GAACZ,QAAQ,CAACa,mBAAmB,cAAAD,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACgB,0BAA0B,EAAER,OAAO,CAAC;;EAEnH,MAAMS,UAAU,GAAGC,aAAa,CAAQlB,KAAK,CAACmB,cAAc,EAAEnB,KAAK,CAACoB,aAAa,CAAC;;EAElF,MAAMC,OAAO,GAAGC,UAAU,CAAQd,OAAO,CAACe,aAAa,EAAEtB,GAAG,EAAEgB,UAAU,EAAEjB,KAAK,CAACwB,MAAM,CAAC;;EAEvF,MAAMC,QAAQ,GAAGC,WAAW,CAAClB,OAAO,CAACmB,cAAc,EAAEzB,QAAQ,CAAC0B,mCAAmC,EAAE5B,KAAK,CAACK,EAAE,CAAC;;EAE5G,MAAMwB,UAAU,GAAGC,aAAa,CAAQ9B,KAAK,CAAC+B,aAAa,EAAE/B,KAAK,CAACgC,mBAAmB,CAAC;;EAEvF,MAAMC,OAAO,GAAGC,UAAU,CAAC1B,OAAO,CAAC2B,aAAa,CAAC;;EAEjD,MAAMC,OAAO,GAAGC,UAAU,CAAC7B,OAAO,CAAC8B,aAAa,EAAEtC,KAAK,CAACuC,SAAS,CAAC;;EAElE,MAAMC,MAAM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I,aAAa,EAAE;IACvB,IAAIjJ,KAAK,CAACsI,MAAM,EAAE;MACd5H,YAAY,CAAC6J,aAAa,GAAG,IAAI;;KAEpC,MAAM;MACH7J,YAAY,CAAC8J,iBAAiB,GAAGA,iBAAiB,EAAE;;;EAI5D,OAAO9J,YAAY;AACvB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import { ColumnOrderState, ColumnSizingState, SortingState, VisibilityState, BuiltInSortingFn } from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\nimport {\n TableColumnFilter,\n TableColumnRendererControl,\n TableColumnSort,\n TableFilterHandler,\n TableRef,\n TableRowClickHandler,\n TableRowGotoHandler,\n TableRowHeight,\n TableRowSelectHandler,\n TableServerLoadAllHandler,\n TableServerLoadPageHandler,\n TableSortHandler,\n} from '../../primitives/Table/types';\nimport { FontSize, ValueOf } from '../../types';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\n\nexport type Table3ColumnControlRenderer<TType = unknown> = TableColumnRendererControl<TType>;\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type Table3GroupProps = {\n id: string;\n header: string;\n colSpan?: number;\n children: (JSX.Element | boolean | null | undefined)[];\n};\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = TableRowHeight;\nexport type Table3RowClickHandler<TType = unknown> = TableRowClickHandler<TType>;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = TableRowSelectHandler<TType>;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator | null;\n value: any;\n};\n\nexport type Table3Filter = { id: string | null; value: Table3FilterValue };\n\nexport type ColumnFilter = TableColumnFilter;\nexport type Table3FilterHandler = TableFilterHandler;\nexport type Table3LoadPageHandler = TableServerLoadPageHandler;\nexport type Table3LoadAllHandler = TableServerLoadAllHandler;\nexport type Table3RowGotoHandler = TableRowGotoHandler;\nexport type Table3ColumnSort = TableColumnSort;\nexport type Table3SortHandler = TableSortHandler;\nexport type RowErrors = Record<string, string>;\nexport type Table3CellValidationHandler<TType = unknown> = (\n cellValue: any,\n cellId: string,\n row: TType\n) => Promise<RowErrors | undefined | void>;\nexport type Table3RowValidationHandler<TType = unknown> = (row: TType) => Promise<RowErrors | undefined | void>;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n onCellValidate?: Table3CellValidationHandler<TType>;\n onRowValidate?: Table3RowValidationHandler<TType>;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n rowIdentifier?: string;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = TableRef & {\n instance: {\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n clearChangesConfirmationDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n validation: {\n index: string;\n alert: {\n unsavedEntries: (count?: number) => string;\n incompleteAndHavntBeenSaved: (count?: number) => string;\n };\n resetFiltersDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IAsHYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import { ColumnOrderState, ColumnSizingState, SortingState, VisibilityState, BuiltInSortingFn } from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\nimport {\n TableColumnFilter,\n TableColumnRendererControl,\n TableColumnRendererControlProps,\n TableColumnSort,\n TableFilterHandler,\n TableRef,\n TableRowClickHandler,\n TableRowGotoHandler,\n TableRowHeight,\n TableRowSelectHandler,\n TableServerLoadAllHandler,\n TableServerLoadPageHandler,\n TableSortHandler,\n} from '../../primitives/Table/types';\nimport { FontSize, ValueOf } from '../../types';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = TableColumnRendererControlProps;\nexport type Table3ColumnControlRenderer<TType = unknown> = TableColumnRendererControl<TType>;\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type Table3GroupProps = {\n id: string;\n header: string;\n colSpan?: number;\n children: (JSX.Element | boolean | null | undefined)[];\n};\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = TableRowHeight;\nexport type Table3RowClickHandler<TType = unknown> = TableRowClickHandler<TType>;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = TableRowSelectHandler<TType>;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator | null;\n value: any;\n};\n\nexport type Table3Filter = { id: string | null; value: Table3FilterValue };\n\nexport type ColumnFilter = TableColumnFilter;\nexport type Table3FilterHandler = TableFilterHandler;\nexport type Table3LoadPageHandler = TableServerLoadPageHandler;\nexport type Table3LoadAllHandler = TableServerLoadAllHandler;\nexport type Table3RowGotoHandler = TableRowGotoHandler;\nexport type Table3ColumnSort = TableColumnSort;\nexport type Table3SortHandler = TableSortHandler;\nexport type RowErrors = Record<string, string>;\nexport type Table3CellValidationHandler<TType = unknown> = (\n cellValue: any,\n cellId: string,\n row: TType\n) => Promise<RowErrors | undefined | void>;\nexport type Table3RowValidationHandler<TType = unknown> = (row: TType) => Promise<RowErrors | undefined | void>;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n onCellValidate?: Table3CellValidationHandler<TType>;\n onRowValidate?: Table3RowValidationHandler<TType>;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n rowIdentifier?: string;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = TableRef & {\n instance: {\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n clearChangesConfirmationDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n validation: {\n index: string;\n alert: {\n unsavedEntries: (count?: number) => string;\n incompleteAndHavntBeenSaved: (count?: number) => string;\n };\n resetFiltersDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IA2GYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n GroupingState as ReactTableGroupingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n ColumnMeta as ReactTableColumnMeta,\n} from '@tanstack/react-table';\nimport { FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\n\ntype TODO = any;\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n invalid?: boolean;\n onBlur?: (value: unknown) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: unknown) => void;\n value: unknown;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'lite' | 'complex';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n grouping?: ReactTableGroupingState;\n rowHeight?: TableRowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSettings?: boolean;\n};\n\nexport type useTableInternalColumn<TType = unknown> = {\n header?: (info: ReactTableHeaderContext<TType, unknown>) => JSX.Element | string | null;\n renderer: (info: ReactTableCellContext<TType, unknown>) => JSX.Element | string | null;\n meta?: ReactTableColumnMeta<TType, unknown>;\n size?: number;\n};\n\nexport type useTableInternalColumns<TType = unknown> = {\n rowActions?: useTableInternalColumn<TType>;\n rowExpansion?: useTableInternalColumn<TType>;\n rowSelection?: useTableInternalColumn<TType>;\n};\n\ntype useTableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n shortcuts?: TableShortcuts<TType>;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TODO; // not currently supported\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\ninterface useTableClientProps<TType = unknown> extends useTableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\ninterface useTableServerProps<TType = unknown> extends useTableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type useTableProps<TType = unknown> = useTableClientProps<TType> | useTableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n } & {\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AA8BA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAmGrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n GroupingState as ReactTableGroupingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n ColumnMeta as ReactTableColumnMeta,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\n\ntype TODO = any;\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'lite' | 'complex';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n grouping?: ReactTableGroupingState;\n rowHeight?: TableRowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSettings?: boolean;\n /*\n\n | {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n };\n */\n};\n\nexport type useTableInternalColumn<TType = unknown> = {\n header?: (info: ReactTableHeaderContext<TType, unknown>) => JSX.Element | string | null;\n renderer: (info: ReactTableCellContext<TType, unknown>) => JSX.Element | string | null;\n meta?: ReactTableColumnMeta<TType, unknown>;\n size?: number;\n};\n\nexport type useTableInternalColumns<TType = unknown> = {\n rowActions?: useTableInternalColumn<TType>;\n rowExpansion?: useTableInternalColumn<TType>;\n rowSelection?: useTableInternalColumn<TType>;\n};\n\ntype useTableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n shortcuts?: TableShortcuts<TType>;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TODO; // not currently supported\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\ninterface useTableClientProps<TType = unknown> extends useTableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\ninterface useTableServerProps<TType = unknown> extends useTableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type useTableProps<TType = unknown> = useTableClientProps<TType> | useTableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n } & {\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AA8BA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAoGrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ColumnFilter as ReactTableColumnFilter, ColumnFiltersState as ReactTableColumnFilterState, ColumnOrderState as ReactTableColumnOrderState, ColumnPinningState as ReactTableColumnPinningState, ColumnSort as ReactTableColumnSort, ColumnSizingState as ReactTableColumnSizingState, GroupingState as ReactTableGroupingState, VisibilityState as ReactTableColumnVisibilityState, SortingState as ReactTableSortingState, BuiltInAggregationFn as ReactTableBuiltInAggregationFn, BuiltInSortingFn as ReactTableBuiltInSortingFn, HeaderContext as ReactTableHeaderContext, CellContext as ReactTableCellContext, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';
3
- import { FontSizes, ValueOf } from '../../types';
3
+ import { FontSize, FontSizes, ValueOf } from '../../types';
4
4
  import { MenuProps } from '../../components/Menu/Menu';
5
5
  declare type TODO = any;
6
6
  export declare type TableRef = HTMLTableElement & {
@@ -46,13 +46,14 @@ export declare type TableColumnRendererControl<TType = unknown> = ((props: Table
46
46
  export declare type TableColumnRendererControlProps = {
47
47
  className?: string;
48
48
  disabled?: boolean;
49
+ fontSize?: FontSize;
49
50
  invalid?: boolean;
50
- onBlur?: (value: unknown) => void;
51
+ onBlur?: (value: any) => void;
51
52
  onFocus?: React.FocusEventHandler;
52
53
  readOnly?: boolean;
53
54
  ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);
54
- setValue: (value: unknown) => void;
55
- value: unknown;
55
+ setValue: (value: any) => void;
56
+ value: any;
56
57
  };
57
58
  export declare type TableColumnRendererHeader = string;
58
59
  export declare type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;
@@ -14471,7 +14471,7 @@ var SavingStatusValue;
14471
14471
  SavingStatusValue["Saved"] = "saved";
14472
14472
  SavingStatusValue["Error"] = "error";
14473
14473
  })(SavingStatusValue || (SavingStatusValue = {}));
14474
- function useEditing(isEnabled, validation, onSave) {
14474
+ function useEditing(isEnabled, tableRef, validation, onSave) {
14475
14475
  // used to switch the table into editing mode
14476
14476
  const [isEditing, setIsEditing] = React__default.useState(false);
14477
14477
  // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',
@@ -14638,6 +14638,20 @@ function useEditing(isEnabled, validation, onSave) {
14638
14638
  }
14639
14639
  return false;
14640
14640
  }, [isEditing, editingState]);
14641
+ React__default.useEffect(() => {
14642
+ const handleClickOutside = event => {
14643
+ const target = event.target;
14644
+ const closestPopup = target.closest('[role="dialog"], [role="menu"]');
14645
+ // Need to check that neither target itself nor closest popup is inside or triggetred from the table.
14646
+ if (!isElementInsideOrTriggeredFromContainer(target, tableRef.current) && !isElementInsideOrTriggeredFromContainer(closestPopup, tableRef.current)) {
14647
+ saveChangesIfNeeded();
14648
+ }
14649
+ };
14650
+ document.addEventListener('click', handleClickOutside);
14651
+ return () => {
14652
+ document.removeEventListener('click', handleClickOutside);
14653
+ };
14654
+ }, [saveChangesIfNeeded]);
14641
14655
  function getSavingStatus(rowId) {
14642
14656
  return savingStatuses && savingStatuses[rowId];
14643
14657
  }
@@ -16394,7 +16408,7 @@ function useTable$1(props, ref) {
16394
16408
  // can't change due to rename to "active row"
16395
16409
  const validation = useValidation(props.onCellValidate, props.onRowValidate);
16396
16410
  // not relevant to common table
16397
- const editing = useEditing(options.enableEditing, validation, props.onSave);
16411
+ const editing = useEditing(options.enableEditing, ref, validation, props.onSave);
16398
16412
  // we changed how printing works, so this shouldn't be migrated
16399
16413
  const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);
16400
16414
  // needs to be moved