@pie-lib/graphing 4.0.22 → 4.0.24-beta.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 (66) hide show
  1. package/CHANGELOG.md +0 -88
  2. package/lib/mark-label.js +7 -197
  3. package/lib/mark-label.js.map +1 -1
  4. package/lib/tools/circle/component.js +3 -34
  5. package/lib/tools/circle/component.js.map +1 -1
  6. package/lib/tools/point/component.js +8 -29
  7. package/lib/tools/point/component.js.map +1 -1
  8. package/lib/tools/polygon/component.js +6 -31
  9. package/lib/tools/polygon/component.js.map +1 -1
  10. package/lib/tools/shared/line/index.js +3 -34
  11. package/lib/tools/shared/line/index.js.map +1 -1
  12. package/package.json +17 -17
  13. package/src/mark-label.jsx +8 -209
  14. package/src/tools/circle/component.jsx +3 -26
  15. package/src/tools/point/component.jsx +8 -21
  16. package/src/tools/polygon/component.jsx +6 -24
  17. package/src/tools/shared/line/index.jsx +3 -26
  18. package/LICENSE.md +0 -5
  19. package/src/__tests__/bg.test.jsx +0 -250
  20. package/src/__tests__/coordinates-label.test.jsx +0 -243
  21. package/src/__tests__/graph-with-controls.test.jsx +0 -198
  22. package/src/__tests__/graph.test.jsx +0 -796
  23. package/src/__tests__/grid-setup.test.jsx +0 -645
  24. package/src/__tests__/grid.test.jsx +0 -22
  25. package/src/__tests__/key-legend.test.jsx +0 -260
  26. package/src/__tests__/label-svg-icon.test.jsx +0 -278
  27. package/src/__tests__/labels.test.jsx +0 -55
  28. package/src/__tests__/mark-label.test.jsx +0 -437
  29. package/src/__tests__/toggle-bar.test.jsx +0 -146
  30. package/src/__tests__/tool-menu.test.jsx +0 -115
  31. package/src/__tests__/undo-redo.test.jsx +0 -24
  32. package/src/__tests__/use-debounce.test.js +0 -21
  33. package/src/__tests__/utils.js +0 -41
  34. package/src/__tests__/utils.test.js +0 -105
  35. package/src/axis/__tests__/arrow.test.jsx +0 -38
  36. package/src/axis/__tests__/axes.test.jsx +0 -216
  37. package/src/container/__tests__/actions.test.js +0 -105
  38. package/src/container/__tests__/index.test.jsx +0 -319
  39. package/src/container/__tests__/marks.test.js +0 -172
  40. package/src/container/__tests__/middleware.test.js +0 -235
  41. package/src/container/__tests__/reducer.test.js +0 -324
  42. package/src/tools/absolute/__tests__/component.test.jsx +0 -53
  43. package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
  44. package/src/tools/circle/__tests__/component.test.jsx +0 -494
  45. package/src/tools/circle/__tests__/index.test.js +0 -480
  46. package/src/tools/exponential/__tests__/component.test.jsx +0 -53
  47. package/src/tools/exponential/__tests__/index.test.js +0 -729
  48. package/src/tools/line/__tests__/component.test.jsx +0 -37
  49. package/src/tools/parabola/__tests__/component.test.jsx +0 -48
  50. package/src/tools/parabola/__tests__/index.test.js +0 -470
  51. package/src/tools/point/__tests__/component.test.jsx +0 -475
  52. package/src/tools/point/__tests__/index.test.js +0 -241
  53. package/src/tools/polygon/__tests__/component.test.jsx +0 -471
  54. package/src/tools/polygon/__tests__/index.test.js +0 -294
  55. package/src/tools/polygon/__tests__/line.test.jsx +0 -35
  56. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
  57. package/src/tools/ray/__tests__/component.test.jsx +0 -29
  58. package/src/tools/segment/__tests__/component.test.jsx +0 -28
  59. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
  60. package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
  61. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
  62. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
  63. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  64. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  65. package/src/tools/sine/__tests__/component.test.jsx +0 -51
  66. package/src/tools/vector/__tests__/component.test.jsx +0 -25
