@syntrologie/adapt-faq 2.8.0-canary.215 → 2.8.0-canary.216

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.
@@ -4,7 +4,7 @@
4
4
  * Editable variant of the FAQ accordion for the canvas editor surface.
5
5
  * Renders the same Q&A rows as <syntro-faq-accordion> but adds:
6
6
  * - Pencil button per row (shows on hover, calls controller.editItem on click)
7
- * - Double-click on row calls controller.editItem
7
+ * - Click on question text expands/collapses to show the answer (normal FAQ behavior)
8
8
  * - Drag handle per row when items.length >= 2
9
9
  * - Drag-and-drop reorder via the sortable utility (injected via mount config)
10
10
  * - Read-only fallback when controller is null
@@ -80,6 +80,9 @@ export declare class FAQAccordionEditableElement extends LitElement {
80
80
  _hoveredId: {
81
81
  state: boolean;
82
82
  };
83
+ _expandedId: {
84
+ state: boolean;
85
+ };
83
86
  };
84
87
  faqConfig: FAQConfig;
85
88
  /** Null when loaded without an editor context — renders read-only accordion. */
@@ -106,8 +109,10 @@ export declare class FAQAccordionEditableElement extends LitElement {
106
109
  */
107
110
  liveRegion: HTMLElement | null;
108
111
  _hoveredId: string | null;
112
+ _expandedId: string | null;
109
113
  private _sortableHandle;
110
114
  createRenderRoot(): this;
115
+ connectedCallback(): void;
111
116
  /**
112
117
  * Wire (or re-wire) the sortable whenever the properties it depends on change.
113
118
  * `updated()` fires after every render, including the first, so we don't need
@@ -118,8 +123,8 @@ export declare class FAQAccordionEditableElement extends LitElement {
118
123
  disconnectedCallback(): void;
119
124
  private _attachSortable;
120
125
  private _handleEdit;
121
- private _handleRowDblClick;
122
126
  private _handlePencilClick;
127
+ private _toggleExpand;
123
128
  private _renderRow;
124
129
  render(): import("lit-html").TemplateResult<1>;
125
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FAQWidgetLit.editable.d.ts","sourceRoot":"","sources":["../src/FAQWidgetLit.editable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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ACb,SAAS,GAAG;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACnC,mFAAmF;QACnF,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC7B,8EAA8E;QAC9E,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;KACjC;CAkCJ,CAAC"}
package/dist/editor.js CHANGED
@@ -4446,7 +4446,7 @@ if (!customElements.get("se-group-header")) {
4446
4446
  }
4447
4447
 
4448
4448
  // src/faq-item-editor.ts
4449
- import { html as html10, LitElement as LitElement9, nothing as nothing5 } from "lit";
4449
+ import { css, html as html10, LitElement as LitElement9, nothing as nothing5 } from "lit";
4450
4450
  var getAnswerText = (answer) => {
4451
4451
  if (typeof answer === "string") return answer;
4452
4452
  if (answer.type === "rich") return answer.html;
@@ -4465,10 +4465,6 @@ var FAQItemEditorLit = class extends LitElement9 {
4465
4465
  this.onChange = () => {
4466
4466
  };
4467
4467
  }
4468
- // Shadow DOM — so tests can query shadowRoot
4469
- createRenderRoot() {
4470
- return this.attachShadow({ mode: "open" });
4471
- }
4472
4468
  _findItem() {
4473
4469
  return this.appConfig.actions.find((a) => a.config.id === this.itemId);
4474
4470
  }
@@ -4537,6 +4533,56 @@ var FAQItemEditorLit = class extends LitElement9 {
4537
4533
  `;
4538
4534
  }
4539
4535
  };
4536
+ FAQItemEditorLit.styles = css`
4537
+ :host {
4538
+ display: block;
4539
+ width: 100%;
4540
+ font-family: system-ui, -apple-system, sans-serif;
4541
+ }
4542
+ form {
4543
+ display: flex;
4544
+ flex-direction: column;
4545
+ gap: 16px;
4546
+ }
4547
+ label {
4548
+ display: flex;
4549
+ flex-direction: column;
4550
+ gap: 6px;
4551
+ }
4552
+ label > span {
4553
+ font-size: 13px;
4554
+ font-weight: 500;
4555
+ color: var(--syntro-text-secondary, #a8afba);
4556
+ }
4557
+ input,
4558
+ textarea {
4559
+ width: 100%;
4560
+ box-sizing: border-box;
4561
+ padding: 8px 12px;
4562
+ border-radius: 6px;
4563
+ border: 1px solid var(--syntro-input-field-border-default, #2b333f);
4564
+ background: var(--syntro-input-field-bg-default, #0e1114);
4565
+ color: var(--syntro-text-primary, #cbd0d7);
4566
+ font-size: 14px;
4567
+ font-family: inherit;
4568
+ outline: none;
4569
+ }
4570
+ input:focus,
4571
+ textarea:focus {
4572
+ border-color: var(--syntro-input-field-border-selected, #b72e2a);
4573
+ box-shadow: var(--syntro-focus-ring-primary, 0 0 0 4px rgba(221, 109, 105, 0.25));
4574
+ }
4575
+ textarea {
4576
+ resize: vertical;
4577
+ }
4578
+ [data-rationale] {
4579
+ font-size: 13px;
4580
+ color: var(--syntro-text-tertiary, #87919f);
4581
+ padding: 8px 12px;
4582
+ background: var(--syntro-background-secondary, #07080a);
4583
+ border-radius: 6px;
4584
+ }
4585
+ `;
4540
4586
  FAQItemEditorLit.properties = {
4541
4587
  itemId: { type: String, attribute: "item-id" },
4542
4588
  appConfig: { attribute: false },
@@ -4581,12 +4627,35 @@ function sm(styles) {
4581
4627
  return styles;
4582
4628
  }
4583
4629
  var ADAPTIVE_ID = "adaptive-faq:accordion";
4630
+ var SORTABLE_STYLE_ID = "syntro-sortable-drag-styles";
4631
+ function ensureSortableStyles() {
4632
+ if (document.getElementById(SORTABLE_STYLE_ID)) return;
4633
+ const style = document.createElement("style");
4634
+ style.id = SORTABLE_STYLE_ID;
4635
+ style.textContent = `
4636
+ .syntro-sortable-dragging {
4637
+ opacity: 0.4;
4638
+ background: rgba(106, 89, 206, 0.08) !important;
4639
+ box-shadow: inset 0 0 0 1px rgba(106, 89, 206, 0.2);
4640
+ transition: opacity 150ms ease, background 150ms ease;
4641
+ }
4642
+ .syntro-sortable-drag-over {
4643
+ background: rgba(106, 89, 206, 0.04) !important;
4644
+ transition: background 150ms ease;
4645
+ }
4646
+ .syntro-sortable-active [data-drag-handle] {
4647
+ cursor: grabbing;
4648
+ }
4649
+ `;
4650
+ document.head.appendChild(style);
4651
+ }
4584
4652
  var ROW_STYLE = {
4585
4653
  position: "relative",
4586
4654
  display: "flex",
4655
+ flexWrap: "wrap",
4587
4656
  alignItems: "center",
4588
4657
  padding: "12px 16px",
4589
- cursor: "pointer",
4658
+ cursor: "default",
4590
4659
  userSelect: "none",
4591
4660
  borderBottom: "1px solid rgba(0, 0, 0, 0.06)",
4592
4661
  transition: "background 0.15s ease"
@@ -4600,7 +4669,15 @@ var QUESTION_STYLE = {
4600
4669
  fontWeight: "500",
4601
4670
  fontSize: "14px",
4602
4671
  lineHeight: "1.4",
4603
- color: "inherit"
4672
+ color: "inherit",
4673
+ cursor: "pointer"
4674
+ };
4675
+ var ANSWER_STYLE = {
4676
+ width: "100%",
4677
+ padding: "4px 16px 8px",
4678
+ fontSize: "13px",
4679
+ lineHeight: "1.5",
4680
+ color: "rgba(0, 0, 0, 0.6)"
4604
4681
  };
4605
4682
  var PENCIL_STYLE = {
4606
4683
  flexShrink: "0",
@@ -4678,6 +4755,7 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4678
4755
  */
4679
4756
  this.liveRegion = null;
4680
4757
  this._hoveredId = null;
4758
+ this._expandedId = null;
4681
4759
  // -------------------------------------------------------------------------
4682
4760
  // Private sortable state
4683
4761
  // -------------------------------------------------------------------------
@@ -4689,6 +4767,10 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4689
4767
  createRenderRoot() {
4690
4768
  return this;
4691
4769
  }
4770
+ connectedCallback() {
4771
+ super.connectedCallback();
4772
+ ensureSortableStyles();
4773
+ }
4692
4774
  // -------------------------------------------------------------------------
4693
4775
  // Lifecycle — sortable wiring
4694
4776
  // -------------------------------------------------------------------------
@@ -4731,18 +4813,19 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4731
4813
  if (this.controller.isModalOpen()) return;
4732
4814
  this.controller.editItem(ADAPTIVE_ID, itemId, this.tileId || void 0);
4733
4815
  }
