Skip to content

Commit ba6b5af

Browse files
Copilothotlong
andcommitted
refactor(types): extract dashboard enum values to shared constants
Address code review feedback: extract DASHBOARD_COLOR_VARIANTS and DASHBOARD_WIDGET_TYPES as shared constant arrays. Types are derived via (typeof X)[number] and Zod schemas reference the constants directly, ensuring a single source of truth. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent c67a278 commit ba6b5af

4 files changed

Lines changed: 26 additions & 28 deletions

File tree

ROADMAP.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind + Shadcn. It renders JSON metadata from the @objectstack/spec protocol into pixel-perfect, accessible, and interactive enterprise interfaces.
1515

16-
**Where We Are:** Foundation is **solid and shipping** — 35 packages, 91+ components, 5,070+ tests, 78 Storybook stories, 42/42 builds passing, ~85% protocol alignment. SpecBridge, Expression Engine, Action Engine, data binding, all view plugins (Grid/Kanban/Calendar/Gantt/Timeline/Map/Gallery), Record components, Report engine, Dashboard BI features, mobile UX, i18n (11 locales), WCAG AA accessibility, Designer Phase 1, Console through Phase 19 (L3), and **AppShell Navigation Renderer** (P0.1) — all ✅ complete.
16+
**Where We Are:** Foundation is **solid and shipping** — 35 packages, 91+ components, 5,100+ tests, 78 Storybook stories, 42/42 builds passing, ~85% protocol alignment. SpecBridge, Expression Engine, Action Engine, data binding, all view plugins (Grid/Kanban/Calendar/Gantt/Timeline/Map/Gallery), Record components, Report engine, Dashboard BI features, mobile UX, i18n (11 locales), WCAG AA accessibility, Designer Phase 1 (ViewDesigner drag-to-reorder ✅), Console through Phase 20 (L3), and **AppShell Navigation Renderer** (P0.1) — all ✅ complete.
1717

1818
**What Remains:** The gap to **Airtable-level UX** is primarily in:
1919
1. ~~**AppShell** — No dynamic navigation renderer from spec JSON (last P0 blocker)~~ ✅ Complete
20-
2. **Designer Interaction** — ViewDesigner and DataModelDesigner have undo/redo, field type selectors, inline editing, Ctrl+S save (column drag-to-reorder with dnd-kit pending)
20+
2. **Designer Interaction** — ViewDesigner and DataModelDesigner have undo/redo, field type selectors, inline editing, Ctrl+S save, column drag-to-reorder with dnd-kit
2121
3. **Dashboard Config Panel** — Airtable-style right-side configuration panel for dashboards (data source, layout, widget properties, sub-editors, type definitions)
2222
4. **Console Advanced Polish** — Remaining upgrades for forms, import/export, automation, comments
2323
5. **PWA Sync** — Background sync is simulated only
@@ -47,7 +47,7 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
4747
> Source: ROADMAP_DESIGNER Phase 2. These two designers are the core user workflow.
4848
4949
**ViewDesigner:**
50-
- [ ] Column drag-to-reorder via `@dnd-kit/core` (replace up/down buttons with drag handles)
50+
- [x] Column drag-to-reorder via `@dnd-kit/core` (replace up/down buttons with drag handles)
5151
- [x] Add `Ctrl+S`/`Cmd+S` keyboard shortcut to save
5252
- [x] Add field type selector dropdown with icons from `DESIGNER_FIELD_TYPES`
5353
- [x] Column width validation (min/max/pattern check)
@@ -139,7 +139,7 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
139139
> Airtable-style right-side configuration panel for dashboards. Phased rollout from shared infrastructure to full type-safe editing.
140140
141141
**Phase 0 — Component Infrastructure:**
142-
- [ ] Extract `ConfigRow` / `SectionHeader` from `ViewConfigPanel` into `@object-ui/components` as reusable primitives
142+
- [x] Extract `ConfigRow` / `SectionHeader` from `ViewConfigPanel` into `@object-ui/components` as reusable primitives
143143

144144
**Phase 1 — Dashboard-Level Config Panel:**
145145
- [ ] Develop `DashboardConfigPanel` supporting data source, layout (columns/gap), filtering, appearance, user filters & actions
@@ -156,8 +156,8 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
156156
- [ ] Add Storybook stories for `DashboardConfigPanel` and `DashboardWithConfig`
157157

