@economic/taco 2.20.2 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. package/dist/components/Report/components/Body/Body.d.ts +1 -0
  2. package/dist/components/Report/components/Body/util.d.ts +6 -0
  3. package/dist/components/Report/components/Cell/Cell.d.ts +7 -1
  4. package/dist/components/Report/components/Cell/DisplayCell.d.ts +3 -2
  5. package/dist/components/Report/components/Cell/GroupedCell.d.ts +3 -2
  6. package/dist/components/Report/components/Row/Row.d.ts +2 -1
  7. package/dist/components/Report/components/Row/RowContext.d.ts +0 -1
  8. package/dist/components/Table3/hooks/features/useEditing.d.ts +2 -2
  9. package/dist/esm/packages/taco/src/components/Table3/Table3.js +4 -2
  10. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +10 -1
  12. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +16 -1
  14. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +1 -1
  16. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  17. package/dist/esm/packages/taco/src/utils/dom.js +12 -3
  18. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  19. package/dist/taco.cjs.development.js +42 -8
  20. package/dist/taco.cjs.development.js.map +1 -1
  21. package/dist/taco.cjs.production.min.js +1 -1
  22. package/dist/taco.cjs.production.min.js.map +1 -1
  23. package/package.json +2 -2
  24. package/types.json +4054 -3906
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Table as ReactTable } from '@tanstack/react-table';
3
3
  declare type BodyProps<TType = unknown> = React.HTMLAttributes<HTMLTableSectionElement> & {
4
+ enableArrowKeyFocusing?: boolean;
4
5
  length: number;
5
6
  table: ReactTable<TType>;
6
7
  };
@@ -0,0 +1,6 @@
1
+ export declare function useAugmentedFocusManager(): {
2
+ focusPrevious: () => import("@react-types/shared").FocusableElement;
3
+ focusNext: () => import("@react-types/shared").FocusableElement;
4
+ focusFirst: () => import("@react-types/shared").FocusableElement;
5
+ focusLast: () => import("@react-types/shared").FocusableElement;
6
+ };
@@ -1,3 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { Cell as ReactTableCell } from '@tanstack/react-table';
3
- export declare function Cell<TType = unknown>(cell: ReactTableCell<TType, unknown>, index: number): JSX.Element | null;
3
+ declare type CellProps<TType = unknown> = {
4
+ cell: ReactTableCell<TType, unknown>;
5
+ index: number;
6
+ rowIndex: number;
7
+ };
8
+ export declare function Cell<TType = unknown>(props: CellProps<TType>): JSX.Element | null;
9
+ export {};
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { Cell as ReactTableCell } from '@tanstack/react-table';
3
3
  export declare type DisplayCellProps<TType = unknown> = {
4
- index: number;
5
4
  cell: ReactTableCell<TType, unknown>;
5
+ cellRef: React.RefObject<HTMLTableCellElement>;
6
+ isHighlighted?: true | 'current';
6
7
  };
7
8
  export declare function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>): JSX.Element;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { Cell as ReactTableCell } from '@tanstack/react-table';
3
3
  export declare type GroupedCellProps<TType = unknown> = {
4
- index: number;
5
4
  cell: ReactTableCell<TType, unknown>;
5
+ cellRef: React.RefObject<HTMLTableCellElement>;
6
+ isHighlighted?: true | 'current';
6
7
  };
7
8
  export declare function GroupedCell<TType = unknown>(props: GroupedCellProps<TType>): JSX.Element;
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { Table as ReactTable, Row as ReactTableRow } from '@tanstack/react-table';
3
3
  export declare type RowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> & {
4
4
  index: number;
5
+ measureRow: (size: number, expansionHeight?: number) => void;
5
6
  row: ReactTableRow<TType>;
6
7
  table: ReactTable<TType>;
7
8
  };
8
- export declare function Row<TType = unknown>(row: ReactTableRow<TType>, index: number, table: ReactTable<TType>, measureRow: (size: number, expansionHeight?: number) => void): JSX.Element;
9
+ export declare function Row<TType = unknown>(props: RowProps<TType>): JSX.Element;
@@ -5,5 +5,4 @@ declare type RowContextValue = {
5
5
  rowIndex: number;
6
6
  };
7
7
  export declare const RowContext: React.Context<RowContextValue>;
8
- export declare const useRowContext: () => RowContextValue;
9
8
  export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Cell as RTCell } from '@tanstack/react-table';
3
- import { Table3SaveHandler } from '../../types';
3
+ import { Table3Ref, Table3SaveHandler } from '../../types';
4
4
  import { IndicatorReason } from '../../components/columns/cell/Indicator';
5
5
  import { Table3Validation } from './useValidation';
6
6
  export declare enum SavingStatusValue {
@@ -8,7 +8,7 @@ export declare enum SavingStatusValue {
8
8
  Saved = "saved",
9
9
  Error = "error"
10
10
  }
11
- export declare function useEditing<TType = unknown>(isEnabled: boolean, validation: Table3Validation<TType>, onSave?: Table3SaveHandler<TType>): {
11
+ export declare function useEditing<TType = unknown>(isEnabled: boolean, tableRef: React.RefObject<Table3Ref>, validation: Table3Validation<TType>, onSave?: Table3SaveHandler<TType>): {
12
12
  isEnabled: boolean;
13
13
  isEditing: boolean;
14
14
  toggleEditing: React.Dispatch<React.SetStateAction<boolean>>;
@@ -192,7 +192,9 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
192
192
  role: "rowgroup",
193
193
  ref: bodyRef
194
194
  }, renderBody())), /*#__PURE__*/React__default.createElement("div", {
195
- className: "border-grey-300 col-span-full translate-y-px border-t"
195
+ className: cn('border-grey-300 col-span-full border-t', {
196
+ 'translate-y-px': tableMeta.enableFooter
197
+ })
196
198
  }), tableMeta.enableFooter ? ( /*#__PURE__*/React__default.createElement("div", {
197
199
  className: "group/footer contents",
198
200
  "data-taco": "table2-footer",
@@ -210,7 +212,7 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
210
212
  length: length,
211
213
  table: table
212
214
  })) : null)) : null)) : ( /*#__PURE__*/React__default.createElement("div", {
213
- className: "col-span-full min-h-[theme(spacing.8)]"
215
+ className: "col-span-full box-border min-h-[theme(spacing.8)]"
214
216
  }, EmptyState ? /*#__PURE__*/React__default.createElement(EmptyState, null) : null))));
215
217
  });
