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.
- package/dist/cjs/client/IntlayerBinding.cjs +93 -1
- package/dist/cjs/client/index.cjs +28 -1
- package/dist/cjs/client/installIntlayer.cjs +6 -1
- package/dist/cjs/client/useDictionary.cjs +24 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +47 -1
- package/dist/cjs/client/useIntlayer.cjs +30 -1
- package/dist/cjs/client/useLocale.cjs +90 -1
- package/dist/cjs/client/useLocaleStorage.cjs +56 -1
- package/dist/cjs/client/useRewriteURL.cjs +48 -1
- package/dist/cjs/editor/useEditor.cjs +3 -1
- package/dist/cjs/format/index.cjs +19 -1
- package/dist/cjs/format/useCompact.cjs +34 -1
- package/dist/cjs/format/useCurrency.cjs +34 -1
- package/dist/cjs/format/useDate.cjs +52 -1
- package/dist/cjs/format/useIntl.cjs +66 -1
- package/dist/cjs/format/useList.cjs +34 -1
- package/dist/cjs/format/useNumber.cjs +40 -1
- package/dist/cjs/format/usePercentage.cjs +34 -1
- package/dist/cjs/format/useRelativeTime.cjs +34 -1
- package/dist/cjs/format/useUnit.cjs +34 -1
- package/dist/cjs/getDictionary.cjs +14 -1
- package/dist/cjs/getIntlayer.cjs +14 -1
- package/dist/cjs/html/HTMLRenderer.cjs +53 -1
- package/dist/cjs/html/index.cjs +8 -1
- package/dist/cjs/html/installIntlayerHTML.cjs +90 -1
- package/dist/cjs/html/types.cjs +1 -1
- package/dist/cjs/index.cjs +41 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +97 -1
- package/dist/cjs/markdown/compiler.cjs +72 -1
- package/dist/cjs/markdown/index.cjs +12 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
- package/dist/cjs/markdown/runtime.cjs +86 -1
- package/dist/cjs/plugins.cjs +217 -3
- package/dist/cjs/renderIntlayerNode.cjs +29 -1
- package/dist/esm/client/IntlayerBinding.mjs +75 -33
- package/dist/esm/client/index.mjs +9 -9
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs +22 -10
- package/dist/esm/client/useDictionaryDynamic.mjs +44 -11
- package/dist/esm/client/useIntlayer.mjs +28 -10
- package/dist/esm/client/useLocale.mjs +71 -19
- package/dist/esm/client/useLocaleStorage.mjs +45 -12
- package/dist/esm/client/useRewriteURL.mjs +36 -18
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/format/index.mjs +10 -10
- package/dist/esm/format/useCompact.mjs +23 -19
- package/dist/esm/format/useCurrency.mjs +23 -19
- package/dist/esm/format/useDate.mjs +37 -27
- package/dist/esm/format/useIntl.mjs +54 -13
- package/dist/esm/format/useList.mjs +23 -19
- package/dist/esm/format/useNumber.mjs +29 -19
- package/dist/esm/format/usePercentage.mjs +23 -19
- package/dist/esm/format/useRelativeTime.mjs +23 -19
- package/dist/esm/format/useUnit.mjs +23 -19
- package/dist/esm/getDictionary.mjs +11 -6
- package/dist/esm/getIntlayer.mjs +11 -6
- package/dist/esm/html/HTMLRenderer.mjs +38 -13
- package/dist/esm/html/index.mjs +3 -3
- package/dist/esm/html/installIntlayerHTML.mjs +82 -13
- package/dist/esm/index.mjs +12 -12
- package/dist/esm/markdown/MarkdownRenderer.mjs +66 -26
- package/dist/esm/markdown/compiler.mjs +68 -22
- package/dist/esm/markdown/index.mjs +4 -4
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +87 -23
- package/dist/esm/markdown/runtime.mjs +58 -28
- package/dist/esm/plugins.mjs +156 -106
- package/dist/esm/renderIntlayerNode.mjs +17 -17
- package/dist/installIntlayer-CCMOc1XT.mjs +174 -0
- package/dist/installIntlayer-HB8aIQ-i.js +203 -0
- package/package.json +7 -7
- package/dist/installIntlayer-CFvvijL7.js +0 -1
- package/dist/installIntlayer-CTpPd7yz.mjs +0 -82
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { currency
|
|
2
|
-
import { r as
|
|
1
|
+
import { currency } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useCurrency.ts
|
|
4
|
-
var
|
|
4
|
+
var CurrencyController = class {
|
|
5
5
|
host;
|
|
6
6
|
_unsubscribe = null;
|
|
7
7
|
value;
|
|
8
|
-
constructor(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
28
|
+
this._unsubscribe?.();
|
|
29
|
+
this._unsubscribe = null;
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
31
|
+
};
|
|
32
|
+
var useCurrency = (host) => new CurrencyController(host);
|
|
33
|
+
export { useCurrency };
|
|
@@ -1,41 +1,51 @@
|
|
|
1
|
-
import { date
|
|
2
|
-
import { r as
|
|
1
|
+
import { date, presets } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useDate.ts
|
|
4
|
-
|
|
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(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
|
|
13
|
-
...
|
|
14
|
-
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
|
-
...
|
|
17
|
-
locale:
|
|
19
|
+
...args[1],
|
|
20
|
+
locale: args[1]?.locale ?? client.locale
|
|
18
21
|
};
|
|
19
|
-
return
|
|
20
|
-
}
|
|
22
|
+
return date(args[0], options);
|
|
23
|
+
};
|
|
24
|
+
host.addController(this);
|
|
21
25
|
}
|
|
22
26
|
hostConnected() {
|
|
23
|
-
|
|
24
|
-
this._unsubscribe =
|
|
25
|
-
this.value = (...
|
|
26
|
-
|
|
27
|
-
...
|
|
28
|
-
locale:
|
|
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
|
-
...
|
|
31
|
-
locale:
|
|
34
|
+
...args[1],
|
|
35
|
+
locale: args[1]?.locale ?? newLocale
|
|
32
36
|
};
|
|
33
|
-
return
|
|
34
|
-
}
|
|
37
|
+
return date(args[0], options);
|
|
38
|
+
};
|
|
39
|
+
this.host.requestUpdate();
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
hostDisconnected() {
|
|
38
|
-
this._unsubscribe?.()
|
|
43
|
+
this._unsubscribe?.();
|
|
44
|
+
this._unsubscribe = null;
|
|
39
45
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
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
|
|
2
|
-
import { r as
|
|
1
|
+
import { bindIntl } from "@intlayer/core/utils";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useIntl.ts
|
|
4
|
-
|
|
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(
|
|
10
|
-
this.host =
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
this._unsubscribe =
|
|
17
|
-
this.value =
|
|
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?.()
|
|
33
|
+
this._unsubscribe?.();
|
|
34
|
+
this._unsubscribe = null;
|
|
22
35
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
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
|
|
2
|
-
import { r as
|
|
1
|
+
import { list } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useList.ts
|
|
4
|
-
var
|
|
4
|
+
var ListController = class {
|
|
5
5
|
host;
|
|
6
6
|
_unsubscribe = null;
|
|
7
7
|
value;
|
|
8
|
-
constructor(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
28
|
+
this._unsubscribe?.();
|
|
29
|
+
this._unsubscribe = null;
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
31
|
+
};
|
|
32
|
+
var useList = (host) => new ListController(host);
|
|
33
|
+
export { useList };
|
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
import { number
|
|
2
|
-
import { r as
|
|
1
|
+
import { number } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useNumber.ts
|
|
4
|
-
|
|
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(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
31
|
+
this._unsubscribe?.();
|
|
32
|
+
this._unsubscribe = null;
|
|
27
33
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
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
|
|
2
|
-
import { r as
|
|
1
|
+
import { percentage } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/usePercentage.ts
|
|
4
|
-
var
|
|
4
|
+
var PercentageController = class {
|
|
5
5
|
host;
|
|
6
6
|
_unsubscribe = null;
|
|
7
7
|
value;
|
|
8
|
-
constructor(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
28
|
+
this._unsubscribe?.();
|
|
29
|
+
this._unsubscribe = null;
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
31
|
+
};
|
|
32
|
+
var usePercentage = (host) => new PercentageController(host);
|
|
33
|
+
export { usePercentage };
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { relativeTime
|
|
2
|
-
import { r as
|
|
1
|
+
import { relativeTime } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useRelativeTime.ts
|
|
4
|
-
var
|
|
4
|
+
var RelativeTimeController = class {
|
|
5
5
|
host;
|
|
6
6
|
_unsubscribe = null;
|
|
7
7
|
value;
|
|
8
|
-
constructor(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
28
|
+
this._unsubscribe?.();
|
|
29
|
+
this._unsubscribe = null;
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
31
|
+
};
|
|
32
|
+
var useRelativeTime = (host) => new RelativeTimeController(host);
|
|
33
|
+
export { useRelativeTime };
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { units
|
|
2
|
-
import { r as
|
|
1
|
+
import { units } from "@intlayer/core/formatters";
|
|
2
|
+
import { r as getIntlayerClient } from "../../installIntlayer-CCMOc1XT.mjs";
|
|
3
3
|
// src/format/useUnit.ts
|
|
4
|
-
var
|
|
4
|
+
var UnitController = class {
|
|
5
5
|
host;
|
|
6
6
|
_unsubscribe = null;
|
|
7
7
|
value;
|
|
8
|
-
constructor(
|
|
9
|
-
this.host =
|
|
10
|
-
|
|
11
|
-
this.value = (...
|
|
12
|
-
...
|
|
13
|
-
locale:
|
|
14
|
-
})
|
|
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
|
-
|
|
18
|
-
this._unsubscribe =
|
|
19
|
-
this.value = (...
|
|
20
|
-
...
|
|
21
|
-
locale:
|
|
22
|
-
})
|
|
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?.()
|
|
28
|
+
this._unsubscribe?.();
|
|
29
|
+
this._unsubscribe = null;
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
31
|
+
};
|
|
32
|
+
var useUnit = (host) => new UnitController(host);
|
|
33
|
+
export { useUnit };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { getDictionary as
|
|
2
|
-
import { getPlugins
|
|
1
|
+
import { getDictionary as getDictionary$1 } from "@intlayer/core/interpreter";
|
|
2
|
+
import { getPlugins } from "./plugins.mjs";
|
|
3
3
|
// src/getDictionary.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
13
|
+
export { getDictionary };
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { getIntlayer as
|
|
2
|
-
import { getPlugins
|
|
1
|
+
import { getIntlayer as getIntlayer$1 } from "@intlayer/core/interpreter";
|
|
2
|
+
import { getPlugins } from "./plugins.mjs";
|
|
3
3
|
// src/getIntlayer.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
13
|
+
export { getIntlayer };
|
|
@@ -1,25 +1,50 @@
|
|
|
1
|
-
import { LitElement
|
|
2
|
-
import { unsafeHTML
|
|
3
|
-
import { useHTML
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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:
|
|
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
|
|
20
|
-
|
|
21
|
-
return
|
|
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")
|
|
25
|
-
export {
|
|
49
|
+
if (!customElements.get("intlayer-html-renderer")) customElements.define("intlayer-html-renderer", HTMLRenderer);
|
|
50
|
+
export { HTMLRenderer, renderHTML, useHTMLRenderer };
|
package/dist/esm/html/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { renderHTML
|
|
2
|
-
import { installIntlayerHTML
|
|
3
|
-
export {
|
|
1
|
+
import { renderHTML, useHTMLRenderer } from "./HTMLRenderer.mjs";
|
|
2
|
+
import { installIntlayerHTML, installIntlayerHTMLDynamic, useHTML } from "./installIntlayerHTML.mjs";
|
|
3
|
+
export { installIntlayerHTML, installIntlayerHTMLDynamic, renderHTML, useHTML, useHTMLRenderer };
|