@aparte/core 1.0.1 → 1.0.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.
@@ -258,7 +258,8 @@ export declare class AparteComposer extends HTMLElement {
258
258
  set disabled(value: boolean);
259
259
  /**
260
260
  * When false, Shift+Enter submits and a bare Enter inserts a newline —
261
- * the inverse of the default. Driven by the `submit-on-enter` attribute.
261
+ * the inverse of the default. Driven by the `submit-on-enter` attribute, and it
262
+ * holds in a panel's one-line fields as it does in the editor.
262
263
  */
263
264
  get submitOnEnter(): boolean;
264
265
  get attachments(): File[];
@@ -360,6 +361,21 @@ export declare class AparteComposer extends HTMLElement {
360
361
  * then belongs to another request, and that request must not orphan.
361
362
  */
362
363
  hidePanel(token?: symbol): void;
364
+ /**
365
+ * Enter in a panel's one-line field presses the send button, as it does in the editor.
366
+ *
367
+ * The panel takes the editor's place and the editor was the only thing listening, so
368
+ * what a person wrote in a panel went out by mouse alone: Enter added a line to an
369
+ * approval's instruction and did nothing in a question's text box. It lives here, once,
370
+ * because the button is the composer's and so is `submit-on-enter`; `submit()` then
371
+ * applies the panel's own gates (no act for the button, nothing written, put aside).
372
+ * The key is cancelled even when nothing can be sent, as the editor does, so an empty
373
+ * field does not fill with blank lines.
374
+ *
375
+ * Same IME guard as the editor: that Enter confirms a candidate. `defaultPrevented`
376
+ * leaves the key to a field that used it, a combobox picking its highlighted row.
377
+ */
378
+ private _onPanelKeydown;
363
379
  /** Close the panel AND tell its owner, so a pending request never orphans. */
364
380
  private _evictPanel;
365
381
  private _teardownPanel;
@@ -1 +1 @@
1
- {"version":3,"file":"aparte-composer.d.ts","sourceRoot":"","sources":["../../../src/components/composer/aparte-composer.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAKxD,MAAM,WAAW,sBAAsB;IACnC,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM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;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;IAapB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB,CAAuB;IAElD;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,kBAAkB;CAQ7B"}
@@ -25537,7 +25537,7 @@
25537
25537
  "type": {
25538
25538
  "text": "boolean"
25539
25539
  },
25540
- "description": "When false, Shift+Enter submits and a bare Enter inserts a newline —\nthe inverse of the default. Driven by the `submit-on-enter` attribute.",
25540
+ "description": "When false, Shift+Enter submits and a bare Enter inserts a newline —\nthe inverse of the default. Driven by the `submit-on-enter` attribute, and it\nholds in a panel's one-line fields as it does in the editor.",
25541
25541
  "readonly": true
25542
25542
  },
25543
25543
  {
@@ -25685,6 +25685,12 @@
25685
25685
  ],
25686
25686
  "description": "Remove the panel, tell its owner, and restore the composer's own controls.\n\nWith a `token`, this closes the panel only if that token still owns the slot —\nso a presenter settling late cannot tear down the panel that replaced it. With\nno token it closes whatever is there, which is what a consumer driving the\ncomposer directly means.\n\nThe two forms differ on purpose, and the difference is who already knows:\n\n- **With a matching token** the OWNER is closing its own panel, which is what\n `<aparte-elicitation>`'s `close()` does right after it resolves. It must NOT be\n notified — telling it \"you were evicted\" for a request it just settled would\n fire `onEvict` against a finished promise.\n- **With no token** somebody else is closing a panel they do not own, so the owner\n cannot know and has to be told. That includes the presenter's own defensive\n `hidePanel(undefined)` when it settles before `showPanel` ran: whatever is open\n then belongs to another request, and that request must not orphan."
25687
25687
  },
25688
+ {
25689
+ "kind": "field",
25690
+ "name": "_onPanelKeydown",
25691
+ "privacy": "private",
25692
+ "description": "Enter in a panel's one-line field presses the send button, as it does in the editor.\n\nThe panel takes the editor's place and the editor was the only thing listening, so\nwhat a person wrote in a panel went out by mouse alone: Enter added a line to an\napproval's instruction and did nothing in a question's text box. It lives here, once,\nbecause the button is the composer's and so is `submit-on-enter`; `submit()` then\napplies the panel's own gates (no act for the button, nothing written, put aside).\nThe key is cancelled even when nothing can be sent, as the editor does, so an empty\nfield does not fill with blank lines.\n\nSame IME guard as the editor: that Enter confirms a candidate. `defaultPrevented`\nleaves the key to a field that used it, a combobox picking its highlighted row."
25693
+ },
25688
25694
  {
25689
25695
  "kind": "method",
25690
25696
  "name": "_evictPanel",
package/dist/index.js CHANGED
@@ -5071,6 +5071,11 @@ deferHydrationOf(AparteChatViewport);
5071
5071
  if (!customElements.get("aparte-chat-viewport")) {
5072
5072
  customElements.define("aparte-chat-viewport", AparteChatViewport);
5073
5073
  }
5074
+ const ONE_LINE_INPUTS = /* @__PURE__ */ new Set(["text", "search", "email", "url", "tel", "number", "password"]);
5075
+ function isOneLineField(target) {
5076
+ if (target instanceof HTMLTextAreaElement) return target.rows === 1;
5077
+ return target instanceof HTMLInputElement && ONE_LINE_INPUTS.has(target.type);
5078
+ }
5074
5079
  class AparteComposer extends HTMLElement {
5075
5080
  _value = "";
5076
5081
  _streaming = false;
@@ -5201,7 +5206,8 @@ class AparteComposer extends HTMLElement {
5201
5206
  }
5202
5207
  /**
5203
5208
  * When false, Shift+Enter submits and a bare Enter inserts a newline —
5204
- * the inverse of the default. Driven by the `submit-on-enter` attribute.
5209
+ * the inverse of the default. Driven by the `submit-on-enter` attribute, and it
5210
+ * holds in a panel's one-line fields as it does in the editor.
5205
5211
  */
5206
5212
  get submitOnEnter() {
5207
5213
  return this.getAttribute("submit-on-enter") !== "false";
@@ -5309,6 +5315,7 @@ class AparteComposer extends HTMLElement {
5309
5315
  const inputEl = this.querySelector("aparte-composer-input");
5310
5316
  this.setAttribute("data-panel-active", "");
5311
5317
  panel.dataset["apartePanel"] = "true";
5318
+ panel.addEventListener("keydown", this._onPanelKeydown);
5312
5319
  if (host) {
5313
5320
  host.appendChild(panel);
5314
5321
  } else if (inputEl) {
@@ -5354,6 +5361,28 @@ class AparteComposer extends HTMLElement {
5354
5361
  }
5355
5362
  this._evictPanel();
5356
5363
  }
5364
+ /**
5365
+ * Enter in a panel's one-line field presses the send button, as it does in the editor.
5366
+ *
5367
+ * The panel takes the editor's place and the editor was the only thing listening, so
5368
+ * what a person wrote in a panel went out by mouse alone: Enter added a line to an
5369
+ * approval's instruction and did nothing in a question's text box. It lives here, once,
5370
+ * because the button is the composer's and so is `submit-on-enter`; `submit()` then
5371
+ * applies the panel's own gates (no act for the button, nothing written, put aside).
5372
+ * The key is cancelled even when nothing can be sent, as the editor does, so an empty
5373
+ * field does not fill with blank lines.
5374
+ *
5375
+ * Same IME guard as the editor: that Enter confirms a candidate. `defaultPrevented`
5376
+ * leaves the key to a field that used it, a combobox picking its highlighted row.
5377
+ */
5378
+ _onPanelKeydown = (e) => {
5379
+ if (e.key !== "Enter" || e.isComposing || e.keyCode === 229 || e.defaultPrevented) return;
5380
+ if (!isOneLineField(e.target)) return;
5381
+ const submits = this.submitOnEnter ? !e.shiftKey : e.shiftKey;
5382
+ if (!submits) return;
5383
+ e.preventDefault();
5384
+ this.submit();
5385
+ };
5357
5386
  /** Close the panel AND tell its owner, so a pending request never orphans. */
5358
5387
  _evictPanel() {
5359
5388
  const onEvict = this._panelOnEvict;