@economic/taco 2.26.19 → 2.27.0

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 (39) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/components/Report/types.d.ts +1 -1
  3. package/dist/components/Report/useReport.d.ts +2 -2
  4. package/dist/components/Select2/Select2.d.ts +2 -0
  5. package/dist/components/Select2/utilities.d.ts +2 -0
  6. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +1 -1
  7. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Report/useReport.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Select2/Select2.js +14 -2
  10. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +2 -6
  12. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +3 -6
  14. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Select2/utilities.js +14 -1
  16. package/dist/esm/packages/taco/src/components/Select2/utilities.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +2 -2
  18. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  19. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -2
  20. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  21. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +15 -6
  22. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  23. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +15 -6
  24. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  25. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +10 -3
  26. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  28. package/dist/esm/packages/taco/src/utils/date.js +2 -2
  29. package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
  30. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +11 -2
  31. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
  32. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  33. package/dist/primitives/Table/Core/useTable.d.ts +1 -1
  34. package/dist/taco.cjs.development.js +73 -31
  35. package/dist/taco.cjs.development.js.map +1 -1
  36. package/dist/taco.cjs.production.min.js +1 -1
  37. package/dist/taco.cjs.production.min.js.map +1 -1
  38. package/dist/utils/date.d.ts +1 -1
  39. package/package.json +2 -2
@@ -17,7 +17,7 @@ export declare type useTableReturnValue<TType = unknown> = {
17
17
  };
18
18
  ref: React.RefObject<TableRef>;
19
19
  renderer: {
20
- rows: JSX.Element[] | null;
20
+ rows: (JSX.Element | null)[] | null;
21
21
  style: React.CSSProperties;
22
22
  scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;
23
23
  };
@@ -5977,7 +5977,7 @@ const format = (date, mask = 'dd.mm.yy') => {
5977
5977
  const pad = v => String(v).length === 1 ? `0${v}` : v.toString();
5978
5978
  return mask.replace('dd', pad(value.getDate())).replace('mm', pad(value.getMonth() + 1)).replace('yy', String(value.getFullYear()).slice(2));
5979
5979
  };
