@economic/taco 2.17.0 → 2.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -10090,7 +10090,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
10090
10090
  disabled: disabled,
10091
10091
  onClick: handleClick,
10092
10092
  ref: ref,
10093
- role: "button",
10093
+ role: "combobox",
10094
10094
  tabIndex: disabled || readOnly ? -1 : tabIndex,
10095
10095
  type: "button"
10096
10096
  }), children, /*#__PURE__*/React__default.createElement(Icon, {
@@ -12897,7 +12897,7 @@ function DisplayCell(props) {
12897
12897
  index,
12898
12898
  tableRef
12899
12899
  };
12900
- }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);
12900
+ }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex, className]);
12901
12901
  return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, memoedProps, {
12902
12902
  highlighted: highlighted,
12903
12903
  highlightedAsCurrent: highlightedAsCurrent
@@ -13010,6 +13010,85 @@ function FontSize$1(props) {
13010
13010
  }, texts.table3.fontSize.sizes.large)));
13011
13011
  }
13012
13012
 
13013
+ var IndicatorReason;
13014
+ (function (IndicatorReason) {
13015
+ IndicatorReason["SEARCH"] = "SEARCH";
13016
+ IndicatorReason["SORTING"] = "SORTING";
13017
+ IndicatorReason["FILTER"] = "FILTER";
13018
+ })(IndicatorReason || (IndicatorReason = {}));
13019
+ const useIndicatorText = reason => {
13020
+ let title = '';
13021
+ let description = '';
13022
+ const {
13023
+ texts
13024
+ } = useLocalization();
13025
+ switch (reason) {
13026
+ case IndicatorReason.FILTER:
13027
+ title = texts.table3.editing.rowIndicator.rowWillBeHidden;
13028
+ description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;
13029
+ break;
13030
+ case IndicatorReason.SEARCH:
13031
+ title = texts.table3.editing.rowIndicator.rowWillBeHidden;
13032
+ description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;
13033
+ break;
13034
+ case IndicatorReason.SORTING:
13035
+ title = texts.table3.editing.rowIndicator.rowWillMove;
13036
+ description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;
13037
+ break;
13038
+ }
13039
+ return {
13040
+ title,
13041
+ description
13042
+ };
13043
+ };
13044
+ const Indicator = ({
13045
+ reason,
13046
+ columnName,
13047
+ mountNode,
13048
+ validationErrors
13049
+ }) => {
13050
+ const container = React__default.useMemo(() => {
13051
+ const element = document.createElement('div');
13052
+ element.className += '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';
13053
+ return element;
13054
+ }, []);
13055
+ const indicatorText = useIndicatorText(reason);
13056
+ const hasValidationErrorsInRow = !!validationErrors;
13057
+ React__default.useEffect(() => {
13058
+ // mountNode could be null when rows are filtered
13059
+ // Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.
13060
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.add('!z-[21]', 'relative');
13061
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.appendChild(container);
13062
+ return () => {
13063
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.remove('!z-[21]', 'relative');
13064
+ mountNode === null || mountNode === void 0 ? void 0 : mountNode.removeChild(container);
13065
+ };
13066
+ }, [hasValidationErrorsInRow, mountNode]);
13067
+ // Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring
13068
+ // and being able to use Taco Tooltip component in side the visual indicator, portal is used.
13069
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(Tooltip, {
13070
+ title: indicatorText.description.replace('[COLUMN]', columnName)
13071
+ }, /*#__PURE__*/React__default.createElement("span", {
13072
+ className: "flex gap-1 hover:cursor-pointer"
13073
+ }, /*#__PURE__*/React__default.createElement(Icon, {
13074
+ name: "info",
13075
+ className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
13076
+ }), indicatorText.title)), container);
13077
+ };
13078
+ /**
13079
+ * Generates class names needed to highlight row cells, used when row has a move indicator
13080
+ */
13081
+ function getIndicatorCellClassName(columnIndex, lastColumnIndex) {
13082
+ return cn('!border-blue !border-y-2 border-x-0', {
13083
+ 'border-l-2 rounded-l': columnIndex === 0,
13084
+ 'border-r-2 rounded-r': columnIndex === lastColumnIndex
13085
+ });
13086
+ }
13087
+ function isIndicatorVisible(rowIndex, rowActiveIndex, rowMoveReason) {
13088
+ const isActiveRow = rowActiveIndex === rowIndex;
13089
+ return isActiveRow && rowMoveReason;
13090
+ }
13091
+
13013
13092
  const COLUMN_ID = '__actions';
