@visiion/forms-library 1.4.1 → 1.4.2
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/Inputs/Checklist.d.ts +11 -0
- package/dist/components/Inputs/DynamicInput.d.ts +1 -0
- package/dist/components/Inputs/Upload.d.ts +10 -0
- package/dist/components/Pdf/index.d.ts +14 -0
- package/dist/components/Pdf/pdf.d.ts +15 -0
- package/dist/index.esm.js +453 -20
- package/dist/index.js +453 -20
- package/dist/types/index.d.ts +4 -3
- package/dist/utils/Common.d.ts +5 -4
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -102,6 +102,16 @@ function __generator(thisArg, body) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
function __spreadArray(to, from, pack) {
|
|
106
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
107
|
+
if (ar || !(i in from)) {
|
|
108
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
109
|
+
ar[i] = from[i];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
113
|
+
}
|
|
114
|
+
|
|
105
115
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
106
116
|
var e = new Error(message);
|
|
107
117
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -10200,7 +10210,12 @@ var SelectInput = function (_a) {
|
|
|
10200
10210
|
var RadioInput = function (_a) {
|
|
10201
10211
|
var _b;
|
|
10202
10212
|
var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error;
|
|
10203
|
-
|
|
10213
|
+
var handleSearch = function (e) {
|
|
10214
|
+
var _a;
|
|
10215
|
+
onChange(e);
|
|
10216
|
+
(_a = field === null || field === void 0 ? void 0 : field.onSearch) === null || _a === void 0 ? void 0 : _a.call(field, e.target.value);
|
|
10217
|
+
};
|
|
10218
|
+
return (jsxRuntime.jsxs(InputWrapper, __assign({}, field, { error: error, children: [jsxRuntime.jsx("div", { className: "space-y-2", children: (_b = field.options) === null || _b === void 0 ? void 0 : _b.map(function (option) { return (jsxRuntime.jsx(RadioOption, { id: "".concat(field.id, "-").concat(option.value), name: field.name, value: option.value, checked: value === option.value, onChange: handleSearch, label: option.label }, option.value)); }) }), error && jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: error })] })));
|
|
10204
10219
|
};
|
|
10205
10220
|
|
|
10206
10221
|
var TextareaInput = function (_a) {
|
|
@@ -10227,7 +10242,7 @@ var TextareaInput = function (_a) {
|
|
|
10227
10242
|
}
|
|
10228
10243
|
}
|
|
10229
10244
|
};
|
|
10230
|
-
return (jsxRuntime.jsx(InputWrapper, { id: finalId || "", label: finalLabel || "", tooltip: finalTooltip, error: error, children: jsxRuntime.jsxs("div", { className: "space-y-2", children: [jsxRuntime.jsx(flowbiteReact.Textarea, { id: finalId, name: finalName, placeholder: finalPlaceholder, value: value, onChange: handleChange, disabled: finalDisabled, required: finalRequired, rows: rows, className: "".concat(className || "", " resize-none bg-white"), color: error ? "failure" : undefined }), jsxRuntime.jsxs("div", { className: "flex justify-between", children: [jsxRuntime.jsx("span", { className: " text-sm text-red-500 font-bold", children: error }), jsxRuntime.jsxs("div", { className: " justify-end text-gray-400 text-sm", children: [charCount, "/", finalMaxLength] })] })] }) }));
|
|
10245
|
+
return (jsxRuntime.jsx(InputWrapper, { id: finalId || "", label: finalLabel || "", tooltip: finalTooltip, error: error, children: jsxRuntime.jsxs("div", { className: "space-y-2", children: [jsxRuntime.jsx(flowbiteReact.Textarea, { id: finalId, name: finalName, placeholder: finalPlaceholder, value: value || "", onChange: handleChange, disabled: finalDisabled, required: finalRequired, rows: rows, className: "".concat(className || "", " resize-none bg-white"), color: error ? "failure" : undefined }), jsxRuntime.jsxs("div", { className: "flex justify-between", children: [jsxRuntime.jsx("span", { className: " text-sm text-red-500 font-bold", children: error }), jsxRuntime.jsxs("div", { className: " justify-end text-gray-400 text-sm", children: [charCount, "/", finalMaxLength] })] })] }) }));
|
|
10231
10246
|
};
|
|
10232
10247
|
|
|
10233
10248
|
var CheckboxInput = function (_a) {
|
|
@@ -19672,27 +19687,40 @@ var useMiDt = create(function (set) { return ({
|
|
|
19672
19687
|
var Common = /** @class */ (function () {
|
|
19673
19688
|
function Common() {
|
|
19674
19689
|
}
|
|
19690
|
+
// Función para limpiar acentos de un texto
|
|
19691
|
+
Common.removeAccents = function (text) {
|
|
19692
|
+
return text
|
|
19693
|
+
.normalize("NFD")
|
|
19694
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
19695
|
+
.toLowerCase();
|
|
19696
|
+
};
|
|
19675
19697
|
// Función para obtener región por nombre
|
|
19676
19698
|
Common.getRegionByName = function (regionName, regiones) {
|
|
19699
|
+
var _this = this;
|
|
19700
|
+
var _a;
|
|
19677
19701
|
if (!regiones || !Array.isArray(regiones))
|
|
19678
19702
|
return null;
|
|
19703
|
+
var cleanRegionName = this.removeAccents(regionName);
|
|
19679
19704
|
var region = regiones.find(function (r) {
|
|
19680
|
-
var
|
|
19681
|
-
return (
|
|
19682
|
-
|
|
19705
|
+
var cleanRegionNombre = _this.removeAccents(r.Nombre || "");
|
|
19706
|
+
return (cleanRegionNombre.includes(cleanRegionName) ||
|
|
19707
|
+
cleanRegionName.includes(cleanRegionNombre));
|
|
19683
19708
|
});
|
|
19684
|
-
return region ? region.
|
|
19709
|
+
return (_a = region === null || region === void 0 ? void 0 : region.Codigo) !== null && _a !== void 0 ? _a : null;
|
|
19685
19710
|
};
|
|
19686
19711
|
// Función para obtener comuna por nombre
|
|
19687
19712
|
Common.getComunaByName = function (comunaName, comunas) {
|
|
19713
|
+
var _this = this;
|
|
19714
|
+
var _a;
|
|
19688
19715
|
if (!comunas || !Array.isArray(comunas))
|
|
19689
19716
|
return null;
|
|
19717
|
+
var cleanComunaName = this.removeAccents(comunaName);
|
|
19690
19718
|
var comuna = comunas.find(function (c) {
|
|
19691
|
-
var
|
|
19692
|
-
return (
|
|
19693
|
-
|
|
19719
|
+
var cleanComunaNombre = _this.removeAccents(c.Nombre || "");
|
|
19720
|
+
return (cleanComunaNombre.includes(cleanComunaName) ||
|
|
19721
|
+
cleanComunaName.includes(cleanComunaNombre));
|
|
19694
19722
|
});
|
|
19695
|
-
return comuna ? comuna.
|
|
19723
|
+
return (_a = comuna === null || comuna === void 0 ? void 0 : comuna.Codigo) !== null && _a !== void 0 ? _a : null;
|
|
19696
19724
|
};
|
|
19697
19725
|
// Función para obtener región por ID de comuna
|
|
19698
19726
|
Common.getRegionIdByComunaId = function (comunaId, comunas) {
|
|
@@ -19904,7 +19932,7 @@ var GoogleMaps = function (_a) {
|
|
|
19904
19932
|
};
|
|
19905
19933
|
|
|
19906
19934
|
var SubtitleInput = function (_a) {
|
|
19907
|
-
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;
|
|
19935
|
+
var title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.textClassName, textClassName = _c === void 0 ? "pl-5 pb-2 text-[24px] text-text text-xl font-bold font-roboto" : _c;
|
|
19908
19936
|
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" })] }));
|
|
19909
19937
|
};
|
|
19910
19938
|
|
|
@@ -20007,8 +20035,148 @@ var Typography = function (_a) {
|
|
|
20007
20035
|
return (jsxRuntime.jsx("div", { className: (_b = props === null || props === void 0 ? void 0 : props.className) !== null && _b !== void 0 ? _b : "text-sm text font-medium", children: label }));
|
|
20008
20036
|
};
|
|
20009
20037
|
|
|
20038
|
+
var Checklist = function (_a) {
|
|
20039
|
+
var field = _a.field, _b = _a.value, value = _b === void 0 ? [] : _b, onChange = _a.onChange, error = _a.error, props = _a.props;
|
|
20040
|
+
var _c = React.useState(value), selectedOptions = _c[0], setSelectedOptions = _c[1];
|
|
20041
|
+
var _d = React.useState(props.valueOtraMedida), otraMedida = _d[0], setOtraMedida = _d[1];
|
|
20042
|
+
var options = field.options || [];
|
|
20043
|
+
React.useEffect(function () {
|
|
20044
|
+
setSelectedOptions(value);
|
|
20045
|
+
}, [value]);
|
|
20046
|
+
var handleOptionChange = function (optionValue, checked) {
|
|
20047
|
+
var newSelectedOptions;
|
|
20048
|
+
if (checked) {
|
|
20049
|
+
// Validaciones específicas para separación de espacios vs total
|
|
20050
|
+
if (optionValue === "separacion-espacios" &&
|
|
20051
|
+
selectedOptions.includes("separacion-total")) {
|
|
20052
|
+
// Si selecciona separación de espacios, remover separación total
|
|
20053
|
+
newSelectedOptions = selectedOptions.filter(function (opt) { return opt !== "separacion-total"; });
|
|
20054
|
+
}
|
|
20055
|
+
else if (optionValue === "separacion-total" &&
|
|
20056
|
+
selectedOptions.includes("separacion-espacios")) {
|
|
20057
|
+
// Si selecciona separación total, remover separación de espacios
|
|
20058
|
+
newSelectedOptions = selectedOptions.filter(function (opt) { return opt !== "separacion-espacios"; });
|
|
20059
|
+
}
|
|
20060
|
+
else {
|
|
20061
|
+
newSelectedOptions = __spreadArray(__spreadArray([], selectedOptions, true), [optionValue], false);
|
|
20062
|
+
}
|
|
20063
|
+
}
|
|
20064
|
+
else {
|
|
20065
|
+
newSelectedOptions = selectedOptions.filter(function (opt) { return opt !== optionValue; });
|
|
20066
|
+
}
|
|
20067
|
+
setSelectedOptions(newSelectedOptions);
|
|
20068
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newSelectedOptions);
|
|
20069
|
+
};
|
|
20070
|
+
var handleOtraMedidaChange = function (text) {
|
|
20071
|
+
var _a;
|
|
20072
|
+
setOtraMedida(text);
|
|
20073
|
+
// Actualizar el valor con la otra medida
|
|
20074
|
+
var updatedOptions = selectedOptions.filter(function (opt) { return opt !== "otra-medida"; });
|
|
20075
|
+
if (text.trim()) {
|
|
20076
|
+
updatedOptions.push("otra-medida");
|
|
20077
|
+
}
|
|
20078
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(updatedOptions);
|
|
20079
|
+
(_a = props.onOtraMedidaChange) === null || _a === void 0 ? void 0 : _a.call(props, text);
|
|
20080
|
+
};
|
|
20081
|
+
var isOtraMedidaRequired = selectedOptions.includes("otra-medida");
|
|
20082
|
+
return (jsxRuntime.jsxs("div", { className: "space-y-4", children: [jsxRuntime.jsx("div", { className: "space-y-2", children: options.map(function (option) { return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("input", { type: "checkbox", checked: selectedOptions.includes(option.value), onChange: function (e) {
|
|
20083
|
+
return handleOptionChange(option.value, e.target.checked);
|
|
20084
|
+
}, className: "w-4 h-4 text-orange-600 border-gray-800 rounded focus:ring-orange-500 bg-white border-2" }), jsxRuntime.jsx("label", { className: "font-normal text-text font-roboto font-normal font-weight-400 text-sm leading-4 text-gray-600", children: option.label })] }, option.value)); }) }), isOtraMedidaRequired && (jsxRuntime.jsx("div", { className: "mt-4", children: jsxRuntime.jsx("input", { type: "text", value: otraMedida, onChange: function (e) { return handleOtraMedidaChange(e.target.value); }, placeholder: "-", maxLength: 100, className: "w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" }) })), error && jsxRuntime.jsx("div", { className: "text-red-600 text-sm mt-2", children: error })] }));
|
|
20085
|
+
};
|
|
20086
|
+
|
|
20087
|
+
var Upload = function (_a) {
|
|
20088
|
+
_a.field; var value = _a.value, onChange = _a.onChange, error = _a.error;
|
|
20089
|
+
var _b = React.useState({
|
|
20090
|
+
file: value || null,
|
|
20091
|
+
error: null,
|
|
20092
|
+
isDragOver: false,
|
|
20093
|
+
}), state = _b[0], setState = _b[1];
|
|
20094
|
+
var fileInputRef = React.useRef(null);
|
|
20095
|
+
var dropZoneRef = React.useRef(null);
|
|
20096
|
+
var validateFile = function (file) {
|
|
20097
|
+
// Validar formato PDF
|
|
20098
|
+
if (file.type !== "application/pdf") {
|
|
20099
|
+
return "Formato no es PDF";
|
|
20100
|
+
}
|
|
20101
|
+
// Validar tamaño máximo (5MB = 5 * 1024 * 1024 bytes)
|
|
20102
|
+
var maxSize = 5 * 1024 * 1024;
|
|
20103
|
+
if (file.size > maxSize) {
|
|
20104
|
+
return "Archivo supera los 5MB";
|
|
20105
|
+
}
|
|
20106
|
+
return null;
|
|
20107
|
+
};
|
|
20108
|
+
var handleFileSelect = React.useCallback(function (file) {
|
|
20109
|
+
var validationError = validateFile(file);
|
|
20110
|
+
if (validationError) {
|
|
20111
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { file: null, error: validationError })); });
|
|
20112
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
20113
|
+
}
|
|
20114
|
+
else {
|
|
20115
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { file: file, error: null })); });
|
|
20116
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(file);
|
|
20117
|
+
}
|
|
20118
|
+
}, [onChange]);
|
|
20119
|
+
var handleFileInputChange = function (event) {
|
|
20120
|
+
var _a;
|
|
20121
|
+
var file = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
20122
|
+
if (file) {
|
|
20123
|
+
handleFileSelect(file);
|
|
20124
|
+
}
|
|
20125
|
+
};
|
|
20126
|
+
var handleDrop = React.useCallback(function (event) {
|
|
20127
|
+
event.preventDefault();
|
|
20128
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { isDragOver: false })); });
|
|
20129
|
+
var file = event.dataTransfer.files[0];
|
|
20130
|
+
if (file) {
|
|
20131
|
+
handleFileSelect(file);
|
|
20132
|
+
}
|
|
20133
|
+
}, [handleFileSelect]);
|
|
20134
|
+
var handleDragOver = React.useCallback(function (event) {
|
|
20135
|
+
event.preventDefault();
|
|
20136
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { isDragOver: true })); });
|
|
20137
|
+
}, []);
|
|
20138
|
+
var handleDragLeave = React.useCallback(function (event) {
|
|
20139
|
+
event.preventDefault();
|
|
20140
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { isDragOver: false })); });
|
|
20141
|
+
}, []);
|
|
20142
|
+
var handleRemoveFile = function () {
|
|
20143
|
+
setState(function (prev) { return (__assign(__assign({}, prev), { file: null, error: null })); });
|
|
20144
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
20145
|
+
if (fileInputRef.current) {
|
|
20146
|
+
fileInputRef.current.value = "";
|
|
20147
|
+
}
|
|
20148
|
+
};
|
|
20149
|
+
var handleUploadClick = function () {
|
|
20150
|
+
var _a;
|
|
20151
|
+
(_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
20152
|
+
};
|
|
20153
|
+
var formatFileSize = function (bytes) {
|
|
20154
|
+
if (bytes === 0)
|
|
20155
|
+
return "0 Bytes";
|
|
20156
|
+
var k = 1024;
|
|
20157
|
+
var sizes = ["Bytes", "KB", "MB", "GB"];
|
|
20158
|
+
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
20159
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
20160
|
+
};
|
|
20161
|
+
var renderUploadZone = function () {
|
|
20162
|
+
var hasError = state.error || error;
|
|
20163
|
+
var isErrorState = hasError && !state.file;
|
|
20164
|
+
return (jsxRuntime.jsxs("div", { ref: dropZoneRef, className: "\n relative border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors\n ".concat(isErrorState
|
|
20165
|
+
? "border-red-500 bg-red-50"
|
|
20166
|
+
: state.isDragOver
|
|
20167
|
+
? "border-blue-500 bg-blue-50"
|
|
20168
|
+
: "border-gray-300 hover:border-gray-400", "\n "), onDrop: handleDrop, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onClick: handleUploadClick, children: [jsxRuntime.jsx("input", { ref: fileInputRef, type: "file", accept: ".pdf", onChange: handleFileInputChange, className: "hidden" }), jsxRuntime.jsx("div", { className: "\n w-20 h-12 mx-auto mb-4 rounded-lg flex items-center justify-center\n ".concat(isErrorState ? "bg-red-500" : "bg-blue", "\n "), children: jsxRuntime.jsx("svg", { width: "25", height: "25", viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M18.5 15.5005V18.5005H6.5V15.5005H4.5V18.5005C4.5 19.6005 5.4 20.5005 6.5 20.5005H18.5C19.6 20.5005 20.5 19.6005 20.5 18.5005V15.5005H18.5ZM7.5 9.50049L8.91 10.9105L11.5 8.33049V16.5005H13.5V8.33049L16.09 10.9105L17.5 9.50049L12.5 4.50049L7.5 9.50049Z", fill: "white" }) }) }), jsxRuntime.jsx("h3", { className: "\n text-lg font-semibold mb-2\n ".concat(isErrorState ? "text-red-600" : "text-gray-700", "\n "), children: isErrorState ? "Error" : "Sube tu archivo" }), jsxRuntime.jsx("p", { className: "\n text-sm\n ".concat(isErrorState ? "text-red-500" : "text-gray-500", "\n "), children: isErrorState ? state.error : "Formato PDF y máximo 5MB" })] }));
|
|
20169
|
+
};
|
|
20170
|
+
var renderFilePreview = function () {
|
|
20171
|
+
if (!state.file)
|
|
20172
|
+
return null;
|
|
20173
|
+
return (jsxRuntime.jsx("div", { className: "bg-white border border-gray-200 rounded-lg p-4 shadow-sm", children: jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntime.jsxs("div", { className: "flex items-center space-x-3", children: [jsxRuntime.jsx("div", { className: "w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center", children: jsxRuntime.jsx("svg", { className: "w-6 h-6 text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) }) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900", children: state.file.name }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500", children: formatFileSize(state.file.size) })] })] }), jsxRuntime.jsxs("button", { onClick: handleRemoveFile, className: "px-3 py-1 bg-red-500 text-white text-sm rounded hover:bg-red-600 transition-colors flex items-center space-x-1", children: [jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" }) }), jsxRuntime.jsx("span", { children: "Eliminar" })] })] }) }));
|
|
20174
|
+
};
|
|
20175
|
+
return (jsxRuntime.jsxs("div", { className: "space-y-4", children: [state.file ? renderFilePreview() : renderUploadZone(), error && !state.error && jsxRuntime.jsx("p", { className: "text-sm text-red-600", children: error })] }));
|
|
20176
|
+
};
|
|
20177
|
+
|
|
20010
20178
|
var DynamicInput = function (_a) {
|
|
20011
|
-
var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error;
|
|
20179
|
+
var field = _a.field, value = _a.value, onChange = _a.onChange, error = _a.error, formData = _a.formData;
|
|
20012
20180
|
switch (field.type) {
|
|
20013
20181
|
case "status":
|
|
20014
20182
|
return (jsxRuntime.jsx(StatusScreen, __assign({}, field, { title: field.props.title, message: field.props.message, type: field.props.type, leftButton: field.props.leftButton, rightButton: field.props.rightButton })));
|
|
@@ -20028,6 +20196,39 @@ var DynamicInput = function (_a) {
|
|
|
20028
20196
|
return jsxRuntime.jsx(Typography, __assign({}, field));
|
|
20029
20197
|
case "checkbox":
|
|
20030
20198
|
return (jsxRuntime.jsx(CheckboxInput, { field: field, value: value, onChange: onChange, error: error }));
|
|
20199
|
+
case "checklist":
|
|
20200
|
+
return (jsxRuntime.jsx(Checklist, { field: field, value: value, onChange: function (newValue) {
|
|
20201
|
+
// Convertir el array de strings a un evento de cambio
|
|
20202
|
+
var event = {
|
|
20203
|
+
target: {
|
|
20204
|
+
name: field.name,
|
|
20205
|
+
value: newValue,
|
|
20206
|
+
},
|
|
20207
|
+
};
|
|
20208
|
+
onChange(event);
|
|
20209
|
+
}, error: error, props: {
|
|
20210
|
+
valueOtraMedida: formData["otraMedida"] || "",
|
|
20211
|
+
onOtraMedidaChange: function (text) {
|
|
20212
|
+
var event = {
|
|
20213
|
+
target: {
|
|
20214
|
+
name: "otraMedida",
|
|
20215
|
+
value: text,
|
|
20216
|
+
},
|
|
20217
|
+
};
|
|
20218
|
+
onChange(event);
|
|
20219
|
+
},
|
|
20220
|
+
} }));
|
|
20221
|
+
case "upload":
|
|
20222
|
+
return (jsxRuntime.jsx(Upload, { field: field, value: value, onChange: function (file) {
|
|
20223
|
+
// Convertir el archivo a un evento de cambio
|
|
20224
|
+
var event = {
|
|
20225
|
+
target: {
|
|
20226
|
+
name: field.name,
|
|
20227
|
+
value: file,
|
|
20228
|
+
},
|
|
20229
|
+
};
|
|
20230
|
+
onChange(event);
|
|
20231
|
+
}, error: error }));
|
|
20031
20232
|
case "rut":
|
|
20032
20233
|
return (jsxRuntime.jsx(RutInput, { field: field, value: value, onChange: onChange, error: error, onSearch: field.onSearch, disabled: field.disabled, placeholder: field.placeholder, minLength: field.minLength, maxLength: field.maxLength }));
|
|
20033
20234
|
case "address":
|
|
@@ -21428,6 +21629,23 @@ for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At
|
|
|
21428
21629
|
for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
|
|
21429
21630
|
for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
|
|
21430
21631
|
|
|
21632
|
+
const returnsTrue = () => true;
|
|
21633
|
+
function create$8(spec) {
|
|
21634
|
+
return new MixedSchema(spec);
|
|
21635
|
+
}
|
|
21636
|
+
class MixedSchema extends Schema {
|
|
21637
|
+
constructor(spec) {
|
|
21638
|
+
super(typeof spec === 'function' ? {
|
|
21639
|
+
type: 'mixed',
|
|
21640
|
+
check: spec
|
|
21641
|
+
} : Object.assign({
|
|
21642
|
+
type: 'mixed',
|
|
21643
|
+
check: returnsTrue
|
|
21644
|
+
}, spec));
|
|
21645
|
+
}
|
|
21646
|
+
}
|
|
21647
|
+
create$8.prototype = MixedSchema.prototype;
|
|
21648
|
+
|
|
21431
21649
|
/**
|
|
21432
21650
|
* This file is a modified version of the file from the following repository:
|
|
21433
21651
|
* Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
|
|
@@ -22172,6 +22390,189 @@ class ObjectSchema extends Schema {
|
|
|
22172
22390
|
}
|
|
22173
22391
|
create$3.prototype = ObjectSchema.prototype;
|
|
22174
22392
|
|
|
22393
|
+
function create$2(type) {
|
|
22394
|
+
return new ArraySchema(type);
|
|
22395
|
+
}
|
|
22396
|
+
class ArraySchema extends Schema {
|
|
22397
|
+
constructor(type) {
|
|
22398
|
+
super({
|
|
22399
|
+
type: 'array',
|
|
22400
|
+
spec: {
|
|
22401
|
+
types: type
|
|
22402
|
+
},
|
|
22403
|
+
check(v) {
|
|
22404
|
+
return Array.isArray(v);
|
|
22405
|
+
}
|
|
22406
|
+
});
|
|
22407
|
+
|
|
22408
|
+
// `undefined` specifically means uninitialized, as opposed to "no subtype"
|
|
22409
|
+
this.innerType = void 0;
|
|
22410
|
+
this.innerType = type;
|
|
22411
|
+
}
|
|
22412
|
+
_cast(_value, _opts) {
|
|
22413
|
+
const value = super._cast(_value, _opts);
|
|
22414
|
+
|
|
22415
|
+
// should ignore nulls here
|
|
22416
|
+
if (!this._typeCheck(value) || !this.innerType) {
|
|
22417
|
+
return value;
|
|
22418
|
+
}
|
|
22419
|
+
let isChanged = false;
|
|
22420
|
+
const castArray = value.map((v, idx) => {
|
|
22421
|
+
const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
|
|
22422
|
+
path: `${_opts.path || ''}[${idx}]`
|
|
22423
|
+
}));
|
|
22424
|
+
if (castElement !== v) {
|
|
22425
|
+
isChanged = true;
|
|
22426
|
+
}
|
|
22427
|
+
return castElement;
|
|
22428
|
+
});
|
|
22429
|
+
return isChanged ? castArray : value;
|
|
22430
|
+
}
|
|
22431
|
+
_validate(_value, options = {}, panic, next) {
|
|
22432
|
+
var _options$recursive;
|
|
22433
|
+
// let sync = options.sync;
|
|
22434
|
+
// let path = options.path;
|
|
22435
|
+
let innerType = this.innerType;
|
|
22436
|
+
// let endEarly = options.abortEarly ?? this.spec.abortEarly;
|
|
22437
|
+
let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
|
|
22438
|
+
options.originalValue != null ? options.originalValue : _value;
|
|
22439
|
+
super._validate(_value, options, panic, (arrayErrors, value) => {
|
|
22440
|
+
var _options$originalValu2;
|
|
22441
|
+
if (!recursive || !innerType || !this._typeCheck(value)) {
|
|
22442
|
+
next(arrayErrors, value);
|
|
22443
|
+
return;
|
|
22444
|
+
}
|
|
22445
|
+
|
|
22446
|
+
// #950 Ensure that sparse array empty slots are validated
|
|
22447
|
+
let tests = new Array(value.length);
|
|
22448
|
+
for (let index = 0; index < value.length; index++) {
|
|
22449
|
+
var _options$originalValu;
|
|
22450
|
+
tests[index] = innerType.asNestedTest({
|
|
22451
|
+
options,
|
|
22452
|
+
index,
|
|
22453
|
+
parent: value,
|
|
22454
|
+
parentPath: options.path,
|
|
22455
|
+
originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
|
|
22456
|
+
});
|
|
22457
|
+
}
|
|
22458
|
+
this.runTests({
|
|
22459
|
+
value,
|
|
22460
|
+
tests,
|
|
22461
|
+
originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
|
|
22462
|
+
options
|
|
22463
|
+
}, panic, innerTypeErrors => next(innerTypeErrors.concat(arrayErrors), value));
|
|
22464
|
+
});
|
|
22465
|
+
}
|
|
22466
|
+
clone(spec) {
|
|
22467
|
+
const next = super.clone(spec);
|
|
22468
|
+
// @ts-expect-error readonly
|
|
22469
|
+
next.innerType = this.innerType;
|
|
22470
|
+
return next;
|
|
22471
|
+
}
|
|
22472
|
+
|
|
22473
|
+
/** Parse an input JSON string to an object */
|
|
22474
|
+
json() {
|
|
22475
|
+
return this.transform(parseJson);
|
|
22476
|
+
}
|
|
22477
|
+
concat(schema) {
|
|
22478
|
+
let next = super.concat(schema);
|
|
22479
|
+
|
|
22480
|
+
// @ts-expect-error readonly
|
|
22481
|
+
next.innerType = this.innerType;
|
|
22482
|
+
if (schema.innerType)
|
|
22483
|
+
// @ts-expect-error readonly
|
|
22484
|
+
next.innerType = next.innerType ?
|
|
22485
|
+
// @ts-expect-error Lazy doesn't have concat and will break
|
|
22486
|
+
next.innerType.concat(schema.innerType) : schema.innerType;
|
|
22487
|
+
return next;
|
|
22488
|
+
}
|
|
22489
|
+
of(schema) {
|
|
22490
|
+
// FIXME: this should return a new instance of array without the default to be
|
|
22491
|
+
let next = this.clone();
|
|
22492
|
+
if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema));
|
|
22493
|
+
|
|
22494
|
+
// @ts-expect-error readonly
|
|
22495
|
+
next.innerType = schema;
|
|
22496
|
+
next.spec = Object.assign({}, next.spec, {
|
|
22497
|
+
types: schema
|
|
22498
|
+
});
|
|
22499
|
+
return next;
|
|
22500
|
+
}
|
|
22501
|
+
length(length, message = array.length) {
|
|
22502
|
+
return this.test({
|
|
22503
|
+
message,
|
|
22504
|
+
name: 'length',
|
|
22505
|
+
exclusive: true,
|
|
22506
|
+
params: {
|
|
22507
|
+
length
|
|
22508
|
+
},
|
|
22509
|
+
skipAbsent: true,
|
|
22510
|
+
test(value) {
|
|
22511
|
+
return value.length === this.resolve(length);
|
|
22512
|
+
}
|
|
22513
|
+
});
|
|
22514
|
+
}
|
|
22515
|
+
min(min, message) {
|
|
22516
|
+
message = message || array.min;
|
|
22517
|
+
return this.test({
|
|
22518
|
+
message,
|
|
22519
|
+
name: 'min',
|
|
22520
|
+
exclusive: true,
|
|
22521
|
+
params: {
|
|
22522
|
+
min
|
|
22523
|
+
},
|
|
22524
|
+
skipAbsent: true,
|
|
22525
|
+
// FIXME(ts): Array<typeof T>
|
|
22526
|
+
test(value) {
|
|
22527
|
+
return value.length >= this.resolve(min);
|
|
22528
|
+
}
|
|
22529
|
+
});
|
|
22530
|
+
}
|
|
22531
|
+
max(max, message) {
|
|
22532
|
+
message = message || array.max;
|
|
22533
|
+
return this.test({
|
|
22534
|
+
message,
|
|
22535
|
+
name: 'max',
|
|
22536
|
+
exclusive: true,
|
|
22537
|
+
params: {
|
|
22538
|
+
max
|
|
22539
|
+
},
|
|
22540
|
+
skipAbsent: true,
|
|
22541
|
+
test(value) {
|
|
22542
|
+
return value.length <= this.resolve(max);
|
|
22543
|
+
}
|
|
22544
|
+
});
|
|
22545
|
+
}
|
|
22546
|
+
ensure() {
|
|
22547
|
+
return this.default(() => []).transform((val, original) => {
|
|
22548
|
+
// We don't want to return `null` for nullable schema
|
|
22549
|
+
if (this._typeCheck(val)) return val;
|
|
22550
|
+
return original == null ? [] : [].concat(original);
|
|
22551
|
+
});
|
|
22552
|
+
}
|
|
22553
|
+
compact(rejector) {
|
|
22554
|
+
let reject = !rejector ? v => !!v : (v, i, a) => !rejector(v, i, a);
|
|
22555
|
+
return this.transform(values => values != null ? values.filter(reject) : values);
|
|
22556
|
+
}
|
|
22557
|
+
describe(options) {
|
|
22558
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
22559
|
+
const base = super.describe(options);
|
|
22560
|
+
if (next.innerType) {
|
|
22561
|
+
var _innerOptions;
|
|
22562
|
+
let innerOptions = options;
|
|
22563
|
+
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
22564
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
22565
|
+
parent: innerOptions.value,
|
|
22566
|
+
value: innerOptions.value[0]
|
|
22567
|
+
});
|
|
22568
|
+
}
|
|
22569
|
+
base.innerType = next.innerType.describe(innerOptions);
|
|
22570
|
+
}
|
|
22571
|
+
return base;
|
|
22572
|
+
}
|
|
22573
|
+
}
|
|
22574
|
+
create$2.prototype = ArraySchema.prototype;
|
|
22575
|
+
|
|
22175
22576
|
var createValidationSchema = function (fields) {
|
|
22176
22577
|
var schema = {};
|
|
22177
22578
|
// Filtrar campos válidos antes de procesarlos
|
|
@@ -22189,7 +22590,20 @@ var createValidationSchema = function (fields) {
|
|
|
22189
22590
|
});
|
|
22190
22591
|
validFields.forEach(function (field) {
|
|
22191
22592
|
if (field.validations && field.validations.length > 0) {
|
|
22192
|
-
|
|
22593
|
+
// Determinar el tipo de esquema basado en el tipo de campo
|
|
22594
|
+
var fieldSchema_1;
|
|
22595
|
+
switch (field.type) {
|
|
22596
|
+
case "checkbox":
|
|
22597
|
+
case "checklist":
|
|
22598
|
+
fieldSchema_1 = create$2().of(create$6());
|
|
22599
|
+
break;
|
|
22600
|
+
case "upload":
|
|
22601
|
+
fieldSchema_1 = create$8();
|
|
22602
|
+
break;
|
|
22603
|
+
default:
|
|
22604
|
+
fieldSchema_1 = create$6();
|
|
22605
|
+
break;
|
|
22606
|
+
}
|
|
22193
22607
|
field.validations.forEach(function (validation) {
|
|
22194
22608
|
switch (validation.type) {
|
|
22195
22609
|
case "required":
|
|
@@ -22239,7 +22653,24 @@ var createValidationSchema = function (fields) {
|
|
|
22239
22653
|
}
|
|
22240
22654
|
else if (field.required) {
|
|
22241
22655
|
// Validación básica de requerido si no hay validaciones específicas
|
|
22242
|
-
|
|
22656
|
+
var requiredSchema = void 0;
|
|
22657
|
+
switch (field.type) {
|
|
22658
|
+
case "checkbox":
|
|
22659
|
+
requiredSchema = create$2().min(1, "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
|
|
22660
|
+
break;
|
|
22661
|
+
case "checklist":
|
|
22662
|
+
requiredSchema = create$2()
|
|
22663
|
+
.of(create$6())
|
|
22664
|
+
.min(1, "El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
|
|
22665
|
+
break;
|
|
22666
|
+
case "upload":
|
|
22667
|
+
requiredSchema = create$8().required("El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
|
|
22668
|
+
break;
|
|
22669
|
+
default:
|
|
22670
|
+
requiredSchema = create$6().required("El campo ".concat(field.label || field.name || "sin nombre", " es requerido"));
|
|
22671
|
+
break;
|
|
22672
|
+
}
|
|
22673
|
+
schema[field.name] = requiredSchema;
|
|
22243
22674
|
}
|
|
22244
22675
|
});
|
|
22245
22676
|
return create$3().shape(schema);
|
|
@@ -22330,12 +22761,13 @@ var GenericForm = function (_a) {
|
|
|
22330
22761
|
var _s = React.useState(getInitialFormData), formData = _s[0], setFormData = _s[1];
|
|
22331
22762
|
var _t = React.useState({}), errors = _t[0], setErrors = _t[1];
|
|
22332
22763
|
React.useEffect(function () {
|
|
22764
|
+
var _a, _b;
|
|
22333
22765
|
if (allData) {
|
|
22334
22766
|
setMiDtData({
|
|
22335
22767
|
allData: {
|
|
22336
22768
|
metadata: {
|
|
22337
|
-
Regiones: allData.metadata.Regiones,
|
|
22338
|
-
Comunas: allData.metadata.Comunas,
|
|
22769
|
+
Regiones: (_a = allData === null || allData === void 0 ? void 0 : allData.metadata) === null || _a === void 0 ? void 0 : _a.Regiones,
|
|
22770
|
+
Comunas: (_b = allData === null || allData === void 0 ? void 0 : allData.metadata) === null || _b === void 0 ? void 0 : _b.Comunas,
|
|
22339
22771
|
},
|
|
22340
22772
|
},
|
|
22341
22773
|
});
|
|
@@ -22438,7 +22870,7 @@ var GenericForm = function (_a) {
|
|
|
22438
22870
|
}
|
|
22439
22871
|
};
|
|
22440
22872
|
var renderField = function (field) {
|
|
22441
|
-
var _a, _b, _c
|
|
22873
|
+
var _a, _b, _c;
|
|
22442
22874
|
// Prioridad: field.value > formData > getFieldValue
|
|
22443
22875
|
var fieldValue = (_b = (_a = formData[field.name]) !== null && _a !== void 0 ? _a : field.value) !== null && _b !== void 0 ? _b : getFieldValue(field);
|
|
22444
22876
|
// Preparar el campo con las funciones de búsqueda si están disponibles
|
|
@@ -22448,8 +22880,7 @@ var GenericForm = function (_a) {
|
|
|
22448
22880
|
(_a = config.onSearch) === null || _a === void 0 ? void 0 : _a.call(config, field, value, __assign(__assign({}, stepperData), formData));
|
|
22449
22881
|
}
|
|
22450
22882
|
} });
|
|
22451
|
-
|
|
22452
|
-
return (jsxRuntime.jsx("div", { className: (_d = field.className) !== null && _d !== void 0 ? _d : "col-span-12 md:col-span-6", children: jsxRuntime.jsx(DynamicInput, { field: fieldWithHandlers, value: fieldValue, onChange: handleInputChange, error: errors[field.name] }) }, field.id));
|
|
22883
|
+
return (jsxRuntime.jsx("div", { className: (_c = field.className) !== null && _c !== void 0 ? _c : "col-span-12 md:col-span-6", children: jsxRuntime.jsx(DynamicInput, { field: fieldWithHandlers, value: fieldValue, onChange: handleInputChange, error: errors[field.name], formData: formData }) }, field.id));
|
|
22453
22884
|
};
|
|
22454
22885
|
var buttonHandlers = {
|
|
22455
22886
|
handleBack: handleBack,
|
|
@@ -22470,7 +22901,9 @@ var GenericForm = function (_a) {
|
|
|
22470
22901
|
if (loading) {
|
|
22471
22902
|
return (jsxRuntime.jsxs("div", { className: "min-h-[550px] flex flex-col justify-between gap-10 ".concat(className), children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-10", children: [jsxRuntime.jsxs("div", { id: "title", children: [jsxRuntime.jsx("div", { className: "h-8 bg-gray-200 rounded animate-pulse w-3/4 mb-2" }), jsxRuntime.jsx("div", { className: "w-full h-[3px] bg-gray-200 rounded-full animate-pulse" })] }), jsxRuntime.jsxs("div", { className: "text-gray-500 text-lg font-normal flex flex-col gap-2", children: [jsxRuntime.jsx("div", { className: "h-6 bg-gray-200 rounded animate-pulse w-1/2 ml-5" }), jsxRuntime.jsx("div", { className: "w-full h-[1px] bg-gray-200 animate-pulse" })] }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { className: "flex max-w-1xl mx-auto flex-col gap-4", children: jsxRuntime.jsx("div", { className: "grid grid-cols-12 gap-4", children: (_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.map(function (field) { return (jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-6", children: [jsxRuntime.jsx("div", { className: "h-4 bg-gray-200 rounded animate-pulse w-1/3 mb-2" }), jsxRuntime.jsx("div", { className: "h-10 bg-gray-200 rounded animate-pulse w-full" })] }, field.id)); }) }) }) })] }), jsxRuntime.jsxs("div", { className: "flex justify-between", children: [jsxRuntime.jsxs("div", { className: "flex gap-2", children: [jsxRuntime.jsx("div", { className: "h-10 bg-gray-200 rounded animate-pulse w-20" }), jsxRuntime.jsx("div", { className: "h-10 bg-gray-200 rounded animate-pulse w-20" })] }), jsxRuntime.jsx("div", { className: "h-10 bg-gray-200 rounded animate-pulse w-24" })] })] }));
|
|
22472
22903
|
}
|
|
22473
|
-
var formContent = (jsxRuntime.jsxs("div", { className: "min-h-[550px] flex flex-col justify-between gap-10 ".concat(className), children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-10", children: [config.title ? (jsxRuntime.jsxs("div", { id: "title", children: [jsxRuntime.jsx("h1", { className: "text-text text-3xl font-bold font-roboto", children: config.title }), jsxRuntime.jsx("div", { className:
|
|
22904
|
+
var formContent = (jsxRuntime.jsxs("div", { className: "min-h-[550px] flex flex-col justify-between gap-10 ".concat(className), children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-10", children: [config.title ? (jsxRuntime.jsxs("div", { id: "title", children: [jsxRuntime.jsx("h1", { className: "text-text text-3xl font-bold font-roboto", children: config.title }), jsxRuntime.jsx("div", { className: config.titleClassName
|
|
22905
|
+
? config.titleClassName
|
|
22906
|
+
: "w-full h-[3px] bg-orange-500 rounded-full mt-2" })] })) : null, (config === null || config === void 0 ? void 0 : config.steps) && (jsxRuntime.jsx(FormStepper, { steps: (_c = config === null || config === void 0 ? void 0 : config.steps) === null || _c === void 0 ? void 0 : _c.obj, activeStep: (_d = config === null || config === void 0 ? void 0 : config.steps) === null || _d === void 0 ? void 0 : _d.activeStep, completedSteps: (_e = config === null || config === void 0 ? void 0 : config.steps) === null || _e === void 0 ? void 0 : _e.completedSteps, changeActiveStep: (_f = config === null || config === void 0 ? void 0 : config.steps) === null || _f === void 0 ? void 0 : _f.changeActiveStep })), (config === null || config === void 0 ? void 0 : config.subtitle) && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: "text-gray-500 text-lg font-normal flex flex-col gap-2", children: [jsxRuntime.jsx("h3", { className: "pl-5 text-[24px] text-text text-xl font-bold font-roboto", children: config.subtitle }), jsxRuntime.jsx("hr", { className: "w-full border-gray-400" })] }) })), config.showInfoAlert && config.infoMessage && (jsxRuntime.jsx(Alert, { type: (_g = config.infoMessage.type) !== null && _g !== void 0 ? _g : "info", text: config.infoMessage.message })), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("form", { className: "flex max-w-1xl mx-auto flex-col gap-4", children: jsxRuntime.jsx("div", { className: "grid grid-cols-12 gap-4", children: config.fields.map(renderField) }) }) })] }), ((_h = config === null || config === void 0 ? void 0 : config.navigation) === null || _h === void 0 ? void 0 : _h.buttons) && (jsxRuntime.jsx("div", { className: (_k = (_j = config.navigation) === null || _j === void 0 ? void 0 : _j.containerClass) !== null && _k !== void 0 ? _k : "flex justify-between", children: (_m = (_l = config === null || config === void 0 ? void 0 : config.navigation) === null || _l === void 0 ? void 0 : _l.buttons) === null || _m === void 0 ? void 0 : _m.map(function (btn, index) {
|
|
22474
22907
|
var _a;
|
|
22475
22908
|
return btn.show ? (jsxRuntime.jsx("div", { className: (_a = btn.className) !== null && _a !== void 0 ? _a : "", children: jsxRuntime.jsx(NavigationButton, { direction: btn.direction, onClick: buttonHandlers[btn.onClick], disabled: isButtonDisabled(btn), label: btn.label }) }, index)) : null;
|
|
22476
22909
|
}) }))] }));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import React from "react";
|
|
|
2
2
|
export interface IFormField {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
|
-
type: "radio" | "text" | "select" | "textarea" | "checkbox" | "rut" | "address" | "subtitle" | "alert" | "date" | "declaration" | "typography" | "status";
|
|
5
|
+
type: "radio" | "text" | "select" | "textarea" | "checkbox" | "checklist" | "upload" | "rut" | "address" | "subtitle" | "alert" | "date" | "declaration" | "typography" | "status";
|
|
6
6
|
label: string;
|
|
7
|
-
value?: string | number |
|
|
7
|
+
value?: string | number | any;
|
|
8
8
|
options?: Array<{
|
|
9
9
|
value: string;
|
|
10
10
|
label: string;
|
|
@@ -17,7 +17,7 @@ export interface IFormField {
|
|
|
17
17
|
maxLength?: number;
|
|
18
18
|
className?: string;
|
|
19
19
|
validate?: boolean;
|
|
20
|
-
onSearch?: (value: string | any) => void;
|
|
20
|
+
onSearch?: (field: IFormField, value: string | any, formData: any) => void;
|
|
21
21
|
onAddressChange?: (address: any) => void;
|
|
22
22
|
showMap?: boolean;
|
|
23
23
|
mapHeight?: string;
|
|
@@ -35,6 +35,7 @@ export interface IFormField {
|
|
|
35
35
|
export interface IFormConfig {
|
|
36
36
|
id: string;
|
|
37
37
|
title: string;
|
|
38
|
+
titleClassName?: string | null;
|
|
38
39
|
subtitle?: string;
|
|
39
40
|
description?: string;
|
|
40
41
|
backStep?: string | null;
|
package/dist/utils/Common.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export interface Region {
|
|
2
2
|
id: number;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Nombre: string;
|
|
4
|
+
Codigo?: number | null;
|
|
5
5
|
}
|
|
6
6
|
export interface Comuna {
|
|
7
7
|
id: number;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Nombre: string;
|
|
9
|
+
Codigo?: number | null;
|
|
10
10
|
region_id?: number;
|
|
11
11
|
}
|
|
12
12
|
declare class Common {
|
|
13
|
+
static removeAccents(text: string): string;
|
|
13
14
|
static getRegionByName(regionName: string, regiones: Region[]): number | null;
|
|
14
15
|
static getComunaByName(comunaName: string, comunas: Comuna[]): number | null;
|
|
15
16
|
static getRegionIdByComunaId(comunaId: number, comunas: Comuna[]): number | null;
|