@economic/taco 2.28.1 → 2.29.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/dist/components/Icon/components/Phone.d.ts +3 -0
  2. package/dist/components/Icon/components/index.d.ts +1 -1
  3. package/dist/components/Input/Input.d.ts +1 -1
  4. package/dist/components/List/components/Item.d.ts +1 -1
  5. package/dist/components/Menu/components/Item.d.ts +1 -1
  6. package/dist/components/Menu/components/Link.d.ts +1 -1
  7. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  8. package/dist/components/Select2/components/Option.d.ts +2 -2
  9. package/dist/components/Select2/components/Search.d.ts +1 -1
  10. package/dist/components/Tag/Tag.d.ts +1 -1
  11. package/dist/esm/index.css +11 -7
  12. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +59 -43
  13. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +1 -1
  15. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/Icon/components/Phone.js +17 -0
  17. package/dist/esm/packages/taco/src/components/Icon/components/Phone.js.map +1 -0
  18. package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
  19. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +1 -1
  21. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js +9 -2
  23. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +4 -1
  25. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  26. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.js +3 -7
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.js.map +1 -1
  28. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
  29. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  30. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +11 -9
  31. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
  32. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +7 -6
  33. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  34. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js +4 -2
  35. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js.map +1 -1
  36. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js +9 -8
  37. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
  38. package/dist/esm/packages/taco/src/primitives/Table/Core/util/rows.js +2 -2
  39. package/dist/esm/packages/taco/src/primitives/Table/Core/util/rows.js.map +1 -1
  40. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +7 -1
  41. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
  42. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +15 -11
  43. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  44. package/dist/esm/packages/taco/src/utils/date.js +3 -3
  45. package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
  46. package/dist/index.css +11 -7
  47. package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +1 -3
  48. package/dist/primitives/Table/Core/util/rows.d.ts +1 -1
  49. package/dist/primitives/Table/useTableManager/util/columns.d.ts +1 -1
  50. package/dist/taco.cjs.development.js +146 -94
  51. package/dist/taco.cjs.development.js.map +1 -1
  52. package/dist/taco.cjs.production.min.js +1 -1
  53. package/dist/taco.cjs.production.min.js.map +1 -1
  54. package/dist/utils/date.d.ts +1 -1
  55. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport { isWeakEqual as isWeakEqualDate } from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n\n const handleFocus = useEditingCellAutofocus<TType>(props);\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.validateCell(cell);\n };\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n handleBlur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: (value: unknown) => tableMeta.editing.setCellValue(cell, value, rowIndex),\n row: cell.row.original,\n tabIndex: isActiveRow ? 0 : -1,\n toggleEditing: tableMeta.editing.toggleEditing,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type: columnMeta.control ?? 'input',\n value: cell.getValue(),\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n tabIndex?: number;\n toggleEditing: (editing: React.SetStateAction<boolean>) => void;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n tabIndex = -1,\n toggleEditing,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n value,\n };\n return type(controlFnProps, row);\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n event.preventDefault();\n\n if (isDetailedMode) {\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n } else {\n toggleEditing(false);\n }\n\n return;\n }\n\n // toggle into detailed mode when actually inputting something\n if (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace') {\n toggleDetailedMode(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail;\n\n if (isDate(value) && isDate(newDate) && !isWeakEqualDate(value as Date, newDate as Date)) {\n props.onChange((event as any).detail);\n }\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={value as Date}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","handleFocus","useEditingCellAutofocus","handleBlur","editing","toggleDetailedMode","validateCell","useEffect","ref","current","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","value","setCellValue","row","original","tabIndex","toggleEditing","type","_columnMeta$control","control","getValue","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","test","handleChange","newDate","detail","isDate","isWeakEqualDate","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;SAiBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGJ,KAAK;EACrD,MAAM;IAAEK;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAMC,SAAS,GAAGR,IAAI,CAACS,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGb,IAAI,CAACc,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,WAAW,GAAGR,SAAS,CAACS,SAAS,CAACC,cAAc,KAAKd,QAAQ;EAEnE,MAAMe,WAAW,GAAGC,uBAAuB,CAAQrB,KAAK,CAAC;EAEzD,MAAMsB,UAAU,GAAGA;IACfb,SAAS,CAACc,OAAO,CAACC,kBAAkB,CAAC,KAAK,CAAC;IAC3Cf,SAAS,CAACc,OAAO,CAACE,YAAY,CAACxB,IAAI,CAAC;GACvC;;EAGDK,cAAK,CAACoB,SAAS,CAAC;IACZ,MAAMC,GAAG,GAAGzB,OAAO,CAAC0B,OAAO;IAE3B,OAAO;MACH,IAAIC,QAAQ,CAACC,aAAa,KAAKH,GAAG,IAAII,uCAAuC,CAACF,QAAQ,CAACC,aAAa,EAAEH,GAAG,C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ClBG,OAAO,EAAEA,OAAO;MAChBE,WAAW,EAAEA,WAAW;MACxBG,QAAQ,EAAEgD,YAAY;MACtBlC,OAAO,EAAEtC,WAAW;MACpB8E,SAAS,EAAEzB,kBAAkB;MAC7B9C,GAAG,EAAEqC,UAAkD;MACvDnB,KAAK,EAAEuD,MAAM,CAACvD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;OAC3B;;EAIV,MAAM+C,YAAY,GAAIlB,KAA0C;IAC5D9B,QAAQ,CAACT,QAAQ,KAAK,QAAQ,IAAIuC,KAAK,CAACC,MAAM,CAAC9B,KAAK,GAAGwD,MAAM,CAACC,QAAQ,CAAC5B,KAAK,CAACC,MAAM,CAAC9B,KAAK,CAAC,GAAG6B,KAAK,CAACC,MAAM,CAAC9B,KAAK,CAAC;GACnH;EAED,oBACIvC,6BAACiG,KAAK,oBACEpC,WAAW;IACf5B,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAEgD,YAAY;IACtBlC,OAAO,EAAEtC,WAAW;IACpB8E,SAAS,EAAEzB,kBAAkB;IAC7B9C,GAAG,EAAEqC,UAA+C;IACpDb,IAAI,EAAEhB,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGsB,SAAS;IAClDZ,KAAK,EAAEV,QAAQ,KAAK,QAAQ,GAAIU,KAAgB,GAAGuD,MAAM,CAACvD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