13014
13093
  const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
13015
13094
  const {
@@ -13054,7 +13133,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
13054
13133
  // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.
13055
13134
  '-mt-2': fontSize === FONT_SIZE.small,
13056
13135
  '-mt-1.5': fontSize !== FONT_SIZE.small
13057
- });
13136
+ }, props.className);
13058
13137
  content = /*#__PURE__*/React__default.createElement("span", {
13059
13138
  className: className,
13060
13139
  ref: ref
@@ -13089,9 +13168,13 @@ function Cell(context) {
13089
13168
  rowIndex
13090
13169
  } = React__default.useContext(RowContext);
13091
13170
  const tableMeta = context.table.options.meta;
13171
+ const allVisibleColumns = context.table.getVisibleLeafColumns();
13172
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
13173
+ const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(context.index, lastColumnIndex) : undefined;
13092
13174
  return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, context, {
13093
13175
  actions: tableMeta.rowActions.actionsForRow,
13094
13176
  actionsLength: tableMeta.rowActions.actionsForRowLength,
13177
+ className: className,
13095
13178
  fontSize: tableMeta.fontSize.size,
13096
13179
  isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex,
13097
13180
  isEditing: tableMeta.editing.isEditing,
@@ -13526,8 +13609,9 @@ function useLazyEffect(effect, deps) {
13526
13609
  }
13527
13610
 
13528
13611
  function useTableRowSelectionListener(table, onRowSelect) {
13529
- const selectedRows = table.getSelectedRowModel().rows;
13612
+ const rowSelection = table.getState().rowSelection;
13530
13613
  useLazyEffect(() => {
13614
+ const selectedRows = table.getSelectedRowModel().rows;
13531
13615
  if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
13532
13616
  if (table.options.enableMultiRowSelection) {
13533
13617
  onRowSelect(selectedRows.map(row => row.original));
@@ -13536,7 +13620,11 @@ function useTableRowSelectionListener(table, onRowSelect) {
13536
13620
  onRowSelect((_ref = [(_selectedRows$ = selectedRows[0]) === null || _selectedRows$ === void 0 ? void 0 : _selectedRows$.original]) !== null && _ref !== void 0 ? _ref : []);
13537
13621
  }
13538
13622
  }
13539
- }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, selectedRows]);
13623
+ // It is important to stringify either rowSelection state or selectedRows, because we don't
13624
+ // know if the array or object that is returned by react-table has the same reference or not.
13625
+ // rowSelection state is used here because it will be more expensive to strigify selectedRows
13626
+ // than rowSelection state.
13627
+ }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
13540
13628
  }
13541
13629
 
13542
13630
  function useRowDrag(isEnabled) {
@@ -13907,72 +13995,6 @@ function useRowDrop(isEnabled, handler) {
13907
13995
  };
13908
13996
  }
13909
13997
 
13910
- var IndicatorReason;
13911
- (function (IndicatorReason) {
13912
- IndicatorReason["SEARCH"] = "SEARCH";
13913
- IndicatorReason["SORTING"] = "SORTING";
13914
- IndicatorReason["FILTER"] = "FILTER";
13915
- })(IndicatorReason || (IndicatorReason = {}));
13916
- const useIndicatorText = reason => {
13917
- let title = '';
13918
- let description = '';
13919
- const {
13920
- texts
13921
- } = useLocalization();
13922
- switch (reason) {
13923
- case IndicatorReason.FILTER:
13924
- title = texts.table3.editing.rowIndicator.rowWillBeHidden;
13925
- description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;
13926
- break;
13927
- case IndicatorReason.SEARCH:
13928
- title = texts.table3.editing.rowIndicator.rowWillBeHidden;
13929
- description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;
13930
- break;
13931
- case IndicatorReason.SORTING:
13932
- title = texts.table3.editing.rowIndicator.rowWillMove;
13933
- description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;
13934
- break;
13935
- }
13936
- return {
13937
- title,
13938
- description
13939
- };
13940
- };
13941
- const Indicator = ({
13942
- reason,
13943
- columnName,
13944
- mountNode,
13945
- validationErrors
13946
- }) => {
13947
- const container = React__default.useMemo(() => {
13948
- const element = document.createElement('div');
13949
- element.className += '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';
13950
- return element;
13951
- }, []);
13952
- const indicatorText = useIndicatorText(reason);
13953
- const hasValidationErrorsInRow = !!validationErrors;
13954
- React__default.useEffect(() => {
13955
- // mountNode could be null when rows are filtered
13956
- // Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.
13957
- mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.add('!z-[21]', 'relative');
13958
- mountNode === null || mountNode === void 0 ? void 0 : mountNode.appendChild(container);
13959
- return () => {
13960
- mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.remove('!z-[21]', 'relative');
13961
- mountNode === null || mountNode === void 0 ? void 0 : mountNode.removeChild(container);
13962
- };
13963
- }, [hasValidationErrorsInRow, mountNode]);
13964
- // Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring
13965
- // and being able to use Taco Tooltip component in side the visual indicator, portal is used.
13966
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(Tooltip, {
13967
- title: indicatorText.description.replace('[COLUMN]', columnName)
13968
- }, /*#__PURE__*/React__default.createElement("span", {
13969
- className: "flex gap-1 hover:cursor-pointer"
13970
- }, /*#__PURE__*/React__default.createElement(Icon, {
13971
- name: "info",
13972
- className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
13973
- }), indicatorText.title)), container);
13974
- };
13975
-
13976
13998
  const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];
