@concord-consortium/lara-interactive-api 1.9.3-pre.5 → 1.9.3-pre.7
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 +3 -4
- package/index-bundle.d.ts +3 -4
- package/index.js +9 -9
- package/package.json +1 -1
package/hooks.d.ts
CHANGED
|
@@ -23,10 +23,9 @@ export interface IUseReportItemOptions<InteractiveState, AuthoredState> {
|
|
|
23
23
|
export declare const useReportItem: <InteractiveState, AuthoredState>({ metadata, handler }: IUseReportItemOptions<InteractiveState, AuthoredState>) => void;
|
|
24
24
|
export declare const DefaultAccessibilitySettings: IAccessibilitySettings;
|
|
25
25
|
export interface IUseAccessibilityProps {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
26
|
+
updateHtmlFontSize?: boolean;
|
|
27
|
+
addBodyClass?: boolean;
|
|
28
|
+
fontFamilySelector?: string;
|
|
30
29
|
}
|
|
31
30
|
export declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
|
|
32
31
|
export {};
|
package/index-bundle.d.ts
CHANGED
|
@@ -675,10 +675,9 @@ interface IUseReportItemOptions<InteractiveState, AuthoredState> {
|
|
|
675
675
|
declare const useReportItem: <InteractiveState, AuthoredState>({ metadata, handler }: IUseReportItemOptions<InteractiveState, AuthoredState>) => void;
|
|
676
676
|
declare const DefaultAccessibilitySettings: IAccessibilitySettings;
|
|
677
677
|
interface IUseAccessibilityProps {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
};
|
|
678
|
+
updateHtmlFontSize?: boolean;
|
|
679
|
+
addBodyClass?: boolean;
|
|
680
|
+
fontFamilySelector?: string;
|
|
682
681
|
}
|
|
683
682
|
declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
|
|
684
683
|
|
package/index.js
CHANGED
|
@@ -5589,35 +5589,35 @@ exports.DefaultAccessibilitySettings = {
|
|
|
5589
5589
|
fontFamilyForType: (0, accessibility_1.getFamilyForFontType)("normal"),
|
|
5590
5590
|
};
|
|
5591
5591
|
var useAccessibility = function (props) {
|
|
5592
|
-
var
|
|
5592
|
+
var _a = props || {}, updateHtmlFontSize = _a.updateHtmlFontSize, addBodyClass = _a.addBodyClass, fontFamilySelector = _a.fontFamilySelector;
|
|
5593
5593
|
var initMessage = (0, exports.useInitMessage)();
|
|
5594
|
-
var
|
|
5595
|
-
|
|
5594
|
+
var _b = (0, react_1.useState)(exports.DefaultAccessibilitySettings), accessibility = _b[0], setAccessibility = _b[1];
|
|
5595
|
+
// text may be optional while font type setting is rolled out from staging to production through AP
|
|
5596
|
+
var normalizeClass = function (text) { return (text || "").toLowerCase().replace(/\s/, "-"); };
|
|
5596
5597
|
(0, react_1.useEffect)(function () {
|
|
5597
5598
|
var _a;
|
|
5598
5599
|
if (initMessage && initMessage.mode === "runtime") {
|
|
5599
5600
|
var _accessibility = initMessage.accessibility || exports.DefaultAccessibilitySettings;
|
|
5600
5601
|
var fontSize = _accessibility.fontSize, fontSizeInPx = _accessibility.fontSizeInPx, fontType = _accessibility.fontType, fontFamilyForType = _accessibility.fontFamilyForType;
|
|
5601
5602
|
setAccessibility(_accessibility);
|
|
5602
|
-
if (
|
|
5603
|
-
var fontFamilySelector = updateDOM.fontFamilySelector;
|
|
5603
|
+
if (updateHtmlFontSize || addBodyClass || fontFamilySelector) {
|
|
5604
5604
|
var html = document.getElementsByTagName("html").item(0);
|
|
5605
5605
|
var body = document.getElementsByTagName("body").item(0);
|
|
5606
|
-
if (html) {
|
|
5606
|
+
if (updateHtmlFontSize && html && fontSizeInPx) {
|
|
5607
5607
|
html.style.fontSize = fontSizeInPx + "px";
|
|
5608
5608
|
}
|
|
5609
|
-
if (body) {
|
|
5609
|
+
if (addBodyClass && body) {
|
|
5610
5610
|
body.classList.add("font-size-" + normalizeClass(fontSize));
|
|
5611
5611
|
body.classList.add("font-type-" + normalizeClass(fontType));
|
|
5612
5612
|
}
|
|
5613
|
-
if (fontFamilySelector) {
|
|
5613
|
+
if (fontFamilySelector && fontFamilyForType) {
|
|
5614
5614
|
var style = document.createElement("style");
|
|
5615
5615
|
document.head.appendChild(style);
|
|
5616
5616
|
(_a = style.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(fontFamilySelector + " { font-family: " + fontFamilyForType + "; }", 0);
|
|
5617
5617
|
}
|
|
5618
5618
|
}
|
|
5619
5619
|
}
|
|
5620
|
-
}, [initMessage,
|
|
5620
|
+
}, [initMessage, updateHtmlFontSize, addBodyClass, fontFamilySelector]);
|
|
5621
5621
|
return accessibility;
|
|
5622
5622
|
};
|
|
5623
5623
|
exports.useAccessibility = useAccessibility;
|