enefit-design-system 0.6.2-alpha.1 → 0.7.2
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.
- package/README.md +7 -1
- package/dist/Accordion/Accordion.js +3 -3
- package/dist/Autocomplete/Autocomplete.js +3 -3
- package/dist/Badge/Badge.js +3 -3
- package/dist/Calendar/CalendarHeader.js +3 -3
- package/dist/Calendar/Day/CalendarCell.js +3 -3
- package/dist/Calendar/Day/CalendarGrid.js +3 -3
- package/dist/Calendar/Month/MonthCell.js +3 -3
- package/dist/Calendar/Year/YearCell.js +3 -3
- package/dist/Chart/Chart.js +150 -126
- package/dist/Chart/ChartArea.js +17 -15
- package/dist/Chart/ChartAxes.js +74 -0
- package/dist/Chart/ChartBar.js +42 -42
- package/dist/Chart/ChartLine.js +33 -32
- package/dist/Chart/ChartTooltip.js +61 -47
- package/dist/Chart/axes.js +66 -0
- package/dist/Chart/curve.js +37 -30
- package/dist/Chart/utils.js +53 -46
- package/dist/Checkbox/Checkbox.js +3 -3
- package/dist/CheckboxGroup/CheckboxGroup.js +3 -3
- package/dist/Choice/Choice.js +3 -3
- package/dist/ChoiceCard/ChoiceCard.js +3 -3
- package/dist/DatePicker/DatePicker.js +3 -3
- package/dist/DatePicker/DatePickerSegment.js +3 -3
- package/dist/InfoHint/InfoHint.js +3 -3
- package/dist/Modal/ModalDialog.js +3 -3
- package/dist/Notification/Notification.js +3 -3
- package/dist/Notification/NotificationDescription.js +3 -3
- package/dist/Notification/NotificationTitle.js +3 -3
- package/dist/Phone/Phone.js +3 -3
- package/dist/Phone/PhoneSelect.js +3 -3
- package/dist/Phone/PhoneTrigger.js +3 -3
- package/dist/Radio/Radio.js +3 -3
- package/dist/RadioGroup/RadioGroup.js +3 -3
- package/dist/Searchfield/Searchfield.js +3 -3
- package/dist/Select/Select.js +3 -3
- package/dist/Select/SelectListOption.js +3 -3
- package/dist/Slider/Slider.js +3 -3
- package/dist/Slider/SliderThumb.js +3 -3
- package/dist/Switch/Switch.js +3 -3
- package/dist/SwitchGroup/SwitchGroup.js +3 -3
- package/dist/Tab/Tab.js +3 -3
- package/dist/Table/TableCell.js +3 -3
- package/dist/Table/TableFooterCell.js +3 -3
- package/dist/Table/TableHeaderCell.js +3 -3
- package/dist/Textarea/Textarea.js +3 -3
- package/dist/Textfield/Textfield.js +3 -3
- package/dist/Toast/Toast.js +3 -3
- package/dist/_virtual/index3.js +2 -2
- package/dist/_virtual/index4.js +2 -2
- package/dist/external/prop-types/index.js +1 -1
- package/dist/external/recharts/es6/context/chartLayoutContext.js +3 -3
- package/dist/external/use-sync-external-store/shim/index.js +1 -1
- package/dist/index.d.ts +13 -11
- package/dist/index.js +1717 -1713
- package/dist/llms.txt +2143 -294
- package/dist/output/icons/IconCompareSm.js +15 -0
- package/dist/output/icons/IconRefreshXs.js +15 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -2
- package/dist/Chart/ChartAxis.js +0 -66
- package/dist/Chart/ticks.js +0 -74
- /package/dist/{breakpoints2.css → breakpoints.css} +0 -0
- /package/dist/output/{variables2/tailwind2.json.js → variables/tailwind.json.js} +0 -0
package/dist/Chart/ChartBar.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { getYDataKeys as l, getName as
|
|
1
|
+
import { j as t } from "../external/react/jsx-runtime.js";
|
|
2
|
+
import { getYDataKeys as l, getName as b, getChartHide as x, getColor as a, getYAxisId as A, getBarRadius as c } from "./utils.js";
|
|
3
3
|
import C from "./ChartAnnotation.js";
|
|
4
|
-
import { Bar as
|
|
5
|
-
import { Cell as
|
|
6
|
-
import { Rectangle as
|
|
7
|
-
function
|
|
4
|
+
import { Bar as $ } from "../external/recharts/es6/cartesian/Bar.js";
|
|
5
|
+
import { Cell as F } from "../external/recharts/es6/component/Cell.js";
|
|
6
|
+
import { Rectangle as p } from "../external/recharts/es6/shape/Rectangle.js";
|
|
7
|
+
function W({
|
|
8
8
|
settings: h,
|
|
9
9
|
dataset: r,
|
|
10
10
|
data: u,
|
|
11
11
|
index: s,
|
|
12
|
-
active: e = !1
|
|
12
|
+
active: e = !1,
|
|
13
|
+
stack: j = !1
|
|
13
14
|
}) {
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
l(r).map((m,
|
|
17
|
-
|
|
15
|
+
const f = u || [];
|
|
16
|
+
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
17
|
+
l(r).map((m, o) => /* @__PURE__ */ t.jsx(
|
|
18
|
+
$,
|
|
18
19
|
{
|
|
19
|
-
id: `${s}-${
|
|
20
|
+
id: `${s}-${o}`,
|
|
20
21
|
dataKey: m,
|
|
21
|
-
yAxisId:
|
|
22
|
-
stroke: e ?
|
|
22
|
+
yAxisId: A(r),
|
|
23
|
+
stroke: e ? a(r, o).barStrokeFade : a(r, o).barStroke,
|
|
23
24
|
strokeWidth: 1,
|
|
24
|
-
fill: e ?
|
|
25
|
+
fill: e ? a(r, o).barBgFade : a(r, o).barBg,
|
|
25
26
|
isAnimationActive: !1,
|
|
26
|
-
hide:
|
|
27
|
-
name:
|
|
27
|
+
hide: x(r),
|
|
28
|
+
name: b(r, o),
|
|
28
29
|
unit: r.unit,
|
|
29
|
-
shape: (
|
|
30
|
-
|
|
30
|
+
shape: (i) => /* @__PURE__ */ t.jsx(
|
|
31
|
+
p,
|
|
31
32
|
{
|
|
32
|
-
...
|
|
33
|
-
radius:
|
|
33
|
+
...i,
|
|
34
|
+
radius: c(
|
|
34
35
|
l(r),
|
|
35
36
|
m,
|
|
36
|
-
|
|
37
|
+
i.payload
|
|
37
38
|
)
|
|
38
39
|
}
|
|
39
40
|
),
|
|
40
|
-
activeBar: (
|
|
41
|
-
|
|
41
|
+
activeBar: (i) => /* @__PURE__ */ t.jsx(
|
|
42
|
+
p,
|
|
42
43
|
{
|
|
43
|
-
...
|
|
44
|
-
stroke:
|
|
44
|
+
...i,
|
|
45
|
+
stroke: a(r, o).barStroke,
|
|
45
46
|
strokeWidth: 1,
|
|
46
|
-
fill:
|
|
47
|
-
radius:
|
|
47
|
+
fill: a(r, o).barBg,
|
|
48
|
+
radius: c(
|
|
48
49
|
l(r),
|
|
49
50
|
m,
|
|
50
|
-
|
|
51
|
+
i.payload
|
|
51
52
|
)
|
|
52
53
|
}
|
|
53
54
|
),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$,
|
|
55
|
+
stackId: j ? `stack-${s}` : void 0,
|
|
56
|
+
children: f.map((i, B) => {
|
|
57
|
+
var g, n;
|
|
58
|
+
return /* @__PURE__ */ t.jsx(
|
|
59
|
+
F,
|
|
60
60
|
{
|
|
61
|
-
className: (
|
|
62
|
-
style: (
|
|
61
|
+
className: (g = i == null ? void 0 : i._settings) == null ? void 0 : g.className,
|
|
62
|
+
style: (n = i == null ? void 0 : i._settings) == null ? void 0 : n.style
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
B
|
|
65
65
|
);
|
|
66
66
|
})
|
|
67
67
|
},
|
|
68
|
-
`${s}-${
|
|
68
|
+
`${s}-${o}`
|
|
69
69
|
)),
|
|
70
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ t.jsx(
|
|
71
71
|
C,
|
|
72
72
|
{
|
|
73
73
|
settings: h,
|
|
74
74
|
dataset: r,
|
|
75
|
-
data:
|
|
75
|
+
data: f,
|
|
76
76
|
index: s
|
|
77
77
|
}
|
|
78
78
|
)
|
|
79
79
|
] });
|
|
80
80
|
}
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
W as default
|
|
83
83
|
};
|
package/dist/Chart/ChartLine.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { getName as
|
|
3
|
-
import
|
|
4
|
-
import { Line as
|
|
5
|
-
function
|
|
6
|
-
settings:
|
|
7
|
-
dataset:
|
|
8
|
-
data:
|
|
9
|
-
curve:
|
|
10
|
-
index:
|
|
1
|
+
import { j as r } from "../external/react/jsx-runtime.js";
|
|
2
|
+
import { getYDataKeys as s, getName as u, getChartHide as f, getColor as p, getYAxisId as x } from "./utils.js";
|
|
3
|
+
import d from "./ChartAnnotation.js";
|
|
4
|
+
import { Line as c } from "../external/recharts/es6/cartesian/Line.js";
|
|
5
|
+
function C({
|
|
6
|
+
settings: t,
|
|
7
|
+
dataset: i,
|
|
8
|
+
data: m,
|
|
9
|
+
curve: a = "linear",
|
|
10
|
+
index: o,
|
|
11
|
+
active: l
|
|
11
12
|
}) {
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
/* @__PURE__ */
|
|
14
|
-
|
|
13
|
+
return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
14
|
+
s(i).map((e, n) => /* @__PURE__ */ r.jsx(
|
|
15
|
+
c,
|
|
15
16
|
{
|
|
16
|
-
id:
|
|
17
|
-
dataKey:
|
|
18
|
-
yAxisId:
|
|
19
|
-
stroke:
|
|
17
|
+
id: `${o}-${e}`,
|
|
18
|
+
dataKey: e,
|
|
19
|
+
yAxisId: x(i),
|
|
20
|
+
stroke: p(i, n).lineStroke,
|
|
20
21
|
strokeWidth: 3,
|
|
21
22
|
dot: !1,
|
|
22
|
-
activeDot:
|
|
23
|
+
activeDot: l,
|
|
23
24
|
isAnimationActive: !1,
|
|
24
|
-
type:
|
|
25
|
-
hide:
|
|
25
|
+
type: a,
|
|
26
|
+
hide: f(i),
|
|
26
27
|
strokeLinejoin: "round",
|
|
27
28
|
strokeLinecap: "round",
|
|
28
|
-
filter:
|
|
29
|
-
name:
|
|
30
|
-
unit:
|
|
29
|
+
filter: t.variant !== "card" && "url(#outline)",
|
|
30
|
+
name: u(i, n),
|
|
31
|
+
unit: i.unit
|
|
31
32
|
},
|
|
32
|
-
e
|
|
33
|
-
),
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
33
|
+
`${o}-${e}`
|
|
34
|
+
)),
|
|
35
|
+
/* @__PURE__ */ r.jsx(
|
|
36
|
+
d,
|
|
36
37
|
{
|
|
37
|
-
settings:
|
|
38
|
-
dataset:
|
|
39
|
-
data:
|
|
40
|
-
index:
|
|
38
|
+
settings: t,
|
|
39
|
+
dataset: i,
|
|
40
|
+
data: m,
|
|
41
|
+
index: o
|
|
41
42
|
}
|
|
42
43
|
)
|
|
43
44
|
] });
|
|
44
45
|
}
|
|
45
46
|
export {
|
|
46
|
-
|
|
47
|
+
C as default
|
|
47
48
|
};
|
|
@@ -1,66 +1,80 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as i } from "../external/react/jsx-runtime.js";
|
|
2
|
+
import { useState as g, useRef as A, useEffect as C } from "react";
|
|
2
3
|
/* empty css */
|
|
3
|
-
import { getYDataKeysFlipped as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { getYDataKeys as x, getYDataKeysFlipped as E, defaultYAxisFormatter as F, getColor as K } from "./utils.js";
|
|
5
|
+
import { usePlotArea as b } from "../external/recharts/es6/hooks.js";
|
|
6
|
+
import { Tooltip as v } from "../external/recharts/es6/component/Tooltip.js";
|
|
7
|
+
function W(o) {
|
|
8
|
+
const {
|
|
9
|
+
active: e,
|
|
10
|
+
payload: t,
|
|
11
|
+
label: a,
|
|
12
|
+
tooltip: u,
|
|
13
|
+
datasets: h = [],
|
|
14
|
+
onTooltipWidth: p
|
|
15
|
+
} = o, f = A(null);
|
|
16
|
+
C(() => {
|
|
17
|
+
f.current && p && p(f.current.offsetWidth);
|
|
18
|
+
}, [e, t, p]);
|
|
19
|
+
const y = (c, r) => r.map((n) => {
|
|
20
|
+
let l = n.value, s;
|
|
21
|
+
return c.forEach((d) => {
|
|
22
|
+
!s && x(d).includes(n.dataKey) && (s = d), E(d).forEach((m) => {
|
|
23
|
+
m === n.dataKey && (l = Math.abs(Number(l)));
|
|
11
24
|
});
|
|
12
|
-
}), { ...
|
|
13
|
-
}),
|
|
14
|
-
let
|
|
15
|
-
return
|
|
16
|
-
const s =
|
|
17
|
-
s.forEach((
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
|
|
25
|
+
}), s != null && s.yAxisFormatter ? l = s.yAxisFormatter(l) : l = F(l), { ...n, value: l };
|
|
26
|
+
}), j = (c) => {
|
|
27
|
+
let r;
|
|
28
|
+
return h.forEach((n, l) => {
|
|
29
|
+
const s = x(n);
|
|
30
|
+
s.forEach((d, m) => {
|
|
31
|
+
if (d === c.dataKey) {
|
|
32
|
+
const T = s.length > 1 ? m : l;
|
|
33
|
+
r = K(n, T).text;
|
|
21
34
|
}
|
|
22
35
|
});
|
|
23
|
-
}),
|
|
36
|
+
}), r;
|
|
24
37
|
};
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/* @__PURE__ */ r.jsx("p", { children: c }),
|
|
32
|
-
l.map((o, t) => /* @__PURE__ */ r.jsxs("p", { style: { color: h(o) }, children: [
|
|
33
|
-
o.name,
|
|
38
|
+
if (e && t && t.length) {
|
|
39
|
+
const c = y(h, t);
|
|
40
|
+
return u === "default" ? /* @__PURE__ */ i.jsxs("div", { ref: f, className: "eds-chart-tooltip", children: [
|
|
41
|
+
/* @__PURE__ */ i.jsx("p", { children: a }),
|
|
42
|
+
c.map((r, n) => /* @__PURE__ */ i.jsxs("p", { style: { color: j(r) }, children: [
|
|
43
|
+
r.name,
|
|
34
44
|
" ",
|
|
35
|
-
|
|
45
|
+
r.value,
|
|
36
46
|
" ",
|
|
37
|
-
|
|
38
|
-
] },
|
|
39
|
-
] }) :
|
|
47
|
+
r.unit
|
|
48
|
+
] }, n))
|
|
49
|
+
] }) : u === "label" ? /* @__PURE__ */ i.jsx("div", { ref: f, className: "eds-chart-tooltip", children: /* @__PURE__ */ i.jsx("p", { children: a }) }) : /* @__PURE__ */ i.jsx("div", { ref: f });
|
|
40
50
|
}
|
|
41
51
|
return null;
|
|
42
52
|
}
|
|
43
|
-
function N({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
function N(o, e, t, a) {
|
|
54
|
+
return o - e / 2 <= t ? o + e / 2 - 10 : o + e / 2 >= a ? o - e / 2 + 10 : o;
|
|
55
|
+
}
|
|
56
|
+
function M({
|
|
57
|
+
settings: o,
|
|
58
|
+
datasets: e,
|
|
59
|
+
active: t
|
|
47
60
|
}) {
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const { x: a, width: u } = b(), [h, p] = g(0), f = (t == null ? void 0 : t.x) !== void 0 ? N(t.x, h, a, u) : void 0;
|
|
62
|
+
return t ? /* @__PURE__ */ i.jsx(
|
|
63
|
+
v,
|
|
50
64
|
{
|
|
51
|
-
content: /* @__PURE__ */
|
|
52
|
-
|
|
65
|
+
content: /* @__PURE__ */ i.jsx(
|
|
66
|
+
W,
|
|
53
67
|
{
|
|
54
|
-
tooltip:
|
|
55
|
-
datasets:
|
|
68
|
+
tooltip: o.tooltip || "default",
|
|
69
|
+
datasets: e,
|
|
70
|
+
onTooltipWidth: p
|
|
56
71
|
}
|
|
57
72
|
),
|
|
58
|
-
position: { x:
|
|
59
|
-
isAnimationActive: !1
|
|
60
|
-
cursor: n.tooltip !== "none"
|
|
73
|
+
position: { x: f, y: 0 },
|
|
74
|
+
isAnimationActive: !1
|
|
61
75
|
}
|
|
62
|
-
);
|
|
76
|
+
) : null;
|
|
63
77
|
}
|
|
64
78
|
export {
|
|
65
|
-
|
|
79
|
+
M as default
|
|
66
80
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getYAxisId as b, getYDataKeys as S } from "./utils.js";
|
|
2
|
+
const N = (e) => Number.isFinite(+e) ? +e : NaN, k = (e, y) => {
|
|
3
|
+
const M = S(e), p = Array.isArray(e.yDataKey), i = { min: 1 / 0, max: -1 / 0 }, { min: r, max: s } = y.reduce((t, o) => {
|
|
4
|
+
if (p) {
|
|
5
|
+
let u = 0, x = 0;
|
|
6
|
+
return M.forEach((g) => {
|
|
7
|
+
const c = N(o == null ? void 0 : o[g]);
|
|
8
|
+
Number.isFinite(c) && (c >= 0 ? u += c : x += c);
|
|
9
|
+
}), t.min = Math.min(t.min, x), t.max = Math.max(t.max, u), t;
|
|
10
|
+
}
|
|
11
|
+
return M.forEach((u) => {
|
|
12
|
+
const x = N(o == null ? void 0 : o[u]);
|
|
13
|
+
Number.isFinite(x) && (t.min = Math.min(t.min, x), t.max = Math.max(t.max, x));
|
|
14
|
+
}), t;
|
|
15
|
+
}, i);
|
|
16
|
+
if (!Number.isFinite(r) || !Number.isFinite(s))
|
|
17
|
+
return { min: 0, max: 0 };
|
|
18
|
+
if (r === s) {
|
|
19
|
+
const t = Math.max(1, Math.abs(r) * 0.1);
|
|
20
|
+
return { min: r - t, max: s + t };
|
|
21
|
+
}
|
|
22
|
+
return { min: r, max: s };
|
|
23
|
+
};
|
|
24
|
+
function Y(e, y, M) {
|
|
25
|
+
const p = [...new Set(e.map((n) => b(n)))], i = {}, r = {};
|
|
26
|
+
p.forEach((n) => {
|
|
27
|
+
const a = e.filter((m) => b(m) === n);
|
|
28
|
+
r[n] = a.find((m) => m.show !== !1) ?? a[0];
|
|
29
|
+
const h = a.map((m) => k(m, y)).reduce(
|
|
30
|
+
(m, d) => ({
|
|
31
|
+
min: Math.min(m.min, d.min),
|
|
32
|
+
max: Math.max(m.max, d.max)
|
|
33
|
+
}),
|
|
34
|
+
{ min: 1 / 0, max: -1 / 0 }
|
|
35
|
+
);
|
|
36
|
+
i[n] = h.min === 1 / 0 || h.max === -1 / 0 ? { min: 0, max: 0 } : h;
|
|
37
|
+
});
|
|
38
|
+
const s = [...p].sort((n, a) => {
|
|
39
|
+
const f = i[n], h = i[a], m = f.min === 0 && f.max === 0, d = h.min === 0 && h.max === 0;
|
|
40
|
+
return m === d ? 0 : m ? 1 : -1;
|
|
41
|
+
}), t = M - 1, o = s.map((n) => {
|
|
42
|
+
const { min: a, max: f } = i[n];
|
|
43
|
+
return Math.min(
|
|
44
|
+
t,
|
|
45
|
+
Math.max(0, Math.round((0 - a) / (f - a || 1) * t))
|
|
46
|
+
);
|
|
47
|
+
}), u = Math.max(
|
|
48
|
+
...s.map((n) => i[n].min < 0 ? 1 : 0)
|
|
49
|
+
), x = Math.min(
|
|
50
|
+
...s.map((n) => i[n].max > 0 ? t - 1 : t)
|
|
51
|
+
), g = Math.max(...o), c = Math.max(u, Math.min(g, x));
|
|
52
|
+
return s.map((n) => {
|
|
53
|
+
const a = i[n], f = Math.max(c, a.min < 0 ? 1 : 0), h = Math.max(t - c, a.max > 0 ? 1 : 0), m = Math.max(
|
|
54
|
+
a.min < 0 ? Math.abs(a.min) / f : 0,
|
|
55
|
+
a.max > 0 ? a.max / h : 0,
|
|
56
|
+
1e-9
|
|
57
|
+
), I = Math.ceil(m * 10) / 10, A = -c * I, l = Array.from(
|
|
58
|
+
{ length: M },
|
|
59
|
+
(D, E) => A + E * I
|
|
60
|
+
), F = [l[0], l[l.length - 1]];
|
|
61
|
+
return { id: n, ticks: l, domain: F, dataset: r[n] };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
Y as getAxes
|
|
66
|
+
};
|
package/dist/Chart/curve.js
CHANGED
|
@@ -1,74 +1,81 @@
|
|
|
1
|
-
import { smoothPath as
|
|
2
|
-
function
|
|
1
|
+
import { smoothPath as d } from "../external/svg-smoother/dist/index.js";
|
|
2
|
+
function f(e) {
|
|
3
|
+
return (Math.abs(e) < 1e-9 ? 0 : e).toFixed(3).replace(/\.0+$/, "").replace(/(\.[0-9]*?)0+$/, "$1");
|
|
4
|
+
}
|
|
5
|
+
function m(e, t) {
|
|
3
6
|
return e.length === 0 ? "" : e.slice(1).reduce(
|
|
4
7
|
(i, [s, n], c) => {
|
|
5
|
-
const [r, o] = e[c],
|
|
6
|
-
return i.push(
|
|
8
|
+
const [r, o] = e[c], l = s - r, h = Math.min(t / 2, Math.abs(l) / 2), a = (r + s) / 2, _ = a - h, u = a + h;
|
|
9
|
+
return i.push(
|
|
10
|
+
`L ${f(_)} ${f(o)}`,
|
|
11
|
+
`L ${f(u)} ${f(n)}`,
|
|
12
|
+
`L ${f(s)} ${f(n)}`
|
|
13
|
+
), i;
|
|
7
14
|
},
|
|
8
|
-
[`M ${e[0][0]} ${e[0][1]}`]
|
|
15
|
+
[`M ${f(e[0][0])} ${f(e[0][1])}`]
|
|
9
16
|
).join(" ");
|
|
10
17
|
}
|
|
11
|
-
const
|
|
18
|
+
const C = (e) => e.map(([t, i]) => `${f(t)},${f(i)}`).join("|"), p = (e, t) => Array.from(
|
|
12
19
|
{ length: Math.floor(e.length / t) },
|
|
13
20
|
(i, s) => e.slice(s * t, s * t + t)
|
|
14
21
|
);
|
|
15
|
-
function
|
|
22
|
+
function g(e) {
|
|
16
23
|
const t = Array.from(e.matchAll(/([MLC])([^MLC]+)/g)).map((o) => ({
|
|
17
24
|
cmd: o[1],
|
|
18
25
|
vals: (o[2] || "").trim().split(/[ ,]+/).map(Number)
|
|
19
26
|
}));
|
|
20
27
|
let i = NaN, s = NaN;
|
|
21
28
|
const n = [];
|
|
22
|
-
if (t.forEach(({ cmd: o, vals:
|
|
29
|
+
if (t.forEach(({ cmd: o, vals: l }) => {
|
|
23
30
|
if (o === "M") {
|
|
24
|
-
[i, s] =
|
|
31
|
+
[i, s] = l;
|
|
25
32
|
return;
|
|
26
33
|
}
|
|
27
34
|
if (o === "L") {
|
|
28
|
-
const [h, a] =
|
|
35
|
+
const [h, a] = l;
|
|
29
36
|
n.push([i, s, i, s, h, a, h, a]), i = h, s = a;
|
|
30
37
|
return;
|
|
31
38
|
}
|
|
32
|
-
o === "C" &&
|
|
33
|
-
n.push([i, s, h, a,
|
|
39
|
+
o === "C" && p(l, 6).forEach(([h, a, _, u, P, $]) => {
|
|
40
|
+
n.push([i, s, h, a, _, u, P, $]), i = P, s = $;
|
|
34
41
|
});
|
|
35
42
|
}), !n.length) return e;
|
|
36
43
|
const [c, r] = n[n.length - 1].slice(6, 8);
|
|
37
44
|
return [
|
|
38
45
|
`M ${c} ${r}`,
|
|
39
46
|
...n.slice().reverse().map(
|
|
40
|
-
([o,
|
|
47
|
+
([o, l, h, a, _, u]) => `C ${_} ${u} ${h} ${a} ${o} ${l}`
|
|
41
48
|
)
|
|
42
49
|
].join(" ");
|
|
43
50
|
}
|
|
44
|
-
function
|
|
51
|
+
function b(e, t) {
|
|
45
52
|
Array.from(e.matchAll(/([MLCZ])([^MLCZ]*)/g)).map((s) => ({
|
|
46
53
|
cmd: s[1],
|
|
47
54
|
nums: (s[2] || "").trim().split(/[ ,]+/).map(Number).filter(Number.isFinite)
|
|
48
55
|
})).forEach(({ cmd: s, nums: n }) => {
|
|
49
56
|
if (s === "M") {
|
|
50
|
-
|
|
57
|
+
p(n, 2).forEach(
|
|
51
58
|
([c, r], o) => (o === 0 ? t.moveTo : t.lineTo).call(t, c, r)
|
|
52
59
|
);
|
|
53
60
|
return;
|
|
54
61
|
}
|
|
55
62
|
if (s === "L") {
|
|
56
|
-
|
|
63
|
+
p(n, 2).forEach(([c, r]) => t.lineTo(c, r));
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
66
|
if (s === "C") {
|
|
60
|
-
|
|
61
|
-
([c, r, o,
|
|
67
|
+
p(n, 6).forEach(
|
|
68
|
+
([c, r, o, l, h, a]) => t.bezierCurveTo(c, r, o, l, h, a)
|
|
62
69
|
);
|
|
63
70
|
return;
|
|
64
71
|
}
|
|
65
72
|
s === "Z" && t.closePath();
|
|
66
73
|
});
|
|
67
74
|
}
|
|
68
|
-
function
|
|
75
|
+
function M(e, t, i) {
|
|
69
76
|
this._context = e, this._offset = t, this._radius = i, this._inArea = !1, this._line = 0, this._points = [], this._topPoints = [], this._topPath = "", this._edgeCache = /* @__PURE__ */ new Map();
|
|
70
77
|
}
|
|
71
|
-
|
|
78
|
+
M.prototype = {
|
|
72
79
|
areaStart() {
|
|
73
80
|
this._inArea = !0, this._line = 0, this._topPoints = [], this._topPath = "";
|
|
74
81
|
},
|
|
@@ -81,40 +88,40 @@ b.prototype = {
|
|
|
81
88
|
lineEnd() {
|
|
82
89
|
if (this._points.length) {
|
|
83
90
|
if (!this._inArea) {
|
|
84
|
-
const e =
|
|
91
|
+
const e = m(this._points, this._offset), t = d(e, {
|
|
85
92
|
radius: this._radius,
|
|
86
93
|
reduceCommands: !1
|
|
87
94
|
});
|
|
88
|
-
|
|
95
|
+
b(t, this._context);
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
91
98
|
if (this._line === 1) {
|
|
92
99
|
this._topPoints = this._points.slice();
|
|
93
|
-
const e =
|
|
100
|
+
const e = m(this._topPoints, this._offset), t = d(e, {
|
|
94
101
|
radius: this._radius,
|
|
95
102
|
reduceCommands: !1
|
|
96
103
|
});
|
|
97
|
-
this._edgeCache.set(
|
|
104
|
+
this._edgeCache.set(C(this._topPoints), t), this._topPath = t;
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
if (this._line === 2) {
|
|
101
|
-
const t = this._points.slice().slice().reverse(), i =
|
|
108
|
+
const t = this._points.slice().slice().reverse(), i = C(t);
|
|
102
109
|
let s = this._edgeCache.get(i);
|
|
103
110
|
if (!s) {
|
|
104
|
-
const o =
|
|
111
|
+
const o = m(
|
|
105
112
|
t,
|
|
106
113
|
this._offset
|
|
107
114
|
);
|
|
108
|
-
s =
|
|
115
|
+
s = d(o, {
|
|
109
116
|
radius: this._radius,
|
|
110
117
|
reduceCommands: !1
|
|
111
118
|
}), this._edgeCache.set(i, s);
|
|
112
119
|
}
|
|
113
|
-
const c =
|
|
120
|
+
const c = g(s).replace(
|
|
114
121
|
/^[Mm]\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/,
|
|
115
122
|
"L $1 $2"
|
|
116
123
|
), r = `${this._topPath} ${c} Z`;
|
|
117
|
-
|
|
124
|
+
b(r, this._context), this._topPoints = [], this._topPath = "", this._line = 0;
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
},
|
|
@@ -123,7 +130,7 @@ b.prototype = {
|
|
|
123
130
|
}
|
|
124
131
|
};
|
|
125
132
|
function L(e = 10, t = 5) {
|
|
126
|
-
return (i) => new
|
|
133
|
+
return (i) => new M(i, e, t);
|
|
127
134
|
}
|
|
128
135
|
export {
|
|
129
136
|
L as curveSloped
|