@object-ui/types 3.0.3 → 3.1.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.
Files changed (85) hide show
  1. package/dist/app.d.ts +217 -0
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +85 -1
  4. package/dist/complex.d.ts +128 -0
  5. package/dist/complex.d.ts.map +1 -1
  6. package/dist/data-display.d.ts +105 -1
  7. package/dist/data-display.d.ts.map +1 -1
  8. package/dist/data.d.ts +45 -0
  9. package/dist/data.d.ts.map +1 -1
  10. package/dist/designer.d.ts +197 -35
  11. package/dist/designer.d.ts.map +1 -1
  12. package/dist/designer.js +11 -1
  13. package/dist/index.d.ts +21 -10
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/layout.d.ts +39 -2
  17. package/dist/layout.d.ts.map +1 -1
  18. package/dist/navigation.d.ts +27 -0
  19. package/dist/navigation.d.ts.map +1 -1
  20. package/dist/objectql.d.ts +641 -7
  21. package/dist/objectql.d.ts.map +1 -1
  22. package/dist/record-components.d.ts +160 -0
  23. package/dist/record-components.d.ts.map +1 -0
  24. package/dist/record-components.js +8 -0
  25. package/dist/reports.d.ts +37 -0
  26. package/dist/reports.d.ts.map +1 -1
  27. package/dist/theme.d.ts +5 -0
  28. package/dist/theme.d.ts.map +1 -1
  29. package/dist/views.d.ts +324 -4
  30. package/dist/views.d.ts.map +1 -1
  31. package/dist/workflow.d.ts +198 -0
  32. package/dist/workflow.d.ts.map +1 -1
  33. package/dist/zod/app.zod.d.ts +42 -2
  34. package/dist/zod/app.zod.d.ts.map +1 -1
  35. package/dist/zod/app.zod.js +61 -1
  36. package/dist/zod/complex.zod.d.ts +122 -0
  37. package/dist/zod/complex.zod.d.ts.map +1 -1
  38. package/dist/zod/complex.zod.js +57 -0
  39. package/dist/zod/data-display.zod.d.ts +4 -0
  40. package/dist/zod/data-display.zod.d.ts.map +1 -1
  41. package/dist/zod/data-display.zod.js +2 -0
  42. package/dist/zod/form.zod.d.ts +6 -6
  43. package/dist/zod/index.zod.d.ts +365 -41
  44. package/dist/zod/index.zod.d.ts.map +1 -1
  45. package/dist/zod/index.zod.js +2 -2
  46. package/dist/zod/layout.zod.d.ts +6 -6
  47. package/dist/zod/navigation.zod.d.ts +58 -12
  48. package/dist/zod/navigation.zod.d.ts.map +1 -1
  49. package/dist/zod/navigation.zod.js +21 -9
  50. package/dist/zod/objectql.zod.d.ts +515 -27
  51. package/dist/zod/objectql.zod.d.ts.map +1 -1
  52. package/dist/zod/objectql.zod.js +162 -0
  53. package/dist/zod/reports.zod.d.ts +38 -38
  54. package/dist/zod/views.zod.d.ts +163 -7
  55. package/dist/zod/views.zod.d.ts.map +1 -1
  56. package/dist/zod/views.zod.js +22 -3
  57. package/package.json +2 -2
  58. package/src/__tests__/app-creation-types.test.ts +177 -0
  59. package/src/__tests__/dashboard-config.test.ts +208 -0
  60. package/src/__tests__/examples-metadata-compliance.test.ts +264 -0
  61. package/src/__tests__/navigation-model.test.ts +406 -0
  62. package/src/__tests__/p1-spec-alignment.test.ts +660 -0
  63. package/src/__tests__/p2-spec-exports.test.ts +312 -0
  64. package/src/__tests__/phase2-schemas.test.ts +108 -0
  65. package/src/app.ts +377 -0
  66. package/src/complex.ts +130 -0
  67. package/src/data-display.ts +107 -0
  68. package/src/data.ts +49 -0
  69. package/src/designer.ts +219 -30
  70. package/src/index.ts +194 -3
  71. package/src/layout.ts +55 -2
  72. package/src/navigation.ts +20 -0
  73. package/src/objectql.ts +757 -8
  74. package/src/record-components.ts +188 -0
  75. package/src/reports.ts +43 -0
  76. package/src/theme.ts +6 -0
  77. package/src/views.ts +344 -4
  78. package/src/workflow.ts +226 -0
  79. package/src/zod/app.zod.ts +74 -1
  80. package/src/zod/complex.zod.ts +59 -0
  81. package/src/zod/data-display.zod.ts +2 -0
  82. package/src/zod/index.zod.ts +5 -0
  83. package/src/zod/navigation.zod.ts +22 -10
  84. package/src/zod/objectql.zod.ts +167 -0
  85. package/src/zod/views.zod.ts +22 -3
