@mochabug/adapt-web 1.0.0-rc52 → 1.0.0-rc54

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.
@@ -10,8 +10,10 @@ const OBSERVED_ATTRIBUTES = [
10
10
  "fork-display-mode",
11
11
  "side-by-side-split",
12
12
  "dialog-backdrop-close",
13
+ "dialog-resize-to-content",
13
14
  "dark-mode",
14
15
  "auto-resizing",
16
+ "persist",
15
17
  ];
16
18
  /**
17
19
  * `<adapt-automation>` custom element for embedding Adapt automations.
@@ -20,7 +22,7 @@ const OBSERVED_ATTRIBUTES = [
20
22
  * - `automation-id` (string, required) — recreates client on change
21
23
  * - `session-token`, `auth-token`, `transmitter`, `challenge-token`,
22
24
  * `requires-challenge`, `inherit-token`, `side-by-side-split` — read at creation only
23
- * - `fork-display-mode`, `dialog-backdrop-close`, `dark-mode`, `auto-resizing` — mutable at runtime
25
+ * - `fork-display-mode`, `dialog-backdrop-close`, `dialog-resize-to-content`, `dark-mode`, `auto-resizing` — mutable at runtime
24
26
  *
25
27
  * Properties (non-serializable, set via JS):
26
28
  * - `signals`, `capWidgetOptions`, `inheritFrom`, `classNames`, `styles`
@@ -95,6 +97,36 @@ export class AdaptAutomationElement extends BaseElement {
95
97
  this.removeAttribute("dialog-backdrop-close");
96
98
  }
97
99
  }
100
+ get dialogResizeToContent() {
101
+ return this.hasAttribute("dialog-resize-to-content");
102
+ }
103
+ set dialogResizeToContent(v) {
104
+ if (v) {
105
+ this.setAttribute("dialog-resize-to-content", "");
106
+ }
107
+ else {
108
+ this.removeAttribute("dialog-resize-to-content");
109
+ }
110
+ }
111
+ get persist() {
112
+ return this.hasAttribute("persist");
113
+ }
114
+ set persist(v) {
115
+ if (v) {
116
+ this.setAttribute("persist", "");
117
+ }
118
+ else {
119
+ this.removeAttribute("persist");
120
+ }
121
+ }
122
+ /**
123
+ * Clear persisted state, stop current session, and reinitialize fresh.
124
+ */
125
+ async newSession() {
126
+ if (this._client) {
127
+ await this._client.newSession();
128
+ }
129
+ }
98
130
  // --- Lifecycle ---
