@khanacademy/perseus 39.0.0 → 40.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.
@@ -1,48 +1,3 @@
1
1
  /// <reference path="../../types/aphrodite.d.ts" />
2
- import type { StyleDeclaration } from "aphrodite";
3
- export declare const colors: {
4
- readonly white: "#FFFFFF";
5
- readonly gray98: "#FAFAFA";
6
- readonly gray97: "#F6F7F7";
7
- readonly gray95: "#F0F1F2";
8
- readonly gray90: "#E3E5E6";
9
- readonly gray85: "#D6D8DA";
10
- readonly gray76: "#BABEC2";
11
- readonly gray72: "#999A9D";
12
- readonly gray68: "#888D93";
13
- readonly gray55: "#707378";
14
- readonly gray41: "#626569";
15
- readonly gray25: "#3B3E40";
16
- readonly gray17: "#21242C";
17
- readonly gray10: "#1499af";
18
- readonly black: "#000000";
19
- readonly alertRed: "#C42420";
20
- readonly homepageBlue: "#46A8BF";
21
- readonly kaBlue: "#314453";
22
- readonly kaBlueLight: "#4D6779";
23
- readonly kaGreen: "#71B307";
24
- readonly kaGreenLight: "#BED47A";
25
- readonly learnstormBlue: "#4898FC";
26
- readonly backgroundBlue: "#00294A";
27
- readonly adminGreen: "#78C008";
28
- readonly kaBlueExtraLight: "#39c2db";
29
- readonly kaBlueHover: "#0c7f99";
30
- readonly kaGreenHover: "#518005";
31
- readonly skyDark: "#001f4d";
32
- readonly recommendationGold: "#ffbe26";
33
- readonly starAced: "#ff9c39";
34
- readonly google: "#C1432f";
35
- readonly modernGoogle: "#be2612";
36
- readonly modernGoogleHover: "#8c1c0d";
37
- readonly facebook: "#4267B2";
38
- readonly modernFacebook: "#4267B2";
39
- readonly modernFacebookHover: "#00294a";
40
- readonly wonderBlocksGold: "#FFB100";
41
- readonly wonderBlocksLightBlue: "#37C5FD";
42
- readonly breadcrumbs: "rgba(255, 255, 255, 0.7)";
43
- };
44
- export declare const borderRadius = 4;
45
- export declare const fonts: {
46
- readonly regular: "inherit";
47
- };
48
- export declare const typography: StyleDeclaration;
2
+ import type { CSSProperties } from "aphrodite";
3
+ export declare const bodyXsmallBold: CSSProperties;
@@ -1,4 +1,4 @@
1
- import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusIFrameWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, PerseusNumericInputWidgetOptions, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, PerseusSorterWidgetOptions, PerseusTableWidgetOptions } from "./perseus-types";
1
+ import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioChoice, PerseusTableWidgetOptions } from "./perseus-types";
2
2
  import type { InteractiveMarkerType } from "./widgets/label-image/types";
3
3
  import type { Relationship } from "./widgets/number-line/number-line";
4
4
  export type UserInputStatus = "correct" | "incorrect" | "incomplete";
@@ -31,7 +31,7 @@ export type PerseusGrapherRubric = {
31
31
  correct: GrapherAnswerTypes;
32
32
  };
33
33
  export type PerseusGrapherUserInput = PerseusGrapherRubric["correct"];
