@pagamio/frontend-commons-lib 0.8.334 → 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.
- package/lib/api/swr.d.ts +1 -1
- package/lib/components/ui/FilterComponent.js +2 -2
- package/lib/components/ui/Label.d.ts +1 -1
- package/lib/components/ui/Sheet.d.ts +1 -1
- package/lib/components/ui/StatCard.d.ts +3 -3
- package/lib/dashboard-visuals/hooks/useChartData.d.ts +1 -1
- package/lib/dashboard-visuals/utils/formatUtil.js +1 -0
- package/lib/pagamio-table/data-table/exportUtils.js +5 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.js +3 -0
- package/lib/shared/hooks/usePagamioTable.js +7 -3
- package/package.json +2 -2
package/lib/api/swr.d.ts
CHANGED
|
@@ -42,5 +42,5 @@ export declare function useApiSWRWithMutation<ResponseData>(endpoint: Key, confi
|
|
|
42
42
|
data: ResponseData | undefined;
|
|
43
43
|
error: ApiErrorResponse | undefined;
|
|
44
44
|
isValidating: boolean;
|
|
45
|
-
isLoading: import("swr/
|
|
45
|
+
isLoading: import("swr/_internal").IsLoadingResponse<Data, Config>;
|
|
46
46
|
};
|
|
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/
|
|
4
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
|
|
5
5
|
export default Label;
|
|
@@ -9,7 +9,7 @@ declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
|
|
|
9
9
|
declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
declare const sheetVariants: (props?: ({
|
|
11
11
|
side?: "left" | "right" | "bottom" | "top" | null | undefined;
|
|
12
|
-
} & import("class-variance-authority/
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
13
|
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
|
|
14
14
|
}
|
|
15
15
|
declare const SheetContent: React.ForwardRefExoticComponent<SheetContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -3,15 +3,15 @@ import * as React from 'react';
|
|
|
3
3
|
declare const statCardVariants: (props?: ({
|
|
4
4
|
variant?: "green" | "orange" | "teal" | "dark" | "light" | "primary" | "light-orange" | "light-teal" | "light-green" | null | undefined;
|
|
5
5
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare const iconContainerVariants: (props?: ({
|
|
8
8
|
variant?: "green" | "orange" | "teal" | "dark" | "light" | "primary" | "light-orange" | "light-teal" | "light-green" | null | undefined;
|
|
9
9
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
10
|
-
} & import("class-variance-authority/
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
declare const changeIndicatorVariants: (props?: ({
|
|
12
12
|
direction?: "up" | "down" | "neutral" | null | undefined;
|
|
13
13
|
onSolid?: boolean | null | undefined;
|
|
14
|
-
} & import("class-variance-authority/
|
|
14
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
export interface StatCardChange {
|
|
16
16
|
/** Percentage value (e.g., 22 for 22%) */
|
|
17
17
|
value: number;
|
|
@@ -7,7 +7,7 @@ import type { MetricData } from '../types';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const useChartData: <T = MetricData[], TransformReturnType = T>(url: string, query: QueryProps, transform?: (data: T) => TransformReturnType) => {
|
|
9
9
|
data: T | TransformReturnType | undefined;
|
|
10
|
-
error: import("
|
|
10
|
+
error: import("../..").ApiErrorResponse | undefined;
|
|
11
11
|
loading: boolean;
|
|
12
12
|
isEmpty: boolean;
|
|
13
13
|
refresh: () => Promise<any>;
|
|
@@ -57,6 +57,7 @@ const formatDateValue = (value) => {
|
|
|
57
57
|
day: 'numeric',
|
|
58
58
|
hour: '2-digit',
|
|
59
59
|
minute: '2-digit',
|
|
60
|
+
hour12: false,
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
// Handle ISO date strings - more comprehensive regex
|
|
@@ -72,6 +73,7 @@ const formatDateValue = (value) => {
|
|
|
72
73
|
day: 'numeric',
|
|
73
74
|
hour: '2-digit',
|
|
74
75
|
minute: '2-digit',
|
|
76
|
+
hour12: false,
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
}
|
|
@@ -246,6 +248,7 @@ export const exportToCsv = (data, columns, options = {}) => {
|
|
|
246
248
|
day: 'numeric',
|
|
247
249
|
hour: '2-digit',
|
|
248
250
|
minute: '2-digit',
|
|
251
|
+
hour12: false,
|
|
249
252
|
})}`;
|
|
250
253
|
csvRows.push(`# ${timestamp}`);
|
|
251
254
|
}
|
|
@@ -330,6 +333,7 @@ const createWorksheetData = (title, subtitle, includeTimestamp, headers, formatt
|
|
|
330
333
|
day: 'numeric',
|
|
331
334
|
hour: '2-digit',
|
|
332
335
|
minute: '2-digit',
|
|
336
|
+
hour12: false,
|
|
333
337
|
})}`;
|
|
334
338
|
worksheetData.push([timestamp]);
|
|
335
339
|
currentRow++;
|
|
@@ -582,6 +586,7 @@ export const exportToPdf = async (data, columns, options = {}) => {
|
|
|
582
586
|
day: 'numeric',
|
|
583
587
|
hour: '2-digit',
|
|
584
588
|
minute: '2-digit',
|
|
589
|
+
hour12: false,
|
|
585
590
|
})}`, colors, logo, } = options;
|
|
586
591
|
// Create PDF document with better settings
|
|
587
592
|
const doc = new jsPDF({
|
|
@@ -14,6 +14,7 @@ export const createPdfExportOptions = (config, title) => {
|
|
|
14
14
|
day: 'numeric',
|
|
15
15
|
hour: '2-digit',
|
|
16
16
|
minute: '2-digit',
|
|
17
|
+
hour12: false,
|
|
17
18
|
})}`,
|
|
18
19
|
colors: {
|
|
19
20
|
primary: config.theme.colors.primary,
|
|
@@ -42,6 +43,7 @@ export const createXlsxExportOptions = (config, title, sheetName) => {
|
|
|
42
43
|
day: 'numeric',
|
|
43
44
|
hour: '2-digit',
|
|
44
45
|
minute: '2-digit',
|
|
46
|
+
hour12: false,
|
|
45
47
|
})}`,
|
|
46
48
|
colors: {
|
|
47
49
|
primary: config.theme.colors.primary,
|
|
@@ -67,6 +69,7 @@ export const createDefaultXlsxExportOptions = (title, sheetName) => {
|
|
|
67
69
|
day: 'numeric',
|
|
68
70
|
hour: '2-digit',
|
|
69
71
|
minute: '2-digit',
|
|
72
|
+
hour12: false,
|
|
70
73
|
})}`,
|
|
71
74
|
colors: {
|
|
72
75
|
primary: {
|
|
@@ -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
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"build:watch": "tsc --watch",
|
|
84
84
|
"build": "rm -rf lib && tsc && yarn build:css && yarn copy-locale-files",
|
|
85
85
|
"build:css": "postcss src/index.css -o lib/styles.css",
|
|
86
|
-
"lint": "eslint
|
|
86
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
87
87
|
"lint:fix": "eslint . --fix",
|
|
88
88
|
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss}\"",
|
|
89
89
|
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,scss}\"",
|