4734
- _handleRowDblClick(itemId) {
4735
- this._handleEdit(itemId);
4736
- }
4737
4816
  _handlePencilClick(e, itemId) {
4738
4817
  e.stopPropagation();
4739
4818
  this._handleEdit(itemId);
4740
4819
  }
4820
+ _toggleExpand(itemId) {
4821
+ this._expandedId = this._expandedId === itemId ? null : itemId;
4822
+ }
4741
4823
  // -------------------------------------------------------------------------
4742
4824
  // Render helpers
4743
4825
  // -------------------------------------------------------------------------
4744
4826
  _renderRow(item, showHandles) {
4745
4827
  const isHovered = this._hoveredId === item.config.id;
4828
+ const isExpanded = this._expandedId === item.config.id;
4746
4829
  const rowStyle = isHovered ? ROW_HOVER_STYLE : ROW_STYLE;
4747
4830
  const pencilStyle = isHovered ? PENCIL_VISIBLE_STYLE : PENCIL_STYLE;
4748
4831
  return html11`
@@ -4750,7 +4833,6 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4750
4833
  data-faq-editable-row
4751
4834
  data-item-id=${item.config.id}
4752
4835
  style=${styleMap4(sm(rowStyle))}
4753
- @dblclick=${() => this._handleRowDblClick(item.config.id)}
4754
4836
  @mouseenter=${() => {
4755
4837
  this._hoveredId = item.config.id;
4756
4838
  }}
@@ -4767,7 +4849,10 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4767
4849
  >⠿</span>
4768
4850
  ` : nothing6}