5980
- const parseFromCustomString = (date = '', mask = 'dd.mm.yy') => {
5980
+ const parseFromCustomString = (date = '', mask = 'dd.mm.yy', defaultYear = undefined) => {
5981
5981
  if (!date || !date.length) {
5982
5982
  return undefined;
5983
5983
  }
@@ -6011,7 +6011,7 @@ const parseFromCustomString = (date = '', mask = 'dd.mm.yy') => {
6011
6011
  month = Number.parseInt(month, 10);
6012
6012
  year = Number.parseInt(year, 10);
6013
6013
  const currentDate = new Date();
6014
- return new Date( /* year */Object.is(year, NaN) ? currentDate.getFullYear() : year, /* month */Object.is(month, NaN) ? currentDate.getMonth() : month - 1,
6014
+ return new Date( /* year */Object.is(year, NaN) ? defaultYear !== null && defaultYear !== void 0 ? defaultYear : currentDate.getFullYear() : year, /* month */Object.is(month, NaN) ? currentDate.getMonth() : month - 1,
6015
6015
  // months are zero based in javascript, so subtract a day
6016
6016
  /* day */
6017
6017
  Object.is(day, NaN) ? currentDate.getDate() : day, /* hours */12, /* minutes */0 // set to midday to avoid UTC offset causing dates to be mismatched server side
@@ -6049,7 +6049,7 @@ const useDatepicker = ({
6049
6049
  // event handlers
6050
6050
  const handleInputBlur = event => {
6051
6051
  event.persist();
6052
- const valueAsDate = parseFromCustomString(event.target.value);
6052
+ const valueAsDate = parseFromCustomString(event.target.value, 'dd.mm.yy', value === null || value === void 0 ? void 0 : value.getFullYear());
6053
6053
  const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';
6054
6054
  event.target.value = formattedValue;
6055
6055
  if (onChange) {
@@ -11243,10 +11243,11 @@ function Row(props) {
11243
11243
  const TABLE_SCROLL_PADDING_BOTTOM = 36;
11244
11244
  const TABLE_PADDING_BOTTOM = 120;
11245
11245
  function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11246
- var _table$getState$group, _virtualItems$;
11246
+ var _table$getState$group, _ref, _virtualItems$padding, _virtualItems$padding2, _ref2, _virtualItems;
11247
11247
  const tableMeta = table.options.meta;
11248
11248
  const rows = table.getRowModel().rows;
11249
11249
  const HEADER_OFFSET_TOTAL = HEADER_ROW_HEIGHT_ESTIMATE * table.getHeaderGroups().length;
11250
+ const isTableGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
11250
11251
  // expanded rows
11251
11252
  const {
11252
11253
  createRowMeasurer,
@@ -11260,7 +11261,7 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11260
11261
  getScrollElement: () => tableRef.current,
11261
11262
  overscan: tableMeta.printing.isPrinting ? rows.length : undefined,
11262
11263
  rangeExtractor,
11263
- scrollPaddingStart: (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length ? HEADER_ROW_HEIGHT_ESTIMATE : undefined,
11264
+ scrollPaddingStart: isTableGrouped ? HEADER_ROW_HEIGHT_ESTIMATE : undefined,
11264
11265
  scrollPaddingEnd: HEADER_OFFSET_TOTAL + TABLE_SCROLL_PADDING_BOTTOM,
11265
11266
  paddingEnd: TABLE_PADDING_BOTTOM
11266
11267
  });
@@ -11293,10 +11294,12 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11293
11294
  }
11294
11295
  }
11295
11296
  }, [virtualItems.length, tableRef.current]);
11297
+ // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0
11298
+ const paddingStartIndex = isTableGrouped && rows.length > 1 ? 1 : 0;
11296
11299
  // styling for offsetting rows - this "is" the virtualisation
11297
11300
  const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [
11298
11301
  // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0
11299
- Math.max(0, ((_virtualItems$ = virtualItems[1]) !== null && _virtualItems$ !== void 0 ? _virtualItems$ : virtualItems[0]).start - virtualiser.options.scrollMargin - virtualItems[0].size), Math.max(0, virtualiser.getTotalSize() - virtualItems[virtualItems.length - 1].end)] : [0, 0];
11302
+ Math.max(0, (_ref = ((_virtualItems$padding = virtualItems[paddingStartIndex]) === null || _virtualItems$padding === void 0 ? void 0 : _virtualItems$padding.start) - virtualiser.options.scrollMargin - ((_virtualItems$padding2 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding2 === void 0 ? void 0 : _virtualItems$padding2.size)) !== null && _ref !== void 0 ? _ref : 0), Math.max(0, (_ref2 = virtualiser.getTotalSize() - ((_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end)) !== null && _ref2 !== void 0 ? _ref2 : 0)] : [0, 0];
11300
11303
  // ensure default active rows are scrolled to
11301
11304
  React__default.useEffect(() => {
11302
11305
  if (defaultRowActiveIndex) {
@@ -11316,6 +11319,10 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11316
11319
  paddingTop
11317
11320
  };
11318
11321
  content = virtualItems.map(virtualRow => {
11322
+ // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
11323
+ if (!virtualRow) {
11324
+ return null;
11325
+ }
11319
11326
  const row = rows[virtualRow.index];
11320
11327
  const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);
11321
11328
  return /*#__PURE__*/React__default.createElement(Row, {
@@ -12810,16 +12817,25 @@ function Summary(props) {
12810
12817
  }, label, "\u00A0", count);
12811
12818
  }
12812
12819
 
12813
- function Footer$3(header) {
12814
- return /*#__PURE__*/React__default.createElement(MemoedFooter, {
12820
+ function Foot(props) {
12821
+ const nonGroupedHeaders = props.table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
12822
+ return /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => ( /*#__PURE__*/React__default.createElement(Footer$3, {
12815
12823
  key: header.id,
12816
- footer: header
12824
+ header: header,
12825
+ index: index
12826
+ })))));
12827
+ }
12828
+ function Footer$3(props) {
12829
+ return /*#__PURE__*/React__default.createElement(MemoedFooter, {
12830
+ footer: props.header,
12831
+ index: props.index
12817
12832
  });
12818
12833
  }
12819
12834
  const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
12820
12835
  var _footer$subHeaders, _footer$subHeaders$fi;
12821
12836
  const {
12822
- footer
12837
+ footer,
12838
+ index
12823
12839
  } = props;
12824
12840
  const columnMeta = footer.column.columnDef.meta;
12825
12841
  // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
@@ -12832,7 +12848,7 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
12832
12848
  }
12833
12849
  let content;
12834
12850
  let align;
12835
- if (footer.index === 0) {
12851
+ if (index === 0) {
12836
12852
  align = 'left';
12837
12853
  content = /*#__PURE__*/React__default.createElement(Summary, {
12838
12854
  table: footer.getContext().table
@@ -13872,6 +13888,18 @@ const createOptionClassName = (shouldPauseHoverState = false) => cn('group mb-px
13872
13888
  'hover:wcag-grey-200': !shouldPauseHoverState
13873
13889
  });
13874
13890
  const createCollectionClassName = () => 'flex flex-col gap-px';
13891
+ const getFontSize = fontSize => {
13892
+ switch (fontSize) {
13893
+ case exports.FontSizes.small:
13894
+ return 'text-xs';
13895
+ case exports.FontSizes.medium:
13896
+ return 'text-sm';
13897
+ case exports.FontSizes.large:
13898
+ return 'text-base';
13899
+ default:
13900
+ return 'text-sm';
13901
+ }
13902
+ };
13875
13903
 
13876
13904
  const Select2Context = /*#__PURE__*/React__default.createContext({});
13877
13905
  const useSelect2Context = () => React__default.useContext(Select2Context);
@@ -14083,11 +14111,7 @@ const Option$1 = /*#__PURE__*/React__default.forwardRef(function Select2Option(p
14083
14111
  value,
14084
14112
  fontSize = exports.FontSizes.medium
14085
14113
  } = useSelect2Context();
14086
- const className = cn(createOptionClassName(shouldPauseHoverState), {
14087
- 'text-xs': fontSize === exports.FontSizes.small,
14088
- 'text-sm': fontSize === exports.FontSizes.medium,
14089
- 'text-base': fontSize === exports.FontSizes.large
14090
- }, cName);
14114
+ const className = cn(createOptionClassName(shouldPauseHoverState), fontSize && getFontSize(fontSize), cName);
14091
14115
  const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;
14092
14116
  const isTag = tags && !!color;
14093
14117
  const handleClick = () => {
@@ -14220,11 +14244,8 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
14220
14244
  highlighted,
14221
14245
  invalid,
14222
14246
  readOnly
14223
- }).replace('w-full', '').replace('px-2', ''), {
14224
- 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-')),
14225
- 'text-xs': fontSize === exports.FontSizes.small,
14226
- 'text-sm': fontSize === exports.FontSizes.medium,
14227
- 'text-base': fontSize === exports.FontSizes.large
14247
+ }).replace('w-full', '').replace('px-2', ''), fontSize && getFontSize(fontSize), {
14248
+ 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-'))
14228
14249
  }, props.className);
14229
14250
  const handleClick = event => {
14230
14251
  if (disabled || readOnly) {
@@ -14732,6 +14753,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
14732
14753
  tags = false,
14733
14754
  value: prop,
14734
14755
  fontSize,
14756
+ loading,
14735
14757
  ...otherProps
14736
14758
  } = props;
14737
14759
  const emptyOption = React__default.useMemo(() => {
@@ -14944,7 +14966,16 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
14944
14966
  onClick: areAllSelected ? deselectAll : selectAll
14945
14967
  }, selectAllText), /*#__PURE__*/React__default.createElement("div", {
14946
14968
  className: "border-grey-300 mx-3 rounded border-t"
14947
- }))))) : null, flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
14969
+ }))))) : null, loading ? ( /*#__PURE__*/React__default.createElement("span", {
14970
+ className: cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))
14971
+ }, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(Spinner, {
14972
+ delay: 0,
14973
+ className: cn('ml-3 mr-2 mt-1.5 h-5 w-5', {
14974
+ '!mt-1 !h-3.5 !w-3.5': fontSize === exports.FontSizes.small,
14975
+ '!h-4 !w-4': fontSize === exports.FontSizes.medium,
14976
+ '!h-5 !w-5': fontSize === exports.FontSizes.large
14977
+ })
14978
+ })), /*#__PURE__*/React__default.createElement("span", null, texts.listbox.loading))) : flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
14948
14979
  className: "text-grey-700 -mt-0.5 flex h-8 items-center px-2",
