@ikonai/sdk-react-ui-standard 1.0.78 → 1.0.79

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,351 @@
1
+ import { a as f, b as p, t as l, d as be, c as ge, j as m } from "./index-DLtRfon-.js";
2
+ import { useUiNode as ye } from "@ikonai/sdk-react-ui";
3
+ import { ResponsiveBar as $e } from "@nivo/bar";
4
+ import { ResponsiveLine as Pe } from "@nivo/line";
5
+ import { ResponsivePie as We } from "@nivo/pie";
6
+ import { memo as ke, useRef as we, useCallback as De, Component as Ue, useLayoutEffect as Ge } from "react";
7
+ import { createPortal as Xe } from "react-dom";
8
+ function Oe(o, t, i, d = 14, u = 8) {
9
+ let c = o.x + d;
10
+ c + t.width > i.width - u && (c = o.x - d - t.width), c = Math.min(c, i.width - u - t.width), c = Math.max(u, c);
11
+ let v = o.y + d;
12
+ return v + t.height > i.height - u && (v = o.y - d - t.height), v = Math.min(v, i.height - u - t.height), v = Math.max(u, v), { left: c, top: v };
13
+ }
14
+ const Ye = new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }), Ee = new Intl.NumberFormat("en-US", { maximumFractionDigits: 1 }), ze = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }), He = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" });
15
+ function y(o) {
16
+ const t = Math.abs(o);
17
+ return t >= 100 ? Ye.format(o) : t >= 10 ? Ee.format(o) : ze.format(o);
18
+ }
19
+ function Ne(o) {
20
+ const t = Math.abs(o);
21
+ return t < 1e3 ? `${y(o)} ms` : t < 6e4 ? `${y(o / 1e3)} s` : t < 36e5 ? `${y(o / 6e4)} min` : `${y(o / 36e5)} h`;
22
+ }
23
+ function Ke(o) {
24
+ const t = Math.abs(o), i = 1024, d = i * 1024, u = d * 1024, c = u * 1024;
25
+ return t < i ? `${y(o)} B` : t < d ? `${y(o / i)} KB` : t < u ? `${y(o / d)} MB` : t < c ? `${y(o / u)} GB` : `${y(o / c)} TB`;
26
+ }
27
+ function _e(o) {
28
+ const t = Math.abs(o), i = o < 0 ? "-" : "";
29
+ return t >= 1e6 ? `${i}$${y(t / 1e6)}M` : t >= 1e5 ? `${i}$${y(t / 1e3)}K` : He.format(o);
30
+ }
31
+ function Se(o) {
32
+ const t = o.trim().toLowerCase();
33
+ return (i) => {
34
+ if (typeof i != "number" || !Number.isFinite(i))
35
+ return String(i);
36
+ switch (t) {
37
+ case "ms":
38
+ case "millis":
39
+ case "msec":
40
+ case "millisecond":
41
+ case "milliseconds":
42
+ return Ne(i);
43
+ case "s":
44
+ case "sec":
45
+ case "secs":
46
+ case "second":
47
+ case "seconds":
48
+ return Ne(i * 1e3);
49
+ case "byte":
50
+ case "bytes":
51
+ return Ke(i);
52
+ case "%":
53
+ case "pct":
54
+ case "percent":
55
+ case "percentage":
56
+ return `${y(i)}%`;
57
+ case "$":
58
+ case "usd":
59
+ case "dollar":
60
+ case "dollars":
61
+ return _e(i);
62
+ default:
63
+ return `${y(i)} ${o.trim()}`;
64
+ }
65
+ };
66
+ }
67
+ class Ce extends Ue {
68
+ state = { hasError: !1 };
69
+ static getDerivedStateFromError() {
70
+ return { hasError: !0 };
71
+ }
72
+ componentDidCatch(t, i) {
73
+ console.error("[ikon] Chart rendering error:", t, i.componentStack);
74
+ }
75
+ render() {
76
+ return this.state.hasError ? null : this.props.children;
77
+ }
78
+ }
79
+ function ce(o) {
80
+ if (o != null && typeof o == "object")
81
+ return o;
82
+ }
83
+ function K(o) {
84
+ if (Array.isArray(o))
85
+ return o;
86
+ }
87
+ function ue(o) {
88
+ if (Array.isArray(o))
89
+ return o.filter((t) => typeof t == "string");
90
+ }
91
+ function qe(o) {
92
+ const t = {};
93
+ for (const i in o)
94
+ o[i] !== void 0 && o[i] !== null && (t[i] = o[i]);
95
+ return t;
96
+ }
97
+ function _(o) {
98
+ if (o === null)
99
+ return null;
100
+ const t = ce(o);
101
+ if (t)
102
+ return qe({
103
+ ...t,
104
+ tickRotation: t.tickRotation ?? 0
105
+ });
106
+ }
107
+ function me(o, t) {
108
+ if (!o || o === null)
109
+ return o;
110
+ const i = o, d = i.tickValues;
111
+ if (typeof d != "number" || d <= 0 || t.length === 0)
112
+ return o;
113
+ const u = Math.min(d, t.length), c = t.length / u, v = [];
114
+ for (let k = 0; k < u; k++)
115
+ v.push(t[Math.round(k * c)]);
116
+ return { ...i, tickValues: v };
117
+ }
118
+ function re(o, t) {
119
+ if (o === null)
120
+ return null;
121
+ const i = o ?? {};
122
+ return i.format !== void 0 ? i : { ...i, format: t };
123
+ }
124
+ function Le(o) {
125
+ if (o == null)
126
+ return;
127
+ const t = ce(o);
128
+ if (t)
129
+ return t;
130
+ }
131
+ function Fe() {
132
+ const o = we(null), t = De((i) => {
133
+ o.current = { x: i.clientX, y: i.clientY };
134
+ }, []);
135
+ return { cursor: o, onMouseMove: t };
136
+ }
137
+ function Ae(o) {
138
+ const t = o?.tooltip?.container ?? {}, i = o?.text ?? {}, d = t.color ?? i.fill ?? "#1f2933", u = t.fontFamily ?? i.fontFamily ?? "inherit";
139
+ return {
140
+ background: t.background ?? "#ffffff",
141
+ border: t.borderColor ?? "rgba(0, 0, 0, 0.12)",
142
+ text: d,
143
+ muted: i.fill ?? d,
144
+ fontFamily: u
145
+ };
146
+ }
147
+ function ve({ cursor: o, colors: t, children: i }) {
148
+ const d = we(null), u = o.current;
149
+ return Ge(() => {
150
+ const c = d.current, v = o.current;
151
+ if (!c || !v)
152
+ return;
153
+ const k = c.getBoundingClientRect(), e = Oe(
154
+ v,
155
+ { width: k.width, height: k.height },
156
+ { width: window.innerWidth, height: window.innerHeight }
157
+ );
158
+ c.style.left = `${e.left}px`, c.style.top = `${e.top}px`;
159
+ }), u ? Xe(
160
+ /* @__PURE__ */ m.jsx(
161
+ "div",
162
+ {
163
+ ref: d,
164
+ style: {
165
+ position: "fixed",
166
+ left: u.x + 14,
167
+ top: u.y + 14,
168
+ zIndex: 99999,
169
+ pointerEvents: "none",
170
+ background: t.background,
171
+ border: `1px solid ${t.border}`,
172
+ borderRadius: 8,
173
+ padding: "8px 10px",
174
+ fontFamily: t.fontFamily,
175
+ fontSize: 12,
176
+ color: t.text,
177
+ boxShadow: "0 8px 18px rgba(0, 0, 0, 0.18)",
178
+ maxWidth: 360
179
+ },
180
+ children: i
181
+ }
182
+ ),
183
+ document.body
184
+ ) : null;
185
+ }
186
+ function he({ color: o, label: t, value: i, colors: d }) {
187
+ return /* @__PURE__ */ m.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
188
+ /* @__PURE__ */ m.jsx("span", { style: { display: "inline-block", width: 10, height: 10, borderRadius: 2, background: o, flexShrink: 0 } }),
189
+ /* @__PURE__ */ m.jsx("span", { style: { flex: 1, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: t }),
190
+ /* @__PURE__ */ m.jsx("span", { style: { color: d.text, fontWeight: 600, fontVariantNumeric: "tabular-nums" }, children: i })
191
+ ] });
192
+ }
193
+ function no() {
194
+ const o = ke(function({ nodeId: i, context: d, className: u }) {
195
+ const c = ye(d.store, i), { cursor: v, onMouseMove: k } = Fe();
196
+ if (!c)
197
+ return null;
198
+ const e = c.props ?? {}, F = K(e.data) ?? [], A = ue(e.keys), j = l(e.indexBy), C = l(e.groupMode), S = l(e.layout), q = l(e.valueScale), J = l(e.indexScale), I = f(e.minValue) ?? "auto", $ = f(e.maxValue) ?? "auto", Q = f(e.padding), R = f(e.innerPadding), Z = ce(e.margin), P = _(e.axisTop), B = _(e.axisRight), ee = _(e.axisBottom), T = _(e.axisLeft), W = p(e.enableGridX), D = p(e.enableGridY), M = p(e.enableLabel), U = f(e.labelSkipWidth), V = f(e.labelSkipHeight), G = l(e.labelTextColor), X = K(e.legends), N = ue(e.colors), O = l(e.colorScheme), Y = Le(e.theme), w = l(e.borderColor), E = f(e.borderRadius), L = f(e.borderWidth), z = l(e.valueFormat), H = l(e.valueUnit), a = p(e.isInteractive), b = be(e.onClickId), g = b ? (x) => {
199
+ d.dispatchAction(b, {
200
+ id: String(x.id),
201
+ indexValue: String(x.indexValue),
202
+ value: x.value ?? 0
203
+ });
204
+ } : void 0, oe = ge("nivo-bar-chart", u, l(e.className)), r = {
205
+ data: F
206
+ };
207
+ A !== void 0 && (r.keys = A), j !== void 0 && (r.indexBy = j), C !== void 0 && (r.groupMode = C), S !== void 0 && (r.layout = S), (q !== void 0 || I !== "auto" || $ !== "auto") && (r.valueScale = {
208
+ type: q ?? "linear",
209
+ min: I,
210
+ max: $
211
+ }), J !== void 0 && (r.indexScale = { type: J }), Q !== void 0 && (r.padding = Q), R !== void 0 && (r.innerPadding = R);
212
+ const le = j ?? "id", ae = F.map((x) => x[le]), ie = me(ee, ae), te = me(P, ae);
213
+ if (Z !== void 0 && (r.margin = Z), te !== void 0 && (r.axisTop = te), B !== void 0 && (r.axisRight = B), ie !== void 0 && (r.axisBottom = ie), T !== void 0 && (r.axisLeft = T), W !== void 0 && (r.enableGridX = W), D !== void 0 && (r.enableGridY = D), M !== void 0 && (r.enableLabel = M), U !== void 0 && (r.labelSkipWidth = U), V !== void 0 && (r.labelSkipHeight = V), G !== void 0 && (r.labelTextColor = G), X !== void 0 && (r.legends = X), N !== void 0 && (r.colors = N), O !== void 0 && N === void 0 && (r.colors = { scheme: O }), Y !== void 0 && (r.theme = Y), w !== void 0 && (r.borderColor = w), E !== void 0 && (r.borderRadius = E), L !== void 0 && (r.borderWidth = L), z !== void 0 && (r.valueFormat = z), a !== void 0 && (r.isInteractive = a), g !== void 0 && (r.onClick = g), H !== void 0) {
214
+ const x = Se(H);
215
+ r.valueFormat = x, S === "horizontal" ? (r.axisBottom = re(ie, x), te !== void 0 && (r.axisTop = re(te, x))) : (r.axisLeft = re(T, x), B !== void 0 && (r.axisRight = re(B, x)));
216
+ }
217
+ if (a !== !1) {
218
+ const x = Ae(Y);
219
+ r.tooltip = ((se) => /* @__PURE__ */ m.jsxs(ve, { cursor: v, colors: x, children: [
220
+ /* @__PURE__ */ m.jsx("div", { style: { color: x.muted, fontSize: 11, marginBottom: 4 }, children: String(se.indexValue) }),
221
+ /* @__PURE__ */ m.jsx(he, { color: se.color, label: se.id, value: se.formattedValue, colors: x })
222
+ ] }));
223
+ }
224
+ return /* @__PURE__ */ m.jsx(Ce, { children: /* @__PURE__ */ m.jsx("div", { className: oe, "data-ikon-node-id": c.id, "data-ikon-source": c.sourceMarker, onMouseMove: k, children: /* @__PURE__ */ m.jsx($e, { ...r }) }) });
225
+ });
226
+ return (t) => {
227
+ if (t.type === "std.chart-bar")
228
+ return o;
229
+ };
230
+ }
231
+ function ro() {
232
+ const o = ke(function({ nodeId: i, context: d, className: u }) {
233
+ const c = ye(d.store, i), { cursor: v, onMouseMove: k } = Fe();
234
+ if (!c)
235
+ return null;
236
+ const e = c.props ?? {}, F = K(e.data) ?? [], A = l(e.xScaleType), j = l(e.yScaleType), C = f(e.xScaleMin), S = f(e.xScaleMax), q = f(e.yScaleMin) ?? "auto", J = f(e.yScaleMax) ?? "auto", I = p(e.yScaleStacked), $ = ce(e.margin), Q = _(e.axisTop), R = _(e.axisRight), Z = _(e.axisBottom), P = _(e.axisLeft), B = p(e.enableGridX), ee = p(e.enableGridY), T = p(e.enablePoints), W = f(e.pointSize), D = l(e.pointColor), M = l(e.pointBorderColor), U = f(e.pointBorderWidth), V = p(e.enableArea), G = f(e.areaOpacity), X = f(e.areaBaselineValue), N = p(e.enableCrosshair), O = l(e.crosshairType), Y = l(e.curve), w = Y ? Y.replace(/-([a-z])/g, (s, h) => h.toUpperCase()) : void 0, E = K(e.legends), L = ue(e.colors), z = l(e.colorScheme), H = Le(e.theme), a = f(e.lineWidth), b = p(e.isInteractive), g = p(e.useMesh), oe = p(e.enableSlices), r = l(e.xFormat), le = l(e.yFormat), ae = l(e.valueUnit), ie = be(e.onClickId), te = ie ? (s) => {
237
+ const h = s;
238
+ d.dispatchAction(ie, {
239
+ serieId: String(h.serieId ?? ""),
240
+ value: h.data?.y ?? 0
241
+ });
242
+ } : void 0, x = ge("nivo-line-chart", u, l(e.className)), n = {
243
+ data: A === "time" ? F.map((s) => ({
244
+ ...s,
245
+ data: s.data.map((h) => ({
246
+ ...h,
247
+ x: h.x instanceof Date ? h.x : new Date(h.x)
248
+ }))
249
+ })) : F
250
+ }, Re = C !== void 0 || S !== void 0;
251
+ if (A === "linear") {
252
+ const s = { type: "linear" };
253
+ C !== void 0 && (s.min = C), S !== void 0 && (s.max = S), Re && (s.nice = !1), n.xScale = s;
254
+ } else if (A === "time") {
255
+ const s = { type: "time" };
256
+ C !== void 0 && (s.min = new Date(C)), S !== void 0 && (s.max = new Date(S)), Re && (s.nice = !1), n.xScale = s;
257
+ } else
258
+ n.xScale = { type: "point" };
259
+ const Be = {
260
+ type: j ?? "linear",
261
+ min: q,
262
+ max: J
263
+ };
264
+ I !== void 0 && (Be.stacked = I), n.yScale = Be;
265
+ const je = A ?? "point";
266
+ let de = Z, fe = Q;
267
+ if (je === "point") {
268
+ const s = F.length > 0 ? F[0].data.map((h) => h.x) : [];
269
+ de = me(de, s), fe = me(fe, s);
270
+ }
271
+ $ !== void 0 && (n.margin = $), fe !== void 0 && (n.axisTop = fe), R !== void 0 && (n.axisRight = R), de !== void 0 && (n.axisBottom = de), P !== void 0 && (n.axisLeft = P), B !== void 0 && (n.enableGridX = B), ee !== void 0 && (n.enableGridY = ee);
272
+ const pe = K(e.gridXValues)?.filter((s) => typeof s == "number"), xe = K(e.gridYValues)?.filter((s) => typeof s == "number");
273
+ if (pe && pe.length > 0 && (n.gridXValues = pe), xe && xe.length > 0 && (n.gridYValues = xe), T !== void 0 && (n.enablePoints = T), W !== void 0 && (n.pointSize = W), D !== void 0 && (n.pointColor = D), M !== void 0 && (n.pointBorderColor = M), U !== void 0 && (n.pointBorderWidth = U), V !== void 0 && (n.enableArea = V), G !== void 0 && (n.areaOpacity = G), X !== void 0 && (n.areaBaselineValue = X), N !== void 0 && (n.enableCrosshair = N), O !== void 0 && (n.crosshairType = O), w !== void 0 && (n.curve = w), E !== void 0 && (n.legends = E), L !== void 0 && (n.colors = L), z !== void 0 && L === void 0 && (n.colors = { scheme: z }), H !== void 0 && (n.theme = H), a !== void 0 && (n.lineWidth = a), b !== void 0 && (n.isInteractive = b), g !== void 0 && (n.useMesh = g), oe !== void 0 && (n.enableSlices = oe ? "x" : !1), r !== void 0 && (n.xFormat = r), le !== void 0 && (n.yFormat = le), te !== void 0 && (n.onClick = te), ae !== void 0) {
274
+ const s = Se(ae);
275
+ n.yFormat = s, n.axisLeft = re(P, s), R !== void 0 && (n.axisRight = re(R, s));
276
+ }
277
+ if (b !== !1) {
278
+ const s = Ae(H);
279
+ n.tooltip = ((h) => /* @__PURE__ */ m.jsx(ve, { cursor: v, colors: s, children: /* @__PURE__ */ m.jsx(he, { color: h.point.seriesColor, label: h.point.seriesId, value: h.point.data.yFormatted, colors: s }) })), n.sliceTooltip = ((h) => {
280
+ const Ve = [...h.slice.points].sort((ne, Ie) => Number(Ie.data.y ?? 0) - Number(ne.data.y ?? 0));
281
+ return /* @__PURE__ */ m.jsxs(ve, { cursor: v, colors: s, children: [
282
+ /* @__PURE__ */ m.jsx("div", { style: { color: s.muted, fontSize: 11, marginBottom: 6, fontWeight: 500 }, children: String(Ve[0]?.data?.xFormatted ?? "") }),
283
+ /* @__PURE__ */ m.jsx("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: Ve.map((ne) => /* @__PURE__ */ m.jsx(he, { color: ne.seriesColor, label: ne.seriesId, value: ne.data.yFormatted, colors: s }, ne.id)) })
284
+ ] });
285
+ });
286
+ }
287
+ const Te = l(e.gradientFromColor), Me = l(e.gradientToColor);
288
+ if (Te && Me) {
289
+ const s = `ikon-line-grad-${c.id}`;
290
+ n.defs = [
291
+ {
292
+ id: s,
293
+ type: "linearGradient",
294
+ // nivo gradients default to vertical (offset 0 at top). rotate -90°
295
+ // about the center so it flows left→right with offset 0 (gradientFrom)
296
+ // at the LEFT edge — i.e. the start/launch — and offset 100 at the right.
297
+ gradientTransform: "rotate(-90 0.5 0.5)",
298
+ colors: [
299
+ { offset: 0, color: Te },
300
+ { offset: 100, color: Me }
301
+ ]
302
+ }
303
+ ], n.fill = [{ match: "*", id: s }], n.colors = ((h) => `url(#${s})`);
304
+ }
305
+ return /* @__PURE__ */ m.jsx(Ce, { children: /* @__PURE__ */ m.jsx("div", { className: x, "data-ikon-node-id": c.id, "data-ikon-source": c.sourceMarker, onMouseMove: k, children: /* @__PURE__ */ m.jsx(Pe, { ...n }) }) });
306
+ });
307
+ return (t) => {
308
+ if (t.type === "std.chart-line")
309
+ return o;
310
+ };
311
+ }
312
+ function ao() {
313
+ const o = ke(function({ nodeId: i, context: d, className: u }) {
314
+ const c = ye(d.store, i), { cursor: v, onMouseMove: k } = Fe();
315
+ if (!c)
316
+ return null;
317
+ const e = c.props ?? {}, F = K(e.data) ?? [], A = f(e.innerRadius), j = f(e.padAngle), C = f(e.cornerRadius), S = f(e.startAngle), q = f(e.endAngle), J = p(e.sortByValue), I = ce(e.margin), $ = p(e.enableArcLabels), Q = l(e.arcLabelsTextColor), R = f(e.arcLabelsSkipAngle), Z = p(e.enableArcLinkLabels), P = l(e.arcLinkLabelsTextColor), B = f(e.arcLinkLabelsSkipAngle), ee = f(e.arcLinkLabelsThickness), T = l(e.arcLinkLabelsColor), W = f(e.activeOuterRadiusOffset), D = K(e.legends), M = ue(e.colors), U = l(e.colorScheme), V = Le(e.theme), G = l(e.borderColor), X = f(e.borderWidth), N = l(e.valueFormat), O = l(e.valueUnit), Y = p(e.arcLabelAsPercentage), w = p(e.isInteractive), E = be(e.onClickId), L = F.reduce((b, g) => b + (Number(g.value) || 0), 0), z = E ? (b) => {
318
+ d.dispatchAction(E, {
319
+ id: String(b.id),
320
+ value: b.value
321
+ });
322
+ } : void 0, H = ge("nivo-pie-chart", u, l(e.className)), a = {
323
+ data: F
324
+ };
325
+ if (A !== void 0 && (a.innerRadius = A), j !== void 0 && (a.padAngle = j), C !== void 0 && (a.cornerRadius = C), S !== void 0 && (a.startAngle = S), q !== void 0 && (a.endAngle = q), J !== void 0 && (a.sortByValue = J), I !== void 0 && (a.margin = I), $ !== void 0 && (a.enableArcLabels = $), Q !== void 0 && (a.arcLabelsTextColor = Q), R !== void 0 && (a.arcLabelsSkipAngle = R), Z !== void 0 && (a.enableArcLinkLabels = Z), P !== void 0 && (a.arcLinkLabelsTextColor = P), B !== void 0 && (a.arcLinkLabelsSkipAngle = B), ee !== void 0 && (a.arcLinkLabelsThickness = ee), T !== void 0 && (a.arcLinkLabelsColor = T), W !== void 0 && (a.activeOuterRadiusOffset = W), D !== void 0 && (a.legends = D), M !== void 0 && (a.colors = M), U !== void 0 && M === void 0 && (a.colors = { scheme: U }), V !== void 0 && (a.theme = V), G !== void 0 && (a.borderColor = G), X !== void 0 && (a.borderWidth = X), N !== void 0 && (a.valueFormat = N), O !== void 0 && (a.valueFormat = Se(O)), w !== void 0 && (a.isInteractive = w), z !== void 0 && (a.onClick = z), Y && (a.arcLabel = ((b) => L > 0 ? `${(b.value / L * 100).toFixed(1)}%` : "0%")), w !== !1) {
326
+ const b = Ae(V);
327
+ a.tooltip = ((g) => {
328
+ const oe = L > 0 ? `${(g.datum.value / L * 100).toFixed(1)}%` : void 0;
329
+ return /* @__PURE__ */ m.jsx(ve, { cursor: v, colors: b, children: /* @__PURE__ */ m.jsx(
330
+ he,
331
+ {
332
+ color: g.datum.color,
333
+ label: g.datum.label ?? g.datum.id,
334
+ value: oe ? `${g.datum.formattedValue} · ${oe}` : g.datum.formattedValue,
335
+ colors: b
336
+ }
337
+ ) });
338
+ });
339
+ }
340
+ return /* @__PURE__ */ m.jsx(Ce, { children: /* @__PURE__ */ m.jsx("div", { className: H, "data-ikon-node-id": c.id, "data-ikon-source": c.sourceMarker, onMouseMove: k, children: /* @__PURE__ */ m.jsx(We, { ...a }) }) });
341
+ });
342
+ return (t) => {
343
+ if (t.type === "std.chart-pie")
344
+ return o;
345
+ };
346
+ }
347
+ export {
348
+ no as createNivoBarChartResolver,
349
+ ro as createNivoLineChartResolver,
350
+ ao as createNivoPieChartResolver
351
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk-react-ui-standard",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,4 +1,4 @@
1
- import { j as $e, t as ht, p as yi, c as ki } from "./index-B4FlX03L.js";
1
+ import { j as $e, t as ht, p as yi, c as ki } from "./index-DLtRfon-.js";
2
2
  import { useUiNode as xi } from "@ikonai/sdk-react-ui";
3
3
  import { memo as bi } from "react";
4
4
  function tr(e) {
@@ -1,267 +0,0 @@
1
- import { a as l, b as v, t as s, d as me, c as xe, j as d } from "./index-B4FlX03L.js";
2
- import { useUiNode as he } from "@ikonai/sdk-react-ui";
3
- import { ResponsiveBar as je } from "@nivo/bar";
4
- import { ResponsiveLine as Fe } from "@nivo/line";
5
- import { ResponsivePie as Me } from "@nivo/pie";
6
- import { memo as be, useRef as Ne, useCallback as Ie, Component as We } from "react";
7
- import { createPortal as Pe } from "react-dom";
8
- class ge extends We {
9
- state = { hasError: !1 };
10
- static getDerivedStateFromError() {
11
- return { hasError: !0 };
12
- }
13
- componentDidCatch(i, c) {
14
- console.error("[ikon] Chart rendering error:", i, c.componentStack);
15
- }
16
- render() {
17
- return this.state.hasError ? null : this.props.children;
18
- }
19
- }
20
- function re(o) {
21
- if (o != null && typeof o == "object")
22
- return o;
23
- }
24
- function z(o) {
25
- if (Array.isArray(o))
26
- return o;
27
- }
28
- function ce(o) {
29
- if (Array.isArray(o))
30
- return o.filter((i) => typeof i == "string");
31
- }
32
- function Ge(o) {
33
- const i = {};
34
- for (const c in o)
35
- o[c] !== void 0 && o[c] !== null && (i[c] = o[c]);
36
- return i;
37
- }
38
- function E(o) {
39
- if (o === null)
40
- return null;
41
- const i = re(o);
42
- if (i)
43
- return Ge({
44
- ...i,
45
- tickRotation: i.tickRotation ?? 0
46
- });
47
- }
48
- function de(o, i) {
49
- if (!o || o === null)
50
- return o;
51
- const c = o, f = c.tickValues;
52
- if (typeof f != "number" || f <= 0 || i.length === 0)
53
- return o;
54
- const y = Math.min(f, i.length), p = i.length / y, A = [];
55
- for (let R = 0; R < y; R++)
56
- A.push(i[Math.round(R * p)]);
57
- return { ...c, tickValues: A };
58
- }
59
- function ye(o) {
60
- if (o == null)
61
- return;
62
- const i = re(o);
63
- if (i)
64
- return i;
65
- }
66
- function ke() {
67
- const o = Ne(null), i = Ie((c) => {
68
- o.current = { x: c.clientX, y: c.clientY };
69
- }, []);
70
- return { cursor: o, onMouseMove: i };
71
- }
72
- function Se(o) {
73
- const i = o?.tooltip?.container ?? {}, c = o?.text ?? {}, f = i.color ?? c.fill ?? "#1f2933", y = i.fontFamily ?? c.fontFamily ?? "inherit";
74
- return {
75
- background: i.background ?? "#ffffff",
76
- border: i.borderColor ?? "rgba(0, 0, 0, 0.12)",
77
- text: f,
78
- muted: c.fill ?? f,
79
- fontFamily: y
80
- };
81
- }
82
- function fe({ cursor: o, colors: i, children: c }) {
83
- const f = o.current;
84
- return f ? Pe(
85
- /* @__PURE__ */ d.jsx(
86
- "div",
87
- {
88
- style: {
89
- position: "fixed",
90
- left: f.x + 14,
91
- top: f.y + 14,
92
- zIndex: 99999,
93
- pointerEvents: "none",
94
- background: i.background,
95
- border: `1px solid ${i.border}`,
96
- borderRadius: 8,
97
- padding: "8px 10px",
98
- fontFamily: i.fontFamily,
99
- fontSize: 12,
100
- color: i.text,
101
- boxShadow: "0 8px 18px rgba(0, 0, 0, 0.18)",
102
- maxWidth: 360
103
- },
104
- children: c
105
- }
106
- ),
107
- document.body
108
- ) : null;
109
- }
110
- function ue({ color: o, label: i, value: c, colors: f }) {
111
- return /* @__PURE__ */ d.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
112
- /* @__PURE__ */ d.jsx("span", { style: { display: "inline-block", width: 10, height: 10, borderRadius: 2, background: o, flexShrink: 0 } }),
113
- /* @__PURE__ */ d.jsx("span", { style: { flex: 1, color: f.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: i }),
114
- /* @__PURE__ */ d.jsx("span", { style: { color: f.text, fontWeight: 600, fontVariantNumeric: "tabular-nums" }, children: c })
115
- ] });
116
- }
117
- function $e() {
118
- const o = be(function({ nodeId: c, context: f, className: y }) {
119
- const p = he(f.store, c), { cursor: A, onMouseMove: R } = ke();
120
- if (!p)
121
- return null;
122
- const e = p.props ?? {}, k = z(e.data) ?? [], S = ce(e.keys), F = s(e.indexBy), h = s(e.groupMode), b = s(e.layout), $ = s(e.valueScale), H = s(e.indexScale), M = l(e.minValue) ?? "auto", N = l(e.maxValue) ?? "auto", U = l(e.padding), I = l(e.innerPadding), _ = re(e.margin), q = E(e.axisTop), W = E(e.axisRight), J = E(e.axisBottom), P = E(e.axisLeft), G = v(e.enableGridX), X = v(e.enableGridY), T = v(e.enableLabel), w = l(e.labelSkipWidth), B = l(e.labelSkipHeight), O = s(e.labelTextColor), D = z(e.legends), V = ce(e.colors), K = s(e.colorScheme), C = ye(e.theme), Y = s(e.borderColor), L = l(e.borderRadius), j = l(e.borderWidth), Q = s(e.valueFormat), n = v(e.isInteractive), m = me(e.onClickId), x = m ? (g) => {
123
- f.dispatchAction(m, {
124
- id: String(g.id),
125
- indexValue: String(g.indexValue),
126
- value: g.value ?? 0
127
- });
128
- } : void 0, Z = xe("nivo-bar-chart", y, s(e.className)), r = {
129
- data: k
130
- };
131
- S !== void 0 && (r.keys = S), F !== void 0 && (r.indexBy = F), h !== void 0 && (r.groupMode = h), b !== void 0 && (r.layout = b), ($ !== void 0 || M !== "auto" || N !== "auto") && (r.valueScale = {
132
- type: $ ?? "linear",
133
- min: M,
134
- max: N
135
- }), H !== void 0 && (r.indexScale = { type: H }), U !== void 0 && (r.padding = U), I !== void 0 && (r.innerPadding = I);
136
- const ae = F ?? "id", oe = k.map((g) => g[ae]), ie = de(J, oe), te = de(q, oe);
137
- if (_ !== void 0 && (r.margin = _), te !== void 0 && (r.axisTop = te), W !== void 0 && (r.axisRight = W), ie !== void 0 && (r.axisBottom = ie), P !== void 0 && (r.axisLeft = P), G !== void 0 && (r.enableGridX = G), X !== void 0 && (r.enableGridY = X), T !== void 0 && (r.enableLabel = T), w !== void 0 && (r.labelSkipWidth = w), B !== void 0 && (r.labelSkipHeight = B), O !== void 0 && (r.labelTextColor = O), D !== void 0 && (r.legends = D), V !== void 0 && (r.colors = V), K !== void 0 && V === void 0 && (r.colors = { scheme: K }), C !== void 0 && (r.theme = C), Y !== void 0 && (r.borderColor = Y), L !== void 0 && (r.borderRadius = L), j !== void 0 && (r.borderWidth = j), Q !== void 0 && (r.valueFormat = Q), n !== void 0 && (r.isInteractive = n), x !== void 0 && (r.onClick = x), n !== !1) {
138
- const g = Se(C);
139
- r.tooltip = ((ne) => /* @__PURE__ */ d.jsxs(fe, { cursor: A, colors: g, children: [
140
- /* @__PURE__ */ d.jsx("div", { style: { color: g.muted, fontSize: 11, marginBottom: 4 }, children: String(ne.indexValue) }),
141
- /* @__PURE__ */ d.jsx(ue, { color: ne.color, label: ne.id, value: ne.formattedValue, colors: g })
142
- ] }));
143
- }
144
- return /* @__PURE__ */ d.jsx(ge, { children: /* @__PURE__ */ d.jsx("div", { className: Z, "data-ikon-node-id": p.id, "data-ikon-source": p.sourceMarker, onMouseMove: R, children: /* @__PURE__ */ d.jsx(je, { ...r }) }) });
145
- });
146
- return (i) => {
147
- if (i.type === "std.chart-bar")
148
- return o;
149
- };
150
- }
151
- function He() {
152
- const o = be(function({ nodeId: c, context: f, className: y }) {
153
- const p = he(f.store, c), { cursor: A, onMouseMove: R } = ke();
154
- if (!p)
155
- return null;
156
- const e = p.props ?? {}, k = z(e.data) ?? [], S = s(e.xScaleType), F = s(e.yScaleType), h = l(e.xScaleMin), b = l(e.xScaleMax), $ = l(e.yScaleMin) ?? "auto", H = l(e.yScaleMax) ?? "auto", M = v(e.yScaleStacked), N = re(e.margin), U = E(e.axisTop), I = E(e.axisRight), _ = E(e.axisBottom), q = E(e.axisLeft), W = v(e.enableGridX), J = v(e.enableGridY), P = v(e.enablePoints), G = l(e.pointSize), X = s(e.pointColor), T = s(e.pointBorderColor), w = l(e.pointBorderWidth), B = v(e.enableArea), O = l(e.areaOpacity), D = l(e.areaBaselineValue), V = v(e.enableCrosshair), K = s(e.crosshairType), C = s(e.curve), Y = C ? C.replace(/-([a-z])/g, (a, u) => u.toUpperCase()) : void 0, L = z(e.legends), j = ce(e.colors), Q = s(e.colorScheme), n = ye(e.theme), m = l(e.lineWidth), x = v(e.isInteractive), Z = v(e.useMesh), r = v(e.enableSlices), ae = s(e.xFormat), oe = s(e.yFormat), ie = me(e.onClickId), te = ie ? (a) => {
157
- const u = a;
158
- f.dispatchAction(ie, {
159
- serieId: String(u.serieId ?? ""),
160
- value: u.data?.y ?? 0
161
- });
162
- } : void 0, g = xe("nivo-line-chart", y, s(e.className)), t = {
163
- data: S === "time" ? k.map((a) => ({
164
- ...a,
165
- data: a.data.map((u) => ({
166
- ...u,
167
- x: u.x instanceof Date ? u.x : new Date(u.x)
168
- }))
169
- })) : k
170
- }, Ce = h !== void 0 || b !== void 0;
171
- if (S === "linear") {
172
- const a = { type: "linear" };
173
- h !== void 0 && (a.min = h), b !== void 0 && (a.max = b), Ce && (a.nice = !1), t.xScale = a;
174
- } else if (S === "time") {
175
- const a = { type: "time" };
176
- h !== void 0 && (a.min = new Date(h)), b !== void 0 && (a.max = new Date(b)), Ce && (a.nice = !1), t.xScale = a;
177
- } else
178
- t.xScale = { type: "point" };
179
- const Le = {
180
- type: F ?? "linear",
181
- min: $,
182
- max: H
183
- };
184
- M !== void 0 && (Le.stacked = M), t.yScale = Le;
185
- const Be = S ?? "point";
186
- let se = _, le = U;
187
- if (Be === "point") {
188
- const a = k.length > 0 ? k[0].data.map((u) => u.x) : [];
189
- se = de(se, a), le = de(le, a);
190
- }
191
- N !== void 0 && (t.margin = N), le !== void 0 && (t.axisTop = le), I !== void 0 && (t.axisRight = I), se !== void 0 && (t.axisBottom = se), q !== void 0 && (t.axisLeft = q), W !== void 0 && (t.enableGridX = W), J !== void 0 && (t.enableGridY = J);
192
- const ve = z(e.gridXValues)?.filter((a) => typeof a == "number"), pe = z(e.gridYValues)?.filter((a) => typeof a == "number");
193
- if (ve && ve.length > 0 && (t.gridXValues = ve), pe && pe.length > 0 && (t.gridYValues = pe), P !== void 0 && (t.enablePoints = P), G !== void 0 && (t.pointSize = G), X !== void 0 && (t.pointColor = X), T !== void 0 && (t.pointBorderColor = T), w !== void 0 && (t.pointBorderWidth = w), B !== void 0 && (t.enableArea = B), O !== void 0 && (t.areaOpacity = O), D !== void 0 && (t.areaBaselineValue = D), V !== void 0 && (t.enableCrosshair = V), K !== void 0 && (t.crosshairType = K), Y !== void 0 && (t.curve = Y), L !== void 0 && (t.legends = L), j !== void 0 && (t.colors = j), Q !== void 0 && j === void 0 && (t.colors = { scheme: Q }), n !== void 0 && (t.theme = n), m !== void 0 && (t.lineWidth = m), x !== void 0 && (t.isInteractive = x), Z !== void 0 && (t.useMesh = Z), r !== void 0 && (t.enableSlices = r ? "x" : !1), ae !== void 0 && (t.xFormat = ae), oe !== void 0 && (t.yFormat = oe), te !== void 0 && (t.onClick = te), x !== !1) {
194
- const a = Se(n);
195
- t.tooltip = ((u) => /* @__PURE__ */ d.jsx(fe, { cursor: A, colors: a, children: /* @__PURE__ */ d.jsx(ue, { color: u.point.seriesColor, label: u.point.seriesId, value: u.point.data.yFormatted, colors: a }) })), t.sliceTooltip = ((u) => {
196
- const Te = [...u.slice.points].sort((ee, Ve) => Number(Ve.data.y ?? 0) - Number(ee.data.y ?? 0));
197
- return /* @__PURE__ */ d.jsxs(fe, { cursor: A, colors: a, children: [
198
- /* @__PURE__ */ d.jsx("div", { style: { color: a.muted, fontSize: 11, marginBottom: 6, fontWeight: 500 }, children: String(Te[0]?.data?.xFormatted ?? "") }),
199
- /* @__PURE__ */ d.jsx("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: Te.map((ee) => /* @__PURE__ */ d.jsx(ue, { color: ee.seriesColor, label: ee.seriesId, value: ee.data.yFormatted, colors: a }, ee.id)) })
200
- ] });
201
- });
202
- }
203
- const Ae = s(e.gradientFromColor), Re = s(e.gradientToColor);
204
- if (Ae && Re) {
205
- const a = `ikon-line-grad-${p.id}`;
206
- t.defs = [
207
- {
208
- id: a,
209
- type: "linearGradient",
210
- // nivo gradients default to vertical (offset 0 at top). rotate -90°
211
- // about the center so it flows left→right with offset 0 (gradientFrom)
212
- // at the LEFT edge — i.e. the start/launch — and offset 100 at the right.
213
- gradientTransform: "rotate(-90 0.5 0.5)",
214
- colors: [
215
- { offset: 0, color: Ae },
216
- { offset: 100, color: Re }
217
- ]
218
- }
219
- ], t.fill = [{ match: "*", id: a }], t.colors = ((u) => `url(#${a})`);
220
- }
221
- return /* @__PURE__ */ d.jsx(ge, { children: /* @__PURE__ */ d.jsx("div", { className: g, "data-ikon-node-id": p.id, "data-ikon-source": p.sourceMarker, onMouseMove: R, children: /* @__PURE__ */ d.jsx(Fe, { ...t }) }) });
222
- });
223
- return (i) => {
224
- if (i.type === "std.chart-line")
225
- return o;
226
- };
227
- }
228
- function Ue() {
229
- const o = be(function({ nodeId: c, context: f, className: y }) {
230
- const p = he(f.store, c), { cursor: A, onMouseMove: R } = ke();
231
- if (!p)
232
- return null;
233
- const e = p.props ?? {}, k = z(e.data) ?? [], S = l(e.innerRadius), F = l(e.padAngle), h = l(e.cornerRadius), b = l(e.startAngle), $ = l(e.endAngle), H = v(e.sortByValue), M = re(e.margin), N = v(e.enableArcLabels), U = s(e.arcLabelsTextColor), I = l(e.arcLabelsSkipAngle), _ = v(e.enableArcLinkLabels), q = s(e.arcLinkLabelsTextColor), W = l(e.arcLinkLabelsSkipAngle), J = l(e.arcLinkLabelsThickness), P = s(e.arcLinkLabelsColor), G = l(e.activeOuterRadiusOffset), X = z(e.legends), T = ce(e.colors), w = s(e.colorScheme), B = ye(e.theme), O = s(e.borderColor), D = l(e.borderWidth), V = s(e.valueFormat), K = v(e.arcLabelAsPercentage), C = v(e.isInteractive), Y = me(e.onClickId), L = k.reduce((m, x) => m + (Number(x.value) || 0), 0), j = Y ? (m) => {
234
- f.dispatchAction(Y, {
235
- id: String(m.id),
236
- value: m.value
237
- });
238
- } : void 0, Q = xe("nivo-pie-chart", y, s(e.className)), n = {
239
- data: k
240
- };
241
- if (S !== void 0 && (n.innerRadius = S), F !== void 0 && (n.padAngle = F), h !== void 0 && (n.cornerRadius = h), b !== void 0 && (n.startAngle = b), $ !== void 0 && (n.endAngle = $), H !== void 0 && (n.sortByValue = H), M !== void 0 && (n.margin = M), N !== void 0 && (n.enableArcLabels = N), U !== void 0 && (n.arcLabelsTextColor = U), I !== void 0 && (n.arcLabelsSkipAngle = I), _ !== void 0 && (n.enableArcLinkLabels = _), q !== void 0 && (n.arcLinkLabelsTextColor = q), W !== void 0 && (n.arcLinkLabelsSkipAngle = W), J !== void 0 && (n.arcLinkLabelsThickness = J), P !== void 0 && (n.arcLinkLabelsColor = P), G !== void 0 && (n.activeOuterRadiusOffset = G), X !== void 0 && (n.legends = X), T !== void 0 && (n.colors = T), w !== void 0 && T === void 0 && (n.colors = { scheme: w }), B !== void 0 && (n.theme = B), O !== void 0 && (n.borderColor = O), D !== void 0 && (n.borderWidth = D), V !== void 0 && (n.valueFormat = V), C !== void 0 && (n.isInteractive = C), j !== void 0 && (n.onClick = j), K && (n.arcLabel = ((m) => L > 0 ? `${(m.value / L * 100).toFixed(1)}%` : "0%")), C !== !1) {
242
- const m = Se(B);
243
- n.tooltip = ((x) => {
244
- const Z = L > 0 ? `${(x.datum.value / L * 100).toFixed(1)}%` : void 0;
245
- return /* @__PURE__ */ d.jsx(fe, { cursor: A, colors: m, children: /* @__PURE__ */ d.jsx(
246
- ue,
247
- {
248
- color: x.datum.color,
249
- label: x.datum.label ?? x.datum.id,
250
- value: Z ? `${x.datum.formattedValue} · ${Z}` : x.datum.formattedValue,
251
- colors: m
252
- }
253
- ) });
254
- });
255
- }
256
- return /* @__PURE__ */ d.jsx(ge, { children: /* @__PURE__ */ d.jsx("div", { className: Q, "data-ikon-node-id": p.id, "data-ikon-source": p.sourceMarker, onMouseMove: R, children: /* @__PURE__ */ d.jsx(Me, { ...n }) }) });
257
- });
258
- return (i) => {
259
- if (i.type === "std.chart-pie")
260
- return o;
261
- };
262
- }
263
- export {
264
- $e as createNivoBarChartResolver,
265
- He as createNivoLineChartResolver,
266
- Ue as createNivoPieChartResolver
267
- };