4769
4851
 
4770
- <span style=${styleMap4(sm(QUESTION_STYLE))}>${item.config.question}</span>
4852
+ <span
4853
+ style=${styleMap4(sm(QUESTION_STYLE))}
4854
+ @click=${() => this._toggleExpand(item.config.id)}
4855
+ >${item.config.question}</span>
4771
4856
 
4772
4857
  <button
4773
4858
  type="button"
@@ -4778,6 +4863,8 @@ var FAQAccordionEditableElement = class extends LitElement10 {
4778
4863
  aria-label="Edit ${item.config.question}"
4779
4864
  @click=${(e) => this._handlePencilClick(e, item.config.id)}
4780
4865
  >✏️</button>
4866
+
4867
+ ${isExpanded && item.config.answer ? html11`<div data-faq-answer style=${styleMap4(sm(ANSWER_STYLE))}>${item.config.answer}</div>` : nothing6}
4781
4868
  </div>
4782
4869
  `;
4783
4870
  }
@@ -4840,7 +4927,8 @@ FAQAccordionEditableElement.properties = {
4840
4927
  controller: { attribute: false },
4841
4928
  tileId: { attribute: false },
4842
4929
  // Internal hover state per item id
4843
- _hoveredId: { state: true }
4930
+ _hoveredId: { state: true },
4931
+ _expandedId: { state: true }
4844
4932
  };
4845
4933
  if (!customElements.get("syntro-faq-accordion-editable")) {
4846
4934
  customElements.define("syntro-faq-accordion-editable", FAQAccordionEditableElement);