selfstore 1.7.3 → 1.7.5

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/widgets.d.ts CHANGED
@@ -8,8 +8,6 @@ import './machine-ALMkT3mk.js';
8
8
 
9
9
  /** Flat key -> string map; widgets merge a partial override over EN defaults. */
10
10
  type WidgetLabels = Record<string, string>;
11
- /** The common shell: shadow root + styles, label merging, focus-preserving
12
- * re-render, event emission, subscription cleanup. */
13
11
  declare abstract class FlowWidget extends HTMLElement {
14
12
  protected root: ShadowRoot;
15
13
  private styleEl;
@@ -50,6 +48,10 @@ declare abstract class FlowWidget extends HTMLElement {
50
48
  /** Map a flow error to copy: labels can override per labelKey
51
49
  * ('error.targetUnavailable', ...), with a generic fallback. */
52
50
  protected errorText(labelKey: string | undefined): string;
51
+ /** Hands back whatever the host set before this class existed, then the
52
+ * subclass reads its attributes and wires itself. Subclasses override this
53
+ * and call `super.connectedCallback()` FIRST, for that reason. */
54
+ connectedCallback(): void;
53
55
  protected emit(name: string, detail?: unknown): void;
54
56
  /** Rebuild the body, keeping the focused input's value and focus across the
55
57
  * rebuild (inputs carry data-keep so typing survives a snapshot change). */
@@ -57,22 +59,6 @@ declare abstract class FlowWidget extends HTMLElement {
57
59
  disconnectedCallback(): void;
58
60
  }
59
61
 
60
- /**
61
- * <selfstore-connect>: the "where does my data live" journey, ready to drop
62
- * in. A thin skin over connectFlow - every ordering and failure rule lives in
63
- * the flow (and its tests); this element only renders the snapshot and calls
64
- * the actions. Theme it with --selfstore-* custom properties and ::part()
65
- * selectors; reword or localize it through the `labels` property.
66
- *
67
- * import { defineSelfstoreWidgets } from 'selfstore/widgets';
68
- * defineSelfstoreWidgets();
69
- *
70
- * const el = document.querySelector('selfstore-connect');
71
- * el.store = store; // simple store (or a FlowHost)
72
- * el.targets = { drive: gisDriveAuth({ clientId }), file: true };
73
- * el.addEventListener('selfstore-connected', (e) => ...e.detail.outcome...);
74
- */
75
-
76
62
  /** A named WebDAV provider offered in the connect form's quick-pick row, so a
77
63
  * user can start from their host instead of a blank URL field. selfstore ships
78
64
  * no list - the app supplies whichever providers it wants to surface (its own
package/dist/widgets.js CHANGED
@@ -7,6 +7,24 @@ import './chunk-QBCU7OOP.js';
7
7
  import './chunk-CM3HSBCE.js';
8
8
  import './chunk-SFF7KKM4.js';
9
9
 
10
+ // src/widgets/icons.ts
11
+ var INK = "#8a8f98";
12
+ var svg = (body) => `data:image/svg+xml,${encodeURIComponent(
13
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${INK}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`
14
+ )}`;
15
+ var defaultIcons = {
16
+ drive: svg('<path d="M7 18h10a4 4 0 0 0 .6-7.96A6 6 0 0 0 6.2 9.2 3.9 3.9 0 0 0 7 18Z"/>'),
17
+ file: svg(
18
+ '<path d="M14 3H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7Z"/><path d="M14 3v4h4"/>'
19
+ ),
20
+ webdav: svg(
21
+ '<rect x="3" y="4" width="18" height="7" rx="2"/><rect x="3" y="13" width="18" height="7" rx="2"/><path d="M7 7.5h.01M7 16.5h.01"/>'
22
+ ),
23
+ s3: svg(
24
+ '<path d="M4.5 6h15l-1.4 13a2 2 0 0 1-2 1.8H7.9a2 2 0 0 1-2-1.8Z"/><path d="M4.5 6c0-1.1 3.4-2 7.5-2s7.5.9 7.5 2"/>'
25
+ )
26
+ };
27
+
10
28
  // src/widgets/base.ts
11
29
  var baseStyles = `
12
30
  :host {
@@ -337,6 +355,16 @@ function h(tag, attrs = {}, ...children) {
337
355
  }
338
356
  return el;
339
357
  }
358
+ function upgradeOwnProperties(el) {
359
+ const proto = Object.getPrototypeOf(el);
360
+ const bag = el;
361
+ for (const name of Object.getOwnPropertyNames(el)) {
362
+ if (!(name in proto)) continue;
363
+ const value = bag[name];
364
+ delete bag[name];
365
+ bag[name] = value;
366
+ }
367
+ }
340
368
  var FlowWidget = class extends HTMLElement {
341
369
  root;
342
370
  styleEl;
@@ -404,6 +432,12 @@ var FlowWidget = class extends HTMLElement {
404
432
  }
405
433
  return this.t("error.generic");
406
434
  }
435
+ /** Hands back whatever the host set before this class existed, then the
436
+ * subclass reads its attributes and wires itself. Subclasses override this
437
+ * and call `super.connectedCallback()` FIRST, for that reason. */
438
+ connectedCallback() {
439
+ upgradeOwnProperties(this);
440
+ }
407
441
  emit(name, detail) {
408
442
  this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
409
443
  }
@@ -674,6 +708,7 @@ var SelfstoreConnectElement = class extends FlowWidget {
674
708
  }
675
709
  }
676
710
  connectedCallback() {
711
+ super.connectedCallback();
677
712
  if (this.#recommended === null && this.hasAttribute("recommended")) {
678
713
  this.recommended = this.getAttribute("recommended");
679
714
  }
@@ -911,7 +946,7 @@ var SelfstoreConnectElement = class extends FlowWidget {
911
946
  return h("label", { part: "labelled" }, h("span", { part: "label" }, this.t(labelKey)), input);
912
947
  }
913
948
  destCard(kind) {
914
- const icon = this.#icons[kind];
949
+ const icon = this.#icons[kind] ?? defaultIcons[kind];
915
950
  const head = icon ? h("img", { part: "icon", src: icon, alt: "" }) : null;
916
951
  const title = h(
917
952
  "div",
@@ -1391,6 +1426,7 @@ var SelfstoreShareElement = class extends FlowWidget {
1391
1426
  if (name === "with-members") this.withMembers = value == null || !isOff(value);
1392
1427
  }
1393
1428
  connectedCallback() {
1429
+ super.connectedCallback();
1394
1430
  this.wire();
1395
1431
  }
1396
1432
  wire() {
@@ -1679,6 +1715,7 @@ var SelfstoreJoinElement = class extends FlowWidget {
1679
1715
  if (name === "variant") this.variant = value ?? "card";
1680
1716
  }
1681
1717
  connectedCallback() {
1718
+ super.connectedCallback();
1682
1719
  if (!this.#link && this.hasAttribute("link")) this.#link = this.getAttribute("link");
1683
1720
  if (this.hasAttribute("variant")) {
1684
1721
  this.#variant = this.getAttribute("variant") === "banner" ? "banner" : "card";
@@ -1905,6 +1942,7 @@ var SelfstoreStatusElement = class extends FlowWidget {
1905
1942
  if (name === "variant") this.variant = value;
1906
1943
  }
1907
1944
  connectedCallback() {
1945
+ super.connectedCallback();
1908
1946
  if (this.hasAttribute("variant")) this.variant = this.getAttribute("variant");
1909
1947
  this.wire();
1910
1948
  }
@@ -2259,6 +2297,7 @@ var SelfstoreBackupsElement = class extends FlowWidget {
2259
2297
  if (name === "with-shared") this.withShared = on;
2260
2298
  }
2261
2299
  connectedCallback() {
2300
+ super.connectedCallback();
2262
2301
  this.wire();
2263
2302
  }
2264
2303
  /** Re-list the rows from the destination (the host calls this after a
@@ -3342,6 +3381,7 @@ var SelfstoreGateElement = class extends FlowWidget {
3342
3381
  if (name === "deferrable") this.deferrable = value !== "false";
3343
3382
  }
3344
3383
  connectedCallback() {
3384
+ super.connectedCallback();
3345
3385
  if (this.hasAttribute("armed")) this.armed = this.getAttribute("armed") !== "false";
3346
3386
  if (this.hasAttribute("deferrable")) {
3347
3387
  this.deferrable = this.getAttribute("deferrable") !== "false";