@nice2dev/ui 1.4.23 → 1.4.24
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/CHANGELOG.md +57 -0
- package/dist/{NicePivotGrid-B5Fgi5E_.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +586 -773
- package/dist/charts/NiceChartRangeSelector.mjs +159 -0
- package/dist/charts/NiceHeatMap.mjs +140 -70
- package/dist/charts/NiceOrganizationChart.mjs +183 -90
- package/dist/charts/NiceSankey.mjs +166 -93
- package/dist/charts/NiceStockChart.mjs +258 -157
- package/dist/charts-CSgOgfES.cjs +867 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +126 -102
- package/dist/charts.mjs +22 -24
- package/dist/core/lazy.mjs +50 -63
- package/dist/core-lazy-sO0xvg64.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/demo/docs/docPreviews.mjs +450 -466
- package/dist/demo/docs/docRegistry.mjs +5 -35
- package/dist/index.cjs +60 -67
- package/dist/index.d.ts +121 -172
- package/dist/index.mjs +831 -836
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +41 -23
- package/dist/lazy.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/tools/NiceShowcase.mjs +1 -2
- package/package.json +4 -4
- package/dist/charts/NiceRangeSelector.mjs +0 -135
- package/dist/charts/NiceTreeMap.mjs +0 -100
- package/dist/charts/NiceVectorMap.mjs +0 -59
- package/dist/charts-C9B548D2.cjs +0 -924
- package/dist/core-lazy-B54FdghB.cjs +0 -1
|
@@ -1,169 +1,270 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useControlId as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
const
|
|
5
|
-
/* @__PURE__ */
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useControlId as J } from "@nice2dev/ui-core";
|
|
3
|
+
import { forwardRef as K, useRef as Q, useState as E, useEffect as U, useMemo as Z } from "react";
|
|
4
|
+
const ee = [], re = /* @__PURE__ */ Object.assign(
|
|
5
|
+
/* @__PURE__ */ K(
|
|
6
6
|
({
|
|
7
|
-
data: c =
|
|
8
|
-
type:
|
|
9
|
-
showVolume:
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
12
|
-
bullColor:
|
|
13
|
-
bearColor:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
data: c = ee,
|
|
8
|
+
type: S = "candlestick",
|
|
9
|
+
showVolume: b = !0,
|
|
10
|
+
width: I = 800,
|
|
11
|
+
height: f = 400,
|
|
12
|
+
bullColor: M = "var(--nice-color-success, #22c55e)",
|
|
13
|
+
bearColor: R = "var(--nice-color-error, #ef4444)",
|
|
14
|
+
showCrosshair: w = !0,
|
|
15
|
+
responsive: d = !0,
|
|
16
|
+
formatPrice: y = (W) => W.toFixed(2),
|
|
17
|
+
className: L,
|
|
18
|
+
style: j,
|
|
19
|
+
id: P,
|
|
20
|
+
testId: V,
|
|
21
|
+
"data-testid": Y
|
|
22
|
+
}, p) => {
|
|
23
|
+
const W = J(P), $ = Q(null), [z, F] = E(null);
|
|
24
|
+
U(() => {
|
|
25
|
+
const e = $.current;
|
|
26
|
+
if (!d || !e || typeof ResizeObserver > "u")
|
|
27
|
+
return;
|
|
28
|
+
const t = new ResizeObserver(([i]) => {
|
|
29
|
+
const o = Math.round(i.contentRect.width);
|
|
30
|
+
o > 0 && F(o);
|
|
31
|
+
});
|
|
32
|
+
return t.observe(e), () => t.disconnect();
|
|
33
|
+
}, [d]);
|
|
34
|
+
const k = d && z ? z : I, [v, A] = E(null), n = { top: 20, right: 20, bottom: 30, left: 60 }, _ = Math.max(10, k - n.left - n.right), D = b ? 50 : 0, G = b ? 8 : 0, H = f - n.top - n.bottom - D - G, { minP: g, maxP: O, maxVol: X } = Z(() => {
|
|
21
35
|
if (c.length === 0)
|
|
22
36
|
return { minP: 0, maxP: 1, maxVol: 0 };
|
|
23
|
-
let
|
|
24
|
-
for (const
|
|
25
|
-
|
|
26
|
-
return { minP:
|
|
27
|
-
}, [c]),
|
|
28
|
-
|
|
37
|
+
let e = 1 / 0, t = -1 / 0, i = 0;
|
|
38
|
+
for (const o of c)
|
|
39
|
+
o.low < e && (e = o.low), o.high > t && (t = o.high), o.volume && o.volume > i && (i = o.volume);
|
|
40
|
+
return { minP: e, maxP: t, maxVol: i };
|
|
41
|
+
}, [c]), u = Math.max(1, _ / c.length * 0.7), x = (e) => n.left + (e + 0.5) * (_ / c.length), r = (e) => n.top + H - (e - g) / (O - g || 1) * H, T = f - n.bottom, B = (e) => T - D * (e / (X || 1)), a = v != null ? c[v] : void 0, q = (e) => {
|
|
42
|
+
if (!w || c.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
const t = e.currentTarget.getBoundingClientRect(), i = e.clientX - t.left - n.left, o = Math.floor(i / _ * c.length);
|
|
45
|
+
A(o >= 0 && o < c.length ? o : null);
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ h(
|
|
29
48
|
"div",
|
|
30
49
|
{
|
|
31
|
-
ref:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"line",
|
|
42
|
-
{
|
|
43
|
-
x1: r.left,
|
|
44
|
-
x2: u - r.right,
|
|
45
|
-
y1: o(e),
|
|
46
|
-
y2: o(e),
|
|
47
|
-
stroke: "var(--nice-border, #e5e7eb)",
|
|
48
|
-
strokeDasharray: "2,2"
|
|
49
|
-
}
|
|
50
|
-
),
|
|
51
|
-
c.length > 0 && /* @__PURE__ */ l(
|
|
52
|
-
"text",
|
|
53
|
-
{
|
|
54
|
-
x: r.left - 4,
|
|
55
|
-
y: o(e) + 4,
|
|
56
|
-
textAnchor: "end",
|
|
57
|
-
fontSize: 10,
|
|
58
|
-
fill: "var(--nice-text-secondary, #888)",
|
|
59
|
-
children: e.toFixed(2)
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
] }, t);
|
|
63
|
-
}),
|
|
64
|
-
v === "line" ? /* @__PURE__ */ l(
|
|
65
|
-
"polyline",
|
|
50
|
+
ref: (e) => {
|
|
51
|
+
$.current = e, typeof p == "function" ? p(e) : p && (p.current = e);
|
|
52
|
+
},
|
|
53
|
+
id: W,
|
|
54
|
+
className: `nice-stock-chart ${L || ""}`,
|
|
55
|
+
style: d ? { width: "100%", position: "relative", ...j } : { position: "relative", ...j },
|
|
56
|
+
"data-testid": Y ?? V,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ h(
|
|
59
|
+
"svg",
|
|
66
60
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
61
|
+
width: k,
|
|
62
|
+
height: f,
|
|
63
|
+
className: "nice-stock-chart__svg",
|
|
64
|
+
onMouseMove: q,
|
|
65
|
+
onMouseLeave: () => A(null),
|
|
66
|
+
children: [
|
|
67
|
+
[0, 0.25, 0.5, 0.75, 1].map((e) => {
|
|
68
|
+
const t = g + e * (O - g);
|
|
69
|
+
return /* @__PURE__ */ h("g", { children: [
|
|
70
|
+
/* @__PURE__ */ l(
|
|
71
|
+
"line",
|
|
72
|
+
{
|
|
73
|
+
x1: n.left,
|
|
74
|
+
x2: k - n.right,
|
|
75
|
+
y1: r(t),
|
|
76
|
+
y2: r(t),
|
|
77
|
+
stroke: "var(--nice-border, #e5e7eb)",
|
|
78
|
+
strokeDasharray: "2,2"
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
c.length > 0 && /* @__PURE__ */ l(
|
|
82
|
+
"text",
|
|
83
|
+
{
|
|
84
|
+
x: n.left - 4,
|
|
85
|
+
y: r(t) + 4,
|
|
86
|
+
textAnchor: "end",
|
|
87
|
+
fontSize: 10,
|
|
88
|
+
fill: "var(--nice-text-secondary, #888)",
|
|
89
|
+
children: y(t)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }, e);
|
|
93
|
+
}),
|
|
94
|
+
S === "line" ? /* @__PURE__ */ l(
|
|
95
|
+
"polyline",
|
|
89
96
|
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
y2: o(t.open),
|
|
94
|
-
stroke: n,
|
|
97
|
+
points: c.map((e, t) => `${x(t)},${r(e.close)}`).join(" "),
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: M,
|
|
95
100
|
strokeWidth: 1.5
|
|
96
101
|
}
|
|
97
|
-
),
|
|
98
|
-
|
|
99
|
-
"
|
|
102
|
+
) : c.map((e, t) => {
|
|
103
|
+
const i = e.close >= e.open, o = i ? M : R, s = x(t);
|
|
104
|
+
if (S === "ohlc")
|
|
105
|
+
return /* @__PURE__ */ h("g", { children: [
|
|
106
|
+
/* @__PURE__ */ l(
|
|
107
|
+
"line",
|
|
108
|
+
{
|
|
109
|
+
x1: s,
|
|
110
|
+
x2: s,
|
|
111
|
+
y1: r(e.high),
|
|
112
|
+
y2: r(e.low),
|
|
113
|
+
stroke: o,
|
|
114
|
+
strokeWidth: 1
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ l(
|
|
118
|
+
"line",
|
|
119
|
+
{
|
|
120
|
+
x1: s - u / 2,
|
|
121
|
+
x2: s,
|
|
122
|
+
y1: r(e.open),
|
|
123
|
+
y2: r(e.open),
|
|
124
|
+
stroke: o,
|
|
125
|
+
strokeWidth: 1.5
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ l(
|
|
129
|
+
"line",
|
|
130
|
+
{
|
|
131
|
+
x1: s,
|
|
132
|
+
x2: s + u / 2,
|
|
133
|
+
y1: r(e.close),
|
|
134
|
+
y2: r(e.close),
|
|
135
|
+
stroke: o,
|
|
136
|
+
strokeWidth: 1.5
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] }, t);
|
|
140
|
+
const m = r(Math.max(e.open, e.close)), N = r(Math.min(e.open, e.close)), C = Math.abs(N - m) < 1;
|
|
141
|
+
return /* @__PURE__ */ h("g", { className: "nice-stock-chart__candle", children: [
|
|
142
|
+
/* @__PURE__ */ l(
|
|
143
|
+
"line",
|
|
144
|
+
{
|
|
145
|
+
x1: s,
|
|
146
|
+
x2: s,
|
|
147
|
+
y1: r(e.high),
|
|
148
|
+
y2: m,
|
|
149
|
+
stroke: o,
|
|
150
|
+
strokeWidth: 1
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ l(
|
|
154
|
+
"line",
|
|
155
|
+
{
|
|
156
|
+
x1: s,
|
|
157
|
+
x2: s,
|
|
158
|
+
y1: N,
|
|
159
|
+
y2: r(e.low),
|
|
160
|
+
stroke: o,
|
|
161
|
+
strokeWidth: 1
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
C ? /* @__PURE__ */ l(
|
|
165
|
+
"line",
|
|
166
|
+
{
|
|
167
|
+
x1: s - u / 2,
|
|
168
|
+
x2: s + u / 2,
|
|
169
|
+
y1: m,
|
|
170
|
+
y2: m,
|
|
171
|
+
stroke: o,
|
|
172
|
+
strokeWidth: 1.5
|
|
173
|
+
}
|
|
174
|
+
) : /* @__PURE__ */ l(
|
|
175
|
+
"rect",
|
|
176
|
+
{
|
|
177
|
+
x: s - u / 2,
|
|
178
|
+
y: m,
|
|
179
|
+
width: u,
|
|
180
|
+
height: N - m,
|
|
181
|
+
fill: i ? "var(--nice-bg-primary, #ffffff)" : o,
|
|
182
|
+
stroke: o,
|
|
183
|
+
strokeWidth: 1
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }, t);
|
|
187
|
+
}),
|
|
188
|
+
b && c.map((e, t) => {
|
|
189
|
+
if (!e.volume)
|
|
190
|
+
return null;
|
|
191
|
+
const i = e.close >= e.open;
|
|
192
|
+
return /* @__PURE__ */ l(
|
|
193
|
+
"rect",
|
|
194
|
+
{
|
|
195
|
+
x: x(t) - u / 2,
|
|
196
|
+
y: B(e.volume),
|
|
197
|
+
width: u,
|
|
198
|
+
height: T - B(e.volume),
|
|
199
|
+
fill: i ? M : R,
|
|
200
|
+
opacity: 0.3
|
|
201
|
+
},
|
|
202
|
+
`v${t}`
|
|
203
|
+
);
|
|
204
|
+
}),
|
|
205
|
+
c.map((e, t) => t % Math.max(1, Math.floor(c.length / 8)) !== 0 ? null : /* @__PURE__ */ l(
|
|
206
|
+
"text",
|
|
100
207
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
fill: "var(--nice-text-secondary, #888)",
|
|
162
|
-
children: t.date
|
|
163
|
-
},
|
|
164
|
-
`l${e}`
|
|
165
|
-
))
|
|
166
|
-
] })
|
|
208
|
+
x: x(t),
|
|
209
|
+
y: f - n.bottom + 16,
|
|
210
|
+
textAnchor: "middle",
|
|
211
|
+
fontSize: 9,
|
|
212
|
+
fill: "var(--nice-text-secondary, #888)",
|
|
213
|
+
children: e.date
|
|
214
|
+
},
|
|
215
|
+
`l${t}`
|
|
216
|
+
)),
|
|
217
|
+
w && a && v != null && /* @__PURE__ */ h("g", { pointerEvents: "none", className: "nice-stock-chart__crosshair", children: [
|
|
218
|
+
/* @__PURE__ */ l(
|
|
219
|
+
"line",
|
|
220
|
+
{
|
|
221
|
+
x1: x(v),
|
|
222
|
+
x2: x(v),
|
|
223
|
+
y1: n.top,
|
|
224
|
+
y2: f - n.bottom,
|
|
225
|
+
stroke: "var(--nice-text-secondary, #888)",
|
|
226
|
+
strokeDasharray: "3,3"
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ l(
|
|
230
|
+
"line",
|
|
231
|
+
{
|
|
232
|
+
x1: n.left,
|
|
233
|
+
x2: k - n.right,
|
|
234
|
+
y1: r(a.close),
|
|
235
|
+
y2: r(a.close),
|
|
236
|
+
stroke: "var(--nice-text-secondary, #888)",
|
|
237
|
+
strokeDasharray: "3,3"
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] })
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
w && a && /* @__PURE__ */ h("div", { className: "nice-stock-chart__tooltip", role: "status", children: [
|
|
245
|
+
/* @__PURE__ */ l("strong", { children: a.date }),
|
|
246
|
+
/* @__PURE__ */ h("span", { children: [
|
|
247
|
+
"O ",
|
|
248
|
+
y(a.open)
|
|
249
|
+
] }),
|
|
250
|
+
/* @__PURE__ */ h("span", { children: [
|
|
251
|
+
"H ",
|
|
252
|
+
y(a.high)
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ h("span", { children: [
|
|
255
|
+
"L ",
|
|
256
|
+
y(a.low)
|
|
257
|
+
] }),
|
|
258
|
+
/* @__PURE__ */ h("span", { children: [
|
|
259
|
+
"C ",
|
|
260
|
+
y(a.close)
|
|
261
|
+
] }),
|
|
262
|
+
a.volume != null && /* @__PURE__ */ h("span", { children: [
|
|
263
|
+
"V ",
|
|
264
|
+
a.volume.toLocaleString()
|
|
265
|
+
] })
|
|
266
|
+
] })
|
|
267
|
+
]
|
|
167
268
|
}
|
|
168
269
|
);
|
|
169
270
|
}
|
|
@@ -171,5 +272,5 @@ const V = [], F = /* @__PURE__ */ Object.assign(
|
|
|
171
272
|
{ displayName: "NiceStockChart" }
|
|
172
273
|
);
|
|
173
274
|
export {
|
|
174
|
-
|
|
275
|
+
re as NiceStockChart
|
|
175
276
|
};
|