@pie-lib/graphing 4.0.5-next.31 → 4.0.5-next.32

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 (93) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +3 -3
  2. package/dist/axis/arrow.js +1 -1
  3. package/dist/axis/axes.js +6 -6
  4. package/dist/container/index.js +4 -4
  5. package/dist/container/reducer.js +1 -1
  6. package/dist/coordinates-label.js +1 -1
  7. package/dist/graph-with-controls.js +4 -4
  8. package/dist/graph.js +2 -2
  9. package/dist/grid-setup.js +8 -8
  10. package/dist/grid.js +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/labels.js +1 -1
  13. package/dist/mark-label.d.ts +2 -0
  14. package/dist/mark-label.js +99 -69
  15. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +1 -1
  16. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +1 -1
  17. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +1 -1
  18. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +1 -1
  19. package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +1 -1
  20. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +1 -1
  21. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +1 -1
  22. package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-shape.js +8 -0
  23. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +1 -1
  24. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_Hash.js +1 -1
  25. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_ListCache.js +1 -1
  26. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_Map.js +1 -1
  27. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_MapCache.js +1 -1
  28. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_Symbol.js +1 -1
  29. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_assocIndexOf.js +1 -1
  30. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_baseGetTag.js +1 -1
  31. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_baseIsNative.js +1 -1
  32. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_coreJsData.js +1 -1
  33. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_freeGlobal.js +1 -1
  34. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_getMapData.js +1 -1
  35. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_getNative.js +1 -1
  36. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_getRawTag.js +1 -1
  37. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_getValue.js +1 -1
  38. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_hashClear.js +1 -1
  39. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_hashDelete.js +1 -1
  40. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_hashGet.js +1 -1
  41. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_hashHas.js +1 -1
  42. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_hashSet.js +1 -1
  43. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_isKeyable.js +1 -1
  44. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_isMasked.js +1 -1
  45. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_listCacheClear.js +1 -1
  46. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_listCacheDelete.js +1 -1
  47. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_listCacheGet.js +1 -1
  48. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_listCacheHas.js +1 -1
  49. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_listCacheSet.js +1 -1
  50. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_mapCacheClear.js +1 -1
  51. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_mapCacheDelete.js +1 -1
  52. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_mapCacheGet.js +1 -1
  53. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_mapCacheHas.js +1 -1
  54. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_mapCacheSet.js +1 -1
  55. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_nativeCreate.js +1 -1
  56. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_objectToString.js +1 -1
  57. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_root.js +1 -1
  58. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/_toSource.js +1 -1
  59. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/eq.js +1 -1
  60. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/isFunction.js +1 -1
  61. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/isObject.js +1 -1
  62. package/dist/node_modules/.bun/{lodash@4.17.21 → lodash@4.18.1}/node_modules/lodash/memoize.js +1 -1
  63. package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +7 -7
  64. package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +1 -1
  65. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +2 -2
  66. package/dist/toggle-bar.js +1 -1
  67. package/dist/tool-menu.js +3 -3
  68. package/dist/tools/circle/bg-circle.js +2 -2
  69. package/dist/tools/circle/component.d.ts +5 -0
  70. package/dist/tools/circle/component.js +30 -17
  71. package/dist/tools/index.js +1 -1
  72. package/dist/tools/line/component.js +2 -2
  73. package/dist/tools/point/component.d.ts +2 -0
  74. package/dist/tools/point/component.js +16 -10
  75. package/dist/tools/point/index.js +1 -1
  76. package/dist/tools/polygon/component.d.ts +5 -0
  77. package/dist/tools/polygon/component.js +27 -18
  78. package/dist/tools/polygon/index.js +1 -1
  79. package/dist/tools/polygon/line.js +1 -1
  80. package/dist/tools/polygon/polygon.js +3 -3
  81. package/dist/tools/ray/component.js +2 -2
  82. package/dist/tools/segment/component.js +1 -1
  83. package/dist/tools/shared/line/index.d.ts +10 -4
  84. package/dist/tools/shared/line/index.js +27 -14
  85. package/dist/tools/shared/line/line-path.js +2 -2
  86. package/dist/tools/shared/line/with-root-edge.d.ts +10 -4
  87. package/dist/tools/shared/line/with-root-edge.js +3 -3
  88. package/dist/tools/shared/point/base-point.js +1 -1
  89. package/dist/tools/vector/component.js +1 -1
  90. package/dist/undo-redo.js +2 -2
  91. package/dist/utils.js +1 -1
  92. package/package.json +15 -10
  93. package/dist/node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js +0 -2
