@object-ui/components 3.0.2 → 3.1.0

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 (55) hide show
  1. package/.turbo/turbo-build.log +12 -12
  2. package/CHANGELOG.md +8 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +24701 -22929
  5. package/dist/index.umd.cjs +37 -37
  6. package/dist/src/custom/config-field-renderer.d.ts +21 -0
  7. package/dist/src/custom/config-panel-renderer.d.ts +81 -0
  8. package/dist/src/custom/config-row.d.ts +27 -0
  9. package/dist/src/custom/index.d.ts +5 -0
  10. package/dist/src/custom/mobile-dialog-content.d.ts +20 -0
  11. package/dist/src/custom/navigation-overlay.d.ts +8 -0
  12. package/dist/src/custom/section-header.d.ts +31 -0
  13. package/dist/src/debug/DebugPanel.d.ts +39 -0
  14. package/dist/src/debug/index.d.ts +9 -0
  15. package/dist/src/hooks/use-config-draft.d.ts +46 -0
  16. package/dist/src/index.d.ts +4 -0
  17. package/dist/src/renderers/action/action-bar.d.ts +23 -0
  18. package/dist/src/types/config-panel.d.ts +92 -0
  19. package/dist/src/ui/sheet.d.ts +2 -0
  20. package/dist/src/ui/sidebar.d.ts +4 -0
  21. package/package.json +17 -17
  22. package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +3 -3
  23. package/src/__tests__/action-bar.test.tsx +172 -0
  24. package/src/__tests__/config-field-renderer.test.tsx +307 -0
  25. package/src/__tests__/config-panel-renderer.test.tsx +580 -0
  26. package/src/__tests__/config-primitives.test.tsx +106 -0
  27. package/src/__tests__/mobile-accessibility.test.tsx +120 -0
  28. package/src/__tests__/navigation-overlay.test.tsx +97 -0
  29. package/src/__tests__/use-config-draft.test.tsx +295 -0
  30. package/src/custom/config-field-renderer.tsx +276 -0
  31. package/src/custom/config-panel-renderer.tsx +306 -0
  32. package/src/custom/config-row.tsx +50 -0
  33. package/src/custom/index.ts +5 -0
  34. package/src/custom/mobile-dialog-content.tsx +67 -0
  35. package/src/custom/navigation-overlay.tsx +42 -4
  36. package/src/custom/section-header.tsx +68 -0
  37. package/src/debug/DebugPanel.tsx +313 -0
  38. package/src/debug/__tests__/DebugPanel.test.tsx +134 -0
  39. package/src/{index.test.ts → debug/index.ts} +2 -7
  40. package/src/hooks/use-config-draft.ts +127 -0
  41. package/src/index.css +4 -0
  42. package/src/index.ts +15 -0
  43. package/src/renderers/action/action-bar.tsx +202 -0
  44. package/src/renderers/action/index.ts +1 -0
  45. package/src/renderers/complex/__tests__/data-table-airtable-ux.test.tsx +239 -0
  46. package/src/renderers/complex/__tests__/data-table.test.ts +16 -0
  47. package/src/renderers/complex/data-table.tsx +346 -43
  48. package/src/renderers/data-display/breadcrumb.tsx +3 -2
  49. package/src/renderers/form/form.tsx +4 -4
  50. package/src/renderers/navigation/header-bar.tsx +69 -10
  51. package/src/stories/ConfigPanel.stories.tsx +232 -0
  52. package/src/types/config-panel.ts +101 -0
  53. package/src/ui/dialog.tsx +20 -3
  54. package/src/ui/sheet.tsx +6 -3
  55. package/src/ui/sidebar.tsx +93 -9