1
+ {"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport { isWeakEqual as isWeakEqualDate } from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n\n const handleFocus = useEditingCellAutofocus<TType>(props);\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.validateCell(cell);\n };\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n handleBlur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: (value: unknown) => tableMeta.editing.setCellValue(cell, value, rowIndex),\n row: cell.row.original,\n tabIndex: isActiveRow ? 0 : -1,\n toggleEditing: tableMeta.editing.toggleEditing,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type: columnMeta.control ?? 'input',\n value: cell.getValue(),\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n tabIndex?: number;\n toggleEditing: (editing: React.SetStateAction<boolean>) => void;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n tabIndex = -1,\n toggleEditing,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n value,\n };\n return type(controlFnProps, row);\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n event.preventDefault();\n\n if (isDetailedMode) {\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n } else {\n toggleEditing(false);\n }\n\n return;\n }\n\n // toggle into detailed mode when actually inputting something\n if (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace') {\n toggleDetailedMode(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail;\n\n if (!value || (isDate(value) && isDate(newDate) && !isWeakEqualDate(value as Date, newDate as Date))) {\n props.onChange((event as any).detail);\n }\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={value as Date}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","handleFocus","useEditingCellAutofocus","handleBlur","editing","toggleDetailedMode","validateCell","useEffect","ref","current","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","value","setCellValue","row","original","tabIndex","toggleEditing","type","_columnMeta$control","control","getValue","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","test","handleChange","newDate","detail","isDate","isWeakEqualDate","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;SAiBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,O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CAACC,MAAM,CAAC9B,KAAK,CAAC;GACnH;EAED,oBACIvC,6BAACiG,KAAK,oBACEpC,WAAW;IACf5B,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAEgD,YAAY;IACtBlC,OAAO,EAAEtC,WAAW;IACpB8E,SAAS,EAAEzB,kBAAkB;IAC7B9C,GAAG,EAAEqC,UAA+C;IACpDb,IAAI,EAAEhB,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGsB,SAAS;IAClDZ,KAAK,EAAEV,QAAQ,KAAK,QAAQ,GAAIU,KAAgB,GAAGuD,MAAM,CAACvD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
@@ -29,8 +29,15 @@ function useEditingCellAutofocus(props) {
29
29
  const tableElement = (_props$cellRef$curren3 = props.cellRef.current) === null || _props$cellRef$curren3 === void 0 ? void 0 : _props$cellRef$curren3.closest('table');
30
30
  if (tableElement && table.getIsSomeColumnsPinned() && !props.cell.column.getIsPinned()) {
31
31
  const columnFreezingOffset = table.getLeftTotalSize();
32
- const leftOffsetFromScrollContainer = event.currentTarget.getBoundingClientRect().left - tableElement.getBoundingClientRect().left;
33
- if (leftOffsetFromScrollContainer < columnFreezingOffset) {
32
+ const targetRect = event.currentTarget.getBoundingClientRect();
33
+ const tableRect = tableElement.getBoundingClientRect();
34
+ const leftOffsetFromScrollContainer = targetRect.left - tableRect.left;
35
+ const scrollbarWidth = tableElement.offsetWidth - tableElement.clientWidth; // the width of table vertical scrollbar
36
+ if (
37
+ // When pinned column overlaps the focused cell
38
+ leftOffsetFromScrollContainer < columnFreezingOffset ||
39
+ // When focused cell goes behidn the edge of the table
40
+ leftOffsetFromScrollContainer + targetRect.width > tableRect.width - scrollbarWidth) {
34
41
  tableElement.scrollTo(props.cell.column.getStart() - columnFreezingOffset, tableElement.scrollTop);
35
42
  }
36
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/util.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useAugmentedFocusManager } from '../../../../../primitives/Table/Core/components/Body/util';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\n\nexport function useEditingCellAutofocus<TType = unknown>(props: TableCellRendererProps<TType>) {\n const focusManager = useAugmentedFocusManager();\n const { rowIndex } = React.useContext(RowContext);\n const table = props.cell.getContext().table;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n\n const autoFocus = props.index === tableMeta.editing.lastFocusedCellIndex && isActiveRow;\n\n // focus the cell so that we trigger it's handle focus\n React.useEffect(() => {\n if (props.cellRef.current) {\n const isFocusedElementInCurrentRow = props.cellRef.current.closest('tr')?.contains(document.activeElement);\n const isFocusedElementSearch = document.activeElement?.getAttribute('name') === 'table-search';\n\n if (autoFocus && !isFocusedElementInCurrentRow && !isFocusedElementSearch) {\n props.cellRef.current?.focus();\n }\n }\n }, [autoFocus]);\n\n // when the cell receives focus we actually want to focus the control inside it...\n const handleFocus = (event: React.FocusEvent<HTMLTableCellElement>) => {\n const tableElement = props.cellRef.current?.closest('table');\n\n if (tableElement && table.getIsSomeColumnsPinned() && !props.cell.column.getIsPinned()) {\n const columnFreezingOffset = table.getLeftTotalSize();\n const leftOffsetFromScrollContainer =\n event.currentTarget.getBoundingClientRect().left - tableElement.getBoundingClientRect().left;\n\n if (leftOffsetFromScrollContainer < columnFreezingOffset) {\n tableElement.scrollTo(props.cell.column.getStart() - columnFreezingOffset, tableElement.scrollTop);\n }\n }\n\n if (event.target === event.currentTarget) {\n focusManager.focusNext();\n }\n };\n\n return handleFocus;\n}\n"],"names":["useEditingCellAutofocus","props","focusManager","useAugmentedFocusManager","rowIndex","React","useContext","RowContext","table","cell","getContext","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","autoFocus","index","editing","lastFocusedCellIndex","useEffect","cellRef","current","_props$cellRef$curren","_document$activeEleme","isFocusedElementInCurrentRow","closest","contains","document","activeElement","isFocusedElementSearch","getAttribute","_props$cellRef$curren2","focus","handleFocus","event","tableElement","_props$cellRef$curren3","getIsSomeColumnsPinned","column","getIsPinned","columnFreezingOffset","getLeftTotalSize","leftOffsetFromScrollContainer","currentTarget","getBoundingClientRect","left","scrollTo","getStart","scrollTop","target","focusNext"],"mappings":";;;;SAMgBA,uBAAuBA,CAAkBC,KAAoC;EACzF,MAAMC,YAAY,GAAGC,wBAAwB,EAAE;EAC/C,MAAM;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAMC,KAAK,GAAGP,KAAK,CAACQ,IAAI,CAACC,UAAU,EAAE,CAACF,KAAK;EAC3C,MAAMG,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,WAAW,GAAGH,SAAS,CAACI,SAAS,CAACC,cAAc,KAAKZ,QAAQ;EAEnE,MAAMa,SAAS,GAAGhB,KAAK,CAACiB,KAAK,KAAKP,SAAS,CAACQ,OAAO,CAACC,oBAAoB,IAAIN,WAAW;;EAGvFT,cAAK,CAACgB,SAAS,CAAC;IACZ,IAAIpB,KAAK,CAACqB,OAAO,CAACC,OAAO,EAAE;MAAA,IAAAC,qBAAA,EAAAC,qBAAA;MACvB,MAAMC,4BAA4B,IAAAF,qBAAA,GAAGvB,KAAK,CAACqB,OAAO,CAACC,OAAO,CAACI,OAAO,CAAC,IAAI,CAAC,cAAAH,qBAAA,uBAAnCA,qBAAA,CAAqCI,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC;MAC1G,MAAMC,sBAAsB,GAAG,EAAAN,qBAAA,GAAAI,QAAQ,CAACC,aAAa,cAAAL,qBAAA,uBAAtBA,qBAAA,CAAwBO,YAAY,CAAC,MAAM,CAAC,MAAK,cAAc;MAE9F,IAAIf,SAAS,IAAI,CAACS,4BAA4B,IAAI,CAACK,sBAAsB,EAAE;QAAA,IAAAE,sBAAA;QACvE,CAAAA,sBAAA,GAAAhC,KAAK,CAACqB,OAAO,CAACC,OAAO,cAAAU,sBAAA,uBAArBA,sBAAA,CAAuBC,KAAK,EAAE;;;GAGzC,EAAE,CAACjB,SAAS,CAAC,CAAC;;EAGf,MAAMkB,WAAW,GAAIC,KAA6C;;IAC9D,MAAMC,YAAY,IAAAC,sBAAA,GAAGrC,KAAK,CAACqB,OAAO,CAACC,OAAO,cAAAe,sBAAA,uBAArBA,sBAAA,CAAuBX,OAAO,CAAC,OAAO,CAAC;IAE5D,IAAIU,YAAY,IAAI7B,KAAK,CAAC+B,sBAAsB,EAAE,IAAI,CAACtC,KAAK,CAACQ,IAAI,CAAC+B,MAAM,CAACC,WAAW,EAAE,EAAE;MACpF,MAAMC,oBAAoB,GAAGlC,KAAK,CAACmC,gBAAgB,EAAE;MACrD,MAAMC,6BAA6B,GAC/BR,KAAK,CAACS,aAAa,CAACC,qBAAqB,EAAE,CAACC,IAAI,GAAGV,YAAY,CAACS,qBAAqB,EAAE,CAACC,IAAI;MAEhG,IAAIH,6BAA6B,GAAGF,oBAAoB,EAAE;QACtDL,YAAY,CAACW,QAAQ,CAAC/C,KAAK,CAACQ,IAAI,CAAC+B,MAAM,CAACS,QAAQ,EAAE,GAAGP,oBAAoB,EAAEL,YAAY,CAACa,SAAS,CAAC;;;IAI1G,IAAId,KAAK,CAACe,MAAM,KAAKf,KAAK,CAACS,aAAa,EAAE;MACtC3C,YAAY,CAACkD,SAAS,EAAE;;GAE/B;EAED,OAAOjB,WAAW;AACtB;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/util.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useAugmentedFocusManager } from '../../../../../primitives/Table/Core/components/Body/util';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\n\nexport function useEditingCellAutofocus<TType = unknown>(props: TableCellRendererProps<TType>) {\n const focusManager = useAugmentedFocusManager();\n const { rowIndex } = React.useContext(RowContext);\n const table = props.cell.getContext().table;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n\n const autoFocus = props.index === tableMeta.editing.lastFocusedCellIndex && isActiveRow;\n\n // focus the cell so that we trigger it's handle focus\n React.useEffect(() => {\n if (props.cellRef.current) {\n const isFocusedElementInCurrentRow = props.cellRef.current.closest('tr')?.contains(document.activeElement);\n const isFocusedElementSearch = document.activeElement?.getAttribute('name') === 'table-search';\n\n if (autoFocus && !isFocusedElementInCurrentRow && !isFocusedElementSearch) {\n props.cellRef.current?.focus();\n }\n }\n }, [autoFocus]);\n\n // when the cell receives focus we actually want to focus the control inside it...\n const handleFocus = (event: React.FocusEvent<HTMLTableCellElement>) => {\n const tableElement = props.cellRef.current?.closest('table');\n\n if (tableElement && table.getIsSomeColumnsPinned() && !props.cell.column.getIsPinned()) {\n const columnFreezingOffset = table.getLeftTotalSize();\n const targetRect = event.currentTarget.getBoundingClientRect();\n const tableRect = tableElement.getBoundingClientRect();\n const leftOffsetFromScrollContainer = targetRect.left - tableRect.left;\n const scrollbarWidth = tableElement.offsetWidth - tableElement.clientWidth; // the width of table vertical scrollbar\n\n if (\n // When pinned column overlaps the focused cell\n leftOffsetFromScrollContainer < columnFreezingOffset ||\n // When focused cell goes behidn the edge of the table\n leftOffsetFromScrollContainer + targetRect.width > tableRect.width - scrollbarWidth\n ) {\n tableElement.scrollTo(props.cell.column.getStart() - columnFreezingOffset, tableElement.scrollTop);\n }\n }\n\n if (event.target === event.currentTarget) {\n focusManager.focusNext();\n }\n };\n\n return handleFocus;\n}\n"],"names":["useEditingCellAutofocus","props","focusManager","useAugmentedFocusManager","rowIndex","React","useContext","RowContext","table","cell","getContext","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","autoFocus","index","editing","lastFocusedCellIndex","useEffect","cellRef","current","_props$cellRef$curren","_document$activeEleme","isFocusedElementInCurrentRow","closest","contains","document","activeElement","isFocusedElementSearch","getAttribute","_props$cellRef$curren2","focus","handleFocus","event","tableElement","_props$cellRef$curren3","getIsSomeColumnsPinned","column","getIsPinned","columnFreezingOffset","getLeftTotalSize","targetRect","currentTarget","getBoundingClientRect","tableRect","leftOffsetFromScrollContainer","left","scrollbarWidth","offsetWidth","clientWidth","width","scrollTo","getStart","scrollTop","target","focusNext"],"mappings":";;;;SAMgBA,uBAAuBA,CAAkBC,KAAoC;EACzF,MAAMC,YAAY,GAAGC,wBAAwB,EAAE;EAC/C,MAAM;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAMC,KAAK,GAAGP,KAAK,CAACQ,IAAI,CAACC,UAAU,EAAE,CAACF,KAAK;EAC3C,MAAMG,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,WAAW,GAAGH,SAAS,CAACI,SAAS,CAACC,cAAc,KAAKZ,QAAQ;EAEnE,MAAMa,SAAS,GAAGhB,KAAK,CAACiB,KAAK,KAAKP,SAAS,CAACQ,OAAO,CAACC,oBAAoB,IAAIN,WAAW;;EAGvFT,cAAK,CAACgB,SAAS,CAAC;IACZ,IAAIpB,KAAK,CAACqB,OAAO,CAACC,OAAO,EAAE;MAAA,IAAAC,qBAAA,EAAAC,qBAAA;MACvB,MAAMC,4BAA4B,IAAAF,qBAAA,GAAGvB,KAAK,CAACqB,OAAO,CAACC,OAAO,CAACI,OAAO,CAAC,IAAI,CAAC,cAAAH,qBAAA,uBAAnCA,qBAAA,CAAqCI,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC;MAC1G,MAAMC,sBAAsB,GAAG,EAAAN,qBAAA,GAAAI,QAAQ,CAACC,aAAa,cAAAL,qBA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M,KAAKrB,KAAK,CAACS,aAAa,EAAE;MACtC3C,YAAY,CAACwD,SAAS,EAAE;;GAE/B;EAED,OAAOvB,WAAW;AACtB;;;;"}
@@ -1,6 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom.js';
3
3
  import { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown.js';
4
+ import { isDate } from 'date-fns';
4
5
  import { _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
5
6
  import { willRowMove } from '../util/editing.js';
6
7
 
@@ -17,7 +18,9 @@ function useTableEditing(isEnabled = false, handleSave, validator) {
17
18
  const pendingChangesFns = usePendingChanges(isEnabled, handleSave, validator);
18
19
  // if focus leaves the table in any way, trigger a save
19
20
  const handleBlur = React__default.useCallback(event => {
20
- if (event.relatedTarget !== event.currentTarget && !isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
21
+ // custom event from datepicker, and it doesn't have the relatedTarget property set.
22
+ const isClosingDatepicker = isDate(event.detail);
23
+ if (event.relatedTarget !== event.currentTarget && !isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget) && !isClosingDatepicker) {
21
24
  pendingChangesFns.saveChanges();
22
25
  }
23
26
  }, [pendingChangesFns.saveChanges]);
@@ -1 +1 @@
1
- {"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { willRowMove } from '../util/editing';\nimport { TableRef } from '../../../primitives/Table/types';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, toggleEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();\n\n // store pending changes for each row\n // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes\n // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved\n const pendingChangesFns = usePendingChanges<TType>(isEnabled, handleSave, validator);\n\n // if focus leaves the table in any way, trigger a save\n const handleBlur = React.useCallback(\n (event: React.FocusEvent<HTMLTableElement>) => {\n if (\n event.relatedTarget !== event.currentTarget &&\n !isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)\n ) {\n pendingChangesFns.saveChanges();\n }\n },\n [pendingChangesFns.saveChanges]\n );\n\n // TODO: using useGlobalKeyDown prevents trigger when focused on inputs, but it's more \"proper\"\n useGlobalKeyDown(isEnabled && isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n pendingChangesFns.saveChanges();\n });\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n handleBlur: isEnabled && isEditing ? handleBlur : () => undefined,\n };\n}\n\ntype SaveState = 'pending' | 'complete';\ntype PendingChange<TType = unknown> = Partial<TType> & {\n _meta: {\n original: TType;\n moveReason: Record<string, 'search' | 'sorting' | 'filter'>;\n errors: {\n row: string;\n cells: Record<string, string>;\n hasShownErrorAlert: boolean;\n };\n status?: SaveState;\n };\n};\n\nfunction usePendingChanges<TType = unknown>(\n isEnabled: boolean,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const [pendingChanges, setPendingChanges] = React.useState<Record<string, PendingChange<TType>>>({});\n // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted\n const [saveStates, setSaveState] = React.useState<Record<string, SaveState>>({});\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return pendingChanges[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return pendingChanges[cell.row.id]?._meta.errors?.cells?.[cell.column.id];\n }\n\n const setCellValue = React.useCallback(function <T extends TType>(\n cell: ReactTableCell<T, unknown>,\n change: unknown,\n rowIndex: number\n ) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n const rowChanges = {\n ...currentChanges[cell.row.id],\n _meta: {\n ...currentChanges[cell.row.id]?._meta,\n original: cell.row.original,\n moveReason: {\n ...currentChanges[cell.row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[cell.row.id]?._meta.errors,\n },\n },\n } as PendingChange<T>;\n\n // update if the change is different to the original (saved) value,\n // otherwise remove any change - no point saving the same value\n if (change !== cell.row.original[cell.column.id]) {\n rowChanges[cell.column.id] = change;\n\n // determine if the row will move position based on this change, and save why it will move\n const reason = willRowMove(cell, change, rowIndex);\n\n if (reason) {\n rowChanges._meta.moveReason[cell.column.id] = reason;\n } else {\n delete rowChanges._meta.moveReason[cell.column.id];\n }\n } else {\n delete rowChanges[cell.column.id];\n }\n\n // set the changes for the row...\n // or delete if there are no changes left, so that we don't store changes with unchanged data\n if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {\n nextChanges[cell.row.id] = rowChanges;\n } else {\n delete nextChanges[cell.row.id];\n }\n\n return nextChanges;\n });\n },\n []);\n\n async function validateCell<T extends TType>(cell: ReactTableCell<T, unknown>) {\n if (!validator || !isEnabled) {\n return;\n }\n\n const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);\n\n // only validate if the cell being blurred actually has any changes\n if (cell.column.id in changeSet) {\n const errors = ((await validator(changeSet)) ?? {}) as Record<string, string>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[cell.row.id]._meta = {\n ...nextChanges[cell.row.id]._meta,\n errors: {\n ...nextChanges[cell.row.id]._meta.errors,\n cells: errors,\n hasShownErrorAlert:\n Object.keys(errors).length && !nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert\n ? false\n : nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert,\n },\n };\n return nextChanges;\n });\n }\n }\n\n function hasRowErrors(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return (\n !!pendingChanges[rowId]?._meta.errors?.row || !!Object.keys(pendingChanges[rowId]?._meta.errors?.cells ?? {}).length\n );\n }\n\n function hasRowErrorsSeen(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return hasRowErrors(rowId) && !!pendingChanges[rowId]._meta.errors?.hasShownErrorAlert;\n }\n\n function setRowErrorsSeen(rowId: string) {\n if (pendingChanges[rowId]._meta.errors?.hasShownErrorAlert === false) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n ...nextChanges[rowId]._meta.errors,\n hasShownErrorAlert: true,\n };\n return nextChanges;\n });\n }\n }\n\n function getRowSaveStatus(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return saveStates[rowId];\n }\n\n function setRowSaveStatus(rowId: string, status: 'pending' | 'complete' | undefined) {\n setSaveState(currentStates => {\n const nextStates = { ...currentStates };\n\n if (status) {\n nextStates[rowId] = status;\n } else {\n delete nextStates[rowId];\n }\n\n return nextStates;\n });\n }\n\n function getRowMoveReason(rowId: string) {\n return pendingChanges[rowId]?._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;\n }\n\n function hasChanges(rowId?: string) {\n if (!isEnabled) {\n return false;\n }\n\n return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;\n }\n\n function hasErrors<T extends TType>(table: ReactTable<T>, tableRef: React.RefObject<TableRef>) {\n if (!isEnabled) {\n return false;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const focusIsInsideTable = tableRef.current?.contains(document.activeElement);\n\n let activeRow;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n activeRow = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex];\n }\n\n return Object.keys(\n getErrors().filter(error => {\n if (activeRow?.id && focusIsInsideTable) {\n return error.rowId === activeRow?.id ? error.pendingChange._meta.errors.hasShownErrorAlert : true;\n }\n\n return true;\n })\n ).length;\n }\n\n function getErrors<T extends TType>() {\n return Object.keys(pendingChanges)\n .filter(hasRowErrors)\n .map(rowId => ({ rowId, pendingChange: pendingChanges[rowId] as PendingChange<T> }));\n }\n\n function resetChanges(rowId: string) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n delete nextChanges[rowId];\n return nextChanges;\n });\n }\n\n async function saveChanges(rowId: string | undefined = undefined) {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onSave handler');\n return;\n }\n\n // we save back to pendingChanges, so make a copy of it's state when save was triggered\n const changesToSave = rowId ? { [rowId]: pendingChanges[rowId] } : { ...pendingChanges };\n const changes = Object.keys(changesToSave);\n\n if (changes.length) {\n changes.map(async rowId => {\n const pendingChange = changesToSave[rowId];\n\n const changeSet = getChangesetFromChanges(pendingChange);\n\n try {\n // set saving = true\n setRowSaveStatus(rowId, 'pending');\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n resetChanges(rowId);\n setRowSaveStatus(rowId, 'complete');\n } catch (error) {\n // the onSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n row: rowError,\n cells: cellErrors,\n hasShownErrorAlert: nextChanges[rowId]._meta.errors?.hasShownErrorAlert ?? false,\n };\n return nextChanges;\n });\n }\n\n setRowSaveStatus(rowId, undefined);\n }\n });\n }\n }\n\n return {\n getCellValue,\n getCellError,\n setCellValue,\n validateCell,\n hasChanges,\n hasErrors,\n getErrors,\n saveChanges,\n resetChanges,\n hasRowErrors,\n hasRowErrorsSeen,\n setRowErrorsSeen,\n getRowSaveStatus,\n setRowSaveStatus,\n getRowMoveReason,\n };\n}\n\nfunction useLastFocusedCellIndex(): [number | undefined, (index: number | undefined) => void] {\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const lastFocusedCellIndexRef = React.useRef<number | undefined>(undefined);\n const setLastFocusedCellIndex = React.useCallback((index: number | undefined) => {\n lastFocusedCellIndexRef.current = index;\n }, []);\n\n return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];\n}\n\nfunction getChangesetFromChanges<TType = unknown>(changes: PendingChange<TType>): TType {\n // extract the original data from the row changes\n const { _meta, ...changeset } = changes ?? {};\n // and mix them in with the changes, ready to send to the server\n return { ..._meta?.original, ...changeset };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","validator","isEditing","toggleEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","useLastFocusedCellIndex","pendingChangesFns","usePendingChanges","handleBlur","useCallback","event","relatedTarget","currentTarget","isElementInsideOrTriggeredFromContainer","saveChanges","useGlobalKeyDown","key","meta","shift","undefined","preventDefault","rowId","console","warn","Promise","resolve","changesToSave","pendingChanges","changes","Object","keys","length","map","pendingChange","changeSet","getChangesetFromChanges","_catch","_temp3","_result","_exit","then","resetChanges","setRowSaveStatus","_temp2","errors","error","rowError","cellErrors","Error","_error$response","message","response","data","_error$response2","setPendingChanges","currentChanges","nextChanges","_meta","row","cells","hasShownErrorAlert","_nextChanges$rowId$_m","_nextChanges$rowId$_m2","e","reject","validateCell","cell","id","_temp","column","saveStates","setSaveState","getCellValue","_pendingChanges$cell$","getCellError","_pendingChanges$cell$2","_pendingChanges$cell$3","_pendingChanges$cell$4","setCellValue","change","rowIndex","rowChanges","_currentChanges$cell$","original","moveReason","_currentChanges$cell$2","_currentChanges$cell$3","reason","willRowMove","filter","k","hasRowErrors","_pendingChanges$rowId","_pendingChanges$rowId2","_pendingChanges$rowId3","_pendingChanges$rowId4","_pendingChanges$rowId5","hasRowErrorsSeen","_pendingChanges$rowId6","setRowErrorsSeen","_pendingChanges$rowId7","getRowSaveStatus","status","currentStates","nextStates","getRowMoveReason","_pendingChanges$rowId8","values","hasChanges","hasErrors","table","tableRef","tableMeta","options","focusIsInsideTable","_tableRef$current","current","contains","document","activeElement","activeRow","rowActive","rowActiveIndex","getRowModel","rows","getErrors","_activeRow","_activeRow2","lastFocusedCellIndexRef","useRef","index","changeset"],"mappings":";;;;;;SAQgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,SAAsD;;EAGtD,MAAM,CAACC,SAAS,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGxD,MAAM,CAACC,cAAc,EAAEC,kBAAkB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGlE,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGC,uBAAuB,EAAE;;;;EAKjF,MAAMC,iBAAiB,GAAGC,iBAAiB,CAAQb,SAAS,EAAEC,UAAU,EAAEC,SAAS,CAAC;;EAGpF,MAAMY,UAAU,GAAGT,cAAK,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3E,MAAM;IAAE6B,KAAK;IAAE,GAAG0E;GAAW,GAAGvG,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE;;EAE7C,OAAO;IAAE,IAAG6B,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE0B,QAAQ;IAAE,GAAGgD;GAAW;AAC/C;;;;"}
1
+ {"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { willRowMove } from '../util/editing';\nimport { TableRef } from '../../../primitives/Table/types';\nimport { isDate } from 'date-fns';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, toggleEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();\n\n // store pending changes for each row\n // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes\n // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved\n const pendingChangesFns = usePendingChanges<TType>(isEnabled, handleSave, validator);\n\n // if focus leaves the table in any way, trigger a save\n const handleBlur = React.useCallback(\n (event: React.FocusEvent<HTMLTableElement>) => {\n // custom event from datepicker, and it doesn't have the relatedTarget property set.\n const isClosingDatepicker = isDate((event as any).detail);\n\n if (\n event.relatedTarget !== event.currentTarget &&\n !isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget) &&\n !isClosingDatepicker\n ) {\n pendingChangesFns.saveChanges();\n }\n },\n [pendingChangesFns.saveChanges]\n );\n\n // TODO: using useGlobalKeyDown prevents trigger when focused on inputs, but it's more \"proper\"\n useGlobalKeyDown(isEnabled && isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n pendingChangesFns.saveChanges();\n });\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n handleBlur: isEnabled && isEditing ? handleBlur : () => undefined,\n };\n}\n\ntype SaveState = 'pending' | 'complete';\ntype PendingChange<TType = unknown> = Partial<TType> & {\n _meta: {\n original: TType;\n moveReason: Record<string, 'search' | 'sorting' | 'filter'>;\n errors: {\n row: string;\n cells: Record<string, string>;\n hasShownErrorAlert: boolean;\n };\n status?: SaveState;\n };\n};\n\nfunction usePendingChanges<TType = unknown>(\n isEnabled: boolean,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const [pendingChanges, setPendingChanges] = React.useState<Record<string, PendingChange<TType>>>({});\n // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted\n const [saveStates, setSaveState] = React.useState<Record<string, SaveState>>({});\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return pendingChanges[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return pendingChanges[cell.row.id]?._meta.errors?.cells?.[cell.column.id];\n }\n\n const setCellValue = React.useCallback(function <T extends TType>(\n cell: ReactTableCell<T, unknown>,\n change: unknown,\n rowIndex: number\n ) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n const rowChanges = {\n ...currentChanges[cell.row.id],\n _meta: {\n ...currentChanges[cell.row.id]?._meta,\n original: cell.row.original,\n moveReason: {\n ...currentChanges[cell.row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[cell.row.id]?._meta.errors,\n },\n },\n } as PendingChange<T>;\n\n // update if the change is different to the original (saved) value,\n // otherwise remove any change - no point saving the same value\n if (change !== cell.row.original[cell.column.id]) {\n rowChanges[cell.column.id] = change;\n\n // determine if the row will move position based on this change, and save why it will move\n const reason = willRowMove(cell, change, rowIndex);\n\n if (reason) {\n rowChanges._meta.moveReason[cell.column.id] = reason;\n } else {\n delete rowChanges._meta.moveReason[cell.column.id];\n }\n } else {\n delete rowChanges[cell.column.id];\n }\n\n // set the changes for the row...\n // or delete if there are no changes left, so that we don't store changes with unchanged data\n if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {\n nextChanges[cell.row.id] = rowChanges;\n } else {\n delete nextChanges[cell.row.id];\n }\n\n return nextChanges;\n });\n },\n []);\n\n async function validateCell<T extends TType>(cell: ReactTableCell<T, unknown>) {\n if (!validator || !isEnabled) {\n return;\n }\n\n const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);\n\n // only validate if the cell being blurred actually has any changes\n if (cell.column.id in changeSet) {\n const errors = ((await validator(changeSet)) ?? {}) as Record<string, string>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[cell.row.id]._meta = {\n ...nextChanges[cell.row.id]._meta,\n errors: {\n ...nextChanges[cell.row.id]._meta.errors,\n cells: errors,\n hasShownErrorAlert:\n Object.keys(errors).length && !nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert\n ? false\n : nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert,\n },\n };\n return nextChanges;\n });\n }\n }\n\n function hasRowErrors(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return (\n !!pendingChanges[rowId]?._meta.errors?.row || !!Object.keys(pendingChanges[rowId]?._meta.errors?.cells ?? {}).length\n );\n }\n\n function hasRowErrorsSeen(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return hasRowErrors(rowId) && !!pendingChanges[rowId]._meta.errors?.hasShownErrorAlert;\n }\n\n function setRowErrorsSeen(rowId: string) {\n if (pendingChanges[rowId]._meta.errors?.hasShownErrorAlert === false) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n ...nextChanges[rowId]._meta.errors,\n hasShownErrorAlert: true,\n };\n return nextChanges;\n });\n }\n }\n\n function getRowSaveStatus(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return saveStates[rowId];\n }\n\n function setRowSaveStatus(rowId: string, status: 'pending' | 'complete' | undefined) {\n setSaveState(currentStates => {\n const nextStates = { ...currentStates };\n\n if (status) {\n nextStates[rowId] = status;\n } else {\n delete nextStates[rowId];\n }\n\n return nextStates;\n });\n }\n\n function getRowMoveReason(rowId: string) {\n return pendingChanges[rowId]?._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;\n }\n\n function hasChanges(rowId?: string) {\n if (!isEnabled) {\n return false;\n }\n\n return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;\n }\n\n function hasErrors<T extends TType>(table: ReactTable<T>, tableRef: React.RefObject<TableRef>) {\n if (!isEnabled) {\n return false;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const focusIsInsideTable = tableRef.current?.contains(document.activeElement);\n\n let activeRow;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n activeRow = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex];\n }\n\n return Object.keys(\n getErrors().filter(error => {\n if (activeRow?.id && focusIsInsideTable) {\n return error.rowId === activeRow?.id ? error.pendingChange._meta.errors.hasShownErrorAlert : true;\n }\n\n return true;\n })\n ).length;\n }\n\n function getErrors<T extends TType>() {\n return Object.keys(pendingChanges)\n .filter(hasRowErrors)\n .map(rowId => ({ rowId, pendingChange: pendingChanges[rowId] as PendingChange<T> }));\n }\n\n function resetChanges(rowId: string) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n delete nextChanges[rowId];\n return nextChanges;\n });\n }\n\n async function saveChanges(rowId: string | undefined = undefined) {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onSave handler');\n return;\n }\n\n // we save back to pendingChanges, so make a copy of it's state when save was triggered\n const changesToSave = rowId ? { [rowId]: pendingChanges[rowId] } : { ...pendingChanges };\n const changes = Object.keys(changesToSave);\n\n if (changes.length) {\n changes.map(async rowId => {\n const pendingChange = changesToSave[rowId];\n\n const changeSet = getChangesetFromChanges(pendingChange);\n\n try {\n // set saving = true\n setRowSaveStatus(rowId, 'pending');\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n resetChanges(rowId);\n setRowSaveStatus(rowId, 'complete');\n } catch (error) {\n // the onSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n row: rowError,\n cells: cellErrors,\n hasShownErrorAlert: nextChanges[rowId]._meta.errors?.hasShownErrorAlert ?? false,\n };\n return nextChanges;\n });\n }\n\n setRowSaveStatus(rowId, undefined);\n }\n });\n }\n }\n\n return {\n getCellValue,\n getCellError,\n setCellValue,\n validateCell,\n hasChanges,\n hasErrors,\n getErrors,\n saveChanges,\n resetChanges,\n hasRowErrors,\n hasRowErrorsSeen,\n setRowErrorsSeen,\n getRowSaveStatus,\n setRowSaveStatus,\n getRowMoveReason,\n };\n}\n\nfunction useLastFocusedCellIndex(): [number | undefined, (index: number | undefined) => void] {\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const lastFocusedCellIndexRef = React.useRef<number | undefined>(undefined);\n const setLastFocusedCellIndex = React.useCallback((index: number | undefined) => {\n lastFocusedCellIndexRef.current = index;\n }, []);\n\n return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];\n}\n\nfunction getChangesetFromChanges<TType = unknown>(changes: PendingChange<TType>): TType {\n // extract the original data from the row changes\n const { _meta, ...changeset } = changes ?? {};\n // and mix them in with the changes, ready to send to the server\n return { ..._meta?.original, ...changeset };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","validator","isEditing","toggleEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","useLastFocusedCellIndex","pendingChangesFns","usePendingChanges","handleBlur","useCallback","event","isClosingDatepicker","isDate","detail","relatedTarget","currentTarget","isElementInsideOrTriggeredFromContainer","saveChanges","useGlobalKeyDown","key","meta","shift","undefined","preventDefault","rowId","console","warn","Promise","resolve","changesToSave","pendingChanges","changes","Object","keys","length","map","pendingChange","changeSet","getChangesetFromChanges","_catch","_temp3","_result","_exit","then","resetChanges","setRowSaveStatus","_temp2","errors","error","rowError","cellErrors","Error","_error$response","message","response","data","_error$response2","setPendingChanges","currentChanges","nextChanges","_meta","row","cells","hasShownErrorAlert","_nextChanges$rowId$_m","_nextChanges$rowId$_m2","e","reject","validateCell","cell","id","_temp","column","saveStates","setSaveState","getCellValue","_pendingChanges$cell$","getCellError","_pendingChanges$cell$2","_pendingChanges$cell$3","_pendingChanges$cell$4","setCellValue","change","rowIndex","rowChanges","_currentChanges$cell$","original","moveReason","_currentChanges$cell$2","_currentChanges$cell$3","reason","willRowMove","filter","k","hasRowErrors","_pendingChanges$rowId","_pendingChanges$rowId2","_pendingChanges$rowId3","_pendingChanges$rowId4","_pendingChanges$rowId5","hasRowErrorsSeen","_pendingChanges$rowId6","setRowErrorsSeen","_pendingChanges$rowId7","getRowSaveStatus","status","currentStates","nextStates","getRowMoveReason","_pendingChanges$rowId8","values","hasChanges","hasErrors","table","tableRef","tableMeta","options","focusIsInsideTable","_tableRef$current","current","contains","document","activeElement","activeRow","rowActive","rowActiveIndex","getRowModel","rows","getErrors","_activeRow","_activeRow2","lastFocusedCellIndexRef","useRef","index","changeset"],"mappings":";;;;;;;SASgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,SAAsD;;EAGtD,MAAM,CAACC,SAAS,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGxD,MAAM,CAACC,cAAc,EAAEC,kBAAkB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGlE,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGC,uBAAuB,EAAE;;;;EAKjF,MAAMC,iBAAiB,GAAGC,iBAAiB,CAAQb,SAAS,EAAEC,UAAU,EAAEC,SAAS,CAAC;;EAGpF,MAAMY,UAAU,GAAGT,cAAK,CAACU,WAAW,CAC/BC,KAAyC;;IAEtC,MAAMC,mBAAmB,GAAGC,MAAM,CAAEF,KAAa,CAACG,MAAM,CAAC;IAEzD,IACIH,KAAK,CAACI,aAAa,KAAKJ,KAAK,CAACK,aAAa,IAC3C,CAACC,uCAAuC,CAACN,KAAK,CAACI,aAAa,EAAEJ,KAAK,CAACK,aAAa,CAAC,IAClF,CAACJ,mBAAmB,EACtB;MACEL,iBAAiB,CAACW,WAAW,EAAE;;GAEtC,EACD,CAACX,iBAAiB,CAACW,WAAW,CAAC,CAClC;;EAGDC,gBAAgB,CAACxB,SAAS,IAAIG,SAAS,GAAG;IAAEsB,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE,IAAI;IAAEC,KAAK,EAAE;GAAO,GAAGC,SAAS,EAAEZ,KAAK;IA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,KAAK;MAAEA,KAAK;MAAEY,aAAa,EAAEN,cAAc,CAACN,KAAK;KAAuB,CAAC,CAAC;;EAG5F,SAASoB,YAAYA,CAACpB,KAAa;IAC/BiC,iBAAiB,CAACC,cAAc;MAC5B,MAAMC,WAAW,GAAG;QAAE,GAAGD;OAAgB;MACzC,OAAOC,WAAW,CAACnC,KAAK,CAAC;MACzB,OAAOmC,WAAW;KACrB,CAAC;;EA2EN,OAAO;IACHgB,YAAY;IACZE,YAAY;IACZI,YAAY;IACZb,YAAY;IACZ2C,UAAU;IACVC,SAAS;IACTgB,SAAS;IACT/G,WAAW;IACX2B,YAAY;IACZkD,YAAY;IACZM,gBAAgB;IAChBE,gBAAgB;IAChBE,gBAAgB;IAChB3D,gBAAgB;IAChB+D;GACH;AACL;AAEA,SAASvG,uBAAuBA;;EAE5B,MAAM8H,uBAAuB,GAAGpI,cAAK,CAACqI,MAAM,CAAqB9G,SAAS,CAAC;EAC3E,MAAMlB,uBAAuB,GAAGL,cAAK,CAACU,WAAW,CAAE4H,KAAyB;IACxEF,uBAAuB,CAACZ,OAAO,GAAGc,KAAK;GAC1C,EAAE,EAAE,CAAC;EAEN,OAAO,CAACF,uBAAuB,CAACZ,OAAO,EAAEnH,uBAAuB,CAAC;AACrE;AAEA,SAASkC,uBAAuBA,CAAkBP,OAA6B;;EAE3E,MAAM;IAAE6B,KAAK;IAAE,GAAG0E;GAAW,GAAGvG,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE;;EAE7C,OAAO;IAAE,IAAG6B,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE0B,QAAQ;IAAE,GAAGgD;GAAW;AAC/C;;;;"}
@@ -1,7 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { flexRender } from '@tanstack/react-table';
3
3
  import { isInternalColumn } from '../../../../../useTableManager/util/columns.js';
4
- import { RowContext } from '../../../Row/RowContext.js';
5
4
  import { getCellAttributes } from '../util.js';
6
5
 
7
6
  function DisplayCell(props) {
@@ -12,23 +11,20 @@ function DisplayCell(props) {
12
11
  isHighlighted,
13
12
  ...cellAttributes
14
13
  } = props;
15
- const {
16
- isHovered
17
- } = React__default.useContext(RowContext);
18
14
  const columnMeta = cell.column.columnDef.meta;
19
15
  const attributes = getCellAttributes(cell, index, isHighlighted);
20
16
  const isTruncated = !!columnMeta.enableTruncate;
17
+ const value = cell.getValue();
21
18
  let content;
22
19
  if (isInternalColumn(cell.column.id)) {
23
20
  content = flexRender(cell.column.columnDef.cell, cell.getContext());
24
21
  } else {
25
22
  var _ref, _columnMeta$renderer, _columnMeta$renderer2;
26
- content = (_ref = (_columnMeta$renderer = (_columnMeta$renderer2 = columnMeta.renderer) === null || _columnMeta$renderer2 === void 0 ? void 0 : _columnMeta$renderer2.call(columnMeta, cell.getValue(), cell.row.original)) !== null && _columnMeta$renderer !== void 0 ? _columnMeta$renderer : cell.getValue()) !== null && _ref !== void 0 ? _ref : null;
23
+ content = (_ref = (_columnMeta$renderer = (_columnMeta$renderer2 = columnMeta.renderer) === null || _columnMeta$renderer2 === void 0 ? void 0 : _columnMeta$renderer2.call(columnMeta, value, cell.row.original)) !== null && _columnMeta$renderer !== void 0 ? _columnMeta$renderer : value) !== null && _ref !== void 0 ? _ref : null;
27
24
  }
28
25
  return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, cellAttributes, attributes, {
29
26
  cellRef: cellRef,
30
- isTruncated: isTruncated,
31
- key: `${cell.id}_${isHovered}`
27
+ isTruncated: isTruncated
32
28
  }), content);
33
29
  }
34
30
  const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDisplayCell(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnMeta as ReactTableColumnMeta, flexRender } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { TableCellRendererProps } from '../../../../types';\nimport { RowContext } from '../../../Row/RowContext';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\n\nexport function DisplayCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted, ...cellAttributes } = props;\n const { isHovered } = React.useContext(RowContext);\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n const isTruncated = !!columnMeta.enableTruncate;\n let content;\n\n if (isInternalColumn(cell.column.id)) {\n content = flexRender(cell.column.columnDef.cell, cell.getContext());\n } else {\n content = columnMeta.renderer?.(cell.getValue<TType>(), cell.row.original) ?? cell.getValue() ?? null;\n }\n\n return (\n <MemoedDisplayCell\n {...cellAttributes}\n {...attributes}\n cellRef={cellRef}\n isTruncated={isTruncated}\n key={`${cell.id}_${isHovered}`}>\n {content}\n </MemoedDisplayCell>\n );\n}\n\ntype MemoedDisplayCellProps = React.TdHTMLAttributes<HTMLTableCellElement> & {\n cellRef: any;\n isTruncated: boolean;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell(props: MemoedDisplayCellProps) {\n const { cellRef, children, isTruncated, ...cellAttributes } = props;\n\n return (\n <td {...cellAttributes} ref={cellRef}>\n {isTruncated ? <span className=\"truncate print:overflow-visible print:whitespace-normal\">{children}</span> : children}\n </td>\n );\n});\n"],"names":["DisplayCell","props","cell","cellRef","index","isHighlighted","cellAttributes","isHovered","React","useContext","RowContext","columnMeta","column","columnDef","meta","attributes","getCellAttributes","isTruncated","enableTruncate","content","isInternalColumn","id","flexRender","getContext","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","getValue","row","original","MemoedDisplayCell","key","memo","children","ref","className"],"mappings":";;;;;;SAOgBA,WAAWA,CAAkBC,KAAoC;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC,aAAa;IAAE,GAAGC;GAAgB,GAAGL,KAAK;EACxE,MAAM;IAAE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cAAc;IAAE8B,GAAG,EAAEjC;MACxBc,WAAW,gBAAGT;IAAM6B,SAAS,EAAC;KAA2DF,QAAQ,CAAQ,GAAGA,QAAQ,CACpH;AAEb,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnMeta as ReactTableColumnMeta, flexRender } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { TableCellRendererProps } from '../../../../types';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\n\nexport function DisplayCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted, ...cellAttributes } = props;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n const isTruncated = !!columnMeta.enableTruncate;\n const value = cell.getValue<TType>();\n\n let content;\n\n if (isInternalColumn(cell.column.id)) {\n content = flexRender(cell.column.columnDef.cell, cell.getContext());\n } else {\n content = columnMeta.renderer?.(value, cell.row.original) ?? value ?? null;\n }\n\n return (\n <MemoedDisplayCell {...cellAttributes} {...attributes} cellRef={cellRef} isTruncated={isTruncated}>\n {content}\n </MemoedDisplayCell>\n );\n}\n\ntype MemoedDisplayCellProps = React.TdHTMLAttributes<HTMLTableCellElement> & {\n cellRef: any;\n isTruncated: boolean;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell(props: MemoedDisplayCellProps) {\n const { cellRef, children, isTruncated, ...cellAttributes } = props;\n\n return (\n <td {...cellAttributes} ref={cellRef}>\n {isTruncated ? <span className=\"truncate print:overflow-visible print:whitespace-normal\">{children}</span> : children}\n </td>\n );\n});\n"],"names":["DisplayCell","props","cell","cellRef","index","isHighlighted","cellAttributes","columnMeta","column","columnDef","meta","attributes","getCellAttributes","isTruncated","enableTruncate","value","getValue","content","isInternalColumn","id","flexRender","getContext","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","row","original","React","MemoedDisplayCell","memo","children","ref","className"],"mappings":";;;;;SAMgBA,WAAWA,CAAkBC,KAAoC;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC,aAAa;IAAE,GAAGC;GAAgB,GAAGL,KAAK;EACxE,MAAMM,UAAU,GAAGL,IAAI,CAACM,MAAM,CAACC,SAAS,CAACC,IAA4C;EACrF,MAAMC,UAAU,GAAGC,iBAAiB,CAACV,IAAI,EAAEE,KAAK,EAAEC,aAAa,CAAC;EAChE,MAAMQ,WAAW,GAAG,CAAC,CAACN,UAAU,CAACO,cAAc;EAC/C,MAAMC,KAAK,GAAGb,IAAI,CAACc,QAAQ,EAAS;EAEpC,IAAIC,OAAO;EAEX,IAAIC,gBAAgB,CAAChB,IAAI,CAACM,MAAM,CAACW,EAAE,CAAC,EAAE;IAClCF,OAAO,GAAGG,UAAU,CAAClB,IAAI,CAACM,MAAM,CAACC,SAAS,CAACP,IAAI,EAAEA,IAAI,CAACmB,UAAU,EAAE,CAAC;GACtE,MAAM;IAAA,IAAAC,IAAA,EAAAC,oBAAA,EAAAC,qBAAA;IACHP,OAAO,IAAAK,IAAA,IAAAC,oBAAA,IAAAC,qBAAA,GAAGjB,UAAU,CAACkB,QAAQ,cAAAD,qBAAA,uBAAnBA,qBAAA,CAAAE,IAAA,CAAAnB,UAAU,EAAYQ,KAAK,EAAEb,IAAI,CAACyB,GAAG,CAACC,QAAQ,CAAC,cAAAL,oBAAA,cAAAA,oBAAA,GAAIR,KAAK,cAAAO,IAAA,cAAAA,IAAA,GAAI,IAAI;;EAG9E,oBACIO,6BAACC,iBAAiB,oBAAKxB,cAAc,EAAMK,UAAU;IAAER,OAAO,EAAEA,OAAO;IAAEU,WAAW,EAAEA;MACjFI,OAAO,CACQ;AAE5B;AAOA,MAAMa,iBAAiB,gBAAGD,cAAK,CAACE,IAAI,CAAC,SAASD,iBAAiBA,CAAC7B,KAA6B;EACzF,MAAM;IAAEE,OAAO;IAAE6B,QAAQ;IAAEnB,WAAW;IAAE,GAAGP;GAAgB,GAAGL,KAAK;EAEnE,oBACI4B,qDAAQvB,cAAc;IAAE2B,GAAG,EAAE9B;MACxBU,WAAW,gBAAGgB;IAAMK,SAAS,EAAC;KAA2DF,QAAQ,CAAQ,GAAGA,QAAQ,CACpH;AAEb,CAAC,CAAC;;;;"}
@@ -29,7 +29,7 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
29
29
  const style = {};
30
30
  if (isPinned) {
31
31
  // pinned columns should be offset from either the left or right
32
- style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;
32
+ style[isPinned] = `${footer.column.getStart(isPinned)}px`;
33
33
  }
34
34
  let content;
35
35
  let align;
@@ -1 +1 @@
1
- {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n} from '@tanstack/react-table';\nimport { Summary } from './Summary';\n\nexport type FootProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n return (\n <tfoot>\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} index={index} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n index: number;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} index={props.index} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n index: number;\n};\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, index } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned) - 1}px`;\n }\n\n let content;\n let align;\n\n if (index === 0) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","nonGroupedHeaders","table","getFooterGroups","headers","filter","header","column","getIsGrouped","React","map","index","Footer","key","id","MemoedFooter","footer","memo","columnMeta","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;SAYgBA,IAAIA,CAAkBC,KAAuB;EACzD,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,KAAK,CAACC,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CAACC,MAAM,CAACC,YAAY,EAAE,CAAC;EAClH,oBACIC,yDACIA,yCACKR,iBAAiB,CAACS,GAAG,CAAC,CAACJ,MAAM,EAAEK,KAAK,oBACjCF,6BAACG,MAAM;IAACC,GAAG,EAAEP,MAAM,CAACQ,EAAE;IAAER,MAAM,EAAEA,MAAM;IAAEK,KAAK,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,IAAI,GAAGC,UAAU,CAACrB,MAAM,CAACT,MAAM,CAACY,SAAS,CAACH,MAAM,EAAEA,MAAM,CAACmB,UAAU,EAAE,CAAC;;EAG3G,oBACI1B;IACII,GAAG,EAAEG,MAAM,CAACF,EAAE;uBACGmB,KAAK;oBACRjB,MAAM,CAACF,EAAE;wBACLW,QAAQ,GAAGA,QAAQ,GAAGa,SAAS;IACjDR,KAAK,EAAEA;KACNE,OAAO,CACP;AAEb,CAAC,CAAsE;;;;"}
1
+ {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n} from '@tanstack/react-table';\nimport { Summary } from './Summary';\n\nexport type FootProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n return (\n <tfoot>\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} index={index} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n index: number;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} index={props.index} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n index: number;\n};\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, index } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned)}px`;\n }\n\n let content;\n let align;\n\n if (index === 0) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","nonGroupedHeaders","table","getFooterGroups","headers","filter","header","column","getIsGrouped","React","map","index","Footer","key","id","MemoedFooter","footer","memo","columnMeta","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;SAYgBA,IAAIA,CAAkBC,KAAuB;EACzD,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,KAAK,CAACC,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CAACC,MAAM,CAACC,YAAY,EAAE,CAAC;EAClH,oBACIC,yDACIA,yCACKR,iBAAiB,CAACS,GAAG,CAAC,CAACJ,MAAM,EAAEK,KAAK,oBACjCF,6BAACG,MAAM;IAACC,GAAG,EAAEP,MAAM,CAACQ,EAAE;IAAER,MAAM,EAAEA,MAAM;IAAEK,KAAK,EAAEA;IAAS,CAC3D,CAAC,CACD,CACD;AAEhB;SAMgBC,MAAMA,CAAkBZ,KAAyB;EAC7D,oBAAOS,6BAACM,YAAY;IAACC,MAAM,EAAEhB,KAAK,CAACM,MAAM;IAAEK,KAAK,EAAEX,KAAK,CAACW;IAAS;AACrE;AAMA,MAAMI,YAAY,gBAAGN,c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,GAAGa,SAAS;IACjDR,KAAK,EAAEA;KACNE,OAAO,CACP;AAEb,CAAC,CAAsE;;;;"}
@@ -14,11 +14,11 @@ function SkeletonRow(props) {
14
14
  }));