@@ -341,6 +341,13 @@ export interface DataTableSchema extends BaseSchema {
341
341
  * @default false
342
342
  */
343
343
  selectable?: boolean | 'single' | 'multiple';
344
+ /**
345
+ * Selection checkbox display style
346
+ * - 'always': Checkboxes are always visible
347
+ * - 'hover': Checkboxes only appear on row hover
348
+ * @default 'always'
349
+ */
350
+ selectionStyle?: 'always' | 'hover';
344
351
  /**
345
352
  * Enable column sorting
346
353
  * @default true
@@ -388,6 +395,12 @@ export interface DataTableSchema extends BaseSchema {
388
395
  * @default false
389
396
  */
390
397
  editable?: boolean;
398
+ /**
399
+ * Enable single-click editing mode
400
+ * When true with editable, clicking a cell enters edit mode (instead of double-click)
401
+ * @default false
402
+ */
403
+ singleClickEdit?: boolean;
391
404
  /**
392
405
  * Cell value change handler
393
406
  * Called when a cell value is edited
@@ -413,6 +426,41 @@ export interface DataTableSchema extends BaseSchema {
413
426
  * Function that returns a CSS class string for each row
414
427
  */
415
428
  rowClassName?: (row: any, index: number) => string | undefined;
429
+ /**
430
+ * Dynamic row inline style
431
+ * Function that returns CSSProperties for each row (e.g., from conditionalFormatting).
432
+ */
433
+ rowStyle?: (row: any, index: number) => React.CSSProperties | undefined;
434
+ /**
435
+ * Number of columns to freeze (left-pin)
436
+ * When set, the first N columns remain fixed while the rest scroll horizontally.
437
+ * @default 0
438
+ */
439
+ frozenColumns?: number;
440
+ /**
441
+ * Show row numbers in the first column (Airtable-style)
442
+ * @default false
443
+ */
444
+ showRowNumbers?: boolean;
445
+ /**
446
+ * Show "+ Add record" row at the bottom of the table (Airtable-style)
447
+ * @default false
448
+ */
449
+ showAddRow?: boolean;
450
+ /**
451
+ * Callback when the "+ Add record" row is clicked
452
+ */
453
+ onAddRecord?: () => void;
454
+ /**
455
+ * Column resize handler
456
+ * Called when a column is resized
457
+ */
458
+ onColumnResize?: (columnKey: string, width: number) => void;
459
+ /**
460
+ * Column reorder handler (new order of accessorKeys)
461
+ * Called when columns are reordered via drag-and-drop
462
+ */
463
+ onColumnReorder?: (newOrder: string[]) => void;
416
464
  }
417
465
 
418
466
  /**
@@ -593,6 +641,64 @@ export interface ChartSchema extends BaseSchema {
593
641
  config?: Record<string, any>;
594
642
  }
595
643
 
644
+ /**
645
+ * Aggregation function for pivot table values
646
+ */
647
+ export type PivotAggregation = 'sum' | 'count' | 'avg' | 'min' | 'max';
648
+
649
+ /**
650
+ * Pivot table (cross-tabulation) component
651
+ *
652
+ * Renders a matrix where rows correspond to one field,
653
+ * columns to another, and cells show an aggregated value.
654
+ */
655
+ export interface PivotTableSchema extends BaseSchema {
656
+ type: 'pivot';
657
+ /**
658
+ * Pivot table title
659
+ */
660
+ title?: string;
661
+ /**
662
+ * Field used for row headers
663
+ */
664
+ rowField: string;
665
+ /**
666
+ * Field used for column headers
667
+ */
668
+ columnField: string;
669
+ /**
670
+ * Field whose values are aggregated in cells
671
+ */
672
+ valueField: string;
673
+ /**
674
+ * Aggregation function applied to valueField
675
+ * @default 'sum'
676
+ */
677
+ aggregation?: PivotAggregation;
678
+ /**
679
+ * Source data rows
680
+ */
681
+ data: Record<string, unknown>[];
682
+ /**
683
+ * Show a totals column on the right
684
+ * @default false
685
+ */
686
+ showRowTotals?: boolean;
687
+ /**
688
+ * Show a totals row at the bottom
689
+ * @default false
690
+ */
691
+ showColumnTotals?: boolean;
692
+ /**
693
+ * Numeric format string (e.g. "$,.2f") — applied via simple prefix/suffix/decimals
694
+ */
695
+ format?: string;
696
+ /**
697
+ * Mapping of column header values to Tailwind text-color classes
698
+ */
699
+ columnColors?: Record<string, string>;
700
+ }
701
+
596
702
  /**
597
703
  * Timeline event
598
704
  */