99
131
  connectedCallback() {
100
132
  // Defer to next microtask to avoid TDZ issues from circular imports
@@ -107,7 +139,7 @@ export class AdaptAutomationElement extends BaseElement {
107
139
  attributeChangedCallback(name, oldValue, newValue) {
108
140
  if (oldValue === newValue)
109
141
  return;
110
- if (name === "automation-id") {
142
+ if (name === "automation-id" || name === "persist") {
111
143
  this._destroyClient();
112
144
  queueMicrotask(() => this._tryInit());
113
145
  return;
@@ -122,6 +154,9 @@ export class AdaptAutomationElement extends BaseElement {
122
154
  case "dialog-backdrop-close":
123
155
  this._client.setDialogBackdropClose(this.dialogBackdropClose);
124
156
  break;
157
+ case "dialog-resize-to-content":
158
+ this._client.setDialogResizeToContent(this.dialogResizeToContent);
159
+ break;
125
160
  case "dark-mode":
126
161
  this._client.setDarkMode(this.darkMode);
127
162
  break;
@@ -146,12 +181,28 @@ export class AdaptAutomationElement extends BaseElement {
146
181
  const requiresChallenge = this.hasAttribute("requires-challenge");
147
182
  const inheritToken = this.getAttribute("inherit-token");
148
183
  const sideBySideSplitAttr = this.getAttribute("side-by-side-split");
184
+ // Build ForkDisplay union from flat attributes
185
+ let forkDisplay;
186
+ if (this.forkDisplayMode === "dialog") {
187
+ forkDisplay = {
188
+ mode: "dialog",
189
+ backdropClose: this.dialogBackdropClose,
190
+ resizeToContent: this.dialogResizeToContent,
191
+ };
192
+ }
193
+ else {
194
+ forkDisplay = {
195
+ mode: "side-by-side",
196
+ ...(sideBySideSplitAttr !== null && {
197
+ split: Number(sideBySideSplitAttr),
198
+ }),
199
+ };
200
+ }
149
201
  // Build options conditionally to satisfy exactOptionalPropertyTypes
150
202
  const options = {
151
203
  container: this,
152
204
  id: automationId,
153
- forkDisplayMode: this.forkDisplayMode,
154
- dialogBackdropClose: this.dialogBackdropClose,
205
+ forkDisplay,
155
206
  darkMode: this.darkMode,
156
207
  autoResizing: this.autoResizing,
157
208
  onSession: (status, fork) => {
@@ -188,8 +239,6 @@ export class AdaptAutomationElement extends BaseElement {
188
239
  options.requiresChallenge = true;
189
240
  if (inheritToken)
190
241
  options.inheritToken = inheritToken;
191
- if (sideBySideSplitAttr !== null)
192
- options.sideBySideSplit = Number(sideBySideSplitAttr);
193
242
  if (this.signals !== undefined)
194
243
  options.signals = this.signals;
195
244
  if (this.capWidgetOptions !== undefined)
@@ -200,6 +249,13 @@ export class AdaptAutomationElement extends BaseElement {
200
249
  options.classNames = this.classNames;
201
250
  if (this.styles !== undefined)
202
251
  options.styles = this.styles;
252
+ // Persist: object options take precedence, otherwise use boolean attribute
253
+ if (this.persistOptions !== undefined) {
254
+ options.persist = this.persistOptions;
255
+ }
256
+ else if (this.persist) {
257
+ options.persist = true;
258
+ }
203
259
  this._client = new AdaptWebClient(options);
204
260
  }
205
261
  _destroyClient() {
@@ -222,4 +278,3 @@ if (typeof customElements !== "undefined" &&
222
278
  document.head.appendChild(s);
223
279
  }
224
280
  }
225
- //# sourceMappingURL=AdaptAutomationElement.js.map
@@ -145,4 +145,3 @@ if (typeof customElements !== "undefined" &&
145
145
  document.head.appendChild(s);
146
146
  }
147
147
  }
148
- //# sourceMappingURL=AdaptCapElement.js.map
@@ -122,6 +122,8 @@ export class AdaptCapWidget {
122
122
  align-items: center;
123
123
  justify-content: center;
124
124
  padding: 16px;
125
+ flex-shrink: 0;
126
+ min-height: calc(var(--mb-cap-height) + 32px);
125
127
  }
126
128
 
127
129
  /* Cap Widget */
@@ -285,4 +287,3 @@ export class AdaptCapWidget {
285
287
  this.widgetElement = null;
286
288
  }
287
289
  }
288
- //# sourceMappingURL=AdaptCapWidget.js.map
@@ -144,4 +144,3 @@ export function cleanupCapAdapter() {
144
144
  currentClient = null;
145
145
  currentAutomationId = null;
146
146
  }
147
- //# sourceMappingURL=cap-adapter.js.map
@@ -2,4 +2,3 @@
2
2
  // Usage: import "@mochabug/adapt-web/elements";
3
3
  import "./AdaptAutomationElement.js";
4
4
  import "./AdaptCapElement.js";
5
- //# sourceMappingURL=elements.js.map
@@ -22,4 +22,3 @@
22
22
  export function getIframeSrc(url, token) {
23
23
  return `${url}${token ? `#mb_token=${encodeURIComponent(token)}` : ""}`;
24
24
  }
25
- //# sourceMappingURL=iframe-url.js.map