@pagamio/frontend-commons-lib 0.8.262 → 0.8.264
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.
|
@@ -102,13 +102,21 @@ const DateRangePickerWithPresets = ({ value, onChange, presets = defaultDatePres
|
|
|
102
102
|
}, [isOpen, value, selectedPreset]);
|
|
103
103
|
// Format the display text
|
|
104
104
|
const displayText = useMemo(() => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
// Custom range with dates selected — show the formatted date range
|
|
106
|
+
if (value?.from) {
|
|
107
|
+
if (value.to) {
|
|
108
|
+
return `${format(value.from, dateFormat)} - ${format(value.to, dateFormat)}`;
|
|
109
|
+
}
|
|
110
|
+
return format(value.from, dateFormat);
|
|
111
|
+
}
|
|
112
|
+
// No custom dates — show the active preset label
|
|
113
|
+
if (selectedPreset && selectedPreset !== 'custom') {
|
|
114
|
+
const activePreset = presets.find((p) => p.value === selectedPreset);
|
|
115
|
+
if (activePreset)
|
|
116
|
+
return activePreset.label;
|
|
109
117
|
}
|
|
110
|
-
return
|
|
111
|
-
}, [value, dateFormat, placeholder]);
|
|
118
|
+
return placeholder;
|
|
119
|
+
}, [value, dateFormat, placeholder, selectedPreset, presets]);
|
|
112
120
|
// Handle preset selection
|
|
113
121
|
const handlePresetSelect = (preset) => {
|
|
114
122
|
// For custom preset, preserve current selection or clear it
|
|
@@ -160,7 +168,7 @@ const DateRangePickerWithPresets = ({ value, onChange, presets = defaultDatePres
|
|
|
160
168
|
? `${format(tempRange.from, dateFormat)} - ${format(tempRange.to, dateFormat)}`
|
|
161
169
|
: tempRange?.from
|
|
162
170
|
? format(tempRange.from, dateFormat)
|
|
163
|
-
: 'Select a range' }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { size: "sm", onClick: handleApply, disabled: !tempRange?.from, children: "Apply" })] })] })] }))] }) })] }));
|
|
171
|
+
: 'Select a range' }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { size: "sm", onClick: handleApply, disabled: !tempRange?.from || !tempRange?.to, children: "Apply" })] })] })] }))] }) })] }));
|
|
164
172
|
};
|
|
165
173
|
DateRangePickerWithPresets.displayName = 'DateRangePickerWithPresets';
|
|
166
174
|
export default DateRangePickerWithPresets;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { MRT_Cell } from 'mantine-react-table';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
2
3
|
export interface StatusCellProps<T extends Record<string, any> = {}> {
|
|
3
4
|
readonly cell: MRT_Cell<T>;
|
|
4
5
|
readonly color: string;
|
|
5
6
|
readonly displayValue: string;
|
|
6
7
|
readonly className?: string;
|
|
8
|
+
readonly icon?: ReactNode;
|
|
7
9
|
}
|
|
8
|
-
declare function StatusCell<T extends Record<string, any> = {}>({ displayValue, className, }: Readonly<StatusCellProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function StatusCell<T extends Record<string, any> = {}>({ displayValue, className, icon, }: Readonly<StatusCellProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export default StatusCell;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
function StatusCell({ displayValue, className = '', }) {
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
function StatusCell({ displayValue, className = '', icon, }) {
|
|
3
3
|
const baseClass = 'rounded-full px-4 py-1.5 whitespace-nowrap';
|
|
4
|
+
if (icon) {
|
|
5
|
+
return (_jsxs("span", { className: `inline-flex items-center gap-1 ${baseClass} ${className}`.trim(), children: [icon, displayValue] }));
|
|
6
|
+
}
|
|
4
7
|
return _jsx("span", { className: `${baseClass} ${className}`.trim(), children: displayValue });
|
|
5
8
|
}
|
|
6
9
|
export default StatusCell;
|
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.264",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|