ds-one 0.2.5-alpha.10 → 0.2.5-alpha.12

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.
@@ -1807,13 +1807,106 @@ var o7 = s5.litElementPolyfillSupport;
1807
1807
  o7?.({ LitElement: i6 });
1808
1808
  (s5.litElementVersions ?? (s5.litElementVersions = [])).push("4.2.1");
1809
1809
 
1810
+ // dist/2-core/ds-text.js
1811
+ var Text = class extends i6 {
1812
+ static get properties() {
1813
+ return {
1814
+ key: { type: String, reflect: true },
1815
+ defaultValue: { type: String, reflect: true, attribute: "default-value" },
1816
+ fallback: { type: String, reflect: true },
1817
+ // Kept for backward compatibility
1818
+ _text: { type: String, state: true }
1819
+ };
1820
+ }
1821
+ constructor() {
1822
+ super();
1823
+ this.key = "";
1824
+ this.defaultValue = "";
1825
+ this.fallback = "";
1826
+ this._text = "";
1827
+ this._currentLanguage = currentLanguage.value;
1828
+ this.boundHandlers = {
1829
+ languageChanged: (() => {
1830
+ console.log("Language changed event received in ds-text");
1831
+ this._currentLanguage = currentLanguage.value;
1832
+ this._updateLanguageAttribute();
1833
+ this._loadText();
1834
+ this.requestUpdate();
1835
+ })
1836
+ };
1837
+ }
1838
+ connectedCallback() {
1839
+ super.connectedCallback();
1840
+ this._currentLanguage = currentLanguage.value;
1841
+ this._updateLanguageAttribute();
1842
+ this._loadText();
1843
+ window.addEventListener("language-changed", this.boundHandlers.languageChanged);
1844
+ window.addEventListener("translations-loaded", this.boundHandlers.languageChanged);
1845
+ }
1846
+ disconnectedCallback() {
1847
+ super.disconnectedCallback();
1848
+ window.removeEventListener("language-changed", this.boundHandlers.languageChanged);
1849
+ window.removeEventListener("translations-loaded", this.boundHandlers.languageChanged);
1850
+ }
1851
+ updated(changedProperties) {
1852
+ super.updated(changedProperties);
1853
+ if (changedProperties.has("key") || changedProperties.has("defaultValue")) {
1854
+ this._loadText();
1855
+ }
1856
+ }
1857
+ _updateLanguageAttribute() {
1858
+ const lang = this._currentLanguage || currentLanguage.value;
1859
+ const primaryLang = lang?.toLowerCase().split(/[-_]/)[0] || "";
1860
+ if (primaryLang === "ja") {
1861
+ this.setAttribute("data-language", "ja");
1862
+ } else {
1863
+ this.removeAttribute("data-language");
1864
+ }
1865
+ }
1866
+ _loadText() {
1867
+ if (!this.key) {
1868
+ this._text = this.defaultValue || this.fallback || "";
1869
+ this._updateLanguageAttribute();
1870
+ this.requestUpdate();
1871
+ return;
1872
+ }
1873
+ try {
1874
+ const text = getText(this.key);
1875
+ this._text = text || this.defaultValue || this.fallback || this.key;
1876
+ } catch (error) {
1877
+ console.error("Error loading text for key:", this.key, error);
1878
+ this._text = this.defaultValue || this.fallback || this.key;
1879
+ }
1880
+ this._updateLanguageAttribute();
1881
+ this.requestUpdate();
1882
+ }
1883
+ render() {
1884
+ return x`<span>${this._text || this.defaultValue || this.key}</span>`;
1885
+ }
1886
+ };
1887
+ Text.styles = i4`
1888
+ :host {
1889
+ display: inline;
1890
+ font-family: var(--typeface-regular);
1891
+ font-size: calc(var(--type-size-default) * var(--sf));
1892
+ font-weight: var(--type-weight-default);
1893
+ line-height: calc(var(--type-lineheight-default) * var(--sf));
1894
+ letter-spacing: calc(var(--type-letterspacing-default) * var(--sf));
1895
+ text-align: var(--text-align-default);
1896
+ text-transform: var(--text-transform-default);
1897
+ text-decoration: var(--text-decoration-default);
1898
+ }
1899
+
1900
+ :host([data-language="ja"]) {
1901
+ font-family: var(--typeface-regular-jp);
1902
+ }
1903
+ `;
1904
+ customElements.define("ds-text", Text);
1905
+
1810
1906
  // dist/2-core/ds-button.js
