lit-intlayer 9.9.3 → 9.9.4

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.
Files changed (72) hide show
  1. package/dist/cjs/client/IntlayerBinding.cjs +93 -1
  2. package/dist/cjs/client/index.cjs +28 -1
  3. package/dist/cjs/client/installIntlayer.cjs +6 -1
  4. package/dist/cjs/client/useDictionary.cjs +24 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +47 -1
  6. package/dist/cjs/client/useIntlayer.cjs +30 -1
  7. package/dist/cjs/client/useLocale.cjs +90 -1
  8. package/dist/cjs/client/useLocaleStorage.cjs +56 -1
  9. package/dist/cjs/client/useRewriteURL.cjs +48 -1
  10. package/dist/cjs/editor/useEditor.cjs +3 -1
  11. package/dist/cjs/format/index.cjs +19 -1
  12. package/dist/cjs/format/useCompact.cjs +34 -1
  13. package/dist/cjs/format/useCurrency.cjs +34 -1
  14. package/dist/cjs/format/useDate.cjs +52 -1
  15. package/dist/cjs/format/useIntl.cjs +66 -1
  16. package/dist/cjs/format/useList.cjs +34 -1
  17. package/dist/cjs/format/useNumber.cjs +40 -1
  18. package/dist/cjs/format/usePercentage.cjs +34 -1
  19. package/dist/cjs/format/useRelativeTime.cjs +34 -1
  20. package/dist/cjs/format/useUnit.cjs +34 -1
  21. package/dist/cjs/getDictionary.cjs +14 -1
  22. package/dist/cjs/getIntlayer.cjs +14 -1
  23. package/dist/cjs/html/HTMLRenderer.cjs +53 -1
  24. package/dist/cjs/html/index.cjs +8 -1
  25. package/dist/cjs/html/installIntlayerHTML.cjs +90 -1
  26. package/dist/cjs/html/types.cjs +1 -1
  27. package/dist/cjs/index.cjs +41 -1
  28. package/dist/cjs/markdown/MarkdownRenderer.cjs +97 -1
  29. package/dist/cjs/markdown/compiler.cjs +72 -1
  30. package/dist/cjs/markdown/index.cjs +12 -1
  31. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
  32. package/dist/cjs/markdown/runtime.cjs +86 -1
  33. package/dist/cjs/plugins.cjs +217 -3
  34. package/dist/cjs/renderIntlayerNode.cjs +29 -1
  35. package/dist/esm/client/IntlayerBinding.mjs +75 -33
  36. package/dist/esm/client/index.mjs +9 -9
  37. package/dist/esm/client/installIntlayer.mjs +1 -1
  38. package/dist/esm/client/useDictionary.mjs +22 -10
  39. package/dist/esm/client/useDictionaryDynamic.mjs +44 -11
  40. package/dist/esm/client/useIntlayer.mjs +28 -10
  41. package/dist/esm/client/useLocale.mjs +71 -19
  42. package/dist/esm/client/useLocaleStorage.mjs +45 -12
  43. package/dist/esm/client/useRewriteURL.mjs +36 -18
  44. package/dist/esm/editor/useEditor.mjs +1 -1
  45. package/dist/esm/format/index.mjs +10 -10
  46. package/dist/esm/format/useCompact.mjs +23 -19
  47. package/dist/esm/format/useCurrency.mjs +23 -19
  48. package/dist/esm/format/useDate.mjs +37 -27
  49. package/dist/esm/format/useIntl.mjs +54 -13
  50. package/dist/esm/format/useList.mjs +23 -19
  51. package/dist/esm/format/useNumber.mjs +29 -19
  52. package/dist/esm/format/usePercentage.mjs +23 -19
  53. package/dist/esm/format/useRelativeTime.mjs +23 -19
  54. package/dist/esm/format/useUnit.mjs +23 -19
  55. package/dist/esm/getDictionary.mjs +11 -6
  56. package/dist/esm/getIntlayer.mjs +11 -6
  57. package/dist/esm/html/HTMLRenderer.mjs +38 -13
  58. package/dist/esm/html/index.mjs +3 -3
  59. package/dist/esm/html/installIntlayerHTML.mjs +82 -13
  60. package/dist/esm/index.mjs +12 -12
  61. package/dist/esm/markdown/MarkdownRenderer.mjs +66 -26
  62. package/dist/esm/markdown/compiler.mjs +68 -22
  63. package/dist/esm/markdown/index.mjs +4 -4
  64. package/dist/esm/markdown/installIntlayerMarkdown.mjs +87 -23
  65. package/dist/esm/markdown/runtime.mjs +58 -28
  66. package/dist/esm/plugins.mjs +156 -106
  67. package/dist/esm/renderIntlayerNode.mjs +17 -17
  68. package/dist/installIntlayer-CCMOc1XT.mjs +174 -0
  69. package/dist/installIntlayer-HB8aIQ-i.js +203 -0
  70. package/package.json +7 -7
  71. package/dist/installIntlayer-CFvvijL7.js +0 -1
  72. package/dist/installIntlayer-CTpPd7yz.mjs +0 -82
