@object-ui/components 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 (60) hide show
  1. package/.turbo/turbo-build.log +12 -12
  2. package/CHANGELOG.md +9 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +24932 -23139
  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/filter-builder.d.ts +1 -1
  10. package/dist/src/custom/index.d.ts +5 -0
  11. package/dist/src/custom/mobile-dialog-content.d.ts +20 -0
  12. package/dist/src/custom/navigation-overlay.d.ts +8 -0
  13. package/dist/src/custom/section-header.d.ts +31 -0
  14. package/dist/src/debug/DebugPanel.d.ts +39 -0
  15. package/dist/src/debug/index.d.ts +9 -0
  16. package/dist/src/hooks/use-config-draft.d.ts +46 -0
  17. package/dist/src/index.d.ts +4 -0
  18. package/dist/src/renderers/action/action-bar.d.ts +25 -0
  19. package/dist/src/renderers/action/action-button.d.ts +1 -0
  20. package/dist/src/types/config-panel.d.ts +92 -0
  21. package/dist/src/ui/sheet.d.ts +2 -0
  22. package/dist/src/ui/sidebar.d.ts +4 -0
  23. package/package.json +17 -17
  24. package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +3 -3
  25. package/src/__tests__/action-bar.test.tsx +206 -0
  26. package/src/__tests__/config-field-renderer.test.tsx +307 -0
  27. package/src/__tests__/config-panel-renderer.test.tsx +580 -0
  28. package/src/__tests__/config-primitives.test.tsx +106 -0
  29. package/src/__tests__/filter-builder.test.tsx +409 -0
  30. package/src/__tests__/mobile-accessibility.test.tsx +120 -0
  31. package/src/__tests__/navigation-overlay.test.tsx +97 -0
  32. package/src/__tests__/use-config-draft.test.tsx +295 -0
  33. package/src/custom/config-field-renderer.tsx +276 -0
  34. package/src/custom/config-panel-renderer.tsx +306 -0
  35. package/src/custom/config-row.tsx +50 -0
  36. package/src/custom/filter-builder.tsx +76 -25
  37. package/src/custom/index.ts +5 -0
  38. package/src/custom/mobile-dialog-content.tsx +67 -0
  39. package/src/custom/navigation-overlay.tsx +42 -4
  40. package/src/custom/section-header.tsx +68 -0
  41. package/src/debug/DebugPanel.tsx +313 -0
  42. package/src/debug/__tests__/DebugPanel.test.tsx +134 -0
  43. package/src/debug/index.ts +10 -0
  44. package/src/hooks/use-config-draft.ts +127 -0
  45. package/src/index.css +4 -0
  46. package/src/index.ts +15 -0
  47. package/src/renderers/action/action-bar.tsx +221 -0
  48. package/src/renderers/action/action-button.tsx +17 -6
  49. package/src/renderers/action/index.ts +1 -0
  50. package/src/renderers/complex/__tests__/data-table-airtable-ux.test.tsx +239 -0
  51. package/src/renderers/complex/__tests__/data-table.test.ts +16 -0
  52. package/src/renderers/complex/data-table.tsx +346 -43
  53. package/src/renderers/data-display/breadcrumb.tsx +3 -2
  54. package/src/renderers/form/form.tsx +4 -4
  55. package/src/renderers/navigation/header-bar.tsx +69 -10
  56. package/src/stories/ConfigPanel.stories.tsx +232 -0
  57. package/src/types/config-panel.ts +101 -0
  58. package/src/ui/dialog.tsx +20 -3
  59. package/src/ui/sheet.tsx +6 -3
  60. package/src/ui/sidebar.tsx +93 -9
@@ -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 }
@@ -13,6 +13,7 @@ import { X, Plus, Trash2 } from "lucide-react"
13
13
 
14
14
  import { cn } from "../lib/utils"
15
15
  import { Button } from "../ui/button"
16
+ import { Checkbox } from "../ui/checkbox"
16
17
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"
17
18
  import { Input } from "../ui/input"
18
19
 
@@ -20,7 +21,7 @@ export interface FilterCondition {
20
21
  id: string
21
22
  field: string
22
23
  operator: string
23
- value: string | number | boolean
24
+ value: string | number | boolean | (string | number | boolean)[]
24
25
  }
25
26
 