@@ -706,6 +812,7 @@ export type DataDisplaySchema =
706
812
  | MarkdownSchema
707
813
  | TreeViewSchema
708
814
  | ChartSchema
815
+ | PivotTableSchema
709
816
  | TimelineSchema
710
817
  | HtmlSchema
711
818
  | StatisticSchema
package/src/data.ts CHANGED
@@ -237,6 +237,19 @@ export interface DataSource<T = any> {
237
237
  */
238
238
  getView?(objectName: string, viewId: string): Promise<any | null>;
239
239
 
240
+ /**
241
+ * Persist a view configuration to the backend.
242
+ * Called when a user saves view settings (columns, filters, sort, toggles, etc.)
243
+ * from the inline ViewConfigPanel.
244
+ * Optional — implementations that do not support view persistence may omit this.
245
+ *
246
+ * @param objectName - Object name
247
+ * @param viewId - View identifier (e.g., 'all', 'pipeline')
248
+ * @param config - The full view configuration to persist
249
+ * @returns Promise resolving to the persisted config (or void)
250
+ */
251
+ updateViewConfig?(objectName: string, viewId: string, config: Record<string, any>): Promise<Record<string, any> | void>;
252
+
240
253
  /**
241
254
  * Get an application definition by name or ID.
242
255
  * Used by app shells to render server-defined navigation, branding, and layout.
@@ -296,6 +309,42 @@ export interface DataSource<T = any> {
296
309
  onProgress?: (percent: number) => void;
297
310
  },
298
311
  ): Promise<FileUploadResult[]>;
312
+
313
+ /**
314
+ * Perform server-side aggregation on a resource.
315
+ * Used by chart widgets to offload grouping/aggregation to the backend,
316
+ * avoiding large data downloads.
317
+ * Optional — when not implemented, chart components will fall back to
318
+ * fetching all records via `find()` and aggregating client-side.
319
+ *
320
+ * @param resource - Resource name (e.g., 'opportunity')
321
+ * @param params - Aggregation parameters (field, function, groupBy, filter)
322
+ * @returns Promise resolving to aggregated results
323
+ */
324
+ aggregate?(resource: string, params: AggregateParams): Promise<AggregateResult[]>;
325
+ }
326
+
327
+ /**
328
+ * Parameters for server-side aggregation.
329
+ * Describes how to group and aggregate data on the backend.
330
+ */
331
+ export interface AggregateParams {
332
+ /** Field to aggregate (e.g., 'amount') */
333
+ field: string;
334
+ /** Aggregation function (e.g., 'sum', 'count', 'avg', 'min', 'max') */
335
+ function: string;
336
+ /** Field to group by (e.g., 'stage') */
337
+ groupBy: string;
338
+ /** Optional filter to apply before aggregation */
339
+ filter?: any;
340
+ }
341
+
342
+ /**
343
+ * Result of a server-side aggregation.
344
+ * Each entry represents one group with the aggregated value.
345
+ */
346
+ export interface AggregateResult {
347
+ [key: string]: any;
299
348
  }
300
349
 
