@estiva-app/ui 0.91.2 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/AppProvider.d.ts +7 -3
  2. package/dist/AppProvider.d.ts.map +1 -1
  3. package/dist/AttachedCard.d.ts +5 -1
  4. package/dist/AttachedCard.d.ts.map +1 -1
  5. package/dist/BlockNodes.d.ts +14 -1
  6. package/dist/BlockNodes.d.ts.map +1 -1
  7. package/dist/CommentBox.d.ts +9 -2
  8. package/dist/CommentBox.d.ts.map +1 -1
  9. package/dist/ComposerTriggers.d.ts +11 -2
  10. package/dist/ComposerTriggers.d.ts.map +1 -1
  11. package/dist/DocumentEditor.d.ts.map +1 -1
  12. package/dist/LinkCard.d.ts.map +1 -1
  13. package/dist/LinkChip.d.ts.map +1 -1
  14. package/dist/LinkChips.d.ts +2 -1
  15. package/dist/LinkChips.d.ts.map +1 -1
  16. package/dist/LinkParts.d.ts +6 -1
  17. package/dist/LinkParts.d.ts.map +1 -1
  18. package/dist/LinkPlaces.d.ts +7 -0
  19. package/dist/LinkPlaces.d.ts.map +1 -1
  20. package/dist/LinkRow.d.ts +29 -6
  21. package/dist/LinkRow.d.ts.map +1 -1
  22. package/dist/PartCard.d.ts +9 -2
  23. package/dist/PartCard.d.ts.map +1 -1
  24. package/dist/ReferenceCards.d.ts +9 -39
  25. package/dist/ReferenceCards.d.ts.map +1 -1
  26. package/dist/ReferenceMenu.d.ts.map +1 -1
  27. package/dist/editor.d.ts +1 -1
  28. package/dist/editor.d.ts.map +1 -1
  29. package/dist/editor.js +204 -183
  30. package/dist/editor.js.map +3 -3
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +165 -50
  34. package/dist/index.js.map +3 -3
  35. package/dist/linked.d.ts +48 -3
  36. package/dist/linked.d.ts.map +1 -1
  37. package/dist/linked.examples.d.ts +6 -0
  38. package/dist/linked.examples.d.ts.map +1 -1
  39. package/dist/linkedFrom.d.ts +7 -3
  40. package/dist/linkedFrom.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/registry.json +53 -56
  43. package/src/AppProvider.mdx +7 -5
  44. package/src/AppProvider.test.tsx +15 -1
  45. package/src/AppProvider.tsx +13 -4
  46. package/src/AttachedCard.mdx +2 -1
  47. package/src/AttachedCard.test.tsx +28 -0
  48. package/src/AttachedCard.tsx +12 -2
  49. package/src/BlockNodes.mdx +8 -1
  50. package/src/BlockNodes.tsx +98 -11
  51. package/src/CommentBox.mdx +8 -2
  52. package/src/CommentBox.stories.tsx +28 -1
  53. package/src/CommentBox.test.tsx +64 -1
  54. package/src/CommentBox.tsx +44 -5
  55. package/src/ComposerTriggers.mdx +1 -0
  56. package/src/ComposerTriggers.tsx +34 -15
  57. package/src/DocumentEditor.mdx +1 -1
  58. package/src/DocumentEditor.stories.tsx +2 -2
  59. package/src/DocumentEditor.test.tsx +37 -7
  60. package/src/DocumentEditor.tsx +2 -1
  61. package/src/LinkCard.mdx +9 -5
  62. package/src/LinkCard.stories.tsx +17 -2
  63. package/src/LinkCard.test.tsx +21 -0
  64. package/src/LinkCard.tsx +35 -16
  65. package/src/LinkChip.mdx +6 -1
  66. package/src/LinkChip.stories.tsx +7 -1
  67. package/src/LinkChip.test.tsx +12 -0
  68. package/src/LinkChip.tsx +6 -2
  69. package/src/LinkChips.mdx +4 -3
  70. package/src/LinkChips.stories.tsx +2 -2
  71. package/src/LinkChips.test.tsx +1 -2
  72. package/src/LinkChips.ts +2 -1
  73. package/src/LinkParts.mdx +3 -2
  74. package/src/LinkParts.stories.tsx +8 -0
  75. package/src/LinkParts.tsx +40 -6
  76. package/src/LinkPlaces.mdx +3 -0
  77. package/src/LinkPlaces.ts +19 -0
  78. package/src/LinkRow.mdx +8 -2
  79. package/src/LinkRow.stories.tsx +14 -2
  80. package/src/LinkRow.test.tsx +31 -1
  81. package/src/LinkRow.tsx +69 -25
  82. package/src/PartCard.mdx +9 -1
  83. package/src/PartCard.stories.tsx +9 -0
  84. package/src/PartCard.test.tsx +13 -0
  85. package/src/PartCard.tsx +19 -5
  86. package/src/ReferenceCards.test.tsx +4 -35
  87. package/src/ReferenceCards.ts +10 -119
  88. package/src/ReferenceMenu.mdx +6 -4
  89. package/src/ReferenceMenu.test.tsx +67 -5
  90. package/src/ReferenceMenu.tsx +18 -7
  91. package/src/editor.ts +0 -3
  92. package/src/index.ts +4 -1
  93. package/src/linked.examples.ts +6 -0
  94. package/src/linked.test.ts +35 -1
  95. package/src/linked.ts +108 -3
  96. package/src/linkedFrom.test.tsx +42 -2
  97. package/src/linkedFrom.ts +15 -7
  98. package/src/registry/registry.test.ts +25 -6
  99. package/src/ReferenceCards.mdx +0 -86
  100. package/src/ReferenceCards.stories.tsx +0 -66
package/src/LinkCard.mdx CHANGED
@@ -12,14 +12,17 @@ A link's card: what a row cannot hold, and the changes the reader may make from
12
12
  ## When
13
13
 
