@visiion/forms-library 1.4.11 → 1.4.13

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 CHANGED
@@ -10165,7 +10165,7 @@ var RadioOption = function (_a) {
10165
10165
 
10166
10166
  var TextInput = function (_a) {
10167
10167
  var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error;
10168
- return (jsx(TextInputField, { id: field.id, name: field.name, label: field.label, type: "text", placeholder: field.placeholder, value: value, onChange: onChange, helperText: error, disabled: field.disabled, color: error ? "failure" : undefined, addon: field.addon, required: field.required }));
10168
+ return (jsx(TextInputField, __assign({ id: field.id, name: field.name, label: field.label, type: field.type || "text", placeholder: field.placeholder, value: value, onChange: onChange, helperText: error, disabled: field.disabled, color: error ? "failure" : undefined, addon: field.addon, required: field.required }, field.props)));
10169
10169
  };
10170
10170
 
10171
10171
  // THIS FILE IS AUTO GENERATED
@@ -22800,6 +22800,7 @@ var createValidationSchema = function (fields) {
22800
22800
  return true;
22801
22801
  });
22802
22802
  validFields.forEach(function (field) {
22803
+ var _a, _b, _c;
22803
22804
  if (field.validations && field.validations.length > 0) {
22804
22805
  // Determinar el tipo de esquema basado en el tipo de campo
22805
22806
  var fieldSchema_1;
@@ -22808,7 +22809,7 @@ var createValidationSchema = function (fields) {
22808
22809
  case "checklist":
22809
22810
  fieldSchema_1 = create$2()
22810
22811
  .of(create$6())
22811
- .min(1, field.validations[0].params[0] ||
22812
+ .min(1, ((_c = (_b = (_a = field.validations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c[0]) ||
22812
22813
  "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
22813
22814
  break;
22814
22815
  case "declaration":
@@ -23043,7 +23044,8 @@ var GenericForm = function (_a) {
23043
23044
  }
23044
23045
  }, [stepperData, config.fields]);
23045
23046
  var handleInputChange = function (e) {
23046
- var _a = e.target, name = _a.name, value = _a.value, type = _a.type;
23047
+ var _a;
23048
+ var _b = e.target, name = _b.name, value = _b.value, type = _b.type;
23047
23049
  var checked = type === "checkbox" ? e.target.checked : undefined;
23048
23050
  var newValue = type === "checkbox" ? checked : value;
23049
23051
  // Actualizar estado local
@@ -23051,6 +23053,12 @@ var GenericForm = function (_a) {
23051
23053
  var _a;
23052
23054
  return (__assign(__assign({}, prevData), (_a = {}, _a[name] = newValue, _a)));
23053
23055
  });
23056
+ if (config.onCallback) {
23057
+ 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; });
23058
+ if (field) {
23059
+ config.onCallback(field, newValue, __assign(__assign({}, stepperData), formData));
23060
+ }
23061
+ }
23054
23062
  // Limpiar error del campo
23055
23063
  if (errors[name]) {
23056
23064
  setErrors(function (prev) {
package/dist/index.js CHANGED
@@ -10184,7 +10184,7 @@ var RadioOption = function (_a) {
10184
10184
 
10185
10185
  var TextInput = function (_a) {
10186
10186
  var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error;
10187
- return (jsxRuntime.jsx(TextInputField, { id: field.id, name: field.name, label: field.label, type: "text", placeholder: field.placeholder, value: value, onChange: onChange, helperText: error, disabled: field.disabled, color: error ? "failure" : undefined, addon: field.addon, required: field.required }));
10187
+ return (jsxRuntime.jsx(TextInputField, __assign({ id: field.id, name: field.name, label: field.label, type: field.type || "text", placeholder: field.placeholder, value: value, onChange: onChange, helperText: error, disabled: field.disabled, color: error ? "failure" : undefined, addon: field.addon, required: field.required }, field.props)));
10188
10188
  };
10189
10189
 
10190
10190
  // THIS FILE IS AUTO GENERATED
@@ -22819,6 +22819,7 @@ var createValidationSchema = function (fields) {
22819
22819
  return true;
22820
22820
  });
22821
22821
  validFields.forEach(function (field) {
22822
+ var _a, _b, _c;
22822
22823
  if (field.validations && field.validations.length > 0) {
22823
22824
  // Determinar el tipo de esquema basado en el tipo de campo
22824
22825
  var fieldSchema_1;
@@ -22827,7 +22828,7 @@ var createValidationSchema = function (fields) {
22827
22828
  case "checklist":
22828
22829
  fieldSchema_1 = create$2()
22829
22830
  .of(create$6())
22830
- .min(1, field.validations[0].params[0] ||
22831
+ .min(1, ((_c = (_b = (_a = field.validations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c[0]) ||
22831
22832
  "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
22832
22833
  break;
22833
22834
  case "declaration":
@@ -23062,7 +23063,8 @@ var GenericForm = function (_a) {
23062
23063
  }
23063
23064
  }, [stepperData, config.fields]);
23064
23065
  var handleInputChange = function (e) {
23065
- var _a = e.target, name = _a.name, value = _a.value, type = _a.type;
23066
+ var _a;
23067
+ var _b = e.target, name = _b.name, value = _b.value, type = _b.type;
23066
23068
  var checked = type === "checkbox" ? e.target.checked : undefined;
23067
23069
  var newValue = type === "checkbox" ? checked : value;
23068
23070
  // Actualizar estado local
@@ -23070,6 +23072,12 @@ var GenericForm = function (_a) {
23070
23072
  var _a;
23071
23073
  return (__assign(__assign({}, prevData), (_a = {}, _a[name] = newValue, _a)));
23072
23074
  });
23075
+ if (config.onCallback) {
23076
+ 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; });
23077
+ if (field) {
23078
+ config.onCallback(field, newValue, __assign(__assign({}, stepperData), formData));
23079
+ }
23080
+ }
23073
23081
  // Limpiar error del campo
23074
23082
  if (errors[name]) {
23075
23083
  setErrors(function (prev) {
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visiion/forms-library",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "Librería de componentes de formularios reutilizables",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",