@economic/taco 2.45.0-alpha.26 → 2.45.0-alpha.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/components/Select/Select.d.ts +19 -5
  3. package/dist/esm/index.css +74 -4
  4. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +8 -7
  5. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  6. package/dist/esm/packages/taco/src/components/Select/Select.js +9 -0
  7. package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +33 -26
  9. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -0
  11. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +0 -1
  13. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Toast/Toaster.js +16 -2
  15. package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
  16. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +16 -4
  17. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  18. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +20 -6
  19. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  20. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  21. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -0
  22. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  23. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +4 -1
  24. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  25. package/dist/index.css +74 -4
  26. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  27. package/dist/primitives/Table/types.d.ts +5 -1
  28. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +2 -1
  29. package/dist/taco.cjs.development.js +109 -47
  30. package/dist/taco.cjs.development.js.map +1 -1
  31. package/dist/taco.cjs.production.min.js +1 -1
  32. package/dist/taco.cjs.production.min.js.map +1 -1
  33. package/package.json +3 -2
  34. package/tailwind.config.js +1 -0
@@ -27,7 +27,7 @@ var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
27
27
  var PrimitiveSwitch = require('@radix-ui/react-switch');
28
28
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
29
29
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
30
- var reactPortal = require('@radix-ui/react-portal');
30
+ var ReactDOM = _interopDefault(require('react-dom'));
31
31
  var reactTable = require('@tanstack/react-table');
32
32
  var get = _interopDefault(require('lodash/get'));
33
33
  var reactVirtual = require('@tanstack/react-virtual');
