@khanacademy/perseus 4.0.1 → 5.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.
- package/CHANGELOG.md +26 -0
- package/dist/components/highlighting/highlightable-content.d.ts +4 -4
- package/dist/components/highlighting/highlightable-content.js.flow +4 -7
- package/dist/components/highlighting/ui/highlight-renderer.d.ts +6 -6
- package/dist/components/highlighting/ui/highlight-renderer.js.flow +6 -8
- package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +5 -5
- package/dist/components/highlighting/ui/highlight-set-renderer.js.flow +5 -8
- package/dist/components/highlighting/ui/highlight-tooltip.d.ts +2 -2
- package/dist/components/highlighting/ui/highlight-tooltip.js.flow +2 -4
- package/dist/components/highlighting/ui/highlighting-ui.d.ts +3 -3
- package/dist/components/highlighting/ui/highlighting-ui.js.flow +2 -2
- package/dist/components/highlighting/ui/selection-tracker.d.ts +5 -5
- package/dist/components/highlighting/ui/selection-tracker.js.flow +5 -7
- package/dist/components/highlighting/word-indexer.d.ts +2 -2
- package/dist/components/highlighting/word-indexer.js.flow +2 -2
- package/dist/components/inline-icon.d.ts +35 -1
- package/dist/components/inline-icon.js.flow +11 -1
- package/dist/components/simple-keypad-input.d.ts +1 -1
- package/dist/components/simple-keypad-input.js.flow +1 -1
- package/dist/components/tex-buttons.d.ts +2 -2
- package/dist/components/tex-buttons.js.flow +2 -2
- package/dist/error-boundary.d.ts +4 -4
- package/dist/error-boundary.js.flow +4 -6
- package/dist/es/index.js +53 -233
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +53 -233
- package/dist/index.js.map +1 -1
- package/dist/multi-items/multi-renderer.d.ts +1 -1
- package/dist/multi-items/multi-renderer.js.flow +1 -1
- package/dist/multi-items/prop-type-builders.d.ts +1 -1
- package/dist/multi-items/shape-types.d.ts +1 -1
- package/dist/multi-items/shape-types.js.flow +1 -1
- package/dist/multi-items/tree-types.d.ts +1 -1
- package/dist/multi-items/tree-types.js.flow +1 -1
- package/dist/perseus-types.d.ts +0 -1
- package/dist/perseus-types.js.flow +0 -1
- package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +6 -0
- package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +12 -0
- package/dist/widgets/expression.d.ts +2 -2
- package/dist/widgets/expression.js.flow +2 -2
- package/dist/widgets/interaction/element-container.d.ts +5 -4
- package/dist/widgets/interaction/element-container.js.flow +6 -11
- package/dist/widgets/label-image/marker.d.ts +4 -4
- package/dist/widgets/label-image/marker.js.flow +4 -6
- package/dist/widgets/numeric-input.d.ts +0 -2
- package/dist/widgets/numeric-input.js.flow +0 -4
- package/dist/widgets/radio/base-radio.d.ts +7 -1
- package/dist/widgets/radio/base-radio.js.flow +7 -1
- package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
- package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
- package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
- package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
- package/dist/widgets/radio/focus-ring.d.ts +8 -1
- package/dist/widgets/radio/focus-ring.js.flow +8 -1
- package/dist/widgets/radio/option-status.d.ts +2 -2
- package/dist/widgets/radio/option-status.js.flow +2 -2
- package/dist/widgets/video-transcript-link.d.ts +1 -1
- package/dist/widgets/video-transcript-link.js.flow +1 -1
- package/package.json +4 -4
- package/src/__stories__/item-renderer.stories.tsx +2 -6
- package/src/__stories__/server-item-renderer.stories.tsx +2 -6
- package/src/__testdata__/item-renderer.testdata.ts +1 -1
- package/src/__testdata__/renderer.testdata.ts +1 -1
- package/src/__tests__/item-renderer.test.tsx +1 -2
- package/src/__tests__/renderer-api.test.tsx +1 -5
- package/src/__tests__/renderer.test.tsx +1 -1
- package/src/components/__stories__/button-group.stories.tsx +2 -6
- package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
- package/src/components/__stories__/graph.stories.tsx +3 -5
- package/src/components/__stories__/graphie.stories.tsx +3 -5
- package/src/components/__stories__/hud.stories.tsx +2 -6
- package/src/components/__stories__/icon.stories.tsx +1 -1
- package/src/components/__stories__/image-loader.stories.tsx +4 -4
- package/src/components/__stories__/info-tip.stories.tsx +2 -6
- package/src/components/__stories__/inline-icon.stories.tsx +4 -8
- package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
- package/src/components/__stories__/lint.stories.tsx +12 -12
- package/src/components/__stories__/math-input.stories.tsx +4 -8
- package/src/components/__stories__/math-output.stories.tsx +3 -5
- package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
- package/src/components/__stories__/number-input.stories.tsx +6 -8
- package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
- package/src/components/__stories__/range-input.stories.tsx +4 -6
- package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
- package/src/components/__stories__/sortable.stories.tsx +15 -15
- package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
- package/src/components/__stories__/svg-image.stories.tsx +10 -18
- package/src/components/__stories__/tex.stories.tsx +1 -3
- package/src/components/__stories__/text-buttons.stories.tsx +10 -22
- package/src/components/__stories__/text-input.stories.tsx +4 -10
- package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
- package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
- package/src/components/__stories__/zoomable.stories.tsx +1 -3
- package/src/components/fixed-to-responsive.tsx +0 -1
- package/src/components/graph.tsx +0 -4
- package/src/components/highlighting/highlightable-content.tsx +4 -7
- package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
- package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
- package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
- package/src/components/highlighting/ui/highlighting-ui.tsx +5 -15
- package/src/components/highlighting/ui/selection-tracker.tsx +6 -9
- package/src/components/highlighting/word-indexer.tsx +2 -6
- package/src/components/inline-icon.tsx +2 -2
- package/src/components/math-input.tsx +0 -2
- package/src/components/number-input.tsx +0 -2
- package/src/components/simple-keypad-input.tsx +2 -2
- package/src/components/tex-buttons.tsx +2 -2
- package/src/components/text-list-editor.tsx +0 -4
- package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
- package/src/components/zoomable-tex.tsx +0 -2
- package/src/components/zoomable.tsx +0 -4
- package/src/definition-context.tsx +0 -1
- package/src/error-boundary.tsx +4 -7
- package/src/hints-renderer.tsx +1 -1
- package/src/interactive2/__tests__/movable-point.test.ts +0 -1
- package/src/item-renderer.tsx +0 -5
- package/src/mixins/changeable.ts +1 -1
- package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -5
- package/src/multi-items/__tests__/items.test.ts +3 -13
- package/src/multi-items/__tests__/multi-renderer.test.tsx +3 -4
- package/src/multi-items/__tests__/prop-type-builders.test.ts +1 -1
- package/src/multi-items/__tests__/trees.test.ts +2 -10
- package/src/multi-items/multi-renderer.tsx +7 -10
- package/src/multi-items/prop-type-builders.ts +1 -1
- package/src/multi-items/shape-types.ts +1 -1
- package/src/multi-items/tree-types.ts +1 -1
- package/src/perseus-markdown.tsx +0 -2
- package/src/perseus-types.ts +1 -4
- package/src/renderer.tsx +2 -5
- package/src/server-item-renderer.tsx +0 -3
- package/src/util/graphie.ts +3 -3
- package/src/util/interactive.ts +0 -4
- package/src/util/math.ts +0 -3
- package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
- package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
- package/src/widgets/__stories__/definition.stories.tsx +3 -7
- package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
- package/src/widgets/__stories__/explanation.stories.tsx +2 -2
- package/src/widgets/__stories__/expression.stories.tsx +113 -13
- package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
- package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
- package/src/widgets/__stories__/grapher.stories.tsx +7 -21
- package/src/widgets/__stories__/group.stories.tsx +1 -1
- package/src/widgets/__stories__/iframe.stories.tsx +1 -1
- package/src/widgets/__stories__/image.stories.tsx +2 -2
- package/src/widgets/__stories__/input-number.stories.tsx +3 -12
- package/src/widgets/__stories__/interaction.stories.tsx +1 -1
- package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
- package/src/widgets/__stories__/matcher.stories.tsx +1 -1
- package/src/widgets/__stories__/matrix.stories.tsx +1 -1
- package/src/widgets/__stories__/number-line.stories.tsx +1 -1
- package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
- package/src/widgets/__stories__/orderer.stories.tsx +1 -1
- package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
- package/src/widgets/__stories__/passage.stories.tsx +3 -9
- package/src/widgets/__stories__/radio.stories.tsx +3 -5
- package/src/widgets/__stories__/sorter.stories.tsx +1 -1
- package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx} +15 -57
- package/src/widgets/__stories__/transformer.stories.tsx +1 -1
- package/src/widgets/__stories__/unit.stories.tsx +1 -3
- package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
- package/src/widgets/__stories__/video.stories.tsx +1 -1
- package/src/widgets/__testdata__/expression.testdata.ts +16 -12
- package/src/widgets/__testdata__/group.testdata.ts +0 -2
- package/src/widgets/__testdata__/numeric-input.testdata.ts +0 -1
- package/src/widgets/__testdata__/transformer.testdata.ts +0 -1
- package/src/widgets/__tests__/group.test.tsx +0 -2
- package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
- package/src/widgets/__tests__/radio.test.ts +1 -1
- package/src/widgets/expression.tsx +4 -4
- package/src/widgets/graded-group-set.tsx +0 -4
- package/src/widgets/graded-group.tsx +0 -4
- package/src/widgets/grapher/util.tsx +1 -5
- package/src/widgets/grapher.tsx +0 -5
- package/src/widgets/group.tsx +0 -1
- package/src/widgets/interaction/element-container.tsx +7 -8
- package/src/widgets/interaction.tsx +0 -1
- package/src/widgets/interactive-graph.tsx +3 -62
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
- package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
- package/src/widgets/label-image/marker.tsx +4 -4
- package/src/widgets/label-image.tsx +1 -1
- package/src/widgets/measurer.tsx +0 -1
- package/src/widgets/number-line.tsx +0 -2
- package/src/widgets/numeric-input.tsx +0 -3
- package/src/widgets/orderer.tsx +0 -3
- package/src/widgets/passage/passage-markdown.tsx +3 -3
- package/src/widgets/passage-ref-target.tsx +0 -1
- package/src/widgets/passage.tsx +1 -1
- package/src/widgets/plotter.tsx +0 -1
- package/src/widgets/radio/__stories__/base-radio.stories.tsx +13 -21
- package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
- package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
- package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
- package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
- package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
- package/src/widgets/radio/base-radio.tsx +2 -2
- package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
- package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
- package/src/widgets/radio/choice-none-above.tsx +2 -2
- package/src/widgets/radio/choice.tsx +1 -3
- package/src/widgets/radio/focus-ring.tsx +1 -1
- package/src/widgets/radio/option-status.tsx +2 -4
- package/src/widgets/radio/widget.tsx +0 -1
- package/src/widgets/reaction-diagram.tsx +2 -2
- package/src/widgets/transformer.tsx +1 -16
- package/src/widgets/video-transcript-link.tsx +1 -1
- package/src/widgets.ts +1 -1
- package/src/zoom.ts +0 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,29 +1,129 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {ItemRendererWithDebugUI} from "../../../../../testing/item-renderer-with-debug-ui";
|
|
4
|
+
import KeypadContext from "../../keypad-context";
|
|
4
5
|
import {
|
|
5
6
|
expressionItem2,
|
|
6
7
|
expressionItem3,
|
|
7
8
|
} from "../__testdata__/expression.testdata";
|
|
9
|
+
import expressionExport from "../expression";
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
import TestKeypadContext from "./test-keypad-context-wrapper";
|
|
12
|
+
|
|
13
|
+
import type {PerseusItem} from "../../perseus-types";
|
|
14
|
+
|
|
15
|
+
type StoryArgs = {
|
|
16
|
+
customKeypad: boolean;
|
|
17
|
+
};
|
|
10
18
|
|
|
11
19
|
type Story = {
|
|
12
20
|
title: string;
|
|
21
|
+
argTypes: any;
|
|
13
22
|
};
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
type WrappedKeypadContextProps = {
|
|
25
|
+
item: PerseusItem;
|
|
26
|
+
customKeypad: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const WrappedKeypadContext = (props: WrappedKeypadContextProps) => {
|
|
30
|
+
return (
|
|
31
|
+
<TestKeypadContext>
|
|
32
|
+
<KeypadContext.Consumer>
|
|
33
|
+
{({keypadElement, setRenderer, scrollableElement}) => {
|
|
34
|
+
return (
|
|
35
|
+
<ItemRendererWithDebugUI
|
|
36
|
+
item={props.item}
|
|
37
|
+
apiOptions={{
|
|
38
|
+
customKeypad: props.customKeypad,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}}
|
|
43
|
+
</KeypadContext.Consumer>
|
|
44
|
+
</TestKeypadContext>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const DesktopKitchenSink = (args: StoryArgs): React.ReactElement => {
|
|
49
|
+
const reviewModeRubric = {
|
|
50
|
+
functions: ["f", "g", "h"],
|
|
51
|
+
times: true,
|
|
52
|
+
answerForms: [],
|
|
53
|
+
buttonSets: [
|
|
54
|
+
"basic",
|
|
55
|
+
"basic+div",
|
|
56
|
+
"trig",
|
|
57
|
+
"prealgebra",
|
|
58
|
+
"logarithms",
|
|
59
|
+
"basic relations",
|
|
60
|
+
"advanced relations",
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const keypadConfiguration = {
|
|
65
|
+
keypadType: "EXPRESSION",
|
|
66
|
+
extraKeys: ["x", "y", "z"],
|
|
67
|
+
};
|
|
18
68
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
69
|
+
return (
|
|
70
|
+
<div style={{padding: "2rem"}}>
|
|
71
|
+
<expressionExport.widget
|
|
72
|
+
alignment={null}
|
|
73
|
+
value=""
|
|
74
|
+
containerSizeClass="small"
|
|
75
|
+
findWidgets={(callback) => []}
|
|
76
|
+
isLastUsedWidget={false}
|
|
77
|
+
onChange={() => {}}
|
|
78
|
+
problemNum={1}
|
|
79
|
+
static={false}
|
|
80
|
+
trackInteraction={() => {}}
|
|
81
|
+
widgetId="expression"
|
|
82
|
+
reviewModeRubric={reviewModeRubric}
|
|
83
|
+
keypadConfiguration={keypadConfiguration}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
23
87
|
};
|
|
24
88
|
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
): React.ReactElement => {
|
|
28
|
-
return <RendererWithDebugUI question={expressionItem3.question} />;
|
|
89
|
+
export const Desktop = (args: StoryArgs): React.ReactElement => {
|
|
90
|
+
return <WrappedKeypadContext item={expressionItem3} customKeypad={false} />;
|
|
29
91
|
};
|
|
92
|
+
|
|
93
|
+
export const Mobile = (args: StoryArgs): React.ReactElement => {
|
|
94
|
+
return (
|
|
95
|
+
<div>
|
|
96
|
+
<p>
|
|
97
|
+
For some reason you need to be{" "}
|
|
98
|
+
<a href="https://developer.chrome.com/docs/devtools/device-mode/">
|
|
99
|
+
emulating mobile
|
|
100
|
+
</a>{" "}
|
|
101
|
+
to see the custom keypad.
|
|
102
|
+
</p>
|
|
103
|
+
<WrappedKeypadContext item={expressionItem3} customKeypad={true} />
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const ExpressionItem2 = (args: StoryArgs): React.ReactElement => {
|
|
109
|
+
return (
|
|
110
|
+
<WrappedKeypadContext
|
|
111
|
+
item={expressionItem2}
|
|
112
|
+
customKeypad={args.customKeypad}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const ExpressionItem3 = (args: StoryArgs): React.ReactElement => {
|
|
118
|
+
return (
|
|
119
|
+
<WrappedKeypadContext
|
|
120
|
+
item={expressionItem3}
|
|
121
|
+
customKeypad={args.customKeypad}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default {
|
|
127
|
+
title: "Perseus/Widgets/Expression",
|
|
128
|
+
argTypes: {customKeypad: {control: "boolean"}},
|
|
129
|
+
} as Story;
|
|
@@ -12,7 +12,7 @@ type GradedGroupSetStory = {
|
|
|
12
12
|
args: StoryArgs;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const Article1
|
|
15
|
+
export const Article1 = (args: StoryArgs): React.ReactElement => {
|
|
16
16
|
return (
|
|
17
17
|
<RendererWithDebugUI
|
|
18
18
|
apiOptions={{
|
|
@@ -17,44 +17,30 @@ export default {
|
|
|
17
17
|
|
|
18
18
|
type StoryArgs = Record<any, any>;
|
|
19
19
|
|
|
20
|
-
export const AbsoluteValueQuestion: React.
|
|
21
|
-
args,
|
|
22
|
-
): React.ReactElement => {
|
|
20
|
+
export const AbsoluteValueQuestion = (args: StoryArgs): React.ReactElement => {
|
|
23
21
|
return <RendererWithDebugUI question={absoluteValueQuestion} />;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
export const ExponentialQuestion: React.
|
|
27
|
-
args,
|
|
28
|
-
): React.ReactElement => {
|
|
24
|
+
export const ExponentialQuestion = (args: StoryArgs): React.ReactElement => {
|
|
29
25
|
return <RendererWithDebugUI question={exponentialQuestion} />;
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
export const LinearQuestion: React.
|
|
33
|
-
args,
|
|
34
|
-
): React.ReactElement => {
|
|
28
|
+
export const LinearQuestion = (args: StoryArgs): React.ReactElement => {
|
|
35
29
|
return <RendererWithDebugUI question={linearQuestion} />;
|
|
36
30
|
};
|
|
37
31
|
|
|
38
|
-
export const LogarithmQuestion: React.
|
|
39
|
-
args,
|
|
40
|
-
): React.ReactElement => {
|
|
32
|
+
export const LogarithmQuestion = (args: StoryArgs): React.ReactElement => {
|
|
41
33
|
return <RendererWithDebugUI question={logarithmQuestion} />;
|
|
42
34
|
};
|
|
43
35
|
|
|
44
|
-
export const QuadraticQuestion: React.
|
|
45
|
-
args,
|
|
46
|
-
): React.ReactElement => {
|
|
36
|
+
export const QuadraticQuestion = (args: StoryArgs): React.ReactElement => {
|
|
47
37
|
return <RendererWithDebugUI question={quadraticQuestion} />;
|
|
48
38
|
};
|
|
49
39
|
|
|
50
|
-
export const SinusoidQuestion: React.
|
|
51
|
-
args,
|
|
52
|
-
): React.ReactElement => {
|
|
40
|
+
export const SinusoidQuestion = (args: StoryArgs): React.ReactElement => {
|
|
53
41
|
return <RendererWithDebugUI question={sinusoidQuestion} />;
|
|
54
42
|
};
|
|
55
43
|
|
|
56
|
-
export const ComplexQuestion: React.
|
|
57
|
-
args,
|
|
58
|
-
): React.ReactElement => {
|
|
44
|
+
export const ComplexQuestion = (args: StoryArgs): React.ReactElement => {
|
|
59
45
|
return <RendererWithDebugUI question={multipleAvailableTypesQuestion} />;
|
|
60
46
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ type ImageStory = {
|
|
|
16
16
|
args: StoryArgs;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const Question1
|
|
19
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
20
20
|
const apiOptions: APIOptions = {
|
|
21
21
|
isMobile: args.isMobile,
|
|
22
22
|
};
|
|
@@ -31,7 +31,7 @@ export const Question1: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
31
31
|
options:
|
|
32
32
|
// `options` is nullable so we have handle it explicitly
|
|
33
33
|
// to avoid spreading `null` and generating
|
|
34
|
-
// hard-to-understand
|
|
34
|
+
// hard-to-understand type errors about missing keys
|
|
35
35
|
// in object literal.
|
|
36
36
|
imageOptions != null
|
|
37
37
|
? {
|
|
@@ -82,29 +82,20 @@ const updateWidgetOptions = (
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const Rational: React.
|
|
86
|
-
args,
|
|
87
|
-
): React.ReactElement => {
|
|
85
|
+
export const Rational = (args: InputNumberOptions): React.ReactElement => {
|
|
88
86
|
const question = updateWidgetOptions(question1, "input-number 1", args);
|
|
89
87
|
return <RendererWithDebugUI question={question} />;
|
|
90
88
|
};
|
|
91
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
92
89
|
Rational.args = question1.widgets["input-number 1"].options;
|
|
93
90
|
|
|
94
|
-
export const PiSimplify: React.
|
|
95
|
-
args,
|
|
96
|
-
): React.ReactElement => {
|
|
91
|
+
export const PiSimplify = (args: InputNumberOptions): React.ReactElement => {
|
|
97
92
|
const question = updateWidgetOptions(question2, "input-number 1", args);
|
|
98
93
|
return <RendererWithDebugUI question={question} />;
|
|
99
94
|
};
|
|
100
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
101
95
|
PiSimplify.args = question2.widgets["input-number 1"].options;
|
|
102
96
|
|
|
103
|
-
export const Percent: React.
|
|
104
|
-
args,
|
|
105
|
-
): React.ReactElement => {
|
|
97
|
+
export const Percent = (args: InputNumberOptions): React.ReactElement => {
|
|
106
98
|
const question = updateWidgetOptions(question3, "input-number 1", args);
|
|
107
99
|
return <RendererWithDebugUI question={question} />;
|
|
108
100
|
};
|
|
109
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
110
101
|
Percent.args = question3.widgets["input-number 1"].options;
|
|
@@ -19,39 +19,39 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
type StoryArgs = Record<any, any>;
|
|
21
21
|
|
|
22
|
-
export const Angle
|
|
22
|
+
export const Angle = (args: StoryArgs): React.ReactElement => (
|
|
23
23
|
<RendererWithDebugUI question={angleQuestion} />
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
export const Circle
|
|
26
|
+
export const Circle = (args: StoryArgs): React.ReactElement => (
|
|
27
27
|
<RendererWithDebugUI question={circleQuestion} />
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
export const Linear
|
|
30
|
+
export const Linear = (args: StoryArgs): React.ReactElement => (
|
|
31
31
|
<RendererWithDebugUI question={linearQuestion} />
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
export const LinearSystem
|
|
34
|
+
export const LinearSystem = (args: StoryArgs): React.ReactElement => (
|
|
35
35
|
<RendererWithDebugUI question={linearSystemQuestion} />
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
export const Point
|
|
38
|
+
export const Point = (args: StoryArgs): React.ReactElement => (
|
|
39
39
|
<RendererWithDebugUI question={pointQuestion} />
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
export const Polygon
|
|
42
|
+
export const Polygon = (args: StoryArgs): React.ReactElement => (
|
|
43
43
|
<RendererWithDebugUI question={polygonQuestion} />
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
export const Ray
|
|
46
|
+
export const Ray = (args: StoryArgs): React.ReactElement => (
|
|
47
47
|
<RendererWithDebugUI question={rayQuestion} />
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
export const Segment
|
|
50
|
+
export const Segment = (args: StoryArgs): React.ReactElement => (
|
|
51
51
|
<RendererWithDebugUI question={segmentQuestion} />
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
export const Sinusoid
|
|
54
|
+
export const Sinusoid = (args: StoryArgs): React.ReactElement => (
|
|
55
55
|
<RendererWithDebugUI question={sinusoidQuestion} />
|
|
56
56
|
);
|
|
57
57
|
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -62,13 +62,13 @@ export const Question1 = (): React.ReactElement => {
|
|
|
62
62
|
return <RendererWithDebugUI question={question1} />;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
export const Interactive
|
|
65
|
+
export const Interactive = (args: StoryArgs): React.ReactElement => {
|
|
66
66
|
const props = generateProps(args);
|
|
67
67
|
|
|
68
68
|
return <NumericInput {...props} />;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
export const Sizes
|
|
71
|
+
export const Sizes = (args: StoryArgs): React.ReactElement => {
|
|
72
72
|
const smallProps = generateProps({...args, size: "small"});
|
|
73
73
|
const normalProps = generateProps({...args, size: "normal"});
|
|
74
74
|
|
|
@@ -86,9 +86,7 @@ export const Sizes: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
export const TextAlignment: React.
|
|
90
|
-
args,
|
|
91
|
-
): React.ReactElement => {
|
|
89
|
+
export const TextAlignment = (args: StoryArgs): React.ReactElement => {
|
|
92
90
|
const leftProps = generateProps({...args, rightAlign: false});
|
|
93
91
|
const rightProps = generateProps({...args, rightAlign: true});
|
|
94
92
|
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -13,10 +13,10 @@ export default {
|
|
|
13
13
|
title: "Perseus/Widgets/PassageRef",
|
|
14
14
|
} as Story;
|
|
15
15
|
|
|
16
|
-
export const ShortPassage
|
|
16
|
+
export const ShortPassage = (args: StoryArgs): React.ReactElement => {
|
|
17
17
|
return <RendererWithDebugUI question={question1} />;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const LongPassage
|
|
20
|
+
export const LongPassage = (args: StoryArgs): React.ReactElement => {
|
|
21
21
|
return <RendererWithDebugUI question={question2} />;
|
|
22
22
|
};
|
|
@@ -13,20 +13,14 @@ export default {
|
|
|
13
13
|
|
|
14
14
|
type StoryArgs = Record<any, any>;
|
|
15
15
|
|
|
16
|
-
export const SimpleQuestion: React.
|
|
17
|
-
args,
|
|
18
|
-
): React.ReactElement => {
|
|
16
|
+
export const SimpleQuestion = (args: StoryArgs): React.ReactElement => {
|
|
19
17
|
return <RendererWithDebugUI question={question1} />;
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
export const MultiPassageQuestion: React.
|
|
23
|
-
args,
|
|
24
|
-
): React.ReactElement => {
|
|
20
|
+
export const MultiPassageQuestion = (args: StoryArgs): React.ReactElement => {
|
|
25
21
|
return <RendererWithDebugUI question={question2} />;
|
|
26
22
|
};
|
|
27
23
|
|
|
28
|
-
export const SingleNumberedPassage: React.
|
|
29
|
-
args,
|
|
30
|
-
): React.ReactElement => {
|
|
24
|
+
export const SingleNumberedPassage = (args: StoryArgs): React.ReactElement => {
|
|
31
25
|
return <RendererWithDebugUI question={question3} />;
|
|
32
26
|
};
|
|
@@ -55,7 +55,7 @@ const buildApiOptions = (args: StoryArgs): APIOptions => {
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
export const SingleSelect
|
|
58
|
+
export const SingleSelect = (args: StoryArgs): React.ReactElement => {
|
|
59
59
|
return (
|
|
60
60
|
<RendererWithDebugUI
|
|
61
61
|
question={applyStoryArgs(questionWithPassage, args)}
|
|
@@ -65,9 +65,7 @@ export const SingleSelect: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
65
65
|
);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export const MultiSelectSimple: React.
|
|
69
|
-
args,
|
|
70
|
-
): React.ReactElement => {
|
|
68
|
+
export const MultiSelectSimple = (args: StoryArgs): React.ReactElement => {
|
|
71
69
|
return (
|
|
72
70
|
<RendererWithDebugUI
|
|
73
71
|
question={applyStoryArgs(multiChoiceQuestionSimple, args)}
|
|
@@ -77,7 +75,7 @@ export const MultiSelectSimple: React.FC<StoryArgs> = (
|
|
|
77
75
|
);
|
|
78
76
|
};
|
|
79
77
|
|
|
80
|
-
export const MultiSelect
|
|
78
|
+
export const MultiSelect = (args: StoryArgs): React.ReactElement => {
|
|
81
79
|
return (
|
|
82
80
|
<RendererWithDebugUI
|
|
83
81
|
question={applyStoryArgs(multiChoiceQuestion, args)}
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx}
RENAMED
|
@@ -3,60 +3,11 @@ import {View} from "@khanacademy/wonder-blocks-core";
|
|
|
3
3
|
import {StyleSheet} from "aphrodite";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
|
|
6
|
-
import {ItemRenderer} from "../../index";
|
|
7
6
|
import KeypadContext from "../../keypad-context";
|
|
8
|
-
import {expressionItem3} from "../__testdata__/expression.testdata";
|
|
9
|
-
|
|
10
|
-
type StoryArgs = Record<any, any>;
|
|
11
|
-
|
|
12
|
-
type Story = {
|
|
13
|
-
title: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: "Perseus/Demos/On Screen Keypad",
|
|
18
|
-
} as Story;
|
|
19
|
-
|
|
20
|
-
const Content = (): React.ReactElement => {
|
|
21
|
-
return (
|
|
22
|
-
<KeypadContext.Consumer>
|
|
23
|
-
{({keypadElement, setRenderer, scrollableElement}) => (
|
|
24
|
-
<>
|
|
25
|
-
<ItemRenderer
|
|
26
|
-
ref={setRenderer}
|
|
27
|
-
problemNum={0}
|
|
28
|
-
apiOptions={{
|
|
29
|
-
customKeypad: true,
|
|
30
|
-
onFocusChange: (
|
|
31
|
-
newFocusPath,
|
|
32
|
-
oldFocusPath,
|
|
33
|
-
keypadElement,
|
|
34
|
-
focusedElement,
|
|
35
|
-
) => {},
|
|
36
|
-
}}
|
|
37
|
-
item={expressionItem3}
|
|
38
|
-
savedState={null}
|
|
39
|
-
/>
|
|
40
|
-
<div id="workarea" />
|
|
41
|
-
<div id="hintsarea" />
|
|
42
|
-
</>
|
|
43
|
-
)}
|
|
44
|
-
</KeypadContext.Consumer>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
7
|
|
|
48
8
|
const Footer = (): React.ReactElement => {
|
|
49
9
|
return (
|
|
50
|
-
<View
|
|
51
|
-
style={[
|
|
52
|
-
styles.keypadContainer,
|
|
53
|
-
{
|
|
54
|
-
// NOTE: in webapp we normally get this from problemProgress
|
|
55
|
-
// from the exercise state store.
|
|
56
|
-
height: 240,
|
|
57
|
-
},
|
|
58
|
-
]}
|
|
59
|
-
>
|
|
10
|
+
<View style={styles.keypadContainer}>
|
|
60
11
|
<KeypadContext.Consumer>
|
|
61
12
|
{({keypadElement, setKeypadElement, renderer}) => (
|
|
62
13
|
<Keypad
|
|
@@ -70,9 +21,13 @@ const Footer = (): React.ReactElement => {
|
|
|
70
21
|
);
|
|
71
22
|
};
|
|
72
23
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
24
|
+
type Props = {
|
|
25
|
+
children: React.ReactElement;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const TestKeypadContextWrapper = (props: Props): React.ReactElement => {
|
|
29
|
+
const [keypadElement, setKeypadElement] = React.useState(null);
|
|
30
|
+
const [renderer, setRenderer] = React.useState(null);
|
|
76
31
|
const [scrollableElement, setScrollableElement] = React.useState(
|
|
77
32
|
document.body,
|
|
78
33
|
);
|
|
@@ -80,8 +35,10 @@ const Demo = () => {
|
|
|
80
35
|
return (
|
|
81
36
|
<KeypadContext.Provider
|
|
82
37
|
value={{
|
|
38
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Dispatch<SetStateAction<HTMLElement>>' is not assignable to type '(scrollableElement?: HTMLElement | null | undefined) => void'.
|
|
83
39
|
setKeypadElement,
|
|
84
40
|
keypadElement,
|
|
41
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Dispatch<SetStateAction<HTMLElement>>' is not assignable to type '(scrollableElement?: HTMLElement | null | undefined) => void'.
|
|
85
42
|
setRenderer,
|
|
86
43
|
renderer,
|
|
87
44
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Dispatch<SetStateAction<HTMLElement>>' is not assignable to type '(scrollableElement?: HTMLElement | null | undefined) => void'.
|
|
@@ -89,15 +46,13 @@ const Demo = () => {
|
|
|
89
46
|
scrollableElement,
|
|
90
47
|
}}
|
|
91
48
|
>
|
|
92
|
-
|
|
49
|
+
{props.children}
|
|
93
50
|
<Footer />
|
|
94
51
|
</KeypadContext.Provider>
|
|
95
52
|
);
|
|
96
53
|
};
|
|
97
54
|
|
|
98
|
-
export
|
|
99
|
-
<Demo />
|
|
100
|
-
);
|
|
55
|
+
export default TestKeypadContextWrapper;
|
|
101
56
|
|
|
102
57
|
const styles = StyleSheet.create({
|
|
103
58
|
keypad: {
|
|
@@ -116,5 +71,8 @@ const styles = StyleSheet.create({
|
|
|
116
71
|
// Prevent container from swallowing events that the exercise
|
|
117
72
|
// below it needs to respond to.
|
|
118
73
|
pointerEvents: "none",
|
|
74
|
+
// NOTE: in webapp we normally get this from problemProgress
|
|
75
|
+
// from the exercise state store.
|
|
76
|
+
height: 240,
|
|
119
77
|
},
|
|
120
78
|
});
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question
|
|
12
|
+
export const Question = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question} />;
|
|
14
14
|
};
|
|
@@ -13,9 +13,7 @@ export default {
|
|
|
13
13
|
title: "Perseus/Widgets/Unit",
|
|
14
14
|
} as Story;
|
|
15
15
|
|
|
16
|
-
export const NonStaticRender: React.
|
|
17
|
-
args,
|
|
18
|
-
): React.ReactElement => {
|
|
16
|
+
export const NonStaticRender = (args: StoryArgs): React.ReactElement => {
|
|
19
17
|
return (
|
|
20
18
|
<OldUnitInput
|
|
21
19
|
apiOptions={{
|
|
@@ -12,16 +12,12 @@ export default {
|
|
|
12
12
|
title: "Perseus/Components/Video Transcript Link",
|
|
13
13
|
} as Story;
|
|
14
14
|
|
|
15
|
-
export const YoutubeVideoLink: React.
|
|
16
|
-
args,
|
|
17
|
-
): React.ReactElement => {
|
|
15
|
+
export const YoutubeVideoLink = (args: StoryArgs): React.ReactElement => {
|
|
18
16
|
return (
|
|
19
17
|
<VideoTranscriptLink location="https://www.youtube.com/watch?v=YoutubeId" />
|
|
20
18
|
);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
export const SlugVideoLink: React.
|
|
24
|
-
args,
|
|
25
|
-
): React.ReactElement => {
|
|
21
|
+
export const SlugVideoLink = (args: StoryArgs): React.ReactElement => {
|
|
26
22
|
return <VideoTranscriptLink location="slug-video-id" />;
|
|
27
23
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|