@@ -1,29 +1,33 @@
1
- import { currency as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { currency } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useCurrency.ts
4
- var n = class {
4
+ var CurrencyController = class {
5
5
  host;
6
6
  _unsubscribe = null;
7
7
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], {
12
- ...t[1],
13
- locale: t[1]?.locale ?? r.locale
14
- }), n.addController(this);
8
+ constructor(host) {
9
+ this.host = host;
10
+ const client = getIntlayerClient();
11
+ this.value = (...args) => currency(args[0], {
12
+ ...args[1],
13
+ locale: args[1]?.locale ?? client.locale
14
+ });
15
+ host.addController(this);
15
16
  }
16
17
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], {
20
- ...n[1],
21
- locale: n[1]?.locale ?? t
22
- }), this.host.requestUpdate();
18
+ const client = getIntlayerClient();
19
+ this._unsubscribe = client.subscribe((newLocale) => {
20
+ this.value = (...args) => currency(args[0], {
21
+ ...args[1],
22
+ locale: args[1]?.locale ?? newLocale
23
+ });
24
+ this.host.requestUpdate();
23
25
  });
24
26
  }
25
27
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
28
+ this._unsubscribe?.();
29
+ this._unsubscribe = null;
27
30
  }
28
- }, r = (e) => new n(e);
29
- export { r as useCurrency };
31
+ };
32
+ var useCurrency = (host) => new CurrencyController(host);
33
+ export { useCurrency };
@@ -1,41 +1,51 @@
1
- import { date as e, presets as t } from "@intlayer/core/formatters";
2
- import { r as n } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { date, presets } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useDate.ts
4
- var r = class {
4
+ /**
5
+ * ReactiveController that provides a locale-bound date formatter.
6
+ */
7
+ var DateController = class {
5
8
  host;
6
9
  _unsubscribe = null;
7
10
  value;
8
- constructor(r) {
9
- this.host = r;
10
- let i = n();
11
- this.value = (...n) => {
12
- let r = typeof n[1] == "string" ? {
13
- ...t[n[1]],
14
- locale: i.locale
11
+ constructor(host) {
12
+ this.host = host;
13
+ const client = getIntlayerClient();
14
+ this.value = (...args) => {
15
+ const options = typeof args[1] === "string" ? {
16
+ ...presets[args[1]],
17
+ locale: client.locale
15
18
  } : {
16
- ...n[1],
17
- locale: n[1]?.locale ?? i.locale
19
+ ...args[1],
20
+ locale: args[1]?.locale ?? client.locale
18
21
  };
19
- return e(n[0], r);
20
- }, r.addController(this);
22
+ return date(args[0], options);
23
+ };
24
+ host.addController(this);
21
25
  }
22
26
  hostConnected() {
23
- let r = n();
24
- this._unsubscribe = r.subscribe((n) => {
25
- this.value = (...r) => {
26
- let i = typeof r[1] == "string" ? {
27
- ...t[r[1]],
28
- locale: n
27
+ const client = getIntlayerClient();
28
+ this._unsubscribe = client.subscribe((newLocale) => {
29
+ this.value = (...args) => {
30
+ const options = typeof args[1] === "string" ? {
31
+ ...presets[args[1]],
32
+ locale: newLocale
29
33
  } : {
30
- ...r[1],
31
- locale: r[1]?.locale ?? n
34
+ ...args[1],
35
+ locale: args[1]?.locale ?? newLocale
32
36
  };
33
- return e(r[0], i);
34
- }, this.host.requestUpdate();
37
+ return date(args[0], options);
38
+ };
39
+ this.host.requestUpdate();
35
40
  });
36
41
  }
37
42
  hostDisconnected() {
38
- this._unsubscribe?.(), this._unsubscribe = null;
43
+ this._unsubscribe?.();
44
+ this._unsubscribe = null;
39
45
  }
40
- }, i = (e) => new r(e);
41
- export { i as useDate };
46
+ };
47
+ /**
48
+ * Reactive hook that provides a locale-bound date formatter.
49
+ */
50
+ var useDate = (host) => new DateController(host);
51
+ export { useDate };
@@ -1,24 +1,65 @@
1
- import { bindIntl as e } from "@intlayer/core/utils";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { bindIntl } from "@intlayer/core/utils";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useIntl.ts
4
- var n = class {
4
+ /**
5
+ * ReactiveController that provides a locale-bound `Intl` object.
6
+ *
7
+ * Acts exactly like the native `Intl` namespace but automatically uses the
8
+ * current application locale, updating the host whenever the locale changes.
9
+ *
10
+ * @internal
11
+ */
12
+ var IntlController = class {
5
13
  host;
6
14
  _overrideLocale;
7
15
  _unsubscribe = null;
16
+ /** The locale-bound Intl object. */
8
17
  value;
9
- constructor(n, r) {
10
- this.host = n, this._overrideLocale = r;
11
- let i = t();
12
- this.value = e(this._overrideLocale ?? i.locale), n.addController(this);
18
+ constructor(host, locale) {
19
+ this.host = host;
20
+ this._overrideLocale = locale;
21
+ const client = getIntlayerClient();
22
+ this.value = bindIntl(this._overrideLocale ?? client.locale);
23
+ host.addController(this);
13
24
  }
14
25
  hostConnected() {
15
- let n = t();
16
- this._unsubscribe = n.subscribe((t) => {
17
- this.value = e(this._overrideLocale ?? t), this.host.requestUpdate();
26
+ const client = getIntlayerClient();
27
+ this._unsubscribe = client.subscribe((newLocale) => {
28
+ this.value = bindIntl(this._overrideLocale ?? newLocale);
29
+ this.host.requestUpdate();
18
30
  });
19
31
  }
20
32
  hostDisconnected() {
21
- this._unsubscribe?.(), this._unsubscribe = null;
33
+ this._unsubscribe?.();
34
+ this._unsubscribe = null;
22
35
  }
23
- }, r = (e, t) => new n(e, t);
24
- export { r as useIntl };
36
+ };
37
+ /**
38
+ * Reactive hook that provides a locale-bound `Intl` object.
39
+ *
40
+ * The returned controller's `.value` property gives access to locale-aware
41
+ * `NumberFormat`, `DateTimeFormat`, `RelativeTimeFormat`, etc. without
42
+ * needing to pass the current locale manually.
43
+ *
44
+ * @param host - The LitElement (or any ReactiveControllerHost).
45
+ * @param locale - Optional locale override.
46
+ * @returns An `IntlController` with a `.value: WrappedIntl` property.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * class PriceTag extends LitElement {
51
+ * private intl = useIntl(this);
52
+ *
53
+ * render() {
54
+ * const formatted = new this.intl.value.NumberFormat({
55
+ * style: 'currency',
56
+ * currency: 'USD',
57
+ * }).format(9.99);
58
+ *
59
+ * return html`<span>${formatted}</span>`;
60
+ * }
61
+ * }
62
+ * ```
63
+ */
64
+ var useIntl = (host, locale) => new IntlController(host, locale);
65
+ export { useIntl };
@@ -1,29 +1,33 @@
1
- import { list as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { list } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useList.ts
4
- var n = class {
4
+ var ListController = class {
5
5
  host;
6
6
  _unsubscribe = null;
7
7
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], {
12
- ...t[1],
13
- locale: t[1]?.locale ?? r.locale
14
- }), n.addController(this);
8
+ constructor(host) {
9
+ this.host = host;
10
+ const client = getIntlayerClient();
11
+ this.value = (...args) => list(args[0], {
12
+ ...args[1],
13
+ locale: args[1]?.locale ?? client.locale
14
+ });
15
+ host.addController(this);
15
16
  }
16
17
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], {
20
- ...n[1],
21
- locale: n[1]?.locale ?? t
22
- }), this.host.requestUpdate();
18
+ const client = getIntlayerClient();
19
+ this._unsubscribe = client.subscribe((newLocale) => {
20
+ this.value = (...args) => list(args[0], {
21
+ ...args[1],
22
+ locale: args[1]?.locale ?? newLocale
23
+ });
24
+ this.host.requestUpdate();
23
25
  });
24
26
  }
25
27
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
28
+ this._unsubscribe?.();
29
+ this._unsubscribe = null;
27
30
  }
28
- }, r = (e) => new n(e);
29
- export { r as useList };
31
+ };
32
+ var useList = (host) => new ListController(host);
33
+ export { useList };
@@ -1,29 +1,39 @@
1
- import { number as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { number } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useNumber.ts
4
- var n = class {
4
+ /**
5
+ * ReactiveController that provides a locale-bound number formatter.
6
+ */
7
+ var NumberController = class {
5
8
  host;
6
9
  _unsubscribe = null;
7
10
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], {
12
- ...t[1],
13
- locale: t[1]?.locale ?? r.locale
14
- }), n.addController(this);
11
+ constructor(host) {
12
+ this.host = host;
13
+ const client = getIntlayerClient();
14
+ this.value = (...args) => number(args[0], {
15
+ ...args[1],
16
+ locale: args[1]?.locale ?? client.locale
17
+ });
18
+ host.addController(this);
15
19
  }
16
20
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], {
20
- ...n[1],
21
- locale: n[1]?.locale ?? t
22
- }), this.host.requestUpdate();
21
+ const client = getIntlayerClient();
22
+ this._unsubscribe = client.subscribe((newLocale) => {
23
+ this.value = (...args) => number(args[0], {
24
+ ...args[1],
25
+ locale: args[1]?.locale ?? newLocale
26
+ });
27
+ this.host.requestUpdate();
23
28
  });
24
29
  }
25
30
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
31
+ this._unsubscribe?.();
32
+ this._unsubscribe = null;
27
33
  }
