@khanacademy/perseus 11.3.0 → 11.5.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.
@@ -1,9 +1,8 @@
1
- import { KeypadType } from "@khanacademy/math-input";
2
1
  import * as React from "react";
3
2
  import { useDependencies } from "../dependencies";
4
3
  import type { PerseusExpressionWidgetOptions } from "../perseus-types";
5
4
  import type { PerseusScore, WidgetProps } from "../types";
6
- import type { Keys as Key } from "@khanacademy/math-input";
5
+ import type { Keys as Key, KeypadConfiguration } from "@khanacademy/math-input";
7
6
  type InputPath = ReadonlyArray<string>;
8
7
  type Rubric = PerseusExpressionWidgetOptions;
9
8
  type RenderProps = {
@@ -79,10 +78,7 @@ export declare class Expression extends React.Component<Props, ExpressionState>
79
78
  * to be included as keys on the keypad. These are scraped from the answer
80
79
  * forms.
81
80
  */
82
- declare const keypadConfigurationForProps: (widgetOptions: PerseusExpressionWidgetOptions) => {
83
- keypadType: KeypadType;
84
- extraKeys: string[];
85
- };
81
+ declare const keypadConfigurationForProps: (widgetOptions: PerseusExpressionWidgetOptions) => KeypadConfiguration;
86
82
  declare const _default: Readonly<{
87
83
  name: string;
88
84
  displayName: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "11.3.0",
6
+ "version": "11.5.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -24,10 +24,10 @@
24
24
  "dependencies": {
25
25
  "@khanacademy/kas": "^0.3.1",
26
26
  "@khanacademy/kmath": "^0.1.2",
27
- "@khanacademy/math-input": "^12.1.0",
28
- "@khanacademy/perseus-core": "1.0.0",
29
- "@khanacademy/perseus-linter": "^0.3.3",
30
- "@khanacademy/pure-markdown": "^0.2.5",
27
+ "@khanacademy/math-input": "^13.0.0",
28
+ "@khanacademy/perseus-core": "1.1.0",
29
+ "@khanacademy/perseus-linter": "^0.3.4",
30
+ "@khanacademy/pure-markdown": "^0.2.6",
31
31
  "@khanacademy/simple-markdown": "^0.10.0"
32
32
  },
33
33
  "devDependencies": {
@@ -110,10 +110,6 @@
110
110
  color: inherit;
111
111
  }
112
112
 
113
- .perseus-image-widget {
114
- text-align: center;
115
- }
116
-
117
113
  .perseus-image-caption .perseus-renderer .paragraph .paragraph,
118
114
  .perseus-image-caption .perseus-renderer .paragraph ol,
119
115
  .perseus-image-caption .perseus-renderer .paragraph ul {
@@ -11,6 +11,7 @@ import expressionExport from "../expression";
11
11
  import TestKeypadContextWrapper from "./test-keypad-context-wrapper";
12
12
 
13
13
  import type {PerseusItem} from "../../perseus-types";
14
+ import type {Keys as Key} from "@khanacademy/math-input";
14
15
 
15
16
  type StoryArgs = {
16
17
  customKeypad: boolean;
@@ -34,8 +35,11 @@ const WrappedKeypadContext = (props: WrappedKeypadContextProps) => {
34
35
  return (
35
36
  <ItemRendererWithDebugUI
36
37
  item={props.item}
38
+ // Hardcoding the V2 Keypad to true as the Storybook Args
39
+ // were not working.
37
40
  apiOptions={{
38
41
  customKeypad: props.customKeypad,
42
+ useV2Keypad: true,
39
43
  }}
40
44
  />
41
45
  );
@@ -63,7 +67,7 @@ export const DesktopKitchenSink = (args: StoryArgs): React.ReactElement => {
63
67
 
64
68
  const keypadConfiguration = {
65
69
  keypadType: KeypadType.EXPRESSION,
66
- extraKeys: ["x", "y", "z"],
70
+ extraKeys: ["x", "y", "z"] as Key[],
67
71
  };
68
72
 
69
73
  return (
@@ -29,7 +29,7 @@ import type {
29
29
  WidgetExports,
30
30
  WidgetProps,
31
31
  } from "../types";
32
- import type {Keys as Key} from "@khanacademy/math-input";
32
+ import type {Keys as Key, KeypadConfiguration} from "@khanacademy/math-input";
33
33
  import type {PropsFor} from "@khanacademy/wonder-blocks-core";
34
34
 
35
35
  type InputPath = ReadonlyArray<string>;
@@ -610,7 +610,7 @@ export class Expression extends React.Component<Props, ExpressionState> {
610
610
  */
611
611
  const keypadConfigurationForProps = (
612
612
  widgetOptions: PerseusExpressionWidgetOptions,
613
- ) => {
613
+ ): KeypadConfiguration => {
614
614
  // Always use the Expression keypad, regardless of the button sets that have
615
615
  // been enabled.
616
616
  const keypadType = KeypadType.EXPRESSION;
@@ -642,20 +642,22 @@ const keypadConfigurationForProps = (
642
642
 
643
643
  // TODO(charlie): Alert the keypad as to which of these symbols should be
644
644
  // treated as functions.
645
- const extraVariables = Object.keys(uniqueExtraVariables);
646
- extraVariables.sort();
645
+ const extraVariables = Object.keys(
646
+ uniqueExtraVariables,
647
+ ).sort() as ReadonlyArray<Key>;
647
648
 
648
- const extraConstants = Object.keys(uniqueExtraConstants);
649
- extraConstants.sort();
649
+ const extraConstants = Object.keys(
650
+ uniqueExtraConstants,
651
+ ).sort() as ReadonlyArray<Key>;
650
652
 
651
- const extraKeys = [...extraVariables, ...extraConstants];
653
+ let extraKeys = [...extraVariables, ...extraConstants];
652
654
  if (!extraKeys.length) {
653
655
  // If there are no extra symbols available, we include Pi anyway, so
654
656
  // that the "extra symbols" button doesn't appear empty.
655
- extraKeys.push("PI");
657
+ extraKeys = ["PI"];
656
658
  }
657
659
 
658
- return {keypadType, extraKeys};
660
+ return {keypadType, extraKeys, times: widgetOptions.times};
659
661
  };
660
662
 
661
663
  const propUpgrades = {