@estiva-app/ui 0.85.0 → 0.86.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.
@@ -0,0 +1,83 @@
1
+ import type { LinkState, Linked, LinkedConversation, LinkedKind } from './linked';
2
+ /** A person as interop names them: a profile, possibly empty. */
3
+ export interface LinkedProfile {
4
+ displayName?: string;
5
+ picture?: string;
6
+ }
7
+ /** One of interop's resolved slots. */
8
+ export interface LinkedSlot {
9
+ value: string;
10
+ label?: string;
11
+ colour?: string;
12
+ isPubkey?: boolean;
13
+ field?: string;
14
+ }
15
+ /** One of interop's resolved actions: what the file's own app lets a reader change. */
16
+ export interface LinkedAction {
17
+ id: string;
18
+ label: string;
19
+ control: string;
20
+ field?: string;
21
+ current?: string;
22
+ options?: {
23
+ value: string;
24
+ label: string;
25
+ colour?: string;
26
+ }[];
27
+ }
28
+ /** The part of interop's `ForeignObject` a link is built from. */
29
+ export interface LinkedSource {
30
+ ref: string;
31
+ address?: string;
32
+ eventId?: string;
33
+ kind: number;
34
+ widget: string | string[];
35
+ noun?: string;
36
+ appName?: string;
37
+ slots: Record<string, LinkedSlot | undefined>;
38
+ meta: LinkedSlot[];
39
+ children?: LinkedSource[];
40
+ people?: Record<string, LinkedProfile>;
41
+ actions: LinkedAction[];
42
+ parentField?: string;
43
+ openUrl?: string;
44
+ unreachable?: boolean;
45
+ archived?: unknown;
46
+ /** When it last changed, in seconds (interop 0.64). */
47
+ changedAt?: number;
48
+ }
49
+ /** `T` is the app's own object type (interop's `ForeignObject`), so `hrefOf` takes it as it is. */
50
+ export interface LinkedFromOptions<T extends LinkedSource = LinkedSource> {
51
+ /**
52
+ * Where a file opens in this app: the linked file itself (`top`), or one of
53
+ * the rows on its card. Another app's address comes from a manifest anyone
54
+ * may publish, so the app keeps it to https.
55
+ */
56
+ hrefOf: (object: T, top: boolean) => string;
57
+ /** A message's words for a one-line preview: marks stripped, references read as words. */
58
+ previewText: (body: string, people: Record<string, LinkedProfile> | undefined) => string;
59
+ /** The workspace's people, for the owner picker's options. */
60
+ directory?: Record<string, LinkedProfile>;
61
+ /**
62
+ * Changes the file from its card. Without it the values read as words
63
+ * (Decided 16 Oct: any reader may change a file from its card; words only in
64
+ * a preview and for a file that cannot be read). An archived file's read as
65
+ * words whatever is passed: its page is read-only.
66
+ */
67
+ onAct?: (actionId: string, value: string) => void;
68
+ /** What was said about it, when the app has read that. */
69
+ conversation?: LinkedConversation;
70
+ }
71
+ /** The file a reference names, as the kit's chip, row and card draw it. */
72
+ export declare function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFromOptions<T>): Linked;
73
+ /**
74
+ * Where a reference's read stands, for the kit: `undefined` is still read,
75
+ * `null` an answer of nothing. `unread` is what the app knows from the address
76
+ * alone, for those two. Nothing, and a file the reader may not read, draw
77
+ * alike: "not available." (Miky, 15 Oct).
78
+ */
79
+ export declare function linkStateFrom<T extends LinkedSource>(object: T | null | undefined, unread: {
80
+ kind: LinkedKind;
81
+ noun: string;
82
+ }, options: LinkedFromOptions<T>): LinkState;
83
+ //# sourceMappingURL=linkedFrom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkedFrom.d.ts","sourceRoot":"","sources":["../src/linkedFrom.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.85.0",
3
+ "version": "0.86.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,9 +4,9 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.85.0",
8
- "exports": 206,
9
- "typeExports": 206,
7
+ "packageVersion": "0.86.1",
8
+ "exports": 209,
9
+ "typeExports": 211,
10
10
  "files": null