216
218
  const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { ErrorAlert } from './components/alert/ErrorAlert';\nimport { fixedForwardRef, FontSizes } from '../../types';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const {\n emptyState: EmptyState,\n customSettings,\n toolbarLeft,\n toolbarRight,\n defaultCurrentRowIndex: defaultRowActiveIndex,\n } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props, internalRef);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n // On a very first render, the tanstack table rendered without any rows,\n // so we delaying default row scrolling logic with using of requestAnimation frame\n const animationFrameId = requestAnimationFrame(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center' });\n }\n });\n\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, []);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n // Select2 also have combobox role to align with W3C guidelines\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]:not([data-taco=\"Select2\"])');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (\n eventOriginatedFromCombobox ||\n (dialog && !dialog?.contains(internalRef.current)) ||\n tableMeta.shortcutsState.isPaused\n ) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n\n tableMeta.rowActive.handleKeyDown(\n event,\n rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing ? undefined : internalRef\n );\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current, tableMeta.rowActive.rowActiveIndex]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.rowActive.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FontSizes.small,\n 'text-sm': tableMeta.fontSize.size === FontSizes.medium,\n 'text-base': tableMeta.fontSize.size === FontSizes.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.printing.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle && !tableMeta.printing.isPrinting ? (\n <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style>\n ) : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <ErrorAlert table={table} tableRef={internalRef} scrollToIndex={scrollToIndex} rowIdentifier={props.rowIdentifier} />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.rowActive.isHoverStatePaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div className=\"group/body contents\" data-taco=\"table2-body\" role=\"rowgroup\" ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {\n // Render the footer cell only for individual columns, excluding column groups.\n table\n .getFooterGroups()\n .slice(0, 1)\n .map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))\n }\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","Table","fixedForwardRef","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","defaultCurrentRowIndex","defaultRowActiveIndex","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","React","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","animationFrameId","requestAnimationFrame","align","cancelAnimationFrame","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","shortcutsState","isPaused","rows","getRowModel","rowActive","editing","isEditing","undefined","rowActiveIndex","_rows$tableMeta$rowAc","rowClick","original","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","handleFocus","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FontSizes","small","medium","large","style","cssGridStyle","useCssGrid","printing","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","ErrorAlert","tableRef","rowIdentifier","horizontallyScrolled","isHoverStatePaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","enableFooter","getFooterGroups","slice","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAEjC,MAAME,KAAK,gBAAGC,eAAe,CAAC,SAASC,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EAC/G,MAAM;IACFC,UAAU,EAAEC,UAAU;IACtBC,cAAc;IACdC,WAAW;IACXC,YAAY;IACZC,sBAAsB,EAAEC;GAC3B,GAAGR,KAAK;EACT,MAAMS,WAAW,GAAGC,YAAY,CAAYT,GAAG,CAAC;EAEhD,MAAM;IAAEU,KAAK;IAAEC;GAAQ,GAAGC,QAAQ,CAAQb,KAAK,EAAES,WAAW,CAAC;EAC7DK,wBAAwB,CAACH,KAAK,EAAEF,WAAW,CAAC;EAE5CM,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIhB,KAAK,CAACiB,SAAS,EAAE;MAAA,IAAAC,oBAAA;MACjB,CAAAA,oBAAA,GAAAT,WAAW,CAACU,OAAO,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAqBE,KAAK,EAAE;;GAEnC,EAAE,EAAE,CAAC;EAEN,MAAM;IAAEC,UAAU;IAAEC;GAAe,GAAGC,sBAAsB,CAAQvB,KAAK,EAAEW,KAAK,EAAEF,WAAW,CAAC;EAC9F,MAAMe,SAAS,GAAGb,KAAK,CAACc,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGhB,KAAK,CAACiB,QAAQ,EAAE;EAE9B,MAAMC,OAAO,GAAGd,cAAK,CAACe,MAAM,CAAwB,IAAI,CAAC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AACD,IAAI,CAAChC,MAAM;IAAEA,MAAM,EAAEA,MAAM;IAAED,KAAK,EAAEA;IAAS,IACzF,IAAI,CACN,IACN,IAAI,CACT,mBAEHI;IAAKoD,SAAS,EAAC;KAA0ChE,UAAU,gBAAGY,6BAACZ,UAAU,OAAG,GAAG,IAAI,CAAO,CACrG,CACC,CACP;AAEX,CAAC,CAAC;MAOWJ,MAAM,gBAAGD,eAAe,CAAC,SAASC,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EACvH,MAAMsI,mBAAmB,GAAGC,MAAM,CAACxI,KAAK,CAACyI,QAAQ,CAAC;;;EAGlD,MAAMvB,GAAG,GAAGnG,cAAK,CAAC2H,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOxH,6BAAClB,KAAK,oBAAYG,KAAK;IAAEkH,GAAG,EAAEA,GAAG;IAAEjH,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACN,MAAM,GAAGA,MAAM;AACtBM,MAAM,CAACH,KAAK,GAAGA,KAAK;;;;"}
1
+ {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { ErrorAlert } from './components/alert/ErrorAlert';\nimport { fixedForwardRef, FontSizes } from '../../types';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const {\n emptyState: EmptyState,\n customSettings,\n toolbarLeft,\n toolbarRight,\n defaultCurrentRowIndex: defaultRowActiveIndex,\n } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props, internalRef);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n // On a very first render, the tanstack table rendered without any rows,\n // so we delaying default row scrolling logic with using of requestAnimation frame\n const animationFrameId = requestAnimationFrame(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center' });\n }\n });\n\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, []);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n // Select2 also have combobox role to align with W3C guidelines\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]:not([data-taco=\"Select2\"])');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (\n eventOriginatedFromCombobox ||\n (dialog && !dialog?.contains(internalRef.current)) ||\n tableMeta.shortcutsState.isPaused\n ) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n\n tableMeta.rowActive.handleKeyDown(\n event,\n rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing ? undefined : internalRef\n );\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current, tableMeta.rowActive.rowActiveIndex]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.rowActive.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FontSizes.small,\n 'text-sm': tableMeta.fontSize.size === FontSizes.medium,\n 'text-base': tableMeta.fontSize.size === FontSizes.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.printing.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle && !tableMeta.printing.isPrinting ? (\n <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style>\n ) : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <ErrorAlert table={table} tableRef={internalRef} scrollToIndex={scrollToIndex} rowIdentifier={props.rowIdentifier} />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.rowActive.isHoverStatePaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div className=\"group/body contents\" data-taco=\"table2-body\" role=\"rowgroup\" ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div\n className={cn('border-grey-300 col-span-full border-t', { 'translate-y-px': tableMeta.enableFooter })}\n />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {\n // Render the footer cell only for individual columns, excluding column groups.\n table\n .getFooterGroups()\n .slice(0, 1)\n .map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))\n }\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full box-border min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","Table","fixedForwardRef","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","defaultCurrentRowIndex","defaultRowActiveIndex","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","React","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","animationFrameId","requestAnimationFrame","align","cancelAnimationFrame","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","shortcutsState","isPaused","rows","getRowModel","rowActive","editing","isEditing","undefined","rowActiveIndex","_rows$tableMeta$rowAc","rowClick","original","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","handleFocus","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FontSizes","small","medium","large","style","cssGridStyle","useCssGrid","printing","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","ErrorAlert","tableRef","rowIdentifier","horizontallyScrolled","isHoverStatePaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","enableFooter","getFooterGroups","slice","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAEjC,MAAME,KAAK,gBAAGC,eAAe,CAAC,SAASC,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EAC/G,MAAM;IACFC,UAAU,EAAEC,UAAU;IACtBC,cAAc;IACdC,WAAW;IACXC,YAAY;IACZC,sBAAsB,EAAEC;GAC3B,GAAGR,KAAK;EACT,MAAMS,WAAW,GAAGC,YAAY,CAAYT,GAAG,CAAC;EAEhD,MAAM;IAAEU,KAAK;IAAEC;GAAQ,GAAGC,QAAQ,CAAQb,KAAK,EAAES,WAAW,CAAC;EAC7DK,wBAAwB,CAACH,KAAK,EAAEF,WAAW,CAAC;EAE5CM,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIhB,KAAK,CAACiB,SAAS,EAAE;MAAA,IAAAC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/React__default.forwardRef(function Textarea
25
25
  onKeyDown: handleKeyDown,
