@estiva-app/ui 0.84.0 → 0.85.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.
@@ -596,11 +596,10 @@ describe('one search over the package and the apps', () => {
596
596
  root: app({ 'src/Composer.tsx': '/** Where a comment is written and sent. */\nexport function Composer() {\n return <form />\n}\n' }),
597
597
  repo: 'fixture',
598
598
  })
599
- // Since the Leaf prototype (9 October) the package has a box for writing comments, ComposeBox, and it answers first by its
600
- // own purpose. What this guards still holds: the app's composer is found above the parts the words reach only through notes.
599
+ // The package's one box for writing is CommentBox (ComposeBox went into it, 21 October); the app's own composer still answers
600
+ // first, above the parts the words reach only through notes.
601
601
  const found = findInRegistries([packageRegistry, composer], 'comment composer', { limit: 10 }).map((f) => `${f.entry.repo}:${f.entry.name}`)
602
- expect(found[0]).toBe('estiva-ui:ComposeBox')
603
- expect(found.indexOf('fixture:Composer')).toBeGreaterThan(0)
602
+ expect(found[0]).toBe('fixture:Composer')
604
603
  const triggers = found.indexOf('estiva-ui:ComposerTriggers')
605
604
  if (triggers >= 0) expect(found.indexOf('fixture:Composer')).toBeLessThan(triggers)
606
605
  })
@@ -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: 141 components, 65 helpers and 3 hooks (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 206 names over 96 files: 139 components, 64 helpers and 3 hooks (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: 141, helper: 65, hook: 3 })
58
- expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(97)
57
+ expect(kinds).toEqual({ component: 139, helper: 64, hook: 3 })
58
+ expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(96)
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
- expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(91)
64
- expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(118)
63
+ expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(90)
64
+ expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(116)
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', () => {
@@ -76,7 +76,6 @@ fork freely, owe nothing back, mention it on the package's ticket.
76
76
  | An editor that saves a block document and must keep its block ids | **BlockNodes** — `BlockId`, `UnknownBlock`, `ReferenceNode` and `AttachmentNode` from `@estiva-app/ui/editor`, beside StarterKit and TableKit |
77
77
  | A page's title or the line under it, edited where it stands, as in a document | **InlineText**, from `@estiva-app/ui/editor` — no box; Enter saves and moves on |
78
78
  | A comment, a reply or a line written and sent, in any app | **CommentBox**, from `@estiva-app/ui/editor` — triggers, keys, drafts, files, editing and a refused send; the app supplies its people, its `[` sections, its `/` rows and a send |
79
- | The box alone, around an editor the app makes itself | **ComposeBox**, from `@estiva-app/ui/editor` — the app brings its editor and adds `ComposeKeys` |
80
79
  | Comments on words, a passage or whole blocks of a document, drawn where they are | **CommentHighlights**, from `@estiva-app/ui/editor` — a run of blocks and the words quoted; says which was clicked and which moved or are gone |
81
80
  | Move, turn, duplicate or delete one block of a document being edited | **EditorBlockHandle**, from `@estiva-app/ui/editor`, with your rows after its own |