11
11
  },
12
12
  "storybook": {
@@ -4188,6 +4188,38 @@
4188
4188
  "border-border-tooltip-key bg-bg-tooltip-key text-text-tooltip-key signal:bg-bg-tooltip-key ship:bg-bg-tooltip-key"
4189
4189
  ]
4190
4190
  },
4191
+ {
4192
+ "name": "keepCommentBoxWarm",
4193
+ "repo": "estiva-ui",
4194
+ "kind": "helper",
4195
+ "importPath": "@estiva-app/ui/editor",
4196
+ "sourceFile": "src/CommentBox.tsx",
4197
+ "purpose": "Keeps an editor built ahead for the next empty box given these `extensions` and `referenceView`, so it opens at once.",
4198
+ "purposeFrom": "comment",
4199
+ "props": [
4200
+ {
4201
+ "name": "extensions",
4202
+ "takes": "readonly AnyExtension[]",
4203
+ "required": false,
4204
+ "note": null
4205
+ },
4206
+ {
4207
+ "name": "referenceView",
4208
+ "takes": "ComponentType<ReferenceViewProps>",
4209
+ "required": false,
4210
+ "note": null
4211
+ }
4212
+ ],
4213
+ "variants": [],
4214
+ "ownsBehaviours": [],
4215
+ "status": "stable",
4216
+ "migrationStage": null,
4217
+ "docsId": "primitives-commentbox--docs",
4218
+ "storyId": "primitives-commentbox--empty",
4219
+ "docPage": null,
4220
+ "app": null,
4221
+ "looks": []
4222
+ },
4191
4223
  {
4192
4224
  "name": "keepSelection",
4193
4225
  "repo": "estiva-ui",
@@ -4571,6 +4603,25 @@
4571
4603
  "app": null,
4572
4604
  "looks": []
4573
4605
  },
4606
+ {
4607
+ "name": "linkedFrom",
4608
+ "repo": "estiva-ui",
4609
+ "kind": "helper",
4610
+ "importPath": "@estiva-app/ui",
4611
+ "sourceFile": "src/linkedFrom.ts",
4612
+ "purpose": "The file a reference names, as the kit's chip, row and card draw it.",
4613
+ "purposeFrom": "comment",
4614
+ "props": [],
4615
+ "variants": [],
4616
+ "ownsBehaviours": [],
4617
+ "status": "stable",
4618
+ "migrationStage": null,
4619
+ "docsId": null,
4620
+ "storyId": null,
4621
+ "docPage": null,
4622
+ "app": null,
4623
+ "looks": []
4624
+ },
4574
4625
  {
4575
4626
  "name": "LinkedIcon",
4576
4627
  "repo": "estiva-ui",
@@ -4821,6 +4872,25 @@
4821
4872
  "app": null,
4822
4873
  "looks": []
4823
4874
  },
