@khanacademy/perseus 85.1.3 → 86.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.
@@ -4,8 +4,6 @@ declare const Interactive2: {
4
4
  readonly addMovablePoint: (graphie: any, options: any) => any;
5
5
  readonly MovableLine: (graphie: any, movable: any, options: any) => void;
6
6
  readonly addMovableLine: (graphie: any, options: any) => any;
7
- readonly MovablePolygon: (graphie: any, movable: any, options: any) => void;
8
- readonly addMovablePolygon: (graphie: any, options: any) => any;
9
7
  readonly addMovablePointV2: (widget: any, extraProps: any) => any;
10
8
  };
11
9
  export default Interactive2;
@@ -105,6 +105,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<Pick<SharedRenderer
105
105
  isArticle?: boolean;
106
106
  onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
107
107
  showAlignmentOptions?: boolean;
108
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
108
109
  readOnly?: boolean;
109
110
  editingDisabled?: boolean;
110
111
  answerableCallback?: (arg1: boolean) => unknown;
@@ -128,7 +129,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<Pick<SharedRenderer
128
129
  isMobile?: boolean;
129
130
  isMobileApp?: boolean;
130
131
  hintProgressColor?: string;
131
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
132
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
132
133
  }> | undefined;
133
134
  linterContext?: PerseusLinter.LinterContextProps | undefined;
134
135
  onRendered?: ((isRendered: boolean) => void) | undefined;
@@ -9,8 +9,9 @@ type Props = {
9
9
  * `json`, but it is the article. Trust me.
10
10
  */
11
11
  json: PerseusArticle;
12
+ seed?: number;
12
13
  apiOptions?: APIOptions;
13
14
  linterContext?: LinterContextProps;
14
15
  };
15
- export declare const ArticleRendererWithDebugUI: ({ title, json, apiOptions, linterContext, }: Props) => React.ReactElement;
16
+ export declare const ArticleRendererWithDebugUI: ({ title, json, seed, apiOptions, linterContext, }: Props) => React.ReactElement;
16
17
  export {};
@@ -7,6 +7,8 @@ declare const DEFAULT_FEATURE_FLAGS: Record<"perseus-test-flag-1" | "perseus-tes
7
7
  export declare function getFeatureFlags(overrides?: Partial<typeof DEFAULT_FEATURE_FLAGS>): {
8
8
  "perseus-renderer-upgrade": boolean;
9
9
  "desmos-calculator": boolean;
10
+ "article-extras": boolean;
11
+ "dnd-widget-fitb": boolean;
10
12
  "perseus-test-flag-1": boolean;
11
13
  "perseus-test-flag-2": boolean;
12
14
  };
