@ai-matrx/records-ui 0.116.79 → 0.116.81
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.
- package/CHANGELOG.md +5 -4
- package/dist/{chunk-5ICDUZS7.js → chunk-5DELD6DC.js} +18 -5
- package/dist/{chunk-5ICDUZS7.js.map → chunk-5DELD6DC.js.map} +1 -1
- package/dist/entity-doors.cjs +164 -0
- package/dist/entity-doors.cjs.map +1 -0
- package/dist/entity-doors.d.cts +289 -0
- package/dist/entity-doors.d.ts +289 -0
- package/dist/entity-doors.js +154 -0
- package/dist/entity-doors.js.map +1 -0
- package/dist/entity-ref.cjs +795 -0
- package/dist/entity-ref.cjs.map +1 -0
- package/dist/entity-ref.d.cts +709 -0
- package/dist/entity-ref.d.ts +709 -0
- package/dist/entity-ref.js +764 -0
- package/dist/entity-ref.js.map +1 -0
- package/dist/index.cjs +18 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +16 -3
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +24 -4
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ComponentType, MouseEvent, ReactNode, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Door resolution — the ONE place a (token, id) pair becomes reachable doors.
|
|
6
|
+
*
|
|
7
|
+
* THE DOOR LAW (common-docs/policies/no-dead-ends.md): if the UI names a thing
|
|
8
|
+
* that has an identity in our system, the UI must let the user reach it. Two
|
|
9
|
+
* different presentations need the same answer:
|
|
10
|
+
*
|
|
11
|
+
* `EntityRef` — a NAME with doors (the default; prefer it always)
|
|
12
|
+
* `MatrxUuidCell` — an ID with doors (only when the name genuinely isn't
|
|
13
|
+
* loaded — a raw FK column in a dense admin table)
|
|
14
|
+
*
|
|
15
|
+
* Both call `resolveEntityDoors`, so a registry edit lights up both at once and
|
|
16
|
+
* neither can drift from the other. This module is deliberately component-free
|
|
17
|
+
* and cheap to import: it pulls the entity registry (icons + `hrefFor`) and the
|
|
18
|
+
* peek KIND LIST — never `features/organizations/peek/registry.ts`, which
|
|
19
|
+
* statically imports all 19 peek components (THE FRAGMENTATION LAW).
|
|
20
|
+
*
|
|
21
|
+
* Adding a door for a new entity type is a registry edit, never a change here:
|
|
22
|
+
* route → `hrefFor` in `features/scopes/registry/entityRegistry.ts`
|
|
23
|
+
* peek → `features/organizations/peek/registry.ts` + `kinds-list.ts` for a
|
|
24
|
+
* BESPOKE preview. Every registered entity with a readable title
|
|
25
|
+
* column already gets the generic `RegistryPeek` for free, so a new
|
|
26
|
+
* entity is previewable the moment it is registered — write a bespoke
|
|
27
|
+
* one only when the kind deserves more than title/description/dates.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* True when a value is a real uuid — the guard a surface needs BEFORE handing an
|
|
32
|
+
* id to `EntityRef` / `EntityDoorControls`.
|
|
33
|
+
*
|
|
34
|
+
* Door resolution deliberately does not validate ids (a token's `hrefFor` is
|
|
35
|
+
* free to use slugs), so any surface that DERIVES an id — parsing it out of a
|
|
36
|
+
* surface key, reading an untyped column — must check first, or it mints a link
|
|
37
|
+
* to `/agents/<junk>`: a door that opens on nothing, which the doctrine ranks
|
|
38
|
+
* worse than no door at all.
|
|
39
|
+
*
|
|
40
|
+
* It lives here, beside `resolveEntityDoors`, because this module is the one
|
|
41
|
+
* component-free entry point on the door path. It used to live only inside
|
|
42
|
+
* `MatrxUuidCell`, which meant guarding an id dragged a table cell (and its
|
|
43
|
+
* tooltip/toast/peek-host graph) into whatever chunk needed the check —
|
|
44
|
+
* THE FRAGMENTATION LAW, paid for a three-line regex. Every importer was moved
|
|
45
|
+
* to this module in the same change — there is deliberately no re-export left
|
|
46
|
+
* behind in `MatrxUuidCell`, because that tripped `no-barrel-files` and the
|
|
47
|
+
* rule is right.
|
|
48
|
+
*/
|
|
49
|
+
declare function isUuidValue(value: unknown): value is string;
|
|
50
|
+
interface EntityDoors {
|
|
51
|
+
/** Canonical route to the record, or null when the token has no `hrefFor`. */
|
|
52
|
+
href: string | null;
|
|
53
|
+
/** True when a peek is registered for this token. */
|
|
54
|
+
canPeek: boolean;
|
|
55
|
+
/** Catalog key to hand `<ResourcePeekHost kind=…>`. */
|
|
56
|
+
peekKind: string;
|
|
57
|
+
/** Registry icon for the entity type, when one is registered. */
|
|
58
|
+
Icon: ComponentType<{
|
|
59
|
+
className?: string;
|
|
60
|
+
}> | null;
|
|
61
|
+
/** Singular display label ("Agent", "Note"), or null for unknown tokens. */
|
|
62
|
+
label: string | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve every door we can open for one record.
|
|
66
|
+
*
|
|
67
|
+
* `hrefOverride` wins over the registry route — for records that live in two
|
|
68
|
+
* shells (a system agent under `/administration/…` vs a personal one under
|
|
69
|
+
* `/agents/…`). It is honored EXACTLY: an explicit `null` means "this
|
|
70
|
+
* particular record has no door" and must not fall through to the registry,
|
|
71
|
+
* which would send the user somewhere the caller deliberately ruled out. Only
|
|
72
|
+
* `undefined` (no opinion) defers.
|
|
73
|
+
*
|
|
74
|
+
* Unknown tokens degrade to "no doors", never throw: a surface passing a token
|
|
75
|
+
* we don't register yet must still render its text.
|
|
76
|
+
*/
|
|
77
|
+
declare function resolveEntityDoors(token: string, id: string, hrefOverride?: string | null): EntityDoors;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve an FK COLUMN NAME to a canonical entity token — `agent_id` → `agent`,
|
|
80
|
+
* `task_id` → `task`. Deliberately strict: exact `<token>_id` only, and only
|
|
81
|
+
* for tokens that actually have a door. Anything else returns null rather than
|
|
82
|
+
* guessing, because a wrong link is worse than no link (a `<token>_id` that
|
|
83
|
+
* points somewhere else would send the user to another record entirely).
|
|
84
|
+
*
|
|
85
|
+
* Used by generic surfaces that render a row's raw columns (the data-table row
|
|
86
|
+
* inspector) and therefore can't be told each column's target by hand.
|
|
87
|
+
*/
|
|
88
|
+
declare function doorTokenFromColumnName(column: string): string | null;
|
|
89
|
+
/**
|
|
90
|
+
* True when the platform can open this token at all (route or peek).
|
|
91
|
+
* Use it to decide whether a bare id is worth rendering as a door — never to
|
|
92
|
+
* decide whether to render the record at all.
|
|
93
|
+
*/
|
|
94
|
+
declare function hasAnyDoor(token: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The entity token a sentence was talking about right before it printed an id.
|
|
97
|
+
*
|
|
98
|
+
* Deliberately conservative — it reads at most the four words in front of the
|
|
99
|
+
* id, nearest first, and accepts only a word that resolves to a token the
|
|
100
|
+
* platform can actually OPEN (`hasAnyDoor`). Anything else returns null and
|
|
101
|
+
* the caller prints the id as it always did. Guessing here would mint links to
|
|
102
|
+
* `/agents/<a workflow id>`: a door onto the wrong record, which reads as a
|
|
103
|
+
* fact and is a lie.
|
|
104
|
+
*/
|
|
105
|
+
declare function tokenFromPrecedingWords(preceding: string): string | null;
|
|
106
|
+
/**
|
|
107
|
+
* One piece of a sentence: plain prose, an id we can open a door on, or a run
|
|
108
|
+
* the author marked as CODE with markdown backticks.
|
|
109
|
+
*/
|
|
110
|
+
type SentenceSegment = {
|
|
111
|
+
kind: "text";
|
|
112
|
+
text: string;
|
|
113
|
+
} | {
|
|
114
|
+
kind: "code";
|
|
115
|
+
text: string;
|
|
116
|
+
} | {
|
|
117
|
+
kind: "ref";
|
|
118
|
+
id: string;
|
|
119
|
+
token: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* INLINE CODE, THE WAY ITS AUTHOR WROTE IT.
|
|
123
|
+
*
|
|
124
|
+
* 🚨 THE DEFECT (V-PARITY/UX R-O2, both walk rounds). Sentences that name a
|
|
125
|
+
* field, a key or a variable mark it the one way every author on this platform
|
|
126
|
+
* marks it — markdown backticks:
|
|
127
|
+
*
|
|
128
|
+
* Its structured output is missing `title`, `slides` — whatever reads this
|
|
129
|
+
* job's result requires them.
|
|
130
|
+
*
|
|
131
|
+
* Printed through a plain `<span>` the backtick CHARACTERS land on a subject
|
|
132
|
+
* matter expert's screen. There is no second renderer for this: every sentence
|
|
133
|
+
* somebody else wrote already reaches a person through `TextWithDoors`, so the
|
|
134
|
+
* marks are understood HERE, beside the ids, and every one of its ~10 adopting
|
|
135
|
+
* surfaces is fixed by the same three lines.
|
|
136
|
+
*
|
|
137
|
+
* Deliberately ONLY single-backtick spans, and never across a newline: this is
|
|
138
|
+
* a sentence renderer, not a markdown engine. Anything else — an unmatched
|
|
139
|
+
* backtick, a fenced block — stays exactly as it was typed.
|
|
140
|
+
*/
|
|
141
|
+
/**
|
|
142
|
+
* Split a server-authored sentence into prose, inline code and openable ids.
|
|
143
|
+
*
|
|
144
|
+
* `defaultToken` is what the CALL SITE knows that the sentence does not — a
|
|
145
|
+
* mandate-resolution refusal is always about an agent, so its screen may say
|
|
146
|
+
* so. It is used only when the prose itself names nothing openable.
|
|
147
|
+
*
|
|
148
|
+
* Every character of the input survives into the output in order — apart from
|
|
149
|
+
* the two backticks delimiting an inline-code run, which are MARKUP the author
|
|
150
|
+
* wrote to say "this is code" and were never words meant to be read. A caller
|
|
151
|
+
* that joins the segments back together gets the server's words unchanged.
|
|
152
|
+
*/
|
|
153
|
+
declare function segmentSentenceIds(text: string, defaultToken?: string | null): SentenceSegment[];
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* src/entity-ref/slot.ts — @ai-matrx/records-ui/entity-doors (no "use client": pure, server-safe)
|
|
157
|
+
*
|
|
158
|
+
* THE ENTITY-REF HOST: what a reference to another record needs from the app that draws it.
|
|
159
|
+
*
|
|
160
|
+
* A reference (`EntityRef`, `EntityDoorControls`, `TextWithDoors`, `toastDoor`, `NewTabLink`) is
|
|
161
|
+
* drawn EVERYWHERE — table cells, chat bubbles, toasts, sentences — far outside any
|
|
162
|
+
* `<RecordsUiProvider>`. So, unlike the screens' host, this one is bound ONCE per page through
|
|
163
|
+
* `configureEntityRefs(...)` (a module-level slot on `globalThis`, so every module-graph copy of the
|
|
164
|
+
* package reads the same binding) before anything renders.
|
|
165
|
+
*
|
|
166
|
+
* The ports, each with a default that ANNOUNCES ITSELF instead of pretending:
|
|
167
|
+
*
|
|
168
|
+
* registry token → label, icon, route, title column (the app's scopes/entity registry).
|
|
169
|
+
* Default: knows no token — every reference draws its name with no door.
|
|
170
|
+
* adminHref the admin-shell twin of a record's route. Default: none.
|
|
171
|
+
* hasPeek whether a quick-look exists for a kind. Default: none.
|
|
172
|
+
* openPeek opens the app's ONE quick-look host. Default: opens `fallbackHref` in a new tab.
|
|
173
|
+
* useAddress a HOOK resolving tokens whose address depends on more than the id (an agent's kind,
|
|
174
|
+
* a team's organization). Default: none — the registry route is used.
|
|
175
|
+
* Link the app's router link. Default: design-system's registered tap-target link, else <a>.
|
|
176
|
+
* ErrorMenu the actions drawn beside a KNOWN refusal. Default: none.
|
|
177
|
+
*
|
|
178
|
+
* Unconfigured, every reference carries `data-entity-ref-host="unconfigured"` and the first draw
|
|
179
|
+
* warns once in the console, naming `configureEntityRefs`.
|
|
180
|
+
*
|
|
181
|
+
* The host MUST be configured before the first render: `useAddress` is a hook, and the number of
|
|
182
|
+
* hooks a component calls cannot change between renders.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/** One registered entity type, as a reference draws it. */
|
|
186
|
+
interface EntityRefDescriptor {
|
|
187
|
+
/** Singular display label ("Agent", "Note"). */
|
|
188
|
+
label: string;
|
|
189
|
+
/** The type's icon. */
|
|
190
|
+
Icon: ComponentType<{
|
|
191
|
+
className?: string;
|
|
192
|
+
}> | null;
|
|
193
|
+
/** Canonical route to one record, or null when the type has no page. */
|
|
194
|
+
hrefFor: ((id: string) => string) | null;
|
|
195
|
+
/** The column a generic quick-look reads the title from; null = no generic quick-look. */
|
|
196
|
+
titleColumn: string | null;
|
|
197
|
+
/**
|
|
198
|
+
* True when the type's table is NOT browser-readable (a candidates lister stands in), so a
|
|
199
|
+
* generic quick-look would always fail and is not offered.
|
|
200
|
+
*/
|
|
201
|
+
listCandidatesOnly: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** The entity registry as a reference needs it. */
|
|
204
|
+
interface EntityRefRegistry {
|
|
205
|
+
/** Raw token (a kind column owned by another system) → canonical token. */
|
|
206
|
+
canonical(token: string): string;
|
|
207
|
+
/** Canonical token → descriptor, or null for a token nobody registered. */
|
|
208
|
+
describe(token: string): EntityRefDescriptor | null;
|
|
209
|
+
}
|
|
210
|
+
/** A quick-look request. */
|
|
211
|
+
interface EntityRefPeekAsk {
|
|
212
|
+
/** Peek catalog key. */
|
|
213
|
+
kind: string;
|
|
214
|
+
id: string;
|
|
215
|
+
/** The destination the CALLER resolved, when a token alone cannot name it. */
|
|
216
|
+
href?: string | null | undefined;
|
|
217
|
+
anchor?: Element | null | undefined;
|
|
218
|
+
trigger?: "hover" | "click" | undefined;
|
|
219
|
+
/** Where the record opens when the host has no quick-look surface mounted. */
|
|
220
|
+
fallbackHref?: string | null | undefined;
|
|
221
|
+
}
|
|
222
|
+
/** An address resolved by the host's `useAddress` hook. */
|
|
223
|
+
type EntityAddress = {
|
|
224
|
+
state: "ready";
|
|
225
|
+
href: string;
|
|
226
|
+
}
|
|
227
|
+
/** A REAL href that works while resolving (a server-side redirect route). */
|
|
228
|
+
| {
|
|
229
|
+
state: "resolving";
|
|
230
|
+
href: string;
|
|
231
|
+
}
|
|
232
|
+
/** The record genuinely cannot be reached; `reason` is the sentence the UI says. */
|
|
233
|
+
| {
|
|
234
|
+
state: "refused";
|
|
235
|
+
reason: string;
|
|
236
|
+
};
|
|
237
|
+
interface EntityRefLinkProps {
|
|
238
|
+
href: string;
|
|
239
|
+
target?: string | undefined;
|
|
240
|
+
rel?: string | undefined;
|
|
241
|
+
prefetch?: boolean | undefined;
|
|
242
|
+
title?: string | undefined;
|
|
243
|
+
className?: string | undefined;
|
|
244
|
+
onClick?: ((event: MouseEvent<HTMLAnchorElement>) => void) | undefined;
|
|
245
|
+
"aria-label"?: string | undefined;
|
|
246
|
+
"data-tap-target"?: boolean | undefined;
|
|
247
|
+
children?: ReactNode;
|
|
248
|
+
ref?: Ref<HTMLAnchorElement> | undefined;
|
|
249
|
+
}
|
|
250
|
+
/** A person as an identity resolver answers them (UserIdentity-compatible). */
|
|
251
|
+
interface EntityRefPerson {
|
|
252
|
+
id?: string | null;
|
|
253
|
+
email?: string | null;
|
|
254
|
+
displayName?: string | null;
|
|
255
|
+
avatarUrl?: string | null;
|
|
256
|
+
}
|
|
257
|
+
interface EntityRefHost {
|
|
258
|
+
registry: EntityRefRegistry;
|
|
259
|
+
adminHref?: ((token: string, id: string) => string | null) | undefined;
|
|
260
|
+
hasPeek?: ((kind: string) => boolean) | undefined;
|
|
261
|
+
openPeek?: ((ask: EntityRefPeekAsk) => void) | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* A HOOK, called on every render of every reference: `id` is null for the tokens the host does
|
|
264
|
+
* not resolve itself, and the hook returns null for them. Must call the same hooks every time.
|
|
265
|
+
*/
|
|
266
|
+
useAddress?: ((token: string, id: string | null, context: string) => EntityAddress | null) | undefined;
|
|
267
|
+
Link?: ComponentType<EntityRefLinkProps> | undefined;
|
|
268
|
+
ErrorMenu?: ComponentType<{
|
|
269
|
+
error: string;
|
|
270
|
+
}> | undefined;
|
|
271
|
+
/** Draws one person (avatar + name), compact. Default: the name as text. */
|
|
272
|
+
Person?: ComponentType<{
|
|
273
|
+
user: EntityRefPerson;
|
|
274
|
+
className?: string;
|
|
275
|
+
}> | undefined;
|
|
276
|
+
}
|
|
277
|
+
/** Bind the app's entity-ref host. Call once, at module load, before anything renders. */
|
|
278
|
+
declare function configureEntityRefs(host: EntityRefHost | null): void;
|
|
279
|
+
/** True once a host has been bound. */
|
|
280
|
+
declare function entityRefsConfigured(): boolean;
|
|
281
|
+
/** A modified click (new tab/window, middle button) keeps the browser's native behavior. */
|
|
282
|
+
declare function isNativeNewTabClick(e: {
|
|
283
|
+
metaKey?: boolean;
|
|
284
|
+
ctrlKey?: boolean;
|
|
285
|
+
shiftKey?: boolean;
|
|
286
|
+
altKey?: boolean;
|
|
287
|
+
button?: number;
|
|
288
|
+
}): boolean;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* EntityRef — THE way to render a reference to another record.
|
|
292
|
+
*
|
|
293
|
+
* THE DOOR LAW (common-docs/policies/no-dead-ends.md): if the UI names a thing
|
|
294
|
+
* that has an identity in our system, the UI must let the user reach it. This
|
|
295
|
+
* component is that law made importable — drop it anywhere a name, a title, or
|
|
296
|
+
* (worse) a bare id is being printed, and the user gets every door we can open:
|
|
297
|
+
*
|
|
298
|
+
* Open → click the name; canonical route from the entity registry
|
|
299
|
+
* New tab → explicit control, so a user deep inside a console/modal never
|
|
300
|
+
* has to trade their current state for an answer
|
|
301
|
+
* Peek → non-blocking preview via the peek registry, when one exists
|
|
302
|
+
* (Window) → surfaces pass their own opener through `extraActions`
|
|
303
|
+
*
|
|
304
|
+
* It composes primitives, it does not duplicate them:
|
|
305
|
+
* - route + icon + label → `getEntityInfo(token)` (features/scopes/registry)
|
|
306
|
+
* - preview → `openResourcePeek` + `hasPeek` (features/organizations/peek) —
|
|
307
|
+
* the app's ONE peek host draws it; a reference never mounts one
|
|
308
|
+
*
|
|
309
|
+
* Safe inside clickable table rows: every control stops propagation, and the
|
|
310
|
+
* peek renders in the app's one host, outside this reference's React tree.
|
|
311
|
+
*
|
|
312
|
+
* Adding a door for a new entity type is a registry edit, never a change here:
|
|
313
|
+
* give the token an `hrefFor` in `entityRegistry.ts`, and/or a peek in
|
|
314
|
+
* `features/organizations/peek/registry.ts` + `kinds-list.ts`.
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
interface EntityRefProps {
|
|
318
|
+
/** Canonical entity token (`agent`, `note`, `task`, …). */
|
|
319
|
+
token: string;
|
|
320
|
+
/** The record's id. */
|
|
321
|
+
id: string;
|
|
322
|
+
/**
|
|
323
|
+
* Display name. When omitted the id is shown truncated — acceptable only
|
|
324
|
+
* when the name genuinely isn't loaded; prefer passing it.
|
|
325
|
+
*/
|
|
326
|
+
name?: string | null;
|
|
327
|
+
/** Override the registry route (e.g. an admin-side route for the same record). */
|
|
328
|
+
href?: string;
|
|
329
|
+
/** Show the entity's registry icon before the name. Default true. */
|
|
330
|
+
showIcon?: boolean;
|
|
331
|
+
/** Hide the peek control even when one is registered. */
|
|
332
|
+
disablePeek?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Hide the new-tab CONTROL (rare — only when the row is already a link).
|
|
335
|
+
*
|
|
336
|
+
* It does NOT make the name inert: the label stays a real `Link` whenever a
|
|
337
|
+
* route resolves, so a plain click still navigates and a modified click
|
|
338
|
+
* still opens a tab. If what you actually want is "name this record but do
|
|
339
|
+
* not offer a door" — the record is already open, so every door leads back
|
|
340
|
+
* to where the user is standing — then don't use `EntityRef` for that row at
|
|
341
|
+
* all. Render the text, and say in a comment why the door is absent.
|
|
342
|
+
*/
|
|
343
|
+
disableNewTab?: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* The name itself opens in a NEW TAB.
|
|
346
|
+
*
|
|
347
|
+
* Set this on any surface embedded in something the user would lose by
|
|
348
|
+
* navigating — a side panel, a workspace rail, a sheet over an editor, a
|
|
349
|
+
* dialog. In-place navigation there is the data-loss THE DOOR LAW's new-tab
|
|
350
|
+
* door exists to prevent, and it is the single easiest regression to
|
|
351
|
+
* introduce when replacing a hand-rolled `window.open` with this component
|
|
352
|
+
* (it has already been caught twice in review).
|
|
353
|
+
*
|
|
354
|
+
* Implemented as a real `target="_blank"` on the anchor — no JS interception,
|
|
355
|
+
* so modified clicks and middle-clicks keep behaving natively. The separate
|
|
356
|
+
* new-tab control is suppressed automatically, since it would be a duplicate.
|
|
357
|
+
*/
|
|
358
|
+
openInNewTab?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Let the label WRAP instead of truncating.
|
|
361
|
+
*
|
|
362
|
+
* `EntityRef` truncates by default because its home is a table cell. That is
|
|
363
|
+
* wrong for a detail panel or an audit row that prints a full id — there the
|
|
364
|
+
* id IS the information, and an ellipsis silently destroys the thing the user
|
|
365
|
+
* came to copy. Set this wherever the old markup wrapped (`break-all`,
|
|
366
|
+
* `whitespace-normal`) so the conversion doesn't quietly shorten the content.
|
|
367
|
+
*
|
|
368
|
+
* A call-site `className` cannot substitute: it lands on the outer wrapper,
|
|
369
|
+
* while `truncate` is on the label element itself.
|
|
370
|
+
*/
|
|
371
|
+
wrap?: boolean;
|
|
372
|
+
/**
|
|
373
|
+
* The NAME control stretches to fill the width, instead of hugging its text.
|
|
374
|
+
*
|
|
375
|
+
* Set this whenever you replace a full-width `<button>`/`<a>` with an
|
|
376
|
+
* `EntityRef`. A `className` of `flex-1` on the component only stretches the
|
|
377
|
+
* outer WRAPPER — the clickable label inside it still ends where the text
|
|
378
|
+
* does, so every pixel of the old control's padding silently stops opening
|
|
379
|
+
* the record. On a short name in a wide row that is most of the hit target.
|
|
380
|
+
*
|
|
381
|
+
* Combines with `truncate` (the default) exactly as the markup it replaces
|
|
382
|
+
* did: fill the space, ellipsise if the name outgrows it. It also pushes the
|
|
383
|
+
* hover controls to the far edge, which is why it is opt-in — inside a table
|
|
384
|
+
* cell you usually want them beside the name.
|
|
385
|
+
*/
|
|
386
|
+
fill?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Classes for the clickable LABEL itself, not the wrapper.
|
|
389
|
+
*
|
|
390
|
+
* `className` lands on the outer wrapper, which is right for layout and
|
|
391
|
+
* wrong for anything that must apply to the text: `line-through` on a
|
|
392
|
+
* completed task, a font weight, a decoration. Whether such a style reaches
|
|
393
|
+
* the label by inheritance depends on the box type and fights the label's
|
|
394
|
+
* own `hover:underline` — so it is passed explicitly rather than hoped for.
|
|
395
|
+
* This is the third call-site need of this shape; `wrap` and `fill` stay as
|
|
396
|
+
* named props because they encode a DECISION, while this is plain styling.
|
|
397
|
+
*/
|
|
398
|
+
labelClassName?: string;
|
|
399
|
+
/** Backward-compatible name-label class used by existing Door Law callers. */
|
|
400
|
+
nameClassName?: string;
|
|
401
|
+
/** Controls stay visible instead of appearing on hover/focus. */
|
|
402
|
+
alwaysShowActions?: boolean;
|
|
403
|
+
/** Surface-specific extra doors (open in window, jump to versions, …). */
|
|
404
|
+
extraActions?: react__default.ReactNode;
|
|
405
|
+
/**
|
|
406
|
+
* Intercept the plain left-click on the name — for surfaces that open the
|
|
407
|
+
* record their OWN way (in a window, in a side panel, via a container's
|
|
408
|
+
* `openEntity` handler) instead of navigating the tab.
|
|
409
|
+
*
|
|
410
|
+
* Cmd/Ctrl/Shift/Alt/middle clicks are NOT intercepted: they keep the
|
|
411
|
+
* browser's native new-tab behavior via the real `href`, so a surface that
|
|
412
|
+
* takes over the click can never cost the user their current state. The
|
|
413
|
+
* explicit new-tab control stays visible regardless.
|
|
414
|
+
*
|
|
415
|
+
* CONTRACT — pass `undefined` when the handler cannot actually open
|
|
416
|
+
* anything. With no registry route AND an `onOpen`, the name renders as a
|
|
417
|
+
* link-styled BUTTON; if that handler then no-ops (because it too was
|
|
418
|
+
* gated on a route that doesn't exist), the user gets a control that looks
|
|
419
|
+
* openable and does nothing — a dead end with extra steps, which is the
|
|
420
|
+
* precise thing this component exists to kill. Gate at the call site:
|
|
421
|
+
* `onOpen={canOpen ? handler : undefined}`.
|
|
422
|
+
*/
|
|
423
|
+
onOpen?: () => void;
|
|
424
|
+
className?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Render arbitrary content as the label instead of the name text.
|
|
427
|
+
*
|
|
428
|
+
* The doors are the point of this component; the label is incidental. A
|
|
429
|
+
* table cell renders `<span>{title}</span><Badge>Draft</Badge>`, a card
|
|
430
|
+
* renders a title over a subtitle — neither is a string, and before this
|
|
431
|
+
* existed those surfaces could not adopt `EntityRef` at all without
|
|
432
|
+
* flattening what they show. That is how a shell ends up with its OWN
|
|
433
|
+
* Open-only door beside this one (`MatrxDataTable.href`) and every column
|
|
434
|
+
* that names a record loses new-tab and peek.
|
|
435
|
+
*
|
|
436
|
+
* `name` is still required-ish when you pass children: it supplies the
|
|
437
|
+
* `title`/`aria-label` text, so a screen reader and a tooltip still say
|
|
438
|
+
* which record this is.
|
|
439
|
+
*/
|
|
440
|
+
children?: react__default.ReactNode;
|
|
441
|
+
}
|
|
442
|
+
declare function EntityRef({ token, id, name, href, showIcon, disablePeek, disableNewTab, openInNewTab, wrap, fill, labelClassName, nameClassName, alwaysShowActions, extraActions, onOpen, className, children, }: EntityRefProps): react__default.JSX.Element;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* EntityDoorControls — the DOORS, without the name.
|
|
446
|
+
*
|
|
447
|
+
* `EntityRef` is the default: it renders a record's name AS the door. But some
|
|
448
|
+
* surfaces genuinely cannot make the name an anchor:
|
|
449
|
+
*
|
|
450
|
+
* - the name is an inline EDITOR (`AssociationEntitySelect` — click to rename)
|
|
451
|
+
* - the name sits inside a `<button>` whose click means something else
|
|
452
|
+
* (a picker row, where clicking = attach). An `<a>` inside a `<button>` is
|
|
453
|
+
* invalid DOM and a hydration error, and a stray click that navigated away
|
|
454
|
+
* would cost the user the picker they are standing in.
|
|
455
|
+
*
|
|
456
|
+
* Those surfaces render this cluster as a SIBLING of the name. It is the same
|
|
457
|
+
* implementation `EntityRef` uses (EntityRef composes it), so a registry edit
|
|
458
|
+
* lights up both and neither can drift.
|
|
459
|
+
*
|
|
460
|
+
* Same-tab "Open" is OPT-IN (`showOpen`) precisely because the callers above are
|
|
461
|
+
* mid-task surfaces: peek + new tab answer "which one is that?" without
|
|
462
|
+
* destroying what the user is doing. Pass `showOpen` when the surface is a plain
|
|
463
|
+
* list the user can safely leave.
|
|
464
|
+
*
|
|
465
|
+
* Standalone controls are visible by default. Hover reveal is opt-in through
|
|
466
|
+
* `revealOnHover`; when enabled, controls fade in on hover of EITHER the named `group/entity-ref`
|
|
467
|
+
* (what `EntityRef` puts on its own wrapper) OR a plain Tailwind `group`, which
|
|
468
|
+
* is what almost every row in this codebase already carries for its other
|
|
469
|
+
* hover-revealed affordances.
|
|
470
|
+
*
|
|
471
|
+
* Accepting both is deliberate and load-bearing. The named group alone made a
|
|
472
|
+
* silent, invisible failure the DEFAULT for standalone callers: forget the
|
|
473
|
+
* class and the doors render at `opacity-0`, so the surface looks finished, the
|
|
474
|
+
* markup is right, type-check and lint are green — and the user simply cannot
|
|
475
|
+
* see the door. That is the exact dead end this module exists to remove, and it
|
|
476
|
+
* shipped twice (the two debug-window sidebars, 2026-08-09) before Bugbot
|
|
477
|
+
* caught it. A primitive whose correct use depends on remembering an invisible
|
|
478
|
+
* convention will be misused; make the common case work instead.
|
|
479
|
+
*
|
|
480
|
+
* `alwaysShowActions` remains as a compatibility override that pins them visible
|
|
481
|
+
* (a window title bar, a touch-first list). **Reach for it in any popover or
|
|
482
|
+
* transient panel too**: `opacity-0` does not disable hit-testing, so on touch
|
|
483
|
+
* the hover form is the worst case — invisible controls that are still
|
|
484
|
+
* tappable. The row reserves their width either way (this cluster is
|
|
485
|
+
* `shrink-0`), so pinning them costs no layout.
|
|
486
|
+
*
|
|
487
|
+
* Link doors carry `data-tap-target` so a host's `matrx-touch-targets` scope
|
|
488
|
+
* can raise these intentionally compact desktop controls to the 44px
|
|
489
|
+
* coarse-pointer floor without treating prose links as controls.
|
|
490
|
+
*
|
|
491
|
+
* The peek opens through `openResourcePeek` and renders in the app's ONE host
|
|
492
|
+
* (`ResourcePeekRoot`, app/Providers.tsx), outside this component's tree — so a
|
|
493
|
+
* popover that closes because the person clicked into the peek no longer
|
|
494
|
+
* unmounts the peek with it (the "door that deletes itself" trap, 2026-08-09).
|
|
495
|
+
* The popover still closes; a container that should stay open must ignore
|
|
496
|
+
* events whose target is inside a dialog:
|
|
497
|
+
*
|
|
498
|
+
* if (target?.closest?.('[role="dialog"], [role="alertdialog"]')) return;
|
|
499
|
+
*
|
|
500
|
+
* Adding a door for a new entity type is a registry edit, never a change here:
|
|
501
|
+
* route → `hrefFor` in `features/scopes/registry/entityRegistry.ts`
|
|
502
|
+
* peek → `features/organizations/peek/registry.ts` + `kinds-list.ts`
|
|
503
|
+
*/
|
|
504
|
+
|
|
505
|
+
declare const ENTITY_DOOR_CONTROL_CLASS: string;
|
|
506
|
+
interface EntityDoorControlsProps {
|
|
507
|
+
/** Canonical entity token (`agent`, `note`, `task`, …). */
|
|
508
|
+
token: string;
|
|
509
|
+
/** The record's id. */
|
|
510
|
+
id: string;
|
|
511
|
+
/** Display name — used only for the control labels/tooltips. */
|
|
512
|
+
name?: string | null;
|
|
513
|
+
/**
|
|
514
|
+
* Override the registry route. Honored exactly: `null` means "this record
|
|
515
|
+
* has no door" and must not fall through to the registry; omit to defer.
|
|
516
|
+
*/
|
|
517
|
+
href?: string | null;
|
|
518
|
+
/** Hide the peek control even when one is registered. */
|
|
519
|
+
disablePeek?: boolean;
|
|
520
|
+
/** Hide the new-tab control. */
|
|
521
|
+
disableNewTab?: boolean;
|
|
522
|
+
/** Also render a same-tab Open control (off by default — see the header). */
|
|
523
|
+
showOpen?: boolean;
|
|
524
|
+
/** Controls stay visible instead of appearing on hover/focus. */
|
|
525
|
+
alwaysShowActions?: boolean;
|
|
526
|
+
/** Opt into hover/focus reveal. Standalone controls are visible by default. */
|
|
527
|
+
revealOnHover?: boolean;
|
|
528
|
+
/** Surface-specific extra doors (open in window, jump to versions, …). */
|
|
529
|
+
extraActions?: react__default.ReactNode;
|
|
530
|
+
/**
|
|
531
|
+
* `md` = THE control (`Button` variant="quiet", 28px, 16px glyph) — use it in
|
|
532
|
+
* any bar of 28px controls (card hover bars, attach-menu rows) so the bar
|
|
533
|
+
* never mixes sizes. `sm` = the compact inline 20px door beside text.
|
|
534
|
+
*/
|
|
535
|
+
size?: "sm" | "md";
|
|
536
|
+
className?: string;
|
|
537
|
+
}
|
|
538
|
+
declare function EntityDoorControls({ token, id, name, href, disablePeek, disableNewTab, showOpen, alwaysShowActions, revealOnHover, extraActions, size, className, }: EntityDoorControlsProps): react__default.JSX.Element | null;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* NewTabLink — THE box-with-arrow (lucide `ExternalLink`) control.
|
|
542
|
+
*
|
|
543
|
+
* Arman, 2026-09-26: the ExternalLink icon means ONE thing platform-wide —
|
|
544
|
+
* "open this in a new tab". It was being drawn on same-tab links and rendered
|
|
545
|
+
* disabled beside names that had nothing to open. So the icon has one home:
|
|
546
|
+
*
|
|
547
|
+
* - it is always a real anchor with `target="_blank"` + `rel="noopener
|
|
548
|
+
* noreferrer"` (modified clicks and middle-clicks stay native);
|
|
549
|
+
* - it is never disabled — with no `href` it renders NOTHING;
|
|
550
|
+
* - it stops propagation, so it is safe inside clickable rows and cards.
|
|
551
|
+
*
|
|
552
|
+
* A same-tab "open" uses `ArrowUpRight` (see `EntityDoorControls`), never this
|
|
553
|
+
* icon. The Lightbulb means Peek. Guard: `pnpm check:new-tab-icon`.
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
declare const NEW_TAB_CONTROL_CLASS: string;
|
|
557
|
+
interface NewTabLinkProps {
|
|
558
|
+
/** Where the new tab goes. Absent/empty → the control is absent. */
|
|
559
|
+
href: string | null | undefined;
|
|
560
|
+
/** What opens, for the tooltip and screen readers ("Deep Research"). */
|
|
561
|
+
label: string;
|
|
562
|
+
className?: string;
|
|
563
|
+
iconClassName?: string;
|
|
564
|
+
/** Text beside the icon ("New tab"). Icon-only when omitted. */
|
|
565
|
+
children?: react__default.ReactNode;
|
|
566
|
+
/** Runs after the tab opens (e.g. close the palette that held the link). */
|
|
567
|
+
onOpen?: () => void;
|
|
568
|
+
}
|
|
569
|
+
declare function NewTabLink({ href, label, className, iconClassName, children, onOpen, }: NewTabLinkProps): react__default.JSX.Element | null;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* TextWithDoors — THE way to print a sentence somebody else wrote.
|
|
573
|
+
*
|
|
574
|
+
* THE DOOR LAW (common-docs/policies/no-dead-ends.md) does not stop at table
|
|
575
|
+
* cells: if the UI NAMES a thing that has an identity in our system, the UI
|
|
576
|
+
* must let the user reach it. A server refusal that says
|
|
577
|
+
*
|
|
578
|
+
* resolved system agent <agent uuid> breaks the
|
|
579
|
+
* mandate contract: declares no structured output_schema
|
|
580
|
+
*
|
|
581
|
+
* names an agent. Printed as flat text it is a dead end with extra steps — the
|
|
582
|
+
* person is told which record is wrong and then made to hand-copy a uuid into
|
|
583
|
+
* a URL bar to go look at it. That is the defect this component closes, and it
|
|
584
|
+
* closes it for the whole class: every surface that prints a server sentence
|
|
585
|
+
* (`ServerNotes`, refusal banners, dropped-rung reasons, run failures) renders
|
|
586
|
+
* it through here instead of through a bare `{message}`.
|
|
587
|
+
*
|
|
588
|
+
* VERBATIM. The server is the authority on what it just said, so nothing here
|
|
589
|
+
* rewrites, shortens or re-orders a word — `segmentSentenceIds` preserves every
|
|
590
|
+
* character in order. The only change is that the ids become openable, with the
|
|
591
|
+
* full id still on screen (`name={id}`), never truncated to `8f0bbfc2…`.
|
|
592
|
+
*
|
|
593
|
+
* THE AUTHOR'S OWN MARKS ARE HONORED, NOT PRINTED. A sentence that says its
|
|
594
|
+
* field names in markdown backticks meant them as code; this is the one place
|
|
595
|
+
* that renders them as `<code>`, so no surface needs — or is allowed to grow —
|
|
596
|
+
* a second inline-markdown renderer of its own. See `doors.ts`
|
|
597
|
+
* § INLINE CODE, THE WAY ITS AUTHOR WROTE IT.
|
|
598
|
+
*
|
|
599
|
+
* CONSERVATIVE. An id becomes a door only when the sentence's own words name an
|
|
600
|
+
* entity type the platform can actually open, or the call site declares one via
|
|
601
|
+
* `defaultToken`. Anything else stays plain text: a link to the wrong record
|
|
602
|
+
* reads as a fact and is a lie, which the doctrine ranks below no link at all.
|
|
603
|
+
*/
|
|
604
|
+
|
|
605
|
+
interface TextWithDoorsProps {
|
|
606
|
+
/** The sentence, exactly as its author wrote it. */
|
|
607
|
+
text: string | null | undefined;
|
|
608
|
+
/**
|
|
609
|
+
* The entity type this surface KNOWS its sentences are about, used only when
|
|
610
|
+
* the prose names nothing openable — a mandate-resolution refusal is always
|
|
611
|
+
* about an agent, and its screen may say so.
|
|
612
|
+
*/
|
|
613
|
+
defaultToken?: string | null;
|
|
614
|
+
/**
|
|
615
|
+
* Ids open in a NEW TAB (default). These sentences live in banners, panels
|
|
616
|
+
* and sheets over work in progress; navigating the tab away to go read the
|
|
617
|
+
* accused record is the data loss the new-tab door exists to prevent.
|
|
618
|
+
*/
|
|
619
|
+
openInNewTab?: boolean;
|
|
620
|
+
/** Classes for each id's `EntityRef` wrapper. */
|
|
621
|
+
refClassName?: string;
|
|
622
|
+
}
|
|
623
|
+
declare function TextWithDoors({ text, defaultToken, openInNewTab, refClassName, }: TextWithDoorsProps): react__default.JSX.Element | null;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* toastDoor — the door for a record a TOAST just told you about.
|
|
627
|
+
*
|
|
628
|
+
* THE DEAD END this kills: "Note created", "Duplicated", "Reassigned 5
|
|
629
|
+
* resources". The app just made or changed a specific record, had its id in
|
|
630
|
+
* hand, and the only thing the user can do about it is watch the toast fade.
|
|
631
|
+
* Finding the thing again means going back to a list and hunting for it.
|
|
632
|
+
*
|
|
633
|
+
* Sonner's `action` accepts a ReactNode as well as `{label, onClick}`, so the
|
|
634
|
+
* door is a real `<Link>`, NOT a button with an onClick. That matters: an
|
|
635
|
+
* anchor gives same-tab Open, cmd-click and middle-click new-tab, and a
|
|
636
|
+
* copyable target — three of the four doors — where an onClick gives exactly
|
|
637
|
+
* one and steals the rest. Never "fix" this into a button.
|
|
638
|
+
*
|
|
639
|
+
* toast.success("Note created", { action: toastDoor("note", id) })
|
|
640
|
+
*
|
|
641
|
+
* Returns `undefined` when the token has no route, so the spread above is safe
|
|
642
|
+
* everywhere: a toast about an unreachable record simply has no action, rather
|
|
643
|
+
* than a control that goes nowhere.
|
|
644
|
+
*
|
|
645
|
+
* Peek is deliberately NOT offered. A toast is transient and usually
|
|
646
|
+
* off-center; a preview that outlives its trigger is a worse affordance than a
|
|
647
|
+
* link. Adding a door for a new entity type is a registry edit
|
|
648
|
+
* (`hrefFor` in `features/scopes/registry/entityRegistry.ts`), never a change
|
|
649
|
+
* here.
|
|
650
|
+
*/
|
|
651
|
+
|
|
652
|
+
interface ToastDoorOptions {
|
|
653
|
+
/** Button text. Defaults to "Open". */
|
|
654
|
+
label?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Override the registry route. Honored exactly: `null` means "no door" and
|
|
657
|
+
* must not fall through to the registry.
|
|
658
|
+
*/
|
|
659
|
+
href?: string | null;
|
|
660
|
+
}
|
|
661
|
+
declare function toastDoor(token: string, id: string | null | undefined, options?: ToastDoorOptions): react__default.ReactNode | undefined;
|
|
662
|
+
|
|
663
|
+
interface EntityHrefResult {
|
|
664
|
+
/** The href, or null while resolving / when the record cannot be placed. */
|
|
665
|
+
href: string | null;
|
|
666
|
+
/**
|
|
667
|
+
* Set only when the record genuinely cannot be reached. The UI must SAY
|
|
668
|
+
* this, not render a link that 404s and not render a dead-looking control
|
|
669
|
+
* with no explanation.
|
|
670
|
+
*/
|
|
671
|
+
refusal: string | null;
|
|
672
|
+
/** True while an address is still being resolved — not a refusal. */
|
|
673
|
+
resolving: boolean;
|
|
674
|
+
}
|
|
675
|
+
declare function useEntityHref(token: string, id: string, hrefOverride?: string): EntityHrefResult;
|
|
676
|
+
|
|
677
|
+
/** One actor as `resolveActor` answers it (the host's identity resolver, e.g. the app's `useRecordActors`). */
|
|
678
|
+
interface RecordStampActor {
|
|
679
|
+
id: string;
|
|
680
|
+
/** Non-null once we know who this is. */
|
|
681
|
+
user: EntityRefPerson | null;
|
|
682
|
+
/** True while the directory read is still in flight. */
|
|
683
|
+
loading: boolean;
|
|
684
|
+
}
|
|
685
|
+
interface RecordStampsProps {
|
|
686
|
+
organizationId?: string | null;
|
|
687
|
+
createdAt?: string | null;
|
|
688
|
+
/**
|
|
689
|
+
* The row's creator. OMIT for a COMPONENT row (one that takes its access
|
|
690
|
+
* from a parent): there the database rewrites `created_by` to the PARENT's
|
|
691
|
+
* owner (db-rules §6d-1), so it is not who created this row — pass
|
|
692
|
+
* `component` instead and the Created stamp shows the time only.
|
|
693
|
+
*/
|
|
694
|
+
createdBy?: string | null;
|
|
695
|
+
/** A component row: the Created stamp carries no actor (see `createdBy`). */
|
|
696
|
+
component?: boolean;
|
|
697
|
+
updatedAt?: string | null;
|
|
698
|
+
updatedBy?: string | null;
|
|
699
|
+
deletedAt?: string | null;
|
|
700
|
+
version?: number | null;
|
|
701
|
+
/** Formatter for a timestamp — pass the surface's own (e.g. `formatDate`). */
|
|
702
|
+
formatTimestamp: (value: string | null) => string;
|
|
703
|
+
/** Resolver from `useRecordActors` — call the hook in the parent. */
|
|
704
|
+
resolveActor: ((id: string | null | undefined) => RecordStampActor | null) | null;
|
|
705
|
+
className?: string;
|
|
706
|
+
}
|
|
707
|
+
declare function RecordStamps({ createdAt, createdBy, component, updatedAt, updatedBy, deletedAt, version, formatTimestamp, resolveActor, className, }: RecordStampsProps): react.JSX.Element;
|
|
708
|
+
|
|
709
|
+
export { ENTITY_DOOR_CONTROL_CLASS, type EntityAddress, EntityDoorControls, type EntityDoorControlsProps, type EntityDoors, type EntityHrefResult, EntityRef, type EntityRefDescriptor, type EntityRefHost, type EntityRefLinkProps, type EntityRefPeekAsk, type EntityRefPerson, type EntityRefRegistry, NEW_TAB_CONTROL_CLASS, NewTabLink, type NewTabLinkProps, type RecordStampActor, RecordStamps, type RecordStampsProps, type SentenceSegment, TextWithDoors, type TextWithDoorsProps, type ToastDoorOptions, configureEntityRefs, doorTokenFromColumnName, entityRefsConfigured, hasAnyDoor, isNativeNewTabClick, isUuidValue, resolveEntityDoors, segmentSentenceIds, toastDoor, tokenFromPrecedingWords, useEntityHref };
|