13977
13999
  const focusableSelector = /*#__PURE__*/focussableNodeNames.join(', ');
13978
14000
  const hasChanged = (value, newValue) => {
@@ -14627,10 +14649,11 @@ const COLUMN_ID$1 = '__editing_actions';
14627
14649
  const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
14628
14650
  var _column$columnDef$met;
14629
14651
  const {
14652
+ className,
14653
+ editing,
14630
14654
  hasChanges,
14631
14655
  isActiveRow,
14632
14656
  row,
14633
- editing,
14634
14657
  rowIdentifier,
14635
14658
  table
14636
14659
  } = props;
@@ -14724,7 +14747,7 @@ const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props)
14724
14747
  '-mb-2 -mt-2': isActiveRow
14725
14748
  });
14726
14749
  return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, {
14727
- className: cn({
14750
+ className: cn(className, {
14728
14751
  '!sticky': !!content
14729
14752
  })
14730
14753
  }), content ? /*#__PURE__*/React__default.createElement("span", {
@@ -14737,10 +14760,14 @@ function Cell$1(props) {
14737
14760
  } = React__default.useContext(RowContext);
14738
14761
  const tableMeta = props.table.options.meta;
14739
14762
  const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];
14763
+ const allVisibleColumns = props.table.getVisibleLeafColumns();
14764
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
14765
+ const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(props.index, lastColumnIndex) : undefined;
14740
14766
  return /*#__PURE__*/React__default.createElement(MemoedCell$1, Object.assign({}, props, {
14767
+ className: className,
14768
+ editing: tableMeta.editing,
14741
14769
  hasChanges: changeset.indexOf(props.row.id) >= 0,
14742
- isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex,
14743
- editing: tableMeta.editing
14770
+ isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex
14744
14771
  }));
14745
14772
  }
14746
14773
  const EDITING_ACTIONS_WIDTH = 60;
@@ -15136,6 +15163,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
15136
15163
  highlighted,
15137
15164
  highlightedAsCurrent
15138
15165
  } = props;
15166
+ const {
15167
+ rowIndex
15168
+ } = React__default.useContext(RowContext);
15139
15169
  const columnMeta = column.columnDef.meta;
15140
15170
  const cellRef = React__default.useRef(null);
15141
15171
  const controlRef = React__default.useRef(null);