package/CHANGELOG.md CHANGED
@@ -3,94 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [4.0.22](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.21...@pie-lib/graphing@4.0.22) (2026-09-16)
7
-
8
- **Note:** Version bump only for package @pie-lib/graphing
9
-
10
- ## [4.0.21](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.20...@pie-lib/graphing@4.0.21) (2026-09-03)
11
-
12
- **Note:** Version bump only for package @pie-lib/graphing
13
-
14
- ## [4.0.20](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.19...@pie-lib/graphing@4.0.20) (2026-09-02)
15
-
16
- ### Bug Fixes
17
-
18
- - **deps:** align versions with pie-elements-ng and upgrade [@visx](https://github.com/visx) to v4 PIE-926 ([16c5ff0](https://github.com/pie-framework/pie-lib/commit/16c5ff093a36fea98a46d5e2b37f95d9ec03025c))
19
-
20
- ## [4.0.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.18...@pie-lib/graphing@4.0.19) (2026-08-28)
21
-
22
- ### Bug Fixes
23
-
24
- - **graphing:** give a new label a caret, not just the focus PIE-681 ([eccf0df](https://github.com/pie-framework/pie-lib/commit/eccf0df50183eab617bf492eec197a1ce9a55087))
25
-
26
- ## [4.0.18](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.17...@pie-lib/graphing@4.0.18) (2026-08-26)
27
-
28
- ### Bug Fixes
29
-
30
- - **graphing:** hold the focus on a new label and save it on blur PIE-681 ([26c5f98](https://github.com/pie-framework/pie-lib/commit/26c5f9875b45f4495d76827633f28d82d93d8cb9))
31
-
32
- ## [4.0.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.16...@pie-lib/graphing@4.0.17) (2026-08-21)
33
-
34
- ### Bug Fixes
35
-
36
- - **graphing:** focus a new label even if its tool was remounted PIE-681 ([663177b](https://github.com/pie-framework/pie-lib/commit/663177b95aa73f4f53ee2aff31c3bde750435d6e))
37
-
38
- ## [4.0.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.15...@pie-lib/graphing@4.0.16) (2026-08-18)
39
-
40
- ### Bug Fixes
41
-
42
- - **graphing:** keep label input focused while it is being edited PIE-681 ([9c836f5](https://github.com/pie-framework/pie-lib/commit/9c836f5ab2437be4e48665426f3656561050c590))
43
-
44
- ## [4.0.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.14...@pie-lib/graphing@4.0.15) (2026-08-13)
45
-
46
- **Note:** Version bump only for package @pie-lib/graphing
47
-
48
- ## [4.0.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.13...@pie-lib/graphing@4.0.14) (2026-07-31)
49
-
50
- **Note:** Version bump only for package @pie-lib/graphing
51
-
52
- ## [4.0.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.12...@pie-lib/graphing@4.0.13) (2026-07-08)
53
-
54
- **Note:** Version bump only for package @pie-lib/graphing
55
-
56
- ## [4.0.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.11...@pie-lib/graphing@4.0.12) (2026-07-01)
57
-
58
- **Note:** Version bump only for package @pie-lib/graphing
59
-
60
- ## [4.0.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.10...@pie-lib/graphing@4.0.11) (2026-06-25)
61
-
62
- **Note:** Version bump only for package @pie-lib/graphing
63
-
64
- ## [4.0.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.9...@pie-lib/graphing@4.0.10) (2026-06-19)
65
-
66
- **Note:** Version bump only for package @pie-lib/graphing
67
-
68
- ## [4.0.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.8...@pie-lib/graphing@4.0.9) (2026-06-17)
69
-
70
- **Note:** Version bump only for package @pie-lib/graphing
71
-
72
- ## [4.0.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.7...@pie-lib/graphing@4.0.8) (2026-06-12)
73
-
74
- ### Bug Fixes
75
-
76
- - correct @emotion/style typo to @emotion/styled in package deps PIE-678 ([d529ac7](https://github.com/pie-framework/pie-lib/commit/d529ac7bc3dfa94d8037688452d4c70c66f2590b))
77
-
78
- ## [4.0.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.6...@pie-lib/graphing@4.0.7) (2026-06-03)
79
-
80
- **Note:** Version bump only for package @pie-lib/graphing
81
-
82
- ## [4.0.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.5...@pie-lib/graphing@4.0.6) (2026-06-01)
83
-
84
- ### Bug Fixes
85
-
86
- - **graphing:** make sure evaluate mode marks are not included in undo/redo history PIE-582 ([74f4820](https://github.com/pie-framework/pie-lib/commit/74f482052b5331d918212dcfd847a477f1e5e2d4))
87
-
88
- ## [4.0.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.4...@pie-lib/graphing@4.0.5) (2026-05-21)
89
-
90
- ### Bug Fixes
91
-
92
- - add a bigger stroke for polygons PIE-451 ([4908eda](https://github.com/pie-framework/pie-lib/commit/4908edae1bb176575e18a5c5979cb3d4e9eb1454))
93
-
94
6
  ## [4.0.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@4.0.3...@pie-lib/graphing@4.0.4) (2026-05-15)
95
7
 
96
8
  ### Bug Fixes
package/lib/mark-label.js CHANGED
@@ -19,17 +19,6 @@ var _labelSvgIcon = _interopRequireDefault(require("./label-svg-icon"));
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
- var DEBOUNCE_DELAY = 500;
23
- // A new label insists on the focus and the caret for this long, and again on each of the ticks
24
- // below. No single moment is reliable: the authoring host re-renders the whole element while it
25
- // saves, and the input is replaced under this component more than once. Nothing typed yet is what
26
- // tells a transient blur apart from the user leaving the label.
27
- var INSIST_ON_FOCUS_FOR = 500;
28
- var INSIST_AT = [0, 50, 120, 250, 400, 700, 1000];
29
- // how many times a label will do the heavier focus cycle to get a caret back
30
- var MAX_CARET_CYCLES = 3;
31
- // how wide an editable label input is while it is empty
32
- var EMPTY_INPUT_WIDTH = 30;
33
22
  var StyledInputCorrect = (0, _styles.styled)('div')(function (_ref2) {
34
23
  var theme = _ref2.theme;
35
24
  return {
@@ -148,30 +137,12 @@ var coordinates = exports.coordinates = function coordinates(graphProps, mark) {
148
137
  return {};
149
138
  }
150
139
  };
151
-
152
- /**
153
- * Whether the document's caret is in this input. The characters land at the caret, not at the
154
- * focused node - an input can be the active element with no caret anywhere, and then keypress fires
155
- * and nothing is inserted, with nothing in the page cancelling anything.
156
- */
157
- var caretIsInside = function caretIsInside(node) {
158
- if (typeof document === 'undefined' || !document.getSelection) {
159
- return true;
160
- }
161
- var selection = document.getSelection();
162
- if (!selection || !selection.rangeCount || !selection.anchorNode) {
163
- return false;
164
- }
165
- var anchor = selection.anchorNode;
166
- return anchor === node || anchor === node.parentNode || node.contains(anchor);
167
- };
168
140
  var LabelInput = function LabelInput(_ref5) {
169
141
  var _ref = _ref5._ref,
170
142
  externalInputRef = _ref5.externalInputRef,
171
143
  label = _ref5.label,
172
144
  disabled = _ref5.disabled,
173
145
  inputStyle = _ref5.inputStyle,
174
- minWidth = _ref5.minWidth,
175
146
  onChange = _ref5.onChange,
176
147
  onBlur = _ref5.onBlur;
177
148
  return /*#__PURE__*/_react["default"].createElement(_reactInputAutosize["default"], {
@@ -181,7 +152,6 @@ var LabelInput = function LabelInput(_ref5) {
181
152
  },
182
153
  disabled: disabled,
183
154
  inputStyle: inputStyle,
184
- minWidth: minWidth,
185
155
  value: label,
186
156
  onChange: onChange,
187
157
  onBlur: onBlur
@@ -193,26 +163,21 @@ LabelInput.propTypes = {
193
163
  label: _propTypes["default"].string,
194
164
  disabled: _propTypes["default"].bool,
195
165
  inputStyle: _propTypes["default"].object,
196
- minWidth: _propTypes["default"].number,
197
166
  onChange: _propTypes["default"].func,
198
167
  onBlur: _propTypes["default"].func
199
168
  };
200
169
  var MarkLabel = exports.MarkLabel = function MarkLabel(props) {
201
- // the state repositions the label once the input has a size, the ref is never a render behind
202
- var inputNode = (0, _react.useRef)(null);
203
170
  var _useState = (0, _react.useState)(null),
204
171
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
205
172
  input = _useState2[0],
206
173
  setInput = _useState2[1];
207
174
  var _ref = (0, _react.useCallback)(function (node) {
208
- inputNode.current = node;
209
- setInput(node);
210
- }, []);
175
+ return setInput(node);
176
+ });
211
177
  var theme = (0, _styles.useTheme)();
212
178
  var mark = props.mark,
213
179
  graphProps = props.graphProps,
214
180
  disabled = props.disabled,
215
- autoFocus = props.autoFocus,
216
181
  externalInputRef = props.inputRef;
217
182
  var _useState3 = (0, _react.useState)(mark.label),
218
183
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
@@ -221,168 +186,27 @@ var MarkLabel = exports.MarkLabel = function MarkLabel(props) {
221
186
  var correctness = mark.correctness,
222
187
  correctnesslabel = mark.correctnesslabel,
223
188
  correctlabel = mark.correctlabel;
224
- var isFocused = function isFocused() {
225
- return !!inputNode.current && typeof document !== 'undefined' && document.activeElement === inputNode.current;
226
- };
227
-
228
- // an empty label with an enabled input is one the user just added: label mode has to be on and it
229
- // always starts off. Read from the mark, not from autoFocus, because the tool that asked for the
230
- // label can be remounted by the marks coming back from the host before the input renders.
231
- var isNewLabel = (0, _react.useRef)(mark.label === '' && !disabled && !mark.disabled);
232
- var insistUntil = (0, _react.useRef)(0);
233
- var lastSaved = (0, _react.useRef)(mark.label);
234
- var insisting = function insisting() {
235
- return Date.now() < insistUntil.current && !(inputNode.current && inputNode.current.value);
236
- };
237
- // the whole window losing the focus is not the user leaving the label - another window, the
238
- // devtools, or the host moving the focus while it saves. The window blur arrives before the
239
- // input's own blur, so this flag is set by the time the label is asked to give itself up.
240
- var windowAway = (0, _react.useRef)(false);
241
- // our own blur, from the focus cycle that puts a missing caret back
242
- var selfFocusing = (0, _react.useRef)(false);
243
- var caretCycles = (0, _react.useRef)(0);
244
189
  var onChange = function onChange(e) {
245
190
  return setLabel(e.target.value);
246
191
  };
247
- var saveLabel = function saveLabel(value) {
248
- if (value === lastSaved.current) {
249
- return;
250
- }
251
- lastSaved.current = value;
252
- props.onChange(value);
253
- };
254
192
  var handleBlur = (0, _react.useCallback)(function () {
255
- // in the DNA env the focus is moved while the model is saved - not the user leaving the label
256
- if (insisting() || windowAway.current || selfFocusing.current) {
257
- return;
258
- }
259
- isNewLabel.current = false;
260
193
  if (label === '') {
261
194
  props.onChange('');
262
- } else if (label !== mark.label) {
263
- // the debounce can still be pending, and once the focus is gone an echo of the model would
264
- // overwrite what was typed before it fires
265
- saveLabel(label);
266
- }
267
-
268
- // lets the tool know that this label is not being edited anymore, so it stops auto focusing it
269
- if (props.onBlur) {
270
- props.onBlur();
271
195
  }
272
- }, [label, mark.label, props.onChange, props.onBlur]);
273
- var debouncedLabel = (0, _useDebounce.useDebounce)(label, DEBOUNCE_DELAY);
196
+ }, [label, props.onChange]);
197
+ var debouncedLabel = (0, _useDebounce.useDebounce)(label, 200);
274
198
 
275
- // props to state, but not while focused: the mark can come back from an async model save with an
276
- // older label and overwrite what was typed meanwhile
199
+ // useState only sets the value once, to synch props to state need useEffect
277
200
  (0, _react.useEffect)(function () {
278
- if (isFocused()) {
279
- return;
280
- }
281
201
  setLabel(mark.label);
282
202
  }, [mark.label]);
283
203
 
284
204
  // pick up the change to debouncedLabel and save it
285
205
  (0, _react.useEffect)(function () {
286
206
  if (typeof debouncedLabel === 'string' && debouncedLabel !== mark.label) {
287
- saveLabel(debouncedLabel);
207
+ props.onChange(debouncedLabel);
288
208
  }
289
209
  }, [debouncedLabel]);
290
- var focusInput = function focusInput() {
291
- var node = inputNode.current;
292
-
293
- // node.disabled, not the disabled prop: a disabled input silently ignores focus()
294
- if (!autoFocus && !isNewLabel.current && !insisting() || !node || node.disabled) {
295
- return;
296
- }
297
- var wasFocused = isFocused();
298
- if (!wasFocused) {
299
- node.focus();
300
-
301
- // a new label is focused once, so it cannot fight over the focus with another one
302
- if (isFocused()) {
303
- isNewLabel.current = false;
304
- }
305
- }
306
- if (!node.setSelectionRange) {
307
- return;
308
- }
309
-
310
- // a label that was already being edited keeps the caret the user put in it; one that has just
311
- // taken the focus gets it at the end, otherwise typing continues in front of the existing label
312
- var keepCaret = wasFocused && node.value;
313
- var start = keepCaret ? node.selectionStart : (node.value || '').length;
314
- var end = keepCaret ? node.selectionEnd : start;
315
-
316
- // The characters land at the document's caret, not at the focused node. An input focused while
317
- // it was being replaced, or while the window was away, ends up as the active element with no
318
- // caret anywhere: keypress fires and nothing is inserted, with nothing in the page cancelling
319
- // anything. Re-asserting the range is what puts the caret back.
320
- if (!caretIsInside(node)) {
321
- node.setSelectionRange(start, end);
322
- }
323
-
324
- // and if it still is not there, a focus cycle is the heavier way to get it. Every focusInput
325
- // call is another go at it - after each render, on each insist tick, and when the window comes
326
- // back - up to a few times per label, since the state comes back as the input is replaced.
327
- if (caretIsInside(node) || caretCycles.current >= MAX_CARET_CYCLES) {
328
- return;
329
- }
330
- caretCycles.current += 1;
331
- // our own blur, so the label is not given up over it
332
- selfFocusing.current = true;
333
- node.blur();
334
- node.focus();
335
- node.setSelectionRange(start, end);
336
- selfFocusing.current = false;
337
- };
338
-
339
- // after every render: the input can appear a render or more later (the mark comes back from an
340
- // async model save) and a replaced node loses the focus without this component being told
341
- (0, _react.useEffect)(function () {
342
- return focusInput();
343
- });
344
-
345
- // and again on a timer, for the DNA env, where the focus is moved once the renders are over. The
346
- // original code focused from a setTimeout, which is what let it survive that.
347
- (0, _react.useEffect)(function () {
348
- if (!autoFocus && !isNewLabel.current) {
349
- return;
350
- }
351
- if (!insistUntil.current) {
352
- insistUntil.current = Date.now() + INSIST_ON_FOCUS_FOR;
353
- }
354
- var timers = INSIST_AT.map(function (delay) {
355
- return setTimeout(focusInput, delay);
356
- });
357
- return function () {
358
- return timers.forEach(function (t) {
359
- return clearTimeout(t);
360
- });
361
- };
362
- }, [autoFocus]);
363
-
364
- // the blur that came with the window going away is ignored, so the label is still the one being
365
- // edited when the window comes back and it takes the focus, and its selection, back
366
- (0, _react.useEffect)(function () {
367
- var onWindowBlur = function onWindowBlur() {
368
- windowAway.current = true;
369
- };
370
- var onWindowFocus = function onWindowFocus() {
371
- // coming back only means something if the window went away: moving the focus from one element
372
- // to another inside the page reaches window too in some implementations
373
- if (!windowAway.current) {
374
- return;
375
- }
376
- windowAway.current = false;
377
- focusInput();
378
- };
379
- window.addEventListener('blur', onWindowBlur);
380
- window.addEventListener('focus', onWindowFocus);
381
- return function () {
382
- window.removeEventListener('blur', onWindowBlur);
383
- window.removeEventListener('focus', onWindowFocus);
384
- };
385
- }, [autoFocus]);
386
210
  var rect = input ? input.getBoundingClientRect() : {
387
211
  width: 0,
388
212
  height: 0
@@ -406,13 +230,7 @@ var MarkLabel = exports.MarkLabel = function MarkLabel(props) {
406
230
  externalInputRef: externalInputRef,
407
231
  label: labelValue,
408
232
  disabled: disabledInput,
409
- inputStyle: inputStyle
410
- // an editable label sizes itself to its content, so an empty one is 2px wide: enough for the
411
- // caret, not enough for anybody to see that the label is waiting to be typed into. Chrome
412
- // does not blink the caret of an input inside an svg foreignObject, it only paints a hairline,
413
- // so the box itself has to say that it has the focus.
414
- ,
415
- minWidth: disabledInput ? 1 : EMPTY_INPUT_WIDTH,
233
+ inputStyle: inputStyle,
416
234
  onChange: onChange,
417
235
  onBlur: handleBlur
418
236
  });
@@ -452,20 +270,12 @@ var MarkLabel = exports.MarkLabel = function MarkLabel(props) {
452
270
  style: style
453
271
  }, renderInput(studentInputStyle, label));
454
272
  }
455
-
456
- // an empty label that cannot be edited is just an empty box - the config draws the background
457
- // marks into every correct answer graph too
458
- if (disabledInput && !label) {
459
- return null;
460
- }
461
273
  return /*#__PURE__*/_react["default"].createElement("div", {
462
274
  style: style
463
275
  }, renderInput(getInputStyles(theme, disabled, mark.disabled), label));
464
276
  };
465
277
  MarkLabel.propTypes = {
466
- autoFocus: _propTypes["default"].bool,
467
278
  disabled: _propTypes["default"].bool,
468
- onBlur: _propTypes["default"].func,
469
279
  onChange: _propTypes["default"].func,
470
280
  graphProps: _plot.types.GraphPropsType,
471
281
  inputRef: _propTypes["default"].func,
@@ -1 +1 @@
1
- {"version":3,"file":"mark-label.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_styles","_reactInputAutosize","_useDebounce","_plot","_renderUi","_labelSvgIcon","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","DEBOUNCE_DELAY","INSIST_ON_FOCUS_FOR","INSIST_AT","MAX_CARET_CYCLES","EMPTY_INPUT_WIDTH","StyledInputCorrect","styled","_ref2","theme","padding","spacing","borderRadius","fontSize","backgroundColor","color","defaults","WHITE","CORRECT_WITH_ICON","border","concat","StyledInputIncorrect","_ref3","INCORRECT_WITH_ICON","StyledInputMissing","_ref4","MISSING_WITH_ICON","fontWeight","StyledIncorrect","getInputStyles","disabled","markDisabled","fontFamily","typography","PRIMARY_DARK","SECONDARY","WebkitOpacity","undefined","WebkitTextFillColor","getStudentInputStyles","position","exports","graphProps","mark","rect","width","height","scale","domain","range","shift","rightEdge","x","bottomEdge","y","h","max","v","min","coordinates","left","top","caretIsInside","node","document","getSelection","selection","rangeCount","anchorNode","anchor","parentNode","contains","LabelInput","_ref5","_ref","externalInputRef","label","inputStyle","minWidth","onChange","onBlur","createElement","inputRef","value","propTypes","PropTypes","func","string","bool","object","number","MarkLabel","props","inputNode","useRef","_useState","useState","_useState2","_slicedToArray2","input","setInput","useCallback","current","useTheme","autoFocus","_useState3","_useState4","setLabel","correctness","correctnesslabel","correctlabel","isFocused","activeElement","isNewLabel","insistUntil","lastSaved","insisting","Date","now","windowAway","selfFocusing","caretCycles","target","saveLabel","handleBlur","debouncedLabel","useDebounce","useEffect","focusInput","wasFocused","focus","setSelectionRange","keepCaret","start","selectionStart","end","selectionEnd","blur","timers","map","delay","setTimeout","clearTimeout","onWindowBlur","onWindowFocus","window","addEventListener","removeEventListener","getBoundingClientRect","pos","leftTop","style","pointerEvents","display","alignItems","gap","secondLabelStyle","disabledInput","renderInput","labelValue","studentInputStyle","type","Fragment","marginLeft","types","GraphPropsType","_default"],"sources":["../src/mark-label.jsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { styled, useTheme } from '@mui/material/styles';\nimport AutosizeInput from 'react-input-autosize';\nimport { useDebounce } from './use-debounce';\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport SvgIcon from './label-svg-icon';\n\nconst DEBOUNCE_DELAY = 500;\n// A new label insists on the focus and the caret for this long, and again on each of the ticks\n// below. No single moment is reliable: the authoring host re-renders the whole element while it\n// saves, and the input is replaced under this component more than once. Nothing typed yet is what\n// tells a transient blur apart from the user leaving the label.\nconst INSIST_ON_FOCUS_FOR = 500;\nconst INSIST_AT = [0, 50, 120, 250, 400, 700, 1000];\n// how many times a label will do the heavier focus cycle to get a caret back\nconst MAX_CARET_CYCLES = 3;\n// how wide an editable label input is while it is empty\nconst EMPTY_INPUT_WIDTH = 30;\n\nconst StyledInputCorrect = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.CORRECT_WITH_ICON,\n border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,\n}));\n\nconst StyledInputIncorrect = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.INCORRECT_WITH_ICON,\n border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,\n}));\n\nconst StyledInputMissing = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.MISSING_WITH_ICON,\n border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,\n fontWeight: 'bold',\n}));\n\nconst StyledIncorrect = styled('div')(() => ({\n float: 'right',\n padding: 0,\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.INCORRECT_WITH_ICON,\n fontWeight: 'bold',\n}));\n\nconst getInputStyles = (theme, disabled, markDisabled) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n fontFamily: theme.typography.fontFamily,\n fontSize: '10px',\n border: disabled\n ? `solid 1px ${color.defaults.PRIMARY_DARK}`\n : markDisabled\n ? `solid 1px ${color.disabled()}`\n : `solid 1px ${color.defaults.SECONDARY}`,\n borderRadius: '3px',\n color: markDisabled ? color.disabled() : color.defaults.PRIMARY_DARK,\n backgroundColor: color.defaults.WHITE,\n WebkitOpacity: disabled ? '1' : undefined,\n WebkitTextFillColor: markDisabled ? color.disabled() : undefined,\n});\n\nconst getStudentInputStyles = () => ({\n padding: '0',\n border: 'none',\n color: 'inherit',\n fontWeight: 'bold',\n});\n\nexport const position = (graphProps, mark, rect = { width: 0, height: 0 }) => {\n const { scale, domain, range } = graphProps;\n const shift = 5;\n\n const rightEdge = scale.x(mark.x) + rect.width + shift;\n const bottomEdge = scale.y(mark.y) + rect.height + shift;\n\n const h = rightEdge >= scale.x(domain.max) ? 'left' : 'right';\n const v = bottomEdge >= scale.y(range.min) ? 'top' : 'bottom';\n\n return `${v}-${h}`;\n};\n\nexport const coordinates = (graphProps, mark, rect = { width: 0, height: 0 }, position) => {\n const { scale } = graphProps;\n const shift = 5;\n\n switch (position) {\n case 'bottom-right':\n return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) + shift };\n case 'bottom-left':\n return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) + shift };\n case 'top-left':\n return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) - shift - rect.height };\n case 'top-right':\n return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) - shift - rect.height };\n default:\n return {};\n }\n};\n\n/**\n * Whether the document's caret is in this input. The characters land at the caret, not at the\n * focused node - an input can be the active element with no caret anywhere, and then keypress fires\n * and nothing is inserted, with nothing in the page cancelling anything.\n */\nconst caretIsInside = (node) => {\n if (typeof document === 'undefined' || !document.getSelection) {\n return true;\n }\n\n const selection = document.getSelection();\n\n if (!selection || !selection.rangeCount || !selection.anchorNode) {\n return false;\n }\n\n const anchor = selection.anchorNode;\n\n return anchor === node || anchor === node.parentNode || node.contains(anchor);\n};\n\nconst LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, minWidth, onChange, onBlur }) => (\n <AutosizeInput\n inputRef={(r) => {\n _ref(r);\n externalInputRef(r);\n }}\n disabled={disabled}\n inputStyle={inputStyle}\n minWidth={minWidth}\n value={label}\n onChange={onChange}\n onBlur={onBlur}\n />\n);\n\nLabelInput.propTypes = {\n _ref: PropTypes.func,\n externalInputRef: PropTypes.func,\n label: PropTypes.string,\n disabled: PropTypes.bool,\n inputStyle: PropTypes.object,\n minWidth: PropTypes.number,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n};\n\nexport const MarkLabel = (props) => {\n // the state repositions the label once the input has a size, the ref is never a render behind\n const inputNode = useRef(null);\n const [input, setInput] = useState(null);\n const _ref = useCallback((node) => {\n inputNode.current = node;\n setInput(node);\n }, []);\n const theme = useTheme();\n\n const { mark, graphProps, disabled, autoFocus, inputRef: externalInputRef } = props;\n\n const [label, setLabel] = useState(mark.label);\n const { correctness, correctnesslabel, correctlabel } = mark;\n\n const isFocused = () =>\n !!inputNode.current && typeof document !== 'undefined' && document.activeElement === inputNode.current;\n\n // an empty label with an enabled input is one the user just added: label mode has to be on and it\n // always starts off. Read from the mark, not from autoFocus, because the tool that asked for the\n // label can be remounted by the marks coming back from the host before the input renders.\n const isNewLabel = useRef(mark.label === '' && !disabled && !mark.disabled);\n const insistUntil = useRef(0);\n const lastSaved = useRef(mark.label);\n const insisting = () => Date.now() < insistUntil.current && !(inputNode.current && inputNode.current.value);\n // the whole window losing the focus is not the user leaving the label - another window, the\n // devtools, or the host moving the focus while it saves. The window blur arrives before the\n // input's own blur, so this flag is set by the time the label is asked to give itself up.\n const windowAway = useRef(false);\n // our own blur, from the focus cycle that puts a missing caret back\n const selfFocusing = useRef(false);\n const caretCycles = useRef(0);\n\n const onChange = (e) => setLabel(e.target.value);\n\n const saveLabel = (value) => {\n if (value === lastSaved.current) {\n return;\n }\n\n lastSaved.current = value;\n props.onChange(value);\n };\n\n const handleBlur = useCallback(() => {\n // in the DNA env the focus is moved while the model is saved - not the user leaving the label\n if (insisting() || windowAway.current || selfFocusing.current) {\n return;\n }\n\n isNewLabel.current = false;\n\n if (label === '') {\n props.onChange('');\n } else if (label !== mark.label) {\n // the debounce can still be pending, and once the focus is gone an echo of the model would\n // overwrite what was typed before it fires\n saveLabel(label);\n }\n\n // lets the tool know that this label is not being edited anymore, so it stops auto focusing it\n if (props.onBlur) {\n props.onBlur();\n }\n }, [label, mark.label, props.onChange, props.onBlur]);\n\n const debouncedLabel = useDebounce(label, DEBOUNCE_DELAY);\n\n // props to state, but not while focused: the mark can come back from an async model save with an\n // older label and overwrite what was typed meanwhile\n useEffect(() => {\n if (isFocused()) {\n return;\n }\n\n setLabel(mark.label);\n }, [mark.label]);\n\n // pick up the change to debouncedLabel and save it\n useEffect(() => {\n if (typeof debouncedLabel === 'string' && debouncedLabel !== mark.label) {\n saveLabel(debouncedLabel);\n }\n }, [debouncedLabel]);\n\n const focusInput = () => {\n const node = inputNode.current;\n\n // node.disabled, not the disabled prop: a disabled input silently ignores focus()\n if ((!autoFocus && !isNewLabel.current && !insisting()) || !node || node.disabled) {\n return;\n }\n\n const wasFocused = isFocused();\n\n if (!wasFocused) {\n node.focus();\n\n // a new label is focused once, so it cannot fight over the focus with another one\n if (isFocused()) {\n isNewLabel.current = false;\n }\n }\n\n if (!node.setSelectionRange) {\n return;\n }\n\n // a label that was already being edited keeps the caret the user put in it; one that has just\n // taken the focus gets it at the end, otherwise typing continues in front of the existing label\n const keepCaret = wasFocused && node.value;\n const start = keepCaret ? node.selectionStart : (node.value || '').length;\n const end = keepCaret ? node.selectionEnd : start;\n\n // The characters land at the document's caret, not at the focused node. An input focused while\n // it was being replaced, or while the window was away, ends up as the active element with no\n // caret anywhere: keypress fires and nothing is inserted, with nothing in the page cancelling\n // anything. Re-asserting the range is what puts the caret back.\n if (!caretIsInside(node)) {\n node.setSelectionRange(start, end);\n }\n\n // and if it still is not there, a focus cycle is the heavier way to get it. Every focusInput\n // call is another go at it - after each render, on each insist tick, and when the window comes\n // back - up to a few times per label, since the state comes back as the input is replaced.\n if (caretIsInside(node) || caretCycles.current >= MAX_CARET_CYCLES) {\n return;\n }\n\n caretCycles.current += 1;\n // our own blur, so the label is not given up over it\n selfFocusing.current = true;\n node.blur();\n node.focus();\n node.setSelectionRange(start, end);\n selfFocusing.current = false;\n };\n\n // after every render: the input can appear a render or more later (the mark comes back from an\n // async model save) and a replaced node loses the focus without this component being told\n useEffect(() => focusInput());\n\n // and again on a timer, for the DNA env, where the focus is moved once the renders are over. The\n // original code focused from a setTimeout, which is what let it survive that.\n useEffect(() => {\n if (!autoFocus && !isNewLabel.current) {\n return;\n }\n\n if (!insistUntil.current) {\n insistUntil.current = Date.now() + INSIST_ON_FOCUS_FOR;\n }\n\n const timers = INSIST_AT.map((delay) => setTimeout(focusInput, delay));\n\n return () => timers.forEach((t) => clearTimeout(t));\n }, [autoFocus]);\n\n // the blur that came with the window going away is ignored, so the label is still the one being\n // edited when the window comes back and it takes the focus, and its selection, back\n useEffect(() => {\n const onWindowBlur = () => {\n windowAway.current = true;\n };\n\n const onWindowFocus = () => {\n // coming back only means something if the window went away: moving the focus from one element\n // to another inside the page reaches window too in some implementations\n if (!windowAway.current) {\n return;\n }\n\n windowAway.current = false;\n focusInput();\n };\n\n window.addEventListener('blur', onWindowBlur);\n window.addEventListener('focus', onWindowFocus);\n\n return () => {\n window.removeEventListener('blur', onWindowBlur);\n window.removeEventListener('focus', onWindowFocus);\n };\n }, [autoFocus]);\n\n const rect = input ? input.getBoundingClientRect() : { width: 0, height: 0 };\n const pos = position(graphProps, mark, rect);\n const leftTop = coordinates(graphProps, mark, rect, pos);\n\n const style = {\n position: 'fixed',\n pointerEvents: 'auto',\n display: 'flex',\n alignItems: 'center',\n gap: '3px',\n ...leftTop,\n };\n\n const secondLabelStyle = {\n ...style,\n top: leftTop.top + 25,\n };\n\n const disabledInput = disabled || mark.disabled;\n\n const renderInput = (inputStyle, labelValue) => (\n <LabelInput\n _ref={_ref}\n externalInputRef={externalInputRef}\n label={labelValue}\n disabled={disabledInput}\n inputStyle={inputStyle}\n // an editable label sizes itself to its content, so an empty one is 2px wide: enough for the\n // caret, not enough for anybody to see that the label is waiting to be typed into. Chrome\n // does not blink the caret of an input inside an svg foreignObject, it only paints a hairline,\n // so the box itself has to say that it has the focus.\n minWidth={disabledInput ? 1 : EMPTY_INPUT_WIDTH}\n onChange={onChange}\n onBlur={handleBlur}\n />\n );\n\n const studentInputStyle = getStudentInputStyles();\n\n if (correctness === 'correct' && correctnesslabel === 'correct' && correctlabel) {\n return (\n <StyledInputCorrect style={style}>\n <SvgIcon type=\"correct\" />\n {renderInput(studentInputStyle, correctlabel)}\n </StyledInputCorrect>\n );\n }\n\n if (correctness === 'correct' && correctnesslabel === 'correct' && !correctlabel) {\n return null;\n }\n\n if (correctness === 'correct' && correctnesslabel === 'incorrect') {\n return (\n <>\n <StyledInputIncorrect style={style}>\n <SvgIcon type=\"incorrect\" />\n {label === '' ? (\n <SvgIcon type=\"empty\" style={{ marginLeft: '3px' }} />\n ) : (\n renderInput(studentInputStyle, label)\n )}\n </StyledInputIncorrect>\n <StyledInputMissing style={secondLabelStyle}>{renderInput(studentInputStyle, correctlabel)}</StyledInputMissing>\n </>\n );\n }\n\n if (correctness === 'missing') {\n return <StyledInputMissing style={style}>{renderInput(studentInputStyle, label)}</StyledInputMissing>;\n }\n\n if (correctness === 'incorrect') {\n return <StyledIncorrect style={style}>{renderInput(studentInputStyle, label)}</StyledIncorrect>;\n }\n\n // an empty label that cannot be edited is just an empty box - the config draws the background\n // marks into every correct answer graph too\n if (disabledInput && !label) {\n return null;\n }\n\n return <div style={style}>{renderInput(getInputStyles(theme, disabled, mark.disabled), label)}</div>;\n};\n\nMarkLabel.propTypes = {\n autoFocus: PropTypes.bool,\n disabled: PropTypes.bool,\n onBlur: PropTypes.func,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType,\n inputRef: PropTypes.func,\n mark: PropTypes.object,\n};\n\nexport default MarkLabel;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAA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AAS","ignoreList":[]}
1
+ {"version":3,"file":"mark-label.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_styles","_reactInputAutosize","_useDebounce","_plot","_renderUi","_labelSvgIcon","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","StyledInputCorrect","styled","_ref2","theme","padding","spacing","borderRadius","fontSize","backgroundColor","color","defaults","WHITE","CORRECT_WITH_ICON","border","concat","StyledInputIncorrect","_ref3","INCORRECT_WITH_ICON","StyledInputMissing","_ref4","MISSING_WITH_ICON","fontWeight","StyledIncorrect","getInputStyles","disabled","markDisabled","fontFamily","typography","PRIMARY_DARK","SECONDARY","WebkitOpacity","undefined","WebkitTextFillColor","getStudentInputStyles","position","exports","graphProps","mark","rect","width","height","scale","domain","range","shift","rightEdge","x","bottomEdge","y","h","max","v","min","coordinates","left","top","LabelInput","_ref5","_ref","externalInputRef","label","inputStyle","onChange","onBlur","createElement","inputRef","value","propTypes","PropTypes","func","string","bool","object","MarkLabel","props","_useState","useState","_useState2","_slicedToArray2","input","setInput","useCallback","node","useTheme","_useState3","_useState4","setLabel","correctness","correctnesslabel","correctlabel","target","handleBlur","debouncedLabel","useDebounce","useEffect","getBoundingClientRect","pos","leftTop","style","pointerEvents","display","alignItems","gap","secondLabelStyle","disabledInput","renderInput","labelValue","studentInputStyle","type","Fragment","marginLeft","types","GraphPropsType","_default"],"sources":["../src/mark-label.jsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { styled, useTheme } from '@mui/material/styles';\nimport AutosizeInput from 'react-input-autosize';\nimport { useDebounce } from './use-debounce';\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport SvgIcon from './label-svg-icon';\n\nconst StyledInputCorrect = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.CORRECT_WITH_ICON,\n border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,\n}));\n\nconst StyledInputIncorrect = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.INCORRECT_WITH_ICON,\n border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,\n}));\n\nconst StyledInputMissing = styled('div')(({ theme }) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.MISSING_WITH_ICON,\n border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,\n fontWeight: 'bold',\n}));\n\nconst StyledIncorrect = styled('div')(() => ({\n float: 'right',\n padding: 0,\n borderRadius: '4px',\n fontSize: '10px',\n backgroundColor: color.defaults.WHITE,\n color: color.defaults.INCORRECT_WITH_ICON,\n fontWeight: 'bold',\n}));\n\nconst getInputStyles = (theme, disabled, markDisabled) => ({\n float: 'right',\n padding: theme.spacing(0.5),\n fontFamily: theme.typography.fontFamily,\n fontSize: '10px',\n border: disabled\n ? `solid 1px ${color.defaults.PRIMARY_DARK}`\n : markDisabled\n ? `solid 1px ${color.disabled()}`\n : `solid 1px ${color.defaults.SECONDARY}`,\n borderRadius: '3px',\n color: markDisabled ? color.disabled() : color.defaults.PRIMARY_DARK,\n backgroundColor: color.defaults.WHITE,\n WebkitOpacity: disabled ? '1' : undefined,\n WebkitTextFillColor: markDisabled ? color.disabled() : undefined,\n});\n\nconst getStudentInputStyles = () => ({\n padding: '0',\n border: 'none',\n color: 'inherit',\n fontWeight: 'bold',\n});\n\nexport const position = (graphProps, mark, rect = { width: 0, height: 0 }) => {\n const { scale, domain, range } = graphProps;\n const shift = 5;\n\n const rightEdge = scale.x(mark.x) + rect.width + shift;\n const bottomEdge = scale.y(mark.y) + rect.height + shift;\n\n const h = rightEdge >= scale.x(domain.max) ? 'left' : 'right';\n const v = bottomEdge >= scale.y(range.min) ? 'top' : 'bottom';\n\n return `${v}-${h}`;\n};\n\nexport const coordinates = (graphProps, mark, rect = { width: 0, height: 0 }, position) => {\n const { scale } = graphProps;\n const shift = 5;\n\n switch (position) {\n case 'bottom-right':\n return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) + shift };\n case 'bottom-left':\n return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) + shift };\n case 'top-left':\n return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) - shift - rect.height };\n case 'top-right':\n return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) - shift - rect.height };\n default:\n return {};\n }\n};\n\nconst LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, onChange, onBlur }) => (\n <AutosizeInput\n inputRef={(r) => {\n _ref(r);\n externalInputRef(r);\n }}\n disabled={disabled}\n inputStyle={inputStyle}\n value={label}\n onChange={onChange}\n onBlur={onBlur}\n />\n);\n\nLabelInput.propTypes = {\n _ref: PropTypes.func,\n externalInputRef: PropTypes.func,\n label: PropTypes.string,\n disabled: PropTypes.bool,\n inputStyle: PropTypes.object,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n};\n\nexport const MarkLabel = (props) => {\n const [input, setInput] = useState(null);\n const _ref = useCallback((node) => setInput(node));\n const theme = useTheme();\n\n const { mark, graphProps, disabled, inputRef: externalInputRef } = props;\n\n const [label, setLabel] = useState(mark.label);\n const { correctness, correctnesslabel, correctlabel } = mark;\n\n const onChange = (e) => setLabel(e.target.value);\n\n const handleBlur = useCallback(() => {\n if (label === '') {\n props.onChange('');\n }\n }, [label, props.onChange]);\n\n const debouncedLabel = useDebounce(label, 200);\n\n // useState only sets the value once, to synch props to state need useEffect\n useEffect(() => {\n setLabel(mark.label);\n }, [mark.label]);\n\n // pick up the change to debouncedLabel and save it\n useEffect(() => {\n if (typeof debouncedLabel === 'string' && debouncedLabel !== mark.label) {\n props.onChange(debouncedLabel);\n }\n }, [debouncedLabel]);\n\n const rect = input ? input.getBoundingClientRect() : { width: 0, height: 0 };\n const pos = position(graphProps, mark, rect);\n const leftTop = coordinates(graphProps, mark, rect, pos);\n\n const style = {\n position: 'fixed',\n pointerEvents: 'auto',\n display: 'flex',\n alignItems: 'center',\n gap: '3px',\n ...leftTop,\n };\n\n const secondLabelStyle = {\n ...style,\n top: leftTop.top + 25,\n };\n\n const disabledInput = disabled || mark.disabled;\n\n const renderInput = (inputStyle, labelValue) => (\n <LabelInput\n _ref={_ref}\n externalInputRef={externalInputRef}\n label={labelValue}\n disabled={disabledInput}\n inputStyle={inputStyle}\n onChange={onChange}\n onBlur={handleBlur}\n />\n );\n\n const studentInputStyle = getStudentInputStyles();\n\n if (correctness === 'correct' && correctnesslabel === 'correct' && correctlabel) {\n return (\n <StyledInputCorrect style={style}>\n <SvgIcon type=\"correct\" />\n {renderInput(studentInputStyle, correctlabel)}\n </StyledInputCorrect>\n );\n }\n\n if (correctness === 'correct' && correctnesslabel === 'correct' && !correctlabel) {\n return null;\n }\n\n if (correctness === 'correct' && correctnesslabel === 'incorrect') {\n return (\n <>\n <StyledInputIncorrect style={style}>\n <SvgIcon type=\"incorrect\" />\n {label === '' ? (\n <SvgIcon type=\"empty\" style={{ marginLeft: '3px' }} />\n ) : (\n renderInput(studentInputStyle, label)\n )}\n </StyledInputIncorrect>\n <StyledInputMissing style={secondLabelStyle}>{renderInput(studentInputStyle, correctlabel)}</StyledInputMissing>\n </>\n );\n }\n\n if (correctness === 'missing') {\n return <StyledInputMissing style={style}>{renderInput(studentInputStyle, label)}</StyledInputMissing>;\n }\n\n if (correctness === 'incorrect') {\n return <StyledIncorrect style={style}>{renderInput(studentInputStyle, label)}</StyledIncorrect>;\n }\n\n return <div style={style}>{renderInput(getInputStyles(theme, disabled, mark.disabled), label)}</div>;\n};\n\nMarkLabel.propTypes = {\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType,\n inputRef: PropTypes.func,\n mark: PropTypes.object,\n};\n\nexport default MarkLabel;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAN,sBAAA,CAAAF,OAAA;AAAuC,SAAAD,wBAAAU,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,wBAAAU,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,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WAAW,CAACE,iBAAiB,EAAElB,YAAY,CAAsB,CAC/G,CAAC;EAEP;EAEA,IAAIF,WAAW,KAAK,SAAS,EAAE;IAC7B,oBAAOpI,MAAA,YAAA6G,aAAA,CAAC9C,kBAAkB;MAACgF,KAAK,EAAEA;IAAM,GAAEO,WAAW,CAACE,iBAAiB,EAAE/C,KAAK,CAAsB,CAAC;EACvG;EAEA,IAAI2B,WAAW,KAAK,WAAW,EAAE;IAC/B,oBAAOpI,MAAA,YAAA6G,aAAA,CAAC1C,eAAe;MAAC4E,KAAK,EAAEA;IAAM,GAAEO,WAAW,CAACE,iBAAiB,EAAE/C,KAAK,CAAmB,CAAC;EACjG;EAEA,oBAAOzG,MAAA,YAAA6G,aAAA;IAAKkC,KAAK,EAAEA;EAAM,GAAEO,WAAW,CAAClF,cAAc,CAACpB,KAAK,EAAEqB,QAAQ,EAAEa,IAAI,CAACb,QAAQ,CAAC,EAAEoC,KAAK,CAAO,CAAC;AACtG,CAAC;AAEDa,SAAS,CAACN,SAAS,GAAG;EACpB3C,QAAQ,EAAE4C,qBAAS,CAACG,IAAI;EACxBT,QAAQ,EAAEM,qBAAS,CAACC,IAAI;EACxBjC,UAAU,EAAE2E,WAAK,CAACC,cAAc;EAChC/C,QAAQ,EAAEG,qBAAS,CAACC,IAAI;EACxBhC,IAAI,EAAE+B,qBAAS,CAACI;AAClB,CAAC;AAAC,IAAAyC,QAAA,GAAA9E,OAAA,cAEasC,SAAS","ignoreList":[]}
@@ -54,10 +54,6 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
54
54
  args[_key] = arguments[_key];
55
55
  }
56
56
  _this = _callSuper(this, RawBaseCircle, [].concat(args));
57
- // which of from/to/middle has its label edited, null if none
58
- (0, _defineProperty2["default"])(_this, "state", {
59
- editingLabel: null
60
- });
61
57
  (0, _defineProperty2["default"])(_this, "onChangePoint", function (point) {
62
58
  var _this$props = _this.props,
63
59
  middle = _this$props.middle,
@@ -126,13 +122,6 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
126
122
  if (!point.label || (0, _lodashEs.isEmpty)(point.label)) delete update.label;
127
123
  changeMarkProps((0, _defineProperty2["default"])({}, type, update));
128
124
  });
129
- (0, _defineProperty2["default"])(_this, "stopEditingLabel", function () {
130
- if (_this.state.editingLabel !== null) {
131
- _this.setState({
132
- editingLabel: null
133
- });
134
- }
135
- });
136
125
  (0, _defineProperty2["default"])(_this, "clickPoint", function (point, type, data) {
137
126
  var _this$props5 = _this.props,
138
127
  changeMarkProps = _this$props5.changeMarkProps,
@@ -158,28 +147,15 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
158
147
  }, type, _objectSpread({
159
148
  label: ''
160
149
  }, point)));
161
-
162
- // MarkLabel focuses itself once it is rendered - it also holds on to the focus if the model
163
- // that comes back from the host (api save) remounts the input.
164
- _this.setState({
165
- editingLabel: type
166
- });
150
+ if (_this.input[type]) {
151
+ _this.input[type].focus();
152
+ }
167
153
  });
168
154
  (0, _defineProperty2["default"])(_this, "input", {});
169
155
  return _this;
170
156
  }
171
157
  (0, _inherits2["default"])(RawBaseCircle, _React$Component);
172
158
  return (0, _createClass2["default"])(RawBaseCircle, [{
173
- key: "componentDidUpdate",
174
- value: function componentDidUpdate(prevProps) {
175
- // leaving label mode closes any label that is still being edited
176
- if (prevProps.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null) {
177
- this.setState({
178
- editingLabel: null
179
- });
180
- }
181
- }
182
- }, {
183
159
  key: "render",
184
160
  value: function render() {
185
161
  var _this2 = this;
@@ -197,7 +173,6 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
197
173
  graphProps = _this$props6.graphProps,
198
174
  labelNode = _this$props6.labelNode,
199
175
  labelModeEnabled = _this$props6.labelModeEnabled;
200
- var editingLabel = this.state.editingLabel;
201
176
  var common = {
202
177
  onDragStart: onDragStart,
203
178
  onDragStop: onDragStop,
@@ -216,11 +191,9 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
216
191
  inputRef: function inputRef(r) {
217
192
  return _this2.input.from = r;
218
193
  },
219
- autoFocus: editingLabel === 'from',
220
194
  disabled: !labelModeEnabled,
221
195
  mark: from,
222
196
  graphProps: graphProps,
223
- onBlur: this.stopEditingLabel,
224
197
  onChange: function onChange(label) {
225
198
  return _this2.labelChange(_objectSpread(_objectSpread({}, from), {}, {
226
199
  label: label
@@ -233,11 +206,9 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
233
206
  inputRef: function inputRef(r) {
234
207
  return _this2.input.to = r;
235
208
  },
236
- autoFocus: editingLabel === 'to',
237
209
  disabled: !labelModeEnabled,
238
210
  mark: to,
239
211
  graphProps: graphProps,
240
- onBlur: this.stopEditingLabel,
241
212
  onChange: function onChange(label) {
242
213
  return _this2.labelChange(_objectSpread(_objectSpread({}, to), {}, {
243
214
  label: label
@@ -250,11 +221,9 @@ var RawBaseCircle = exports.RawBaseCircle = /*#__PURE__*/function (_React$Compon
250
221
  inputRef: function inputRef(r) {
251
222
  return _this2.input.middle = r;
252
223
  },
253
- autoFocus: editingLabel === 'middle',
254
224
  disabled: !labelModeEnabled,
255
225
  mark: middle,
256
226
  graphProps: graphProps,
257
- onBlur: this.stopEditingLabel,
258
227
  onChange: function onChange(label) {
259
228
  return _this2.labelChange(_objectSpread(_objectSpread({}, middle), {}, {
260
229
  label: label