@dabalabs/lang 0.0.1-beta → 0.0.2-beta

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/dabalang.cjs CHANGED
@@ -97,7 +97,10 @@ async function fetchProjectMetadata(gatewayUrl, projectId, apiKey) {
97
97
  code: l.code,
98
98
  provider: l.provider,
99
99
  pathPrefix: l.path_prefix,
100
- isDefault: l.is_default
100
+ isDefault: l.is_default,
101
+ // Absent means an older gateway that has no readiness concept —
102
+ // treat as ready rather than hiding every language.
103
+ ready: l.ready ?? true
101
104
  }))
102
105
  };
103
106
  }
@@ -631,10 +634,14 @@ function injectStyles() {
631
634
  display: inline-flex;
632
635
  align-items: center;
633
636
  gap: 6px;
634
- border: 1px solid rgba(0, 0, 0, 0.12);
635
- background: #ffffff;
636
- color: rgba(0, 0, 0, 0.75);
637
- border-radius: 999px;
637
+ border: 1px solid var(--dabalang-border-color, rgba(0, 0, 0, 0.12));
638
+ background: var(--dabalang-bg, #ffffff);
639
+ color: var(--dabalang-color, rgba(0, 0, 0, 0.75));
640
+ /* Themeable so the switcher can match the host's own buttons. A widget
641
+ cannot know whether a site uses pills or 6px corners, and defaulting
642
+ to a pill made this the one control on the page that did not match.
643
+ Set --dabalang-radius on any ancestor to align it. */
644
+ border-radius: var(--dabalang-radius, 999px);
638
645
  padding: 6px 12px;
639
646
  cursor: pointer;
640
647
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
@@ -901,8 +908,10 @@ function injectStyles() {
901
908
  max-height: 320px;
902
909
  overflow-y: auto;
903
910
  background: #ffffff;
904
- border: 1px solid rgba(0, 0, 0, 0.1);
905
- border-radius: 14px;
911
+ border: 1px solid var(--dabalang-border-color, rgba(0, 0, 0, 0.1));
912
+ /* Panel corners follow the trigger's family, one step softer, so a
913
+ square-cornered host does not get a pill-shaped dropdown. */
914
+ border-radius: var(--dabalang-panel-radius, 14px);
906
915
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
907
916
  padding: 6px;
908
917
  box-sizing: border-box;
@@ -1257,7 +1266,7 @@ var DabaLang = class {
1257
1266
  });
1258
1267
  this.switcher = renderLanguageSwitcher(
1259
1268
  this.container,
1260
- this.metadata.targetLanguages,
1269
+ this.readyLanguages(),
1261
1270
  this.metadata.sourceLang,
1262
1271
  (langCode) => {
1263
1272
  void this.selectLanguage(langCode);
@@ -1285,6 +1294,22 @@ var DabaLang = class {
1285
1294
  * with a prefix match, the widget never machine-translates that page.
1286
1295
  * (A prefix-less developer language instead swaps its uploaded
1287
1296
  * catalogue in place.) */
1297
+ /** Target languages that actually have translations behind them.
1298
+ *
1299
+ * A configured-but-unpopulated language is worse than a missing one: a
1300
+ * visitor picks it and watches the page translate live, paragraph by
1301
+ * paragraph, or lands on a half-translated page while a run is still
1302
+ * going. Languages with no config row at all are legacy
1303
+ * target_languages entries that predate per-language config — they are
1304
+ * shown, because hiding a language that has been serving traffic would
1305
+ * be a regression. */
1306
+ readyLanguages() {
1307
+ const configs = this.metadata?.languages ?? [];
1308
+ return (this.metadata?.targetLanguages ?? []).filter((code) => {
1309
+ const config = configs.find((l) => l.code === code);
1310
+ return config ? config.ready : true;
1311
+ });
1312
+ }
1288
1313
  isSiteTranslated(langCode) {
1289
1314
  const config = this.metadata?.languages.find((l) => l.code === langCode);
1290
1315
  return config?.provider === "developer";