34
- export type PerseusIFrameRubric = PerseusIFrameWidgetOptions;
34
+ export type PerseusIFrameRubric = Empty;
35
35
  export type PerseusIFrameUserInput = {
36
36
  status: UserInputStatus;
37
37
  message: string | null;
@@ -60,9 +60,11 @@ export type PerseusMatcherUserInput = {
60
60
  left: ReadonlyArray<string>;
61
61
  right: ReadonlyArray<string>;
62
62
  };
63
- export type PerseusMatrixRubric = PerseusMatrixWidgetOptions;
63
+ export type PerseusMatrixRubric = {
64
+ answers: PerseusMatrixWidgetAnswers;
65
+ };
64
66
  export type PerseusMatrixUserInput = {
65
- answers: ReadonlyArray<ReadonlyArray<number>>;
67
+ answers: PerseusMatrixRubric["answers"];
66
68
  };
67
69
  export type PerseusNumberLineRubric = PerseusNumberLineWidgetOptions & {
68
70
  isInequality: boolean;
@@ -74,7 +76,10 @@ export type PerseusNumberLineUserInput = {
74
76
  numDivisions: number;
75
77
  divisionRange: ReadonlyArray<number>;
76
78
  };
77
- export type PerseusNumericInputRubric = PerseusNumericInputWidgetOptions;
79
+ export type PerseusNumericInputRubric = {
80
+ answers: ReadonlyArray<PerseusNumericInputAnswer>;
81
+ coefficient: boolean;
82
+ };
78
83
  export type PerseusNumericInputUserInput = {
79
84
  currentValue: string;
80
85
  };
@@ -84,15 +89,18 @@ export type PerseusOrdererUserInput = {
84
89
  };
85
90
  export type PerseusPlotterRubric = PerseusPlotterWidgetOptions;
86
91
  export type PerseusPlotterUserInput = ReadonlyArray<number>;
87
- export type PerseusRadioRubric = PerseusRadioWidgetOptions;
92
+ export type PerseusRadioRubric = {
93
+ choices: ReadonlyArray<PerseusRadioChoice>;
94
+ };
88
95
  export type PerseusRadioUserInput = {
89
- countChoices?: boolean;
90
96
  choicesSelected: ReadonlyArray<boolean>;
91
97
  numCorrect?: number;
92
98
  noneOfTheAboveIndex?: number | null | undefined;
93
99
  noneOfTheAboveSelected?: boolean;
94
100
  };
95
- export type PerseusSorterRubric = PerseusSorterWidgetOptions;
101
+ export type PerseusSorterRubric = {
102
+ correct: ReadonlyArray<string>;
103
+ };
96
104
  export type PerseusSorterUserInput = {
97
105
  options: ReadonlyArray<string>;
98
106
  changed: boolean;
@@ -1,8 +1,5 @@
1
1
  import type { LinearType, QuadraticType, SinusoidType, TangentType, ExponentialType, LogarithmType, AbsoluteValueType } from "./grapher-types";
2
2
  import type { Coord } from "../../interactive2/types";
3
- export declare const DEFAULT_BACKGROUND_IMAGE: {
4
- readonly url: null;
5
- };
6
3
  declare const functionTypeMapping: {
7
4
  readonly linear: LinearType;
8
5
  readonly quadratic: QuadraticType;
@@ -17,7 +14,6 @@ type FunctionTypeMappingKeys = keyof typeof functionTypeMapping;
17
14
  type ConditionalGraderType<T extends FunctionTypeMappingKeys> = T extends "linear" ? LinearType : T extends "quadratic" ? QuadraticType : T extends "sinusoid" ? SinusoidType : T extends "tangent" ? TangentType : T extends "exponential" ? ExponentialType : T extends "logarithm" ? LogarithmType : T extends "absolute_value" ? AbsoluteValueType : never;
18
15
  export declare function functionForType<T extends FunctionTypeMappingKeys>(type: T): ConditionalGraderType<T>;
19
16
  export declare const getEquationString: (props: any) => string;
20
- export declare const pointsFromNormalized: (coordsList: ReadonlyArray<Coord>, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord>;
21
17
  export declare const maybePointsFromNormalized: (coordsList: ReadonlyArray<Coord> | null | undefined, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord> | null | undefined;
22
18
  export declare const defaultPlotProps: (type: FunctionTypeMappingKeys, graph: any) => any;
23
19
  export declare const chooseType: <T>(list: ReadonlyArray<T>) => T | undefined;
@@ -1,3 +1,3 @@
1
1
  import type { PerseusScore } from "../../types";
2
2
  import type { PerseusIFrameUserInput } from "../../validation.types";
3
- export declare function iframeValidator(state: PerseusIFrameUserInput): PerseusScore;
3
+ export declare function iframeValidator(userInput: PerseusIFrameUserInput): PerseusScore;
@@ -5,19 +5,9 @@ type Props = {
5
5
  point: vec.Vector2;
6
6
  color?: string | undefined;
7
7
  dragging: boolean;
8
- focusBehavior: FocusBehaviorConfig;
8
+ showFocusRing: boolean;
9
9
  cursor?: CSSCursor | undefined;
10
10
  onClick?: () => unknown;
11
11
  };
12
- type FocusBehaviorConfig = ControlledFocusBehavior | UncontrolledFocusBehavior;
13
- type ControlledFocusBehavior = {
14
- type: "controlled";
15
- showFocusRing: boolean;
16
- };
17
- type UncontrolledFocusBehavior = {
18
- type: "uncontrolled";
19
- tabIndex: number;
20
- onFocusChange?: (event: React.FocusEvent, isFocused: boolean) => unknown;
21
- };
22
12
  export declare const MovablePointView: React.ForwardRefExoticComponent<Props & React.RefAttributes<SVGGElement>>;
23
13
  export {};
@@ -9,7 +9,8 @@ type Props = {
9
9
  color?: string;
10
10
  cursor?: CSSCursor | undefined;
11
11
  constrain?: KeyboardMovementConstraint;
12
- onFocusChange?: (event: React.FocusEvent, isFocused: boolean) => unknown;
12
+ onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
13
+ onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
13
14
  };
14
15
  export declare const MovablePoint: React.ForwardRefExoticComponent<Props & React.RefAttributes<SVGGElement | null>>;
15
16
  export {};
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import type { CSSCursor } from "./css-cursor";
3
+ import type { KeyboardMovementConstraint } from "../use-draggable";
4
+ import type { vec } from "mafs";
5
+ type Params = {
6
+ point: vec.Vector2;
7
+ color?: string | undefined;
8
+ cursor?: CSSCursor | undefined;
9
+ constrain?: KeyboardMovementConstraint;
10
+ onMove?: ((newPoint: vec.Vector2) => unknown) | undefined;
11
+ onClick?: (() => unknown) | undefined;
12
+ onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
13
+ onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
14
+ forwardedRef?: React.ForwardedRef<SVGGElement | null> | undefined;
15
+ };
16
+ type Return = {
17
+ focusableHandle: React.ReactNode;
18
+ visiblePoint: React.ReactNode;
19
+ focusableHandleRef: React.RefObject<SVGGElement>;
20
+ visiblePointRef: React.RefObject<SVGGElement>;
21
+ };
22
+ export declare function useControlPoint(params: Params): Return;
23
+ export {};
@@ -1,6 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { MafsGraphProps, PolygonGraphState } from "../types";
3
3
  type Props = MafsGraphProps<PolygonGraphState>;
4
- export declare const PolygonGraph: (props: Props) => React.JSX.Element;
4
+ export declare const LimitedPolygonGraph: (props: Props) => React.JSX.Element;
5
+ export declare const UnlimitedPolygonGraph: (props: Props) => React.JSX.Element;
5
6
  export declare const hasFocusVisible: (element: Element | null | undefined) => boolean;
7
+ export declare const PolygonGraph: (props: Props) => React.JSX.Element;
6
8
  export {};
@@ -24,7 +24,6 @@ export type MafsGraphProps = {
24
24
  readOnly: boolean;
25
25
  static: boolean | null | undefined;
26
26
  };
27
- export declare const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
28
27
  export declare const MafsGraph: (props: MafsGraphProps) => React.JSX.Element;
29
28
  export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: number, height: number) => {
30
29
  viewboxX: number;
@@ -34,6 +34,11 @@ export declare const actions: {
34
34
  polygon: {
35
35
  movePoint: typeof movePoint;
36
36
  moveAll: typeof moveAll;
37
+ addPoint: typeof addPoint;
38
+ removePoint: typeof removePoint;
39
+ focusPoint: typeof focusPoint;
40
+ blurPoint: typeof blurPoint;
41
+ clickPoint: typeof clickPoint;
37
42
  };
38
43
  quadratic: {
39
44
  movePoint: typeof movePoint;
@@ -8,7 +8,9 @@ export type MafsGraphProps<T extends InteractiveGraphState> = {
8
8
  graphState: T;
9
9
  dispatch: (action: InteractiveGraphAction) => unknown;
10
10
  };
11
+ export type InteractiveGraphType = "none" | "angle" | "segment" | "linear-system" | "linear" | "ray" | "polygon" | "point" | "circle" | "quadratic" | "sinusoid";
11
12
  export type InteractiveGraphState = AngleGraphState | SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | NoneGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
13
+ export type UnlimitedGraphState = PointGraphState | PolygonGraphState;
12
14
  export interface InteractiveGraphStateCommon {
13
15
  hasBeenInteractedWith: boolean;
14
16
  range: [xRange: Interval, yRange: Interval];
@@ -49,6 +51,11 @@ export interface PolygonGraphState extends InteractiveGraphStateCommon {
49
51
  showSides: boolean;
50
52
  snapTo: "grid" | "angles" | "sides";
51
53
  coords: Coord[];
54
+ numSides?: number | "unlimited";
55
+ focusedPointIndex: number | null;
56
+ showRemovePointButton: boolean;
57
+ interactionMode: InteractionMode;
58
+ showKeyboardInteractionInvitation: boolean;
52
59
  }
53
60
  export interface CircleGraphState extends InteractiveGraphStateCommon {
54
61
  type: "circle";
@@ -1,3 +1,4 @@
1
+ import type { InteractiveGraphState, UnlimitedGraphState } from "./types";
1
2
  import type { Coord } from "../../interactive2/types";
2
3
  import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
3
4
  import type { Interval, vec } from "mafs";
@@ -6,6 +7,7 @@ import type { Interval, vec } from "mafs";
6
7
  * https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
7
8
  */
8
9
  export declare const TARGET_SIZE = 44;
10
+ export declare const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
9
11
  export declare const normalizePoints: <A extends Coord[]>(range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: A, noSnap?: boolean) => A;
10
12
  export declare const normalizeCoords: <A extends Coord[]>(coordsList: A, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => A;
11
13
  export declare function bound({ snapStep, range, point, }: {
@@ -13,3 +15,4 @@ export declare function bound({ snapStep, range, point, }: {
13
15
  range: [Interval, Interval];
14
16
  point: vec.Vector2;
15
17
  }): vec.Vector2;
18
+ export declare function isUnlimitedGraphState(state: InteractiveGraphState): state is UnlimitedGraphState;
@@ -1,5 +1,5 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
2
  import type { PerseusScore } from "../../types";
3
3
  import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
4
- declare function matrixValidator(state: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
4
+ declare function matrixValidator(userInput: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
5
5
  export default matrixValidator;
@@ -21,11 +21,11 @@ type Props = {
21
21
  apiOptions: APIOptions;
22
22
  choices: ReadonlyArray<ChoiceType>;
23
23
  deselectEnabled?: boolean;
24
- editMode: boolean;
24
+ editMode?: boolean;
25
25
  labelWrap: boolean;
26
26
  countChoices: boolean | null | undefined;
27
27
  numCorrect: number;
28
- multipleSelect: boolean;
28
+ multipleSelect?: boolean;
29
29
  reviewModeRubric?: PerseusRadioWidgetOptions | null;
30
30
  reviewMode: boolean;
31
31
  onChange: (newValues: {
@@ -35,11 +35,5 @@ type Props = {
35
35
  registerFocusFunction?: (arg1: FocusFunction) => void;
36
36
  isLastUsedWidget?: boolean;
37
37
  };
38
- declare const BaseRadio: {
39
- (props: Props): React.ReactElement;
40
- defaultProps: {
41
- editMode: boolean;
42
- multipleSelect: boolean;
43
- };
44
- };
38
+ declare const BaseRadio: ({ apiOptions, reviewModeRubric, reviewMode, choices, editMode, multipleSelect, labelWrap, countChoices, numCorrect, isLastUsedWidget, onChange, registerFocusFunction, }: Props) => React.ReactElement;
45
39
  export default BaseRadio;
@@ -4,16 +4,9 @@
4
4
  import * as React from "react";
5
5
  type Props = {
6
6
  children?: React.ReactNode;
7
- visible: boolean;
8
- color: string;
9
- multipleSelect: boolean;
10
- };
11
- declare const FocusRing: {
12
- (props: Props): React.ReactElement;
13
- defaultProps: {
14
- visible: boolean;
15
- color: string;
16
- multipleSelect: boolean;
17
- };
7
+ visible?: boolean;
8
+ color?: string;
9
+ multipleSelect?: boolean;
18
10
  };
11
+ declare const FocusRing: ({ visible, color, multipleSelect, children, }: Props) => React.ReactElement;
19
12
  export default FocusRing;
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": "39.0.0",
6
+ "version": "40.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -40,14 +40,14 @@
40
40
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
41
41
  },
42
42
  "dependencies": {
43
- "@khanacademy/kas": "^0.3.15",
44
- "@khanacademy/keypad-context": "^1.0.3",
45
- "@khanacademy/kmath": "^0.1.15",
46
- "@khanacademy/math-input": "^21.1.1",
47
- "@khanacademy/perseus-core": "1.5.2",
48
- "@khanacademy/perseus-linter": "^1.2.3",
49
- "@khanacademy/pure-markdown": "^0.3.10",
50
- "@khanacademy/simple-markdown": "^0.13.3",
43
+ "@khanacademy/kas": "^0.3.16",
44
+ "@khanacademy/keypad-context": "^1.0.4",
45
+ "@khanacademy/kmath": "^0.1.16",
46
+ "@khanacademy/math-input": "^21.1.3",
47
+ "@khanacademy/perseus-core": "1.5.3",
48
+ "@khanacademy/perseus-linter": "^1.2.4",
49
+ "@khanacademy/pure-markdown": "^0.3.11",
50
+ "@khanacademy/simple-markdown": "^0.13.4",
51
51
  "@types/classnames": "2.2.0",
52
52
  "@use-gesture/react": "^10.2.27",
53
53
  "mafs": "0.19.0",
@@ -78,6 +78,7 @@
78
78
  "aphrodite": "^1.2.5",
79
79
  "classnames": "1.1.4",
80
80
  "create-react-class": "15.6.3",
81
+ "csstype": "^3.1.3",
81
82
  "intersection-observer": "^0.12.0",
82
83
  "jquery": "^2.1.1",
83
84
  "lodash.debounce": "^4.0.8",
@@ -1,7 +0,0 @@
1
- export declare const devices: {
2
- readonly PHONE: "phone";
3
- readonly TABLET: "tablet";
4
- readonly DESKTOP: "desktop";
5
- };
6
- export declare const lintGutterWidth = 36;
7
- export declare const perseusFrameBorderWidth = 1;