@sebgroup/green-core 1.0.2 → 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/generated/locales/sv.d.ts +1 -0
- package/index.js +13 -8
- package/localization.d.ts +1 -1
- package/localization.js +27 -14
- package/package.json +1 -1
- package/transitional-styles.js +2 -1
- package/utils/localization/localization.d.ts +26 -0
- package/utils/localization.d.ts +0 -5
package/index.js
CHANGED
|
@@ -9,9 +9,9 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
9
|
__defProp(target, key, result);
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
|
-
var __accessCheck = (obj, member,
|
|
12
|
+
var __accessCheck = (obj, member, msg3) => {
|
|
13
13
|
if (!member.has(obj))
|
|
14
|
-
throw TypeError("Cannot " +
|
|
14
|
+
throw TypeError("Cannot " + msg3);
|
|
15
15
|
};
|
|
16
16
|
var __privateGet = (obj, member, getter) => {
|
|
17
17
|
__accessCheck(obj, member, "read from private field");
|
|
@@ -38,7 +38,7 @@ import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
|
38
38
|
import { when as when2 } from "lit/directives/when.js";
|
|
39
39
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
40
40
|
import { createRef as createRef3, ref as ref3 } from "lit/directives/ref.js";
|
|
41
|
-
import { msg, str, updateWhenLocaleChanges } from "@lit/localize";
|
|
41
|
+
import { msg as msg2, str, updateWhenLocaleChanges } from "@lit/localize";
|
|
42
42
|
import "reflect-metadata";
|
|
43
43
|
|
|
44
44
|
// libs/core/src/utils/helpers/constrain-slots.ts
|
|
@@ -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 = "-
|
|
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) {
|
|
@@ -559,6 +559,7 @@ GdsListbox = __decorateClass([
|
|
|
559
559
|
// libs/core/src/primitives/popover/popover.ts
|
|
560
560
|
import { LitElement as LitElement3, html as html3, unsafeCSS as unsafeCSS3 } from "lit";
|
|
561
561
|
import { property as property3 } from "lit/decorators.js";
|
|
562
|
+
import { msg } from "@lit/localize";
|
|
562
563
|
import { createRef as createRef2, ref as ref2 } from "lit/directives/ref.js";
|
|
563
564
|
import { computePosition, autoUpdate, offset, flip } from "@floating-ui/dom";
|
|
564
565
|
|
|
@@ -804,7 +805,11 @@ var GdsPopover = class extends LitElement3 {
|
|
|
804
805
|
return html3`<dialog ${ref2(__privateGet(this, _dialogElementRef))}>
|
|
805
806
|
<header>
|
|
806
807
|
<h2>${this.label}</h2>
|
|
807
|
-
<button
|
|
808
|
+
<button
|
|
809
|
+
class="close"
|
|
810
|
+
@click=${__privateGet(this, _handleCloseButton)}
|
|
811
|
+
aria-label="${msg("Close")}"
|
|
812
|
+
>
|
|
808
813
|
<i></i>
|
|
809
814
|
</button>
|
|
810
815
|
</header>
|
|
@@ -1156,7 +1161,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1156
1161
|
get displayValue() {
|
|
1157
1162
|
let displayValue;
|
|
1158
1163
|
if (Array.isArray(this.value)) {
|
|
1159
|
-
this.value.length > 2 ? displayValue =
|
|
1164
|
+
this.value.length > 2 ? displayValue = msg2(str`${this.value.length} selected`) : displayValue = this.value.reduce(
|
|
1160
1165
|
(acc, cur) => acc + this.options.find((v) => v.value === cur)?.innerHTML + ", ",
|
|
1161
1166
|
""
|
|
1162
1167
|
).slice(0, -2);
|
|
@@ -1201,8 +1206,8 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1201
1206
|
this.searchable,
|
|
1202
1207
|
() => html`<input
|
|
1203
1208
|
type="text"
|
|
1204
|
-
aria-label="${
|
|
1205
|
-
placeholder="${
|
|
1209
|
+
aria-label="${msg2("Filter available options")}"
|
|
1210
|
+
placeholder="${msg2("Search")}"
|
|
1206
1211
|
${ref3(__privateGet(this, _searchInputRef))}
|
|
1207
1212
|
@keydown=${__privateGet(this, _handleSearchFieldKeyDown)}
|
|
1208
1213
|
@keyup=${__privateGet(this, _handleSearchFieldKeyUp)}
|
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
|
|
@@ -22,23 +22,36 @@ import { str } from "@lit/localize";
|
|
|
22
22
|
var templates = {
|
|
23
23
|
"s58bfb494feb8eb02": str`${0} valda`,
|
|
24
24
|
"s5d929ff1619ac0c9": `S\xF6k`,
|
|
25
|
+
"s5e8250fb85d64c23": `St\xE4ng`,
|
|
25
26
|
"sd898d99fd9c13de6": `S\xF6k i listan av val`
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
// libs/core/src/utils/localization.ts
|
|
29
|
+
// libs/core/src/utils/localization/localization.ts
|
|
29
30
|
var localizedTemplates = /* @__PURE__ */ new Map([["sv", sv_exports]]);
|
|
30
|
-
var {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
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);
|
|
39
38
|
}
|
|
40
|
-
|
|
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
|
+
};
|
|
41
54
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
gdsInitLocalization,
|
|
56
|
+
targetLocales
|
|
44
57
|
};
|
package/package.json
CHANGED
package/transitional-styles.js
CHANGED
|
@@ -5668,6 +5668,7 @@ button {
|
|
|
5668
5668
|
max-width: 100%;
|
|
5669
5669
|
font-size: inherit;
|
|
5670
5670
|
font-weight: normal;
|
|
5671
|
+
line-height: 1.125;
|
|
5671
5672
|
margin-bottom: 0.5rem;
|
|
5672
5673
|
margin-top: 0.5rem;
|
|
5673
5674
|
width: 100%;
|
|
@@ -5796,7 +5797,7 @@ function register3() {
|
|
|
5796
5797
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
5797
5798
|
import { html as litHtml } from "lit";
|
|
5798
5799
|
import { customElement } from "lit/decorators.js";
|
|
5799
|
-
var VER_SUFFIX = "-
|
|
5800
|
+
var VER_SUFFIX = "-0863bc";
|
|
5800
5801
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
5801
5802
|
var templateCache = /* @__PURE__ */ new WeakMap();
|
|
5802
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
|
+
};
|