15
15
  }
16
16
  return /*#__PURE__*/React__default.createElement(Skeleton, {
17
- id: row.id,
18
- cells: row.getVisibleCells()
17
+ cellsCount: row.getVisibleCells().length
19
18
  });
20
19
  }
21
20
  function RowWithServerLoading(props) {
21
+ var _table$getState$group, _table$getState;
22
22
  const {
23
23
  index,
24
24
  row,
@@ -40,23 +40,25 @@ function RowWithServerLoading(props) {
40
40
  (_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, pageIndex, table.getState().sorting, table.getState().columnFilters, table.getState().globalFilter);
41
41
  }
42
42
  }, [inView]);
43
+ const groupedCellCount = (_table$getState$group = (_table$getState = table.getState()) === null || _table$getState === void 0 ? void 0 : _table$getState.grouping.length) !== null && _table$getState$group !== void 0 ? _table$getState$group : 0;
44
+ const ungroupedCellCount = row.getVisibleCells().length - groupedCellCount;
43
45
  return /*#__PURE__*/React__default.createElement(Skeleton, {
44
- cells: row.getVisibleCells(),
46
+ cellsCount: ungroupedCellCount,
45
47
  ref: ref
46
48
  });
47
49
  }
48
50
  const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props, ref) {
49
51
  const {
50
- cells
52
+ cellsCount
51
53
  } = props;
52
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", {
54
+ return /*#__PURE__*/React__default.createElement("tr", {
53
55
  ref: ref
54
- }, cells.map(cell => ( /*#__PURE__*/React__default.createElement("td", {
55
- key: cell.id
56
+ }, Array(cellsCount).fill(null).map((_, index) => ( /*#__PURE__*/React__default.createElement("td", {
57
+ key: index
56
58
  }, /*#__PURE__*/React__default.createElement("span", {
57
59
  className: "bg-grey-100 text-grey-700 h-4 w-full text-center text-xs"
58
- }))))));
60
+ })))));
59
61
  });
