@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 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
- image = /*#__PURE__*/React.createElement(SvgImage, {
26701
- src: backgroundImage.url,
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
- div next to the image in addition to
26705
- the alt attribute.
26706
- If there is no alt text at all,
26707
- we don't put an alt attribute on
26708
- the image, so that screen readers
26709
- know there's something they can't
26710
- read there :(.
26711
- NOTE: React <=0.13 (maybe later)
26712
- has a bug where it won't ever
26713
- remove an attribute, so if this
26714
- alt node is ever defined it's
26715
- not removed. This is sort of
26716
- dangerous, but we usually re-key
26717
- new renderers so that they're
26718
- rendered from scratch anyways,
26719
- so this shouldn't be a problem
26720
- in practice right now, although
26721
- it will exhibit weird behaviour
26722
- while editing. */
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
- /*#__PURE__*/
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
- React.createElement(SvgImage, {
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 = "13.2.0";
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