28
- }, r = (e) => new n(e);
29
- export { r as useNumber };
34
+ };
35
+ /**
36
+ * Reactive hook that provides a locale-bound number formatter.
37
+ */
38
+ var useNumber = (host) => new NumberController(host);
39
+ export { useNumber };
@@ -1,29 +1,33 @@
1
- import { percentage as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { percentage } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/usePercentage.ts
4
- var n = class {
4
+ var PercentageController = class {
5
5
  host;
6
6
  _unsubscribe = null;
7
7
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], {
12
- ...t[1],
13
- locale: t[1]?.locale ?? r.locale
14
- }), n.addController(this);
8
+ constructor(host) {
9
+ this.host = host;
10
+ const client = getIntlayerClient();
11
+ this.value = (...args) => percentage(args[0], {
12
+ ...args[1],
13
+ locale: args[1]?.locale ?? client.locale
14
+ });
15
+ host.addController(this);
15
16
  }
16
17
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], {
20
- ...n[1],
21
- locale: n[1]?.locale ?? t
22
- }), this.host.requestUpdate();
18
+ const client = getIntlayerClient();
19
+ this._unsubscribe = client.subscribe((newLocale) => {
20
+ this.value = (...args) => percentage(args[0], {
21
+ ...args[1],
22
+ locale: args[1]?.locale ?? newLocale
23
+ });
24
+ this.host.requestUpdate();
23
25
  });
