@economic/taco 2.17.0 → 2.17.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +1 -0
  2. package/dist/components/Table3/components/columns/cell/Indicator.d.ts +5 -0
  3. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
  4. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  5. package/dist/esm/packages/taco/src/components/Table3/Table3.js +2 -1
  6. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +12 -7
  8. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +1 -1
  10. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +18 -8
  12. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js +15 -1
  14. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +6 -1
  16. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +10 -4
  18. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -1
  20. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js +7 -2
  21. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js.map +1 -1
  22. package/dist/taco.cjs.development.js +130 -88
  23. package/dist/taco.cjs.development.js.map +1 -1
  24. package/dist/taco.cjs.production.min.js +1 -1
  25. package/dist/taco.cjs.production.min.js.map +1 -1
  26. package/package.json +2 -2
  27. package/types.json +3083 -2937
@@ -1,4 +1,5 @@
1
1
  import React__default from 'react';
2
+ import cn from 'classnames';
2
3
  import { Icon } from '../../../../Icon/Icon.js';
3
4
  import { Tooltip } from '../../../../Tooltip/Tooltip.js';
4
5
  import { useLocalization } from '../../../../Provider/Localization.js';
@@ -69,6 +70,19 @@ const Indicator = ({
69
70
  className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
70
71
  }), indicatorText.title)), container);
71
72
  };
73
+ /**
74
+ * Generates class names needed to highlight row cells, used when row has a move indicator
75
+ */
76
+ function getIndicatorCellClassName(columnIndex, lastColumnIndex) {
77
+ return cn('!border-blue !border-y-2 border-x-0', {
78
+ 'border-l-2 rounded-l': columnIndex === 0,
79
+ 'border-r-2 rounded-r': columnIndex === lastColumnIndex
80
+ });
81
+ }
82
+ function isIndicatorVisible(rowIndex, rowActiveIndex, rowMoveReason) {
83
+ const isActiveRow = rowActiveIndex === rowIndex;
84
+ return isActiveRow && rowMoveReason;
85
+ }
72
86
 
73
- export { Indicator, IndicatorReason, useIndicatorText };
87
+ export { Indicator, IndicatorReason, getIndicatorCellClassName, isIndicatorVisible, useIndicatorText };
74
88
  //# sourceMappingURL=Indicator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Indicator.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Indicator.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Icon } from '../../../../Icon/Icon';\n\nexport enum IndicatorReason {\n SEARCH = 'SEARCH',\n SORTING = 'SORTING',\n FILTER = 'FILTER',\n}\n\nexport const useIndicatorText = reason => {\n let title = '';\n let description = '';\n\n const { texts } = useLocalization();\n\n switch (reason) {\n case IndicatorReason.FILTER:\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;\n break;\n case IndicatorReason.SEARCH:\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;\n break;\n case IndicatorReason.SORTING:\n title = texts.table3.editing.rowIndicator.rowWillMove;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;\n break;\n }\n\n return { title, description };\n};\n\nexport type IndicatorProps = {\n reason: IndicatorReason;\n columnName: string;\n mountNode: Element | null;\n validationErrors: any;\n};\nexport const Indicator = ({ reason, columnName, mountNode, validationErrors }: IndicatorProps) => {\n const container = React.useMemo(() => {\n const element = document.createElement('div');\n element.className +=\n 'rounded-b-md items-center wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap px-1 py-0.5 text-xs font-bold shadow-sm';\n\n return element;\n }, []);\n\n const indicatorText = useIndicatorText(reason);\n\n const hasValidationErrorsInRow = !!validationErrors;\n\n React.useEffect(() => {\n // mountNode could be null when rows are filtered\n // Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.\n mountNode?.classList.add('!z-[21]', 'relative');\n mountNode?.appendChild(container);\n\n return () => {\n mountNode?.classList.remove('!z-[21]', 'relative');\n mountNode?.removeChild(container);\n };\n }, [hasValidationErrorsInRow, mountNode]);\n\n // Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring\n // and being able to use Taco Tooltip component in side the visual indicator, portal is used.\n return ReactDOM.createPortal(\n <Tooltip title={indicatorText.description.replace('[COLUMN]', columnName)}>\n <span className=\"flex gap-1 hover:cursor-pointer\">\n <Icon name=\"info\" className=\"!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500\" />\n {indicatorText.title}\n </span>\n </Tooltip>,\n container\n );\n};\n"],"names":["IndicatorReason","useIndicatorText","reason","title","description","texts","useLocalization","FILTER","table3","editing","rowIndicator","rowWillBeHidden","rowWillMoveReasonFilter","SEARCH","rowWillMoveReasonSearch","SORTING","rowWillMove","rowWillMoveReasonSorting","Indicator","columnName","mountNode","validationErrors","container","React","useMemo","element","document","createElement","className","indicatorText","hasValidationErrorsInRow","useEffect","classList","add","appendChild","remove","removeChild","ReactDOM","createPortal","Tooltip","replace","Icon","name"],"mappings":";;;;;;IAMYA;AAAZ,WAAYA,eAAe;EACvBA,oCAAiB;EACjBA,sCAAmB;EACnBA,oCAAiB;AACrB,CAAC,EAJWA,eAAe,KAAfA,eAAe;MAMdC,gBAAgB,GAAGC,MAAM;EAClC,IAAIC,KAAK,GAAG,EAAE;EACd,IAAIC,WAAW,GAAG,EAAE;EAEpB,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAEnC,QAAQJ,MAAM;IACV,KAAKF,eAAe,CAACO,MAAM;MACvBJ,KAAK,GAAGE,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACC,eAAe;MACzDP,WAAW,GAAGC,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACE,uBAAuB;MACvE;IACJ,KAAKZ,eAAe,CAACa,MAAM;MACvBV,KAAK,GAAGE,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACC,eAAe;MACzDP,WAAW,GAAGC,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACI,uBAAuB;MACvE;IACJ,KAAKd,eAAe,CAACe,OAAO;MACxBZ,KAAK,GAAGE,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACM,WAAW;MACrDZ,WAAW,GAAGC,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACO,wBAAwB;MACxE;;EAGR,OAAO;IAAEd,KAAK;IAAEC;GAAa;AACjC;MAQac,SAAS,GAAGA,CAAC;EAAEhB,MAAM;EAAEiB,UAAU;EAAEC,SAAS;EAAEC;CAAkC;EACzF,MAAMC,SAAS,GAAGC,cAAK,CAACC,OAAO,CAAC;IAC5B,MAAMC,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IAC7CF,OAAO,CAACG,SAAS,IACb,iIAAiI;IAErI,OAAOH,OAAO;GACjB,EAAE,EAAE,CAAC;EAEN,MAAMI,aAAa,GAAG5B,gBAAgB,CAACC,MAAM,CAAC;EAE9C,MAAM4B,wBAAwB,GAAG,CAAC,CAACT,gBAAgB;EAEnDE,cAAK,CAACQ,SAAS,CAAC;;;IAGZX,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEY,SAAS,CAACC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/Cb,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEc,WAAW,CAACZ,SAAS,CAAC;IAEjC,OAAO;MACHF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEY,SAAS,CAACG,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC;MAClDf,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEgB,WAAW,CAACd,SAAS,CAAC;KACpC;GACJ,EAAE,CAACQ,wBAAwB,EAAEV,SAAS,CAAC,CAAC;;;EAIzC,oBAAOiB,QAAQ,CAACC,YAAY,eACxBf,6BAACgB,OAAO;IAACpC,KAAK,EAAE0B,aAAa,CAACzB,WAAW,CAACoC,OAAO,CAAC,UAAU,EAAErB,UAAU;kBACpEI;IAAMK,SAAS,EAAC;kBACZL,6BAACkB,IAAI;IAACC,IAAI,EAAC,MAAM;IAACd,SAAS,EAAC;IAAuD,EAClFC,aAAa,CAAC1B,KAAK,CACjB,CACD,EACVmB,SAAS,CACZ;AACL;;;;"}
