@khanacademy/perseus 71.4.0 → 71.4.1
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/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/math-rendering-context.d.ts +2 -2
- package/dist/mixins/widget-prop-denylist.d.ts +0 -17
- package/dist/types.d.ts +1 -2
- package/dist/util.d.ts +1 -1
- package/dist/widgets/expression/expression.d.ts +66 -1
- package/dist/widgets/interactive-graphs/backgrounds/utils.d.ts +0 -5
- package/dist/widgets/label-image/label-image.d.ts +66 -1
- package/dist/widgets/numeric-input/numeric-input.d.ts +66 -1
- package/dist/widgets/numeric-input/utils.d.ts +0 -7
- package/dist/widgets/plotter/plotter.d.ts +1 -1
- package/dist/widgets/radio/multiple-choice-widget.new.d.ts +68 -2
- package/dist/widgets/radio/radio-component.d.ts +1 -1
- package/package.json +51 -52
- package/dist/components/visibility-observer/create-visibility-observer.d.ts +0 -34
- package/dist/components/visibility-observer/get-scroll-parent.d.ts +0 -1
- package/dist/components/visibility-observer/visibility-observer.d.ts +0 -31
- package/dist/widgets/radio/choice-icon/choice-icon-styles.d.ts +0 -9
- package/dist/widgets/radio/choice-icon/choice-icon.new.d.ts +0 -22
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview A React context for managing math rendering options.
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
|
|
5
|
+
type MathRenderingContextType = {
|
|
6
6
|
shouldAddAriaLabels: boolean;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
@@ -15,5 +15,5 @@ export type MathRenderingContextType = {
|
|
|
15
15
|
* addition of aria labels for times when the element is not within such
|
|
16
16
|
* containers.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
declare const MathRenderingContext: React.Context<MathRenderingContextType>;
|
|
19
19
|
export default MathRenderingContext;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* These are things that widgets should exclude when serializing themselves.
|
|
3
|
-
*
|
|
4
|
-
* The use of this list needs to die. Basically, there are codepaths that
|
|
5
|
-
* blindly serialize the "props" of a widget so that it can pass around its
|
|
6
|
-
* info. Unfortunately, props aren't guaranteed to be serializable, and
|
|
7
|
-
* automatically serializing schemaless list of attributes causes issues (e.g.
|
|
8
|
-
* circular JSON structures sometimes).
|
|
9
|
-
*
|
|
10
|
-
* This blocks things that we know don't need to be serialized.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated and likely a very broken API
|
|
14
|
-
* [LEMS-3185] do not trust serializedState
|
|
15
|
-
*/
|
|
16
|
-
declare const denylist: string[];
|
|
17
1
|
export declare function excludeDenylistKeys(obj: Record<any, any>): {};
|
|
18
|
-
export default denylist;
|
package/dist/types.d.ts
CHANGED
|
@@ -101,7 +101,6 @@ export type GenerateUrlArgs = {
|
|
|
101
101
|
url: string;
|
|
102
102
|
context: GenerateUrlContext;
|
|
103
103
|
};
|
|
104
|
-
export type GenerateUrlFn = (args: GenerateUrlArgs) => string;
|
|
105
104
|
/**
|
|
106
105
|
* APIOptions provides different ways to customize the behaviour of Perseus.
|
|
107
106
|
*
|
|
@@ -377,7 +376,7 @@ export type WidgetProps<TWidgetOptions, TUserInput = Empty, TrackingExtraArgs =
|
|
|
377
376
|
/**
|
|
378
377
|
* The props passed to every widget, regardless of its `type`.
|
|
379
378
|
*/
|
|
380
|
-
|
|
379
|
+
type UniversalWidgetProps<TUserInput = Empty, TrackingExtraArgs = Empty> = {
|
|
381
380
|
trackInteraction: (extraData?: TrackingExtraArgs) => void;
|
|
382
381
|
widgetId: string;
|
|
383
382
|
widgetIndex: number;
|
package/dist/util.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare function inputPathsEqual(a?: ReadonlyArray<string> | null, b?: ReadonlyA
|
|
|
41
41
|
*/
|
|
42
42
|
declare function firstNumericalParse(text: string): ParsedValue | null | undefined;
|
|
43
43
|
declare function stringArrayOfSize(size: number): string[];
|
|
44
|
-
|
|
44
|
+
declare function stringArrayOfSize2D(opt: {
|
|
45
45
|
rows: number;
|
|
46
46
|
columns: number;
|
|
47
47
|
}): string[][];
|
|
@@ -145,7 +145,72 @@ declare function getCorrectUserInput(options: PerseusExpressionWidgetOptions): P
|
|
|
145
145
|
declare const _default: {
|
|
146
146
|
name: string;
|
|
147
147
|
displayName: string;
|
|
148
|
-
widget: React.ForwardRefExoticComponent<Omit<Pick<PerseusExpressionWidgetOptions &
|
|
148
|
+
widget: React.ForwardRefExoticComponent<Omit<Pick<PerseusExpressionWidgetOptions & {
|
|
149
|
+
trackInteraction: (extraData?: Empty | undefined) => void;
|
|
150
|
+
widgetId: string;
|
|
151
|
+
widgetIndex: number;
|
|
152
|
+
alignment: string | null | undefined;
|
|
153
|
+
static: boolean | null | undefined;
|
|
154
|
+
problemNum: number | null | undefined;
|
|
155
|
+
apiOptions: Readonly<Readonly<{
|
|
156
|
+
isArticle?: boolean;
|
|
157
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
158
|
+
GroupMetadataEditor?: React.ComponentType<any>;
|
|
159
|
+
showAlignmentOptions?: boolean;
|
|
160
|
+
readOnly?: boolean;
|
|
161
|
+
answerableCallback?: (arg1: boolean) => unknown;
|
|
162
|
+
getAnotherHint?: () => unknown;
|
|
163
|
+
interactionCallback?: (widgetData: {
|
|
164
|
+
[widgetId: string]: any;
|
|
165
|
+
}) => void;
|
|
166
|
+
groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
|
|
167
|
+
imagePlaceholder?: React.ReactNode;
|
|
168
|
+
widgetPlaceholder?: React.ReactNode;
|
|
169
|
+
baseElements?: {
|
|
170
|
+
Link: React.ComponentType<any>;
|
|
171
|
+
};
|
|
172
|
+
imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
|
|
173
|
+
trackInteraction?: (args: {
|
|
174
|
+
type: string;
|
|
175
|
+
id: string;
|
|
176
|
+
correct?: boolean;
|
|
177
|
+
} & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
|
|
178
|
+
visible: number;
|
|
179
|
+
}>) => void;
|
|
180
|
+
customKeypad?: boolean;
|
|
181
|
+
nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
|
|
182
|
+
isMobile?: boolean;
|
|
183
|
+
isMobileApp?: boolean;
|
|
184
|
+
setDrawingAreaAvailable?: (arg1: boolean) => unknown;
|
|
185
|
+
hintProgressColor?: string;
|
|
186
|
+
canScrollPage?: boolean;
|
|
187
|
+
editorChangeDelay?: number;
|
|
188
|
+
flags?: Record<"new-radio-widget" | "image-widget-upgrade", boolean>;
|
|
189
|
+
}> & {
|
|
190
|
+
baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
|
|
191
|
+
canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
|
|
192
|
+
editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
|
|
193
|
+
groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
|
|
194
|
+
isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
|
|
195
|
+
isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
|
|
196
|
+
isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
|
|
197
|
+
onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
|
|
198
|
+
readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
|
|
199
|
+
setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
|
|
200
|
+
showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
|
|
201
|
+
}>;
|
|
202
|
+
keypadElement?: any;
|
|
203
|
+
questionCompleted?: boolean;
|
|
204
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
205
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
206
|
+
findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
|
|
207
|
+
reviewMode: boolean;
|
|
208
|
+
showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
|
|
209
|
+
handleUserInput: (newUserInput: string, cb?: () => void, silent?: boolean) => void;
|
|
210
|
+
userInput: string;
|
|
211
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
212
|
+
containerSizeClass: import("../../util/sizing-utils").SizeClass;
|
|
213
|
+
} & Partial<import("../..").PerseusDependenciesV2> & {
|
|
149
214
|
apiOptions: NonNullable<ExternalProps["apiOptions"]>;
|
|
150
215
|
buttonSets: NonNullable<ExternalProps["buttonSets"]>;
|
|
151
216
|
functions: NonNullable<ExternalProps["functions"]>;
|
|
@@ -9,11 +9,6 @@ export declare const getLabelTransform: (labelLocation: GraphConfig["labelLocati
|
|
|
9
9
|
xLabelTransform: string;
|
|
10
10
|
yLabelTransform: string;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Calculate the maximum number of digits needed to display tick labels on the y-axis.
|
|
14
|
-
* This accounts for both the integer part of the range values and decimal places in the tick step.
|
|
15
|
-
*/
|
|
16
|
-
export declare const calculateMaxDigitsInRange: (range: [number, number], tickStep: number) => number;
|
|
17
12
|
export declare const getLabelPosition: (graphInfo: GraphDimensions, labelLocation: GraphConfig["labelLocation"], tickStep: GraphConfig["tickStep"]) => vec.Vector2[];
|
|
18
13
|
export declare const shouldShowLabel: (currentTick: number, range: [Interval, Interval], tickStep: number) => boolean;
|
|
19
14
|
export declare function generateTickLocations(tickStep: number, min: number, max: number, otherAxisMin: number): number[];
|
|
@@ -111,7 +111,72 @@ declare const _default: {
|
|
|
111
111
|
displayName: string;
|
|
112
112
|
widget: React.ForwardRefExoticComponent<Omit<Omit<PerseusLabelImageWidgetOptions, "markers"> & {
|
|
113
113
|
markers: ReadonlyArray<OptionalAnswersMarkerType>;
|
|
114
|
-
} &
|
|
114
|
+
} & {
|
|
115
|
+
trackInteraction: (extraData?: Empty | undefined) => void;
|
|
116
|
+
widgetId: string;
|
|
117
|
+
widgetIndex: number;
|
|
118
|
+
alignment: string | null | undefined;
|
|
119
|
+
static: boolean | null | undefined;
|
|
120
|
+
problemNum: number | null | undefined;
|
|
121
|
+
apiOptions: Readonly<Readonly<{
|
|
122
|
+
isArticle?: boolean;
|
|
123
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
124
|
+
GroupMetadataEditor?: React.ComponentType<any>;
|
|
125
|
+
showAlignmentOptions?: boolean;
|
|
126
|
+
readOnly?: boolean;
|
|
127
|
+
answerableCallback?: (arg1: boolean) => unknown;
|
|
128
|
+
getAnotherHint?: () => unknown;
|
|
129
|
+
interactionCallback?: (widgetData: {
|
|
130
|
+
[widgetId: string]: any;
|
|
131
|
+
}) => void;
|
|
132
|
+
groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
|
|
133
|
+
imagePlaceholder?: React.ReactNode;
|
|
134
|
+
widgetPlaceholder?: React.ReactNode;
|
|
135
|
+
baseElements?: {
|
|
136
|
+
Link: React.ComponentType<any>;
|
|
137
|
+
};
|
|
138
|
+
imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
|
|
139
|
+
trackInteraction?: (args: {
|
|
140
|
+
type: string;
|
|
141
|
+
id: string;
|
|
142
|
+
correct?: boolean;
|
|
143
|
+
} & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
|
|
144
|
+
visible: number;
|
|
145
|
+
}>) => void;
|
|
146
|
+
customKeypad?: boolean;
|
|
147
|
+
nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
|
|
148
|
+
isMobile?: boolean;
|
|
149
|
+
isMobileApp?: boolean;
|
|
150
|
+
setDrawingAreaAvailable?: (arg1: boolean) => unknown;
|
|
151
|
+
hintProgressColor?: string;
|
|
152
|
+
canScrollPage?: boolean;
|
|
153
|
+
editorChangeDelay?: number;
|
|
154
|
+
flags?: Record<"new-radio-widget" | "image-widget-upgrade", boolean>;
|
|
155
|
+
}> & {
|
|
156
|
+
baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
|
|
157
|
+
canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
|
|
158
|
+
editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
|
|
159
|
+
groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
|
|
160
|
+
isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
|
|
161
|
+
isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
|
|
162
|
+
isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
|
|
163
|
+
onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
|
|
164
|
+
readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
|
|
165
|
+
setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
|
|
166
|
+
showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
|
|
167
|
+
}>;
|
|
168
|
+
keypadElement?: any;
|
|
169
|
+
questionCompleted?: boolean;
|
|
170
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
171
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
172
|
+
findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
|
|
173
|
+
reviewMode: boolean;
|
|
174
|
+
showSolutions?: ShowSolutions;
|
|
175
|
+
handleUserInput: (newUserInput: PerseusLabelImageUserInput, cb?: () => void, silent?: boolean) => void;
|
|
176
|
+
userInput: PerseusLabelImageUserInput;
|
|
177
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
178
|
+
containerSizeClass: import("../../util/sizing-utils").SizeClass;
|
|
179
|
+
} & {
|
|
115
180
|
analytics: DependencyProps["analytics"];
|
|
116
181
|
preferredPopoverDirection?: PreferredPopoverDirection;
|
|
117
182
|
}, keyof import("../..").PerseusDependenciesV2> & React.RefAttributes<LabelImage>>;
|
|
@@ -5,7 +5,72 @@ import type { Focusable } from "../../types";
|
|
|
5
5
|
* component. It is responsible for rendering the UI elements of the Numeric
|
|
6
6
|
* Input widget.
|
|
7
7
|
*/
|
|
8
|
-
export declare const NumericInputComponent: React.ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions &
|
|
8
|
+
export declare const NumericInputComponent: React.ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions & {
|
|
9
|
+
trackInteraction: (extraData?: Empty | undefined) => void;
|
|
10
|
+
widgetId: string;
|
|
11
|
+
widgetIndex: number;
|
|
12
|
+
alignment: string | null | undefined;
|
|
13
|
+
static: boolean | null | undefined;
|
|
14
|
+
problemNum: number | null | undefined;
|
|
15
|
+
apiOptions: Readonly<Readonly<{
|
|
16
|
+
isArticle?: boolean;
|
|
17
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
18
|
+
GroupMetadataEditor?: React.ComponentType<any>;
|
|
19
|
+
showAlignmentOptions?: boolean;
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
answerableCallback?: (arg1: boolean) => unknown;
|
|
22
|
+
getAnotherHint?: () => unknown;
|
|
23
|
+
interactionCallback?: (widgetData: {
|
|
24
|
+
[widgetId: string]: any;
|
|
25
|
+
}) => void;
|
|
26
|
+
groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
|
|
27
|
+
imagePlaceholder?: React.ReactNode;
|
|
28
|
+
widgetPlaceholder?: React.ReactNode;
|
|
29
|
+
baseElements?: {
|
|
30
|
+
Link: React.ComponentType<any>;
|
|
31
|
+
};
|
|
32
|
+
imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
|
|
33
|
+
trackInteraction?: (args: {
|
|
34
|
+
type: string;
|
|
35
|
+
id: string;
|
|
36
|
+
correct?: boolean;
|
|
37
|
+
} & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
|
|
38
|
+
visible: number;
|
|
39
|
+
}>) => void;
|
|
40
|
+
customKeypad?: boolean;
|
|
41
|
+
nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
|
|
42
|
+
isMobile?: boolean;
|
|
43
|
+
isMobileApp?: boolean;
|
|
44
|
+
setDrawingAreaAvailable?: (arg1: boolean) => unknown;
|
|
45
|
+
hintProgressColor?: string;
|
|
46
|
+
canScrollPage?: boolean;
|
|
47
|
+
editorChangeDelay?: number;
|
|
48
|
+
flags?: Record<"new-radio-widget" | "image-widget-upgrade", boolean>;
|
|
49
|
+
}> & {
|
|
50
|
+
baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
|
|
51
|
+
canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
|
|
52
|
+
editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
|
|
53
|
+
groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
|
|
54
|
+
isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
|
|
55
|
+
isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
|
|
56
|
+
isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
|
|
57
|
+
onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
|
|
58
|
+
readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
|
|
59
|
+
setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
|
|
60
|
+
showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
|
|
61
|
+
}>;
|
|
62
|
+
keypadElement?: any;
|
|
63
|
+
questionCompleted?: boolean;
|
|
64
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
65
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
66
|
+
findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<import("../../types").Widget>;
|
|
67
|
+
reviewMode: boolean;
|
|
68
|
+
showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
|
|
69
|
+
handleUserInput: (newUserInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
|
|
70
|
+
userInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput;
|
|
71
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
72
|
+
containerSizeClass: import("../../util/sizing-utils").SizeClass;
|
|
73
|
+
} & {
|
|
9
74
|
size: NonNullable<string>;
|
|
10
75
|
rightAlign: NonNullable<boolean | undefined>;
|
|
11
76
|
apiOptions: NonNullable<Readonly<Readonly<{
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { PerseusStrings } from "../../strings";
|
|
2
2
|
import type { PerseusNumericInputAnswerForm, PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
|
|
3
|
-
/**
|
|
4
|
-
* The full list of available strings for the numeric input widget,
|
|
5
|
-
* based on whether the Content Creator has specified that the answer must be simplified.
|
|
6
|
-
*/
|
|
7
|
-
export declare const NumericExampleStrings: {
|
|
8
|
-
[key: string]: (form: PerseusNumericInputAnswerForm, strings: PerseusStrings) => string;
|
|
9
|
-
};
|
|
10
3
|
/**
|
|
11
4
|
* Generates the specific set of examples for the current question.
|
|
12
5
|
* This string is shown as examples to the user in a tooltip.
|
|
@@ -23,7 +23,7 @@ type DefaultProps = {
|
|
|
23
23
|
type State = {
|
|
24
24
|
categoryHeights: Record<string, number>;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
declare class Plotter extends React.Component<Props, State> implements Widget {
|
|
27
27
|
static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
|
|
28
28
|
context: React.ContextType<typeof PerseusI18nContext>;
|
|
29
29
|
_isMounted: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { ChoiceState, Widget, ChangeHandler } from "../../types";
|
|
3
3
|
import type { PerseusRadioChoice, PerseusRadioRubric, PerseusRadioUserInput } from "@khanacademy/perseus-core";
|
|
4
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
4
5
|
/**
|
|
5
6
|
* Represents a single choice in the MultipleChoiceComponent
|
|
6
7
|
*/
|
|
@@ -18,7 +19,7 @@ export interface ChoiceType {
|
|
|
18
19
|
revealNoneOfTheAbove: boolean;
|
|
19
20
|
disabled: boolean;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
type RadioProps = {
|
|
22
23
|
numCorrect: number;
|
|
23
24
|
hasNoneOfTheAbove?: boolean;
|
|
24
25
|
multipleSelect?: boolean;
|
|
@@ -37,5 +38,70 @@ export interface RadioChoiceWithMetadata extends PerseusRadioChoice {
|
|
|
37
38
|
originalIndex: number;
|
|
38
39
|
correct?: boolean;
|
|
39
40
|
}
|
|
40
|
-
declare const Radio: React.ForwardRefExoticComponent<RadioProps &
|
|
41
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & {
|
|
42
|
+
trackInteraction: (extraData?: PerseusRadioRubric | undefined) => void;
|
|
43
|
+
widgetId: string;
|
|
44
|
+
widgetIndex: number;
|
|
45
|
+
alignment: string | null | undefined;
|
|
46
|
+
static: boolean | null | undefined;
|
|
47
|
+
problemNum: number | null | undefined;
|
|
48
|
+
apiOptions: Readonly<Readonly<{
|
|
49
|
+
isArticle?: boolean;
|
|
50
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
51
|
+
GroupMetadataEditor?: React.ComponentType<any>;
|
|
52
|
+
showAlignmentOptions?: boolean;
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
answerableCallback?: (arg1: boolean) => unknown;
|
|
55
|
+
getAnotherHint?: () => unknown;
|
|
56
|
+
interactionCallback?: (widgetData: {
|
|
57
|
+
[widgetId: string]: any;
|
|
58
|
+
}) => void;
|
|
59
|
+
groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
|
|
60
|
+
imagePlaceholder?: React.ReactNode;
|
|
61
|
+
widgetPlaceholder?: React.ReactNode;
|
|
62
|
+
baseElements?: {
|
|
63
|
+
Link: React.ComponentType<any>;
|
|
64
|
+
};
|
|
65
|
+
imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
|
|
66
|
+
trackInteraction?: (args: {
|
|
67
|
+
type: string;
|
|
68
|
+
id: string;
|
|
69
|
+
correct?: boolean;
|
|
70
|
+
} & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
|
|
71
|
+
visible: number;
|
|
72
|
+
}>) => void;
|
|
73
|
+
customKeypad?: boolean;
|
|
74
|
+
nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
|
|
75
|
+
isMobile?: boolean;
|
|
76
|
+
isMobileApp?: boolean;
|
|
77
|
+
setDrawingAreaAvailable?: (arg1: boolean) => unknown;
|
|
78
|
+
hintProgressColor?: string;
|
|
79
|
+
canScrollPage?: boolean;
|
|
80
|
+
editorChangeDelay?: number;
|
|
81
|
+
flags?: Record<"new-radio-widget" | "image-widget-upgrade", boolean>;
|
|
82
|
+
}> & {
|
|
83
|
+
baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
|
|
84
|
+
canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
|
|
85
|
+
editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
|
|
86
|
+
groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
|
|
87
|
+
isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
|
|
88
|
+
isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
|
|
89
|
+
isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
|
|
90
|
+
onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
|
|
91
|
+
readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
|
|
92
|
+
setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
|
|
93
|
+
showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
|
|
94
|
+
}>;
|
|
95
|
+
keypadElement?: any;
|
|
96
|
+
questionCompleted?: boolean;
|
|
97
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
98
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
99
|
+
findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
|
|
100
|
+
reviewMode: boolean;
|
|
101
|
+
showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
|
|
102
|
+
handleUserInput: (newUserInput: PerseusRadioUserInput, cb?: () => void, silent?: boolean) => void;
|
|
103
|
+
userInput: PerseusRadioUserInput;
|
|
104
|
+
linterContext: LinterContextProps;
|
|
105
|
+
containerSizeClass: import("../../util/sizing-utils").SizeClass;
|
|
106
|
+
} & React.RefAttributes<Widget>>;
|
|
41
107
|
export default Radio;
|
|
@@ -15,7 +15,7 @@ export type RadioProps = PerseusRadioWidgetOptions & {
|
|
|
15
15
|
choiceStates?: ChoiceState[];
|
|
16
16
|
onChange: ChangeHandler;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type Props = WidgetProps<RadioProps, PerseusRadioUserInput, PerseusRadioRubric>;
|
|
19
19
|
type DefaultProps = Required<Pick<Props, "choices" | "multipleSelect" | "countChoices" | "deselectEnabled" | "linterContext" | "showSolutions">>;
|
|
20
20
|
export type RadioChoiceWithMetadata = PerseusRadioChoice & {
|
|
21
21
|
originalIndex: number;
|
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": "71.4.
|
|
6
|
+
"version": "71.4.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -42,45 +42,44 @@
|
|
|
42
42
|
"tiny-invariant": "1.3.1",
|
|
43
43
|
"uuid": "^10.0.0",
|
|
44
44
|
"@khanacademy/kas": "2.1.3",
|
|
45
|
-
"@khanacademy/keypad-context": "3.2.
|
|
46
|
-
"@khanacademy/kmath": "2.2.
|
|
47
|
-
"@khanacademy/math-input": "26.2.
|
|
48
|
-
"@khanacademy/perseus-core": "20.1.
|
|
49
|
-
"@khanacademy/perseus-linter": "4.4.
|
|
50
|
-
"@khanacademy/perseus-score": "8.0.
|
|
45
|
+
"@khanacademy/keypad-context": "3.2.15",
|
|
46
|
+
"@khanacademy/kmath": "2.2.15",
|
|
47
|
+
"@khanacademy/math-input": "26.2.16",
|
|
48
|
+
"@khanacademy/perseus-core": "20.1.3",
|
|
49
|
+
"@khanacademy/perseus-linter": "4.4.5",
|
|
50
|
+
"@khanacademy/perseus-score": "8.0.4",
|
|
51
51
|
"@khanacademy/perseus-utils": "2.1.1",
|
|
52
52
|
"@khanacademy/pure-markdown": "2.2.1",
|
|
53
53
|
"@khanacademy/simple-markdown": "2.1.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@khanacademy/wonder-blocks-announcer": "1.0.
|
|
57
|
-
"@khanacademy/wonder-blocks-banner": "
|
|
58
|
-
"@khanacademy/wonder-blocks-button": "11.2.
|
|
59
|
-
"@khanacademy/wonder-blocks-clickable": "8.0.
|
|
60
|
-
"@khanacademy/wonder-blocks-core": "12.4.
|
|
61
|
-
"@khanacademy/wonder-blocks-data": "14.1.
|
|
62
|
-
"@khanacademy/wonder-blocks-dropdown": "10.4.
|
|
63
|
-
"@khanacademy/wonder-blocks-form": "7.4.
|
|
64
|
-
"@khanacademy/wonder-blocks-icon-button": "10.5.
|
|
65
|
-
"@khanacademy/wonder-blocks-icon": "5.3.
|
|
66
|
-
"@khanacademy/wonder-blocks-labeled-field": "4.0.
|
|
67
|
-
"@khanacademy/wonder-blocks-layout": "3.1.
|
|
68
|
-
"@khanacademy/wonder-blocks-link": "10.0.
|
|
69
|
-
"@khanacademy/wonder-blocks-modal": "8.
|
|
70
|
-
"@khanacademy/wonder-blocks-pill": "3.1.
|
|
71
|
-
"@khanacademy/wonder-blocks-popover": "6.1.
|
|
72
|
-
"@khanacademy/wonder-blocks-progress-spinner": "3.1.
|
|
73
|
-
"@khanacademy/wonder-blocks-switch": "3.3.
|
|
74
|
-
"@khanacademy/wonder-blocks-timing": "7.0.
|
|
75
|
-
"@khanacademy/wonder-blocks-tokens": "14.
|
|
76
|
-
"@khanacademy/wonder-blocks-tooltip": "4.1.
|
|
77
|
-
"@khanacademy/wonder-blocks-typography": "4.2.
|
|
56
|
+
"@khanacademy/wonder-blocks-announcer": "1.0.4",
|
|
57
|
+
"@khanacademy/wonder-blocks-banner": "5.0.2",
|
|
58
|
+
"@khanacademy/wonder-blocks-button": "11.2.6",
|
|
59
|
+
"@khanacademy/wonder-blocks-clickable": "8.0.2",
|
|
60
|
+
"@khanacademy/wonder-blocks-core": "12.4.1",
|
|
61
|
+
"@khanacademy/wonder-blocks-data": "14.1.7",
|
|
62
|
+
"@khanacademy/wonder-blocks-dropdown": "10.4.10",
|
|
63
|
+
"@khanacademy/wonder-blocks-form": "7.4.3",
|
|
64
|
+
"@khanacademy/wonder-blocks-icon-button": "10.5.5",
|
|
65
|
+
"@khanacademy/wonder-blocks-icon": "5.3.2",
|
|
66
|
+
"@khanacademy/wonder-blocks-labeled-field": "4.0.8",
|
|
67
|
+
"@khanacademy/wonder-blocks-layout": "3.1.39",
|
|
68
|
+
"@khanacademy/wonder-blocks-link": "10.0.3",
|
|
69
|
+
"@khanacademy/wonder-blocks-modal": "8.5.3",
|
|
70
|
+
"@khanacademy/wonder-blocks-pill": "3.1.45",
|
|
71
|
+
"@khanacademy/wonder-blocks-popover": "6.1.40",
|
|
72
|
+
"@khanacademy/wonder-blocks-progress-spinner": "3.1.39",
|
|
73
|
+
"@khanacademy/wonder-blocks-switch": "3.3.22",
|
|
74
|
+
"@khanacademy/wonder-blocks-timing": "7.0.3",
|
|
75
|
+
"@khanacademy/wonder-blocks-tokens": "14.1.0",
|
|
76
|
+
"@khanacademy/wonder-blocks-tooltip": "4.1.54",
|
|
77
|
+
"@khanacademy/wonder-blocks-typography": "4.2.24",
|
|
78
78
|
"@khanacademy/wonder-stuff-core": "1.5.5",
|
|
79
79
|
"@phosphor-icons/core": "2.0.2",
|
|
80
80
|
"@popperjs/core": "2.10.2",
|
|
81
81
|
"aphrodite": "1.2.5",
|
|
82
82
|
"classnames": "1.1.4",
|
|
83
|
-
"csstype": "^3.1.3",
|
|
84
83
|
"intersection-observer": "^0.12.0",
|
|
85
84
|
"jquery": "2.1.1",
|
|
86
85
|
"lodash.debounce": "^4.0.8",
|
|
@@ -93,28 +92,28 @@
|
|
|
93
92
|
"raphael": "1.5.4"
|
|
94
93
|
},
|
|
95
94
|
"peerDependencies": {
|
|
96
|
-
"@khanacademy/wonder-blocks-announcer": "^1.0.
|
|
97
|
-
"@khanacademy/wonder-blocks-banner": "^
|
|
98
|
-
"@khanacademy/wonder-blocks-button": "^11.2.
|
|
99
|
-
"@khanacademy/wonder-blocks-clickable": "^8.0.
|
|
100
|
-
"@khanacademy/wonder-blocks-core": "^12.4.
|
|
101
|
-
"@khanacademy/wonder-blocks-data": "^14.1.
|
|
102
|
-
"@khanacademy/wonder-blocks-dropdown": "^10.4.
|
|
103
|
-
"@khanacademy/wonder-blocks-form": "^7.4.
|
|
104
|
-
"@khanacademy/wonder-blocks-icon": "^5.3.
|
|
105
|
-
"@khanacademy/wonder-blocks-icon-button": "^10.5.
|
|
106
|
-
"@khanacademy/wonder-blocks-labeled-field": "^4.0.
|
|
107
|
-
"@khanacademy/wonder-blocks-layout": "^3.1.
|
|
108
|
-
"@khanacademy/wonder-blocks-link": "^10.0.
|
|
109
|
-
"@khanacademy/wonder-blocks-modal": "^8.
|
|
110
|
-
"@khanacademy/wonder-blocks-pill": "^3.1.
|
|
111
|
-
"@khanacademy/wonder-blocks-popover": "^6.1.
|
|
112
|
-
"@khanacademy/wonder-blocks-progress-spinner": "^3.1.
|
|
113
|
-
"@khanacademy/wonder-blocks-switch": "^3.3.
|
|
114
|
-
"@khanacademy/wonder-blocks-timing": "^7.0.
|
|
115
|
-
"@khanacademy/wonder-blocks-tokens": "^14.
|
|
116
|
-
"@khanacademy/wonder-blocks-tooltip": "^4.1.
|
|
117
|
-
"@khanacademy/wonder-blocks-typography": "^4.2.
|
|
95
|
+
"@khanacademy/wonder-blocks-announcer": "^1.0.4",
|
|
96
|
+
"@khanacademy/wonder-blocks-banner": "^5.0.2",
|
|
97
|
+
"@khanacademy/wonder-blocks-button": "^11.2.6",
|
|
98
|
+
"@khanacademy/wonder-blocks-clickable": "^8.0.2",
|
|
99
|
+
"@khanacademy/wonder-blocks-core": "^12.4.1",
|
|
100
|
+
"@khanacademy/wonder-blocks-data": "^14.1.7",
|
|
101
|
+
"@khanacademy/wonder-blocks-dropdown": "^10.4.10",
|
|
102
|
+
"@khanacademy/wonder-blocks-form": "^7.4.3",
|
|
103
|
+
"@khanacademy/wonder-blocks-icon": "^5.3.2",
|
|
104
|
+
"@khanacademy/wonder-blocks-icon-button": "^10.5.5",
|
|
105
|
+
"@khanacademy/wonder-blocks-labeled-field": "^4.0.8",
|
|
106
|
+
"@khanacademy/wonder-blocks-layout": "^3.1.39",
|
|
107
|
+
"@khanacademy/wonder-blocks-link": "^10.0.3",
|
|
108
|
+
"@khanacademy/wonder-blocks-modal": "^8.5.3",
|
|
109
|
+
"@khanacademy/wonder-blocks-pill": "^3.1.45",
|
|
110
|
+
"@khanacademy/wonder-blocks-popover": "^6.1.40",
|
|
111
|
+
"@khanacademy/wonder-blocks-progress-spinner": "^3.1.39",
|
|
112
|
+
"@khanacademy/wonder-blocks-switch": "^3.3.22",
|
|
113
|
+
"@khanacademy/wonder-blocks-timing": "^7.0.3",
|
|
114
|
+
"@khanacademy/wonder-blocks-tokens": "^14.1.0",
|
|
115
|
+
"@khanacademy/wonder-blocks-tooltip": "^4.1.54",
|
|
116
|
+
"@khanacademy/wonder-blocks-typography": "^4.2.24",
|
|
118
117
|
"@khanacademy/wonder-stuff-core": "^1.5.5",
|
|
119
118
|
"@phosphor-icons/core": "^2.0.2",
|
|
120
119
|
"@popperjs/core": "^2.10.2",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VisibilityObserver watches a target element for changes to visibility,
|
|
3
|
-
* relative to a given root node.
|
|
4
|
-
*
|
|
5
|
-
* When the target element entirely disappears, or partially reappears, the
|
|
6
|
-
* caller is notified via the `onVisibilityChange` callback.
|
|
7
|
-
*
|
|
8
|
-
* Potential visibility changes include:
|
|
9
|
-
* - Being scrolled out of view, by any scroll container between the target
|
|
10
|
-
* and the root.
|
|
11
|
-
* - Style changes to the target element or an ancestor, like `display: none`.
|
|
12
|
-
*
|
|
13
|
-
* The VisibilityObserver relies on the IntersectionObserver, which does not
|
|
14
|
-
* exist on Safari and is buggy on Edge. Instead, we will polyfill the
|
|
15
|
-
* IntersectionObserver on those platforms.
|
|
16
|
-
*
|
|
17
|
-
* TODO(mdr): Currently, we emulate the API of IntersectionObserver. It might
|
|
18
|
-
* be nicer to instead use a more React-y API: let `targetElement` be a
|
|
19
|
-
* required prop, and render the element only when it's present. Then, we
|
|
20
|
-
* can use React lifecycle methods to set-up/tear-down handlers. Not sure
|
|
21
|
-
* that's _actually_ a net win, though, in complexity or performance - but
|
|
22
|
-
* worth thinking about if this API is causing too much entanglement!
|
|
23
|
-
*/
|
|
24
|
-
import "intersection-observer";
|
|
25
|
-
export interface VisibilityObserver {
|
|
26
|
-
setTargetElement(targetElement: HTMLElement): void;
|
|
27
|
-
disconnect(): void;
|
|
28
|
-
}
|
|
29
|
-
type VisibilityChangeCallback = (isVisible: boolean, rootBounds: DOMRectReadOnly) => void;
|
|
30
|
-
/**
|
|
31
|
-
* Create a new VisibilityObserver.
|
|
32
|
-
*/
|
|
33
|
-
export declare function createVisibilityObserver(rootElement: HTMLElement | null | undefined, onVisibilityChange: VisibilityChangeCallback, rootMargin?: string): VisibilityObserver;
|
|
34
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getScrollParent: (node: Element) => Element | null | undefined;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a wrapper component for the visibility-observer.js utility which
|
|
3
|
-
* abstracts the native or polyfilled IntersectionObserver utility. The
|
|
4
|
-
* primary purpose of this comonent is to tell you whether the children of
|
|
5
|
-
* the component are visibile within a scrollable ancestor. It will notify
|
|
6
|
-
* you via an onChange event when the visibility changes, and whether the
|
|
7
|
-
* children are below or above the scroll.
|
|
8
|
-
*/
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
import type { VisibilityObserver as IVisibilityObserver } from "./create-visibility-observer";
|
|
11
|
-
export type ScrollVisibility = "hidden-above" | "hidden-below" | "visible" | "unknown";
|
|
12
|
-
type Props = {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
rootMargin?: string;
|
|
15
|
-
scrollParentIsNotBody?: boolean;
|
|
16
|
-
onChange: (visibility: ScrollVisibility) => void;
|
|
17
|
-
};
|
|
18
|
-
declare class VisibilityObserver extends React.Component<Props> {
|
|
19
|
-
_observer: IVisibilityObserver;
|
|
20
|
-
_node: HTMLElement;
|
|
21
|
-
static defaultProps: {
|
|
22
|
-
onChange: () => void;
|
|
23
|
-
};
|
|
24
|
-
componentDidMount(): void;
|
|
25
|
-
componentWillUnmount(): void;
|
|
26
|
-
handleVisibilityChange: (isVisible: boolean, rootBounds: DOMRectReadOnly) => void;
|
|
27
|
-
registerVisibilityObserver(): void;
|
|
28
|
-
unregisterVisibilityObserver(): void;
|
|
29
|
-
render(): React.ReactNode;
|
|
30
|
-
}
|
|
31
|
-
export default VisibilityObserver;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const CHOICE_ICON_SIZE = 24;
|
|
2
|
-
declare const styles: {
|
|
3
|
-
readonly iconWrapper: {
|
|
4
|
-
readonly display: "inline-block";
|
|
5
|
-
readonly position: "relative";
|
|
6
|
-
readonly background: "linear-gradient(to right, white 10%, transparent)";
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export default styles;
|