@khanacademy/perseus 6.5.1 → 6.6.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 +15 -0
- package/dist/es/index.js +1 -12
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -13
- package/dist/index.js.flow +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction-tracker.d.ts +3 -3
- package/dist/interaction-tracker.js.flow +3 -3
- package/dist/perseus-api.d.ts +1 -1
- package/dist/perseus-api.js.flow +6 -3
- package/dist/types.d.ts +1 -1
- package/dist/types.js.flow +6 -3
- package/dist/widgets/sequence.d.ts +16 -51
- package/dist/widgets/sequence.js.flow +16 -63
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/interaction-tracker.ts +3 -3
- package/src/types.ts +18 -10
- package/src/widgets/sequence.tsx +21 -24
- package/tsconfig-build.tsbuildinfo +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { APIOptions } from "./types";
|
|
1
|
+
import type { APIOptions, Tracking } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Wrapper for the trackInteraction apiOption.
|
|
4
4
|
*/
|
|
5
5
|
declare class InteractionTracker {
|
|
6
6
|
_tracked: boolean;
|
|
7
|
-
setting:
|
|
7
|
+
setting: Tracking;
|
|
8
8
|
track: (extraData?: any) => void;
|
|
9
9
|
trackApi: any;
|
|
10
10
|
widgetID: string;
|
|
11
11
|
widgetType: string;
|
|
12
|
-
constructor(trackApi: APIOptions["trackInteraction"], widgetType: string, widgetID: string, setting:
|
|
12
|
+
constructor(trackApi: APIOptions["trackInteraction"], widgetType: string, widgetID: string, setting: Tracking);
|
|
13
13
|
/**
|
|
14
14
|
* Function that actually calls the API to mark the interaction. This is
|
|
15
15
|
* private. The public version is just `.track` and is bound to this object
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import type { APIOptions } from "./types";
|
|
7
|
+
import type { APIOptions, Tracking } from "./types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Wrapper for the trackInteraction apiOption.
|
|
11
11
|
*/
|
|
12
12
|
declare class InteractionTracker {
|
|
13
13
|
_tracked: boolean;
|
|
14
|
-
setting:
|
|
14
|
+
setting: Tracking;
|
|
15
15
|
track: (extraData?: any) => void;
|
|
16
16
|
trackApi: any;
|
|
17
17
|
widgetID: string;
|
|
@@ -20,7 +20,7 @@ declare class InteractionTracker {
|
|
|
20
20
|
trackApi: $PropertyType<APIOptions, "trackInteraction">,
|
|
21
21
|
widgetType: string,
|
|
22
22
|
widgetID: string,
|
|
23
|
-
setting:
|
|
23
|
+
setting: Tracking
|
|
24
24
|
): this;
|
|
25
25
|
|
|
26
26
|
/**
|
package/dist/perseus-api.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare const ApiOptions: {
|
|
|
82
82
|
type: string;
|
|
83
83
|
id: string;
|
|
84
84
|
correct?: boolean | undefined;
|
|
85
|
-
}) => void) | undefined;
|
|
85
|
+
} & Record<string, unknown>) => void) | undefined;
|
|
86
86
|
customKeypad?: boolean | undefined;
|
|
87
87
|
nativeKeypadProxy?: (() => unknown) | undefined;
|
|
88
88
|
isMobile?: boolean | undefined;
|
package/dist/perseus-api.js.flow
CHANGED
|
@@ -80,9 +80,12 @@ declare export var ApiOptions: {|
|
|
|
80
80
|
| void,
|
|
81
81
|
trackInteraction?:
|
|
82
82
|
| ((args: {|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
...{|
|
|
84
|
+
type: string,
|
|
85
|
+
id: string,
|
|
86
|
+
correct?: boolean | void,
|
|
87
|
+
|},
|
|
88
|
+
...{ [key: string]: mixed },
|
|
86
89
|
|}) => void)
|
|
87
90
|
| void,
|
|
88
91
|
customKeypad?: boolean | void,
|
package/dist/types.d.ts
CHANGED
package/dist/types.js.flow
CHANGED
|
@@ -133,9 +133,12 @@ export type APIOptions = $ReadOnly<{|
|
|
|
133
133
|
|},
|
|
134
134
|
imagePreloader?: (dimensions: Dimensions) => React.Node,
|
|
135
135
|
trackInteraction?: (args: {|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
...{|
|
|
137
|
+
type: string,
|
|
138
|
+
id: string,
|
|
139
|
+
correct?: boolean,
|
|
140
|
+
|},
|
|
141
|
+
...{ [key: string]: mixed },
|
|
139
142
|
|}) => void,
|
|
140
143
|
customKeypad?: boolean,
|
|
141
144
|
nativeKeypadProxy?: () => mixed,
|
|
@@ -1,56 +1,21 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Link: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
-
}>>;
|
|
21
|
-
imagePreloader: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
trackInteraction: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
customKeypad: PropTypes.Requireable<boolean>;
|
|
24
|
-
nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
isMobile: PropTypes.Requireable<boolean>;
|
|
26
|
-
setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
useDraftEditor: PropTypes.Requireable<boolean>;
|
|
28
|
-
hintProgressColor: PropTypes.Requireable<string>;
|
|
29
|
-
canScrollPage: PropTypes.Requireable<boolean>;
|
|
30
|
-
inModal: PropTypes.Requireable<boolean>;
|
|
31
|
-
crossOutEnabled: PropTypes.Requireable<boolean>;
|
|
32
|
-
editorChangeDelay: PropTypes.Requireable<number>;
|
|
33
|
-
}>>>;
|
|
34
|
-
json: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
35
|
-
content: PropTypes.Requireable<string>;
|
|
36
|
-
images: PropTypes.Requireable<{
|
|
37
|
-
[x: string]: any;
|
|
38
|
-
}>;
|
|
39
|
-
widgets: PropTypes.Requireable<{
|
|
40
|
-
[x: string]: any;
|
|
41
|
-
}>;
|
|
42
|
-
}> | null | undefined)[]>;
|
|
43
|
-
trackInteraction: PropTypes.Validator<(...args: any[]) => any>;
|
|
44
|
-
linterContext: PropTypes.Requireable<PropTypes.InferProps<{
|
|
45
|
-
contentType: PropTypes.Requireable<string>;
|
|
46
|
-
highlightLint: PropTypes.Requireable<boolean>;
|
|
47
|
-
paths: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
48
|
-
stack: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
49
|
-
}>>;
|
|
50
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
2
|
+
import { PerseusSequenceWidgetOptions } from "../perseus-types";
|
|
3
|
+
import type { WidgetProps } from "../types";
|
|
4
|
+
type Rubric = PerseusSequenceWidgetOptions;
|
|
5
|
+
type ExternalProps = WidgetProps<PerseusSequenceWidgetOptions, Rubric>;
|
|
6
|
+
type Props = ExternalProps;
|
|
7
|
+
type DefaultProps = {
|
|
8
|
+
json: Props["json"];
|
|
9
|
+
linterContext: Props["linterContext"];
|
|
10
|
+
};
|
|
11
|
+
type State = {
|
|
12
|
+
visible: number;
|
|
13
|
+
};
|
|
14
|
+
declare class Sequence extends React.Component<Props, State> {
|
|
15
|
+
static defaultProps: DefaultProps;
|
|
16
|
+
state: {
|
|
17
|
+
visible: number;
|
|
51
18
|
};
|
|
52
|
-
static defaultProps: any;
|
|
53
|
-
state: any;
|
|
54
19
|
shouldComponentUpdate(nextProps: any, nextState: any): boolean;
|
|
55
20
|
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
56
21
|
_handleInteraction: (arg1: string) => void;
|
|
@@ -5,71 +5,24 @@
|
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
import * as $Flowgen$Import$_2e__2e__2f_types from "../types";
|
|
8
|
-
import PropTypes from "prop-types";
|
|
9
8
|
import * as React from "react";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
widgetPlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>,
|
|
27
|
-
baseElements: PropTypes.Requireable<
|
|
28
|
-
PropTypes.InferProps<{|
|
|
29
|
-
Link: PropTypes.Requireable<(...args: any[]) => any>,
|
|
30
|
-
|}>
|
|
31
|
-
>,
|
|
32
|
-
imagePreloader: PropTypes.Requireable<(...args: any[]) => any>,
|
|
33
|
-
trackInteraction: PropTypes.Requireable<(...args: any[]) => any>,
|
|
34
|
-
customKeypad: PropTypes.Requireable<boolean>,
|
|
35
|
-
nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>,
|
|
36
|
-
isMobile: PropTypes.Requireable<boolean>,
|
|
37
|
-
setDrawingAreaAvailable: PropTypes.Requireable<
|
|
38
|
-
(...args: any[]) => any
|
|
39
|
-
>,
|
|
40
|
-
useDraftEditor: PropTypes.Requireable<boolean>,
|
|
41
|
-
hintProgressColor: PropTypes.Requireable<string>,
|
|
42
|
-
canScrollPage: PropTypes.Requireable<boolean>,
|
|
43
|
-
inModal: PropTypes.Requireable<boolean>,
|
|
44
|
-
crossOutEnabled: PropTypes.Requireable<boolean>,
|
|
45
|
-
editorChangeDelay: PropTypes.Requireable<number>,
|
|
46
|
-
|}>
|
|
47
|
-
>
|
|
48
|
-
>,
|
|
49
|
-
json: PropTypes.Requireable<
|
|
50
|
-
(PropTypes.InferProps<{|
|
|
51
|
-
content: PropTypes.Requireable<string>,
|
|
52
|
-
images: PropTypes.Requireable<{
|
|
53
|
-
[x: string]: any,
|
|
54
|
-
}>,
|
|
55
|
-
widgets: PropTypes.Requireable<{
|
|
56
|
-
[x: string]: any,
|
|
57
|
-
}>,
|
|
58
|
-
|}> | null | void)[]
|
|
59
|
-
>,
|
|
60
|
-
trackInteraction: PropTypes.Validator<(...args: any[]) => any>,
|
|
61
|
-
linterContext: PropTypes.Requireable<
|
|
62
|
-
PropTypes.InferProps<{|
|
|
63
|
-
contentType: PropTypes.Requireable<string>,
|
|
64
|
-
highlightLint: PropTypes.Requireable<boolean>,
|
|
65
|
-
paths: PropTypes.Requireable<(string | null | void)[]>,
|
|
66
|
-
stack: PropTypes.Requireable<(string | null | void)[]>,
|
|
67
|
-
|}>
|
|
68
|
-
>,
|
|
69
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>,
|
|
9
|
+
import { PerseusSequenceWidgetOptions } from "../perseus-types";
|
|
10
|
+
import type { WidgetProps } from "../types";
|
|
11
|
+
declare type Rubric = PerseusSequenceWidgetOptions;
|
|
12
|
+
declare type ExternalProps = WidgetProps<PerseusSequenceWidgetOptions, Rubric>;
|
|
13
|
+
declare type Props = ExternalProps;
|
|
14
|
+
declare type DefaultProps = {|
|
|
15
|
+
json: $PropertyType<Props, "json">,
|
|
16
|
+
linterContext: $PropertyType<Props, "linterContext">,
|
|
17
|
+
|};
|
|
18
|
+
declare type State = {|
|
|
19
|
+
visible: number,
|
|
20
|
+
|};
|
|
21
|
+
declare class Sequence extends React.Component<Props, State> {
|
|
22
|
+
static defaultProps: DefaultProps;
|
|
23
|
+
state: {|
|
|
24
|
+
visible: number,
|
|
70
25
|
|};
|
|
71
|
-
static defaultProps: any;
|
|
72
|
-
state: any;
|
|
73
26
|
shouldComponentUpdate(nextProps: any, nextState: any): boolean;
|
|
74
27
|
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
75
28
|
_handleInteraction: (arg1: string) => void;
|
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": "6.
|
|
6
|
+
"version": "6.6.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kas": "^0.3.1",
|
|
25
25
|
"@khanacademy/kmath": "^0.1.1",
|
|
26
|
-
"@khanacademy/math-input": "^
|
|
26
|
+
"@khanacademy/math-input": "^7.0.0",
|
|
27
27
|
"@khanacademy/perseus-core": "0.0.2",
|
|
28
28
|
"@khanacademy/perseus-linter": "^0.3.1",
|
|
29
29
|
"@khanacademy/pure-markdown": "^0.2.3",
|
package/src/index.ts
CHANGED
|
@@ -128,6 +128,7 @@ export type {
|
|
|
128
128
|
PerseusImageBackground,
|
|
129
129
|
PerseusInteractiveGraphWidgetOptions,
|
|
130
130
|
PerseusRadioWidgetOptions,
|
|
131
|
+
PerseusExpressionWidgetOptions,
|
|
131
132
|
PerseusRenderer,
|
|
132
133
|
} from "./perseus-types";
|
|
133
134
|
export type {Coord} from "./interactive2/types";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {APIOptions} from "./types";
|
|
1
|
+
import type {APIOptions, Tracking} from "./types";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This alternate version of `.track` does nothing as an optimization.
|
|
@@ -12,7 +12,7 @@ class InteractionTracker {
|
|
|
12
12
|
// @ts-expect-error [FEI-5003] - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
|
|
13
13
|
_tracked: boolean;
|
|
14
14
|
// @ts-expect-error [FEI-5003] - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
|
|
15
|
-
setting:
|
|
15
|
+
setting: Tracking;
|
|
16
16
|
track: (extraData?: any) => void;
|
|
17
17
|
trackApi: any;
|
|
18
18
|
// @ts-expect-error [FEI-5003] - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
|
|
@@ -24,7 +24,7 @@ class InteractionTracker {
|
|
|
24
24
|
trackApi: APIOptions["trackInteraction"],
|
|
25
25
|
widgetType: string,
|
|
26
26
|
widgetID: string,
|
|
27
|
-
setting:
|
|
27
|
+
setting: Tracking,
|
|
28
28
|
) {
|
|
29
29
|
if (!trackApi) {
|
|
30
30
|
this.track = _noop;
|
package/src/types.ts
CHANGED
|
@@ -179,15 +179,18 @@ export type APIOptions = Readonly<{
|
|
|
179
179
|
// Function that takes dimensions and returns a React component
|
|
180
180
|
// to display while an image is loading
|
|
181
181
|
imagePreloader?: (dimensions: Dimensions) => React.ReactNode;
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
// A function that is called when the user has interacted with a widget. It
|
|
183
|
+
// also includes any extra parameters that the originating widget provided.
|
|
184
|
+
// This is used for keeping track of widget interactions.
|
|
185
|
+
trackInteraction?: (
|
|
186
|
+
args: {
|
|
187
|
+
// The widget type that this interaction originates from
|
|
188
|
+
type: string;
|
|
189
|
+
// The widget id that this interaction originates from
|
|
190
|
+
id: string;
|
|
191
|
+
correct?: boolean;
|
|
192
|
+
} & Record<string, unknown>,
|
|
193
|
+
) => void;
|
|
191
194
|
// A boolean that indicates whether or not a custom keypad is
|
|
192
195
|
// being used. For mobile web this will be the ProvidedKeypad
|
|
193
196
|
// component. In this situation we use the MathInput component
|
|
@@ -375,7 +378,12 @@ export type LinterContextProps = {
|
|
|
375
378
|
// additional properties can be added to the context by widgets
|
|
376
379
|
};
|
|
377
380
|
|
|
378
|
-
export type Tracking =
|
|
381
|
+
export type Tracking =
|
|
382
|
+
// Track interactions once
|
|
383
|
+
| ""
|
|
384
|
+
// Track all interactions
|
|
385
|
+
| "all";
|
|
386
|
+
|
|
379
387
|
export type Alignment =
|
|
380
388
|
| "default"
|
|
381
389
|
| "block"
|
package/src/widgets/sequence.tsx
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
linterContextProps,
|
|
3
|
-
linterContextDefault,
|
|
4
|
-
} from "@khanacademy/perseus-linter";
|
|
5
|
-
import PropTypes from "prop-types";
|
|
1
|
+
import {linterContextDefault} from "@khanacademy/perseus-linter";
|
|
6
2
|
import * as React from "react";
|
|
7
3
|
import _ from "underscore";
|
|
8
4
|
|
|
9
5
|
import InlineIcon from "../components/inline-icon";
|
|
10
6
|
import {iconOk} from "../icon-paths";
|
|
11
7
|
import * as Changeable from "../mixins/changeable";
|
|
12
|
-
import {
|
|
8
|
+
import {PerseusSequenceWidgetOptions} from "../perseus-types";
|
|
13
9
|
import Renderer from "../renderer";
|
|
14
10
|
import Util from "../util";
|
|
15
11
|
|
|
16
|
-
import type {WidgetExports} from "../types";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
import type {WidgetExports, WidgetProps} from "../types";
|
|
13
|
+
|
|
14
|
+
type Rubric = PerseusSequenceWidgetOptions;
|
|
15
|
+
|
|
16
|
+
type ExternalProps = WidgetProps<PerseusSequenceWidgetOptions, Rubric>;
|
|
17
|
+
|
|
18
|
+
type Props = ExternalProps;
|
|
19
|
+
|
|
20
|
+
type DefaultProps = {
|
|
21
|
+
json: Props["json"];
|
|
22
|
+
linterContext: Props["linterContext"];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type State = {
|
|
26
|
+
visible: number;
|
|
27
|
+
};
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
class Sequence extends React.Component<Props, State> {
|
|
30
|
+
static defaultProps: DefaultProps = {
|
|
34
31
|
json: [
|
|
35
32
|
{
|
|
36
33
|
content: "",
|
|
@@ -41,7 +38,7 @@ class Sequence extends React.Component<any, any> {
|
|
|
41
38
|
linterContext: linterContextDefault,
|
|
42
39
|
};
|
|
43
40
|
|
|
44
|
-
state
|
|
41
|
+
state = {
|
|
45
42
|
visible: 1,
|
|
46
43
|
};
|
|
47
44
|
|