301
350
  /**
package/src/designer.ts CHANGED
@@ -393,11 +393,11 @@ export interface ReportDesignerSchema extends BaseSchema {
393
393
  }
394
394
 
395
395
  // ============================================================================
396
- // View Designer (List View Layout Editor)
396
+ // Unified View Configuration
397
397
  // ============================================================================
398
398
 
399
- /** Column configuration for the view designer */
400
- export interface ViewDesignerColumn {
399
+ /** Column configuration for rich view columns */
400
+ export interface ViewColumnConfig {
401
401
  /** Field name */
402
402
  field: string;
403
403
  /** Display label */
@@ -412,35 +412,224 @@ export interface ViewDesignerColumn {
412
412
  order?: number;
413
413
  }
414
414
 
415
- /** View designer schema */
416
- export interface ViewDesignerSchema extends BaseSchema {
417
- type: 'view-designer';
418
- /** Object name this view is for */
419
- objectName: string;
420
- /** View identifier (for editing existing views) */
421
- viewId?: string;
422
- /** View display label */
423
- viewLabel?: string;
415
+ /** View type union */
416
+ export type UnifiedViewType = 'grid' | 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map' | 'chart';
417
+
418
+ /**
419
+ * Unified data model for view configuration.
420
+ *
421
+ * Used by ViewConfigPanel (create/edit).
422
+ * Columns may be simple field-name strings or rich ViewColumnConfig objects;
423
+ * consumers should handle both.
424
+ */
425
+ export interface UnifiedViewConfig {
426
+ /** View identifier */
427
+ id?: string;
428
+ /** Display label */
429
+ label?: string;
424
430
  /** View type */
425
- viewType?: 'grid' | 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map';
426
- /** Columns / fields to display */
427
- columns?: ViewDesignerColumn[];
428
- /** Filter conditions */
429
- filters?: Array<{ field: string; operator: string; value: any }>;
431
+ type?: UnifiedViewType;
432
+ /** Column configuration simple field names or rich ViewColumnConfig objects */
433
+ columns?: Array<string | ViewColumnConfig>;
434
+ /** Filter conditions in @objectstack/spec JSON-rules array format */
435
+ filter?: any[];
430
436
  /** Sort configuration */
431
- sort?: Array<{ field: string; direction: 'asc' | 'desc' }>;
432
- /** Available fields from the object schema */
433
- availableFields?: Array<{ name: string; label: string; type: string }>;
434
- /** Type-specific options */
435
- options?: Record<string, any>;
436
- /** Read-only mode */
437
- readOnly?: boolean;
438
- /** Callback when view config changes */
439
- onChange?: string;
440
- /** Callback when view is saved */
441
- onSave?: string;
442
- /** Callback when cancelled */
443
- onCancel?: string;
437
+ sort?: Array<{ field: string; order?: string; direction?: string; id?: string }>;
438
+ /** Description */
439
+ description?: string;
440
+ /** Enable search bar */
441
+ showSearch?: boolean;
442
+ /** Enable user filter controls */
443
+ showFilters?: boolean;
444
+ /** Enable user sort controls */
445
+ showSort?: boolean;
446
+ /** Allow data export */
447
+ allowExport?: boolean;
448
+ /** Show view description */
449
+ showDescription?: boolean;
450
+ /** Enable "add record via form" action */
451
+ addRecordViaForm?: boolean;
452
+ /** Export options */
453
+ exportOptions?: any;
454
+
455
+ // -- Type-specific options (nested per @objectstack/spec protocol) ----------
456
+
457
+ /** Kanban-specific options */
458
+ kanban?: {
459
+ groupByField?: string;
460
+ groupField?: string;
461
+ titleField?: string;
462
+ columns?: string[];
463
+ };
464
+ /** Calendar-specific options */
465
+ calendar?: {
466
+ startDateField?: string;
467
+ endDateField?: string;
468
+ titleField?: string;
469
+ colorField?: string;
470
+ allDayField?: string;
471
+ defaultView?: string;
472
+ };
473
+ /** Map-specific options */
474
+ map?: {
475
+ locationField?: string;
476
+ titleField?: string;
477
+ latitudeField?: string;
478
+ longitudeField?: string;
479
+ zoom?: number;
480
+ center?: { lat: number; lng: number };
481
+ };
482
+ /** Gallery-specific options */
483
+ gallery?: {
484
+ imageField?: string;
485
+ titleField?: string;
486
+ subtitleField?: string;
487
+ };
488
+ /** Timeline-specific options */
489
+ timeline?: {
490
+ dateField?: string;
491
+ titleField?: string;
492
+ descriptionField?: string;
493
+ };
494
+ /** Gantt-specific options */
495
+ gantt?: {
496
+ startDateField?: string;
497
+ endDateField?: string;
498
+ titleField?: string;
499
+ progressField?: string;
500
+ dependenciesField?: string;
501
+ colorField?: string;
502
+ };
503
+ /** Chart-specific options */
504
+ chart?: {
505
+ chartType?: string;
506
+ xAxisField?: string;
507
+ yAxisFields?: string[];
508
+ aggregation?: string;
509
+ series?: any[];
510
+ config?: any;
511
+ filter?: any;
512
+ };
513
+
514
+ /** Catch-all for additional properties */
515
+ [key: string]: any;
516
+ }
517
+
518
+ // ============================================================================
519
+ // Dashboard Configuration
520
+ // ============================================================================
521
+
522
+ /** All supported color variants for dashboard widgets */
523
+ export const DASHBOARD_COLOR_VARIANTS = [
524
+ 'default', 'blue', 'teal', 'orange', 'purple', 'success', 'warning', 'danger',
525
+ ] as const;
526
+
527
+ /** Color variant for dashboard widgets */
528
+ export type DashboardColorVariant = (typeof DASHBOARD_COLOR_VARIANTS)[number];
529
+
530
+ /** All supported widget visualization types */
531
+ export const DASHBOARD_WIDGET_TYPES = [
532
+ 'metric', 'bar', 'line', 'pie', 'donut', 'area', 'scatter', 'table', 'pivot', 'list', 'custom',
533
+ ] as const;
534
+
535
+ /** Widget visualization type */
536
+ export type DashboardWidgetType = (typeof DASHBOARD_WIDGET_TYPES)[number];
537
+
538
+ /** Layout position for a single dashboard widget */
539
+ export interface DashboardWidgetConfig {
540
+ /** Widget identifier */
541
+ id: string;
542
+ /** Widget title */
543
+ title?: string;
544
+ /** Widget description */
545
+ description?: string;
546
+ /** Visualization type */
547
+ type?: DashboardWidgetType;
548
+ /** Data source object name */
549
+ object?: string;
550
+ /** Filter conditions applied to widget data */
551
+ filter?: any[];
552
+ /** Category / x-axis field */
553
+ categoryField?: string;
554
+ /** Value / y-axis field */
555
+ valueField?: string;
556
+ /** Aggregation function (count, sum, avg, min, max) */
557
+ aggregate?: string;
558
+ /** Chart-specific configuration */
559
+ chartConfig?: any;
560
+ /** Color variant */
561
+ colorVariant?: DashboardColorVariant;
562
+ /** Grid layout position */
563
+ layout?: { x: number; y: number; w: number; h: number };
564
+ /** Clickable action URL */
565
+ actionUrl?: string;
566
+ }
567
+
568
+ /**
569
+ * Unified data model for dashboard configuration.
570
+ *
571
+ * Used by the DashboardConfigPanel for create/edit workflows.
572
+ * Mirrors the pattern of UnifiedViewConfig for view configuration.
573
+ */
574
+ export interface DashboardConfig {
575
+ /** Dashboard identifier */
576
+ id?: string;
577
+ /** Display title */
578
+ title?: string;
579
+ /** Dashboard description */
580
+ description?: string;
581
+ /** Number of grid columns (default: 12) */
582
+ columns?: number;
583
+ /** Grid gap in pixels */
584
+ gap?: number;
585
+ /** Auto-refresh interval in seconds */
586
+ refreshInterval?: number;
587
+ /** Dashboard widgets */
588
+ widgets?: DashboardWidgetConfig[];
589
+
590
+ // -- Global filters --------------------------------------------------------
591
+
592
+ /** Global filter conditions applied across all widgets */
593
+ globalFilters?: any[];
594
+ /** Date range filter configuration */
595
+ dateRange?: {
596
+ enabled?: boolean;
597
+ field?: string;
598
+ presets?: string[];
599
+ };
600
+ /** User-selectable filter fields */
601
+ userFilters?: Array<{
602
+ field: string;
603
+ label?: string;
604
+ type?: string;
605
+ }>;
606
+
607
+ // -- Appearance ------------------------------------------------------------
608
+
609
+ /** Show dashboard header with title/description */
610
+ showHeader?: boolean;
611
+ /** Show global filter bar */
612
+ showFilters?: boolean;
613
+ /** Show date range picker */
614
+ showDateRange?: boolean;
615
+ /** Action buttons in dashboard header */
616
+ headerActions?: Array<{
617
+ label: string;
618
+ action?: string;
619
+ icon?: string;
620
+ variant?: string;
621
+ }>;
622
+
623
+ // -- Accessibility ---------------------------------------------------------
624
+
625
+ /** ARIA properties */
626
+ aria?: {
627
+ label?: string;
628
+ description?: string;
629
+ };
630
+
631
+ /** Catch-all for additional properties */
632
+ [key: string]: any;
444
633
  }
445
634
 
446
635
  // ============================================================================