@@ -1,4 +1,4 @@
1
- import e from "./component.js";
1
+ import { Point as e } from "./component.js";
2
2
  //#region src/tools/point/index.ts
3
3
  var t = () => ({
4
4
  label: "Point",
@@ -66,11 +66,16 @@ export declare class RawBaseComponent extends React.Component {
66
66
  static defaultProps: {
67
67
  points: never[];
68
68
  };
69
+ state: {
70
+ editingLabel: null;
71
+ };
72
+ componentDidUpdate(prevProps: any): void;
69
73
  dragPoint: any;
70
74
  dragLine: any;
71
75
  dragPoly: any;
72
76
  close: any;
73
77
  labelChange: any;
78
+ stopEditingLabel: any;
74
79
  clickPoint: any;
75
80
  input: {};
76
81
  render(): React.JSX.Element;
@@ -3,7 +3,7 @@ import { require_browser as t } from "../../node_modules/.bun/invariant@2.2.4/no
3
3
  import { equalPoints as n, getMiddleOfTwoPoints as r, getRightestPoints as i, stripEmptyLabel as a } from "../../utils.js";
4
4
  import { BasePoint as o } from "../shared/point/index.js";
5
5
  import { ToolPropTypeFields as s } from "../shared/types.js";
6
- import c from "../../mark-label.js";
6
+ import { MarkLabel as c } from "../../mark-label.js";
7
7
  import l from "./line.js";
8
8
  import u, { Polygon as d } from "./polygon.js";
9
9
  import f from "react";
@@ -62,6 +62,10 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
62
62
  onChangeProps: p.func
63
63
  };
64
64
  static defaultProps = { points: [] };
65
+ state = { editingLabel: null };
66
+ componentDidUpdate(e) {
67
+ e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
68
+ }
65
69
  dragPoint = (e, t, r) => {
66
70
  C("[dragPoint] from, to:", t, r);
67
71
  let { onChange: i, points: a } = this.props, o = [...a], s = !!(a || []).find((e) => n(e, r));
@@ -89,6 +93,9 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
89
93
  let a = [...n];
90
94
  a.splice(t, 1, i), r(a);
91
95
  };
96
+ stopEditingLabel = () => {
97
+ this.state.editingLabel !== null && this.setState({ editingLabel: null });
98
+ };
92
99
  clickPoint = (e, t, n) => {
93
100
  let { closed: o, disabled: s, middle: c, onClick: l, isToolActive: u, labelModeEnabled: d, limitLabeling: f, onSetMiddleLabel: p, points: m } = this.props;
94
101
  if (d) {
@@ -107,9 +114,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
107
114
  ...e
108
115
  }), p(c && a(c), n);
109
116
  }
110
- setTimeout(() => {
111
- this.input[t] && this.input[t].focus();
112
- }, 0);
117
+ this.setState({ editingLabel: t });
113
118
  return;
114
119
  }
115
120
  if (u && !o && t === 0) {
@@ -120,18 +125,20 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
120
125
  };
121
126
  input = {};
