albinasoft-ui-package 1.0.94 → 1.0.95
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.
@@ -21,6 +21,8 @@ export interface AlbinaFormProps {
|
|
21
21
|
onSubmit: (values: Record<string, any>) => Promise<any> | void;
|
22
22
|
/** İptal işlemi */
|
23
23
|
onCancel?: () => void;
|
24
|
+
/** Form değeri değiştiğinde çağrılacak callback */
|
25
|
+
onValuesChange?: (values: Record<string, any>) => void;
|
24
26
|
}
|
25
27
|
declare const AlbinaForm: React.ForwardRefExoticComponent<AlbinaFormProps & React.RefAttributes<AlbinaFormHandles>>;
|
26
28
|
export default AlbinaForm;
|
@@ -37,9 +37,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
var react_1 = __importStar(require("react"));
|
38
38
|
var CustomForm_1 = __importStar(require("./CustomForm"));
|
39
39
|
var AlbinaForm = (0, react_1.forwardRef)(function (_a, ref) {
|
40
|
-
var _b = _a.initialValues, initialValues = _b === void 0 ? {} : _b, elements = _a.elements, _c = _a.innerRowCustomClass, innerRowCustomClass = _c === void 0 ? "justify-content-evenly" : _c, _d = _a.confirmLabel, confirmLabel = _d === void 0 ? "Gönder" : _d, _e = _a.cancelLabel, cancelLabel = _e === void 0 ? "İptal" : _e, _f = _a.showConfirmButton, showConfirmButton = _f === void 0 ? true : _f, _g = _a.showCancelButton, showCancelButton = _g === void 0 ? false : _g, onSubmit = _a.onSubmit, onCancel = _a.onCancel;
|
40
|
+
var _b = _a.initialValues, initialValues = _b === void 0 ? {} : _b, elements = _a.elements, _c = _a.innerRowCustomClass, innerRowCustomClass = _c === void 0 ? "justify-content-evenly" : _c, _d = _a.confirmLabel, confirmLabel = _d === void 0 ? "Gönder" : _d, _e = _a.cancelLabel, cancelLabel = _e === void 0 ? "İptal" : _e, _f = _a.showConfirmButton, showConfirmButton = _f === void 0 ? true : _f, _g = _a.showCancelButton, showCancelButton = _g === void 0 ? false : _g, onSubmit = _a.onSubmit, onCancel = _a.onCancel, onValuesChange = _a.onValuesChange;
|
41
41
|
var _h = (0, react_1.useState)(initialValues), formValues = _h[0], setFormValues = _h[1];
|
42
|
-
//
|
42
|
+
// Form değerleri değiştikçe dışarıya bildiriyoruz.
|
43
|
+
(0, react_1.useEffect)(function () {
|
44
|
+
if (onValuesChange) {
|
45
|
+
onValuesChange(formValues);
|
46
|
+
}
|
47
|
+
}, [formValues, onValuesChange]);
|
43
48
|
var handleInputChange = function (id) { return function (e) {
|
44
49
|
if (e instanceof Date || e === null) {
|
45
50
|
setFormValues(function (prev) {
|
@@ -61,7 +66,6 @@ var AlbinaForm = (0, react_1.forwardRef)(function (_a, ref) {
|
|
61
66
|
});
|
62
67
|
}
|
63
68
|
}; };
|
64
|
-
// Elemana ait onChange handler ile formValues state'ini update ediyoruz.
|
65
69
|
var enhancedElements = elements.map(function (element) {
|
66
70
|
if (element.id && element.type === CustomForm_1.ElementType.SELECT) {
|
67
71
|
return __assign(__assign({}, element), { value: formValues[element.id] || [], onChange: handleInputChange(element.id) });
|
@@ -75,10 +79,7 @@ var AlbinaForm = (0, react_1.forwardRef)(function (_a, ref) {
|
|
75
79
|
onSubmit(formValues);
|
76
80
|
};
|
77
81
|
// Ref üzerinden dışarıya sunulacak metod
|
78
|
-
var getFormValues = function () {
|
79
|
-
return formValues;
|
80
|
-
};
|
81
|
-
// useImperativeHandle ile ref üzerinden sunulan metotları belirtiyoruz.
|
82
|
+
var getFormValues = function () { return formValues; };
|
82
83
|
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
83
84
|
getFormValues: getFormValues,
|
84
85
|
}); });
|