ds-one 0.2.5-alpha.8 → 0.2.5-alpha.9
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/DS1/0-face/i18n.ts +36 -89
- package/DS1/1-root/one.css +1 -1
- package/DS1/2-core/ds-button.ts +6 -9
- package/DS1/2-core/ds-cycle.ts +9 -9
- package/DS1/2-core/ds-tooltip.ts +2 -8
- package/README.md +2 -2
- package/dist/0-face/i18n.d.ts +0 -2
- package/dist/0-face/i18n.d.ts.map +1 -1
- package/dist/0-face/i18n.js +36 -73
- package/dist/2-core/ds-button.d.ts +2 -7
- package/dist/2-core/ds-button.d.ts.map +1 -1
- package/dist/2-core/ds-button.js +5 -7
- package/dist/2-core/ds-cycle.d.ts.map +1 -1
- package/dist/2-core/ds-cycle.js +9 -7
- package/dist/2-core/ds-tooltip.d.ts +1 -1
- package/dist/2-core/ds-tooltip.d.ts.map +1 -1
- package/dist/2-core/ds-tooltip.js +2 -8
- package/dist/ds-one.bundle.js +50 -92
- package/dist/ds-one.bundle.js.map +2 -2
- package/dist/ds-one.bundle.min.js +19 -15
- package/dist/ds-one.bundle.min.js.map +3 -3
- package/package.json +1 -2
package/DS1/0-face/i18n.ts
CHANGED
|
@@ -15,15 +15,15 @@ let translationKeys: TranslationMap = {};
|
|
|
15
15
|
// Primary language list – prioritise the 10 requested languages when cycling
|
|
16
16
|
const LANGUAGE_PRIORITY_ORDER = [
|
|
17
17
|
"da",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"pt",
|
|
18
|
+
"de",
|
|
19
|
+
"en",
|
|
21
20
|
"es",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"fr",
|
|
22
|
+
"it",
|
|
24
23
|
"ja",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
24
|
+
"pt",
|
|
25
|
+
"sv",
|
|
26
|
+
"zh",
|
|
27
27
|
] as const;
|
|
28
28
|
|
|
29
29
|
const LANGUAGE_PRIORITY_LOOKUP = new Map<string, number>(
|
|
@@ -34,27 +34,27 @@ const LANGUAGE_PRIORITY_LOOKUP = new Map<string, number>(
|
|
|
34
34
|
const FALLBACK_LANGUAGE_NAMES: Record<string, string> = {
|
|
35
35
|
da: "Danish",
|
|
36
36
|
"da-dk": "Danish",
|
|
37
|
-
nb: "Norwegian",
|
|
38
|
-
"nb-no": "Norwegian",
|
|
39
|
-
sv: "Swedish",
|
|
40
|
-
"sv-se": "Swedish",
|
|
41
37
|
de: "German",
|
|
42
38
|
"de-de": "German",
|
|
43
39
|
en: "English",
|
|
44
40
|
"en-us": "English",
|
|
45
|
-
pt: "Portuguese",
|
|
46
|
-
"pt-pt": "Portuguese",
|
|
47
|
-
"pt-br": "Portuguese (Brazil)",
|
|
48
41
|
es: "Spanish",
|
|
49
42
|
"es-es": "Spanish",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
43
|
+
fr: "French",
|
|
44
|
+
"fr-fr": "French",
|
|
45
|
+
it: "Italian",
|
|
46
|
+
"it-it": "Italian",
|
|
54
47
|
ja: "Japanese",
|
|
55
48
|
"ja-jp": "Japanese",
|
|
56
|
-
|
|
57
|
-
"
|
|
49
|
+
pt: "Portuguese",
|
|
50
|
+
"pt-pt": "Portuguese",
|
|
51
|
+
sv: "Swedish",
|
|
52
|
+
"sv-se": "Swedish",
|
|
53
|
+
zh: "Chinese",
|
|
54
|
+
"zh-cn": "Chinese",
|
|
55
|
+
"zh-tw": "Chinese",
|
|
56
|
+
"zh-hans": "Chinese",
|
|
57
|
+
"zh-hant": "Chinese",
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
const DISPLAY_NAME_CACHE = new Map<string, Intl.DisplayNames>();
|
|
@@ -263,9 +263,6 @@ function getTranslationData(): TranslationMap {
|
|
|
263
263
|
// Cached translation data - use getter to always get fresh data
|
|
264
264
|
let translationData = getTranslationData();
|
|
265
265
|
|
|
266
|
-
type NotionCache = Map<string, string>;
|
|
267
|
-
|
|
268
|
-
const notionStore = new Map<LanguageCode, NotionCache>();
|
|
269
266
|
const defaultLanguage: LanguageCode = "en";
|
|
270
267
|
|
|
271
268
|
function extractPrimarySubtag(code: LanguageCode): string {
|
|
@@ -409,33 +406,30 @@ export function getLanguageDisplayName(
|
|
|
409
406
|
const BROWSER_LANGUAGE_PREFERENCES: Record<string, LanguageCode> = {
|
|
410
407
|
da: "da",
|
|
411
408
|
"da-dk": "da",
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
"
|
|
417
|
-
sv: "sv",
|
|
418
|
-
"sv-se": "sv",
|
|
419
|
-
pt: "pt",
|
|
420
|
-
"pt-pt": "pt",
|
|
421
|
-
"pt-br": "pt",
|
|
409
|
+
de: "de",
|
|
410
|
+
"de-de": "de",
|
|
411
|
+
en: "en",
|
|
412
|
+
"en-us": "en",
|
|
413
|
+
"en-gb": "en",
|
|
422
414
|
es: "es",
|
|
423
415
|
"es-es": "es",
|
|
424
416
|
"es-mx": "es",
|
|
417
|
+
fr: "fr",
|
|
418
|
+
"fr-fr": "fr",
|
|
419
|
+
it: "it",
|
|
420
|
+
"it-it": "it",
|
|
421
|
+
ja: "ja",
|
|
422
|
+
"ja-jp": "ja",
|
|
423
|
+
pt: "pt",
|
|
424
|
+
"pt-pt": "pt",
|
|
425
|
+
"pt-br": "pt",
|
|
426
|
+
sv: "sv",
|
|
427
|
+
"sv-se": "sv",
|
|
425
428
|
zh: "zh",
|
|
426
429
|
"zh-cn": "zh",
|
|
427
430
|
"zh-hans": "zh",
|
|
428
431
|
"zh-tw": "zh",
|
|
429
432
|
"zh-hant": "zh",
|
|
430
|
-
ko: "ko",
|
|
431
|
-
"ko-kr": "ko",
|
|
432
|
-
ja: "ja",
|
|
433
|
-
"ja-jp": "ja",
|
|
434
|
-
en: "en",
|
|
435
|
-
"en-us": "en",
|
|
436
|
-
"en-gb": "en",
|
|
437
|
-
de: "de",
|
|
438
|
-
"de-de": "de",
|
|
439
433
|
};
|
|
440
434
|
|
|
441
435
|
function resolvePreferredLanguage(languageTag: string): LanguageCode | null {
|
|
@@ -532,7 +526,6 @@ if (typeof window !== "undefined") {
|
|
|
532
526
|
|
|
533
527
|
// Dispatch that translations are loaded
|
|
534
528
|
window.dispatchEvent(new CustomEvent("translations-loaded"));
|
|
535
|
-
(window as any).notionDataLoaded = true;
|
|
536
529
|
|
|
537
530
|
// Dispatch language-changed to update all components
|
|
538
531
|
const currentLang = currentLanguage.value;
|
|
@@ -551,7 +544,6 @@ if (typeof window !== "undefined") {
|
|
|
551
544
|
setTimeout(() => {
|
|
552
545
|
// Since we directly imported the data, just dispatch the events
|
|
553
546
|
window.dispatchEvent(new CustomEvent("translations-loaded"));
|
|
554
|
-
(window as any).notionDataLoaded = true;
|
|
555
547
|
|
|
556
548
|
// Also dispatch language-changed with the current language
|
|
557
549
|
const currentLang = currentLanguage.value;
|
|
@@ -614,51 +606,6 @@ export function getText(key: string): string {
|
|
|
614
606
|
return translate(key);
|
|
615
607
|
}
|
|
616
608
|
|
|
617
|
-
// Get text from translation data (async for compatibility)
|
|
618
|
-
export async function getNotionText(
|
|
619
|
-
key: string,
|
|
620
|
-
language: LanguageCode = currentLanguage.value
|
|
621
|
-
): Promise<string | null> {
|
|
622
|
-
if (!key) {
|
|
623
|
-
return null;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
if (!translationData || !translationData[language]) {
|
|
627
|
-
return null;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
const text = translationData[language][key];
|
|
631
|
-
if (text) {
|
|
632
|
-
return text;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// Fallback to English
|
|
636
|
-
if (language !== defaultLanguage && translationData[defaultLanguage]?.[key]) {
|
|
637
|
-
return translationData[defaultLanguage][key];
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// Store Notion text (for dynamic updates)
|
|
644
|
-
export function setNotionText(
|
|
645
|
-
key: string,
|
|
646
|
-
value: string,
|
|
647
|
-
language: LanguageCode = currentLanguage.value
|
|
648
|
-
): void {
|
|
649
|
-
if (!key) return;
|
|
650
|
-
|
|
651
|
-
const bucket = getLanguageBucket(language);
|
|
652
|
-
bucket.set(key, value);
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
function getLanguageBucket(language: LanguageCode): NotionCache {
|
|
656
|
-
if (!notionStore.has(language)) {
|
|
657
|
-
notionStore.set(language, new Map());
|
|
658
|
-
}
|
|
659
|
-
return notionStore.get(language)!;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
609
|
// Get available languages - dynamically detect from loaded data
|
|
663
610
|
export function getAvailableLanguages(): Promise<LanguageCode[]> {
|
|
664
611
|
// Always get fresh translation data
|
package/DS1/1-root/one.css
CHANGED
package/DS1/2-core/ds-button.ts
CHANGED
|
@@ -15,14 +15,13 @@ export class Button extends LitElement {
|
|
|
15
15
|
attribute: "no-background",
|
|
16
16
|
},
|
|
17
17
|
blank: { type: Boolean, reflect: true },
|
|
18
|
-
notionKey: { type: String, attribute: "notion-key" },
|
|
19
18
|
key: { type: String },
|
|
20
19
|
fallback: { type: String },
|
|
21
20
|
language: { type: String },
|
|
22
21
|
defaultText: { type: String, attribute: "default-text" },
|
|
23
22
|
href: { type: String },
|
|
24
23
|
_loading: { type: Boolean, state: true },
|
|
25
|
-
|
|
24
|
+
_text: { type: String, state: true },
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
// Public properties
|
|
@@ -31,7 +30,6 @@ export class Button extends LitElement {
|
|
|
31
30
|
declare bold: boolean;
|
|
32
31
|
declare "no-background": boolean;
|
|
33
32
|
declare blank: boolean;
|
|
34
|
-
declare notionKey: string | null;
|
|
35
33
|
declare key: string;
|
|
36
34
|
declare fallback: string;
|
|
37
35
|
declare language: string;
|
|
@@ -40,7 +38,7 @@ export class Button extends LitElement {
|
|
|
40
38
|
|
|
41
39
|
// Private state
|
|
42
40
|
declare _loading: boolean;
|
|
43
|
-
declare
|
|
41
|
+
declare _text: string | null;
|
|
44
42
|
|
|
45
43
|
constructor() {
|
|
46
44
|
super();
|
|
@@ -49,14 +47,13 @@ export class Button extends LitElement {
|
|
|
49
47
|
this.bold = false;
|
|
50
48
|
this["no-background"] = false;
|
|
51
49
|
this.blank = false;
|
|
52
|
-
this.notionKey = null;
|
|
53
50
|
this.key = "";
|
|
54
51
|
this.fallback = "";
|
|
55
52
|
this.language = "en-US";
|
|
56
53
|
this.defaultText = "";
|
|
57
54
|
this.href = "";
|
|
58
55
|
this._loading = false;
|
|
59
|
-
this.
|
|
56
|
+
this._text = null;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
static styles = css`
|
|
@@ -141,9 +138,9 @@ export class Button extends LitElement {
|
|
|
141
138
|
*/
|
|
142
139
|
private _updateText() {
|
|
143
140
|
if (this.key) {
|
|
144
|
-
this.
|
|
141
|
+
this._text = getText(this.key);
|
|
145
142
|
} else {
|
|
146
|
-
this.
|
|
143
|
+
this._text = this.defaultText || this.fallback || null;
|
|
147
144
|
}
|
|
148
145
|
this.requestUpdate();
|
|
149
146
|
}
|
|
@@ -157,7 +154,7 @@ export class Button extends LitElement {
|
|
|
157
154
|
?no-background=${this["no-background"]}
|
|
158
155
|
@click=${this._handleClick}
|
|
159
156
|
>
|
|
160
|
-
${this.
|
|
157
|
+
${this._text ? this._text : html`<slot></slot>`}
|
|
161
158
|
</button>
|
|
162
159
|
`;
|
|
163
160
|
}
|
package/DS1/2-core/ds-cycle.ts
CHANGED
|
@@ -186,9 +186,6 @@ export class Cycle extends LitElement {
|
|
|
186
186
|
|
|
187
187
|
// Apply the accent color to ensure it's active
|
|
188
188
|
applyAccentColor();
|
|
189
|
-
|
|
190
|
-
// Set label
|
|
191
|
-
this.label = this.getLabel();
|
|
192
189
|
} else if (this.type === "notes-style-medium") {
|
|
193
190
|
// Set up notes style medium cycling
|
|
194
191
|
this.values = ["default", "big", "gallery"];
|
|
@@ -272,9 +269,6 @@ export class Cycle extends LitElement {
|
|
|
272
269
|
|
|
273
270
|
// Apply the accent color to ensure it's active
|
|
274
271
|
applyAccentColor();
|
|
275
|
-
|
|
276
|
-
// Update label
|
|
277
|
-
this.label = this.getLabel();
|
|
278
272
|
} else if (this.type === "notes-style-medium") {
|
|
279
273
|
// Get current notes style medium
|
|
280
274
|
const currentNotesStyle = getNotesStyleMedium();
|
|
@@ -495,8 +489,8 @@ export class Cycle extends LitElement {
|
|
|
495
489
|
} else if (this.type === "theme") {
|
|
496
490
|
// Try to get translated theme name
|
|
497
491
|
if (this.translationsReady) {
|
|
498
|
-
const translatedName = translate(
|
|
499
|
-
if (translatedName && translatedName !==
|
|
492
|
+
const translatedName = translate(value);
|
|
493
|
+
if (translatedName && translatedName !== value) {
|
|
500
494
|
return translatedName;
|
|
501
495
|
}
|
|
502
496
|
}
|
|
@@ -654,7 +648,13 @@ export class Cycle extends LitElement {
|
|
|
654
648
|
default-value="Theme"
|
|
655
649
|
class="cycle-label"
|
|
656
650
|
></ds-text>`
|
|
657
|
-
:
|
|
651
|
+
: this.type === "accent-color"
|
|
652
|
+
? html`<ds-text
|
|
653
|
+
key="accentColor"
|
|
654
|
+
default-value="Accent color"
|
|
655
|
+
class="cycle-label"
|
|
656
|
+
></ds-text>`
|
|
657
|
+
: html`<span class="cycle-label">${this.label}</span>`}`
|
|
658
658
|
: ""}
|
|
659
659
|
<div
|
|
660
660
|
style="display: flex; align-items: center; ${this.type === "icon-only"
|
package/DS1/2-core/ds-tooltip.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { translate
|
|
2
|
+
import { translate } from "../0-face/i18n";
|
|
3
3
|
|
|
4
4
|
export class Tooltip extends LitElement {
|
|
5
5
|
static properties = {
|
|
@@ -152,7 +152,7 @@ export class Tooltip extends LitElement {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
_loadText(): void {
|
|
156
156
|
if (!this.key) {
|
|
157
157
|
this._text = this.defaultValue || "";
|
|
158
158
|
this.requestUpdate();
|
|
@@ -160,12 +160,6 @@ export class Tooltip extends LitElement {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
try {
|
|
163
|
-
const notionText = await getNotionText(this.key);
|
|
164
|
-
if (notionText) {
|
|
165
|
-
this._text = notionText;
|
|
166
|
-
this.requestUpdate();
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
163
|
const t = translate(this.key);
|
|
170
164
|
this._text = t && t !== this.key ? t : this.defaultValue || this.key;
|
|
171
165
|
} catch (err) {
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DS one (0.2.5-alpha.
|
|
1
|
+
# DS one (0.2.5-alpha.9)
|
|
2
2
|
|
|
3
3
|
A plug and play design system
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ yarn add ds-one@alpha
|
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
**Note**: Currently published as alpha version `0.2.5-alpha.
|
|
23
|
+
**Note**: Currently published as alpha version `0.2.5-alpha.9`
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
package/dist/0-face/i18n.d.ts
CHANGED
|
@@ -19,8 +19,6 @@ export declare const currentLanguage: {
|
|
|
19
19
|
export declare function translate(key: string): string;
|
|
20
20
|
export declare function hasTranslation(key: string, language?: LanguageCode): boolean;
|
|
21
21
|
export declare function getText(key: string): string;
|
|
22
|
-
export declare function getNotionText(key: string, language?: LanguageCode): Promise<string | null>;
|
|
23
|
-
export declare function setNotionText(key: string, value: string, language?: LanguageCode): void;
|
|
24
22
|
export declare function getAvailableLanguages(): Promise<LanguageCode[]>;
|
|
25
23
|
export declare function getAvailableLanguagesSync(): LanguageCode[];
|
|
26
24
|
export declare function loadTranslations(language: LanguageCode, translations: TranslationData): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../DS1/0-face/i18n.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAGlC,KAAK,eAAe,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAyDF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACtD,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../DS1/0-face/i18n.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAGlC,KAAK,eAAe,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAyDF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACtD,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF;AA+RD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,MAAM,CA6CR;AAqDD,wBAAgB,kBAAkB,IAAI,YAAY,CAwBjD;AAWD,eAAO,MAAM,eAAe;;gBAGL,YAAY;CAWlC,CAAC;AAuDF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,YAAoC,GAC7C,OAAO,CAmBT;AAGD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAGD,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAS/D;AAGD,wBAAgB,yBAAyB,IAAI,YAAY,EAAE,CAO1D;AAGD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,eAAe,GAC5B,IAAI,CAON;AAGD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAgBxD"}
|
package/dist/0-face/i18n.js
CHANGED
|
@@ -4,42 +4,42 @@ let translationKeys = {};
|
|
|
4
4
|
// Primary language list – prioritise the 10 requested languages when cycling
|
|
5
5
|
const LANGUAGE_PRIORITY_ORDER = [
|
|
6
6
|
"da",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"pt",
|
|
7
|
+
"de",
|
|
8
|
+
"en",
|
|
10
9
|
"es",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"fr",
|
|
11
|
+
"it",
|
|
13
12
|
"ja",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
13
|
+
"pt",
|
|
14
|
+
"sv",
|
|
15
|
+
"zh",
|
|
16
16
|
];
|
|
17
17
|
const LANGUAGE_PRIORITY_LOOKUP = new Map(LANGUAGE_PRIORITY_ORDER.map((code, index) => [code, index]));
|
|
18
18
|
// Fallback language names if Intl.DisplayNames is not available
|
|
19
19
|
const FALLBACK_LANGUAGE_NAMES = {
|
|
20
20
|
da: "Danish",
|
|
21
21
|
"da-dk": "Danish",
|
|
22
|
-
nb: "Norwegian",
|
|
23
|
-
"nb-no": "Norwegian",
|
|
24
|
-
sv: "Swedish",
|
|
25
|
-
"sv-se": "Swedish",
|
|
26
22
|
de: "German",
|
|
27
23
|
"de-de": "German",
|
|
28
24
|
en: "English",
|
|
29
25
|
"en-us": "English",
|
|
30
|
-
pt: "Portuguese",
|
|
31
|
-
"pt-pt": "Portuguese",
|
|
32
|
-
"pt-br": "Portuguese (Brazil)",
|
|
33
26
|
es: "Spanish",
|
|
34
27
|
"es-es": "Spanish",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
28
|
+
fr: "French",
|
|
29
|
+
"fr-fr": "French",
|
|
30
|
+
it: "Italian",
|
|
31
|
+
"it-it": "Italian",
|
|
39
32
|
ja: "Japanese",
|
|
40
33
|
"ja-jp": "Japanese",
|
|
41
|
-
|
|
42
|
-
"
|
|
34
|
+
pt: "Portuguese",
|
|
35
|
+
"pt-pt": "Portuguese",
|
|
36
|
+
sv: "Swedish",
|
|
37
|
+
"sv-se": "Swedish",
|
|
38
|
+
zh: "Chinese",
|
|
39
|
+
"zh-cn": "Chinese",
|
|
40
|
+
"zh-tw": "Chinese",
|
|
41
|
+
"zh-hans": "Chinese",
|
|
42
|
+
"zh-hant": "Chinese",
|
|
43
43
|
};
|
|
44
44
|
const DISPLAY_NAME_CACHE = new Map();
|
|
45
45
|
let displayNameFallbackWarningShown = false;
|
|
@@ -179,7 +179,6 @@ function getTranslationData() {
|
|
|
179
179
|
}
|
|
180
180
|
// Cached translation data - use getter to always get fresh data
|
|
181
181
|
let translationData = getTranslationData();
|
|
182
|
-
const notionStore = new Map();
|
|
183
182
|
const defaultLanguage = "en";
|
|
184
183
|
function extractPrimarySubtag(code) {
|
|
185
184
|
if (!code) {
|
|
@@ -288,33 +287,30 @@ export function getLanguageDisplayName(code, options = {}) {
|
|
|
288
287
|
const BROWSER_LANGUAGE_PREFERENCES = {
|
|
289
288
|
da: "da",
|
|
290
289
|
"da-dk": "da",
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
"
|
|
296
|
-
sv: "sv",
|
|
297
|
-
"sv-se": "sv",
|
|
298
|
-
pt: "pt",
|
|
299
|
-
"pt-pt": "pt",
|
|
300
|
-
"pt-br": "pt",
|
|
290
|
+
de: "de",
|
|
291
|
+
"de-de": "de",
|
|
292
|
+
en: "en",
|
|
293
|
+
"en-us": "en",
|
|
294
|
+
"en-gb": "en",
|
|
301
295
|
es: "es",
|
|
302
296
|
"es-es": "es",
|
|
303
297
|
"es-mx": "es",
|
|
298
|
+
fr: "fr",
|
|
299
|
+
"fr-fr": "fr",
|
|
300
|
+
it: "it",
|
|
301
|
+
"it-it": "it",
|
|
302
|
+
ja: "ja",
|
|
303
|
+
"ja-jp": "ja",
|
|
304
|
+
pt: "pt",
|
|
305
|
+
"pt-pt": "pt",
|
|
306
|
+
"pt-br": "pt",
|
|
307
|
+
sv: "sv",
|
|
308
|
+
"sv-se": "sv",
|
|
304
309
|
zh: "zh",
|
|
305
310
|
"zh-cn": "zh",
|
|
306
311
|
"zh-hans": "zh",
|
|
307
312
|
"zh-tw": "zh",
|
|
308
313
|
"zh-hant": "zh",
|
|
309
|
-
ko: "ko",
|
|
310
|
-
"ko-kr": "ko",
|
|
311
|
-
ja: "ja",
|
|
312
|
-
"ja-jp": "ja",
|
|
313
|
-
en: "en",
|
|
314
|
-
"en-us": "en",
|
|
315
|
-
"en-gb": "en",
|
|
316
|
-
de: "de",
|
|
317
|
-
"de-de": "de",
|
|
318
314
|
};
|
|
319
315
|
function resolvePreferredLanguage(languageTag) {
|
|
320
316
|
if (!languageTag) {
|
|
@@ -391,7 +387,6 @@ if (typeof window !== "undefined") {
|
|
|
391
387
|
translationData = getTranslationData();
|
|
392
388
|
// Dispatch that translations are loaded
|
|
393
389
|
window.dispatchEvent(new CustomEvent("translations-loaded"));
|
|
394
|
-
window.notionDataLoaded = true;
|
|
395
390
|
// Dispatch language-changed to update all components
|
|
396
391
|
const currentLang = currentLanguage.value;
|
|
397
392
|
window.dispatchEvent(new CustomEvent("language-changed", {
|
|
@@ -406,7 +401,6 @@ if (typeof window !== "undefined") {
|
|
|
406
401
|
setTimeout(() => {
|
|
407
402
|
// Since we directly imported the data, just dispatch the events
|
|
408
403
|
window.dispatchEvent(new CustomEvent("translations-loaded"));
|
|
409
|
-
window.notionDataLoaded = true;
|
|
410
404
|
// Also dispatch language-changed with the current language
|
|
411
405
|
const currentLang = currentLanguage.value;
|
|
412
406
|
window.dispatchEvent(new CustomEvent("language-changed", {
|
|
@@ -448,37 +442,6 @@ export function hasTranslation(key, language = currentLanguage.value) {
|
|
|
448
442
|
export function getText(key) {
|
|
449
443
|
return translate(key);
|
|
450
444
|
}
|
|
451
|
-
// Get text from translation data (async for compatibility)
|
|
452
|
-
export async function getNotionText(key, language = currentLanguage.value) {
|
|
453
|
-
if (!key) {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
if (!translationData || !translationData[language]) {
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
const text = translationData[language][key];
|
|
460
|
-
if (text) {
|
|
461
|
-
return text;
|
|
462
|
-
}
|
|
463
|
-
// Fallback to English
|
|
464
|
-
if (language !== defaultLanguage && translationData[defaultLanguage]?.[key]) {
|
|
465
|
-
return translationData[defaultLanguage][key];
|
|
466
|
-
}
|
|
467
|
-
return null;
|
|
468
|
-
}
|
|
469
|
-
// Store Notion text (for dynamic updates)
|
|
470
|
-
export function setNotionText(key, value, language = currentLanguage.value) {
|
|
471
|
-
if (!key)
|
|
472
|
-
return;
|
|
473
|
-
const bucket = getLanguageBucket(language);
|
|
474
|
-
bucket.set(key, value);
|
|
475
|
-
}
|
|
476
|
-
function getLanguageBucket(language) {
|
|
477
|
-
if (!notionStore.has(language)) {
|
|
478
|
-
notionStore.set(language, new Map());
|
|
479
|
-
}
|
|
480
|
-
return notionStore.get(language);
|
|
481
|
-
}
|
|
482
445
|
// Get available languages - dynamically detect from loaded data
|
|
483
446
|
export function getAvailableLanguages() {
|
|
484
447
|
// Always get fresh translation data
|
|
@@ -22,10 +22,6 @@ export declare class Button extends LitElement {
|
|
|
22
22
|
type: BooleanConstructor;
|
|
23
23
|
reflect: boolean;
|
|
24
24
|
};
|
|
25
|
-
notionKey: {
|
|
26
|
-
type: StringConstructor;
|
|
27
|
-
attribute: string;
|
|
28
|
-
};
|
|
29
25
|
key: {
|
|
30
26
|
type: StringConstructor;
|
|
31
27
|
};
|
|
@@ -46,7 +42,7 @@ export declare class Button extends LitElement {
|
|
|
46
42
|
type: BooleanConstructor;
|
|
47
43
|
state: boolean;
|
|
48
44
|
};
|
|
49
|
-
|
|
45
|
+
_text: {
|
|
50
46
|
type: StringConstructor;
|
|
51
47
|
state: boolean;
|
|
52
48
|
};
|
|
@@ -56,14 +52,13 @@ export declare class Button extends LitElement {
|
|
|
56
52
|
bold: boolean;
|
|
57
53
|
"no-background": boolean;
|
|
58
54
|
blank: boolean;
|
|
59
|
-
notionKey: string | null;
|
|
60
55
|
key: string;
|
|
61
56
|
fallback: string;
|
|
62
57
|
language: string;
|
|
63
58
|
defaultText: string;
|
|
64
59
|
href: string;
|
|
65
60
|
_loading: boolean;
|
|
66
|
-
|
|
61
|
+
_text: string | null;
|
|
67
62
|
constructor();
|
|
68
63
|
static styles: import("lit").CSSResult;
|
|
69
64
|
connectedCallback(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds-button.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-button.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGjE,qBAAa,MAAO,SAAQ,UAAU;IACpC,MAAM,CAAC,UAAU
|
|
1
|
+
{"version":3,"file":"ds-button.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-button.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGjE,qBAAa,MAAO,SAAQ,UAAU;IACpC,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBf;IAGM,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;;IAkB7B,MAAM,CAAC,MAAM,0BAkDX;IAEF,iBAAiB;IAQjB,oBAAoB;IAKpB,qBAAqB,aAEnB;IAEF,OAAO,CAAC,YAAY,EAAE,cAAc;IAQpC;;OAEG;IACH,OAAO,CAAC,WAAW;IASnB,MAAM;IAcN,OAAO,CAAC,YAAY;CAwBrB;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,MAAM,CAAC;KACrB;CACF"}
|
package/dist/2-core/ds-button.js
CHANGED
|
@@ -13,14 +13,13 @@ export class Button extends LitElement {
|
|
|
13
13
|
this.bold = false;
|
|
14
14
|
this["no-background"] = false;
|
|
15
15
|
this.blank = false;
|
|
16
|
-
this.notionKey = null;
|
|
17
16
|
this.key = "";
|
|
18
17
|
this.fallback = "";
|
|
19
18
|
this.language = "en-US";
|
|
20
19
|
this.defaultText = "";
|
|
21
20
|
this.href = "";
|
|
22
21
|
this._loading = false;
|
|
23
|
-
this.
|
|
22
|
+
this._text = null;
|
|
24
23
|
}
|
|
25
24
|
connectedCallback() {
|
|
26
25
|
super.connectedCallback();
|
|
@@ -43,10 +42,10 @@ export class Button extends LitElement {
|
|
|
43
42
|
*/
|
|
44
43
|
_updateText() {
|
|
45
44
|
if (this.key) {
|
|
46
|
-
this.
|
|
45
|
+
this._text = getText(this.key);
|
|
47
46
|
}
|
|
48
47
|
else {
|
|
49
|
-
this.
|
|
48
|
+
this._text = this.defaultText || this.fallback || null;
|
|
50
49
|
}
|
|
51
50
|
this.requestUpdate();
|
|
52
51
|
}
|
|
@@ -59,7 +58,7 @@ export class Button extends LitElement {
|
|
|
59
58
|
?no-background=${this["no-background"]}
|
|
60
59
|
@click=${this._handleClick}
|
|
61
60
|
>
|
|
62
|
-
${this.
|
|
61
|
+
${this._text ? this._text : html `<slot></slot>`}
|
|
63
62
|
</button>
|
|
64
63
|
`;
|
|
65
64
|
}
|
|
@@ -97,14 +96,13 @@ Button.properties = {
|
|
|
97
96
|
attribute: "no-background",
|
|
98
97
|
},
|
|
99
98
|
blank: { type: Boolean, reflect: true },
|
|
100
|
-
notionKey: { type: String, attribute: "notion-key" },
|
|
101
99
|
key: { type: String },
|
|
102
100
|
fallback: { type: String },
|
|
103
101
|
language: { type: String },
|
|
104
102
|
defaultText: { type: String, attribute: "default-text" },
|
|
105
103
|
href: { type: String },
|
|
106
104
|
_loading: { type: Boolean, state: true },
|
|
107
|
-
|
|
105
|
+
_text: { type: String, state: true },
|
|
108
106
|
};
|
|
109
107
|
Button.styles = css `
|
|
110
108
|
button {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds-cycle.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-cycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAY5C,OAAO,aAAa,CAAC;AACrB,OAAO,WAAW,CAAC;AACnB,OAAO,WAAW,CAAC;AAqCnB,qBAAa,KAAM,SAAQ,UAAU;IAEnC,MAAM,KAAK,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;MAUpB;IAED,MAAM,CAAC,MAAM,0BAWX;IAIM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAGxB,OAAO,CAAC,aAAa,CAOnB;;IAyBF,iBAAiB;IA6BX,gBAAgB;
|
|
1
|
+
{"version":3,"file":"ds-cycle.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-cycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAY5C,OAAO,aAAa,CAAC;AACrB,OAAO,WAAW,CAAC;AACnB,OAAO,WAAW,CAAC;AAqCnB,qBAAa,KAAM,SAAQ,UAAU;IAEnC,MAAM,KAAK,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;MAUpB;IAED,MAAM,CAAC,MAAM,0BAWX;IAIM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAGxB,OAAO,CAAC,aAAa,CAOnB;;IAyBF,iBAAiB;IA6BX,gBAAgB;IA6EtB,sBAAsB;IAatB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IASnE,iBAAiB;IAoDvB,qBAAqB;IAKrB,oBAAoB;IA0BpB,iBAAiB,CAAC,CAAC,EAAE,KAAK;IAuJ1B,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG;IA+C5C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAyBtC,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAe/B,QAAQ,IAAI,MAAM;IAgElB,MAAM;YAyDQ,mBAAmB;IAwBjC,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,yBAAyB;CAGlC;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,KAAK,CAAC;KACnB;CACF"}
|