@juv/codego-react-ui 3.2.8 → 3.3.1

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
@@ -194,11 +194,19 @@ interface NotificationBannerProps {
194
194
  }
195
195
  declare function NotificationBanner({ variant, title, description, icon, closable, onClose, action, className, }: NotificationBannerProps): react_jsx_runtime.JSX.Element;
196
196
 
197
+ /**
198
+ * Represents a single pagination link in server-side pagination
199
+ * @interface ServerPaginationLink
200
+ */
197
201
  interface ServerPaginationLink {
198
202
  page: number;
199
203
  url: string;
200
204
  active: boolean;
201
205
  }
206
+ /**
207
+ * Server-side pagination metadata returned from the API
208
+ * @interface ServerPagination
209
+ */
202
210
  interface ServerPagination {
203
211
  first_page_url: string;
204
212
  last_page_url: string;
@@ -209,11 +217,20 @@ interface ServerPagination {
209
217
  total: number;
210
218
  links: ServerPaginationLink[];
211
219
  }
220
+ /**
221
+ * Response structure from server-side table API
222
+ * @template T - The data type for table rows
223
+ * @extends ServerPagination
224
+ */
212
225
  interface ServerTableResponse<T> extends ServerPagination {
213
226
  current_page: number;
214
227
  data: T[];
215
228
  pagination?: ServerPagination;
216
229
  }
230
+ /**
231
+ * Options for the useServerTable hook
232
+ * @interface UseServerTableOptions
233
+ */
217
234
  interface UseServerTableOptions {
218
235
  /** Base URL — page param appended automatically: `url?page=N` */
219
236
  url: string;
@@ -232,6 +249,11 @@ interface UseServerTableOptions {
232
249
  */
233
250
  columnOverrides?: Record<string, Partial<Column<any>>>;
234
251
  }
252
+ /**
253
+ * Return type from the useServerTable hook
254
+ * @template T - The data type for table rows
255
+ * @interface UseServerTableReturn
256
+ */
235
257
  interface UseServerTableReturn<T> {
236
258
  data: T[];
237
259
  columns: Column<T>[];
@@ -243,24 +265,52 @@ interface UseServerTableReturn<T> {
243
265
  goToPage: (page: number) => void;
244
266
  reload: () => void;
245
267
  }
268
+ /**
269
+ * Server-side pagination prop passed to the Table component
270
+ * @interface ServerPaginationProp
271
+ */
246
272
  interface ServerPaginationProp {
247
273
  pagination: ServerPagination;
248
274
  currentPage: number;
249
275
  goToPage: (page: number) => void;
250
276
  }
277
+ /**
278
+ * Custom hook for fetching and managing server-side paginated table data.
279
+ * Supports Laravel encryption, auto-column derivation, and flexible pagination.
280
+ *
281
+ * @template T - The data type for table rows
282
+ * @param options - Configuration options for the server table
283
+ * @returns Object with data, columns, pagination state, loading, error, and control functions
284
+ *
285
+ * @example
286
+ * ```tsx
287
+ * const { data, columns, serverPagination, loading } = useServerTable({
288
+ * url: "/api/users",
289
+ * params: { sort: "name" },
290
+ * })
291
+ * ```
292
+ */
251
293
  declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides }: UseServerTableOptions): UseServerTableReturn<T>;
294
+ /**
295
+ * Available field types for action forms (edit/view modals)
296
+ * @type {ActionFieldType}
297
+ */
252
298
  type ActionFieldType = "input" | "password" | "textarea" | "checkbox" | "toggle" | "select" | "radio" | "slider" | "tag-input" | "otp" | "combobox" | "color-picker" | "date-range" | "rich-text" | "file-upload" | "repeater";
299
+ /**
300
+ * Configuration for a single field in action forms (edit/view modals)
301
+ * @interface ActionField
302
+ */
253
303
  interface ActionField {
254
304
  key: string;
255
305
  label: string;
256
306
  type?: ActionFieldType;
257
307
  /** HTML input type for type="input" (e.g. "email", "number", "password") */
258
308
  inputType?: string;
259
- /** Options for type="select", "radio", "combobox" — string[] or { label, value }[] */
309
+ /** Options for type="select", "radio", "combobox" — string[], { label, value }[], or [label, value][] */
260
310
  options?: string[] | {
261
311
  label: string;
262
312
  value: string;
263
- }[];
313
+ }[] | [string, string][];
264
314
  placeholder?: string;
265
315
  required?: boolean;
266
316
  /** Min value for type="slider" */
@@ -282,7 +332,10 @@ interface ActionField {
282
332
  /** Custom render — overrides built-in field renderer */
283
333
  render?: (value: any, onChange: (v: any) => void) => React.ReactNode;
284
334
  }
285
- /** Controls appearance of a default action button (view / edit / delete) */
335
+ /**
336
+ * Configuration for customizing the appearance of action buttons (View/Edit/Delete)
337
+ * @interface ActionButtonConfig
338
+ */
286
339
  interface ActionButtonConfig {
287
340
  /** Button variant. Defaults: view→"outline", edit→"outline", delete→"danger" */
288
341
  variant?: "primary" | "secondary" | "outline" | "ghost" | "link" | "danger" | "success" | "destructive";
@@ -304,7 +357,11 @@ interface ActionButtonConfig {
304
357
  displayMode?: "icon" | "text" | "icon-text";
305
358
  className?: string;
306
359
  }
307
- /** Extra action button appended alongside the default view/edit/delete buttons */
360
+ /**
361
+ * Configuration for extra custom action buttons added alongside default actions
362
+ * @template T - The data type for table rows
363
+ * @interface ExtraActionConfig
364
+ */
308
365
  interface ExtraActionConfig<T> {
309
366
  /** Unique key */
310
367
  key: string;
@@ -328,6 +385,11 @@ interface ExtraActionConfig<T> {
328
385
  className?: string;
329
386
  onClick: (item: T) => void;
330
387
  }
388
+ /**
389
+ * Configuration for default View/Edit/Delete actions on table rows
390
+ * @template T - The data type for table rows
391
+ * @interface DefaultActionsConfig
392
+ */
331
393
  interface DefaultActionsConfig<T> {
332
394
  /**
333
395
  * Base URL used to build PUT and DELETE requests.
@@ -345,6 +407,8 @@ interface DefaultActionsConfig<T> {
345
407
  viewForm?: ActionField[];
346
408
  /** Grid columns for the edit form layout (e.g. 2 = two-column grid). Default single column. */
347
409
  editFormGrid?: number;
410
+ /** Size of the View / Edit / Delete / extra action buttons. Default "xs". */
411
+ actionsSize?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
348
412
  /** Width of the Edit/View/Delete modal. Default "lg". */
349
413
  modalWidth?: ModalWidth;
350
414
  /** Called after a successful edit or delete so the parent can refresh data. */
@@ -360,6 +424,10 @@ interface DefaultActionsConfig<T> {
360
424
  /** Extra action buttons rendered alongside view/edit/delete */
361
425
  extraActions?: ExtraActionConfig<T>[];
362
426
  }
427
+ /**
428
+ * Configuration for success notifications after edit/delete operations
429
+ * @interface ActionSuccessNotif
430
+ */
363
431
  interface ActionSuccessNotif {
364
432
  /** "toast" uses the ToastProvider. "notification" renders an inline banner. Default "toast". */
365
433
  type?: "toast" | "notification";
@@ -380,6 +448,22 @@ interface ActionSuccessNotif {
380
448
  /** Extra action element rendered inside the notification */
381
449
  action?: React.ReactNode;
382
450
  }
451
+ /**
452
+ * Predefined modal width options for View/Edit/Delete modals
453
+ * @constant {Object} MODAL_WIDTH
454
+ * @property {string} sm - Small: max-w-sm (384px)
455
+ * @property {string} md - Medium: max-w-md (448px)
456
+ * @property {string} lg - Large: max-w-lg (512px)
457
+ * @property {string} xl - Extra Large: max-w-xl (576px)
458
+ * @property {string} 2xl - 2X Large: max-w-2xl (672px)
459
+ * @property {string} 3xl - 3X Large: max-w-3xl (768px)
460
+ * @property {string} 4xl - 4X Large: max-w-4xl (896px)
461
+ * @property {string} 5xl - 5X Large: max-w-5xl (1024px)
462
+ * @property {string} 6xl - 6X Large: max-w-6xl (1152px)
463
+ * @property {string} 7xl - 7X Large: max-w-7xl (1280px)
464
+ * @property {string} screen - Screen width: max-w-screen-xl (1280px)
465
+ * @property {string} full - Full width: max-w-full
466
+ */
383
467
  declare const MODAL_WIDTH: {
384
468
  readonly sm: "max-w-sm";
385
469
  readonly md: "max-w-md";
@@ -395,6 +479,11 @@ declare const MODAL_WIDTH: {
395
479
  readonly full: "max-w-full";
396
480
  };
397
481
  type ModalWidth = keyof typeof MODAL_WIDTH;
482
+ /**
483
+ * Column definition for the Table component
484
+ * @template T - The data type for table rows
485
+ * @interface Column
486
+ */
398
487
  interface Column<T> {
399
488
  key: keyof T | string;
400
489
  title: string;
@@ -412,6 +501,11 @@ interface Column<T> {
412
501
  /** Called when a cell value changes (select, toggle, color, checkbox) */
413
502
  onChange?: (item: T, value: any) => void;
414
503
  }
504
+ /**
505
+ * Props for the Table component
506
+ * @template T - The data type for table rows
507
+ * @interface TableProps
508
+ */
415
509
  interface TableProps<T> {
416
510
  data: T[];
417
511
  columns: Column<T>[];
@@ -428,6 +522,33 @@ interface TableProps<T> {
428
522
  serverPagination?: ServerPaginationProp | null;
429
523
  className?: string;
430
524
  }
525
+ /**
526
+ * Data table component with sorting, filtering, pagination, and CRUD actions
527
+ *
528
+ * @template T - The data type for table rows (must be a record with string keys)
529
+ * @param props - Table configuration including data, columns, and options
530
+ * @returns Rendered table with toolbar, pagination, and optional action modals
531
+ *
532
+ * @example
533
+ * ```tsx
534
+ * <Table
535
+ * data={users}
536
+ * columns={[
537
+ * { key: "name", title: "Name", sortable: true },
538
+ * { key: "status", type: "badge" },
539
+ * { key: "active", type: "toggle", onChange: handleToggle },
540
+ * ]}
541
+ * searchable
542
+ * pagination
543
+ * selectable
544
+ * onBulkDelete={handleBulkDelete}
545
+ * defaultActions={{
546
+ * baseUrl: "/api/users",
547
+ * editForm: [{ key: "name", label: "Name", required: true }],
548
+ * }}
549
+ * />
550
+ * ```
551
+ */
431
552
  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;
432
553
 
433
554
  type BulletinPriority = "low" | "medium" | "high" | "urgent";
@@ -842,13 +963,26 @@ interface MetricRowProps {
842
963
  }
843
964
  declare function MetricRow({ items, divided, className }: MetricRowProps): react_jsx_runtime.JSX.Element;
844
965
 
966
+ /**
967
+ * Props for server-side pagination in DataGrid.
968
+ * Used when DataGrid is controlled by server-side data fetching.
969
+ */
845
970
  interface ServerDataGridProp {
971
+ /** Server pagination metadata from Laravel/API */
846
972
  pagination: ServerPagination;
973
+ /** Current active page number (1-based) */
847
974
  currentPage: number;
975
+ /** Function to navigate to a specific page */
848
976
  goToPage: (page: number) => void;
849
977
  }
978
+ /**
979
+ * Options for the useServerDataGrid hook.
980
+ * Provides server-side data fetching with optional Laravel payload decryption.
981
+ */
850
982
  interface UseServerDataGridOptions {
983
+ /** API endpoint URL to fetch data from */
851
984
  url: string;
985
+ /** Query parameters to include in the request */
852
986
  params?: Record<string, string | number>;
853
987
  /** If true, the response is expected to be a Laravel-encrypted payload */
854
988
  encrypt?: boolean;
@@ -863,45 +997,142 @@ interface UseServerDataGridOptions {
863
997
  */
864
998
  columnOverrides?: Record<string, Partial<DataGridColumn<any>>>;
865
999
  }
1000
+ /**
1001
+ * Return type for the useServerDataGrid hook.
1002
+ * Contains all data and state needed to render a server-side DataGrid.
1003
+ * @template T - The data item type
1004
+ */
866
1005
  interface UseServerDataGridReturn<T> {
1006
+ /** Array of data items for the current page */
867
1007
  data: T[];
1008
+ /** Auto-derived column definitions from first data row */
868
1009
  columns: DataGridColumn<T>[];
1010
+ /** Current active page number */
869
1011
  currentPage: number;
1012
+ /** Server pagination metadata or null if not available */
870
1013
  pagination: ServerPagination | null;
1014
+ /** Formatted pagination prop for DataGrid component */
871
1015
  serverPagination: ServerDataGridProp | null | undefined;
1016
+ /** Whether data is currently being fetched */
872
1017
  loading: boolean;
1018
+ /** Error message if request failed, null otherwise */
873
1019
  error: string | null;
1020
+ /** Function to navigate to a specific page */
874
1021
  goToPage: (page: number) => void;
1022
+ /** Function to force reload current page data */
875
1023
  reload: () => void;
876
1024
  }
1025
+ /**
1026
+ * Custom hook for server-side data fetching with DataGrid.
1027
+ * Handles pagination, sorting, filtering, and optional Laravel payload decryption.
1028
+ *
1029
+ * @param options - Configuration options for the server data grid
1030
+ * @returns Object containing data, columns, pagination state, and control functions
1031
+ *
1032
+ * @example
1033
+ * ```tsx
1034
+ * const { data, columns, loading, pagination, goToPage, reload } = useServerDataGrid<User>({
1035
+ * url: "/api/users",
1036
+ * params: { status: "active" },
1037
+ * encrypt: true,
1038
+ * key: import.meta.env["VITE_LARAVEL_KEY"],
1039
+ * });
1040
+ * ```
1041
+ */
877
1042
  declare function useServerDataGrid<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides }: UseServerDataGridOptions): UseServerDataGridReturn<T>;
1043
+ /**
1044
+ * Sort direction for DataGrid columns.
1045
+ * - "asc" - Ascending order
1046
+ * - "desc" - Descending order
1047
+ * - null - No sorting applied
1048
+ */
878
1049
  type SortDir = "asc" | "desc" | null;
1050
+ /**
1051
+ * Column definition for DataGrid component.
1052
+ * @template T - The data item type
1053
+ */
879
1054
  interface DataGridColumn<T> {
1055
+ /** Unique key identifying this column (must match a property in T) */
880
1056
  key: keyof T | string;
1057
+ /** Column header display text or React node */
881
1058
  header: React.ReactNode;
1059
+ /** Custom render function for cell content */
882
1060
  render?: (row: T, idx: number) => React.ReactNode;
1061
+ /** Whether this column is sortable */
883
1062
  sortable?: boolean;
1063
+ /** Column width (e.g., "100px", "20%") */
884
1064
  width?: string;
1065
+ /** Text alignment within the column */
885
1066
  align?: "left" | "center" | "right";
886
1067
  }
1068
+ /**
1069
+ * Props for the DataGrid component.
1070
+ * @template T - The data item type
1071
+ */
887
1072
  interface DataGridProps<T> {
1073
+ /** Column definitions for the grid */
888
1074
  columns: DataGridColumn<T>[];
1075
+ /** Array of data items to display */
889
1076
  data: T[];
1077
+ /** Property name or function to get unique row identifier */
890
1078
  rowKey: keyof T | ((row: T) => string);
1079
+ /** Array of column keys that should have filter inputs */
891
1080
  filterable?: string[];
1081
+ /** Whether rows can be selected via checkboxes */
892
1082
  selectable?: boolean;
1083
+ /** Controlled selected row keys (used with onSelectChange) */
893
1084
  selected?: string[];
1085
+ /** Callback when selection changes */
894
1086
  onSelectChange?: (keys: string[]) => void;
1087
+ /** Number of items per page (default: 10) */
895
1088
  pageSize?: number;
1089
+ /** Whether to show pagination controls */
896
1090
  showPagination?: boolean;
1091
+ /** Whether to show column visibility toggle */
897
1092
  showColumnToggle?: boolean;
1093
+ /** Whether to show loading skeleton */
898
1094
  loading?: boolean;
1095
+ /** Message shown when no data is available */
899
1096
  emptyMessage?: string;
1097
+ /** Additional CSS classes for the container */
900
1098
  className?: string;
1099
+ /** Callback when a row is clicked */
901
1100
  onRowClick?: (row: T) => void;
1101
+ /** Configuration for default row actions (view/edit/delete) */
902
1102
  defaultActions?: DefaultActionsConfig<T>;
1103
+ /** Server-side pagination prop (for controlled/server-fetched pagination) */
903
1104
  serverPagination?: ServerDataGridProp | null;
904
1105
  }
1106
+ /**
1107
+ * DataGrid component - A powerful data table with sorting, filtering, pagination, and built-in actions.
1108
+ *
1109
+ * Supports both client-side and server-side pagination, column visibility toggling,
1110
+ * row selection, and default CRUD actions (view/edit/delete) with modal forms.
1111
+ *
1112
+ * @param props - DataGridProps<T> containing columns, data, and configuration options
1113
+ * @returns A fully-featured data grid React component
1114
+ *
1115
+ * @example
1116
+ * ```tsx
1117
+ * <DataGrid
1118
+ * columns={[
1119
+ * { key: "id", header: "ID", sortable: true },
1120
+ * { key: "name", header: "Name", sortable: true },
1121
+ * { key: "email", header: "Email" },
1122
+ * ]}
1123
+ * data={users}
1124
+ * rowKey="id"
1125
+ * filterable={["name", "email"]}
1126
+ * selectable
1127
+ * pageSize={25}
1128
+ * onRowClick={(row) => console.log(row)}
1129
+ * defaultActions={{
1130
+ * baseUrl: "/api/users",
1131
+ * viewForm: [{ key: "name", label: "Name" }, { key: "email", label: "Email" }],
1132
+ * }}
1133
+ * />
1134
+ * ```
1135
+ */
905
1136
  declare function DataGrid<T extends Record<string, unknown>>({ columns, data, rowKey, filterable, selectable, selected: controlledSelected, onSelectChange, pageSize, showPagination, showColumnToggle, loading, emptyMessage, className, onRowClick, defaultActions, serverPagination, }: DataGridProps<T>): react_jsx_runtime.JSX.Element;
906
1137
 
907
1138
  interface DatePickerProps {
@@ -1461,45 +1692,58 @@ interface PaginationProps {
1461
1692
  declare function Pagination({ page, total, pageSize, siblingCount, showFirstLast, showPageSize, pageSizeOptions, onPageChange, onPageSizeChange, className, }: PaginationProps): react_jsx_runtime.JSX.Element;
1462
1693
 
1463
1694
  interface PanelBrand {
1464
- /** Image URL shown as the project logo */
1465
1695
  image?: string;
1466
- /** Fallback icon when no image — any React element */
1467
1696
  icon?: React.ReactNode;
1468
- /** Project / app title shown when expanded */
1469
1697
  title?: React.ReactNode;
1470
- /** Extra content rendered to the right of title when expanded */
1471
1698
  trailing?: React.ReactNode;
1472
1699
  }
1473
1700
  interface PanelProfile {
1474
- /** Avatar image URL */
1475
1701
  image?: string;
1476
- /** Fallback icon when no image — any React element */
1477
1702
  icon?: React.ReactNode;
1478
- /** Full profile content rendered when expanded */
1479
1703
  content?: React.ReactNode;
1480
1704
  }
1481
1705
  interface PanelProps {
1482
1706
  sidebar?: React.ReactNode;
1483
- /** Structured brand header: shows image+title when expanded, image/icon only when collapsed */
1484
1707
  sidebarBrand?: PanelBrand;
1485
- /** Structured profile footer: shows full content when expanded, image/icon only when collapsed */
1486
1708
  sidebarProfile?: PanelProfile;
1487
- /** @deprecated use sidebarBrand */
1488
1709
  sidebarHeader?: React.ReactNode;
1489
- /** @deprecated use sidebarProfile */
1490
1710
  sidebarFooter?: React.ReactNode;
1491
1711
  sidebarWidth?: string;
1492
1712
  topbar?: React.ReactNode;
1493
1713
  topbarTrailing?: React.ReactNode;
1494
1714
  defaultCollapsed?: boolean;
1715
+ collapsed?: boolean;
1716
+ onCollapsedChange?: (collapsed: boolean) => void;
1495
1717
  collapsible?: boolean;
1496
1718
  showThemeToggle?: boolean;
1497
1719
  defaultPage?: string;
1720
+ currentPage?: string;
1721
+ onPageChange?: (page: string) => void;
1498
1722
  height?: string;
1499
1723
  children?: React.ReactNode;
1500
1724
  className?: string;
1501
- }
1502
- declare function Panel({ sidebar, sidebarBrand, sidebarProfile, sidebarHeader, sidebarFooter, sidebarWidth, topbar, topbarTrailing, defaultCollapsed, collapsible, showThemeToggle, defaultPage, height, children, className, }: PanelProps): react_jsx_runtime.JSX.Element;
1725
+ loading?: boolean;
1726
+ emptyState?: React.ReactNode;
1727
+ error?: string | null;
1728
+ showGroupDividers?: boolean;
1729
+ expandedGroups?: string[];
1730
+ onGroupToggle?: (groupTitle: string, expanded: boolean) => void;
1731
+ theme?: "light" | "dark" | "auto";
1732
+ collapseIcon?: React.ReactNode;
1733
+ expandIcon?: React.ReactNode;
1734
+ meta?: Record<string, any>;
1735
+ actions?: Record<string, () => void>;
1736
+ keyboardNavigation?: boolean;
1737
+ draggable?: boolean;
1738
+ onSidebarReorder?: (items: React.ReactNode[]) => void;
1739
+ animationDuration?: number;
1740
+ animationEasing?: string;
1741
+ sidebarTooltip?: (item: React.ReactNode) => React.ReactNode;
1742
+ mobileBreakpoint?: number;
1743
+ mobileCollapsed?: boolean;
1744
+ onMobileCollapseChange?: (collapsed: boolean) => void;
1745
+ }
1746
+ declare function Panel({ sidebar, sidebarBrand, sidebarProfile, sidebarHeader, sidebarFooter, sidebarWidth, topbar, topbarTrailing, defaultCollapsed, collapsed: controlledCollapsed, onCollapsedChange, collapsible, showThemeToggle, defaultPage, currentPage: controlledPage, onPageChange, height, children, className, loading, emptyState, error, showGroupDividers, expandedGroups: controlledExpandedGroups, onGroupToggle, theme: themeProp, collapseIcon, expandIcon, meta, actions, keyboardNavigation, draggable, onSidebarReorder, animationDuration, animationEasing, sidebarTooltip, mobileBreakpoint, mobileCollapsed: controlledMobileCollapsed, onMobileCollapseChange, }: PanelProps): react_jsx_runtime.JSX.Element;
1503
1747
  declare function PanelSidebarItem({ icon: Icon, label, active, onClick, }: {
1504
1748
  icon?: React.ElementType;
1505
1749
  label: string;