60
62
 
61
- export { RowWithServerLoading, Skeleton, SkeletonRow };
63
+ export { SkeletonRow };
62
64
  //# sourceMappingURL=SkeletonRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SkeletonRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport { useInView } from 'react-intersection-observer';\n\nexport type RowProps<TType = unknown> = {\n index: number;\n row: ReactTableRow<TType>;\n table: ReactTable<TType>;\n};\n\nexport function SkeletonRow<TType = unknown>(props: RowProps<TType>) {\n const { index, row, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (tableMeta.server.isEnabled) {\n return <RowWithServerLoading {...props} index={index} />;\n }\n\n return <Skeleton id={row.id} cells={row.getVisibleCells()} />;\n}\n\nexport function RowWithServerLoading<TType = unknown>(props: RowProps<TType>) {\n const { index, row, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const pageIndex = (Math.floor(index / tableMeta.server.pageSize) * tableMeta.server.pageSize) / tableMeta.server.pageSize;\n\n const { ref, inView } = useInView({\n threshold: 0,\n triggerOnce: true,\n initialInView: pageIndex === 0,\n });\n\n React.useEffect(() => {\n if (inView) {\n tableMeta.server.loadPage?.(\n pageIndex,\n table.getState().sorting,\n table.getState().columnFilters,\n table.getState().globalFilter\n );\n }\n }, [inView]);\n\n return <Skeleton cells={row.getVisibleCells()} ref={ref} />;\n}\n\nexport const Skeleton = React.forwardRef(function Skeleton(props: any, ref: React.Ref<HTMLTableRowElement>) {\n const { cells } = props;\n\n return (\n <>\n <tr ref={ref}>\n {cells.map(cell => (\n <td key={cell.id}>\n <span className=\"bg-grey-100 text-grey-700 h-4 w-full text-center text-xs\" />\n </td>\n ))}\n </tr>\n </>\n );\n});\n"],"names":["SkeletonRow","props","index","row","table","tableMeta","options","meta","server","isEnabled","React","RowWithServerLoading","Skeleton","id","cells","getVisibleCells","pageIndex","Math","floor","pageSize","ref","inView","useInView","threshold","triggerOnce","initialInView","useEffect","_tableMeta$server$loa","_tableMeta$server","loadPage","call","getState","sorting","columnFilters","globalFilter","forwardRef","map","cell","key","className"],"mappings":";;;SAUgBA,WAAWA,CAAkBC,KAAsB;EAC/D,MAAM;IAAEC,KAAK;IAAEC,GAAG;IAAEC;GAAO,GAAGH,KAAK;EACnC,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,IAAIF,SAAS,CAACG,MAAM,CAACC,SAAS,EAAE;IAC5B,oBAAOC,6BAACC,oBAAoB,oBAAKV,KAAK;MAAEC,KAAK,EAAEA;OAAS;;EAG5D,oBAAOQ,6BAACE,QAAQ;IAACC,EAAE,EAAEV,GAAG,CAACU,EAAE;IAAEC,KAAK,EAAEX,GAAG,CAACY,eAAe;IAAM;AACjE;SAEgBJ,oBAAoBA,CAAkBV,KAAsB;EACxE,MAAM;IAAEC,KAAK;IAAEC,GAAG;IAAEC;GAAO,GAAGH,KAAK;EACnC,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,MAAMS,SAAS,GAAIC,IAAI,CAACC,KAAK,CAAChB,KAAK,GAAGG,SAAS,CAACG,MAAM,CAACW,QAAQ,CAAC,GAAGd,SAAS,CAACG,MAAM,CAACW,QAAQ,GAAId,SAAS,CAACG,MAAM,CAACW,QAAQ;EAEzH,MAAM;IAAEC,GAAG;IAAEC;GAAQ,GAAGC,SAAS,CAAC;IAC9BC,SAAS,EAAE,CAAC;IACZC,WAAW,EAAE,IAAI;IACjBC,aAAa,EAAET,SAAS,KAAK;GAChC,CAAC;EAEFN,cAAK,CAACgB,SAAS,CAAC;IACZ,IAAIL,MAAM,EAAE;MAAA,IAAAM,qBAAA,EAAAC,iBAAA;MACR,CAAAD,qBAAA,IAAAC,iBAAA,GAAAvB,SAAS,CAACG,MAAM,EAACqB,QAAQ,cAAAF,qBAAA,uBAAzBA,qBAAA,CAAAG,IAAA,CAAAF,iBAAA,EACIZ,SAAS,EACTZ,KAAK,CAAC2B,QAAQ,EAAE,CAACC,OAAO,EACxB5B,KAAK,CAAC2B,QAAQ,EAAE,CAACE,aAAa,EAC9B7B,KAAK,CAAC2B,QAAQ,EAAE,CAACG,YAAY,CAChC;;GAER,EAAE,CAACb,MAAM,CAAC,CAAC;EAEZ,oBAAOX,6BAACE,QAAQ;IAACE,KAAK,EAAEX,GAAG,CAACY,eAAe,EAAE;IAAEK,GAAG,EAAEA;IAAO;AAC/D;MAEaR,QAAQ,gBAAGF,cAAK,CAACyB,UAAU,CAAC,SAASvB,QAAQA,CAACX,KAAU,EAAEmB,GAAmC;EACtG,MAAM;IAAEN;GAAO,GAAGb,KAAK;EAEvB,oBACIS,yEACIA;IAAIU,GAAG,EAAEA;KACJN,KAAK,CAACsB,GAAG,CAACC,IAAI,mBACX3B;IAAI4B,GAAG,EAAED,IAAI,CAACxB;kBACVH;IAAM6B,SAAS,EAAC;IAA6D,CAC5E,CACR,CAAC,CACD,CACN;AAEX,CAAC;;;;"}
