@pie-lib/charting 8.0.1-next.20261004003105 → 8.0.1-next.20261004011201

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -3,17 +3,17 @@ import t from "prop-types";
3
3
  import { styled as n } from "@mui/material/styles";
4
4
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
5
  import { color as a } from "@pie-lib/render-ui";
6
- import o from "@mui/material/Button";
7
- import s from "@mui/material/Popover";
8
- import c from "@mui/material/Paper";
9
- import l from "@pie-lib/translator";
6
+ import o from "@pie-lib/translator";
7
+ import s from "@mui/material/Button";
8
+ import c from "@mui/material/Popover";
9
+ import l from "@mui/material/Paper";
10
10
  //#region src/actions-button.tsx
11
- var { translator: u } = l, d = n("div")(() => ({ alignSelf: "flex-end" })), f = n("div")(({ theme: e }) => ({
11
+ var { translator: u } = o, d = n("div")(() => ({ alignSelf: "flex-end" })), f = n("div")(({ theme: e }) => ({
12
12
  cursor: "pointer",
13
13
  fontSize: e.typography.fontSize,
14
14
  color: a.tertiary(),
15
15
  padding: e.spacing(1)
16
- })), p = n(c)(({ theme: e }) => ({
16
+ })), p = n(l)(({ theme: e }) => ({
17
17
  padding: e.spacing(1),
18
18
  display: "flex",
19
19
  flexDirection: "column",
@@ -58,7 +58,7 @@ var { translator: u } = l, d = n("div")(() => ({ alignSelf: "flex-end" })), f =
58
58
  tabIndex: 0,
59
59
  onClick: this.handleActionsClick,
60
60
  children: "Actions"
61
- }), /* @__PURE__ */ r(s, {
61
+ }), /* @__PURE__ */ r(c, {
62
62
  open: !!n,
63
63
  anchorEl: n,
64
64
  onClose: this.handleActionsClose,
@@ -70,10 +70,10 @@ var { translator: u } = l, d = n("div")(() => ({ alignSelf: "flex-end" })), f =
70
70
  vertical: "top",
71
71
  horizontal: "left"
72
72
  },
73
- children: /* @__PURE__ */ i(p, { children: [/* @__PURE__ */ i(o, {
73
+ children: /* @__PURE__ */ i(p, { children: [/* @__PURE__ */ i(s, {
74
74
  onClick: () => this.handleAddCategory(),
75
75
  children: ["+ ", u.t("charting.add", { lng: t })]
76
- }), e.length > 0 && e.map((e, n) => e.deletable && !e.correctness && /* @__PURE__ */ r(o, {
76
+ }), e.length > 0 && e.map((e, n) => e.deletable && !e.correctness && /* @__PURE__ */ r(s, {
77
77
  onClick: () => this.handleDeleteCategory(n),
78
78
  children: `${u.t("charting.delete", { lng: t })} <${e.label || u.t("charting.newLabel", { lng: t })}>`
79
79
  }, n))] })
package/dist/axes.d.ts CHANGED
@@ -59,6 +59,7 @@ export declare class RawChartAxes extends React.Component {
59
59
  hiddenLabelRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.InferProps<{
60
60
  current: PropTypes.Requireable<Element>;
61
61
  }> | null | undefined>>;
62
+ language: PropTypes.Requireable<string>;
62
63
  };
63
64
  state: {
64
65
  height: number;
package/dist/axes.js CHANGED
@@ -12,23 +12,24 @@ import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
12
  import { color as m } from "@pie-lib/render-ui";
13
13
  import h from "@mui/material/Checkbox";
14
14
  import { renderMath as g } from "@pie-element/shared-math-rendering-mathjax";
15
+ import _ from "@pie-lib/translator";
15
16
  //#region src/axes.tsx
16
- var _ = /* @__PURE__ */ new Set(), v = null;
17
- function y(e) {
18
- _.add(e), !v && typeof document < "u" && (v = new MutationObserver(() => {
19
- _.forEach((e) => e());
20
- }), v.observe(document.body, {
17
+ var { translator: v } = _, y = /* @__PURE__ */ new Set(), b = null;
18
+ function x(e) {
19
+ y.add(e), !b && typeof document < "u" && (b = new MutationObserver(() => {
20
+ y.forEach((e) => e());
21
+ }), b.observe(document.body, {
21
22
  childList: !0,
22
23
  subtree: !0
23
24
  }));
24
25
  }
25
- function b(e) {
26
- _.delete(e), _.size === 0 && v && (v.disconnect(), v = null);
26
+ function S(e) {
27
+ y.delete(e), y.size === 0 && b && (b.disconnect(), b = null);
27
28
  }
28
- var x = l("text")(({ theme: e }) => ({
29
+ var C = l("text")(({ theme: e }) => ({
29
30
  fontSize: e.typography.fontSize - 2,
30
31
  fill: e.palette.error.main
31
- })), S = l(h)(() => ({ color: `${m.tertiary()} !important` })), C = l("g")(({ theme: e }) => ({
32
+ })), w = l(h)(() => ({ color: `${m.tertiary()} !important` })), T = l("g")(({ theme: e }) => ({
32
33
  "& .vx-axis-line": {
33
34
  stroke: m.visualElementsColors.AXIS_LINE_COLOR,
34
35
  strokeWidth: 2
@@ -43,7 +44,7 @@ var x = l("text")(({ theme: e }) => ({
43
44
  fontSize: e.typography.fontSize,
44
45
  textAnchor: "middle"
45
46
  }
46
- })), w = (e) => ({
47
+ })), E = (e) => ({
47
48
  borderRadius: e.spacing(2),
48
49
  color: m.defaults.WHITE,
49
50
  fontSize: "16px",
@@ -52,7 +53,7 @@ var x = l("text")(({ theme: e }) => ({
52
53
  padding: "2px",
53
54
  border: `1px solid ${m.defaults.WHITE}`,
54
55
  boxSizing: "unset"
55
- }), T = { backgroundColor: m.incorrectWithIcon() }, E = { backgroundColor: m.correct() }, D = class extends s.Component {
56
+ }), D = { backgroundColor: m.incorrectWithIcon() }, O = { backgroundColor: m.correct() }, k = class extends s.Component {
56
57
  static propTypes = {
57
58
  defineChart: c.bool,
58
59
  error: c.any
@@ -112,16 +113,16 @@ var x = l("text")(({ theme: e }) => ({
112
113
  return n;
113
114
  };
114
115
  render() {
115
- let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: s, top: c, graphProps: l, defineChart: u, chartingOptions: m, x: h, y: g, formattedValue: _, changeInteractiveEnabled: v, changeEditableEnabled: y, error: b, autoFocus: C, hiddenLabelRef: D, showCorrectness: O } = this.props;
116
+ let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: s, top: c, graphProps: l, defineChart: u, chartingOptions: m, x: h, y: g, formattedValue: _, changeInteractiveEnabled: y, changeEditableEnabled: b, error: x, autoFocus: S, hiddenLabelRef: T, showCorrectness: k, language: A } = this.props;
116
117
  if (!_) return null;
117
- let k = {
118
- correctnessIcon: w,
119
- incorrectIcon: T,
120
- correctIcon: E
121
- }, { dialog: A } = this.state, { changeEditable: j, changeInteractive: M } = m || {}, N = parseInt(_.split("-")[0], 10), P = e[N], { editable: F, interactive: I, label: L, correctness: R } = P || {}, z = t(r({ label: L }, N)), B = (e || []).reduce((e, t) => (e && e.label ? e.label.length : 0) > (t && t.label ? t.label.length : 0) ? e : t, { label: "" }), V = b ? [...new Set(Object.values(b))].join(" ") : "";
118
+ let j = {
119
+ correctnessIcon: E,
120
+ incorrectIcon: D,
121
+ correctIcon: O
122
+ }, { dialog: M } = this.state, { changeEditable: N, changeInteractive: P } = m || {}, F = parseInt(_.split("-")[0], 10), I = e[F], { editable: L, interactive: R, label: z, correctness: B } = I || {}, V = t(r({ label: z }, F)), H = (e || []).reduce((e, t) => (e && e.label ? e.label.length : 0) > (t && t.label ? t.label.length : 0) ? e : t, { label: "" }), U = x ? [...new Set(Object.values(x))].join(" ") : "";
122
123
  return /* @__PURE__ */ p("g", { children: [
123
124
  /* @__PURE__ */ p("foreignObject", {
124
- x: i ? z : h - a / 2,
125
+ x: i ? V : h - a / 2,
125
126
  y: 18,
126
127
  width: a,
127
128
  height: 4,
@@ -129,42 +130,46 @@ var x = l("text")(({ theme: e }) => ({
129
130
  pointerEvents: "none",
130
131
  overflow: "visible"
131
132
  },
132
- children: [N === 0 && /* @__PURE__ */ f(o, {
133
+ children: [F === 0 && /* @__PURE__ */ f(o, {
133
134
  isHiddenLabel: !0,
134
- inputRef: D,
135
+ inputRef: T,
135
136
  disabled: !0,
136
- mark: B,
137
+ mark: H,
137
138
  graphProps: l,
138
139
  barWidth: a
139
140
  }), /* @__PURE__ */ f(o, {
140
- autoFocus: u && C,
141
+ autoFocus: u && S,
141
142
  inputRef: (e) => this.input = e,
142
- disabled: !u && !F,
143
- mark: P,
143
+ disabled: !u && !L,
144
+ mark: I,
144
145
  graphProps: l,
145
- onChange: (e) => this.changeCategory(N, e),
146
+ onChange: (e) => this.changeCategory(F, e),
146
147
  barWidth: a,
147
148
  rotate: s,
148
- correctness: R,
149
- error: b && b[N],
149
+ correctness: B,
150
+ error: x && x[F],
151
+ ariaLabel: v.t("charting.categoryLabel", {
152
+ lng: A,
153
+ index: F + 1
154
+ }),
150
155
  limitCharacters: !0,
151
- correctnessIndicator: O && R && /* @__PURE__ */ f(n, {
152
- correctness: R,
153
- interactive: I,
154
- classes: k
156
+ correctnessIndicator: k && B && /* @__PURE__ */ f(n, {
157
+ correctness: B,
158
+ interactive: R,
159
+ classes: j
155
160
  })
156
161
  })]
157
162
  }),
158
- b && N === 0 && /* @__PURE__ */ f(x, {
163
+ x && F === 0 && /* @__PURE__ */ f(C, {
159
164
  y: g + 23,
160
165
  height: 6,
161
166
  textAnchor: "start",
162
- children: V
167
+ children: U
163
168
  }),
164
- u && N === 0 && /* @__PURE__ */ p("svg", {
169
+ u && F === 0 && /* @__PURE__ */ p("svg", {
165
170
  x: -55,
166
171
  style: { overflow: "visible" },
167
- children: [v && /* @__PURE__ */ f("text", {
172
+ children: [y && /* @__PURE__ */ f("text", {
168
173
  y: g + 90 + c,
169
174
  width: a,
170
175
  height: 4,
@@ -175,12 +180,12 @@ var x = l("text")(({ theme: e }) => ({
175
180
  maxWidth: a,
176
181
  display: "inline-block"
177
182
  },
178
- children: this.splitText(M?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ f("tspan", {
183
+ children: this.splitText(P?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ f("tspan", {
179
184
  x: "0",
180
185
  dy: `${t > 0 ? "1.2em" : ".6em"}`,
181
186
  children: e
182
187
  }, t))
183
- }), y && /* @__PURE__ */ f("text", {
188
+ }), b && /* @__PURE__ */ f("text", {
184
189
  y: g + 145 + c,
185
190
  width: a,
186
191
  height: 4,
@@ -191,14 +196,14 @@ var x = l("text")(({ theme: e }) => ({
191
196
  maxWidth: a,
192
197
  display: "inline-block"
193
198
  },
194
- children: this.splitText(j?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ f("tspan", {
199
+ children: this.splitText(N?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ f("tspan", {
195
200
  x: "0",
196
201
  dy: `${t > 0 ? "1.2em" : ".6em"}`,
197
202
  children: e
198
203
  }, t))
199
204
  })]
200
205
  }),
201
- u && v && /* @__PURE__ */ f("foreignObject", {
206
+ u && y && /* @__PURE__ */ f("foreignObject", {
202
207
  x: h - 24,
203
208
  y: g + 80 + c,
204
209
  width: a,
@@ -207,13 +212,13 @@ var x = l("text")(({ theme: e }) => ({
207
212
  pointerEvents: "visible",
208
213
  overflow: "visible"
209
214
  },
210
- children: /* @__PURE__ */ f(S, {
215
+ children: /* @__PURE__ */ f(w, {
211
216
  style: { position: "fixed" },
212
- checked: I,
213
- onChange: (e) => this.changeInteractive(N, e.target.checked)
217
+ checked: R,
218
+ onChange: (e) => this.changeInteractive(F, e.target.checked)
214
219
  })
215
220
  }),
216
- u && y && /* @__PURE__ */ f("foreignObject", {
221
+ u && b && /* @__PURE__ */ f("foreignObject", {
217
222
  x: h - 24,
218
223
  y: g + 130 + c,
219
224
  width: a,
@@ -222,10 +227,10 @@ var x = l("text")(({ theme: e }) => ({
222
227
  pointerEvents: "visible",
223
228
  overflow: "visible"
224
229
  },
225
- children: /* @__PURE__ */ f(S, {
230
+ children: /* @__PURE__ */ f(w, {
226
231
  style: { position: "fixed" },
227
- checked: F,
228
- onChange: (e) => this.changeEditable(N, e.target.checked)
232
+ checked: L,
233
+ onChange: (e) => this.changeEditable(F, e.target.checked)
229
234
  })
230
235
  }),
231
236
  /* @__PURE__ */ f("foreignObject", {
@@ -238,17 +243,17 @@ var x = l("text")(({ theme: e }) => ({
238
243
  overflow: "visible"
239
244
  },
240
245
  children: /* @__PURE__ */ f(d, {
241
- open: A.open,
242
- title: A.title,
243
- text: A.text,
244
- onClose: A.onClose,
245
- onConfirm: A.onConfirm
246
+ open: M.open,
247
+ title: M.title,
248
+ text: M.text,
249
+ onClose: M.onClose,
250
+ onConfirm: M.onConfirm
246
251
  })
247
252
  })
248
253
  ] });
249
254
  }
250
255
  };
251
- D.propTypes = {
256
+ k.propTypes = {
252
257
  categories: c.array,
253
258
  xBand: c.func,
254
259
  bandWidth: c.number,
@@ -269,9 +274,10 @@ D.propTypes = {
269
274
  autoFocus: c.bool,
270
275
  onAutoFocusUsed: c.func,
271
276
  showCorrectness: c.bool,
272
- hiddenLabelRef: c.oneOfType([c.func, c.shape({ current: c.instanceOf(Element) })])
277
+ hiddenLabelRef: c.oneOfType([c.func, c.shape({ current: c.instanceOf(Element) })]),
278
+ language: c.string
273
279
  };
274
- var O = class extends s.Component {
280
+ var A = class extends s.Component {
275
281
  static propTypes = {
276
282
  bottomScale: c.func,
277
283
  categories: c.array,
@@ -290,7 +296,8 @@ var O = class extends s.Component {
290
296
  autoFocus: c.bool,
291
297
  onAutoFocusUsed: c.func,
292
298
  showCorrectness: c.bool,
293
- hiddenLabelRef: c.oneOfType([c.func, c.shape({ current: c.instanceOf(Element) })])
299
+ hiddenLabelRef: c.oneOfType([c.func, c.shape({ current: c.instanceOf(Element) })]),
300
+ language: c.string
294
301
  };
295
302
  state = {
296
303
  height: 0,
@@ -310,7 +317,7 @@ var O = class extends s.Component {
310
317
  observeHiddenLabel = (e) => {
311
318
  if (!e) return;
312
319
  let t = e.querySelector("[data-latex], [data-raw]");
313
- t && g(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), y(this._onDocMutation);
320
+ t && g(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), x(this._onDocMutation);
314
321
  };
315
322
  setHiddenLabelRef = (e) => {
316
323
  e && e !== this.hiddenLabelRef && (this.hiddenLabelRef = e, this.observeHiddenLabel(e));
@@ -319,38 +326,38 @@ var O = class extends s.Component {
319
326
  this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef);
320
327
  }
321
328
  componentWillUnmount() {
322
- b(this._onDocMutation), this._updateTimer && clearTimeout(this._updateTimer);
329
+ S(this._onDocMutation), this._updateTimer && clearTimeout(this._updateTimer);
323
330
  }
324
331
  componentDidUpdate(e) {
325
332
  e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50));
326
333
  }
327
334
  render() {
328
- let { graphProps: n, xBand: r, leftAxis: o, onChange: s, onChangeCategory: c, categories: l = [], top: u, defineChart: d, chartingOptions: m, changeInteractiveEnabled: h, changeEditableEnabled: g, theme: _, autoFocus: v, onAutoFocusUsed: y, error: b, showCorrectness: x } = this.props, { scale: S = {}, range: w = {}, domain: T = {}, size: E = {} } = n || {}, { height: O, width: k } = this.state, A = r && typeof r.rangeRound == "function" && r.rangeRound([0, E.width]), j = r && typeof r.bandwidth == "function" && r.bandwidth(), M = j || S.x && S.x(T.max) / l.length, N = a({
335
+ let { graphProps: n, xBand: r, leftAxis: o, onChange: s, onChangeCategory: c, categories: l = [], top: u, defineChart: d, chartingOptions: m, changeInteractiveEnabled: h, changeEditableEnabled: g, theme: _, autoFocus: v, onAutoFocusUsed: y, error: b, showCorrectness: x, language: S } = this.props, { scale: C = {}, range: w = {}, domain: E = {}, size: D = {} } = n || {}, { height: O, width: A } = this.state, j = r && typeof r.rangeRound == "function" && r.rangeRound([0, D.width]), M = r && typeof r.bandwidth == "function" && r.bandwidth(), N = M || C.x && C.x(E.max) / l.length, P = a({
329
336
  ...w,
330
337
  step: w.labelStep
331
- }), P = i(_ && _.typography ? _.typography.fontSize : 14, O), F = k > M ? 25 : 0;
332
- return /* @__PURE__ */ p(C, { children: [o && /* @__PURE__ */ f(e, {
333
- scale: S.y,
338
+ }), F = i(_ && _.typography ? _.typography.fontSize : 14, O), I = A > N ? 25 : 0;
339
+ return /* @__PURE__ */ p(T, { children: [o && /* @__PURE__ */ f(e, {
340
+ scale: C.y,
334
341
  tickLength: 10,
335
342
  tickFormat: (e) => e,
336
- tickValues: N,
343
+ tickValues: P,
337
344
  tickLabelProps: (e) => ({
338
345
  dy: 4,
339
346
  dx: -10 - (e.toLocaleString().length || 1) * 5
340
347
  })
341
348
  }), /* @__PURE__ */ f(t, {
342
- scale: A,
349
+ scale: j,
343
350
  labelProps: { y: 60 + u },
344
- top: S.y && S.y(w.min),
351
+ top: C.y && C.y(w.min),
345
352
  textLabelProps: () => ({ textAnchor: "middle" }),
346
353
  tickFormat: (e) => e,
347
- tickComponent: (e) => /* @__PURE__ */ f(D, {
354
+ tickComponent: (e) => /* @__PURE__ */ f(k, {
348
355
  hiddenLabelRef: this.setHiddenLabelRef,
349
356
  categories: l,
350
357
  xBand: r,
351
- bandWidth: j,
352
- barWidth: M,
353
- rotate: P || F,
358
+ bandWidth: M,
359
+ barWidth: N,
360
+ rotate: F || I,
354
361
  top: u,
355
362
  defineChart: d,
356
363
  chartingOptions: m,
@@ -365,7 +372,8 @@ var O = class extends s.Component {
365
372
  x: e.x,
366
373
  y: e.y,
367
374
  formattedValue: e.formattedValue,
368
- showCorrectness: x
375
+ showCorrectness: x,
376
+ language: S
369
377
  }),
370
378
  autoFocus: v,
371
379
  onAutoFocusUsed: y
@@ -373,4 +381,4 @@ var O = class extends s.Component {
373
381
  }
374
382
  };
375
383
  //#endregion
376
- export { O as RawChartAxes, O as default, D as TickComponent };
384
+ export { A as RawChartAxes, A as default, k as TickComponent };
package/dist/chart.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ export declare const chartAlternative: ({ title, chartType, categories, range, language }: {
4
+ title: any;
5
+ chartType: any;
6
+ categories: any;
7
+ range: any;
8
+ language: any;
9
+ }) => {
10
+ ariaLabel: string;
11
+ ariaDescription: string;
12
+ };
3
13
  export declare class Chart extends React.Component {
4
14
  constructor(props: any);
5
15
  static propTypes: {
package/dist/chart.js CHANGED
@@ -8,12 +8,34 @@ import l from "prop-types";
8
8
  import { styled as u } from "@mui/material/styles";
9
9
  import d from "debug";
10
10
  import { cloneDeep as f } from "@pie-element/shared-lodash";
11
- import { Root as p, createGraphProps as m } from "@pie-lib/plot";
12
- import { AlertDialog as h } from "@pie-lib/config-ui";
13
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
14
- import v from "@pie-lib/translator";
11
+ import { Root as p, createGraphProps as m, utils as h } from "@pie-lib/plot";
12
+ import { AlertDialog as g } from "@pie-lib/config-ui";
13
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
14
+ import y from "@pie-lib/translator";
15
15
  //#region src/chart.tsx
16
- var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({ width: "min-content" })), S = class extends c.Component {
16
+ var { translator: b } = y, ee = d("pie-lib:charts:chart"), x = u("div")(() => ({ width: "min-content" })), S = (e) => e ? h.extractTextFromHTML(e).trim() : "", C = ({ title: e, chartType: t, categories: n, range: r, language: i }) => {
17
+ let a = {
18
+ lng: i,
19
+ interpolation: { escapeValue: !1 }
20
+ }, o = b.t(`charting.chartTypes.${t}`, a), s = S(r.label), c = s ? b.t("charting.labelledValueRange", {
21
+ ...a,
22
+ label: s,
23
+ min: r.min,
24
+ max: r.max
25
+ }) : b.t("charting.valueRange", {
26
+ ...a,
27
+ min: r.min,
28
+ max: r.max
29
+ }), l = b.t("charting.categories", {
30
+ ...a,
31
+ count: n.length,
32
+ categories: n.map((e) => S(e.label)).join(", ")
33
+ });
34
+ return {
35
+ ariaLabel: S(e) || o,
36
+ ariaDescription: `${o}. ${l} ${c}`
37
+ };
38
+ }, w = class extends c.Component {
17
39
  constructor(e) {
18
40
  super(e), this.state = {
19
41
  dialog: { open: !1 },
@@ -114,15 +136,15 @@ var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({
114
136
  let { onDataChange: e, data: t, categoryDefaultLabel: n, defineChart: r, categoryDefaults: i, language: a } = this.props;
115
137
  (t || []).length > 19 ? this.setState({ dialog: {
116
138
  open: !0,
117
- title: y.t("common:warning", { lng: a }),
118
- text: y.t("charting.reachedLimit_other", {
139
+ title: b.t("common:warning", { lng: a }),
140
+ text: b.t("charting.reachedLimit_other", {
119
141
  count: 20,
120
142
  lng: a
121
143
  }),
122
144
  onConfirm: () => this.handleAlertDialog(!1)
123
145
  } }) : (this.setState({ autoFocus: !0 }), e([...t, {
124
146
  inDefineChart: r,
125
- label: n || y.t("charting.newLabel", { lng: a }),
147
+ label: n || b.t("charting.newLabel", { lng: a }),
126
148
  value: 0,
127
149
  deletable: !0,
128
150
  editable: !i || i?.editable,
@@ -144,27 +166,36 @@ var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({
144
166
  this.setState({ autoFocus: !1 });
145
167
  };
146
168
  render() {
147
- let { domain: o = {}, range: c = {}, chartingOptions: l, size: u, title: d, onChangeTitle: v, onChangeLabels: y, labelsPlaceholders: S, titlePlaceholder: C, addCategoryEnabled: w, changeInteractiveEnabled: T, changeEditableEnabled: E, showPixelGuides: D, error: O, mathMlOptions: k = {}, language: A, labelsCharactersLimit: j, correctData: M } = this.props, { chartType: N } = this.props, { dialog: P } = this.state, F = this.props.defineChart || !1, { width: I, height: L } = u || {}, R = {
169
+ let { domain: o = {}, range: c = {}, chartingOptions: l, size: u, title: d, onChangeTitle: h, onChangeLabels: y, labelsPlaceholders: b, titlePlaceholder: S, addCategoryEnabled: w, changeInteractiveEnabled: T, changeEditableEnabled: E, showPixelGuides: D, error: O, mathMlOptions: k = {}, language: A, labelsCharactersLimit: j, correctData: M } = this.props, { chartType: N } = this.props, { dialog: P } = this.state, F = this.props.defineChart || !1, { width: I, height: L } = u || {}, R = {
148
170
  left: c?.label || "",
149
171
  bottom: o?.label || ""
150
- }, { ChartComponent: z } = this.getChart(), B = this.getFilteredCategories(), V = n(o, c, N), { verticalLines: H, horizontalLines: U, leftAxis: W } = r(V.range, N), G = { graphProps: m(V.domain, V.range, u, () => this.rootNode) };
151
- b("[render] common:", G);
152
- let K = {
172
+ }, { type: z, ChartComponent: B } = this.getChart(), V = this.getFilteredCategories(), H = n(o, c, N), { ariaLabel: U, ariaDescription: W } = C({
173
+ title: d,
174
+ chartType: z,
175
+ categories: V,
176
+ range: {
177
+ ...H.range,
178
+ label: c.label
179
+ },
180
+ language: A
181
+ }), { verticalLines: G, horizontalLines: K, leftAxis: q } = r(H.range, N), J = { graphProps: m(H.domain, H.range, u, () => this.rootNode) };
182
+ ee("[render] common:", J);
183
+ let Y = {
153
184
  x: -10,
154
185
  y: -75,
155
186
  width: I + 20,
156
187
  height: L + 130
157
- }, { scale: q } = G.graphProps, J = t(q.x, B, I, N), Y = J.bandwidth() || q.x(V.domain.max) / B.length, X = F ? 160 : 60, Z = i(Y), Q = f(G);
158
- return Q.graphProps.size.height += Z + X, (N === "dotPlot" || N === "linePlot") && M?.length && R.bottom && (Q.graphProps.size.height += 25), /* @__PURE__ */ _(x, { children: [/* @__PURE__ */ _(p, {
188
+ }, { scale: X } = J.graphProps, Z = t(X.x, V, I, N), te = Z.bandwidth() || X.x(H.domain.max) / V.length, ne = F ? 160 : 60, Q = i(te), $ = f(J);
189
+ return $.graphProps.size.height += Q + ne, (N === "dotPlot" || N === "linePlot") && M?.length && R.bottom && ($.graphProps.size.height += 25), /* @__PURE__ */ v(x, { children: [/* @__PURE__ */ v(p, {
159
190
  title: d,
160
- onChangeTitle: v,
191
+ onChangeTitle: h,
161
192
  disabledTitle: !F,
162
193
  showTitle: !0,
163
194
  showLabels: !0,
164
195
  labels: R,
165
196
  onChangeLabels: y,
166
- labelsPlaceholders: S,
167
- titlePlaceholder: C,
197
+ labelsPlaceholders: b,
198
+ titlePlaceholder: S,
168
199
  defineChart: F,
169
200
  disabledLabels: !F,
170
201
  isChart: !0,
@@ -172,64 +203,67 @@ var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({
172
203
  rootRef: (e) => this.rootNode = e,
173
204
  mathMlOptions: k,
174
205
  labelsCharactersLimit: j,
175
- ...Q,
206
+ ariaLabel: U,
207
+ ariaDescription: W,
208
+ ...$,
176
209
  children: [
177
- /* @__PURE__ */ g(e, {
178
- ...G,
179
- xBand: J,
180
- rowTickValues: U,
181
- columnTickValues: H
210
+ /* @__PURE__ */ _(e, {
211
+ ...J,
212
+ xBand: Z,
213
+ rowTickValues: K,
214
+ columnTickValues: G
182
215
  }),
183
- /* @__PURE__ */ g(a, {
216
+ /* @__PURE__ */ _(a, {
184
217
  autoFocus: this.state.autoFocus,
185
218
  onAutoFocusUsed: this.resetAutoFocus,
186
- ...G,
219
+ ...J,
187
220
  defineChart: F,
188
- categories: B,
189
- xBand: J,
190
- leftAxis: W,
221
+ categories: V,
222
+ xBand: Z,
223
+ leftAxis: q,
191
224
  onChange: this.changeData,
192
225
  onChangeCategory: this.changeCategory,
193
226
  chartingOptions: l,
194
227
  changeInteractiveEnabled: T,
195
228
  changeEditableEnabled: E,
196
- top: Z,
229
+ top: Q,
197
230
  error: O,
198
- showCorrectness: N === "linePlot" || N === "dotPlot"
231
+ showCorrectness: N === "linePlot" || N === "dotPlot",
232
+ language: A
199
233
  }),
200
- w ? /* @__PURE__ */ g("foreignObject", {
234
+ w ? /* @__PURE__ */ _("foreignObject", {
201
235
  x: I,
202
236
  y: L - 16,
203
237
  width: I,
204
238
  height: L,
205
- children: /* @__PURE__ */ g("div", {
239
+ children: /* @__PURE__ */ _("div", {
206
240
  xmlns: "http://www.w3.org/1999/xhtml",
207
241
  style: {
208
242
  display: "flex",
209
243
  justifyContent: "flex-start"
210
244
  },
211
- children: /* @__PURE__ */ g(s, {
212
- categories: B,
245
+ children: /* @__PURE__ */ _(s, {
246
+ categories: V,
213
247
  addCategory: this.addCategory,
214
248
  deleteCategory: this.deleteCategory,
215
249
  language: A
216
250
  })
217
251
  })
218
252
  }) : null,
219
- /* @__PURE__ */ g("mask", {
253
+ /* @__PURE__ */ _("mask", {
220
254
  id: `${this.maskUid}`,
221
- children: /* @__PURE__ */ g("rect", {
222
- ...K,
255
+ children: /* @__PURE__ */ _("rect", {
256
+ ...Y,
223
257
  fill: "white"
224
258
  })
225
259
  }),
226
- /* @__PURE__ */ g("g", {
260
+ /* @__PURE__ */ _("g", {
227
261
  id: "marks",
228
262
  mask: `url('#${this.maskUid}')`,
229
- children: z && /* @__PURE__ */ g(z, {
230
- ...G,
231
- data: B,
232
- height: Q.graphProps.size.height,
263
+ children: B && /* @__PURE__ */ _(B, {
264
+ ...J,
265
+ data: V,
266
+ height: $.graphProps.size.height,
233
267
  defineChart: F,
234
268
  onChange: this.changeData,
235
269
  onChangeCategory: this.changeCategory,
@@ -237,7 +271,7 @@ var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({
237
271
  })
238
272
  })
239
273
  ]
240
- }), /* @__PURE__ */ g(h, {
274
+ }), /* @__PURE__ */ _(g, {
241
275
  open: P.open,
242
276
  title: P.title,
243
277
  text: P.text,
@@ -247,4 +281,4 @@ var { translator: y } = v, b = d("pie-lib:charts:chart"), x = u("div")(() => ({
247
281
  }
248
282
  };
249
283
  //#endregion
250
- export { S as Chart, S as default };
284
+ export { w as Chart, w as default, C as chartAlternative };
@@ -3,9 +3,9 @@ import e from "prop-types";
3
3
  import { styled as t } from "@mui/material/styles";
4
4
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
5
  import { color as i } from "@pie-lib/render-ui";
6
- import a from "@mui/icons-material/Check";
7
- import o from "@mui/icons-material/Close";
8
- import s from "@pie-lib/translator";
6
+ import a from "@pie-lib/translator";
7
+ import o from "@mui/icons-material/Check";
8
+ import s from "@mui/icons-material/Close";
9
9
  //#region src/key-legend.tsx
10
10
  var c = t("div")(({ theme: e }) => ({
11
11
  backgroundColor: i.defaults.WHITE,
@@ -22,11 +22,11 @@ var c = t("div")(({ theme: e }) => ({
22
22
  })), u = t("div")(({ theme: e }) => ({
23
23
  fontSize: e.typography.h6.fontSize,
24
24
  fontWeight: "700"
25
- })), d = t("div")(() => ({ marginLeft: "2px" })), f = t(a)(({ theme: e }) => ({
25
+ })), d = t("div")(() => ({ marginLeft: "2px" })), f = t(o)(({ theme: e }) => ({
26
26
  backgroundColor: i.correct(),
27
27
  borderRadius: e.spacing(2),
28
28
  color: i.defaults.WHITE
29
- })), p = t(o)(({ theme: e }) => ({
29
+ })), p = t(s)(({ theme: e }) => ({
30
30
  backgroundColor: i.incorrectWithIcon(),
31
31
  borderRadius: e.spacing(2),
32
32
  color: i.defaults.WHITE
@@ -35,7 +35,7 @@ var c = t("div")(({ theme: e }) => ({
35
35
  display: "flex",
36
36
  alignItems: "center",
37
37
  gap: "12px"
38
- })), { translator: h } = s, g = ({ language: e }) => /* @__PURE__ */ r(c, { children: [
38
+ })), { translator: h } = a, g = ({ language: e }) => /* @__PURE__ */ r(c, { children: [
39
39
  /* @__PURE__ */ n(u, { children: "Key" }),
40
40
  /* @__PURE__ */ r(l, { children: [/* @__PURE__ */ n(p, {}), /* @__PURE__ */ n("div", { children: h.t("charting.keyLegend.incorrectAnswer", { lng: e }) })] }),
41
41
  /* @__PURE__ */ r(l, { children: [/* @__PURE__ */ n(f, {}), /* @__PURE__ */ n("div", { children: h.t("charting.keyLegend.correctAnswer", { lng: e }) })] }),
@@ -42,6 +42,7 @@ export declare const MarkLabel: {
42
42
  isHiddenLabel: PropTypes.Requireable<boolean>;
43
43
  limitCharacters: PropTypes.Requireable<boolean>;
44
44
  correctnessIndicator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
45
+ ariaLabel: PropTypes.Requireable<string>;
45
46
  };
46
47
  };
47
48
  export default MarkLabel;
@@ -51,22 +51,22 @@ function b(e) {
51
51
  if (y(e)) return i[0] && i[1] && (r = i[0]), a = `\\(${r}\\frac{${n[0]}}{${n[1]}}\\)`, a;
52
52
  }
53
53
  var x = (n) => {
54
- let [r, i] = c(null), l = a((e) => i(e), null), { mark: u = {}, disabled: d, inputRef: m, barWidth: y, rotate: x, correctness: S, autoFocus: C, error: w, isHiddenLabel: T, limitCharacters: E, correctnessIndicator: D } = n, [O, k] = c(u.label), [A, j] = c(b(u.label)), [M, N] = c(!1), P = s(null), F = (e) => {
55
- E && e.target.value && e.target.value.length > 20 || k(e.target.value);
56
- }, I = () => M === !1 && A !== void 0, L = (e) => {
57
- j(b(u.label)), N(!1), n.onChange(e.target.value);
58
- }, R = {};
59
- return x && (R = {
54
+ let [r, i] = c(null), l = a((e) => i(e), null), { mark: u = {}, disabled: d, inputRef: m, barWidth: y, rotate: x, correctness: S, autoFocus: C, error: w, isHiddenLabel: T, limitCharacters: E, correctnessIndicator: D, ariaLabel: O } = n, [k, A] = c(u.label), [j, M] = c(b(u.label)), [N, P] = c(!1), F = s(null), I = (e) => {
55
+ E && e.target.value && e.target.value.length > 20 || A(e.target.value);
56
+ }, L = () => N === !1 && j !== void 0, R = (e) => {
57
+ M(b(u.label)), P(!1), n.onChange(e.target.value);
58
+ }, z = {};
59
+ return x && (z = {
60
60
  width: "unset",
61
61
  textAlign: "left"
62
62
  }), o(() => {
63
- k(u.label);
63
+ A(u.label);
64
64
  }, [u.label]), o(() => {
65
- let e = P.current;
66
- e && A && (e.innerHTML = A, h(e));
67
- }, [O, A]), /* @__PURE__ */ p(g, { children: [D, I() ? /* @__PURE__ */ f(v, {
65
+ let e = F.current;
66
+ e && j && (e.innerHTML = j, h(e));
67
+ }, [k, j]), /* @__PURE__ */ p(g, { children: [D, L() ? /* @__PURE__ */ f(v, {
68
68
  ref: (e) => {
69
- P.current = e, typeof m == "function" && m(e);
69
+ F.current = e, typeof m == "function" && m(e);
70
70
  },
71
71
  className: e({
72
72
  disabledMarkLabel: d,
@@ -74,7 +74,7 @@ var x = (n) => {
74
74
  correct: u.editable && S?.label === "correct",
75
75
  incorrect: u.editable && S?.label === "incorrect"
76
76
  }),
77
- onClick: () => N(!0),
77
+ onClick: () => P(!0),
78
78
  style: {
79
79
  minWidth: y,
80
80
  position: "fixed",
@@ -88,7 +88,8 @@ var x = (n) => {
88
88
  l(e), typeof m == "function" && m(e);
89
89
  },
90
90
  name: "mark-label-input",
91
- autoFocus: M || C,
91
+ "aria-label": O,
92
+ autoFocus: N || C,
92
93
  disabled: d,
93
94
  inputClassName: e(S && u.editable ? S.label : null, d && "disabledMarkLabel", w && "error"),
94
95
  inputStyle: {
@@ -103,9 +104,9 @@ var x = (n) => {
103
104
  color: _,
104
105
  WebkitTextFillColor: _
105
106
  } : {},
106
- ...R
107
+ ...z
107
108
  },
108
- value: O,
109
+ value: k,
109
110
  style: {
110
111
  position: "fixed",
111
112
  pointerEvents: "auto",
@@ -117,8 +118,8 @@ var x = (n) => {
117
118
  visibility: T ? "hidden" : "unset",
118
119
  marginTop: D ? "24px" : "0"
119
120
  },
120
- onChange: F,
121
- onBlur: L
121
+ onChange: I,
122
+ onBlur: R
122
123
  })] });
123
124
  };
124
125
  x.propTypes = {
@@ -137,7 +138,8 @@ x.propTypes = {
137
138
  }),
138
139
  isHiddenLabel: l.bool,
139
140
  limitCharacters: l.bool,
140
- correctnessIndicator: l.node
141
+ correctnessIndicator: l.node,
142
+ ariaLabel: l.string
141
143
  };
142
144
  //#endregion
143
145
  export { x as MarkLabel, x as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/charting",
3
- "version": "8.0.1-next.20261004003105",
3
+ "version": "8.0.1-next.20261004011201",
4
4
  "description": "charting",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,9 +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/plot": "5.0.1-next.20261004003105",
16
+ "@pie-lib/plot": "5.0.1-next.20261004011201",
17
17
  "@pie-lib/render-ui": "8.0.1-next.20261003161149",
18
- "@pie-lib/translator": "5.0.1-next.20261004003105",
18
+ "@pie-lib/translator": "5.0.1-next.20261004011201",
19
19
  "@visx/axis": "^4.0.0",
20
20
  "@visx/event": "^4.0.0",
21
21
  "@visx/grid": "^4.0.0",
@@ -29,7 +29,7 @@
29
29
  "invariant": "^2.2.4",
30
30
  "react-draggable": "^4.7.1",
31
31
  "prop-types": "^15.8.1",
32
- "@pie-lib/config-ui": "14.0.1-next.20261004003105",
32
+ "@pie-lib/config-ui": "14.0.1-next.20261004011201",
33
33
  "@pie-element/shared-math-rendering-mathjax": "0.1.2-next.20261003161149",
34
34
  "@pie-element/shared-lodash": "0.1.2-next.20261002215153",
35
35
  "clsx": "^2.1.1",