@khanacademy/perseus 6.7.0 → 7.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,22 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - f9ee9d24: Move KeypadContext from Perseus to MathInput
8
+
9
+ ### Minor Changes
10
+
11
+ - b18986d3: Adds useV2Keypad API option for switching between new and legacy keypads
12
+
13
+ ### Patch Changes
14
+
15
+ - b18986d3: Replace Legacy/Mobile keypads with a component that switches between them
16
+ - Updated dependencies [f9ee9d24]
17
+ - Updated dependencies [b18986d3]
18
+ - @khanacademy/math-input@8.0.0
19
+
3
20
  ## 6.7.0
4
21
 
5
22
  ### Minor Changes
package/dist/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as KAS from '@khanacademy/kas';
2
- import { keyTranslator, createMathField, mathQuillInstance, KeypadInput, KeypadType, keypadElementPropType, LegacyKeypad } from '@khanacademy/math-input';
2
+ import { keyTranslator, createMathField, mathQuillInstance, KeypadInput, KeypadType, keypadElementPropType, Keypad } from '@khanacademy/math-input';
3
3
  import * as PerseusLinter from '@khanacademy/perseus-linter';
4
4
  import { linterContextDefault, Rule, linterContextProps } from '@khanacademy/perseus-linter';
5
5
  import * as i18n from '@khanacademy/wonder-blocks-i18n';