1
+ {"version":3,"file":"Indicator.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Indicator.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport ReactDOM from 'react-dom';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Icon } from '../../../../Icon/Icon';\n\nexport enum IndicatorReason {\n SEARCH = 'SEARCH',\n SORTING = 'SORTING',\n FILTER = 'FILTER',\n}\n\nexport const useIndicatorText = reason => {\n let title = '';\n let description = '';\n\n const { texts } = useLocalization();\n\n switch (reason) {\n case IndicatorReason.FILTER:\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;\n break;\n case IndicatorReason.SEARCH:\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;\n break;\n case IndicatorReason.SORTING:\n title = texts.table3.editing.rowIndicator.rowWillMove;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;\n break;\n }\n\n return { title, description };\n};\n\nexport type IndicatorProps = {\n reason: IndicatorReason;\n columnName: string;\n mountNode: Element | null;\n validationErrors: any;\n};\nexport const Indicator = ({ reason, columnName, mountNode, validationErrors }: IndicatorProps) => {\n const container = React.useMemo(() => {\n const element = document.createElement('div');\n element.className +=\n 'rounded-b-md items-center wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap px-1 py-0.5 text-xs font-bold shadow-sm';\n\n return element;\n }, []);\n\n const indicatorText = useIndicatorText(reason);\n\n const hasValidationErrorsInRow = !!validationErrors;\n\n React.useEffect(() => {\n // mountNode could be null when rows are filtered\n // Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.\n mountNode?.classList.add('!z-[21]', 'relative');\n mountNode?.appendChild(container);\n\n return () => {\n mountNode?.classList.remove('!z-[21]', 'relative');\n mountNode?.removeChild(container);\n };\n }, [hasValidationErrorsInRow, mountNode]);\n\n // Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring\n // and being able to use Taco Tooltip component in side the visual indicator, portal is used.\n return ReactDOM.createPortal(\n <Tooltip title={indicatorText.description.replace('[COLUMN]', columnName)}>\n <span className=\"flex gap-1 hover:cursor-pointer\">\n <Icon name=\"info\" className=\"!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500\" />\n {indicatorText.title}\n </span>\n </Tooltip>,\n container\n );\n};\n\n/**\n * Generates class names needed to highlight row cells, used when row has a move indicator\n */\nexport function getIndicatorCellClassName(columnIndex: number, lastColumnIndex: number) {\n return cn('!border-blue !border-y-2 border-x-0', {\n 'border-l-2 rounded-l': columnIndex === 0,\n 'border-r-2 rounded-r': columnIndex === lastColumnIndex,\n });\n}\n\nexport function isIndicatorVisible(rowIndex, rowActiveIndex, rowMoveReason) {\n const isActiveRow = rowActiveIndex === rowIndex;\n return isActiveRow && rowMoveReason;\n}\n"],"names":["IndicatorReason","useIndicatorText","reason","title","description","texts","useLocalization","FILTER","table3","editing","rowIndicator","rowWillBeHidden","rowWillMoveReasonFilter","SEARCH","rowWillMoveReasonSearch","SORTING","rowWillMove","rowWillMoveReasonSorting","Indicator","columnName","mountNode","validationErrors","container","React","useMemo","element","document","createElement","className","indicatorText","hasValidationErrorsInRow","useEffect","classList","add","appendChild","remove","removeChild","ReactDOM","createPortal","Tooltip","replace","Icon","name","getIndicatorCellClassName","columnIndex","lastColumnIndex","cn","isIndicatorVisible","rowIndex","rowActiveIndex","rowMoveReason","isActiveRow"],"mappings":";;;;;;;IAOYA;AAAZ,WAAYA,eAAe;EACvBA,oCAAiB;EACjBA,sCAAmB;EACnBA,oCAAiB;AACrB,CAAC,EAJWA,eAAe,KAAfA,eAAe;MAMdC,gBAAgB,GAAGC,MAAM;EAClC,IAAIC,KAAK,GAAG,EAAE;EACd,IAAIC,WAAW,GAAG,EAAE;EAEpB,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAEnC,QAAQJ,MAAM;IACV,KAAKF,eAAe,CAACO,MAAM;MACvBJ,KAAK,GAAGE,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACC,eAAe;MACzDP,WAAW,GAAGC,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,YAAY,CAACE,uBAAuB;MACvE;IACJ,KAAK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C,CAAC;;;EAIzC,oBAAOiB,QAAQ,CAACC,YAAY,eACxBf,6BAACgB,OAAO;IAACpC,KAAK,EAAE0B,aAAa,CAACzB,WAAW,CAACoC,OAAO,CAAC,UAAU,EAAErB,UAAU;kBACpEI;IAAMK,SAAS,EAAC;kBACZL,6BAACkB,IAAI;IAACC,IAAI,EAAC,MAAM;IAACd,SAAS,EAAC;IAAuD,EAClFC,aAAa,CAAC1B,KAAK,CACjB,CACD,EACVmB,SAAS,CACZ;AACL;AAEA;;;SAGgBqB,yBAAyBA,CAACC,WAAmB,EAAEC,eAAuB;EAClF,OAAOC,EAAE,CAAC,qCAAqC,EAAE;IAC7C,sBAAsB,EAAEF,WAAW,KAAK,CAAC;IACzC,sBAAsB,EAAEA,WAAW,KAAKC;GAC3C,CAAC;AACN;SAEgBE,kBAAkBA,CAACC,QAAQ,EAAEC,cAAc,EAAEC,aAAa;EACtE,MAAMC,WAAW,GAAGF,cAAc,KAAKD,QAAQ;EAC/C,OAAOG,WAAW,IAAID,aAAa;AACvC;;;;"}
@@ -9,6 +9,7 @@ import { RowContext } from '../../rows/RowContext.js';
9
9
  import { DisplayCell } from '../cell/DisplayCell.js';
