@khanacademy/perseus 60.0.2 → 61.0.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.
Files changed (45) hide show
  1. package/dist/es/index.css +1 -3184
  2. package/dist/es/index.js +58 -30
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.css +1 -3184
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +58 -33
  7. package/dist/index.js.map +1 -1
  8. package/dist/perseus-version.d.ts +0 -4
  9. package/dist/types.d.ts +0 -1
  10. package/dist/util/test-utils.d.ts +1 -12
  11. package/dist/util.d.ts +6 -1
  12. package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +2 -2
  13. package/dist/widgets/expression/expression.d.ts +3 -3
  14. package/dist/widgets/graded-group/graded-group.d.ts +2 -2
  15. package/dist/widgets/graded-group-set/graded-group-set.d.ts +2 -2
  16. package/dist/widgets/grapher/grapher.d.ts +2 -2
  17. package/dist/widgets/group/group.d.ts +2 -2
  18. package/dist/widgets/input-number/input-number.d.ts +3 -3
  19. package/dist/widgets/interactive-graph.d.ts +13 -13
  20. package/dist/widgets/interactive-graphs/types.d.ts +1 -1
  21. package/dist/widgets/matcher/matcher.d.ts +2 -2
  22. package/dist/widgets/matrix/matrix.d.ts +2 -2
  23. package/dist/widgets/measurer/measurer.d.ts +1 -1
  24. package/dist/widgets/mock-widgets/mock-widget.d.ts +2 -2
  25. package/dist/widgets/number-line/number-line.d.ts +2 -2
  26. package/dist/widgets/numeric-input/numeric-input.class.d.ts +1 -1
  27. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -1
  28. package/dist/widgets/orderer/orderer.d.ts +2 -2
  29. package/dist/widgets/phet-simulation/phet-simulation.d.ts +1 -1
  30. package/dist/widgets/plotter/plotter.d.ts +3 -3
  31. package/dist/widgets/radio/base-radio.new.d.ts +49 -0
  32. package/dist/widgets/radio/choice-a11y-text.new.d.ts +14 -0
  33. package/dist/widgets/radio/choice-icon/choice-icon.new.d.ts +23 -0
  34. package/dist/widgets/radio/choice-none-above.new.d.ts +6 -0
  35. package/dist/widgets/radio/choice.new.d.ts +23 -0
  36. package/dist/widgets/radio/focus-ring.new.d.ts +19 -0
  37. package/dist/widgets/radio/option-status.new.d.ts +24 -0
  38. package/dist/widgets/radio/radio-component.d.ts +4 -4
  39. package/dist/widgets/radio/radio-component.new.d.ts +63 -0
  40. package/dist/widgets/radio/radio.d.ts +1 -1
  41. package/dist/widgets/radio/radio.ff.d.ts +24 -0
  42. package/dist/widgets/sorter/sorter.d.ts +2 -2
  43. package/dist/widgets/table/table.d.ts +23 -17
  44. package/dist/widgets/table/test-util.d.ts +2 -0
  45. package/package.json +11 -11