@@ -15194,17 +15224,24 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
15194
15224
  React__default.useEffect(() => {
15195
15225
  // To avoid reseting move reason on another row hover,
15196
15226
  // we need to check for changes only if value got changed in the current row.
15197
- if (!isActiveRow || error) {
15227
+ if (!isActiveRow) {
15228
+ return;
15229
+ }
15230
+ if (error) {
15198
15231
  if (tableMeta.editing.rowMoveReason) {
15199
15232
  removeMoveReason();
15200
15233
  }
15201
15234
  return;
15202
15235
  }
15203
15236
  if (hasChanged(getValue(), value)) {
15204
- const moveReason = getRowMoveReason(table, row.index, row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
15205
- tableMeta.editing.setRowMoveReason({
15206
- [cell.column.id]: moveReason
15207
- });
15237
+ const moveReason = getRowMoveReason(table, rowIndex,
15238
+ // cannot use row.index, as this is not kept in sync once a column is sorted.
15239
+ row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
15240
+ if (moveReason) {
15241
+ tableMeta.editing.setRowMoveReason({
15242
+ [cell.column.id]: moveReason
15243
+ });
15244
+ }
15208
15245
  } else {
15209
15246
  removeMoveReason();
15210
15247
  }
@@ -15214,7 +15251,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
15214
15251
  const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
15215
15252
  // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative
15216
15253
  relative: controlRenderer === 'textarea' && columnMeta.enableTruncate
15217
- }, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
15254
+ }, props.className, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
15218
15255
  const fieldClassName = cn('!min-h-0 w-full !pb-0', {
15219
15256
  '!pb-3': !!error
15220
15257
  });
@@ -15297,7 +15334,8 @@ function Cell$2(props) {
15297
15334
  } = props;
15298
15335
  const {
15299
15336
  isHovered: isHoveredRow,
15300
- hasError
15337
+ hasError,
15338
+ rowIndex
15301
15339
  } = useRowContext();
15302
15340
  const rows = table.getRowModel().rows;
15303
15341
  const tableMeta = table.options.meta;
@@ -15307,15 +15345,15 @@ function Cell$2(props) {
15307
15345
  const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;
15308
15346
  const isActiveRow = rowActiveIndex !== undefined && ((_rows$rowActiveIndex = rows[rowActiveIndex]) === null || _rows$rowActiveIndex === void 0 ? void 0 : _rows$rowActiveIndex.id) === row.id;
15309
15347
  let value = getValue();
15348
+ const allVisibleColumns = table.getVisibleLeafColumns();
15349
+ const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
15350
+ const className = isIndicatorVisible(rowIndex, rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(index, lastColumnIndex) : undefined;
15310
15351
  // When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.
15311
15352
  // Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.
15312
15353
  if (tableMeta.editing.isEditing) {
15313
15354
  const editingValue = tableMeta.editing.getCellValue(cell);
15314
15355
  value = editingValue !== null && editingValue !== void 0 ? editingValue : value;
15315
15356
  }
15316
- const {
15317
- rowIndex
15318
- } = React__default.useContext(RowContext);
15319
15357
  const memoedHighlight = React__default.useMemo(() => {
15320
15358
  var _tableMeta$search$que;
15321
15359
  if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
@@ -15343,10 +15381,13 @@ function Cell$2(props) {
15343
15381
  if (tableMeta.editing.isEditing && columnMeta.control && (isActiveRow || isHoveredRow && !tableMeta.rowActive.isHoverStatePaused ||
15344
15382
  // When cell has error, we renderimg it in edit mode (UX reqirement)
15345
15383
  isColumnError)) {
15346
- return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps));
15384
+ return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps, {
15385
+ className: className
15386
+ }));
15347
15387
  }
15348
15388
  return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, highlightProps, {
15349
- value: value
15389
+ value: value,
15390
+ className: className
15350
15391
  }));
15351
15392
  }
15352
15393
 
@@ -18670,7 +18711,8 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
18670
18711
  const handleKeyDown = event => {
18671
18712
  const target = event.target;
18672
18713
  const dialog = target.closest('[role="dialog"]');
18673
- const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]');
18714
+ // Select2 also have combobox role to align with W3C guidelines
18715
+ const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]:not([data-taco="Select2"])');
18674
18716
  // Don't trigger global shortcuts on the table if event originated from a combobox or if table is
18675
18717
  // outside the dialog
18676
18718
  if (eventOriginatedFromCombobox || dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current)) || tableMeta.shortcutsState.isPaused) {