1
+ {"version":3,"file":"SkeletonRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport { useInView } from 'react-intersection-observer';\n\nexport type RowProps<TType = unknown> = {\n index: number;\n row: ReactTableRow<TType>;\n table: ReactTable<TType>;\n};\n\nexport function SkeletonRow<TType = unknown>(props: RowProps<TType>) {\n const { index, row, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (tableMeta.server.isEnabled) {\n return <RowWithServerLoading {...props} index={index} />;\n }\n\n return <Skeleton cellsCount={row.getVisibleCells().length} />;\n}\n\nfunction RowWithServerLoading<TType = unknown>(props: RowProps<TType>) {\n const { index, row, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const pageIndex = (Math.floor(index / tableMeta.server.pageSize) * tableMeta.server.pageSize) / tableMeta.server.pageSize;\n\n const { ref, inView } = useInView({\n threshold: 0,\n triggerOnce: true,\n initialInView: pageIndex === 0,\n });\n\n React.useEffect(() => {\n if (inView) {\n tableMeta.server.loadPage?.(\n pageIndex,\n table.getState().sorting,\n table.getState().columnFilters,\n table.getState().globalFilter\n );\n }\n }, [inView]);\n\n const groupedCellCount = table.getState()?.grouping.length ?? 0;\n const ungroupedCellCount = row.getVisibleCells().length - groupedCellCount;\n\n return <Skeleton cellsCount={ungroupedCellCount} ref={ref} />;\n}\n\nconst Skeleton = React.forwardRef(function Skeleton(props: { cellsCount: number }, ref: React.Ref<HTMLTableRowElement>) {\n const { cellsCount } = props;\n\n return (\n <tr ref={ref}>\n {Array(cellsCount)\n .fill(null)\n .map((_, index) => (\n <td key={index}>\n <span className=\"bg-grey-100 text-grey-700 h-4 w-full text-center text-xs\" />\n </td>\n ))}\n </tr>\n );\n});\n"],"names":["SkeletonRow","props","index","row","table","tableMeta","options","meta","server","isEnabled","React","RowWithServerLoading","Skeleton","cellsCount","getVisibleCells","length","pageIndex","Math","floor","pageSize","ref","inView","useInView","threshold","triggerOnce","initialInView","useEffect","_tableMeta$server$loa","_tableMeta$server","loadPage","call","getState","sorting","columnFilters","globalFilter","groupedCellCount","_table$getState$group","_table$getState","grouping","ungroupedCellCount","forwardRef","Array","fill","map","_","key","className"],"mappings":";;;SAUgBA,WAAWA,CAAkBC,KAAsB;EAC/D,MAAM;IAAEC,KAAK;IAAEC,GAAG;IAAEC;GAAO,GAAGH,KAAK;EACnC,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,IAAIF,SAAS,CAACG,MAAM,CAACC,SAAS,EAAE;IAC5B,oBAAOC,6BAACC,oBAAoB,oBAAKV,KAAK;MAAEC,KAAK,EAAEA;OA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GpC,GAAG,CAACW,eAAe,EAAE,CAACC,MAAM,GAAGoB,gBAAgB;EAE1E,oBAAOzB,6BAACE,QAAQ;IAACC,UAAU,EAAE0B,kBAAkB;IAAEnB,GAAG,EAAEA;IAAO;AACjE;AAEA,MAAMR,QAAQ,gBAAGF,cAAK,CAAC8B,UAAU,CAAC,SAAS5B,QAAQA,CAACX,KAA6B,EAAEmB,GAAmC;EAClH,MAAM;IAAEP;GAAY,GAAGZ,KAAK;EAE5B,oBACIS;IAAIU,GAAG,EAAEA;KACJqB,KAAK,CAAC5B,UAAU,CAAC,CACb6B,IAAI,CAAC,IAAI,CAAC,CACVC,GAAG,CAAC,CAACC,CAAC,EAAE1C,KAAK,oBACVQ;IAAImC,GAAG,EAAE3C;kBACLQ;IAAMoC,SAAS,EAAC;IAA6D,CAC5E,CACR,CAAC,CACL;AAEb,CAAC,CAAC;;;;"}
@@ -1,16 +1,17 @@
1
1
  import React__default from 'react';
