@doenet/doenetml-iframe 0.7.21-dev.361 → 0.7.21-dev.363

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/README.md CHANGED
@@ -197,8 +197,9 @@ differ — a Spanish-speaking student may work a French physics problem.
197
197
  `documentLocale`, so a fully Spanish activity is fully Spanish without the
198
198
  host configuring anything.
199
199
  - `localeResources` — FTL message catalogs keyed by locale, for locales other
200
- than English. English is bundled, so a host that only needs English passes
201
- nothing. Nothing is translated yet, so there are no catalogs to supply today.
200
+ than the bundled ones. English and Spanish are bundled, so a host needing
201
+ only those passes nothing; a catalog supplied here wins over a bundled one
202
+ for the same locale, which is how a deployment corrects a translation.
202
203
 
203
204
  When a language is declared — by either route — the rendered container carries
204
205
  a matching `lang` attribute, so screen readers pronounce the content with the
package/index.js CHANGED
@@ -39023,6 +39023,7 @@ function requireClassnames() {
39023
39023
  }
39024
39024
  var classnamesExports = requireClassnames();
39025
39025
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs$1(classnamesExports);
39026
+ const untranslated = (key, _args, fallback) => fallback ?? key;
39026
39027
  const KeyboardIcon = () => /* @__PURE__ */ React__default.createElement(
39027
39028
  "svg",
39028
39029
  {
@@ -39040,9 +39041,13 @@ const KeyboardIcon = () => /* @__PURE__ */ React__default.createElement(
39040
39041
  );
39041
39042
  function KeyboardTray({
39042
39043
  onClick,
39043
- theme
39044
+ theme,
39045
+ translate
39044
39046
  }) {
39045
39047
  const [open, setOpen] = React__default.useState(false);
39048
+ const t4 = translate ?? untranslated;
39049
+ const openLabel = t4("keyboard-open", void 0, "Open Keyboard");
39050
+ const closeLabel = t4("keyboard-close", void 0, "Close Keyboard");
39046
39051
  return createPortal(
39047
39052
  /* @__PURE__ */ React__default.createElement(
39048
39053
  "div",
@@ -39066,8 +39071,8 @@ function KeyboardTray({
39066
39071
  {
39067
39072
  className: "open-keyboard-button",
39068
39073
  onClick: () => setOpen((old) => !old),
39069
- title: open ? "Close Keyboard" : "Open Keyboard",
39070
- "aria-label": open ? "Close Keyboard" : "Open Keyboard"
39074
+ title: open ? closeLabel : openLabel,
39075
+ "aria-label": open ? closeLabel : openLabel
39071
39076
  },
39072
39077
  /* @__PURE__ */ React__default.createElement(KeyboardIcon, null)
39073
39078
  ),
@@ -39076,8 +39081,8 @@ function KeyboardTray({
39076
39081
  {
39077
39082
  className: "close-keyboard-button",
39078
39083
  onClick: () => setOpen(false),
39079
- title: "Close Keyboard",
39080
- "aria-label": "Close Keyboard"
39084
+ title: closeLabel,
39085
+ "aria-label": closeLabel
39081
39086
  },
39082
39087
  "×"
39083
39088
  ), /* @__PURE__ */ React__default.createElement(ManagedKeyboard, { onClick }))
@@ -65384,36 +65389,42 @@ function getActiveRegistration() {
65384
65389
  }
65385
65390
  return null;
65386
65391
  }
65387
- function getTrayTheme() {
65392
+ function getTrayRegistration() {
65388
65393
  const activeRegistration = getActiveRegistration();
65389
65394
  if (activeRegistration) {
65390
- return activeRegistration.theme;
65395
+ return activeRegistration;
65391
65396
  }
65392
65397
  const lastActiveRegistration = getRegistrationById(
65393
65398
  virtualKeyboardState.lastActiveRegistrationId
65394
65399
  );
65395
65400
  if (lastActiveRegistration) {
65396
- return lastActiveRegistration.theme;
65401
+ return lastActiveRegistration;
65397
65402
  }
65398
65403
  const registrations = virtualKeyboardState.registrations;
65399
- return registrations[registrations.length - 1]?.theme;
65404
+ return registrations[registrations.length - 1];
65400
65405
  }
65401
65406
  function rerenderTray() {
65402
- const theme = getTrayTheme();
65407
+ const registration = getTrayRegistration();
65408
+ const theme = registration?.theme;
65409
+ const translate = registration?.translate;
65403
65410
  const trayEl = getTrayElement();
65404
65411
  if (trayEl) {
65405
65412
  const currentTheme = trayEl.getAttribute("data-theme") ?? void 0;
65406
- if (currentTheme === theme) {
65413
+ if (currentTheme === theme && virtualKeyboardState.lastRenderedTranslate === translate) {
65407
65414
  return;
65408
65415
  }
65409
65416
  }
65410
- virtualKeyboardState.keyboardReactRoot?.render(renderTray(theme));
65417
+ virtualKeyboardState.lastRenderedTranslate = translate;
65418
+ virtualKeyboardState.keyboardReactRoot?.render(
65419
+ renderTray(theme, translate)
65420
+ );
65411
65421
  }
65412
- function renderTray(theme) {
65422
+ function renderTray(theme, translate) {
65413
65423
  return /* @__PURE__ */ React__default.createElement(MathJaxContext, { config: mathjaxConfig, version: 4 }, /* @__PURE__ */ React__default.createElement(
65414
65424
  KeyboardTray,
65415
65425
  {
65416
65426
  theme,
65427
+ translate,
65417
65428
  onClick: (e2) => {
65418
65429
  getActiveRegistration()?.onClick(e2);
65419
65430
  }
@@ -65423,6 +65434,7 @@ function renderTray(theme) {
65423
65434
  function UniqueKeyboardTray({
65424
65435
  onClick,
65425
65436
  theme,
65437
+ translate,
65426
65438
  ownerRef
65427
65439
  }) {
65428
65440
  const [id2] = React__default.useState(() => {
@@ -65451,6 +65463,7 @@ function UniqueKeyboardTray({
65451
65463
  id: id2,
65452
65464
  onClick,
65453
65465
  theme,
65466
+ translate,
65454
65467
  ownerRef
65455
65468
  });
65456
65469
  rerenderTray();
@@ -65494,10 +65507,11 @@ function UniqueKeyboardTray({
65494
65507
  if (registration) {
65495
65508
  registration.onClick = onClick;
65496
65509
  registration.theme = theme;
65510
+ registration.translate = translate;
65497
65511
  registration.ownerRef = ownerRef;
65498
65512
  rerenderTray();
65499
65513
  }
65500
- }, [onClick, ownerRef, theme]);
65514
+ }, [onClick, ownerRef, theme, translate]);
65501
65515
  return null;
65502
65516
  }
65503
65517
  function ExternalVirtualKeyboard({
@@ -65529,7 +65543,7 @@ function ExternalVirtualKeyboard({
65529
65543
  }
65530
65544
  );
65531
65545
  }
65532
- const version = "0.7.21-dev.361";
65546
+ const version = "0.7.21-dev.363";
65533
65547
  const latestDoenetmlVersion = version;
65534
65548
  function subscribeToPinnedTheme() {
65535
65549
  return () => {