@khanacademy/perseus 12.1.0 → 12.2.0
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/CHANGELOG.md +8 -0
- package/dist/article-renderer.d.ts +2 -0
- package/dist/es/index.css +3 -0
- package/dist/es/index.js +28 -23
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +3 -0
- package/dist/index.js +28 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__stories__/article-renderer.stories.tsx +28 -2
- package/src/__testdata__/article-renderer.testdata.ts +85 -0
- package/src/__tests__/article-renderer.test.tsx +131 -0
- package/src/article-renderer.tsx +58 -45
- package/src/styles/perseus-renderer.less +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.css
CHANGED
|
@@ -2613,6 +2613,7 @@ img.zoom-img {
|
|
|
2613
2613
|
}
|
|
2614
2614
|
/* Widget CSS */
|
|
2615
2615
|
.perseus-graph-padding {
|
|
2616
|
+
box-sizing: content-box;
|
|
2616
2617
|
padding: 25px 25px 0 0;
|
|
2617
2618
|
}
|
|
2618
2619
|
.categorizer-container {
|
|
@@ -2749,6 +2750,7 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2749
2750
|
margin: 0px 4px;
|
|
2750
2751
|
}
|
|
2751
2752
|
.perseus-widget-grapher {
|
|
2753
|
+
box-sizing: content-box;
|
|
2752
2754
|
padding: 25px 25px 0 0;
|
|
2753
2755
|
}
|
|
2754
2756
|
.perseus-widget-grapher > .graphie-container {
|
|
@@ -2836,6 +2838,7 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2836
2838
|
margin-top: 5px;
|
|
2837
2839
|
}
|
|
2838
2840
|
.perseus-widget-interactive-graph {
|
|
2841
|
+
box-sizing: content-box;
|
|
2839
2842
|
padding: 25px 25px 0 0;
|
|
2840
2843
|
}
|
|
2841
2844
|
.perseus-widget-interactive-graph > .graphie-container {
|
package/dist/index.js
CHANGED
|
@@ -44015,7 +44015,7 @@ const init = function (options) {
|
|
|
44015
44015
|
|
|
44016
44016
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44017
44017
|
const libName = "@khanacademy/perseus";
|
|
44018
|
-
const libVersion = "12.
|
|
44018
|
+
const libVersion = "12.2.0";
|
|
44019
44019
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44020
44020
|
|
|
44021
44021
|
const apiVersion = {
|
|
@@ -44037,6 +44037,7 @@ class ArticleRenderer extends React__namespace.Component {
|
|
|
44037
44037
|
constructor(props) {
|
|
44038
44038
|
super(props);
|
|
44039
44039
|
_defineProperty(this, "_currentFocus", void 0);
|
|
44040
|
+
_defineProperty(this, "sectionRenderers", []);
|
|
44040
44041
|
_defineProperty(this, "_handleFocusChange", (newFocusPath, oldFocusPath) => {
|
|
44041
44042
|
// TODO(charlie): DRY this up--some of this logic is repeated in
|
|
44042
44043
|
// ItemRenderer.
|
|
@@ -44061,17 +44062,17 @@ class ArticleRenderer extends React__namespace.Component {
|
|
|
44061
44062
|
// paths, so as to check whether the focused path represents an
|
|
44062
44063
|
// input.
|
|
44063
44064
|
let didFocusInput = false;
|
|
44065
|
+
let focusedInput;
|
|
44064
44066
|
if (this._currentFocus) {
|
|
44065
|
-
const [
|
|
44066
|
-
|
|
44067
|
-
// @ts-expect-error - TS2339 - Property 'getInputPaths' does not exist on type 'ReactInstance'.
|
|
44068
|
-
const inputPaths = this.refs[sectionRef].getInputPaths();
|
|
44067
|
+
const [sectionIndex, ...focusPath] = this._currentFocus;
|
|
44068
|
+
const inputPaths = this.sectionRenderers[sectionIndex].getInputPaths();
|
|
44069
44069
|
didFocusInput = inputPaths.some(inputPath => {
|
|
44070
44070
|
return Util.inputPathsEqual(inputPath, focusPath);
|
|
44071
44071
|
});
|
|
44072
|
+
focusedInput = this.sectionRenderers[sectionIndex].getDOMNodeForPath(focusPath);
|
|
44072
44073
|
}
|
|
44073
44074
|
if (this.props.apiOptions.onFocusChange != null) {
|
|
44074
|
-
this.props.apiOptions.onFocusChange(this._currentFocus, prevFocusPath, didFocusInput ? keypadElement === null || keypadElement === void 0 ? void 0 : keypadElement.getDOMNode() : null);
|
|
44075
|
+
this.props.apiOptions.onFocusChange(this._currentFocus, prevFocusPath, didFocusInput ? keypadElement === null || keypadElement === void 0 ? void 0 : keypadElement.getDOMNode() : null, didFocusInput ? focusedInput : null);
|
|
44075
44076
|
}
|
|
44076
44077
|
if (keypadElement && isMobile) {
|
|
44077
44078
|
if (didFocusInput) {
|
|
@@ -44103,10 +44104,8 @@ class ArticleRenderer extends React__namespace.Component {
|
|
|
44103
44104
|
});
|
|
44104
44105
|
_defineProperty(this, "blur", () => {
|
|
44105
44106
|
if (this._currentFocus) {
|
|
44106
|
-
const [
|
|
44107
|
-
|
|
44108
|
-
// @ts-expect-error - TS2339 - Property 'blurPath' does not exist on type 'ReactInstance'.
|
|
44109
|
-
this.refs[sectionRef].blurPath(inputPath);
|
|
44107
|
+
const [sectionIndex, ...inputPath] = this._currentFocus;
|
|
44108
|
+
this.sectionRenderers[sectionIndex].blurPath(inputPath);
|
|
44110
44109
|
}
|
|
44111
44110
|
});
|
|
44112
44111
|
_defineProperty(this, "_sections", () => {
|
|
@@ -44134,34 +44133,40 @@ class ArticleRenderer extends React__namespace.Component {
|
|
|
44134
44133
|
});
|
|
44135
44134
|
|
|
44136
44135
|
// TODO(alex): Add mobile api functions and pass them down here
|
|
44137
|
-
|
|
44138
|
-
|
|
44139
|
-
|
|
44140
|
-
|
|
44141
|
-
|
|
44142
|
-
key:
|
|
44136
|
+
// We're using the index as the key here because we don't have a unique
|
|
44137
|
+
// identifier for each section. This should be fine as we never remove
|
|
44138
|
+
// or reorder sections.
|
|
44139
|
+
const sections = this._sections().map((section, sectionIndex) => {
|
|
44140
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
44141
|
+
key: sectionIndex,
|
|
44143
44142
|
className: "clearfix"
|
|
44144
44143
|
}, /*#__PURE__*/React__namespace.createElement(Renderer, _extends({}, section, {
|
|
44145
|
-
ref:
|
|
44146
|
-
|
|
44147
|
-
|
|
44144
|
+
ref: elem => {
|
|
44145
|
+
if (elem) {
|
|
44146
|
+
this.sectionRenderers[sectionIndex] = elem;
|
|
44147
|
+
}
|
|
44148
|
+
},
|
|
44149
|
+
key: sectionIndex,
|
|
44150
|
+
key_: sectionIndex,
|
|
44148
44151
|
keypadElement: this.props.keypadElement,
|
|
44149
44152
|
apiOptions: {
|
|
44150
44153
|
...apiOptions,
|
|
44151
44154
|
onFocusChange: (newFocusPath, oldFocusPath) => {
|
|
44152
|
-
// Prefix the paths with the relevant section,
|
|
44155
|
+
// Prefix the paths with the relevant section index,
|
|
44153
44156
|
// so as to allow us to distinguish between
|
|
44154
44157
|
// equivalently-named inputs across Renderers.
|
|
44155
|
-
this._handleFocusChange(newFocusPath && [
|
|
44158
|
+
this._handleFocusChange(newFocusPath && [sectionIndex].concat(newFocusPath), oldFocusPath && [sectionIndex].concat(oldFocusPath));
|
|
44156
44159
|
}
|
|
44157
44160
|
},
|
|
44158
44161
|
linterContext: PerseusLinter__namespace.pushContextStack(this.props.linterContext, "article"),
|
|
44159
44162
|
legacyPerseusLint: this.props.legacyPerseusLint
|
|
44160
|
-
})))
|
|
44163
|
+
})));
|
|
44161
44164
|
});
|
|
44162
44165
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
44163
44166
|
className: classes
|
|
44164
|
-
},
|
|
44167
|
+
}, /*#__PURE__*/React__namespace.createElement(DependenciesContext.Provider, {
|
|
44168
|
+
value: this.props.dependencies
|
|
44169
|
+
}, sections));
|
|
44165
44170
|
}
|
|
44166
44171
|
}
|
|
44167
44172
|
_defineProperty(ArticleRenderer, "defaultProps", {
|