@pagamio/frontend-commons-lib 0.8.352 → 0.8.354
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.
|
@@ -3,6 +3,12 @@ interface EmptyStateProps {
|
|
|
3
3
|
title: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Optional CTA rendered below the description. Pass a Button (or a
|
|
8
|
+
* cluster of buttons in a Fragment) so the empty state can guide the
|
|
9
|
+
* user toward the next step.
|
|
10
|
+
*/
|
|
11
|
+
action?: React.ReactNode;
|
|
6
12
|
}
|
|
7
13
|
declare const EmptyState: React.FC<EmptyStateProps>;
|
|
8
14
|
export default EmptyState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MdOutlineFolder } from 'react-icons/md';
|
|
3
|
-
const EmptyState = ({ title, description, icon }) => {
|
|
4
|
-
return (_jsxs("div", { className: "flex flex-col items-center justify-center rounded-lg border border-input bg-muted p-8 text-center", children: [_jsx("div", { className: "mb-4 flex h-32 w-32 items-center justify-center", children: icon ?? _jsx(MdOutlineFolder, { className: "h-full w-full text-muted-foreground" }) }), _jsx("h2", { className: "mb-2 text-lg font-semibold text-foreground", children: title }), _jsx("p", { className: "text-muted-foreground", children: description ?? "We couldn't find any data at this moment. Please try again later or adjust your filters." })] }));
|
|
3
|
+
const EmptyState = ({ title, description, icon, action }) => {
|
|
4
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center rounded-lg border border-input bg-muted p-8 text-center", children: [_jsx("div", { className: "mb-4 flex h-32 w-32 items-center justify-center", children: icon ?? _jsx(MdOutlineFolder, { className: "h-full w-full text-muted-foreground" }) }), _jsx("h2", { className: "mb-2 text-lg font-semibold text-foreground", children: title }), _jsx("p", { className: "text-muted-foreground", children: description ?? "We couldn't find any data at this moment. Please try again later or adjust your filters." }), action && _jsx("div", { className: "mt-4", children: action })] }));
|
|
5
5
|
};
|
|
6
6
|
export default EmptyState;
|
|
@@ -47,31 +47,36 @@ const FormEngine = ({ fields, onSubmit, initialValues, layout = 'vertical', isNo
|
|
|
47
47
|
}
|
|
48
48
|
return initialValues;
|
|
49
49
|
};
|
|
50
|
-
const { control, handleSubmit, watch, formState: { errors, isSubmitting }, reset, setValue, trigger, } = useForm({ mode: 'onBlur', defaultValues: getEffectiveInitialValues() });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
//
|
|
50
|
+
const { control, handleSubmit, watch, formState: { errors, isSubmitting }, reset, setValue, trigger, getValues, } = useForm({ mode: 'onBlur', defaultValues: getEffectiveInitialValues() });
|
|
51
|
+
// Subscribe to field changes via the callback form of `watch` so this
|
|
52
|
+
// component does NOT re-render on every keystroke / select change. The
|
|
53
|
+
// previous `const allFields = watch()` (no args) caused the entire
|
|
54
|
+
// FormEngine subtree — including all Radix Select popovers — to re-render
|
|
55
|
+
// synchronously inside the field's onChange. That race produced the
|
|
56
|
+
// "click twice to commit" symptom on Select inputs: the first click's
|
|
57
|
+
// outside-dismiss fired during the parent re-render and the popover lost
|
|
58
|
+
// its open state. Subscribing via callback keeps RHF state updates
|
|
59
|
+
// isolated to the affected Controller subtree.
|
|
55
60
|
useEffect(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
getFieldValues(allFields);
|
|
63
|
-
}
|
|
64
|
-
}, [allFields, getFieldValues]);
|
|
65
|
-
// Save form data when fields change (for persistence)
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (persistenceKey && allFields && Object.keys(allFields).length > 0) {
|
|
68
|
-
// Only save if there are actual field values (not just empty object)
|
|
69
|
-
const hasValues = Object.values(allFields).some((value) => value !== undefined && value !== null && value !== '');
|
|
70
|
-
if (hasValues) {
|
|
71
|
-
saveFormData(allFields, true);
|
|
61
|
+
const subscription = watch((values, info) => {
|
|
62
|
+
if (info?.name === 'password') {
|
|
63
|
+
const cp = values?.confirmPassword;
|
|
64
|
+
if (values?.password && cp) {
|
|
65
|
+
trigger('confirmPassword');
|
|
66
|
+
}
|
|
72
67
|
}
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
if (getFieldValues) {
|
|
69
|
+
getFieldValues(values);
|
|
70
|
+
}
|
|
71
|
+
if (persistenceKey) {
|
|
72
|
+
const hasValues = Object.values(values ?? {}).some((value) => value !== undefined && value !== null && value !== '');
|
|
73
|
+
if (hasValues) {
|
|
74
|
+
saveFormData(values, true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return () => subscription.unsubscribe();
|
|
79
|
+
}, [watch, trigger, getFieldValues, persistenceKey, saveFormData]);
|
|
75
80
|
// Expose form control methods via ref
|
|
76
81
|
useEffect(() => {
|
|
77
82
|
if (formRef && 'current' in formRef) {
|
|
@@ -109,11 +114,12 @@ const FormEngine = ({ fields, onSubmit, initialValues, layout = 'vertical', isNo
|
|
|
109
114
|
const validateConfirmPassword = (value) => {
|
|
110
115
|
if (!value)
|
|
111
116
|
return 'Please confirm your password';
|
|
112
|
-
|
|
117
|
+
const currentPassword = getValues('password');
|
|
118
|
+
if (!currentPassword)
|
|
113
119
|
return 'Please enter a password first';
|
|
114
|
-
if (
|
|
120
|
+
if (currentPassword.length < 8)
|
|
115
121
|
return 'Please enter a valid password first (minimum 8 characters)';
|
|
116
|
-
if (value !==
|
|
122
|
+
if (value !== currentPassword)
|
|
117
123
|
return 'Passwords do not match';
|
|
118
124
|
return true;
|
|
119
125
|
};
|
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.354",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|