@estiva-app/ui 0.79.0 → 0.80.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.map +1 -1
- package/dist/editor.js +4 -1
- package/dist/editor.js.map +2 -2
- package/package.json +1 -1
- package/registry.json +1 -1
- package/src/CommentBox.mdx +2 -2
- package/src/CommentBox.stories.tsx +1 -1
- package/src/CommentBox.test.tsx +16 -2
- package/src/CommentBox.tsx +7 -3
package/package.json
CHANGED
package/registry.json
CHANGED
package/src/CommentBox.mdx
CHANGED
|
@@ -68,14 +68,14 @@ It does these by itself. Write none of them around it.
|
|
|
68
68
|
| Holding the words until the answer, or showing the send at once | a sending state |
|
|
69
69
|
| A refusal: the words back, and a line under the box | a toast, or putting text back |
|
|
70
70
|
| The draft, written as you type and forgotten once sent | an update listener |
|
|
71
|
-
| Files: picking, pasting, dropping, uploading, failing; Send waits | a file list |
|
|
71
|
+
| Files: picking, pasting, dropping, uploading, failing; Send waits for an upload and holds on a failed file until its ✕ removes it | a file list |
|
|
72
72
|
| The read-only line | a disabled box |
|
|
73
73
|
|
|
74
74
|
## Keys
|
|
75
75
|
|
|
76
76
|
| Key | What it does |
|
|
77
77
|
|---|---|
|
|
78
|
-
| Enter | Sends; saves an edit. With a list open, picks the row. |
|
|
78
|
+
| Enter | Sends; saves an edit. With a list open, picks the row. Holds while a file is uploading or did not upload. |
|
|
79
79
|
| Ctrl/Cmd+Enter | Sends, as Enter does. |
|
|
80
80
|
| Shift+Enter | A new line; in a list, a new item. |
|
|
81
81
|
| Escape | Cancels an edit. With a list open, closes the list first. |
|
|
@@ -195,7 +195,7 @@ export const EditingRefused: Story = {
|
|
|
195
195
|
/** A file uploading: Send waits for it. */
|
|
196
196
|
export const FileUploading: Story = { render: () => <Live upload={uploads('never')} />, play: pickAFile }
|
|
197
197
|
|
|
198
|
-
/** A file that failed: it says why and
|
|
198
|
+
/** A file that failed: it says why, Send holds, and its ✕ removes it. */
|
|
199
199
|
export const FileFailed: Story = { render: () => <Live upload={uploads('failed')} />, play: pickAFile }
|
|
200
200
|
|
|
201
201
|
/** Read-only, archived: a line in the box's place. */
|
package/src/CommentBox.test.tsx
CHANGED
|
@@ -225,8 +225,9 @@ describe('files', () => {
|
|
|
225
225
|
expect(send.mock.calls[0][1]).toMatchObject([{ name: 'plan.pdf', state: 'ready', value: 'the-record' }])
|
|
226
226
|
})
|
|
227
227
|
|
|
228
|
-
it('a failed upload says why
|
|
229
|
-
|
|
228
|
+
it('a failed upload says why and holds Send and Enter until its ✕ takes it off', async () => {
|
|
229
|
+
const send = vi.fn<CommentBoxProps['send']>(async () => ({ accepted: true }))
|
|
230
|
+
render(<Box send={send} upload={async () => ({ accepted: false, reason: 'too large' })} />)
|
|
230
231
|
const input = document.querySelector('input[type=file]') as HTMLInputElement
|
|
231
232
|
await act(async () => {
|
|
232
233
|
fireEvent.change(input, { target: { files: [new File(['x'], 'big.mov', { type: 'video/quicktime' })] } })
|
|
@@ -234,6 +235,19 @@ describe('files', () => {
|
|
|
234
235
|
await settle()
|
|
235
236
|
expect(screen.getByText('too large')).toBeTruthy()
|
|
236
237
|
expect(screen.queryByText('Uploading… Send waits for the file.')).toBeNull()
|
|
238
|
+
await type('See this')
|
|
239
|
+
expect(screen.getByText('Remove the file that did not upload to send.')).toBeTruthy()
|
|
240
|
+
expect((screen.getByRole('button', { name: 'Send' }) as HTMLButtonElement).disabled).toBe(true)
|
|
241
|
+
await press('Enter')
|
|
242
|
+
expect(send).not.toHaveBeenCalled()
|
|
243
|
+
await act(async () => {
|
|
244
|
+
fireEvent.click(screen.getByRole('button', { name: 'Remove big.mov' }))
|
|
245
|
+
})
|
|
246
|
+
expect(screen.queryByText('Remove the file that did not upload to send.')).toBeNull()
|
|
247
|
+
await press('Enter')
|
|
248
|
+
expect(send).toHaveBeenCalledTimes(1)
|
|
249
|
+
expect(textOf(send.mock.calls[0][0])).toBe('See this')
|
|
250
|
+
expect(send.mock.calls[0][1]).toEqual([])
|
|
237
251
|
})
|
|
238
252
|
|
|
239
253
|
it('an upload that arrives after the box opened offers File in /', async () => {
|
package/src/CommentBox.tsx
CHANGED
|
@@ -306,6 +306,8 @@ export function CommentBox({
|
|
|
306
306
|
}, [upload, edit])
|
|
307
307
|
|
|
308
308
|
const uploading = files.some((f) => f.state === 'uploading')
|
|
309
|
+
// A file that did not upload holds Send until its ✕ takes it off, so it is never sent without it unnoticed.
|
|
310
|
+
const failed = files.filter((f) => f.state === 'failed').length
|
|
309
311
|
const ready = files.some((f) => f.state === 'ready')
|
|
310
312
|
|
|
311
313
|
const go = useCallback(
|
|
@@ -431,8 +433,7 @@ export function CommentBox({
|
|
|
431
433
|
</div>
|
|
432
434
|
</div>
|
|
433
435
|
</div>
|
|
434
|
-
{sending && <FieldLine>Saving…</FieldLine>}
|
|
435
|
-
{refusedLine}
|
|
436
|
+
{sending && <FieldLine>Saving…</FieldLine>} {refusedLine}
|
|
436
437
|
</div>
|
|
437
438
|
)
|
|
438
439
|
}
|
|
@@ -459,13 +460,16 @@ export function CommentBox({
|
|
|
459
460
|
}
|
|
460
461
|
attachments={fileCards}
|
|
461
462
|
ready={ready}
|
|
462
|
-
holding={uploading || sending}
|
|
463
|
+
holding={uploading || failed > 0 || sending}
|
|
463
464
|
selection={{ link: true }}
|
|
464
465
|
className={cn(sending && '[&_[data-composer-editor]]:text-text-muted')}
|
|
465
466
|
/>
|
|
466
467
|
{upload && <FilePicker ref={picker} multiple accept={accept} onPick={attachFiles} />}
|
|
467
468
|
{sending && <FieldLine>Sending…</FieldLine>}
|
|
468
469
|
{uploading && !sending && <FieldLine>Uploading… Send waits for the file.</FieldLine>}
|
|
470
|
+
{failed > 0 && !uploading && !sending && (
|
|
471
|
+
<FieldLine>{failed === 1 ? 'Remove the file that did not upload to send.' : 'Remove the files that did not upload to send.'}</FieldLine>
|
|
472
|
+
)}
|
|
469
473
|
{refusedLine}
|
|
470
474
|
</div>
|
|
471
475
|
)
|