@estiva-app/ui 0.86.1 → 0.87.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.86.1",
3
+ "version": "0.87.1",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.86.1",
8
- "exports": 209,
7
+ "packageVersion": "0.87.1",
8
+ "exports": 210,
9
9
  "typeExports": 211,
10
10
  "files": null
11
11
  },
@@ -279,6 +279,25 @@
279
279
  "overflow-hidden rounded-2xl bg-bg-surface signal:border signal:border-border-subtle signal:shadow-highlight-inset"
280
280
  ]
281
281
  },
282
+ {
283
+ "name": "archivedLine",
284
+ "repo": "estiva-ui",
285
+ "kind": "helper",
286
+ "importPath": "@estiva-app/ui",
287
+ "sourceFile": "src/archivedLine.ts",
288
+ "purpose": "The line in the comment box's place on an archived file (CommentBox's `closed.reason`), in every app's words alike.",
289
+ "purposeFrom": "comment",
290
+ "props": [],
291
+ "variants": [],
292
+ "ownsBehaviours": [],
293
+ "status": "stable",
294
+ "migrationStage": null,
295
+ "docsId": null,
296
+ "storyId": null,
297
+ "docPage": null,
298
+ "app": null,
299
+ "looks": []
300
+ },
282
301
  {
283
302
  "name": "AttachmentCard",
284
303
  "repo": "estiva-ui",
@@ -134,6 +134,34 @@ describe('saving', () => {
134
134
  expect(editorOf().getText()).toBe('First line kept')
135
135
  })
136
136
 
137
+ it('closed while its save is out, a refused save is not sent again with the same text', async () => {
138
+ let answer: (ok: boolean) => void = () => {}
139
+ const onCommit = vi.fn<DocumentEditorProps['onCommit']>(() => new Promise<boolean>((resolve) => (answer = resolve)))
140
+ const { unmount } = render(<Doc onCommit={onCommit} />)
141
+ await type(' and more')
142
+ await leave()
143
+ expect(onCommit).toHaveBeenCalledTimes(1)
144
+ // The page goes while the relay has not answered: closing asks to save the same text again.
145
+ unmount()
146
+ await act(async () => answer(false))
147
+ await settle()
148
+ expect(onCommit).toHaveBeenCalledTimes(1)
149
+ })
150
+
151
+ it('a change made while a save is out is saved next', async () => {
152
+ let answer: (ok: boolean) => void = () => {}
153
+ const onCommit = vi.fn<DocumentEditorProps['onCommit']>(() => new Promise<boolean>((resolve) => (answer = resolve)))
154
+ render(<Doc onCommit={onCommit} />)
155
+ await type(' and more')
156
+ await leave()
157
+ await type('!')
158
+ await leave()
159
+ await act(async () => answer(true))
160
+ await settle()
161
+ expect(onCommit).toHaveBeenCalledTimes(2)
162
+ expect(saved(onCommit.mock.calls[1][0])).toEqual([{ id: 'a1', runs: [{ text: 'First line and more!', marks: [] }] }])
163
+ })
164
+
137
165
  it('Escape leaves, and so saves', async () => {
138
166
  const onCommit = vi.fn(async () => true)
139
167
  render(<Doc onCommit={onCommit} />)
@@ -283,8 +283,10 @@ export function DocumentEditor({
283
283
  setSaving(false)
284
284
  if (again.current) {
285
285
  again.current = false
286
- // After an ending it is held for after the tap, and a save would only be refused.
287
- if (!ended()) void latestSave.current(typed.current)
286
+ // After an ending it is held for after the tap, and a save would only be refused. Only a change: leaving
287
+ // while a blur's save is out asks again for the same text, and a refused one would be sent and said twice.
288
+ const waiting = typed.current
289
+ if (!ended() && waiting && latest.current.codec.write(waiting).value !== next.value) void latestSave.current(waiting)
288
290
  }
289
291
  }
290
292
  },
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The line in the comment box's place on an archived file names what to
3
+ * unarchive: the file itself, or the closest archived one above it by its kind
4
+ * (PEEKM-2, record a-file-is-archived-with-the-closest-archived-file-above-it).
5
+ */
6
+ import { describe, expect, it } from 'vitest'
7
+ import { archivedLine } from './archivedLine'
8
+
9
+ const ABOVE = '30023:aaaa:plan'
10
+
11
+ describe('archivedLine', () => {
12
+ it('says nothing for a file that is not archived', () => {
13
+ expect(archivedLine(undefined, 'page')).toBeUndefined()
14
+ })
15
+
16
+ it('tells a person to unarchive the file itself when it is archived itself', () => {
17
+ expect(archivedLine({}, 'page')).toBe('Archived. Unarchive it to comment.')
18
+ })
19
+
20
+ it('names the closest archived file above by its kind', () => {
21
+ expect(archivedLine({ with: ABOVE }, 'page')).toBe('Unarchive the page to comment.')
22
+ expect(archivedLine({ with: ABOVE }, 'project')).toBe('Unarchive the project to comment.')
23
+ expect(archivedLine({ with: ABOVE }, 'PDF')).toBe('Unarchive the PDF to comment.')
24
+ })
25
+
26
+ it('writes Folder as a proper noun', () => {
27
+ expect(archivedLine({ with: ABOVE }, 'folder')).toBe('Unarchive the Folder to comment.')
28
+ })
29
+
30
+ it('still says what to do when the app has no noun for what is above', () => {
31
+ expect(archivedLine({ with: ABOVE })).toBe('Unarchive the parent to comment.')
32
+ expect(archivedLine({ with: ABOVE }, ' ')).toBe('Unarchive the parent to comment.')
33
+ })
34
+ })
@@ -0,0 +1,24 @@
1
+ /**
2
+ * archivedLine, the one sentence every app shows on an archived file (PEEKM-2).
3
+ */
4
+
5
+ /**
6
+ * The line in the comment box's place on an archived file (CommentBox's
7
+ * `closed.reason`), in every app's words alike.
8
+ *
9
+ * A file archived itself says so; one archived with a file above it names the
10
+ * closest archived one by its kind — "Unarchive the page to comment." — so a
11
+ * person unarchives the right thing, and once it is unarchived the next one up
12
+ * is named. Which file that is comes from interop: `archive.with` is its
13
+ * address, and the app reads its noun.
14
+ *
15
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-file-is-archived-with-the-closest-archived-file-above-it.md
16
+ */
17
+ export function archivedLine(archive: { with?: string } | undefined, noun?: string): string | undefined {
18
+ if (!archive) return undefined
19
+ if (!archive.with) return 'Archived. Unarchive it to comment.'
20
+ // A noun arrives as the manifest wrote it; a Folder is a proper noun in every
21
+ // app's copy. With no noun, Peek's ArchivedNotice word.
22
+ const word = noun?.trim()
23
+ return `Unarchive the ${word === 'folder' ? 'Folder' : word || 'parent'} to comment.`
24
+ }
package/src/index.ts CHANGED
@@ -103,6 +103,7 @@ export {
103
103
  type StatusColour,
104
104
  type UnavailableMemory,
105
105
  } from './linked'
106
+ export { archivedLine } from './archivedLine'
106
107
  export {
107
108
  linkedFrom,
108
109
  linkStateFrom,
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
48
48
  expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
49
49
  })
50
50
 
51
- it('counts 209 names over 97 files: 139 components, 67 helpers and 3 hooks (keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
51
+ it('counts 210 names over 98 files: 139 components, 68 helpers and 3 hooks (archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
52
52
  // The reconciliation GATES.md §24 explains. If this changes, that changes.
53
53
  // The `EDITOR_EXTENSIONS` count as components by their names; they are
54
54
  // editor extensions, documented on SelectionToolbar's, BlockNodes' and
55
55
  // ComposerTriggers' pages.
56
56
  const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
57
- expect(kinds).toEqual({ component: 139, helper: 67, hook: 3 })
58
- expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(97)
57
+ expect(kinds).toEqual({ component: 139, helper: 68, hook: 3 })
58
+ expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(98)
59
59
  })
60
60
 
61
61
  it('gives every entry a purpose, from its own page or from the comment above it', () => {
62
62
  expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
63
63
  expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(90)
64
- expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(119)
64
+ expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(120)
65
65
  })
66
66
 
67
67
  it('takes a name with a page of its own from the page, and a name without one from the code', () => {
@@ -263,7 +263,7 @@ describe('the ids point at something', () => {
263
263
  it('gives every component a page and a story, and only a helper none', () => {
264
264
  const without = registry.entries.filter((one) => one.docsId === null || one.storyId === null)
265
265
  // The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), and the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's on LinkCard's).
266
- expect(without.map((one) => one.name).sort()).toEqual(['chosenOf', 'cn', 'isApplePlatform', 'isSuggestionActive', 'isSuggestionOpen', 'linkStateFrom', 'linkedFrom', 'loadingShapeOf', 'shortcutLabel', 'suggestionPopup', 'unavailableMemory'])
266
+ expect(without.map((one) => one.name).sort()).toEqual(['archivedLine', 'chosenOf', 'cn', 'isApplePlatform', 'isSuggestionActive', 'isSuggestionOpen', 'linkStateFrom', 'linkedFrom', 'loadingShapeOf', 'shortcutLabel', 'suggestionPopup', 'unavailableMemory'])
267
267
  expect(without.every((one) => one.kind !== 'component')).toBe(true)
268
268
  })
269
269