4875
+ {
4876
+ "name": "linkStateFrom",
4877
+ "repo": "estiva-ui",
4878
+ "kind": "helper",
4879
+ "importPath": "@estiva-app/ui",
4880
+ "sourceFile": "src/linkedFrom.ts",
4881
+ "purpose": "Where a reference's read stands, for the kit: `undefined` is still read, `null` an answer of nothing.",
4882
+ "purposeFrom": "comment",
4883
+ "props": [],
4884
+ "variants": [],
4885
+ "ownsBehaviours": [],
4886
+ "status": "stable",
4887
+ "migrationStage": null,
4888
+ "docsId": null,
4889
+ "storyId": null,
4890
+ "docPage": null,
4891
+ "app": null,
4892
+ "looks": []
4893
+ },
4824
4894
  {
4825
4895
  "name": "LinkUnavailable",
4826
4896
  "repo": "estiva-ui",
package/src/LinkCard.mdx CHANGED
@@ -44,6 +44,7 @@ const linked = {
44
44
  - The picker offers only the options it is given: to let the reader set nobody as the owner, include an option for it.
45
45
  - `linked.latest` is drawn whenever it is given: pass it only to a reader who may read it.
46
46
  - `linked.conversation.unread` only for a member of it.
47
+ - **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). The app passes `hrefOf(object, top)`, `previewText(body, people)` and, for a link not yet read, its kind and noun.
47
48
 
48
49
  ## What it owns
49
50
 
package/src/editor.ts CHANGED
@@ -12,6 +12,7 @@ export { KeptSelection, SelectionToolbar, keepSelection, releaseSelection, norma
12
12
  export {
13
13
  CommentBox,
14
14
  commentBoxRows,
15
+ keepCommentBoxWarm,
15
16
  type CommentBoxProps,
16
17
  type CommentBoxDraft,
17
18
  type CommentBoxEdit,
package/src/index.ts CHANGED
@@ -103,6 +103,15 @@ export {
103
103
  type StatusColour,
104
104
  type UnavailableMemory,
105
105
  } from './linked'
106
+ export {
107
+ linkedFrom,
108
+ linkStateFrom,
109
+ type LinkedAction,
110
+ type LinkedFromOptions,
111
+ type LinkedProfile,
112
+ type LinkedSlot,
113
+ type LinkedSource,
114
+ } from './linkedFrom'
106
115
  export { CommentCount, LinkedIcon, LinkKey, LinkPickers, ProgressRing, StatusMark, type LinkPickersProps } from './LinkParts'
107
116
  export { LinkChip, type LinkChipProps } from './LinkChip'
108
117
  export { LinkRow, LinkUnavailable, type LinkRowProps, type LinkUnavailableProps } from './LinkRow'
@@ -0,0 +1,193 @@
1
+ // @vitest-environment jsdom
2
+ /**
3
+ * One file, one card, in every app (5ebf2756): what the card built from
4
+ * interop's projection shows — its key, its most recently changed items and
5
+ * how many of all of them are done, pickers for a reader who may change it,
6
+ * words for an archived file and for one whose app shares no control.
7
+ */
8
+ import { cleanup, render, screen, within } from '@testing-library/react'
9
+ import userEvent from '@testing-library/user-event'
10
+ import { afterEach, describe, expect, it, vi } from 'vitest'
11
+ import { LinkCard } from './LinkCard'
12
+ import { LinkChip } from './LinkChip'
13
+ import { linkStateFrom, type LinkedFromOptions, type LinkedSource } from './linkedFrom'
14
+
15
+ afterEach(cleanup)
16
+
17
+ const OWNER = 'a'.repeat(64)
18
+ const OTHER = 'b'.repeat(64)
19
+ const PEOPLE = { [OWNER]: { displayName: 'Person one' }, [OTHER]: { displayName: 'Person two' } }
20
+
21
+ const STATUSES = [
22
+ { value: 'todo', label: 'Todo', colour: 'neutral' },
23
+ { value: 'doing', label: 'Doing', colour: 'blue' },
24
+ { value: 'done', label: 'Done', colour: 'green' },
25
+ { value: 'dropped', label: 'Dropped', colour: 'muted' },
26
+ ]
27
+
28
+ function item(n: number, status: (typeof STATUSES)[number], changedAt: number): LinkedSource {
29
+ return {
30
+ ref: `2:${OWNER}:item-${n}`,
31
+ address: `2:${OWNER}:item-${n}`,
32
+ kind: 2,
33
+ widget: 'row',
34
+ slots: { title: { value: `Item ${n}`, field: 'title' }, status: { value: status.label, colour: status.colour, field: 'status' } },
35
+ meta: [
36
+ { value: `ABC-${n}`, field: 'ref' },
37
+ { value: OWNER, field: 'assignee', isPubkey: true, label: 'Assignee' },
38
+ ],
39
+ people: PEOPLE,
40
+ actions: [],
41
+ changedAt,
42
+ }
43
+ }
44
+
45
+ const [TODO, DOING, DONE, DROPPED] = STATUSES
46
+
47
+ /** Nine items: 3 done, 1 dropped. Items 8 and 9 changed in the same second. */
48
+ const ITEMS = [
49
+ item(1, DONE, 100),
50
+ item(2, DONE, 200),
51
+ item(3, TODO, 900),
52
+ item(4, DOING, 400),
53
+ item(5, DROPPED, 500),
54
+ item(6, TODO, 600),
55
+ item(7, DONE, 50),
56
+ item(9, TODO, 800),
57
+ item(8, DOING, 800),
58
+ ]
59
+
60
+ const GROUP: LinkedSource = {
61
+ ref: `1:${OWNER}:group`,
62
+ address: `1:${OWNER}:group`,
63
+ kind: 1,
64
+ widget: 'card',
65
+ slots: {
66
+ title: { value: 'Group one', field: 'title' },
67
+ subtitle: { value: 'What the group is for.' },
68
+ status: { value: 'Doing', colour: 'blue', field: 'status' },
69
+ },
70
+ meta: [
71
+ { value: 'ABC', field: 'key' },
72
+ { value: OWNER, field: 'lead', isPubkey: true, label: 'Lead' },
73
+ ],
74
+ children: ITEMS,
75
+ people: PEOPLE,
76
+ actions: [
77
+ { id: 'set-status', label: 'Status', control: 'select', field: 'status', current: 'doing', options: STATUSES },
78
+ { id: 'set-lead', label: 'Lead', control: 'pubkey', field: 'lead', current: OWNER },
79
+ ],
80
+ }
81
+
82
+ const options = (more: Partial<LinkedFromOptions> = {}): LinkedFromOptions => ({
83
+ hrefOf: (object, top) => `#${top ? 'top' : 'row'}-${object.address}`,
84
+ previewText: (body) => body.replace(/\*/g, ''),
85
+ directory: PEOPLE,
86
+ ...more,
87
+ })
88
+
89
+ const UNREAD = { kind: 'file' as const, noun: 'File' }
90
+
91
+ const rowTitles = () =>
92
+ screen
93
+ .getAllByRole('link')
94
+ .map((link) => link.textContent ?? '')
95
+ .filter((text) => /^ABC-\d/.test(text) || /^Item \d/.test(text))
96
+
97
+ describe('a card built from interop’s projection', () => {
98
+ it('lists the 7 most recently changed items, newest first, a tie going to the address', () => {
99
+ render(<LinkCard link={linkStateFrom(GROUP, UNREAD, options())} />)
100
+ const rows = rowTitles().map((text) => text.match(/Item \d/)?.[0])
101
+ expect(rows).toEqual(['Item 3', 'Item 8', 'Item 9', 'Item 6', 'Item 5', 'Item 4', 'Item 2'])
102
+ })
103
+
104
+ it('keeps the order it was given when nothing says when an item changed', () => {
105
+ const unknown = ITEMS.map(({ changedAt: _, ...rest }) => rest)
106
+ render(<LinkCard link={linkStateFrom({ ...GROUP, children: unknown }, UNREAD, options())} />)
107
+ const rows = rowTitles().map((text) => text.match(/Item \d/)?.[0])
108
+ expect(rows).toEqual(['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7'])
109
+ })
110
+
111
+ it('counts every item in its ring, listed or not, a dropped one in the total and not as done', () => {
112
+ render(<LinkCard link={linkStateFrom(GROUP, UNREAD, options())} />)
113
+ expect(screen.getByText('3/9')).toBeTruthy()
114
+ })
115
+
116
+ it('shows its key before its title, in the card and in the chip', () => {
117
+ render(<LinkCard link={linkStateFrom(GROUP, UNREAD, options())} />)
118
+ expect(screen.getByText('ABC')).toBeTruthy()
119
+ cleanup()
120
+ render(<LinkChip link={linkStateFrom(GROUP, UNREAD, options())} />)
121
+ expect(screen.getByText('ABC')).toBeTruthy()
122
+ })
123
+
124
+ it('lets a reader who may change it pick a status and a lead, through the app’s own actions', async () => {
125
+ const user = userEvent.setup()
126
+ const onAct = vi.fn()
127
+ render(<LinkCard link={linkStateFrom(GROUP, UNREAD, options({ onAct }))} />)
128
+ await user.click(screen.getByRole('combobox', { name: 'Status' }))
129
+ await user.click(await screen.findByRole('option', { name: /Done/ }))
130
+ expect(onAct).toHaveBeenCalledWith('set-status', 'done')
131
+ await user.click(screen.getByRole('combobox', { name: 'Lead' }))
132
+ await user.click(await screen.findByRole('option', { name: /Person two/ }))
133
+ expect(onAct).toHaveBeenCalledWith('set-lead', OTHER)
134
+ })
135
+
136
+ it('shows an archived file’s status and lead as words, even to a reader who could change them', () => {
137
+ render(<LinkCard link={linkStateFrom({ ...GROUP, archived: { by: OWNER, at: 1 } }, UNREAD, options({ onAct: vi.fn() }))} />)
138
+ expect(screen.queryByRole('combobox')).toBeNull()
139
+ expect(screen.getAllByText('Doing').length).toBeGreaterThan(0)
140
+ })
141
+
142
+ it('names the owner as words when the file’s app shares no control for it', () => {
143
+ const card = render(<LinkCard link={linkStateFrom({ ...GROUP, children: [], actions: [] }, UNREAD, options({ onAct: vi.fn() }))} />)
144
+ expect(screen.queryByRole('combobox')).toBeNull()
145
+ expect(within(card.container).getByText('Person one')).toBeTruthy()
146
+ })
147
+
148
+ it('opens the file and each row where the app says', () => {
149
+ render(<LinkCard link={linkStateFrom(GROUP, UNREAD, options())} />)
150
+ expect(screen.getByRole('link', { name: /Group one/ }).getAttribute('href')).toBe(`#top-${GROUP.address}`)
151
+ expect(screen.getByRole('link', { name: /Item 3/ }).getAttribute('href')).toBe(`#row-2:${OWNER}:item-3`)
152
+ })
153
+ })
154
+
155
+ describe('a file the reader cannot read', () => {
156
+ it('is not available, and opens in its app only at an https address', () => {
157
+ const stub: LinkedSource = { ...GROUP, unreachable: true, noun: 'group', appName: 'App one', openUrl: 'https://app.example/x' }
158
+ render(<LinkCard link={linkStateFrom(stub, UNREAD, options())} />)
159
+ expect(screen.getByText(/Group — not available/)).toBeTruthy()
160
+ expect(screen.getByRole('link', { name: /App one/ }).getAttribute('href')).toBe('https://app.example/x')
161
+ cleanup()
162
+ render(<LinkCard link={linkStateFrom({ ...stub, openUrl: 'javascript:alert(1)' }, UNREAD, options())} />)
163
+ expect(screen.queryByRole('link')).toBeNull()
164
+ })
165
+
166
+ it('is named by its address when its app gives it no noun', () => {
167
+ render(<LinkCard link={linkStateFrom({ ...GROUP, unreachable: true, appName: 'App one' }, { kind: 'file', noun: 'Record' }, options())} />)
168
+ expect(screen.getByText('Record — not available.')).toBeTruthy()
169
+ })
170
+
171
+ it('reads as the address says while it loads and when nothing came back', () => {
172
+ render(<LinkCard link={linkStateFrom(null, { kind: 'file', noun: 'Record' }, options())} />)
173
+ expect(screen.getByText('Record — not available.')).toBeTruthy()
174
+ })
175
+ })
176
+
177
+ describe('a message', () => {
178
+ it('is drawn as its author’s words, through the app’s preview', () => {
179
+ const message: LinkedSource = {
180
+ ref: 'e'.repeat(64),
181
+ eventId: 'e'.repeat(64),
182
+ kind: 9,
183
+ widget: ['message', 'card'],
184
+ slots: { title: { value: OTHER, isPubkey: true, field: 'pubkey' }, body: { value: 'Ship it **today**' } },
185
+ meta: [],
186
+ people: PEOPLE,
187
+ actions: [],
188
+ }
189
+ render(<LinkCard link={linkStateFrom(message, UNREAD, options())} />)
190
+ expect(screen.getByText('Person two')).toBeTruthy()
191
+ expect(screen.getByText('Ship it today')).toBeTruthy()
192
+ })
193
+ })