14949
14980
  role: "presentation"
14950
14981
  }, "No results found...")) : ( /*#__PURE__*/React__default.createElement(Root$1, {
@@ -15127,12 +15158,21 @@ function Print$1(props) {
15127
15158
  // do this here because Safari doesn't support the beforeprint event
15128
15159
  togglePrinting(true);
15129
15160
  requestAnimationFrame(() => {
15130
- try {
15131
- // window.print doesn't always work in Safari :man_shrugging:
15132
- document.execCommand('print', false, undefined);
15133
- } catch {
15134
- window.print();
15135
- }
15161
+ requestAnimationFrame(() => {
15162
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
15163
+ if (isSafari) {
15164
+ try {
15165
+ // Try using document.execCommand for printing in Safari
15166
+ document.execCommand('print', false, undefined);
15167
+ } catch (error) {
15168
+ // If document.execCommand fails or throws an error, fallback to window.print()
15169
+ window.print();
15170
+ }
15171
+ } else {
15172
+ // Execute window.print() for all other browsers
15173
+ window.print();
15174
+ }
15175
+ });
15136
15176
  });
15137
15177
  }, 150);
15138
15178
  }
@@ -15823,7 +15863,9 @@ function TableGrid(props) {
15823
15863
  enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
15824
15864
  table: table.instance,
15825
15865
  style: table.renderer.style
15826
- }, table.renderer.rows), table.meta.footer.isEnabled ? ( /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, table.instance.getFooterGroups()[0].headers.map(Footer$3)))) : null)) : ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
15866
+ }, table.renderer.rows), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
15867
+ table: table.instance
15868
+ }) : null)) : ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
15827
15869
  emptyState: table.props.emptyState
15828
15870
  })))));
15829
15871
  }
@@ -18438,8 +18480,8 @@ function Alert$1(props) {
18438
18480
  if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
18439
18481
  links.push(validationTexts.alert.messageAnd);
18440
18482
  }
18483
+ const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
18441
18484
  const handleClick = () => {
18442
- const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
18443
18485
  if (rowIndex > -1) {
18444
18486
  scrollToRow(rowIndex);
18445
18487
  } else {
@@ -18462,7 +18504,7 @@ function Alert$1(props) {
18462
18504
  className: "text-blue",
18463
18505
  onClick: handleClick,
18464
18506
  role: "button"
18465
- }, rowIdentityColumn ? error.pendingChange._meta.original[rowIdentityColumn.id] : error.rowId)));
18507
+ }, rowIdentityColumn ? error.pendingChange._meta.original[rowIdentityColumn.id] : rowIndex + 1)));
18466
18508
  // if appropriate, concatenate the item with the text ","
18467
18509
  if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
18468
18510
  links.push(', ');