@khanacademy/perseus-editor 4.1.5 → 4.1.7

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 (175) hide show
  1. package/dist/es/index.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/package.json +9 -6
  4. package/.babelrc.js +0 -8
  5. package/.eslintrc.js +0 -12
  6. package/CHANGELOG.md +0 -1155
  7. package/src/README.md +0 -7
  8. package/src/__stories__/editor-page.stories.tsx +0 -65
  9. package/src/__stories__/editor.stories.tsx +0 -134
  10. package/src/__stories__/item-editor.stories.tsx +0 -41
  11. package/src/__stories__/tex-error-view.stories.tsx +0 -26
  12. package/src/__testdata__/input-number.testdata.ts +0 -27
  13. package/src/__tests__/editor.test.tsx +0 -142
  14. package/src/__tests__/hint-editor.test.tsx +0 -83
  15. package/src/__tests__/i18n.test.ts +0 -501
  16. package/src/__tests__/integration.test.ts +0 -5
  17. package/src/__tests__/item-extras-editor.test.tsx +0 -85
  18. package/src/__tests__/traversal.test.ts +0 -377
  19. package/src/all-editors.test.ts +0 -16
  20. package/src/all-editors.ts +0 -83
  21. package/src/all-widgets.ts +0 -7
  22. package/src/article-editor.tsx +0 -438
  23. package/src/components/__stories__/blur-input.stories.tsx +0 -22
  24. package/src/components/__stories__/section-control-button.stories.tsx +0 -26
  25. package/src/components/__tests__/blur-input.test.tsx +0 -67
  26. package/src/components/blur-input.tsx +0 -69
  27. package/src/components/checkbox.tsx +0 -194
  28. package/src/components/device-framer.tsx +0 -90
  29. package/src/components/drag-target.tsx +0 -87
  30. package/src/components/dropdown-option.tsx +0 -311
  31. package/src/components/form-wrapped-text-field.tsx +0 -245
  32. package/src/components/graph-points-count-selector.tsx +0 -31
  33. package/src/components/graph-settings.tsx +0 -627
  34. package/src/components/graph-type-selector.tsx +0 -31
  35. package/src/components/hover-behavior.ts +0 -177
  36. package/src/components/json-editor.tsx +0 -121
  37. package/src/components/link.ts +0 -173
  38. package/src/components/section-control-button.tsx +0 -53
  39. package/src/components/segment-count-selector.tsx +0 -27
  40. package/src/components/simple-button.tsx +0 -85
  41. package/src/components/sortable.tsx +0 -187
  42. package/src/components/util.ts +0 -38
  43. package/src/components/viewport-resizer.tsx +0 -72
  44. package/src/components/widget-editor.tsx +0 -222
  45. package/src/components/widget-select.tsx +0 -48
  46. package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
  47. package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
  48. package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
  49. package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
  50. package/src/diffs/__tests__/split-diff.test.ts +0 -33
  51. package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
  52. package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
  53. package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
  54. package/src/diffs/article-diff.tsx +0 -69
  55. package/src/diffs/item-diff.tsx +0 -76
  56. package/src/diffs/renderer-diff.tsx +0 -137
  57. package/src/diffs/split-diff.ts +0 -31
  58. package/src/diffs/string-array-diff.ts +0 -74
  59. package/src/diffs/structured-item-diff.tsx +0 -275
  60. package/src/diffs/tags-diff.tsx +0 -49
  61. package/src/diffs/text-diff.tsx +0 -193
  62. package/src/diffs/widget-diff-performer.ts +0 -69
  63. package/src/diffs/widget-diff.tsx +0 -290
  64. package/src/editor-page.tsx +0 -325
  65. package/src/editor.tsx +0 -1099
  66. package/src/hint-editor.tsx +0 -469
  67. package/src/i18n.ts +0 -140
  68. package/src/iframe-content-renderer.tsx +0 -188
  69. package/src/index.ts +0 -30
  70. package/src/item-editor.tsx +0 -158
  71. package/src/item-extras-editor.tsx +0 -230
  72. package/src/katex-mhchem/index.js +0 -73
  73. package/src/katex-mhchem/parser.js +0 -2659
  74. package/src/multirenderer-editor.tsx +0 -1061
  75. package/src/stateful-article-editor.tsx +0 -173
  76. package/src/stateful-editor-page.tsx +0 -88
  77. package/src/styles/perseus-editor.less +0 -1321
  78. package/src/testing-widgets.ts +0 -11
  79. package/src/tex-error-view.tsx +0 -90
  80. package/src/util/points.test.ts +0 -24
  81. package/src/util/points.ts +0 -13
  82. package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
  83. package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
  84. package/src/version.ts +0 -10
  85. package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
  86. package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
  87. package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
  88. package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
  89. package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
  90. package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
  91. package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
  92. package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
  93. package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
  94. package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
  95. package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
  96. package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
  97. package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
  98. package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
  99. package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
  100. package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
  101. package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
  102. package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
  103. package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
  104. package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
  105. package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
  106. package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
  107. package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
  108. package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
  109. package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
  110. package/src/widgets/categorizer-editor.tsx +0 -104
  111. package/src/widgets/cs-program-editor.tsx +0 -256
  112. package/src/widgets/definition-editor.tsx +0 -77
  113. package/src/widgets/deprecated-standin-editor.tsx +0 -29
  114. package/src/widgets/dropdown-editor.tsx +0 -211
  115. package/src/widgets/example-graphie-widget-editor.tsx +0 -70
  116. package/src/widgets/example-graphie-widget.tsx +0 -172
  117. package/src/widgets/example-widget-editor.tsx +0 -62
  118. package/src/widgets/example-widget.tsx +0 -154
  119. package/src/widgets/explanation-editor.tsx +0 -92
  120. package/src/widgets/expression-editor.tsx +0 -557
  121. package/src/widgets/graded-group-editor.tsx +0 -161
  122. package/src/widgets/graded-group-set-editor.tsx +0 -104
  123. package/src/widgets/grapher-editor.tsx +0 -155
  124. package/src/widgets/group-editor.tsx +0 -83
  125. package/src/widgets/iframe-editor.tsx +0 -202
  126. package/src/widgets/image-editor.tsx +0 -367
  127. package/src/widgets/input-number-editor.tsx +0 -288
  128. package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
  129. package/src/widgets/interaction-editor/function-editor.tsx +0 -108
  130. package/src/widgets/interaction-editor/index.ts +0 -3
  131. package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
  132. package/src/widgets/interaction-editor/label-editor.tsx +0 -87
  133. package/src/widgets/interaction-editor/line-editor.tsx +0 -125
  134. package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
  135. package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
  136. package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
  137. package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
  138. package/src/widgets/interaction-editor/point-editor.tsx +0 -72
  139. package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
  140. package/src/widgets/interactive-graph-editor.tsx +0 -571
  141. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
  142. package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
  143. package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
  144. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
  145. package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
  146. package/src/widgets/label-image/answer-choices.tsx +0 -231
  147. package/src/widgets/label-image/behavior.tsx +0 -122
  148. package/src/widgets/label-image/marker.tsx +0 -290
  149. package/src/widgets/label-image/question-markers.tsx +0 -176
  150. package/src/widgets/label-image/select-image.tsx +0 -81
  151. package/src/widgets/label-image-editor.tsx +0 -252
  152. package/src/widgets/lights-puzzle-editor.tsx +0 -278
  153. package/src/widgets/matcher-editor.tsx +0 -149
  154. package/src/widgets/matrix-editor.tsx +0 -156
  155. package/src/widgets/measurer-editor.tsx +0 -253
  156. package/src/widgets/molecule-editor.tsx +0 -64
  157. package/src/widgets/number-line-editor.tsx +0 -512
  158. package/src/widgets/numeric-input-editor.tsx +0 -536
  159. package/src/widgets/orderer-editor.tsx +0 -172
  160. package/src/widgets/passage-editor.tsx +0 -117
  161. package/src/widgets/passage-ref-editor.tsx +0 -80
  162. package/src/widgets/passage-ref-target-editor.tsx +0 -49
  163. package/src/widgets/plotter-editor.tsx +0 -542
  164. package/src/widgets/radio/editor.tsx +0 -398
  165. package/src/widgets/reaction-diagram-editor.tsx +0 -131
  166. package/src/widgets/sequence-editor.tsx +0 -205
  167. package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
  168. package/src/widgets/simple-markdown-tester.tsx +0 -92
  169. package/src/widgets/simulator-editor.tsx +0 -146
  170. package/src/widgets/sorter-editor.tsx +0 -103
  171. package/src/widgets/table-editor.tsx +0 -164
  172. package/src/widgets/unit-editor.tsx +0 -299
  173. package/src/widgets/video-editor.tsx +0 -73
  174. package/tsconfig-build.json +0 -22
  175. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,512 +0,0 @@