1811
1907
  var Button = class extends i6 {
1812
1908
  constructor() {
1813
1909
  super();
1814
- this._handleLanguageChange = () => {
1815
- this._updateText();
1816
- };
1817
1910
  this.variant = "title";
1818
1911
  this.disabled = false;
1819
1912
  this.bold = false;
@@ -1825,35 +1918,12 @@ var Button = class extends i6 {
1825
1918
  this.defaultText = "";
1826
1919
  this.href = "";
1827
1920
  this._loading = false;
1828
- this._text = null;
1829
1921
  }
1830
1922
  connectedCallback() {
1831
1923
  super.connectedCallback();
1832
- this._updateText();
1833
- window.addEventListener("language-changed", this._handleLanguageChange);
1834
- }
1835
- disconnectedCallback() {
1836
- super.disconnectedCallback();
1837
- window.removeEventListener("language-changed", this._handleLanguageChange);
1838
- }
1839
- updated(changedProps) {
1840
- super.updated(changedProps);
1841
- if (changedProps.has("key") || changedProps.has("defaultText")) {
1842
- this._updateText();
1843
- }
1844
- }
1845
- /**
1846
- * Update text from translations (synchronous like Portfolio)
1847
- */
1848
- _updateText() {
1849
- if (this.key) {
1850
- this._text = getText(this.key);
1851
- } else {
1852
- this._text = this.defaultText || this.fallback || null;
1853
- }
1854
- this.requestUpdate();
1855
1924
  }
1856
1925
  render() {
1926
+ const hasTextProps = this.key || this.defaultText || this.fallback;
1857
1927
  return x`
1858
1928
  <button
1859
1929
  class=${this.variant}
@@ -1862,7 +1932,11 @@ var Button = class extends i6 {
1862
1932
  ?no-background=${this["no-background"]}
1863
1933
  @click=${this._handleClick}
1864
1934
  >
1865
- ${this._text ? this._text : x`<slot></slot>`}
1935
+ ${hasTextProps ? x`<ds-text
1936
+ .key=${this.key}
1937
+ .defaultValue=${this.defaultText}
1938
+ .fallback=${this.fallback}
1939
+ ></ds-text>` : x`<slot></slot>`}
1866
1940
  </button>
1867
1941
  `;
1868
1942
  }
@@ -1899,8 +1973,7 @@ Button.properties = {
1899
1973
  language: { type: String },
1900
1974
  defaultText: { type: String, attribute: "default-text" },
1901
1975
  href: { type: String },
1902
- _loading: { type: Boolean, state: true },
1903
- _text: { type: String, state: true }
1976
+ _loading: { type: Boolean, state: true }
1904
1977
  };
1905
1978
  Button.styles = i4`
1906
1979
  button {
@@ -2263,98 +2336,6 @@ Icon.iconNameToSvgMap = (() => {
2263
2336
  customElements.define("ds-icon", Icon);
2264
2337
  console.log("Icon component registered with custom elements registry");
2265
2338
 
2266
- // dist/2-core/ds-text.js
2267
- var Text = class extends i6 {
2268
- static get properties() {
2269
- return {
2270
- key: { type: String, reflect: true },
2271
- defaultValue: { type: String, reflect: true, attribute: "default-value" },
2272
- fallback: { type: String, reflect: true },
2273
- // Kept for backward compatibility
2274
- _text: { type: String, state: true }
2275
- };
2276
- }
2277
- constructor() {
2278
- super();
2279
- this.key = "";
2280
- this.defaultValue = "";
2281
- this.fallback = "";
2282
- this._text = "";
2283
- this._currentLanguage = currentLanguage.value;
2284
- this.boundHandlers = {
2285
- languageChanged: (() => {
2286
- console.log("Language changed event received in ds-text");
2287
- this._currentLanguage = currentLanguage.value;
2288
- this._loadText();
2289
- this.requestUpdate();
2290
- })
2291
- };
2292
- }
2293
- connectedCallback() {
2294
- super.connectedCallback();
2295
- this._currentLanguage = currentLanguage.value;
2296
- this._updateLanguageAttribute();
2297
- this._loadText();
2298
- window.addEventListener("language-changed", this.boundHandlers.languageChanged);
2299
- window.addEventListener("translations-loaded", this.boundHandlers.languageChanged);
2300
- }
2301
- disconnectedCallback() {
2302
- super.disconnectedCallback();
2303
- window.removeEventListener("language-changed", this.boundHandlers.languageChanged);
2304
- window.removeEventListener("translations-loaded", this.boundHandlers.languageChanged);
2305
- }
2306
- updated(changedProperties) {
2307
- super.updated(changedProperties);
2308
- if (changedProperties.has("key") || changedProperties.has("defaultValue")) {
2309
- this._loadText();
2310
- }
2311
- }
2312
- _updateLanguageAttribute() {
2313
- const lang = this._currentLanguage || currentLanguage.value;
2314
- if (lang === "ja") {
2315
- this.setAttribute("data-language", "ja");
2316
- } else {
2317
- this.removeAttribute("data-language");
2318
- }
2319
- }
2320
- _loadText() {
2321
- if (!this.key) {
2322
- this._text = this.defaultValue || this.fallback || "";
2323
- return;
2324
- }
2325
- try {
2326
- const text = getText(this.key);
2327
- this._text = text || this.defaultValue || this.fallback || this.key;
2328
- } catch (error) {
2329
- console.error("Error loading text for key:", this.key, error);
2330
- this._text = this.defaultValue || this.fallback || this.key;
2331
- }
2332
- this._updateLanguageAttribute();
2333
- this.requestUpdate();
2334
- }
2335
- render() {
2336
- return x`<span>${this._text || this.defaultValue || this.key}</span>`;
2337
- }
2338
- };
2339
- Text.styles = i4`
2340
- :host {
2341
- display: inline;
2342
- font-family: var(--typeface-regular);
2343
- font-size: calc(var(--type-size-default) * var(--sf));
2344
- font-weight: var(--type-weight-default);
2345
- line-height: calc(var(--type-lineheight-default) * var(--sf));
2346
- letter-spacing: calc(var(--type-letterspacing-default) * var(--sf));
2347
- text-align: var(--text-align-default);
2348
- text-transform: var(--text-transform-default);
2349
- text-decoration: var(--text-decoration-default);
2350
- }
2351
-
2352
- :host([data-language="ja"]) {
2353
- font-family: var(--typeface-regular-jp);
2354
- }
2355
- `;
2356
- customElements.define("ds-text", Text);
2357
-
2358
2339
  // dist/2-core/ds-cycle.js
2359
2340
  var saveAccentColor = (color) => {
2360
2341
  localStorage.setItem("accentColor", color);
@@ -2750,18 +2731,20 @@ var Cycle = class extends i6 {
2750
2731
  ${this.type === "notes-style-medium" || this.type === "icon-only" ? x`<span
2751
2732
  style="display: inline-flex; align-items: center; gap: var(--025)"
2752
2733
  >${this.getValueDisplay(this.currentValue)}</span
2753
- >` : this.type === "theme" ? x`<ds-text
2754
- key=${this.currentValue}
2755
- default-value=${this.currentValue}
2756
- ></ds-text>` : this.type === "accent-color" ? x`<ds-text
2757
- key=${this.getColorKey(this.currentValue)}
2758
- default-value=${this.getColorName(this.currentValue)}
2759
- ></ds-text>` : this.type === "page-style" ? x`<ds-text
2760
- key=${this.currentValue}
2761
- default-value=${this.currentValue}
2762
- ></ds-text>` : x`<ds-text
2763
- default-value=${this.getValueDisplay(this.currentValue)}
2764
- ></ds-text>`}
2734
+ >` : this.type === "language" ? x`<ds-text
2735
+ default-value=${this.getValueDisplay(this.currentValue)}
2736
+ ></ds-text>` : this.type === "theme" ? x`<ds-text
2737
+ key=${this.currentValue}
2738
+ default-value=${this.currentValue}
2739
+ ></ds-text>` : this.type === "accent-color" ? x`<ds-text
2740
+ key=${this.getColorKey(this.currentValue)}
2741
+ default-value=${this.getColorName(this.currentValue)}
2742
+ ></ds-text>` : this.type === "page-style" ? x`<ds-text
2743
+ key=${this.currentValue}
2744
+ default-value=${this.currentValue}
2745
+ ></ds-text>` : x`<ds-text
2746
+ default-value=${this.getValueDisplay(this.currentValue)}
2747
+ ></ds-text>`}
2765
2748
  </ds-button>
2766
2749
  ${this.type === "accent-color" ? x`
2767
2750
  <div