@nice2dev/ui 1.4.23 → 1.4.25

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +2 -4
  3. package/dist/NiceModuleLifecyclePanel-bsHwj1pO.cjs +1 -0
  4. package/dist/{NicePivotGrid-B5Fgi5E_.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
  5. package/dist/{NiceStreamDashboard.doc-74KUXya1.cjs → NiceStreamDashboard.doc-CdkHFf4Y.cjs} +2 -2
  6. package/dist/charts/NiceAdvancedCharts.mjs +586 -773
  7. package/dist/charts/NiceChartRangeSelector.mjs +159 -0
  8. package/dist/charts/NiceHeatMap.mjs +140 -70
  9. package/dist/charts/NiceOrganizationChart.mjs +183 -90
  10. package/dist/charts/NiceSankey.mjs +166 -93
  11. package/dist/charts/NiceStockChart.mjs +258 -157
  12. package/dist/charts-CSgOgfES.cjs +867 -0
  13. package/dist/charts.cjs +1 -1
  14. package/dist/charts.d.ts +126 -102
  15. package/dist/charts.mjs +22 -24
  16. package/dist/core/lazy.mjs +50 -63
  17. package/dist/core-lazy-sO0xvg64.cjs +1 -0
  18. package/dist/data.cjs +1 -1
  19. package/dist/demo/docs/docPreviews.mjs +504 -546
  20. package/dist/demo/docs/docRegistry.mjs +9 -94
  21. package/dist/docs/NiceStreamDashboard.doc.json.mjs +1 -1
  22. package/dist/documentation/utils.mjs +1 -1
  23. package/dist/index.cjs +95 -121
  24. package/dist/index.d.ts +126 -217
  25. package/dist/index.mjs +829 -836
  26. package/dist/lazy.cjs +1 -1
  27. package/dist/lazy.d.ts +41 -23
  28. package/dist/lazy.mjs +1 -1
  29. package/dist/navigation/NiceDock.mjs +55 -48
  30. package/dist/navigation/NiceMenuTypes.mjs +197 -251
  31. package/dist/navigation.cjs +1 -1
  32. package/dist/navigation.d.ts +5 -16
  33. package/dist/navigation.mjs +53 -54
  34. package/dist/style.css +2 -2
  35. package/dist/tools/NiceShowcase.mjs +2 -4
  36. package/package.json +4 -4
  37. package/dist/NiceDiagram.doc-CASS0Tnj.cjs +0 -8
  38. package/dist/NiceModuleLifecyclePanel-jckyVqqt.cjs +0 -1
  39. package/dist/charts/NiceRangeSelector.mjs +0 -135
  40. package/dist/charts/NiceTreeMap.mjs +0 -100
  41. package/dist/charts/NiceVectorMap.mjs +0 -59
  42. package/dist/charts-C9B548D2.cjs +0 -924
  43. package/dist/core-lazy-B54FdghB.cjs +0 -1
  44. package/dist/docs/NiceDiagram.doc.json.mjs +0 -32
  45. package/dist/tools/NiceChat.mjs +0 -98
@@ -1,169 +1,270 @@
1
- import { jsx as l, jsxs as p } from "react/jsx-runtime";
2
- import { useControlId as z } from "@nice2dev/ui-core";
3
- import { forwardRef as D, useMemo as H } from "react";
4
- const V = [], F = /* @__PURE__ */ Object.assign(
5
- /* @__PURE__ */ D(
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 = V,
8
- type: v = "candlestick",
9
- showVolume: y = !0,
10
- width: u = 800,
11
- height: a = 400,
12
- bullColor: k = "var(--nice-color-success, #22c55e)",
13
- bearColor: g = "var(--nice-color-error, #ef4444)",
14
- className: S,
15
- style: N,
16
- id: $,
17
- testId: j,
18
- "data-testid": A
19
- }, w) => {
20
- const I = z($), r = { top: 20, right: 20, bottom: y ? 80 : 30, left: 60 }, b = u - r.left - r.right, h = y ? 50 : 0, d = a - r.top - r.bottom - h, { minP: x, maxP: M, maxVol: T } = H(() => {
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 t = 1 / 0, e = -1 / 0, s = 0;
24
- for (const n of c)
25
- n.low < t && (t = n.low), n.high > e && (e = n.high), n.volume && n.volume > s && (s = n.volume);
26
- return { minP: t, maxP: e, maxVol: s };
27
- }, [c]), m = Math.max(1, b / c.length * 0.7), f = (t) => r.left + (t + 0.5) * (b / c.length), o = (t) => r.top + d - (t - x) / (M - x || 1) * d, W = (t) => a - r.bottom - h + h * (1 - t / (T || 1));
28
- return /* @__PURE__ */ l(
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: w,
32
- id: I,
33
- className: `nice-stock-chart ${S || ""}`,
34
- style: N,
35
- "data-testid": A ?? j,
36
- children: /* @__PURE__ */ p("svg", { width: u, height: a, className: "nice-stock-chart__svg", children: [
37
- [0, 0.25, 0.5, 0.75, 1].map((t) => {
38
- const e = x + t * (M - x);
39
- return /* @__PURE__ */ p("g", { children: [
40
- /* @__PURE__ */ l(
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
- points: c.map((t, e) => `${f(e)},${o(t.close)}`).join(" "),
68
- fill: "none",
69
- stroke: k,
70
- strokeWidth: 1.5
71
- }
72
- ) : c.map((t, e) => {
73
- const s = t.close >= t.open, n = s ? k : g, i = f(e);
74
- if (v === "ohlc")
75
- return /* @__PURE__ */ p("g", { children: [
76
- /* @__PURE__ */ l(
77
- "line",
78
- {
79
- x1: i,
80
- x2: i,
81
- y1: o(t.high),
82
- y2: o(t.low),
83
- stroke: n,
84
- strokeWidth: 1
85
- }
86
- ),
87
- /* @__PURE__ */ l(
88
- "line",
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
- x1: i - m / 2,
91
- x2: i,
92
- y1: o(t.open),
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
- /* @__PURE__ */ l(
99
- "line",
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
- x1: i,
102
- x2: i + m / 2,
103
- y1: o(t.close),
104
- y2: o(t.close),
105
- stroke: n,
106
- strokeWidth: 1.5
107
- }
108
- )
109
- ] }, e);
110
- const P = o(Math.max(t.open, t.close)), _ = o(Math.min(t.open, t.close));
111
- return /* @__PURE__ */ p("g", { children: [
112
- /* @__PURE__ */ l(
113
- "line",
114
- {
115
- x1: i,
116
- x2: i,
117
- y1: o(t.high),
118
- y2: o(t.low),
119
- stroke: n,
120
- strokeWidth: 1
121
- }
122
- ),
123
- /* @__PURE__ */ l(
124
- "rect",
125
- {
126
- x: i - m / 2,
127
- y: P,
128
- width: m,
129
- height: Math.max(_ - P, 1),
130
- fill: s ? "transparent" : n,
131
- stroke: n,
132
- strokeWidth: 1
133
- }
134
- )
135
- ] }, e);
136
- }),
137
- y && c.map((t, e) => {
138
- if (!t.volume)
139
- return null;
140
- const s = t.close >= t.open;
141
- return /* @__PURE__ */ l(
142
- "rect",
143
- {
144
- x: f(e) - m / 2,
145
- y: W(t.volume),
146
- width: m,
147
- height: a - r.bottom - W(t.volume),
148
- fill: s ? k : g,
149
- opacity: 0.3
150
- },
151
- `v${e}`
152
- );
153
- }),
154
- c.map((t, e) => e % Math.max(1, Math.floor(c.length / 8)) !== 0 ? null : /* @__PURE__ */ l(
155
- "text",
156
- {
157
- x: f(e),
158
- y: a - r.bottom + h + 14,
159
- textAnchor: "middle",
160
- fontSize: 9,
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
- F as NiceStockChart
275
+ re as NiceStockChart
175
276
  };