@estiva-app/ui 0.90.2 → 0.91.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.
- package/dist/AttachedCard.d.ts +30 -0
- package/dist/AttachedCard.d.ts.map +1 -0
- package/dist/AttachmentCard.d.ts +14 -0
- package/dist/AttachmentCard.d.ts.map +1 -1
- package/dist/AvatarGroup.d.ts +7 -1
- package/dist/AvatarGroup.d.ts.map +1 -1
- package/dist/Card.d.ts +4 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +1 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/InlineText.d.ts +5 -2
- package/dist/InlineText.d.ts.map +1 -1
- package/dist/Link.d.ts +3 -2
- package/dist/Link.d.ts.map +1 -1
- package/dist/LinkCard.d.ts +3 -3
- package/dist/LinkCard.d.ts.map +1 -1
- package/dist/LinkChip.d.ts.map +1 -1
- package/dist/LinkParts.d.ts +17 -3
- package/dist/LinkParts.d.ts.map +1 -1
- package/dist/LinkPreview.d.ts.map +1 -1
- package/dist/LinkRow.d.ts +10 -5
- package/dist/LinkRow.d.ts.map +1 -1
- package/dist/PartCard.d.ts +16 -4
- package/dist/PartCard.d.ts.map +1 -1
- package/dist/Popover.d.ts +8 -1
- package/dist/Popover.d.ts.map +1 -1
- package/dist/ReactionRow.d.ts.map +1 -1
- package/dist/RichText.d.ts.map +1 -1
- package/dist/ShowMore.d.ts +8 -3
- package/dist/ShowMore.d.ts.map +1 -1
- package/dist/SuggestionMenu.d.ts +6 -2
- package/dist/SuggestionMenu.d.ts.map +1 -1
- package/dist/editor.js +19 -12
- package/dist/editor.js.map +3 -3
- package/dist/eslint/has-a-page-and-a-story.d.ts.map +1 -1
- package/dist/eslint/index.js +1093 -1076
- package/dist/eslint/index.js.map +4 -4
- package/dist/eslint/no-restyled-part.d.ts +9 -4
- package/dist/eslint/no-restyled-part.d.ts.map +1 -1
- package/dist/gates/{chunk-BS5JASHV.js → chunk-P2P6AHRY.js} +2 -2
- package/dist/gates/{chunk-BS5JASHV.js.map → chunk-P2P6AHRY.js.map} +2 -2
- package/dist/gates/cli.js +1 -1
- package/dist/gates/gate-config.d.ts +4 -1
- package/dist/gates/gate-config.d.ts.map +1 -1
- package/dist/gates/hook.d.ts.map +1 -1
- package/dist/gates/index.js +2 -2
- package/dist/gates/index.js.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +318 -200
- package/dist/index.js.map +4 -4
- package/dist/linked.d.ts +7 -9
- package/dist/linked.d.ts.map +1 -1
- package/dist/linked.examples.d.ts.map +1 -1
- package/dist/linkedFrom.d.ts +5 -0
- package/dist/linkedFrom.d.ts.map +1 -1
- package/dist/links.d.ts +2 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/looks.d.ts +24 -0
- package/dist/looks.d.ts.map +1 -1
- package/dist/registry/{app-X2GI4WTU.js → app-IGBRDD4L.js} +3 -3
- package/dist/registry/{build-P6X3PTZP.js → build-MWN4UI23.js} +2 -2
- package/dist/registry/{chunk-P55P2QFD.js → chunk-4TWYUIOB.js} +1 -1
- package/dist/registry/chunk-4TWYUIOB.js.map +7 -0
- package/dist/registry/{chunk-V67F474L.js → chunk-NSHK76XT.js} +2 -2
- package/dist/registry/{chunk-4QWD3EBY.js → chunk-THI3SLW5.js} +1 -1
- package/dist/registry/{chunk-4QWD3EBY.js.map → chunk-THI3SLW5.js.map} +1 -1
- package/dist/registry/cli.js +3 -3
- package/dist/registry/find.d.ts +1 -1
- package/dist/registry/find.d.ts.map +1 -1
- package/dist/registry/index.js +3 -3
- package/package.json +1 -1
- package/registry.json +532 -462
- package/src/AppProvider.stories.tsx +1 -1
- package/src/AppShell.stories.tsx +1 -1
- package/src/AttachedCard.mdx +55 -0
- package/src/{CardUnder.stories.tsx → AttachedCard.stories.tsx} +10 -19
- package/src/{CardUnder.test.tsx → AttachedCard.test.tsx} +11 -11
- package/src/AttachedCard.tsx +41 -0
- package/src/AttachmentCard.stories.tsx +1 -1
- package/src/AttachmentCard.tsx +36 -14
- package/src/Avatar.stories.tsx +1 -1
- package/src/AvatarGroup.stories.tsx +1 -1
- package/src/AvatarGroup.tsx +8 -2
- package/src/Banner.stories.tsx +1 -1
- package/src/BlockHandle.stories.tsx +1 -1
- package/src/BlockNodes.stories.tsx +1 -1
- package/src/Breadcrumb.stories.tsx +1 -1
- package/src/Button.stories.tsx +1 -1
- package/src/Card.stories.tsx +1 -1
- package/src/Card.test.tsx +1 -1
- package/src/Card.tsx +5 -2
- package/src/Checkbox.stories.tsx +1 -1
- package/src/Chip.stories.tsx +1 -1
- package/src/ChipInput.stories.tsx +1 -1
- package/src/CodeBlockColours.stories.tsx +1 -1
- package/src/CollapsibleSection.stories.tsx +1 -1
- package/src/CommandPalette.stories.tsx +1 -1
- package/src/CommentBox.mdx +3 -3
- package/src/CommentBox.stories.tsx +39 -7
- package/src/CommentBox.test.tsx +1 -1
- package/src/CommentBox.tsx +27 -17
- package/src/CommentHighlights.stories.tsx +1 -1
- package/src/ComposerTriggers.stories.tsx +1 -1
- package/src/ConfirmDialog.stories.tsx +1 -1
- package/src/ContainerHeader.stories.tsx +1 -1
- package/src/DialogShell.stories.tsx +1 -1
- package/src/Divider.stories.tsx +1 -1
- package/src/DocumentEditor.stories.tsx +1 -1
- package/src/EditableText.stories.tsx +1 -1
- package/src/EditorBlockHandle.stories.tsx +1 -1
- package/src/EditorTableControls.stories.tsx +1 -1
- package/src/EmptyState.stories.tsx +1 -1
- package/src/EntryShell.mdx +1 -1
- package/src/EntryShell.stories.tsx +1 -1
- package/src/ErrorBoundary.stories.tsx +1 -1
- package/src/Field.stories.tsx +1 -1
- package/src/FieldLine.stories.tsx +1 -1
- package/src/FilePicker.stories.tsx +1 -1
- package/src/Form.stories.tsx +1 -1
- package/src/IconButton.stories.tsx +1 -1
- package/src/IdentityMenu.stories.tsx +1 -1
- package/src/InlineChip.stories.tsx +1 -1
- package/src/InlineText.mdx +1 -0
- package/src/InlineText.stories.tsx +6 -3
- package/src/InlineText.tsx +7 -2
- package/src/Kbd.stories.tsx +1 -1
- package/src/KindIcon.stories.tsx +1 -1
- package/src/Lightbox.stories.tsx +1 -1
- package/src/Link.mdx +3 -2
- package/src/Link.stories.tsx +1 -1
- package/src/Link.test.tsx +5 -3
- package/src/Link.tsx +5 -3
- package/src/LinkCard.mdx +7 -5
- package/src/LinkCard.stories.tsx +4 -1
- package/src/LinkCard.test.tsx +8 -2
- package/src/LinkCard.tsx +97 -67
- package/src/LinkChip.mdx +3 -3
- package/src/LinkChip.stories.tsx +1 -1
- package/src/LinkChip.test.tsx +1 -1
- package/src/LinkChip.tsx +17 -4
- package/src/LinkChips.stories.tsx +1 -1
- package/src/LinkParts.stories.tsx +1 -1
- package/src/LinkParts.tsx +40 -8
- package/src/LinkPlaces.stories.tsx +1 -1
- package/src/LinkPreview.mdx +1 -1
- package/src/LinkPreview.stories.tsx +1 -1
- package/src/LinkPreview.tsx +3 -1
- package/src/LinkRow.mdx +8 -6
- package/src/LinkRow.stories.tsx +3 -3
- package/src/LinkRow.test.tsx +3 -3
- package/src/LinkRow.tsx +71 -41
- package/src/ListColumn.stories.tsx +1 -1
- package/src/MembersDialog.stories.tsx +1 -1
- package/src/MembersPill.stories.tsx +1 -1
- package/src/Menu.stories.tsx +1 -1
- package/src/MenuItem.stories.tsx +1 -1
- package/src/NavItem.stories.tsx +1 -1
- package/src/NavTree.stories.tsx +1 -1
- package/src/Panel.stories.tsx +1 -1
- package/src/PartCard.mdx +5 -4
- package/src/PartCard.stories.tsx +34 -7
- package/src/PartCard.test.tsx +5 -3
- package/src/PartCard.tsx +48 -24
- package/src/PastedImages.stories.tsx +1 -1
- package/src/PastedMarkdown.stories.tsx +1 -1
- package/src/Person.stories.tsx +1 -1
- package/src/PersonTrigger.stories.tsx +1 -1
- package/src/Popover.stories.tsx +1 -1
- package/src/Popover.tsx +6 -2
- package/src/PreviewCard.stories.tsx +1 -1
- package/src/ProgressBar.stories.tsx +1 -1
- package/src/Property.stories.tsx +1 -1
- package/src/Rail.stories.tsx +1 -1
- package/src/RailItem.stories.tsx +1 -1
- package/src/Reaction.stories.tsx +1 -1
- package/src/ReactionPicker.stories.tsx +1 -1
- package/src/ReactionRow.stories.tsx +1 -1
- package/src/ReactionRow.tsx +3 -1
- package/src/ReferenceCards.mdx +3 -0
- package/src/ReferenceCards.stories.tsx +3 -1
- package/src/ReferenceMenu.mdx +1 -1
- package/src/ReferenceMenu.stories.tsx +1 -1
- package/src/RichText.stories.tsx +1 -1
- package/src/RichText.tsx +6 -2
- package/src/ScrollArea.stories.tsx +1 -1
- package/src/SearchInput.stories.tsx +1 -1
- package/src/SectionHeader.stories.tsx +1 -1
- package/src/SectionLabel.stories.tsx +1 -1
- package/src/Select.stories.tsx +1 -1
- package/src/SelectionToolbar.stories.tsx +1 -1
- package/src/ShowMore.mdx +4 -4
- package/src/ShowMore.stories.tsx +1 -1
- package/src/ShowMore.tsx +11 -6
- package/src/Sidebar.stories.tsx +1 -1
- package/src/Skeleton.stories.tsx +1 -1
- package/src/SuggestionMenu.mdx +4 -1
- package/src/SuggestionMenu.stories.tsx +14 -8
- package/src/SuggestionMenu.tsx +20 -3
- package/src/Tabs.stories.tsx +1 -1
- package/src/TextInput.stories.tsx +1 -1
- package/src/Textarea.stories.tsx +1 -1
- package/src/Toast.stories.tsx +1 -1
- package/src/Toolbar.stories.tsx +1 -1
- package/src/Tooltip.stories.tsx +1 -1
- package/src/TopBar.stories.tsx +1 -1
- package/src/UnreadDot.stories.tsx +1 -1
- package/src/eslint/has-a-page-and-a-story.test.ts +5 -0
- package/src/eslint/has-a-page-and-a-story.ts +11 -2
- package/src/eslint/no-restyled-part.test.ts +32 -8
- package/src/eslint/no-restyled-part.ts +50 -23
- package/src/gates/gate-config.ts +5 -2
- package/src/gates/gates.test.ts +20 -2
- package/src/gates/hook.ts +4 -3
- package/src/index.ts +2 -1
- package/src/linked.examples.ts +3 -4
- package/src/linked.ts +11 -1
- package/src/linkedFrom.test.tsx +55 -3
- package/src/linkedFrom.ts +47 -2
- package/src/links.ts +3 -2
- package/src/looks.ts +29 -0
- package/src/registry/build.ts +1 -1
- package/src/registry/contract.test.ts +1 -1
- package/src/registry/find.ts +1 -1
- package/src/registry/registry.test.ts +12 -12
- package/src/suggestionPopup.tsx +1 -1
- package/stories/Choosing.mdx +2 -2
- package/stories/DesignTokens.mdx +1 -1
- package/stories/GettingStarted.mdx +2 -2
- package/stories/Introduction.mdx +23 -4
- package/stories/TokensPage.tsx +12 -7
- package/dist/CardUnder.d.ts +0 -31
- package/dist/CardUnder.d.ts.map +0 -1
- package/dist/registry/chunk-P55P2QFD.js.map +0 -7
- package/src/CardUnder.mdx +0 -54
- package/src/CardUnder.tsx +0 -49
- /package/dist/registry/{app-X2GI4WTU.js.map → app-IGBRDD4L.js.map} +0 -0
- /package/dist/registry/{build-P6X3PTZP.js.map → build-MWN4UI23.js.map} +0 -0
- /package/dist/registry/{chunk-V67F474L.js.map → chunk-NSHK76XT.js.map} +0 -0
|
@@ -19,15 +19,18 @@ import { ESCAPE_MESSAGES, isEscaped } from './escape'
|
|
|
19
19
|
* of names is kept, so a part added to the package later is covered the day it
|
|
20
20
|
* is added.
|
|
21
21
|
*
|
|
22
|
-
* - In an app: anything imported from `@estiva-app/ui
|
|
23
|
-
*
|
|
22
|
+
* - In an app: anything imported from `@estiva-app/ui` or one of its other
|
|
23
|
+
* entries (`@estiva-app/ui/editor`, where `CommentBox` lives), and anything
|
|
24
|
+
* imported from the app's own files that is one of those — a re-export (Peek's
|
|
24
25
|
* `components/ui/Button.tsx`), a wrapper that hands its props on to a part
|
|
25
26
|
* (`{...rest}`), or a component that hands its own `className` on to a part
|
|
26
27
|
* (Peek's `ConversationCard` into `Card`). Relative imports and the apps' `@/`
|
|
27
28
|
* alias are followed; `@/` is the `src` folder beside the nearest
|
|
28
29
|
* `package.json`.
|
|
29
|
-
* - Inside the package (Katerina, 17 September): a name
|
|
30
|
-
*
|
|
30
|
+
* - Inside the package (Katerina, 17 September): a name one of its entries
|
|
31
|
+
* exports (`src/index.ts`, `src/editor.ts`…, read from `package.json`),
|
|
32
|
+
* imported from a sibling file or declared in the same file. Until 0.91 only
|
|
33
|
+
* `src/index.ts` was read, so `CommentBox` could be restyled from a story.
|
|
31
34
|
*
|
|
32
35
|
* **What it reads:** a string, a template, `cn()`/`clsx()` and their arguments,
|
|
33
36
|
* both sides of a condition, a `const` in the same file and the values of a
|
|
@@ -133,11 +136,13 @@ export const PART_LOOK_PROPS: Record<string, string[]> = {
|
|
|
133
136
|
Chip: ['type'],
|
|
134
137
|
KindIcon: ['tone'],
|
|
135
138
|
LinkedIcon: ['tone'],
|
|
139
|
+
LinkKey: ['tone'],
|
|
136
140
|
CollapsibleSection: ['look'],
|
|
137
141
|
Divider: ['tone', 'orientation'],
|
|
138
142
|
EmptyState: ['scope'],
|
|
139
143
|
FieldLine: ['tone'],
|
|
140
144
|
IconButton: ['variant', 'pressed', 'glow'],
|
|
145
|
+
InlineText: ['variant'],
|
|
141
146
|
InputChip: ['truncate'],
|
|
142
147
|
Kbd: ['tone'],
|
|
143
148
|
Link: ['variant', 'truncate', 'cover'],
|
|
@@ -223,7 +228,7 @@ interface ModuleFacts {
|
|
|
223
228
|
const PACKAGE = '@estiva-app/ui'
|
|
224
229
|
const moduleCache = new Map<string, ModuleFacts>()
|
|
225
230
|
const packageDirCache = new Map<string, string | null>()
|
|
226
|
-
const packagePartsCache = new Map<string, {
|
|
231
|
+
const packagePartsCache = new Map<string, { mtimes: string; parts: Set<string> }>()
|
|
227
232
|
|
|
228
233
|
function parseFile(parser: Parser, filePath: string): Node | null {
|
|
229
234
|
const code = readFileSync(filePath, 'utf8')
|
|
@@ -238,7 +243,7 @@ function parseFile(parser: Parser, filePath: string): Node | null {
|
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
/** The nearest folder holding a `package.json`, from a file. */
|
|
241
|
-
function packageDirOf(file: string): string | null {
|
|
246
|
+
export function packageDirOf(file: string): string | null {
|
|
242
247
|
const start = dirname(resolve(file))
|
|
243
248
|
if (packageDirCache.has(start)) return packageDirCache.get(start) ?? null
|
|
244
249
|
let dir = start
|
|
@@ -269,32 +274,53 @@ function resolveModule(fromFile: string, specifier: string): string | null {
|
|
|
269
274
|
return null
|
|
270
275
|
}
|
|
271
276
|
|
|
272
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* The source file behind each of the package's entries: `"."` → `src/index.ts`,
|
|
279
|
+
* `"./editor"` → `src/editor.ts`, read from its `package.json` `exports`, so an
|
|
280
|
+
* entry added later is read the day it is added.
|
|
281
|
+
*/
|
|
282
|
+
function entrySources(dir: string, exports: unknown): string[] {
|
|
283
|
+
const found: string[] = []
|
|
284
|
+
for (const target of Object.values(exports && typeof exports === 'object' ? exports : {})) {
|
|
285
|
+
const built = typeof target === 'string' ? target : (target as { default?: unknown } | null)?.default
|
|
286
|
+
const match = typeof built === 'string' ? /^\.\/dist\/(.+)\.js$/.exec(built) : null
|
|
287
|
+
if (!match) continue
|
|
288
|
+
const source = [`${match[1]}.ts`, `${match[1]}.tsx`].map((name) => join(dir, 'src', name)).find((file) => existsSync(file))
|
|
289
|
+
if (source) found.push(source)
|
|
290
|
+
}
|
|
291
|
+
// A package.json with no `exports` (a test's copy of the layout) has its one entry.
|
|
292
|
+
if (!found.length && existsSync(join(dir, 'src', 'index.ts'))) found.push(join(dir, 'src', 'index.ts'))
|
|
293
|
+
return found
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** The names this package's entries export, when the file lives in `@estiva-app/ui` itself. */
|
|
273
297
|
function packagePartsFor(file: string, parser: Parser): Set<string> | null {
|
|
274
298
|
const dir = packageDirOf(file)
|
|
275
299
|
if (!dir) return null
|
|
276
|
-
let
|
|
300
|
+
let manifest: { name?: string; exports?: unknown }
|
|
277
301
|
try {
|
|
278
|
-
|
|
302
|
+
manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')) as { name?: string; exports?: unknown }
|
|
279
303
|
} catch {
|
|
280
304
|
return null
|
|
281
305
|
}
|
|
282
|
-
if (name !== PACKAGE) return null
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
285
|
-
const
|
|
286
|
-
const cached = packagePartsCache.get(
|
|
287
|
-
if (cached && cached.
|
|
306
|
+
if (manifest.name !== PACKAGE) return null
|
|
307
|
+
const entries = entrySources(dir, manifest.exports)
|
|
308
|
+
if (!entries.length) return null
|
|
309
|
+
const mtimes = entries.map((entry) => `${entry}:${statSync(entry).mtimeMs}`).join('|')
|
|
310
|
+
const cached = packagePartsCache.get(dir)
|
|
311
|
+
if (cached && cached.mtimes === mtimes) return cached.parts
|
|
288
312
|
const parts = new Set<string>()
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
313
|
+
for (const entry of entries) {
|
|
314
|
+
const ast = parseFile(parser, entry)
|
|
315
|
+
for (const statement of ast ? children(ast, 'body') : []) {
|
|
316
|
+
if (statement?.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') continue
|
|
317
|
+
for (const specifier of children(statement, 'specifiers')) {
|
|
318
|
+
const exported = nameOf(child(specifier as Node, 'exported'))
|
|
319
|
+
if (specifier?.exportKind !== 'type' && exported && /^[A-Z][a-z]/.test(exported)) parts.add(exported)
|
|
320
|
+
}
|
|
295
321
|
}
|
|
296
322
|
}
|
|
297
|
-
packagePartsCache.set(
|
|
323
|
+
packagePartsCache.set(dir, { mtimes, parts })
|
|
298
324
|
return parts
|
|
299
325
|
}
|
|
300
326
|
|
|
@@ -334,7 +360,8 @@ function moduleParts(file: string, program: Node, parser: Parser, stack: Set<str
|
|
|
334
360
|
const body = children(program, 'body')
|
|
335
361
|
|
|
336
362
|
const exportsOf = (specifier: string): Map<string, PartBinding> | 'package' | null => {
|
|
337
|
-
|
|
363
|
+
// The package's other entries are the package too: `CommentBox` comes from `@estiva-app/ui/editor`.
|
|
364
|
+
if (specifier === PACKAGE || specifier.startsWith(`${PACKAGE}/`)) return 'package'
|
|
338
365
|
const target = resolveModule(file, specifier)
|
|
339
366
|
if (!target) return null
|
|
340
367
|
if (packageParts) return 'package'
|
package/src/gates/gate-config.ts
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
* Where: every `.ts` and `.tsx` under `src`, stories included (a story is what
|
|
11
11
|
* people read and copy), tests not (a test mounts markup to test it) —
|
|
12
12
|
* Katerina's rulings of 13 September; `.ts` since UIG-8. This package's own
|
|
13
|
-
* inward set reads `.tsx` only, as it always has
|
|
13
|
+
* inward set reads `.tsx` only, as it always has, and its root `stories/` as
|
|
14
|
+
* well as `src/` (28 October): a prototype built there is what a build is
|
|
15
|
+
* checked against, and the One conversation prototype passed unread with five
|
|
16
|
+
* refusals in it.
|
|
14
17
|
*
|
|
15
18
|
* A place that keeps something says why, on the line above:
|
|
16
19
|
* `// @estiva-escape: <reason>`, or `{/* @estiva-escape: <reason> *\/}` as a
|
|
@@ -48,7 +51,7 @@ export function gateLint({ audience = 'app' }: Pick<GateConfigOptions, 'audience
|
|
|
48
51
|
...(audience === 'package' ? estiva.configs.package : estiva.configs.recommended),
|
|
49
52
|
// An app's every script type: a raw <button> in a .jsx, or a key listener in a .mts,
|
|
50
53
|
// passed while only .ts and .tsx were read (the re-review after the audit before UIG-26).
|
|
51
|
-
files: audience === 'package' ? ['src/**/*.tsx'] : ['src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'],
|
|
54
|
+
files: audience === 'package' ? ['src/**/*.tsx', 'stories/**/*.tsx'] : ['src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'],
|
|
52
55
|
ignores: ['**/*.test.*'],
|
|
53
56
|
languageOptions: {
|
|
54
57
|
parser: typescriptParser,
|
package/src/gates/gates.test.ts
CHANGED
|
@@ -132,10 +132,16 @@ describe('gateConfig', () => {
|
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
-
it('reads .ts for an app (UIG-8), and .tsx only for the package', async () => {
|
|
135
|
+
it('reads .ts for an app (UIG-8), and .tsx only for the package, in src/ and its root stories/', async () => {
|
|
136
136
|
const listener = "export function listen() {\n window.addEventListener('keydown', () => {})\n}\n"
|
|
137
137
|
expect(await lintWith(gateConfig(), listener, 'src/lib/probe.ts')).toEqual([expect.objectContaining({ ruleId: 'estiva/no-rebuilt-behaviour' })])
|
|
138
|
-
expect(gateLint({ audience: 'package' }).files).toEqual(['src/**/*.tsx'])
|
|
138
|
+
expect(gateLint({ audience: 'package' }).files).toEqual(['src/**/*.tsx', 'stories/**/*.tsx'])
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
// 28 October: the One conversation prototype, built in the package's root stories/, passed unread.
|
|
142
|
+
it("refuses a buried raw element in the package's root stories/, and asks no page or story of a helper there", async () => {
|
|
143
|
+
const messages = await lintWith(gateConfig({ audience: 'package' }), component('<div><button type="button">x</button></div>'), 'stories/one-conversation/Probe.tsx')
|
|
144
|
+
expect(messages.map((m) => m.ruleId)).toEqual(['estiva/raw-element-outside-a-wrapper'])
|
|
139
145
|
})
|
|
140
146
|
|
|
141
147
|
it('leaves tests alone', async () => {
|
|
@@ -293,6 +299,18 @@ describe('runHook', () => {
|
|
|
293
299
|
expect((await runHook({ root: dir, input: write('src/Probe.test.jsx', component('<button type="button">x</button>')) })).code).toBe(0)
|
|
294
300
|
})
|
|
295
301
|
|
|
302
|
+
// 28 October: the One conversation prototype was written in the package's root stories/, which the hook let through unread.
|
|
303
|
+
it("in the package, judges a write to the root stories/ as well as src/", async () => {
|
|
304
|
+
const pkg = app('hook-package', {})
|
|
305
|
+
writeFileSync(join(pkg, 'package.json'), JSON.stringify({ name: '@estiva-app/ui', private: true, type: 'module' }))
|
|
306
|
+
writeFileSync(join(pkg, 'eslint.gates.config.js'), `import { gateConfig } from '${built}'\nexport default gateConfig({ audience: 'package' })\n`)
|
|
307
|
+
const buried = component('<div><button type="button">x</button></div>')
|
|
308
|
+
const result = await runHook({ root: pkg, audience: 'package', input: write('stories/one-conversation/Probe.tsx', buried) })
|
|
309
|
+
expect(result.code).toBe(2)
|
|
310
|
+
expect(result.message).toContain('estiva/raw-element-outside-a-wrapper')
|
|
311
|
+
expect((await runHook({ root: pkg, audience: 'package', input: write('scripts/probe.tsx', buried) })).code).toBe(0)
|
|
312
|
+
})
|
|
313
|
+
|
|
296
314
|
it('lets through a test, a declaration file, and anything outside src', async () => {
|
|
297
315
|
for (const path of ['src/Probe.test.tsx', 'src/types.d.ts', 'scripts/probe.tsx']) {
|
|
298
316
|
expect((await runHook({ root: dir, input: write(path, component('<button type="button">x</button>')) })).code).toBe(0)
|
package/src/gates/hook.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* token contract too, keeping only that contract's errors (B4), and a copied
|
|
18
18
|
* look, which only warns, reaches Claude as a note on a write let through (R10). Tests are not checked
|
|
19
19
|
* (Katerina, 13 September); stories are. This package's inward gate reads `.tsx`
|
|
20
|
-
* only, as its lint does.
|
|
20
|
+
* only, as its lint does, under `src/` and the root `stories/` (28 October).
|
|
21
21
|
*
|
|
22
22
|
* Input, from Claude Code on stdin: `tool_name` and `tool_input` — `file_path`
|
|
23
23
|
* and `content` for Write; `file_path`, `old_string`, `new_string` and
|
|
@@ -111,8 +111,9 @@ export async function runHook({ root, app = '.', audience = 'app', input, seen }
|
|
|
111
111
|
const file = isAbsolute(args.file_path) ? args.file_path : resolve(call.cwd ?? top, args.file_path)
|
|
112
112
|
const rel = relative(appDir, file).split(sep).join('/')
|
|
113
113
|
// Every script under an app's src/, as the gate reads it (a raw <button> in a .jsx passed
|
|
114
|
-
// before, the re-review after the audit before UIG-26); the package's own gate is .tsx only
|
|
115
|
-
|
|
114
|
+
// before, the re-review after the audit before UIG-26); the package's own gate is .tsx only,
|
|
115
|
+
// in src/ and in the root stories/, where a prototype is built.
|
|
116
|
+
const source = audience === 'package' ? /^(?:src|stories)\/.+\.tsx$/ : APP_SOURCE
|
|
116
117
|
if (rel.startsWith('../') || isAbsolute(rel) || !source.test(rel) || /\.test\.[cm]?[jt]sx?$/.test(rel) || /\.d\.[cm]?ts$/.test(rel)) return PASS
|
|
117
118
|
|
|
118
119
|
const text = proposed(call.tool_name, args, file)
|
package/src/index.ts
CHANGED
|
@@ -88,6 +88,7 @@ export { PreviewCard, type PreviewCardProps } from './PreviewCard'
|
|
|
88
88
|
// How a link draws, wherever it sits: one kit for every app (Widgets 2).
|
|
89
89
|
export {
|
|
90
90
|
chosenOf,
|
|
91
|
+
inTheBox,
|
|
91
92
|
loadingShapeOf,
|
|
92
93
|
unavailableMemory,
|
|
93
94
|
type Linked,
|
|
@@ -118,7 +119,7 @@ export { LinkChip, type LinkChipProps } from './LinkChip'
|
|
|
118
119
|
export { LinkRow, LinkUnavailable, type LinkRowProps, type LinkUnavailableProps } from './LinkRow'
|
|
119
120
|
export { LinkCard, LinkCardLoading, type LinkCardProps, type LinkCardLoadingProps } from './LinkCard'
|
|
120
121
|
export { LinkPreview, LinkPreviewOpen, useCanHover, type LinkPreviewProps } from './LinkPreview'
|
|
121
|
-
export {
|
|
122
|
+
export { AttachedCard, type AttachedCardProps } from './AttachedCard'
|
|
122
123
|
export { PartCard, type PartCardProps } from './PartCard'
|
|
123
124
|
export { Person, type PersonProps } from './Person'
|
|
124
125
|
export { Rail, type RailProps } from './Rail'
|
package/src/linked.examples.ts
CHANGED
|
@@ -24,13 +24,13 @@ const picker = (value: string | undefined, options: PickerOption[], mayChange =
|
|
|
24
24
|
const SUMMARY = 'A one-sentence summary of what this is for.'
|
|
25
25
|
|
|
26
26
|
/** A tracked item: a key, a status and an owner the reader may change, and a conversation. */
|
|
27
|
+
// No subtitle: no app sends one (linkedFrom never fills it), and the examples hold only what an app can (Katerina, 29 Oct).
|
|
27
28
|
export const ITEM: Linked = {
|
|
28
29
|
id: 'example:item',
|
|
29
30
|
kind: 'issue',
|
|
30
31
|
title: 'Item one, with a title long enough to be cut short',
|
|
31
32
|
href: '#item',
|
|
32
33
|
key: 'ABC-2',
|
|
33
|
-
subtitle: 'Group one',
|
|
34
34
|
summary: SUMMARY,
|
|
35
35
|
status: picker('doing', STATUS_OPTIONS),
|
|
36
36
|
owner: picker('a', PEOPLE),
|
|
@@ -86,10 +86,9 @@ export const PAGE: Linked = {
|
|
|
86
86
|
kind: 'page',
|
|
87
87
|
title: 'Page one',
|
|
88
88
|
href: '#page',
|
|
89
|
-
subtitle: 'Shelf one',
|
|
90
89
|
summary: SUMMARY,
|
|
91
90
|
authors: [{ name: 'Person one' }, { name: 'Person three' }],
|
|
92
|
-
updated: '
|
|
91
|
+
updated: '1d ago',
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
/** Words a person wrote, linked as themselves. */
|
|
@@ -105,4 +104,4 @@ export const SAID: Linked = {
|
|
|
105
104
|
|
|
106
105
|
export const ready = (linked: Linked): LinkState => ({ state: 'ready', linked })
|
|
107
106
|
export const LOADING: LinkState = { state: 'loading', kind: 'issue' }
|
|
108
|
-
export const UNAVAILABLE: LinkState = { state: 'unavailable', kind: 'issue', noun: '
|
|
107
|
+
export const UNAVAILABLE: LinkState = { state: 'unavailable', kind: 'issue', noun: 'Issue', openIn: { app: 'App one', href: '#elsewhere' } }
|
package/src/linked.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a link stands for, as the link widgets draw it (LinkChip, LinkRow,
|
|
3
|
-
* LinkCard, LinkPreview,
|
|
3
|
+
* LinkCard, LinkPreview, AttachedCard). The app builds it from its own lookup —
|
|
4
4
|
* every Estiva app from `@estiva-app/interop`'s projection — and hands it in
|
|
5
5
|
* whole: the words, the addresses, and the changes the reader may make. The
|
|
6
6
|
* widgets look nothing up, and keep nothing but what a reader does to them.
|
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
* The shape follows the prototype Miky approved (Widgets 2, 15 Oct; why:
|
|
9
9
|
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md).
|
|
10
10
|
*/
|
|
11
|
+
import { createContext } from 'react'
|
|
11
12
|
import type { ThingKind } from './KindIcon'
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Inside a box being written in (CommentBox): a card or a part there sits on a
|
|
16
|
+
* file's fill, `elevated`, as the files beside it do, and a card's values read
|
|
17
|
+
* as words, not pickers, until it is sent (Katerina, 29 Oct). False anywhere else.
|
|
18
|
+
*/
|
|
19
|
+
export const inTheBox = createContext(false)
|
|
20
|
+
|
|
13
21
|
/** What a link stands for, by its icon. `page` draws a page of text. */
|
|
14
22
|
export type LinkedKind = ThingKind | 'page'
|
|
15
23
|
|
|
@@ -83,6 +91,8 @@ export interface Linked {
|
|
|
83
91
|
href: string
|
|
84
92
|
/** What the reader calls it, quietly before the title: "ABC-2". */
|
|
85
93
|
key?: string
|
|
94
|
+
/** What the app calls it, from its description of its files: "Issue", "Project", "Topic", "Document". Absent, the kind's own word. */
|
|
95
|
+
noun?: string
|
|
86
96
|
/** The line under a card's title: what it is in. Drawn after the key. */
|
|
87
97
|
subtitle?: string
|
|
88
98
|
/** Its short summary, a sentence or two. Without one a card shows the title alone. */
|
package/src/linkedFrom.test.tsx
CHANGED
|
@@ -152,11 +152,63 @@ describe('a card built from interop’s projection', () => {
|
|
|
152
152
|
})
|
|
153
153
|
})
|
|
154
154
|
|
|
155
|
+
// Katerina, 30 Oct: "there are no metadata in the card, no date no person".
|
|
156
|
+
describe('when it changed, and who made it', () => {
|
|
157
|
+
const now = Math.floor(Date.now() / 1000)
|
|
158
|
+
const PAGE: LinkedSource = {
|
|
159
|
+
ref: `30842:${OTHER}:page`,
|
|
160
|
+
address: `30842:${OTHER}:page`,
|
|
161
|
+
kind: 30842,
|
|
162
|
+
widget: 'card',
|
|
163
|
+
slots: { title: { value: 'Page one', field: 'title' }, subtitle: { value: 'What the page is for.' } },
|
|
164
|
+
meta: [],
|
|
165
|
+
actions: [],
|
|
166
|
+
changedAt: now - 2 * 3600,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
it('says when it last changed, and who made it, by the key its address is signed by', () => {
|
|
170
|
+
const card = render(<LinkCard link={linkStateFrom(PAGE, UNREAD, options())} />)
|
|
171
|
+
expect(within(card.container).getByText('Updated 2h ago')).toBeTruthy()
|
|
172
|
+
expect(within(card.container).getByText('PT')).toBeTruthy()
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('says it in the app’s words when the app gives them', () => {
|
|
176
|
+
render(<LinkCard link={linkStateFrom(PAGE, UNREAD, options({ whenOf: () => 'Tuesday' }))} />)
|
|
177
|
+
expect(screen.getByText('Updated Tuesday')).toBeTruthy()
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('names nobody it cannot name, and a topic, whose key is its relay’s', () => {
|
|
181
|
+
const stranger = { ...PAGE, address: `30842:${'c'.repeat(64)}:page` }
|
|
182
|
+
render(<LinkCard link={linkStateFrom(stranger, UNREAD, options())} />)
|
|
183
|
+
expect(screen.getByText('Updated 2h ago')).toBeTruthy()
|
|
184
|
+
cleanup()
|
|
185
|
+
render(<LinkCard link={linkStateFrom({ ...PAGE, kind: 39000, address: `39000:${OTHER}:topic` }, UNREAD, options())} />)
|
|
186
|
+
expect(screen.getByText('Updated 2h ago')).toBeTruthy()
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('leaves the person to the owner picker on a file that has one', () => {
|
|
190
|
+
const card = render(<LinkCard link={linkStateFrom({ ...GROUP, children: [] }, UNREAD, options())} />)
|
|
191
|
+
expect(within(card.container).queryByText('PT')).toBeNull()
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('counts minutes, hours and days, then gives the date', () => {
|
|
195
|
+
const at = (gone: number) => {
|
|
196
|
+
cleanup()
|
|
197
|
+
render(<LinkCard link={linkStateFrom({ ...PAGE, address: undefined, changedAt: now - gone }, UNREAD, options())} />)
|
|
198
|
+
return screen.getByText(/^Updated /).textContent
|
|
199
|
+
}
|
|
200
|
+
expect(at(10)).toBe('Updated just now')
|
|
201
|
+
expect(at(5 * 60)).toBe('Updated 5m ago')
|
|
202
|
+
expect(at(3 * 86400)).toBe('Updated 3d ago')
|
|
203
|
+
expect(at(30 * 86400)).not.toMatch(/ago/)
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
|
|
155
207
|
describe('a file the reader cannot read', () => {
|
|
156
208
|
it('is not available, and opens in its app only at an https address', () => {
|
|
157
209
|
const stub: LinkedSource = { ...GROUP, unreachable: true, noun: 'group', appName: 'App one', openUrl: 'https://app.example/x' }
|
|
158
210
|
render(<LinkCard link={linkStateFrom(stub, UNREAD, options())} />)
|
|
159
|
-
expect(screen.getByText(/Group
|
|
211
|
+
expect(screen.getByText(/Group not available/)).toBeTruthy()
|
|
160
212
|
expect(screen.getByRole('link', { name: /App one/ }).getAttribute('href')).toBe('https://app.example/x')
|
|
161
213
|
cleanup()
|
|
162
214
|
render(<LinkCard link={linkStateFrom({ ...stub, openUrl: 'javascript:alert(1)' }, UNREAD, options())} />)
|
|
@@ -165,12 +217,12 @@ describe('a file the reader cannot read', () => {
|
|
|
165
217
|
|
|
166
218
|
it('is named by its address when its app gives it no noun', () => {
|
|
167
219
|
render(<LinkCard link={linkStateFrom({ ...GROUP, unreachable: true, appName: 'App one' }, { kind: 'file', noun: 'Record' }, options())} />)
|
|
168
|
-
expect(screen.getByText('Record
|
|
220
|
+
expect(screen.getByText('Record not available')).toBeTruthy()
|
|
169
221
|
})
|
|
170
222
|
|
|
171
223
|
it('reads as the address says while it loads and when nothing came back', () => {
|
|
172
224
|
render(<LinkCard link={linkStateFrom(null, { kind: 'file', noun: 'Record' }, options())} />)
|
|
173
|
-
expect(screen.getByText('Record
|
|
225
|
+
expect(screen.getByText('Record not available')).toBeTruthy()
|
|
174
226
|
})
|
|
175
227
|
})
|
|
176
228
|
|
package/src/linkedFrom.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* words, what an address is before it is read) is the app's, passed in.
|
|
11
11
|
*/
|
|
12
12
|
import { thingKindOf } from './KindIcon'
|
|
13
|
-
import type { LinkState, Linked, LinkedChild, LinkedConversation, LinkedKind, LinkedPicker, StatusColour } from './linked'
|
|
13
|
+
import type { LinkState, Linked, LinkedChild, LinkedConversation, LinkedKind, LinkedPerson, LinkedPicker, StatusColour } from './linked'
|
|
14
14
|
|
|
15
15
|
/** A person as interop names them: a profile, possibly empty. */
|
|
16
16
|
export interface LinkedProfile {
|
|
@@ -80,6 +80,23 @@ export interface LinkedFromOptions<T extends LinkedSource = LinkedSource> {
|
|
|
80
80
|
onAct?: (actionId: string, value: string) => void
|
|
81
81
|
/** What was said about it, when the app has read that. */
|
|
82
82
|
conversation?: LinkedConversation
|
|
83
|
+
/**
|
|
84
|
+
* When it last changed, from interop's `changedAt` (in seconds), in the app's words. Without it a card says it the
|
|
85
|
+
* kit's way, alike in every app: "just now", "5m ago", "2h ago", "3d ago", then the date.
|
|
86
|
+
*/
|
|
87
|
+
whenOf?: (seconds: number) => string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** How long ago a time in seconds was, as a card says it: "just now", "5m ago", "2h ago", "3d ago", then "12 Oct". */
|
|
91
|
+
function agoOf(seconds: number, now = Date.now()): string {
|
|
92
|
+
const gone = Math.max(0, Math.floor(now / 1000 - seconds))
|
|
93
|
+
if (gone < 60) return 'just now'
|
|
94
|
+
if (gone < 3600) return `${Math.floor(gone / 60)}m ago`
|
|
95
|
+
if (gone < 86400) return `${Math.floor(gone / 3600)}h ago`
|
|
96
|
+
if (gone < 7 * 86400) return `${Math.floor(gone / 86400)}d ago`
|
|
97
|
+
const date = new Date(seconds * 1000)
|
|
98
|
+
const year = date.getFullYear() === new Date(now).getFullYear() ? {} : { year: 'numeric' as const }
|
|
99
|
+
return date.toLocaleDateString(undefined, { day: 'numeric', month: 'short', ...year })
|
|
83
100
|
}
|
|
84
101
|
|
|
85
102
|
/** How many of a file's items its card lists: the most recently changed (Miky, 21 Oct). */
|
|
@@ -226,17 +243,40 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
226
243
|
}
|
|
227
244
|
}
|
|
228
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Who made it, when the app can name them: the key its address is signed by (`kind:pubkey:d`). A topic's is its
|
|
248
|
+
* relay's, which names nobody; a file with no address has no key in it.
|
|
249
|
+
*/
|
|
250
|
+
function authorOf(object: LinkedSource, directory: LinkedFromOptions['directory']): LinkedPerson | undefined {
|
|
251
|
+
if (object.kind === KIND_CHANNEL || !object.address) return undefined
|
|
252
|
+
const pubkey = object.address.split(':')[1]
|
|
253
|
+
if (!pubkey || !/^[0-9a-f]{64}$/.test(pubkey)) return undefined
|
|
254
|
+
const profile = object.people?.[pubkey] ?? directory?.[pubkey]
|
|
255
|
+
if (!profile?.displayName) return undefined
|
|
256
|
+
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}) }
|
|
257
|
+
}
|
|
258
|
+
|
|
229
259
|
/** The file a reference names, as the kit's chip, row and card draw it. */
|
|
230
260
|
export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFromOptions<T>): Linked {
|
|
231
261
|
const { slots, people } = object
|
|
232
262
|
const id = idOf(object)
|
|
233
263
|
const href = options.hrefOf(object, true)
|
|
264
|
+
// When it last changed (Katerina, 30 Oct: "no date no person"). A message's is when it was written.
|
|
265
|
+
const updated = object.changedAt !== undefined ? (options.whenOf ?? agoOf)(object.changedAt) : undefined
|
|
234
266
|
if (isMessage(object) && slots.title?.isPubkey) {
|
|
235
267
|
// A message is titled by its author (RIC-11): drawn with their face, then its opening words.
|
|
236
268
|
const person = people?.[slots.title.value]
|
|
237
269
|
const name = person?.displayName ?? '—'
|
|
238
270
|
const body = slots.body?.value ? options.previewText(slots.body.value, people) : ''
|
|
239
|
-
return {
|
|
271
|
+
return {
|
|
272
|
+
id,
|
|
273
|
+
kind: 'message',
|
|
274
|
+
title: name,
|
|
275
|
+
href,
|
|
276
|
+
author: { name, ...(person?.picture ? { picture: person.picture } : {}) },
|
|
277
|
+
...(body ? { body } : {}),
|
|
278
|
+
...(updated ? { updated } : {}),
|
|
279
|
+
}
|
|
240
280
|
}
|
|
241
281
|
const onAct = object.archived ? undefined : options.onAct
|
|
242
282
|
const key = keyOf(object)
|
|
@@ -244,12 +284,15 @@ export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFro
|
|
|
244
284
|
const owner = ownerOf(object, options, onAct)
|
|
245
285
|
const children = childrenOf(object, options)
|
|
246
286
|
const done = doneOf(object)
|
|
287
|
+
// Who made it, when nothing else on it names a person: an issue's owner already does.
|
|
288
|
+
const author = owner ? undefined : authorOf(object, options.directory)
|
|
247
289
|
return {
|
|
248
290
|
id,
|
|
249
291
|
kind: linkedKindOfKind(object.kind),
|
|
250
292
|
title: titleOf(object),
|
|
251
293
|
href,
|
|
252
294
|
...(key ? { key } : {}),
|
|
295
|
+
...(object.noun ? { noun: object.noun.charAt(0).toUpperCase() + object.noun.slice(1) } : {}),
|
|
253
296
|
// Interop reads every file kind's summary into its subtitle (SPEC §6.12).
|
|
254
297
|
...(slots.subtitle?.value ? { summary: slots.subtitle.value } : {}),
|
|
255
298
|
...(status ? { status } : {}),
|
|
@@ -257,6 +300,8 @@ export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFro
|
|
|
257
300
|
...(options.conversation ? { conversation: options.conversation } : {}),
|
|
258
301
|
...(children ? { children } : {}),
|
|
259
302
|
...(done ? { done } : {}),
|
|
303
|
+
...(author ? { authors: [author] } : {}),
|
|
304
|
+
...(updated ? { updated } : {}),
|
|
260
305
|
}
|
|
261
306
|
}
|
|
262
307
|
|
package/src/links.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Extension, type Mark } from '@tiptap/core'
|
|
|
2
2
|
import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state'
|
|
3
3
|
import { Decoration, DecorationSet } from '@tiptap/pm/view'
|
|
4
4
|
import StarterKit from '@tiptap/starter-kit'
|
|
5
|
+
import { WEB_LINK_CLASSES } from './looks'
|
|
5
6
|
|
|
6
7
|
/*
|
|
7
8
|
* Links in the kit's editors: a URL pasted over words, the link mark that holds
|
|
@@ -101,8 +102,8 @@ export const DocumentKit = StarterKit.extend({
|
|
|
101
102
|
const LINK_SPLIT = /\[[^[\]\n]+\]\((?:https?:\/\/|mailto:)[^\s)]+\)|https?:\/\/[^\s]+/g
|
|
102
103
|
/** Punctuation after a bare address ends the sentence, not the address. */
|
|
103
104
|
const TRAILING = /[.,;:!?)\]]+$/
|
|
104
|
-
/** A link's look in an editor: the package `Link variant="text"`, spelled out for a mark's element and a decoration's range
|
|
105
|
-
export const LINK_CLASS =
|
|
105
|
+
/** A link's look in an editor: the package `Link variant="text"`, spelled out for a mark's element and a decoration's range, with the link icon and its underline as in `RichText`. */
|
|
106
|
+
export const LINK_CLASS = `text-info-default cursor-pointer ${WEB_LINK_CLASSES}`
|
|
106
107
|
|
|
107
108
|
/** What a click may open: an address a reader may follow (SPEC §13.1), never `javascript:` and the like. */
|
|
108
109
|
const OPENABLE = /^(https?:\/\/|mailto:)/i
|
package/src/looks.ts
CHANGED
|
@@ -43,6 +43,13 @@ export const COUNT_TEXT_CLASSES = 'font-mono text-caption tabular-nums text-text
|
|
|
43
43
|
/** A chip's words: Chip's label and Reaction's count. */
|
|
44
44
|
export const CHIP_TEXT_CLASSES = 'text-chip signal:font-mono signal:text-small signal:font-semibold signal:tabular-nums'
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The time of something a person said: one line, and in Signal the mono micro-type with even digits, as Peek's
|
|
48
|
+
* conversation draws a message's time (its MetaText). Only there: words a person wrote, and the latest conversation
|
|
49
|
+
* (Katerina, 29 Oct); "Updated" and other times keep the text's own type.
|
|
50
|
+
*/
|
|
51
|
+
export const TIME_CLASSES = 'whitespace-nowrap signal:font-mono signal:text-small signal:tracking-wide signal:tabular-nums'
|
|
52
|
+
|
|
46
53
|
/** Small secondary words that turn mono under signal: Kbd's key, CommandPalette's footer and MembersPill's count. */
|
|
47
54
|
export const MONO_CAPTION_CLASSES = 'text-caption text-text-secondary signal:font-mono signal:text-small'
|
|
48
55
|
|
|
@@ -75,3 +82,25 @@ export const COLLAPSIBLE_PANEL_CLASSES = 'h-[var(--collapsible-panel-height)] ov
|
|
|
75
82
|
*/
|
|
76
83
|
export const WRITING_BOX_CLASSES =
|
|
77
84
|
'relative bg-bg-inset border border-border-default rounded-lg p-3 flex flex-col gap-4 signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring'
|
|
85
|
+
|
|
86
|
+
/** The 36px tile a file's type sits in: AttachmentCard's, and a link's kind in LinkRow, LinkCard and PartCard (Katerina, 29 Oct). */
|
|
87
|
+
export const TYPE_TILE_CLASSES = 'size-9 rounded-md bg-bg-active flex items-center justify-center shrink-0 text-text-secondary'
|
|
88
|
+
|
|
89
|
+
/** The bar down a quoted part's left edge: PartCard's blocks, and (proposal) a card's latest conversation. */
|
|
90
|
+
export const QUOTE_BAR_CLASSES = 'border-l-2 border-border-default pl-3'
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A link in text: the link icon before its words, in the link's colour and at the text's size, and one underline
|
|
94
|
+
* under the icon and the words together, as Slack draws one, so it never reads as a chip (Katerina, 29 Oct: "icon
|
|
95
|
+
* before but also underlined", "I want the icon to be underlined as well like Slack does"). A chip of an Estiva thing
|
|
96
|
+
* starts with its kind's icon instead and wears none of this.
|
|
97
|
+
*
|
|
98
|
+
* The browser's underline (`text-decoration`) skips an icon, so the line is the link's own background instead: 1px of
|
|
99
|
+
* its colour along the bottom of each line it runs over. Tabler's `link` is drawn as a mask on `::before`, so it takes
|
|
100
|
+
* the link's colour and nothing is added to what is saved or copied. `Link`'s `text` look is this, and so are the
|
|
101
|
+
* editors' links (`LINK_CLASS`).
|
|
102
|
+
*/
|
|
103
|
+
/** The line a link in text draws under everything in it, icon included: its own 1px background, since text-decoration skips an icon. */
|
|
104
|
+
export const LINK_UNDERLINE_CLASSES = 'no-underline bg-[linear-gradient(currentColor,currentColor)] bg-[length:100%_1px] bg-bottom bg-no-repeat'
|
|
105
|
+
|
|
106
|
+
export const WEB_LINK_CLASSES = `${LINK_UNDERLINE_CLASSES} before:content-[''] before:inline-block before:size-[1em] before:mr-0.5 before:align-[-0.125em] before:bg-current before:[mask:url(data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%271.75%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M9%2015l6%20-6%27%2F%3E%3Cpath%20d%3D%27M11%206l.463%20-.536a5%205%200%200%201%207.071%207.072l-.534%20.464%27%2F%3E%3Cpath%20d%3D%27M13%2018l-.397%20.534a5.068%205.068%200%200%201%20-7.127%200a4.972%204.972%200%200%201%200%20-7.071l.524%20-.463%27%2F%3E%3C%2Fsvg%3E)_center/contain_no-repeat]`
|
package/src/registry/build.ts
CHANGED
|
@@ -76,7 +76,7 @@ export function sanitize(name: string): string {
|
|
|
76
76
|
/**
|
|
77
77
|
* Storybook's `storyNameFromExport`, which is lodash's `startCase`: an export
|
|
78
78
|
* called `WithCounts` is the story "With Counts", and its id is
|
|
79
|
-
* `
|
|
79
|
+
* `page-structure-tabs--with-counts`, not `--withcounts`.
|
|
80
80
|
*
|
|
81
81
|
* Measured against a real `storybook build` (2026-09-18): without this, 11 of
|
|
82
82
|
* the 81 ids resolved nowhere — every export whose name is more than one word.
|
|
@@ -220,7 +220,7 @@ describe('nameProblems', () => {
|
|
|
220
220
|
const seen = '**Seen in** — *Parts/Badge*, *To be removed/\nTopicActivity* and\n*Media/AttachmentCard*.'
|
|
221
221
|
const dir = app({ 'src/Badge.mdx': page('A word.', seen) })
|
|
222
222
|
const titles = new Set(['Parts/Badge'])
|
|
223
|
-
expect(nameProblems(registry(dir), dir, { known, titles, packageIds: ['
|
|
223
|
+
expect(nameProblems(registry(dir), dir, { known, titles, packageIds: ['links-references-attachmentcard--document'] })).toEqual([
|
|
224
224
|
'src/Badge.mdx: "Seen in" names To be removed/TopicActivity, which no Storybook has',
|
|
225
225
|
'src/Badge.mdx: "Seen in" names Media/AttachmentCard, which no Storybook has',
|
|
226
226
|
])
|
package/src/registry/find.ts
CHANGED
|
@@ -175,7 +175,7 @@ export function findInRegistries(registries: Registry[], query: string, { limit
|
|
|
175
175
|
return findings.slice(0, limit)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/** `http://localhost:6008/?path=/docs/
|
|
178
|
+
/** `http://localhost:6008/?path=/docs/menus-windows-popover--docs`, or `null` where the entry has no page. */
|
|
179
179
|
export function docsLink(registry: Registry, entry: RegistryEntry): string | null {
|
|
180
180
|
if (!entry.docsId) return null
|
|
181
181
|
return registry.storybook.devUrl + registry.storybook.docsPath.replace('{docsId}', entry.docsId)
|