26
27
  export interface FilterGroup {
@@ -65,6 +66,23 @@ const numberOperators = ["equals", "notEquals", "greaterThan", "lessThan", "grea
65
66
  const booleanOperators = ["equals", "notEquals"]
66
67
  const dateOperators = ["equals", "notEquals", "before", "after", "between", "isEmpty", "isNotEmpty"]
67
68
  const selectOperators = ["equals", "notEquals", "in", "notIn", "isEmpty", "isNotEmpty"]
69
+ const lookupOperators = ["equals", "notEquals", "in", "notIn", "isEmpty", "isNotEmpty"]
70
+
71
+ /** Field types that share the same operator/input behavior as number (numeric comparison operators, number input) */
72
+ const numberLikeTypes = ["number", "currency", "percent", "rating"]
73
+ /** Field types that share the same operator/input behavior as date (before/after operators, date/datetime/time input) */
74
+ const dateLikeTypes = ["date", "datetime", "time"]
75
+ /** Field types that use select operators (equals/in/notIn) and render dropdown or checkbox list when options provided */
76
+ const selectLikeTypes = ["select", "status"]
77
+ /** Relational/reference field types that use lookup operators (equals/in/notIn) and render dropdown or checkbox list when options provided */
78
+ const lookupLikeTypes = ["lookup", "master_detail", "user", "owner"]
79
+
80
+ /** Normalize a filter value into an array for multi-select scenarios */
81
+ function normalizeToArray(value: FilterCondition["value"]): (string | number | boolean)[] {
82
+ if (Array.isArray(value)) return value
83
+ if (value !== undefined && value !== null && value !== "") return [value as string | number | boolean]
84
+ return []
85
+ }
68
86
 
69
87
  function FilterBuilder({
70
88
  fields = [],
@@ -139,19 +157,22 @@ function FilterBuilder({
139
157
  const field = fields.find((f) => f.value === fieldValue)
140
158
  const fieldType = field?.type || "text"
141
159
 
142
- switch (fieldType) {
143
- case "number":
144
- return defaultOperators.filter((op) => numberOperators.includes(op.value))
145
- case "boolean":
146
- return defaultOperators.filter((op) => booleanOperators.includes(op.value))
147
- case "date":
148
- return defaultOperators.filter((op) => dateOperators.includes(op.value))
149
- case "select":
150
- return defaultOperators.filter((op) => selectOperators.includes(op.value))
151
- case "text":
152
- default:
153
- return defaultOperators.filter((op) => textOperators.includes(op.value))
160
+ if (numberLikeTypes.includes(fieldType)) {
161
+ return defaultOperators.filter((op) => numberOperators.includes(op.value))
162
+ }
163
+ if (fieldType === "boolean") {
164
+ return defaultOperators.filter((op) => booleanOperators.includes(op.value))
165
+ }
166
+ if (dateLikeTypes.includes(fieldType)) {
167
+ return defaultOperators.filter((op) => dateOperators.includes(op.value))
168
+ }
169
+ if (selectLikeTypes.includes(fieldType)) {
170
+ return defaultOperators.filter((op) => selectOperators.includes(op.value))
171
+ }
172
+ if (lookupLikeTypes.includes(fieldType)) {
173
+ return defaultOperators.filter((op) => lookupOperators.includes(op.value))
154
174
  }
175
+ return defaultOperators.filter((op) => textOperators.includes(op.value))
155
176
  }
156
177
 
157
178
  const needsValueInput = (operator: string) => {
@@ -162,21 +183,51 @@ function FilterBuilder({
162
183
  const field = fields.find((f) => f.value === fieldValue)
163
184
  const fieldType = field?.type || "text"
164
185
 
165
- switch (fieldType) {
166
- case "number":
167
- return "number"
168
- case "date":
169
- return "date"
170
- default:
171
- return "text"
172
- }
186
+ if (numberLikeTypes.includes(fieldType)) return "number"
187
+ if (fieldType === "date") return "date"
188
+ if (fieldType === "datetime") return "datetime-local"
189
+ if (fieldType === "time") return "time"
190
+ return "text"
173
191
  }
174
192
 
175
193
  const renderValueInput = (condition: FilterCondition) => {
176
194
  const field = fields.find((f) => f.value === condition.field)
195
+ const isMultiOperator = ["in", "notIn"].includes(condition.operator)
177
196
 
178
- // For select fields with options
179
- if (field?.type === "select" && field.options) {
197
+ // For select/lookup fields with options and multi-select operator (in/notIn)
198
+ if (field?.options && isMultiOperator) {
199
+ const selectedValues = normalizeToArray(condition.value)
200
+ return (
201
+ <div className="max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2">
202
+ {field.options.map((opt) => {
203
+ const isChecked = selectedValues.map(String).includes(String(opt.value))
204
+ return (
205
+ <label
206
+ key={opt.value}
207
+ className={cn(
208
+ "flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer",
209
+ isChecked ? "bg-primary/5 text-primary" : "hover:bg-muted",
210
+ )}
211
+ >
212
+ <Checkbox
213
+ checked={isChecked}
214
+ onCheckedChange={(checked) => {
215
+ const next = checked
216
+ ? [...selectedValues, opt.value]
217
+ : selectedValues.filter((v) => String(v) !== String(opt.value))
218
+ updateCondition(condition.id, { value: next })
219
+ }}
220
+ />
221
+ <span className="truncate">{opt.label}</span>
222
+ </label>
223
+ )
224
+ })}
225
+ </div>
226
+ )
227
+ }
228
+
229
+ // For select/lookup fields with options (single select)
230
+ if (field?.options && (selectLikeTypes.includes(field.type || "") || lookupLikeTypes.includes(field.type || ""))) {
180
231
  return (
181
232
  <Select
182
233
  value={String(condition.value || "")}
@@ -235,9 +286,9 @@ function FilterBuilder({
235
286
  const handleValueChange = (newValue: string) => {
236
287
  let convertedValue: string | number | boolean = newValue
237
288
 
238
- if (field?.type === "number" && newValue !== "") {
289
+ if (numberLikeTypes.includes(field?.type || "") && newValue !== "") {
239
290
  convertedValue = parseFloat(newValue) || 0
240
- } else if (field?.type === "date") {
291
+ } else if (dateLikeTypes.includes(field?.type || "")) {
241
292
  convertedValue = newValue // Keep as ISO string
242
293
  }
243
294
 
@@ -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';
@@ -0,0 +1,67 @@
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
+ /**
10
+ * MobileDialogContent
11
+ *
12
+ * A mobile-optimized wrapper around the upstream Shadcn DialogContent.
13
+ * On mobile (< sm breakpoint), the dialog is full-screen with a larger
14
+ * close-button touch target (≥ 44×44px per WCAG 2.5.5).
15
+ * On tablet+ (≥ sm), it falls back to the standard centered dialog.
16
+ *
17
+ * This lives in `custom/` to avoid modifying the Shadcn-synced `ui/dialog.tsx`.
18
+ */
19
+
20
+ import * as React from 'react';
21
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
22
+ import { X } from 'lucide-react';
23
+ import { cn } from '../lib/utils';
24
+ import { DialogOverlay, DialogPortal } from '../ui/dialog';
25
+
26
+ export const MobileDialogContent = React.forwardRef<
27
+ React.ElementRef<typeof DialogPrimitive.Content>,
28
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
29
+ >(({ className, children, ...props }, ref) => (
30
+ <DialogPortal>
31
+ <DialogOverlay />
32
+ <DialogPrimitive.Content
33
+ ref={ref}
34
+ className={cn(
35
+ // Mobile-first: full-screen
36
+ 'fixed inset-0 z-50 w-full bg-background p-4 shadow-lg duration-200',
37
+ 'h-[100dvh]',
38
+ // Desktop (sm+): centered dialog with border + rounded corners
39
+ 'sm:inset-auto sm:left-[50%] sm:top-[50%] sm:translate-x-[-50%] sm:translate-y-[-50%]',
40
+ 'sm:max-w-lg sm:h-auto sm:max-h-[90vh] sm:rounded-lg sm:border sm:p-6',
41
+ // Animations
42
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out',
43
+ 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
44
+ 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
45
+ 'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',
46
+ 'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
47
+ className,
48
+ )}
49
+ {...props}
50
+ >
51
+ {children}
52
+ <DialogPrimitive.Close
53
+ className={cn(
54
+ 'absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity',
55
+ 'hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
56
+ 'disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground',
57
+ // Mobile touch target ≥ 44×44px (WCAG 2.5.5)
58
+ 'min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 flex items-center justify-center',
59
+ )}
60
+ >
61
+ <X className="h-5 w-5 sm:h-4 sm:w-4" />
62
+ <span className="sr-only">Close</span>
63
+ </DialogPrimitive.Close>
64
+ </DialogPrimitive.Content>
65
+ </DialogPortal>
66
+ ));
67
+ MobileDialogContent.displayName = 'MobileDialogContent';