@economic/taco 2.36.0 → 2.36.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 (26) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/components/Select2/components/Search.d.ts +6 -0
  3. package/dist/components/Table3/Table3.d.ts +1 -25
  4. package/dist/components/Table3/types.d.ts +1 -11
  5. package/dist/esm/packages/taco/src/components/Select2/Select2.js +16 -7
  6. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/Select2/components/Search.js +12 -2
  8. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +3 -24
  11. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  12. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  13. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -2
  14. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  15. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +0 -9
  16. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  17. package/dist/esm/packages/taco/src/utils/dom.js +2 -2
  18. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  19. package/dist/primitives/Table/types.d.ts +1 -1
  20. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
  21. package/dist/taco.cjs.development.js +34 -46
  22. package/dist/taco.cjs.development.js.map +1 -1
  23. package/dist/taco.cjs.production.min.js +1 -1
  24. package/dist/taco.cjs.production.min.js.map +1 -1
  25. package/dist/utils/dom.d.ts +1 -1
  26. package/package.json +2 -2
@@ -4156,7 +4156,7 @@ const getIndexOfFirstChildOverflowingParent = (element, overscan = 0) => {
4156
4156
  }
4157
4157
  return boundaryChildIndex;
4158
4158
  };
4159
- const getNextFocussableElement = (currentElement, direction = 1) => {
4159
+ const getNextFocussableElement = currentElement => {
4160
4160
  if (!currentElement) {
4161
4161
  return null;
4162
4162
  }
@@ -4166,7 +4166,7 @@ const getNextFocussableElement = (currentElement, direction = 1) => {
4166
4166
  if (currentElementIndex !== -1 && currentElementIndex === focussableElements.length - 1) {
4167
4167
  return null;
4168
4168
  }
4169
- return focussableElements[currentElementIndex + direction];
4169
+ return focussableElements[currentElementIndex + 1];
4170
4170
  };
4171
4171
  const getOverlaySelector = element => {
4172
4172
  switch (element === null || element === void 0 ? void 0 : element.getAttribute('role')) {
@@ -10218,13 +10218,6 @@ function mapTableChildrenToColumns(props, settings, options, internalColumns) {
10218
10218
  function configureReactTableOptions(options, props) {
10219
10219
  var _options$enableFilter, _options$enableColumn, _options$enableRowExp, _options$enableColumn2, _options$enableColumn3, _options$enableSortin;
10220
10220
  const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;
10221
- const getRowIdentityColumnAccessor = () => {
10222
- if (!props.rowIdentityColumnAccessor) {
10223
- return undefined;
10224
- }
10225
- const rowIdentityColumnAccessors = [props.rowIdentityColumnAccessor].flat();
10226
- return originalRow => rowIdentityColumnAccessors.map(identityColumnAccessor => String(originalRow[identityColumnAccessor])).join('_');
10227
- };
10228
10221
  const tableOptions = {
10229
10222
  defaultColumn: {
10230
10223
  enableColumnFilter: options.enableFiltering || true,
@@ -10249,8 +10242,6 @@ function configureReactTableOptions(options, props) {
10249
10242
  // models for default features
10250
10243
  getExpandedRowModel: reactTable.getExpandedRowModel(),
10251
10244
  getGroupedRowModel: reactTable.getGroupedRowModel(),
10252
- // Use row indentity column values as id for each row
10253
- getRowId: getRowIdentityColumnAccessor(),
10254
10245
  groupedColumnMode: false
10255
10246
  };
10256
10247
  if (tableOptions.enableColumnResizing) {
@@ -11592,7 +11583,6 @@ function useTableManager(props, meta, internalColumns) {
11592
11583
  // ensure data is always valid
11593
11584
  const data = (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : [];
11594
11585
  const length = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : data.length;
11595
- const rowIdentityColumnAccessor = props.rowIdentityColumnAccessor !== undefined ? [props.rowIdentityColumnAccessor].flat() : [];
11596
11586
  // create a react-table instance
11597
11587
  const instance = reactTable.useReactTable({
11598
11588
  data,
@@ -11620,7 +11610,7 @@ function useTableManager(props, meta, internalColumns) {
11620
11610
  rowDrag,
11621
11611
  rowDrop: rowDrop,
11622
11612
  rowExpansion: rowExpansion,
11623
- rowIdentityColumnAccessor,
11613
+ rowIdentityColumnId: props.rowIdentityColumnId,
11624
11614
  rowGoto,
11625
11615
  rowGroups: rowGroups,
11626
11616
  rowHeight,
@@ -15279,12 +15269,17 @@ const BubbleSelect = props => {
15279
15269
  };
15280
15270
 
15281
15271
  const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(props, ref) {
15272
+ const {
15273
+ onTabKeyPress,
15274
+ ...otherProps
15275
+ } = props;
15282
15276
  const {
15283
15277
  listboxRef,
15284
15278
  searchQuery,
15285
15279
  setSearchQuery,
15286
15280
  setValidationError,
15287
- validationError
15281
+ validationError,
15282
+ setOpen
15288
15283
  } = useSelect2Context();
15289
15284
  const handleChange = event => {
15290
15285
  if (validationError) {
@@ -15297,6 +15292,11 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
15297
15292
  if (event.key === ' ') {
15298
15293
  return;
15299
15294
  }
15295
+ // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)
15296
+ if (event.key === 'Tab') {
15297
+ setOpen(false);
15298
+ onTabKeyPress();
15299
+ }
15300
15300
  if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
15301
15301
  var _listboxRef$current;
15302
15302
  event.preventDefault();
@@ -15311,7 +15311,7 @@ const Search$2 = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(p
15311
15311
  }),
15312
15312
  invalid: !!validationError,
15313
15313
  message: validationError === null || validationError === void 0 ? void 0 : validationError.message
15314
- }, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, props, {
15314
+ }, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, otherProps, {
15315
15315
  "aria-hidden": true,
15316
15316
  autoFocus: true,
15317
15317
  invalid: !!validationError,
@@ -15522,6 +15522,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15522
15522
  // align the listbox min width with the width of the input - it should never be smaller
15523
15523
  const dimensions = useBoundingClientRectListener(internalRef);
15524
15524
  // state
15525
+ const [tabTriggeredClose, setTabTriggeredClose] = React__default.useState(false);
15525
15526
  const [open, setOpen] = React__default.useState(false);
15526
15527
  const [value, _setValue] = reactUseControllableState.useControllableState({
15527
15528
  // uncontrolled
@@ -15607,13 +15608,20 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15607
15608
  setShouldPauseHoverState(true);
15608
15609
  }
15609
15610
  };
15610
- const handleTab = event => {
15611
- if (event.key === 'Tab') {
15612
- const nextFocussableElement = getNextFocussableElement(internalRef.current, event.shiftKey ? -1 : +1);
15611
+ const handleCloseAutoFocus = event => {
15612
+ event.preventDefault();
15613
+ event.stopPropagation();
15614
+ if (tabTriggeredClose) {
15615
+ const nextFocussableElement = getNextFocussableElement(internalRef.current);
15613
15616
  if (nextFocussableElement) {
15614
15617
  // UX requirement: move focus to the next focussable element when tab key is pressed to select the value
15615
15618
  nextFocussableElement.focus();
15619
+ // Reset the tabTriggeredClose state
15620
+ setTabTriggeredClose(false);
15616
15621
  }
15622
+ } else {
15623
+ var _internalRef$current;
15624
+ (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
15617
15625
  }
15618
15626
  };
15619
15627
  const selectOptions = searchQuery === '' ? flattenedChildren.map(child => child.props.value) : filteredChildren.map(child => isGroup(child) ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value) : child.props.value).flatMap(c => c) || [];
@@ -15668,10 +15676,10 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15668
15676
  asChild: true,
15669
15677
  align: "start",
15670
15678
  onOpenAutoFocus: () => {
15671
- var _internalRef$current;
15672
- (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
15679
+ var _internalRef$current2;
15680
+ (_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.focus();
15673
15681
  },
15674
- onKeyDown: handleTab,
15682
+ onCloseAutoFocus: handleCloseAutoFocus,
15675
15683
  sideOffset: 4,
15676
15684
  tabIndex: -1
15677
15685
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -15681,7 +15689,8 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15681
15689
  }
15682
15690
  }, flattenedChildren.length > 0 || onCreate ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Search$2, {
15683
15691
  placeholder: onCreate ? texts.select2.searchOrCreate : texts.select2.search,
15684
- ref: searchRef
15692
+ ref: searchRef,
15693
+ onTabKeyPress: () => setTabTriggeredClose(true)
15685
15694
  }), multiple && selectOptions.length > 1 && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button$1, {
15686
15695
  className: "!justify-start",
15687
15696
  appearance: "discrete",
@@ -19273,22 +19282,6 @@ function Alert$1(props) {
19273
19282
  const tableMeta = table.options.meta;
19274
19283
  const [showFilterResetDialog, setShowFilterResetDialog] = React__default.useState(false);
19275
19284
  const pendingChangesWithErrors = tableMeta.editing.getErrors();
19276
- const resetPendingChanges = tableMeta.editing.resetChanges;
19277
- const allRows = table.getPreFilteredRowModel().rows;
19278
- // This effect deletes error in the alert if the row that has the error is deleted.
19279
- React__default.useEffect(() => {
19280
- pendingChangesWithErrors.forEach(errorRow => {
19281
- const errorRowId = errorRow.rowId;
19282
- try {
19283
- // getRow throws error if it fails to find the row
19284
- if (!table.getRow(errorRowId)) {
19285
- resetPendingChanges(errorRowId);
19286
- }
19287
- } catch {
19288
- resetPendingChanges(errorRowId);
19289
- }
19290
- });
19291
- }, [allRows.length]);
19292
19285
  const activeRow = React__default.useMemo(() => tableMeta.rowActive.rowActiveIndex ? table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex] : undefined, [tableMeta.rowActive.rowActiveIndex]);
19293
19286
  // mark errors being rendered as seen
19294
19287
  React__default.useEffect(() => {
@@ -19317,23 +19310,18 @@ function Alert$1(props) {
19317
19310
  const title = (pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural).replace('[COUNT]', String(pendingChangesWithErrors.length));
19318
19311
  // generate links to each invalid row, to go into the error message
19319
19312
  const links = [];
19320
- const rowIdentityColumn = tableMeta.rowIdentityColumnAccessor ?
19321
- // Since rowIdentityColumnAccessor can have multiple ids, we use the first id to refer to the row in Alert
19322
- table.getColumn(String(tableMeta.rowIdentityColumnAccessor[0])) : undefined;
19313
+ const rowIdentityColumn = tableMeta.rowIdentityColumnId ? table.getColumn(tableMeta.rowIdentityColumnId) : undefined;
19323
19314
  pendingChangesWithErrors.forEach((error, index) => {
19324
19315
  // if appropriate, concatenate the item with the text "and"
19325
19316
  if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
19326
19317
  // Add space before and after `messageAnd` text
19327
19318
  links.push(` ${validationTexts.alert.messageAnd} `);
19328
19319
  }
19329
- const rowIndex = table.getFilteredRowModel().rows.findIndex(row => row.id === error.rowId);
19320
+ const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
19330
19321
  const handleClick = () => {
19331
- // if row is visible
19332
19322
  if (rowIndex > -1) {
19333
19323
  scrollToRow(rowIndex);
19334
- }
19335
- // if row is filtered out
19336
- else {
19324
+ } else {
19337
19325
  setShowFilterResetDialog(error.rowId);
19338
19326
  }
19339
19327
  };