@@ -1433,6 +1433,10 @@ const ApiOptions = {
1433
1433
  nativeKeypadProxy: PropTypes.func,
1434
1434
  // Indicates whether or not to use mobile styling.
1435
1435
  isMobile: PropTypes.bool,
1436
+ // Whether to use v1 (Legacy) Keypad for MathInput mobile or
1437
+ // use the new v2 Keypad
1438
+ // TODO [LC-1088]: remove after v2 release
1439
+ useV2Keypad: PropTypes.bool,
1436
1440
  // A function, called with a bool indicating whether use of the
1437
1441
  // drawing area (scratchpad) should be allowed/disallowed.
1438
1442
  // Previously handled by `Khan.scratchpad.enable/disable`
@@ -1471,6 +1475,7 @@ const ApiOptions = {
1471
1475
  defaults: {
1472
1476
  isArticle: false,
1473
1477
  isMobile: false,
1478
+ useV2Keypad: false,
1474
1479
  onInputError: function () {},
1475
1480
  onFocusChange: function () {},
1476
1481
  GroupMetadataEditor: StubTagEditor,
@@ -2938,7 +2943,7 @@ const defaultContext$2 = {
2938
2943
  assetStatuses: {},
2939
2944
  setAssetStatus: (assetKey, loaded) => {}
2940
2945
  };
2941
- const context$2 = /*#__PURE__*/React.createContext(defaultContext$2);
2946
+ const context$1 = /*#__PURE__*/React.createContext(defaultContext$2);
2942
2947
 
2943
2948
  /* eslint-disable @babel/no-invalid-this, getter-return, one-var */
2944
2949
  let supportsPassive = false;
@@ -17597,7 +17602,7 @@ class ZoomableTeX extends React.Component {
17597
17602
  return /*#__PURE__*/React.createElement(Zoomable, {
17598
17603
  readyToMeasure: this.state.isRendered,
17599
17604
  computeChildBounds: computeMathBounds
17600
- }, /*#__PURE__*/React.createElement(context$2.Consumer, null, ({
17605
+ }, /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
17601
17606
  setAssetStatus
17602
17607
  }) => /*#__PURE__*/React.createElement(Tex, {
17603
17608
  onRender: this.handleRender,
@@ -19687,7 +19692,7 @@ class Renderer extends React.Component {
19687
19692
  }, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("div", {
19688
19693
  className: "perseus-block-math-inner",
19689
19694
  style: innerStyle
19690
- }, /*#__PURE__*/React.createElement(context$2.Consumer, null, ({
19695
+ }, /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
19691
19696
  setAssetStatus
19692
19697
  }) => /*#__PURE__*/React.createElement(Tex, {
19693
19698
  setAssetStatus: setAssetStatus
@@ -19709,7 +19714,7 @@ class Renderer extends React.Component {
19709
19714
  // wrap to the next line
19710
19715
  whiteSpace: "nowrap"
19711
19716
  }
19712
- }, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("span", null), /*#__PURE__*/React.createElement(context$2.Consumer, null, ({
19717
+ }, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("span", null), /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
19713
19718
  setAssetStatus
19714
19719
  }) => /*#__PURE__*/React.createElement(Tex, {
19715
19720
  onRender: this.props.onRender,
@@ -19737,7 +19742,7 @@ class Renderer extends React.Component {
19737
19742
  const responsive = !state.inTable;
19738
19743
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
19739
19744
  key: state.key
19740
- }, /*#__PURE__*/React.createElement(context$2.Consumer, null, ({
19745
+ }, /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
19741
19746
  setAssetStatus
19742
19747
  }) => /*#__PURE__*/React.createElement(SvgImage, _extends({
19743
19748
  setAssetStatus: setAssetStatus
@@ -31728,7 +31733,7 @@ class LabelImage extends React.Component {
31728
31733
  // than its rendered in the widget, this would
31729
31734
  // result in a zoom of the image.
31730
31735
  selectedMarkerIndex !== -1 && styles$f.imageInteractionDisabled)
31731
- }, /*#__PURE__*/React.createElement(context$2.Consumer, null, ({
31736
+ }, /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
31732
31737
  setAssetStatus
31733
31738
  }) => /*#__PURE__*/React.createElement(SvgImage, {
31734
31739
  alt: imageAlt,
@@ -43944,13 +43949,9 @@ const ProvideKeypad = {
43944
43949
  },
43945
43950
  componentDidMount() {
43946
43951
  const _this = this;
43947
- if (
43948
- // @ts-expect-error [FEI-5003] - 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...'.
43949
- _this.props.apiOptions &&
43950
- // @ts-expect-error [FEI-5003] - 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...'.
43951
- _this.props.apiOptions.customKeypad &&
43952
43952
  // @ts-expect-error [FEI-5003] - 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...'.
43953
- !_this.props.apiOptions.nativeKeypadProxy) {
43953
+ const apiOptions = _this.props.apiOptions;
43954
+ if (apiOptions && apiOptions.customKeypad && !apiOptions.nativeKeypadProxy) {
43954
43955
  var _document$body;
43955
43956
  // TODO(charlie): Render this and the wrapped component in the same
43956
43957
  // React tree. We may also want to add this keypad asynchronously
@@ -43959,7 +43960,7 @@ const ProvideKeypad = {
43959
43960
  _this._keypadContainer = document.createElement("div");
43960
43961
  // @ts-expect-error [FEI-5003] - TS2339 - Property '_keypadContainer' 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...'.
43961
43962
  (_document$body = document.body) == null ? void 0 : _document$body.appendChild(_this._keypadContainer);
43962
- render( /*#__PURE__*/React.createElement(LegacyKeypad, {
43963
+ render( /*#__PURE__*/React.createElement(Keypad, {
43963
43964
  onElementMounted: element => {
43964
43965
  // NOTE(kevinb): The reason why this setState works is
43965
43966
  // b/c we're calling it manually from item-renderer.jsx
@@ -43975,7 +43976,8 @@ const ProvideKeypad = {
43975
43976
  }
43976
43977
  // @ts-expect-error [FEI-5003] - 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...'.
43977
43978
  ,
43978
- style: _this.props.keypadStyle
43979
+ style: _this.props.keypadStyle,
43980
+ useV2Keypad: apiOptions.useV2Keypad
43979
43981
  }),
43980
43982
  // @ts-expect-error [FEI-5003] - TS2339 - Property '_keypadContainer' 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...'.
43981
43983
  _this._keypadContainer);
@@ -44889,7 +44891,7 @@ ItemRenderer.defaultProps = {
44889
44891
  const defaultContext = {
44890
44892
  onRendered: isRendered => {}
44891
44893
  };
44892
- const context$1 = /*#__PURE__*/React.createContext(defaultContext);
44894
+ const context = /*#__PURE__*/React.createContext(defaultContext);
44893
44895
 
44894
44896
  const {
44895
44897
  mapObject
@@ -45157,7 +45159,7 @@ class ServerItemRenderer extends React.Component {
45157
45159
  assetStatuses: this.state.assetStatuses,
45158
45160
  setAssetStatus: this.setAssetStatus
45159
45161
  };
45160
- const questionRenderer = /*#__PURE__*/React.createElement(context$2.Provider, {
45162
+ const questionRenderer = /*#__PURE__*/React.createElement(context$1.Provider, {
45161
45163
  value: contextValue
45162
45164
  }, /*#__PURE__*/React.createElement(Renderer, {
45163
45165
  keypadElement: this.props.keypadElement,
@@ -45204,7 +45206,7 @@ const styles$3 = StyleSheet.create({
45204
45206
  marginLeft: 50
45205
45207
  }
45206
45208
  });
45207
- const ref = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(context$1.Consumer, null, ({
45209
+ const ref = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(context.Consumer, null, ({
45208
45210
  onRendered
45209
45211
  }) => /*#__PURE__*/React.createElement(ServerItemRenderer, _extends({}, props, {
45210
45212
  onRendered: onRendered,
@@ -45695,24 +45697,6 @@ var constants = /*#__PURE__*/Object.freeze({
45695
45697
  perseusFrameBorderWidth: perseusFrameBorderWidth
45696
45698
  });
45697
45699
 
45698
- /**
45699
- * KeypadContext provides a way to the Keypad and (Server)ItemRenderer to
45700
- * communicate.
45701
- *
45702
- * The KeypadContext.Provider wraps the ExerciseFooter while KeypadContext.Consumer
45703
- * wraps each (Server)ItemRenderer render site and the Keypad rendered in the
45704
- * ExerciseFooter.
45705
- */
45706
- // @ts-expect-error [FEI-5003] - TS2322 - Type 'Context<{ setKeypadElement: (keypadElement: HTMLElement | null | undefined) => void; keypadElement: null; setRenderer: (renderer: RendererInterface | null | undefined) => void; renderer: null; setScrollableElement: (scrollableElement: HTMLElement | ... 1 more ... | undefined) => void; scrollableElement: null; }>' is not assignable to type 'Context<KeypadContext>'.
45707
- const context = /*#__PURE__*/React.createContext({
45708
- setKeypadElement: keypadElement => {},
45709
- keypadElement: null,
45710
- setRenderer: renderer => {},
45711
- renderer: null,
45712
- setScrollableElement: scrollableElement => {},
45713
- scrollableElement: null
45714
- });
45715
-
45716
45700
  // TODO(FEI-4010): Remove `Perseus` prefix for all types here
45717
45701
  // TODO(FEI-4011): Use types generated by https://github.com/jaredly/generate-perseus-flowtypes
45718
45702
 
@@ -46881,5 +46865,5 @@ const EditorJsonify = {
46881
46865
  const apiVersion = version.apiVersion;
46882
46866
  const itemDataVersion = version.itemDataVersion;
46883
46867
 
46884
- export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, context as KeypadContext, KhanColors, KhanMath, context$1 as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
46868
+ export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
46885
46869
  //# sourceMappingURL=index.js.map