@ikonai/sdk-react-ui-standard 1.0.65 → 1.0.67

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,267 @@
1
+ import { a as l, b as v, t as s, d as me, c as xe, j as d } from "./index-0g7J2N9e.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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk-react-ui-standard",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",