@pie-lib/plot 5.0.2-next.20261007003844 → 5.0.2-next.20261007021359

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 (3) hide show
  1. package/dist/label.js +41 -40
  2. package/dist/root.js +75 -74
  3. package/package.json +4 -3
package/dist/label.js CHANGED
@@ -6,14 +6,15 @@ import * as a from "@pie-lib/render-ui";
6
6
  import { Readable as o, color as s } from "@pie-lib/render-ui";
7
7
  import { jsx as c } from "react/jsx-runtime";
8
8
  import l from "@pie-lib/editable-html-tip-tap";
9
+ import { sanitizeModelHtml as u } from "@pie-element/shared-utils";
9
10
  //#region src/label.tsx
10
- function u(e) {
11
+ function d(e) {
11
12
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
12
13
  }
13
- function d(e, t) {
14
- return !e || u(e) ? e : u(e.default) ? e.default : t && u(e[t]) ? e[t] : t && u(e[t]?.default) ? e[t].default : e;
14
+ function f(e, t) {
15
+ return !e || d(e) ? e : d(e.default) ? e.default : t && d(e[t]) ? e[t] : t && d(e[t]?.default) ? e[t].default : e;
15
16
  }
16
- var f = d(o, "Readable") || d(h.Readable, "Readable"), p = a, m = p.default, h = m && typeof m == "object" ? m : p, g = {
17
+ var p = f(o, "Readable") || f(g.Readable, "Readable"), m = a, h = m.default, g = h && typeof h == "object" ? h : m, _ = {
17
18
  axisLabel: {
18
19
  fontSize: 12,
19
20
  textAlign: "center",
@@ -55,64 +56,64 @@ var f = d(o, "Readable") || d(h.Readable, "Readable"), p = a, m = p.default, h =
55
56
  width: "100%",
56
57
  textAlign: "center"
57
58
  } }
58
- }, _ = r("div")({ ...g.centerPlaceholder }), v = r("div")({
59
- ...g.disabledLabel,
59
+ }, v = r("div")({ ..._.centerPlaceholder }), y = r("div")({
60
+ ..._.disabledLabel,
60
61
  "& p": { margin: 0 }
61
- }), y = (r) => {
62
- let { disabledLabel: i, graphHeight: a, graphWidth: o, isChartBottomLabel: s, isDefineChartBottomLabel: u, isChartLeftLabel: d, isDefineChartLeftLabel: p, placeholder: m, text: h, side: y, onChange: b, mathMlOptions: x = {}, charactersLimit: S, titleHeight: C, preventNewLines: w } = r, [T, E] = n(!1), D = [
62
+ }), b = (r) => {
63
+ let { disabledLabel: i, graphHeight: a, graphWidth: o, isChartBottomLabel: s, isDefineChartBottomLabel: d, isChartLeftLabel: f, isDefineChartLeftLabel: m, placeholder: h, text: g, side: b, onChange: x, mathMlOptions: S = {}, charactersLimit: C, titleHeight: w, preventNewLines: T } = r, [E, D] = n(!1), O = [
63
64
  "bold",
64
65
  "italic",
65
66
  "underline",
66
67
  "strikethrough",
67
68
  "math"
68
- ], O = s || d || u || p, k = y === "left" && p && a - 220, A = {
69
- width: k || (y === "left" || y === "right" ? a - 8 : o - 8),
70
- top: k || d && `${a - 70}px` || y === "left" && `${a - 8}px` || s && `${a - 60 + C}px` || y === "bottom" && `${a - 120 + C}px` || 0,
71
- left: y === "right" && `${o - 8}px` || (p || u) && "40px" || s && "-10px" || 0
72
- }, j = {
69
+ ], k = s || f || d || m, A = b === "left" && m && a - 220, j = {
70
+ width: A || (b === "left" || b === "right" ? a - 8 : o - 8),
71
+ top: A || f && `${a - 70}px` || b === "left" && `${a - 8}px` || s && `${a - 60 + w}px` || b === "bottom" && `${a - 120 + w}px` || 0,
72
+ left: b === "right" && `${o - 8}px` || (m || d) && "40px" || s && "-10px" || 0
73
+ }, M = {
73
74
  width: o - 8,
74
- top: y === "right" ? `${a - 22}px` : 0,
75
+ top: b === "right" ? `${a - 22}px` : 0,
75
76
  left: 0
76
- }, M = () => {
77
- !i && (y === "left" || y === "right") && E(!0);
78
77
  }, N = () => {
79
- E(!1), requestAnimationFrame(() => {
78
+ !i && (b === "left" || b === "right") && D(!0);
79
+ }, P = () => {
80
+ D(!1), requestAnimationFrame(() => {
80
81
  document.activeElement?.blur?.();
81
82
  });
82
- }, P = (e) => !!(w && e.key === "Enter");
83
- return /* @__PURE__ */ c(f, {
83
+ }, F = (e) => !!(T && e.key === "Enter");
84
+ return /* @__PURE__ */ c(p, {
84
85
  false: !0,
85
- children: /* @__PURE__ */ c(_, {
86
- onClick: M,
86
+ children: /* @__PURE__ */ c(v, {
87
+ onClick: N,
87
88
  style: {
88
- ...T ? j : A,
89
- ...O ? g.chartLabel : g.axisLabel,
90
- ...y === "left" && !T ? g.rotateLeftLabel : {},
91
- ...y === "right" && !T ? g.rotateRightLabel : {},
92
- ...T ? g.editLabel : {},
93
- ...s || u ? g.customBottom : {},
94
- ...i && !O && t(e(h)) && g.displayNone
89
+ ...E ? M : j,
90
+ ...k ? _.chartLabel : _.axisLabel,
91
+ ...b === "left" && !E ? _.rotateLeftLabel : {},
92
+ ...b === "right" && !E ? _.rotateRightLabel : {},
93
+ ...E ? _.editLabel : {},
94
+ ...s || d ? _.customBottom : {},
95
+ ...i && !k && t(e(g)) && _.displayNone
95
96
  },
96
- children: i ? /* @__PURE__ */ c(v, { dangerouslySetInnerHTML: { __html: h || "" } }) : /* @__PURE__ */ c(l, {
97
- markup: h || "",
98
- onChange: b,
99
- placeholder: !i && m,
97
+ children: i ? /* @__PURE__ */ c(y, { dangerouslySetInnerHTML: { __html: u(g) } }) : /* @__PURE__ */ c(l, {
98
+ markup: g || "",
99
+ onChange: x,
100
+ placeholder: !i && h,
100
101
  toolbarOpts: {
101
- position: y === "bottom" ? "top" : "bottom",
102
+ position: b === "bottom" ? "top" : "bottom",
102
103
  noPadding: !0,
103
104
  noBorder: !0
104
105
  },
105
106
  disableScrollbar: !0,
106
- activePlugins: D,
107
- onDone: N,
108
- onKeyDown: P,
109
- mathMlOptions: x,
110
- charactersLimit: S
107
+ activePlugins: O,
108
+ onDone: P,
109
+ onKeyDown: F,
110
+ mathMlOptions: S,
111
+ charactersLimit: C
111
112
  })
112
113
  })
113
114
  });
114
115
  };
115
- y.propTypes = {
116
+ b.propTypes = {
116
117
  disabledLabel: i.bool,
117
118
  graphHeight: i.number,
118
119
  graphWidth: i.number,
@@ -129,4 +130,4 @@ y.propTypes = {
129
130
  titleHeight: i.number
130
131
  };
131
132
  //#endregion
132
- export { y as default };
133
+ export { b as default };
package/dist/root.js CHANGED
@@ -9,39 +9,40 @@ import * as d from "@pie-lib/render-ui";
9
9
  import { Readable as f, color as p } from "@pie-lib/render-ui";
10
10
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
11
  import g from "@pie-lib/editable-html-tip-tap";
12
+ import { sanitizeModelHtml as _ } from "@pie-element/shared-utils";
12
13
  //#region src/root.tsx
13
- function _(e) {
14
+ function v(e) {
14
15
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
15
16
  }
16
- function v(e, t) {
17
- return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
17
+ function y(e, t) {
18
+ return !e || v(e) ? e : v(e.default) ? e.default : t && v(e[t]) ? e[t] : t && v(e[t]?.default) ? e[t].default : e;
18
19
  }
19
- var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S = x && typeof x == "object" ? x : b, C = { "& .ProseMirror p.is-editor-empty::before, & .ProseMirror div.is-editor-empty::before": {
20
+ var b = y(f, "Readable") || y(C.Readable, "Readable"), x = d, S = x.default, C = S && typeof S == "object" ? S : x, w = { "& .ProseMirror p.is-editor-empty::before, & .ProseMirror div.is-editor-empty::before": {
20
21
  left: 0,
21
22
  right: 0,
22
23
  width: "100%",
23
24
  textAlign: "center"
24
- } }, w = s("div")(({ theme: e }) => ({
25
+ } }, T = s("div")(({ theme: e }) => ({
25
26
  border: `solid 1px ${p.primaryLight()}`,
26
27
  color: p.defaults.TEXT,
27
28
  backgroundColor: e.palette.common.white,
28
29
  touchAction: "none",
29
30
  position: "relative",
30
31
  boxSizing: "unset"
31
- })), T = s("div")({
32
+ })), E = s("div")({
32
33
  display: "flex",
33
34
  position: "relative"
34
- }), E = s("svg")({
35
+ }), D = s("svg")({
35
36
  paddingLeft: "50px",
36
37
  overflow: "visible",
37
38
  boxSizing: "content-box"
38
- }), D = s("svg")({
39
+ }), O = s("svg")({
39
40
  overflow: "visible",
40
41
  boxSizing: "content-box"
41
- }), O = s("g")({
42
+ }), k = s("g")({
42
43
  cursor: "pointer",
43
44
  userSelect: "none"
44
- }), k = s("div")(({ theme: e }) => ({
45
+ }), A = s("div")(({ theme: e }) => ({
45
46
  color: p.defaults.TEXT,
46
47
  fontSize: e.typography.fontSize + 2,
47
48
  padding: `${e.spacing(1.5)} ${e.spacing(.5)} 0`,
@@ -49,8 +50,8 @@ var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S =
49
50
  "&.disabledTitle": { pointerEvents: "none" },
50
51
  "&.rightMargin": { marginRight: "74px" },
51
52
  "& p": { margin: 0 },
52
- ...C
53
- })), A = s("div")(({ theme: e }) => ({
53
+ ...w
54
+ })), j = s("div")(({ theme: e }) => ({
54
55
  color: p.defaults.TEXT,
55
56
  fontSize: e.typography.fontSize + 4,
56
57
  padding: `${e.spacing(1.5)} ${e.spacing(.5)} 0`,
@@ -58,29 +59,29 @@ var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S =
58
59
  "&.disabledTitle": { pointerEvents: "none" },
59
60
  "&.rightMargin": { marginRight: "74px" },
60
61
  "& p": { margin: 0 },
61
- ...C
62
- })), j = s("div")({
62
+ ...w
63
+ })), M = s("div")({
63
64
  display: "flex",
64
65
  paddingTop: "6px"
65
- }), M = s("div")({
66
+ }), N = s("div")({
66
67
  display: "flex",
67
68
  flexDirection: "column",
68
69
  alignItems: "center",
69
70
  width: "100px",
70
71
  pointerEvents: "none",
71
72
  userSelect: "none"
72
- }), N = s("div")({
73
+ }), P = s("div")({
73
74
  width: "70px",
74
75
  display: "flex",
75
76
  flexDirection: "column",
76
77
  marginRight: "6px"
77
- }), P = s("div")({
78
+ }), F = s("div")({
78
79
  textAlign: "right",
79
80
  height: "20px",
80
81
  pointerEvents: "none",
81
82
  userSelect: "none",
82
83
  "&:not(:last-child)": { marginBottom: "80px" }
83
- }), F = class extends o.Component {
84
+ }), I = class extends o.Component {
84
85
  constructor(e) {
85
86
  super(e), this.state = { titleHeight: 0 }, this.resizeObserver = null, this.descriptionId = `plot-description-${Math.random().toString(36).slice(2, 10)}`;
86
87
  }
@@ -171,7 +172,7 @@ var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S =
171
172
  this.resizeObserver &&= (this.resizeObserver.disconnect(), null);
172
173
  };
173
174
  render() {
174
- let { disabledTitle: e, disabledLabels: t, labels: o, labelsPlaceholders: s, titlePlaceholder: c, graphProps: l, children: u, defineChart: d, onChangeTitle: f, isChart: p, showLabels: _, showPixelGuides: v, showTitle: b, title: x, rootRef: S, mathMlOptions: C = {}, labelsCharactersLimit: F, ariaLabel: I, ariaDescription: L } = this.props, { size: { width: R = 500, height: z = 500 }, domain: B, range: V } = l, H = i(n(o?.left)) && r(s) ? 48 : 70, U = i(n(o?.right)) && r(s) ? 48 : 70, W = R + H + U + (B.padding || 0) * 2, G = z + 80 + (V.padding || 0) * 2, K = [
175
+ let { disabledTitle: e, disabledLabels: t, labels: o, labelsPlaceholders: s, titlePlaceholder: c, graphProps: l, children: u, defineChart: d, onChangeTitle: f, isChart: p, showLabels: v, showPixelGuides: y, showTitle: x, title: S, rootRef: C, mathMlOptions: w = {}, labelsCharactersLimit: I, ariaLabel: L, ariaDescription: R } = this.props, { size: { width: z = 500, height: B = 500 }, domain: V, range: H } = l, U = i(n(o?.left)) && r(s) ? 48 : 70, W = i(n(o?.right)) && r(s) ? 48 : 70, G = z + U + W + (V.padding || 0) * 2, K = B + 80 + (H.padding || 0) * 2, q = [
175
176
  "bold",
176
177
  "italic",
177
178
  "underline",
@@ -179,112 +180,112 @@ var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S =
179
180
  "subscript",
180
181
  "strikethrough",
181
182
  "math"
182
- ], q = d && v ? z - 160 : z, J = parseInt(R / 100), Y = parseInt(q / 100), X = parseInt(q % 100), { titleHeight: Z } = this.state, Q = {
183
- ...I && {
183
+ ], J = d && y ? B - 160 : B, Y = parseInt(z / 100), X = parseInt(J / 100), Z = parseInt(J % 100), { titleHeight: Q } = this.state, $ = {
184
+ ...L && {
184
185
  role: "group",
185
- "aria-label": I
186
+ "aria-label": L
186
187
  },
187
- ...L && { "aria-describedby": this.descriptionId }
188
- }, $ = L ? /* @__PURE__ */ m("desc", {
188
+ ...R && { "aria-describedby": this.descriptionId }
189
+ }, ee = R ? /* @__PURE__ */ m("desc", {
189
190
  id: this.descriptionId,
190
- children: L
191
+ children: R
191
192
  }) : null;
192
- return /* @__PURE__ */ h(w, { children: [
193
- v && /* @__PURE__ */ m(j, {
194
- style: { marginLeft: p ? 80 : _ ? 30 : 10 },
195
- children: [...Array(J + 1).keys()].map((e) => /* @__PURE__ */ m(y, {
193
+ return /* @__PURE__ */ h(T, { children: [
194
+ y && /* @__PURE__ */ m(M, {
195
+ style: { marginLeft: p ? 80 : v ? 30 : 10 },
196
+ children: [...Array(Y + 1).keys()].map((e) => /* @__PURE__ */ m(b, {
196
197
  false: !0,
197
- children: /* @__PURE__ */ h(M, { children: [/* @__PURE__ */ h("div", { children: [e * 100, "px"] }), /* @__PURE__ */ m("div", { children: "|" })] })
198
+ children: /* @__PURE__ */ h(N, { children: [/* @__PURE__ */ h("div", { children: [e * 100, "px"] }), /* @__PURE__ */ m("div", { children: "|" })] })
198
199
  }, `top-guide-${e}`))
199
200
  }),
200
- b && (e ? /* @__PURE__ */ m("div", {
201
+ x && (e ? /* @__PURE__ */ m("div", {
201
202
  ref: (e) => this.titleRef = e,
202
203
  style: {
203
- ...p && { width: W },
204
- ...i(n(x)) && { display: "none" }
204
+ ...p && { width: G },
205
+ ...i(n(S)) && { display: "none" }
205
206
  },
206
- children: m(p ? A : k, {
207
+ children: m(p ? j : A, {
207
208
  className: "disabledTitle",
208
- dangerouslySetInnerHTML: { __html: x || "" }
209
+ dangerouslySetInnerHTML: { __html: _(S) }
209
210
  })
210
211
  }) : /* @__PURE__ */ m("div", {
211
212
  ref: (e) => this.titleRef = e,
212
- children: m(p ? A : k, {
213
- className: v ? "rightMargin" : "",
213
+ children: m(p ? j : A, {
214
+ className: y ? "rightMargin" : "",
214
215
  children: /* @__PURE__ */ m(g, {
215
- ...p && { width: W },
216
- markup: x || "",
216
+ ...p && { width: G },
217
+ markup: S || "",
217
218
  onChange: f,
218
219
  placeholder: d && c || !e && "Click here to add a title for this graph",
219
220
  toolbarOpts: {
220
221
  noPadding: !0,
221
222
  noBorder: !0
222
223
  },
223
- activePlugins: K,
224
+ activePlugins: q,
224
225
  disableScrollbar: !0,
225
226
  onKeyDown: this.handleKeyDown
226
227
  })
227
228
  })
228
229
  })),
229
- _ && !p && /* @__PURE__ */ m(a, {
230
+ v && !p && /* @__PURE__ */ m(a, {
230
231
  side: "top",
231
232
  text: o.top,
232
233
  disabledLabel: t,
233
234
  placeholder: s?.top,
234
- graphHeight: G,
235
- graphWidth: W,
235
+ graphHeight: K,
236
+ graphWidth: G,
236
237
  onChange: (e) => this.onChangeLabel(e, "top"),
237
- mathMlOptions: C,
238
+ mathMlOptions: w,
238
239
  preventNewLines: !0,
239
- charactersLimit: F
240
+ charactersLimit: I
240
241
  }),
241
- /* @__PURE__ */ h(T, { children: [
242
- _ && /* @__PURE__ */ m(a, {
242
+ /* @__PURE__ */ h(E, { children: [
243
+ v && /* @__PURE__ */ m(a, {
243
244
  side: "left",
244
245
  text: o.left,
245
246
  disabledLabel: t,
246
247
  placeholder: s?.left,
247
- graphHeight: G,
248
- graphWidth: W,
248
+ graphHeight: K,
249
+ graphWidth: G,
249
250
  isChartLeftLabel: p && !d,
250
251
  isDefineChartLeftLabel: p && d,
251
252
  onChange: (e) => this.onChangeLabel(e, "left"),
252
- mathMlOptions: C,
253
+ mathMlOptions: w,
253
254
  preventNewLines: !0,
254
- charactersLimit: F
255
+ charactersLimit: I
255
256
  }),
256
- h(d ? E : D, {
257
- width: W,
258
- height: G,
259
- ...Q,
260
- children: [$, /* @__PURE__ */ m(O, {
257
+ h(d ? D : O, {
258
+ width: G,
259
+ height: K,
260
+ ...$,
261
+ children: [ee, /* @__PURE__ */ m(k, {
261
262
  ref: (e) => {
262
- this.g = e, S && S(e);
263
+ this.g = e, C && C(e);
263
264
  },
264
- transform: `translate(${H + (B.padding || 0)}, ${40 + (V.padding || 0)})`,
265
+ transform: `translate(${U + (V.padding || 0)}, ${40 + (H.padding || 0)})`,
265
266
  children: u
266
267
  })]
267
268
  }),
268
- _ && !p && /* @__PURE__ */ m(a, {
269
+ v && !p && /* @__PURE__ */ m(a, {
269
270
  side: "right",
270
271
  text: o.right,
271
272
  disabledLabel: t,
272
273
  placeholder: s?.right,
273
- graphHeight: G,
274
- graphWidth: W,
274
+ graphHeight: K,
275
+ graphWidth: G,
275
276
  onChange: (e) => this.onChangeLabel(e, "right"),
276
- mathMlOptions: C,
277
+ mathMlOptions: w,
277
278
  preventNewLines: !0,
278
- charactersLimit: F
279
+ charactersLimit: I
279
280
  }),
280
- v && /* @__PURE__ */ m(N, {
281
+ y && /* @__PURE__ */ m(P, {
281
282
  style: {
282
- paddingTop: X,
283
+ paddingTop: Z,
283
284
  marginTop: 31
284
285
  },
285
- children: [...Array(Y + 1).keys()].reverse().map((e) => /* @__PURE__ */ m(y, {
286
+ children: [...Array(X + 1).keys()].reverse().map((e) => /* @__PURE__ */ m(b, {
286
287
  false: !0,
287
- children: /* @__PURE__ */ h(P, { children: [
288
+ children: /* @__PURE__ */ h(F, { children: [
288
289
  "━ ",
289
290
  e * 100,
290
291
  "px"
@@ -292,23 +293,23 @@ var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S =
292
293
  }, `top-guide-${e}`))
293
294
  })
294
295
  ] }),
295
- _ && /* @__PURE__ */ m(a, {
296
+ v && /* @__PURE__ */ m(a, {
296
297
  side: "bottom",
297
298
  text: o.bottom,
298
299
  disabledLabel: t,
299
300
  placeholder: s?.bottom,
300
- graphHeight: G,
301
- graphWidth: W,
302
- titleHeight: Z,
301
+ graphHeight: K,
302
+ graphWidth: G,
303
+ titleHeight: Q,
303
304
  isChartBottomLabel: p && !d,
304
305
  isDefineChartBottomLabel: p && d,
305
306
  onChange: (e) => this.onChangeLabel(e, "bottom"),
306
- mathMlOptions: C,
307
+ mathMlOptions: w,
307
308
  preventNewLines: !0,
308
- charactersLimit: F
309
+ charactersLimit: I
309
310
  })
310
311
  ] });
311
312
  }
312
313
  };
313
314
  //#endregion
314
- export { F as Root, F as default };
315
+ export { I as Root, I as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/plot",
3
- "version": "5.0.2-next.20261007003844",
3
+ "version": "5.0.2-next.20261007021359",
4
4
  "description": "Some underlying components for building charts/graphs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,8 +13,9 @@
13
13
  "@mapbox/point-geometry": "^1.1.0",
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
- "@pie-lib/editable-html-tip-tap": "3.0.2-next.20261007003844",
17
- "@pie-lib/render-ui": "8.0.2-next.20261007003844",
16
+ "@pie-element/shared-utils": "0.2.0-next.20261007021359",
17
+ "@pie-lib/editable-html-tip-tap": "3.0.2-next.20261007021359",
18
+ "@pie-lib/render-ui": "8.0.2-next.20261007021359",
18
19
  "assert": "^2.1.0",
19
20
  "d3-scale": "^4.0.2",
20
21
  "d3-selection": "^3.0.0",