@estiva-app/ui 0.102.1 → 0.103.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.
- package/dist/CommentBox.d.ts +16 -0
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConfirmDialog.d.ts +6 -1
- package/dist/ConfirmDialog.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +2 -0
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/LinkChip.d.ts.map +1 -1
- package/dist/LinkRow.d.ts +13 -3
- package/dist/LinkRow.d.ts.map +1 -1
- package/dist/QuotedLine.d.ts +1 -1
- package/dist/QuotedLine.d.ts.map +1 -1
- package/dist/SectionHeader.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +14 -6
- package/dist/editor.js.map +3 -3
- package/dist/index.js +32 -22
- package/dist/index.js.map +2 -2
- package/dist/linked.d.ts +3 -1
- package/dist/linked.d.ts.map +1 -1
- package/dist/linkedFrom.d.ts +1 -0
- package/dist/linkedFrom.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +33 -3
- package/src/CommentBox.mdx +1 -0
- package/src/CommentBox.stories.tsx +17 -1
- package/src/CommentBox.test.tsx +24 -0
- package/src/CommentBox.tsx +29 -1
- package/src/ConfirmDialog.mdx +2 -0
- package/src/ConfirmDialog.stories.tsx +6 -0
- package/src/ConfirmDialog.test.tsx +12 -1
- package/src/ConfirmDialog.tsx +8 -1
- package/src/ConversationCard.mdx +2 -0
- package/src/ConversationCard.stories.tsx +6 -0
- package/src/ConversationCard.test.tsx +50 -0
- package/src/ConversationCard.tsx +13 -7
- package/src/LinkCard.stories.tsx +6 -0
- package/src/LinkCard.tsx +1 -1
- package/src/LinkChip.test.tsx +13 -2
- package/src/LinkChip.tsx +4 -3
- package/src/LinkRow.test.tsx +13 -0
- package/src/LinkRow.tsx +16 -7
- package/src/NavTree.stories.tsx +1 -1
- package/src/QuotedLine.mdx +2 -1
- package/src/QuotedLine.test.tsx +9 -0
- package/src/QuotedLine.tsx +4 -2
- package/src/SectionHeader.mdx +1 -0
- package/src/SectionHeader.test.tsx +7 -0
- package/src/SectionHeader.tsx +4 -1
- package/src/editor.ts +1 -0
- package/src/linked.ts +3 -1
- package/src/linkedFrom.test.tsx +15 -3
- package/src/linkedFrom.ts +5 -3
package/src/LinkRow.test.tsx
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
4
4
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
5
5
|
import { DELETED, ITEM, ITEM_UNREAD, LOADING, PLACE, ready, SAID, UNAVAILABLE } from './linked.examples'
|
|
6
|
+
import { LinkCard } from './LinkCard'
|
|
7
|
+
import type { LinkState } from './linked'
|
|
6
8
|
import { LinkRow } from './LinkRow'
|
|
7
9
|
|
|
8
10
|
afterEach(cleanup)
|
|
@@ -53,6 +55,17 @@ describe('LinkRow', () => {
|
|
|
53
55
|
expect(screen.getByText('3 comments')).toBeTruthy()
|
|
54
56
|
})
|
|
55
57
|
|
|
58
|
+
// Miky, 3 November: a failed read is not an answer about access.
|
|
59
|
+
it('says a failed read could not load, never that you cannot open it, in a row and a card alike', () => {
|
|
60
|
+
const failed: LinkState = { state: 'unavailable', kind: 'issue', noun: 'Issue', failed: true }
|
|
61
|
+
const { rerender } = render(<LinkRow link={failed} />)
|
|
62
|
+
expect(screen.getByText("Couldn't load this issue")).toBeTruthy()
|
|
63
|
+
expect(screen.queryByText(/can't open/)).toBeNull()
|
|
64
|
+
rerender(<LinkCard link={failed} />)
|
|
65
|
+
expect(screen.getByText("Couldn't load this issue")).toBeTruthy()
|
|
66
|
+
expect(screen.queryByRole('link')).toBeNull()
|
|
67
|
+
})
|
|
68
|
+
|
|
56
69
|
it('says it was deleted, apart from not available, with no way out', () => {
|
|
57
70
|
render(<LinkRow link={DELETED} />)
|
|
58
71
|
expect(screen.getByText('Issue deleted')).toBeTruthy()
|
package/src/LinkRow.tsx
CHANGED
|
@@ -24,8 +24,10 @@ export interface LinkUnavailableProps {
|
|
|
24
24
|
kind: LinkedKind
|
|
25
25
|
/** What it is, in a word: "Issue". Drawn as "You can't open this issue", or "Issue deleted". */
|
|
26
26
|
noun: string
|
|
27
|
-
/** `noun` is its app's name ("App one"), its type having none:
|
|
27
|
+
/** `noun` is its app's name ("App one"), its type having none: "You can't open this file in App one". */
|
|
28
28
|
named?: boolean
|
|
29
|
+
/** Its read failed (the network, a busy relay), which says nothing about access: "Couldn't load this issue". */
|
|
30
|
+
failed?: boolean
|
|
29
31
|
/** @deprecated Not drawn since 0.102.0: someone who can't open it has nowhere to go. */
|
|
30
32
|
openIn?: { app: string; href: string }
|
|
31
33
|
/** In a card's place: a card's 12px round it. Default a row's. */
|
|
@@ -43,12 +45,19 @@ const ROW_CLASSES = 'flex items-center gap-3 p-1.5 pr-3'
|
|
|
43
45
|
* would have been, on the same fill and edge (Katerina, 29 Oct: "same styling
|
|
44
46
|
* as the linkcard default"), its words muted. Not this reader's: "You can't
|
|
45
47
|
* open this issue", the approved story's words, with no way out, since there
|
|
46
|
-
* is nothing for them to open (Miky, ALO-4's review, 3 November).
|
|
48
|
+
* is nothing for them to open (Miky, ALO-4's review, 3 November). A read that
|
|
49
|
+
* failed says "Couldn't load this issue" instead: it is not an answer about
|
|
50
|
+
* access (Miky, 3 November).
|
|
47
51
|
*/
|
|
48
|
-
export function LinkUnavailable({ kind, noun, named = false, card = false, deleted = false }: LinkUnavailableProps) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
export function LinkUnavailable({ kind, noun, named = false, card = false, deleted = false, failed = false }: LinkUnavailableProps) {
|
|
53
|
+
return <UnavailableRow kind={kind} words={unavailableWords(noun, { named, deleted, failed })} card={card} />
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** What a link that can't be opened says, row, card and chip alike: "You can't open this issue", "Couldn't load this issue", "Issue deleted". */
|
|
57
|
+
export function unavailableWords(noun: string, { named = false, deleted = false, failed = false }: { named?: boolean; deleted?: boolean; failed?: boolean } = {}): string {
|
|
58
|
+
// A word ("Issue") reads in the sentence in small letters; an app's name is where the file lives: "file in Peek".
|
|
59
|
+
const word = named ? `file in ${noun}` : /^[A-Z][a-z]*$/.test(noun) ? noun.toLowerCase() : noun
|
|
60
|
+
return deleted ? `${named ? `File in ${noun}` : noun} deleted` : failed ? `Couldn't load this ${word}` : `You can't open this ${word}`
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
/** The not-available row with the words it is given; `href` makes the words a link (a part that can't be shown opens its whole file). */
|
|
@@ -117,7 +126,7 @@ export function LinkRow({ link, preview = true }: LinkRowProps) {
|
|
|
117
126
|
}
|
|
118
127
|
if (link.state === 'unavailable') {
|
|
119
128
|
if (link.url) return <WrittenUrl url={link.url} block />
|
|
120
|
-
return <LinkUnavailable kind={link.kind} noun={link.noun} named={link.named} deleted={link.deleted} />
|
|
129
|
+
return <LinkUnavailable kind={link.kind} noun={link.noun} named={link.named} deleted={link.deleted} failed={link.failed} />
|
|
121
130
|
}
|
|
122
131
|
const { linked } = link
|
|
123
132
|
const status = chosenOf(linked.status)
|
package/src/NavTree.stories.tsx
CHANGED
|
@@ -36,7 +36,7 @@ const GROUPS: NavTreeGroup[] = [
|
|
|
36
36
|
{ id: 'f', label: 'An item with a hint and a count', href: '#', icon: placeholder, hint, count: 12, countLabel: '12 open' },
|
|
37
37
|
],
|
|
38
38
|
},
|
|
39
|
-
{ id: 'g3', title: '
|
|
39
|
+
{ id: 'g3', title: 'A group whose name runs longer than the column, cut short', nodes: [{ id: 'g', label: 'Item six', href: '#', icon: placeholder }] },
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
const meta = {
|
package/src/QuotedLine.mdx
CHANGED
|
@@ -12,6 +12,7 @@ On a comment on a part of the page: the words it is on, in the page's own highli
|
|
|
12
12
|
## When
|
|
13
13
|
|
|
14
14
|
- On a **ConversationCard** about a part of the page, in its `about`.
|
|
15
|
+
- Above a **CommentBox** whose new comment will be on that part, in its `about`: the same line the posted card will carry.
|
|
15
16
|
|
|
16
17
|
<Canvas of={Stories.Reworded} />
|
|
17
18
|
|
|
@@ -32,7 +33,7 @@ import { ConversationCard, QuotedLine } from '@estiva-app/ui'
|
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
- Two lines at most; the whole words are in the tooltip.
|
|
35
|
-
- A part with no words, a picture or a block: `label`, its name in your words.
|
|
36
|
+
- A part with no words, a picture or a block: `label`, its name in your words, on the grey: the yellow is only for words still in the page.
|
|
36
37
|
- Made for the card's `about`: the card puts it under the name, where the words start.
|
|
37
38
|
|
|
38
39
|
## What it owns
|
package/src/QuotedLine.test.tsx
CHANGED
|
@@ -31,4 +31,13 @@ describe('QuotedLine', () => {
|
|
|
31
31
|
expect(screen.getByText('Picture: plan-sketch.png')).toBeTruthy()
|
|
32
32
|
expect(container.querySelector('[data-quoted="part"]')).not.toBeNull()
|
|
33
33
|
})
|
|
34
|
+
|
|
35
|
+
// Yellow means "these words are in the page"; a block's name is not (Katerina, 3 November: grey, not yellow).
|
|
36
|
+
it('draws a part’s name on the grey, never the page’s yellow', () => {
|
|
37
|
+
render(<QuotedLine label="On the paragraph" />)
|
|
38
|
+
const mark = screen.getByText('On the paragraph')
|
|
39
|
+
expect(mark.className).not.toMatch(/\bbg-warning-muted\b/)
|
|
40
|
+
expect(mark.className).toMatch(/\bbg-bg-inset\b/)
|
|
41
|
+
expect(mark.className).not.toMatch(/\bline-through\b/)
|
|
42
|
+
})
|
|
34
43
|
})
|
package/src/QuotedLine.tsx
CHANGED
|
@@ -16,15 +16,17 @@ const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as co
|
|
|
16
16
|
* What a comment on a part of the page is on: its words, two lines at most, in the page's own highlight, so the two
|
|
17
17
|
* read as one. ConversationCard puts it under the name, above the comment's words ("above the message, not above the
|
|
18
18
|
* person": Katerina, 1 November). Words changed since or deleted lose the highlight and say so; a part with no words
|
|
19
|
-
* gives its name.
|
|
19
|
+
* gives its name, on the grey: it is not words of the page.
|
|
20
20
|
*/
|
|
21
21
|
export function QuotedLine({ words, state = 'here', label }: QuotedLineProps) {
|
|
22
22
|
const shown = words ?? label ?? ''
|
|
23
|
+
// The page's yellow only for words still in it; a part's name is not words of the page, so it takes the grey (Katerina, 3 November).
|
|
24
|
+
const inThePage = !!words && state === 'here'
|
|
23
25
|
return (
|
|
24
26
|
<div data-quoted={words ? state : 'part'} className="flex w-full min-w-0 flex-col gap-0.5">
|
|
25
27
|
<WithTooltip label={shown} wrapperClassName="flex min-w-0">
|
|
26
28
|
<p className="line-clamp-2 text-caption text-text-secondary">
|
|
27
|
-
<mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]',
|
|
29
|
+
<mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', inThePage ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
|
|
28
30
|
</p>
|
|
29
31
|
</WithTooltip>
|
|
30
32
|
{state !== 'here' && <span className="text-caption italic text-text-muted">{SINCE[state]}</span>}
|
package/src/SectionHeader.mdx
CHANGED
|
@@ -93,6 +93,7 @@ It does these by itself. Write none of them around it.
|
|
|
93
93
|
| With `chevron`, its title is a button that calls `onToggle` on a click, Enter or Space, and says whether it is open | a button of your own, or `aria-expanded` | |
|
|
94
94
|
| Shows its actions while the keyboard is in the row — on the title or on one of them — and always on a screen with no hover | a focus style of your own | |
|
|
95
95
|
| Keeps its 32px in a scrolling column | `shrink-0` | |
|
|
96
|
+
| Keeps a long title on one line, cut short with "…", in every look | `truncate` around the title | |
|
|
96
97
|
|
|
97
98
|
## Keys
|
|
98
99
|
|
|
@@ -49,6 +49,13 @@ describe('SectionHeader', () => {
|
|
|
49
49
|
expect(screen.queryByRole('button')).toBeNull()
|
|
50
50
|
expect(screen.getByText('Section')).not.toBeNull()
|
|
51
51
|
})
|
|
52
|
+
|
|
53
|
+
// A Folder named by its id ran onto two lines in the sidebar (Katerina, 3 November). Chrome draws the cut (the NavTree story).
|
|
54
|
+
it.each(['heading', 'quiet', 'row'] as const)('a long title stays on one line, cut short, in the %s look', (look) => {
|
|
55
|
+
const name = '0f3c9a12-5b7e-4d21-9c8a-6e2f1b4d7a90'
|
|
56
|
+
render(<SectionHeader title={name} chevron look={look} />)
|
|
57
|
+
expect(screen.getByText(name).className.split(' ')).toEqual(expect.arrayContaining(['min-w-0', 'truncate']))
|
|
58
|
+
})
|
|
52
59
|
})
|
|
53
60
|
|
|
54
61
|
/**
|
package/src/SectionHeader.tsx
CHANGED
|
@@ -189,7 +189,10 @@ export function SectionHeader({ title, chevron = false, icon, isExpanded = true,
|
|
|
189
189
|
// A row's words: NavItem's size and colour, brightening under the pointer with the row.
|
|
190
190
|
<span className="min-w-0 flex-1 truncate text-body-2">{title}</span>
|
|
191
191
|
) : (
|
|
192
|
-
|
|
192
|
+
// One line, as the other looks and a NavItem's label: a Folder named by its id ran onto two (Katerina, 3 November).
|
|
193
|
+
<SectionLabel folds={chevron} truncate>
|
|
194
|
+
{title}
|
|
195
|
+
</SectionLabel>
|
|
193
196
|
)}
|
|
194
197
|
{/* 8px after the title with the 4px gap, in a row's count style. */}
|
|
195
198
|
{count != null && <span className={cn('ml-1 shrink-0', COUNT_TEXT_CLASSES)}>{count}</span>}
|
package/src/editor.ts
CHANGED
package/src/linked.ts
CHANGED
|
@@ -158,8 +158,10 @@ export type LinkState =
|
|
|
158
158
|
kind: LinkedKind
|
|
159
159
|
/** What it is, in a word: "Item". */
|
|
160
160
|
noun: string
|
|
161
|
-
/** `noun` is its app's name ("Notes"), its type having none:
|
|
161
|
+
/** `noun` is its app's name ("Notes"), its type having none: "You can't open this file in Notes". */
|
|
162
162
|
named?: boolean
|
|
163
|
+
/** Its read failed (the network, a busy relay): "Couldn't load this issue", which says nothing about access. */
|
|
164
|
+
failed?: boolean
|
|
163
165
|
/** @deprecated Not drawn since 0.102.0: someone who can't open it has nowhere to go (Miky, ALO-4's review). */
|
|
164
166
|
openIn?: { app: string; href: string }
|
|
165
167
|
/** Deleted, as a trusted deletion naming its address says (SPEC §13.6.1): "Issue deleted", with no way out. */
|
package/src/linkedFrom.test.tsx
CHANGED
|
@@ -233,12 +233,24 @@ describe('a file the reader cannot read', () => {
|
|
|
233
233
|
|
|
234
234
|
it('is named by its app when its type has no name, as the record a-file-is-labelled-by-its-type-not-its-app says', () => {
|
|
235
235
|
render(<LinkCard link={linkStateFrom({ ...GROUP, unreachable: true, appName: 'App one' }, { kind: 'file', noun: 'Record' }, options())} />)
|
|
236
|
-
expect(screen.getByText("You can't open this App one")).toBeTruthy()
|
|
236
|
+
expect(screen.getByText("You can't open this file in App one")).toBeTruthy()
|
|
237
237
|
})
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
// Miky, 3 November: nobody opens "a Peek"; the app is where the file lives.
|
|
240
|
+
it('says an app-named file is a file in that app, its name as written: "this file in Peek", never "this Peek"', () => {
|
|
240
241
|
render(<LinkCard link={linkStateFrom({ ...GROUP, unreachable: true, appName: 'Peek' }, { kind: 'file', noun: 'Record' }, options())} />)
|
|
241
|
-
expect(screen.getByText("You can't open this Peek")).toBeTruthy()
|
|
242
|
+
expect(screen.getByText("You can't open this file in Peek")).toBeTruthy()
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('says a read that failed could not load, from the same lookup, never that you cannot open it', () => {
|
|
246
|
+
render(<LinkCard link={linkStateFrom(null, { kind: 'file', noun: 'Record', failed: true }, options())} />)
|
|
247
|
+
expect(screen.getByText("Couldn't load this record")).toBeTruthy()
|
|
248
|
+
expect(screen.queryByText(/can't open/)).toBeNull()
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
it('says a deleted app-named file is a file in that app, never "Peek deleted"', () => {
|
|
252
|
+
render(<LinkCard link={{ state: 'unavailable', kind: 'file', noun: 'Peek', named: true, deleted: true }} />)
|
|
253
|
+
expect(screen.getByText('File in Peek deleted')).toBeTruthy()
|
|
242
254
|
})
|
|
243
255
|
|
|
244
256
|
it('reads as the address says while it loads and when nothing came back', () => {
|
package/src/linkedFrom.ts
CHANGED
|
@@ -321,19 +321,21 @@ export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFro
|
|
|
321
321
|
*/
|
|
322
322
|
export function linkStateFrom<T extends LinkedSource>(
|
|
323
323
|
object: T | null | undefined,
|
|
324
|
-
unread: { kind: LinkedKind; noun: string; deleted?: boolean; url?: string },
|
|
324
|
+
unread: { kind: LinkedKind; noun: string; deleted?: boolean; failed?: boolean; url?: string },
|
|
325
325
|
options: LinkedFromOptions<T>,
|
|
326
326
|
): LinkState {
|
|
327
327
|
if (object === undefined) return { state: 'loading', kind: unread.kind }
|
|
328
328
|
const written = unread.url ? { url: unread.url } : {}
|
|
329
|
-
|
|
329
|
+
// `failed`: the read failed (the network, a busy relay), so `null` is no answer: "Couldn't load this issue".
|
|
330
|
+
const why = unread.deleted ? { deleted: true } : unread.failed ? { failed: true } : {}
|
|
331
|
+
if (object === null) return { state: 'unavailable', kind: unread.kind, noun: unread.noun, ...why, ...written }
|
|
330
332
|
if (object.unreachable) {
|
|
331
333
|
const noun = nounOf(object)
|
|
332
334
|
return {
|
|
333
335
|
state: 'unavailable',
|
|
334
336
|
kind: linkedKindOfKind(object.kind),
|
|
335
337
|
noun: noun || unread.noun,
|
|
336
|
-
// Its app's name, its type having none: "You can't open this
|
|
338
|
+
// Its app's name, its type having none: "You can't open this file in Notes".
|
|
337
339
|
...(noun && !object.noun ? { named: true } : {}),
|
|
338
340
|
...written,
|
|
339
341
|
}
|