24
26
  }
25
27
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
28
+ this._unsubscribe?.();
29
+ this._unsubscribe = null;
27
30
  }
28
- }, r = (e) => new n(e);
29
- export { r as usePercentage };
31
+ };
32
+ var usePercentage = (host) => new PercentageController(host);
33
+ export { usePercentage };
@@ -1,29 +1,33 @@
1
- import { relativeTime as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { relativeTime } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useRelativeTime.ts
4
- var n = class {
4
+ var RelativeTimeController = class {
5
5
  host;
6
6
  _unsubscribe = null;
7
7
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], t[1], {
12
- ...t[2],
13
- locale: t[2]?.locale ?? r.locale
14
- }), n.addController(this);
8
+ constructor(host) {
9
+ this.host = host;
10
+ const client = getIntlayerClient();
11
+ this.value = (...args) => relativeTime(args[0], args[1], {
12
+ ...args[2],
13
+ locale: args[2]?.locale ?? client.locale
14
+ });
15
+ host.addController(this);
15
16
  }
16
17
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], n[1], {
20
- ...n[2],
21
- locale: n[2]?.locale ?? t
22
- }), this.host.requestUpdate();
18
+ const client = getIntlayerClient();
19
+ this._unsubscribe = client.subscribe((newLocale) => {
20
+ this.value = (...args) => relativeTime(args[0], args[1], {
21
+ ...args[2],
22
+ locale: args[2]?.locale ?? newLocale
23
+ });
24
+ this.host.requestUpdate();
23
25
  });