158158
**Phase 5 — Type Definitions & Validation:**
159-
- [ ] Add `DashboardConfig` types to `@object-ui/types`
160-
- [ ] Add Zod schema validation for `DashboardConfig`
159+
- [x] Add `DashboardConfig` types to `@object-ui/types`
160+
- [x] Add Zod schema validation for `DashboardConfig`
161161

162162
### P1.9 Console — Content Area Layout & Responsiveness
163163

packages/types/src/designer.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -554,29 +554,21 @@ export interface UnifiedViewConfig {
554554
// Dashboard Configuration
555555
// ============================================================================
556556

557+
/** All supported color variants for dashboard widgets */
558+
export const DASHBOARD_COLOR_VARIANTS = [
559+
'default', 'blue', 'teal', 'orange', 'purple', 'success', 'warning', 'danger',
560+
] as const;
561+
557562
/** Color variant for dashboard widgets */
558-
export type DashboardColorVariant =
559-
| 'default'
560-
| 'blue'
561-
| 'teal'
562-
| 'orange'
563-
| 'purple'
564-
| 'success'
565-
| 'warning'
566-
| 'danger';
563+
export type DashboardColorVariant = (typeof DASHBOARD_COLOR_VARIANTS)[number];
564+
565+
/** All supported widget visualization types */
566+
export const DASHBOARD_WIDGET_TYPES = [
567+
'metric', 'bar', 'line', 'pie', 'donut', 'area', 'scatter', 'table', 'list', 'custom',
568+
] as const;
567569

568570
/** Widget visualization type */
569-
export type DashboardWidgetType =
570-
| 'metric'
571-
| 'bar'
572-
| 'line'
573-
| 'pie'
574-
| 'donut'
575-
| 'area'
576-
| 'scatter'
577-
| 'table'
578-
| 'list'
579-
| 'custom';
571+
export type DashboardWidgetType = (typeof DASHBOARD_WIDGET_TYPES)[number];
580572

581573
/** Layout position for a single dashboard widget */
582574
export interface DashboardWidgetConfig {

packages/types/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ export type {
550550
DashboardConfig,
551551
} from './designer';
552552

553+
export {
554+
DASHBOARD_COLOR_VARIANTS,
555+
DASHBOARD_WIDGET_TYPES,
556+
} from './designer';
557+
553558
// ============================================================================
554559
// API and Events - API Integration and Event Handling
555560
// ============================================================================

packages/types/src/zod/complex.zod.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import { z } from 'zod';
2020
import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
21+
import { DASHBOARD_COLOR_VARIANTS, DASHBOARD_WIDGET_TYPES } from '../designer.js';
2122

2223
/**
2324
* Kanban Card Schema
@@ -258,14 +259,14 @@ export const DashboardWidgetConfigSchema = z.object({
258259
id: z.string().describe('Widget ID'),
259260
title: z.string().optional().describe('Widget title'),
260261
description: z.string().optional().describe('Widget description'),
261-
type: z.enum(['metric', 'bar', 'line', 'pie', 'donut', 'area', 'scatter', 'table', 'list', 'custom']).optional().describe('Widget visualization type'),
262+
type: z.enum(DASHBOARD_WIDGET_TYPES).optional().describe('Widget visualization type'),
262263
object: z.string().optional().describe('Data source object name'),
263264
filter: z.array(z.any()).optional().describe('Widget filter conditions'),
264265
categoryField: z.string().optional().describe('Category/x-axis field'),
265266
valueField: z.string().optional().describe('Value/y-axis field'),
266267
aggregate: z.string().optional().describe('Aggregation function'),
267268
chartConfig: z.any().optional().describe('Chart configuration'),
268-
colorVariant: z.enum(['default', 'blue', 'teal', 'orange', 'purple', 'success', 'warning', 'danger']).optional().describe('Color variant'),
269+
colorVariant: z.enum(DASHBOARD_COLOR_VARIANTS).optional().describe('Color variant'),
269270
layout: DashboardWidgetLayoutSchema.optional().describe('Widget grid layout'),
270271
actionUrl: z.string().optional().describe('Clickable action URL'),
271272
});

0 commit comments

Comments
 (0)