2
2
  import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
3
- import { HEADER_ROW_HEIGHT_ESTIMATE, ROW_HEIGHT_ESTIMATES } from '../util/rows.js';
3
+ import { HEADER_FOOTER_ROW_HEIGHT_ESTIMATE, ROW_HEIGHT_ESTIMATES } from '../util/rows.js';
4
4
  import { Row } from '../components/Row/Row.js';
5
5
 
6
6
  const TABLE_SCROLL_PADDING_BOTTOM = 36;
7
- const TABLE_PADDING_BOTTOM = 120;
7
+ const TABLE_PADDING_BOTTOM = 0;
8
8
  function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
9
9
  var _table$getState$group, _ref, _virtualItems$padding, _virtualItems$padding2, _ref2, _virtualItems;
10
10
  const tableMeta = table.options.meta;
11
11
  const rows = table.getRowModel().rows;
12
- const HEADER_OFFSET_TOTAL = HEADER_ROW_HEIGHT_ESTIMATE * table.getHeaderGroups().length;
12
+ const HEADER_OFFSET_TOTAL = HEADER_FOOTER_ROW_HEIGHT_ESTIMATE * table.getHeaderGroups().length;
13
13
  const isTableGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
14
+ const FOOTER_OFFSET_TOTAL = tableMeta.footer.isEnabled ? HEADER_FOOTER_ROW_HEIGHT_ESTIMATE : 0;
14
15
  // expanded rows