1
- /* eslint-disable @khanacademy/ts-no-error-suppressions */
2
- import {number as knumber} from "@khanacademy/kmath";
3
- import {components, EditorJsonify} from "@khanacademy/perseus";
4
- import PropTypes from "prop-types";
5
- import * as React from "react";
6
- import _ from "underscore";
7
-
8
- const {ButtonGroup, InfoTip, NumberInput, PropCheckBox, RangeInput} =
9
- components;
10
-
11
- type Range = [number, number];
12
-
13
- const bound = (x: number, gt: number, lt: number): number =>
14
- Math.min(Math.max(x, gt), lt);
15
-
16
- const EN_DASH = "\u2013";
17
-
18
- type Props = any;
19
-
20
- class NumberLineEditor extends React.Component<Props> {
21
- static propTypes = {
22
- range: PropTypes.arrayOf(PropTypes.number).isRequired,
23
-
24
- labelRange: PropTypes.arrayOf(PropTypes.number).isRequired,
25
- labelStyle: PropTypes.string.isRequired,
26
- labelTicks: PropTypes.bool,
27
-
28
- divisionRange: PropTypes.arrayOf(PropTypes.number).isRequired,
29
- numDivisions: PropTypes.number.isRequired,
30
- snapDivisions: PropTypes.number,
31
-
32
- tickStep: PropTypes.number,
33
- correctRel: PropTypes.oneOf(["lt", "gt", "le", "ge", "eq"]),
34
- correctX: PropTypes.number,
35
- initialX: PropTypes.number,
36
- isTickCtrl: PropTypes.bool,
37
-
38
- onChange: PropTypes.func.isRequired,
39
-
40
- static: PropTypes.bool,
41
- showTooltips: PropTypes.bool,
42
- };
43
-
44
- static widgetName = "number-line" as const;
45
-
46
- static defaultProps: Props = {
47
- range: [0, 10],
48
-
49
- labelRange: [null, null],
50
- labelStyle: "decimal",
51
- labelTicks: true,
52
-
53
- divisionRange: [1, 12],
54
- numDivisions: 5,
55
- snapDivisions: 2,
56
-
57
- tickStep: null,
58
- correctRel: "eq",
59
- correctX: null,
60
- initialX: null,
61
-
62
- showTooltips: false,
63
- };
64
-
65
- onRangeChange: (arg1: Range) => void = (range) => {
66
- // Changing the range constrains the initial position, as well as the
67
- // position of the answer and labels. Atm, it just marks them as
68
- // invalid and prevents the number line from showing; it was annoying
69
- // to change it for them, because if they're typing in fractions,
70
- // it registers one-at-a-time and messes things up.
71
- this.props.onChange({range: range});
72
- };
73
-
74
- onLabelRangeChange: (arg1: number, arg2: number) => void = (i, num) => {
75
- let labelRange = this.props.labelRange.slice();
76
- const otherNum = labelRange[1 - i];
77
-
78
- if (num == null || otherNum == null) {
79
- labelRange[i] = num;
80
- } else {
81
- // If both labels have values, this updates the "appropriate" one.
82
- // It enforces that the position of the left label <= right label.
83
- // If left otherwise, it makes certain aspects of validation hard.
84
- labelRange = [Math.min(num, otherNum), Math.max(num, otherNum)];
85
- }
86
-
87
- this.props.onChange({labelRange: labelRange});
88
- };
89
-
90
- onDivisionRangeChange: (arg1: Range) => void = (divisionRange) => {
91
- let numDivisions = this.props.numDivisions;
92
- numDivisions = bound(numDivisions, divisionRange[0], divisionRange[1]);
93
- this.props.onChange({
94
- divisionRange: divisionRange,
95
- numDivisions: numDivisions,
96
- });
97
- };
98
-
99
- onNumChange: (
100
- arg1: "correctX" | "initialX" | "snapDivisions",
101
- arg2: number,
102
- ) => void = (key, value) => {
103
- const opts: Record<string, any> = {};
104
- opts[key] = value;
105
- this.props.onChange(opts);
106
- };
107
-
108
- onNumDivisionsChange: (arg1: number) => void = (numDivisions) => {
109
- const divRange = this.props.divisionRange.slice();
110
-
111
- // Don't allow a fraction for the number of divisions
112
- numDivisions = _.isFinite(numDivisions) ? Math.round(numDivisions) : 0;
113
-
114
- // Don't allow negative numbers for the number of divisions
115
- numDivisions = numDivisions < 0 ? numDivisions * -1 : numDivisions;
116
-
117
- // If the number of divisions isn't blank, update the number line
118
- if (numDivisions) {
119
- // Constrain numDivisions to be within the allowed range
120
- numDivisions = Math.min(
121
- divRange[1],
122
- Math.max(divRange[0], numDivisions),
123
- );
124
-
125
- this.props.onChange({
126
- tickStep: null,
127
- divisionRange: divRange,
128
- numDivisions: numDivisions,
129
- });
130
- }
131
- };
132
-
133
- onTickStepChange: (arg1: number) => void = (tickStep) => {
134
- this.props.onChange({
135
- numDivisions: null,
136
- tickStep: tickStep,
137
- });
138
- };
139
-
140
- onChangeRelation: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
141
- e,
142
- ) => {
143
- const value = e.target.value;
144
- this.props.onChange({
145
- correctRel: value,
146
- isInequality: value !== "eq",
147
- });
148
- };
149
-
150
- onLabelStyleChange: (arg1: any) => void = (labelStyle) => {
151
- this.props.onChange({
152
- labelStyle: labelStyle,
153
- });
154
- };
155
-
156
- serialize: () => any = () => {
157
- return EditorJsonify.serialize.call(this);
158
- };
159
-
160
- render(): React.ReactNode {
161
- const range = this.props.range;
162
- const labelRange = this.props.labelRange;
163
- const divisionRange = this.props.divisionRange;
164
-
165
- range[0] = +range[0];
166
- range[1] = +range[1];
167
-
168
- const width = range[1] - range[0];
169
- const numDivisions = this.props.numDivisions;
170
- const snapDivisions = this.props.snapDivisions;
171
- const tickStep = this.props.tickStep;
172
- const isTickCtrl = this.props.isTickCtrl;
173
-
174
- let step;
175
- if (!isTickCtrl) {
176
- // this will help constrain the answer to what is reachable
177
- step = tickStep
178
- ? tickStep / snapDivisions
179
- : width / numDivisions / snapDivisions;
180
- } else {
181
- // but if tickCtrl is on, the range of what is reachable is
182
- // rather large, and it becomes obnoxious to check for this
183
- step = null;
184
- }
185
-
186
- const labelStyleEditorButtons = [
187
- {
188
- value: "decimal",
189
- content: "0.75",
190
- title: "Decimals",
191
- },
192
- {
193
- value: "improper",
194
- content: "\u2077\u2044\u2084",
195
- title: "Improper fractions",
196
- },
197
- {
198
- value: "mixed",
199
- content: "1\u00BE",
200
- title: "Mixed numbers",
201
- },
202
- {
203
- value: "non-reduced",
204
- content: "\u2078\u2044\u2084",
205
- title: "Non-reduced",
206
- },
207
- ];
208
-
209
- return (
210
- <div className="perseus-widget-number-line-editor">
211
- <div className="perseus-widget-row">
212
- Correct x{" "}
213
- <select
214
- value={this.props.correctRel}
215
- // @ts-expect-error - TS2322 - Type '(arg1: ChangeEvent<HTMLInputElement>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.
216
- onChange={this.onChangeRelation}
217
- aria-label="Select relationship"
218
- >
219
- <option value="eq" aria-label="Equal">
220
- =
221
- </option>
222
- <option value="lt" aria-label="Less than">
223
- &lt;
224
- </option>
225
- <option value="gt" aria-label="Greater than">
226
- &gt;
227
- </option>
228
- <option value="le" aria-label="Less than or equal">
229
- &le;
230
- </option>
231
- <option value="ge" aria-label="Greater than or equal">
232
- &ge;
233
- </option>
234
- </select>{" "}
235
- <NumberInput
236
- value={this.props.correctX}
237
- format={this.props.labelStyle}
238
- // eslint-disable-next-line react/jsx-no-bind
239
- onChange={this.onNumChange.bind(this, "correctX")}
240
- checkValidity={(val) =>
241
- val >= range[0] &&
242
- val <= range[1] &&
243
- (!step ||
244
- knumber.isInteger((val - range[0]) / step))
245
- }
246
- placeholder="answer"
247
- size="normal"
248
- useArrowKeys={true}
249
- />
250
- <InfoTip>
251
- <p>
252
- This is the correct answer. The answer is validated
253
- (as right or wrong) by using only the end position
254
- of the point and the relation (=, &lt;, &gt;, &le;,
255
- &ge;).
256
- </p>
257
- </InfoTip>
258
- </div>
259
-
260
- <div className="perseus-widget-row">
261
- {this.props.static ? (
262
- <label>
263
- {/* Don't display initial position input in
264
- static mode since it isn't used. */}
265
- Range:
266
- </label>
267
- ) : (
268
- <label>
269
- Position:{" "}
270
- <NumberInput
271
- value={this.props.initialX}
272
- format={this.props.labelStyle}
273
- // eslint-disable-next-line react/jsx-no-bind
274
- onChange={this.onNumChange.bind(
275
- this,
276
- "initialX",
277
- )}
278
- placeholder={range[0]}
279
- checkValidity={(val) => {
280
- return val >= range[0] && val <= range[1];
281
- }}
282
- useArrowKeys={true}
283
- />
284
- {" \u2208 "}
285
- </label>
286
- )}
287
-
288
- <RangeInput
289
- value={range}
290
- onChange={this.onRangeChange}
291
- format={this.props.labelStyle}
292
- useArrowKeys={true}
293
- />
294
- <InfoTip>
295
- <p>
296
- This controls the initial position of the point
297
- along the number line and the
298
- <strong>range</strong>, the position of the
299
- endpoints of the number line. Setting the range
300
- constrains the position of the answer and the
301
- labels.
302
- </p>
303
- <p>
304
- In static mode, the initial position of the point is
305
- determined by Correct x instead of position.
306
- </p>
307
- </InfoTip>
308
- </div>
309
- <div className="perseus-widget-row">
310
- <div className="perseus-widget-left-col">
311
- Labels:{" "}
312
- <NumberInput
313
- value={labelRange[0]}
314
- placeholder={range[0]}
315
- format={this.props.labelStyle}
316
- checkValidity={(val) =>
317
- val >= range[0] && val <= range[1]
318
- }
319
- // eslint-disable-next-line react/jsx-no-bind
320
- onChange={this.onLabelRangeChange.bind(this, 0)}
321
- useArrowKeys={true}
322
- />
323
- <span> &amp; </span>
324
- <NumberInput
325
- value={labelRange[1]}
326
- placeholder={range[1]}
327
- format={this.props.labelStyle}
328
- checkValidity={(val) =>
329
- val >= range[0] && val <= range[1]
330
- }
331
- // eslint-disable-next-line react/jsx-no-bind
332
- onChange={this.onLabelRangeChange.bind(this, 1)}
333
- useArrowKeys={true}
334
- />
335
- <InfoTip>
336
- <p>
337
- This controls the position of the left / right
338
- labels. By default, the labels are set by the
339
- range <br />
340
- <strong>Note:</strong> Ensure that the labels
341
- line up with the tick marks, or it may be
342
- confusing for users.
343
- </p>
344
- </InfoTip>
345
- </div>
346
- </div>
347
- <div className="perseus-widget-row">
348
- Style:{" "}
349
- <ButtonGroup
350
- allowEmpty={false}
351
- value={this.props.labelStyle}
352
- buttons={labelStyleEditorButtons}
353
- onChange={this.onLabelStyleChange}
354
- />
355
- <InfoTip>
356
- <p>
357
- This controls the styling of the labels for the two
358
- main labels as well as all the tick mark labels, if
359
- applicable. Your choices are decimal, improper
360
- fractions, mixed fractions, and non-reduced
361
- fractions.
362
- </p>
363
- </InfoTip>
364
- </div>
365
- <div className="perseus-widget-row">
366
- {!this.props.static && (
367
- <div className="perseus-widget-left-col">
368
- <PropCheckBox
369
- label="Show tick controller"
370
- isTickCtrl={this.props.isTickCtrl}
371
- onChange={this.props.onChange}
372
- />
373
- </div>
374
- )}
375
- <div className="perseus-widget-right-col">
376
- <PropCheckBox
377
- label="Show label ticks"
378
- labelTicks={this.props.labelTicks}
379
- onChange={this.props.onChange}
380
- />
381
- </div>
382
- </div>
383
-
384
- <div className="perseus-widget-row">
385
- {!this.props.static && (
386
- <PropCheckBox
387
- label="Show tooltips"
388
- showTooltips={this.props.showTooltips}
389
- onChange={this.props.onChange}
390
- />
391
- )}
392
- </div>
393
- <div className="perseus-widget-row">
394
- {isTickCtrl && (
395
- <span>
396
- <label>
397
- Start num divisions at{" "}
398
- <NumberInput
399
- value={this.props.numDivisions || null}
400
- format="decimal"
401
- onChange={this.onNumDivisionsChange}
402
- checkValidity={(val) => {
403
- return (
404
- val >= divisionRange[0] &&
405
- val <= divisionRange[1]
406
- );
407
- }}
408
- placeholder={width / this.props.tickStep}
409
- useArrowKeys={true}
410
- />
411
- </label>
412
- <InfoTip>
413
- <p>
414
- This controls the number (and position) of
415
- the tick marks. The number of divisions is
416
- constrained to
417
- {" " +
418
- divisionRange[0] +
419
- EN_DASH +
420
- divisionRange[1]}
421
- .
422
- <br />
423
- <strong>Note:</strong> The user will be able
424
- to specify the number of divisions in a
425
- number input.
426
- </p>
427
- </InfoTip>
428
- </span>
429
- )}
430
- {!isTickCtrl && (
431
- <span>
432
- <label>
433
- Num divisions:{" "}
434
- <NumberInput
435
- value={this.props.numDivisions || null}
436
- format="decimal"
437
- onChange={this.onNumDivisionsChange}
438
- checkValidity={(val) => {
439
- return (
440
- val >= divisionRange[0] &&
441
- val <= divisionRange[1]
442
- );
443
- }}
444
- placeholder={width / this.props.tickStep}
445
- useArrowKeys={true}
446
- />
447
- </label>{" "}
448
- <label>
449
- or tick step:{" "}
450
- <NumberInput
451
- value={this.props.tickStep || null}
452
- format={this.props.labelStyle}
453
- onChange={this.onTickStepChange}
454
- checkValidity={(val) => {
455
- return val > 0 && val <= width;
456
- }}
457
- placeholder={
458
- width / this.props.numDivisions
459
- }
460
- useArrowKeys={true}
461
- />
462
- </label>
463
- <InfoTip>
464
- <p>
465
- This controls the number (and position) of
466
- the tick marks; you can either set the
467
- number of divisions (2 divisions would split
468
- the entire range in two halves), or the tick
469
- step (the distance between ticks) and the
470
- other value will be updated accordingly.{" "}
471
- <br />
472
- <strong>Note:</strong> There is no check to
473
- see if labels coordinate with the tick
474
- marks, which may be confusing for users if
475
- the blue labels and black ticks are
476
- off-step.
477
- </p>
478
- </InfoTip>
479
- </span>
480
- )}
481
- </div>
482
- <div className="perseus-widget-row">
483
- <label>
484
- Snap increments per tick:{" "}
485
- <NumberInput
486
- value={snapDivisions}
487
- checkValidity={(val) => val > 0}
488
- format={this.props.labelStyle}
489
- // eslint-disable-next-line react/jsx-no-bind
490
- onChange={this.onNumChange.bind(
491
- this,
492
- "snapDivisions",
493
- )}
494
- useArrowKeys={true}
495
- />
496
- </label>
497
- <InfoTip>
498
- <p>
499
- This determines the number of different places the
500
- point will snap between two adjacent tick marks.{" "}
501
- <br />
502
- <strong>Note:</strong>Ensure the required number of
503
- snap increments is provided to answer the question.
504
- </p>
505
- </InfoTip>
506
- </div>
507
- </div>
508
- );
509
- }
510
- }
511
-
512
- export default NumberLineEditor;