10
10
  import { Footer } from '../footer/Footer.js';
11
11
  import { FONT_SIZE } from '../../toolbar/FontSize.js';
12
+ import { isIndicatorVisible, getIndicatorCellClassName } from '../cell/Indicator.js';
12
13
 
13
14
  const COLUMN_ID = '__actions';
14
15
  const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
@@ -54,7 +55,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
54
55
  // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.
55
56
  '-mt-2': fontSize === FONT_SIZE.small,
56
57
  '-mt-1.5': fontSize !== FONT_SIZE.small
57
- });
58
+ }, props.className);
58
59
  content = /*#__PURE__*/React__default.createElement("span", {
59
60
  className: className,
60
61
  ref: ref
@@ -89,9 +90,13 @@ function Cell(context) {
89
90
  rowIndex
90
91
  } = React__default.useContext(RowContext);
91
92
  const tableMeta = context.table.options.meta;
93
+ const allVisibleColumns = context.table.getVisibleLeafColumns();
94
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
95
+ const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(context.index, lastColumnIndex) : undefined;
92
96
  return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, context, {
93
97
  actions: tableMeta.rowActions.actionsForRow,
94
98
  actionsLength: tableMeta.rowActions.actionsForRowLength,
99
+ className: className,
95
100
  fontSize: tableMeta.fontSize.size,
96
101
  isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex,
97
102
  isEditing: tableMeta.editing.isEditing,
@@ -1 +1 @@
1
- {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3FontSize, Table3RowActionRenderer } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\nimport { FONT_SIZE } from '../../toolbar/FontSize';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n fontSize: Table3FontSize;\n isActiveRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isActiveRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn('-mb-2 flex justify-end pl-2 text-right', {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FONT_SIZE.small,\n '-mt-1.5': fontSize !== FONT_SIZE.small,\n });\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n\n return (\n <MemoedCell<TType>\n {...context}\n actions={tableMeta.rowActions.actionsForRow}\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.rowActive.isHoverStatePaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isActiveRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","FONT_SIZE","small","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","rowActions","actionsForRow","actionsForRowLength","size","rowActive","rowActiveIndex","editing","getState","columnSizingInfo","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;;MAcaA,SAAS,GAAG;AAYzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,SAAS;IAAEC,gBAAgB;IAAEC,kBAAkB;IAAEC;GAAK,GAAGR,KAAK;EACrH,MAAM;IAAES;GAAW,GAAGX,cAAK,CAACY,UAAU,CAACC,UAAU,CAAC;EAClD,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGhB,cAAK,CAACiB,MAAM,CAAyB,IAAI,CAAC;;;;;;;;;;;;;;;EAkBtD,IAAIC,OAAO;;;EAIX,IAAIf,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEgB,MAAM,IAAI,CAACZ,SAAS,KAAKD,WAAW,IAAKK,SAAS,IAAI,CAACF,kBAAkB,IAAI,CAACD,gBAAiB,CAAC,EAAE;IAC3G,MAAMY,cAAc,GAAGjB,OAAO,CAACkB,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACZ,GAAG,CAACa,QAAQ,CAAC,CAAC,CAACC,MAAM,CAACF,MAAM,IAAI,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ACG,KAAK,CAACU,QAAQ,EAAE,CAACC,gBAAgB,CAAC/D,gBAAgB;IAC9EC,kBAAkB,EAAE,CAAC,CAACkD,SAAS,CAACQ,SAAS,CAAC1D;KAC5C;AAEV;SAEgB+D,sBAAsBA;EAClC,OAAO;IACHC,EAAE,EAAE3E,SAAS;IACb4E,MAAM,EAAEC,MAAY;IACpBC,IAAI,EAAEpB,IAAI;IACVqB,MAAM,EAAEC,MAAM;IACdhB,IAAI,EAAE;MACFiB,KAAK,EAAE,OAAO;MACdnD,SAAS,EAAEC,EAAE,CACT,oPAAoP,EACpP,wDAAwD,EACxD,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACDmD,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
1
+ {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3FontSize, Table3RowActionRenderer } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\nimport { FONT_SIZE } from '../../toolbar/FontSize';\nimport { getIndicatorCellClassName, isIndicatorVisible } from '../cell/Indicator';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n className?: string;\n fontSize: Table3FontSize;\n isActiveRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isActiveRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n '-mb-2 flex justify-end pl-2 text-right',\n {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FONT_SIZE.small,\n '-mt-1.5': fontSize !== FONT_SIZE.small,\n },\n props.className\n );\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n const allVisibleColumns = context.table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(context.index, lastColumnIndex)\n : undefined;\n\n return (\n <MemoedCell<TType>\n {...context}\n actions={tableMeta.rowActions.actionsForRow}\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n className={className}\n fontSize={tableMeta.fontSize.size}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.rowActive.isHoverStatePaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isActiveRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","FONT_SIZE","small","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","isIndicatorVisible","rowActive","rowActiveIndex","editing","rowMoveReason","getIndicatorCellClassName","undefined","rowActions","actionsForRow","actionsForRowLength","size","getState","columnSizingInfo","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;;;MAeaA,SAAS,GAAG;AAazB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,SAAS;IAAEC,gBAAgB;IAAEC,kBAAkB;IAAEC;GAAK,GAAGR,KAAK;EACrH,MAAM;IAAES;GAAW,GAAGX,cAAK,CAACY,UAAU,CAACC,UAAU,CAAC;EAClD,MAAM;IAAEC;GAA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ACpP,wDAAwD,EACxD,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACD0D,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
@@ -14,6 +14,7 @@ import { Header } from '../header/Header.js';
14
14
  import { RowContext } from '../../rows/RowContext.js';
15
15
  import { DisplayCell } from '../cell/DisplayCell.js';
16
16
  import { Footer } from '../footer/Footer.js';
17
+ import { isIndicatorVisible, getIndicatorCellClassName } from '../cell/Indicator.js';
17
18
  import { getColumnIndex } from '../../../util/editing.js';
18
19
  import { lastCellIndex } from '../../rows/Row.js';
19
20
  import { SavingStatusValue } from '../../../hooks/features/useEditing.js';
@@ -23,10 +24,11 @@ const COLUMN_ID = '__editing_actions';
23
24
  const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
24
25
  var _column$columnDef$met;
25
26
  const {
27
+ className,
28
+ editing,
26
29
  hasChanges,
27
30
  isActiveRow,
28
31
  row,
29
- editing,
30
32
  rowIdentifier,
31
33
  table
32
34
  } = props;
@@ -120,7 +122,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
120
122
  '-mb-2 -mt-2': isActiveRow
121
123
  });
122
124
  return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, {
123
- className: cn({
125
+ className: cn(className, {
124
126
  '!sticky': !!content
125
127
  })
126
128
  }), content ? /*#__PURE__*/React__default.createElement("span", {
@@ -133,10 +135,14 @@ function Cell(props) {
133
135
  } = React__default.useContext(RowContext);
134
136
  const tableMeta = props.table.options.meta;
135
137
  const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];
138
+ const allVisibleColumns = props.table.getVisibleLeafColumns();
139
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
140
+ const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(props.index, lastColumnIndex) : undefined;
136
141
  return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, props, {
142
+ className: className,
143
+ editing: tableMeta.editing,
137
144
  hasChanges: changeset.indexOf(props.row.id) >= 0,
138
- isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex,
139
- editing: tableMeta.editing
145
+ isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex
140
146
  }));
141
147
  }
142
148
  const EDITING_ACTIONS_WIDTH = 60;
@@ -1 +1 @@
1
- {"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStatusValue, useEditing } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Dialog } from '../../../../Dialog/Dialog';\nimport { Group } from '../../../../Group/Group';\nimport { Button } from '../../../../Button/Button';\nimport { lastCellIndex } from '../../rows/Row';\nimport { getColumnIndex } from '../../../util/editing';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n hasChanges: boolean;\n isActiveRow: boolean;\n editing: ReturnType<typeof useEditing>;\n rowIdentifier?: string;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { hasChanges, isActiveRow, row, editing, rowIdentifier, table } = props;\n\n const savingStatus = editing.getSavingStatus(row.id);\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const { texts } = useLocalization();\n const [clearConfirmationOpen, setClearConfirmationOpen] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n const edititngActionsRef = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n editing.resetSavingStatus(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingStatus && savingStatus === SavingStatusValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingStatus]);\n\n React.useEffect(() => {\n tableMeta.shortcutsState.pause(clearConfirmationOpen);\n }, [clearConfirmationOpen]);\n\n let content;\n\n if (savingStatus) {\n if (savingStatus === SavingStatusValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n }\n }\n\n if (editing.isEditing && isActiveRow) {\n content = (\n <>\n {content}\n <IconButton\n ref={edititngActionsRef}\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item icon=\"tick\" disabled={!hasChanges} onClick={() => editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item icon=\"close\" disabled={!hasChanges} onClick={() => setClearConfirmationOpen(true)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isActiveRow ? 0 : -1}\n />\n <Dialog\n size=\"xs\"\n open={clearConfirmationOpen}\n onClose={() => {\n setClearConfirmationOpen(false);\n requestAnimationFrame(() => {\n if (edititngActionsRef.current) {\n edititngActionsRef.current.focus();\n // When table looses focus, we need to re-set the last column index\n lastCellIndex.value = getColumnIndex(edititngActionsRef.current);\n }\n });\n }}>\n <Dialog.Content aria-label={texts.table3.editing.clearChangesConfirmationDialog.title}>\n <Dialog.Title>{texts.table3.editing.clearChangesConfirmationDialog.title}</Dialog.Title>\n\n <p>\n {texts.table3.editing.clearChangesConfirmationDialog.description\n .replace(\n '[ROW_IDENTIFIER]',\n rowIdentifier && rowIdentifierHeader ? rowIdentifierHeader : texts.table3.validation.index\n )\n .replace(\n '[ROW_IDENTIFIER_VALUE]',\n rowIdentifier && rowIdentifierHeader ? row.original[rowIdentifier] : row.index\n )}\n </p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button tabIndex={0}>{texts.table3.editing.clearChangesConfirmationDialog.cancel}</Button>\n </Dialog.Close>\n <Dialog.Close>\n <Button\n tabIndex={0}\n appearance=\"primary\"\n autoFocus\n onClick={() => editing.resetChange(row.id)}>\n {texts.table3.editing.clearChangesConfirmationDialog.confirm}\n </Button>\n </Dialog.Close>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </>\n );\n }\n\n const contentClassName = cn('flex items-center justify-end text-right', { '-mb-2 -mt-2': isActiveRow });\n return (\n <DisplayCell {...props} className={cn({ '!sticky': !!content })}>\n {content ? <span className={contentClassName}>{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {\n rowIdentifier?: string;\n};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n\n return (\n <MemoedCell\n {...props}\n hasChanges={changeset.indexOf(props.row.id) >= 0}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n editing={tableMeta.editing}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 60;\n\nexport function createRowEditingActionsColumn<TType = unknown>(rowIdentifier?: string): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: (context: CellContext<TType, unknown>) => <Cell {...context} rowIdentifier={rowIdentifier} />,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","hasChanges","isActiveRow","row","editing","rowIdentifier","table","savingStatus","getSavingStatus","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","texts","useLocalization","clearConfirmationOpen","setClearConfirmationOpen","columns","getAllFlatColumns","column","find","rowIdentifierHeader","_column$columnDef$met","columnDef","meta","header","edititngActionsRef","useRef","tableMeta","options","handleSaved","resetSavingStatus","timer","useTimer","useEffect","SavingStatusValue","Saved","start","shortcutsState","pause","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","className","complete","Icon","name","isEditing","IconButton","ref","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","clear","toggleEditing","exit","tabIndex","Dialog","size","open","onClose","requestAnimationFrame","current","focus","lastCellIndex","value","getColumnIndex","clearChangesConfirmationDialog","Title","description","replace","validation","index","original","Footer","Group","Close","Button","cancel","autoFocus","resetChange","confirm","contentClassName","cn","DisplayCell","undefined","Cell","rowIndex","useContext","RowContext","changeset","changes","Object","keys","indexOf","rowActive","rowActiveIndex","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","ColumnHeader","cell","context","footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","minSize"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AASzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;;EAC5F,MAAM;IAAEC,UAAU;IAAEC,WAAW;IAAEC,GAAG;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGN,KAAK;EAE7E,MAAMO,YAAY,GAAGH,OAAO,CAACI,eAAe,CAACL,GAAG,CAACM,EAAE,CAAC;EACpD,MAAM,CAACC,uBAAuB,EAAEC,2BAA2B,CAAC,GAAGb,cAAK,CAACc,QAAQ,CAAC,KAAK,CAAC;EACpF,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,qBAAqB,EAAEC,wBAAwB,CAA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;IAC5DnG,OAAO,EAAEwB,SAAS,CAACxB;KACrB;AAEV;MAEa6G,qBAAqB,GAAG;SAErBC,6BAA6BA,CAAkB7G,aAAsB;EACjF,OAAO;IACHI,EAAE,EAAEb,SAAS;IACb6B,MAAM,EAAE0F,MAAY;IACpBC,IAAI,EAAGC,OAAoC,iBAAKvH,6BAACwG,IAAI,oBAAKe,OAAO;MAAEhH,aAAa,EAAEA;OAAiB;IACnGiH,MAAM,EAAE5B,MAAM;IACdlE,IAAI,EAAE;MACF+F,KAAK,EAAE,OAAO;MACdtE,SAAS,EAAEkD,EAAE,CACT,mIAAmI,EACnI,kIAAkI,EAClI,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACDqB,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBjG,MAAM,EAAE,EAAE;MACVkG,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE,KAAK;IACrBlD,IAAI,EAAEuC,qBAAqB;IAC3BY,OAAO,EAAEZ;GACZ;AACL;;;;"}
1
+ {"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStatusValue, useEditing } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Dialog } from '../../../../Dialog/Dialog';\nimport { Group } from '../../../../Group/Group';\nimport { Button } from '../../../../Button/Button';\nimport { lastCellIndex } from '../../rows/Row';\nimport { getColumnIndex } from '../../../util/editing';\nimport { getIndicatorCellClassName, isIndicatorVisible } from '../cell/Indicator';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n editing: ReturnType<typeof useEditing>;\n hasChanges: boolean;\n isActiveRow: boolean;\n rowIdentifier?: string;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { className, editing, hasChanges, isActiveRow, row, rowIdentifier, table } = props;\n\n const savingStatus = editing.getSavingStatus(row.id);\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const { texts } = useLocalization();\n const [clearConfirmationOpen, setClearConfirmationOpen] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n const edititngActionsRef = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n editing.resetSavingStatus(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingStatus && savingStatus === SavingStatusValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingStatus]);\n\n React.useEffect(() => {\n tableMeta.shortcutsState.pause(clearConfirmationOpen);\n }, [clearConfirmationOpen]);\n\n let content;\n\n if (savingStatus) {\n if (savingStatus === SavingStatusValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n }\n }\n\n if (editing.isEditing && isActiveRow) {\n content = (\n <>\n {content}\n <IconButton\n ref={edititngActionsRef}\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item icon=\"tick\" disabled={!hasChanges} onClick={() => editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item icon=\"close\" disabled={!hasChanges} onClick={() => setClearConfirmationOpen(true)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isActiveRow ? 0 : -1}\n />\n <Dialog\n size=\"xs\"\n open={clearConfirmationOpen}\n onClose={() => {\n setClearConfirmationOpen(false);\n requestAnimationFrame(() => {\n if (edititngActionsRef.current) {\n edititngActionsRef.current.focus();\n // When table looses focus, we need to re-set the last column index\n lastCellIndex.value = getColumnIndex(edititngActionsRef.current);\n }\n });\n }}>\n <Dialog.Content aria-label={texts.table3.editing.clearChangesConfirmationDialog.title}>\n <Dialog.Title>{texts.table3.editing.clearChangesConfirmationDialog.title}</Dialog.Title>\n\n <p>\n {texts.table3.editing.clearChangesConfirmationDialog.description\n .replace(\n '[ROW_IDENTIFIER]',\n rowIdentifier && rowIdentifierHeader ? rowIdentifierHeader : texts.table3.validation.index\n )\n .replace(\n '[ROW_IDENTIFIER_VALUE]',\n rowIdentifier && rowIdentifierHeader ? row.original[rowIdentifier] : row.index\n )}\n </p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button tabIndex={0}>{texts.table3.editing.clearChangesConfirmationDialog.cancel}</Button>\n </Dialog.Close>\n <Dialog.Close>\n <Button\n tabIndex={0}\n appearance=\"primary\"\n autoFocus\n onClick={() => editing.resetChange(row.id)}>\n {texts.table3.editing.clearChangesConfirmationDialog.confirm}\n </Button>\n </Dialog.Close>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </>\n );\n }\n\n const contentClassName = cn('flex items-center justify-end text-right', { '-mb-2 -mt-2': isActiveRow });\n return (\n <DisplayCell {...props} className={cn(className, { '!sticky': !!content })}>\n {content ? <span className={contentClassName}>{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {\n rowIdentifier?: string;\n};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n const allVisibleColumns = props.table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(props.index, lastColumnIndex)\n : undefined;\n\n return (\n <MemoedCell\n {...props}\n className={className}\n editing={tableMeta.editing}\n hasChanges={changeset.indexOf(props.row.id) >= 0}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 60;\n\nexport function createRowEditingActionsColumn<TType = unknown>(rowIdentifier?: string): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: (context: CellContext<TType, unknown>) => <Cell {...context} rowIdentifier={rowIdentifier} />,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","className","editing","hasChanges","isActiveRow","row","rowIdentifier","table","savingStatus","getSavingStatus","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","texts","useLocalization","clearConfirmationOpen","setClearConfirmationOpen","columns","getAllFlatColumns","column","find","rowIdentifierHeader","_column$columnDef$met","columnDef","meta","header","edititngActionsRef","useRef","tableMeta","options","handleSaved","resetSavingStatus","timer","useTimer","useEffect","SavingStatusValue","Saved","start","shortcutsState","pause","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","complete","Icon","name","isEditing","IconButton","ref","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","clear","toggleEditing","exit","tabIndex","Dialog","size","open","onClose","requestAnimationFrame","current","focus","lastCellIndex","value","getColumnIndex","clearChangesConfirmationDialog","Title","description","replace","validation","index","original","Footer","Group","Close","Button","cancel","autoFocus","resetChange","confirm","contentClassName","cn","DisplayCell","undefined","Cell","rowIndex","useContext","RowContext","changeset","changes","Object","keys","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","length","isIndicatorVisible","rowActive","rowActiveIndex","rowMoveReason","getIndicatorCellClassName","indexOf","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","ColumnHeader","cell","context","footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","minSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AAUzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;;EAC5F,MAAM;IAAEC,SAAS;IAAEC,OAAO;IAAEC,UAAU;IAAEC,WAAW;IAAEC,GAAG;IAAEC,aAAa;IAAEC;GAAO,GAAGP,KAAK;EAExF,MAAMQ,YAAY,GAAGN,OAAO,CAACO,eAAe,CAACJ,GAAG,CAACK,EAAE,CAAC;EACpD,MAAM,CAACC,uBAAuB,EAAEC,2BAA2B,CAAC,GAAGd,cAAK,CAACe,QAAQ,CAAC,KAAK,CAAC;EACpF,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGnB,cAAK,CAACe,QAAQ,CAAC,KAAK,CAAC;EAC/E,MAAMK,OAAO,GAAGX,KAAK,CAACY,iBAAiB,EAAE;EACzC,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACV,EAAE,KAAKJ,aAAa,CAAC;EAClE,MAAMgB,mBAAmB,GAAGF,MAAM,aAANA,MAAM,wBAAAG,qBAAA,GAANH,MAAM,CAAEI,SAAS,CAACC,IAAI,cAAAF,qBAAA,uBAAtBA,qBAAA,CAAwBG,MAAM;EAC1D,MAAMC,kBAAkB,GAAG7B,cAAK,CAAC8B,MAAM,CAAwC,IAAI,CAAC;EACpF,MAAMC,SAAS,GAAGtB,KAAK,CAACuB,OAAO,CAACL,IAAwB;EAExD,MAAMM,WAAW,GAAGA;IAChBnB,2BAA2B,CAAC,KAAK,CAAC;IAClCV,OAAO,CAAC8B,iBAAiB,CAAC3B,GAAG,CAACK,EAAE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AAM,EAAEgG,MAAY;IACpBC,IAAI,EAAGC,OAAoC,iBAAK9H,6BAACwG,IAAI,oBAAKsB,OAAO;MAAEtH,aAAa,EAAEA;OAAiB;IACnGuH,MAAM,EAAEnC,MAAM;IACdjE,IAAI,EAAE;MACFqG,KAAK,EAAE,OAAO;MACd7H,SAAS,EAAEkG,EAAE,CACT,mIAAmI,EACnI,kIAAkI,EAClI,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACD4B,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBvG,MAAM,EAAE,EAAE;MACVwG,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE,KAAK;IACrBzD,IAAI,EAAE8C,qBAAqB;IAC3BY,OAAO,EAAEZ;GACZ;AACL;;;;"}
@@ -62,8 +62,8 @@ import '../../../../Table/components/PaginatedTable.js';
62
62
  import '../../../../Table/components/WindowedTable.js';
63
63
  import '../../../../Table/util/rowIndexPath.js';
64
64
  import '../../../../Table/hooks/useRowCreation.js';
65
- import '../../../../../hooks/useLazyEffect.js';
66
65
  import ReactDOM from 'react-dom';
66
+ import '../../../../../hooks/useLazyEffect.js';
67
67
  import '../../../../Textarea/Textarea.js';
68
68
  import '../../../../../hooks/useMatchMedia.js';
69
69
  import '../../../../../hooks/useIsLargeScreen.js';
@@ -1,8 +1,9 @@
1
1
  import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
2
2
 
3
3
  function useTableRowSelectionListener(table, onRowSelect) {
4
- const selectedRows = table.getSelectedRowModel().rows;
4
+ const rowSelection = table.getState().rowSelection;
5
5
  useLazyEffect(() => {
6
+ const selectedRows = table.getSelectedRowModel().rows;
6
7
  if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
7
8
  if (table.options.enableMultiRowSelection) {
8
9
  onRowSelect(selectedRows.map(row => row.original));
@@ -11,7 +12,11 @@ function useTableRowSelectionListener(table, onRowSelect) {
11
12
  onRowSelect((_ref = [(_selectedRows$ = selectedRows[0]) === null || _selectedRows$ === void 0 ? void 0 : _selectedRows$.original]) !== null && _ref !== void 0 ? _ref : []);
12
13
  }
13
14
  }
14
- }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, selectedRows]);
15
+ // It is important to stringify either rowSelection state or selectedRows, because we don't
16
+ // know if the array or object that is returned by react-table has the same reference or not.
17
+ // rowSelection state is used here because it will be more expensive to strigify selectedRows
18
+ // than rowSelection state.
19
+ }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
15
20
  }
