@redi.run/redi-components 0.0.63 → 0.0.64

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.
@@ -0,0 +1,626 @@
1
+ import { default as default_2 } from 'react';
2
+ import { JSX } from 'react/jsx-runtime';
3
+ import { PropsWithChildren } from 'react';
4
+ import { ReactNode } from 'react';
5
+
6
+ /**
7
+ * AdvancedTable Component
8
+ *
9
+ * Supports both Client-Side and Server-Side data handling.
10
+ *
11
+ * Server-Side Mode:
12
+ * Provide the `fetchData` prop to enable server-side mode.
13
+ * The function will be called with pagination, sorting and filter params.
14
+ *
15
+ * Optional props for Server-Side:
16
+ * - `onRefresh`: Callback for external refresh triggers
17
+ */
18
+ export declare const AdvancedTable: <T>({ data, columns, defaultSort, defaultFilters, defaultPageSize, pageSizeOptions, enableSorting, enableFiltering, enablePagination, enableExport, initialConfig, onConfigChange, className, labels, enableColumnReordering, enableColumnPinning, enableColumnResizing, enableRowSelection, stickyActionsColumn, rowKey, onRowSelectionChange, renderActions, actionsColumnLabel, loading, fetchData, onRefresh, onPaginationChange, onFiltersChange, syncFiltersWithUrl, enableColumnConfig, enableInlineEditing, onRowSave, onRowEditCancel, }: AdvancedTableProps<T>) => JSX.Element;
19
+
20
+ export declare interface AdvancedTableProps<T> {
21
+ data: T[];
22
+ columns: Column<T>[];
23
+ defaultSort?: SortConfig;
24
+ defaultFilters?: FilterConfig;
25
+ defaultPageSize?: number;
26
+ pageSizeOptions?: number[];
27
+ enableSorting?: boolean;
28
+ enableFiltering?: boolean;
29
+ enablePagination?: boolean;
30
+ enableColumnReordering?: boolean;
31
+ enableColumnPinning?: boolean;
32
+ enableColumnResizing?: boolean;
33
+ enableRowSelection?: boolean;
34
+ stickyActionsColumn?: boolean;
35
+ enableExport?: boolean;
36
+ initialConfig?: Partial<TableConfig<T>>;
37
+ onRowClick?: (row: T, index: number) => void;
38
+ onConfigChange?: (config: TableConfig<T>) => void;
39
+ className?: string;
40
+ enableColumnConfig?: boolean;
41
+ loading?: boolean;
42
+ emptyMessage?: string;
43
+ exportFileName?: string;
44
+ labels?: LabelsProps;
45
+ renderActions?: ({ row, index, column }: {
46
+ row: T;
47
+ index: number;
48
+ column: Column<T>;
49
+ }) => default_2.ReactNode;
50
+ actionsColumnLabel?: string;
51
+ onRefresh?: () => void;
52
+ onPaginationChange?: (pagination: PaginationConfig) => void;
53
+ onFiltersChange?: (filters: FilterConfig) => void;
54
+ rowKey?: keyof T | ((row: T) => string | number);
55
+ onRowSelectionChange?: (selectedIds: (string | number)[]) => void;
56
+ enableInlineEditing?: boolean;
57
+ onRowSave?: (row: T, newValues: Partial<T>) => Promise<void> | void;
58
+ onRowEditCancel?: () => void;
59
+ /**
60
+ * Función para cargar datos del servidor.
61
+ * Si se proporciona, la tabla entrará en modo "Server-Side".
62
+ * Recibe los parámetros de paginación, ordenamiento y filtros.
63
+ * Debe retornar una promesa con los datos y el total de elementos.
64
+ */
65
+ /**
66
+ * If true, keeps filters in sync with URL query parameters.
67
+ * - In client-side mode: Syncs all filters.
68
+ * - In server-side mode (`fetchData` provided): Syncs ONLY filters for columns with `shouldBeRefetch: true`.
69
+ */
70
+ syncFiltersWithUrl?: boolean;
71
+ fetchData?: (params: FetchParams) => Promise<FetchResponse<T>>;
72
+ }
73
+
74
+ export declare const Alert: ({ id, title, description, tone, autoDismiss, onClose, className, actions, closeOnAction, showIcon, icon, }: AlertProps) => JSX.Element;
75
+
76
+ export declare type AlertAction = {
77
+ label: string;
78
+ onClick: (id: string) => void | Promise<void>;
79
+ variant?: AlertActionVariant;
80
+ disabled?: boolean;
81
+ ariaLabel?: string;
82
+ };
83
+
84
+ export declare type AlertActionVariant = 'primary' | 'secondary' | 'ghost';
85
+
86
+ export declare type AlertPlacement = 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right';
87
+
88
+ export declare interface AlertProps {
89
+ id: string;
90
+ title?: string;
91
+ description?: string;
92
+ tone?: AlertTone;
93
+ autoDismiss?: number;
94
+ onClose?: (id: string) => void;
95
+ className?: string;
96
+ actions?: AlertAction[];
97
+ closeOnAction?: boolean;
98
+ showIcon?: boolean;
99
+ icon?: React.ReactNode;
100
+ }
101
+
102
+ export declare type AlertTone = 'info' | 'success' | 'warning' | 'danger';
103
+
104
+ export declare const AlertViewport: ({ placement, className, children, }: AlertViewportProps) => JSX.Element;
105
+
106
+ declare interface AlertViewportProps extends PropsWithChildren {
107
+ placement?: AlertPlacement;
108
+ className?: string;
109
+ }
110
+
111
+ export declare type Align = 'start' | 'center' | 'end';
112
+
113
+ export declare const Badge: ({ label, count, max, tone, dot, showIcon, icon, iconPosition, show, animation, animationDuration, shape, className, ariaLabel, role, ariaLive, onExited, }: BadgeProps) => JSX.Element | null;
114
+
115
+ export declare type BadgeAnchorProps = {
116
+ children: default_2.ReactNode;
117
+ /** Un badge o varios badges (para stacking simple). */
118
+ badge: default_2.ReactNode;
119
+ /** Corner donde se “ancla” el/los badges. */
120
+ placement?: BadgePlacement;
121
+ /** Offset en px. */
122
+ offset?: BadgeOffset;
123
+ /** Clase para el contenedor. */
124
+ className?: string;
125
+ };
126
+
127
+ export declare type BadgeAnimation = 'none' | 'fade' | 'scale';
128
+
129
+ export declare type BadgeOffset = {
130
+ x?: number;
131
+ y?: number;
132
+ };
133
+
134
+ export declare type BadgePlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
135
+
136
+ export declare type BadgeProps = {
137
+ shape?: BadgeShape;
138
+ /** Texto o contenido libre (si no usas count). */
139
+ label?: default_2.ReactNode;
140
+ /** Número para mostrar con max (p.ej. 120 => 99+). */
141
+ count?: number;
142
+ /** Máximo para count; default 99. */
143
+ max?: number;
144
+ tone?: BadgeTone;
145
+ /** Modo punto (sin contenido). */
146
+ dot?: boolean;
147
+ /** Icono built-in por tone. */
148
+ showIcon?: boolean;
149
+ /** Icono custom (ReactNode). Si existe, reemplaza al built-in. */
150
+ icon?: default_2.ReactNode;
151
+ iconPosition?: 'left' | 'right';
152
+ /** Control de presencia para animación entry/exit. */
153
+ show?: boolean;
154
+ animation?: BadgeAnimation;
155
+ /** Duración animación (ms). Default 160. */
156
+ animationDuration?: number;
157
+ /** Clase adicional. */
158
+ className?: string;
159
+ /** Para accesibilidad (si no, se deriva de label/count). */
160
+ ariaLabel?: string;
161
+ /** Override a11y si lo deseas. */
162
+ role?: 'status' | 'alert';
163
+ ariaLive?: 'polite' | 'assertive' | 'off';
164
+ /** Callback al terminar exit (útil si el padre quiere desmontar). */
165
+ onExited?: () => void;
166
+ };
167
+
168
+ export declare type BadgeShape = 'auto' | 'round' | 'pill';
169
+
170
+ export declare type BadgeStackProps = {
171
+ items: Array<Omit<BadgeProps, 'show'>>;
172
+ placement?: BadgePlacement;
173
+ offset?: BadgeOffset;
174
+ /** Separación vertical entre badges (px). */
175
+ step?: number;
176
+ /** Clase del wrapper. */
177
+ className?: string;
178
+ };
179
+
180
+ export declare type BadgeTone = 'success' | 'warning' | 'danger' | 'info';
181
+
182
+ export declare interface BreadcrumbItem {
183
+ label: string;
184
+ href?: string;
185
+ }
186
+
187
+ export declare const Breadcrumbs: ({ items, onNavigate }: BreadcrumbsProps) => JSX.Element;
188
+
189
+ export declare interface BreadcrumbsProps {
190
+ items: BreadcrumbItem[];
191
+ onNavigate?: (item: BreadcrumbItem, index: number) => void;
192
+ }
193
+
194
+ export declare const Button: ({ level, size, type, posIcon, disabled, loading, label, icon, children, theme, color, backgroundColor, className, ...props }: ButtonProps) => JSX.Element;
195
+
196
+ export declare type ButtonLevel = 'primary' | 'secondary' | 'tertiary' | 'link' | 'icon';
197
+
198
+ export declare interface ButtonProps {
199
+ level?: ButtonLevel;
200
+ theme?: ColorFamily;
201
+ color?: string;
202
+ backgroundColor?: string;
203
+ size?: 'small' | 'medium' | 'large';
204
+ type?: 'button' | 'submit' | 'reset';
205
+ label?: string;
206
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
207
+ icon?: React.ReactNode;
208
+ posIcon?: 'left' | 'right';
209
+ disabled?: boolean;
210
+ loading?: boolean;
211
+ children?: React.ReactNode;
212
+ className?: string;
213
+ }
214
+
215
+ export declare const Card: ({ header, footer, children }: CardProps) => JSX.Element;
216
+
217
+ export declare interface CardProps {
218
+ header?: ReactNode;
219
+ footer?: ReactNode;
220
+ children: ReactNode;
221
+ }
222
+
223
+ export declare const Checkbox: ({ checked, onChange, label, disabled, color, theme, indeterminate, error, helperText, id, name }: CheckboxProps) => JSX.Element;
224
+
225
+ export declare interface CheckboxProps {
226
+ checked: boolean;
227
+ onChange: (checked: boolean) => void;
228
+ label?: string;
229
+ disabled?: boolean;
230
+ color?: string;
231
+ theme?: ColorFamily;
232
+ indeterminate?: boolean;
233
+ error?: boolean;
234
+ helperText?: string;
235
+ id?: string;
236
+ name?: string;
237
+ }
238
+
239
+ declare type ColorFamily = keyof typeof colorPalette;
240
+
241
+ /**
242
+ * Paleta de colores centralizada - Importada desde src/config/colorConfig.ts
243
+ * Esta es la única fuente de verdad para los colores del proyecto
244
+ */
245
+ declare const colorPalette: Record<string, Record<number | string, string>>;
246
+
247
+ export declare interface Column<T> {
248
+ id: string;
249
+ label: string;
250
+ accessor: keyof T | ((row: T) => unknown);
251
+ sortable?: boolean;
252
+ filterable?: boolean;
253
+ width?: number;
254
+ minWidth?: number;
255
+ align?: 'left' | 'center' | 'right';
256
+ render?: ({ value, row, column, index }: {
257
+ value: unknown;
258
+ row: T;
259
+ column: Column<T>;
260
+ index: number;
261
+ }) => default_2.ReactNode;
262
+ hidden?: boolean;
263
+ pinned?: boolean;
264
+ draggable?: boolean;
265
+ isAction?: boolean;
266
+ shouldBeRefetch?: boolean;
267
+ fetchColumn?: () => Promise<FilterOption[]>;
268
+ editable?: boolean;
269
+ inputType?: 'text' | 'number' | 'select' | 'date';
270
+ options?: {
271
+ label: string;
272
+ value: string | number;
273
+ }[];
274
+ validation?: (value: unknown) => string | null;
275
+ }
276
+
277
+ export declare const Container: ({ children, size, padding }: ContainerProps) => JSX.Element;
278
+
279
+ export declare interface ContainerProps {
280
+ children: ReactNode;
281
+ size?: ContainerSize;
282
+ padding?: string;
283
+ }
284
+
285
+ export declare type ContainerSize = 'sm' | 'md' | 'lg' | 'xl';
286
+
287
+ export declare const DateInput: ({ value, onChange, min, max, disabled }: DateInputProps) => JSX.Element;
288
+
289
+ export declare interface DateInputProps {
290
+ value: string;
291
+ onChange: (value: string) => void;
292
+ min?: string;
293
+ max?: string;
294
+ disabled?: boolean;
295
+ }
296
+
297
+ export declare type Direction = 'vertical' | 'horizontal';
298
+
299
+ export declare const Divider: ({ orientation }: DividerProps) => JSX.Element;
300
+
301
+ export declare type DividerOrientation = 'horizontal' | 'vertical';
302
+
303
+ export declare interface DividerProps {
304
+ orientation?: DividerOrientation;
305
+ }
306
+
307
+ export declare interface FetchParams {
308
+ page_number: number;
309
+ page_size: number;
310
+ order_by?: string;
311
+ [key: string]: string | number | boolean | Array<string | number> | undefined;
312
+ }
313
+
314
+ export declare interface FetchResponse<T> {
315
+ items: T[];
316
+ /**
317
+ * Total de elementos DESPUÉS de aplicar filtros.
318
+ * Este valor se usa para calcular las páginas disponibles.
319
+ * Ejemplo: Si hay 100 elementos en BD pero se filtran solo 5, este valor debe ser 5.
320
+ */
321
+ total_items: number;
322
+ page?: number;
323
+ page_size?: number;
324
+ total_pages?: number;
325
+ /**
326
+ * Total de elementos SIN filtros (total en base de datos).
327
+ * Campo opcional. Si no se proporciona, se asume igual a total_items.
328
+ * Ejemplo: Si hay 100 elementos en BD, este valor debe ser 100.
329
+ */
330
+ total_unfiltered_items?: number;
331
+ }
332
+
333
+ export declare const FileInput: ({ multiple, accept, onChange, disabled, uploadUrl, onUploadComplete, onUploadError, maxSize, label, helperText, color, id, name }: FileInputProps) => JSX.Element;
334
+
335
+ export declare interface FileInputProps {
336
+ multiple?: boolean;
337
+ accept?: string;
338
+ onChange: (files: File[]) => void;
339
+ disabled?: boolean;
340
+ uploadUrl?: string;
341
+ onUploadComplete?: (response: any) => void;
342
+ onUploadError?: (error: any) => void;
343
+ maxSize?: number;
344
+ label?: string;
345
+ helperText?: string;
346
+ color?: string;
347
+ id?: string;
348
+ name?: string;
349
+ }
350
+
351
+ export declare interface FilterConfig {
352
+ [columnId: string]: {
353
+ type: 'text' | 'select' | 'multiselect';
354
+ value: string | string[];
355
+ textValue?: string;
356
+ options?: string[];
357
+ };
358
+ }
359
+
360
+ export declare interface FilterOption {
361
+ value: string;
362
+ count: number;
363
+ label: string;
364
+ group?: string;
365
+ }
366
+
367
+ export declare interface FilterTagProps {
368
+ columnLabel: string;
369
+ value: string;
370
+ onRemove: () => void;
371
+ }
372
+
373
+ export declare const Grid: ({ children, cols, gap }: GridProps) => JSX.Element;
374
+
375
+ export declare interface GridProps {
376
+ children: ReactNode;
377
+ cols?: 1 | 2 | 3 | 4;
378
+ gap?: string;
379
+ }
380
+
381
+ export declare interface IconProps extends React.SVGProps<SVGSVGElement> {
382
+ color?: string;
383
+ size?: number;
384
+ }
385
+
386
+ export declare type Justify = 'start' | 'center' | 'end';
387
+
388
+ export declare const KPI: ({ variant, title, value, progress, trendValue, trendDirection, icon, chartData, color, footer, subtitle, className, }: KPIProps) => JSX.Element | null;
389
+
390
+ export declare interface KPIProps {
391
+ /**
392
+ * The variant of the KPI card to render
393
+ * @default 'simple'
394
+ */
395
+ variant?: KPIVariant;
396
+ /**
397
+ * The title of the KPI
398
+ */
399
+ title: string;
400
+ /**
401
+ * The main value to display
402
+ */
403
+ value: string | number;
404
+ /**
405
+ * Percentage value for progress or circular variants (0-100)
406
+ */
407
+ progress?: number;
408
+ /**
409
+ * Trend percentage or value to display
410
+ */
411
+ trendValue?: string | number;
412
+ /**
413
+ * Direction of the trend
414
+ */
415
+ trendDirection?: KPITrendDirection;
416
+ /**
417
+ * Optional icon to display
418
+ */
419
+ icon?: React.ReactNode;
420
+ /**
421
+ * Array of numbers for sparkline charts
422
+ */
423
+ chartData?: number[];
424
+ /**
425
+ * Custom color for accents (charts, icons, progress bars)
426
+ * If not provided, defaults will be used based on theme or trend
427
+ */
428
+ color?: string;
429
+ /**
430
+ * Footer text for card-footer variant
431
+ */
432
+ footer?: string;
433
+ /**
434
+ * Optional subtitle for stacked variant
435
+ */
436
+ subtitle?: string;
437
+ /**
438
+ * Additional CSS classes
439
+ */
440
+ className?: string;
441
+ }
442
+
443
+ export declare type KPITrendDirection = 'up' | 'down' | 'neutral';
444
+
445
+ export declare type KPIVariant = 'simple' | 'chart' | 'trend' | 'progress' | 'icon-bg' | 'side-icon' | 'card-footer' | 'circular' | 'sparkline-row' | 'solid' | 'bordered' | 'stacked';
446
+
447
+ export declare interface LabelsProps {
448
+ configuration?: string;
449
+ columnVisibility?: string;
450
+ clearAllFilters?: string;
451
+ noData?: string;
452
+ pagination?: {
453
+ showingItems: string;
454
+ to: string;
455
+ of: string;
456
+ items: string;
457
+ showPerPage?: string;
458
+ perPageItems?: string;
459
+ };
460
+ }
461
+
462
+ export declare const Link: ({ href, children, onClick }: LinkProps) => JSX.Element;
463
+
464
+ export declare interface LinkProps {
465
+ href?: string;
466
+ children: ReactNode;
467
+ onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
468
+ }
469
+
470
+ export declare const Modal: ({ open, onClose, title, children }: ModalProps) => JSX.Element | null;
471
+
472
+ export declare interface ModalProps {
473
+ open: boolean;
474
+ onClose: () => void;
475
+ title?: ReactNode;
476
+ children: ReactNode;
477
+ }
478
+
479
+ export declare const Pagination: ({ page, totalPages, onChange }: PaginationProps) => JSX.Element;
480
+
481
+ export declare interface PaginationConfig {
482
+ page: number;
483
+ pageSize: number;
484
+ total: number;
485
+ }
486
+
487
+ export declare interface PaginationProps {
488
+ page: number;
489
+ totalPages: number;
490
+ onChange: (page: number) => void;
491
+ }
492
+
493
+ export declare const RadioGroup: ({ name, options, value, onChange, disabled }: RadioGroupProps) => JSX.Element;
494
+
495
+ export declare interface RadioGroupProps {
496
+ name: string;
497
+ options: RadioOption[];
498
+ value: string;
499
+ onChange: (value: string) => void;
500
+ disabled?: boolean;
501
+ }
502
+
503
+ export declare interface RadioOption {
504
+ label: string;
505
+ value: string;
506
+ }
507
+
508
+ export declare const Select: ({ options, value, onChange, disabled, placeholder, label, error, helperText, color, fullWidth, id, name }: SelectProps) => JSX.Element;
509
+
510
+ export declare interface SelectOption {
511
+ label: string;
512
+ value: string;
513
+ }
514
+
515
+ export declare interface SelectProps {
516
+ options: SelectOption[];
517
+ value: string;
518
+ onChange: (value: string) => void;
519
+ disabled?: boolean;
520
+ placeholder?: string;
521
+ label?: string;
522
+ error?: string;
523
+ helperText?: string;
524
+ color?: string;
525
+ fullWidth?: boolean;
526
+ id?: string;
527
+ name?: string;
528
+ }
529
+
530
+ export declare const Slider: ({ min, max, step, value, onChange, disabled }: SliderProps) => JSX.Element;
531
+
532
+ export declare interface SliderProps {
533
+ min?: number;
534
+ max?: number;
535
+ step?: number;
536
+ value: number;
537
+ onChange: (value: number) => void;
538
+ disabled?: boolean;
539
+ }
540
+
541
+ export declare interface SortConfig {
542
+ column: string;
543
+ direction: 'asc' | 'desc';
544
+ }
545
+
546
+ export declare const Stack: ({ children, direction, gap, align, justify }: StackProps) => JSX.Element;
547
+
548
+ export declare interface StackProps {
549
+ children: ReactNode;
550
+ direction?: Direction;
551
+ gap?: string;
552
+ align?: Align;
553
+ justify?: Justify;
554
+ }
555
+
556
+ export declare const Switch: ({ checked, onChange, disabled, label, color, size, id, name }: SwitchProps) => JSX.Element;
557
+
558
+ export declare interface SwitchProps {
559
+ checked: boolean;
560
+ onChange: (checked: boolean) => void;
561
+ disabled?: boolean;
562
+ label?: string;
563
+ color?: string;
564
+ size?: 'small' | 'medium';
565
+ id?: string;
566
+ name?: string;
567
+ }
568
+
569
+ export declare interface TabItem {
570
+ id: string;
571
+ label: string;
572
+ content: ReactNode;
573
+ }
574
+
575
+ export declare interface TableConfig<T> {
576
+ columns: Column<T>[];
577
+ sort?: SortConfig;
578
+ filters: FilterConfig;
579
+ pagination: PaginationConfig;
580
+ columnOrder: string[];
581
+ hiddenColumns: string[];
582
+ pinnedColumns: string[];
583
+ }
584
+
585
+ export declare interface TableState<T> {
586
+ data: T[];
587
+ filteredData: T[];
588
+ paginatedData: T[];
589
+ sortConfig?: SortConfig;
590
+ filters: FilterConfig;
591
+ pagination: PaginationConfig;
592
+ columnOrder: string[];
593
+ hiddenColumns: string[];
594
+ pinnedColumns: string[];
595
+ selectedRows: (string | number)[];
596
+ columnWidths: Record<string, number>;
597
+ loading: boolean;
598
+ totalUnfiltered: number;
599
+ }
600
+
601
+ export declare const Tabs: ({ items, activeId, onChange }: TabsProps) => JSX.Element;
602
+
603
+ export declare interface TabsProps {
604
+ items: TabItem[];
605
+ activeId?: string;
606
+ onChange?: (id: string) => void;
607
+ }
608
+
609
+ export declare const TextArea: ({ value, onChange, placeholder, rows, disabled, label, error, helperText, color, fullWidth, id, name }: TextAreaProps) => JSX.Element;
610
+
611
+ export declare interface TextAreaProps {
612
+ value: string;
613
+ onChange: (value: string) => void;
614
+ placeholder?: string;
615
+ rows?: number;
616
+ disabled?: boolean;
617
+ error?: string;
618
+ helperText?: string;
619
+ label?: string;
620
+ color?: string;
621
+ fullWidth?: boolean;
622
+ id?: string;
623
+ name?: string;
624
+ }
625
+
626
+ export { }