@economic/taco 2.68.0 → 2.69.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.
package/dist/taco.cjs CHANGED
@@ -18262,7 +18262,7 @@ const ScrollableList = React__namespace.forwardRef(function ScrollableList2(prop
18262
18262
  role: options.length <= 0 || loading ? "presentation" : "listbox",
18263
18263
  tabIndex: otherProps.tabIndex || 0
18264
18264
  };
18265
- return /* @__PURE__ */ React__namespace.createElement("ul", { ...list, "data-taco": "scrollable-list" }, loading ? /* @__PURE__ */ React__namespace.createElement("li", { className: "yt-list__empty" }, /* @__PURE__ */ React__namespace.createElement("span", null, /* @__PURE__ */ React__namespace.createElement(Spinner, { delay: 0 })), /* @__PURE__ */ React__namespace.createElement("span", null, texts.listbox.loading)) : options.length ? options.map(({ children, icon, ...optionProps }) => /* @__PURE__ */ React__namespace.createElement("li", { ...optionProps }, icon, /* @__PURE__ */ React__namespace.createElement("span", { className: "flex-grow truncate text-left" }, children), multiselect && /* @__PURE__ */ React__namespace.createElement(
18265
+ return /* @__PURE__ */ React__namespace.createElement("ul", { ...list, "data-taco": "scrollable-list" }, loading ? /* @__PURE__ */ React__namespace.createElement("li", { className: "yt-list__empty" }, /* @__PURE__ */ React__namespace.createElement("span", null, /* @__PURE__ */ React__namespace.createElement(Spinner, { delay: 0 })), /* @__PURE__ */ React__namespace.createElement("span", null, texts.listbox.loading)) : options.length ? options.map(({ children, icon, ...optionProps }) => /* @__PURE__ */ React__namespace.createElement("li", { ...optionProps }, icon, /* @__PURE__ */ React__namespace.createElement("span", { "data-taco": "list-option", className: "flex-grow truncate text-left" }, children), multiselect && /* @__PURE__ */ React__namespace.createElement(
18266
18266
  Checkbox$2,
18267
18267
  {
18268
18268
  "aria-hidden": true,
@@ -44241,7 +44241,7 @@ const Option = React.forwardRef(function Select2Option(props, ref) {
44241
44241
  value: props.value
44242
44242
  }
44243
44243
  ) : void 0;
44244
- return /* @__PURE__ */ React.createElement(Option$1, { ...otherProps, className, onClick: handleClick, onKeyDown: handleKeyDown, ref }, hasValue2 ? /* @__PURE__ */ React.createElement(Icon$1, { name: "tick", className: "pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible" }) : null, typeof children === "string" ? isTag ? /* @__PURE__ */ React.createElement(Tag, { className: "pointer-events-none my-1", color: color2, icon: prefix2 }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, prefix2 ? typeof prefix2 === "string" ? /* @__PURE__ */ React.createElement(Icon$1, { name: prefix2, className: "!h-5 !w-5" }) : prefix2 : null, /* @__PURE__ */ React.createElement("span", { className: "flex w-full justify-between" }, /* @__PURE__ */ React.createElement("span", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement("span", null, children), description ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 -mt-1.5 mb-1.5 text-xs", "data-taco": "description" }, description) : null), /* @__PURE__ */ React.createElement("span", { className: "flex flex-col self-center" }, postfix ? typeof postfix === "string" ? /* @__PURE__ */ React.createElement(Icon$1, { name: postfix, className: "!h-5 !w-5" }) : postfix : null))) : /* @__PURE__ */ React.createElement("span", null, children), popover ? /* @__PURE__ */ React.createElement(
44244
+ return /* @__PURE__ */ React.createElement(Option$1, { ...otherProps, className, onClick: handleClick, onKeyDown: handleKeyDown, ref }, hasValue2 ? /* @__PURE__ */ React.createElement(Icon$1, { name: "tick", className: "pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible" }) : null, typeof children === "string" ? isTag ? /* @__PURE__ */ React.createElement(Tag, { className: "pointer-events-none my-1", color: color2, icon: prefix2 }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, prefix2 ? typeof prefix2 === "string" ? /* @__PURE__ */ React.createElement(Icon$1, { name: prefix2, className: "!h-5 !w-5" }) : prefix2 : null, /* @__PURE__ */ React.createElement("span", { className: "flex w-full justify-between" }, /* @__PURE__ */ React.createElement("span", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement("span", null, children), description ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 -mt-1.5 mb-1.5 text-xs", "data-taco": "description" }, description) : null), /* @__PURE__ */ React.createElement("span", { className: "flex flex-col self-center" }, postfix ? typeof postfix === "string" ? /* @__PURE__ */ React.createElement(Icon$1, { name: postfix, className: "!h-5 !w-5" }) : postfix : null))) : /* @__PURE__ */ React.createElement("span", { className: "w-full" }, children), popover ? /* @__PURE__ */ React.createElement(
44245
44245
  IconButton,
44246
44246
  {
44247
44247
  icon: "ellipsis-vertical",
@@ -45249,11 +45249,11 @@ function guessComparatorsBasedOnControl(column) {
45249
45249
  }
45250
45250
  const FilterContext = React.createContext([]);
45251
45251
  const FilterColumn = React.forwardRef((props, ref) => {
45252
- const { allHeaders, onChange: handleChange, value = null, ...attributes } = props;
45252
+ const { allColumns, onChange: handleChange, value = null, ...attributes } = props;
45253
45253
  const { texts } = useLocalization();
45254
45254
  const filters = React.useContext(FilterContext);
45255
- const selectedColumn = allHeaders.find((header) => header.id === value);
45256
- const warning2 = selectedColumn && !selectedColumn.column.getIsVisible();
45255
+ const selectedColumn = allColumns.find((column) => column.id === value);
45256
+ const warning2 = selectedColumn && !selectedColumn.getIsVisible();
45257
45257
  return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement(
45258
45258
  Field,
45259
45259
  {
@@ -45271,23 +45271,22 @@ const FilterColumn = React.forwardRef((props, ref) => {
45271
45271
  onChange: handleChange,
45272
45272
  value
45273
45273
  },
45274
- allHeaders.map((header) => {
45274
+ allColumns.map((column) => {
45275
45275
  var _a, _b;
45276
45276
  return /* @__PURE__ */ React.createElement(
45277
45277
  Select22.Option,
45278
45278
  {
45279
- key: header.column.id,
45280
- value: header.column.id,
45281
- postfix: !header.column.getIsVisible() || header.column.getIsGrouped() ? /* @__PURE__ */ React.createElement(
45282
- Tooltip$3,
45283
- {
45284
- title: header.column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45285
- },
45286
- /* @__PURE__ */ React.createElement(Icon$1, { name: "eye-off", className: "text-grey-500 !h-5 !w-5" })
45287
- ) : void 0,
45288
- disabled: header.column.id !== value && (!header.column.getCanFilter() || !!filters.some((f2) => f2.id === header.column.id))
45279
+ key: column.id,
45280
+ value: column.id,
45281
+ disabled: column.id !== value && (!column.getCanFilter() || !!filters.some((f2) => f2.id === column.id))
45289
45282
  },
45290
- /* @__PURE__ */ React.createElement(React.Fragment, null, flexRender(header.column.columnDef.header, header.getContext()), header.column.parent ? ` (${flexRender((_b = (_a = header.column.parent) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.header, header.getContext())})` : "")
45283
+ /* @__PURE__ */ React.createElement("span", { className: "flex w-full justify-between" }, /* @__PURE__ */ React.createElement("span", { className: "flex flex-col" }, flexRender(column.columnDef.header, { column }), column.parent ? flexRender((_b = (_a = column.parent) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.header, { column }) : ""), /* @__PURE__ */ React.createElement("span", { className: "flex flex-col self-center" }, !column.getIsVisible() || column.getIsGrouped() ? /* @__PURE__ */ React.createElement(
45284
+ Tooltip$3,
45285
+ {
45286
+ title: column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45287
+ },
45288
+ /* @__PURE__ */ React.createElement(Icon$1, { name: "eye-off", className: "text-grey-500 !h-5 !w-5" })
45289
+ ) : void 0))
45291
45290
  );
45292
45291
  })
45293
45292
  )
@@ -45458,9 +45457,9 @@ function Control(props) {
45458
45457
  );
45459
45458
  }
45460
45459
  function Filter(props) {
45461
- const { allHeaders, filter: filter2, onChange: handleChange, onRemove, position } = props;
45460
+ const { allColumns, filter: filter2, onChange: handleChange, onRemove, position } = props;
45462
45461
  const { texts } = useLocalization();
45463
- const column = allHeaders.find((header) => header.column.id === filter2.id);
45462
+ const column = allColumns.find((column2) => column2.id === filter2.id);
45464
45463
  const ref = React.useRef(null);
45465
45464
  const {
45466
45465
  id: id2,
@@ -45468,13 +45467,13 @@ function Filter(props) {
45468
45467
  } = filter2;
45469
45468
  const handleChangeColumn = (columnId) => {
45470
45469
  var _a, _b, _c;
45471
- const previousColumn = allHeaders.find((header) => header.column.id === id2);
45472
- const nextColumn = allHeaders.find((header) => header.column.id === columnId);
45473
- if (((_a = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.column.columnDef.meta) == null ? void 0 : _c.dataType)) {
45470
+ const previousColumn = allColumns.find((column2) => column2.id === id2);
45471
+ const nextColumn = allColumns.find((column2) => column2.id === columnId);
45472
+ if (((_a = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.columnDef.meta) == null ? void 0 : _c.dataType)) {
45474
45473
  handleChange(position, { id: columnId, value: filter2.value });
45475
45474
  return;
45476
45475
  }
45477
- const validComparators = guessComparatorsBasedOnControl(nextColumn == null ? void 0 : nextColumn.column);
45476
+ const validComparators = guessComparatorsBasedOnControl(nextColumn);
45478
45477
  const value2 = {
45479
45478
  comparator: validComparators[0],
45480
45479
  value: void 0
@@ -45497,13 +45496,13 @@ function Filter(props) {
45497
45496
  ref.current.focus();
45498
45497
  }
45499
45498
  }, [id2]);
45500
- return /* @__PURE__ */ React.createElement("div", { className: "flex items-start gap-2", "data-taco": "filter-row" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45499
+ return /* @__PURE__ */ React.createElement("div", { className: "flex items-start gap-2", "data-taco": "filter-row" }, /* @__PURE__ */ React.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React.createElement(FilterColumn, { allColumns, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React.createElement(FilterComparator, { column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React.createElement(FilterValue, { column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45501
45500
  }
45502
45501
  const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
45503
45502
  function ManageFiltersPopover(props) {
45504
45503
  const { length, table, ...popoverProps } = props;
45505
45504
  const { locale: locale2, texts } = useLocalization();
45506
- const allHeaders = table.getLeafHeaders().filter((column) => !isInternalColumn(column.id)).sort((headerA, headerB) => sortByHeader(headerA.column, headerB.column));
45505
+ const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45507
45506
  const columnFilters = table.getState().columnFilters;
45508
45507
  const tableMeta = table.options.meta;
45509
45508
  const [filters, setFilters] = React.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
@@ -45542,7 +45541,7 @@ function ManageFiltersPopover(props) {
45542
45541
  if (f2.id === null || f2.id === "") {
45543
45542
  return false;
45544
45543
  }
45545
- const controlRenderer = (_b = (_a = allHeaders.find((header) => header.column.id === f2.id)) == null ? void 0 : _a.column.columnDef.meta) == null ? void 0 : _b.control;
45544
+ const controlRenderer = (_b = (_a = allColumns.find((column) => column.id === f2.id)) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.control;
45546
45545
  if (f2.value.comparator === TableFilterComparator.IsEmpty || f2.value.comparator === TableFilterComparator.IsNotEmpty || controlRenderer === "switch") {
45547
45546
  return true;
45548
45547
  }
@@ -45572,7 +45571,7 @@ function ManageFiltersPopover(props) {
45572
45571
  Filter,
45573
45572
  {
45574
45573
  key: `filter_${index2}`,
45575
- allHeaders,
45574
+ allColumns,
45576
45575
  filter: filter2,
45577
45576
  position: index2,
45578
45577
  onChange: handleChangeFilter,
@@ -55653,6 +55652,7 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55653
55652
  pendingChangesFns.saveChanges(table);
55654
55653
  }
55655
55654
  async function createRow2(table, row) {
55655
+ var _a, _b;
55656
55656
  if (!handleCreate) {
55657
55657
  return;
55658
55658
  }
@@ -55663,7 +55663,10 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55663
55663
  return;
55664
55664
  }
55665
55665
  }
55666
- const changeset = row ?? await handleCreate();
55666
+ const currentRow = ((_a = table.options.meta) == null ? void 0 : _a.rowActive.rowActiveIndex) !== void 0 ? table.getRowModel().flatRows[(_b = table.options.meta) == null ? void 0 : _b.rowActive.rowActiveIndex] : void 0;
55667
+ const changeset = row ?? await handleCreate({
55668
+ activeRow: currentRow ? { ...currentRow.original, ...tableMeta.editing.getRowValue(currentRow.id) } : void 0
55669
+ });
55667
55670
  try {
55668
55671
  if (changeset) {
55669
55672
  const temporaryRows = tableMeta.editing.temporaryRows;
@@ -55672,10 +55675,10 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55672
55675
  requestAnimationFrame(() => {
55673
55676
  const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
55674
55677
  table.setRowPinning((currentState) => {
55675
- var _a;
55678
+ var _a2;
55676
55679
  return {
55677
55680
  ...currentState,
55678
- bottom: (_a = currentState.bottom ?? []) == null ? void 0 : _a.concat(newRowId)
55681
+ bottom: (_a2 = currentState.bottom ?? []) == null ? void 0 : _a2.concat(newRowId)
55679
55682
  };
55680
55683
  });
55681
55684
  toggleDetailedMode(false);
@@ -56229,10 +56232,10 @@ function Row(props) {
56229
56232
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === index2;
56230
56233
  const rowRef = React.useRef(null);
56231
56234
  const hasErrors = tableMeta.editing.hasRowErrors(row.id);
56232
- React.useLayoutEffect(() => {
56235
+ React.useEffect(() => {
56233
56236
  if (!measureRow || !rowRef.current) return;
56234
56237
  measureRow(rowRef.current.getBoundingClientRect().height);
56235
- }, [hasErrors, measureRow, row.id]);
56238
+ }, [hasErrors, measureRow]);
56236
56239
  React.useEffect(() => {
56237
56240
  if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === void 0) {
56238
56241
  const element = focusManager.focusFirst();