14
14
  - **ready** — it starts as its row does: its kind in a file's 36px tile, the title as the link on one line, cut short when long, and under it the key and what it is ("ABC-2 · Issue"); on the title's line, at the right, its ring, its conversation count and its faces, in that order, as a row's. Then its summary, the items inside it in a box of their own, its newest conversation as a quote, and a footer: the pickers, or who wrote it and when. No summary, the title alone.
15
- - **width** — at most 480px, in a message, a document and a box being written in alike; in a box it sits on the files' fill, its values as words until it is sent.
15
+ - **width** — at most 480px, in a message, a document and a box being written in alike; in a box it sits on the files' fill, its values and its links (the title, the count, its items) as words until it is sent, so a click on it never leaves the draft.
16
16
  - **footer** — only when there is something for it: a title and a summary alone end at the summary.
17
17
  - **read only** — a picker the app passed no `onChange` for reads as words in the same place: the reader may not change it. `readOnly` makes every value words, as the hover preview does.
18
18
  - **words a person wrote** — their 24px face, their name, the time beside it as the link (without a time, the name), and the words.
19
- - **loading** — the card it will become in bars, at its own height: `shape` from `loadingShapeOf(linked)` the last time it drew, or the kind's usual card. **LinkCardLoading**, from this file.
20
- - **unavailable** — one row, as **LinkRow** draws it.
19
+ - **loading** — the card it will become in bars, at its own height: `shape` from `loadingShapeOf(linked)` the last time it drew (kept per device by `cardShapeMemory`), or the kind's usual card. **LinkCardLoading**, from this file.
20
+ - **archived** — `linked.archived`: "Archived" in the line under the title, and its values as words.
21
+ - **unavailable** — one row, as **LinkRow** draws it: "Issue not available", or with `deleted` "Issue deleted"; with `url`, the URL as it was written.
21
22
 
22
23
  <Canvas of={LinkCardStories.ReadOnly} />
24
+ <Canvas of={LinkCardStories.InABox} />
25
+ <Canvas of={LinkCardStories.Archived} />
23
26
  <Canvas of={LinkCardStories.Loading} />
24
27
 
25
28
  ## When not
