albinasoft-ui-package 1.0.92 → 1.0.94
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/dist/components/AlbinaForm.d.ts +26 -0
- package/dist/components/AlbinaForm.js +87 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from "react";
|
2
|
+
export interface AlbinaFormHandles {
|
3
|
+
getFormValues: () => Record<string, any>;
|
4
|
+
}
|
5
|
+
export interface AlbinaFormProps {
|
6
|
+
/** Başlangıç form değerleri */
|
7
|
+
initialValues?: Record<string, any>;
|
8
|
+
/** Form elemanları konfigürasyonu (CustomForm’un elements prop’una verilecek) */
|
9
|
+
elements: any[];
|
10
|
+
/** İç satırın sınıfı */
|
11
|
+
innerRowCustomClass?: string;
|
12
|
+
/** Onay buton etiketi */
|
13
|
+
confirmLabel?: string;
|
14
|
+
/** İptal buton etiketi */
|
15
|
+
cancelLabel?: string;
|
16
|
+
/** Onay butonu görünürlüğü */
|
17
|
+
showConfirmButton?: boolean;
|
18
|
+
/** İptal butonu görünürlüğü */
|
19
|
+
showCancelButton?: boolean;
|
20
|
+
/** Form gönderme işlemi */
|
21
|
+
onSubmit: (values: Record<string, any>) => Promise<any> | void;
|
22
|
+
/** İptal işlemi */
|
23
|
+
onCancel?: () => void;
|
24
|
+
}
|
25
|
+
declare const AlbinaForm: React.ForwardRefExoticComponent<AlbinaFormProps & React.RefAttributes<AlbinaFormHandles>>;
|
26
|
+
export default AlbinaForm;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
18
|
+
}
|
19
|
+
Object.defineProperty(o, k2, desc);
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
37
|
+
var react_1 = __importStar(require("react"));
|
38
|
+
var CustomForm_1 = __importStar(require("./CustomForm"));
|
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;
|
41
|
+
var _h = (0, react_1.useState)(initialValues), formValues = _h[0], setFormValues = _h[1];
|
42
|
+
// Her input için onChange eventini içeren ortak handler
|
43
|
+
var handleInputChange = function (id) { return function (e) {
|
44
|
+
if (e instanceof Date || e === null) {
|
45
|
+
setFormValues(function (prev) {
|
46
|
+
var _a;
|
47
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[id] = e, _a)));
|
48
|
+
});
|
49
|
+
}
|
50
|
+
else if (e.target) {
|
51
|
+
var _a = e.target, type_1 = _a.type, checked_1 = _a.checked, value_1 = _a.value;
|
52
|
+
setFormValues(function (prev) {
|
53
|
+
var _a;
|
54
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[id] = type_1 === "checkbox" ? checked_1 : value_1, _a)));
|
55
|
+
});
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
setFormValues(function (prev) {
|
59
|
+
var _a;
|
60
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[id] = e, _a)));
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}; };
|
64
|
+
// Elemana ait onChange handler ile formValues state'ini update ediyoruz.
|
65
|
+
var enhancedElements = elements.map(function (element) {
|
66
|
+
if (element.id && element.type === CustomForm_1.ElementType.SELECT) {
|
67
|
+
return __assign(__assign({}, element), { value: formValues[element.id] || [], onChange: handleInputChange(element.id) });
|
68
|
+
}
|
69
|
+
else if (element.id) {
|
70
|
+
return __assign(__assign({}, element), { value: formValues[element.id] || "", onChange: handleInputChange(element.id) });
|
71
|
+
}
|
72
|
+
return element;
|
73
|
+
});
|
74
|
+
var handleFormSubmit = function (values) {
|
75
|
+
onSubmit(formValues);
|
76
|
+
};
|
77
|
+
// Ref üzerinden dışarıya sunulacak metod
|
78
|
+
var getFormValues = function () {
|
79
|
+
return formValues;
|
80
|
+
};
|
81
|
+
// useImperativeHandle ile ref üzerinden sunulan metotları belirtiyoruz.
|
82
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
83
|
+
getFormValues: getFormValues,
|
84
|
+
}); });
|
85
|
+
return (react_1.default.createElement(CustomForm_1.default, { elements: enhancedElements, innerRowCustomClass: innerRowCustomClass, confirmLabel: confirmLabel, cancelLabel: cancelLabel, showConfirmButton: showConfirmButton, showCancelButton: showCancelButton, onSubmit: handleFormSubmit, handleCancel: onCancel }));
|
86
|
+
});
|
87
|
+
exports.default = AlbinaForm;
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import AlbinaForm from './components/AlbinaForm';
|
1
2
|
import CustomButton from './components/CustomButton';
|
2
3
|
import CustomCheckbox from './components/CustomCheckbox';
|
3
4
|
import CustomDateTimePicker from './components/CustomDateTimePicker';
|
@@ -16,4 +17,4 @@ import CustomAutocompleteInput from './components/CustomAutocompleteInput';
|
|
16
17
|
import CustomProgressBar from './components/CustomProgressBar';
|
17
18
|
import CustomTimeline from './components/CustomTimeline';
|
18
19
|
import CustomDatatable from './components/CustomDatatable';
|
19
|
-
export { CustomButton, CustomCheckbox, CustomDateTimePicker, CustomDivider, CustomForm, CustomInput, CustomModal, CustomRadioButton, CustomRichTextbox, CustomSelect, CustomTab, CustomText, CustomTextarea, CustomTreeView, CustomAutocompleteInput, CustomProgressBar, CustomTimeline, CustomDatatable, };
|
20
|
+
export { AlbinaForm, CustomButton, CustomCheckbox, CustomDateTimePicker, CustomDivider, CustomForm, CustomInput, CustomModal, CustomRadioButton, CustomRichTextbox, CustomSelect, CustomTab, CustomText, CustomTextarea, CustomTreeView, CustomAutocompleteInput, CustomProgressBar, CustomTimeline, CustomDatatable, };
|
package/dist/index.js
CHANGED
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.CustomDatatable = exports.CustomTimeline = exports.CustomProgressBar = exports.CustomAutocompleteInput = exports.CustomTreeView = exports.CustomTextarea = exports.CustomText = exports.CustomTab = exports.CustomSelect = exports.CustomRichTextbox = exports.CustomRadioButton = exports.CustomModal = exports.CustomInput = exports.CustomForm = exports.CustomDivider = exports.CustomDateTimePicker = exports.CustomCheckbox = exports.CustomButton = void 0;
|
6
|
+
exports.CustomDatatable = exports.CustomTimeline = exports.CustomProgressBar = exports.CustomAutocompleteInput = exports.CustomTreeView = exports.CustomTextarea = exports.CustomText = exports.CustomTab = exports.CustomSelect = exports.CustomRichTextbox = exports.CustomRadioButton = exports.CustomModal = exports.CustomInput = exports.CustomForm = exports.CustomDivider = exports.CustomDateTimePicker = exports.CustomCheckbox = exports.CustomButton = exports.AlbinaForm = void 0;
|
7
|
+
var AlbinaForm_1 = __importDefault(require("./components/AlbinaForm"));
|
8
|
+
exports.AlbinaForm = AlbinaForm_1.default;
|
7
9
|
var CustomButton_1 = __importDefault(require("./components/CustomButton"));
|
8
10
|
exports.CustomButton = CustomButton_1.default;
|
9
11
|
var CustomCheckbox_1 = __importDefault(require("./components/CustomCheckbox"));
|