@concord-consortium/lara-interactive-api 1.9.3-pre.2 → 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
- updateHtmlFontFamily?: 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
- updateHtmlFontFamily?: 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,27 +5589,28 @@ 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, updateHtmlFontFamily = _a.updateHtmlFontFamily, 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
- if (updateHtmlFontSize || updateHtmlFontFamily) {
5601
+ if (updateHtmlFontSize && (fontSize !== exports.DefaultAccessibilitySettings.fontSize)) {
5602
5602
  var html = document.getElementsByTagName("html").item(0);
5603
5603
  if (html) {
5604
- if (updateHtmlFontSize && (fontSizeInPx !== exports.DefaultAccessibilitySettings.fontSizeInPx)) {
5605
- html.style.fontSize = fontSizeInPx + "px";
5606
- }
5607
- if (updateHtmlFontFamily && (fontType !== exports.DefaultAccessibilitySettings.fontType)) {
5608
- html.style.fontFamily = fontFamilyForType;
5609
- }
5604
+ html.style.fontSize = fontSizeInPx + "px";
5610
5605
  }
5611
5606
  }
5612
- if (addBodyClass) {
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
+ });
5612
+ }
5613
+ if (addBodyClasses) {
5613
5614
  var body = document.getElementsByTagName("body").item(0);
5614
5615
  if (body) {
5615
5616
  body.classList.add("font-size-" + normalizeClass(fontSize));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concord-consortium/lara-interactive-api",
3
- "version": "1.9.3-pre.2",
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",