@@ -16,6 +16,7 @@ export declare const useItemRenderer: (item: PerseusItem, apiOptions?: APIOption
16
16
  isArticle?: boolean;
17
17
  onFocusChange?: (newFocusPath: import("..").FocusPath, oldFocusPath: import("..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
18
18
  showAlignmentOptions?: boolean;
19
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
19
20
  readOnly?: boolean;
20
21
  editingDisabled?: boolean;
21
22
  answerableCallback?: (arg1: boolean) => unknown;
@@ -34,7 +35,7 @@ export declare const useItemRenderer: (item: PerseusItem, apiOptions?: APIOption
34
35
  }>) => void;
35
36
  isMobileApp?: boolean;
36
37
  hintProgressColor?: string;
37
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
38
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
38
39
  };
39
40
  toggleMobile: (isMobile: boolean) => void;
40
41
  toggleRtl: (isRtl: boolean) => void;
package/dist/types.d.ts CHANGED
@@ -104,6 +104,7 @@ export type APIOptions = Readonly<{
104
104
  isArticle?: boolean;
105
105
  onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
106
106
  showAlignmentOptions?: boolean;
107
+ renderExtras?: (answerArea: PerseusAnswerArea, widgetId: string) => React.ReactNode;
107
108
  /**
108
109
  * A boolean that indicates whether the associated problem has been
109
110
  * answered correctly and should no longer be interactive.
@@ -1,6 +1,17 @@
1
+ /**
2
+ * Color constants we use throughout Perseus (originally on KhanUtil).
3
+ *
4
+ * DEPRECATED: This palette is retained only for the interaction editor's
5
+ * color swatches and the measurer widget's graphie rendering. Do not add
6
+ * new uses — use Wonder Blocks semanticColor tokens instead.
7
+ *
8
+ * Note that if the color palette changes substantially, it may also need to be
9
+ * updated in khan-exercises and cherry-picked into graphie-to-png's
10
+ * khan-exercises submodule, as graphie-to-png still relies on the palette
11
+ * provided on KhanUtil.
12
+ */
1
13
  declare const KhanColors: {
2
14
  readonly BLUE: string;
3
- readonly ORANGE: "#FFA500";
4
15
  readonly PINK: "#FF00AF";
5
16
  readonly GREEN: string;
6
17
  readonly PURPLE: "#9D38BD";
@@ -13,67 +24,8 @@ declare const KhanColors: {
13
24
  readonly LIGHT_GREEN: "#9BEDCE";
14
25
  readonly LIGHT_PURPLE: "#DA9BED";
15
26
  readonly LIGHT_RED: "#ED9AAC";
16
- readonly LIGHT_GRAY: "#ED9B9B";
17
- readonly LIGHT_BLACK: "#ED9B9B";
18
- readonly GRAY10: "#D6D6D6";
19
- readonly GRAY20: "#CDCDCD";
20
- readonly GRAY30: "#B3B3B3";
21
- readonly GRAY40: "#9A9A9A";
22
- readonly GRAY50: "#808080";
23
- readonly GRAY60: "#666666";
24
- readonly GRAY70: "#4D4D4D";
25
- readonly GRAY80: "#333333";
26
- readonly GRAY90: "#1A1A1A";
27
- readonly BLUE_A: "#CCFAFF";
28
- readonly BLUE_B: "#80F6FF";
29
- readonly BLUE_C: "#63D9EA";
30
- readonly BLUE_D: "#11ACCD";
31
- readonly BLUE_E: "#0C7F99";
32
- readonly TEAL_A: "#94FFF5";
33
- readonly TEAL_B: "#26EDD5";
34
- readonly TEAL_C: "#01D1C1";
35
- readonly TEAL_D: "#01A995";
36
- readonly TEAL_E: "#208170";
37
- readonly GREEN_A: "#B6FFB0";
38
- readonly GREEN_B: "#8AF281";
39
- readonly GREEN_C: "#74CF70";
40
- readonly GREEN_D: "#1FAB54";
41
- readonly GREEN_E: "#0D923F";
42
- readonly GOLD_A: "#FFD0A9";
43
- readonly GOLD_B: "#FFBB71";
44
- readonly GOLD_C: "#FF9C39";
45
- readonly GOLD_D: "#E07D10";
46
- readonly GOLD_E: "#A75A05";
47
- readonly RED_A: "#FCA9A9";
48
- readonly RED_B: "#FF8482";
49
- readonly RED_C: "#F9685D";
50
- readonly RED_D: "#E84D39";
51
- readonly RED_E: "#BC2612";
52
- readonly MAROON_A: "#FFBDE0";
53
- readonly MAROON_B: "#FF92C6";
54
- readonly MAROON_C: "#ED5FA6";
55
- readonly MAROON_D: "#CA337C";
56
- readonly MAROON_E: "#9E034E";
57
- readonly PURPLE_A: "#DDD7FF";
58
- readonly PURPLE_B: "#C6B9FC";
59
- readonly PURPLE_C: "#AA87FF";
60
- readonly PURPLE_D: "#7854AB";
61
- readonly PURPLE_E: "#543B78";
62
- readonly MINT_A: "#F5F9E8";
63
- readonly MINT_B: "#EDF2DF";
64
- readonly MINT_C: "#E0E5CC";
65
- readonly GRAY_A: "#F6F7F7";
66
- readonly GRAY_B: "#F0F1F2";
67
27
  readonly GRAY_C: "#E3E5E6";
68
- readonly GRAY_D: "#D6D8DA";
69
- readonly GRAY_E: "#BABEC2";
70
- readonly GRAY_F: "#888D93";
71
28
  readonly GRAY_G: "#626569";
72
- readonly GRAY_H: "#3B3E40";
73
- readonly GRAY_I: "#21242C";
74
- readonly KA_BLUE: "#314453";
75
- readonly KA_GREEN: "#71B307";
76
- readonly _BACKGROUND: "#FDFDFD";
77
29
  readonly INTERACTING: string;
78
30
  readonly INTERACTIVE: string;
79
31
  readonly DYNAMIC: string;
@@ -87,4 +39,24 @@ declare const KhanColors: {
87
39
  * @returns a string representing the background color, or a CSS variable for the default background color.
88
40
  */
89
41
  export declare const getBackgroundColor: (elementToInspect: HTMLElement) => string;
42
+ interface RGB {
43
+ r: number;
44
+ g: number;
45
+ b: number;
46
+ }
47
+ /**
48
+ * Resolves a CSS color into its red, green, and blue components.
49
+ * @param color - can be hex, a name like `"black"`, or e.g. `rgb(0, 0, 0)`.
50
+ */
51
+ export declare function resolveColor(color: string): RGB;
52
+ export declare function toClosestMathColor(target: string): string;
53
+ export declare function parseHexColor(hex: string): RGB;
54
+ /**
55
+ * Uses a variant of the "redmean" algorithm to determine how similar two
56
+ * colors are. In contrast to redmean, we skip taking the square root of the
57
+ * result, which means this function gives you a relative difference, not an
58
+ * absolute difference.
59
+ * See: https://en.wikipedia.org/wiki/Color_difference
60
+ */
61
+ export declare function diffColors(a: RGB, b: RGB): number;
90
62
  export default KhanColors;
@@ -2,7 +2,6 @@ import type { MouseHandler } from "./interactive";
2
2
  import type { Interval } from "./interval";
3
3
  import type { Coord } from "../interactive2/types";
4
4
  import type { GraphieLabelElement } from "../types";
5
- export declare function polar(r: number | Coord, th: number): Coord;
6
5
  interface RaphaelElement {
7
6
  type: string;
8
7
  attrs: Record<string, any>;
@@ -29,7 +29,6 @@ export declare class GradedGroup extends React.Component<Props, State> implement
29
29
  rendererRef: React.RefObject<Renderer>;
30
30
  hintRendererRef: React.RefObject<Renderer>;
31
31
  componentDidMount(): void;
32
- shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
33
32
  _handleUserInput(_userInput: UserInputMap, widgetsEmpty: boolean): void;
34
33
  _checkAnswer: () => void;
35
34
  getInputPaths: () => ReadonlyArray<FocusPath>;
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  isArticle?: boolean;
22
22
  onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
23
23
  showAlignmentOptions?: boolean;
24
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
24
25
  readOnly?: boolean;
25
26
  editingDisabled?: boolean;
26
27
  answerableCallback?: (arg1: boolean) => unknown;
@@ -44,7 +45,7 @@ declare const _default: {
44
45
  isMobile?: boolean;
45
46
  isMobileApp?: boolean;
46
47
  hintProgressColor?: string;
47
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
48
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
48
49
  }> & {
49
50
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
50
51
  isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
@@ -30,6 +30,7 @@ declare class InteractiveGraph extends React.Component<Props> {
30
30
  isArticle?: boolean;
31
31
  onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
32
32
  showAlignmentOptions?: boolean;
33
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
33
34
  readOnly?: boolean;
34
35
  editingDisabled?: boolean;
35
36
  answerableCallback?: (arg1: boolean) => unknown;
@@ -53,7 +54,7 @@ declare class InteractiveGraph extends React.Component<Props> {
53
54
  isMobile?: boolean;
54
55
  isMobileApp?: boolean;
55
56
  hintProgressColor?: string;
56
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
57
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
57
58
  }> & {
58
59
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
59
60
  isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
@@ -42,6 +42,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
42
42
  isArticle?: boolean;
43
43
  onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
44
44
  showAlignmentOptions?: boolean;
45
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
45
46
  readOnly?: boolean;
46
47
  editingDisabled?: boolean;
47
48
  answerableCallback?: (arg1: boolean) => unknown;
@@ -65,7 +66,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
65
66
  isMobile?: boolean;
66
67
  isMobileApp?: boolean;
67
68
  hintProgressColor?: string;
68
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
69
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
69
70
  }> & {
70
71
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
71
72
  isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  isArticle?: boolean;
22
22
  onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
23
23
  showAlignmentOptions?: boolean;
24
+ renderExtras?: (answerArea: import("@khanacademy/perseus-core").PerseusAnswerArea, widgetId: string) => React.ReactNode;
24
25
  readOnly?: boolean;
25
26
  editingDisabled?: boolean;
26
27
  answerableCallback?: (arg1: boolean) => unknown;
@@ -44,7 +45,7 @@ declare const _default: {
44
45
  isMobile?: boolean;
45
46
  isMobileApp?: boolean;
46
47
  hintProgressColor?: string;
47
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
48
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
48
49
  }> & {
49
50
  baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
50
51
  isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
package/dist/widgets.d.ts CHANGED
@@ -13,7 +13,13 @@ export declare const registerWidgets: (widgetArr: ReadonlyArray<WidgetExports>)
13
13
  */
14
14
  export declare const replaceWidget: (type: string, replacementType: string) => void;
15
15
  export declare const replaceDeprecatedWidgets: () => void;
16
- export declare const registerEditors: (editorsToRegister: ReadonlyArray<Editor>) => void;
16
+ /**
17
+ * Register widget editors, keyed by the type of widget each one edits.
18
+ *
19
+ * The keys are widget types as they appear in Perseus content (eg. `radio`),
20
+ * which is what `getEditor` looks up when the editor page renders a widget.
21
+ */
22
+ export declare const registerEditors: (editorsToRegister: Record<string, Editor>) => void;
17
23
  /**
18
24
  *
19
25
  * @param type - the widget that you are trying to replace
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": "85.1.3",
6
+ "version": "86.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -45,12 +45,12 @@
45
45
  "uuid": "^10.0.0",
46
46
  "jquery": "^2.1.1",
47
47
  "@khanacademy/kas": "2.2.6",
48
- "@khanacademy/keypad-context": "3.2.87",
49
- "@khanacademy/kmath": "2.4.46",
50
- "@khanacademy/perseus-core": "38.0.1",
51
- "@khanacademy/perseus-linter": "5.2.0",
52
- "@khanacademy/perseus-score": "8.12.19",
53
- "@khanacademy/math-input": "27.0.9",
48
+ "@khanacademy/keypad-context": "3.2.89",
49
+ "@khanacademy/kmath": "2.4.48",
50
+ "@khanacademy/math-input": "27.0.11",
51
+ "@khanacademy/perseus-core": "38.1.1",
52
+ "@khanacademy/perseus-linter": "5.2.2",
53
+ "@khanacademy/perseus-score": "8.12.21",
54
54
  "@khanacademy/perseus-utils": "2.1.5",
55
55
  "@khanacademy/pure-markdown": "2.3.2",
56
56
  "@khanacademy/simple-markdown": "3.0.1"
@@ -62,7 +62,7 @@
62
62
  "@khanacademy/wonder-blocks-clickable": "8.2.9",
63
63
  "@khanacademy/wonder-blocks-core": "12.4.4",
64
64
  "@khanacademy/wonder-blocks-data": "15.0.3",
65
- "@khanacademy/wonder-blocks-dropdown": "10.11.8",
65
+ "@khanacademy/wonder-blocks-dropdown": "10.12.0",
66
66
  "@khanacademy/wonder-blocks-form": "7.6.10",
67
67
  "@khanacademy/wonder-blocks-icon": "5.3.23",
68
68
  "@khanacademy/wonder-blocks-icon-button": "11.4.5",
@@ -98,7 +98,7 @@
98
98
  "@khanacademy/wonder-blocks-clickable": "^8.2.9",
99
99
  "@khanacademy/wonder-blocks-core": "^12.4.4",
100
100
  "@khanacademy/wonder-blocks-data": "^15.0.3",
101
- "@khanacademy/wonder-blocks-dropdown": "^10.11.8",
101
+ "@khanacademy/wonder-blocks-dropdown": "^10.12.0",
102
102
  "@khanacademy/wonder-blocks-form": "^7.6.10",
103
103
  "@khanacademy/wonder-blocks-icon": "^5.3.23",
104
104
  "@khanacademy/wonder-blocks-icon-button": "^11.4.5",
@@ -127,7 +127,7 @@
127
127
  },
128
128
  "keywords": [],
129
129
  "khan": {
130
- "catalogHash": "bcf5b2d4681b77c1"
130
+ "catalogHash": "08e8d9a41dfc2cab"
131
131
  },
132
132
  "scripts": {}
133
133
  }
@@ -1,40 +0,0 @@
1
- /**
2
- * A library of options to pass to add/draw/remove/constraints
3
- */
4
- import type { Coord } from "./types";
5
- declare const _default: {
6
- add: {
7
- readonly constrain: () => void;
8
- readonly pointsToFront: (state: any) => void;
9
- };
10
- modify: {
11
- readonly draw: () => void;
12
- };
13
- draw: {
14
- readonly basic: (state: any, prevState: any) => void;
15
- readonly labels: (state: any, prevState: any) => void;
16
- readonly highlight: (state: any, prevState: any) => void;
17
- };
18
- remove: {
19
- readonly basic: () => void;
20
- readonly labels: () => void;
21
- };
22
- onMoveStart: {
23
- standard: null;
24
- };
25
- constraints: {
26
- readonly fixed: () => () => boolean;
27
- readonly snap: (snap: any) => (arg1: Coord) => unknown;
28
- readonly bound: (range: any, snap: any, paddingPx: number) => (arg1: Coord, arg2: Coord) => Coord;
29
- };
30
- onMove: {
31
- readonly updatePoints: (coord: Coord, prevCoord: Coord) => void;
32
- };
33
- onMoveEnd: {
34
- standard: null;
35
- };
36
- onClick: {
37
- standard: null;
38
- };
39
- };
40
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const MovablePolygon: (graphie: any, movable: any, options: any) => void;
2
- export default MovablePolygon;