16
21
 
17
22
  export { useTableRowSelectionListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const selectedRows = table.getSelectedRowModel().rows;\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n if (table.options.enableMultiRowSelection) {\n onRowSelect(selectedRows.map(row => row.original));\n } else {\n onRowSelect([selectedRows[0]?.original] ?? []);\n }\n }\n }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, selectedRows]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","selectedRows","getSelectedRowModel","rows","useLazyEffect","options","enableRowSelection","enableMultiRowSelection","map","row","original","_ref","_selectedRows$"],"mappings":";;SAIgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,YAAY,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,IAAI;EAErDC,aAAa,CAAC;IACV,IAAIL,KAAK,CAACM,OAAO,CAACC,kBAAkB,IAAI,OAAON,WAAW,KAAK,UAAU,EAAE;MACvE,IAAID,KAAK,CAACM,OAAO,CAACE,uBAAuB,EAAE;QACvCP,WAAW,CAACC,YAAY,CAACO,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,CAAC;OACrD,MAAM;QAAA,IAAAC,IAAA,EAAAC,cAAA;QACHZ,WAAW,EAAAW,IAAA,GAAC,EAAAC,cAAA,GAACX,YAAY,CAAC,CAAC,CAAC,cAAAW,cAAA,uBAAfA,cAAA,CAAiBF,QAAQ,CAAC,cAAAC,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;;;GAGzD,EAAE,CAACZ,KAAK,CAACM,OAAO,CAACC,kBAAkB,EAAEP,KAAK,CAACM,OAAO,CAACE,uBAAuB,EAAEN,YAAY,CAAC,CAAC;AAC/F;;;;"}