@@ -0,0 +1,63 @@
1
+ import * as React from "react";
2
+ import { PerseusI18nContext } from "../../components/i18n-context";
3
+ import type { FocusFunction } from "./base-radio.new";
4
+ import type { WidgetProps, ChoiceState, Widget } from "../../types";
5
+ import type { RadioPromptJSON } from "../../widget-ai-utils/radio/radio-ai-utils";
6
+ import type { PerseusRadioChoice, ShowSolutions, PerseusRadioRubric, PerseusRadioUserInput, RecursiveReadonly } from "@khanacademy/perseus-core";
7
+ export type RenderProps = {
8
+ numCorrect: number;
9
+ hasNoneOfTheAbove?: boolean;
10
+ multipleSelect?: boolean;
11
+ countChoices?: boolean;
12
+ deselectEnabled?: boolean;
13
+ choices: ReadonlyArray<RadioChoiceWithMetadata>;
14
+ selectedChoices: ReadonlyArray<PerseusRadioChoice["correct"]>;
15
+ showSolutions?: ShowSolutions;
16
+ choiceStates?: ReadonlyArray<ChoiceState>;
17
+ values?: ReadonlyArray<boolean>;
18
+ };
19
+ type Props = WidgetProps<RenderProps, PerseusRadioRubric>;
20
+ type DefaultProps = Required<Pick<Props, "choices" | "multipleSelect" | "countChoices" | "deselectEnabled" | "linterContext" | "showSolutions">>;
21
+ export type RadioChoiceWithMetadata = PerseusRadioChoice & {
22
+ originalIndex: number;
23
+ correct?: boolean;
24
+ };
25
+ /**
26
+ * This component is a duplicate of the Radio component in radio.tsx
27
+ * for the Radio Revitalization Project. (LEMS-2933)
28
+ * This component will be split up to move the rendering logic to a new functional component.
29
+ * This file will be renamed to radio.class.tsx and will supercede radio-component.tsx when
30
+ * the feature flag is no longer needed.
31
+ *
32
+ * TODO(LEMS-2994): Clean up this file.
33
+ */
34
+ declare class Radio extends React.Component<Props> implements Widget {
35
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
36
+ context: React.ContextType<typeof PerseusI18nContext>;
37
+ focusFunction: FocusFunction;
38
+ static defaultProps: DefaultProps;
39
+ static getUserInputFromProps(props: Props, unshuffle?: boolean): PerseusRadioUserInput;
40
+ componentDidUpdate(prevProps: Props): void;
41
+ _renderRenderer: (content?: string) => React.ReactElement;
42
+ focus(choiceIndex?: number | null): boolean;
43
+ registerFocusFunction(fun: FocusFunction): void;
44
+ updateChoices: (newValueLists: Readonly<{
45
+ checked: ReadonlyArray<boolean>;
46
+ crossedOut: ReadonlyArray<boolean>;
47
+ }>) => void;
48
+ getUserInput(): PerseusRadioUserInput;
49
+ getPromptJSON(): RadioPromptJSON;
50
+ /**
51
+ * Turn on rationale display for the currently selected choices. Note that
52
+ * this leaves rationales on for choices that are already showing
53
+ * rationales.
54
+ * @deprecated Internal only. Use `showSolutions` prop instead.
55
+ */
56
+ showRationalesForCurrentlySelectedChoices: (arg1: RecursiveReadonly<PerseusRadioRubric>) => void;
57
+ /**
58
+ * Deselects any currently-selected choices that are not correct choices.
59
+ */
60
+ deselectIncorrectSelectedChoices: () => void;
61
+ render(): React.ReactNode;
62
+ }
63
+ export default Radio;
@@ -1,4 +1,4 @@
1
- import Radio from "./radio-component";
1
+ import Radio from "./radio.ff";
2
2
  import type { RenderProps } from "./radio-component";
3
3
  import type { PerseusStrings } from "../../strings";
