@estiva-app/ui 0.108.0 → 0.108.2

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.108.0",
3
+ "version": "0.108.2",
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",
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "devDependencies": {
135
135
  "@eslint/js": "^10.0.1",
136
- "@estiva-app/conversation": "^0.33.0",
136
+ "@estiva-app/conversation": "^0.35.0",
137
137
  "@estiva-app/protocol": "^0.51.0",
138
138
  "@storybook/addon-a11y": "^10.6.0",
139
139
  "@storybook/addon-docs": "^10.5.10",
package/registry.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.108.0",
7
+ "packageVersion": "0.108.2",
8
8
  "exports": 250,
9
9
  "typeExports": 259,
10
10
  "files": null
@@ -2298,6 +2298,12 @@
2298
2298
  "required": false,
2299
2299
  "note": "The app shows a send before the relay answers: the box empties at once, and a refusal puts the words back."
2300
2300
  },
2301
+ {
2302
+ "name": "reply",
2303
+ "takes": "true/false",
2304
+ "required": false,
2305
+ "note": "The box answers a message, which can be deleted while you write: a send refused because it went says \"this message was deleted, or you can no longer write here\"."
2306
+ },
2301
2307
  {
2302
2308
  "name": "label",
2303
2309
  "takes": "text",
@@ -100,7 +100,25 @@ describe('sending, held until the relay answers', () => {
100
100
  expect(screen.queryByText(/262144|invalid:/)).toBeNull()
101
101
  })
102
102
 
103
- it('a send refused as on a deleted message says you can no longer write here, not that a message was deleted', async () => {
103
+ it('a reply refused because its message was deleted says the message was deleted, and the text stays in the box', async () => {
104
+ render(<Box reply send={async () => ({ accepted: false, reason: 'invalid: reply parent not found in this team' })} />)
105
+ await type('Hello there')
106
+ await press('Enter')
107
+ await settle()
108
+ expect(editorOf().getText()).toBe('Hello there')
109
+ expect(screen.getByText('Not sent: this message was deleted, or you can no longer write here. Your text is back in the box.')).toBeTruthy()
110
+ })
111
+
112
+ it('a reply shown at once and refused because its message was deleted says so, with the text put back', async () => {
113
+ render(<Box reply showsAtOnce send={async () => ({ accepted: false, reason: 'invalid: reply parent not found in this team' })} />)
114
+ await type('Hello there')
115
+ await press('Enter')
116
+ await settle()
117
+ expect(editorOf().getText()).toBe('Hello there')
118
+ expect(screen.getByText('Not sent: this message was deleted, or you can no longer write here. Your text is back in the box.')).toBeTruthy()
119
+ })
120
+
121
+ it('a new message refused as on a deleted message says you can no longer write here, not that a message was deleted', async () => {
104
122
  render(<Box send={async () => ({ accepted: false, reason: 'invalid: reply target event not found' })} />)
105
123
  await type('Hello there')
106
124
  await press('Enter')
@@ -80,12 +80,13 @@ export interface BoxFile {
80
80
  }
81
81
 
82
82
  /**
83
- * Why a send was refused. "This message was deleted" is an edit's or a reaction's (Decided, ONE-4): a new message
84
- * refused the same way (a reply whose message went) is one you can no longer write here.
83
+ * Why a send was refused. "This message was deleted" is an edit's, a reaction's (Decided, ONE-4) and a reply's, whose
84
+ * message may have gone while it was written (Decided, ONE-10, 9 November); a new top-level message refused the same
85
+ * way is one you can no longer write here.
85
86
  */
86
- function sendRefusal(reason: unknown): string {
87
+ function sendRefusal(reason: unknown, reply: boolean): string {
87
88
  const cause = refusalCause(reason)
88
- return REFUSAL_REASONS[cause === 'gone' ? 'no-access' : cause]
89
+ return REFUSAL_REASONS[cause === 'gone' && !reply ? 'no-access' : cause]
89
90
  }
90
91
 
91
92
  /** A draft, in the box's terms — `@estiva-app/conversation`'s `composerDraft` is one. */
@@ -182,6 +183,11 @@ export interface CommentBoxProps {
182
183
  * until the answer.
183
184
  */
184
185
  showsAtOnce?: boolean
186
+ /**
187
+ * The box answers a message, which can be deleted while you write: a send refused because it went says "this message
188
+ * was deleted, or you can no longer write here". A box that starts something new says "you can no longer write here".
189
+ */
190
+ reply?: boolean
185
191
  /** The editor's accessible name: what the box is for. */
186
192
  label: string
187
193
  /** Said in the empty box. */
@@ -506,6 +512,7 @@ function OpenCommentBox({
506
512
  marked,
507
513
  onEditor,
508
514
  className,
515
+ reply = false,
509
516
  }: CommentBoxProps) {
510
517
  const [files, setFiles] = useState<BoxFile[]>(edit?.files ?? [])
511
518
  const [sending, setSending] = useState(false)
@@ -700,7 +707,7 @@ function OpenCommentBox({
700
707
  ed.commands.focus('end')
701
708
  setRemoved((now) => new Set([...now, ...took]))
702
709
  setFiles((all) => [...sent, ...all])
703
- setRefused(sendRefusal(answer.reason))
710
+ setRefused(sendRefusal(answer.reason, reply))
704
711
  })
705
712
  return true
706
713
  }
@@ -710,7 +717,7 @@ function OpenCommentBox({
710
717
  setSending(false)
711
718
  if (!answer.accepted) {
712
719
  layout?.refused()
713
- setRefused(sendRefusal(answer.reason))
720
+ setRefused(sendRefusal(answer.reason, reply))
714
721
  return
715
722
  }
716
723
  if (!ed.isDestroyed) ed.commands.clearContent(true)
@@ -721,7 +728,7 @@ function OpenCommentBox({
721
728
  })
722
729
  return false
723
730
  },
724
- [files, removed, underOf, showsAtOnce, send, draft, onSent, onRefused, layout],
731
+ [files, removed, underOf, showsAtOnce, send, draft, onSent, onRefused, layout, reply],
725
732
  )
726
733
 
727
734
  // An edit holding nothing, no words and no file, cannot be saved: Save is off, and nothing is said (Miky, 4 Nov). One