@juv/codego-react-ui 3.4.6 → 3.4.8

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.d.cts CHANGED
@@ -104,6 +104,26 @@ interface BreadcrumbProps {
104
104
  }
105
105
  declare function Breadcrumb({ items, separator, maxItems, className, }: BreadcrumbProps): react_jsx_runtime.JSX.Element;
106
106
 
107
+ interface RepeaterField {
108
+ type: "input" | "image" | "attachment";
109
+ key: string;
110
+ label?: string;
111
+ placeholder?: string;
112
+ }
113
+ interface RepeaterProps<T> {
114
+ items: T[];
115
+ onAdd: () => void;
116
+ onRemove: (index: number) => void;
117
+ renderItem?: (item: T, index: number) => React.ReactNode;
118
+ /** Structured field definitions — when provided, renders fields automatically */
119
+ fields?: RepeaterField[];
120
+ /** Called when a field value changes: (rowIndex, key, value) */
121
+ onFieldChange?: (index: number, key: string, value: any) => void;
122
+ addButtonText?: string;
123
+ className?: string;
124
+ }
125
+ declare function Repeater<T extends Record<string, any>>({ items, onAdd, onRemove, renderItem, fields, onFieldChange, addButtonText, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
126
+
107
127
  type ToastVariant = "default" | "success" | "error" | "warning" | "info";
108
128
  type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
109
129
  interface ToastItem {
@@ -289,15 +309,46 @@ interface UseServerTableReturn<T> {
289
309
  error: string | null;
290
310
  goToPage: (page: number) => void;
291
311
  reload: () => void;
292
- /** Manually trigger a data refresh (alias for reload, respects refresh option) */
293
312
  refresh: () => void;
294
- searchValue?: string;
295
- onSearchChange?: (value: string) => void;
313
+ searchValue: string;
314
+ onSearchChange: (value: string) => void;
315
+ page: number;
316
+ onPageChange: (page: number) => void;
317
+ sort: {
318
+ key: string;
319
+ direction: "asc" | "desc";
320
+ }[];
321
+ onSortChange: (sort: {
322
+ key: string;
323
+ direction: "asc" | "desc";
324
+ }[]) => void;
325
+ onRowClick?: (item: T) => void;
326
+ onRowDoubleClick?: (item: T) => void;
327
+ rowClassName?: (item: T) => string;
328
+ expandable?: boolean;
329
+ renderExpanded?: (item: T) => React.ReactNode;
330
+ columnVisibility?: Record<string, boolean>;
331
+ onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
332
+ exportable?: boolean;
333
+ onExport?: (type: "csv" | "excel" | "pdf") => void;
334
+ virtualized?: boolean;
335
+ draggable?: boolean;
336
+ onRowReorder?: (data: T[]) => void;
337
+ keyboardNavigation?: boolean;
338
+ theme?: "light" | "dark" | "auto";
339
+ meta?: Record<string, any>;
340
+ actions?: Record<string, (item: T) => void>;
341
+ searchable?: boolean;
342
+ searchPlaceholder?: string;
343
+ clientPagination?: boolean;
344
+ itemsPerPage?: number;
345
+ selectable?: boolean;
346
+ onBulkDelete?: (selectedIds: string[]) => void;
347
+ bulkDeleteBaseUrl?: string;
348
+ idKey?: keyof T;
349
+ defaultActions?: DefaultActionsConfig<T>;
350
+ className?: string;
296
351
  }
297
- /**
298
- * Server-side pagination prop passed to the Table component
299
- * @interface ServerPaginationProp
300
- */
301
352
  interface ServerPaginationProp {
302
353
  pagination: ServerPagination;
303
354
  currentPage: number;
@@ -325,6 +376,11 @@ declare function useServerTable<T extends Record<string, any>>({ url, params, en
325
376
  * @type {ActionFieldType}
326
377
  */
327
378
  type ActionFieldType = "input" | "password" | "textarea" | "checkbox" | "toggle" | "select" | "radio" | "slider" | "tag-input" | "otp" | "combobox" | "color-picker" | "date-range" | "rich-text" | "file-upload" | "repeater";
379
+ /**
380
+ * Display type for viewForm fields — controls how the value is rendered in the View modal
381
+ * @type {ViewFieldType}
382
+ */
383
+ type ViewFieldType = "text" | "image" | "checkbox" | "toggle" | "attachment" | "text-url" | "text-url-open-other-tabs" | "image-url" | "image-url-open-other-tabs" | "repeater";
328
384
  /**
329
385
  * Configuration for a single field in action forms (edit/view modals)
330
386
  * @interface ActionField
@@ -350,6 +406,8 @@ interface ActionField {
350
406
  step?: number;
351
407
  /** Number of OTP digits for type="otp" */
352
408
  digits?: number;
409
+ /** Field definitions for type="repeater" / viewType="repeater" */
410
+ repeaterFields?: RepeaterField[];
353
411
  /** Validation: regex or built-in preset ("email" | "url" | "numeric" | "alpha" | "alphanumeric") */
354
412
  validation?: RegExp | "email" | "url" | "numeric" | "alpha" | "alphanumeric";
355
413
  /** Custom message shown when validation fails */
@@ -364,6 +422,17 @@ interface ActionField {
364
422
  component?: React.ReactNode;
365
423
  /** Hide this field from view/edit forms */
366
424
  hidden?: boolean;
425
+ /**
426
+ * Display type for viewForm — controls how the value is rendered in the View modal.
427
+ * Overrides type for view-only rendering.
428
+ * "text" | "image" | "checkbox" | "toggle" | "attachment" |
429
+ * "text-url" | "text-url-open-other-tabs" | "image-url" | "image-url-open-other-tabs"
430
+ */
431
+ viewType?: ViewFieldType;
432
+ /** Width applied to the field value in the View modal (e.g. 120, "100%", "8rem") */
433
+ width?: number | string;
434
+ /** Height applied to the field value in the View modal (e.g. 80, "5rem") */
435
+ height?: number | string;
367
436
  }
368
437
  /**
369
438
  * Configuration for customizing the appearance of action buttons (View/Edit/Delete)
@@ -438,6 +507,8 @@ interface DefaultActionsConfig<T> {
438
507
  editForm?: ActionField[];
439
508
  /** Fields rendered in the View modal. Auto-derived from row keys when omitted. */
440
509
  viewForm?: ActionField[];
510
+ /** Grid columns for the view form layout (e.g. 2 = two-column grid). Default single column. */
511
+ viewFormGrid?: number;
441
512
  /** Grid columns for the edit form layout (e.g. 2 = two-column grid). Default single column. */
442
513
  editFormGrid?: number;
443
514
  /** Size of the View / Edit / Delete / extra action buttons. Default "xs". */
@@ -537,7 +608,7 @@ type ModalWidth = keyof typeof MODAL_WIDTH;
537
608
  interface Column<T> {
538
609
  key: keyof T | string;
539
610
  title: string;
540
- type?: "text" | "image" | "badge" | "icon" | "stack" | "select" | "toggle" | "color" | "checkbox";
611
+ type?: "text" | "image" | "badge" | "icon" | "stack" | "select" | "toggle" | "color" | "checkbox" | "text-url";
541
612
  stackProps?: {
542
613
  limit?: number;
543
614
  stacked?: boolean;
@@ -564,6 +635,18 @@ interface Column<T> {
564
635
  tooltip?: (item: T) => string;
565
636
  /** Allow copying cell content */
566
637
  copyable?: boolean;
638
+ /**
639
+ * For type="text-url": static URL to navigate to. If omitted, uses the cell value as the URL.
640
+ * Supports dynamic URL via function: (item) => string
641
+ */
642
+ redirect?: string | ((item: T) => string);
643
+ /** For type="text-url": open link in a new tab. Default false. */
644
+ openNewTab?: boolean;
645
+ /**
646
+ * For type="text-url": underline color.
647
+ * Accepts: "primary" | "info" | "success" | "warning" | "danger" | any hex | rgb | rgba string.
648
+ */
649
+ underlineColor?: "primary" | "info" | "success" | "warning" | "danger" | string;
567
650
  }
568
651
  /**
569
652
  * Props for the Table component
@@ -606,15 +689,30 @@ interface TableProps<T> {
606
689
  actions?: Record<string, (item: T) => void>;
607
690
  searchable?: boolean;
608
691
  searchPlaceholder?: string;
609
- pagination?: boolean;
692
+ clientPagination?: boolean;
610
693
  itemsPerPage?: number;
611
694
  selectable?: boolean;
612
695
  onBulkDelete?: (selectedIds: string[]) => void;
613
696
  idKey?: keyof T;
697
+ /**
698
+ * Base URL for built-in bulk delete actions.
699
+ * DELETE all → `{bulkDeleteBaseUrl}/delete/all`
700
+ * DELETE selected → `{bulkDeleteBaseUrl}/delete/{ids}/selected`
701
+ */
702
+ bulkDeleteBaseUrl?: string;
614
703
  /** When provided, appends an Actions column with View / Edit / Delete buttons */
615
704
  defaultActions?: DefaultActionsConfig<T>;
616
705
  /** Pass the serverPagination object from useServerTable to enable server-side pagination */
617
706
  serverPagination?: ServerPaginationProp | null;
707
+ /**
708
+ * Visual variant of the table.
709
+ * - `"default"` — bordered card with subtle bg (original style)
710
+ * - `"zebra"` — alternating row colors for easy scanning
711
+ * - `"card"` — each row rendered as an individual card
712
+ * - `"glass"` — glassmorphism: transparent + backdrop blur
713
+ * - `"soft"` — neumorphic soft shadows, no hard borders
714
+ */
715
+ variant?: "default" | "zebra" | "card" | "glass" | "soft";
618
716
  className?: string;
619
717
  }
620
718
  /**
@@ -634,7 +732,7 @@ interface TableProps<T> {
634
732
  * { key: "active", type: "toggle", onChange: handleToggle },
635
733
  * ]}
636
734
  * searchable
637
- * pagination
735
+ * clientPagination
638
736
  * selectable
639
737
  * onBulkDelete={handleBulkDelete}
640
738
  * defaultActions={{
@@ -644,7 +742,7 @@ interface TableProps<T> {
644
742
  * />
645
743
  * ```
646
744
  */
647
- declare function Table<T extends Record<string, any>>({ data, columns, searchable, searchPlaceholder, pagination, itemsPerPage, selectable, onBulkDelete, idKey, defaultActions, serverPagination, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
745
+ declare function Table<T extends Record<string, any>>({ data, columns, loading, emptyState, error: errorProp, searchable, searchPlaceholder, searchValue: controlledSearch, onSearchChange, clientPagination, itemsPerPage, selectable, onBulkDelete, idKey, bulkDeleteBaseUrl, defaultActions, serverPagination, variant, className, onRowClick, onRowDoubleClick, rowClassName, expandable, renderExpanded, columnVisibility, onColumnVisibilityChange, exportable, onExport, virtualized, draggable, onRowReorder, keyboardNavigation, }: TableProps<T>): react_jsx_runtime.JSX.Element;
648
746
 
649
747
  type BulletinPriority = "low" | "medium" | "high" | "urgent";
650
748
  type BulletinLayout = "grid" | "list" | "masonry";
@@ -1925,16 +2023,6 @@ interface RadioGroupProps {
1925
2023
  }
1926
2024
  declare function RadioGroup({ options, value: controlledValue, defaultValue, onChange, variant, size, orientation, name, className, required, error, }: RadioGroupProps): react_jsx_runtime.JSX.Element;
1927
2025
 
1928
- interface RepeaterProps<T> {
1929
- items: T[];
1930
- onAdd: () => void;
1931
- onRemove: (index: number) => void;
1932
- renderItem: (item: T, index: number) => React.ReactNode;
1933
- addButtonText?: string;
1934
- className?: string;
1935
- }
1936
- declare function Repeater<T>({ items, onAdd, onRemove, renderItem, addButtonText, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
1937
-
1938
2026
  interface ResizablePanelsProps {
1939
2027
  children: [React.ReactNode, React.ReactNode];
1940
2028
  orientation?: "horizontal" | "vertical";
package/dist/index.d.ts CHANGED
@@ -104,6 +104,26 @@ interface BreadcrumbProps {
104
104
  }
105
105
  declare function Breadcrumb({ items, separator, maxItems, className, }: BreadcrumbProps): react_jsx_runtime.JSX.Element;
106
106
 
107
+ interface RepeaterField {
108
+ type: "input" | "image" | "attachment";
109
+ key: string;
110
+ label?: string;
111
+ placeholder?: string;
112
+ }
113
+ interface RepeaterProps<T> {
114
+ items: T[];
115
+ onAdd: () => void;
116
+ onRemove: (index: number) => void;
117
+ renderItem?: (item: T, index: number) => React.ReactNode;
118
+ /** Structured field definitions — when provided, renders fields automatically */
119
+ fields?: RepeaterField[];
120
+ /** Called when a field value changes: (rowIndex, key, value) */
121
+ onFieldChange?: (index: number, key: string, value: any) => void;
122
+ addButtonText?: string;
123
+ className?: string;
124
+ }
125
+ declare function Repeater<T extends Record<string, any>>({ items, onAdd, onRemove, renderItem, fields, onFieldChange, addButtonText, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
126
+
107
127
  type ToastVariant = "default" | "success" | "error" | "warning" | "info";
108
128
  type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
109
129
  interface ToastItem {
@@ -289,15 +309,46 @@ interface UseServerTableReturn<T> {
289
309
  error: string | null;
290
310
  goToPage: (page: number) => void;
291
311
  reload: () => void;
292
- /** Manually trigger a data refresh (alias for reload, respects refresh option) */
293
312
  refresh: () => void;
294
- searchValue?: string;
295
- onSearchChange?: (value: string) => void;
313
+ searchValue: string;
314
+ onSearchChange: (value: string) => void;
315
+ page: number;
316
+ onPageChange: (page: number) => void;
317
+ sort: {
318
+ key: string;
319
+ direction: "asc" | "desc";
320
+ }[];
321
+ onSortChange: (sort: {
322
+ key: string;
323
+ direction: "asc" | "desc";
324
+ }[]) => void;
325
+ onRowClick?: (item: T) => void;
326
+ onRowDoubleClick?: (item: T) => void;
327
+ rowClassName?: (item: T) => string;
328
+ expandable?: boolean;
329
+ renderExpanded?: (item: T) => React.ReactNode;
330
+ columnVisibility?: Record<string, boolean>;
331
+ onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
332
+ exportable?: boolean;
333
+ onExport?: (type: "csv" | "excel" | "pdf") => void;
334
+ virtualized?: boolean;
335
+ draggable?: boolean;
336
+ onRowReorder?: (data: T[]) => void;
337
+ keyboardNavigation?: boolean;
338
+ theme?: "light" | "dark" | "auto";
339
+ meta?: Record<string, any>;
340
+ actions?: Record<string, (item: T) => void>;
341
+ searchable?: boolean;
342
+ searchPlaceholder?: string;
343
+ clientPagination?: boolean;
344
+ itemsPerPage?: number;
345
+ selectable?: boolean;
346
+ onBulkDelete?: (selectedIds: string[]) => void;
347
+ bulkDeleteBaseUrl?: string;
348
+ idKey?: keyof T;
349
+ defaultActions?: DefaultActionsConfig<T>;
350
+ className?: string;
296
351
  }
297
- /**
298
- * Server-side pagination prop passed to the Table component
299
- * @interface ServerPaginationProp
300
- */
301
352
  interface ServerPaginationProp {
302
353
  pagination: ServerPagination;
303
354
  currentPage: number;
@@ -325,6 +376,11 @@ declare function useServerTable<T extends Record<string, any>>({ url, params, en
325
376
  * @type {ActionFieldType}
326
377
  */
327
378
  type ActionFieldType = "input" | "password" | "textarea" | "checkbox" | "toggle" | "select" | "radio" | "slider" | "tag-input" | "otp" | "combobox" | "color-picker" | "date-range" | "rich-text" | "file-upload" | "repeater";
379
+ /**
380
+ * Display type for viewForm fields — controls how the value is rendered in the View modal
381
+ * @type {ViewFieldType}
382
+ */
383
+ type ViewFieldType = "text" | "image" | "checkbox" | "toggle" | "attachment" | "text-url" | "text-url-open-other-tabs" | "image-url" | "image-url-open-other-tabs" | "repeater";
328
384
  /**
329
385
  * Configuration for a single field in action forms (edit/view modals)
330
386
  * @interface ActionField
@@ -350,6 +406,8 @@ interface ActionField {
350
406
  step?: number;
351
407
  /** Number of OTP digits for type="otp" */
352
408
  digits?: number;
409
+ /** Field definitions for type="repeater" / viewType="repeater" */
410
+ repeaterFields?: RepeaterField[];
353
411
  /** Validation: regex or built-in preset ("email" | "url" | "numeric" | "alpha" | "alphanumeric") */
354
412
  validation?: RegExp | "email" | "url" | "numeric" | "alpha" | "alphanumeric";
355
413
  /** Custom message shown when validation fails */
@@ -364,6 +422,17 @@ interface ActionField {
364
422
  component?: React.ReactNode;
365
423
  /** Hide this field from view/edit forms */
366
424
  hidden?: boolean;
425
+ /**
426
+ * Display type for viewForm — controls how the value is rendered in the View modal.
427
+ * Overrides type for view-only rendering.
428
+ * "text" | "image" | "checkbox" | "toggle" | "attachment" |
429
+ * "text-url" | "text-url-open-other-tabs" | "image-url" | "image-url-open-other-tabs"
430
+ */
431
+ viewType?: ViewFieldType;
432
+ /** Width applied to the field value in the View modal (e.g. 120, "100%", "8rem") */
433
+ width?: number | string;
434
+ /** Height applied to the field value in the View modal (e.g. 80, "5rem") */
435
+ height?: number | string;
367
436
  }
368
437
  /**
369
438
  * Configuration for customizing the appearance of action buttons (View/Edit/Delete)
@@ -438,6 +507,8 @@ interface DefaultActionsConfig<T> {
438
507
  editForm?: ActionField[];
439
508
  /** Fields rendered in the View modal. Auto-derived from row keys when omitted. */
440
509
  viewForm?: ActionField[];
510
+ /** Grid columns for the view form layout (e.g. 2 = two-column grid). Default single column. */
511
+ viewFormGrid?: number;
441
512
  /** Grid columns for the edit form layout (e.g. 2 = two-column grid). Default single column. */
442
513
  editFormGrid?: number;
443
514
  /** Size of the View / Edit / Delete / extra action buttons. Default "xs". */
@@ -537,7 +608,7 @@ type ModalWidth = keyof typeof MODAL_WIDTH;
537
608
  interface Column<T> {
538
609
  key: keyof T | string;
539
610
  title: string;
540
- type?: "text" | "image" | "badge" | "icon" | "stack" | "select" | "toggle" | "color" | "checkbox";
611
+ type?: "text" | "image" | "badge" | "icon" | "stack" | "select" | "toggle" | "color" | "checkbox" | "text-url";
541
612
  stackProps?: {
542
613
  limit?: number;
543
614
  stacked?: boolean;
@@ -564,6 +635,18 @@ interface Column<T> {
564
635
  tooltip?: (item: T) => string;
565
636
  /** Allow copying cell content */
566
637
  copyable?: boolean;
638
+ /**
639
+ * For type="text-url": static URL to navigate to. If omitted, uses the cell value as the URL.
640
+ * Supports dynamic URL via function: (item) => string
641
+ */
642
+ redirect?: string | ((item: T) => string);
643
+ /** For type="text-url": open link in a new tab. Default false. */
644
+ openNewTab?: boolean;
645
+ /**
646
+ * For type="text-url": underline color.
647
+ * Accepts: "primary" | "info" | "success" | "warning" | "danger" | any hex | rgb | rgba string.
648
+ */
649
+ underlineColor?: "primary" | "info" | "success" | "warning" | "danger" | string;
567
650
  }
568
651
  /**
569
652
  * Props for the Table component
@@ -606,15 +689,30 @@ interface TableProps<T> {
606
689
  actions?: Record<string, (item: T) => void>;
607
690
  searchable?: boolean;
608
691
  searchPlaceholder?: string;
609
- pagination?: boolean;
692
+ clientPagination?: boolean;
610
693
  itemsPerPage?: number;
611
694
  selectable?: boolean;
612
695
  onBulkDelete?: (selectedIds: string[]) => void;
613
696
  idKey?: keyof T;
697
+ /**
698
+ * Base URL for built-in bulk delete actions.
699
+ * DELETE all → `{bulkDeleteBaseUrl}/delete/all`
700
+ * DELETE selected → `{bulkDeleteBaseUrl}/delete/{ids}/selected`
701
+ */
702
+ bulkDeleteBaseUrl?: string;
614
703
  /** When provided, appends an Actions column with View / Edit / Delete buttons */
615
704
  defaultActions?: DefaultActionsConfig<T>;
616
705
  /** Pass the serverPagination object from useServerTable to enable server-side pagination */
617
706
  serverPagination?: ServerPaginationProp | null;
707
+ /**
708
+ * Visual variant of the table.
709
+ * - `"default"` — bordered card with subtle bg (original style)
710
+ * - `"zebra"` — alternating row colors for easy scanning
711
+ * - `"card"` — each row rendered as an individual card
712
+ * - `"glass"` — glassmorphism: transparent + backdrop blur
713
+ * - `"soft"` — neumorphic soft shadows, no hard borders
714
+ */
715
+ variant?: "default" | "zebra" | "card" | "glass" | "soft";
618
716
  className?: string;
619
717
  }
620
718
  /**
@@ -634,7 +732,7 @@ interface TableProps<T> {
634
732
  * { key: "active", type: "toggle", onChange: handleToggle },
635
733
  * ]}
636
734
  * searchable
637
- * pagination
735
+ * clientPagination
638
736
  * selectable
639
737
  * onBulkDelete={handleBulkDelete}
640
738
  * defaultActions={{
@@ -644,7 +742,7 @@ interface TableProps<T> {
644
742
  * />
645
743
  * ```
646
744
  */
647
- declare function Table<T extends Record<string, any>>({ data, columns, searchable, searchPlaceholder, pagination, itemsPerPage, selectable, onBulkDelete, idKey, defaultActions, serverPagination, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
745
+ declare function Table<T extends Record<string, any>>({ data, columns, loading, emptyState, error: errorProp, searchable, searchPlaceholder, searchValue: controlledSearch, onSearchChange, clientPagination, itemsPerPage, selectable, onBulkDelete, idKey, bulkDeleteBaseUrl, defaultActions, serverPagination, variant, className, onRowClick, onRowDoubleClick, rowClassName, expandable, renderExpanded, columnVisibility, onColumnVisibilityChange, exportable, onExport, virtualized, draggable, onRowReorder, keyboardNavigation, }: TableProps<T>): react_jsx_runtime.JSX.Element;
648
746
 
649
747
  type BulletinPriority = "low" | "medium" | "high" | "urgent";
650
748
  type BulletinLayout = "grid" | "list" | "masonry";
@@ -1925,16 +2023,6 @@ interface RadioGroupProps {
1925
2023
  }
1926
2024
  declare function RadioGroup({ options, value: controlledValue, defaultValue, onChange, variant, size, orientation, name, className, required, error, }: RadioGroupProps): react_jsx_runtime.JSX.Element;
1927
2025
 
1928
- interface RepeaterProps<T> {
1929
- items: T[];
1930
- onAdd: () => void;
1931
- onRemove: (index: number) => void;
1932
- renderItem: (item: T, index: number) => React.ReactNode;
1933
- addButtonText?: string;
1934
- className?: string;
1935
- }
1936
- declare function Repeater<T>({ items, onAdd, onRemove, renderItem, addButtonText, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
1937
-
1938
2026
  interface ResizablePanelsProps {
1939
2027
  children: [React.ReactNode, React.ReactNode];
1940
2028
  orientation?: "horizontal" | "vertical";