@pagamio/frontend-commons-lib 0.8.288 → 0.8.290
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/components/ui/DatePicker.d.ts +2 -2
- package/lib/components/ui/DatePicker.js +4 -1
- package/lib/components/ui/StatusCell.d.ts +2 -4
- package/lib/components/ui/StatusCell.js +1 -1
- package/lib/form-engine/FormEngine.d.ts +1 -1
- package/lib/form-engine/types/index.d.ts +9 -9
- package/lib/pagamio-drawer/components/DrawerContent.d.ts +5 -5
- package/lib/pagamio-drawer/components/DrawerContent.js +2 -0
- package/lib/pagamio-drawer/index.d.ts +3 -3
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ type DatePickerProps = {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
id?: string;
|
|
7
7
|
className?: string;
|
|
8
|
-
value?: Date | null;
|
|
9
|
-
onChange?: (date:
|
|
8
|
+
value?: Date | string | null;
|
|
9
|
+
onChange?: (date: string) => void;
|
|
10
10
|
};
|
|
11
11
|
declare function DatePicker({ value, disabled, name, placeholder, onChange }: Readonly<DatePickerProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export default DatePicker;
|
|
@@ -80,7 +80,10 @@ function DatePicker({ value, disabled, name, placeholder, onChange }) {
|
|
|
80
80
|
const validDate = new Date(date);
|
|
81
81
|
setSelectedDate(validDate);
|
|
82
82
|
if (onChange && !Number.isNaN(validDate.getTime())) {
|
|
83
|
-
|
|
83
|
+
const yyyy = validDate.getFullYear();
|
|
84
|
+
const mm = String(validDate.getMonth() + 1).padStart(2, '0');
|
|
85
|
+
const dd = String(validDate.getDate()).padStart(2, '0');
|
|
86
|
+
onChange(`${yyyy}-${mm}-${dd}`);
|
|
84
87
|
}
|
|
85
88
|
}, name: name, className: "", disabled: disabled, theme: datepickerTheme }) }));
|
|
86
89
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { MRT_Cell } from 'mantine-react-table';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
|
-
export interface StatusCellProps
|
|
4
|
-
readonly cell: MRT_Cell<T>;
|
|
2
|
+
export interface StatusCellProps {
|
|
5
3
|
readonly color: string;
|
|
6
4
|
readonly displayValue: string;
|
|
7
5
|
readonly className?: string;
|
|
8
6
|
readonly icon?: ReactNode;
|
|
9
7
|
}
|
|
10
|
-
declare function StatusCell
|
|
8
|
+
declare function StatusCell({ displayValue, className, icon }: Readonly<StatusCellProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
9
|
export default StatusCell;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
function StatusCell({ displayValue, className = '', icon
|
|
2
|
+
function StatusCell({ displayValue, className = '', icon }) {
|
|
3
3
|
const baseClass = 'rounded-full px-4 py-1.5 whitespace-nowrap';
|
|
4
4
|
if (icon) {
|
|
5
5
|
return (_jsxs("span", { className: `inline-flex items-center gap-1 ${baseClass} ${className}`.trim(), children: [icon, displayValue] }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FormEngineProps } from './types';
|
|
3
|
-
declare const FormEngine:
|
|
3
|
+
declare const FormEngine: ({ fields, onSubmit, initialValues, layout, isNotTrigger, showCancelButton, submitButtonText, showSubmittingText, submitButtonClass, onCancel, getFieldValues, formRef, className, persistenceKey, }: FormEngineProps) => React.JSX.Element;
|
|
4
4
|
export default FormEngine;
|
|
@@ -3,7 +3,7 @@ import type React from 'react';
|
|
|
3
3
|
export interface ActionProps {
|
|
4
4
|
field: string;
|
|
5
5
|
options?: SelectOption[] | string[];
|
|
6
|
-
value?:
|
|
6
|
+
value?: unknown;
|
|
7
7
|
label?: string;
|
|
8
8
|
hideField?: boolean;
|
|
9
9
|
fieldInnitialData?: Field;
|
|
@@ -53,20 +53,20 @@ export type ControlFields = {
|
|
|
53
53
|
*/
|
|
54
54
|
export interface FormRef {
|
|
55
55
|
reset: () => void;
|
|
56
|
-
setValue?: (name: string, value:
|
|
56
|
+
setValue?: (name: string, value: unknown) => void;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Props for the FormEngine component which handles form rendering and submission
|
|
60
60
|
*/
|
|
61
|
-
export interface FormEngineProps
|
|
61
|
+
export interface FormEngineProps {
|
|
62
62
|
/** Array of field definitions that make up the form */
|
|
63
63
|
fields: Field[];
|
|
64
64
|
/** Callback function called when the form is submitted */
|
|
65
|
-
onSubmit: (data:
|
|
65
|
+
onSubmit: (data: Record<string, unknown>) => void | Promise<void>;
|
|
66
66
|
/** Layout direction of the form */
|
|
67
67
|
layout?: 'vertical' | 'horizontal';
|
|
68
68
|
/** Initial values for form fields */
|
|
69
|
-
initialValues?:
|
|
69
|
+
initialValues?: Record<string, unknown>;
|
|
70
70
|
/** Custom tailwind class for the Form Engine */
|
|
71
71
|
className?: string;
|
|
72
72
|
/** Custom tailwind class for the submit button */
|
|
@@ -82,7 +82,7 @@ export interface FormEngineProps<T extends Record<string, any>> {
|
|
|
82
82
|
/** Callback function called when form cancellation is requested */
|
|
83
83
|
onCancel: () => void;
|
|
84
84
|
/** Callback function called whenever a field value changes */
|
|
85
|
-
getFieldValues?: (
|
|
85
|
+
getFieldValues?: (values: Record<string, unknown>) => void;
|
|
86
86
|
/** Optional persistence key for form data */
|
|
87
87
|
persistenceKey?: string;
|
|
88
88
|
/**
|
|
@@ -174,7 +174,7 @@ export interface Field {
|
|
|
174
174
|
export interface DependentFieldUpdate {
|
|
175
175
|
field: string;
|
|
176
176
|
dependencies?: string[];
|
|
177
|
-
action: (value:
|
|
177
|
+
action: (value: unknown, isInitialLoad?: boolean) => Promise<ActionProps> | ActionProps;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Props for the Form component wrapper
|
|
@@ -220,11 +220,11 @@ export interface FieldWrapperProps {
|
|
|
220
220
|
/** Add new field callback */
|
|
221
221
|
addField?: (field: Field) => void;
|
|
222
222
|
/** Set value function from useForm */
|
|
223
|
-
setValue?: (name: string, value:
|
|
223
|
+
setValue?: (name: string, value: unknown) => void;
|
|
224
224
|
/** Clear errors function from useForm */
|
|
225
225
|
clearErrors?: (field: string) => void;
|
|
226
226
|
/** Get values function from useForm */
|
|
227
|
-
getValues?: () => Record<string,
|
|
227
|
+
getValues?: () => Record<string, unknown>;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
230
|
* Props for basic input components
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import type { DependentFieldUpdate, Field, SelectOption, ValidationRule } from '../../form-engine';
|
|
3
3
|
interface DrawerContentProps {
|
|
4
4
|
fields: Field[];
|
|
5
|
-
onSubmit: (data:
|
|
6
|
-
initialValues?:
|
|
5
|
+
onSubmit: (data: Record<string, unknown>) => void | Promise<void>;
|
|
6
|
+
initialValues?: Record<string, unknown>;
|
|
7
7
|
isOpen?: boolean;
|
|
8
8
|
cancelButtonText?: string;
|
|
9
9
|
submitButtonText?: string;
|
|
@@ -12,15 +12,15 @@ interface DrawerContentProps {
|
|
|
12
12
|
showDrawerButtons?: boolean;
|
|
13
13
|
handleCloseDrawer: () => void;
|
|
14
14
|
onFieldUpdate?: Record<string, DependentFieldUpdate[]>;
|
|
15
|
-
onFieldChange?: (fieldName: string, value:
|
|
15
|
+
onFieldChange?: (fieldName: string, value: unknown) => void;
|
|
16
16
|
updateFieldOptions?: (field: string, options: Array<SelectOption | string>) => void;
|
|
17
17
|
updateFieldLabel?: (fieldName: string, newLabelName: string) => void;
|
|
18
18
|
setFieldHidden?: (fieldName: string, hidden: boolean) => void;
|
|
19
19
|
addField?: (fields: Field) => void;
|
|
20
20
|
updateFieldValidation?: (fieldName: string, newValidation: ValidationRule) => void;
|
|
21
|
-
processInitialFieldUpdates?: (getValues: (name?: string) =>
|
|
21
|
+
processInitialFieldUpdates?: (getValues: (name?: string) => unknown) => Promise<void>;
|
|
22
22
|
processingDependencyRef?: React.MutableRefObject<boolean>;
|
|
23
|
-
pendingUpdatesRef?: React.MutableRefObject<Map<string,
|
|
23
|
+
pendingUpdatesRef?: React.MutableRefObject<Map<string, unknown>>;
|
|
24
24
|
persistenceKey?: string;
|
|
25
25
|
/** Ref updated every render with current dirty state — read by FormEngineDrawer for X-button check. */
|
|
26
26
|
isDirtyRef?: React.MutableRefObject<boolean>;
|
|
@@ -180,6 +180,8 @@ const DrawerContent = ({ fields, onSubmit, isOpen, initialValues, submitButtonTe
|
|
|
180
180
|
if (!result)
|
|
181
181
|
return;
|
|
182
182
|
const { field, options, value, label, hideField, fieldInnitialData } = result;
|
|
183
|
+
if (!field)
|
|
184
|
+
return;
|
|
183
185
|
// Apply each possible update type if needed
|
|
184
186
|
if (options !== undefined && updateFieldOptions) {
|
|
185
187
|
updateFieldOptions(field, options);
|
|
@@ -10,11 +10,11 @@ interface FormEngineDrawerProps {
|
|
|
10
10
|
marginTop?: string;
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
fields: Field[];
|
|
13
|
-
initialValues?:
|
|
14
|
-
onSubmit: (data:
|
|
13
|
+
initialValues?: Record<string, unknown>;
|
|
14
|
+
onSubmit: (data: Record<string, unknown>) => void | Promise<void>;
|
|
15
15
|
onClose: () => void;
|
|
16
16
|
onFieldUpdate?: Record<string, DependentFieldUpdate[]>;
|
|
17
|
-
onFieldChange?: (fieldName: string, value:
|
|
17
|
+
onFieldChange?: (fieldName: string, value: unknown) => void;
|
|
18
18
|
persistenceKey?: string;
|
|
19
19
|
}
|
|
20
20
|
declare const FormEngineDrawer: React.FC<FormEngineDrawerProps>;
|
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.290",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|