@khanacademy/perseus-editor 4.3.4 → 4.4.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.
@@ -3,51 +3,25 @@
3
3
  *
4
4
  * TODO(jack): Add more comments
5
5
  */
6
- import PropTypes from "prop-types";
6
+ import { Changeable } from "@khanacademy/perseus";
7
7
  import * as React from "react";
8
- import type { Coord } from "@khanacademy/perseus";
9
- type Props = any;
8
+ import type { Coord, PerseusExampleGraphieWidgetOptions, APIOptionsWithDefaults } from "@khanacademy/perseus";
9
+ type Props = Changeable.ChangeableProps & {
10
+ apiOptions: APIOptionsWithDefaults;
11
+ graph: PerseusExampleGraphieWidgetOptions["graph"];
12
+ coord: PerseusExampleGraphieWidgetOptions["coord"];
13
+ };
14
+ type DefaultProps = {
15
+ graph: Props["graph"];
16
+ coord: Props["coord"];
17
+ };
10
18
  /**
11
19
  * This is the widget's renderer. It shows up in the right column
12
20
  * in the demo, and is what is visible to users, and where
13
21
  * users enter their answers.
14
22
  */
15
23
  declare class ExampleGraphieWidget extends React.Component<Props> {
16
- static propTypes: {
17
- apiOptions: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
18
- isArticle: PropTypes.Validator<boolean>;
19
- onInputError: PropTypes.Validator<(...args: any[]) => any>;
20
- onFocusChange: PropTypes.Validator<(...args: any[]) => any>;
21
- GroupMetadataEditor: PropTypes.Validator<(...args: any[]) => any>;
22
- showAlignmentOptions: PropTypes.Validator<boolean>;
23
- readOnly: PropTypes.Validator<boolean>;
24
- answerableCallback: PropTypes.Requireable<(...args: any[]) => any>;
25
- getAnotherHint: PropTypes.Requireable<(...args: any[]) => any>;
26
- interactionCallback: PropTypes.Requireable<(...args: any[]) => any>;
27
- groupAnnotator: PropTypes.Validator<(...args: any[]) => any>;
28
- imagePlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
29
- widgetPlaceholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
30
- baseElements: PropTypes.Requireable<PropTypes.InferProps<{
31
- Link: PropTypes.Requireable<(...args: any[]) => any>;
32
- }>>;
33
- imagePreloader: PropTypes.Requireable<(...args: any[]) => any>;
34
- trackInteraction: PropTypes.Requireable<(...args: any[]) => any>;
35
- customKeypad: PropTypes.Requireable<boolean>;
36
- nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
37
- isMobile: PropTypes.Requireable<boolean>;
38
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
39
- useDraftEditor: PropTypes.Requireable<boolean>;
40
- hintProgressColor: PropTypes.Requireable<string>;
41
- canScrollPage: PropTypes.Requireable<boolean>;
42
- inModal: PropTypes.Requireable<boolean>;
43
- crossOutEnabled: PropTypes.Requireable<boolean>;
44
- editorChangeDelay: PropTypes.Requireable<number>;
45
- }>>>;
46
- graph: PropTypes.Validator<object>;
47
- coord: PropTypes.Requireable<(number | null | undefined)[]>;
48
- onChange: PropTypes.Validator<(...args: any[]) => any>;
49
- };
50
- static defaultProps: Props;
24
+ static defaultProps: DefaultProps;
51
25
  /**
52
26
  * This is the widget's grading function
53
27
  */
@@ -1,22 +1,33 @@
1
- import PropTypes from "prop-types";
1
+ /**
2
+ * This is a simple number-entry widget
3
+ * It is not as powerful as number-input, but has a simpler, more
4
+ * representative structure as an example widget, and is easier to
5
+ * test new ideas on.
6
+ *
7
+ * TODO(jack): Add more comments
8
+ */
9
+ import { Changeable } from "@khanacademy/perseus";
2
10
  import * as React from "react";
3
- declare class TextInput extends React.Component<any> {
11
+ import type { PerseusExampleWidgetOptions } from "@khanacademy/perseus";
12
+ type Props = Changeable.ChangeableProps & {
13
+ value: PerseusExampleWidgetOptions["value"];
14
+ };
15
+ declare class TextInput extends React.Component<Props> {
4
16
  input: React.RefObject<HTMLInputElement>;
5
17
  render(): React.ReactNode;
6
18
  focus: () => boolean;
7
19
  changeValue: (e: any) => void;
8
20
  }
21
+ type DefaultProps = {
22
+ value: Props["value"];
23
+ };
9
24
  /**
10
25
  * This is the widget's renderer. It shows up in the right column
11
26
  * in the demo, and is what is visible to users, and where
12
27
  * users enter their answers.
13
28
  */
14
- declare class ExampleWidget extends React.Component<any> {
15
- static propTypes: {
16
- value: PropTypes.Requireable<string>;
17
- onChange: PropTypes.Validator<(...args: any[]) => any>;
18
- };
19
- static defaultProps: any;
29
+ declare class ExampleWidget extends React.Component<Props> {
30
+ static defaultProps: DefaultProps;
20
31
  input: React.RefObject<TextInput>;
21
32
  /**
22
33
  * This is the widget's grading function. simpleValidate generally