@concord-consortium/lara-interactive-api 1.9.3-pre.3 → 1.9.3-pre.4

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/hooks.d.ts CHANGED
@@ -24,8 +24,8 @@ export declare const useReportItem: <InteractiveState, AuthoredState>({ metadata
24
24
  export declare const DefaultAccessibilitySettings: IAccessibilitySettings;
25
25
  export interface IUseAccessibilityProps {
26
26
  updateHtmlFontSize?: boolean;
27
- updateBodyFontFamily?: boolean;
28
- addBodyClass?: boolean;
27
+ updateFontFamilySelector?: string;
28
+ addBodyClasses?: boolean;
29
29
  }
30
30
  export declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
31
31
  export {};
package/index-bundle.d.ts CHANGED
@@ -676,8 +676,8 @@ declare const useReportItem: <InteractiveState, AuthoredState>({ metadata, handl
676
676
  declare const DefaultAccessibilitySettings: IAccessibilitySettings;
677
677
  interface IUseAccessibilityProps {
678
678
  updateHtmlFontSize?: boolean;
679
- updateBodyFontFamily?: boolean;
680
- addBodyClass?: boolean;
679
+ updateFontFamilySelector?: string;
680
+ addBodyClasses?: boolean;
681
681
  }
682
682
  declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
683
683
 
package/index.js CHANGED
@@ -5589,26 +5589,33 @@ exports.DefaultAccessibilitySettings = {
5589
5589
  fontFamilyForType: (0, accessibility_1.getFamilyForFontType)("normal"),
5590
5590
  };
5591
5591
  var useAccessibility = function (props) {
5592
- var _a = props || {}, updateHtmlFontSize = _a.updateHtmlFontSize, updateBodyFontFamily = _a.updateBodyFontFamily, addBodyClass = _a.addBodyClass;
5592
+ var _a = props || {}, updateHtmlFontSize = _a.updateHtmlFontSize, updateFontFamilySelector = _a.updateFontFamilySelector, addBodyClasses = _a.addBodyClasses;
5593
5593
  var initMessage = (0, exports.useInitMessage)();
5594
5594
  var _b = (0, react_1.useState)(exports.DefaultAccessibilitySettings), accessibility = _b[0], setAccessibility = _b[1];
5595
5595
  var normalizeClass = function (text) { return text.toLowerCase().replace(/\s/, "-"); };
5596
5596
  (0, react_1.useEffect)(function () {
5597
5597
  if (initMessage && initMessage.mode === "runtime") {
5598
5598
  var _accessibility = initMessage.accessibility || exports.DefaultAccessibilitySettings;
5599
- var fontSize = _accessibility.fontSize, fontSizeInPx = _accessibility.fontSizeInPx, fontType = _accessibility.fontType, fontFamilyForType = _accessibility.fontFamilyForType;
5599
+ var fontSize = _accessibility.fontSize, fontSizeInPx = _accessibility.fontSizeInPx, fontType = _accessibility.fontType, fontFamilyForType_1 = _accessibility.fontFamilyForType;
5600
5600
  setAccessibility(_accessibility);
5601
- var html = document.getElementsByTagName("html").item(0);
5602
- var body = document.getElementsByTagName("body").item(0);
5603
- if (updateHtmlFontSize && (fontSize !== exports.DefaultAccessibilitySettings.fontSize) && html) {
5604
- html.style.fontSize = fontSizeInPx + "px";
5601
+ if (updateHtmlFontSize && (fontSize !== exports.DefaultAccessibilitySettings.fontSize)) {
5602
+ var html = document.getElementsByTagName("html").item(0);
5603
+ if (html) {
5604
+ html.style.fontSize = fontSizeInPx + "px";
5605
+ }
5605
5606
  }
5606
- if (updateBodyFontFamily && (fontType !== exports.DefaultAccessibilitySettings.fontType) && body) {
5607
- body.style.fontFamily = fontFamilyForType;
5607
+ if (updateFontFamilySelector && (fontType !== exports.DefaultAccessibilitySettings.fontType)) {
5608
+ var elements = document.querySelectorAll(updateFontFamilySelector);
5609
+ elements.forEach(function (element) {
5610
+ element.style.fontFamily = fontFamilyForType_1;
5611
+ });
5608
5612
  }
5609
- if (addBodyClass && body) {
5610
- body.classList.add("font-size-" + normalizeClass(fontSize));
5611
- body.classList.add("font-type-" + normalizeClass(fontType));
5613
+ if (addBodyClasses) {
5614
+ var body = document.getElementsByTagName("body").item(0);
5615
+ if (body) {
5616
+ body.classList.add("font-size-" + normalizeClass(fontSize));
5617
+ body.classList.add("font-type-" + normalizeClass(fontType));
5618
+ }
5612
5619
  }
5613
5620
  }
5614
5621
  }, [initMessage, updateHtmlFontSize]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concord-consortium/lara-interactive-api",
3
- "version": "1.9.3-pre.3",
3
+ "version": "1.9.3-pre.4",
4
4
  "description": "LARA Interactive API client and types",
5
5
  "main": "./index.js",
6
6
  "types": "./index-bundle.d.ts",