@visiion/forms-library 1.4.12 → 1.4.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.
- package/dist/index.esm.js +9 -3
- package/dist/index.js +9 -3
- package/dist/types/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -10329,7 +10329,6 @@ function maskRut(rut) {
|
|
|
10329
10329
|
|
|
10330
10330
|
var RutInput = function (_a) {
|
|
10331
10331
|
var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error, onSearch = _a.onSearch, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.placeholder, placeholder = _c === void 0 ? "0.000.000-0" : _c, _d = _a.minLength, minLength = _d === void 0 ? 12 : _d, _e = _a.maxLength, maxLength = _e === void 0 ? 12 : _e;
|
|
10332
|
-
console.log(value);
|
|
10333
10332
|
// crear variable que si value tiene -error-no-empleador sea true
|
|
10334
10333
|
var errorEmpleador = value.includes("-error-no-empleador") ? true : false;
|
|
10335
10334
|
//sacar el -error-no-empleador de value
|
|
@@ -19964,7 +19963,7 @@ var Alert = function (_a) {
|
|
|
19964
19963
|
|
|
19965
19964
|
var DatePicker = function (_a) {
|
|
19966
19965
|
var id = _a.id, name = _a.name, label = _a.label, value = _a.value, onChange = _a.onChange, error = _a.error, disabled = _a.disabled, required = _a.required, placeholder = _a.placeholder, props = _a.props;
|
|
19967
|
-
return (
|
|
19966
|
+
return (jsxs(InputWrapper, { id: id, label: label, error: error, children: [jsx("input", { id: id, name: name, type: "date", value: value || "", onChange: onChange, disabled: disabled, required: required, placeholder: placeholder, max: props === null || props === void 0 ? void 0 : props.maxDate, min: props === null || props === void 0 ? void 0 : props.minDate, className: "w-full px-3 py-2 font-roboto font-normal text-gray-800 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 ".concat(error ? "border-red-500" : "border-gray-300", " ").concat(disabled ? "bg-gray-100 cursor-not-allowed" : "") }), error && jsx("p", { className: "text-red-500 text-sm", children: error })] }));
|
|
19968
19967
|
};
|
|
19969
19968
|
|
|
19970
19969
|
var SwornDeclaration = function (_a) {
|
|
@@ -23044,7 +23043,8 @@ var GenericForm = function (_a) {
|
|
|
23044
23043
|
}
|
|
23045
23044
|
}, [stepperData, config.fields]);
|
|
23046
23045
|
var handleInputChange = function (e) {
|
|
23047
|
-
var _a
|
|
23046
|
+
var _a;
|
|
23047
|
+
var _b = e.target, name = _b.name, value = _b.value, type = _b.type;
|
|
23048
23048
|
var checked = type === "checkbox" ? e.target.checked : undefined;
|
|
23049
23049
|
var newValue = type === "checkbox" ? checked : value;
|
|
23050
23050
|
// Actualizar estado local
|
|
@@ -23052,6 +23052,12 @@ var GenericForm = function (_a) {
|
|
|
23052
23052
|
var _a;
|
|
23053
23053
|
return (__assign(__assign({}, prevData), (_a = {}, _a[name] = newValue, _a)));
|
|
23054
23054
|
});
|
|
23055
|
+
if (config.onCallback) {
|
|
23056
|
+
var field = (_a = config === null || config === void 0 ? void 0 : config.fields) === null || _a === void 0 ? void 0 : _a.find(function (field) { return field.name === name; });
|
|
23057
|
+
if (field) {
|
|
23058
|
+
config.onCallback(field, newValue, __assign(__assign({}, stepperData), formData));
|
|
23059
|
+
}
|
|
23060
|
+
}
|
|
23055
23061
|
// Limpiar error del campo
|
|
23056
23062
|
if (errors[name]) {
|
|
23057
23063
|
setErrors(function (prev) {
|
package/dist/index.js
CHANGED
|
@@ -10348,7 +10348,6 @@ function maskRut(rut) {
|
|
|
10348
10348
|
|
|
10349
10349
|
var RutInput = function (_a) {
|
|
10350
10350
|
var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error, onSearch = _a.onSearch, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.placeholder, placeholder = _c === void 0 ? "0.000.000-0" : _c, _d = _a.minLength, minLength = _d === void 0 ? 12 : _d, _e = _a.maxLength, maxLength = _e === void 0 ? 12 : _e;
|
|
10351
|
-
console.log(value);
|
|
10352
10351
|
// crear variable que si value tiene -error-no-empleador sea true
|
|
10353
10352
|
var errorEmpleador = value.includes("-error-no-empleador") ? true : false;
|
|
10354
10353
|
//sacar el -error-no-empleador de value
|
|
@@ -19983,7 +19982,7 @@ var Alert = function (_a) {
|
|
|
19983
19982
|
|
|
19984
19983
|
var DatePicker = function (_a) {
|
|
19985
19984
|
var id = _a.id, name = _a.name, label = _a.label, value = _a.value, onChange = _a.onChange, error = _a.error, disabled = _a.disabled, required = _a.required, placeholder = _a.placeholder, props = _a.props;
|
|
19986
|
-
return (jsxRuntime.
|
|
19985
|
+
return (jsxRuntime.jsxs(InputWrapper, { id: id, label: label, error: error, children: [jsxRuntime.jsx("input", { id: id, name: name, type: "date", value: value || "", onChange: onChange, disabled: disabled, required: required, placeholder: placeholder, max: props === null || props === void 0 ? void 0 : props.maxDate, min: props === null || props === void 0 ? void 0 : props.minDate, className: "w-full px-3 py-2 font-roboto font-normal text-gray-800 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 ".concat(error ? "border-red-500" : "border-gray-300", " ").concat(disabled ? "bg-gray-100 cursor-not-allowed" : "") }), error && jsxRuntime.jsx("p", { className: "text-red-500 text-sm", children: error })] }));
|
|
19987
19986
|
};
|
|
19988
19987
|
|
|
19989
19988
|
var SwornDeclaration = function (_a) {
|
|
@@ -23063,7 +23062,8 @@ var GenericForm = function (_a) {
|
|
|
23063
23062
|
}
|
|
23064
23063
|
}, [stepperData, config.fields]);
|
|
23065
23064
|
var handleInputChange = function (e) {
|
|
23066
|
-
var _a
|
|
23065
|
+
var _a;
|
|
23066
|
+
var _b = e.target, name = _b.name, value = _b.value, type = _b.type;
|
|
23067
23067
|
var checked = type === "checkbox" ? e.target.checked : undefined;
|
|
23068
23068
|
var newValue = type === "checkbox" ? checked : value;
|
|
23069
23069
|
// Actualizar estado local
|
|
@@ -23071,6 +23071,12 @@ var GenericForm = function (_a) {
|
|
|
23071
23071
|
var _a;
|
|
23072
23072
|
return (__assign(__assign({}, prevData), (_a = {}, _a[name] = newValue, _a)));
|
|
23073
23073
|
});
|
|
23074
|
+
if (config.onCallback) {
|
|
23075
|
+
var field = (_a = config === null || config === void 0 ? void 0 : config.fields) === null || _a === void 0 ? void 0 : _a.find(function (field) { return field.name === name; });
|
|
23076
|
+
if (field) {
|
|
23077
|
+
config.onCallback(field, newValue, __assign(__assign({}, stepperData), formData));
|
|
23078
|
+
}
|
|
23079
|
+
}
|
|
23074
23080
|
// Limpiar error del campo
|
|
23075
23081
|
if (errors[name]) {
|
|
23076
23082
|
setErrors(function (prev) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface IFormField {
|
|
|
22
22
|
value?: string | any;
|
|
23
23
|
formData?: any;
|
|
24
24
|
}) => void;
|
|
25
|
+
onCallback?: ({ value, formData, }: {
|
|
26
|
+
field?: IFormField;
|
|
27
|
+
value?: string | any;
|
|
28
|
+
formData?: any;
|
|
29
|
+
}) => void;
|
|
25
30
|
onAddressChange?: (address: any) => void;
|
|
26
31
|
showMap?: boolean;
|
|
27
32
|
mapHeight?: string;
|
|
@@ -73,6 +78,7 @@ export interface IFormConfig {
|
|
|
73
78
|
onOut?: () => void;
|
|
74
79
|
onEnd?: () => void;
|
|
75
80
|
onSearch?: (field: IFormField, value: string, formData: any) => void;
|
|
81
|
+
onCallback?: (field: IFormField, value: string | any, formData: any) => void;
|
|
76
82
|
initialData?: any;
|
|
77
83
|
}
|
|
78
84
|
export interface IStepProps {
|