@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @khanacademy/perseus
|
|
2
2
|
|
|
3
|
+
## 14.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#825](https://github.com/Khan/perseus/pull/825) [`7cb40e4c`](https://github.com/Khan/perseus/commit/7cb40e4c919be50e5ced41e4937178bbf849ec74) Thanks [@benchristel](https://github.com/benchristel)! - We've removed the deprecated `useV2Keypad` prop from the MobileKeypad component.
|
|
8
|
+
|
|
9
|
+
The V2 keypad is now the default, and the old keypad has been removed.
|
|
10
|
+
|
|
11
|
+
Additionally, the mobile keypad no longer accepts the `keypadActive` or
|
|
12
|
+
`setKeypadActive` props. It now gets those values itself from the `KeypadContext`.
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#816](https://github.com/Khan/perseus/pull/816) [`cdcd162e`](https://github.com/Khan/perseus/commit/cdcd162ea0902d3ff1d77b1b66ad15f2d55a86cd) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Wrap all SvgImage instances in AssetContext (ensures that host applications can correctly wait for all images to load in a renderer before proceeding).
|
|
17
|
+
|
|
18
|
+
* [#788](https://github.com/Khan/perseus/pull/788) [`8f1f0208`](https://github.com/Khan/perseus/commit/8f1f0208fcc08e137053bfd05d330b6f8bf3522d) Thanks [@jeanettehead](https://github.com/jeanettehead)! - create randomized storybook stories for some widgets
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`7cb40e4c`](https://github.com/Khan/perseus/commit/7cb40e4c919be50e5ced41e4937178bbf849ec74)]:
|
|
23
|
+
- @khanacademy/math-input@16.0.0
|
|
24
|
+
|
|
3
25
|
## 13.2.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -24,6 +24,15 @@ type Props = {
|
|
|
24
24
|
zoomToFullSizeOnMobile?: boolean;
|
|
25
25
|
setAssetStatus: (assetKey: string, loaded: boolean) => void;
|
|
26
26
|
};
|
|
27
|
+
type DefaultProps = {
|
|
28
|
+
constrainHeight: NonNullable<Props["constrainHeight"]>;
|
|
29
|
+
onUpdate: NonNullable<Props["onUpdate"]>;
|
|
30
|
+
responsive: NonNullable<Props["responsive"]>;
|
|
31
|
+
scale: NonNullable<Props["scale"]>;
|
|
32
|
+
setAssetStatus: NonNullable<Props["setAssetStatus"]>;
|
|
33
|
+
src: NonNullable<Props["src"]>;
|
|
34
|
+
zoomToFullSizeOnMobile: NonNullable<Props["zoomToFullSizeOnMobile"]>;
|
|
35
|
+
};
|
|
27
36
|
type Label = {
|
|
28
37
|
coordinates: ReadonlyArray<any>;
|
|
29
38
|
content: string;
|
|
@@ -44,15 +53,7 @@ type State = {
|
|
|
44
53
|
};
|
|
45
54
|
declare class SvgImage extends React.Component<Props, State> {
|
|
46
55
|
_isMounted: boolean;
|
|
47
|
-
static defaultProps:
|
|
48
|
-
constrainHeight: boolean;
|
|
49
|
-
onUpdate: () => void;
|
|
50
|
-
responsive: boolean;
|
|
51
|
-
scale: number;
|
|
52
|
-
setAssetStatus: (src: string, status: boolean) => void;
|
|
53
|
-
src: string;
|
|
54
|
-
zoomToFullSizeOnMobile: boolean;
|
|
55
|
-
};
|
|
56
|
+
static defaultProps: DefaultProps;
|
|
56
57
|
constructor(props: Props);
|
|
57
58
|
componentDidMount(): void;
|
|
58
59
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
package/dist/es/index.js
CHANGED
|
@@ -16521,7 +16521,7 @@ const doJSONP = function doJSONP(url, options) {
|
|
|
16521
16521
|
// system (with file://). We replace urls that start with `web+graphie`
|
|
16522
16522
|
// in the perseus json with this `file+graphie` prefix to indicate that
|
|
16523
16523
|
// they should have the `file://` protocol instead of `https://`.
|
|
16524
|
-
const svgLocalLabelsRegex = /^file\+graphie
|
|
16524
|
+
const svgLocalLabelsRegex = /^file\+graphie:/;
|
|
16525
16525
|
const hashRegex = /\/([^/]+)$/;
|
|
16526
16526
|
function isImageProbablyPhotograph(imageUrl) {
|
|
16527
16527
|
// TODO(david): Do an inventory to refine this heuristic. For example, what
|
|
@@ -26697,29 +26697,32 @@ class ImageWidget extends React.Component {
|
|
|
26697
26697
|
} = this.props;
|
|
26698
26698
|
const backgroundImage = this.props.backgroundImage;
|
|
26699
26699
|
if (backgroundImage.url) {
|
|
26700
|
-
|
|
26701
|
-
|
|
26700
|
+
const url = backgroundImage.url;
|
|
26701
|
+
image = /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
|
|
26702
|
+
setAssetStatus
|
|
26703
|
+
}) => /*#__PURE__*/React.createElement(SvgImage, {
|
|
26704
|
+
src: url,
|
|
26702
26705
|
alt:
|
|
26703
26706
|
/* alt text is formatted in a sr-only
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
26713
|
-
|
|
26714
|
-
|
|
26715
|
-
|
|
26716
|
-
|
|
26717
|
-
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26722
|
-
|
|
26707
|
+
div next to the image in addition to
|
|
26708
|
+
the alt attribute.
|
|
26709
|
+
If there is no alt text at all,
|
|
26710
|
+
we don't put an alt attribute on
|
|
26711
|
+
the image, so that screen readers
|
|
26712
|
+
know there's something they can't
|
|
26713
|
+
read there :(.
|
|
26714
|
+
NOTE: React <=0.13 (maybe later)
|
|
26715
|
+
has a bug where it won't ever
|
|
26716
|
+
remove an attribute, so if this
|
|
26717
|
+
alt node is ever defined it's
|
|
26718
|
+
not removed. This is sort of
|
|
26719
|
+
dangerous, but we usually re-key
|
|
26720
|
+
new renderers so that they're
|
|
26721
|
+
rendered from scratch anyways,
|
|
26722
|
+
so this shouldn't be a problem
|
|
26723
|
+
in practice right now, although
|
|
26724
|
+
it will exhibit weird behaviour
|
|
26725
|
+
while editing. */
|
|
26723
26726
|
this.props.alt,
|
|
26724
26727
|
overrideAriaHidden: true,
|
|
26725
26728
|
width: backgroundImage.width,
|
|
@@ -26733,8 +26736,9 @@ class ImageWidget extends React.Component {
|
|
|
26733
26736
|
trackInteraction: this.props.trackInteraction,
|
|
26734
26737
|
zoomToFullSizeOnMobile: apiOptions.isMobile,
|
|
26735
26738
|
constrainHeight: apiOptions.isMobile,
|
|
26736
|
-
allowFullBleed: apiOptions.isMobile
|
|
26737
|
-
|
|
26739
|
+
allowFullBleed: apiOptions.isMobile,
|
|
26740
|
+
setAssetStatus: setAssetStatus
|
|
26741
|
+
}));
|
|
26738
26742
|
}
|
|
26739
26743
|
if (this.props.alt) {
|
|
26740
26744
|
alt = /*#__PURE__*/React.createElement("span", {
|
|
@@ -27734,16 +27738,18 @@ class Graph extends React.Component {
|
|
|
27734
27738
|
const imageData = this.props.backgroundImage;
|
|
27735
27739
|
if (imageData.url) {
|
|
27736
27740
|
const scale = this.props.box[0] / interactiveSizes$1.defaultBoxSize;
|
|
27737
|
-
image =
|
|
27738
|
-
|
|
27741
|
+
image = /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
|
|
27742
|
+
setAssetStatus
|
|
27743
|
+
}) => /*#__PURE__*/React.createElement(SvgImage
|
|
27739
27744
|
// @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">'.
|
|
27740
|
-
|
|
27745
|
+
, {
|
|
27741
27746
|
src: imageData.url,
|
|
27742
27747
|
width: imageData.width,
|
|
27743
27748
|
height: imageData.height,
|
|
27744
27749
|
scale: scale,
|
|
27745
|
-
responsive: false
|
|
27746
|
-
|
|
27750
|
+
responsive: false,
|
|
27751
|
+
setAssetStatus: setAssetStatus
|
|
27752
|
+
}));
|
|
27747
27753
|
} else {
|
|
27748
27754
|
image = null;
|
|
27749
27755
|
}
|
|
@@ -44083,7 +44089,7 @@ const init = function init(options) {
|
|
|
44083
44089
|
|
|
44084
44090
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44085
44091
|
const libName = "@khanacademy/perseus";
|
|
44086
|
-
const libVersion = "
|
|
44092
|
+
const libVersion = "14.0.0";
|
|
44087
44093
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44088
44094
|
|
|
44089
44095
|
const apiVersion = {
|
|
@@ -44638,7 +44644,6 @@ const ProvideKeypad = {
|
|
|
44638
44644
|
// @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...'.
|
|
44639
44645
|
,
|
|
44640
44646
|
style: _this.props.keypadStyle,
|
|
44641
|
-
useV2Keypad: apiOptions.useV2Keypad,
|
|
44642
44647
|
onAnalyticsEvent: async () => {
|
|
44643
44648
|
// Intentionally left empty. This component is
|
|
44644
44649
|
// deprecated and so we don't want/need to instrument
|