26
26
  onChange: handleChange,
27
27
  onBlur,
28
+ onFocus,
28
29
  column,
29
30
  isCellInDetailMode,
30
31
  align,
@@ -98,6 +99,13 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
98
99
  }
99
100
  onBlur(event);
100
101
  };
102
+ const handleFocus = event => {
103
+ const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
104
+ if (textareaElement) {
105
+ resizeTextArea(textareaElement);
106
+ }
107
+ onFocus(event);
108
+ };
101
109
  return /*#__PURE__*/React__default.createElement("div", {
102
110
  "data-taco": "input-container"
103
111
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -117,7 +125,8 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
117
125
  handleTextareaKeyDown(e);
118
126
  },
119
127
  onBlur: handleBlur,
120
- className: cn(getCellAlignmentClasses(align), `h-fit resize-none [&:not(:focus)]:whitespace-nowrap`, {
128
+ onFocus: handleFocus,
129
+ className: cn(getCellAlignmentClasses(align), `h-fit resize-none overflow-y-hidden focus:overflow-y-auto [&:not(:focus)]:whitespace-nowrap`, {
121
130
  [`!min-h-[${minMaxHeight.min}px]`]: columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate,
122
131
  '!yt-focus-dark': isCellInDetailMode,
123
132
  [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate),
@@ -1 +1 @@
1
- {"version":3,"file":"TextareaControl.js","sources":["../../../../../../../../../../../src/components/Table3/components/columns/cell/controls/TextareaControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Textarea } from '../../../../../Textarea/Textarea';\nimport { EditingControlProps } from '../EditingControl';\nimport { getCellAlignmentClasses } from '../../styles';\nimport { useMergedRef } from '../../../../../../hooks/useMergedRef';\nimport { FontSize } from '../../../../../../types';\n\ntype TextareaHeight = {\n min: number;\n max: number;\n};\n// By UX design, textarea should fold to min size when blured and extend to max 5 lines height when edited in enableTruncate mode,\n// for this reason we need to set min/max height limits for each font size value.\nconst heights: Record<FontSize, TextareaHeight> = {\n small: {\n min: 24,\n max: 86,\n },\n medium: {\n min: 32,\n max: 100,\n },\n large: {\n min: 40,\n max: 140,\n },\n};\n\ntype TextareaControlProps<TType = unknown> = EditingControlProps<TType> & {\n onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n fontSize: FontSize;\n invalid: boolean;\n isCellInDetailMode?: boolean;\n};\n\nexport const TextareaControl = React.forwardRef<HTMLElement, any>(function TextareaControl<TType = unknown>(\n props: TextareaControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n onBlur,\n column,\n isCellInDetailMode,\n align,\n isActiveRow,\n value,\n fontSize,\n ...attributes\n } = props;\n\n const minMaxHeight = heights[fontSize];\n\n const columnMeta = column.columnDef.meta;\n\n const ref = useMergedRef<HTMLTextAreaElement>(externalRef);\n\n React.useEffect(() => {\n if (ref?.current) {\n // Need to reset textarea to min height when font size got changed and if column in enable truncate mode.\n if (columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n\n // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized or fonsSize got changed.\n } else {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n resizeTextArea(textareaElement);\n }\n }\n }, [fontSize]);\n\n React.useEffect(() => {\n // If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.\n // Otherwise it should collapse to minimal height.\n if (ref?.current && columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n\n if (isCellInDetailMode) {\n resizeTextArea(textareaElement);\n } else {\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n }\n }, [isCellInDetailMode]);\n\n const resizeTextArea = (textareaElement: HTMLTextAreaElement) => {\n // Need to set inherit before calculating height, so that browser sets the scrollHeight properly,\n // depending on text inside.\n const textareaRect = textareaElement.getBoundingClientRect();\n const prevHeight = textareaRect.height;\n if (columnMeta?.enableTruncate) {\n if (prevHeight < minMaxHeight.max) {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, minMaxHeight.max)}px`;\n }\n } else {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${textareaElement.scrollHeight}px`;\n }\n };\n\n const handleTextareaChange = e => {\n resizeTextArea(e.target);\n };\n\n const textareaContainerClassName = cn('w-full', {\n 'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-[9]': columnMeta?.enableTruncate,\n });\n const handleTextareaKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // By default Shift + Enter in textarea makes a new line, we want to keep this behaviour\n if (event.shiftKey && event.key === 'Enter') {\n return;\n } else {\n handleKeyDown(event);\n }\n };\n\n const handleBlur = event => {\n // If truncation is enabled, then textarea should shring back to min height, when loosing focus.\n if (columnMeta?.enableTruncate) {\n const textareaElement = event.currentTarget;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n onBlur(event);\n };\n\n return (\n <div data-taco=\"input-container\">\n {/**\n * Textarea should have min height placeholder, because it becomes absolute positioned when focused,\n * which leads to overlapping of validation message rendered bellow.\n * Somehow tailwind cannot dynamically assign min height when arbitary value has been used(in this particular case),\n * so assigning it through style prop here\n **/}\n <div style={{ minHeight: `${minMaxHeight.min}px` }} className=\"relative\">\n <div className={textareaContainerClassName}>\n <Textarea\n {...attributes}\n onChange={event => {\n handleChange(event.target.value);\n handleTextareaChange(event);\n }}\n rows={1}\n onKeyDown={e => {\n handleTextareaKeyDown(e);\n }}\n onBlur={handleBlur}\n className={cn(getCellAlignmentClasses(align), `h-fit resize-none [&:not(:focus)]:whitespace-nowrap`, {\n [`!min-h-[${minMaxHeight.min}px]`]: columnMeta?.enableTruncate,\n '!yt-focus-dark': isCellInDetailMode,\n [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && columnMeta?.enableTruncate,\n // Only allow resizing when focused and truncation enabled\n 'focus:resize-y': isActiveRow && columnMeta?.enableTruncate,\n })}\n ref={ref}\n value={String(value ?? '')}\n />\n </div>\n </div>\n </div>\n );\n});\n"],"names":["heights","small","min","max","medium","large","TextareaControl","React","forwardRef","props","externalRef","onKeyDown","handleKeyDown","onChange","handleChange","onBlur","column","isCellInDetailMode","align","isActiveRow","value","fontSize","attributes","minMaxHeight","columnMeta","columnDef","meta","ref","useMergedRef","useEffect","current","enableTruncate","textareaElement","style","height","resizeTextArea","textareaRect","getBoundingClientRect","prevHeight","Math","scrollHeight","handleTextareaChange","e","target","textareaContainerClassName","cn","handleTextareaKeyDown","event","shiftKey","key","handleBlur","currentTarget","minHeight","className","Textarea","rows","getCellAlignmentClasses","String"],"mappings":";;;;;;AAYA;AACA;AACA,MAAMA,OAAO,GAAqC;EAC9CC,KAAK,EAAE;IACHC,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJF,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDE,KAAK,EAAE;IACHH,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;;CAEZ;MASYG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASF,eAAeA,CACtFG,KAAkC,EAClCC,WAAmC;EAEnC,MAAM;IACFC,SAAS,EAAEC,aAAa;IACxBC,QAAQ,EAAEC,YAAY;IACtBC,MAAM;IACNC,MAAM;IACNC,kBAAkB;IAClBC,KAAK;IACLC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACR,GAAGC;GACN,GAAGb,KAAK;EAET,MAAMc,YAAY,GAAGvB,OAAO,CAACqB,QAAQ,CAAC;EAEtC,MAAMG,UAAU,GAAGR,MAAM,CAACS,SAAS,CAACC,IAAI;EAExC,MAAMC,GAAG,GAAGC,YAAY,CAAsBlB,WAAW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AqB,CAACJ,CAAC,CAAC;KAC3B;IACD3B,MAAM,EAAEmC,UAAU;IAClBG,SAAS,EAAER,EAAE,CAACW,uBAAuB,CAACtC,KAAK,CAAC,uDAAuD,EAAE;MACjG,YAAYK,YAAY,CAACrB,QAAQ,GAAGsB,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;MAC9D,gBAAgB,EAAEd,kBAAkB;MACpC,OAAOM,YAAY,CAACrB,QAAQ,GAAG,CAACe,kBAAkB,KAAIO,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;;MAEhF,gBAAgB,EAAEZ,WAAW,KAAIK,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;KAC9D,CAAC;IACFJ,GAAG,EAAEA,GAAG;IACRP,KAAK,EAAEqC,MAAM,CAACrC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC3B,CACA,CACJ,CACJ;AAEd,CAAC;;;;"}
1
+ {"version":3,"file":"TextareaControl.js","sources":["../../../../../../../../../../../src/components/Table3/components/columns/cell/controls/TextareaControl.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Textarea } from '../../../../../Textarea/Textarea';\nimport { EditingControlProps } from '../EditingControl';\nimport { getCellAlignmentClasses } from '../../styles';\nimport { useMergedRef } from '../../../../../../hooks/useMergedRef';\nimport { FontSize } from '../../../../../../types';\n\ntype TextareaHeight = {\n min: number;\n max: number;\n};\n// By UX design, textarea should fold to min size when blured and extend to max 5 lines height when edited in enableTruncate mode,\n// for this reason we need to set min/max height limits for each font size value.\nconst heights: Record<FontSize, TextareaHeight> = {\n small: {\n min: 24,\n max: 86,\n },\n medium: {\n min: 32,\n max: 100,\n },\n large: {\n min: 40,\n max: 140,\n },\n};\n\ntype TextareaControlProps<TType = unknown> = EditingControlProps<TType> & {\n onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n fontSize: FontSize;\n invalid: boolean;\n isCellInDetailMode?: boolean;\n};\n\nexport const TextareaControl = React.forwardRef<HTMLElement, any>(function TextareaControl<TType = unknown>(\n props: TextareaControlProps<TType>,\n externalRef: React.Ref<HTMLElement>\n) {\n const {\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n onBlur,\n onFocus,\n column,\n isCellInDetailMode,\n align,\n isActiveRow,\n value,\n fontSize,\n ...attributes\n } = props;\n\n const minMaxHeight = heights[fontSize];\n\n const columnMeta = column.columnDef.meta;\n\n const ref = useMergedRef<HTMLTextAreaElement>(externalRef);\n\n React.useEffect(() => {\n if (ref?.current) {\n // Need to reset textarea to min height when font size got changed and if column in enable truncate mode.\n if (columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n\n // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized or fonsSize got changed.\n } else {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n resizeTextArea(textareaElement);\n }\n }\n }, [fontSize]);\n\n React.useEffect(() => {\n // If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.\n // Otherwise it should collapse to minimal height.\n if (ref?.current && columnMeta?.enableTruncate) {\n const textareaElement = ref?.current as HTMLTextAreaElement;\n\n if (isCellInDetailMode) {\n resizeTextArea(textareaElement);\n } else {\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n }\n }, [isCellInDetailMode]);\n\n const resizeTextArea = (textareaElement: HTMLTextAreaElement) => {\n // Need to set inherit before calculating height, so that browser sets the scrollHeight properly,\n // depending on text inside.\n const textareaRect = textareaElement.getBoundingClientRect();\n const prevHeight = textareaRect.height;\n if (columnMeta?.enableTruncate) {\n if (prevHeight < minMaxHeight.max) {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, minMaxHeight.max)}px`;\n }\n } else {\n textareaElement.style.height = 'inherit';\n textareaElement.style.height = `${textareaElement.scrollHeight}px`;\n }\n };\n\n const handleTextareaChange = e => {\n resizeTextArea(e.target);\n };\n\n const textareaContainerClassName = cn('w-full', {\n 'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-[9]': columnMeta?.enableTruncate,\n });\n const handleTextareaKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // By default Shift + Enter in textarea makes a new line, we want to keep this behaviour\n if (event.shiftKey && event.key === 'Enter') {\n return;\n } else {\n handleKeyDown(event);\n }\n };\n\n const handleBlur = event => {\n // If truncation is enabled, then textarea should shring back to min height, when loosing focus.\n if (columnMeta?.enableTruncate) {\n const textareaElement = event.currentTarget;\n textareaElement.style.height = `${minMaxHeight.min}px`;\n }\n onBlur(event);\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n const textareaElement = ref?.current;\n\n if (textareaElement) {\n resizeTextArea(textareaElement);\n }\n\n onFocus(event);\n };\n\n return (\n <div data-taco=\"input-container\">\n {/**\n * Textarea should have min height placeholder, because it becomes absolute positioned when focused,\n * which leads to overlapping of validation message rendered bellow.\n * Somehow tailwind cannot dynamically assign min height when arbitary value has been used(in this particular case),\n * so assigning it through style prop here\n **/}\n <div style={{ minHeight: `${minMaxHeight.min}px` }} className=\"relative\">\n <div className={textareaContainerClassName}>\n <Textarea\n {...attributes}\n onChange={event => {\n handleChange(event.target.value);\n handleTextareaChange(event);\n }}\n rows={1}\n onKeyDown={e => {\n handleTextareaKeyDown(e);\n }}\n onBlur={handleBlur}\n onFocus={handleFocus}\n className={cn(\n getCellAlignmentClasses(align),\n `h-fit resize-none overflow-y-hidden focus:overflow-y-auto [&:not(:focus)]:whitespace-nowrap`,\n {\n [`!min-h-[${minMaxHeight.min}px]`]: columnMeta?.enableTruncate,\n '!yt-focus-dark': isCellInDetailMode,\n [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && columnMeta?.enableTruncate,\n // Only allow resizing when focused and truncation enabled\n 'focus:resize-y': isActiveRow && columnMeta?.enableTruncate,\n }\n )}\n ref={ref}\n value={String(value ?? '')}\n />\n </div>\n </div>\n </div>\n );\n});\n"],"names":["heights","small","min","max","medium","large","TextareaControl","React","forwardRef","props","externalRef","onKeyDown","handleKeyDown","onChange","handleChange","onBlur","onFocus","column","isCellInDetailMode","align","isActiveRow","value","fontSize","attributes","minMaxHeight","columnMeta","columnDef","meta","ref","useMergedRef","useEffect","current","enableTruncate","textareaElement","style","height","resizeTextArea","textareaRect","getBoundingClientRect","prevHeight","Math","scrollHeight","handleTextareaChange","e","target","textareaContainerClassName","cn","handleTextareaKeyDown","event","shiftKey","key","handleBlur","currentTarget","handleFocus","minHeight","className","Textarea","rows","getCellAlignmentClasses","String"],"mappings":";;;;;;AAYA;AACA;AACA,MAAMA,OAAO,GAAqC;EAC9CC,KAAK,EAAE;IACHC,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJF,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;GACR;EACDE,KAAK,EAAE;IACHH,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;;CAEZ;MASYG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CAAmB,SAASF,eAAeA,CACtFG,KAAkC,EAClCC,WAAmC;EAEnC,MAAM;IACFC,SAAS,EAAEC,aAAa;IACxBC,QAAQ,EAAEC,YAAY;IACtBC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,kBAAkB;IAClBC,KAAK;IACLC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACR,GAAGC;GACN,GAAGd,KAAK;EAET,MAAMe,YAAY,GAAGxB,OAAO,CAACsB,QAAQ,CAAC;EAEtC,MAAMG,UAAU,GAAGR,MAAM,CAACS,SAAS,CAACC,IAAI;EAExC,MAAMC,GAAG,GAAGC,YAAY,CAAsBnB,WAAW,CAAC;EAE1DH,cAAK,CAACuB,SAAS,CAAC;IACZ,IAAIF,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEG,OAAO,EAAE;;MAEd,IAAIN,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAA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EAAE,CAAC;IACP9C,SAAS,EAAEgC,CAAC;MACRI,qBAAqB,CAACJ,CAAC,CAAC;KAC3B;IACD5B,MAAM,EAAEoC,UAAU;IAClBnC,OAAO,EAAEqC,WAAW;IACpBE,SAAS,EAAET,EAAE,CACTY,uBAAuB,CAACvC,KAAK,CAAC,+FAC+D,EAC7F;MACI,YAAYK,YAAY,CAACtB,QAAQ,GAAGuB,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;MAC9D,gBAAgB,EAAEd,kBAAkB;MACpC,OAAOM,YAAY,CAACtB,QAAQ,GAAG,CAACgB,kBAAkB,KAAIO,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;;MAEhF,gBAAgB,EAAEZ,WAAW,KAAIK,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,cAAc;KAC9D,CACJ;IACDJ,GAAG,EAAEA,GAAG;IACRP,KAAK,EAAEsC,MAAM,CAACtC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC3B,CACA,CACJ,CACJ;AAEd,CAAC;;;;"}
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { shouldTriggerShortcut } from '../../../../utils/keyboard.js';
3
+ import { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom.js';
3
4
  import _ from 'lodash-es';
4
5
  import { lastCellIndex } from '../../components/rows/Row.js';
5
6
 
@@ -9,7 +10,7 @@ var SavingStatusValue;
9
10
  SavingStatusValue["Saved"] = "saved";
10
11
  SavingStatusValue["Error"] = "error";
11
12
  })(SavingStatusValue || (SavingStatusValue = {}));
12
- function useEditing(isEnabled, validation, onSave) {
13
+ function useEditing(isEnabled, tableRef, validation, onSave) {
13
14
  // used to switch the table into editing mode
14
15
  const [isEditing, setIsEditing] = React__default.useState(false);
15
16
  // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',
@@ -176,6 +177,20 @@ function useEditing(isEnabled, validation, onSave) {
176
177
  }
177
178
  return false;
178
179
  }, [isEditing, editingState]);
180
+ React__default.useEffect(() => {
181
+ const handleClickOutside = event => {
182
+ const target = event.target;
183
+ const closestPopup = target.closest('[role="dialog"], [role="menu"]');
184
+ // Need to check that neither target itself nor closest popup is inside or triggetred from the table.
185
+ if (!isElementInsideOrTriggeredFromContainer(target, tableRef.current) && !isElementInsideOrTriggeredFromContainer(closestPopup, tableRef.current)) {
186
+ saveChangesIfNeeded();
187
+ }
188
+ };
189
+ document.addEventListener('click', handleClickOutside);
190
+ return () => {
191
+ document.removeEventListener('click', handleClickOutside);
192
+ };
193
+ }, [saveChangesIfNeeded]);
179
194
  function getSavingStatus(rowId) {
180
195
  return savingStatuses && savingStatuses[rowId];
181
196
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useEditing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useEditing.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { Cell as RTCell } from '@tanstack/react-table';\n\nimport { Table3SaveHandler } from '../../types';\nimport { IndicatorReason } from '../../components/columns/cell/Indicator';\nimport { shouldTriggerShortcut } from '../../../../utils/keyboard';\nimport { Table3Validation } from './useValidation';\nimport { lastCellIndex } from '../../components/rows/Row';\n\nexport enum SavingStatusValue {\n Saving = 'saving',\n Saved = 'saved',\n Error = 'error',\n}\n\nexport function useEditing<TType = unknown>(\n isEnabled: boolean,\n validation: Table3Validation<TType>,\n onSave?: Table3SaveHandler<TType>\n) {\n // used to switch the table into editing mode\n const [isEditing, setIsEditing] = React.useState(false);\n // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',\n // 'saved' should remain for a few seconds to show tick icon after row has been saved.\n const [savingStatuses, dispatchSavingStatusAction] = React.useReducer(savingStatusesReducer, null);\n\n // sets of row changes pending save, either they have not saved yet or they have errors\n const [editingState, dispatchEditingAction] = React.useReducer((state: EditingState<TType>, action) => editingReducer<TType>(state, action), null);\n\n const [detailModeEditing, setDetailModeEditing] = React.useState(false);\n\n function getCellValue<T extends TType>(cell: RTCell<T, unknown>) {\n return editingState ? editingState[cell.row.id]?.[cell.column.id] : undefined;\n }\n\n // Saves editing cell value into editing state.\n function setCellValue<T extends TType>(cell: RTCell<T, unknown>, value: unknown) {\n dispatchEditingAction({\n type: EditingActionType.SET_CELL_VALUE,\n payload: { rowId: cell.row.id, cellId: cell.column.id, value, originalValues: cell.row.original },\n });\n }\n\n // Removes changes from editing state by row id\n function resetChange(rowId: string) {\n dispatchEditingAction({\n type: EditingActionType.RESET_CHANGE,\n payload: { rowId },\n });\n validation.resetErrors(rowId);\n }\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n setIsEditing(editing => !editing);\n } else if (shouldTriggerShortcut(event, { key: 's', meta: true, shift: false })) {\n // Prevent default browser save\n event.preventDefault();\n saveChangesIfNeeded();\n }\n },\n [isEditing]\n );\n\n const handleBlur = React.useCallback((event: React.FocusEvent) => {\n if (event.target === event.currentTarget) {\n saveChangesIfNeeded();\n }\n }, []);\n\n // Creates initial saving statuses from changes object\n const addSavingStatuses = () => {\n const changeset = Object.keys(editingState || {});\n const additionalSavingStatuses = _.reduce(\n changeset,\n (result, rowId) => {\n return { ...result, [rowId]: SavingStatusValue.Saving };\n },\n {}\n );\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUSES,\n payload: { states: additionalSavingStatuses },\n });\n };\n\n // Resets/removes saving status by row id. Used in delayed saving indicator.\n const resetSavingStatus = (rowId: string) => {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.RESET_SAVING_STATUS,\n payload: { rowId },\n });\n };\n\n // Checks if we have changes, then saves them\n const saveChangesIfNeeded = async () => {\n if (!editingState) {\n return;\n }\n\n const changeset = Object.keys(editingState);\n if (onSave && changeset.length) {\n addSavingStatuses();\n\n const responses = await Promise.allSettled(\n changeset.map(rowId => {\n const validationSavePromise = new Promise<void>((resolve, reject) => {\n const changedRow = editingState?.[rowId];\n if (changedRow) {\n validation\n .validate(rowId, changedRow)\n ?.then(() => {\n const savePromise = onSave(changedRow);\n savePromise\n .then(() => {\n resolve();\n })\n .catch(reason => {\n if (reason.errors) {\n validation.setRowErrors(rowId, reason.errors);\n }\n\n reject(reason);\n });\n })\n .catch(() => {\n validation.confirmErrors(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n reject();\n });\n } else {\n reject();\n }\n });\n return validationSavePromise;\n })\n );\n\n responses.forEach((response, index) => {\n const rowId = changeset[index];\n\n if (response.status === 'fulfilled') {\n resetChange(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Saved },\n });\n } else {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n }\n });\n }\n };\n\n const [rowMoveReason, setRowMoveReason] = React.useState<Record<string, IndicatorReason | null> | null>(null);\n\n const removeRowMoveReason = () => {\n setRowMoveReason(null);\n };\n\n const showWarning = React.useCallback(\n event => {\n if (isEditing && editingState && Object.keys(editingState).length > 0) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n },\n [isEditing, editingState]\n );\n\n function getSavingStatus(rowId: string) {\n return savingStatuses && savingStatuses[rowId];\n }\n\n React.useEffect(() => {\n window.addEventListener('beforeunload', showWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showWarning);\n };\n }, [showWarning]);\n\n React.useEffect(() => {\n if (!isEditing) {\n setDetailModeEditing(false);\n lastCellIndex.value = null;\n }\n }, [isEditing]);\n\n return {\n isEnabled,\n isEditing,\n toggleEditing: setIsEditing,\n changes: editingState,\n getCellValue,\n setCellValue,\n saveChangesIfNeeded,\n detailModeEditing,\n setDetailModeEditing,\n rowMoveReason,\n setRowMoveReason,\n removeRowMoveReason,\n handleKeyDown,\n handleBlur,\n resetChange,\n getSavingStatus,\n resetSavingStatus,\n };\n}\n\nenum EditingActionType {\n SET_CELL_VALUE,\n RESET_CHANGE,\n}\n\ntype EditingState<TType = unknown> = Record<string, TType> | null;\n\ntype EditingAction =\n | { type: EditingActionType.SET_CELL_VALUE; payload: { rowId: string; cellId: string; value: unknown; originalValues } }\n | {\n type: EditingActionType.RESET_CHANGE;\n payload: { rowId: string };\n };\n\nfunction editingReducer<TType = unknown>(state: EditingState<TType>, action: EditingAction): EditingState<TType> {\n switch (action.type) {\n // Set cell value of the row\n case EditingActionType.SET_CELL_VALUE:\n return {\n ...state,\n [action.payload.rowId]: {\n ...(state?.[action.payload.rowId] || action.payload.originalValues),\n [action.payload.cellId]: action.payload.value,\n },\n };\n\n // Reset changes for the row\n case EditingActionType.RESET_CHANGE: {\n let currentChanges: Record<string, TType> | null = { ...state };\n if (currentChanges) {\n delete currentChanges[action.payload.rowId];\n }\n const changeset = Object.keys(currentChanges);\n if (changeset.length === 0) {\n currentChanges = null;\n }\n return currentChanges;\n }\n\n default:\n return state;\n }\n}\n\nenum SavingStatusActionType {\n SET_SAVING_STATUS,\n SET_SAVING_STATUSES,\n RESET_SAVING_STATUS,\n}\n\ntype SavingStatus = Record<string, SavingStatusValue> | null;\n\ntype SavingStatusAction =\n | { type: SavingStatusActionType.SET_SAVING_STATUS; payload: { rowId: string; state: SavingStatusValue } }\n | { type: SavingStatusActionType.SET_SAVING_STATUSES; payload: { states: Record<string, SavingStatusValue> } }\n | { type: SavingStatusActionType.RESET_SAVING_STATUS; payload: { rowId: string } };\n\nfunction savingStatusesReducer(state: SavingStatus, action: SavingStatusAction): SavingStatus {\n switch (action.type) {\n // Set single saving status for the row\n case SavingStatusActionType.SET_SAVING_STATUS:\n return {\n ...state,\n [action.payload.rowId]: action.payload.state,\n };\n // Set multiple saving statuses for multiple rows at the same time\n case SavingStatusActionType.SET_SAVING_STATUSES:\n return {\n ...state,\n ...action.payload.states,\n };\n // Reset/remove saving status for particular row\n case SavingStatusActionType.RESET_SAVING_STATUS: {\n const newSavingStatus = { ...state };\n delete newSavingStatus?.[action.payload.rowId];\n return newSavingStatus;\n }\n\n default:\n return state;\n }\n}\n"],"names":["SavingStatusValue","useEditing","isEnabled","validation","onSave","isEditing","setIsEditing","React","useState","savingStatuses","dispatchSavingStatusAction","useReducer","savingStatusesReducer","editingState","dispatchEditingAction","state","action","editingReducer","detailModeEditing","setDetailModeEditing","getCellValue","cell","_editingState$cell$ro","row","id","column","undefined","setCellValue","value","type","EditingActionType","SET_CELL_VALUE","payload","rowId","cellId","originalValues","original","resetChange","RESET_CHANGE","resetErrors","handleKeyDown","useCallback","event","defaultPrevented","shouldTriggerShortcut","key","meta","shift","editing","preventDefault","saveChangesIfNeeded","handleBlur","target","currentTarget","addSavingStatuses","changeset","Object","keys","additionalSavingStatuses","_","reduce","result","Saving","SavingStatusActionType","SET_SAVING_STATUSES","states","resetSavingStatus","RESET_SAVING_STATUS","Promise","resolve","_temp","length","allSettled","map","validationSavePromise","reject","changedRow","_validation$validate","validate","then","savePromise","catch","reason","errors","setRowErrors","confirmErrors","SET_SAVING_STATUS","Error","responses","forEach","response","index","status","Saved","e","rowMoveReason","setRowMoveReason","removeRowMoveReason","showWarning","returnValue","getSavingStatus","useEffect","window","addEventListener","removeEventListener","lastCellIndex","toggleEditing","changes","currentChanges","newSavingStatus"],"mappings":";;;;;IAUYA;AAAZ,WAAYA,iBAAiB;EACzBA,sCAAiB;EACjBA,oCAAe;EACfA,oCAAe;AACnB,CAAC,EAJWA,iBAAiB,KAAjBA,iBAAiB;SAMbC,UAAUA,CACtBC,SAAkB,EAClBC,UAAmC,EACnCC,MAAiC;;EAGjC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAGvD,MAAM,CAACC,cAAc,EAAEC,0BAA0B,CAAC,GAAGH,cAAK,CAACI,UAAU,CAACC,qBAAqB,EAAE,I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,IAAIsE,cAAc,GAAiC;UAAE,GAAG7F;SAAO;QAC/D,IAAI6F,cAAc,EAAE;UAChB,OAAOA,cAAc,CAAC5F,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;;QAE/C,MAAMsB,SAAS,GAAGC,MAAM,CAACC,IAAI,CAACmD,cAAc,CAAC;QAC7C,IAAIrD,SAAS,CAACgB,MAAM,KAAK,CAAC,EAAE;UACxBqC,cAAc,GAAG,IAAI;;QAEzB,OAAOA,cAAc;;IAGzB;MACI,OAAO7F,KAAK;;AAExB;AAEA,IAAKgD,sBAIJ;AAJD,WAAKA,sBAAsB;EACvBA,6FAAiB;EACjBA,iGAAmB;EACnBA,iGAAmB;AACvB,CAAC,EAJIA,sBAAsB,KAAtBA,sBAAsB;AAa3B,SAASnD,qBAAqBA,CAACG,KAAmB,EAAEC,MAA0B;EAC1E,QAAQA,MAAM,CAACa,IAAI;;IAEf,KAAKkC,sBAAsB,CAACuB,iBAAiB;MACzC,OAAO;QACH,GAAGvE,KAAK;QACR,CAACC,MAAM,CAACgB,OAAO,CAACC,KAAK,GAAGjB,MAAM,CAACgB,OAAO,CAACjB;OAC1C;;IAEL,KAAKgD,sBAAsB,CAACC,mBAAmB;MAC3C,OAAO;QACH,GAAGjD,KAAK;QACR,GAAGC,MAAM,CAACgB,OAAO,CAACiC;OACrB;;IAEL,KAAKF,sBAAsB,CAACI,mBAAmB;MAAE;QAC7C,MAAM0C,eAAe,GAAG;UAAE,GAAG9F;SAAO;QAC7B8F,eAAe,aAAfA,eAAe,qBAAtB,OAAOA,eAAe,CAAG7F,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;QAC9C,OAAO4E,eAAe;;IAG1B;MACI,OAAO9F,KAAK;;AAExB;;;;"}
1
+ {"version":3,"file":"useEditing.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useEditing.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { Cell as RTCell } from '@tanstack/react-table';\n\nimport { Table3Ref, Table3SaveHandler } from '../../types';\nimport { IndicatorReason } from '../../components/columns/cell/Indicator';\nimport { shouldTriggerShortcut } from '../../../../utils/keyboard';\nimport { Table3Validation } from './useValidation';\nimport { lastCellIndex } from '../../components/rows/Row';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport enum SavingStatusValue {\n Saving = 'saving',\n Saved = 'saved',\n Error = 'error',\n}\n\nexport function useEditing<TType = unknown>(\n isEnabled: boolean,\n tableRef: React.RefObject<Table3Ref>,\n validation: Table3Validation<TType>,\n onSave?: Table3SaveHandler<TType>\n) {\n // used to switch the table into editing mode\n const [isEditing, setIsEditing] = React.useState(false);\n // Saving indicator need to show saving status per row, saving status can have at least two states 'saving', 'saved',\n // 'saved' should remain for a few seconds to show tick icon after row has been saved.\n const [savingStatuses, dispatchSavingStatusAction] = React.useReducer(savingStatusesReducer, null);\n\n // sets of row changes pending save, either they have not saved yet or they have errors\n const [editingState, dispatchEditingAction] = React.useReducer(\n (state: EditingState<TType>, action) => editingReducer<TType>(state, action),\n null\n );\n\n const [detailModeEditing, setDetailModeEditing] = React.useState(false);\n\n function getCellValue<T extends TType>(cell: RTCell<T, unknown>) {\n return editingState ? editingState[cell.row.id]?.[cell.column.id] : undefined;\n }\n\n // Saves editing cell value into editing state.\n function setCellValue<T extends TType>(cell: RTCell<T, unknown>, value: unknown) {\n dispatchEditingAction({\n type: EditingActionType.SET_CELL_VALUE,\n payload: { rowId: cell.row.id, cellId: cell.column.id, value, originalValues: cell.row.original },\n });\n }\n\n // Removes changes from editing state by row id\n function resetChange(rowId: string) {\n dispatchEditingAction({\n type: EditingActionType.RESET_CHANGE,\n payload: { rowId },\n });\n validation.resetErrors(rowId);\n }\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (shouldTriggerShortcut(event, { key: 'e', meta: true, shift: false })) {\n setIsEditing(editing => !editing);\n } else if (shouldTriggerShortcut(event, { key: 's', meta: true, shift: false })) {\n // Prevent default browser save\n event.preventDefault();\n saveChangesIfNeeded();\n }\n },\n [isEditing]\n );\n\n const handleBlur = React.useCallback((event: React.FocusEvent) => {\n if (event.target === event.currentTarget) {\n saveChangesIfNeeded();\n }\n }, []);\n\n // Creates initial saving statuses from changes object\n const addSavingStatuses = () => {\n const changeset = Object.keys(editingState || {});\n const additionalSavingStatuses = _.reduce(\n changeset,\n (result, rowId) => {\n return { ...result, [rowId]: SavingStatusValue.Saving };\n },\n {}\n );\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUSES,\n payload: { states: additionalSavingStatuses },\n });\n };\n\n // Resets/removes saving status by row id. Used in delayed saving indicator.\n const resetSavingStatus = (rowId: string) => {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.RESET_SAVING_STATUS,\n payload: { rowId },\n });\n };\n\n // Checks if we have changes, then saves them\n const saveChangesIfNeeded = async () => {\n if (!editingState) {\n return;\n }\n\n const changeset = Object.keys(editingState);\n if (onSave && changeset.length) {\n addSavingStatuses();\n\n const responses = await Promise.allSettled(\n changeset.map(rowId => {\n const validationSavePromise = new Promise<void>((resolve, reject) => {\n const changedRow = editingState?.[rowId];\n if (changedRow) {\n validation\n .validate(rowId, changedRow)\n ?.then(() => {\n const savePromise = onSave(changedRow);\n savePromise\n .then(() => {\n resolve();\n })\n .catch(reason => {\n if (reason.errors) {\n validation.setRowErrors(rowId, reason.errors);\n }\n\n reject(reason);\n });\n })\n .catch(() => {\n validation.confirmErrors(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n reject();\n });\n } else {\n reject();\n }\n });\n return validationSavePromise;\n })\n );\n\n responses.forEach((response, index) => {\n const rowId = changeset[index];\n\n if (response.status === 'fulfilled') {\n resetChange(rowId);\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Saved },\n });\n } else {\n dispatchSavingStatusAction({\n type: SavingStatusActionType.SET_SAVING_STATUS,\n payload: { rowId, state: SavingStatusValue.Error },\n });\n }\n });\n }\n };\n\n const [rowMoveReason, setRowMoveReason] = React.useState<Record<string, IndicatorReason | null> | null>(null);\n\n const removeRowMoveReason = () => {\n setRowMoveReason(null);\n };\n\n const showWarning = React.useCallback(\n event => {\n if (isEditing && editingState && Object.keys(editingState).length > 0) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n },\n [isEditing, editingState]\n );\n\n React.useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n const target = event.target as HTMLElement;\n const closestPopup = target.closest('[role=\"dialog\"], [role=\"menu\"]');\n\n // Need to check that neither target itself nor closest popup is inside or triggetred from the table.\n if (\n !isElementInsideOrTriggeredFromContainer(target, tableRef.current) &&\n !isElementInsideOrTriggeredFromContainer(closestPopup, tableRef.current)\n ) {\n saveChangesIfNeeded();\n }\n };\n\n document.addEventListener('click', handleClickOutside);\n\n return () => {\n document.removeEventListener('click', handleClickOutside);\n };\n }, [saveChangesIfNeeded]);\n\n function getSavingStatus(rowId: string) {\n return savingStatuses && savingStatuses[rowId];\n }\n\n React.useEffect(() => {\n window.addEventListener('beforeunload', showWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showWarning);\n };\n }, [showWarning]);\n\n React.useEffect(() => {\n if (!isEditing) {\n setDetailModeEditing(false);\n lastCellIndex.value = null;\n }\n }, [isEditing]);\n\n return {\n isEnabled,\n isEditing,\n toggleEditing: setIsEditing,\n changes: editingState,\n getCellValue,\n setCellValue,\n saveChangesIfNeeded,\n detailModeEditing,\n setDetailModeEditing,\n rowMoveReason,\n setRowMoveReason,\n removeRowMoveReason,\n handleKeyDown,\n handleBlur,\n resetChange,\n getSavingStatus,\n resetSavingStatus,\n };\n}\n\nenum EditingActionType {\n SET_CELL_VALUE,\n RESET_CHANGE,\n}\n\ntype EditingState<TType = unknown> = Record<string, TType> | null;\n\ntype EditingAction =\n | { type: EditingActionType.SET_CELL_VALUE; payload: { rowId: string; cellId: string; value: unknown; originalValues } }\n | {\n type: EditingActionType.RESET_CHANGE;\n payload: { rowId: string };\n };\n\nfunction editingReducer<TType = unknown>(state: EditingState<TType>, action: EditingAction): EditingState<TType> {\n switch (action.type) {\n // Set cell value of the row\n case EditingActionType.SET_CELL_VALUE:\n return {\n ...state,\n [action.payload.rowId]: {\n ...(state?.[action.payload.rowId] || action.payload.originalValues),\n [action.payload.cellId]: action.payload.value,\n },\n };\n\n // Reset changes for the row\n case EditingActionType.RESET_CHANGE: {\n let currentChanges: Record<string, TType> | null = { ...state };\n if (currentChanges) {\n delete currentChanges[action.payload.rowId];\n }\n const changeset = Object.keys(currentChanges);\n if (changeset.length === 0) {\n currentChanges = null;\n }\n return currentChanges;\n }\n\n default:\n return state;\n }\n}\n\nenum SavingStatusActionType {\n SET_SAVING_STATUS,\n SET_SAVING_STATUSES,\n RESET_SAVING_STATUS,\n}\n\ntype SavingStatus = Record<string, SavingStatusValue> | null;\n\ntype SavingStatusAction =\n | { type: SavingStatusActionType.SET_SAVING_STATUS; payload: { rowId: string; state: SavingStatusValue } }\n | { type: SavingStatusActionType.SET_SAVING_STATUSES; payload: { states: Record<string, SavingStatusValue> } }\n | { type: SavingStatusActionType.RESET_SAVING_STATUS; payload: { rowId: string } };\n\nfunction savingStatusesReducer(state: SavingStatus, action: SavingStatusAction): SavingStatus {\n switch (action.type) {\n // Set single saving status for the row\n case SavingStatusActionType.SET_SAVING_STATUS:\n return {\n ...state,\n [action.payload.rowId]: action.payload.state,\n };\n // Set multiple saving statuses for multiple rows at the same time\n case SavingStatusActionType.SET_SAVING_STATUSES:\n return {\n ...state,\n ...action.payload.states,\n };\n // Reset/remove saving status for particular row\n case SavingStatusActionType.RESET_SAVING_STATUS: {\n const newSavingStatus = { ...state };\n delete newSavingStatus?.[action.payload.rowId];\n return newSavingStatus;\n }\n\n default:\n return state;\n }\n}\n"],"names":["SavingStatusValue","useEditing","isEnabled","tableRef","validation","onSave","isEditing","setIsEditing","React","useState","savingStatuses","dispatchSavingStatusAction","useReducer","savingStatusesReducer","editingState","dispatchEditingAction","state","action","editingReducer","detailModeEditing","setDetailModeEditing","getCellValue","cell","_editingState$cell$ro","row","id","column","undefined","setCellValue","value","type","EditingActionType","SET_CELL_VALUE","payload","rowId","cellId","originalValues","original","resetChange","RESET_CHANGE","resetErrors","handleKeyDown","useCallback","event","defaultPrevented","shouldTriggerShortcut","key","meta","shift","editing","preventDefault","saveChangesIfNeeded","handleBlur","target","currentTarget","addSavingStatuses","changeset","Object","keys","additionalSavingStatuses","_","reduce","result","Saving","SavingStatusActionType","SET_SAVING_STATUSES","states","resetSavingStatus","RESET_SAVING_STATUS","Promise","resolve","_temp","length","allSettled","map","validationSavePromise","reject","changedRow","_validation$validate","validate","then","savePromise","catch","reason","errors","setRowErrors","confirmErrors","SET_SAVING_STATUS","Error","responses","forEach","response","index","status","Saved","e","rowMoveReason","setRowMoveReason","removeRowMoveReason","showWarning","returnValue","useEffect","handleClickOutside","closestPopup","closest","isElementInsideOrTriggeredFromContainer","current","document","addEventListener","removeEventListener","getSavingStatus","window","lastCellIndex","toggleEditing","changes","currentChanges","newSavingStatus"],"mappings":";;;;;;IAWYA;AAAZ,WAAYA,iBAAiB;EACzBA,sCAAiB;EACjBA,oCAAe;EACfA,oCAAe;AACnB,CAAC,EAJWA,iBAAiB,KAAjBA,iBAAiB;SAMbC,UAAUA,CACtBC,SAAkB,EAClBC,QAAoC,EACpCC,UAAmC,EACnCC,MAAiC;;EAGjC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAGvD,MAAM,CAACC,cAAc,EAAEC,0BAA0B,CAAC,GAAGH,cAAK,CAACI,UAAU,CAACC,qBAAqB,EAAE,IAAI,CAAC;;EAGlG,MAAM,CAACC,YAAY,EAAEC,qBAAqB,CAAC,GAAGP,cAAK,CAACI,UAAU,CAC1D,CAACI,KAA0B,EAA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K;QACR,GAAGC,MAAM,CAACgB,OAAO,CAACiC;OACrB;;IAEL,KAAKF,sBAAsB,CAACI,mBAAmB;MAAE;QAC7C,MAAMgD,eAAe,GAAG;UAAE,GAAGpG;SAAO;QAC7BoG,eAAe,aAAfA,eAAe,qBAAtB,OAAOA,eAAe,CAAGnG,MAAM,CAACgB,OAAO,CAACC,KAAK,CAAC;QAC9C,OAAOkF,eAAe;;IAG1B;MACI,OAAOpG,KAAK;;AAExB;;;;"}
@@ -48,7 +48,7 @@ function useTable(props, ref) {
48
48
  // can't change due to rename to "active row"
49
49
  const validation = useValidation(props.onCellValidate, props.onRowValidate);
50
50
  // not relevant to common table
51
- const editing = useEditing(options.enableEditing, validation, props.onSave);
51
+ const editing = useEditing(options.enableEditing, ref, validation, props.onSave);
52
52
  // we changed how printing works, so this shouldn't be migrated
53
53
  const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);
54
54
  // needs to be moved