flysoft-react-ui 1.2.0 → 1.2.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/form-controls/AutocompleteInput.d.ts +7 -2
- package/dist/components/form-controls/AutocompleteInput.d.ts.map +1 -1
- package/dist/components/form-controls/AutocompleteInput.js +207 -65
- package/dist/components/form-controls/Button.js +1 -1
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
- package/dist/components/form-controls/Checkbox.js +1 -1
- package/dist/components/form-controls/SearchSelectInput.d.ts.map +1 -1
- package/dist/components/form-controls/SearchSelectInput.js +7 -7
- package/dist/components/layout/Filter.d.ts +1 -0
- package/dist/components/layout/Filter.d.ts.map +1 -1
- package/dist/components/layout/Filter.js +68 -28
- package/dist/contexts/CrudContext.d.ts +1 -3
- package/dist/contexts/CrudContext.d.ts.map +1 -1
- package/dist/docs/AutocompleteInputDocs.d.ts.map +1 -1
- package/dist/docs/AutocompleteInputDocs.js +10 -1
- package/dist/docs/FilterDocs.d.ts.map +1 -1
- package/dist/docs/FilterDocs.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,7 +25,9 @@ export const Filter = (props) => {
|
|
|
25
25
|
const [inputValue, setInputValue] = useState(currentValue || "");
|
|
26
26
|
const [searchValue, setSearchValue] = useState(currentValue || "");
|
|
27
27
|
const [dateValue, setDateValue] = useState(null);
|
|
28
|
-
const [autocompleteValue, setAutocompleteValue] = useState(currentValue
|
|
28
|
+
const [autocompleteValue, setAutocompleteValue] = useState(currentValue ?
|
|
29
|
+
(props.filterType === "autocomplete" && props.multiple ? currentValue.split("|") : currentValue)
|
|
30
|
+
: "");
|
|
29
31
|
const [searchSelectValue, setSearchSelectValue] = useState(currentValue || undefined);
|
|
30
32
|
const [searchSelectLabel, setSearchSelectLabel] = useState("");
|
|
31
33
|
const [isUserTyping, setIsUserTyping] = useState(false);
|
|
@@ -111,11 +113,12 @@ export const Filter = (props) => {
|
|
|
111
113
|
// Para autocomplete, mantener el value (no el label) para que AutocompleteInput pueda encontrar la opción
|
|
112
114
|
useEffect(() => {
|
|
113
115
|
if (filterType === "autocomplete") {
|
|
116
|
+
const isMultiple = props.multiple;
|
|
114
117
|
// Mantener el value, el AutocompleteInput se encargará de mostrar el label
|
|
115
|
-
setAutocompleteValue(currentValue
|
|
118
|
+
setAutocompleteValue(currentValue ? (isMultiple ? currentValue.split("|") : currentValue) : (isMultiple ? [] : ""));
|
|
116
119
|
setIsUserTyping(false);
|
|
117
120
|
}
|
|
118
|
-
}, [currentValue, filterType]);
|
|
121
|
+
}, [currentValue, filterType, props]);
|
|
119
122
|
// Cerrar el panel al hacer clic fuera
|
|
120
123
|
useEffect(() => {
|
|
121
124
|
if (!isOpen)
|
|
@@ -233,9 +236,17 @@ export const Filter = (props) => {
|
|
|
233
236
|
handleSearchSubmit();
|
|
234
237
|
}
|
|
235
238
|
};
|
|
236
|
-
const handleAutocompleteChange = () => {
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
+
const handleAutocompleteChange = (val) => {
|
|
240
|
+
// Si viene undefined pero estamos en múltiple, podría ser por limpieza
|
|
241
|
+
if (val !== undefined && Array.isArray(val) && props.multiple) {
|
|
242
|
+
setAutocompleteValue(val);
|
|
243
|
+
// En múltiple no manejamos "free text" que no sea opción
|
|
244
|
+
setIsUserTyping(false);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// Marcar que el usuario está escribiendo libremente (input manual simple mode)
|
|
248
|
+
setIsUserTyping(true);
|
|
249
|
+
}
|
|
239
250
|
};
|
|
240
251
|
const handleAutocompleteSelect = () => {
|
|
241
252
|
// Obtener el valor actual del input del AutocompleteInput
|
|
@@ -248,21 +259,28 @@ export const Filter = (props) => {
|
|
|
248
259
|
// Buscar opción por label
|
|
249
260
|
const matchingOption = autocompleteProps.options.find((opt) => getOptionLabel(opt).toLowerCase() === currentInputValue.toLowerCase());
|
|
250
261
|
let newValue;
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
setIsUserTyping(false);
|
|
255
|
-
}
|
|
256
|
-
else if (currentInputValue.trim()) {
|
|
257
|
-
// Si no coincide con ninguna opción, guardar el texto tal cual
|
|
258
|
-
newValue = currentInputValue.trim();
|
|
259
|
-
setAutocompleteValue(newValue);
|
|
262
|
+
if (autocompleteProps.multiple) {
|
|
263
|
+
// Extraemos del estado que ya contiene el arreglo
|
|
264
|
+
newValue = Array.isArray(autocompleteValue) && autocompleteValue.length > 0 ? autocompleteValue.join("|") : undefined;
|
|
260
265
|
setIsUserTyping(false);
|
|
261
266
|
}
|
|
262
267
|
else {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
if (matchingOption) {
|
|
269
|
+
newValue = String(getOptionValue(matchingOption));
|
|
270
|
+
setAutocompleteValue(newValue);
|
|
271
|
+
setIsUserTyping(false);
|
|
272
|
+
}
|
|
273
|
+
else if (currentInputValue.trim()) {
|
|
274
|
+
// Si no coincide con ninguna opción, guardar el texto tal cual
|
|
275
|
+
newValue = currentInputValue.trim();
|
|
276
|
+
setAutocompleteValue(newValue);
|
|
277
|
+
setIsUserTyping(false);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
newValue = undefined;
|
|
281
|
+
setAutocompleteValue("");
|
|
282
|
+
setIsUserTyping(false);
|
|
283
|
+
}
|
|
266
284
|
}
|
|
267
285
|
// Si hay onChange, llamarlo con el nuevo valor
|
|
268
286
|
if (onChange) {
|
|
@@ -286,17 +304,29 @@ export const Filter = (props) => {
|
|
|
286
304
|
if (filterType === "autocomplete") {
|
|
287
305
|
const autocompleteProps = props;
|
|
288
306
|
const getOptionValue = autocompleteProps.getOptionValue || ((item) => item.value || "");
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
307
|
+
const optionValueStr = String(getOptionValue(option));
|
|
308
|
+
let newValueToEmit;
|
|
309
|
+
if (autocompleteProps.multiple) {
|
|
310
|
+
// El onChange directo del AutocompleteInput ya maneja el arreglo,
|
|
311
|
+
// pero si por alguna razón onSelect atrapa esto, actualizamos el array (aunque lo hace en setAutocompleteValue arriba)
|
|
312
|
+
// El array completo actual deberia estar en `autocompleteValue` pero asíncronamente;
|
|
313
|
+
// mejor confiamos en la lógica de `AutocompleteInput` de toggle.
|
|
314
|
+
// En modo onSelect individual (cuando se clickea una recien), solo la disparamos o dejamos que HandleAutoCompleteChange actúe.
|
|
315
|
+
return; // Para múltiple dejamos que submit o el Autocomplete lo haga, o lo sincronizamos a nivel onChange general de autComplete y en Confirm.
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
newValueToEmit = optionValueStr;
|
|
319
|
+
setAutocompleteValue(newValueToEmit);
|
|
320
|
+
setIsUserTyping(false);
|
|
321
|
+
}
|
|
292
322
|
// Si hay onChange, llamarlo con el nuevo valor
|
|
293
323
|
if (onChange) {
|
|
294
|
-
onChange(
|
|
324
|
+
onChange(newValueToEmit);
|
|
295
325
|
}
|
|
296
326
|
// Si hay paramName, actualizar el query param
|
|
297
327
|
if (paramName) {
|
|
298
328
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
299
|
-
newSearchParams.set(paramName,
|
|
329
|
+
newSearchParams.set(paramName, newValueToEmit);
|
|
300
330
|
setSearchParams(newSearchParams, { replace: true });
|
|
301
331
|
}
|
|
302
332
|
setIsOpen(false);
|
|
@@ -405,9 +435,19 @@ export const Filter = (props) => {
|
|
|
405
435
|
if (autocompleteProps.options) {
|
|
406
436
|
const getOptionLabel = autocompleteProps.getOptionLabel || ((item) => item.label || "");
|
|
407
437
|
const getOptionValue = autocompleteProps.getOptionValue || ((item) => item.value || "");
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
438
|
+
if (autocompleteProps.multiple) {
|
|
439
|
+
const valuesArray = currentValue.split("|");
|
|
440
|
+
const labels = valuesArray.map((val) => {
|
|
441
|
+
const option = autocompleteProps.options.find((opt) => String(getOptionValue(opt)) === String(val));
|
|
442
|
+
return option ? getOptionLabel(option) : val;
|
|
443
|
+
});
|
|
444
|
+
return labels.join(", ");
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
const option = autocompleteProps.options.find((opt) => String(getOptionValue(opt)) === String(currentValue));
|
|
448
|
+
if (option) {
|
|
449
|
+
return getOptionLabel(option);
|
|
450
|
+
}
|
|
411
451
|
}
|
|
412
452
|
}
|
|
413
453
|
}
|
|
@@ -508,7 +548,7 @@ export const Filter = (props) => {
|
|
|
508
548
|
}
|
|
509
549
|
// Contenedor tipo badge con diseño similar al Input
|
|
510
550
|
// Altura ajustada para coincidir con input sm: py-1.5 (6px arriba y abajo) + text-sm (14px línea) = ~26px total
|
|
511
|
-
const badgeContainer = (_jsxs("div", { className: "inline-flex items-center gap-2 px-3 py-1.5 h-[2.1rem] rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-default)] text-[var(--color-text-primary)] font-[var(--font-default)] cursor-pointer text-sm transition-colors", onClick: handleTogglePanel, children: [_jsx("span", { className: "text-sm min-w-[1rem]", children: getDisplayValue() || "\u00A0" }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: "p-0.5 hover:bg-[var(--color-bg-secondary)] rounded transition-colors flex items-center justify-center", children: _jsx("i", { className: `${normalizeIconClass("fa-chevron-down")} text-xs text-[var(--color-text-muted)] hover:text-[var(--color-primary)] transition-all ${isOpen ? "rotate-180" : ""}` }) }), currentValue && (_jsx("button", { onClick: handleClearFilter, className: "p-0.5 hover:bg-[var(--color-bg-secondary)] rounded transition-colors flex items-center justify-center", "aria-label": "Borrar filtro", type: "button", children: _jsx("i", { className: `${normalizeIconClass("fa-times")} text-xs text-[var(--color-text-muted)] hover:text-[var(--color-primary)] transition-colors` }) }))] })] }));
|
|
551
|
+
const badgeContainer = (_jsxs("div", { className: "inline-flex items-center gap-2 px-3 py-1.5 h-[2.1rem] rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-default)] text-[var(--color-text-primary)] font-[var(--font-default)] cursor-pointer text-sm transition-colors", onClick: handleTogglePanel, children: [_jsx("span", { className: "text-sm min-w-[1rem]", children: getDisplayValue() || "\u00A0" }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: "p-0.5 hover:bg-[var(--color-bg-secondary)] rounded transition-colors flex items-center justify-center", children: _jsx("i", { className: `${normalizeIconClass("fa-chevron-down")} text-xs text-[var(--color-text-muted)] hover:text-[var(--color-primary)] transition-all ${isOpen ? "rotate-180" : ""}` }) }), currentValue && (_jsx("button", { onClick: handleClearFilter, className: "p-0.5 hover:bg-[var(--color-bg-secondary)] rounded transition-colors flex items-center justify-center cursor-pointer", "aria-label": "Borrar filtro", type: "button", children: _jsx("i", { className: `${normalizeIconClass("fa-times")} text-xs text-[var(--color-text-muted)] hover:text-[var(--color-primary)] transition-colors` }) }))] })] }));
|
|
512
552
|
// Renderizar según el tipo de filtro
|
|
513
553
|
if (filterType === "autocomplete") {
|
|
514
554
|
return (_jsxs("div", { ref: containerRef, className: `relative inline-block ${disabled ? "opacity-50 pointer-events-none" : ""}`, children: [_jsx(DataField, { label: label, value: badgeContainer, className: "inline-block" }), isOpen &&
|
|
@@ -523,7 +563,7 @@ export const Filter = (props) => {
|
|
|
523
563
|
: "text-[var(--color-text-primary)] hover:bg-[var(--color-bg-secondary)]"}`, onMouseDown: (e) => {
|
|
524
564
|
e.preventDefault();
|
|
525
565
|
handleStaticOptionSelect(option);
|
|
526
|
-
}, children: _jsx("span", { className: "font-[var(--font-default)]", children: option.text }) }, option.value))) })), _jsxs("div", { className: "flex items-center justify-start gap-2", children: [_jsx("div", { style: { width: finalInputWidth }, children: _jsx(AutocompleteInput, { ref: autocompleteInputRef, options: props.options, value: isUserTyping ? undefined : autocompleteValue, onChange: handleAutocompleteChange, getOptionLabel: props.getOptionLabel, getOptionValue: props.getOptionValue, renderOption: props.renderOption, noResultsText: props.noResultsText, onSelectOption: handleAutocompleteOptionSelect, disabled: disabled }) }), _jsx(Button, { onClick: handleAutocompleteSelect, icon: "fa-arrow-right", variant: "ghost" })] })] }) }), document.body)] }));
|
|
566
|
+
}, children: _jsx("span", { className: "font-[var(--font-default)]", children: option.text }) }, option.value))) })), _jsxs("div", { className: "flex items-center justify-start gap-2", children: [_jsx("div", { style: { width: finalInputWidth }, children: _jsx(AutocompleteInput, { ref: autocompleteInputRef, options: props.options, value: isUserTyping ? undefined : autocompleteValue, onChange: handleAutocompleteChange, getOptionLabel: props.getOptionLabel, getOptionValue: props.getOptionValue, renderOption: props.renderOption, noResultsText: props.noResultsText, multiple: props.multiple, onSelectOption: handleAutocompleteOptionSelect, disabled: disabled }) }), _jsx(Button, { onClick: handleAutocompleteSelect, icon: props.multiple ? "fa-check" : "fa-arrow-right", variant: "ghost" })] })] }) }), document.body)] }));
|
|
527
567
|
}
|
|
528
568
|
if (filterType === "date") {
|
|
529
569
|
return (_jsxs("div", { ref: containerRef, className: `relative inline-block ${disabled ? "opacity-50 pointer-events-none" : ""}`, children: [_jsx(DataField, { label: label, value: badgeContainer, className: "inline-block" }), isOpen &&
|
|
@@ -44,9 +44,7 @@ interface CrudProviderProps<T> {
|
|
|
44
44
|
getPromise?: ((params?: Record<string, any>) => Promise<Array<T> | PaginationInterface<T> | undefined>) | PromiseWithOptions<Array<T> | PaginationInterface<T> | undefined, [
|
|
45
45
|
params?: Record<string, any>
|
|
46
46
|
]>;
|
|
47
|
-
getItemPromise?: ((
|
|
48
|
-
params?: Record<string, any> | string | number
|
|
49
|
-
]>;
|
|
47
|
+
getItemPromise?: ((id: string | number) => Promise<T | undefined>) | PromiseWithOptions<T | undefined, [id: string | number]>;
|
|
50
48
|
postPromise?: ((item: T) => Promise<T | undefined | null>) | PromiseWithOptions<T | undefined | null, [item: T]>;
|
|
51
49
|
putPromise?: ((item: T) => Promise<T | undefined | null>) | PromiseWithOptions<T | undefined | null, [item: T]>;
|
|
52
50
|
deletePromise?: ((item: T) => Promise<void>) | PromiseWithOptions<void, [item: T]>;
|
|
@@ -1 +1 @@
|
|
|
1
|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
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteInputDocs.d.ts","sourceRoot":"","sources":["../../src/docs/AutocompleteInputDocs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA4E1B,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"AutocompleteInputDocs.d.ts","sourceRoot":"","sources":["../../src/docs/AutocompleteInputDocs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA4E1B,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAmWlC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -65,9 +65,18 @@ const AutocompleteInputDocs = () => {
|
|
|
65
65
|
const [selectedCountry, setSelectedCountry] = React.useState();
|
|
66
66
|
const [value, setValue] = React.useState("");
|
|
67
67
|
const [selectedUser, setSelectedUser] = React.useState();
|
|
68
|
+
const [selectedCountries, setSelectedCountries] = React.useState([]);
|
|
68
69
|
return (_jsx("div", { className: "max-w-5xl mx-auto space-y-8", children: _jsx(Card, { title: "AutocompleteInput - B\u00FAsqueda y selecci\u00F3n de opciones", children: _jsxs("div", { className: "space-y-10", children: [_jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Uso b\u00E1sico" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Pa\u00EDs", placeholder: "Escribe para buscar...", icon: "fa-globe", options: sampleOptions, onSelectOption: (option) => setSelectedCountry(option) }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "escribe para filtrar la lista de opciones y selecciona con el mouse o con Enter" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-medium", style: { color: "var(--flysoft-text-primary)" }, children: "Selecci\u00F3n actual" }), _jsx(Card, { variant: "outlined", children: _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: selectedCountry
|
|
69
70
|
? `${selectedCountry.label} (${selectedCountry.value.toUpperCase()})`
|
|
70
|
-
: "Ningún país seleccionado" }) })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Controlado vs no controlado" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Autocomplete no controlado", placeholder: "Escribe para buscar...", icon: "fa-search", options: sampleOptions }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "sin prop value: el componente maneja internamente el valor del input" })] }), _jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Autocomplete controlado", placeholder: "Escribe para buscar...", icon: "fa-search", options: sampleOptions, value: value, onChange:
|
|
71
|
+
: "Ningún país seleccionado" }) })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Controlado vs no controlado" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Autocomplete no controlado", placeholder: "Escribe para buscar...", icon: "fa-search", options: sampleOptions }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "sin prop value: el componente maneja internamente el valor del input" })] }), _jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Autocomplete controlado", placeholder: "Escribe para buscar...", icon: "fa-search", options: sampleOptions, value: value, onChange: (val) => {
|
|
72
|
+
if (typeof val === "string")
|
|
73
|
+
setValue(val);
|
|
74
|
+
} }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "con value y onChange: el valor del input se controla desde el estado externo" }), _jsx(Input, { label: "Valor actual", value: value, readOnly: true, icon: "fa-code" })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Personalizaci\u00F3n y estados" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Sin resultados", placeholder: "Escribe algo que no exista", icon: "fa-question-circle", options: sampleOptions, noResultsText: "No encontramos coincidencias" }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "el mensaje se muestra cuando no hay coincidencias al filtrar" })] }), _jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Deshabilitado", placeholder: "No editable", icon: "fa-ban", options: sampleOptions, disabled: true }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "respeta el estado disabled heredado del componente Input" })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Selecci\u00F3n m\u00FAltiple" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "M\u00FAltiples Pa\u00EDses", placeholder: "Selecciona uno o m\u00E1s pa\u00EDses...", icon: "fa-globe", options: sampleOptions, multiple: true, value: selectedCountries, onChange: (val) => {
|
|
75
|
+
const stringArray = Array.isArray(val) ? val : [val];
|
|
76
|
+
setSelectedCountries(stringArray);
|
|
77
|
+
} }), _jsxs("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: ["usando la prop ", _jsxs("code", { children: ["multiple=", true] }), " permite seleccionar varias opciones con checkboxes."] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-medium", style: { color: "var(--flysoft-text-primary)" }, children: "Valores seleccionados" }), _jsx(Card, { variant: "outlined", children: _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: selectedCountries.length > 0
|
|
78
|
+
? selectedCountries.join(", ")
|
|
79
|
+
: "Ningún país seleccionado" }) })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Uso gen\u00E9rico con renderOption personalizado" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(AutocompleteInput, { label: "Buscar usuario", placeholder: "Escribe nombre o email...", icon: "fa-users", options: users, getOptionLabel: (user) => `${user.firstName} ${user.lastName}`, getOptionValue: (user) => user.id, getOptionDescription: (user) => user.email, onSelectOption: (user, userId) => {
|
|
71
80
|
setSelectedUser(user);
|
|
72
81
|
console.log("Usuario seleccionado:", user, "ID:", userId);
|
|
73
82
|
}, renderOption: (user) => (_jsxs("div", { className: "flex items-start gap-3 w-full", children: [_jsx("div", { className: "flex-shrink-0 w-10 h-10 rounded-full bg-[var(--color-primary-soft)] flex items-center justify-center", children: _jsx("i", { className: "fal fa-user text-[var(--color-primary)]" }) }), _jsxs("div", { className: "flex flex-col flex-1 min-w-0", children: [_jsxs("span", { className: "font-medium text-[var(--color-text-primary)]", children: [user.firstName, " ", user.lastName] }), _jsx("span", { className: "text-xs text-[var(--color-text-secondary)] truncate", children: user.email }), _jsxs("div", { className: "flex items-center gap-2 mt-1", children: [_jsx("span", { className: "text-xs px-2 py-0.5 rounded bg-[var(--color-bg-secondary)] text-[var(--color-text-secondary)]", children: user.role }), _jsxs("span", { className: "text-xs text-[var(--color-text-muted)]", children: ["\u2022 ", user.department] })] })] })] })) }), _jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "usando getOptionLabel, getOptionValue y renderOption para personalizar completamente el renderizado de opciones sin propiedades label/value/description" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-medium", style: { color: "var(--flysoft-text-primary)" }, children: "Usuario seleccionado" }), _jsx(Card, { variant: "outlined", children: selectedUser ? (_jsxs("div", { className: "space-y-2", children: [_jsxs("p", { className: "text-sm font-medium", style: { color: "var(--flysoft-text-primary)" }, children: [selectedUser.firstName, " ", selectedUser.lastName] }), _jsx("p", { className: "text-xs", style: { color: "var(--flysoft-text-secondary)" }, children: selectedUser.email }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-xs px-2 py-0.5 rounded bg-[var(--color-bg-secondary)]", style: { color: "var(--flysoft-text-secondary)" }, children: selectedUser.role }), _jsx("span", { className: "text-xs", style: { color: "var(--flysoft-text-muted)" }, children: selectedUser.department })] }), _jsxs("p", { className: "text-xs mt-2", style: { color: "var(--flysoft-text-muted)" }, children: ["ID: ", selectedUser.id] })] })) : (_jsx("p", { className: "text-sm", style: { color: "var(--flysoft-text-secondary)" }, children: "Ning\u00FAn usuario seleccionado" })) })] })] })] }), _jsxs("section", { children: [_jsx("h3", { className: "text-lg font-semibold mb-4", style: { color: "var(--flysoft-text-primary)" }, children: "Ejemplo de formulario" }), _jsx(Card, { title: "Formulario de b\u00FAsqueda con AutocompleteInput", subtitle: "Combinaci\u00F3n de AutocompleteInput, Input y Button", footer: _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { variant: "outline", icon: "fa-times", children: "Limpiar" }), _jsx(Button, { variant: "primary", icon: "fa-search", children: "Buscar" })] }), children: _jsxs("div", { className: "space-y-4", children: [_jsx(AutocompleteInput, { label: "Pa\u00EDs de residencia", placeholder: "Selecciona un pa\u00EDs", icon: "fa-flag", options: sampleOptions }), _jsx(Input, { label: "Ciudad", placeholder: "Introduce tu ciudad", icon: "fa-city" })] }) })] })] }) }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterDocs.d.ts","sourceRoot":"","sources":["../../src/docs/FilterDocs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"FilterDocs.d.ts","sourceRoot":"","sources":["../../src/docs/FilterDocs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAizBvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/docs/FilterDocs.js
CHANGED
|
@@ -30,7 +30,7 @@ const FilterDocs = () => {
|
|
|
30
30
|
].map((option) => ({
|
|
31
31
|
text: option.text,
|
|
32
32
|
value: option.value,
|
|
33
|
-
})) }), _jsx(Filter, { paramName: "estado", label: "Estado", filterType: "autocomplete", options: [
|
|
33
|
+
})) }), _jsx(Filter, { paramName: "estado", label: "Estado", filterType: "autocomplete", multiple: true, options: [
|
|
34
34
|
{ label: "Activo", value: "activo" },
|
|
35
35
|
{ label: "Inactivo", value: "inactivo" },
|
|
36
36
|
{ label: "Pendiente", value: "pendiente" },
|