@visiion/forms-library 1.1.4 → 1.1.5

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.
@@ -3,6 +3,7 @@ interface SubtitleInputProps {
3
3
  title?: string;
4
4
  description?: string;
5
5
  className?: string;
6
+ textClassName?: string;
6
7
  }
7
8
  declare const SubtitleInput: React.FC<SubtitleInputProps>;
8
9
  export default SubtitleInput;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface SwornDeclarationProps {
3
3
  title?: string;
4
+ name?: string;
4
5
  declarationText?: string;
5
6
  checked?: boolean;
6
7
  onChange?: (checked: boolean) => void;
package/dist/index.esm.js CHANGED
@@ -34298,8 +34298,8 @@ var GoogleMaps = function (_a) {
34298
34298
  };
34299
34299
 
34300
34300
  var SubtitleInput = function (_a) {
34301
- var title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? "" : _b;
34302
- return (jsxs("div", { className: "col-span-12 ".concat(className), children: [title && (jsx("h3", { className: "text-xl font-bold text-gray-800 mb-2", children: title })), description && jsx("p", { className: "text-gray-600 mb-4", children: description }), jsx("hr", { className: "border-gray-300 mb-4" })] }));
34301
+ var title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.textClassName, textClassName = _c === void 0 ? "pl-5 text-[24px] text-text text-xl font-bold font-roboto" : _c;
34302
+ return (jsxs("div", { className: "col-span-12 ".concat(className), children: [title && jsx("h3", { className: textClassName, children: title }), description && jsx("p", { className: "text-gray-600 mb-4", children: description }), jsx("hr", { className: "border-gray-300 mb-4" })] }));
34303
34303
  };
34304
34304
 
34305
34305
  // THIS FILE IS AUTO GENERATED
@@ -34342,15 +34342,15 @@ var DatePicker = function (_a) {
34342
34342
  };
34343
34343
 
34344
34344
  var SwornDeclaration = function (_a) {
34345
- var _b = _a.title, title = _b === void 0 ? "Declaración Jurada" : _b, _c = _a.declarationText, declarationText = _c === void 0 ? "Declaro bajo juramento ante la Dirección del Trabajo, que los antecedentes entregados son verídicos y que corresponden a la realidad. De ser falsa la presente declaración me hará incurrir en las penas establecidas en el artículo 210 del Código Penal." : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, onChange = _a.onChange, _e = _a.required, required = _e === void 0 ? true : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? "" : _g, error = _a.error;
34346
- var _h = useState(checked), isChecked = _h[0], setIsChecked = _h[1];
34345
+ var _b = _a.title, title = _b === void 0 ? "Declaración Jurada" : _b, _c = _a.name, name = _c === void 0 ? "sworn_declaration" : _c, _d = _a.declarationText, declarationText = _d === void 0 ? "Declaro bajo juramento ante la Dirección del Trabajo, que los antecedentes entregados son verídicos y que corresponden a la realidad. De ser falsa la presente declaración me hará incurrir en las penas establecidas en el artículo 210 del Código Penal." : _d, _e = _a.checked, checked = _e === void 0 ? false : _e, onChange = _a.onChange, _f = _a.required, required = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.className, className = _h === void 0 ? "" : _h, error = _a.error;
34346
+ var _j = useState(checked), isChecked = _j[0], setIsChecked = _j[1];
34347
34347
  var handleCheckboxChange = function (e) {
34348
34348
  var newChecked = e.target.checked;
34349
34349
  setIsChecked(newChecked);
34350
34350
  if (onChange) {
34351
34351
  onChange({
34352
34352
  target: {
34353
- name: "sworn_declaration",
34353
+ name: name,
34354
34354
  value: newChecked,
34355
34355
  type: "declaration",
34356
34356
  },
@@ -34363,7 +34363,7 @@ var SwornDeclaration = function (_a) {
34363
34363
  fontWeight: 500,
34364
34364
  fontSize: "14px",
34365
34365
  lineHeight: "16px",
34366
- }, children: title }), jsxs("div", { className: "flex items-start gap-3", children: [jsx("input", { type: "checkbox", id: "sworn-declaration", checked: isChecked, onChange: handleCheckboxChange, disabled: disabled, required: required, className: "mt-1 w-4 h-4 text-blue-600 bg-white border-gray-800 rounded focus:ring-blue-500 focus:ring-2 border-2 ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer") }), jsx("label", { htmlFor: "sworn-declaration", className: "text-sm text-gray-700 leading-relaxed ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: declarationText })] }), error && !isChecked && (jsx("p", { className: "text-red-500 text-sm font-bold mt-2", children: "Debe aceptar la declaraci\u00F3n jurada para continuar" }))] }));
34366
+ }, children: title }), jsxs("div", { className: "flex items-start gap-3", children: [jsx("input", { type: "checkbox", id: "sworn-declaration", name: name, checked: isChecked, onChange: handleCheckboxChange, disabled: disabled, required: required, className: "mt-1 w-4 h-4 text-blue-600 bg-white border-gray-800 rounded focus:ring-blue-500 focus:ring-2 border-2 ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer") }), jsx("label", { htmlFor: "sworn-declaration", className: "text-sm text-gray-700 leading-relaxed ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: declarationText })] }), error && !isChecked && (jsx("p", { className: "text-red-500 text-sm font-bold mt-2", children: "Debe aceptar la declaraci\u00F3n jurada para continuar" }))] }));
34367
34367
  };
34368
34368
 
34369
34369
  var StatusScreen = function (_a) {
@@ -34371,28 +34371,28 @@ var StatusScreen = function (_a) {
34371
34371
  var getStatusStyles = function () {
34372
34372
  switch (type) {
34373
34373
  case "success":
34374
- return "bg-green-50 border-green-200 text-green-800";
34374
+ return "";
34375
34375
  case "error":
34376
- return "bg-red-50 border-red-200 text-red-800";
34376
+ return "";
34377
34377
  case "warning":
34378
- return "bg-yellow-50 border-yellow-200 text-yellow-800";
34378
+ return "";
34379
34379
  default:
34380
- return "bg-blue-50 border-blue-200 text-blue-800";
34380
+ return "";
34381
34381
  }
34382
34382
  };
34383
34383
  var getIcon = function () {
34384
34384
  switch (type) {
34385
34385
  case "success":
34386
- return (jsx("svg", { className: "w-12 h-12 text-green-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34386
+ return (jsx("svg", { className: "w-28 h-28 text-green-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34387
34387
  case "error":
34388
- return (jsx("svg", { className: "w-12 h-12 text-red-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34388
+ return (jsx("svg", { className: "w-28 h-28 text-red-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34389
34389
  case "warning":
34390
- return (jsx("svg", { className: "w-12 h-12 text-yellow-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" }) }));
34390
+ return (jsx("svg", { className: "w-28 h-28 text-yellow-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" }) }));
34391
34391
  default:
34392
- return (jsx("svg", { className: "w-12 h-12 text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34392
+ return (jsx("svg", { className: "w-28 h-28 text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34393
34393
  }
34394
34394
  };
34395
- return (jsx("div", { className: "col-span-12", children: jsxs("div", { className: "flex flex-col items-center p-8 border rounded-lg ".concat(getStatusStyles()), children: [jsx("div", { className: "mb-4", children: getIcon() }), title && (jsx("h2", { className: "text-2xl font-bold text-center mb-4", children: title })), message && jsx("p", { className: "text-center mb-6 max-w-md", children: message }), (leftButton || rightButton) && (jsxs("div", { className: "flex space-x-4", children: [leftButton && (jsx("button", { onClick: leftButton.onClick, className: "px-6 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500", children: leftButton.label })), rightButton && (jsx("button", { onClick: rightButton.onClick, className: "px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500", children: rightButton.label }))] }))] }) }));
34395
+ return (jsx("div", { className: "col-span-12", children: jsxs("div", { className: "flex flex-col items-center p-8 ".concat(getStatusStyles()), children: [jsx("div", { className: "mb-4", children: getIcon() }), title && (jsx("h2", { className: "text-2xl font-bold text-center mb-4", children: title })), message && jsx("p", { className: "text-center mb-6 max-w-md", children: message }), (leftButton || rightButton) && (jsxs("div", { className: "flex space-x-4", children: [leftButton && (jsx("button", { onClick: leftButton.onClick, className: "px-6 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500", children: leftButton.label })), rightButton && (jsx("button", { onClick: rightButton.onClick, className: "px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500", children: rightButton.label }))] }))] }) }));
34396
34396
  };
34397
34397
 
34398
34398
  var DynamicInput = function (_a) {
@@ -36556,50 +36556,60 @@ create$3.prototype = ObjectSchema.prototype;
36556
36556
 
36557
36557
  var createValidationSchema = function (fields) {
36558
36558
  var schema = {};
36559
- fields.forEach(function (field) {
36559
+ // Filtrar campos válidos antes de procesarlos
36560
+ var validFields = fields.filter(function (_a) {
36561
+ var _b = _a.validate, validate = _b === void 0 ? true : _b, _c = _a.name, name = _c === void 0 ? null : _c, type = _a.type;
36560
36562
  // Excluir campos que no tienen name o son de tipos especiales
36561
- if (!field.name ||
36562
- ['subtitle', 'alert', 'status'].includes(field.type)) {
36563
- return;
36563
+ if (!name || ["subtitle", "alert", "status"].includes(type)) {
36564
+ return false;
36565
+ }
36566
+ // Excluir campos que tienen validate: false
36567
+ if (!validate) {
36568
+ return false;
36564
36569
  }
36570
+ return true;
36571
+ });
36572
+ validFields.forEach(function (field) {
36565
36573
  if (field.validations && field.validations.length > 0) {
36566
36574
  var fieldSchema_1 = create$6();
36567
36575
  field.validations.forEach(function (validation) {
36568
36576
  switch (validation.type) {
36569
- case 'required':
36570
- fieldSchema_1 = fieldSchema_1.required(validation.params[0] || 'Este campo es requerido');
36577
+ case "required":
36578
+ fieldSchema_1 = fieldSchema_1.required(validation.params[0] ||
36579
+ "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
36571
36580
  break;
36572
- case 'min':
36581
+ case "min":
36573
36582
  var minLength = parseInt(validation.params[0]);
36574
36583
  var minMessage = validation.params[1] || "M\u00EDnimo ".concat(minLength, " caracteres");
36575
36584
  fieldSchema_1 = fieldSchema_1.min(minLength, minMessage);
36576
36585
  break;
36577
- case 'max':
36586
+ case "max":
36578
36587
  var maxLength = parseInt(validation.params[0]);
36579
36588
  var maxMessage = validation.params[1] || "M\u00E1ximo ".concat(maxLength, " caracteres");
36580
36589
  fieldSchema_1 = fieldSchema_1.max(maxLength, maxMessage);
36581
36590
  break;
36582
- case 'email':
36583
- var emailMessage = validation.params[0] || 'Email inválido';
36591
+ case "email":
36592
+ var emailMessage = validation.params[0] || "Email inválido";
36584
36593
  fieldSchema_1 = fieldSchema_1.email(emailMessage);
36585
36594
  break;
36586
- case 'pattern':
36595
+ case "pattern":
36587
36596
  var pattern = new RegExp(validation.params[0]);
36588
- var patternMessage = validation.params[1] || 'Formato inválido';
36597
+ var patternMessage = validation.params[1] || "Formato inválido";
36589
36598
  fieldSchema_1 = fieldSchema_1.matches(pattern, patternMessage);
36590
36599
  break;
36591
- case 'custom':
36600
+ case "custom":
36592
36601
  // Para validaciones personalizadas
36593
36602
  var customValidator = validation.params[0];
36594
- if (customValidator === 'rut') {
36595
- fieldSchema_1 = fieldSchema_1.test('rut', validation.params[1] || 'RUT inválido', function (value) {
36603
+ if (customValidator === "rut") {
36604
+ fieldSchema_1 = fieldSchema_1.test("rut", validation.params[1] || "RUT inválido", function (value) {
36596
36605
  if (!value)
36597
36606
  return true; // Si está vacío, la validación required se encargará
36598
36607
  return validate(clean(value));
36599
36608
  });
36600
36609
  }
36601
36610
  else {
36602
- fieldSchema_1 = fieldSchema_1.test('custom', validation.params[1] || 'Validación fallida', function (value) {
36611
+ fieldSchema_1 = fieldSchema_1.test("custom", validation.params[1] ||
36612
+ "Validaci\u00F3n fallida para ".concat(field.label || field.name || "sin nombre"), function (value) {
36603
36613
  // Aquí puedes implementar lógica personalizada
36604
36614
  return value; // Por defecto pasa la validación
36605
36615
  });
@@ -36611,7 +36621,7 @@ var createValidationSchema = function (fields) {
36611
36621
  }
36612
36622
  else if (field.required) {
36613
36623
  // Validación básica de requerido si no hay validaciones específicas
36614
- schema[field.name] = create$6().required("El campo ".concat(field.label, " es requerido"));
36624
+ schema[field.name] = create$6().required("El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
36615
36625
  }
36616
36626
  });
36617
36627
  return create$3().shape(schema);
@@ -36619,24 +36629,24 @@ var createValidationSchema = function (fields) {
36619
36629
  // Validaciones predefinidas
36620
36630
  var commonValidations = {
36621
36631
  required: function (message) { return ({
36622
- type: 'required',
36623
- params: [message || 'Este campo es requerido'],
36632
+ type: "required",
36633
+ params: [message || "Este campo es requerido"],
36624
36634
  }); },
36625
36635
  min: function (length, message) { return ({
36626
- type: 'min',
36636
+ type: "min",
36627
36637
  params: [length.toString(), message || "M\u00EDnimo ".concat(length, " caracteres")],
36628
36638
  }); },
36629
36639
  max: function (length, message) { return ({
36630
- type: 'max',
36640
+ type: "max",
36631
36641
  params: [length.toString(), message || "M\u00E1ximo ".concat(length, " caracteres")],
36632
36642
  }); },
36633
36643
  email: function (message) { return ({
36634
- type: 'email',
36635
- params: [message || 'Email inválido'],
36644
+ type: "email",
36645
+ params: [message || "Email inválido"],
36636
36646
  }); },
36637
36647
  pattern: function (regex, message) { return ({
36638
- type: 'pattern',
36639
- params: [regex, message || 'Formato inválido'],
36648
+ type: "pattern",
36649
+ params: [regex, message || "Formato inválido"],
36640
36650
  }); },
36641
36651
  };
36642
36652
 
package/dist/index.js CHANGED
@@ -34318,8 +34318,8 @@ var GoogleMaps = function (_a) {
34318
34318
  };
34319
34319
 
34320
34320
  var SubtitleInput = function (_a) {
34321
- var title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? "" : _b;
34322
- return (jsxRuntime.jsxs("div", { className: "col-span-12 ".concat(className), children: [title && (jsxRuntime.jsx("h3", { className: "text-xl font-bold text-gray-800 mb-2", children: title })), description && jsxRuntime.jsx("p", { className: "text-gray-600 mb-4", children: description }), jsxRuntime.jsx("hr", { className: "border-gray-300 mb-4" })] }));
34321
+ var title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.textClassName, textClassName = _c === void 0 ? "pl-5 text-[24px] text-text text-xl font-bold font-roboto" : _c;
34322
+ return (jsxRuntime.jsxs("div", { className: "col-span-12 ".concat(className), children: [title && jsxRuntime.jsx("h3", { className: textClassName, children: title }), description && jsxRuntime.jsx("p", { className: "text-gray-600 mb-4", children: description }), jsxRuntime.jsx("hr", { className: "border-gray-300 mb-4" })] }));
34323
34323
  };
34324
34324
 
34325
34325
  // THIS FILE IS AUTO GENERATED
@@ -34362,15 +34362,15 @@ var DatePicker = function (_a) {
34362
34362
  };
34363
34363
 
34364
34364
  var SwornDeclaration = function (_a) {
34365
- var _b = _a.title, title = _b === void 0 ? "Declaración Jurada" : _b, _c = _a.declarationText, declarationText = _c === void 0 ? "Declaro bajo juramento ante la Dirección del Trabajo, que los antecedentes entregados son verídicos y que corresponden a la realidad. De ser falsa la presente declaración me hará incurrir en las penas establecidas en el artículo 210 del Código Penal." : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, onChange = _a.onChange, _e = _a.required, required = _e === void 0 ? true : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? "" : _g, error = _a.error;
34366
- var _h = React.useState(checked), isChecked = _h[0], setIsChecked = _h[1];
34365
+ var _b = _a.title, title = _b === void 0 ? "Declaración Jurada" : _b, _c = _a.name, name = _c === void 0 ? "sworn_declaration" : _c, _d = _a.declarationText, declarationText = _d === void 0 ? "Declaro bajo juramento ante la Dirección del Trabajo, que los antecedentes entregados son verídicos y que corresponden a la realidad. De ser falsa la presente declaración me hará incurrir en las penas establecidas en el artículo 210 del Código Penal." : _d, _e = _a.checked, checked = _e === void 0 ? false : _e, onChange = _a.onChange, _f = _a.required, required = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.className, className = _h === void 0 ? "" : _h, error = _a.error;
34366
+ var _j = React.useState(checked), isChecked = _j[0], setIsChecked = _j[1];
34367
34367
  var handleCheckboxChange = function (e) {
34368
34368
  var newChecked = e.target.checked;
34369
34369
  setIsChecked(newChecked);
34370
34370
  if (onChange) {
34371
34371
  onChange({
34372
34372
  target: {
34373
- name: "sworn_declaration",
34373
+ name: name,
34374
34374
  value: newChecked,
34375
34375
  type: "declaration",
34376
34376
  },
@@ -34383,7 +34383,7 @@ var SwornDeclaration = function (_a) {
34383
34383
  fontWeight: 500,
34384
34384
  fontSize: "14px",
34385
34385
  lineHeight: "16px",
34386
- }, children: title }), jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [jsxRuntime.jsx("input", { type: "checkbox", id: "sworn-declaration", checked: isChecked, onChange: handleCheckboxChange, disabled: disabled, required: required, className: "mt-1 w-4 h-4 text-blue-600 bg-white border-gray-800 rounded focus:ring-blue-500 focus:ring-2 border-2 ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer") }), jsxRuntime.jsx("label", { htmlFor: "sworn-declaration", className: "text-sm text-gray-700 leading-relaxed ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: declarationText })] }), error && !isChecked && (jsxRuntime.jsx("p", { className: "text-red-500 text-sm font-bold mt-2", children: "Debe aceptar la declaraci\u00F3n jurada para continuar" }))] }));
34386
+ }, children: title }), jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [jsxRuntime.jsx("input", { type: "checkbox", id: "sworn-declaration", name: name, checked: isChecked, onChange: handleCheckboxChange, disabled: disabled, required: required, className: "mt-1 w-4 h-4 text-blue-600 bg-white border-gray-800 rounded focus:ring-blue-500 focus:ring-2 border-2 ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer") }), jsxRuntime.jsx("label", { htmlFor: "sworn-declaration", className: "text-sm text-gray-700 leading-relaxed ".concat(disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: declarationText })] }), error && !isChecked && (jsxRuntime.jsx("p", { className: "text-red-500 text-sm font-bold mt-2", children: "Debe aceptar la declaraci\u00F3n jurada para continuar" }))] }));
34387
34387
  };
34388
34388
 
34389
34389
  var StatusScreen = function (_a) {
@@ -34391,28 +34391,28 @@ var StatusScreen = function (_a) {
34391
34391
  var getStatusStyles = function () {
34392
34392
  switch (type) {
34393
34393
  case "success":
34394
- return "bg-green-50 border-green-200 text-green-800";
34394
+ return "";
34395
34395
  case "error":
34396
- return "bg-red-50 border-red-200 text-red-800";
34396
+ return "";
34397
34397
  case "warning":
34398
- return "bg-yellow-50 border-yellow-200 text-yellow-800";
34398
+ return "";
34399
34399
  default:
34400
- return "bg-blue-50 border-blue-200 text-blue-800";
34400
+ return "";
34401
34401
  }
34402
34402
  };
34403
34403
  var getIcon = function () {
34404
34404
  switch (type) {
34405
34405
  case "success":
34406
- return (jsxRuntime.jsx("svg", { className: "w-12 h-12 text-green-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34406
+ return (jsxRuntime.jsx("svg", { className: "w-28 h-28 text-green-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34407
34407
  case "error":
34408
- return (jsxRuntime.jsx("svg", { className: "w-12 h-12 text-red-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34408
+ return (jsxRuntime.jsx("svg", { className: "w-28 h-28 text-red-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34409
34409
  case "warning":
34410
- return (jsxRuntime.jsx("svg", { className: "w-12 h-12 text-yellow-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" }) }));
34410
+ return (jsxRuntime.jsx("svg", { className: "w-28 h-28 text-yellow-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" }) }));
34411
34411
  default:
34412
- return (jsxRuntime.jsx("svg", { className: "w-12 h-12 text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34412
+ return (jsxRuntime.jsx("svg", { className: "w-28 h-28 text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }));
34413
34413
  }
34414
34414
  };
34415
- return (jsxRuntime.jsx("div", { className: "col-span-12", children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center p-8 border rounded-lg ".concat(getStatusStyles()), children: [jsxRuntime.jsx("div", { className: "mb-4", children: getIcon() }), title && (jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-center mb-4", children: title })), message && jsxRuntime.jsx("p", { className: "text-center mb-6 max-w-md", children: message }), (leftButton || rightButton) && (jsxRuntime.jsxs("div", { className: "flex space-x-4", children: [leftButton && (jsxRuntime.jsx("button", { onClick: leftButton.onClick, className: "px-6 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500", children: leftButton.label })), rightButton && (jsxRuntime.jsx("button", { onClick: rightButton.onClick, className: "px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500", children: rightButton.label }))] }))] }) }));
34415
+ return (jsxRuntime.jsx("div", { className: "col-span-12", children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center p-8 ".concat(getStatusStyles()), children: [jsxRuntime.jsx("div", { className: "mb-4", children: getIcon() }), title && (jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-center mb-4", children: title })), message && jsxRuntime.jsx("p", { className: "text-center mb-6 max-w-md", children: message }), (leftButton || rightButton) && (jsxRuntime.jsxs("div", { className: "flex space-x-4", children: [leftButton && (jsxRuntime.jsx("button", { onClick: leftButton.onClick, className: "px-6 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500", children: leftButton.label })), rightButton && (jsxRuntime.jsx("button", { onClick: rightButton.onClick, className: "px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500", children: rightButton.label }))] }))] }) }));
34416
34416
  };
34417
34417
 
34418
34418
  var DynamicInput = function (_a) {
@@ -36576,50 +36576,60 @@ create$3.prototype = ObjectSchema.prototype;
36576
36576
 
36577
36577
  var createValidationSchema = function (fields) {
36578
36578
  var schema = {};
36579
- fields.forEach(function (field) {
36579
+ // Filtrar campos válidos antes de procesarlos
36580
+ var validFields = fields.filter(function (_a) {
36581
+ var _b = _a.validate, validate = _b === void 0 ? true : _b, _c = _a.name, name = _c === void 0 ? null : _c, type = _a.type;
36580
36582
  // Excluir campos que no tienen name o son de tipos especiales
36581
- if (!field.name ||
36582
- ['subtitle', 'alert', 'status'].includes(field.type)) {
36583
- return;
36583
+ if (!name || ["subtitle", "alert", "status"].includes(type)) {
36584
+ return false;
36585
+ }
36586
+ // Excluir campos que tienen validate: false
36587
+ if (!validate) {
36588
+ return false;
36584
36589
  }
36590
+ return true;
36591
+ });
36592
+ validFields.forEach(function (field) {
36585
36593
  if (field.validations && field.validations.length > 0) {
36586
36594
  var fieldSchema_1 = create$6();
36587
36595
  field.validations.forEach(function (validation) {
36588
36596
  switch (validation.type) {
36589
- case 'required':
36590
- fieldSchema_1 = fieldSchema_1.required(validation.params[0] || 'Este campo es requerido');
36597
+ case "required":
36598
+ fieldSchema_1 = fieldSchema_1.required(validation.params[0] ||
36599
+ "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
36591
36600
  break;
36592
- case 'min':
36601
+ case "min":
36593
36602
  var minLength = parseInt(validation.params[0]);
36594
36603
  var minMessage = validation.params[1] || "M\u00EDnimo ".concat(minLength, " caracteres");
36595
36604
  fieldSchema_1 = fieldSchema_1.min(minLength, minMessage);
36596
36605
  break;
36597
- case 'max':
36606
+ case "max":
36598
36607
  var maxLength = parseInt(validation.params[0]);
36599
36608
  var maxMessage = validation.params[1] || "M\u00E1ximo ".concat(maxLength, " caracteres");
36600
36609
  fieldSchema_1 = fieldSchema_1.max(maxLength, maxMessage);
36601
36610
  break;
36602
- case 'email':
36603
- var emailMessage = validation.params[0] || 'Email inválido';
36611
+ case "email":
36612
+ var emailMessage = validation.params[0] || "Email inválido";
36604
36613
  fieldSchema_1 = fieldSchema_1.email(emailMessage);
36605
36614
  break;
36606
- case 'pattern':
36615
+ case "pattern":
36607
36616
  var pattern = new RegExp(validation.params[0]);
36608
- var patternMessage = validation.params[1] || 'Formato inválido';
36617
+ var patternMessage = validation.params[1] || "Formato inválido";
36609
36618
  fieldSchema_1 = fieldSchema_1.matches(pattern, patternMessage);
36610
36619
  break;
36611
- case 'custom':
36620
+ case "custom":
36612
36621
  // Para validaciones personalizadas
36613
36622
  var customValidator = validation.params[0];
36614
- if (customValidator === 'rut') {
36615
- fieldSchema_1 = fieldSchema_1.test('rut', validation.params[1] || 'RUT inválido', function (value) {
36623
+ if (customValidator === "rut") {
36624
+ fieldSchema_1 = fieldSchema_1.test("rut", validation.params[1] || "RUT inválido", function (value) {
36616
36625
  if (!value)
36617
36626
  return true; // Si está vacío, la validación required se encargará
36618
36627
  return validate(clean(value));
36619
36628
  });
36620
36629
  }
36621
36630
  else {
36622
- fieldSchema_1 = fieldSchema_1.test('custom', validation.params[1] || 'Validación fallida', function (value) {
36631
+ fieldSchema_1 = fieldSchema_1.test("custom", validation.params[1] ||
36632
+ "Validaci\u00F3n fallida para ".concat(field.label || field.name || "sin nombre"), function (value) {
36623
36633
  // Aquí puedes implementar lógica personalizada
36624
36634
  return value; // Por defecto pasa la validación
36625
36635
  });
@@ -36631,7 +36641,7 @@ var createValidationSchema = function (fields) {
36631
36641
  }
36632
36642
  else if (field.required) {
36633
36643
  // Validación básica de requerido si no hay validaciones específicas
36634
- schema[field.name] = create$6().required("El campo ".concat(field.label, " es requerido"));
36644
+ schema[field.name] = create$6().required("El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
36635
36645
  }
36636
36646
  });
36637
36647
  return create$3().shape(schema);
@@ -36639,24 +36649,24 @@ var createValidationSchema = function (fields) {
36639
36649
  // Validaciones predefinidas
36640
36650
  var commonValidations = {
36641
36651
  required: function (message) { return ({
36642
- type: 'required',
36643
- params: [message || 'Este campo es requerido'],
36652
+ type: "required",
36653
+ params: [message || "Este campo es requerido"],
36644
36654
  }); },
36645
36655
  min: function (length, message) { return ({
36646
- type: 'min',
36656
+ type: "min",
36647
36657
  params: [length.toString(), message || "M\u00EDnimo ".concat(length, " caracteres")],
36648
36658
  }); },
36649
36659
  max: function (length, message) { return ({
36650
- type: 'max',
36660
+ type: "max",
36651
36661
  params: [length.toString(), message || "M\u00E1ximo ".concat(length, " caracteres")],
36652
36662
  }); },
36653
36663
  email: function (message) { return ({
36654
- type: 'email',
36655
- params: [message || 'Email inválido'],
36664
+ type: "email",
36665
+ params: [message || "Email inválido"],
36656
36666
  }); },
36657
36667
  pattern: function (regex, message) { return ({
36658
- type: 'pattern',
36659
- params: [regex, message || 'Formato inválido'],
36668
+ type: "pattern",
36669
+ params: [regex, message || "Formato inválido"],
36660
36670
  }); },
36661
36671
  };
36662
36672
 
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  export interface IFormField {
3
3
  id: string;
4
- name: string;
5
- type: 'radio' | 'text' | 'select' | 'textarea' | 'checkbox' | 'rut' | 'address' | 'subtitle' | 'alert' | 'date' | 'declaration' | 'status';
4
+ name: string | null;
5
+ type: "radio" | "text" | "select" | "textarea" | "checkbox" | "rut" | "address" | "subtitle" | "alert" | "date" | "declaration" | "status";
6
6
  label: string;
7
7
  value?: string | number | null;
8
8
  options?: Array<{
@@ -16,6 +16,7 @@ export interface IFormField {
16
16
  minLength?: number;
17
17
  maxLength?: number;
18
18
  className?: string;
19
+ validate?: boolean;
19
20
  onSearch?: (value: string | any) => void;
20
21
  onAddressChange?: (address: any) => void;
21
22
  showMap?: boolean;
@@ -25,7 +26,7 @@ export interface IFormField {
25
26
  message?: string;
26
27
  };
27
28
  validations?: Array<{
28
- type: 'required' | 'min' | 'max' | 'email' | 'pattern' | 'custom';
29
+ type: "required" | "min" | "max" | "email" | "pattern" | "custom";
29
30
  params: string[];
30
31
  }>;
31
32
  tooltip?: string;
@@ -40,7 +41,7 @@ export interface IFormConfig {
40
41
  showInfoAlert?: boolean;
41
42
  steps?: any;
42
43
  infoMessage?: {
43
- type: string | 'info' | 'warning' | 'error';
44
+ type: string | "info" | "warning" | "error";
44
45
  message: string | null;
45
46
  };
46
47
  fields: IFormField[];
@@ -48,7 +49,7 @@ export interface IFormConfig {
48
49
  containerClass?: string;
49
50
  buttons?: {
50
51
  key: string;
51
- direction: string | 'next' | 'back' | 'success' | 'guardar' | 'out';
52
+ direction: string | "next" | "back" | "success" | "guardar" | "out";
52
53
  label: string;
53
54
  onClick: string;
54
55
  show: boolean;
@@ -80,7 +81,7 @@ export interface ResponseOnSearch {
80
81
  nextStep?: string | null;
81
82
  }
82
83
  export interface NavigationButtonProps {
83
- direction: 'default' | 'next' | 'back' | 'success' | 'guardar' | 'out' | 'out-light';
84
+ direction: "default" | "next" | "back" | "success" | "guardar" | "out" | "out-light";
84
85
  onClick: (e: React.FormEvent) => void;
85
86
  disabled?: boolean;
86
87
  label?: string;
@@ -106,7 +107,7 @@ export interface StepperContextType {
106
107
  currentDate: Date | null;
107
108
  }
108
109
  export interface ValidationRule {
109
- type: 'required' | 'min' | 'max' | 'email' | 'pattern' | 'custom';
110
+ type: "required" | "min" | "max" | "email" | "pattern" | "custom";
110
111
  params: string[];
111
112
  }
112
113
  export interface CommonValidations {
@@ -1,5 +1,5 @@
1
- import * as Yup from 'yup';
2
- import { IFormField, CommonValidations } from '../types';
1
+ import * as Yup from "yup";
2
+ import { IFormField, CommonValidations } from "../types";
3
3
  export declare const createValidationSchema: (fields: IFormField[]) => Yup.ObjectSchema<{
4
4
  [x: string]: any;
5
5
  }, Yup.AnyObject, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visiion/forms-library",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Librería de componentes de formularios reutilizables",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",