4
4
  import type { PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import RadioOld from "./radio-component";
3
+ import RadioNew from "./radio-component.new";
4
+ import type { RenderProps } from "./radio-component";
5
+ import type { WidgetProps } from "../../types";
6
+ import type { PerseusRadioRubric } from "@khanacademy/perseus-core";
7
+ type Props = WidgetProps<RenderProps, PerseusRadioRubric>;
8
+ /**
9
+ * This is a wrapper around the old radio widget that allows us to
10
+ * conditionally render the new radio widget when the feature flag is on.
11
+ *
12
+ * This is necessary to ensure that we do not interrupt the assessment studies
13
+ * that are currently running.
14
+ *
15
+ * TODO(LEMS-2994): Clean up this file.
16
+ */
17
+ declare class Radio extends RadioOld {
18
+ ffIsOn: boolean;
19
+ radioRef: React.RefObject<RadioOld | RadioNew>;
20
+ constructor(props: Props);
21
+ focus(choiceIndex?: number | null): boolean;
22
+ render(): React.ReactNode;
23
+ }
24
+ export default Radio;
@@ -2,9 +2,9 @@ import * as React from "react";
2
2
  import type { SortableOption } from "../../components/sortable";
3
3
  import type { Widget, WidgetProps } from "../../types";
4
4
  import type { SorterPromptJSON } from "../../widget-ai-utils/sorter/sorter-ai-utils";
5
- import type { PerseusSorterWidgetOptions, PerseusSorterRubric, PerseusSorterUserInput } from "@khanacademy/perseus-core";
5
+ import type { PerseusSorterWidgetOptions, PerseusSorterUserInput } from "@khanacademy/perseus-core";
6
6
  type RenderProps = PerseusSorterWidgetOptions;
7
- type Props = WidgetProps<RenderProps, PerseusSorterRubric>;
7
+ type Props = WidgetProps<RenderProps>;
8
8
  type DefaultProps = {
9
9
  correct: Props["correct"];
10
10
  layout: Props["layout"];
@@ -1,13 +1,15 @@
1
1
  import * as React from "react";
2
+ import ReactDOM from "react-dom";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
4
  import type { ChangeableProps } from "../../mixins/changeable";
4
- import type { Widget, WidgetProps } from "../../types";
5
- import type { PerseusTableWidgetOptions, PerseusTableRubric, PerseusTableUserInput } from "@khanacademy/perseus-core";
6
- type RenderProps = PerseusTableWidgetOptions & {
5
+ import type { FocusPath, Widget, WidgetProps } from "../../types";
6
+ import type { PerseusTableWidgetOptions, PerseusTableUserInput } from "@khanacademy/perseus-core";
7
+ type EditorProps = {
7
8
  editableHeaders: boolean;
8
9
  Editor: any;
9
10
  };
10
- type Props = ChangeableProps & WidgetProps<RenderProps, PerseusTableRubric>;
11
+ type RenderProps = PerseusTableWidgetOptions & EditorProps;
12
+ type Props = WidgetProps<PerseusTableWidgetOptions> & ChangeableProps & EditorProps;
11
13
  type DefaultProps = {
12
14
  apiOptions: Props["apiOptions"];
13
15
  headers: Props["headers"];
@@ -20,28 +22,32 @@ type DefaultProps = {
20
22
  declare class Table extends React.Component<Props> implements Widget {
21
23
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
22
24
  context: React.ContextType<typeof PerseusI18nContext>;
25
+ headerRefs: Record<string, any>;
26
+ answerRefs: Record<string, any>;
23
27
  static defaultProps: DefaultProps;
24
- _getRows: () => number;
25
- _getColumns: () => number;
28
+ _getRows(): number;
29
+ _getColumns(): number;
30
+ _getAnswersClone(): PerseusTableUserInput;
26
31
  getUserInput(): PerseusTableUserInput;
27
- onValueChange: (arg1: any, arg2: any, arg3: any) => void;
28
- onHeaderChange: (arg1: number, arg2: any) => void;
29
- _handleFocus: (arg1: any) => void;
30
- _handleBlur: (arg1: any) => void;
31
- focus: () => boolean;
32
- focusInputPath: (arg1: any) => void;
33
- blurInputPath: (arg1: any) => void;
34
- getDOMNodeForPath(path: any): Element | Text | null;
35
- getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
36
- setInputValue: (arg1: any, arg2: any, arg3: any) => void;
32
+ onValueChange(row: number, column: number, eventOrValue: any): void;
33
+ onHeaderChange(index: number, e: any): void;
34
+ _handleFocus(inputPath: any): void;
35
+ _handleBlur(inputPath: any): void;
36
+ focus(): boolean;
37
+ focusInputPath(path: FocusPath): void;
38
+ blurInputPath(path: FocusPath): void;
39
+ getDOMNodeForPath(path: FocusPath): ReturnType<typeof ReactDOM.findDOMNode>;
40
+ getInputPaths(): string[][];
41
+ setInputValue(path: FocusPath, newValue: string, cb: any): void;
37
42
  render(): React.ReactNode;
38
43
  }
44
+ declare function propTransform(options: Props): RenderProps;
39
45
  declare const _default: {
40
46
  name: string;
41
47
  displayName: string;
42
48
  accessible: true;
43
49
  widget: typeof Table;
44
- transform: (arg1: any) => any;
50
+ transform: typeof propTransform;
45
51
  hidden: true;
46
52
  isLintable: true;
47
53
  };
@@ -0,0 +1,2 @@
1
+ import type { PerseusRenderer } from "@khanacademy/perseus-core";
2
+ export declare function generateTableRenderer(extend?: Partial<PerseusRenderer>): PerseusRenderer;
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": "60.0.2",
6
+ "version": "61.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -40,16 +40,16 @@
40
40
  "@use-gesture/react": "^10.2.27",
41
41
  "mafs": "0.19.0",
42
42
  "uuid": "^10.0.0",
43
- "@khanacademy/kas": "2.0.1",
44
- "@khanacademy/keypad-context": "3.0.4",
45
- "@khanacademy/kmath": "2.0.4",
46
- "@khanacademy/math-input": "25.0.4",
47
- "@khanacademy/perseus-core": "7.1.1",
48
- "@khanacademy/perseus-linter": "3.0.4",
49
- "@khanacademy/perseus-score": "5.0.1",
43
+ "@khanacademy/kas": "2.0.2",
44
+ "@khanacademy/keypad-context": "3.0.6",
45
+ "@khanacademy/kmath": "2.0.6",
46
+ "@khanacademy/math-input": "25.1.0",
47
+ "@khanacademy/perseus-core": "9.0.0",
48
+ "@khanacademy/perseus-linter": "3.0.6",
49
+ "@khanacademy/perseus-score": "5.0.3",
50
50
  "@khanacademy/perseus-utils": "2.0.1",
51
- "@khanacademy/pure-markdown": "2.0.1",
52
- "@khanacademy/simple-markdown": "2.0.1"
51
+ "@khanacademy/pure-markdown": "2.0.2",
52
+ "@khanacademy/simple-markdown": "2.0.2"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@khanacademy/wonder-blocks-banner": "4.1.6",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^18.2.0",
85
85
  "react-popper": "^2.2.5",
86
86
  "underscore": "^1.4.4",
87
- "perseus-build-settings": "0.6.0"
87
+ "perseus-build-settings": "0.6.1"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@khanacademy/wonder-blocks-banner": "4.1.6",