15
16
  const {
16
17
  createRowMeasurer,
@@ -24,7 +25,7 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
24
25
  getScrollElement: () => tableRef.current,
25
26
  overscan: tableMeta.printing.isPrinting ? rows.length : undefined,
26
27
  rangeExtractor,
27
- scrollPaddingStart: isTableGrouped ? HEADER_ROW_HEIGHT_ESTIMATE : undefined,
28
+ scrollPaddingStart: isTableGrouped ? HEADER_FOOTER_ROW_HEIGHT_ESTIMATE : undefined,
28
29
  scrollPaddingEnd: HEADER_OFFSET_TOTAL + TABLE_SCROLL_PADDING_BOTTOM,
29
30
  paddingEnd: TABLE_PADDING_BOTTOM
30
31
  });
@@ -77,7 +78,7 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
77
78
  let content = null;
78
79
  if (rows.length) {
79
80
  style = {
80
- height: `${virtualiser.getTotalSize()}px`,
81
+ height: `${virtualiser.getTotalSize() - HEADER_OFFSET_TOTAL + FOOTER_OFFSET_TOTAL}px`,
81
82
  paddingBottom,
82
83
  paddingTop
83
84
  };
@@ -156,7 +157,7 @@ function useRowGroupVirtualisation(table) {
156
157
  });
157
158
  }
158
159
  return indexes;
159
- }, []);
160
+ }, [rows]);
160
161
  // this is taken from the react-virtual docs/examples
161
162
  const rangeExtractor = React__default.useCallback(range => {
162
163
  var _reverse$find;