ucol-ui 0.1.42 → 0.1.43
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/ucol-ui.d.ts +130 -0
- package/dist/ucol-ui.js +87 -87
- package/dist/ucol-ui.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/ucol-ui.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare interface ActionConfig<T extends Record<string, unknown> = Record
|
|
|
20
20
|
showView?: boolean | ((record: T) => boolean);
|
|
21
21
|
customIcons?: ActionIcons;
|
|
22
22
|
refreshButtonText?: string;
|
|
23
|
+
useDefaultDeleteConfirm?: boolean;
|
|
23
24
|
customActionsColor?: {
|
|
24
25
|
edit?: string;
|
|
25
26
|
delete?: string;
|
|
@@ -180,6 +181,38 @@ export declare interface ColumnsProps<T = Record<string, unknown>> {
|
|
|
180
181
|
sorter?: boolean | ((a: T, b: T) => number);
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Combina múltiples condiciones con operador AND
|
|
186
|
+
* @param conditions - Array de funciones de condición
|
|
187
|
+
* @returns Función que retorna true solo si todas las condiciones son verdaderas
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* // Mostrar acciones solo si es draft Y pertenece al usuario actual
|
|
191
|
+
* actionConfig: {
|
|
192
|
+
* showEdit: combineConditions([
|
|
193
|
+
* showActionWhen('status', 'draft'),
|
|
194
|
+
* hideActionWhen('user.uuid', currentUserUuid)
|
|
195
|
+
* ])
|
|
196
|
+
* }
|
|
197
|
+
*/
|
|
198
|
+
export declare const combineConditions: <T extends Record<string, unknown>>(conditions: Array<(record: T) => boolean>) => (record: T) => boolean;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Combina múltiples condiciones con operador OR
|
|
202
|
+
* @param conditions - Array de funciones de condición
|
|
203
|
+
* @returns Función que retorna true si al menos una condición es verdadera
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* // Mostrar acciones si es draft O es del usuario actual
|
|
207
|
+
* actionConfig: {
|
|
208
|
+
* showEdit: combineConditionsOr([
|
|
209
|
+
* showActionWhen('status', 'draft'),
|
|
210
|
+
* showActionWhen('user.uuid', currentUserUuid)
|
|
211
|
+
* ])
|
|
212
|
+
* }
|
|
213
|
+
*/
|
|
214
|
+
export declare const combineConditionsOr: <T extends Record<string, unknown>>(conditions: Array<(record: T) => boolean>) => (record: T) => boolean;
|
|
215
|
+
|
|
183
216
|
/**
|
|
184
217
|
* Crea un generador de acciones tipado para un tipo específico
|
|
185
218
|
* @returns Una función createMoreAction tipada con T
|
|
@@ -396,6 +429,14 @@ export declare interface FilterItem {
|
|
|
396
429
|
children?: FilterItem[];
|
|
397
430
|
}
|
|
398
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Convierte un objeto anidado en un objeto plano con notación de punto.
|
|
434
|
+
* @param obj Objeto con estructura anidada (ej: {user: {first_name: "John"}})
|
|
435
|
+
* @param parentKey Prefijo para las keys (usado internamente en la recursión)
|
|
436
|
+
* @returns Objeto plano con keys en notación de punto (ej: {"user.first_name": "John"})
|
|
437
|
+
*/
|
|
438
|
+
export declare const flattenObject: (obj: Record<string, unknown>, parentKey?: string) => Record<string, unknown>;
|
|
439
|
+
|
|
399
440
|
export declare interface FormField {
|
|
400
441
|
type: FieldType;
|
|
401
442
|
name: string;
|
|
@@ -433,6 +474,52 @@ export declare const generateColumns: <T extends object>(fields: Record<string,
|
|
|
433
474
|
*/
|
|
434
475
|
export declare const generateFields: (fields: Record<string, SharedFieldConfig>) => FormField[];
|
|
435
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Función auxiliar para acceder a propiedades anidadas usando notación de punto.
|
|
479
|
+
* @param obj Objeto del cual extraer el valor.
|
|
480
|
+
* @param path Ruta de la propiedad (ej: "user.first_name").
|
|
481
|
+
* @returns Valor de la propiedad anidada o undefined si no existe.
|
|
482
|
+
*/
|
|
483
|
+
export declare const getNestedValue: <T extends object>(obj: T, path: string) => unknown;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Crea una función que oculta acciones cuando un campo del registro coincide con un valor específico
|
|
487
|
+
* @param fieldPath - Ruta del campo a comparar (soporta notación de punto para campos anidados)
|
|
488
|
+
* @param value - Valor con el que comparar
|
|
489
|
+
* @returns Función que retorna false si el valor coincide, true en caso contrario
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* // Ocultar acciones si el estado es 'archived'
|
|
493
|
+
* actionConfig: {
|
|
494
|
+
* showEdit: hideActionWhen('status', 'archived'),
|
|
495
|
+
* showDelete: hideActionWhen('status', 'archived')
|
|
496
|
+
* }
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* // Ocultar acciones si el user.uuid coincide con el uuid del usuario actual
|
|
500
|
+
* const currentUserUuid = '123-456';
|
|
501
|
+
* actionConfig: {
|
|
502
|
+
* showEdit: hideActionWhen('user.uuid', currentUserUuid),
|
|
503
|
+
* showDelete: hideActionWhen('user.uuid', currentUserUuid)
|
|
504
|
+
* }
|
|
505
|
+
*/
|
|
506
|
+
export declare const hideActionWhen: <T extends Record<string, unknown>>(fieldPath: string, value: unknown) => (record: T) => boolean;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Crea una función que oculta acciones cuando un campo del registro está incluido en una lista de valores
|
|
510
|
+
* @param fieldPath - Ruta del campo a comparar
|
|
511
|
+
* @param values - Array de valores a comparar
|
|
512
|
+
* @returns Función que retorna false si el valor está en la lista, true en caso contrario
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* // Ocultar acciones si el estado es 'archived' o 'deleted'
|
|
516
|
+
* actionConfig: {
|
|
517
|
+
* showEdit: hideActionWhenIn('status', ['archived', 'deleted']),
|
|
518
|
+
* showDelete: hideActionWhenIn('status', ['archived', 'deleted'])
|
|
519
|
+
* }
|
|
520
|
+
*/
|
|
521
|
+
export declare const hideActionWhenIn: <T extends Record<string, unknown>>(fieldPath: string, values: unknown[]) => (record: T) => boolean;
|
|
522
|
+
|
|
436
523
|
export declare interface MoreActions<T = Record<string, unknown>> {
|
|
437
524
|
key: string;
|
|
438
525
|
label?: string;
|
|
@@ -451,6 +538,19 @@ declare type MutationConfig<TData, TError, TVariables> = {
|
|
|
451
538
|
onSettled?: (data: TData | undefined, error: TError | null) => void;
|
|
452
539
|
};
|
|
453
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Niega una condición
|
|
543
|
+
* @param condition - Función de condición a negar
|
|
544
|
+
* @returns Función que retorna el opuesto de la condición
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* // Ocultar acciones si NO es draft
|
|
548
|
+
* actionConfig: {
|
|
549
|
+
* showEdit: not(showActionWhen('status', 'draft'))
|
|
550
|
+
* }
|
|
551
|
+
*/
|
|
552
|
+
export declare const not: <T extends Record<string, unknown>>(condition: (record: T) => boolean) => (record: T) => boolean;
|
|
553
|
+
|
|
454
554
|
/**
|
|
455
555
|
* Componente de Notificación
|
|
456
556
|
* @description Muestra una notificación con un mensaje
|
|
@@ -560,6 +660,14 @@ export declare interface SelectDependencyConfig {
|
|
|
560
660
|
transformRequest?: (value: string | number) => Record<string, string>;
|
|
561
661
|
}
|
|
562
662
|
|
|
663
|
+
/**
|
|
664
|
+
* Función auxiliar para establecer propiedades anidadas usando notación de punto.
|
|
665
|
+
* @param obj Objeto en el cual establecer el valor.
|
|
666
|
+
* @param path Ruta de la propiedad (ej: "user.first_name").
|
|
667
|
+
* @param value Valor a establecer.
|
|
668
|
+
*/
|
|
669
|
+
export declare const setNestedValue: (obj: Record<string, unknown>, path: string, value: unknown) => void;
|
|
670
|
+
|
|
563
671
|
export declare interface SharedFieldConfig<T = Record<string, unknown>> {
|
|
564
672
|
key: string;
|
|
565
673
|
title: string;
|
|
@@ -597,6 +705,21 @@ export declare interface SharedFieldConfig<T = Record<string, unknown>> {
|
|
|
597
705
|
radioConfig?: RadioConfig;
|
|
598
706
|
}
|
|
599
707
|
|
|
708
|
+
/**
|
|
709
|
+
* Crea una función que muestra acciones solo cuando un campo del registro coincide con un valor específico
|
|
710
|
+
* @param fieldPath - Ruta del campo a comparar (soporta notación de punto para campos anidados)
|
|
711
|
+
* @param value - Valor con el que comparar
|
|
712
|
+
* @returns Función que retorna true si el valor coincide, false en caso contrario
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* // Mostrar acciones solo si el estado es 'draft'
|
|
716
|
+
* actionConfig: {
|
|
717
|
+
* showEdit: showActionWhen('status', 'draft'),
|
|
718
|
+
* showDelete: showActionWhen('status', 'draft')
|
|
719
|
+
* }
|
|
720
|
+
*/
|
|
721
|
+
export declare const showActionWhen: <T extends Record<string, unknown>>(fieldPath: string, value: unknown) => (record: T) => boolean;
|
|
722
|
+
|
|
600
723
|
declare type SortFunction<T> = (a: T, b: T) => number;
|
|
601
724
|
|
|
602
725
|
/**
|
|
@@ -639,6 +762,13 @@ export declare interface ThemeConfig {
|
|
|
639
762
|
|
|
640
763
|
export declare const Title: ({ level, children, className, style }: CustomTitleProps) => JSX.Element;
|
|
641
764
|
|
|
765
|
+
/**
|
|
766
|
+
* Convierte un objeto plano con notación de punto en un objeto anidado.
|
|
767
|
+
* @param flatObj Objeto plano con keys en notación de punto (ej: {"user.first_name": "John"})
|
|
768
|
+
* @returns Objeto con estructura anidada (ej: {user: {first_name: "John"}})
|
|
769
|
+
*/
|
|
770
|
+
export declare const unflattenObject: (flatObj: Record<string, unknown>) => Record<string, unknown>;
|
|
771
|
+
|
|
642
772
|
declare interface UploadConfig {
|
|
643
773
|
textButton?: string;
|
|
644
774
|
iconButton?: string;
|