1
+ {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rowSelection = table.getState().rowSelection;\n\n useLazyEffect(() => {\n const selectedRows = table.getSelectedRowModel().rows;\n\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n if (table.options.enableMultiRowSelection) {\n onRowSelect(selectedRows.map(row => row.original));\n } else {\n onRowSelect([selectedRows[0]?.original] ?? []);\n }\n }\n // It is important to stringify either rowSelection state or selectedRows, because we don't\n // know if the array or object that is returned by react-table has the same reference or not.\n // rowSelection state is used here because it will be more expensive to strigify selectedRows\n // than rowSelection state.\n }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rowSelection","getState","useLazyEffect","selectedRows","getSelectedRowModel","rows","options","enableRowSelection","enableMultiRowSelection","map","row","original","_ref","_selectedRows$","JSON","stringify"],"mappings":";;SAIgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,YAAY,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,YAAY;EAElDE,aAAa,CAAC;IACV,MAAMC,YAAY,GAAGL,KAAK,CAACM,mBAAmB,EAAE,CAACC,IAAI;IAErD,IAAIP,KAAK,CAACQ,OAAO,CAACC,kBAAkB,IAAI,OAAOR,WAAW,KAAK,UAAU,EAAE;MACvE,IAAID,KAAK,CAACQ,OAAO,CAACE,uBAAuB,EAAE;QACvCT,WAAW,CAACI,YAAY,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,CAAC;OACrD,MAAM;QAAA,IAAAC,IAAA,EAAAC,cAAA;QACHd,WAAW,EAAAa,IAAA,GAAC,EAAAC,cAAA,GAACV,YAAY,CAAC,CAAC,CAAC,cAAAU,cAAA,uBAAfA,cAAA,CAAiBF,QAAQ,CAAC,cAAAC,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;;;;;;;GAOzD,EAAE,CAACd,KAAK,CAACQ,OAAO,CAACC,kBAAkB,EAAET,KAAK,CAACQ,OAAO,CAACE,uBAAuB,EAAEM,IAAI,CAACC,SAAS,CAACf,YAAY,CAAC,CAAC,CAAC;AAC/G;;;;"}