@sebgroup/green-core 1.0.3 → 1.1.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.
package/index.js CHANGED
@@ -143,7 +143,7 @@ function watchMediaQuery(q) {
143
143
  // libs/core/src/utils/helpers/custom-element-scoping.ts
144
144
  import { html as litHtml } from "lit";
145
145
  import { customElement } from "lit/decorators.js";
146
- var VER_SUFFIX = "-0c50fd";
146
+ var VER_SUFFIX = "-0863bc";
147
147
  var elementLookupTable = /* @__PURE__ */ new Map();
148
148
  var gdsCustomElement = (tagName) => {
149
149
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
package/localization.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './utils/localization';
1
+ export * from './utils/localization/localization';
package/localization.js CHANGED
@@ -4,7 +4,7 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // libs/core/src/utils/localization.ts
7
+ // libs/core/src/utils/localization/localization.ts
8
8
  import { configureLocalization } from "@lit/localize";
9
9
 
10
10
  // libs/core/src/generated/locale-codes.ts
@@ -26,20 +26,32 @@ var templates = {
26
26
  "sd898d99fd9c13de6": `S\xF6k i listan av val`
27
27
  };
28
28
 
29
- // libs/core/src/utils/localization.ts
29
+ // libs/core/src/utils/localization/localization.ts
30
30
  var localizedTemplates = /* @__PURE__ */ new Map([["sv", sv_exports]]);
31
- var { getLocale, setLocale } = configureLocalization({
32
- sourceLocale,
33
- targetLocales,
34
- loadLocale: async (locale) => {
35
- const localModule = localizedTemplates.get(locale);
36
- if (localModule) {
37
- return localModule;
38
- }
39
- return Promise.reject(new Error(`Locale ${locale} not found`));
31
+ var gdsInitLocalization = ({ extraLocales, extraTemplates } = {
32
+ extraLocales: [],
33
+ extraTemplates: /* @__PURE__ */ new Map()
34
+ }) => {
35
+ const _targetLocales = [...targetLocales];
36
+ for (const [locale, template] of extraTemplates) {
37
+ localizedTemplates.set(locale, template);
40
38
  }
41
- });
39
+ for (const locale of extraLocales) {
40
+ _targetLocales.push(locale);
41
+ }
42
+ return configureLocalization({
43
+ sourceLocale,
44
+ targetLocales: _targetLocales,
45
+ loadLocale: async (locale) => {
46
+ const localModule = localizedTemplates.get(locale);
47
+ if (localModule) {
48
+ return localModule;
49
+ }
50
+ return Promise.reject(new Error(`Locale ${locale} not found`));
51
+ }
52
+ });
53
+ };
42
54
  export {
43
- getLocale,
44
- setLocale
55
+ gdsInitLocalization,
56
+ targetLocales
45
57
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sebgroup/green-core",
3
3
  "description": "A carefully crafted set of Web Components, laying the foundation of the Green Design System.",
4
- "version": "1.0.3",
4
+ "version": "1.1.0",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -5797,7 +5797,7 @@ function register3() {
5797
5797
  // libs/core/src/utils/helpers/custom-element-scoping.ts
5798
5798
  import { html as litHtml } from "lit";
5799
5799
  import { customElement } from "lit/decorators.js";
5800
- var VER_SUFFIX = "-0c50fd";
5800
+ var VER_SUFFIX = "-0863bc";
5801
5801
  var elementLookupTable = /* @__PURE__ */ new Map();
5802
5802
  var templateCache = /* @__PURE__ */ new WeakMap();
5803
5803
  function applyElementScoping(strings, ...values) {
@@ -0,0 +1,26 @@
1
+ import { targetLocales } from '../../generated/locale-codes';
2
+ import * as templates_sv from '../../generated/locales/sv';
3
+ declare const localizedTemplates: Map<string, typeof templates_sv>;
4
+ declare type LocalizationConfig = {
5
+ extraLocales: string[];
6
+ extraTemplates: typeof localizedTemplates;
7
+ };
8
+ /**
9
+ * A list of available built-in locales
10
+ */
11
+ export { targetLocales };
12
+ /**
13
+ * Initializes localization for Green Core. This is a wrapper around Lit's `configureLocalization`,
14
+ * which adds the ability to add extra locales and templates.
15
+ *
16
+ * @param extraLocales - Extra locales to add to the list of target locales
17
+ * @param extraTemplates - Extra templates to add to the list of localized templates
18
+ */
19
+ export declare const gdsInitLocalization: ({ extraLocales, extraTemplates }?: LocalizationConfig) => {
20
+ getLocale: (() => string) & {
21
+ _LIT_LOCALIZE_GET_LOCALE_?: undefined;
22
+ };
23
+ setLocale: ((newLocale: string) => Promise<void>) & {
24
+ _LIT_LOCALIZE_SET_LOCALE_?: undefined;
25
+ };
26
+ };
@@ -1,5 +0,0 @@
1
- export declare const getLocale: (() => string) & {
2
- _LIT_LOCALIZE_GET_LOCALE_?: undefined;
3
- }, setLocale: ((newLocale: string) => Promise<void>) & {
4
- _LIT_LOCALIZE_SET_LOCALE_?: undefined;
5
- };