Skip to content

Commit 3624ee0

Browse files
committed
Merge origin/main (K1 landed)
2 parents 3e1b3b7 + abba2c4 commit 3624ee0

43 files changed

Lines changed: 13590 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎content/docs/data-modeling/field-types.mdx‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,83 @@ what the box accepts, and only one of the two outcomes is announced:
10581058
10591059
"No warning" therefore does not mean "the value is right".
10601060
1061+
### Polymorphic pointer pairs (`referenceVia`)
1062+
1063+
A `text` field that declares `referenceVia` holds a record id of the object its
1064+
sibling column names, row by row: `sys_approval_request.record_id` points at the
1065+
record `object_name` names, and `sys_activity.source_id` at the one
1066+
`source_object` names. The record details grid resolves the pair from the row
1067+
with `resolveRecordPointer(field, row)` and draws it with the renderer
1068+
registered under `RECORD_POINTER_CARD_TYPE`. The fields package's default draws
1069+
the record id as text; the console registers a record preview card there, so a
1070+
pointer field on a record page shows the record it points at. When the card
1071+
could read that record, its title links to the record's page in the current
1072+
app, built by the same record-link builder the page's lookup values use; a
1073+
record the reader cannot read is drawn with no link, and the card never says
1074+
why. Nothing is authored for this: the `referenceVia` declaration on the field
1075+
is the whole contract. List cells are not a call site yet.
1076+
1077+
When the platform deletes the record a pointer names, it can say so on the row.
1078+
A pointer field that also declares `referenceDeletedWhen: { field, value }`
1079+
names a sibling `select` field and the option the platform writes there, as
1080+
`sys_approval_request.record_id` declares
1081+
`{ field: 'cancel_reason', value: 'record_deleted' }`. On a row holding that
1082+
option the details grid draws a tombstone in the option's own label (localized
1083+
when the console's bundle localizes it), reads nothing and links nothing. A
1084+
record the card cannot read on any other row still gets the cause-free text:
1085+
only the declaration means deleted.
1086+
1087+
### Naming a registry item by name (`position-ref`, `permission-ref`)
1088+
1089+
A `text` field that stores the **machine name** of one item of a metadata
1090+
registry — a position, a permission set — declares the matching widget, and the
1091+
record form lists that registry instead of asking for a typed name:
1092+
1093+
```json
1094+
{
1095+
"position": {
1096+
"type": "text",
1097+
"label": "Position",
1098+
"required": true,
1099+
"maxLength": 100,
1100+
"widget": "position-ref"
1101+
}
1102+
}
1103+
```
1104+
1105+
| Widget | Lists | Stores |
1106+
|---|---|---|
1107+
| `position-ref` | the `position` registry (`GET /api/v1/meta/position`) | the position's `name` |
1108+
| `permission-ref` | the `permission` registry (`GET /api/v1/meta/permission`) | the permission set's `name` |
1109+
1110+
Like every `widget` value, the name is looked up as `field:<widget>`. Each item
1111+
reads as its label beside its name, and the value written is the name alone: no
1112+
label, no id. A stored name the registry does not list stays on screen, flagged
1113+
*not found*, so a renamed or removed item is visible rather than dropped.
1114+
`position-ref` leaves out the audience anchors, the spec's
1115+
`AUDIENCE_ANCHOR_POSITIONS` (`everyone`, `guest`), because the server refuses an
1116+
anchor as a grant target; a stored anchor still shows as its own option. The
1117+
list comes from the data source's `listMetadataItems(type)`. When the adapter
1118+
has none, the list is empty, or the load fails, the field is a text box that
1119+
takes the typed name; a failure is shown with its cause, and the box stays
1120+
editable.
1121+
1122+
### A widget's face on the record heading
1123+
1124+
A `text` field that declares `widget: 'recipient-picker'` or `widget: 'object-ref'` is drawn
1125+
in a list column through the read cell registered under that widget's key, which names what
1126+
the stored value references. When that field is also the object's `nameField`, the record
1127+
page heading draws the value through the same cell: a record share heads its page with the
1128+
recipient's name, not the user id it stores. Nothing is authored for this; the `widget`
1129+
declaration on the field is the whole contract.
1130+
1131+
The heading lives in `@object-ui/components`, which this package depends on and so cannot be
1132+
imported from here the other way round. `@object-ui/components` therefore owns a slot,
1133+
`setFieldReadFaceResolver` / `resolveFieldReadFace`, and this package fills it when it loads with the
1134+
lookup the list cells make. The widget's key draws the stored text until a host registers a
1135+
face under it (the console registers its own), and while it does, the heading prints the
1136+
stored value as before. So does a host that does not load `@object-ui/fields`.
1137+
10611138
## Choosing a Field Type
10621139
10631140
Not sure which type fits your data? Follow the [Field Type Decision Tree](/docs/data-modeling/field-type-decision-tree) — a flowchart, quick-reference tables, and a use-case mapping for every type in this gallery.
Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
---
2+
title: "AppShell"
3+
description: "Main application shell with sidebar and header layout"
4+
---
5+
6+
The AppShell component provides the main application layout structure with an integrated sidebar, header, and content area. It's the foundation for building enterprise applications with ObjectUI.
7+
8+
## Basic Usage
9+
10+
```tsx
11+
import { AppShell, SidebarNav, type NavItem } from '@object-ui/layout';
12+
import { Home, Settings, Users } from 'lucide-react';
13+
14+
const navItems: NavItem[] = [
15+
{ title: 'Dashboard', href: '/', icon: Home },
16+
{ title: 'Users', href: '/users', icon: Users },
17+
{ title: 'Settings', href: '/settings', icon: Settings },
18+
];
19+
20+
<AppShell
21+
sidebar={<SidebarNav items={navItems} />}
22+
navbar={
23+
<div className="flex items-center gap-4">
24+
<span className="font-semibold">My App</span>
25+
</div>
26+
}
27+
>
28+
{/* Your page content */}
29+
<div>Main content area</div>
30+
</AppShell>
31+
```
32+
33+
## Component Props
34+
35+
```ts
36+
import type { AppShellBranding } from '@object-ui/layout';
37+
38+
interface AppShellProps {
39+
sidebar?: React.ReactNode; // Sidebar content (usually SidebarNav)
40+
navbar?: React.ReactNode; // Top navbar content (logo, search, user menu)
41+
children: React.ReactNode; // Main content area
42+
className?: string; // Additional CSS classes for content area
43+
defaultOpen?: boolean; // Sidebar default state (default: true)
44+
branding?: AppShellBranding; // App branding — four theme fields, see Branding
45+
rightRail?: React.ReactNode; // Optional right rail beside the content, not
46+
// over it (ADR-0057 P3a)
47+
}
48+
```
49+
50+
## Features
51+
52+
### Responsive Sidebar
53+
54+
The AppShell does not build a sidebar of its own: it renders the node you pass in
55+
`sidebar`, wrapped in a `SidebarProvider`. Pass a `Sidebar`-based node (`SidebarNav`, or
56+
your own) and you get a sidebar that:
57+
- Collapses on mobile devices
58+
- Can be toggled with the `Cmd/Ctrl + B` keyboard shortcut, or by a toggle button you
59+
render yourself — see Collapsible Sidebar below
60+
- Persists state across page navigations
61+
- Supports smooth animations
62+
63+
### Header Bar
64+
65+
The header renders your `navbar` content and nothing else — the AppShell adds no controls
66+
of its own to it, in particular **no sidebar toggle**. If you want one, render it inside
67+
`navbar` (see Collapsible Sidebar below). The header itself provides:
68+
- Custom navbar content area
69+
- Fixed height: `h-12` (3rem / 48px) at every breakpoint — there is no responsive height variant
70+
- Border bottom separator
71+
- Background matching app theme
72+
73+
### Content Area
74+
75+
The main content area features:
76+
- Responsive padding in three steps: `p-3` on mobile, `sm:p-4` from the `sm` breakpoint, `md:p-6` from `md` up
77+
- A taller bottom padding on mobile only: `pb-20` (5rem), which keeps content clear of the mobile bottom bar (that bar is itself `sm:hidden`); from `sm` up the bottom edge follows `sm:pb-4` / `md:pb-6` like the other sides
78+
- Automatic scrolling
79+
- Flexible height (fills viewport)
80+
- Custom className support
81+
82+
### Branding
83+
84+
`branding` is theming, not chrome — the shell hands it to `useAppShellBranding`, and all
85+
four of the fields it declares are read:
86+
87+
- `primaryColor` / `accentColor` — a six-digit hex (`#3B82F6`; the leading `#` is
88+
optional, three-digit shorthand is not accepted), translated into the Shadcn theme
89+
tokens listed under Styling below. A value that does not parse that way is ignored
90+
silently.
91+
- `favicon` — overwrites the `href` of the icon link the page already has (`#favicon`,
92+
otherwise `link[rel="icon"]`). It never creates one, so a document with no icon link is
93+
left unchanged.
94+
- `title` — assigned to `document.title` as given. It is the whole title, not a suffix:
95+
the caller composes the string it wants (the console passes
96+
`"App label — Product name"`).
97+
98+
All of it acts on the document rather than on the shell's subtree, and the colour
99+
properties are removed again when the shell unmounts.
100+
101+
### Right Rail
102+
103+
`rightRail` renders your node as a flex sibling of the content area, so the rail sits
104+
**beside** the content and reflows it rather than overlaying it (ADR-0057 P3a). The shell
105+
adds no wrapper and no width around it — the node you pass owns its width, border and
106+
scrolling; omit it and the layout is the unchanged single pane.
107+
108+
## Layout Structure
109+
110+
```
111+
┌─────────────────────────────────────┐
112+
│ Header (your navbar content) │
113+
├──────────┬──────────────────────────┤
114+
│ │ │
115+
│ Sidebar │ Main Content Area │
116+
│ │ │
117+
│ │ │
118+
│ │ │
119+
└──────────┴──────────────────────────┘
120+
```
121+
122+
## Sidebar Configuration
123+
124+
### Default Open State
125+
126+
Control whether sidebar is open by default:
127+
128+
```plaintext
129+
<AppShell defaultOpen={false}>
130+
{/* Sidebar starts collapsed */}
131+
</AppShell>
132+
```
133+
134+
### Collapsible Sidebar
135+
136+
The AppShell renders no toggle button of its own. What it does give you is the
137+
`SidebarProvider` wrapped around both slots, so the sidebar you supply can be toggled via:
138+
- The `Cmd/Ctrl + B` keyboard shortcut, provided by `SidebarProvider`
139+
- Programmatic control — `useSidebar().toggleSidebar()` from any component inside the shell
140+
- A toggle button you render yourself; it belongs in the `navbar` slot:
141+
142+
```tsx
143+
import { SidebarTrigger } from '@object-ui/components';
144+
import { AppShell, SidebarNav, type NavItem } from '@object-ui/layout';
145+
import { Home, Settings } from 'lucide-react';
146+
147+
const navItems: NavItem[] = [
148+
{ title: 'Dashboard', href: '/', icon: Home },
149+
{ title: 'Settings', href: '/settings', icon: Settings },
150+
];
151+
152+
<AppShell
153+
navbar={<SidebarTrigger />}
154+
sidebar={<SidebarNav items={navItems} />}
155+
>
156+
<div>Your page content</div>
157+
</AppShell>
158+
```
159+
160+
## Navbar Content
161+
162+
The navbar area is flexible and can contain:
163+
164+
### Logo and Title
165+
166+
```plaintext
167+
navbar={
168+
<div className="flex items-center gap-2">
169+
<img src="/logo.svg" alt="Logo" className="h-8 w-8" />
170+
<span className="font-semibold text-lg">My Application</span>
171+
</div>
172+
}
173+
```
174+
175+
### Search Bar
176+
177+
```plaintext
178+
navbar={
179+
<div className="flex-1 max-w-md">
180+
<Input placeholder="Search..." />
181+
</div>
182+
}
183+
```
184+
185+
### User Menu
186+
187+
```plaintext
188+
navbar={
189+
<div className="flex items-center gap-4 ml-auto">
190+
<NotificationsButton />
191+
<UserDropdown />
192+
</div>
193+
}
194+
```
195+
196+
## Complete Example
197+
198+
```tsx
199+
import { AppShell, SidebarNav, type NavItem } from '@object-ui/layout';
200+
import { Avatar, AvatarFallback, Button, Input } from '@object-ui/components';
201+
import { Bell, Folder, LayoutDashboard, Settings, Users } from 'lucide-react';
202+
203+
const navItems: NavItem[] = [
204+
{ title: 'Dashboard', href: '/', icon: LayoutDashboard, badge: '12' },
205+
{
206+
title: 'Projects',
207+
href: '/projects',
208+
icon: Folder,
209+
children: [
210+
{ title: 'Active', href: '/projects/active' },
211+
{ title: 'Archived', href: '/projects/archived' },
212+
],
213+
},
214+
{ title: 'Team', href: '/team', icon: Users },
215+
{ title: 'Settings', href: '/settings', icon: Settings },
216+
];
217+
218+
function App() {
219+
return (
220+
<AppShell
221+
defaultOpen={true}
222+
sidebar={<SidebarNav title="ObjectUI" items={navItems} />}
223+
navbar={
224+
<div className="flex items-center justify-between w-full">
225+
{/* Search */}
226+
<div className="flex-1 max-w-md">
227+
<Input
228+
placeholder="Search..."
229+
className="w-full"
230+
/>
231+
</div>
232+
233+
{/* Right side items */}
234+
<div className="flex items-center gap-4">
235+
<Button variant="ghost" size="icon">
236+
<Bell className="h-5 w-5" />
237+
</Button>
238+
<Avatar>
239+
<AvatarFallback>JD</AvatarFallback>
240+
</Avatar>
241+
</div>
242+
</div>
243+
}
244+
className="bg-gray-50"
245+
>
246+
{/* Main content */}
247+
<div className="max-w-7xl">
248+
<h1 className="text-2xl font-bold mb-4">Dashboard</h1>
249+
{/* Page content */}
250+
</div>
251+
</AppShell>
252+
);
253+
}
254+
```
255+
256+
`SidebarNav` has no logo slot and no footer slot — `title` is its only branding prop, the
257+
section label printed above a flat `NavItem[]` (it is ignored when `items` is a
258+
`NavGroup[]`, since each group prints its own `label`). Put a logo in the `navbar` slot
259+
instead, as the Logo and Title example under Navbar Content above does.
260+
261+
## With Page Component
262+
263+
Combine AppShell with the Page component for complete layouts:
264+
265+
```plaintext
266+
<AppShell sidebar={<SidebarNav items={navItems} />}>
267+
<Page
268+
title="Dashboard"
269+
description="Welcome to your dashboard"
270+
body={[
271+
{ type: 'text', content: 'Dashboard content' }
272+
]}
273+
/>
274+
</AppShell>
275+
```
276+
277+
## Styling
278+
279+
The AppShell uses Tailwind CSS and Shadcn UI components:
280+
281+
- `SidebarProvider`: Manages sidebar state
282+
- `SidebarInset`: Content area wrapper
283+
284+
Brand colours arrive as Shadcn theme tokens rather than as per-component styles: each hex
285+
from `branding` is converted to the `H S% L%` triple those tokens carry and set as a CSS
286+
custom property on `document.documentElement`. `primaryColor` writes `--primary`,
287+
`--primary-foreground`, `--ring`, `--sidebar-primary` and `--sidebar-ring`; `accentColor`
288+
writes `--accent` and `--accent-foreground`. Tailwind's utilities resolve through the same
289+
tokens (`--color-primary: hsl(var(--primary))`), so every `bg-primary` / `text-primary` /
290+
`ring-primary` / `bg-accent` consumer picks the brand colour up with no per-component
291+
wiring. In dark mode a lighter variant of the same hue is used instead, and the shell
292+
re-applies the values whenever the `dark` class on the `html` element changes.
293+
294+
## Accessibility
295+
296+
The AppShell includes:
297+
- A keyboard shortcut for toggling the sidebar (`Cmd/Ctrl + B`), from `SidebarProvider`
298+
- Keyboard navigation support
299+
- Focus management
300+
- Screen reader announcements
301+
302+
## Related
303+
304+
- [SidebarNav](/docs/frontend/sidebar-nav) - Sidebar navigation component
305+
- [PageHeader](/docs/ui/pages) - Page header component
306+
- [Page](/docs/frontend/renderers) - Page layout component

0 commit comments

Comments
 (0)