@visiion/forms-library 1.4.2 → 1.4.4
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
|
@@ -10194,7 +10194,7 @@ var RadioInput = function (_a) {
|
|
|
10194
10194
|
var handleSearch = function (e) {
|
|
10195
10195
|
var _a;
|
|
10196
10196
|
onChange(e);
|
|
10197
|
-
(_a = field === null || field === void 0 ? void 0 : field.onSearch) === null || _a === void 0 ? void 0 : _a.call(field, e.target.value);
|
|
10197
|
+
(_a = field === null || field === void 0 ? void 0 : field.onSearch) === null || _a === void 0 ? void 0 : _a.call(field, { value: e.target.value });
|
|
10198
10198
|
};
|
|
10199
10199
|
return (jsxs(InputWrapper, __assign({}, field, { error: error, children: [jsx("div", { className: "space-y-2", children: (_b = field.options) === null || _b === void 0 ? void 0 : _b.map(function (option) { return (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 && jsx("span", { className: "text-red-500 text-sm", children: error })] })));
|
|
10200
10200
|
};
|
|
@@ -10345,14 +10345,14 @@ var RutInput = function (_a) {
|
|
|
10345
10345
|
// Manejar búsqueda
|
|
10346
10346
|
var handleSearch = function () {
|
|
10347
10347
|
if (onSearch && value && isValidRut) {
|
|
10348
|
-
onSearch(clean(displayValue));
|
|
10348
|
+
onSearch({ value: clean(displayValue) });
|
|
10349
10349
|
}
|
|
10350
10350
|
};
|
|
10351
10351
|
// Manejar tecla Enter para búsqueda
|
|
10352
10352
|
var handleKeyDown = function (e) {
|
|
10353
10353
|
if (e.key === "Enter" && onSearch && value && isValidRut) {
|
|
10354
10354
|
e.preventDefault();
|
|
10355
|
-
onSearch(clean(displayValue));
|
|
10355
|
+
onSearch({ value: clean(displayValue) });
|
|
10356
10356
|
}
|
|
10357
10357
|
};
|
|
10358
10358
|
return (jsxs("div", { className: "flex flex-col gap-1", children: [jsx("label", { htmlFor: field.id, className: "font-medium text-gray-700", children: field.label }), jsxs("div", { className: "flex", children: [jsx("input", { ref: inputRef, id: field.id, name: field.name, type: "text", value: displayValue || "", onChange: handleRutChange, onKeyDown: handleKeyDown, placeholder: placeholder, minLength: minLength, maxLength: maxLength, disabled: disabled, className: "flex-1 px-3 py-2 border rounded-l-md focus:outline-none focus:ring-2 focus:ring-orange-500 h-10 ".concat(error ? "border-red-500" : "border-gray-300", " ").concat(disabled ? "bg-gray-100 cursor-not-allowed" : "") }), onSearch && (jsx(Button, { type: "button", color: "blue", className: "flex items-center justify-center w-10 h-10 rounded-none rounded-tr-md rounded-br-md border-l-0", onClick: handleSearch, disabled: !isValidRut || disabled, children: jsx(IoMdSearch, { className: "w-5 h-5" }) }))] }), error && jsx("span", { className: "text-red-500 text-sm", children: error }), displayValue && !error && (jsx("span", { className: "text-sm ".concat(isValidRut ? "text-green-600" : "text-orange-600"), children: isValidRut ? "✓ RUT válido" : "⚠ Verificar formato del RUT" }))] }));
|
|
@@ -19751,7 +19751,9 @@ var AddressInput = function (_a) {
|
|
|
19751
19751
|
localStorage.setItem("lastLocation", JSON.stringify(newLocation));
|
|
19752
19752
|
var addressComponents = extractAddressComponents(place, newLocation);
|
|
19753
19753
|
if (onSearch) {
|
|
19754
|
-
onSearch(
|
|
19754
|
+
onSearch({
|
|
19755
|
+
value: __assign(__assign({}, addressComponents), { address: place.formatted_address }),
|
|
19756
|
+
});
|
|
19755
19757
|
}
|
|
19756
19758
|
}
|
|
19757
19759
|
}
|
|
@@ -19789,7 +19791,9 @@ var AddressInput = function (_a) {
|
|
|
19789
19791
|
if (address) {
|
|
19790
19792
|
addressComponents = extractAddressComponents(address, newLocation);
|
|
19791
19793
|
if (onSearch) {
|
|
19792
|
-
onSearch(
|
|
19794
|
+
onSearch({
|
|
19795
|
+
value: __assign(__assign({}, addressComponents), { address: address.formatted_address }),
|
|
19796
|
+
});
|
|
19793
19797
|
}
|
|
19794
19798
|
}
|
|
19795
19799
|
return [3 /*break*/, 4];
|
|
@@ -19826,7 +19830,9 @@ var AddressInput = function (_a) {
|
|
|
19826
19830
|
if (response.results[0]) {
|
|
19827
19831
|
addressComponents = extractAddressComponents(response.results[0], newLocation);
|
|
19828
19832
|
if (onSearch) {
|
|
19829
|
-
onSearch(
|
|
19833
|
+
onSearch({
|
|
19834
|
+
value: __assign(__assign({}, addressComponents), { address: response.results[0].formatted_address }),
|
|
19835
|
+
});
|
|
19830
19836
|
}
|
|
19831
19837
|
}
|
|
19832
19838
|
return [3 /*break*/, 4];
|
|
@@ -19982,7 +19988,7 @@ var SwornDeclaration = function (_a) {
|
|
|
19982
19988
|
};
|
|
19983
19989
|
|
|
19984
19990
|
var StatusScreen = function (_a) {
|
|
19985
|
-
var title = _a.title, message = _a.message, _b = _a.type, type = _b === void 0 ? "info" : _b, leftButton = _a.leftButton, rightButton = _a.rightButton;
|
|
19991
|
+
var title = _a.title, message = _a.message, _b = _a.type, type = _b === void 0 ? "info" : _b, leftButton = _a.leftButton, rightButton = _a.rightButton, onSearch = _a.onSearch;
|
|
19986
19992
|
var getStatusStyles = function () {
|
|
19987
19993
|
switch (type) {
|
|
19988
19994
|
case "success":
|
|
@@ -20007,7 +20013,11 @@ var StatusScreen = function (_a) {
|
|
|
20007
20013
|
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" }) }));
|
|
20008
20014
|
}
|
|
20009
20015
|
};
|
|
20010
|
-
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:
|
|
20016
|
+
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: function () {
|
|
20017
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch({ value: "LEFT" });
|
|
20018
|
+
}, 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: function () {
|
|
20019
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch({ value: "RIGHT" });
|
|
20020
|
+
}, 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 }))] }))] }) }));
|
|
20011
20021
|
};
|
|
20012
20022
|
|
|
20013
20023
|
var Typography = function (_a) {
|
|
@@ -22855,10 +22865,13 @@ var GenericForm = function (_a) {
|
|
|
22855
22865
|
// Prioridad: field.value > formData > getFieldValue
|
|
22856
22866
|
var fieldValue = (_b = (_a = formData[field.name]) !== null && _a !== void 0 ? _a : field.value) !== null && _b !== void 0 ? _b : getFieldValue(field);
|
|
22857
22867
|
// Preparar el campo con las funciones de búsqueda si están disponibles
|
|
22858
|
-
var fieldWithHandlers = __assign(__assign({}, field), {
|
|
22859
|
-
|
|
22868
|
+
var fieldWithHandlers = __assign(__assign({}, field), {
|
|
22869
|
+
// ... existing code ...
|
|
22870
|
+
onSearch: function (_a) {
|
|
22871
|
+
var _b;
|
|
22872
|
+
_a.field; var value = _a.value; _a.formData;
|
|
22860
22873
|
if (field.onSearch) {
|
|
22861
|
-
(
|
|
22874
|
+
(_b = config === null || config === void 0 ? void 0 : config.onSearch) === null || _b === void 0 ? void 0 : _b.call(config, field, value !== null && value !== void 0 ? value : "", __assign(__assign({}, stepperData), formData));
|
|
22862
22875
|
}
|
|
22863
22876
|
} });
|
|
22864
22877
|
return (jsx("div", { className: (_c = field.className) !== null && _c !== void 0 ? _c : "col-span-12 md:col-span-6", children: jsx(DynamicInput, { field: fieldWithHandlers, value: fieldValue, onChange: handleInputChange, error: errors[field.name], formData: formData }) }, field.id));
|
package/dist/index.js
CHANGED
|
@@ -10213,7 +10213,7 @@ var RadioInput = function (_a) {
|
|
|
10213
10213
|
var handleSearch = function (e) {
|
|
10214
10214
|
var _a;
|
|
10215
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);
|
|
10216
|
+
(_a = field === null || field === void 0 ? void 0 : field.onSearch) === null || _a === void 0 ? void 0 : _a.call(field, { value: e.target.value });
|
|
10217
10217
|
};
|
|
10218
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 })] })));
|
|
10219
10219
|
};
|
|
@@ -10364,14 +10364,14 @@ var RutInput = function (_a) {
|
|
|
10364
10364
|
// Manejar búsqueda
|
|
10365
10365
|
var handleSearch = function () {
|
|
10366
10366
|
if (onSearch && value && isValidRut) {
|
|
10367
|
-
onSearch(clean(displayValue));
|
|
10367
|
+
onSearch({ value: clean(displayValue) });
|
|
10368
10368
|
}
|
|
10369
10369
|
};
|
|
10370
10370
|
// Manejar tecla Enter para búsqueda
|
|
10371
10371
|
var handleKeyDown = function (e) {
|
|
10372
10372
|
if (e.key === "Enter" && onSearch && value && isValidRut) {
|
|
10373
10373
|
e.preventDefault();
|
|
10374
|
-
onSearch(clean(displayValue));
|
|
10374
|
+
onSearch({ value: clean(displayValue) });
|
|
10375
10375
|
}
|
|
10376
10376
|
};
|
|
10377
10377
|
return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntime.jsx("label", { htmlFor: field.id, className: "font-medium text-gray-700", children: field.label }), jsxRuntime.jsxs("div", { className: "flex", children: [jsxRuntime.jsx("input", { ref: inputRef, id: field.id, name: field.name, type: "text", value: displayValue || "", onChange: handleRutChange, onKeyDown: handleKeyDown, placeholder: placeholder, minLength: minLength, maxLength: maxLength, disabled: disabled, className: "flex-1 px-3 py-2 border rounded-l-md focus:outline-none focus:ring-2 focus:ring-orange-500 h-10 ".concat(error ? "border-red-500" : "border-gray-300", " ").concat(disabled ? "bg-gray-100 cursor-not-allowed" : "") }), onSearch && (jsxRuntime.jsx(flowbiteReact.Button, { type: "button", color: "blue", className: "flex items-center justify-center w-10 h-10 rounded-none rounded-tr-md rounded-br-md border-l-0", onClick: handleSearch, disabled: !isValidRut || disabled, children: jsxRuntime.jsx(IoMdSearch, { className: "w-5 h-5" }) }))] }), error && jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: error }), displayValue && !error && (jsxRuntime.jsx("span", { className: "text-sm ".concat(isValidRut ? "text-green-600" : "text-orange-600"), children: isValidRut ? "✓ RUT válido" : "⚠ Verificar formato del RUT" }))] }));
|
|
@@ -19770,7 +19770,9 @@ var AddressInput = function (_a) {
|
|
|
19770
19770
|
localStorage.setItem("lastLocation", JSON.stringify(newLocation));
|
|
19771
19771
|
var addressComponents = extractAddressComponents(place, newLocation);
|
|
19772
19772
|
if (onSearch) {
|
|
19773
|
-
onSearch(
|
|
19773
|
+
onSearch({
|
|
19774
|
+
value: __assign(__assign({}, addressComponents), { address: place.formatted_address }),
|
|
19775
|
+
});
|
|
19774
19776
|
}
|
|
19775
19777
|
}
|
|
19776
19778
|
}
|
|
@@ -19808,7 +19810,9 @@ var AddressInput = function (_a) {
|
|
|
19808
19810
|
if (address) {
|
|
19809
19811
|
addressComponents = extractAddressComponents(address, newLocation);
|
|
19810
19812
|
if (onSearch) {
|
|
19811
|
-
onSearch(
|
|
19813
|
+
onSearch({
|
|
19814
|
+
value: __assign(__assign({}, addressComponents), { address: address.formatted_address }),
|
|
19815
|
+
});
|
|
19812
19816
|
}
|
|
19813
19817
|
}
|
|
19814
19818
|
return [3 /*break*/, 4];
|
|
@@ -19845,7 +19849,9 @@ var AddressInput = function (_a) {
|
|
|
19845
19849
|
if (response.results[0]) {
|
|
19846
19850
|
addressComponents = extractAddressComponents(response.results[0], newLocation);
|
|
19847
19851
|
if (onSearch) {
|
|
19848
|
-
onSearch(
|
|
19852
|
+
onSearch({
|
|
19853
|
+
value: __assign(__assign({}, addressComponents), { address: response.results[0].formatted_address }),
|
|
19854
|
+
});
|
|
19849
19855
|
}
|
|
19850
19856
|
}
|
|
19851
19857
|
return [3 /*break*/, 4];
|
|
@@ -20001,7 +20007,7 @@ var SwornDeclaration = function (_a) {
|
|
|
20001
20007
|
};
|
|
20002
20008
|
|
|
20003
20009
|
var StatusScreen = function (_a) {
|
|
20004
|
-
var title = _a.title, message = _a.message, _b = _a.type, type = _b === void 0 ? "info" : _b, leftButton = _a.leftButton, rightButton = _a.rightButton;
|
|
20010
|
+
var title = _a.title, message = _a.message, _b = _a.type, type = _b === void 0 ? "info" : _b, leftButton = _a.leftButton, rightButton = _a.rightButton, onSearch = _a.onSearch;
|
|
20005
20011
|
var getStatusStyles = function () {
|
|
20006
20012
|
switch (type) {
|
|
20007
20013
|
case "success":
|
|
@@ -20026,7 +20032,11 @@ var StatusScreen = function (_a) {
|
|
|
20026
20032
|
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" }) }));
|
|
20027
20033
|
}
|
|
20028
20034
|
};
|
|
20029
|
-
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:
|
|
20035
|
+
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: function () {
|
|
20036
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch({ value: "LEFT" });
|
|
20037
|
+
}, 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: function () {
|
|
20038
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch({ value: "RIGHT" });
|
|
20039
|
+
}, 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 }))] }))] }) }));
|
|
20030
20040
|
};
|
|
20031
20041
|
|
|
20032
20042
|
var Typography = function (_a) {
|
|
@@ -22874,10 +22884,13 @@ var GenericForm = function (_a) {
|
|
|
22874
22884
|
// Prioridad: field.value > formData > getFieldValue
|
|
22875
22885
|
var fieldValue = (_b = (_a = formData[field.name]) !== null && _a !== void 0 ? _a : field.value) !== null && _b !== void 0 ? _b : getFieldValue(field);
|
|
22876
22886
|
// Preparar el campo con las funciones de búsqueda si están disponibles
|
|
22877
|
-
var fieldWithHandlers = __assign(__assign({}, field), {
|
|
22878
|
-
|
|
22887
|
+
var fieldWithHandlers = __assign(__assign({}, field), {
|
|
22888
|
+
// ... existing code ...
|
|
22889
|
+
onSearch: function (_a) {
|
|
22890
|
+
var _b;
|
|
22891
|
+
_a.field; var value = _a.value; _a.formData;
|
|
22879
22892
|
if (field.onSearch) {
|
|
22880
|
-
(
|
|
22893
|
+
(_b = config === null || config === void 0 ? void 0 : config.onSearch) === null || _b === void 0 ? void 0 : _b.call(config, field, value !== null && value !== void 0 ? value : "", __assign(__assign({}, stepperData), formData));
|
|
22881
22894
|
}
|
|
22882
22895
|
} });
|
|
22883
22896
|
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));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,7 +17,11 @@ export interface IFormField {
|
|
|
17
17
|
maxLength?: number;
|
|
18
18
|
className?: string;
|
|
19
19
|
validate?: boolean;
|
|
20
|
-
onSearch?: (field
|
|
20
|
+
onSearch?: ({ field, value, formData, }: {
|
|
21
|
+
field?: IFormField;
|
|
22
|
+
value?: string | any;
|
|
23
|
+
formData?: any;
|
|
24
|
+
}) => void;
|
|
21
25
|
onAddressChange?: (address: any) => void;
|
|
22
26
|
showMap?: boolean;
|
|
23
27
|
mapHeight?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visiion/forms-library",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Librería de componentes de formularios reutilizables",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"@googlemaps/js-api-loader": "^1.16.6",
|
|
39
39
|
"@react-google-maps/api": "^2.19.3",
|
|
40
40
|
"@react-pdf/renderer": "^4.3.0",
|
|
41
|
+
"classnames": "^2.5.1",
|
|
42
|
+
"debounce": "^2.2.0",
|
|
41
43
|
"flowbite-react": "0.10.1",
|
|
42
44
|
"framer-motion": "^11.3.8",
|
|
43
45
|
"react-icons": "^5.5.0",
|
|
@@ -73,4 +75,4 @@
|
|
|
73
75
|
"url": "https://github.com/Kuantaz/forms-library/issues"
|
|
74
76
|
},
|
|
75
77
|
"homepage": "https://github.com/Kuantaz/forms-library#readme"
|
|
76
|
-
}
|
|
78
|
+
}
|