82
81
  | Add or delete a table's rows and columns in a document being edited | **EditorTableControls**, from `@estiva-app/ui/editor`, inside the EditorBlockHandle |
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComposeBox.d.ts","sourceRoot":"","sources":["../src/ComposeBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAQ1D,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;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Controls } from '@storybook/addon-docs/blocks'
2
- import * as ComposeBoxStories from './ComposeBox.stories'
3
-
4
- <Meta of={ComposeBoxStories} />
5
-
6
- # ComposeBox
7
-
8
- The box a message, a reply or a comment is written in: the text, the selection strip over it, what is attached, the tools and Send.
9
-
10
- <Canvas of={ComposeBoxStories.Default} />
11
-
12
- ## When
13
-
14
- - **Writing something that is sent**: a message, a reply, a comment. Enter sends, Shift+Enter is a new line.
15
- - `tools` for what acts on the draft — attach, highlight — as `ToolbarButton`s; they are one strip.
16
- - `attachments` for what is attached, as pending `AttachmentCard`s, under the text.
17
- - `marked` for the bar down the text's left while it holds an urgent mention or a highlight.
18
-
19
- <Canvas of={ComposeBoxStories.Reply} />
20
-
21
- ## When not
22
-
23
- - Editing a document in place → the editor itself, with **EditorBlockHandle** and **SelectionToolbar**. Nothing is sent.
24
- - One line of plain text in a form → **TextInput** or **Textarea**, in a **Form**.
25
-
26
- ## How
27
-
28
- ```tsx
29
- import { useEditor } from '@tiptap/react'
30
- import StarterKit from '@tiptap/starter-kit'
31
- import { ComposeBox, ComposeKeys, COMPOSE_EDITOR_CLASSES, KeptSelection } from '@estiva-app/ui/editor'
32
-
33
-
34
- const editor = useEditor({
35
- extensions: [StarterKit, KeptSelection, ComposeKeys /* and the app's own */],
36
- editorProps: { attributes: { class: COMPOSE_EDITOR_CLASSES } },
37
- })
38
-
39
- <ComposeBox editor={editor} onSend={(ed) => send(ed.getJSON())} placeholder={<span>Reply…</span>} />
40
- ```
41
-
42
- - **The app makes the editor.** Its extensions — mentions, references, `/` — are the app's; add `ComposeKeys`, and `COMPOSE_EDITOR_CLASSES` on the editor.
43
- - **`onSend` gets the editor** and writes what it holds in the app's own format. The box empties after it, unless it returns `false`.
44
- - `ready` when something can be sent with no words (a file is ready); `holding` while sending must wait (a file is uploading).
45
-
46
- ## What it owns
47
-
48
- It does these by itself. Write none of them around it.
49
-
50
- | It does | So you never write |
51
- |---|---|
52
- | Enter sends, unless a `/`, `@` or `[` list is open | a keydown handler |
53
- | Shift+Enter: a new line, a new list item, out of an empty item or quote line | list and quote commands |
54
- | Send presses on the way down, so the caret stays in the text | `preventDefault` on the button |
55
- | The placeholder while nothing is written | an empty check |
56
- | The selection strip over selected words | `SelectionToolbar` beside it |
57
-
58
- <Controls />
@@ -1,81 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { useState } from 'react'
3
- import { IconPaperclip } from '@tabler/icons-react'
4
- import { useEditor, type Editor } from '@tiptap/react'
5
- import StarterKit from '@tiptap/starter-kit'
6
- import { AttachmentCard } from './AttachmentCard'
7
- import { Kbd } from './Kbd'
8
- import { ToolbarButton } from './Toolbar'
9
- import { ComposeBox, ComposeKeys, COMPOSE_EDITOR_CLASSES } from './ComposeBox'
10
- import { KeptSelection } from './SelectionToolbar'
11
-
12
- /**
13
- * The box a message, a reply or a comment is written in. Type, select
14
- * words for the strip, Enter to send, Shift+Enter for a new line.
15
- */
16
- const meta = {
17
- title: 'Primitives/ComposeBox',
18
- component: ComposeBox,
19
- parameters: { layout: 'padded' },
20
- decorators: [
21
- (Story) => (
22
- <div className="w-[480px]">
23
- <Story />
24
- </div>
25
- ),
26
- ],
27
- } satisfies Meta<typeof ComposeBox>
28
-
29
- export default meta
30
- type Story = StoryObj
31
-
32
- function Writing({ tools, placeholder, file }: { tools?: boolean; placeholder: 'new' | 'reply'; file?: boolean }) {
33
- const [sent, setSent] = useState<string[]>([])
34
- const editor = useEditor({
35
- extensions: [StarterKit.configure({ link: { openOnClick: false } }), KeptSelection, ComposeKeys],
36
- editorProps: { attributes: { class: COMPOSE_EDITOR_CLASSES } },
37
- })
38
- return (
39
- <div className="flex flex-col gap-3">
40
- {sent.map((text, i) => (
41
- <p key={i} className="text-body-2 text-text-primary">
42
- {text}
43
- </p>
44
- ))}
45
- <ComposeBox
46
- editor={editor}
47
- onSend={(ed: Editor) => setSent((all) => [...all, ed.getText()])}
48
- selection={{ link: true }}
49
- ready={file}
50
- attachments={file ? <AttachmentCard pending name="brief.pdf" size={182_000} contentType="application/pdf" state="ready" onRemove={() => {}} /> : undefined}
51
- placeholder={
52
- placeholder === 'reply' ? (
53
- <span>Reply…</span>
54
- ) : (
55
- <>
56
- <span>Start a new conversation or type</span>
57
- <Kbd>/</Kbd>
58
- <span>for commands</span>
59
- </>
60
- )
61
- }
62
- tools={
63
- tools ? (
64
- <ToolbarButton tooltip="Attach files" aria-label="Attach files">
65
- <IconPaperclip size={16} stroke={1.5} />
66
- </ToolbarButton>
67
- ) : undefined
68
- }
69
- />
70
- </div>
71
- )
72
- }
73
-
74
- /** A new message, with a tool under the text. */
75
- export const Default: Story = { render: () => <Writing placeholder="new" tools /> }
76
-
77
- /** A reply: no tools, only Send. */
78
- export const Reply: Story = { render: () => <Writing placeholder="reply" /> }
79
-
80
- /** A file waiting to be sent: under the text, and Send is ready with no words. */
81
- export const WithAFile: Story = { render: () => <Writing placeholder="new" tools file /> }