albinasoft-ui-package 1.0.93 → 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.
@@ -1,5 +1,8 @@
|
|
1
1
|
import React from "react";
|
2
|
-
interface
|
2
|
+
export interface AlbinaFormHandles {
|
3
|
+
getFormValues: () => Record<string, any>;
|
4
|
+
}
|
5
|
+
export interface AlbinaFormProps {
|
3
6
|
/** Başlangıç form değerleri */
|
4
7
|
initialValues?: Record<string, any>;
|
5
8
|
/** Form elemanları konfigürasyonu (CustomForm’un elements prop’una verilecek) */
|
@@ -15,9 +18,11 @@ interface AlbinaFormProps {
|
|
15
18
|
/** İptal butonu görünürlüğü */
|
16
19
|
showCancelButton?: boolean;
|
17
20
|
/** Form gönderme işlemi */
|
18
|
-
onSubmit: (values: Record<string, any>) => void;
|
21
|
+
onSubmit: (values: Record<string, any>) => Promise<any> | void;
|
19
22
|
/** İptal işlemi */
|
20
23
|
onCancel?: () => void;
|
24
|
+
/** Form değeri değiştiğinde çağrılacak callback */
|
25
|
+
onValuesChange?: (values: Record<string, any>) => void;
|
21
26
|
}
|
22
|
-
declare const AlbinaForm: React.
|
27
|
+
declare const AlbinaForm: React.ForwardRefExoticComponent<AlbinaFormProps & React.RefAttributes<AlbinaFormHandles>>;
|
23
28
|
export default AlbinaForm;
|
@@ -36,9 +36,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
37
37
|
var react_1 = __importStar(require("react"));
|
38
38
|
var CustomForm_1 = __importStar(require("./CustomForm"));
|
39
|
-
var AlbinaForm = function (_a) {
|
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;
|
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, onValuesChange = _a.onValuesChange;
|
41
41
|
var _h = (0, react_1.useState)(initialValues), formValues = _h[0], setFormValues = _h[1];
|
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]);
|
42
48
|
var handleInputChange = function (id) { return function (e) {
|
43
49
|
if (e instanceof Date || e === null) {
|
44
50
|
setFormValues(function (prev) {
|
@@ -72,6 +78,11 @@ var AlbinaForm = function (_a) {
|
|
72
78
|
var handleFormSubmit = function (values) {
|
73
79
|
onSubmit(formValues);
|
74
80
|
};
|
81
|
+
// Ref üzerinden dışarıya sunulacak metod
|
82
|
+
var getFormValues = function () { return formValues; };
|
83
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
84
|
+
getFormValues: getFormValues,
|
85
|
+
}); });
|
75
86
|
return (react_1.default.createElement(CustomForm_1.default, { elements: enhancedElements, innerRowCustomClass: innerRowCustomClass, confirmLabel: confirmLabel, cancelLabel: cancelLabel, showConfirmButton: showConfirmButton, showCancelButton: showCancelButton, onSubmit: handleFormSubmit, handleCancel: onCancel }));
|
76
|
-
};
|
87
|
+
});
|
77
88
|
exports.default = AlbinaForm;
|