@khanacademy/perseus 13.2.0 → 14.0.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 +22 -0
- package/dist/components/svg-image.d.ts +10 -9
- package/dist/es/index.js +36 -31
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +60 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/article-renderer.test.tsx +2 -3
- package/src/components/graph.tsx +14 -8
- package/src/components/svg-image.tsx +13 -11
- package/src/mixins/provide-keypad.tsx +0 -1
- package/src/perseus-types.ts +8 -3
- package/src/widgets/__stories__/random-widgets.stories.tsx +59 -0
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +0 -1
- package/src/widgets/__testdata__/categorizer.testdata.ts +40 -0
- package/src/widgets/__testdata__/dropdown.testdata.ts +38 -0
- package/src/widgets/__testdata__/explanation.testdata.ts +30 -0
- package/src/widgets/__testdata__/expression.testdata.ts +82 -0
- package/src/widgets/__testdata__/interactive-graph-random.testdata.ts +269 -0
- package/src/widgets/__testdata__/radio.testdata.ts +63 -0
- package/src/widgets/__testdata__/randomizers.ts +51 -0
- package/src/widgets/__tests__/expression-mobile.test.tsx +0 -1
- package/src/widgets/__tests__/randomizers.test.ts +53 -0
- package/src/widgets/image.tsx +27 -20
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -16561,7 +16561,7 @@ const doJSONP = function (url, options) {
|
|
|
16561
16561
|
// system (with file://). We replace urls that start with `web+graphie`
|
|
16562
16562
|
// in the perseus json with this `file+graphie` prefix to indicate that
|
|
16563
16563
|
// they should have the `file://` protocol instead of `https://`.
|
|
16564
|
-
const svgLocalLabelsRegex = /^file\+graphie
|
|
16564
|
+
const svgLocalLabelsRegex = /^file\+graphie:/;
|
|
16565
16565
|
const hashRegex = /\/([^/]+)$/;
|
|
16566
16566
|
function isImageProbablyPhotograph(imageUrl) {
|
|
16567
16567
|
// TODO(david): Do an inventory to refine this heuristic. For example, what
|
|
@@ -26857,43 +26857,50 @@ class ImageWidget extends React__namespace.Component {
|
|
|
26857
26857
|
} = this.props;
|
|
26858
26858
|
const backgroundImage = this.props.backgroundImage;
|
|
26859
26859
|
if (backgroundImage.url) {
|
|
26860
|
-
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
26868
|
-
|
|
26869
|
-
|
|
26870
|
-
|
|
26871
|
-
|
|
26872
|
-
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
26879
|
-
|
|
26880
|
-
|
|
26881
|
-
|
|
26882
|
-
|
|
26883
|
-
|
|
26884
|
-
|
|
26885
|
-
|
|
26886
|
-
|
|
26887
|
-
|
|
26888
|
-
|
|
26889
|
-
|
|
26890
|
-
|
|
26891
|
-
|
|
26892
|
-
|
|
26893
|
-
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26860
|
+
const url = backgroundImage.url;
|
|
26861
|
+
image = /*#__PURE__*/React__namespace.createElement(context$1.Consumer, null, _ref => {
|
|
26862
|
+
let {
|
|
26863
|
+
setAssetStatus
|
|
26864
|
+
} = _ref;
|
|
26865
|
+
return /*#__PURE__*/React__namespace.createElement(SvgImage, {
|
|
26866
|
+
src: url,
|
|
26867
|
+
alt:
|
|
26868
|
+
/* alt text is formatted in a sr-only
|
|
26869
|
+
div next to the image in addition to
|
|
26870
|
+
the alt attribute.
|
|
26871
|
+
If there is no alt text at all,
|
|
26872
|
+
we don't put an alt attribute on
|
|
26873
|
+
the image, so that screen readers
|
|
26874
|
+
know there's something they can't
|
|
26875
|
+
read there :(.
|
|
26876
|
+
NOTE: React <=0.13 (maybe later)
|
|
26877
|
+
has a bug where it won't ever
|
|
26878
|
+
remove an attribute, so if this
|
|
26879
|
+
alt node is ever defined it's
|
|
26880
|
+
not removed. This is sort of
|
|
26881
|
+
dangerous, but we usually re-key
|
|
26882
|
+
new renderers so that they're
|
|
26883
|
+
rendered from scratch anyways,
|
|
26884
|
+
so this shouldn't be a problem
|
|
26885
|
+
in practice right now, although
|
|
26886
|
+
it will exhibit weird behaviour
|
|
26887
|
+
while editing. */
|
|
26888
|
+
this.props.alt,
|
|
26889
|
+
overrideAriaHidden: true,
|
|
26890
|
+
width: backgroundImage.width,
|
|
26891
|
+
height: backgroundImage.height,
|
|
26892
|
+
preloader: apiOptions.imagePreloader,
|
|
26893
|
+
extraGraphie: {
|
|
26894
|
+
box: this.props.box,
|
|
26895
|
+
range: this.props.range,
|
|
26896
|
+
labels: this.props.labels
|
|
26897
|
+
},
|
|
26898
|
+
trackInteraction: this.props.trackInteraction,
|
|
26899
|
+
zoomToFullSizeOnMobile: apiOptions.isMobile,
|
|
26900
|
+
constrainHeight: apiOptions.isMobile,
|
|
26901
|
+
allowFullBleed: apiOptions.isMobile,
|
|
26902
|
+
setAssetStatus: setAssetStatus
|
|
26903
|
+
});
|
|
26897
26904
|
});
|
|
26898
26905
|
}
|
|
26899
26906
|
if (this.props.alt) {
|
|
@@ -27896,15 +27903,20 @@ class Graph extends React__namespace.Component {
|
|
|
27896
27903
|
const imageData = this.props.backgroundImage;
|
|
27897
27904
|
if (imageData.url) {
|
|
27898
27905
|
const scale = this.props.box[0] / interactiveSizes$1.defaultBoxSize;
|
|
27899
|
-
image =
|
|
27900
|
-
|
|
27901
|
-
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
width:
|
|
27905
|
-
|
|
27906
|
-
|
|
27907
|
-
|
|
27906
|
+
image = /*#__PURE__*/React__namespace.createElement(context$1.Consumer, null, _ref => {
|
|
27907
|
+
let {
|
|
27908
|
+
setAssetStatus
|
|
27909
|
+
} = _ref;
|
|
27910
|
+
return /*#__PURE__*/React__namespace.createElement(SvgImage
|
|
27911
|
+
// @ts-expect-error - TS2741 - Property 'alt' is missing in type '{ src: any; width: any; height: any; scale: number; responsive: false; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'.
|
|
27912
|
+
, {
|
|
27913
|
+
src: imageData.url,
|
|
27914
|
+
width: imageData.width,
|
|
27915
|
+
height: imageData.height,
|
|
27916
|
+
scale: scale,
|
|
27917
|
+
responsive: false,
|
|
27918
|
+
setAssetStatus: setAssetStatus
|
|
27919
|
+
});
|
|
27908
27920
|
});
|
|
27909
27921
|
} else {
|
|
27910
27922
|
image = null;
|
|
@@ -44209,7 +44221,7 @@ const init = function (options) {
|
|
|
44209
44221
|
|
|
44210
44222
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44211
44223
|
const libName = "@khanacademy/perseus";
|
|
44212
|
-
const libVersion = "
|
|
44224
|
+
const libVersion = "14.0.0";
|
|
44213
44225
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44214
44226
|
|
|
44215
44227
|
const apiVersion = {
|
|
@@ -44764,7 +44776,6 @@ const ProvideKeypad = {
|
|
|
44764
44776
|
// @ts-expect-error - TS2339 - Property 'props' does not exist on type '{ readonly propTypes: { readonly apiOptions: React.PropType<{ customKeypad?: boolean | undefined; nativeKeypadProxy?: ((...a: readonly any[]) => unknown) | undefined; }>; readonly keypadStyle: Requireable<any>; }; readonly getInitialState: () => { ...; }; readonly componentDidMount: () => void; readonly componentWil...'.
|
|
44765
44777
|
,
|
|
44766
44778
|
style: _this.props.keypadStyle,
|
|
44767
|
-
useV2Keypad: apiOptions.useV2Keypad,
|
|
44768
44779
|
onAnalyticsEvent: async () => {
|
|
44769
44780
|
// Intentionally left empty. This component is
|
|
44770
44781
|
// deprecated and so we don't want/need to instrument
|