@@ -6002,22 +6002,23 @@ const useCombobox = ({
6002
6002
  const data = React.useMemo(() => shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData, [shouldFilterData, inputValue, flattenedData]);
6003
6003
  // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state
6004
6004
  const [currentIndex, setCurrentIndex] = React.useState(inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined);
6005
- const setInputValueByIndex = index => {
6005
+ const setInputValueByIndex = (index, focusOut) => {
6006
6006
  if (index !== undefined) {
6007
6007
  const option = data[index];
6008
6008
  if (option && !option.disabled) {
6009
- setInputValueByRef$1(inputRef.current, option.value, 'focusout');
6009
+ const eventType = focusOut ? 'focusout' : inputRef.current === document.activeElement ? 'input' : 'focusout';
6010
+ setInputValueByRef$1(inputRef.current, option.value, eventType);
6010
6011
  }
6011
6012
  }
6012
6013
  };
6013
- const setCurrentValue = index => {
6014
+ const setCurrentValue = (index, focusOut) => {
6014
6015
  if (index === undefined) {
6015
6016
  return;
6016
6017
  }
6017
6018
  const option = data[index];
6018
6019
  // if the selected option is not already selected, trigger blur event
6019
6020
  if (option.value !== value) {
6020
- setInputValueByIndex(index);
6021
+ setInputValueByIndex(index, focusOut);
6021
6022
  } else {
6022
6023
  // if the selected option is already selected, refill input with its value
6023
6024
  setInputValue(convertToInputValue(value));
@@ -6070,8 +6071,8 @@ const useCombobox = ({
6070
6071
  event.preventDefault();
6071
6072
  return;
6072
6073
  }
6073
- const allowClearing = event.isTrusted && event.target.value === '';
6074
- if (onChange && (allowClearing || !event.isTrusted && event.target.value !== String(value))) {
6074
+ // event.target.value is always a string so it is important to cast value to a string before checking the equality
6075
+ if (onChange && event.target.value !== String(value)) {
6075
6076
  const item = findByValue(flattenedData, event.target.value);
6076
6077
  event.detail = sanitizeItem(item);
6077
6078
  const parents = getOptionParents(flattenedData, item === null || item === void 0 ? void 0 : item.path);
@@ -6128,7 +6129,7 @@ const useCombobox = ({
6128
6129
  }
6129
6130
  }
6130
6131
  if (open) {
6131
- setCurrentValue(currentIndex);
6132
+ setCurrentValue(currentIndex, true);
6132
6133
  setOpen(false);
6133
6134
  }
6134
6135
  return;
@@ -9503,8 +9504,16 @@ const BaseSelect = /*#__PURE__*/React.forwardRef(function BaseSelect(props, ref)
9503
9504
  });
9504
9505
  const Select = /*#__PURE__*/React.forwardRef(function Select(props, ref) {
9505
9506
  const {
9507
+ editable,
9506
9508
  ...otherProps
9507
9509
  } = props;
9510
+ if (editable) {
9511
+ return /*#__PURE__*/React.createElement(Combobox, Object.assign({}, otherProps, {
9512
+ dialog: undefined,
9513
+ inline: true,
9514
+ ref: ref
9515
+ }));
9516
+ }
9508
9517
  return /*#__PURE__*/React.createElement(BaseSelect, Object.assign({}, otherProps, {
9509
9518
  ref: ref
9510
9519
  }));
@@ -9799,6 +9808,20 @@ const insertToastWithoutDuplicates = (currentToasts, id, content, options, close
9799
9808
  }
9800
9809
  return nextToasts;
9801
9810
  };
9811
+ const Portal$1 = props => {
9812
+ var _globalThis$document;
9813
+ const {
9814
+ children,
9815
+ container: containerProp,
9816
+ ...portalProps
9817
+ } = props;
9818
+ const [mounted, setMounted] = React.useState(false);
9819
+ React.useLayoutEffect(() => setMounted(true), []);
9820
+ const container = containerProp || mounted && (globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body);
9821
+ return container ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement("div", Object.assign({}, portalProps, {
9822
+ "data-taco": "portal"
9823
+ }), children), container) : null;
9824
+ };
9802
9825
  const ToastProvider = ({
9803
9826
  children,
9804
9827
  ...props
@@ -9890,7 +9913,7 @@ const ToastProvider = ({
9890
9913
  }, []);
9891
9914
  return /*#__PURE__*/React.createElement(ToastContext.Provider, Object.assign({}, props, {
9892
9915
  value: toaster
9893
- }), children, /*#__PURE__*/React.createElement(reactPortal.Portal, null, /*#__PURE__*/React.createElement("div", {
9916
+ }), children, /*#__PURE__*/React.createElement(Portal$1, null, /*#__PURE__*/React.createElement("div", {
9894
9917
  id: "yt-toast__container",
9895
9918
  className: "pointer-events-all absolute !left-auto bottom-0 right-0 z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end",
9896
9919
  role: "log"
@@ -10445,7 +10468,10 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
10445
10468
  // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure
10446
10469
  // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children
10447
10470
  accessorFn: row => get(row, accessorKey),
10448
- header: header,
10471
+ // The header can be either a string or a JSX.Element, but react-table expects it to be a string or a
10472
+ // renderer function, so `() => header` ensures compatibility when header is a JSX.Element.
10473
+ // If we just pass `() => header`, then we will loose truncation for string headers.
10474
+ header: typeof header === 'string' ? header : () => header,
10449
10475
  // features
10450
10476
  enableColumnFilter,
10451
10477
  enableGlobalFilter,
@@ -11979,6 +12005,7 @@ function useTableManager(props, meta, internalColumns) {
11979
12005
  fontSize,
11980
12006
  footer,
11981
12007
  length,
12008
+ onEvent: props.onEvent,
11982
12009
  printing,
11983
12010
  rowActions: rowActions,
11984
12011
  rowActive,
@@ -13705,6 +13732,21 @@ function getIsPinned(header) {
13705
13732
  return (_header$subHeaders = header.subHeaders) !== null && _header$subHeaders !== void 0 && _header$subHeaders.length ? (_header$subHeaders$fi = header.subHeaders.find(x => x.column.getIsPinned())) === null || _header$subHeaders$fi === void 0 ? void 0 : _header$subHeaders$fi.column.getIsPinned() : header.column.getIsPinned();
13706
13733
  }
13707
13734
 
13735
+ const HeaderContent = ({
13736
+ children,
13737
+ tooltip,
13738
+ isInternalColumnHeader
13739
+ }) => {
13740
+ if (isInternalColumnHeader || typeof children !== 'string') {
13741
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
13742
+ }
13743
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
13744
+ title: String(tooltip !== null && tooltip !== void 0 ? tooltip : children),
13745
+ placement: "top"
13746
+ }, /*#__PURE__*/React__default.createElement("span", {
13747
+ className: "truncate"
13748
+ }, children));
13749
+ };
13708
13750
  function Header$5(props) {
13709
13751
  var _header$column$column;
13710
13752
  const {
@@ -13874,12 +13916,11 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
13874
13916
  "data-cell-pinned": isPinned ? isPinned : undefined,
13875
13917
  style: style,
13876
13918
  ref: setRef
13877
- }), isPlaceholder ? null : isInternalColumn(id) ? children : (/*#__PURE__*/React__default.createElement(Tooltip, {
13878
- title: String(tooltip !== null && tooltip !== void 0 ? tooltip : children),
13879
- placement: "top"
13880
- }, /*#__PURE__*/React__default.createElement("span", {
13881
- className: "truncate"
13882
- }, children))), sortDirection ? /*#__PURE__*/React__default.createElement(SortIndicator, {
13919
+ }), !isPlaceholder ? (/*#__PURE__*/React__default.createElement(HeaderContent, {
13920
+ children: children,
13921
+ tooltip: tooltip,
13922
+ isInternalColumnHeader: !!isInternalColumn(id)
13923
+ })) : null, sortDirection ? /*#__PURE__*/React__default.createElement(SortIndicator, {
13883
13924
  direction: sortDirection
13884
13925
  }) : null, hasMenu ? (/*#__PURE__*/React__default.createElement(HeaderMenu, {
13885
13926
  canFilter: canFilter,
@@ -14067,29 +14108,39 @@ function Summary(props) {
14067
14108
  }
14068
14109
 
14069
14110
  function Foot(props) {
14111
+ var _nonGroupedHeaders$fi;
14070
14112
  const {
14071
14113
  children,
14072
14114
  table,
14073
14115
  ...attributes
14074
14116
  } = props;
14117
+ const tableMeta = table.options.meta;
14075
14118
  const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
14119
+ const firstVisibleExternalColumnIndex = (_nonGroupedHeaders$fi = nonGroupedHeaders.find(header => {
14120
+ var _header$column$column;
14121
+ return !isInternalColumn(header.id) && ((_header$column$column = header.column.columnDef.meta) === null || _header$column$column === void 0 ? void 0 : _header$column$column.enablePrinting) !== false;
14122
+ })) === null || _nonGroupedHeaders$fi === void 0 ? void 0 : _nonGroupedHeaders$fi.index;
14123
+ // During printing, the summary should be displayed in the first visible external column,
14124
+ // as internal and hidden columns are excluded from the printed document.
14125
+ // However, in the normal table view, the summary should appear in the first column.
14126
+ const summaryColumnIndex = tableMeta.printing.isPrinting ? firstVisibleExternalColumnIndex : 0;
14076
14127
  return /*#__PURE__*/React__default.createElement("tfoot", Object.assign({}, attributes), children, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => (/*#__PURE__*/React__default.createElement(Footer$3, {
14077
14128
  key: header.id,
14078
14129
  header: header,
14079
- index: index
14130
+ showSummary: index === summaryColumnIndex
14080
14131
  })))));
14081
14132
  }
14082
14133
  function Footer$3(props) {
14083
14134
  return /*#__PURE__*/React__default.createElement(MemoedFooter, {
14084
14135
  footer: props.header,
14085
- index: props.index
14136
+ showSummary: props.showSummary
14086
14137
  });
14087
14138
  }
14088
14139
  const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
14089
14140
  var _footer$subHeaders, _footer$subHeaders$fi;
14090
14141
  const {
14091
14142
  footer,
14092
- index
14143
+ showSummary
14093
14144
  } = props;
14094
14145
  const columnMeta = footer.column.columnDef.meta;
14095
14146
  // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
@@ -14102,7 +14153,8 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
14102
14153
  }
14103
14154
  let content;
14104
14155
  let align;
14105
- if (index === 0) {
14156
+ // Summary should only be appended to the first visible external column, as internal columns like the select column will be hidden in the print view.
14157
+ if (showSummary) {
14106
14158
  align = 'left';
14107
14159
  content = /*#__PURE__*/React__default.createElement(Summary, {
14108
14160
  table: footer.getContext().table
@@ -19519,7 +19571,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
19519
19571
  var _tableMeta$rowActive$, _table$getRowModel$ro;
19520
19572
  const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
19521
19573
  if (tableMeta.rowActive.rowActiveIndex === undefined) {
19522
- console.log('edit toggle active', index);
19523
19574
  tableMeta.rowActive.setRowActiveIndex(index);
19524
19575
  }
19525
19576
  if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
@@ -19884,32 +19935,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
19884
19935
  ref: controlRef,
19885
19936
  tabIndex
19886
19937
  };
19887
- if (typeof type === 'function') {
19888
- const controlFnProps = {
19889
- ...commonProps,
19890
- invalid,
19891
- setValue: onChange,
19892
- value
19893
- };
19894
- return type(controlFnProps, {
19895
- ...row,
19896
- ...rowPendingChanges
19897
- });
19898
- }
19899
- if (type === 'switch') {
19900
- return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, commonProps, {
19901
- checked: Boolean(value),
19902
- onChange: onChange,
19903
- ref: controlRef
19904
- }));
19905
- }
19906
- if (type === 'checkbox') {
19907
- return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
19908
- checked: Boolean(value),
19909
- onChange: onChange,
19910
- ref: controlRef
19911
- }));
19912
- }
19913
19938
  const handleInputKeyDown = event => {
19914
19939
  const target = event.target;
19915
19940
  if (target.readOnly) {
@@ -19957,6 +19982,39 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
19957
19982
  toggleDetailedMode(true);
19958
19983
  }
19959
19984
  };
19985
+ if (typeof type === 'function') {
19986
+ const controlFnProps = {
19987
+ ...commonProps,
19988
+ invalid,
19989
+ setValue: onChange,
19990
+ onKeyDown: event => {
19991
+ const target = event.target || null;
19992
+ // it make sense to handle keydown for the custom edititng controls only if target is either input or textarea
19993
+ if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')) {
19994
+ handleInputKeyDown(event);
19995
+ }
19996
+ },
19997
+ value
19998
+ };
19999
+ return type(controlFnProps, {
20000
+ ...row,
20001
+ ...rowPendingChanges
20002
+ });
20003
+ }
20004
+ if (type === 'switch') {
20005
+ return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, commonProps, {
20006
+ checked: Boolean(value),
20007
+ onChange: onChange,
20008
+ ref: controlRef
20009
+ }));
20010
+ }
20011
+ if (type === 'checkbox') {
20012
+ return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
20013
+ checked: Boolean(value),
20014
+ onChange: onChange,
20015
+ ref: controlRef
20016
+ }));
20017
+ }
19960
20018
  const handleFocus = event => {
19961
20019
  if (!isDetailedMode) {
19962
20020
  event.target.select();
@@ -20438,7 +20496,11 @@ function Editing(props) {
20438
20496
  const ref = React__default.useRef(null);
20439
20497
  const tableMeta = table.options.meta;
20440
20498
  const handleChange = enabled => {
20499
+ var _tableMeta$onEvent;
20441
20500
  tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);
20501
+ (_tableMeta$onEvent = tableMeta.onEvent) === null || _tableMeta$onEvent === void 0 ? void 0 : _tableMeta$onEvent.call(tableMeta, 'editing-mode', {
20502
+ enabled
20503
+ });
20442
20504
  };
20443
20505
  const tooltip = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, texts.table3.editing.buttons.edit.tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
20444
20506
  className: "ml-2",