24
26
  }
25
27
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
28
+ this._unsubscribe?.();
29
+ this._unsubscribe = null;
27
30
  }
28
- }, r = (e) => new n(e);
29
- export { r as useRelativeTime };
31
+ };
32
+ var useRelativeTime = (host) => new RelativeTimeController(host);
33
+ export { useRelativeTime };
@@ -1,29 +1,33 @@
1
- import { units as e } from "@intlayer/core/formatters";
2
- import { r as t } from "../../installIntlayer-CTpPd7yz.mjs";
1
+ import { units } from "@intlayer/core/formatters";
2
+ import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
3
3
  // src/format/useUnit.ts
4
- var n = class {
4
+ var UnitController = class {
5
5
  host;
6
6
  _unsubscribe = null;
7
7
  value;
8
- constructor(n) {
9
- this.host = n;
10
- let r = t();
11
- this.value = (...t) => e(t[0], {
12
- ...t[1],
13
- locale: t[1]?.locale ?? r.locale
14
- }), n.addController(this);
8
+ constructor(host) {
9
+ this.host = host;
10
+ const client = getIntlayerClient();
11
+ this.value = (...args) => units(args[0], {
12
+ ...args[1],
13
+ locale: args[1]?.locale ?? client.locale
14
+ });
15
+ host.addController(this);
15
16
  }
16
17
  hostConnected() {
17
- let n = t();
18
- this._unsubscribe = n.subscribe((t) => {
19
- this.value = (...n) => e(n[0], {
20
- ...n[1],
21
- locale: n[1]?.locale ?? t
22
- }), this.host.requestUpdate();
18
+ const client = getIntlayerClient();
19
+ this._unsubscribe = client.subscribe((newLocale) => {
20
+ this.value = (...args) => units(args[0], {
21
+ ...args[1],
22
+ locale: args[1]?.locale ?? newLocale
23
+ });
24
+ this.host.requestUpdate();
23
25
  });
24
26
  }
25
27
  hostDisconnected() {
26
- this._unsubscribe?.(), this._unsubscribe = null;
28
+ this._unsubscribe?.();
29
+ this._unsubscribe = null;
27
30
  }
28
- }, r = (e) => new n(e);
29
- export { r as useUnit };
31
+ };
32
+ var useUnit = (host) => new UnitController(host);
33
+ export { useUnit };
@@ -1,8 +1,13 @@
1
- import { getDictionary as e } from "@intlayer/core/interpreter";
2
- import { getPlugins as t } from "./plugins.mjs";
1
+ import { getDictionary as getDictionary$1 } from "@intlayer/core/interpreter";
2
+ import { getPlugins } from "./plugins.mjs";
3
3
  // src/getDictionary.ts
4
- var n = (n, r) => {
5
- let i = typeof r == "object" && r ? r.locale : r;
6
- return e(n, r, t(i));
4
+ /**
5
+ * Transforms a dictionary (or qualified dictionary group) and returns its
6
+ * content for the given locale or selector (`{ item }`, `{ variant }`,
7
+ * optionally combined with `locale`).
8
+ */
9
+ var getDictionary = (dictionary, localeOrSelector) => {
10
+ const locale = typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector;
11
+ return getDictionary$1(dictionary, localeOrSelector, getPlugins(locale));
7
12
  };
8
- export { n as getDictionary };
13
+ export { getDictionary };
@@ -1,8 +1,13 @@
1
- import { getIntlayer as e } from "@intlayer/core/interpreter";
2
- import { getPlugins as t } from "./plugins.mjs";
1
+ import { getIntlayer as getIntlayer$1 } from "@intlayer/core/interpreter";
2
+ import { getPlugins } from "./plugins.mjs";
3
3
  // src/getIntlayer.ts
4
- var n = (n, r) => {
5
- let i = typeof r == "object" && r ? r.locale : r;
6
- return e(n, r, t(i));
4
+ /**
5
+ * Picks one dictionary by its key and returns its content for the given
6
+ * locale or selector (`{ item }`, `{ variant }`,
7
+ * optionally combined with `locale`).
8
+ */
9
+ var getIntlayer = (key, localeOrSelector) => {
10
+ const locale = typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector;
11
+ return getIntlayer$1(key, localeOrSelector, getPlugins(locale));
7
12
  };
8
- export { n as getIntlayer };
13
+ export { getIntlayer };
@@ -1,25 +1,50 @@
1
- import { LitElement as e, html as t, nothing as n } from "lit";
2
- import { unsafeHTML as r } from "lit/directives/unsafe-html.js";
3
- import { useHTML as i } from "./installIntlayerHTML.mjs";
1
+ import { LitElement, html, nothing } from "lit";
2
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
3
+ import { useHTML } from "./installIntlayerHTML.mjs";
4
4
  // src/html/HTMLRenderer.ts
5
- var a = (e, t = {}) => e, o = ({ components: e } = {}) => {
6
- let t = i();
7
- return (n) => t.renderHTML(n, { components: e });
8
- }, s = class extends e {
5
+ /**
6
+ * Renders an HTML string directly, without a global provider.
7
+ * Returns the raw string; pass to `unsafeHTML()` in a Lit template.
8
+ */
9
+ var renderHTML = (content, _props = {}) => content;
10
+ /**
11
+ * Returns a render function that uses the global provider's configuration
12
+ * (installed via `installIntlayerHTML`), falling back to identity.
13
+ */
14
+ var useHTMLRenderer = ({ components } = {}) => {
15
+ const context = useHTML();
16
+ return (content) => context.renderHTML(content, { components });
17
+ };
18
+ /**
19
+ * `<intlayer-html-renderer>` — renders an HTML string into the light DOM.
20
+ *
21
+ * Uses the globally installed HTML renderer when available
22
+ * (see `installIntlayerHTML`), or falls back to `unsafeHTML` with the raw string.
23
+ *
24
+ * @example
25
+ * ```html
26
+ * <intlayer-html-renderer content="<strong>Hello</strong> World">
27
+ * </intlayer-html-renderer>
28
+ * ```
29
+ */
30
+ var HTMLRenderer = class extends LitElement {
9
31
  static properties = {
10
32
  content: { type: String },
11
- components: { attribute: !1 }
33
+ components: { attribute: false }
12
34
  };
35
+ /** The HTML string to render. */
13
36
  content = "";
37
+ /** Optional component overrides for HTML tags. */
14
38
  components;
39
+ /** Render into light DOM so host-page CSS can style the output. */
15
40
  createRenderRoot() {
16
41
  return this;
17
42
  }
18
43
  render() {
19
- if (!this.content) return n;
20
- let e = o({ components: this.components });
21
- return t`${r(e(this.content))}`;
44
+ if (!this.content) return nothing;
45
+ const renderer = useHTMLRenderer({ components: this.components });
46
+ return html`${unsafeHTML(renderer(this.content))}`;
22
47
  }
23
48
  };
24
- customElements.get("intlayer-html-renderer") || customElements.define("intlayer-html-renderer", s);
25
- export { s as HTMLRenderer, a as renderHTML, o as useHTMLRenderer };
49
+ if (!customElements.get("intlayer-html-renderer")) customElements.define("intlayer-html-renderer", HTMLRenderer);
50
+ export { HTMLRenderer, renderHTML, useHTMLRenderer };
@@ -1,3 +1,3 @@
1
- import { renderHTML as e, useHTMLRenderer as t } from "./HTMLRenderer.mjs";
2
- import { installIntlayerHTML as n, installIntlayerHTMLDynamic as r, useHTML as i } from "./installIntlayerHTML.mjs";
3
- export { n as installIntlayerHTML, r as installIntlayerHTMLDynamic, e as renderHTML, i as useHTML, t as useHTMLRenderer };
1
+ import { renderHTML, useHTMLRenderer } from "./HTMLRenderer.mjs";
2
+ import { installIntlayerHTML, installIntlayerHTMLDynamic, useHTML } from "./installIntlayerHTML.mjs";
3
+ export { installIntlayerHTML, installIntlayerHTMLDynamic, renderHTML, useHTML, useHTMLRenderer };