122
127
  render() {
123
- let { closed: e, coordinatesOnHover: t, correctness: n, disabled: r, graphProps: i, onChangeLabelProps: a, onDragStart: s, onDragStop: p, points: m, middle: h, labelNode: g, labelModeEnabled: _ } = this.props, v = w(m, e), S = {
128
+ let { closed: e, coordinatesOnHover: t, correctness: n, disabled: r, graphProps: i, onChangeLabelProps: a, onDragStart: s, onDragStop: p, points: m, middle: h, labelNode: g, labelModeEnabled: _ } = this.props, { editingLabel: v } = this.state, S = w(m, e), C = {
124
129
  onDragStart: s,
125
130
  onDragStop: p,
126
131
  graphProps: i,
127
132
  disabled: r,
128
133
  correctness: n
129
- }, C = m && m.length || 0, T = null;
130
- return g && h && Object.prototype.hasOwnProperty.call(h, "label") && (T = x.createPortal(/* @__PURE__ */ y(c, {
131
- inputRef: (e) => this.input[C] = e,
134
+ }, T = m && m.length || 0, E = null;
135
+ return g && h && Object.prototype.hasOwnProperty.call(h, "label") && (E = x.createPortal(/* @__PURE__ */ y(c, {
136
+ inputRef: (e) => this.input[T] = e,
137
+ autoFocus: v === T,
132
138
  disabled: r || !_,
133
139
  mark: h,
134
140
  graphProps: i,
141
+ onBlur: this.stopEditingLabel,
135
142
  onChange: (e) => a({
136
143
  ...h,
137
144
  label: e
@@ -141,19 +148,19 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
141
148
  points: m,
142
149
  onDrag: this.dragPoly.bind(this, m),
143
150
  closed: e,
144
- ...S,
145
- onClick: this.clickPoint.bind(this, h, C)
146
- }), T] }) : /* @__PURE__ */ y(d, {
151
+ ...C,
152
+ onClick: this.clickPoint.bind(this, h, T)
153
+ }), E] }) : /* @__PURE__ */ y(d, {
147
154
  points: m,
148
155
  graphProps: i,
149
156
  closed: e
150
157
  }),
151
- (v || []).map((e, t) => /* @__PURE__ */ y(l, {
158
+ (S || []).map((e, t) => /* @__PURE__ */ y(l, {
152
159
  from: e.from,
153
160
  to: e.to,
154
161
  onDrag: this.dragLine.bind(this, e),
155
- ...S,
156
- onClick: this.clickPoint.bind(this, h, C)
162
+ ...C,
163
+ onClick: this.clickPoint.bind(this, h, T)
157
164
  }, `line-${t}`)),
158
165
  (m || []).map((e, n) => [/* @__PURE__ */ y(o, {
159
166
  coordinatesOnHover: t,
@@ -161,13 +168,15 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
161
168
  x: e.x,
162
169
  y: e.y,
163
170
  onDrag: this.dragPoint.bind(this, n, e),
164
- ...S,
171
+ ...C,
165
172
  onClick: this.clickPoint.bind(this, e, n)
166
173
  }, `point-${n}`), g && Object.prototype.hasOwnProperty.call(e, "label") ? x.createPortal(/* @__PURE__ */ y(c, {
167
174
  inputRef: (e) => this.input[n] = e,
175
+ autoFocus: v === n,
168
176
  disabled: r || !_,
169
177
  mark: e,
170
178
  graphProps: i,
179
+ onBlur: this.stopEditingLabel,
171
180
  onChange: (t) => this.labelChange({
172
181
  ...e,
173
182
  label: t
@@ -175,7 +184,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
175
184
  }), g) : null])
176
185
  ] });
177
186
  }
178
- }, D = class extends f.Component {
187
+ }, D = E, O = class extends f.Component {
179
188
  static propTypes = {
180
189
  ...s,
181
190
  graphProps: _.GraphPropsType.isRequired
@@ -239,7 +248,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
239
248
  };
240
249
  render() {
241
250
  let { coordinatesOnHover: e, mark: t, graphProps: n, onClick: r, isToolActive: i, labelNode: a, labelModeEnabled: o, limitLabeling: s } = this.props, { mark: c } = this.state;
242
- return /* @__PURE__ */ y(E, {
251
+ return /* @__PURE__ */ y(D, {
243
252
  ...c || t,
244
253
  coordinatesOnHover: e,
245
254
  onChange: this.change,
@@ -259,4 +268,4 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
259
268
  }
260
269
  };
261
270
  //#endregion
262
- export { D as default };
271
+ export { D as BaseComponent, E as RawBaseComponent, w as buildLines, O as default, T as swap };
@@ -52,4 +52,4 @@ var n = (t, n) => {
52
52
  }
53
53
  });
54
54
  //#endregion
55
- export { r as tool };
55
+ export { n as addPointToArray, r as tool };
@@ -60,4 +60,4 @@ var u = s("line")(({ disabled: e, correctness: t }) => ({
60
60
  }
61
61
  })(d);
62
62
  //#endregion
63
- export { f as default };
63
+ export { d as Line, f as default };
@@ -56,7 +56,7 @@ var g = p("polygon")(({ disabled: e, correctness: t }) => ({
56
56
  ...o
57
57
  });
58
58
  }
59
- }, b = u({
59
+ }, b = y, x = u({
60
60
  bounds: (t, { domain: r, range: i }) => {
61
61
  let { points: a } = t;
62
62
  return e(n(a), r, i);
@@ -69,6 +69,6 @@ var g = p("polygon")(({ disabled: e, correctness: t }) => ({
69
69
  let { points: r } = e;
70
70
  return r.map((e) => t(e).add(t(n)));
71
71
  }
72
- })(y);
72
+ })(b);
73
73
  //#endregion
74
- export { y as Polygon, b as default };
74
+ export { b as Polygon, y as RawPolygon, x as default, v as getPointString };
@@ -1,5 +1,5 @@
1
1
  import { getAdjustedGraphLimits as e, thinnerShapesNeeded as t } from "../../utils.js";
2
- import n from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
2
+ import { clsx as n } from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
3
3
  import { ArrowMarker as r, genUid as i } from "../shared/arrow-head.js";
4
4
  import { lineBase as a, lineToolComponent as o, styles as s } from "../shared/line/index.js";
5
5
  import "react";
@@ -68,4 +68,4 @@ h.propTypes = {
68
68
  };
69
69
  var g = o(a(h));
70
70
  //#endregion
71
- export { g as default };
71
+ export { h as RayLine, g as default };
@@ -49,4 +49,4 @@ l.propTypes = {
49
49
  };
50
50
  var u = t(e(l));
51
51
  //#endregion
52
- export { u as default };
52
+ export { l as Line, u as default };
@@ -87,6 +87,10 @@ export declare const lineToolComponent: (Component: any) => {
87
87
  };
88
88
  export declare const lineBase: (Comp: any, opts: any) => {
89
89
  new (props: {}): {
90
+ state: {
91
+ editingLabel: null;
92
+ };
93
+ componentDidUpdate(prevProps: any): void;
90
94
  onChangePoint: any;
91
95
  dragComp: ({ from: draggedFrom, to: draggedTo }: {
92
96
  from: any;
@@ -95,6 +99,7 @@ export declare const lineBase: (Comp: any, opts: any) => {
95
99
  dragFrom: any;
96
100
  dragTo: any;
97
101
  labelChange: any;
102
+ stopEditingLabel: any;
98
103
  clickPoint: any;
99
104
  input: {};
100
105
  render(): React.JSX.Element;
@@ -102,7 +107,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
102
107
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
103
108
  forceUpdate(callback?: (() => void) | undefined): void;
104
109
  readonly props: Readonly<{}>;
105
- state: Readonly<{}>;
106
110
  refs: {
107
111
  [key: string]: React.ReactInstance;
108
112
  };
@@ -111,7 +115,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
111
115
  componentWillUnmount?(): void;
112
116
  componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
113
117
  getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
114
- componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
115
118
  componentWillMount?(): void;
116
119
  UNSAFE_componentWillMount?(): void;
117
120
  componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
@@ -120,6 +123,10 @@ export declare const lineBase: (Comp: any, opts: any) => {
120
123
  UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
121
124
  };
122
125
  new (props: {}, context: any): {
126
+ state: {
127
+ editingLabel: null;
128
+ };
129
+ componentDidUpdate(prevProps: any): void;
123
130
  onChangePoint: any;
124
131
  dragComp: ({ from: draggedFrom, to: draggedTo }: {
125
132
  from: any;
@@ -128,6 +135,7 @@ export declare const lineBase: (Comp: any, opts: any) => {
128
135
  dragFrom: any;
129
136
  dragTo: any;
130
137
  labelChange: any;
138
+ stopEditingLabel: any;
131
139
  clickPoint: any;
132
140
  input: {};
133
141
  render(): React.JSX.Element;
@@ -135,7 +143,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
135
143
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
136
144
  forceUpdate(callback?: (() => void) | undefined): void;
137
145
  readonly props: Readonly<{}>;
138
- state: Readonly<{}>;
139
146
  refs: {
140
147
  [key: string]: React.ReactInstance;
141
148
  };
@@ -144,7 +151,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
144
151
  componentWillUnmount?(): void;
145
152
  componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
146
153
  getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
147
- componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
148
154
  componentWillMount?(): void;
149
155
  UNSAFE_componentWillMount?(): void;
150
156
  componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
@@ -1,7 +1,7 @@
1
1
  import { equalPoints as e, getMiddleOfTwoPoints as t, sameAxes as n, stripEmptyLabel as r } from "../../../utils.js";
2
2
  import { correct as i, disabled as a, disabledSecondary as o, incorrect as s, missing as c } from "../styles.js";
3
3
  import { BasePoint as l } from "../point/index.js";
4
- import u from "../../../mark-label.js";
4
+ import { MarkLabel as u } from "../../../mark-label.js";
5
5
  import d from "react";
6
6
  import f from "prop-types";
7
7
  import { cloneDeep as p, isEmpty as m, isEqual as h } from "@pie-element/shared-lodash";
@@ -154,6 +154,10 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
154
154
  labelModeEnabled: f.bool,
155
155
  labelNode: f.object
156
156
  };
157
+ state = { editingLabel: null };
158
+ componentDidUpdate(e) {
159
+ e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
160
+ }
157
161
  onChangePoint = (n) => {
158
162
  let { middle: r, onChange: i } = this.props, { from: a, to: o } = n;
159
163
  e(a, o) || (r && (n.middle = {
@@ -191,6 +195,9 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
191
195
  let { changeMarkProps: n } = this.props, r = { ...e };
192
196
  (!e.label || m(e.label)) && delete r.label, n({ [t]: r });
193
197
  };
198
+ stopEditingLabel = () => {
199
+ this.state.editingLabel !== null && this.setState({ editingLabel: null });
200
+ };
194
201
  clickPoint = (e, n, i) => {
195
202
  let { changeMarkProps: a, disabled: o, from: s, to: c, middle: l, labelModeEnabled: u, limitLabeling: d, onClick: f } = this.props;
196
203
  if (!u) {
@@ -208,41 +215,47 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
208
215
  label: "",
209
216
  ...e
210
217
  }
211
- }), this.input[n] && this.input[n].focus());
218
+ }), this.setState({ editingLabel: n }));
212
219
  };
213
220
  input = {};
214
221
  render() {
215
- let { coordinatesOnHover: e, graphProps: t, onDragStart: n, onDragStop: r, from: i, to: c, middle: l, disabled: d, correctness: f, onClick: p, labelNode: m, labelModeEnabled: h } = this.props, g = {
222
+ let { coordinatesOnHover: e, graphProps: t, onDragStart: n, onDragStop: r, from: i, to: c, middle: l, disabled: d, correctness: f, onClick: p, labelNode: m, labelModeEnabled: h } = this.props, { editingLabel: g } = this.state, v = {
216
223
  graphProps: t,
217
224
  onDragStart: n,
218
225
  onDragStop: r,
219
226
  disabled: d,
220
227
  correctness: f,
221
228
  onClick: p
222
- }, v = c ? _.toDegrees(_.angle(i, c)) : 0, y = null, b = null, C = null;
223
- return m && (i && Object.prototype.hasOwnProperty.call(i, "label") && (y = w.createPortal(/* @__PURE__ */ x(u, {
229
+ }, y = c ? _.toDegrees(_.angle(i, c)) : 0, b = null, C = null, E = null;
230
+ return m && (i && Object.prototype.hasOwnProperty.call(i, "label") && (b = w.createPortal(/* @__PURE__ */ x(u, {
224
231
  inputRef: (e) => this.input.from = e,
232
+ autoFocus: g === "from",
225
233
  disabled: !h,
226
234
  mark: i,
227
235
  graphProps: t,
236
+ onBlur: this.stopEditingLabel,
228
237
  onChange: (e) => this.labelChange({
229
238
  ...i,
230
239
  label: e
231
240
  }, "from")
232
- }), m)), c && Object.prototype.hasOwnProperty.call(c, "label") && (b = w.createPortal(/* @__PURE__ */ x(u, {
241
+ }), m)), c && Object.prototype.hasOwnProperty.call(c, "label") && (C = w.createPortal(/* @__PURE__ */ x(u, {
233
242
  inputRef: (e) => this.input.to = e,
243
+ autoFocus: g === "to",
234
244
  disabled: !h,
235
245
  mark: c,
236
246
  graphProps: t,
247
+ onBlur: this.stopEditingLabel,
237
248
  onChange: (e) => this.labelChange({
238
249
  ...c,
239
250
  label: e
240
251
  }, "to")
241
- }), m)), l && Object.prototype.hasOwnProperty.call(l, "label") && (C = w.createPortal(/* @__PURE__ */ x(u, {
252
+ }), m)), l && Object.prototype.hasOwnProperty.call(l, "label") && (E = w.createPortal(/* @__PURE__ */ x(u, {
242
253
  inputRef: (e) => this.input.middle = e,
254
+ autoFocus: g === "middle",
243
255
  disabled: !h,
244
256
  mark: l,
245
257
  graphProps: t,
258
+ onBlur: this.stopEditingLabel,
246
259
  onChange: (e) => this.labelChange({
247
260
  ...l,
248
261
  label: e
@@ -256,31 +269,31 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
256
269
  to: c,
257
270
  middle: l,
258
271
  onDrag: this.dragComp,
259
- ...g,
272
+ ...v,
260
273
  onClick: (e) => this.clickPoint(l, "middle", e)
261
274
  }),
262
- C,
275
+ E,
263
276
  /* @__PURE__ */ x(o, {
264
277
  x: i.x,
265
278
  y: i.y,
266
279
  labelNode: m,
267
280
  coordinatesOnHover: e,
268
281
  onDrag: this.dragFrom,
269
- ...g,
282
+ ...v,
270
283
  onClick: (e) => this.clickPoint(i, "from", e)
271
284
  }),
272
- y,
285
+ b,
273
286
  c && /* @__PURE__ */ x(s, {
274
287
  x: c.x,
275
288
  y: c.y,
276
- angle: v,
289
+ angle: y,
277
290
  labelNode: m,
278
291
  coordinatesOnHover: e,
279
292
  onDrag: this.dragTo,
280
- ...g,
293
+ ...v,
281
294
  onClick: (e) => this.clickPoint(c, "to", e)
282
295
  }),
283
- b
296
+ C
284
297
  ]
285
298
  });
286
299
  }
@@ -66,6 +66,6 @@ var f = () => ({
66
66
  ...d
67
67
  })] });
68
68
  }
69
- };
69
+ }, g = h;
70
70
  //#endregion
71
- export { h as LinePath };
71
+ export { g as LinePath, h as RawLinePath };
@@ -24,6 +24,10 @@ export declare const rootEdgeComponent: (RootEdgeComp: any) => {
24
24
  };
25
25
  export declare const withRootEdge: (getPoints: any) => {
26
26
  new (props: {}): {
27
+ state: {
28
+ editingLabel: null;
29
+ };
30
+ componentDidUpdate(prevProps: any): void;
27
31
  onChangePoint: any;
28
32
  dragComp: ({ from: draggedFrom, to: draggedTo }: {
29
33
  from: any;
@@ -32,6 +36,7 @@ export declare const withRootEdge: (getPoints: any) => {
32
36
  dragFrom: any;
33
37
  dragTo: any;
34
38
  labelChange: any;
39
+ stopEditingLabel: any;
35
40
  clickPoint: any;
36
41
  input: {};
37
42
  render(): React.JSX.Element;
@@ -39,7 +44,6 @@ export declare const withRootEdge: (getPoints: any) => {
39
44
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
40
45
  forceUpdate(callback?: (() => void) | undefined): void;
41
46
  readonly props: Readonly<{}>;
42
- state: Readonly<{}>;
43
47
  refs: {
44
48
  [key: string]: React.ReactInstance;
45
49
  };
@@ -48,7 +52,6 @@ export declare const withRootEdge: (getPoints: any) => {
48
52
  componentWillUnmount?(): void;
49
53
  componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
50
54
  getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
51
- componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
52
55
  componentWillMount?(): void;
53
56
  UNSAFE_componentWillMount?(): void;
54
57
  componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
@@ -57,6 +60,10 @@ export declare const withRootEdge: (getPoints: any) => {
57
60
  UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
58
61
  };
59
62
  new (props: {}, context: any): {
63
+ state: {
64
+ editingLabel: null;
65
+ };
66
+ componentDidUpdate(prevProps: any): void;
60
67
  onChangePoint: any;
61
68
  dragComp: ({ from: draggedFrom, to: draggedTo }: {
62
69
  from: any;
@@ -65,6 +72,7 @@ export declare const withRootEdge: (getPoints: any) => {
65
72
  dragFrom: any;
66
73
  dragTo: any;
67
74
  labelChange: any;
75
+ stopEditingLabel: any;
68
76
  clickPoint: any;
69
77
  input: {};
70
78
  render(): React.JSX.Element;
@@ -72,7 +80,6 @@ export declare const withRootEdge: (getPoints: any) => {
72
80
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
73
81
  forceUpdate(callback?: (() => void) | undefined): void;
74
82
  readonly props: Readonly<{}>;
75
- state: Readonly<{}>;
76
83
  refs: {
77
84
  [key: string]: React.ReactInstance;
78
85
  };
@@ -81,7 +88,6 @@ export declare const withRootEdge: (getPoints: any) => {
81
88
  componentWillUnmount?(): void;
82
89
  componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
83
90
  getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
84
- componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
85
91
  componentWillMount?(): void;
86
92
  UNSAFE_componentWillMount?(): void;
87
93
  componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
@@ -1,5 +1,5 @@
1
1
  import { LinePath as e } from "./line-path.js";
2
- import { curveMonotoneX as t } from "../../../node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js";
2
+ import { d3_shape_exports as t } from "../../../node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-shape.js";
3
3
  import { lineBase as n, lineToolComponent as r } from "./index.js";
4
4
  import "react";
5
5
  import i from "prop-types";
@@ -46,7 +46,7 @@ var s = (e) => {
46
46
  data: _,
47
47
  from: a,
48
48
  to: s,
49
- curve: t,
49
+ curve: t.curveMonotoneX,
50
50
  ...v,
51
51
  ...m
52
52
  }) : /* @__PURE__ */ o(e, {
@@ -70,4 +70,4 @@ var s = (e) => {
70
70
  }, r;
71
71
  }, f = (e) => n(d(e));
72
72
  //#endregion
73
- export { u as rootEdgeComponent, f as withRootEdge };
73
+ export { u as rootEdgeComponent, l as rootEdgeToFromToWrapper, f as withRootEdge };
@@ -1,5 +1,5 @@
1
1
  import { thinnerShapesNeeded as e } from "../../../utils.js";
2
- import t from "../../../coordinates-label.js";
2
+ import { CoordinatesLabel as t } from "../../../coordinates-label.js";
3
3
  import n from "../icons/MissingSVG.js";
4
4
  import r from "../icons/CorrectSVG.js";
5
5
  import i from "../icons/IncorrectSVG.js";
@@ -41,4 +41,4 @@ u.propTypes = {
41
41
  };
42
42
  var d = r(n(u, { to: t }));
43
43
  //#endregion
44
- export { d as default };
44
+ export { u as Line, d as default };
package/dist/undo-redo.js CHANGED
@@ -1,4 +1,4 @@
1
- import e from "./node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
1
+ import { clsx as e } from "./node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
2
2
  import t from "react";
3
3
  import n from "prop-types";
4
4
  import { styled as r } from "@mui/material/styles";
@@ -44,4 +44,4 @@ var { translator: l } = c, u = r(s)(({ theme: e }) => ({
44
44
  }
45
45
  };
46
46
  //#endregion
47
- export { d as default };
47
+ export { d as UndoRedo, d as default };
package/dist/utils.js CHANGED
@@ -72,4 +72,4 @@ var d = c.bounds, f = c.point, p = () => 0, m = () => 0, h = (e) => {
72
72
  });
73
73
  };
74
74
  //#endregion
75
- export { v as amountToIncreaseWidth, m as arrowDimensions, d as bounds, g as countWords, E as equalPoints, _ as findLongestWord, k as getAdjustedGraphLimits, p as getAngleDeg, A as getDistanceBetweenTwoPoints, C as getMiddleOfTwoPoints, S as getRightestPoints, h as getTickValues, F as isDuplicatedMark, b as lineToArea, f as point, y as polygonToArea, w as roundNumber, T as sameAxes, u as stripEmptyLabel, O as thinnerShapesNeeded };
75
+ export { v as amountToIncreaseWidth, m as arrowDimensions, d as bounds, g as countWords, E as equalPoints, _ as findLongestWord, k as getAdjustedGraphLimits, p as getAngleDeg, A as getDistanceBetweenTwoPoints, C as getMiddleOfTwoPoints, S as getRightestPoints, h as getTickValues, F as isDuplicatedMark, b as lineToArea, f as point, x as pointsToArea, y as polygonToArea, w as roundNumber, T as sameAxes, u as stripEmptyLabel, O as thinnerShapesNeeded };
package/package.json CHANGED
@@ -1,23 +1,28 @@
1
1
  {
2
2
  "name": "@pie-lib/graphing",
3
- "version": "4.0.5-next.31",
3
+ "version": "4.0.5-next.32",
4
4
  "description": "Graphing components",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/pie-framework/pie-elements-ng.git",
8
+ "directory": "packages/lib-react/graphing"
9
+ },
5
10
  "dependencies": {
6
11
  "@dnd-kit/sortable": "10.0.0",
7
12
  "@emotion/react": "^11.14.0",
8
- "@emotion/style": "^0.8.0",
13
+ "@emotion/styled": "^11.14.1",
9
14
  "@mapbox/point-geometry": "^1.1.0",
10
15
  "@mui/icons-material": "^7.3.4",
11
16
  "@mui/material": "^7.3.4",
12
- "@pie-lib/drag": "4.0.3-next.38",
13
- "@pie-lib/editable-html-tip-tap": "2.1.2-next.31",
14
- "@pie-lib/graphing-utils": "3.0.3-next.1",
15
- "@pie-lib/plot": "4.0.4-next.31",
16
- "@pie-lib/render-ui": "6.1.1-next.38",
17
- "@pie-lib/translator": "4.0.3-next.1",
17
+ "@pie-lib/drag": "4.0.3-next.39",
18
+ "@pie-lib/editable-html-tip-tap": "2.1.2-next.32",
19
+ "@pie-lib/graphing-utils": "3.0.3-next.2",
20
+ "@pie-lib/plot": "4.0.4-next.32",
21
+ "@pie-lib/render-ui": "6.1.1-next.39",
22
+ "@pie-lib/translator": "4.0.3-next.2",
18
23
  "@visx/axis": "^3.0.0",
19
24
  "@visx/clip-path": "^3.0.0",
20
- "@visx/curve": "^3.0.0",
25
+ "@visx/curve": "^4.0.0",
21
26
  "@visx/event": "^3.0.0",
22
27
  "@visx/grid": "^3.0.0",
23
28
  "@visx/group": "^3.0.0",
@@ -33,7 +38,7 @@
33
38
  "redux": "^5.0.1",
34
39
  "redux-undo": "^1.1.0",
35
40
  "@pie-element/shared-lodash": "0.1.1-next.1",
36
- "@pie-lib/config-ui": "13.0.4-next.31",
41
+ "@pie-lib/config-ui": "13.0.4-next.32",
37
42
  "@dnd-kit/core": "^6.3.1",
38
43
  "@dnd-kit/utilities": "^3.2.2",
39
44
  "clsx": "^2.1.1",
@@ -1,2 +0,0 @@
1
- import { curveMonotoneX as e } from "d3-shape";
2
- export { e as curveMonotoneX };