@economic/taco 2.67.0 → 2.67.1-create-handler-active-row.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 +22 -11
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +3 -1
- package/dist/taco.js +22 -11
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.d.ts
CHANGED
@@ -3043,7 +3043,9 @@ export declare interface Table3CommonProps<TType = unknown> extends Table3Featur
|
|
3043
3043
|
|
3044
3044
|
export declare type Table3EditingChangeHandler<TType = unknown> = (accessor: string, value: unknown, row: TType, prevRow: TType) => Promise<Partial<TType>> | undefined;
|
3045
3045
|
|
3046
|
-
export declare type Table3EditingCreateHandler<TType = unknown> = (
|
3046
|
+
export declare type Table3EditingCreateHandler<TType = unknown> = ({ activeRow }: {
|
3047
|
+
activeRow: TType;
|
3048
|
+
}) => Promise<Partial<TType>>;
|
3047
3049
|
|
3048
3050
|
declare type Table3EditingDiscardHandler = () => void;
|
3049
3051
|
|
package/dist/taco.js
CHANGED
@@ -26960,7 +26960,7 @@ const Content$4 = React.forwardRef(function HangerContent(props, ref) {
|
|
26960
26960
|
const context = React.useContext(HangerContext);
|
26961
26961
|
const { texts } = useLocalization();
|
26962
26962
|
const className = clsx(
|
26963
|
-
"wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm",
|
26963
|
+
"wcag-blue-500 border border-transparent rounded p-3 pr-12 yt-shadow focus:border-transparent max-w-sm print:hidden",
|
26964
26964
|
props.className
|
26965
26965
|
);
|
26966
26966
|
const handleInteractOutside = (event) => {
|
@@ -39012,6 +39012,9 @@ function Header$1(props) {
|
|
39012
39012
|
if (canHide) {
|
39013
39013
|
memoedProps.onHide = header.column.getToggleVisibilityHandler();
|
39014
39014
|
}
|
39015
|
+
if (header.id === "__expansion") {
|
39016
|
+
memoedProps.isExpanded = table.getIsSomeRowsExpanded();
|
39017
|
+
}
|
39015
39018
|
if (canPin) {
|
39016
39019
|
memoedProps.onPin = (index2) => {
|
39017
39020
|
table.setColumnPinning((pinningState) => {
|
@@ -39062,6 +39065,7 @@ const MemoedHeader = React__default.memo(function MemoedHeader2(props) {
|
|
39062
39065
|
hasMenu,
|
39063
39066
|
id: id2,
|
39064
39067
|
index: index2,
|
39068
|
+
isExpanded,
|
39065
39069
|
isFiltered,
|
39066
39070
|
isGroup: isGroup2,
|
39067
39071
|
isPinned,
|
@@ -39101,6 +39105,7 @@ const MemoedHeader = React__default.memo(function MemoedHeader2(props) {
|
|
39101
39105
|
"data-cell-id": id2,
|
39102
39106
|
"data-cell-pinned": isPinned ? isPinned : void 0,
|
39103
39107
|
"data-taco": isGroup2 ? "grouped-column-header" : "column-header",
|
39108
|
+
"data-rows-expanded": isExpanded ? isExpanded : void 0,
|
39104
39109
|
style,
|
39105
39110
|
ref: setRef
|
39106
39111
|
},
|
@@ -39295,10 +39300,10 @@ function Summary(props) {
|
|
39295
39300
|
} else if (!tableMeta.server.isEnabled && (((_a = table.getState().columnFilters) == null ? void 0 : _a.length) || // filtered data
|
39296
39301
|
!!table.getState().globalFilter && table.options.enableGlobalFilter)) {
|
39297
39302
|
label = texts.table.footer.summary.records;
|
39298
|
-
count2 = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong",
|
39303
|
+
count2 = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-current-count" }, new Intl.NumberFormat(locale2).format(currentLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale2).format(length)));
|
39299
39304
|
} else {
|
39300
39305
|
label = texts.table.footer.summary.records;
|
39301
|
-
count2 = /* @__PURE__ */ React__default.createElement("strong",
|
39306
|
+
count2 = /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale2).format(length));
|
39302
39307
|
}
|
39303
39308
|
return /* @__PURE__ */ React__default.createElement(
|
39304
39309
|
"div",
|
@@ -45149,6 +45154,7 @@ function Print(props) {
|
|
45149
45154
|
{
|
45150
45155
|
icon: "print",
|
45151
45156
|
"aria-label": texts.table.print.tooltip,
|
45157
|
+
id: `${tableId}-toolbar-print`,
|
45152
45158
|
dialog: (dialogProps) => /* @__PURE__ */ React__default.createElement(
|
45153
45159
|
PrintDialog,
|
45154
45160
|
{
|
@@ -45485,7 +45491,7 @@ function Filter(props) {
|
|
45485
45491
|
ref.current.focus();
|
45486
45492
|
}
|
45487
45493
|
}, [id2]);
|
45488
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start gap-2" }, /* @__PURE__ */ React__default.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__default.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React__default.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React__default.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React__default.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
|
45494
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start gap-2", "data-taco": "filter-row" }, /* @__PURE__ */ React__default.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__default.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React__default.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React__default.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React__default.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
|
45489
45495
|
}
|
45490
45496
|
const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
|
45491
45497
|
function ManageFiltersPopover(props) {
|
@@ -45566,10 +45572,10 @@ function ManageFiltersPopover(props) {
|
|
45566
45572
|
onChange: handleChangeFilter,
|
45567
45573
|
onRemove: filters.length > 0 && filters.some((f2) => f2.id) || filters.length > 1 ? handleRemoveFilter : void 0
|
45568
45574
|
}
|
45569
|
-
)), /* @__PURE__ */ React__default.createElement("div", { className: "justify-start" }, /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "discrete", onClick: handleCreate }, "+ ", texts.table.filters.buttons.addFilter))), /* @__PURE__ */ React__default.createElement(Group$6, { className: "ml-auto" }, /* @__PURE__ */ React__default.createElement(Popover.Close, null, /* @__PURE__ */ React__default.createElement(Button$4,
|
45575
|
+
)), /* @__PURE__ */ React__default.createElement("div", { className: "justify-start" }, /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "discrete", onClick: handleCreate, name: "add-filter" }, "+ ", texts.table.filters.buttons.addFilter))), /* @__PURE__ */ React__default.createElement(Group$6, { className: "ml-auto" }, /* @__PURE__ */ React__default.createElement(Popover.Close, null, /* @__PURE__ */ React__default.createElement(Button$4, { name: "close-filters" }, texts.table.filters.buttons.cancel)), /* @__PURE__ */ React__default.createElement(Button$4, { name: "clear-filters", onClick: handleClear }, texts.table.filters.buttons.clear), /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "primary", name: "apply-filters", onClick: handleApply }, texts.table.filters.buttons.apply))))));
|
45570
45576
|
}
|
45571
45577
|
function Filters(props) {
|
45572
|
-
const { length, table } = props;
|
45578
|
+
const { length, tableId, table } = props;
|
45573
45579
|
const { texts } = useLocalization();
|
45574
45580
|
const isLargeScreen = useIsLargeScreen();
|
45575
45581
|
const columnFilters = table.getState().columnFilters;
|
@@ -45582,7 +45588,8 @@ function Filters(props) {
|
|
45582
45588
|
popover: (popoverProps) => /* @__PURE__ */ React__default.createElement(ManageFiltersPopover, { ...popoverProps, length, table }),
|
45583
45589
|
shortcut: shortcut2,
|
45584
45590
|
ref,
|
45585
|
-
tooltip: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React__default.createElement(Shortcut, { className: "ml-2", keys: shortcut2 }))
|
45591
|
+
tooltip: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, texts.table.filters.tooltip, /* @__PURE__ */ React__default.createElement(Shortcut, { className: "ml-2", keys: shortcut2 })),
|
45592
|
+
id: `${tableId}-toolbar-filters`
|
45586
45593
|
};
|
45587
45594
|
React__default.useEffect(() => {
|
45588
45595
|
var _a;
|
@@ -45615,7 +45622,7 @@ function TableToolbar(props) {
|
|
45615
45622
|
"data-taco": "table-toolbar"
|
45616
45623
|
},
|
45617
45624
|
table.props.toolbarLeft,
|
45618
|
-
/* @__PURE__ */ React__default.createElement(Group$6, { className: "ml-auto flex-shrink-0 items-center print:hidden" }, customTools, canFilter ? /* @__PURE__ */ React__default.createElement(Filters, { length: table.meta.length, table: table.instance }) : null, table.props.toolbarRight, canPrint ? /* @__PURE__ */ React__default.createElement(Print, { table: table.instance, tableId: table.id, tableRef: table.ref }) : null, canSettings ? /* @__PURE__ */ React__default.createElement(Settings, { customSettings: table.props.customSettings, id: `${id2}-settings`, table: table.instance }) : null, canSearch ? /* @__PURE__ */ React__default.createElement(Search$1, { scrollToIndex: table.renderer.scrollToIndex, table: table.instance, tableRef: table.ref }) : null)
|
45625
|
+
/* @__PURE__ */ React__default.createElement(Group$6, { className: "ml-auto flex-shrink-0 items-center print:hidden" }, customTools, canFilter ? /* @__PURE__ */ React__default.createElement(Filters, { length: table.meta.length, tableId: table.id, table: table.instance }) : null, table.props.toolbarRight, canPrint ? /* @__PURE__ */ React__default.createElement(Print, { table: table.instance, tableId: table.id, tableRef: table.ref }) : null, canSettings ? /* @__PURE__ */ React__default.createElement(Settings, { customSettings: table.props.customSettings, id: `${id2}-settings`, table: table.instance }) : null, canSearch ? /* @__PURE__ */ React__default.createElement(Search$1, { scrollToIndex: table.renderer.scrollToIndex, table: table.instance, tableRef: table.ref }) : null)
|
45619
45626
|
), table.props.toolbarPanel ? /* @__PURE__ */ React__default.createElement("div", { className: "mb-4" }, table.props.toolbarPanel) : void 0);
|
45620
45627
|
}
|
45621
45628
|
function canChangeSettings(table, customSettings) {
|
@@ -55648,6 +55655,7 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
|
|
55648
55655
|
pendingChangesFns.saveChanges(table);
|
55649
55656
|
}
|
55650
55657
|
async function createRow2(table, row) {
|
55658
|
+
var _a, _b;
|
55651
55659
|
if (!handleCreate) {
|
55652
55660
|
return;
|
55653
55661
|
}
|
@@ -55658,7 +55666,10 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
|
|
55658
55666
|
return;
|
55659
55667
|
}
|
55660
55668
|
}
|
55661
|
-
const
|
55669
|
+
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;
|
55670
|
+
const changeset = row ?? await handleCreate({
|
55671
|
+
activeRow: currentRow ? { ...currentRow.original, ...tableMeta.editing.getRowValue(currentRow.id) } : void 0
|
55672
|
+
});
|
55662
55673
|
try {
|
55663
55674
|
if (changeset) {
|
55664
55675
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
@@ -55667,10 +55678,10 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
|
|
55667
55678
|
requestAnimationFrame(() => {
|
55668
55679
|
const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
|
55669
55680
|
table.setRowPinning((currentState) => {
|
55670
|
-
var
|
55681
|
+
var _a2;
|
55671
55682
|
return {
|
55672
55683
|
...currentState,
|
55673
|
-
bottom: (
|
55684
|
+
bottom: (_a2 = currentState.bottom ?? []) == null ? void 0 : _a2.concat(newRowId)
|
55674
55685
|
};
|
55675
55686
|
});
|
55676
55687
|
toggleDetailedMode(false);
|