@@ -42,11 +45,12 @@ const linked = {
42
45
  <LinkCard link={{ state: 'ready', linked }} />
43
46
  ```
44
47
 
45
- - **Whether the reader may change it is the app's.** Pass `onChange` only to a reader who may; anyone else sees words.
48
+ - **Any app drawing a card offers the file's shared actions** (the record a-card-changes-what-a-files-app-shares): pass `onChange` (with `linkStateFrom`, its `onAct`) wherever the reader can act on the file, in every app. Words only where the reader can't: an archived file (`linkStateFrom` does that itself), an archived or read-only conversation or page, a signed-out reader, and the hover preview (`readOnly`).
46
49
  - The picker offers only the options it is given: to let the reader set nobody as the owner, include an option for it.
47
50
  - `linked.latest` is drawn whenever it is given: pass it only to a reader who may read it.
51
+ - **A placeholder that never jumps:** keep, per device and under the app's own key, the shape each card last drew at with `cardShapeMemory(key)` — `of(id, kind)` for the placeholder's `shape` (with its `height` as the box's least height), `note(id, { ...loadingShapeOf(linked), height })` once it drew — and that it could not be shown with `unavailableMemory(key)`, so the next open draws the not-available row from the first paint. Clear both at sign-out.
48
52
  - `linked.conversation.unread` only for a member of it.
49
- - **From interop's projection, build it with `linkStateFrom(object, unread, options)`** (or `linkedFrom` for a read object), so every app draws one thing as one card: its key, its 7 most recently changed items, a ring over all of them, and pickers through its own actions when `options.onAct` is passed (words once it is archived). When it last changed (`changedAt`) reads "2h ago", the same words in every app unless the app passes `whenOf`; who made it, the key its address is signed by, shows as a face when the app can name them and nothing else on the card names a person. The app passes `hrefOf(object, top)`, `previewText(body, people)` and, for a link not yet read, its kind and noun.
53
+ - **From interop's projection, build it with `linkStateFrom(object, unread, options)`** (or `linkedFrom` for a read object), so every app draws one thing as one card: its key, its 7 most recently changed items, a ring over all of them, and pickers through its own actions when `options.onAct` is passed (words once it is archived). When it last changed (`changedAt`) reads "2h ago", the same words in every app unless the app passes `whenOf`; who made it, the key its address is signed by, shows as a face when the app can name them and nothing else on the card names a person. The app passes `hrefOf(object, top)`, `previewText(body, people)` and, for a link not yet read, its kind and noun, and with them `deleted` when a trusted deletion names the address (SPEC §13.6.1) and `url` when the link was written as an app URL. A file whose type has no name is called by its app's name.
50
54
 
51
55
  ## What it owns
52
56
 
@@ -1,8 +1,8 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import { useState } from 'react'
3
3
  import { LinkCard, LinkCardLoading } from './LinkCard'
4
- import { loadingShapeOf, type Linked } from './linked'
5
- import { GROUP, ITEM, ITEM_NO_SUMMARY, ITEM_READ_ONLY, ITEM_UNREAD, PAGE, PLACE, ready, SAID, UNAVAILABLE } from './linked.examples'
4
+ import { inTheBox, loadingShapeOf, type Linked } from './linked'
5
+ import { DELETED, GROUP, ITEM, ITEM_ARCHIVED, ITEM_NO_SUMMARY, ITEM_READ_ONLY, ITEM_UNREAD, PAGE, PLACE, ready, SAID, UNAVAILABLE } from './linked.examples'
6
6
 
7
7
  const meta = {
8
8
  title: 'Links & references/LinkCard',
@@ -28,6 +28,18 @@ export const Default: Story = {
28
28
  /** To a reader who may not change it: the same two values, as words. */
29
29
  export const ReadOnly: Story = { args: { link: ready(ITEM_READ_ONLY) } }
30
30
 
31
+ /** Archived: "Archived" in the line under its title, its values as words. */
32
+ export const Archived: Story = { args: { link: ready(ITEM_ARCHIVED) } }
33
+
34
+ /** In a box being written in: on the files' fill, its values and its links as words, so a click on it never leaves the draft. */
35
+ export const InABox: Story = {
36
+ render: (args) => (
37
+ <inTheBox.Provider value>
38
+ <LinkCard {...args} />
39
+ </inTheBox.Provider>
40
+ ),
41
+ }
42
+
31
43
  /** Something unread in its conversation, to a member: the count is brighter, with a dot. */
32
44
  export const Unread: Story = { args: { link: ready(ITEM_UNREAD) } }
33
45
 
@@ -69,3 +81,6 @@ export const LoadingByKind: Story = { args: { link: { state: 'loading', kind: 'i
69
81
 
70
82
  /** Deleted, or not this reader's to see: one line. */
71
83
  export const NotAvailable: Story = { args: { link: UNAVAILABLE } }
84
+
85
+ /** Deleted, as a trusted deletion naming it says: the not-available row, its own words, no way out. */
86
+ export const Deleted: Story = { args: { link: DELETED } }
@@ -44,11 +44,32 @@ describe('LinkCard', () => {
44
44
  expect(screen.queryByRole('combobox')).toBeNull()
45
45
  })
46
46
 
47
+ it('draws a file with no address to open as words: no link to nowhere on its title, its count or its items', () => {
48
+ const { container } = render(<LinkCard link={ready({ ...GROUP, href: '', conversation: { count: 1, href: '' }, children: GROUP.children!.map((child) => ({ ...child, href: '' })) })} />)
49
+ expect(container.querySelector('a')).toBeNull()
50
+ expect(screen.getByText(GROUP.title)).toBeTruthy()
51
+ expect(screen.getByText('1 comment')).toBeTruthy()
52
+ })
53
+
47
54
  it('says nobody owns it when nobody does', () => {
48
55
  render(<LinkCard link={ready({ ...ITEM_READ_ONLY, owner: { value: undefined, options: [] } })} />)
49
56
  expect(screen.getByText('Unassigned')).toBeTruthy()
50
57
  })
51
58
 
59
+ it('draws "Unassigned" with the silhouette, never a letter, as words and in the picker alike', async () => {
60
+ const user = userEvent.setup()
61
+ const nobody = { value: '', label: 'Unassigned' }
62
+ render(<LinkCard link={ready({ ...ITEM_READ_ONLY, owner: { value: '', options: [nobody] } })} />)
63
+ expect(screen.getByText('Unassigned')).toBeTruthy()
64
+ expect(screen.queryByText('U')).toBeNull()
65
+ cleanup()
66
+ render(<LinkCard link={ready({ ...ITEM, owner: { ...ITEM.owner!, value: '', options: [nobody, ...ITEM.owner!.options], onChange: () => {} } })} />)
67
+ expect(screen.queryByText('U')).toBeNull()
68
+ await user.click(screen.getByRole('combobox', { name: 'Owner' }))
69
+ await screen.findByRole('option', { name: /Unassigned/ })
70
+ expect(screen.queryByText('U')).toBeNull()
71
+ })
72
+
52
73
  it('shows the title alone when there is no summary', () => {
53
74
  render(<LinkCard link={ready(ITEM_NO_SUMMARY)} />)
54
75
  expect(screen.getByRole('link', { name: 'Item two' })).toBeTruthy()
package/src/LinkCard.tsx CHANGED
@@ -9,11 +9,11 @@
9
9
  *
10
10
  * At most 480px wide, in a message, a document and a box being written in alike
11
11
  * (Katerina, 30 Oct: a card across a wide box did not look good); in a box it
12
- * sits on the files' fill, its values as words until it is sent. While it
13
- * loads it holds the card's own shape, so what is around it does not jump; not
14
- * available is one row.
12
+ * sits on the files' fill, its values and its links as words until it is sent,
13
+ * so a click on it never leaves the draft. While it loads it holds the card's
14
+ * own shape, so what is around it does not jump; not available is one row.
15
15
  */
16
- import { useContext } from 'react'
16
+ import { useContext, type ReactNode } from 'react'
17
17
  import { Avatar } from './Avatar'
18
18
  import { AvatarGroup } from './AvatarGroup'
19
19
  import { Card } from './Card'
@@ -21,7 +21,7 @@ import { cn } from './cn'
21
21
  import { Link } from './Link'
22
22
  import { inTheBox, type Linked, type LinkedKind, type LinkState, type LoadingShape } from './linked'
23
23
  import { CommentCount, LinkedIcon, LinkKey, LinkPickers, LinkTile, ProgressRing, StatusMark } from './LinkParts'
24
- import { linkMetaOf, LinkUnavailable } from './LinkRow'
24
+ import { linkMetaOf, LinkUnavailable, WrittenUrl } from './LinkRow'
25
25
  import { QUOTE_BAR_CLASSES, TIME_CLASSES, TYPE_TILE_CLASSES } from './looks'
26
26
  import { SkeletonBar } from './Skeleton'
27
27
 
@@ -36,11 +36,28 @@ export interface LinkCardProps {
36
36
  /** A card's frame: 12px round it, 12px between what it holds. */
37
37
  const CARD_CLASSES = 'flex flex-col gap-3 p-3'
38
38
 
39
+ /**
40
+ * A link on a card, or its words alone: in a box being written in, where the card under the box follows no click,
41
+ * as the chips in the box do not (Katerina, 30 Oct), and where there is nowhere to open (an empty `href`).
42
+ */
43
+ function CardLink({ href, truncate = false, className, children }: { href: string; truncate?: boolean; className?: string; children: ReactNode }) {
44
+ const boxed = useContext(inTheBox)
45
+ if (boxed || !href) return <span className={cn(truncate && 'truncate', className)}>{children}</span>
46
+ return (
47
+ <Link href={href} variant="quiet" truncate={truncate} className={className}>
48
+ {children}
49
+ </Link>
50
+ )
51
+ }
52
+
39
53
  export function LinkCard({ link, readOnly = false, bare = false }: LinkCardProps) {
40
54
  // In a box being written in: the files' fill, and the values as words until it is sent.
41
55
  const boxed = useContext(inTheBox)
42
56
  if (link.state === 'loading') return <LinkCardLoading kind={link.kind} shape={link.shape} />
43
- if (link.state === 'unavailable') return <LinkUnavailable kind={link.kind} noun={link.noun} openIn={link.openIn} card />
57
+ if (link.state === 'unavailable') {
58
+ if (link.url) return <WrittenUrl url={link.url} block />
59
+ return <LinkUnavailable kind={link.kind} noun={link.noun} openIn={link.openIn} deleted={link.deleted} card />
60
+ }
44
61
  const { linked } = link
45
62
  const body = linked.kind === 'message' && linked.author ? <SaidBody linked={linked} /> : <CardBody linked={linked} readOnly={readOnly || boxed} />
46
63
  if (bare) return <div className={CARD_CLASSES}>{body}</div>
@@ -64,9 +81,9 @@ function CardBody({ linked, readOnly }: { linked: Linked; readOnly: boolean }) {
64
81
  <span className="flex min-w-0 flex-1 flex-col gap-0.5">
65
82
  <span className="block min-w-0 text-body-2-strong text-text-primary">
66
83
  {/* One line, cut short: a long title truncates rather than wrapping (Katerina, 29 Oct). */}
67
- <Link href={linked.href} variant="quiet" truncate className="block">
84
+ <CardLink href={linked.href} truncate className="block">
68
85
  {linked.title}
69
- </Link>
86
+ </CardLink>
70
87
  </span>
71
88
  {meta && <span className="truncate text-caption text-text-secondary">{meta}</span>}
72
89
  </span>
@@ -84,15 +101,19 @@ function CardBody({ linked, readOnly }: { linked: Linked; readOnly: boolean }) {
84
101
  // In a box of their own, a hairline between them, as the card first drew them (Katerina, 29 Oct: "add back the borders").
85
102
  <div className="flex flex-col divide-y divide-border-subtle rounded-md border border-border-subtle leaf:divide-border-strong leaf:border-border-strong">
86
103
  {linked.children.map((child) => (
87
- <div key={child.id} className="relative flex h-8 items-center gap-2 px-2 hover:bg-bg-active">
104
+ <div key={child.id} className={cn('relative flex h-8 items-center gap-2 px-2', !boxed && 'hover:bg-bg-active')}>
88
105
  {/* The status is the row's icon: a list needs no kind icon on every row. */}
89
106
  <StatusMark status={child.status} />
90
107
  {child.key && <LinkKey>{child.key}</LinkKey>}
91
108
  {/* Each opens on its own; the link covers its row. */}
92
109
  <span className="contents text-body-2 text-text-primary">
93
- <Link href={child.href} variant="quiet" cover truncate className="min-w-0 flex-1">
94
- {child.title}
95
- </Link>
110
+ {boxed || !child.href ? (
111
+ <span className="min-w-0 flex-1 truncate">{child.title}</span>
112
+ ) : (
113
+ <Link href={child.href} variant="quiet" cover truncate className="min-w-0 flex-1">
114
+ {child.title}
115
+ </Link>
116
+ )}
96
117
  </span>
97
118
  {child.owner ? <Avatar name={child.owner.name} src={child.owner.picture} size={16} /> : <span className="size-4 shrink-0" aria-hidden />}
98
119
  </div>
@@ -142,13 +163,11 @@ function SaidBody({ linked }: { linked: Linked }) {
142
163
  <Avatar name={author.name} src={author.picture} size={24} />
143
164
  {/* No "Open" in a missing time's place (Katerina, 30 Oct): the name is the link then. */}
144
165
  <span className="text-body-2-strong text-text-primary">
145
- {linked.updated ? author.name : <Link href={linked.href} variant="quiet">{author.name}</Link>}
166
+ {linked.updated ? author.name : <CardLink href={linked.href}>{author.name}</CardLink>}
146
167
  </span>
147
168
  {linked.updated && (
148
169
  <span className={cn('text-caption text-text-muted', TIME_CLASSES)}>
149
- <Link href={linked.href} variant="quiet">
150
- {linked.updated}
151
- </Link>
170
+ <CardLink href={linked.href}>{linked.updated}</CardLink>
152
171
  </span>
153
172
  )}
154
173
  </div>
package/src/LinkChip.mdx CHANGED
@@ -13,10 +13,15 @@ A link in a sentence: its icon, its key, its title cut short, and its status as
13
13
 
14
14
  - **ready** — a link the app has looked up. Hovering it shows its card (**LinkPreview**); a tap or a click opens it.
15
15
  - **loading** — still being looked up: the icon, which the address already says, and a bar.
16
- - **unavailable** — deleted, or not the reader's to see. Both say "Issue not available" in the app's word for it.
16
+ - **unavailable** — not the reader's to see: "Issue not available", in the app's word for it (its type's, else its app's name).
17
+ - **deleted** — `deleted` on the state, when a trusted deletion names it (SPEC §13.6.1): "Issue deleted". A reader tells the two apart; the words never say which a hidden file is.
18
+ - **written as a URL** — `url` on the state: a link written as an app URL that cannot be shown stays that URL, a plain link, deleted or not available alike (SPEC §13.1). The words above are only for a `nostr:` reference.
17
19
  - `preview={false}` — no card on hover, where a card would cover what the reader is choosing from.
20
+ - **no address** — an empty `linked.href` (another app's file with none over https): a label, not a link.
18
21
 
19
22
  <Canvas of={LinkChipStories.EachKind} />
23
+ <Canvas of={LinkChipStories.Deleted} />
24
+ <Canvas of={LinkChipStories.WrittenAsAUrl} />
20
25
 
21
26
  ## When not
22
27
 
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import { LinkChip } from './LinkChip'
3
- import { GROUP, ITEM, LOADING, PAGE, PLACE, ready, SAID, UNAVAILABLE } from './linked.examples'
3
+ import { DELETED, GROUP, ITEM, LOADING, PAGE, PLACE, ready, SAID, UNAVAILABLE, WRITTEN_AS_A_URL } from './linked.examples'
4
4
 
5
5
  const meta = {
6
6
  title: 'Links & references/LinkChip',
@@ -38,3 +38,9 @@ export const NotAvailable: Story = { args: { link: UNAVAILABLE } }
38
38
 
39
39
  /** No card on hover: where a card would cover what the reader is choosing from. */
40
40
  export const WithoutPreview: Story = { args: { preview: false } }
41
+
42
+ /** Deleted, as a trusted deletion naming it says: told apart from not available. */
43
+ export const Deleted: Story = { args: { link: DELETED } }
44
+
45
+ /** Written as a URL that cannot be shown: it stays that URL, a plain link, as a message draws one. */
46
+ export const WrittenAsAUrl: Story = { args: { link: WRITTEN_AS_A_URL } }
@@ -63,6 +63,18 @@ describe('LinkChip', () => {
63
63
  expect(screen.queryByRole('link')).toBeNull()
64
64
  })
65
65
 
66
+ it('is a label, not a link, for a file with no address to open', () => {
67
+ const { container } = render(<LinkChip link={{ state: 'ready', linked: { id: 'x', kind: 'file', title: 'Item one', href: '' } }} preview={false} />)
68
+ expect(container.querySelector('a')).toBeNull()
69
+ expect(screen.getByText('Item one')).toBeTruthy()
70
+ })
71
+
72
+ it('says it was deleted, apart from not available, and leads nowhere', () => {
73
+ render(<LinkChip link={{ state: 'unavailable', kind: 'issue', noun: 'Issue', deleted: true }} />)
74
+ expect(screen.getByText('Issue deleted')).toBeTruthy()
75
+ expect(screen.queryByRole('link')).toBeNull()
76
+ })
77
+
66
78
  it('shows its card, read only, when the pointer rests on it', async () => {
67
79
  screenThatCanHover(true)
68
80
  render(<LinkChip link={ready(ITEM)} />)
package/src/LinkChip.tsx CHANGED
@@ -14,6 +14,7 @@ import type { LinkState } from './linked'
14
14
  import { chosenOf } from './linked'
15
15
  import { LinkedIcon, LinkKey, StatusMark } from './LinkParts'
16
16
  import { LinkPreview } from './LinkPreview'
17
+ import { WrittenUrl } from './LinkRow'
17
18
  import { SkeletonBar } from './Skeleton'
18
19
 
19
20
  export interface LinkChipProps {
@@ -31,9 +32,11 @@ export function LinkChip({ link, preview = true }: LinkChipProps) {
31
32
  )
32
33
  }
33
34
  if (link.state === 'unavailable') {
35
+ // Written as a URL, it stays that URL (SPEC §13.1); only a `nostr:` reference says why it is not shown.
36
+ if (link.url) return <WrittenUrl url={link.url} />
34
37
  return (
35
38
  <InlineChip tone="muted" icon={<LinkedIcon kind={link.kind} size={14} tone="inherit" />}>
36
- {link.noun} not available
39
+ {link.noun} {link.deleted ? 'deleted' : 'not available'}
37
40
  </InlineChip>
38
41
  )
39
42
  }
@@ -43,7 +46,8 @@ export function LinkChip({ link, preview = true }: LinkChipProps) {
43
46
  const chip = (
44
47
  <InlineChip
45
48
  icon={said ? <Avatar name={said.name} src={said.picture} size={14} /> : <LinkedIcon kind={linked.kind} size={14} tone="inherit" />}
46
- href={linked.href}
49
+ // No address to open (another app's file with none over https): a label, not a link to nowhere.
50
+ href={linked.href || undefined}
47
51
  // Never wider than its line. With its hover card, the card's wrapper holds it to the line (max-w-full): a share of the
48
52
  // line on the chip itself made the wrapper as wide as the whole title, and left a gap after the cut-short chip
49
53
  // (Katerina, 29 Oct). Without one, it holds itself, less its own 2px each side.
package/src/LinkChips.mdx CHANGED
@@ -14,8 +14,9 @@ recognise, or has not answered for yet, stays text.
14
14
  ## When
15
15
 
16
16
  - **An editor of a document whose URLs can name things**: pair it with
17
- **ReferenceNode**, which draws the chip, and **ReferenceCards**, which places
18
- the card a chip can ask for.
17
+ **ReferenceNode**, which draws the chip, **LinkPlaces**, which draws a lone
18
+ link as its row or its card, and **ReferenceMenu**, where its writer chooses
19
+ between them. **DocumentEditor** has all of them.
19
20
 
20
21
  ## When not
21
22
 
@@ -29,7 +30,7 @@ recognise, or has not answered for yet, stays text.
29
30
  ## How
30
31
 
31
32
  ```tsx
32
- import { LinkChips, ReferenceCards, ReferenceNode } from '@estiva-app/ui/editor'
33
+ import { LinkChips, LinkPlaces, ReferenceMenu, ReferenceNode } from '@estiva-app/ui/editor'
33
34
 
34
35
  LinkChips.configure({
35
36
  // What the app has resolved so far: the reference a URL names, or undefined.
@@ -5,7 +5,7 @@ import { BlockId, ReferenceNode, type ReferenceViewProps } from './BlockNodes'
5
5
  import { Card } from './Card'
6
6
  import { InlineChip } from './InlineChip'
7
7
  import { LinkChips } from './LinkChips'
8
- import { ReferenceCards } from './ReferenceCards'
8
+ import { LinkPlaces } from './LinkPlaces'
9
9
  import { richTextClassName } from './RichText'
10
10
 
11
11
  /**
@@ -35,7 +35,7 @@ function Box() {
35
35
  StarterKit.configure({ link: false }),
36
36
  BlockId,
37
37
  ReferenceNode.configure({ view: Placeholder }),
38
- ReferenceCards,
38
+ LinkPlaces,
39
39
  LinkChips.configure({
40
40
  referenceOf: (url) => answered.get(url),
41
41
  ask: (urls) =>
@@ -10,7 +10,7 @@ import { TextSelection } from '@tiptap/pm/state'
10
10
  import StarterKit from '@tiptap/starter-kit'
11
11
  import { BlockId, ReferenceNode } from './BlockNodes'
12
12
  import { LinkChips, refreshLinkChips } from './LinkChips'
13
- import { ReferenceCards, referenceAtSelection, referenceCardPlacements } from './ReferenceCards'
13
+ import { referenceAtSelection, referenceCardPlacements } from './ReferenceCards'
14
14
 
15
15
  const URL_ = 'https://app.example/i/one'
16
16
  const V = 'nostr:naddr1example'
@@ -32,7 +32,6 @@ const make = (content: Record<string, unknown>, known: Map<string, string>, aske
32
32
  StarterKit.configure({ link: false }),
33
33
  BlockId,
34
34
  ReferenceNode,
35
- ReferenceCards,
36
35
  LinkChips.configure({
37
36
  referenceOf: (url) => known.get(url),
38
37
  ask: (urls) => {
package/src/LinkChips.ts CHANGED
@@ -176,7 +176,8 @@ export function refreshLinkChips(editor: Editor): void {
176
176
 
177
177
  /**
178
178
  * Turns the app URLs in a document into URL chips. Pair it with `ReferenceNode`;
179
- * `ReferenceCards` then draws a card a URL chip asks for.
179
+ * `LinkPlaces` then draws a lone one as its row or its card, and
180
+ * `ReferenceMenu` lets its writer choose.
180
181
  */
181
182
  export const LinkChips = Extension.create<LinkChipsOptions>({
182
183
  name: 'linkChips',
package/src/LinkParts.mdx CHANGED
@@ -11,13 +11,14 @@ The small parts the link widgets are built from: the pickers, the conversation c
11
11
 
12
12
  ## When
13
13
 
14
- - **LinkPickers** — a status and an owner, changed in place. A picker with no `onChange`, or `readOnly`, reads as words in the same place.
15
- - **CommentCount** — how much was said, as a link to where it is read; brighter, with a dot, when there is something unread for a member.
14
+ - **LinkPickers** — a status and an owner, changed in place. A picker with no `onChange`, or `readOnly`, reads as words in the same place. Nobody — no owner, or the option whose value is `''`, "Unassigned" — is the silhouette, never a letter.
15
+ - **CommentCount** — how much was said, as a link to where it is read; brighter, with a dot, when there is something unread for a member. In a box being written in, or with nowhere to open (an empty `href`), the count alone, no link. A screen reader hears it whole: "1 comment", "3 comments" (`noun` is the plural; one is its singular).
16
16
  - **StatusMark** — a status as its shape, which reads without colour; its words on hover.
17
17
  - **ProgressRing** — how far along, as a ring and a count.
18
18
  - **LinkedIcon**, **LinkKey** — the icon for what a link stands for, and its key.
19
19
 
20
20
  <Canvas of={LinkPartsStories.PickersReadOnly} />
21
+ <Canvas of={LinkPartsStories.Unassigned} />
21
22
  <Canvas of={LinkPartsStories.Conversation} />
22
23
  <Canvas of={LinkPartsStories.Marks} />
23
24
 
@@ -37,6 +37,14 @@ export const NoOwner: Story = {
37
37
  args: { status: { value: 'todo', options: STATUS_OPTIONS }, owner: { value: undefined, options: PEOPLE } },
38
38
  }
39
39
 
40
+ /** "Unassigned" as an owner the reader may pick: the silhouette, never a letter, in the picker and its list. */
41
+ export const Unassigned: Story = {
42
+ render: () => {
43
+ const [owner, setOwner] = useState('')
44
+ return <LinkPickers owner={{ value: owner, options: [{ value: '', label: 'Unassigned' }, ...PEOPLE], onChange: setOwner }} ownerLabel="Owner" />
45
+ },
46
+ }
47
+
40
48
  /** The count of what was said, opening where it is read. With something unread, to a member: brighter, with a dot. */
41
49
  export const Conversation: Story = {
42
50
  render: () => (
package/src/LinkParts.tsx CHANGED
@@ -4,12 +4,13 @@
4
4
  * count with its unread dot, and the pickers. LinkChip, LinkRow and LinkCard
5
5
  * place them; an app may place them too.
6
6
  */
7
+ import { useContext } from 'react'
7
8
  import { IconCircle, IconCircleCheck, IconCircleDashed, IconCircleHalf2, IconCircleX, IconFileText, IconMessage2 } from '@tabler/icons-react'
8
9
  import { Avatar } from './Avatar'
9
10
  import { cn } from './cn'
10
11
  import { KindIcon } from './KindIcon'
11
12
  import { Link } from './Link'
12
- import { chosenOf, type Linked, type LinkedConversation, type LinkedKind, type LinkedPicker, type LinkedStatus, type StatusColour } from './linked'
13
+ import { chosenOf, inTheBox, type Linked, type LinkedConversation, type LinkedKind, type LinkedPicker, type LinkedStatus, type StatusColour } from './linked'
13
14
  import { TYPE_TILE_CLASSES } from './looks'
14
15
  import { Select } from './Select'
15
16
  import { WithTooltip } from './Tooltip'
@@ -92,14 +93,41 @@ export function ProgressRing({ done, total }: { done: number; total: number }) {
92
93
  )
93
94
  }
94
95
 
96
+ /**
97
+ * A count in words, as the kit says one elsewhere ("3 members"): `noun` is the
98
+ * plural, and one is its singular — "1 comment", "1 conversation", "1 reply".
99
+ */
100
+ function countWords(count: number, noun: string): string {
101
+ if (count !== 1) return `${count} ${noun}`
102
+ const one = /ies$/.test(noun) ? noun.replace(/ies$/, 'y') : noun.replace(/s$/, '')
103
+ return `${count} ${one}`
104
+ }
105
+
95
106
  /**
96
107
  * The count of what was said, a link to where it is read. With something
97
108
  * unread there the words are brighter and a dot follows. It sits above a
98
109
  * row's covering link, so the row opens the thing and the count its
99
- * conversation.
110
+ * conversation. In a box being written in it is the count alone, no link: the
111
+ * draft is not left for it (Katerina, 30 Oct); and so it is where the app gives
112
+ * it nowhere to open (an empty `href`).
113
+ *
114
+ * A screen reader hears it whole, "3 comments — open the conversation": the
115
+ * figure drawn is hidden from it, so it never runs into the noun ("3comments").
100
116
  */
101
117
  export function CommentCount({ conversation, noun = 'comments' }: { conversation: LinkedConversation; noun?: string }) {
102
118
  const { count, href, unread = false } = conversation
119
+ const boxed = useContext(inTheBox)
120
+ const said = countWords(count, noun)
121
+ if (boxed || !href) {
122
+ return (
123
+ <span className={cn('inline-flex h-6 shrink-0 items-center gap-1 px-1.5 text-small tabular-nums', unread ? 'font-medium text-text-primary' : 'text-text-secondary')}>
124
+ <IconMessage2 size={14} stroke={1.5} aria-hidden />
125
+ <span aria-hidden>{count}</span>
126
+ <span className="sr-only">{unread ? `${said}, unread` : said}</span>
127
+ {unread && <UnreadDot className="h-auto w-auto" />}
128
+ </span>
129
+ )
130
+ }
103
131
  return (
104
132
  /*
105
133
  * A small button's shape, as Button's small one is: 24px tall like the pickers beside it, 6px each side, its corners
@@ -111,8 +139,8 @@ export function CommentCount({ conversation, noun = 'comments' }: { conversation
111
139
  <span className={cn('relative z-10 inline-flex h-6 shrink-0 rounded-md text-small tabular-nums transition-colors hover:bg-bg-hover', unread ? 'font-medium text-text-primary' : 'text-text-secondary')}>
112
140
  <Link href={href} variant="plain" className="flex h-full items-center gap-1 px-1.5">
113
141
  <IconMessage2 size={14} stroke={1.5} aria-hidden />
114
- {count}
115
- <span className="sr-only">{unread ? `${noun}, unread — open the conversation` : `${noun} — open the conversation`}</span>
142
+ <span aria-hidden>{count}</span>
143
+ <span className="sr-only">{unread ? `${said}, unread — open the conversation` : `${said} — open the conversation`}</span>
116
144
  {unread && <UnreadDot className="h-auto w-auto" />}
117
145
  </Link>
118
146
  </span>
@@ -128,6 +156,12 @@ export interface LinkPickersProps {
128
156
  readOnly?: boolean
129
157
  }
130
158
 
159
+ /** The face for an owner option: nobody (value `''`, "Unassigned") is the silhouette, never a letter (Katerina, 30 Oct). */
160
+ function OwnerFace({ option }: { option: { value: string; label: string; picture?: string } | undefined }) {
161
+ const nobody = !option || option.value === ''
162
+ return <Avatar name={nobody ? undefined : option.label} src={nobody ? undefined : option.picture} size={16} />
163
+ }
164
+
131
165
  /**
132
166
  * A status and an owner, where the reader can change them from the card. A
133
167
  * picker whose app passed no `onChange` reads as words in the same place: the
@@ -162,7 +196,7 @@ export function LinkPickers({ status, owner, ownerLabel = 'Owner', readOnly = fa
162
196
  {owner &&
163
197
  (ownerWords ? (
164
198
  <span className="inline-flex min-w-0 items-center gap-1">
165
- <Avatar name={ownerNow?.label} src={ownerNow?.picture} size={16} />
199
+ <OwnerFace option={ownerNow} />
166
200
  <span className="truncate">{ownerNow?.label ?? 'Unassigned'}</span>
167
201
  </span>
168
202
  ) : (
@@ -174,7 +208,7 @@ export function LinkPickers({ status, owner, ownerLabel = 'Owner', readOnly = fa
174
208
  placeholder="Unassigned"
175
209
  onChange={(value) => owner.onChange?.(value)}
176
210
  ariaLabel={ownerLabel}
177
- options={owner.options.map((option) => ({ value: option.value, label: option.label, leading: <Avatar name={option.label} src={option.picture} size={16} /> }))}
211
+ options={owner.options.map((option) => ({ value: option.value, label: option.label, leading: <OwnerFace option={option} /> }))}
178
212
  />
179
213
  ))}
180
214
  </span>
@@ -53,6 +53,9 @@ const editor = useEditor({ extensions: [StarterKit, BlockId, ReferenceNode.confi
53
53
  - **The same rule as the protocol's** `documentLineDrawOf`, read off the
54
54
  editor's tree on every change; a test holds the two to one answer.
55
55
  - **A row or a card is the whole line**: its view's wrapper is a block.
56
+ - **`editing` is true while the editor is editable**, or with
57
+ `ReferenceNode`'s `editingLine` only while the caret is on the link's line,
58
+ as `DocumentEditor` has it: elsewhere the chip and the row preview.
56
59
 
57
60
  ## What it owns
58
61
 
package/src/LinkPlaces.ts CHANGED
@@ -27,6 +27,8 @@ import { Extension } from '@tiptap/core'
27
27
  import type { Node as PmNode } from '@tiptap/pm/model'
28
28
  import { Plugin, PluginKey } from '@tiptap/pm/state'
29
29
  import { Decoration, DecorationSet } from '@tiptap/pm/view'
30
+ import { thingKindOf } from './KindIcon'
31
+ import type { LinkedKind } from './linked'
30
32
 
31
33
  /** How a reference draws: its chip, its row, or its card in the row's place. */
32
34
  export type LinkPlace = 'chip' | 'row' | 'card'
@@ -76,6 +78,23 @@ function naddrKind(naddr: string): number | null {
76
78
  /** A Folder's kind. */
77
79
  const FOLDER = 39000
78
80
 
81
+ /** A document's kind: it draws a page, as `linkedFrom` draws it. */
82
+ const PAGE = 30842
83
+
84
+ /**
85
+ * What a `nostr:` reference names, by the icon it draws, read off its address
86
+ * alone: a message (`nevent`, `note`), a file by its kind (`naddr`, a document
87
+ * a page), or undefined for what has no kind icon (a person, anything else).
88
+ */
89
+ export function linkedKindOfReference(uri: string): LinkedKind | undefined {
90
+ const bare = uri.toLowerCase().replace(/^nostr:/, '')
91
+ if (bare.startsWith('nevent1') || bare.startsWith('note1')) return 'message'
92
+ if (!bare.startsWith('naddr1')) return undefined
93
+ const kind = naddrKind(bare)
94
+ if (kind === null) return undefined
95
+ return kind === PAGE ? 'page' : thingKindOf(kind)
96
+ }
97
+
79
98
  /**
80
99
  * Whether what `uri` names stays a chip alone on its line: a person (`npub`,
81
100
  * `nprofile`) or a Folder (an `naddr` of kind 39000).
package/src/LinkRow.mdx CHANGED
@@ -12,13 +12,19 @@ A link alone on its line: its kind in a file's tile, the title and its key under
12
12
  ## When
13
13
 
14
14
  - **ready** — its kind in the 36px tile a file's type has (**AttachmentCard**), the title as the link, and under it the key and what it is ("ABC-2 · Issue"), in the app's word for it, else its kind's. On the title's line: its status or its ring, its comment count, then the owner, members or authors at the far right. Hovering it shows its card; a tap opens it.
15
- - **words a person wrote** — their face in the tile, their name with the time beside it, and the words under them.
15
+ - **ready** and archived — `linked.archived`: "Archived" in the line under the title ("ABC-2 · Issue · Archived"). `linkStateFrom` sets it, and words for its values, from an archived file.
16
+ - **words a person wrote** — on one line, as a quote is cut to one: their face in the tile, their name, the words cut to fit, the time.
16
17
  - **width** — at most 480px, in a box being written in too.
17
18
  - **unread** — the count is brighter, with its dot.
18
19
  - **loading** — the row in bars, in the row's own shape.
19
20
  - **unavailable** — a row's shape, "Issue not available", with where it may still open (`openIn`). This is also what a card draws when it is not available: **LinkUnavailable**, from this file.
21
+ - **deleted** — `deleted` on the state, when a trusted deletion names it (SPEC §13.6.1): the same row, "Issue deleted", and no way out.
22
+ - **written as a URL** — `url` on the state: the URL as it was written, a plain link in the row's place, deleted or not available alike (SPEC §13.1).
20
23
 
21
24
  <Canvas of={LinkRowStories.NotAvailable} />
25
+ <Canvas of={LinkRowStories.Deleted} />
26
+ <Canvas of={LinkRowStories.WordsAPersonWrote} />
27
+ <Canvas of={LinkRowStories.Archived} />
22
28
 
23
29
  ## When not
24
30
 
@@ -33,7 +39,7 @@ import { LinkRow } from '@estiva-app/ui'
33
39
  <LinkRow link={{ state: 'ready', linked }} />
34
40
  ```
35
41
 
36
- - The whole row opens `linked.href`; the conversation count opens `linked.conversation.href` on its own.
42
+ - The whole row opens `linked.href`; the conversation count opens `linked.conversation.href` on its own. With no address (an empty `href`, as for another app's file with none over https), its title, or its count, is words and not a link.
37
43
  - `linked.conversation.unread` is the app's to say, and only for a member of it.
38
44
 
39
45
  ## What it owns
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { GROUP, ITEM, ITEM_UNREAD, LOADING, PAGE, PLACE, ready, SAID, UNAVAILABLE } from './linked.examples'
2
+ import { DELETED, GROUP, ITEM, ITEM_ARCHIVED, ITEM_UNREAD, LOADING, PAGE, PLACE, ready, SAID, UNAVAILABLE, WRITTEN_AS_A_URL } from './linked.examples'
3
3
  import { LinkRow, LinkUnavailable } from './LinkRow'
4
4
 
5
5
  const meta = {
@@ -32,12 +32,24 @@ export const EachKind: Story = {
32
32
  /** Something unread in its conversation, to a member: the count shows, with its dot. */
33
33
  export const Unread: Story = { args: { link: ready(ITEM_UNREAD) } }
34
34
 
35
+ /** Words a person wrote, on one line: their face, their name, the words cut to fit, the time. */
36
+ export const WordsAPersonWrote: Story = { args: { link: ready(SAID) } }
37
+
38
+ /** Archived: "Archived" in the line under its title. */
39
+ export const Archived: Story = { args: { link: ready(ITEM_ARCHIVED) } }
40
+
35
41
  /** Still being looked up: the row in bars, at the row's height. */
36
42
  export const Loading: Story = { args: { link: LOADING } }
37
43
 
38
- /** Deleted, or not this reader's to see: one line, and where it may still open. */
44
+ /** Not this reader's to see: one line, and where it may still open. */
39
45
  export const NotAvailable: Story = { args: { link: UNAVAILABLE } }
40
46
 
47
+ /** Deleted, as a trusted deletion naming it says: the same line, its own words, and no way out. */
48
+ export const Deleted: Story = { args: { link: DELETED } }
49
+
50
+ /** Written as a URL that cannot be shown: it stays that URL, a plain link, in the row's place. */
51
+ export const WrittenAsAUrl: Story = { args: { link: WRITTEN_AS_A_URL } }
52
+
41
53
  /** The not-available line on its own, as a card or a part draws it too; without `openIn`, no way out. */
42
54
  export const NotAvailableLine: Story = {
43
55
  render: () => (