@typeolymp/ui-components 1.19.12 → 1.19.14
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.
|
@@ -70,6 +70,12 @@ export declare type PropsType = {
|
|
|
70
70
|
}): void;
|
|
71
71
|
};
|
|
72
72
|
export declare type FormType = {
|
|
73
|
+
validateForm(): Promise<{
|
|
74
|
+
isValid: boolean;
|
|
75
|
+
feedback: {
|
|
76
|
+
[field: string]: FeedbackType;
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
73
79
|
resetForm(): void;
|
|
74
80
|
};
|
|
75
81
|
declare const Form: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<FormType>>;
|
|
@@ -7,6 +7,7 @@ declare const _default: {
|
|
|
7
7
|
export default _default;
|
|
8
8
|
export declare const AllTogether: () => JSX.Element;
|
|
9
9
|
export declare const ResetForm: () => JSX.Element;
|
|
10
|
+
export declare const ValidateForm: () => JSX.Element;
|
|
10
11
|
export declare const Input: () => JSX.Element;
|
|
11
12
|
export declare const Date: () => JSX.Element;
|
|
12
13
|
export declare const Radio: () => JSX.Element;
|
package/build/index.es.js
CHANGED
|
@@ -14751,8 +14751,8 @@ var templateObject_1$y, templateObject_2$u;
|
|
|
14751
14751
|
|
|
14752
14752
|
var DataSummary = function (_a) {
|
|
14753
14753
|
var title = _a.title, data = _a.data, onEdit = _a.onEdit, locale = _a.locale;
|
|
14754
|
-
return (jsx$1(Fragment$1, { children: jsxs(Container$l, { children: [jsxs("div", { children: [jsx$1(Heading, __assign$2({ type: "h5" }, { children: title })), onEdit && (jsx$1("div", __assign$2({ onClick: onEdit }, { children: jsx$1(Heading, __assign$2({ type: "h6", color: "gray" }, { children: translations[locale]["Edit"] })) })))] }), jsx$1(Data, { children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
14755
|
-
return item instanceof Object ? (jsxs("div", { children: [jsxs(Paragraph, __assign$2({ weight: "regular" }, { children: [item.label, ":"] })), jsx$1(Paragraph, __assign$2({ weight: "regular" }, { children: item.value }))] }, "".concat(item.label, "-").concat(item.value))) : (jsx$1(Paragraph, __assign$2({ weight: "regular" }, { children: item })));
|
|
14754
|
+
return (jsx$1(Fragment$1, { children: jsxs(Container$l, { children: [jsxs("div", { children: [jsx$1(Heading, __assign$2({ type: "h5" }, { children: title })), onEdit && (jsx$1("div", __assign$2({ onClick: onEdit }, { children: jsx$1(Heading, __assign$2({ type: "h6", color: "gray" }, { children: translations[locale]["Edit"] })) })))] }), jsx$1(Data, { children: data === null || data === void 0 ? void 0 : data.map(function (item, index) {
|
|
14755
|
+
return item instanceof Object ? (jsxs("div", { children: [jsxs(Paragraph, __assign$2({ weight: "regular" }, { children: [item.label, ":"] })), jsx$1(Paragraph, __assign$2({ weight: "regular" }, { children: item.value }))] }, "".concat(item.label, "-").concat(item.value, "-").concat(index))) : (jsx$1(Paragraph, __assign$2({ weight: "regular" }, { children: item }), "".concat(item, "-").concat(index)));
|
|
14756
14756
|
}) })] }) }));
|
|
14757
14757
|
};
|
|
14758
14758
|
|
|
@@ -47866,6 +47866,7 @@ var Form = forwardRef(function (props, ref) {
|
|
|
47866
47866
|
var _a = useState({}), values = _a[0], setValues = _a[1];
|
|
47867
47867
|
var _b = useState({}), feedback = _b[0], setFeedback = _b[1];
|
|
47868
47868
|
useImperativeHandle(ref, function () { return ({
|
|
47869
|
+
validateForm: validateForm,
|
|
47869
47870
|
resetForm: resetForm,
|
|
47870
47871
|
}); });
|
|
47871
47872
|
useEffect(function () {
|
|
@@ -48007,7 +48008,7 @@ var Form = forwardRef(function (props, ref) {
|
|
|
48007
48008
|
}
|
|
48008
48009
|
});
|
|
48009
48010
|
}); };
|
|
48010
|
-
var
|
|
48011
|
+
var validateForm = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48011
48012
|
var isValid, feedback, _i, _a, field, _b, _c;
|
|
48012
48013
|
return __generator(this, function (_d) {
|
|
48013
48014
|
switch (_d.label) {
|
|
@@ -48033,12 +48034,21 @@ var Form = forwardRef(function (props, ref) {
|
|
|
48033
48034
|
return [3 /*break*/, 1];
|
|
48034
48035
|
case 4:
|
|
48035
48036
|
setFeedback(feedback);
|
|
48036
|
-
|
|
48037
|
+
return [2 /*return*/, { isValid: isValid, feedback: feedback }];
|
|
48038
|
+
}
|
|
48039
|
+
});
|
|
48040
|
+
}); };
|
|
48041
|
+
var onSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48042
|
+
var _a, isValid, feedback;
|
|
48043
|
+
return __generator(this, function (_b) {
|
|
48044
|
+
switch (_b.label) {
|
|
48045
|
+
case 0: return [4 /*yield*/, validateForm()];
|
|
48046
|
+
case 1:
|
|
48047
|
+
_a = _b.sent(), isValid = _a.isValid, feedback = _a.feedback;
|
|
48048
|
+
if (isValid && !!props.onSubmit)
|
|
48037
48049
|
props.onSubmit(values);
|
|
48038
|
-
|
|
48039
|
-
else if (!!props.onError) {
|
|
48050
|
+
else if (!!props.onError)
|
|
48040
48051
|
props.onError(feedback);
|
|
48041
|
-
}
|
|
48042
48052
|
return [2 /*return*/];
|
|
48043
48053
|
}
|
|
48044
48054
|
});
|