@@ -0,0 +1,276 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import * as React from 'react';
10
+ import { Settings } from 'lucide-react';
11
+ import { Input } from '../ui/input';
12
+ import { Switch } from '../ui/switch';
13
+ import { Checkbox } from '../ui/checkbox';
14
+ import { Slider } from '../ui/slider';
15
+ import {
16
+ Select,
17
+ SelectContent,
18
+ SelectItem,
19
+ SelectTrigger,
20
+ SelectValue,
21
+ } from '../ui/select';
22
+ import { Button } from '../ui/button';
23
+ import { cn } from '../lib/utils';
24
+ import { ConfigRow } from './config-row';
25
+ import { FilterBuilder } from './filter-builder';
26
+ import { SortBuilder } from './sort-builder';
27
+ import type { ConfigField } from '../types/config-panel';
28
+
29
+ export interface ConfigFieldRendererProps {
30
+ /** Field schema */
31
+ field: ConfigField;
32
+ /** Current value */
33
+ value: any;
34
+ /** Change handler */
35
+ onChange: (value: any) => void;
36
+ /** Full draft for visibility evaluation and custom render */
37
+ draft: Record<string, any>;
38
+ /** Object definition for field-picker controls */
39
+ objectDef?: Record<string, any>;
40
+ }
41
+
42
+ /**
43
+ * Renders a single config field based on its ControlType.
44
+ *
45
+ * Supports: input, switch, select, checkbox, slider, color, icon-group, custom.
46
+ * filter/sort/field-picker are rendered as placeholders that consumers can
47
+ * override with type='custom' when full sub-editor integration is needed.
48
+ */
49
+ export function ConfigFieldRenderer({
50
+ field,
51
+ value,
52
+ onChange,
53
+ draft,
54
+ objectDef: _objectDef,
55
+ }: ConfigFieldRendererProps) {
56
+ // Visibility gate
57
+ if (field.visibleWhen && !field.visibleWhen(draft)) {
58
+ return null;
59
+ }
60
+
61
+ const effectiveDisabled = field.disabled || (field.disabledWhen ? field.disabledWhen(draft) : false);
62
+ const effectiveValue = value ?? field.defaultValue;
63
+
64
+ let content: React.ReactNode = null;
65
+
66
+ switch (field.type) {
67
+ case 'input':
68
+ content = (
69
+ <ConfigRow label={field.label}>
70
+ <Input
71
+ data-testid={`config-field-${field.key}`}
72
+ className="h-7 w-32 text-xs"
73
+ value={effectiveValue ?? ''}
74
+ placeholder={field.placeholder}
75
+ disabled={effectiveDisabled}
76
+ onChange={(e) => onChange(e.target.value)}
77
+ />
78
+ </ConfigRow>
79
+ );
80
+ break;
81
+
82
+ case 'switch':
83
+ content = (
84
+ <ConfigRow label={field.label}>
85
+ <Switch
86
+ data-testid={`config-field-${field.key}`}
87
+ checked={!!effectiveValue}
88
+ disabled={effectiveDisabled}
89
+ onCheckedChange={(checked) => onChange(checked)}
90
+ className="scale-75"
91
+ />
92
+ </ConfigRow>
93
+ );
94
+ break;
95
+
96
+ case 'checkbox':
97
+ content = (
98
+ <ConfigRow label={field.label}>
99
+ <Checkbox
100
+ data-testid={`config-field-${field.key}`}
101
+ checked={!!effectiveValue}
102
+ disabled={effectiveDisabled}
103
+ onCheckedChange={(checked) => onChange(checked)}
104
+ />
105
+ </ConfigRow>
106
+ );
107
+ break;
108
+
109
+ case 'select':
110
+ content = (
111
+ <ConfigRow label={field.label}>
112
+ <Select
113
+ value={String(effectiveValue ?? '')}
114
+ onValueChange={(val) => onChange(val)}
115
+ disabled={effectiveDisabled}
116
+ >
117
+ <SelectTrigger
118
+ data-testid={`config-field-${field.key}`}
119
+ className="h-7 w-32 text-xs"
120
+ >
121
+ <SelectValue placeholder={field.placeholder ?? 'Select…'} />
122
+ </SelectTrigger>
123
+ <SelectContent>
124
+ {(field.options ?? []).map((opt) => (
125
+ <SelectItem key={opt.value} value={opt.value}>
126
+ {opt.label}
127
+ </SelectItem>
128
+ ))}
129
+ </SelectContent>
130
+ </Select>
131
+ </ConfigRow>
132
+ );
133
+ break;
134
+
135
+ case 'slider':
136
+ content = (
137
+ <ConfigRow label={field.label}>
138
+ <div className="flex items-center gap-2 w-32">
139
+ <Slider
140
+ data-testid={`config-field-${field.key}`}
141
+ value={[Number(effectiveValue ?? field.min ?? 0)]}
142
+ min={field.min ?? 0}
143
+ max={field.max ?? 100}
144
+ step={field.step ?? 1}
145
+ disabled={effectiveDisabled}
146
+ onValueChange={(vals) => onChange(vals[0])}
147
+ aria-label={field.label}
148
+ />
149
+ <span className="text-xs text-muted-foreground w-6 text-right">
150
+ {effectiveValue ?? field.min ?? 0}
151
+ </span>
152
+ </div>
153
+ </ConfigRow>
154
+ );
155
+ break;
156
+
157
+ case 'color':
158
+ content = (
159
+ <ConfigRow label={field.label}>
160
+ <input
161
+ data-testid={`config-field-${field.key}`}
162
+ type="color"
163
+ className="h-7 w-10 rounded border cursor-pointer"
164
+ value={effectiveValue ?? '#000000'}
165
+ disabled={effectiveDisabled}
166
+ onChange={(e) => onChange(e.target.value)}
167
+ />
168
+ </ConfigRow>
169
+ );
170
+ break;
171
+
172
+ case 'icon-group':
173
+ content = (
174
+ <ConfigRow label={field.label}>
175
+ <div className="flex items-center gap-0.5" data-testid={`config-field-${field.key}`}>
176
+ {(field.options ?? []).map((opt) => (
177
+ <Button
178
+ key={opt.value}
179
+ type="button"
180
+ size="sm"
181
+ variant={effectiveValue === opt.value ? 'default' : 'ghost'}
182
+ className={cn('h-7 w-7 p-0', effectiveValue === opt.value && 'ring-1 ring-primary')}
183
+ disabled={effectiveDisabled}
184
+ onClick={() => onChange(opt.value)}
185
+ title={opt.label}
186
+ >
187
+ {opt.icon ?? <span className="text-[10px]">{opt.label.charAt(0)}</span>}
188
+ </Button>
189
+ ))}
190
+ </div>
191
+ </ConfigRow>
192
+ );
193
+ break;
194
+
195
+ case 'field-picker':
196
+ content = (
197
+ <ConfigRow
198
+ label={field.label}
199
+ value={effectiveValue ?? field.placeholder ?? 'Select field…'}
200
+ onClick={effectiveDisabled ? undefined : () => {
201
+ /* open field picker - consumers should use type='custom' for full integration */
202
+ }}
203
+ />
204
+ );
205
+ break;
206
+
207
+ case 'filter':
208
+ content = (
209
+ <div data-testid={`config-field-${field.key}`}>
210
+ <ConfigRow label={field.label} />
211
+ <FilterBuilder
212
+ fields={field.fields}
213
+ value={effectiveValue}
214
+ onChange={onChange}
215
+ className="px-1 pb-2"
216
+ />
217
+ </div>
218
+ );
219
+ break;
220
+
221
+ case 'sort':
222
+ content = (
223
+ <div data-testid={`config-field-${field.key}`}>
224
+ <ConfigRow label={field.label} />
225
+ <SortBuilder
226
+ fields={field.fields}
227
+ value={effectiveValue}
228
+ onChange={onChange}
229
+ className="px-1 pb-2"
230
+ />
231
+ </div>
232
+ );
233
+ break;
234
+
235
+ case 'custom':
236
+ if (field.render) {
237
+ content = <>{field.render(effectiveValue, onChange, draft)}</>;
238
+ }
239
+ break;
240
+
241
+ case 'summary':
242
+ content = (
243
+ <ConfigRow
244
+ label={field.label}
245
+ onClick={field.onSummaryClick}
246
+ >
247
+ <div className="flex items-center gap-1.5">
248
+ <span className="text-xs text-foreground truncate max-w-[120px]" data-testid={`config-field-${field.key}-text`}>
249
+ {field.summaryText ?? effectiveValue ?? ''}
250
+ </span>
251
+ {field.onSummaryClick && (
252
+ <Settings className="h-3.5 w-3.5 text-muted-foreground shrink-0" aria-hidden="true" data-testid={`config-field-${field.key}-gear`} />
253
+ )}
254
+ </div>
255
+ </ConfigRow>
256
+ );
257
+ break;
258
+
259
+ default:
260
+ break;
261
+ }
262
+
263
+ if (!content) return null;
264
+
265
+ // Wrap with helpText when provided
266
+ if (field.helpText) {
267
+ return (
268
+ <div>
269
+ {content}
270
+ <p className="text-[10px] text-muted-foreground mt-0.5 mb-1">{field.helpText}</p>
271
+ </div>
272
+ );
273
+ }
274
+
275
+ return <>{content}</>;
276
+ }
@@ -0,0 +1,306 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import * as React from 'react';
10
+ import { useState } from 'react';
11
+ import { X, Save, RotateCcw, ChevronRight, Undo2, Redo2 } from 'lucide-react';
12
+
13
+ import { cn } from '../lib/utils';
14
+ import { Button } from '../ui/button';
15
+ import { Separator } from '../ui/separator';
16
+ import { SectionHeader } from './section-header';
17
+ import { ConfigFieldRenderer } from './config-field-renderer';
18
+ import type { ConfigPanelSchema } from '../types/config-panel';
19
+
20
+ export interface ConfigPanelRendererProps {
21
+ /** Whether the panel is visible */
22
+ open: boolean;
23
+ /** Close callback */
24
+ onClose: () => void;
25
+ /** Schema describing the panel structure */
26
+ schema: ConfigPanelSchema;
27
+ /** Current draft values */
28
+ draft: Record<string, any>;
29
+ /** Whether the draft has uncommitted changes */
30
+ isDirty: boolean;
31
+ /** Called when any field changes */
32
+ onFieldChange: (key: string, value: any) => void;
33
+ /** Persist current draft */
34
+ onSave: () => void;
35
+ /** Revert draft to source */
36
+ onDiscard: () => void;
37
+ /** Extra content rendered in the header row */
38
+ headerExtra?: React.ReactNode;
39
+ /** Object definition for field pickers */
40
+ objectDef?: Record<string, any>;
41
+ /** Additional CSS class name */
42
+ className?: string;
43
+ /** Label for save button (default: "Save") */
44
+ saveLabel?: string;
45
+ /** Label for discard button (default: "Discard") */
46
+ discardLabel?: string;
47
+ /** Ref for the panel root element */
48
+ panelRef?: React.Ref<HTMLDivElement>;
49
+ /** ARIA role for the panel (e.g. "complementary") */
50
+ role?: string;
51
+ /** ARIA label for the panel */
52
+ ariaLabel?: string;
53
+ /** tabIndex for the panel root element */
54
+ tabIndex?: number;
55
+ /** Override data-testid for the panel root (default: "config-panel") */
56
+ testId?: string;
57
+ /** Title for the close button */
58
+ closeTitle?: string;
59
+ /** Override data-testid for the footer (default: "config-panel-footer") */
60
+ footerTestId?: string;
61
+ /** Override data-testid for the save button (default: "config-panel-save") */
62
+ saveTestId?: string;
63
+ /** Override data-testid for the discard button (default: "config-panel-discard") */
64
+ discardTestId?: string;
65
+ /** Externally-controlled set of section keys that should be expanded (overrides local collapse state) */
66
+ expandedSections?: string[];
67
+ /** Undo callback */
68
+ onUndo?: () => void;
69
+ /** Redo callback */
70
+ onRedo?: () => void;
71
+ /** Whether undo is available */
72
+ canUndo?: boolean;
73
+ /** Whether redo is available */
74
+ canRedo?: boolean;
75
+ /** Label for undo button */
76
+ undoLabel?: string;
77
+ /** Label for redo button */
78
+ redoLabel?: string;
79
+ }
80
+
81
+ /**
82
+ * Schema-driven configuration panel renderer.
83
+ *
84
+ * Takes a `ConfigPanelSchema` and automatically renders the full panel:
85
+ * - Header with breadcrumb & close button
86
+ * - Scrollable body with collapsible sections
87
+ * - Sticky footer with Save / Discard when dirty
88
+ *
89
+ * Each concrete panel (Dashboard, Form, Page…) only needs to provide
90
+ * a schema and wire up `useConfigDraft`.
91
+ */
92
+ export function ConfigPanelRenderer({
93
+ open,
94
+ onClose,
95
+ schema,
96
+ draft,
97
+ isDirty,
98
+ onFieldChange,
99
+ onSave,
100
+ onDiscard,
101
+ headerExtra,
102
+ objectDef,
103
+ className,
104
+ saveLabel = 'Save',
105
+ discardLabel = 'Discard',
106
+ panelRef,
107
+ role,
108
+ ariaLabel,
109
+ tabIndex,
110
+ testId,
111
+ closeTitle,
112
+ footerTestId,
113
+ saveTestId,
114
+ discardTestId,
115
+ expandedSections,
116
+ onUndo,
117
+ onRedo,
118
+ canUndo,
119
+ canRedo,
120
+ undoLabel = 'Undo',
121
+ redoLabel = 'Redo',
122
+ }: ConfigPanelRendererProps) {
123
+ const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});
124
+
125
+ if (!open) return null;
126
+
127
+ const toggleCollapse = (key: string, defaultCollapsed?: boolean) => {
128
+ setCollapsed((prev) => ({
129
+ ...prev,
130
+ [key]: !(prev[key] ?? defaultCollapsed ?? false),
131
+ }));
132
+ };
133
+
134
+ // Resolve effective collapsed state: expandedSections prop overrides local state
135
+ const isCollapsed = (sectionKey: string, defaultCollapsed?: boolean): boolean => {
136
+ if (expandedSections && expandedSections.includes(sectionKey)) {
137
+ return false;
138
+ }
139
+ return collapsed[sectionKey] ?? defaultCollapsed ?? false;
140
+ };
141
+
142
+ return (
143
+ <div
144
+ ref={panelRef}
145
+ data-testid={testId ?? 'config-panel'}
146
+ role={role}
147
+ aria-label={ariaLabel}
148
+ tabIndex={tabIndex}
149
+ className={cn(
150
+ 'absolute inset-y-0 right-0 w-full sm:w-[var(--config-panel-width,280px)] sm:relative border-l bg-background flex flex-col shrink-0 z-20',
151
+ className,
152
+ )}
153
+ >
154
+ {/* ── Header ─────────────────────────────────────────── */}
155
+ <div className="px-4 py-3 border-b flex items-center justify-between shrink-0">
156
+ <nav aria-label="breadcrumb">
157
+ <ol className="flex items-center gap-1 text-xs text-muted-foreground">
158
+ {schema.breadcrumb.map((segment, idx) => (
159
+ <React.Fragment key={idx}>
160
+ {idx > 0 && <ChevronRight className="h-3 w-3" />}
161
+ <li
162
+ className={cn(
163
+ idx === schema.breadcrumb.length - 1 && 'text-foreground font-medium',
164
+ )}
165
+ >
166
+ {segment}
167
+ </li>
168
+ </React.Fragment>
169
+ ))}
170
+ </ol>
171
+ </nav>
172
+ <div className="flex items-center gap-1">
173
+ {onUndo && (
174
+ <Button
175
+ size="sm"
176
+ variant="ghost"
177
+ onClick={onUndo}
178
+ disabled={!canUndo}
179
+ className="h-7 w-7 p-0"
180
+ data-testid="config-panel-undo"
181
+ title={undoLabel}
182
+ >
183
+ <Undo2 className="h-3.5 w-3.5" />
184
+ </Button>
185
+ )}
186
+ {onRedo && (
187
+ <Button
188
+ size="sm"
189
+ variant="ghost"
190
+ onClick={onRedo}
191
+ disabled={!canRedo}
192
+ className="h-7 w-7 p-0"
193
+ data-testid="config-panel-redo"
194
+ title={redoLabel}
195
+ >
196
+ <Redo2 className="h-3.5 w-3.5" />
197
+ </Button>
198
+ )}
199
+ {headerExtra}
200
+ <Button
201
+ size="sm"
202
+ variant="ghost"
203
+ onClick={onClose}
204
+ className="h-7 w-7 p-0"
205
+ data-testid="config-panel-close"
206
+ title={closeTitle}
207
+ >
208
+ <X className="h-3.5 w-3.5" />
209
+ </Button>
210
+ </div>
211
+ </div>
212
+
213
+ {/* ── Scrollable sections ────────────────────────────── */}
214
+ <div className="flex-1 overflow-auto px-4 pb-4">
215
+ {schema.sections.map((section, sectionIdx) => {
216
+ if (section.visibleWhen && !section.visibleWhen(draft)) return null;
217
+
218
+ const sectionCollapsed = isCollapsed(section.key, section.defaultCollapsed);
219
+
220
+ return (
221
+ <div key={section.key} data-testid={`config-section-${section.key}`}>
222
+ {sectionIdx > 0 && <Separator className="my-3" />}
223
+ <SectionHeader
224
+ title={section.title}
225
+ icon={section.icon}
226
+ collapsible={section.collapsible}
227
+ collapsed={sectionCollapsed}
228
+ onToggle={() => toggleCollapse(section.key, section.defaultCollapsed)}
229
+ testId={`section-header-${section.key}`}
230
+ />
231
+ {section.hint && (
232
+ <p className="text-[10px] text-muted-foreground mb-1">
233
+ {section.hint}
234
+ </p>
235
+ )}
236
+ {!sectionCollapsed && (
237
+ <div className="space-y-1">
238
+ {section.fields.map((field) => (
239
+ <ConfigFieldRenderer
240
+ key={field.key}
241
+ field={field}
242
+ value={draft[field.key]}
243
+ onChange={(v) => onFieldChange(field.key, v)}
244
+ draft={draft}
245
+ objectDef={objectDef}
246
+ />
247
+ ))}
248
+ {section.subsections?.map((sub) => {
249
+ if (sub.visibleWhen && !sub.visibleWhen(draft)) return null;
250
+ const subCollapsed = isCollapsed(sub.key, sub.defaultCollapsed);
251
+ return (
252
+ <div key={sub.key} data-testid={`config-subsection-${sub.key}`} className="ml-1" role="group" aria-label={sub.title}>
253
+ <SectionHeader
254
+ title={sub.title}
255
+ icon={sub.icon}
256
+ collapsible={sub.collapsible}
257
+ collapsed={subCollapsed}
258
+ onToggle={() => toggleCollapse(sub.key, sub.defaultCollapsed)}
259
+ testId={`section-header-${sub.key}`}
260
+ className="pt-2 pb-1"
261
+ />
262
+ {!subCollapsed && (
263
+ <div className="space-y-1">
264
+ {sub.fields.map((field) => (
265
+ <ConfigFieldRenderer
266
+ key={field.key}
267
+ field={field}
268
+ value={draft[field.key]}
269
+ onChange={(v) => onFieldChange(field.key, v)}
270
+ draft={draft}
271
+ objectDef={objectDef}
272
+ />
273
+ ))}
274
+ </div>
275
+ )}
276
+ </div>
277
+ );
278
+ })}
279
+ </div>
280
+ )}
281
+ </div>
282
+ );
283
+ })}
284
+ </div>
285
+
286
+ {/* ── Footer ─────────────────────────────────────────── */}
287
+ {isDirty && (
288
+ <div className="px-4 py-2 border-t flex gap-2 shrink-0" data-testid={footerTestId ?? 'config-panel-footer'}>
289
+ <Button size="sm" onClick={onSave} data-testid={saveTestId ?? 'config-panel-save'}>
290
+ <Save className="h-3.5 w-3.5 mr-1" />
291
+ {saveLabel}
292
+ </Button>
293
+ <Button
294
+ size="sm"
295
+ variant="ghost"
296
+ onClick={onDiscard}
297
+ data-testid={discardTestId ?? 'config-panel-discard'}
298
+ >
299
+ <RotateCcw className="h-3.5 w-3.5 mr-1" />
300
+ {discardLabel}
301
+ </Button>
302
+ </div>
303
+ )}
304
+ </div>
305
+ );
306
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import { cn } from "../lib/utils"
10
+
11
+ export interface ConfigRowProps {
12
+ /** Left-side label text */
13
+ label: string
14
+ /** Right-side display value (used when children are not provided) */
15
+ value?: string
16
+ /** Makes row clickable with hover effect */
17
+ onClick?: () => void
18
+ /** Custom content replacing value */
19
+ children?: React.ReactNode
20
+ /** Additional CSS class name */
21
+ className?: string
22
+ }
23
+
24
+ /**
25
+ * A single labeled row in a configuration panel.
26
+ *
27
+ * Renders as a `<button>` when `onClick` is provided, otherwise as a `<div>`.
28
+ * Shows label on the left and either custom children or a text value on the right.
29
+ */
30
+ function ConfigRow({ label, value, onClick, children, className }: ConfigRowProps) {
31
+ const Wrapper = onClick ? 'button' : 'div'
32
+ return (
33
+ <Wrapper
34
+ className={cn(
35
+ 'flex items-center justify-between py-1.5 min-h-[32px] w-full text-left',
36
+ onClick && 'cursor-pointer hover:bg-accent/50 rounded-sm -mx-1 px-1',
37
+ className,
38
+ )}
39
+ onClick={onClick}
40
+ type={onClick ? 'button' : undefined}
41
+ >
42
+ <span className="text-xs text-muted-foreground shrink-0 max-w-[45%] truncate" title={label}>{label}</span>
43
+ {children || (
44
+ <span className="text-xs text-foreground truncate ml-4 text-right max-w-[55%]" title={value}>{value}</span>
45
+ )}
46
+ </Wrapper>
47
+ )
48
+ }
49
+
50
+ export { ConfigRow }
@@ -1,5 +1,8 @@
1
1
  export * from './button-group';
2
2
  export * from './combobox';
3
+ export * from './config-row';
4
+ export * from './config-field-renderer';
5
+ export * from './config-panel-renderer';
3
6
  export * from './date-picker';
4
7
  export * from './empty';
5
8
  export * from './field';
@@ -9,8 +12,10 @@ export * from './item';
9
12
  export * from './kbd';
10
13
  export * from './native-select';
11
14
  export * from './navigation-overlay';
15
+ export * from './section-header';
12
16
  export * from './spinner';
13
17
  export * from './sort-builder';
14
18
  export * from './action-param-dialog';
15
19
  export * from './view-skeleton';
16
20
  export * from './view-states';
21
+ export * from './mobile-dialog-content';