@pagamio/frontend-commons-lib 0.8.335 → 0.8.336
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.
|
@@ -64,11 +64,11 @@ const FilterComponent = ({ filters, selectedFilters, showApplyFilterButton = tru
|
|
|
64
64
|
return (_jsx(DatePicker, { value: value || null, onChange: (date) => handleFilterChange(name, date), placeholder: filter.placeholder ?? `Select ${name}` }));
|
|
65
65
|
}
|
|
66
66
|
if (type === 'multi-select') {
|
|
67
|
-
return (_jsx(MultiSelect, { options: options
|
|
67
|
+
return (_jsx(MultiSelect, { options: Array.isArray(options) ? options : [], placeholder: filter.placeholder ?? `Select ${name}`, value: value || [], onChange: (val) => handleFilterChange(name, val), className: "w-full" }));
|
|
68
68
|
}
|
|
69
69
|
// Default: select
|
|
70
70
|
const currentValue = value || '';
|
|
71
|
-
return (_jsxs(Select, { value: currentValue || undefined, onValueChange: (val) => handleFilterChange(name, val === '__clear__' ? '' : val), children: [_jsx(SelectTrigger, { className: "h-9 w-full border-border bg-background text-sm text-foreground", "aria-label": filter.placeholder ?? name, children: _jsx(SelectValue, { placeholder: filter.placeholder ?? `Select ${name}` }) }), _jsxs(SelectContent, { children: [currentValue && (_jsx(SelectItem, { value: "__clear__", className: "text-muted-foreground", children: filter.placeholder ?? 'All' })), (options
|
|
71
|
+
return (_jsxs(Select, { value: currentValue || undefined, onValueChange: (val) => handleFilterChange(name, val === '__clear__' ? '' : val), children: [_jsx(SelectTrigger, { className: "h-9 w-full border-border bg-background text-sm text-foreground", "aria-label": filter.placeholder ?? name, children: _jsx(SelectValue, { placeholder: filter.placeholder ?? `Select ${name}` }) }), _jsxs(SelectContent, { children: [currentValue && (_jsx(SelectItem, { value: "__clear__", className: "text-muted-foreground", children: filter.placeholder ?? 'All' })), (Array.isArray(options) ? options : []).map((opt) => (_jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value)))] })] }));
|
|
72
72
|
};
|
|
73
73
|
return (
|
|
74
74
|
// Fluid width: full width on mobile, fluid 180–260px on wider
|
|
@@ -79,8 +79,12 @@ function processResponse(response, mapping) {
|
|
|
79
79
|
const totalPath = mapping.total ?? '';
|
|
80
80
|
const extractedData = dataPath ? getNestedValue(response, dataPath) : response;
|
|
81
81
|
const extractedTotal = totalPath ? getNestedValue(response, totalPath) : undefined;
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// Guard against the API returning a non-array at the data path (single-entity
|
|
83
|
+
// response, error envelope, accidentally wrapped paginated response). Downstream
|
|
84
|
+
// consumers iterate `data` directly, so we must hand back an array.
|
|
85
|
+
const fallback = mapping.defaultValues?.data ?? [];
|
|
86
|
+
const data = Array.isArray(extractedData) ? extractedData : fallback;
|
|
87
|
+
const total = extractedTotal ?? data.length;
|
|
84
88
|
return { data, total };
|
|
85
89
|
}
|
|
86
90
|
function buildQueryParams(config, pagination, sorting, filtering) {
|
|
@@ -195,7 +199,7 @@ export const usePagamioTable = ({ queryKey, queryFn, enabled: queryEnabled = tru
|
|
|
195
199
|
return { serverData: processed.data, serverTotal: processed.total };
|
|
196
200
|
}, [rawResponse, responseMapping, isServerMode]);
|
|
197
201
|
// ── Client-side data processing ──────────────────────────────────
|
|
198
|
-
const rawData = isServerMode ? serverData : (clientData
|
|
202
|
+
const rawData = isServerMode ? serverData : Array.isArray(clientData) ? clientData : [];
|
|
199
203
|
const processedData = useMemo(() => {
|
|
200
204
|
let items = [...rawData];
|
|
201
205
|
if (searchMode === 'client' && searchQuery) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.336",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|