@dxos/lit-ui 0.10.0 → 0.11.0

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.
@@ -1,9 +1,10 @@
1
1
  import { LitElement } from 'lit';
2
2
  import { type Size } from '../defs';
3
3
  export declare class DxIcon extends LitElement {
4
+ #private;
4
5
  size: Size;
5
6
  icon: string;
6
- noCache: boolean;
7
+ disconnectedCallback(): void;
7
8
  render(): import("lit").TemplateResult<2>;
8
9
  createRenderRoot(): this;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dx-icon.d.ts","sourceRoot":"","sources":["../../../src/dx-icon/dx-icon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AAGtC,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAIpC,qBACa,MAAO,SAAQ,UAAU;IAGpC,IAAI,EAAE,IAAI,CAAK;IAGf,IAAI,EAAE,MAAM,CAAgC;IAG5C,OAAO,EAAE,OAAO,CAAQ;IAEf,MAAM,oCAId;IAEQ,gBAAgB,IAAI,IAAI,CAEhC;CACF"}
1
+ {"version":3,"file":"dx-icon.d.ts","sourceRoot":"","sources":["../../../src/dx-icon/dx-icon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AAGtC,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAepC,qBACa,MAAO,SAAQ,UAAU;;IAGpC,IAAI,EAAE,IAAI,CAAK;IAGf,IAAI,EAAE,MAAM,CAAgC;IAInC,oBAAoB,IAAI,IAAI,CAGpC;IAEQ,MAAM,oCAYd;IAEQ,gBAAgB,IAAI,IAAI,CAEhC;CAiBF"}
@@ -9,23 +9,51 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
9
9
  };
10
10
  import { LitElement, svg } from 'lit';
11
11
  import { customElement, property } from 'lit/decorators.js';
12
- const ICONS_URL = '/icons.svg';
12
+ // Shared with @dxos/react-ui's IconRegistry; see IconRegistry.tsx for the bridge contract.
13
+ const REGISTRY_GLOBAL = '__dxIconRegistry';
14
+ const getRegistry = () => globalThis[REGISTRY_GLOBAL];
13
15
  let DxIcon = class DxIcon extends LitElement {
14
16
  constructor() {
15
17
  super(...arguments);
16
18
  // TODO(thure): Get Hue type used in theme.
17
19
  this.size = 4;
18
20
  this.icon = 'ph--circle-dashed--regular';
19
- this.noCache = true;
21
+ }
22
+ #unsubscribe;
23
+ disconnectedCallback() {
24
+ super.disconnectedCallback();
25
+ this.#unwatchRegistry();
20
26
  }
21
27
  render() {
22
- const url = this.noCache ? `${ICONS_URL}?nocache=${new Date().getMinutes()}` : ICONS_URL;
23
- const href = `${url}#${this.icon}`;
28
+ const registry = getRegistry();
29
+ if (registry && !registry.hasIcon(this.icon)) {
30
+ registry.requestIcon(this.icon);
31
+ // Omit the <use> while unresolved, mirroring useIconHref: the subscription re-renders
32
+ // once the symbol lands rather than leaving a transient broken ref in the DOM.
33
+ this.#watchRegistry(registry);
34
+ return svg `<svg class="dx-icon" data-size=${this.size}></svg>`;
35
+ }
36
+ this.#unwatchRegistry();
37
+ const href = `#${this.icon}`;
24
38
  return svg `<svg class="dx-icon" data-size=${this.size}><use href=${href} /></svg>`;
25
39
  }
26
40
  createRenderRoot() {
27
41
  return this;
28
42
  }
43
+ #watchRegistry(registry) {
44
+ if (this.#unsubscribe) {
45
+ return;
46
+ }
47
+ this.#unsubscribe = registry.subscribe(() => {
48
+ if (registry.hasIcon(this.icon)) {
49
+ this.requestUpdate();
50
+ }
51
+ });
52
+ }
53
+ #unwatchRegistry() {
54
+ this.#unsubscribe?.();
55
+ this.#unsubscribe = undefined;
56
+ }
29
57
  };
30
58
  __decorate([
31
59
  property({ type: String })
@@ -33,9 +61,6 @@ __decorate([
33
61
  __decorate([
34
62
  property({ type: String })
35
63
  ], DxIcon.prototype, "icon", void 0);
36
- __decorate([
37
- property({ type: Boolean })
38
- ], DxIcon.prototype, "noCache", void 0);
39
64
  DxIcon = __decorate([
40
65
  customElement('dx-icon')
41
66
  ], DxIcon);
@@ -1 +1 @@
1
- {"version":3,"file":"dx-icon.js","sourceRoot":"","sources":["../../../src/dx-icon/dx-icon.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;AAEF,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI5D,MAAM,SAAS,GAAG,YAAY,CAAC;AAGxB,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QACL,2CAA2C;QAE3C,SAAI,GAAS,CAAC,CAAC;QAGf,SAAI,GAAW,4BAA4B,CAAC;QAG5C,YAAO,GAAY,IAAI,CAAC;IAW1B,CAAC;IATU,MAAM;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,YAAY,IAAI,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACzF,MAAM,IAAI,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,GAAG,CAAA,kCAAkC,IAAI,CAAC,IAAI,cAAc,IAAI,WAAW,CAAC;IACrF,CAAC;IAEQ,gBAAgB;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAjBC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACZ;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACiB;AAG5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACJ;AATb,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAoBlB"}
1
+ {"version":3,"file":"d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