@open-mercato/ui 0.6.5-develop.4782.1.29bd722d3d → 0.6.5-develop.4790.1.bffb4fd44b
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/.turbo/turbo-build.log +1 -1
- package/dist/backend/DataTable.js +46 -14
- package/dist/backend/DataTable.js.map +2 -2
- package/dist/backend/filters/FilteredEmptyResults.js +12 -4
- package/dist/backend/filters/FilteredEmptyResults.js.map +2 -2
- package/dist/backend/filters/ListEmptyState.js +44 -0
- package/dist/backend/filters/ListEmptyState.js.map +7 -0
- package/dist/backend/filters/SearchEmptyResults.js +28 -0
- package/dist/backend/filters/SearchEmptyResults.js.map +7 -0
- package/package.json +3 -3
- package/src/backend/DataTable.tsx +57 -22
- package/src/backend/filters/FilteredEmptyResults.tsx +23 -10
- package/src/backend/filters/ListEmptyState.tsx +69 -0
- package/src/backend/filters/SearchEmptyResults.tsx +42 -0
- package/src/backend/filters/__tests__/ListEmptyState.test.tsx +53 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { useRouter } from "next/navigation";
|
|
5
5
|
import { useReactTable, getCoreRowModel, getSortedRowModel, flexRender } from "@tanstack/react-table";
|
|
6
6
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
7
|
-
import { RefreshCw, Loader2, SlidersHorizontal, MoreHorizontal, Circle, Filter, ChevronUp, ChevronDown, ChevronsUpDown, Check } from "lucide-react";
|
|
7
|
+
import { RefreshCw, Loader2, SlidersHorizontal, MoreHorizontal, Circle, Filter, ChevronUp, ChevronDown, ChevronsUpDown, Check, Inbox } from "lucide-react";
|
|
8
8
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../primitives/table.js";
|
|
9
9
|
import { Button } from "../primitives/button.js";
|
|
10
10
|
import { Checkbox } from "../primitives/checkbox.js";
|
|
@@ -22,6 +22,7 @@ import { TooltipProvider } from "../primitives/tooltip.js";
|
|
|
22
22
|
import { TruncatedCell } from "./TruncatedCell.js";
|
|
23
23
|
import { FilterBar } from "./FilterBar.js";
|
|
24
24
|
import { FilteredEmptyResults } from "./filters/FilteredEmptyResults.js";
|
|
25
|
+
import { SearchEmptyResults } from "./filters/SearchEmptyResults.js";
|
|
25
26
|
import { useCustomFieldFilterDefs } from "./utils/customFieldFilters.js";
|
|
26
27
|
import { fetchCustomFieldDefinitionsPayload } from "./utils/customFieldDefs.js";
|
|
27
28
|
import { RowActions } from "./RowActions.js";
|
|
@@ -1959,6 +1960,20 @@ function DataTable({
|
|
|
1959
1960
|
const toolbarWrapperClassName = embedded ? "mt-2" : "mt-3 pt-3 border-t";
|
|
1960
1961
|
const tableScrollWrapperClassName = embedded ? "" : "overflow-auto";
|
|
1961
1962
|
const virtualScrollRef = React.useRef(null);
|
|
1963
|
+
const [tableScrollEl, setTableScrollEl] = React.useState(null);
|
|
1964
|
+
const [emptyStateViewportWidth, setEmptyStateViewportWidth] = React.useState(null);
|
|
1965
|
+
const setTableScrollWrapperRef = React.useCallback((node) => {
|
|
1966
|
+
setTableScrollEl(node);
|
|
1967
|
+
virtualScrollRef.current = node;
|
|
1968
|
+
}, []);
|
|
1969
|
+
React.useEffect(() => {
|
|
1970
|
+
if (!tableScrollEl || typeof ResizeObserver === "undefined") return;
|
|
1971
|
+
const update = () => setEmptyStateViewportWidth(tableScrollEl.clientWidth);
|
|
1972
|
+
update();
|
|
1973
|
+
const observer = new ResizeObserver(update);
|
|
1974
|
+
observer.observe(tableScrollEl);
|
|
1975
|
+
return () => observer.disconnect();
|
|
1976
|
+
}, [tableScrollEl]);
|
|
1962
1977
|
const allRows = table.getRowModel().rows;
|
|
1963
1978
|
const rowVirtualizer = virtualized ? useVirtualizer({
|
|
1964
1979
|
count: allRows.length,
|
|
@@ -2045,7 +2060,7 @@ function DataTable({
|
|
|
2045
2060
|
sensors: dndSensors,
|
|
2046
2061
|
columnIds: headerColumnIds,
|
|
2047
2062
|
onDragEnd: handleHeaderDragEnd,
|
|
2048
|
-
children: /* @__PURE__ */ jsx("div", { ref:
|
|
2063
|
+
children: /* @__PURE__ */ jsx("div", { ref: setTableScrollWrapperRef, className: tableScrollWrapperClassName, style: virtualMaxHeightStyle, children: /* @__PURE__ */ jsxs(Table, { className: "min-w-[640px] md:min-w-0", children: [
|
|
2049
2064
|
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
2050
2065
|
hasInjectedBulkActions ? /* @__PURE__ */ jsx(TableHead, { className: "w-8", children: /* @__PURE__ */ jsx(
|
|
2051
2066
|
Checkbox,
|
|
@@ -2187,19 +2202,36 @@ function DataTable({
|
|
|
2187
2202
|
const bottomPadding = lastItem ? rowVirtualizer.getTotalSize() - lastItem.end : 0;
|
|
2188
2203
|
return bottomPadding > 0 ? /* @__PURE__ */ jsx("tr", { style: { height: `${bottomPadding}px` } }) : null;
|
|
2189
2204
|
})() : null
|
|
2190
|
-
] }) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: mergedColumns.length + (rowActions || injectedRowActions.length > 0 ? 1 : 0) + (hasInjectedBulkActions ? 1 : 0), className: "
|
|
2191
|
-
|
|
2192
|
-
{
|
|
2193
|
-
entityNamePlural: filterAwareEmptyState.entityNamePlural,
|
|
2194
|
-
canRemoveLast: filterAwareEmptyState.canRemoveLast,
|
|
2195
|
-
onClearAll: filterAwareEmptyState.onClearAll,
|
|
2196
|
-
onRemoveLast: filterAwareEmptyState.onRemoveLast
|
|
2197
|
-
}
|
|
2198
|
-
) : emptyState && typeof emptyState !== "string" ? emptyState : /* @__PURE__ */ jsx(
|
|
2199
|
-
EmptyState,
|
|
2205
|
+
] }) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: mergedColumns.length + (rowActions || injectedRowActions.length > 0 ? 1 : 0) + (hasInjectedBulkActions ? 1 : 0), className: "p-0", children: /* @__PURE__ */ jsx(
|
|
2206
|
+
"div",
|
|
2200
2207
|
{
|
|
2201
|
-
|
|
2202
|
-
|
|
2208
|
+
className: cn("sticky left-0 flex justify-center py-6", emptyStateViewportWidth ? "" : "w-fit"),
|
|
2209
|
+
style: emptyStateViewportWidth ? { width: emptyStateViewportWidth } : void 0,
|
|
2210
|
+
children: filterAwareEmptyState?.active ? /* @__PURE__ */ jsx(
|
|
2211
|
+
FilteredEmptyResults,
|
|
2212
|
+
{
|
|
2213
|
+
entityNamePlural: filterAwareEmptyState.entityNamePlural,
|
|
2214
|
+
canRemoveLast: filterAwareEmptyState.canRemoveLast,
|
|
2215
|
+
onClearAll: filterAwareEmptyState.onClearAll,
|
|
2216
|
+
onRemoveLast: filterAwareEmptyState.onRemoveLast,
|
|
2217
|
+
onClearSearch: searchValue && searchValue.trim().length > 0 && onSearchChange ? () => onSearchChange("") : void 0
|
|
2218
|
+
}
|
|
2219
|
+
) : searchValue && searchValue.trim().length > 0 && onSearchChange ? /* @__PURE__ */ jsx(
|
|
2220
|
+
SearchEmptyResults,
|
|
2221
|
+
{
|
|
2222
|
+
query: searchValue.trim(),
|
|
2223
|
+
entityNamePlural: filterAwareEmptyState?.entityNamePlural,
|
|
2224
|
+
onClearSearch: () => onSearchChange("")
|
|
2225
|
+
}
|
|
2226
|
+
) : emptyState && typeof emptyState !== "string" ? emptyState : /* @__PURE__ */ jsx(
|
|
2227
|
+
EmptyState,
|
|
2228
|
+
{
|
|
2229
|
+
variant: "subtle",
|
|
2230
|
+
icon: /* @__PURE__ */ jsx(Inbox, { className: "size-6", "aria-hidden": true }),
|
|
2231
|
+
title: typeof emptyState === "string" ? emptyState : t("ui.dataTable.emptyState.default", "No results."),
|
|
2232
|
+
description: typeof emptyState === "string" ? void 0 : t("ui.dataTable.emptyState.defaultDescription", "Items will appear here once added.")
|
|
2233
|
+
}
|
|
2234
|
+
)
|
|
2203
2235
|
}
|
|
2204
2236
|
) }) }) })
|
|
2205
2237
|
] }) })
|