elseware-ui 2.32.0 → 2.34.0
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/dist/index.css +422 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +913 -158
- package/dist/index.d.ts +913 -158
- package/dist/index.js +2938 -385
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2751 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tailwindMerge = require('tailwind-merge');
|
|
4
|
-
var
|
|
4
|
+
var React3 = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var bs = require('react-icons/bs');
|
|
7
7
|
var fa = require('react-icons/fa');
|
|
@@ -12,7 +12,7 @@ var classNames16 = require('classnames');
|
|
|
12
12
|
var fa6 = require('react-icons/fa6');
|
|
13
13
|
var ReactWorldFlags = require('react-world-flags');
|
|
14
14
|
var emojiFlags = require('emoji-flags');
|
|
15
|
-
var
|
|
15
|
+
var recharts = require('recharts');
|
|
16
16
|
var cloudinaryReact = require('cloudinary-react');
|
|
17
17
|
var formik = require('formik');
|
|
18
18
|
var reactToastify = require('react-toastify');
|
|
@@ -28,29 +28,10 @@ var bi = require('react-icons/bi');
|
|
|
28
28
|
|
|
29
29
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
if (e && e.__esModule) return e;
|
|
33
|
-
var n = Object.create(null);
|
|
34
|
-
if (e) {
|
|
35
|
-
Object.keys(e).forEach(function (k) {
|
|
36
|
-
if (k !== 'default') {
|
|
37
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
38
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () { return e[k]; }
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
n.default = e;
|
|
46
|
-
return Object.freeze(n);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
31
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
50
32
|
var classNames16__default = /*#__PURE__*/_interopDefault(classNames16);
|
|
51
33
|
var ReactWorldFlags__default = /*#__PURE__*/_interopDefault(ReactWorldFlags);
|
|
52
34
|
var emojiFlags__default = /*#__PURE__*/_interopDefault(emojiFlags);
|
|
53
|
-
var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
|
|
54
35
|
|
|
55
36
|
// node_modules/clsx/dist/clsx.mjs
|
|
56
37
|
function r(e) {
|
|
@@ -207,16 +188,336 @@ function resolveAppearanceStyles({
|
|
|
207
188
|
return solid[variant];
|
|
208
189
|
}
|
|
209
190
|
}
|
|
210
|
-
|
|
191
|
+
|
|
192
|
+
// src/utils/configurator/errors.ts
|
|
193
|
+
var ConfiguratorError = class extends Error {
|
|
194
|
+
constructor(message, cause) {
|
|
195
|
+
super(message);
|
|
196
|
+
this.name = "ConfiguratorError";
|
|
197
|
+
this.cause = cause;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function formatIssue(issue) {
|
|
201
|
+
const path = issue.path?.join(".") || "config";
|
|
202
|
+
return `${path} : ${issue.message ?? "Invalid value"}`;
|
|
203
|
+
}
|
|
204
|
+
function formatConfigError(error) {
|
|
205
|
+
const maybeZodError = error;
|
|
206
|
+
if (Array.isArray(maybeZodError.issues)) {
|
|
207
|
+
return maybeZodError.issues.map(formatIssue).join("\n");
|
|
208
|
+
}
|
|
209
|
+
if (maybeZodError?.message) {
|
|
210
|
+
return maybeZodError.message;
|
|
211
|
+
}
|
|
212
|
+
return "Invalid configuration";
|
|
213
|
+
}
|
|
214
|
+
function toConfiguratorError(error, fallbackMessage) {
|
|
215
|
+
if (error instanceof ConfiguratorError) {
|
|
216
|
+
return error;
|
|
217
|
+
}
|
|
218
|
+
if (error instanceof Error) {
|
|
219
|
+
return new ConfiguratorError(error.message || fallbackMessage, error);
|
|
220
|
+
}
|
|
221
|
+
return new ConfiguratorError(fallbackMessage, error);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/utils/configurator/Configurator.ts
|
|
225
|
+
var Configurator = class {
|
|
226
|
+
constructor(options) {
|
|
227
|
+
this.initialized = false;
|
|
228
|
+
this.config = null;
|
|
229
|
+
this.configError = null;
|
|
230
|
+
this.name = options.name ?? "config";
|
|
231
|
+
this.source = options.env;
|
|
232
|
+
this.schema = options.schema;
|
|
233
|
+
this.transform = options.transform;
|
|
234
|
+
if (options.validateOnCreate !== false) {
|
|
235
|
+
this.reload();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
get isValid() {
|
|
239
|
+
this.ensureInitialized();
|
|
240
|
+
return !this.configError;
|
|
241
|
+
}
|
|
242
|
+
get error() {
|
|
243
|
+
this.ensureInitialized();
|
|
244
|
+
return this.configError;
|
|
245
|
+
}
|
|
246
|
+
get value() {
|
|
247
|
+
this.ensureInitialized();
|
|
248
|
+
if (this.configError) {
|
|
249
|
+
throw this.configError;
|
|
250
|
+
}
|
|
251
|
+
return this.config;
|
|
252
|
+
}
|
|
253
|
+
get optionalValue() {
|
|
254
|
+
this.ensureInitialized();
|
|
255
|
+
return this.config;
|
|
256
|
+
}
|
|
257
|
+
reload(env = this.source) {
|
|
258
|
+
this.source = env;
|
|
259
|
+
this.initialized = true;
|
|
260
|
+
const result = this.schema.safeParse(env);
|
|
261
|
+
if (!result.success) {
|
|
262
|
+
this.config = null;
|
|
263
|
+
this.configError = toConfiguratorError(
|
|
264
|
+
result.error,
|
|
265
|
+
formatConfigError(result.error)
|
|
266
|
+
);
|
|
267
|
+
return {
|
|
268
|
+
success: false,
|
|
269
|
+
config: null,
|
|
270
|
+
error: this.configError
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
this.config = this.transform ? this.transform(result.data, { name: this.name }) : result.data;
|
|
275
|
+
this.configError = null;
|
|
276
|
+
return {
|
|
277
|
+
success: true,
|
|
278
|
+
config: this.config,
|
|
279
|
+
error: null
|
|
280
|
+
};
|
|
281
|
+
} catch (error) {
|
|
282
|
+
this.config = null;
|
|
283
|
+
this.configError = toConfiguratorError(
|
|
284
|
+
error,
|
|
285
|
+
`Failed to transform ${this.name}`
|
|
286
|
+
);
|
|
287
|
+
return {
|
|
288
|
+
success: false,
|
|
289
|
+
config: null,
|
|
290
|
+
error: this.configError
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
get(key) {
|
|
295
|
+
this.ensureInitialized();
|
|
296
|
+
if (!this.config) {
|
|
297
|
+
return void 0;
|
|
298
|
+
}
|
|
299
|
+
return this.config[key];
|
|
300
|
+
}
|
|
301
|
+
getRequired(key) {
|
|
302
|
+
const value = this.get(key);
|
|
303
|
+
if (value === void 0 || value === null) {
|
|
304
|
+
throw new Error(`Missing required config value: ${String(key)}`);
|
|
305
|
+
}
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
getPath(path, fallback) {
|
|
309
|
+
this.ensureInitialized();
|
|
310
|
+
if (!this.config) {
|
|
311
|
+
return fallback;
|
|
312
|
+
}
|
|
313
|
+
const value = path.split(".").reduce((current, key) => {
|
|
314
|
+
if (!current || typeof current !== "object") {
|
|
315
|
+
return void 0;
|
|
316
|
+
}
|
|
317
|
+
return current[key];
|
|
318
|
+
}, this.config);
|
|
319
|
+
return value === void 0 ? fallback : value;
|
|
320
|
+
}
|
|
321
|
+
getPathRequired(path) {
|
|
322
|
+
const value = this.getPath(path);
|
|
323
|
+
if (value === void 0 || value === null) {
|
|
324
|
+
throw new Error(`Missing required config value: ${path}`);
|
|
325
|
+
}
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
ensureInitialized() {
|
|
329
|
+
if (!this.initialized) {
|
|
330
|
+
this.reload();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/utils/configurator/createConfigurator.ts
|
|
336
|
+
function createConfigurator(options) {
|
|
337
|
+
return new Configurator(options);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/utils/configurator/helpers/browser.ts
|
|
341
|
+
function getBrowserOrigin() {
|
|
342
|
+
if (typeof window === "undefined") {
|
|
343
|
+
return "";
|
|
344
|
+
}
|
|
345
|
+
return window.location.origin;
|
|
346
|
+
}
|
|
347
|
+
function getBrowserHref() {
|
|
348
|
+
if (typeof window === "undefined") {
|
|
349
|
+
return "";
|
|
350
|
+
}
|
|
351
|
+
return window.location.href;
|
|
352
|
+
}
|
|
353
|
+
function getBrowserRedirectURL(options = {}) {
|
|
354
|
+
const {
|
|
355
|
+
queryParam = "redirect_uri",
|
|
356
|
+
fallbackPath = "/",
|
|
357
|
+
currentHref = getBrowserHref(),
|
|
358
|
+
referrerMode = "path"
|
|
359
|
+
} = options;
|
|
360
|
+
try {
|
|
361
|
+
if (currentHref) {
|
|
362
|
+
const currentURL = new URL(currentHref);
|
|
363
|
+
const redirectUri = currentURL.searchParams.get(queryParam);
|
|
364
|
+
if (redirectUri) {
|
|
365
|
+
return redirectUri;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
369
|
+
const referrerURL = new URL(document.referrer);
|
|
370
|
+
if (referrerMode === "full") {
|
|
371
|
+
return referrerURL.toString();
|
|
372
|
+
}
|
|
373
|
+
return `${referrerURL.pathname}${referrerURL.search}${referrerURL.hash}`;
|
|
374
|
+
}
|
|
375
|
+
return fallbackPath;
|
|
376
|
+
} catch {
|
|
377
|
+
return fallbackPath;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/utils/configurator/helpers/json.ts
|
|
382
|
+
function isRecord(value) {
|
|
383
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
384
|
+
}
|
|
385
|
+
function parseJson(value, key = "JSON value") {
|
|
386
|
+
if (isRecord(value) || Array.isArray(value)) {
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
389
|
+
if (typeof value !== "string") {
|
|
390
|
+
throw new ConfiguratorError(`${key} must be a JSON string`);
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
return JSON.parse(value);
|
|
394
|
+
} catch {
|
|
395
|
+
throw new ConfiguratorError(`Invalid ${key} JSON`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function parseJsonRecord(value, key = "JSON record", validateValue) {
|
|
399
|
+
const parsed = parseJson(value, key);
|
|
400
|
+
if (!isRecord(parsed)) {
|
|
401
|
+
throw new ConfiguratorError(`${key} must be a JSON object`);
|
|
402
|
+
}
|
|
403
|
+
return Object.entries(parsed).reduce(
|
|
404
|
+
(acc, [name, item]) => {
|
|
405
|
+
acc[name] = validateValue ? validateValue(name, item) : item;
|
|
406
|
+
return acc;
|
|
407
|
+
},
|
|
408
|
+
{}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/utils/configurator/helpers/url.ts
|
|
413
|
+
function assertAbsoluteURL(value, key = "URL") {
|
|
414
|
+
if (typeof value !== "string") {
|
|
415
|
+
throw new ConfiguratorError(`${key} must be a string URL`);
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const url = new URL(value);
|
|
419
|
+
if (!["http:", "https:"].includes(url.protocol)) {
|
|
420
|
+
throw new Error();
|
|
421
|
+
}
|
|
422
|
+
return url.toString();
|
|
423
|
+
} catch {
|
|
424
|
+
throw new ConfiguratorError(`${key} must be a valid http/https URL`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function parseUrlMap(value, key = "URL map") {
|
|
428
|
+
return parseJsonRecord(
|
|
429
|
+
value,
|
|
430
|
+
key,
|
|
431
|
+
(name, item) => assertAbsoluteURL(item, `${key}.${name}`)
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
function buildURL(base, path = "", params = {}) {
|
|
435
|
+
const url = new URL(assertAbsoluteURL(base, "base URL"));
|
|
436
|
+
if (path) {
|
|
437
|
+
const currentPath = url.pathname.replace(/\/$/, "");
|
|
438
|
+
const nextPath = path.replace(/^\/+/, "");
|
|
439
|
+
url.pathname = `${currentPath}/${nextPath}`;
|
|
440
|
+
}
|
|
441
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
442
|
+
if (value !== void 0 && value !== null) {
|
|
443
|
+
url.searchParams.set(key, String(value));
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
return url.toString();
|
|
447
|
+
}
|
|
448
|
+
function resolveURLMap(source) {
|
|
449
|
+
return typeof source === "function" ? source() : source;
|
|
450
|
+
}
|
|
451
|
+
function createURLResolver(source, options = {}) {
|
|
452
|
+
const { label = "URL" } = options;
|
|
453
|
+
return (tag, path = "", params = {}) => {
|
|
454
|
+
const map = resolveURLMap(source) ?? {};
|
|
455
|
+
const base = map[tag];
|
|
456
|
+
if (!base) {
|
|
457
|
+
throw new ConfiguratorError(`${label} not configured for tag: ${tag}`);
|
|
458
|
+
}
|
|
459
|
+
return buildURL(base, path, params);
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function getAllowedOrigins(options = {}) {
|
|
463
|
+
const {
|
|
464
|
+
urls = [],
|
|
465
|
+
maps = [],
|
|
466
|
+
includeCurrentOrigin = true,
|
|
467
|
+
currentOrigin = getBrowserOrigin()
|
|
468
|
+
} = options;
|
|
469
|
+
const origins = /* @__PURE__ */ new Set();
|
|
470
|
+
if (includeCurrentOrigin && currentOrigin) {
|
|
471
|
+
origins.add(currentOrigin);
|
|
472
|
+
}
|
|
473
|
+
urls.forEach((url) => {
|
|
474
|
+
origins.add(new URL(assertAbsoluteURL(url)).origin);
|
|
475
|
+
});
|
|
476
|
+
maps.forEach((map) => {
|
|
477
|
+
Object.values(map ?? {}).forEach((url) => {
|
|
478
|
+
origins.add(new URL(assertAbsoluteURL(url)).origin);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
return Array.from(origins);
|
|
482
|
+
}
|
|
483
|
+
function getSafeRedirect(options = {}) {
|
|
484
|
+
const {
|
|
485
|
+
redirectUri,
|
|
486
|
+
fallback = "/",
|
|
487
|
+
allowedOrigins = [],
|
|
488
|
+
currentOrigin = getBrowserOrigin(),
|
|
489
|
+
allowedProtocols = ["http:", "https:"]
|
|
490
|
+
} = options;
|
|
491
|
+
try {
|
|
492
|
+
if (!redirectUri) {
|
|
493
|
+
return fallback;
|
|
494
|
+
}
|
|
495
|
+
const url = new URL(redirectUri, currentOrigin || fallback);
|
|
496
|
+
if (!allowedProtocols.includes(url.protocol)) {
|
|
497
|
+
return fallback;
|
|
498
|
+
}
|
|
499
|
+
const allowed = new Set(allowedOrigins);
|
|
500
|
+
if (currentOrigin) {
|
|
501
|
+
allowed.add(currentOrigin);
|
|
502
|
+
}
|
|
503
|
+
if (!allowed.has(url.origin)) {
|
|
504
|
+
return fallback;
|
|
505
|
+
}
|
|
506
|
+
return url.toString();
|
|
507
|
+
} catch {
|
|
508
|
+
return fallback;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
var EUIContext = React3.createContext(null);
|
|
211
512
|
var EUIProvider = ({
|
|
212
513
|
config,
|
|
213
514
|
children
|
|
214
515
|
}) => {
|
|
215
|
-
const [state, setState] =
|
|
516
|
+
const [state, setState] = React3.useState(config);
|
|
216
517
|
return /* @__PURE__ */ jsxRuntime.jsx(EUIContext.Provider, { value: { config: state, setConfig: setState }, children });
|
|
217
518
|
};
|
|
218
519
|
var useEUIConfig = () => {
|
|
219
|
-
const ctx =
|
|
520
|
+
const ctx = React3.useContext(EUIContext);
|
|
220
521
|
if (!ctx) {
|
|
221
522
|
throw new Error("useEUIConfig must be used inside EUIProvider");
|
|
222
523
|
}
|
|
@@ -644,7 +945,7 @@ var Chip = ({
|
|
|
644
945
|
}
|
|
645
946
|
) });
|
|
646
947
|
};
|
|
647
|
-
var DataViewContext =
|
|
948
|
+
var DataViewContext = React3.createContext(null);
|
|
648
949
|
|
|
649
950
|
// src/components/data-display/data-view/utils/searchData.ts
|
|
650
951
|
function searchData(data, search) {
|
|
@@ -688,19 +989,19 @@ function DataViewProvider({
|
|
|
688
989
|
defaultPageSize = 9,
|
|
689
990
|
sortConfig = {}
|
|
690
991
|
}) {
|
|
691
|
-
const [search, setSearch] =
|
|
692
|
-
const [filters, setFilters] =
|
|
693
|
-
const [sort, setSort] =
|
|
694
|
-
const [page, setPage] =
|
|
695
|
-
const [pageSize, setPageSize] =
|
|
696
|
-
const processedData =
|
|
992
|
+
const [search, setSearch] = React3.useState("");
|
|
993
|
+
const [filters, setFilters] = React3.useState({});
|
|
994
|
+
const [sort, setSort] = React3.useState("suggested");
|
|
995
|
+
const [page, setPage] = React3.useState(1);
|
|
996
|
+
const [pageSize, setPageSize] = React3.useState(defaultPageSize);
|
|
997
|
+
const processedData = React3.useMemo(() => {
|
|
697
998
|
let result = searchData(data, search);
|
|
698
999
|
result = filterData(result, filters);
|
|
699
1000
|
result = sortData(result, sort, sortConfig);
|
|
700
1001
|
return result;
|
|
701
1002
|
}, [data, search, filters, sort, sortConfig]);
|
|
702
1003
|
const totalPages = pageSize === "All" ? 1 : Math.ceil(processedData.length / pageSize);
|
|
703
|
-
const paginatedData =
|
|
1004
|
+
const paginatedData = React3.useMemo(() => {
|
|
704
1005
|
if (pageSize === "All") return processedData;
|
|
705
1006
|
const size = pageSize;
|
|
706
1007
|
const start = (page - 1) * size;
|
|
@@ -738,7 +1039,7 @@ function DataViewSidebar({ children }) {
|
|
|
738
1039
|
}
|
|
739
1040
|
var DataViewSidebar_default = DataViewSidebar;
|
|
740
1041
|
function useDataView() {
|
|
741
|
-
const ctx =
|
|
1042
|
+
const ctx = React3.useContext(DataViewContext);
|
|
742
1043
|
if (!ctx) {
|
|
743
1044
|
throw new Error("useDataView must be used within DataViewProvider");
|
|
744
1045
|
}
|
|
@@ -804,7 +1105,7 @@ function Accordion({
|
|
|
804
1105
|
toggleOnSummaryClick = false,
|
|
805
1106
|
enableChildrenPadding = true
|
|
806
1107
|
}) {
|
|
807
|
-
const [collapse, setCollapse] =
|
|
1108
|
+
const [collapse, setCollapse] = React3.useState(defaultCollapse);
|
|
808
1109
|
const handleToggle = () => {
|
|
809
1110
|
setCollapse((prev) => !prev);
|
|
810
1111
|
};
|
|
@@ -852,7 +1153,7 @@ function Accordion({
|
|
|
852
1153
|
leave: "transition duration-75 ease-out",
|
|
853
1154
|
leaveFrom: "transform scale-100 opacity-100",
|
|
854
1155
|
leaveTo: "transform scale-95 opacity-0",
|
|
855
|
-
as:
|
|
1156
|
+
as: React3.Fragment,
|
|
856
1157
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
857
1158
|
"div",
|
|
858
1159
|
{
|
|
@@ -1305,8 +1606,8 @@ var Flag = ({
|
|
|
1305
1606
|
className,
|
|
1306
1607
|
...rest
|
|
1307
1608
|
}) => {
|
|
1308
|
-
const [pos, setPos] =
|
|
1309
|
-
const [showTooltip, setShowTooltip] =
|
|
1609
|
+
const [pos, setPos] = React3.useState({ x: 0, y: 0 });
|
|
1610
|
+
const [showTooltip, setShowTooltip] = React3.useState(false);
|
|
1310
1611
|
const upperCode = code.toUpperCase();
|
|
1311
1612
|
const country = emojiFlags__default.default.countryCode(upperCode);
|
|
1312
1613
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1348,265 +1649,2452 @@ var Flag = ({
|
|
|
1348
1649
|
);
|
|
1349
1650
|
};
|
|
1350
1651
|
|
|
1351
|
-
// src/components/data-display/graphs/
|
|
1352
|
-
var
|
|
1353
|
-
var
|
|
1354
|
-
|
|
1652
|
+
// src/components/data-display/graphs-v2/constants/graph.constants.ts
|
|
1653
|
+
var GRAPH_DEFAULT_HEIGHT = 320;
|
|
1654
|
+
var GRAPH_DEFAULT_MAX_REALTIME_POINTS = 100;
|
|
1655
|
+
var GRAPH_DEFAULT_POLLING_INTERVAL = 5e3;
|
|
1656
|
+
var GRAPH_DEFAULT_ANIMATION_DURATION = 350;
|
|
1657
|
+
var GRAPH_DEFAULT_MARGIN = {
|
|
1658
|
+
top: 16,
|
|
1659
|
+
right: 24,
|
|
1660
|
+
bottom: 16,
|
|
1661
|
+
left: 8
|
|
1355
1662
|
};
|
|
1356
|
-
var
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1663
|
+
var GRAPH_DEFAULT_STROKE_WIDTH = 2;
|
|
1664
|
+
var GRAPH_DEFAULT_DOT_RADIUS = 3;
|
|
1665
|
+
var GRAPH_DEFAULT_ACTIVE_DOT_RADIUS = 5;
|
|
1666
|
+
var GRAPH_DEFAULT_BAR_RADIUS = [
|
|
1667
|
+
6,
|
|
1668
|
+
6,
|
|
1669
|
+
0,
|
|
1670
|
+
0
|
|
1671
|
+
];
|
|
1672
|
+
var GRAPH_STATUSES = {
|
|
1673
|
+
IDLE: "idle",
|
|
1674
|
+
LOADING: "loading",
|
|
1675
|
+
SUCCESS: "success",
|
|
1676
|
+
ERROR: "error",
|
|
1677
|
+
STREAMING: "streaming"
|
|
1362
1678
|
};
|
|
1363
|
-
var
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}));
|
|
1378
|
-
return d3__namespace.forceSimulation(nodes).force(
|
|
1379
|
-
"link",
|
|
1380
|
-
d3__namespace.forceLink(d3Links).id((d) => d.id).distance(120).strength(0.7)
|
|
1381
|
-
).force("charge", d3__namespace.forceManyBody().strength(-280)).force("center", d3__namespace.forceCenter(width / 2, height / 2)).force("collision", d3__namespace.forceCollide().radius(35));
|
|
1679
|
+
var GRAPH_DATA_MODES = {
|
|
1680
|
+
STATIC: "static",
|
|
1681
|
+
POLLING: "polling",
|
|
1682
|
+
REALTIME: "realtime"
|
|
1683
|
+
};
|
|
1684
|
+
var GRAPH_VALUE_FORMATS = {
|
|
1685
|
+
RAW: "raw",
|
|
1686
|
+
NUMBER: "number",
|
|
1687
|
+
INTEGER: "integer",
|
|
1688
|
+
COMPACT: "compact",
|
|
1689
|
+
PERCENT: "percent",
|
|
1690
|
+
CURRENCY: "currency",
|
|
1691
|
+
BYTES: "bytes",
|
|
1692
|
+
DURATION: "duration"
|
|
1382
1693
|
};
|
|
1694
|
+
var GRAPH_EMPTY_MESSAGE = "No graph data available";
|
|
1695
|
+
var GRAPH_ERROR_MESSAGE = "Unable to load graph data";
|
|
1696
|
+
var GRAPH_LOADING_MESSAGE = "Loading graph data...";
|
|
1383
1697
|
|
|
1384
|
-
// src/components/data-display/graphs/
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1698
|
+
// src/components/data-display/graphs-v2/constants/graph-theme.constants.ts
|
|
1699
|
+
var GRAPH_COLOR_PALETTE = [
|
|
1700
|
+
"#7dd3fc",
|
|
1701
|
+
"#a78bfa",
|
|
1702
|
+
"#34d399",
|
|
1703
|
+
"#fbbf24",
|
|
1704
|
+
"#fb7185",
|
|
1705
|
+
"#60a5fa",
|
|
1706
|
+
"#f472b6",
|
|
1707
|
+
"#22d3ee",
|
|
1708
|
+
"#c084fc",
|
|
1709
|
+
"#a3e635"
|
|
1710
|
+
];
|
|
1711
|
+
var GRAPH_STATUS_COLORS = {
|
|
1712
|
+
primary: "#7dd3fc",
|
|
1713
|
+
secondary: "#a78bfa",
|
|
1714
|
+
success: "#34d399",
|
|
1715
|
+
warning: "#fbbf24",
|
|
1716
|
+
danger: "#fb7185",
|
|
1717
|
+
info: "#60a5fa",
|
|
1718
|
+
muted: "#6b7280"
|
|
1719
|
+
};
|
|
1720
|
+
var GRAPH_DARK_THEME = {
|
|
1721
|
+
panel: {
|
|
1722
|
+
background: "bg-[#111217]",
|
|
1723
|
+
border: "border border-[#2a2d35]",
|
|
1724
|
+
radius: "rounded-xl",
|
|
1725
|
+
shadow: "shadow-sm"
|
|
1726
|
+
},
|
|
1727
|
+
text: {
|
|
1728
|
+
title: "text-gray-100",
|
|
1729
|
+
description: "text-gray-400",
|
|
1730
|
+
muted: "text-gray-500"
|
|
1731
|
+
},
|
|
1732
|
+
chart: {
|
|
1733
|
+
grid: "#2a2d35",
|
|
1734
|
+
axis: "#8b949e",
|
|
1735
|
+
cursor: "rgba(255, 255, 255, 0.06)"
|
|
1736
|
+
},
|
|
1737
|
+
tooltip: {
|
|
1738
|
+
background: "#181b21",
|
|
1739
|
+
border: "#2a2d35",
|
|
1740
|
+
text: "#f3f4f6",
|
|
1741
|
+
muted: "#9ca3af"
|
|
1742
|
+
},
|
|
1743
|
+
colors: GRAPH_COLOR_PALETTE
|
|
1744
|
+
};
|
|
1745
|
+
var GRAPH_LIGHT_THEME = {
|
|
1746
|
+
panel: {
|
|
1747
|
+
background: "bg-white",
|
|
1748
|
+
border: "border border-gray-200",
|
|
1749
|
+
radius: "rounded-xl",
|
|
1750
|
+
shadow: "shadow-sm"
|
|
1751
|
+
},
|
|
1752
|
+
text: {
|
|
1753
|
+
title: "text-gray-900",
|
|
1754
|
+
description: "text-gray-500",
|
|
1755
|
+
muted: "text-gray-400"
|
|
1756
|
+
},
|
|
1757
|
+
chart: {
|
|
1758
|
+
grid: "#e5e7eb",
|
|
1759
|
+
axis: "#6b7280",
|
|
1760
|
+
cursor: "rgba(0, 0, 0, 0.04)"
|
|
1761
|
+
},
|
|
1762
|
+
tooltip: {
|
|
1763
|
+
background: "#ffffff",
|
|
1764
|
+
border: "#e5e7eb",
|
|
1765
|
+
text: "#111827",
|
|
1766
|
+
muted: "#6b7280"
|
|
1767
|
+
},
|
|
1768
|
+
colors: GRAPH_COLOR_PALETTE
|
|
1769
|
+
};
|
|
1770
|
+
var DEFAULT_GRAPH_THEME = GRAPH_DARK_THEME;
|
|
1395
1771
|
|
|
1396
|
-
// src/components/data-display/graphs/
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
const levelGroups = {};
|
|
1409
|
-
nodes.forEach((node) => {
|
|
1410
|
-
const level = levelMap[node.id] ?? 0;
|
|
1411
|
-
if (!levelGroups[level]) levelGroups[level] = [];
|
|
1412
|
-
levelGroups[level].push(node);
|
|
1413
|
-
});
|
|
1414
|
-
return nodes.map((node) => {
|
|
1415
|
-
const level = levelMap[node.id] ?? 0;
|
|
1416
|
-
const siblings = levelGroups[level];
|
|
1417
|
-
const index = siblings.indexOf(node);
|
|
1418
|
-
return {
|
|
1419
|
-
...node,
|
|
1420
|
-
x: (index + 1) * width / (siblings.length + 1),
|
|
1421
|
-
y: (level + 1) * height / (maxLevel + 2)
|
|
1422
|
-
};
|
|
1423
|
-
});
|
|
1772
|
+
// src/components/data-display/graphs-v2/utils/normalizeGraphData.ts
|
|
1773
|
+
var DEFAULT_NORMALIZE_OPTIONS = {
|
|
1774
|
+
serializeDates: true,
|
|
1775
|
+
parseNumericStrings: true,
|
|
1776
|
+
sanitizeInvalidNumbers: true,
|
|
1777
|
+
removeUndefined: true
|
|
1778
|
+
};
|
|
1779
|
+
function isNumericString(value) {
|
|
1780
|
+
if (!value.trim()) {
|
|
1781
|
+
return false;
|
|
1782
|
+
}
|
|
1783
|
+
return !Number.isNaN(Number(value));
|
|
1424
1784
|
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
const x = node.x;
|
|
1429
|
-
const y = node.y;
|
|
1430
|
-
if (renderCustom) {
|
|
1431
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1432
|
-
"foreignObject",
|
|
1433
|
-
{
|
|
1434
|
-
x: x - NODE_SIZE / 2,
|
|
1435
|
-
y: y - NODE_SIZE / 2,
|
|
1436
|
-
width: NODE_SIZE,
|
|
1437
|
-
height: NODE_SIZE,
|
|
1438
|
-
style: { overflow: "visible" },
|
|
1439
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1440
|
-
"div",
|
|
1441
|
-
{
|
|
1442
|
-
style: {
|
|
1443
|
-
width: NODE_SIZE,
|
|
1444
|
-
height: NODE_SIZE,
|
|
1445
|
-
display: "flex",
|
|
1446
|
-
alignItems: "center",
|
|
1447
|
-
justifyContent: "center"
|
|
1448
|
-
},
|
|
1449
|
-
children: renderCustom(node)
|
|
1450
|
-
}
|
|
1451
|
-
)
|
|
1452
|
-
}
|
|
1453
|
-
);
|
|
1785
|
+
function normalizeValue(value, options) {
|
|
1786
|
+
if (value instanceof Date) {
|
|
1787
|
+
return options.serializeDates ? value.toISOString() : value;
|
|
1454
1788
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1789
|
+
if (typeof value === "number") {
|
|
1790
|
+
if (options.sanitizeInvalidNumbers && (Number.isNaN(value) || !Number.isFinite(value))) {
|
|
1791
|
+
return null;
|
|
1792
|
+
}
|
|
1793
|
+
return value;
|
|
1794
|
+
}
|
|
1795
|
+
if (typeof value === "string") {
|
|
1796
|
+
if (options.parseNumericStrings && isNumericString(value)) {
|
|
1797
|
+
return Number(value);
|
|
1798
|
+
}
|
|
1799
|
+
return value;
|
|
1800
|
+
}
|
|
1801
|
+
if (typeof value === "boolean" || value === null || value === void 0) {
|
|
1802
|
+
return value;
|
|
1803
|
+
}
|
|
1804
|
+
return String(value);
|
|
1805
|
+
}
|
|
1806
|
+
function normalizeGraphData(data, options = {}) {
|
|
1807
|
+
if (!Array.isArray(data)) {
|
|
1808
|
+
return [];
|
|
1809
|
+
}
|
|
1810
|
+
const resolvedOptions = {
|
|
1811
|
+
...DEFAULT_NORMALIZE_OPTIONS,
|
|
1812
|
+
...options
|
|
1813
|
+
};
|
|
1814
|
+
return data.map((item) => {
|
|
1815
|
+
const normalizedPoint = {};
|
|
1816
|
+
const keys = options.keys ?? Object.keys(item);
|
|
1817
|
+
keys.forEach((key) => {
|
|
1818
|
+
const value = normalizeValue(item[key], resolvedOptions);
|
|
1819
|
+
if (resolvedOptions.removeUndefined && value === void 0) {
|
|
1820
|
+
return;
|
|
1466
1821
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1822
|
+
normalizedPoint[key] = value;
|
|
1823
|
+
});
|
|
1824
|
+
return normalizedPoint;
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function normalizeGraphDataPoint(dataPoint, options = {}) {
|
|
1828
|
+
return normalizeGraphData([dataPoint], options)[0] ?? {};
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// src/components/data-display/graphs-v2/utils/formatGraphValue.ts
|
|
1832
|
+
var DEFAULT_FORMAT_OPTIONS = {
|
|
1833
|
+
format: "number",
|
|
1834
|
+
locale: "en-US",
|
|
1835
|
+
fallback: "-"
|
|
1469
1836
|
};
|
|
1470
|
-
function
|
|
1471
|
-
return typeof
|
|
1837
|
+
function isValidNumber(value) {
|
|
1838
|
+
return typeof value === "number" && Number.isFinite(value) && !Number.isNaN(value);
|
|
1472
1839
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1840
|
+
function formatBytes(value, locale) {
|
|
1841
|
+
if (value === 0) {
|
|
1842
|
+
return "0 B";
|
|
1843
|
+
}
|
|
1844
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
1845
|
+
const unitIndex = Math.min(
|
|
1846
|
+
Math.floor(Math.log(Math.abs(value)) / Math.log(1024)),
|
|
1847
|
+
units.length - 1
|
|
1848
|
+
);
|
|
1849
|
+
const formattedValue = value / 1024 ** unitIndex;
|
|
1850
|
+
return `${new Intl.NumberFormat(locale, {
|
|
1851
|
+
maximumFractionDigits: formattedValue >= 10 ? 1 : 2
|
|
1852
|
+
}).format(formattedValue)} ${units[unitIndex]}`;
|
|
1853
|
+
}
|
|
1854
|
+
function formatDuration(value, locale) {
|
|
1855
|
+
if (value < 1e3) {
|
|
1856
|
+
return `${Math.round(value)} ms`;
|
|
1857
|
+
}
|
|
1858
|
+
const seconds = value / 1e3;
|
|
1859
|
+
if (seconds < 60) {
|
|
1860
|
+
return `${new Intl.NumberFormat(locale, {
|
|
1861
|
+
maximumFractionDigits: 2
|
|
1862
|
+
}).format(seconds)} s`;
|
|
1863
|
+
}
|
|
1864
|
+
const minutes = seconds / 60;
|
|
1865
|
+
if (minutes < 60) {
|
|
1866
|
+
return `${new Intl.NumberFormat(locale, {
|
|
1867
|
+
maximumFractionDigits: 2
|
|
1868
|
+
}).format(minutes)} min`;
|
|
1869
|
+
}
|
|
1870
|
+
const hours = minutes / 60;
|
|
1871
|
+
return `${new Intl.NumberFormat(locale, {
|
|
1872
|
+
maximumFractionDigits: 2
|
|
1873
|
+
}).format(hours)} h`;
|
|
1874
|
+
}
|
|
1875
|
+
function formatGraphValue(value, options = {}) {
|
|
1876
|
+
const {
|
|
1877
|
+
format,
|
|
1878
|
+
locale,
|
|
1879
|
+
fallback,
|
|
1880
|
+
prefix = "",
|
|
1881
|
+
suffix = "",
|
|
1882
|
+
currency = "USD",
|
|
1883
|
+
minimumFractionDigits,
|
|
1884
|
+
maximumFractionDigits
|
|
1885
|
+
} = {
|
|
1886
|
+
...DEFAULT_FORMAT_OPTIONS,
|
|
1887
|
+
...options
|
|
1888
|
+
};
|
|
1889
|
+
if (value === null || value === void 0 || value === "") {
|
|
1890
|
+
return fallback;
|
|
1891
|
+
}
|
|
1892
|
+
if (format === "raw") {
|
|
1893
|
+
return `${prefix}${String(value)}${suffix}`;
|
|
1894
|
+
}
|
|
1895
|
+
const numericValue = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
|
|
1896
|
+
if (!isValidNumber(numericValue)) {
|
|
1897
|
+
return `${prefix}${String(value)}${suffix}`;
|
|
1898
|
+
}
|
|
1899
|
+
let formattedValue;
|
|
1900
|
+
switch (format) {
|
|
1901
|
+
case "integer":
|
|
1902
|
+
formattedValue = new Intl.NumberFormat(locale, {
|
|
1903
|
+
maximumFractionDigits: 0
|
|
1904
|
+
}).format(numericValue);
|
|
1905
|
+
break;
|
|
1906
|
+
case "compact":
|
|
1907
|
+
formattedValue = new Intl.NumberFormat(locale, {
|
|
1908
|
+
notation: "compact",
|
|
1909
|
+
maximumFractionDigits: maximumFractionDigits ?? 2
|
|
1910
|
+
}).format(numericValue);
|
|
1911
|
+
break;
|
|
1912
|
+
case "percent":
|
|
1913
|
+
formattedValue = new Intl.NumberFormat(locale, {
|
|
1914
|
+
style: "percent",
|
|
1915
|
+
minimumFractionDigits: minimumFractionDigits ?? 0,
|
|
1916
|
+
maximumFractionDigits: maximumFractionDigits ?? 2
|
|
1917
|
+
}).format(numericValue / 100);
|
|
1918
|
+
break;
|
|
1919
|
+
case "currency":
|
|
1920
|
+
formattedValue = new Intl.NumberFormat(locale, {
|
|
1921
|
+
style: "currency",
|
|
1922
|
+
currency,
|
|
1923
|
+
minimumFractionDigits,
|
|
1924
|
+
maximumFractionDigits
|
|
1925
|
+
}).format(numericValue);
|
|
1926
|
+
break;
|
|
1927
|
+
case "bytes":
|
|
1928
|
+
formattedValue = formatBytes(numericValue, locale);
|
|
1929
|
+
break;
|
|
1930
|
+
case "duration":
|
|
1931
|
+
formattedValue = formatDuration(numericValue, locale);
|
|
1932
|
+
break;
|
|
1933
|
+
case "number":
|
|
1934
|
+
default:
|
|
1935
|
+
formattedValue = new Intl.NumberFormat(locale, {
|
|
1936
|
+
minimumFractionDigits,
|
|
1937
|
+
maximumFractionDigits: maximumFractionDigits ?? 2
|
|
1938
|
+
}).format(numericValue);
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
return `${prefix}${formattedValue}${suffix}`;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
// src/components/data-display/graphs-v2/utils/resolveGraphColor.ts
|
|
1945
|
+
var NAMED_COLORS = {
|
|
1946
|
+
primary: GRAPH_STATUS_COLORS.primary,
|
|
1947
|
+
secondary: GRAPH_STATUS_COLORS.secondary,
|
|
1948
|
+
success: GRAPH_STATUS_COLORS.success,
|
|
1949
|
+
warning: GRAPH_STATUS_COLORS.warning,
|
|
1950
|
+
danger: GRAPH_STATUS_COLORS.danger,
|
|
1951
|
+
info: GRAPH_STATUS_COLORS.info,
|
|
1952
|
+
muted: GRAPH_STATUS_COLORS.muted
|
|
1505
1953
|
};
|
|
1506
|
-
|
|
1954
|
+
function isCssColor(value) {
|
|
1955
|
+
return value.startsWith("#") || value.startsWith("rgb(") || value.startsWith("rgba(") || value.startsWith("hsl(") || value.startsWith("hsla(") || value.startsWith("var(");
|
|
1956
|
+
}
|
|
1957
|
+
function resolveGraphColor(color, options = {}) {
|
|
1958
|
+
const {
|
|
1959
|
+
index = 0,
|
|
1960
|
+
fallback = GRAPH_COLOR_PALETTE[0],
|
|
1961
|
+
palette = GRAPH_COLOR_PALETTE
|
|
1962
|
+
} = options;
|
|
1963
|
+
if (color) {
|
|
1964
|
+
if (isCssColor(color)) {
|
|
1965
|
+
return color;
|
|
1966
|
+
}
|
|
1967
|
+
if (color in NAMED_COLORS) {
|
|
1968
|
+
return NAMED_COLORS[color];
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (palette.length > 0) {
|
|
1972
|
+
return palette[index % palette.length];
|
|
1973
|
+
}
|
|
1974
|
+
return fallback;
|
|
1975
|
+
}
|
|
1976
|
+
function resolveGraphColors(count, options = {}) {
|
|
1977
|
+
return Array.from(
|
|
1978
|
+
{ length: count },
|
|
1979
|
+
(_, index) => resolveGraphColor(void 0, {
|
|
1980
|
+
...options,
|
|
1981
|
+
index
|
|
1982
|
+
})
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
// src/components/data-display/graphs-v2/utils/limitRealtimePoints.ts
|
|
1987
|
+
var DEFAULT_MAX_POINTS = 100;
|
|
1988
|
+
function limitRealtimePoints(currentData = [], nextData, options = {}) {
|
|
1989
|
+
const { maxPoints = DEFAULT_MAX_POINTS, appendDirection = "end" } = options;
|
|
1990
|
+
const incomingData = Array.isArray(nextData) ? nextData : [nextData];
|
|
1991
|
+
const mergedData = appendDirection === "start" ? [...incomingData, ...currentData] : [...currentData, ...incomingData];
|
|
1992
|
+
if (maxPoints <= 0) {
|
|
1993
|
+
return mergedData;
|
|
1994
|
+
}
|
|
1995
|
+
if (mergedData.length <= maxPoints) {
|
|
1996
|
+
return mergedData;
|
|
1997
|
+
}
|
|
1998
|
+
return appendDirection === "start" ? mergedData.slice(0, maxPoints) : mergedData.slice(-maxPoints);
|
|
1999
|
+
}
|
|
2000
|
+
function replaceRealtimePoints(nextData = [], options = {}) {
|
|
2001
|
+
const { maxPoints = DEFAULT_MAX_POINTS } = options;
|
|
2002
|
+
if (maxPoints <= 0) {
|
|
2003
|
+
return nextData;
|
|
2004
|
+
}
|
|
2005
|
+
return nextData.slice(-maxPoints);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// src/components/data-display/graphs-v2/hooks/useGraphData.ts
|
|
2009
|
+
function useGraphData({
|
|
1507
2010
|
data,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
2011
|
+
dataSource,
|
|
2012
|
+
autoLoad = true,
|
|
2013
|
+
maxDataPoints = GRAPH_DEFAULT_MAX_REALTIME_POINTS,
|
|
2014
|
+
normalize: normalize2 = true,
|
|
2015
|
+
onDataChange,
|
|
2016
|
+
onError
|
|
2017
|
+
} = {}) {
|
|
2018
|
+
const [state, setState] = React3.useState({
|
|
2019
|
+
data: data ?? [],
|
|
2020
|
+
loading: false,
|
|
2021
|
+
error: null,
|
|
2022
|
+
status: data?.length ? "success" : "idle",
|
|
2023
|
+
lastUpdatedAt: data?.length ? /* @__PURE__ */ new Date() : void 0
|
|
2024
|
+
});
|
|
2025
|
+
const prepareData = React3.useCallback(
|
|
2026
|
+
(nextData) => {
|
|
2027
|
+
if (!normalize2) {
|
|
2028
|
+
return nextData;
|
|
2029
|
+
}
|
|
2030
|
+
return normalizeGraphData(nextData);
|
|
2031
|
+
},
|
|
2032
|
+
[normalize2]
|
|
2033
|
+
);
|
|
2034
|
+
const replaceData = React3.useCallback(
|
|
2035
|
+
(nextData) => {
|
|
2036
|
+
const normalizedData = prepareData(nextData);
|
|
2037
|
+
setState({
|
|
2038
|
+
data: normalizedData,
|
|
2039
|
+
loading: false,
|
|
2040
|
+
error: null,
|
|
2041
|
+
status: "success",
|
|
2042
|
+
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
2043
|
+
});
|
|
2044
|
+
onDataChange?.(normalizedData);
|
|
2045
|
+
},
|
|
2046
|
+
[onDataChange, prepareData]
|
|
2047
|
+
);
|
|
2048
|
+
const appendData = React3.useCallback(
|
|
2049
|
+
(nextData) => {
|
|
2050
|
+
setState((currentState) => {
|
|
2051
|
+
const incomingData = Array.isArray(nextData) ? nextData : [nextData];
|
|
2052
|
+
const normalizedIncomingData = prepareData(incomingData);
|
|
2053
|
+
const limitedData = limitRealtimePoints(
|
|
2054
|
+
currentState.data,
|
|
2055
|
+
normalizedIncomingData,
|
|
2056
|
+
{
|
|
2057
|
+
maxPoints: maxDataPoints
|
|
2058
|
+
}
|
|
2059
|
+
);
|
|
2060
|
+
onDataChange?.(limitedData);
|
|
2061
|
+
return {
|
|
2062
|
+
data: limitedData,
|
|
2063
|
+
loading: false,
|
|
2064
|
+
error: null,
|
|
2065
|
+
status: "streaming",
|
|
2066
|
+
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
2067
|
+
};
|
|
2068
|
+
});
|
|
2069
|
+
},
|
|
2070
|
+
[maxDataPoints, onDataChange, prepareData]
|
|
2071
|
+
);
|
|
2072
|
+
const clearData = React3.useCallback(() => {
|
|
2073
|
+
setState({
|
|
2074
|
+
data: [],
|
|
2075
|
+
loading: false,
|
|
2076
|
+
error: null,
|
|
2077
|
+
status: "idle",
|
|
2078
|
+
lastUpdatedAt: void 0
|
|
1536
2079
|
});
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative overflow-hidden border border-gray-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1556
|
-
"svg",
|
|
1557
|
-
{
|
|
1558
|
-
width: "100%",
|
|
1559
|
-
height,
|
|
1560
|
-
viewBox: `0 0 ${width} ${height}`,
|
|
1561
|
-
onMouseDown,
|
|
1562
|
-
onMouseMove,
|
|
1563
|
-
onMouseUp: stopDrag,
|
|
1564
|
-
onMouseLeave: stopDrag,
|
|
1565
|
-
style: {
|
|
1566
|
-
cursor: isDragging.current ? "grabbing" : "grab"
|
|
1567
|
-
},
|
|
1568
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${offset.x}, ${offset.y})`, children: [
|
|
1569
|
-
edges.map((edge, i) => /* @__PURE__ */ jsxRuntime.jsx(GraphEdge, { edge, nodeMap }, edge.id || i)),
|
|
1570
|
-
nodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(GraphNode, { node, renderCustom: nodeRenderer }, node.id))
|
|
1571
|
-
] })
|
|
2080
|
+
onDataChange?.([]);
|
|
2081
|
+
}, [onDataChange]);
|
|
2082
|
+
const handleError = React3.useCallback(
|
|
2083
|
+
(error) => {
|
|
2084
|
+
setState((currentState) => ({
|
|
2085
|
+
...currentState,
|
|
2086
|
+
loading: false,
|
|
2087
|
+
error,
|
|
2088
|
+
status: "error"
|
|
2089
|
+
}));
|
|
2090
|
+
onError?.(error);
|
|
2091
|
+
},
|
|
2092
|
+
[onError]
|
|
2093
|
+
);
|
|
2094
|
+
const refresh = React3.useCallback(async () => {
|
|
2095
|
+
const resolvedDataSource = dataSource;
|
|
2096
|
+
if (!resolvedDataSource?.refresh && !resolvedDataSource?.getInitialData) {
|
|
2097
|
+
return;
|
|
1572
2098
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
})
|
|
1584
|
-
|
|
1585
|
-
"div",
|
|
1586
|
-
{
|
|
1587
|
-
...rest,
|
|
1588
|
-
style: { width, height },
|
|
1589
|
-
className: cn("relative bg-gray-900 rounded-lg", className),
|
|
1590
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1591
|
-
GraphRenderer,
|
|
1592
|
-
{
|
|
1593
|
-
data,
|
|
1594
|
-
layout,
|
|
1595
|
-
nodeRenderer,
|
|
1596
|
-
width,
|
|
1597
|
-
height
|
|
1598
|
-
}
|
|
1599
|
-
)
|
|
2099
|
+
try {
|
|
2100
|
+
setState((currentState) => ({
|
|
2101
|
+
...currentState,
|
|
2102
|
+
loading: true,
|
|
2103
|
+
error: null,
|
|
2104
|
+
status: "loading"
|
|
2105
|
+
}));
|
|
2106
|
+
const loader = resolvedDataSource.refresh ?? resolvedDataSource.getInitialData;
|
|
2107
|
+
const result = await loader?.();
|
|
2108
|
+
replaceData(result ?? []);
|
|
2109
|
+
} catch (error) {
|
|
2110
|
+
handleError(error instanceof Error ? error : new Error(String(error)));
|
|
1600
2111
|
}
|
|
1601
|
-
);
|
|
2112
|
+
}, [dataSource, handleError, replaceData]);
|
|
2113
|
+
React3.useEffect(() => {
|
|
2114
|
+
if (!data) {
|
|
2115
|
+
return;
|
|
2116
|
+
}
|
|
2117
|
+
replaceData(data);
|
|
2118
|
+
}, [data, replaceData]);
|
|
2119
|
+
React3.useEffect(() => {
|
|
2120
|
+
if (!dataSource || !autoLoad) {
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
const resolvedDataSource = dataSource;
|
|
2124
|
+
let unsubscribe;
|
|
2125
|
+
let isMounted = true;
|
|
2126
|
+
async function loadInitialData() {
|
|
2127
|
+
if (!resolvedDataSource.getInitialData) {
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
2130
|
+
try {
|
|
2131
|
+
setState((currentState) => ({
|
|
2132
|
+
...currentState,
|
|
2133
|
+
loading: true,
|
|
2134
|
+
error: null,
|
|
2135
|
+
status: "loading"
|
|
2136
|
+
}));
|
|
2137
|
+
const result = await resolvedDataSource.getInitialData();
|
|
2138
|
+
if (isMounted) {
|
|
2139
|
+
replaceData(result ?? []);
|
|
2140
|
+
}
|
|
2141
|
+
} catch (error) {
|
|
2142
|
+
if (isMounted) {
|
|
2143
|
+
handleError(
|
|
2144
|
+
error instanceof Error ? error : new Error(String(error))
|
|
2145
|
+
);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
void loadInitialData();
|
|
2150
|
+
if (resolvedDataSource.subscribe) {
|
|
2151
|
+
unsubscribe = resolvedDataSource.subscribe(appendData, handleError);
|
|
2152
|
+
}
|
|
2153
|
+
return () => {
|
|
2154
|
+
isMounted = false;
|
|
2155
|
+
unsubscribe?.();
|
|
2156
|
+
};
|
|
2157
|
+
}, [appendData, autoLoad, dataSource, handleError, replaceData]);
|
|
2158
|
+
return React3.useMemo(
|
|
2159
|
+
() => ({
|
|
2160
|
+
...state,
|
|
2161
|
+
refresh,
|
|
2162
|
+
replaceData,
|
|
2163
|
+
appendData,
|
|
2164
|
+
clearData
|
|
2165
|
+
}),
|
|
2166
|
+
[appendData, clearData, refresh, replaceData, state]
|
|
2167
|
+
);
|
|
2168
|
+
}
|
|
2169
|
+
function useGraphRealtime({
|
|
2170
|
+
enabled = true,
|
|
2171
|
+
maxDataPoints = GRAPH_DEFAULT_MAX_REALTIME_POINTS,
|
|
2172
|
+
normalize: normalize2 = true,
|
|
2173
|
+
connect,
|
|
2174
|
+
onData,
|
|
2175
|
+
onError
|
|
2176
|
+
}) {
|
|
2177
|
+
const [data, setData] = React3.useState([]);
|
|
2178
|
+
const [error, setError] = React3.useState(null);
|
|
2179
|
+
const [connected, setConnected] = React3.useState(false);
|
|
2180
|
+
const [lastUpdatedAt, setLastUpdatedAt] = React3.useState();
|
|
2181
|
+
React3.useEffect(() => {
|
|
2182
|
+
if (!enabled) {
|
|
2183
|
+
setConnected(false);
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
const handleData = (incomingData) => {
|
|
2187
|
+
const incomingArray = Array.isArray(incomingData) ? incomingData : [incomingData];
|
|
2188
|
+
const normalizedIncomingData = normalize2 ? normalizeGraphData(incomingArray) : incomingArray;
|
|
2189
|
+
setData((currentData) => {
|
|
2190
|
+
const nextData = limitRealtimePoints(
|
|
2191
|
+
currentData,
|
|
2192
|
+
normalizedIncomingData,
|
|
2193
|
+
{
|
|
2194
|
+
maxPoints: maxDataPoints
|
|
2195
|
+
}
|
|
2196
|
+
);
|
|
2197
|
+
onData?.(nextData);
|
|
2198
|
+
return nextData;
|
|
2199
|
+
});
|
|
2200
|
+
setError(null);
|
|
2201
|
+
setConnected(true);
|
|
2202
|
+
setLastUpdatedAt(/* @__PURE__ */ new Date());
|
|
2203
|
+
};
|
|
2204
|
+
const handleError = (nextError) => {
|
|
2205
|
+
setError(nextError);
|
|
2206
|
+
onError?.(nextError);
|
|
2207
|
+
};
|
|
2208
|
+
const unsubscribe = connect(handleData, handleError);
|
|
2209
|
+
setConnected(true);
|
|
2210
|
+
return () => {
|
|
2211
|
+
unsubscribe?.();
|
|
2212
|
+
setConnected(false);
|
|
2213
|
+
};
|
|
2214
|
+
}, [connect, enabled, maxDataPoints, normalize2, onData, onError]);
|
|
2215
|
+
return React3.useMemo(
|
|
2216
|
+
() => ({
|
|
2217
|
+
data,
|
|
2218
|
+
error,
|
|
2219
|
+
connected,
|
|
2220
|
+
loading: enabled && !connected && !error,
|
|
2221
|
+
status: error ? "error" : connected ? "streaming" : "idle",
|
|
2222
|
+
lastUpdatedAt,
|
|
2223
|
+
clearData: () => setData([])
|
|
2224
|
+
}),
|
|
2225
|
+
[connected, data, enabled, error, lastUpdatedAt]
|
|
2226
|
+
);
|
|
2227
|
+
}
|
|
2228
|
+
function useGraphPolling({
|
|
2229
|
+
enabled = true,
|
|
2230
|
+
interval = GRAPH_DEFAULT_POLLING_INTERVAL,
|
|
2231
|
+
immediate = true,
|
|
2232
|
+
normalize: normalize2 = true,
|
|
2233
|
+
fetcher,
|
|
2234
|
+
onData,
|
|
2235
|
+
onError
|
|
2236
|
+
}) {
|
|
2237
|
+
const isMountedRef = React3.useRef(false);
|
|
2238
|
+
const isFetchingRef = React3.useRef(false);
|
|
2239
|
+
const [data, setData] = React3.useState([]);
|
|
2240
|
+
const [error, setError] = React3.useState(null);
|
|
2241
|
+
const [loading, setLoading] = React3.useState(immediate);
|
|
2242
|
+
const [lastUpdatedAt, setLastUpdatedAt] = React3.useState();
|
|
2243
|
+
const refresh = React3.useCallback(async () => {
|
|
2244
|
+
if (isFetchingRef.current) {
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2247
|
+
try {
|
|
2248
|
+
isFetchingRef.current = true;
|
|
2249
|
+
setLoading(true);
|
|
2250
|
+
setError(null);
|
|
2251
|
+
const result = await fetcher();
|
|
2252
|
+
const nextData = normalize2 ? normalizeGraphData(result ?? []) : result ?? [];
|
|
2253
|
+
if (!isMountedRef.current) {
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
setData(nextData);
|
|
2257
|
+
setLastUpdatedAt(/* @__PURE__ */ new Date());
|
|
2258
|
+
onData?.(nextData);
|
|
2259
|
+
} catch (error2) {
|
|
2260
|
+
const nextError = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
2261
|
+
if (isMountedRef.current) {
|
|
2262
|
+
setError(nextError);
|
|
2263
|
+
onError?.(nextError);
|
|
2264
|
+
}
|
|
2265
|
+
} finally {
|
|
2266
|
+
if (isMountedRef.current) {
|
|
2267
|
+
setLoading(false);
|
|
2268
|
+
}
|
|
2269
|
+
isFetchingRef.current = false;
|
|
2270
|
+
}
|
|
2271
|
+
}, [fetcher, normalize2, onData, onError]);
|
|
2272
|
+
React3.useEffect(() => {
|
|
2273
|
+
isMountedRef.current = true;
|
|
2274
|
+
return () => {
|
|
2275
|
+
isMountedRef.current = false;
|
|
2276
|
+
};
|
|
2277
|
+
}, []);
|
|
2278
|
+
React3.useEffect(() => {
|
|
2279
|
+
if (!enabled) {
|
|
2280
|
+
setLoading(false);
|
|
2281
|
+
return;
|
|
2282
|
+
}
|
|
2283
|
+
if (immediate) {
|
|
2284
|
+
void refresh();
|
|
2285
|
+
}
|
|
2286
|
+
const timer = window.setInterval(() => {
|
|
2287
|
+
void refresh();
|
|
2288
|
+
}, interval);
|
|
2289
|
+
return () => {
|
|
2290
|
+
window.clearInterval(timer);
|
|
2291
|
+
};
|
|
2292
|
+
}, [enabled, immediate, interval, refresh]);
|
|
2293
|
+
return React3.useMemo(
|
|
2294
|
+
() => ({
|
|
2295
|
+
data,
|
|
2296
|
+
error,
|
|
2297
|
+
loading,
|
|
2298
|
+
status: error ? "error" : loading ? "loading" : "success",
|
|
2299
|
+
lastUpdatedAt,
|
|
2300
|
+
refresh
|
|
2301
|
+
}),
|
|
2302
|
+
[data, error, lastUpdatedAt, loading, refresh]
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
function createLabelFromKey(key) {
|
|
2306
|
+
return key.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (character) => character.toUpperCase());
|
|
2307
|
+
}
|
|
2308
|
+
function inferSeriesKeys(data, xKey, excludeKeys = []) {
|
|
2309
|
+
const firstPoint = data[0];
|
|
2310
|
+
if (!firstPoint) {
|
|
2311
|
+
return [];
|
|
2312
|
+
}
|
|
2313
|
+
return Object.keys(firstPoint).filter((key) => {
|
|
2314
|
+
if (key === xKey) {
|
|
2315
|
+
return false;
|
|
2316
|
+
}
|
|
2317
|
+
if (excludeKeys.includes(key)) {
|
|
2318
|
+
return false;
|
|
2319
|
+
}
|
|
2320
|
+
const value = firstPoint[key];
|
|
2321
|
+
return typeof value === "number";
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
function useGraphSeries({
|
|
2325
|
+
data = [],
|
|
2326
|
+
series,
|
|
2327
|
+
xKey,
|
|
2328
|
+
excludeKeys = []
|
|
2329
|
+
}) {
|
|
2330
|
+
return React3.useMemo(() => {
|
|
2331
|
+
const normalizedSeries = series && series.length > 0 ? series : inferSeriesKeys(data, xKey, excludeKeys).map((key) => ({
|
|
2332
|
+
key
|
|
2333
|
+
}));
|
|
2334
|
+
return normalizedSeries.map((item, index) => ({
|
|
2335
|
+
key: item.key,
|
|
2336
|
+
label: item.label ?? createLabelFromKey(item.key),
|
|
2337
|
+
type: item.type ?? "line",
|
|
2338
|
+
color: resolveGraphColor(item.color, { index }),
|
|
2339
|
+
unit: item.unit,
|
|
2340
|
+
visible: item.visible ?? true,
|
|
2341
|
+
strokeWidth: item.strokeWidth ?? GRAPH_DEFAULT_STROKE_WIDTH,
|
|
2342
|
+
radius: item.radius ?? GRAPH_DEFAULT_ACTIVE_DOT_RADIUS,
|
|
2343
|
+
format: item.format,
|
|
2344
|
+
prefix: item.prefix,
|
|
2345
|
+
suffix: item.suffix,
|
|
2346
|
+
yAxisId: item.yAxisId
|
|
2347
|
+
}));
|
|
2348
|
+
}, [data, excludeKeys, series, xKey]);
|
|
2349
|
+
}
|
|
2350
|
+
function mergeGraphTheme(baseTheme, customTheme) {
|
|
2351
|
+
if (!customTheme) {
|
|
2352
|
+
return baseTheme;
|
|
2353
|
+
}
|
|
2354
|
+
return {
|
|
2355
|
+
panel: {
|
|
2356
|
+
...baseTheme.panel,
|
|
2357
|
+
...customTheme.panel
|
|
2358
|
+
},
|
|
2359
|
+
text: {
|
|
2360
|
+
...baseTheme.text,
|
|
2361
|
+
...customTheme.text
|
|
2362
|
+
},
|
|
2363
|
+
chart: {
|
|
2364
|
+
...baseTheme.chart,
|
|
2365
|
+
...customTheme.chart
|
|
2366
|
+
},
|
|
2367
|
+
tooltip: {
|
|
2368
|
+
...baseTheme.tooltip,
|
|
2369
|
+
...customTheme.tooltip
|
|
2370
|
+
},
|
|
2371
|
+
colors: customTheme.colors ?? baseTheme.colors
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
function useGraphTheme({
|
|
2375
|
+
mode = "dark",
|
|
2376
|
+
theme
|
|
2377
|
+
} = {}) {
|
|
2378
|
+
return React3.useMemo(() => {
|
|
2379
|
+
const baseTheme = mode === "light" ? GRAPH_LIGHT_THEME : mode === "dark" ? GRAPH_DARK_THEME : DEFAULT_GRAPH_THEME;
|
|
2380
|
+
return mergeGraphTheme(baseTheme, theme);
|
|
2381
|
+
}, [mode, theme]);
|
|
2382
|
+
}
|
|
2383
|
+
var GraphContext = React3.createContext({
|
|
2384
|
+
data: [],
|
|
2385
|
+
loading: false,
|
|
2386
|
+
error: null,
|
|
2387
|
+
status: "idle",
|
|
2388
|
+
maxDataPoints: GRAPH_DEFAULT_MAX_REALTIME_POINTS,
|
|
2389
|
+
refresh: async () => {
|
|
2390
|
+
},
|
|
2391
|
+
replaceData: () => {
|
|
2392
|
+
},
|
|
2393
|
+
appendData: () => {
|
|
2394
|
+
},
|
|
2395
|
+
clearData: () => {
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
function GraphProvider({
|
|
2399
|
+
children,
|
|
2400
|
+
data,
|
|
2401
|
+
dataSource,
|
|
2402
|
+
maxDataPoints = GRAPH_DEFAULT_MAX_REALTIME_POINTS,
|
|
2403
|
+
autoLoad = true,
|
|
2404
|
+
onDataChange,
|
|
2405
|
+
onError
|
|
2406
|
+
}) {
|
|
2407
|
+
const graphData = useGraphData({
|
|
2408
|
+
data,
|
|
2409
|
+
dataSource,
|
|
2410
|
+
autoLoad,
|
|
2411
|
+
maxDataPoints,
|
|
2412
|
+
onDataChange,
|
|
2413
|
+
onError
|
|
2414
|
+
});
|
|
2415
|
+
const value = React3.useMemo(
|
|
2416
|
+
() => ({
|
|
2417
|
+
...graphData,
|
|
2418
|
+
mode: dataSource?.mode,
|
|
2419
|
+
maxDataPoints
|
|
2420
|
+
}),
|
|
2421
|
+
[dataSource?.mode, graphData, maxDataPoints]
|
|
2422
|
+
);
|
|
2423
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2424
|
+
GraphContext.Provider,
|
|
2425
|
+
{
|
|
2426
|
+
value,
|
|
2427
|
+
children
|
|
2428
|
+
}
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
function useGraphContext() {
|
|
2432
|
+
return React3.useContext(GraphContext);
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
// src/components/data-display/graphs-v2/context/graphReducer.ts
|
|
2436
|
+
function createInitialGraphState(data = []) {
|
|
2437
|
+
return {
|
|
2438
|
+
data,
|
|
2439
|
+
loading: false,
|
|
2440
|
+
error: null,
|
|
2441
|
+
status: data.length > 0 ? "success" : "idle",
|
|
2442
|
+
lastUpdatedAt: data.length > 0 ? /* @__PURE__ */ new Date() : void 0
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
function graphReducer(state, action) {
|
|
2446
|
+
switch (action.type) {
|
|
2447
|
+
case "SET_LOADING": {
|
|
2448
|
+
const loading = action.payload ?? true;
|
|
2449
|
+
return {
|
|
2450
|
+
...state,
|
|
2451
|
+
loading,
|
|
2452
|
+
error: loading ? null : state.error,
|
|
2453
|
+
status: loading ? "loading" : state.status
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
case "SET_ERROR": {
|
|
2457
|
+
return {
|
|
2458
|
+
...state,
|
|
2459
|
+
loading: false,
|
|
2460
|
+
error: action.payload,
|
|
2461
|
+
status: action.payload ? "error" : state.data.length > 0 ? "success" : "idle"
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
case "SET_DATA": {
|
|
2465
|
+
return {
|
|
2466
|
+
data: action.payload,
|
|
2467
|
+
loading: false,
|
|
2468
|
+
error: null,
|
|
2469
|
+
status: "success",
|
|
2470
|
+
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
case "APPEND_DATA": {
|
|
2474
|
+
const nextData = limitRealtimePoints(state.data, action.payload.data, {
|
|
2475
|
+
maxPoints: action.payload.maxDataPoints ?? GRAPH_DEFAULT_MAX_REALTIME_POINTS
|
|
2476
|
+
});
|
|
2477
|
+
return {
|
|
2478
|
+
data: nextData,
|
|
2479
|
+
loading: false,
|
|
2480
|
+
error: null,
|
|
2481
|
+
status: "streaming",
|
|
2482
|
+
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
case "CLEAR_DATA": {
|
|
2486
|
+
return {
|
|
2487
|
+
data: [],
|
|
2488
|
+
loading: false,
|
|
2489
|
+
error: null,
|
|
2490
|
+
status: "idle",
|
|
2491
|
+
lastUpdatedAt: void 0
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
case "SET_STREAMING": {
|
|
2495
|
+
const streaming = action.payload ?? true;
|
|
2496
|
+
return {
|
|
2497
|
+
...state,
|
|
2498
|
+
loading: false,
|
|
2499
|
+
error: null,
|
|
2500
|
+
status: streaming ? "streaming" : state.data.length > 0 ? "success" : "idle",
|
|
2501
|
+
lastUpdatedAt: streaming ? /* @__PURE__ */ new Date() : state.lastUpdatedAt
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
default:
|
|
2505
|
+
return state;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
function GraphEmptyState({
|
|
2509
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2510
|
+
message = GRAPH_EMPTY_MESSAGE,
|
|
2511
|
+
description,
|
|
2512
|
+
className = ""
|
|
2513
|
+
}) {
|
|
2514
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2515
|
+
"div",
|
|
2516
|
+
{
|
|
2517
|
+
className: `eui-graph flex flex-col items-center justify-center rounded-xl border border-dashed border-gray-700/80 bg-[#111217]/40 px-6 text-center ${className}`,
|
|
2518
|
+
style: { height },
|
|
2519
|
+
children: [
|
|
2520
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full border border-gray-700 bg-white/5 text-gray-500", children: "\u2205" }),
|
|
2521
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 text-sm font-medium text-gray-300", children: message }),
|
|
2522
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 max-w-sm text-xs text-gray-500", children: description })
|
|
2523
|
+
]
|
|
2524
|
+
}
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
function GraphErrorState({
|
|
2528
|
+
error,
|
|
2529
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2530
|
+
title = GRAPH_ERROR_MESSAGE,
|
|
2531
|
+
message,
|
|
2532
|
+
className = "",
|
|
2533
|
+
onRetry,
|
|
2534
|
+
retryLabel = "Retry"
|
|
2535
|
+
}) {
|
|
2536
|
+
const resolvedMessage = message ?? error?.message;
|
|
2537
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2538
|
+
"div",
|
|
2539
|
+
{
|
|
2540
|
+
className: `eui-graph flex flex-col items-center justify-center rounded-xl border border-red-500/30 bg-red-500/5 px-6 text-center ${className}`,
|
|
2541
|
+
style: { height },
|
|
2542
|
+
role: "alert",
|
|
2543
|
+
children: [
|
|
2544
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full border border-red-500/30 bg-red-500/10 text-red-400", children: "!" }),
|
|
2545
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 text-sm font-medium text-red-300", children: title }),
|
|
2546
|
+
resolvedMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 max-w-md text-xs text-red-200/70", children: resolvedMessage }),
|
|
2547
|
+
onRetry && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2548
|
+
"button",
|
|
2549
|
+
{
|
|
2550
|
+
type: "button",
|
|
2551
|
+
onClick: () => void onRetry(),
|
|
2552
|
+
className: "mt-4 rounded-md border border-red-500/30 px-3 py-1.5 text-xs font-medium text-red-200 transition-colors hover:bg-red-500/10",
|
|
2553
|
+
children: retryLabel
|
|
2554
|
+
}
|
|
2555
|
+
)
|
|
2556
|
+
]
|
|
2557
|
+
}
|
|
2558
|
+
);
|
|
2559
|
+
}
|
|
2560
|
+
function GraphHeader({
|
|
2561
|
+
title,
|
|
2562
|
+
description,
|
|
2563
|
+
actions,
|
|
2564
|
+
className = ""
|
|
2565
|
+
}) {
|
|
2566
|
+
if (!title && !description && !actions) {
|
|
2567
|
+
return null;
|
|
2568
|
+
}
|
|
2569
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2570
|
+
"div",
|
|
2571
|
+
{
|
|
2572
|
+
className: `flex items-start justify-between gap-4 border-b border-[#2a2d35] px-4 py-3 ${className}`,
|
|
2573
|
+
children: [
|
|
2574
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
2575
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eui-graph-title truncate text-sm font-semibold text-gray-100", children: title }),
|
|
2576
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eui-graph-description mt-1 text-xs text-gray-400", children: description })
|
|
2577
|
+
] }),
|
|
2578
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: actions })
|
|
2579
|
+
]
|
|
2580
|
+
}
|
|
2581
|
+
);
|
|
2582
|
+
}
|
|
2583
|
+
function GraphLoadingState({
|
|
2584
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2585
|
+
message = GRAPH_LOADING_MESSAGE,
|
|
2586
|
+
className = "",
|
|
2587
|
+
showMessage = true
|
|
2588
|
+
}) {
|
|
2589
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2590
|
+
"div",
|
|
2591
|
+
{
|
|
2592
|
+
className: `eui-graph eui-graph-loading flex flex-col items-center justify-center rounded-xl border border-[#2a2d35] bg-[#111217]/60 px-6 text-center ${className}`,
|
|
2593
|
+
style: { height },
|
|
2594
|
+
role: "status",
|
|
2595
|
+
"aria-live": "polite",
|
|
2596
|
+
"aria-busy": "true",
|
|
2597
|
+
children: [
|
|
2598
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-7 w-7 animate-spin rounded-full border-2 border-gray-700 border-t-gray-200" }),
|
|
2599
|
+
showMessage && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-3 text-sm font-medium text-gray-300", children: message })
|
|
2600
|
+
]
|
|
2601
|
+
}
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
function formatLastUpdatedAt(value) {
|
|
2605
|
+
if (!value) {
|
|
2606
|
+
return "Never updated";
|
|
2607
|
+
}
|
|
2608
|
+
return `Updated ${value.toLocaleTimeString([], {
|
|
2609
|
+
hour: "2-digit",
|
|
2610
|
+
minute: "2-digit",
|
|
2611
|
+
second: "2-digit"
|
|
2612
|
+
})}`;
|
|
2613
|
+
}
|
|
2614
|
+
function GraphToolbar({
|
|
2615
|
+
children,
|
|
2616
|
+
className = "",
|
|
2617
|
+
showRefresh = true,
|
|
2618
|
+
showLastUpdated = true,
|
|
2619
|
+
refreshLabel = "Refresh",
|
|
2620
|
+
onRefresh
|
|
2621
|
+
}) {
|
|
2622
|
+
const graph = useGraphContext();
|
|
2623
|
+
async function handleRefresh() {
|
|
2624
|
+
if (onRefresh) {
|
|
2625
|
+
await onRefresh();
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
await graph.refresh();
|
|
2629
|
+
}
|
|
2630
|
+
if (!children && !showRefresh && !showLastUpdated) {
|
|
2631
|
+
return null;
|
|
2632
|
+
}
|
|
2633
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2634
|
+
"div",
|
|
2635
|
+
{
|
|
2636
|
+
className: `flex flex-wrap items-center justify-between gap-3 border-b border-[#2a2d35] px-4 py-2 ${className}`,
|
|
2637
|
+
children: [
|
|
2638
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 items-center gap-2", children }),
|
|
2639
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-3", children: [
|
|
2640
|
+
showLastUpdated && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-500", children: formatLastUpdatedAt(graph.lastUpdatedAt) }),
|
|
2641
|
+
showRefresh && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2642
|
+
"button",
|
|
2643
|
+
{
|
|
2644
|
+
type: "button",
|
|
2645
|
+
onClick: () => void handleRefresh(),
|
|
2646
|
+
disabled: graph.loading,
|
|
2647
|
+
className: "rounded-md border border-[#2a2d35] px-2.5 py-1.5 text-xs font-medium text-gray-300 transition-colors hover:bg-white/5 disabled:cursor-not-allowed disabled:opacity-60",
|
|
2648
|
+
children: graph.loading ? "Refreshing..." : refreshLabel
|
|
2649
|
+
}
|
|
2650
|
+
)
|
|
2651
|
+
] })
|
|
2652
|
+
]
|
|
2653
|
+
}
|
|
2654
|
+
);
|
|
2655
|
+
}
|
|
2656
|
+
function GraphPanel({
|
|
2657
|
+
title,
|
|
2658
|
+
description,
|
|
2659
|
+
actions,
|
|
2660
|
+
toolbar,
|
|
2661
|
+
children,
|
|
2662
|
+
className = "",
|
|
2663
|
+
contentClassName = "",
|
|
2664
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2665
|
+
loading,
|
|
2666
|
+
error,
|
|
2667
|
+
empty,
|
|
2668
|
+
emptyMessage,
|
|
2669
|
+
emptyDescription,
|
|
2670
|
+
showToolbar = false,
|
|
2671
|
+
showRefresh = true,
|
|
2672
|
+
showLastUpdated = true,
|
|
2673
|
+
onRetry
|
|
2674
|
+
}) {
|
|
2675
|
+
const graph = useGraphContext();
|
|
2676
|
+
const resolvedLoading = loading ?? graph.loading;
|
|
2677
|
+
const resolvedError = error ?? graph.error;
|
|
2678
|
+
const resolvedEmpty = empty ?? graph.data.length === 0;
|
|
2679
|
+
function renderContent() {
|
|
2680
|
+
if (resolvedLoading) {
|
|
2681
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height });
|
|
2682
|
+
}
|
|
2683
|
+
if (resolvedError) {
|
|
2684
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2685
|
+
GraphErrorState,
|
|
2686
|
+
{
|
|
2687
|
+
height,
|
|
2688
|
+
error: resolvedError,
|
|
2689
|
+
onRetry: onRetry ?? graph.refresh
|
|
2690
|
+
}
|
|
2691
|
+
);
|
|
2692
|
+
}
|
|
2693
|
+
if (resolvedEmpty) {
|
|
2694
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2695
|
+
GraphEmptyState,
|
|
2696
|
+
{
|
|
2697
|
+
height,
|
|
2698
|
+
message: emptyMessage,
|
|
2699
|
+
description: emptyDescription
|
|
2700
|
+
}
|
|
2701
|
+
);
|
|
2702
|
+
}
|
|
2703
|
+
return children;
|
|
2704
|
+
}
|
|
2705
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2706
|
+
"section",
|
|
2707
|
+
{
|
|
2708
|
+
className: `eui-graph eui-graph-panel overflow-hidden rounded-xl border border-[#2a2d35] bg-[#111217] ${className}`,
|
|
2709
|
+
children: [
|
|
2710
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphHeader, { title, description, actions }),
|
|
2711
|
+
showToolbar && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2712
|
+
GraphToolbar,
|
|
2713
|
+
{
|
|
2714
|
+
showRefresh,
|
|
2715
|
+
showLastUpdated,
|
|
2716
|
+
children: toolbar
|
|
2717
|
+
}
|
|
2718
|
+
),
|
|
2719
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `p-4 ${contentClassName}`, children: renderContent() })
|
|
2720
|
+
]
|
|
2721
|
+
}
|
|
2722
|
+
);
|
|
2723
|
+
}
|
|
2724
|
+
function createLabelFromKey2(key) {
|
|
2725
|
+
return key.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (character) => character.toUpperCase());
|
|
2726
|
+
}
|
|
2727
|
+
function GraphLegend({
|
|
2728
|
+
items,
|
|
2729
|
+
series,
|
|
2730
|
+
data = [],
|
|
2731
|
+
className = "",
|
|
2732
|
+
showValues = true,
|
|
2733
|
+
valueSource = "latest",
|
|
2734
|
+
onItemClick
|
|
2735
|
+
}) {
|
|
2736
|
+
const legendItems = React3.useMemo(() => {
|
|
2737
|
+
if (items?.length) {
|
|
2738
|
+
return items;
|
|
2739
|
+
}
|
|
2740
|
+
if (!series?.length) {
|
|
2741
|
+
return [];
|
|
2742
|
+
}
|
|
2743
|
+
const latestPoint = data[data.length - 1];
|
|
2744
|
+
return series.map((item, index) => ({
|
|
2745
|
+
key: item.key,
|
|
2746
|
+
label: item.label ?? createLabelFromKey2(item.key),
|
|
2747
|
+
color: resolveGraphColor(item.color, { index }),
|
|
2748
|
+
value: valueSource === "latest" ? latestPoint?.[item.key] : void 0,
|
|
2749
|
+
unit: item.unit,
|
|
2750
|
+
format: item.format,
|
|
2751
|
+
prefix: item.prefix,
|
|
2752
|
+
suffix: item.suffix,
|
|
2753
|
+
active: item.visible ?? true
|
|
2754
|
+
}));
|
|
2755
|
+
}, [data, items, series, valueSource]);
|
|
2756
|
+
if (!legendItems.length) {
|
|
2757
|
+
return null;
|
|
2758
|
+
}
|
|
2759
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2760
|
+
"div",
|
|
2761
|
+
{
|
|
2762
|
+
className: `eui-graph flex flex-wrap items-center gap-x-4 gap-y-2 text-xs ${className}`,
|
|
2763
|
+
children: legendItems.map((item, index) => {
|
|
2764
|
+
const color = resolveGraphColor(item.color, { index });
|
|
2765
|
+
const active = item.active ?? true;
|
|
2766
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2767
|
+
"button",
|
|
2768
|
+
{
|
|
2769
|
+
type: "button",
|
|
2770
|
+
onClick: () => onItemClick?.(item),
|
|
2771
|
+
disabled: !onItemClick,
|
|
2772
|
+
className: `inline-flex items-center gap-2 rounded-md transition-opacity ${active ? "opacity-100" : "opacity-40"} ${onItemClick ? "cursor-pointer hover:opacity-80" : "cursor-default"}`,
|
|
2773
|
+
children: [
|
|
2774
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2775
|
+
"span",
|
|
2776
|
+
{
|
|
2777
|
+
className: "h-2.5 w-2.5 rounded-full",
|
|
2778
|
+
style: { backgroundColor: color }
|
|
2779
|
+
}
|
|
2780
|
+
),
|
|
2781
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: item.label ?? createLabelFromKey2(item.key) }),
|
|
2782
|
+
showValues && item.value !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-200", children: formatGraphValue(item.value, {
|
|
2783
|
+
format: item.format ?? "number",
|
|
2784
|
+
prefix: item.prefix,
|
|
2785
|
+
suffix: item.suffix ?? item.unit
|
|
2786
|
+
}) })
|
|
2787
|
+
]
|
|
2788
|
+
},
|
|
2789
|
+
item.key
|
|
2790
|
+
);
|
|
2791
|
+
})
|
|
2792
|
+
}
|
|
2793
|
+
);
|
|
2794
|
+
}
|
|
2795
|
+
function GraphTooltip({
|
|
2796
|
+
active,
|
|
2797
|
+
label,
|
|
2798
|
+
payload,
|
|
2799
|
+
className = "",
|
|
2800
|
+
labelFormatter,
|
|
2801
|
+
valueFormatter,
|
|
2802
|
+
seriesFormatters = {}
|
|
2803
|
+
}) {
|
|
2804
|
+
if (!active || !payload?.length) {
|
|
2805
|
+
return null;
|
|
2806
|
+
}
|
|
2807
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2808
|
+
"div",
|
|
2809
|
+
{
|
|
2810
|
+
className: `eui-graph rounded-xl border border-[#2a2d35] bg-[#181b21] px-3 py-2 shadow-xl ${className}`,
|
|
2811
|
+
children: [
|
|
2812
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 text-xs font-semibold text-gray-100", children: labelFormatter ? labelFormatter(label) : label }),
|
|
2813
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1.5", children: payload.map((item, index) => {
|
|
2814
|
+
const dataKey = item.dataKey ?? item.name ?? String(index);
|
|
2815
|
+
const formatterOptions = seriesFormatters[dataKey];
|
|
2816
|
+
const formattedValue = valueFormatter ? valueFormatter(item.value, item.name, item) : formatGraphValue(item.value, {
|
|
2817
|
+
format: formatterOptions?.format ?? "number",
|
|
2818
|
+
prefix: formatterOptions?.prefix,
|
|
2819
|
+
suffix: formatterOptions?.suffix ?? formatterOptions?.unit
|
|
2820
|
+
});
|
|
2821
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2822
|
+
"div",
|
|
2823
|
+
{
|
|
2824
|
+
className: "flex min-w-[140px] items-center justify-between gap-4 text-xs",
|
|
2825
|
+
children: [
|
|
2826
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
2827
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2828
|
+
"span",
|
|
2829
|
+
{
|
|
2830
|
+
className: "h-2 w-2 rounded-full",
|
|
2831
|
+
style: { backgroundColor: item.color }
|
|
2832
|
+
}
|
|
2833
|
+
),
|
|
2834
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-gray-400", children: item.name ?? dataKey })
|
|
2835
|
+
] }),
|
|
2836
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-gray-100", children: formattedValue })
|
|
2837
|
+
]
|
|
2838
|
+
},
|
|
2839
|
+
`${dataKey}-${index}`
|
|
2840
|
+
);
|
|
2841
|
+
}) })
|
|
2842
|
+
]
|
|
2843
|
+
}
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
function GraphContainer({
|
|
2847
|
+
children,
|
|
2848
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2849
|
+
className = "",
|
|
2850
|
+
contentClassName = ""
|
|
2851
|
+
}) {
|
|
2852
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2853
|
+
"div",
|
|
2854
|
+
{
|
|
2855
|
+
className: `eui-graph relative w-full min-w-0 overflow-hidden ${className}`,
|
|
2856
|
+
style: { height },
|
|
2857
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `h-full w-full ${contentClassName}`, children })
|
|
2858
|
+
}
|
|
2859
|
+
);
|
|
2860
|
+
}
|
|
2861
|
+
function LineGraph({
|
|
2862
|
+
data,
|
|
2863
|
+
xKey = "time",
|
|
2864
|
+
series,
|
|
2865
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2866
|
+
loading,
|
|
2867
|
+
error,
|
|
2868
|
+
className = "",
|
|
2869
|
+
showGrid = true,
|
|
2870
|
+
showTooltip = true,
|
|
2871
|
+
showLegend = true,
|
|
2872
|
+
animated = true
|
|
2873
|
+
}) {
|
|
2874
|
+
const context = useGraphContext();
|
|
2875
|
+
const theme = useGraphTheme();
|
|
2876
|
+
const graphData = data ?? context.data;
|
|
2877
|
+
const graphLoading = loading ?? context.loading;
|
|
2878
|
+
const graphError = error ?? context.error;
|
|
2879
|
+
const resolvedSeries = useGraphSeries({
|
|
2880
|
+
data: graphData,
|
|
2881
|
+
series,
|
|
2882
|
+
xKey: String(xKey)
|
|
2883
|
+
}).filter((item) => item.visible);
|
|
2884
|
+
if (graphLoading) {
|
|
2885
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
2886
|
+
}
|
|
2887
|
+
if (graphError) {
|
|
2888
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2889
|
+
GraphErrorState,
|
|
2890
|
+
{
|
|
2891
|
+
error: graphError,
|
|
2892
|
+
height,
|
|
2893
|
+
className
|
|
2894
|
+
}
|
|
2895
|
+
);
|
|
2896
|
+
}
|
|
2897
|
+
if (!graphData.length || !resolvedSeries.length) {
|
|
2898
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
2899
|
+
}
|
|
2900
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `eui-graph flex w-full flex-col gap-3 ${className}`, children: [
|
|
2901
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphContainer, { height, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.LineChart, { data: graphData, margin: GRAPH_DEFAULT_MARGIN, children: [
|
|
2902
|
+
showGrid && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2903
|
+
recharts.CartesianGrid,
|
|
2904
|
+
{
|
|
2905
|
+
stroke: theme.chart.grid,
|
|
2906
|
+
strokeDasharray: "3 3",
|
|
2907
|
+
vertical: false
|
|
2908
|
+
}
|
|
2909
|
+
),
|
|
2910
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2911
|
+
recharts.XAxis,
|
|
2912
|
+
{
|
|
2913
|
+
dataKey: String(xKey),
|
|
2914
|
+
stroke: theme.chart.axis,
|
|
2915
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
2916
|
+
tickLine: false,
|
|
2917
|
+
axisLine: false
|
|
2918
|
+
}
|
|
2919
|
+
),
|
|
2920
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2921
|
+
recharts.YAxis,
|
|
2922
|
+
{
|
|
2923
|
+
stroke: theme.chart.axis,
|
|
2924
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
2925
|
+
tickLine: false,
|
|
2926
|
+
axisLine: false,
|
|
2927
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
2928
|
+
format: "compact"
|
|
2929
|
+
})
|
|
2930
|
+
}
|
|
2931
|
+
),
|
|
2932
|
+
showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2933
|
+
recharts.Tooltip,
|
|
2934
|
+
{
|
|
2935
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2936
|
+
GraphTooltip,
|
|
2937
|
+
{
|
|
2938
|
+
seriesFormatters: Object.fromEntries(
|
|
2939
|
+
resolvedSeries.map((item) => [
|
|
2940
|
+
item.key,
|
|
2941
|
+
{
|
|
2942
|
+
format: item.format,
|
|
2943
|
+
prefix: item.prefix,
|
|
2944
|
+
suffix: item.suffix,
|
|
2945
|
+
unit: item.unit
|
|
2946
|
+
}
|
|
2947
|
+
])
|
|
2948
|
+
)
|
|
2949
|
+
}
|
|
2950
|
+
),
|
|
2951
|
+
cursor: { stroke: theme.chart.cursor }
|
|
2952
|
+
}
|
|
2953
|
+
),
|
|
2954
|
+
resolvedSeries.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2955
|
+
recharts.Line,
|
|
2956
|
+
{
|
|
2957
|
+
type: "monotone",
|
|
2958
|
+
dataKey: item.key,
|
|
2959
|
+
name: item.label,
|
|
2960
|
+
stroke: item.color,
|
|
2961
|
+
strokeWidth: item.strokeWidth,
|
|
2962
|
+
dot: false,
|
|
2963
|
+
activeDot: { r: item.radius },
|
|
2964
|
+
isAnimationActive: animated,
|
|
2965
|
+
animationDuration: GRAPH_DEFAULT_ANIMATION_DURATION,
|
|
2966
|
+
yAxisId: item.yAxisId
|
|
2967
|
+
},
|
|
2968
|
+
item.key
|
|
2969
|
+
))
|
|
2970
|
+
] }) }) }),
|
|
2971
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2972
|
+
GraphLegend,
|
|
2973
|
+
{
|
|
2974
|
+
series: resolvedSeries,
|
|
2975
|
+
data: graphData,
|
|
2976
|
+
showValues: true,
|
|
2977
|
+
valueSource: "latest"
|
|
2978
|
+
}
|
|
2979
|
+
)
|
|
2980
|
+
] });
|
|
2981
|
+
}
|
|
2982
|
+
function AreaGraph({
|
|
2983
|
+
data,
|
|
2984
|
+
xKey = "time",
|
|
2985
|
+
series,
|
|
2986
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
2987
|
+
loading,
|
|
2988
|
+
error,
|
|
2989
|
+
className = "",
|
|
2990
|
+
showGrid = true,
|
|
2991
|
+
showTooltip = true,
|
|
2992
|
+
showLegend = true,
|
|
2993
|
+
animated = true
|
|
2994
|
+
}) {
|
|
2995
|
+
const context = useGraphContext();
|
|
2996
|
+
const theme = useGraphTheme();
|
|
2997
|
+
const graphData = data ?? context.data;
|
|
2998
|
+
const graphLoading = loading ?? context.loading;
|
|
2999
|
+
const graphError = error ?? context.error;
|
|
3000
|
+
const resolvedSeries = useGraphSeries({
|
|
3001
|
+
data: graphData,
|
|
3002
|
+
series,
|
|
3003
|
+
xKey: String(xKey)
|
|
3004
|
+
}).filter((item) => item.visible);
|
|
3005
|
+
if (graphLoading) {
|
|
3006
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
3007
|
+
}
|
|
3008
|
+
if (graphError) {
|
|
3009
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3010
|
+
GraphErrorState,
|
|
3011
|
+
{
|
|
3012
|
+
error: graphError,
|
|
3013
|
+
height,
|
|
3014
|
+
className
|
|
3015
|
+
}
|
|
3016
|
+
);
|
|
3017
|
+
}
|
|
3018
|
+
if (!graphData.length || !resolvedSeries.length) {
|
|
3019
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
3020
|
+
}
|
|
3021
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `eui-graph flex w-full flex-col gap-3 ${className}`, children: [
|
|
3022
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphContainer, { height, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.AreaChart, { data: graphData, margin: GRAPH_DEFAULT_MARGIN, children: [
|
|
3023
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: resolvedSeries.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3024
|
+
"linearGradient",
|
|
3025
|
+
{
|
|
3026
|
+
id: `eui-area-gradient-${item.key}`,
|
|
3027
|
+
x1: "0",
|
|
3028
|
+
y1: "0",
|
|
3029
|
+
x2: "0",
|
|
3030
|
+
y2: "1",
|
|
3031
|
+
children: [
|
|
3032
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "5%", stopColor: item.color, stopOpacity: 0.35 }),
|
|
3033
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3034
|
+
"stop",
|
|
3035
|
+
{
|
|
3036
|
+
offset: "95%",
|
|
3037
|
+
stopColor: item.color,
|
|
3038
|
+
stopOpacity: 0.02
|
|
3039
|
+
}
|
|
3040
|
+
)
|
|
3041
|
+
]
|
|
3042
|
+
},
|
|
3043
|
+
item.key
|
|
3044
|
+
)) }),
|
|
3045
|
+
showGrid && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3046
|
+
recharts.CartesianGrid,
|
|
3047
|
+
{
|
|
3048
|
+
stroke: theme.chart.grid,
|
|
3049
|
+
strokeDasharray: "3 3",
|
|
3050
|
+
vertical: false
|
|
3051
|
+
}
|
|
3052
|
+
),
|
|
3053
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3054
|
+
recharts.XAxis,
|
|
3055
|
+
{
|
|
3056
|
+
dataKey: String(xKey),
|
|
3057
|
+
stroke: theme.chart.axis,
|
|
3058
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3059
|
+
tickLine: false,
|
|
3060
|
+
axisLine: false
|
|
3061
|
+
}
|
|
3062
|
+
),
|
|
3063
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3064
|
+
recharts.YAxis,
|
|
3065
|
+
{
|
|
3066
|
+
stroke: theme.chart.axis,
|
|
3067
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3068
|
+
tickLine: false,
|
|
3069
|
+
axisLine: false,
|
|
3070
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
3071
|
+
format: "compact"
|
|
3072
|
+
})
|
|
3073
|
+
}
|
|
3074
|
+
),
|
|
3075
|
+
showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3076
|
+
recharts.Tooltip,
|
|
3077
|
+
{
|
|
3078
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3079
|
+
GraphTooltip,
|
|
3080
|
+
{
|
|
3081
|
+
seriesFormatters: Object.fromEntries(
|
|
3082
|
+
resolvedSeries.map((item) => [
|
|
3083
|
+
item.key,
|
|
3084
|
+
{
|
|
3085
|
+
format: item.format,
|
|
3086
|
+
prefix: item.prefix,
|
|
3087
|
+
suffix: item.suffix,
|
|
3088
|
+
unit: item.unit
|
|
3089
|
+
}
|
|
3090
|
+
])
|
|
3091
|
+
)
|
|
3092
|
+
}
|
|
3093
|
+
),
|
|
3094
|
+
cursor: { stroke: theme.chart.cursor }
|
|
3095
|
+
}
|
|
3096
|
+
),
|
|
3097
|
+
resolvedSeries.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3098
|
+
recharts.Area,
|
|
3099
|
+
{
|
|
3100
|
+
type: "monotone",
|
|
3101
|
+
dataKey: item.key,
|
|
3102
|
+
name: item.label,
|
|
3103
|
+
stroke: item.color,
|
|
3104
|
+
strokeWidth: item.strokeWidth,
|
|
3105
|
+
fill: `url(#eui-area-gradient-${item.key})`,
|
|
3106
|
+
isAnimationActive: animated,
|
|
3107
|
+
animationDuration: GRAPH_DEFAULT_ANIMATION_DURATION,
|
|
3108
|
+
yAxisId: item.yAxisId
|
|
3109
|
+
},
|
|
3110
|
+
item.key
|
|
3111
|
+
))
|
|
3112
|
+
] }) }) }),
|
|
3113
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3114
|
+
GraphLegend,
|
|
3115
|
+
{
|
|
3116
|
+
series: resolvedSeries,
|
|
3117
|
+
data: graphData,
|
|
3118
|
+
showValues: true,
|
|
3119
|
+
valueSource: "latest"
|
|
3120
|
+
}
|
|
3121
|
+
)
|
|
3122
|
+
] });
|
|
3123
|
+
}
|
|
3124
|
+
function BarGraph({
|
|
3125
|
+
data,
|
|
3126
|
+
xKey = "name",
|
|
3127
|
+
series,
|
|
3128
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
3129
|
+
loading,
|
|
3130
|
+
error,
|
|
3131
|
+
className = "",
|
|
3132
|
+
showGrid = true,
|
|
3133
|
+
showTooltip = true,
|
|
3134
|
+
showLegend = true,
|
|
3135
|
+
animated = true,
|
|
3136
|
+
layout = "horizontal"
|
|
3137
|
+
}) {
|
|
3138
|
+
const context = useGraphContext();
|
|
3139
|
+
const theme = useGraphTheme();
|
|
3140
|
+
const graphData = data ?? context.data;
|
|
3141
|
+
const graphLoading = loading ?? context.loading;
|
|
3142
|
+
const graphError = error ?? context.error;
|
|
3143
|
+
const resolvedSeries = useGraphSeries({
|
|
3144
|
+
data: graphData,
|
|
3145
|
+
series,
|
|
3146
|
+
xKey: String(xKey)
|
|
3147
|
+
}).filter((item) => item.visible);
|
|
3148
|
+
if (graphLoading) {
|
|
3149
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
3150
|
+
}
|
|
3151
|
+
if (graphError) {
|
|
3152
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3153
|
+
GraphErrorState,
|
|
3154
|
+
{
|
|
3155
|
+
error: graphError,
|
|
3156
|
+
height,
|
|
3157
|
+
className
|
|
3158
|
+
}
|
|
3159
|
+
);
|
|
3160
|
+
}
|
|
3161
|
+
if (!graphData.length || !resolvedSeries.length) {
|
|
3162
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
3163
|
+
}
|
|
3164
|
+
const isVertical = layout === "vertical";
|
|
3165
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `eui-graph flex w-full flex-col gap-3 ${className}`, children: [
|
|
3166
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphContainer, { height, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3167
|
+
recharts.BarChart,
|
|
3168
|
+
{
|
|
3169
|
+
data: graphData,
|
|
3170
|
+
margin: GRAPH_DEFAULT_MARGIN,
|
|
3171
|
+
layout: isVertical ? "vertical" : "horizontal",
|
|
3172
|
+
children: [
|
|
3173
|
+
showGrid && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3174
|
+
recharts.CartesianGrid,
|
|
3175
|
+
{
|
|
3176
|
+
stroke: theme.chart.grid,
|
|
3177
|
+
strokeDasharray: "3 3",
|
|
3178
|
+
horizontal: !isVertical,
|
|
3179
|
+
vertical: isVertical
|
|
3180
|
+
}
|
|
3181
|
+
),
|
|
3182
|
+
isVertical ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3183
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3184
|
+
recharts.XAxis,
|
|
3185
|
+
{
|
|
3186
|
+
type: "number",
|
|
3187
|
+
stroke: theme.chart.axis,
|
|
3188
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3189
|
+
tickLine: false,
|
|
3190
|
+
axisLine: false,
|
|
3191
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
3192
|
+
format: "compact"
|
|
3193
|
+
})
|
|
3194
|
+
}
|
|
3195
|
+
),
|
|
3196
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3197
|
+
recharts.YAxis,
|
|
3198
|
+
{
|
|
3199
|
+
type: "category",
|
|
3200
|
+
dataKey: String(xKey),
|
|
3201
|
+
stroke: theme.chart.axis,
|
|
3202
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3203
|
+
tickLine: false,
|
|
3204
|
+
axisLine: false,
|
|
3205
|
+
width: 110
|
|
3206
|
+
}
|
|
3207
|
+
)
|
|
3208
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3209
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3210
|
+
recharts.XAxis,
|
|
3211
|
+
{
|
|
3212
|
+
dataKey: String(xKey),
|
|
3213
|
+
stroke: theme.chart.axis,
|
|
3214
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3215
|
+
tickLine: false,
|
|
3216
|
+
axisLine: false
|
|
3217
|
+
}
|
|
3218
|
+
),
|
|
3219
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3220
|
+
recharts.YAxis,
|
|
3221
|
+
{
|
|
3222
|
+
stroke: theme.chart.axis,
|
|
3223
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3224
|
+
tickLine: false,
|
|
3225
|
+
axisLine: false,
|
|
3226
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
3227
|
+
format: "compact"
|
|
3228
|
+
})
|
|
3229
|
+
}
|
|
3230
|
+
)
|
|
3231
|
+
] }),
|
|
3232
|
+
showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3233
|
+
recharts.Tooltip,
|
|
3234
|
+
{
|
|
3235
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3236
|
+
GraphTooltip,
|
|
3237
|
+
{
|
|
3238
|
+
seriesFormatters: Object.fromEntries(
|
|
3239
|
+
resolvedSeries.map((item) => [
|
|
3240
|
+
item.key,
|
|
3241
|
+
{
|
|
3242
|
+
format: item.format,
|
|
3243
|
+
prefix: item.prefix,
|
|
3244
|
+
suffix: item.suffix,
|
|
3245
|
+
unit: item.unit
|
|
3246
|
+
}
|
|
3247
|
+
])
|
|
3248
|
+
)
|
|
3249
|
+
}
|
|
3250
|
+
),
|
|
3251
|
+
cursor: { fill: theme.chart.cursor }
|
|
3252
|
+
}
|
|
3253
|
+
),
|
|
3254
|
+
resolvedSeries.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3255
|
+
recharts.Bar,
|
|
3256
|
+
{
|
|
3257
|
+
dataKey: item.key,
|
|
3258
|
+
name: item.label,
|
|
3259
|
+
fill: item.color,
|
|
3260
|
+
radius: GRAPH_DEFAULT_BAR_RADIUS,
|
|
3261
|
+
isAnimationActive: animated,
|
|
3262
|
+
animationDuration: GRAPH_DEFAULT_ANIMATION_DURATION,
|
|
3263
|
+
yAxisId: isVertical ? void 0 : item.yAxisId
|
|
3264
|
+
},
|
|
3265
|
+
item.key
|
|
3266
|
+
))
|
|
3267
|
+
]
|
|
3268
|
+
}
|
|
3269
|
+
) }) }),
|
|
3270
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3271
|
+
GraphLegend,
|
|
3272
|
+
{
|
|
3273
|
+
series: resolvedSeries,
|
|
3274
|
+
data: graphData,
|
|
3275
|
+
showValues: true,
|
|
3276
|
+
valueSource: "latest"
|
|
3277
|
+
}
|
|
3278
|
+
)
|
|
3279
|
+
] });
|
|
3280
|
+
}
|
|
3281
|
+
function PieGraph({
|
|
3282
|
+
data,
|
|
3283
|
+
nameKey = "name",
|
|
3284
|
+
valueKey = "value",
|
|
3285
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
3286
|
+
loading,
|
|
3287
|
+
error,
|
|
3288
|
+
className = "",
|
|
3289
|
+
showTooltip = true,
|
|
3290
|
+
showLegend = true,
|
|
3291
|
+
animated = true,
|
|
3292
|
+
innerRadius = "45%",
|
|
3293
|
+
outerRadius = "75%",
|
|
3294
|
+
valueFormat = "number",
|
|
3295
|
+
unit
|
|
3296
|
+
}) {
|
|
3297
|
+
const context = useGraphContext();
|
|
3298
|
+
const theme = useGraphTheme();
|
|
3299
|
+
const graphData = data ?? context.data;
|
|
3300
|
+
const graphLoading = loading ?? context.loading;
|
|
3301
|
+
const graphError = error ?? context.error;
|
|
3302
|
+
if (graphLoading) {
|
|
3303
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
3304
|
+
}
|
|
3305
|
+
if (graphError) {
|
|
3306
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3307
|
+
GraphErrorState,
|
|
3308
|
+
{
|
|
3309
|
+
error: graphError,
|
|
3310
|
+
height,
|
|
3311
|
+
className
|
|
3312
|
+
}
|
|
3313
|
+
);
|
|
3314
|
+
}
|
|
3315
|
+
if (!graphData.length) {
|
|
3316
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
3317
|
+
}
|
|
3318
|
+
const legendItems = graphData.map((item, index) => {
|
|
3319
|
+
const key = String(item[String(nameKey)] ?? index);
|
|
3320
|
+
return {
|
|
3321
|
+
key,
|
|
3322
|
+
label: key,
|
|
3323
|
+
value: item[String(valueKey)],
|
|
3324
|
+
color: resolveGraphColor(void 0, {
|
|
3325
|
+
index,
|
|
3326
|
+
palette: theme.colors
|
|
3327
|
+
}),
|
|
3328
|
+
format: valueFormat,
|
|
3329
|
+
unit,
|
|
3330
|
+
active: true
|
|
3331
|
+
};
|
|
3332
|
+
});
|
|
3333
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `eui-graph flex w-full flex-col gap-3 ${className}`, children: [
|
|
3334
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphContainer, { height, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.PieChart, { children: [
|
|
3335
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3336
|
+
recharts.Pie,
|
|
3337
|
+
{
|
|
3338
|
+
data: graphData,
|
|
3339
|
+
dataKey: String(valueKey),
|
|
3340
|
+
nameKey: String(nameKey),
|
|
3341
|
+
innerRadius,
|
|
3342
|
+
outerRadius,
|
|
3343
|
+
paddingAngle: 2,
|
|
3344
|
+
isAnimationActive: animated,
|
|
3345
|
+
animationDuration: GRAPH_DEFAULT_ANIMATION_DURATION,
|
|
3346
|
+
children: graphData.map((_item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3347
|
+
recharts.Cell,
|
|
3348
|
+
{
|
|
3349
|
+
fill: resolveGraphColor(void 0, {
|
|
3350
|
+
index,
|
|
3351
|
+
palette: theme.colors
|
|
3352
|
+
})
|
|
3353
|
+
},
|
|
3354
|
+
`cell-${index}`
|
|
3355
|
+
))
|
|
3356
|
+
}
|
|
3357
|
+
),
|
|
3358
|
+
showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3359
|
+
recharts.Tooltip,
|
|
3360
|
+
{
|
|
3361
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3362
|
+
GraphTooltip,
|
|
3363
|
+
{
|
|
3364
|
+
seriesFormatters: {
|
|
3365
|
+
[String(valueKey)]: {
|
|
3366
|
+
format: valueFormat,
|
|
3367
|
+
suffix: unit
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
)
|
|
3372
|
+
}
|
|
3373
|
+
)
|
|
3374
|
+
] }) }) }),
|
|
3375
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx(GraphLegend, { items: legendItems, showValues: true, valueSource: "latest" })
|
|
3376
|
+
] });
|
|
3377
|
+
}
|
|
3378
|
+
function ScatterGraph({
|
|
3379
|
+
data,
|
|
3380
|
+
xKey = "x",
|
|
3381
|
+
series,
|
|
3382
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
3383
|
+
loading,
|
|
3384
|
+
error,
|
|
3385
|
+
className = "",
|
|
3386
|
+
showGrid = true,
|
|
3387
|
+
showTooltip = true,
|
|
3388
|
+
showLegend = true,
|
|
3389
|
+
animated = true
|
|
3390
|
+
}) {
|
|
3391
|
+
const context = useGraphContext();
|
|
3392
|
+
const theme = useGraphTheme();
|
|
3393
|
+
const graphData = data ?? context.data;
|
|
3394
|
+
const graphLoading = loading ?? context.loading;
|
|
3395
|
+
const graphError = error ?? context.error;
|
|
3396
|
+
const resolvedSeries = useGraphSeries({
|
|
3397
|
+
data: graphData,
|
|
3398
|
+
series,
|
|
3399
|
+
xKey: String(xKey)
|
|
3400
|
+
}).filter((item) => item.visible);
|
|
3401
|
+
if (graphLoading) {
|
|
3402
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
3403
|
+
}
|
|
3404
|
+
if (graphError) {
|
|
3405
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3406
|
+
GraphErrorState,
|
|
3407
|
+
{
|
|
3408
|
+
error: graphError,
|
|
3409
|
+
height,
|
|
3410
|
+
className
|
|
3411
|
+
}
|
|
3412
|
+
);
|
|
3413
|
+
}
|
|
3414
|
+
if (!graphData.length || !resolvedSeries.length) {
|
|
3415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
3416
|
+
}
|
|
3417
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `eui-graph flex w-full flex-col gap-3 ${className}`, children: [
|
|
3418
|
+
/* @__PURE__ */ jsxRuntime.jsx(GraphContainer, { height, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ScatterChart, { margin: GRAPH_DEFAULT_MARGIN, children: [
|
|
3419
|
+
showGrid && /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { stroke: theme.chart.grid, strokeDasharray: "3 3" }),
|
|
3420
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3421
|
+
recharts.XAxis,
|
|
3422
|
+
{
|
|
3423
|
+
type: "number",
|
|
3424
|
+
dataKey: String(xKey),
|
|
3425
|
+
name: String(xKey),
|
|
3426
|
+
stroke: theme.chart.axis,
|
|
3427
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3428
|
+
tickLine: false,
|
|
3429
|
+
axisLine: false,
|
|
3430
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
3431
|
+
format: "compact"
|
|
3432
|
+
})
|
|
3433
|
+
}
|
|
3434
|
+
),
|
|
3435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3436
|
+
recharts.YAxis,
|
|
3437
|
+
{
|
|
3438
|
+
type: "number",
|
|
3439
|
+
stroke: theme.chart.axis,
|
|
3440
|
+
tick: { fill: theme.chart.axis, fontSize: 12 },
|
|
3441
|
+
tickLine: false,
|
|
3442
|
+
axisLine: false,
|
|
3443
|
+
tickFormatter: (value) => formatGraphValue(value, {
|
|
3444
|
+
format: "compact"
|
|
3445
|
+
})
|
|
3446
|
+
}
|
|
3447
|
+
),
|
|
3448
|
+
showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3449
|
+
recharts.Tooltip,
|
|
3450
|
+
{
|
|
3451
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3452
|
+
GraphTooltip,
|
|
3453
|
+
{
|
|
3454
|
+
seriesFormatters: Object.fromEntries(
|
|
3455
|
+
resolvedSeries.map((item) => [
|
|
3456
|
+
item.key,
|
|
3457
|
+
{
|
|
3458
|
+
format: item.format,
|
|
3459
|
+
prefix: item.prefix,
|
|
3460
|
+
suffix: item.suffix,
|
|
3461
|
+
unit: item.unit
|
|
3462
|
+
}
|
|
3463
|
+
])
|
|
3464
|
+
)
|
|
3465
|
+
}
|
|
3466
|
+
),
|
|
3467
|
+
cursor: { stroke: theme.chart.cursor, strokeDasharray: "3 3" }
|
|
3468
|
+
}
|
|
3469
|
+
),
|
|
3470
|
+
resolvedSeries.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3471
|
+
recharts.Scatter,
|
|
3472
|
+
{
|
|
3473
|
+
data: graphData,
|
|
3474
|
+
dataKey: item.key,
|
|
3475
|
+
name: item.label,
|
|
3476
|
+
fill: item.color,
|
|
3477
|
+
isAnimationActive: animated,
|
|
3478
|
+
animationDuration: GRAPH_DEFAULT_ANIMATION_DURATION
|
|
3479
|
+
},
|
|
3480
|
+
item.key
|
|
3481
|
+
))
|
|
3482
|
+
] }) }) }),
|
|
3483
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3484
|
+
GraphLegend,
|
|
3485
|
+
{
|
|
3486
|
+
series: resolvedSeries,
|
|
3487
|
+
data: graphData,
|
|
3488
|
+
showValues: true,
|
|
3489
|
+
valueSource: "latest"
|
|
3490
|
+
}
|
|
3491
|
+
)
|
|
3492
|
+
] });
|
|
3493
|
+
}
|
|
3494
|
+
function GaugeGraph({
|
|
3495
|
+
data,
|
|
3496
|
+
valueKey = "value",
|
|
3497
|
+
label,
|
|
3498
|
+
value,
|
|
3499
|
+
min = 0,
|
|
3500
|
+
max = 100,
|
|
3501
|
+
height = GRAPH_DEFAULT_HEIGHT,
|
|
3502
|
+
color,
|
|
3503
|
+
unit,
|
|
3504
|
+
format = "number",
|
|
3505
|
+
loading,
|
|
3506
|
+
error,
|
|
3507
|
+
className = ""
|
|
3508
|
+
}) {
|
|
3509
|
+
const context = useGraphContext();
|
|
3510
|
+
const theme = useGraphTheme();
|
|
3511
|
+
const graphData = data ?? context.data;
|
|
3512
|
+
const graphLoading = loading ?? context.loading;
|
|
3513
|
+
const graphError = error ?? context.error;
|
|
3514
|
+
const resolvedValue = React3.useMemo(() => {
|
|
3515
|
+
if (typeof value === "number") {
|
|
3516
|
+
return value;
|
|
3517
|
+
}
|
|
3518
|
+
const latestPoint = graphData[graphData.length - 1];
|
|
3519
|
+
const latestValue = latestPoint?.[String(valueKey)];
|
|
3520
|
+
return typeof latestValue === "number" ? latestValue : void 0;
|
|
3521
|
+
}, [graphData, value, valueKey]);
|
|
3522
|
+
if (graphLoading) {
|
|
3523
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height, className });
|
|
3524
|
+
}
|
|
3525
|
+
if (graphError) {
|
|
3526
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3527
|
+
GraphErrorState,
|
|
3528
|
+
{
|
|
3529
|
+
error: graphError,
|
|
3530
|
+
height,
|
|
3531
|
+
className
|
|
3532
|
+
}
|
|
3533
|
+
);
|
|
3534
|
+
}
|
|
3535
|
+
if (resolvedValue === void 0) {
|
|
3536
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height, className });
|
|
3537
|
+
}
|
|
3538
|
+
const range = max - min;
|
|
3539
|
+
const percentage = range === 0 ? 0 : Math.min(100, Math.max(0, (resolvedValue - min) / range * 100));
|
|
3540
|
+
const radius = 72;
|
|
3541
|
+
const strokeWidth = 14;
|
|
3542
|
+
const circumference = Math.PI * radius;
|
|
3543
|
+
const offset = circumference - percentage / 100 * circumference;
|
|
3544
|
+
const resolvedColor = resolveGraphColor(color, {
|
|
3545
|
+
index: 0,
|
|
3546
|
+
palette: theme.colors
|
|
3547
|
+
});
|
|
3548
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3549
|
+
"div",
|
|
3550
|
+
{
|
|
3551
|
+
className: `eui-graph flex items-center justify-center ${className}`,
|
|
3552
|
+
style: { height },
|
|
3553
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
|
|
3554
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "220", height: "130", viewBox: "0 0 220 130", children: [
|
|
3555
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3556
|
+
"path",
|
|
3557
|
+
{
|
|
3558
|
+
d: "M 38 104 A 72 72 0 0 1 182 104",
|
|
3559
|
+
fill: "none",
|
|
3560
|
+
stroke: theme.chart.grid,
|
|
3561
|
+
strokeWidth,
|
|
3562
|
+
strokeLinecap: "round"
|
|
3563
|
+
}
|
|
3564
|
+
),
|
|
3565
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3566
|
+
"path",
|
|
3567
|
+
{
|
|
3568
|
+
d: "M 38 104 A 72 72 0 0 1 182 104",
|
|
3569
|
+
fill: "none",
|
|
3570
|
+
stroke: resolvedColor,
|
|
3571
|
+
strokeWidth,
|
|
3572
|
+
strokeLinecap: "round",
|
|
3573
|
+
strokeDasharray: circumference,
|
|
3574
|
+
strokeDashoffset: offset
|
|
3575
|
+
}
|
|
3576
|
+
),
|
|
3577
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3578
|
+
"text",
|
|
3579
|
+
{
|
|
3580
|
+
x: "110",
|
|
3581
|
+
y: "92",
|
|
3582
|
+
textAnchor: "middle",
|
|
3583
|
+
fill: theme.tooltip.text,
|
|
3584
|
+
fontSize: "28",
|
|
3585
|
+
fontWeight: "700",
|
|
3586
|
+
children: formatGraphValue(resolvedValue, {
|
|
3587
|
+
format,
|
|
3588
|
+
suffix: unit,
|
|
3589
|
+
maximumFractionDigits: 2
|
|
3590
|
+
})
|
|
3591
|
+
}
|
|
3592
|
+
),
|
|
3593
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3594
|
+
"text",
|
|
3595
|
+
{
|
|
3596
|
+
x: "110",
|
|
3597
|
+
y: "118",
|
|
3598
|
+
textAnchor: "middle",
|
|
3599
|
+
fill: theme.tooltip.muted,
|
|
3600
|
+
fontSize: "12",
|
|
3601
|
+
children: label
|
|
3602
|
+
}
|
|
3603
|
+
)
|
|
3604
|
+
] }),
|
|
3605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[180px] justify-between text-xs text-gray-500", children: [
|
|
3606
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatGraphValue(min, {
|
|
3607
|
+
format,
|
|
3608
|
+
suffix: unit
|
|
3609
|
+
}) }),
|
|
3610
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatGraphValue(max, {
|
|
3611
|
+
format,
|
|
3612
|
+
suffix: unit
|
|
3613
|
+
}) })
|
|
3614
|
+
] })
|
|
3615
|
+
] })
|
|
3616
|
+
}
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
function StatGraph({
|
|
3620
|
+
data,
|
|
3621
|
+
valueKey = "value",
|
|
3622
|
+
label,
|
|
3623
|
+
value,
|
|
3624
|
+
previousValue,
|
|
3625
|
+
format = "number",
|
|
3626
|
+
prefix,
|
|
3627
|
+
suffix,
|
|
3628
|
+
unit,
|
|
3629
|
+
loading,
|
|
3630
|
+
error,
|
|
3631
|
+
className = "",
|
|
3632
|
+
showTrend = true
|
|
3633
|
+
}) {
|
|
3634
|
+
const context = useGraphContext();
|
|
3635
|
+
const graphData = data ?? context.data;
|
|
3636
|
+
const graphLoading = loading ?? context.loading;
|
|
3637
|
+
const graphError = error ?? context.error;
|
|
3638
|
+
const resolvedValue = React3.useMemo(() => {
|
|
3639
|
+
if (value !== void 0) {
|
|
3640
|
+
return value;
|
|
3641
|
+
}
|
|
3642
|
+
const latestPoint = graphData[graphData.length - 1];
|
|
3643
|
+
return latestPoint?.[String(valueKey)] ?? null;
|
|
3644
|
+
}, [graphData, value, valueKey]);
|
|
3645
|
+
const resolvedPreviousValue = React3.useMemo(() => {
|
|
3646
|
+
if (previousValue !== void 0) {
|
|
3647
|
+
return previousValue;
|
|
3648
|
+
}
|
|
3649
|
+
const previousPoint = graphData[graphData.length - 2];
|
|
3650
|
+
const previous = previousPoint?.[String(valueKey)];
|
|
3651
|
+
return typeof previous === "number" ? previous : void 0;
|
|
3652
|
+
}, [graphData, previousValue, valueKey]);
|
|
3653
|
+
const trend = React3.useMemo(() => {
|
|
3654
|
+
if (typeof resolvedValue !== "number" || typeof resolvedPreviousValue !== "number") {
|
|
3655
|
+
return null;
|
|
3656
|
+
}
|
|
3657
|
+
const difference = resolvedValue - resolvedPreviousValue;
|
|
3658
|
+
const percentage = resolvedPreviousValue === 0 ? 0 : difference / Math.abs(resolvedPreviousValue) * 100;
|
|
3659
|
+
return {
|
|
3660
|
+
difference,
|
|
3661
|
+
percentage,
|
|
3662
|
+
direction: difference > 0 ? "up" : difference < 0 ? "down" : "neutral"
|
|
3663
|
+
};
|
|
3664
|
+
}, [resolvedPreviousValue, resolvedValue]);
|
|
3665
|
+
if (graphLoading) {
|
|
3666
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphLoadingState, { height: 120, className });
|
|
3667
|
+
}
|
|
3668
|
+
if (graphError) {
|
|
3669
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphErrorState, { error: graphError, height: 120, className });
|
|
3670
|
+
}
|
|
3671
|
+
if (resolvedValue === null || resolvedValue === void 0) {
|
|
3672
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GraphEmptyState, { height: 120, className });
|
|
3673
|
+
}
|
|
3674
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3675
|
+
"div",
|
|
3676
|
+
{
|
|
3677
|
+
className: `eui-graph rounded-xl border border-[#2a2d35] bg-[#111217] p-5 ${className}`,
|
|
3678
|
+
children: [
|
|
3679
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-400", children: label }),
|
|
3680
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-3xl font-semibold tracking-tight text-gray-100", children: formatGraphValue(resolvedValue, {
|
|
3681
|
+
format,
|
|
3682
|
+
prefix,
|
|
3683
|
+
suffix: suffix ?? unit
|
|
3684
|
+
}) }),
|
|
3685
|
+
showTrend && trend && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3686
|
+
"div",
|
|
3687
|
+
{
|
|
3688
|
+
className: `mt-3 text-sm ${trend.direction === "up" ? "text-emerald-400" : trend.direction === "down" ? "text-red-400" : "text-gray-500"}`,
|
|
3689
|
+
children: [
|
|
3690
|
+
trend.direction === "up" ? "\u2191" : trend.direction === "down" ? "\u2193" : "\u2192",
|
|
3691
|
+
" ",
|
|
3692
|
+
formatGraphValue(Math.abs(trend.percentage), {
|
|
3693
|
+
format: "number",
|
|
3694
|
+
suffix: "%",
|
|
3695
|
+
maximumFractionDigits: 2
|
|
3696
|
+
})
|
|
3697
|
+
]
|
|
3698
|
+
}
|
|
3699
|
+
)
|
|
3700
|
+
]
|
|
3701
|
+
}
|
|
3702
|
+
);
|
|
3703
|
+
}
|
|
3704
|
+
function renderGraphChart(props) {
|
|
3705
|
+
const {
|
|
3706
|
+
type = "line",
|
|
3707
|
+
data,
|
|
3708
|
+
xKey,
|
|
3709
|
+
series,
|
|
3710
|
+
height,
|
|
3711
|
+
loading,
|
|
3712
|
+
error,
|
|
3713
|
+
chartClassName = "",
|
|
3714
|
+
showGrid = true,
|
|
3715
|
+
showTooltip = true,
|
|
3716
|
+
showLegend = true,
|
|
3717
|
+
animated = true,
|
|
3718
|
+
layout,
|
|
3719
|
+
nameKey,
|
|
3720
|
+
valueKey,
|
|
3721
|
+
innerRadius,
|
|
3722
|
+
outerRadius,
|
|
3723
|
+
valueFormat,
|
|
3724
|
+
value,
|
|
3725
|
+
previousValue,
|
|
3726
|
+
label,
|
|
3727
|
+
min,
|
|
3728
|
+
max,
|
|
3729
|
+
color,
|
|
3730
|
+
unit,
|
|
3731
|
+
format,
|
|
3732
|
+
prefix,
|
|
3733
|
+
suffix,
|
|
3734
|
+
showTrend
|
|
3735
|
+
} = props;
|
|
3736
|
+
switch (type) {
|
|
3737
|
+
case "area":
|
|
3738
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3739
|
+
AreaGraph,
|
|
3740
|
+
{
|
|
3741
|
+
data,
|
|
3742
|
+
xKey,
|
|
3743
|
+
series,
|
|
3744
|
+
height,
|
|
3745
|
+
loading,
|
|
3746
|
+
error,
|
|
3747
|
+
className: chartClassName,
|
|
3748
|
+
showGrid,
|
|
3749
|
+
showTooltip,
|
|
3750
|
+
showLegend,
|
|
3751
|
+
animated
|
|
3752
|
+
}
|
|
3753
|
+
);
|
|
3754
|
+
case "bar":
|
|
3755
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3756
|
+
BarGraph,
|
|
3757
|
+
{
|
|
3758
|
+
data,
|
|
3759
|
+
xKey,
|
|
3760
|
+
series,
|
|
3761
|
+
height,
|
|
3762
|
+
loading,
|
|
3763
|
+
error,
|
|
3764
|
+
className: chartClassName,
|
|
3765
|
+
showGrid,
|
|
3766
|
+
showTooltip,
|
|
3767
|
+
showLegend,
|
|
3768
|
+
animated,
|
|
3769
|
+
layout
|
|
3770
|
+
}
|
|
3771
|
+
);
|
|
3772
|
+
case "pie":
|
|
3773
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3774
|
+
PieGraph,
|
|
3775
|
+
{
|
|
3776
|
+
data,
|
|
3777
|
+
nameKey,
|
|
3778
|
+
valueKey,
|
|
3779
|
+
height,
|
|
3780
|
+
loading,
|
|
3781
|
+
error,
|
|
3782
|
+
className: chartClassName,
|
|
3783
|
+
showTooltip,
|
|
3784
|
+
showLegend,
|
|
3785
|
+
animated,
|
|
3786
|
+
innerRadius,
|
|
3787
|
+
outerRadius,
|
|
3788
|
+
valueFormat,
|
|
3789
|
+
unit
|
|
3790
|
+
}
|
|
3791
|
+
);
|
|
3792
|
+
case "scatter":
|
|
3793
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3794
|
+
ScatterGraph,
|
|
3795
|
+
{
|
|
3796
|
+
data,
|
|
3797
|
+
xKey,
|
|
3798
|
+
series,
|
|
3799
|
+
height,
|
|
3800
|
+
loading,
|
|
3801
|
+
error,
|
|
3802
|
+
className: chartClassName,
|
|
3803
|
+
showGrid,
|
|
3804
|
+
showTooltip,
|
|
3805
|
+
showLegend,
|
|
3806
|
+
animated
|
|
3807
|
+
}
|
|
3808
|
+
);
|
|
3809
|
+
case "gauge":
|
|
3810
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3811
|
+
GaugeGraph,
|
|
3812
|
+
{
|
|
3813
|
+
data,
|
|
3814
|
+
valueKey,
|
|
3815
|
+
value: typeof value === "number" ? value : void 0,
|
|
3816
|
+
label,
|
|
3817
|
+
min,
|
|
3818
|
+
max,
|
|
3819
|
+
height,
|
|
3820
|
+
color,
|
|
3821
|
+
unit,
|
|
3822
|
+
format,
|
|
3823
|
+
loading,
|
|
3824
|
+
error,
|
|
3825
|
+
className: chartClassName
|
|
3826
|
+
}
|
|
3827
|
+
);
|
|
3828
|
+
case "stat":
|
|
3829
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3830
|
+
StatGraph,
|
|
3831
|
+
{
|
|
3832
|
+
data,
|
|
3833
|
+
valueKey,
|
|
3834
|
+
value,
|
|
3835
|
+
previousValue,
|
|
3836
|
+
label,
|
|
3837
|
+
format,
|
|
3838
|
+
prefix,
|
|
3839
|
+
suffix,
|
|
3840
|
+
unit,
|
|
3841
|
+
loading,
|
|
3842
|
+
error,
|
|
3843
|
+
className: chartClassName,
|
|
3844
|
+
showTrend
|
|
3845
|
+
}
|
|
3846
|
+
);
|
|
3847
|
+
case "line":
|
|
3848
|
+
default:
|
|
3849
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3850
|
+
LineGraph,
|
|
3851
|
+
{
|
|
3852
|
+
data,
|
|
3853
|
+
xKey,
|
|
3854
|
+
series,
|
|
3855
|
+
height,
|
|
3856
|
+
loading,
|
|
3857
|
+
error,
|
|
3858
|
+
className: chartClassName,
|
|
3859
|
+
showGrid,
|
|
3860
|
+
showTooltip,
|
|
3861
|
+
showLegend,
|
|
3862
|
+
animated
|
|
3863
|
+
}
|
|
3864
|
+
);
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
function GraphContent(props) {
|
|
3868
|
+
const {
|
|
3869
|
+
children,
|
|
3870
|
+
withPanel = true,
|
|
3871
|
+
title,
|
|
3872
|
+
description,
|
|
3873
|
+
actions,
|
|
3874
|
+
toolbar,
|
|
3875
|
+
className = "",
|
|
3876
|
+
contentClassName = "",
|
|
3877
|
+
height,
|
|
3878
|
+
loading,
|
|
3879
|
+
error,
|
|
3880
|
+
showToolbar = false,
|
|
3881
|
+
showRefresh = true,
|
|
3882
|
+
showLastUpdated = true,
|
|
3883
|
+
emptyMessage,
|
|
3884
|
+
emptyDescription,
|
|
3885
|
+
onRetry
|
|
3886
|
+
} = props;
|
|
3887
|
+
const chart = children ?? renderGraphChart(props);
|
|
3888
|
+
if (!withPanel) {
|
|
3889
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: chart });
|
|
3890
|
+
}
|
|
3891
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3892
|
+
GraphPanel,
|
|
3893
|
+
{
|
|
3894
|
+
title,
|
|
3895
|
+
description,
|
|
3896
|
+
actions,
|
|
3897
|
+
toolbar,
|
|
3898
|
+
className,
|
|
3899
|
+
contentClassName,
|
|
3900
|
+
height,
|
|
3901
|
+
loading,
|
|
3902
|
+
error,
|
|
3903
|
+
empty: children ? false : void 0,
|
|
3904
|
+
showToolbar,
|
|
3905
|
+
showRefresh,
|
|
3906
|
+
showLastUpdated,
|
|
3907
|
+
emptyMessage,
|
|
3908
|
+
emptyDescription,
|
|
3909
|
+
onRetry,
|
|
3910
|
+
children: chart
|
|
3911
|
+
}
|
|
3912
|
+
);
|
|
3913
|
+
}
|
|
3914
|
+
function Graph(props) {
|
|
3915
|
+
const {
|
|
3916
|
+
data,
|
|
3917
|
+
dataSource,
|
|
3918
|
+
autoLoad = true,
|
|
3919
|
+
maxDataPoints,
|
|
3920
|
+
theme,
|
|
3921
|
+
onDataChange,
|
|
3922
|
+
onError
|
|
3923
|
+
} = props;
|
|
3924
|
+
const shouldUseProvider = Boolean(data || dataSource);
|
|
3925
|
+
const content = /* @__PURE__ */ jsxRuntime.jsx(GraphContent, { ...props });
|
|
3926
|
+
if (!shouldUseProvider) {
|
|
3927
|
+
return content;
|
|
3928
|
+
}
|
|
3929
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3930
|
+
GraphProvider,
|
|
3931
|
+
{
|
|
3932
|
+
data,
|
|
3933
|
+
dataSource,
|
|
3934
|
+
autoLoad,
|
|
3935
|
+
maxDataPoints,
|
|
3936
|
+
theme,
|
|
3937
|
+
onDataChange,
|
|
3938
|
+
onError,
|
|
3939
|
+
children: content
|
|
3940
|
+
}
|
|
3941
|
+
);
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
// src/components/data-display/graphs-v2/datasource/GraphDataSource.ts
|
|
3945
|
+
var BaseGraphDataSource = class {
|
|
3946
|
+
normalizeError(error) {
|
|
3947
|
+
if (error instanceof Error) {
|
|
3948
|
+
return error;
|
|
3949
|
+
}
|
|
3950
|
+
return new Error(String(error));
|
|
3951
|
+
}
|
|
3952
|
+
ensureArray(data) {
|
|
3953
|
+
if (!data) {
|
|
3954
|
+
return [];
|
|
3955
|
+
}
|
|
3956
|
+
return Array.isArray(data) ? data : [data];
|
|
3957
|
+
}
|
|
3958
|
+
safeExecute(executor) {
|
|
3959
|
+
try {
|
|
3960
|
+
return Promise.resolve(executor());
|
|
3961
|
+
} catch (error) {
|
|
3962
|
+
return Promise.reject(this.normalizeError(error));
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
|
|
3967
|
+
// src/components/data-display/graphs-v2/datasource/StaticGraphDataSource.ts
|
|
3968
|
+
var StaticGraphDataSource = class extends BaseGraphDataSource {
|
|
3969
|
+
constructor(config = {}) {
|
|
3970
|
+
super();
|
|
3971
|
+
this.mode = GRAPH_DATA_MODES.STATIC;
|
|
3972
|
+
this.data = Array.isArray(config) ? config : config.data ?? [];
|
|
3973
|
+
}
|
|
3974
|
+
getInitialData() {
|
|
3975
|
+
return this.data;
|
|
3976
|
+
}
|
|
3977
|
+
refresh() {
|
|
3978
|
+
return this.data;
|
|
3979
|
+
}
|
|
3980
|
+
setData(data) {
|
|
3981
|
+
this.data = data;
|
|
3982
|
+
}
|
|
3983
|
+
appendData(data) {
|
|
3984
|
+
const nextData = this.ensureArray(data);
|
|
3985
|
+
this.data = [...this.data, ...nextData];
|
|
3986
|
+
}
|
|
3987
|
+
clearData() {
|
|
3988
|
+
this.data = [];
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
|
|
3992
|
+
// src/components/data-display/graphs-v2/datasource/PollingGraphDataSource.ts
|
|
3993
|
+
var PollingGraphDataSource = class extends BaseGraphDataSource {
|
|
3994
|
+
constructor(config) {
|
|
3995
|
+
super();
|
|
3996
|
+
this.mode = GRAPH_DATA_MODES.POLLING;
|
|
3997
|
+
this.fetcher = config.fetcher;
|
|
3998
|
+
this.interval = config.interval ?? GRAPH_DEFAULT_POLLING_INTERVAL;
|
|
3999
|
+
this.immediate = config.immediate ?? true;
|
|
4000
|
+
}
|
|
4001
|
+
getInitialData() {
|
|
4002
|
+
return this.refresh();
|
|
4003
|
+
}
|
|
4004
|
+
refresh() {
|
|
4005
|
+
return this.safeExecute(async () => {
|
|
4006
|
+
const data = await this.fetcher();
|
|
4007
|
+
return this.ensureArray(data);
|
|
4008
|
+
});
|
|
4009
|
+
}
|
|
4010
|
+
subscribe(onData, onError) {
|
|
4011
|
+
let disposed = false;
|
|
4012
|
+
let fetching = false;
|
|
4013
|
+
let timer;
|
|
4014
|
+
const execute = async () => {
|
|
4015
|
+
if (disposed || fetching) {
|
|
4016
|
+
return;
|
|
4017
|
+
}
|
|
4018
|
+
try {
|
|
4019
|
+
fetching = true;
|
|
4020
|
+
const data = await this.refresh();
|
|
4021
|
+
if (!disposed) {
|
|
4022
|
+
onData(data);
|
|
4023
|
+
}
|
|
4024
|
+
} catch (error) {
|
|
4025
|
+
if (!disposed) {
|
|
4026
|
+
onError?.(this.normalizeError(error));
|
|
4027
|
+
}
|
|
4028
|
+
} finally {
|
|
4029
|
+
fetching = false;
|
|
4030
|
+
}
|
|
4031
|
+
};
|
|
4032
|
+
if (this.immediate) {
|
|
4033
|
+
void execute();
|
|
4034
|
+
}
|
|
4035
|
+
timer = globalThis.setInterval(() => {
|
|
4036
|
+
void execute();
|
|
4037
|
+
}, this.interval);
|
|
4038
|
+
return () => {
|
|
4039
|
+
disposed = true;
|
|
4040
|
+
if (timer) {
|
|
4041
|
+
globalThis.clearInterval(timer);
|
|
4042
|
+
}
|
|
4043
|
+
};
|
|
4044
|
+
}
|
|
4045
|
+
};
|
|
4046
|
+
|
|
4047
|
+
// src/components/data-display/graphs-v2/datasource/RealtimeGraphDataSource.ts
|
|
4048
|
+
var RealtimeGraphDataSource = class extends BaseGraphDataSource {
|
|
4049
|
+
constructor(config) {
|
|
4050
|
+
super();
|
|
4051
|
+
this.mode = GRAPH_DATA_MODES.REALTIME;
|
|
4052
|
+
this.connect = config.connect;
|
|
4053
|
+
this.initialDataLoader = config.getInitialData;
|
|
4054
|
+
this.refreshHandler = config.refresh;
|
|
4055
|
+
}
|
|
4056
|
+
getInitialData() {
|
|
4057
|
+
if (!this.initialDataLoader) {
|
|
4058
|
+
return [];
|
|
4059
|
+
}
|
|
4060
|
+
return this.safeExecute(async () => {
|
|
4061
|
+
const data = await this.initialDataLoader?.();
|
|
4062
|
+
return this.ensureArray(data);
|
|
4063
|
+
});
|
|
4064
|
+
}
|
|
4065
|
+
refresh() {
|
|
4066
|
+
if (!this.refreshHandler) {
|
|
4067
|
+
return this.getInitialData();
|
|
4068
|
+
}
|
|
4069
|
+
return this.safeExecute(async () => {
|
|
4070
|
+
const data = await this.refreshHandler?.();
|
|
4071
|
+
return this.ensureArray(data);
|
|
4072
|
+
});
|
|
4073
|
+
}
|
|
4074
|
+
subscribe(onData, onError) {
|
|
4075
|
+
try {
|
|
4076
|
+
return this.connect(
|
|
4077
|
+
(data) => {
|
|
4078
|
+
onData(this.ensureArray(data));
|
|
4079
|
+
},
|
|
4080
|
+
(error) => {
|
|
4081
|
+
onError?.(this.normalizeError(error));
|
|
4082
|
+
}
|
|
4083
|
+
);
|
|
4084
|
+
} catch (error) {
|
|
4085
|
+
onError?.(this.normalizeError(error));
|
|
4086
|
+
return () => {
|
|
4087
|
+
};
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
1602
4090
|
};
|
|
1603
|
-
var CloudinaryContext =
|
|
4091
|
+
var CloudinaryContext = React3.createContext(null);
|
|
1604
4092
|
var CloudinaryProvider = ({
|
|
1605
4093
|
cloudName,
|
|
1606
4094
|
children
|
|
1607
4095
|
}) => /* @__PURE__ */ jsxRuntime.jsx(CloudinaryContext.Provider, { value: { cloudName }, children });
|
|
1608
4096
|
var useCloudinaryConfig = () => {
|
|
1609
|
-
const ctx =
|
|
4097
|
+
const ctx = React3.useContext(CloudinaryContext);
|
|
1610
4098
|
if (!ctx) {
|
|
1611
4099
|
throw new Error(
|
|
1612
4100
|
"CloudinaryProvider is missing. Wrap your app with <CloudinaryProvider />"
|
|
@@ -2061,7 +4549,7 @@ var ListItem = ({
|
|
|
2061
4549
|
children: bullet
|
|
2062
4550
|
}
|
|
2063
4551
|
),
|
|
2064
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: TypographyComponent ?
|
|
4552
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: TypographyComponent ? React3__default.default.cloneElement(
|
|
2065
4553
|
TypographyComponent,
|
|
2066
4554
|
{
|
|
2067
4555
|
className: cn(
|
|
@@ -2095,7 +4583,7 @@ function normalizeItem(item, defaultBulletType) {
|
|
|
2095
4583
|
bulletType: defaultBulletType
|
|
2096
4584
|
};
|
|
2097
4585
|
}
|
|
2098
|
-
if (
|
|
4586
|
+
if (React3__default.default.isValidElement(item)) {
|
|
2099
4587
|
return {
|
|
2100
4588
|
content: item,
|
|
2101
4589
|
bulletType: defaultBulletType
|
|
@@ -2559,8 +5047,8 @@ function Table({
|
|
|
2559
5047
|
}) {
|
|
2560
5048
|
const eui = useEUIConfig();
|
|
2561
5049
|
const resolvedShape = shape ?? eui?.config?.global?.shape ?? "square";
|
|
2562
|
-
const [sortKey, setSortKey] =
|
|
2563
|
-
const [sortOrder, setSortOrder] =
|
|
5050
|
+
const [sortKey, setSortKey] = React3.useState(null);
|
|
5051
|
+
const [sortOrder, setSortOrder] = React3.useState("asc");
|
|
2564
5052
|
const toggleSort = (key) => {
|
|
2565
5053
|
if (sortKey === key) {
|
|
2566
5054
|
setSortOrder((prev) => prev === "asc" ? "desc" : "asc");
|
|
@@ -2569,7 +5057,7 @@ function Table({
|
|
|
2569
5057
|
setSortOrder("asc");
|
|
2570
5058
|
}
|
|
2571
5059
|
};
|
|
2572
|
-
const sortedData =
|
|
5060
|
+
const sortedData = React3.useMemo(() => {
|
|
2573
5061
|
if (!sortKey) return data;
|
|
2574
5062
|
return [...data].sort((a, b) => {
|
|
2575
5063
|
const aVal = a[sortKey];
|
|
@@ -2652,7 +5140,7 @@ function Tag({ text, className, ...rest }) {
|
|
|
2652
5140
|
);
|
|
2653
5141
|
}
|
|
2654
5142
|
var Tag_default = Tag;
|
|
2655
|
-
function
|
|
5143
|
+
function Tooltip9({
|
|
2656
5144
|
children,
|
|
2657
5145
|
show,
|
|
2658
5146
|
offsetX = 20,
|
|
@@ -2660,8 +5148,8 @@ function Tooltip4({
|
|
|
2660
5148
|
className,
|
|
2661
5149
|
...rest
|
|
2662
5150
|
}) {
|
|
2663
|
-
const [pos, setPos] =
|
|
2664
|
-
|
|
5151
|
+
const [pos, setPos] = React3.useState({ x: 0, y: 0 });
|
|
5152
|
+
React3.useEffect(() => {
|
|
2665
5153
|
if (!show) return;
|
|
2666
5154
|
const handleMove = (e) => {
|
|
2667
5155
|
setPos({ x: e.clientX + offsetX, y: e.clientY + offsetY });
|
|
@@ -2790,8 +5278,8 @@ function CloudinaryVideo({
|
|
|
2790
5278
|
}
|
|
2791
5279
|
var CloudinaryVideo_default = CloudinaryVideo;
|
|
2792
5280
|
var FormObserver = ({ formik, onChange }) => {
|
|
2793
|
-
const prevValuesRef =
|
|
2794
|
-
|
|
5281
|
+
const prevValuesRef = React3.useRef(formik.values);
|
|
5282
|
+
React3.useEffect(() => {
|
|
2795
5283
|
if (!onChange) return;
|
|
2796
5284
|
const currentValues = formik.values;
|
|
2797
5285
|
const prevValues = prevValuesRef.current;
|
|
@@ -2810,7 +5298,7 @@ var FormObserver = ({ formik, onChange }) => {
|
|
|
2810
5298
|
};
|
|
2811
5299
|
var FormObserver_default = FormObserver;
|
|
2812
5300
|
var DirtyObserver = ({ formik, onDirtyChange }) => {
|
|
2813
|
-
|
|
5301
|
+
React3.useEffect(() => {
|
|
2814
5302
|
if (onDirtyChange) {
|
|
2815
5303
|
onDirtyChange(formik.dirty);
|
|
2816
5304
|
}
|
|
@@ -2819,7 +5307,7 @@ var DirtyObserver = ({ formik, onDirtyChange }) => {
|
|
|
2819
5307
|
};
|
|
2820
5308
|
var DirtyObserver_default = DirtyObserver;
|
|
2821
5309
|
var UnsavedChangesGuard = ({ formik, enabled }) => {
|
|
2822
|
-
|
|
5310
|
+
React3.useEffect(() => {
|
|
2823
5311
|
if (!enabled) return;
|
|
2824
5312
|
const handleBeforeUnload = (e) => {
|
|
2825
5313
|
if (!formik.dirty) return;
|
|
@@ -2925,7 +5413,7 @@ function TransitionDropdown({ visibility, children }) {
|
|
|
2925
5413
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2926
5414
|
react.Transition,
|
|
2927
5415
|
{
|
|
2928
|
-
as:
|
|
5416
|
+
as: React3.Fragment,
|
|
2929
5417
|
show: visibility,
|
|
2930
5418
|
enter: "transition duration-100 ease-out",
|
|
2931
5419
|
enterFrom: "transform scale-95 opacity-0",
|
|
@@ -2942,7 +5430,7 @@ function TransitionFadeIn({ visibility, children }) {
|
|
|
2942
5430
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2943
5431
|
react.Transition,
|
|
2944
5432
|
{
|
|
2945
|
-
as:
|
|
5433
|
+
as: React3.Fragment,
|
|
2946
5434
|
show: visibility,
|
|
2947
5435
|
enter: `transition-all ease-in-out duration-700 dalay-[0ms]`,
|
|
2948
5436
|
enterFrom: "opacity-0 translate-y-6",
|
|
@@ -3045,17 +5533,17 @@ function YoutubeVideo({
|
|
|
3045
5533
|
) });
|
|
3046
5534
|
}
|
|
3047
5535
|
var YoutubeVideo_default = YoutubeVideo;
|
|
3048
|
-
var ThemeContext =
|
|
5536
|
+
var ThemeContext = React3.createContext(
|
|
3049
5537
|
void 0
|
|
3050
5538
|
);
|
|
3051
5539
|
var ThemeProvider = ({
|
|
3052
5540
|
defaultTheme = "dark",
|
|
3053
5541
|
children
|
|
3054
5542
|
}) => {
|
|
3055
|
-
const [theme, setTheme] =
|
|
5543
|
+
const [theme, setTheme] = React3.useState(() => {
|
|
3056
5544
|
return localStorage.getItem("theme") || defaultTheme;
|
|
3057
5545
|
});
|
|
3058
|
-
|
|
5546
|
+
React3.useEffect(() => {
|
|
3059
5547
|
if (theme === "dark") {
|
|
3060
5548
|
document.documentElement.classList.add("dark");
|
|
3061
5549
|
} else {
|
|
@@ -3069,7 +5557,7 @@ var ThemeProvider = ({
|
|
|
3069
5557
|
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, setTheme, toggleTheme }, children });
|
|
3070
5558
|
};
|
|
3071
5559
|
var ThemeSwitch = () => {
|
|
3072
|
-
const themeContext =
|
|
5560
|
+
const themeContext = React3.useContext(ThemeContext);
|
|
3073
5561
|
if (!themeContext) return null;
|
|
3074
5562
|
const { theme, toggleTheme } = themeContext;
|
|
3075
5563
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3140,7 +5628,7 @@ var ShapeSwitch = () => {
|
|
|
3140
5628
|
|
|
3141
5629
|
// src/hooks/theme/useCurrentTheme.ts
|
|
3142
5630
|
var useCurrentTheme = () => {
|
|
3143
|
-
const context =
|
|
5631
|
+
const context = React3.useContext(ThemeContext);
|
|
3144
5632
|
if (!context) {
|
|
3145
5633
|
throw new Error("useCurrentTheme must be used within a ThemeProvider");
|
|
3146
5634
|
}
|
|
@@ -14483,7 +16971,7 @@ function WorldMap({
|
|
|
14483
16971
|
}
|
|
14484
16972
|
};
|
|
14485
16973
|
const mode = isDarkMode ? mapStyles.dark : mapStyles.light;
|
|
14486
|
-
const resolvedData =
|
|
16974
|
+
const resolvedData = React3.useMemo(() => {
|
|
14487
16975
|
return data.map((item) => {
|
|
14488
16976
|
const c = COUNTRIES.find((x) => x.code === item.code);
|
|
14489
16977
|
if (!c) return null;
|
|
@@ -14495,8 +16983,8 @@ function WorldMap({
|
|
|
14495
16983
|
}).filter(Boolean);
|
|
14496
16984
|
}, [data]);
|
|
14497
16985
|
const maxValue = resolvedData.length > 0 ? Math.max(...resolvedData.map((d) => d.value)) : 0;
|
|
14498
|
-
const [showTooltip, setShowTooltip] =
|
|
14499
|
-
const [tooltipContent, setTooltipContent] =
|
|
16986
|
+
const [showTooltip, setShowTooltip] = React3.useState(false);
|
|
16987
|
+
const [tooltipContent, setTooltipContent] = React3.useState(null);
|
|
14500
16988
|
const handleMouseMove = (_e, point) => {
|
|
14501
16989
|
setTooltipContent(
|
|
14502
16990
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -14554,7 +17042,7 @@ function WorldMap({
|
|
|
14554
17042
|
]
|
|
14555
17043
|
}
|
|
14556
17044
|
) }),
|
|
14557
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17045
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip9, { show: showTooltip, children: tooltipContent })
|
|
14558
17046
|
] });
|
|
14559
17047
|
}
|
|
14560
17048
|
var sizes4 = {
|
|
@@ -14582,7 +17070,7 @@ function Button({
|
|
|
14582
17070
|
}) {
|
|
14583
17071
|
const eui = useEUIConfig();
|
|
14584
17072
|
const resolvedShape = shape ?? eui?.config?.global?.shape ?? "square";
|
|
14585
|
-
const btnRef =
|
|
17073
|
+
const btnRef = React3.useRef(null);
|
|
14586
17074
|
const variantStyles = resolveAppearanceStyles({
|
|
14587
17075
|
appearance,
|
|
14588
17076
|
variant,
|
|
@@ -14683,7 +17171,7 @@ var toggleType = (visibility) => {
|
|
|
14683
17171
|
var PasswordVisibilityToggler = ({
|
|
14684
17172
|
onClick
|
|
14685
17173
|
}) => {
|
|
14686
|
-
const [passwordVisibility, setPasswordVisibilty] =
|
|
17174
|
+
const [passwordVisibility, setPasswordVisibilty] = React3.useState(false);
|
|
14687
17175
|
const handleOnClick = (visibility) => {
|
|
14688
17176
|
onClick(visibility);
|
|
14689
17177
|
setPasswordVisibilty(visibility);
|
|
@@ -14708,7 +17196,7 @@ var Input = ({
|
|
|
14708
17196
|
const eui = useEUIConfig();
|
|
14709
17197
|
const resolvedShape = shape ?? eui?.config?.global?.shape ?? "square";
|
|
14710
17198
|
const [field, meta] = formik.useField(props);
|
|
14711
|
-
const [passwordVisibility, setPasswordVisibilty] =
|
|
17199
|
+
const [passwordVisibility, setPasswordVisibilty] = React3.useState(false);
|
|
14712
17200
|
const inputType = type === "password" ? toggleType(passwordVisibility) : type;
|
|
14713
17201
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
|
|
14714
17202
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -14753,7 +17241,7 @@ var InputFile = ({
|
|
|
14753
17241
|
styles,
|
|
14754
17242
|
...props
|
|
14755
17243
|
}) => {
|
|
14756
|
-
const fileInputRef =
|
|
17244
|
+
const fileInputRef = React3.useRef(null);
|
|
14757
17245
|
const [field, meta, helpers] = formik.useField(props);
|
|
14758
17246
|
const handleFileChange = (e) => {
|
|
14759
17247
|
const file = e.target.files?.[0] || null;
|
|
@@ -15235,7 +17723,7 @@ function ImageView({ imageUrl, secure = true, alt = "image" }) {
|
|
|
15235
17723
|
) }) });
|
|
15236
17724
|
}
|
|
15237
17725
|
var ImageView_default = ImageView;
|
|
15238
|
-
var ImageInput =
|
|
17726
|
+
var ImageInput = React3.forwardRef(
|
|
15239
17727
|
({
|
|
15240
17728
|
title = "Upload Image",
|
|
15241
17729
|
uploadDir = "eg-frontend-admin-temp",
|
|
@@ -15247,10 +17735,10 @@ var ImageInput = React4.forwardRef(
|
|
|
15247
17735
|
const [field, meta, helpers] = formik.useField(props);
|
|
15248
17736
|
const { value: imageUrl } = field;
|
|
15249
17737
|
const { setValue } = helpers;
|
|
15250
|
-
const [image, setImage] =
|
|
15251
|
-
const [url, setUrl] =
|
|
15252
|
-
const [loading, setLoading] =
|
|
15253
|
-
const [preview, setPreview] =
|
|
17738
|
+
const [image, setImage] = React3.useState(null);
|
|
17739
|
+
const [url, setUrl] = React3.useState(imageUrl);
|
|
17740
|
+
const [loading, setLoading] = React3.useState(false);
|
|
17741
|
+
const [preview, setPreview] = React3.useState(null);
|
|
15254
17742
|
const uploadImage = async () => {
|
|
15255
17743
|
if (!image) return;
|
|
15256
17744
|
setLoading(true);
|
|
@@ -15296,10 +17784,10 @@ var ImageInput = React4.forwardRef(
|
|
|
15296
17784
|
if (!disableSetValue) setValue("");
|
|
15297
17785
|
setLoading(false);
|
|
15298
17786
|
};
|
|
15299
|
-
|
|
17787
|
+
React3.useImperativeHandle(ref, () => ({
|
|
15300
17788
|
handleResetClick
|
|
15301
17789
|
}));
|
|
15302
|
-
|
|
17790
|
+
React3.useEffect(() => {
|
|
15303
17791
|
if (!disableSetValue) setValue(url);
|
|
15304
17792
|
}, [url, setValue, disableSetValue]);
|
|
15305
17793
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
@@ -15384,14 +17872,14 @@ function MultiImageInput({
|
|
|
15384
17872
|
const [field, meta, helpers] = formik.useField(props);
|
|
15385
17873
|
const { value: imageUrls } = field;
|
|
15386
17874
|
const { setValue } = helpers;
|
|
15387
|
-
const imageInputRef =
|
|
17875
|
+
const imageInputRef = React3.useRef(null);
|
|
15388
17876
|
const onValueChanged = (url) => {
|
|
15389
17877
|
setValue([...imageUrls, url]);
|
|
15390
17878
|
if (imageInputRef.current) {
|
|
15391
17879
|
imageInputRef.current.handleResetClick();
|
|
15392
17880
|
}
|
|
15393
17881
|
};
|
|
15394
|
-
|
|
17882
|
+
React3.useEffect(() => {
|
|
15395
17883
|
}, [imageUrls]);
|
|
15396
17884
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
15397
17885
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row flex-wrap gap-5 w-ful", children: [
|
|
@@ -15491,9 +17979,9 @@ function StarRatingInput({
|
|
|
15491
17979
|
const { name } = props;
|
|
15492
17980
|
const [field, meta] = formik.useField(props);
|
|
15493
17981
|
const formikContext = formik.useFormikContext();
|
|
15494
|
-
const [rating, setRating] =
|
|
15495
|
-
const [hover, setHover] =
|
|
15496
|
-
|
|
17982
|
+
const [rating, setRating] = React3.useState(Number(field.value) || 0);
|
|
17983
|
+
const [hover, setHover] = React3.useState(null);
|
|
17984
|
+
React3.useEffect(() => {
|
|
15497
17985
|
setRating(Number(field.value));
|
|
15498
17986
|
}, [field.value]);
|
|
15499
17987
|
const handleOnClick = (index) => {
|
|
@@ -15642,7 +18130,7 @@ function Tags({
|
|
|
15642
18130
|
...props
|
|
15643
18131
|
}) {
|
|
15644
18132
|
const [field, meta, helpers] = formik.useField({ ...props });
|
|
15645
|
-
const [input, setInput] =
|
|
18133
|
+
const [input, setInput] = React3.useState("");
|
|
15646
18134
|
const handleAddTag = () => {
|
|
15647
18135
|
const trimmed = input.trim();
|
|
15648
18136
|
if (trimmed && !field.value.includes(trimmed) && field.value.length < limit) {
|
|
@@ -15906,8 +18394,8 @@ var Header = ({
|
|
|
15906
18394
|
);
|
|
15907
18395
|
};
|
|
15908
18396
|
var useIsMobile = (breakpoint = 768) => {
|
|
15909
|
-
const [isMobile, setIsMobile] =
|
|
15910
|
-
|
|
18397
|
+
const [isMobile, setIsMobile] = React3.useState(window.innerWidth < breakpoint);
|
|
18398
|
+
React3.useEffect(() => {
|
|
15911
18399
|
const handleResize = () => {
|
|
15912
18400
|
setIsMobile(window.innerWidth < breakpoint);
|
|
15913
18401
|
};
|
|
@@ -16017,7 +18505,7 @@ function BlockGroup({
|
|
|
16017
18505
|
}
|
|
16018
18506
|
var BlockGroup_default = BlockGroup;
|
|
16019
18507
|
var useTheme = () => {
|
|
16020
|
-
const context =
|
|
18508
|
+
const context = React3.useContext(ThemeContext);
|
|
16021
18509
|
if (!context) {
|
|
16022
18510
|
throw new Error("useTheme must be used within a ThemeProvider");
|
|
16023
18511
|
}
|
|
@@ -16079,11 +18567,11 @@ function MarkdownEditor({
|
|
|
16079
18567
|
] });
|
|
16080
18568
|
}
|
|
16081
18569
|
var MarkdownEditor_default = MarkdownEditor;
|
|
16082
|
-
var MarkdownContext =
|
|
18570
|
+
var MarkdownContext = React3.createContext(null);
|
|
16083
18571
|
|
|
16084
18572
|
// src/components/markdown/hooks/useMarkdown.tsx
|
|
16085
18573
|
function useMarkdown() {
|
|
16086
|
-
return
|
|
18574
|
+
return React3.useContext(MarkdownContext);
|
|
16087
18575
|
}
|
|
16088
18576
|
|
|
16089
18577
|
// src/components/markdown/utils/generateHeadingNumbers.ts
|
|
@@ -16158,7 +18646,7 @@ function MarkdownViewer({ value }) {
|
|
|
16158
18646
|
const markdown = value ?? context?.markdown ?? "";
|
|
16159
18647
|
const headings = context?.headings ?? [];
|
|
16160
18648
|
const setActiveHeading = context?.setActiveHeading;
|
|
16161
|
-
|
|
18649
|
+
React3.useEffect(() => {
|
|
16162
18650
|
const timeout = setTimeout(() => {
|
|
16163
18651
|
headings.forEach((heading) => {
|
|
16164
18652
|
const headingEls = document.querySelectorAll("h1,h2,h3,h4,h5,h6");
|
|
@@ -16263,8 +18751,8 @@ function extractHeadings(markdown) {
|
|
|
16263
18751
|
});
|
|
16264
18752
|
}
|
|
16265
18753
|
function MarkdownProvider({ markdown, children }) {
|
|
16266
|
-
const [activeHeading, setActiveHeading] =
|
|
16267
|
-
const headings =
|
|
18754
|
+
const [activeHeading, setActiveHeading] = React3.useState("");
|
|
18755
|
+
const headings = React3.useMemo(() => extractHeadings(markdown), [markdown]);
|
|
16268
18756
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16269
18757
|
MarkdownContext.Provider,
|
|
16270
18758
|
{
|
|
@@ -16337,7 +18825,7 @@ var Breadcrumb = ({
|
|
|
16337
18825
|
const { config } = useEUIConfig();
|
|
16338
18826
|
const pathname = currentPath || (typeof window !== "undefined" ? window.location.pathname : "/");
|
|
16339
18827
|
const resolvedRoutes = routes || config?.routes || [];
|
|
16340
|
-
const resolvedData =
|
|
18828
|
+
const resolvedData = React3.useMemo(() => {
|
|
16341
18829
|
if (resolvedRoutes && resolvedRoutes.length > 0) {
|
|
16342
18830
|
return buildFromRoutes(resolvedRoutes, pathname);
|
|
16343
18831
|
}
|
|
@@ -16354,7 +18842,7 @@ var Breadcrumb = ({
|
|
|
16354
18842
|
navigate(item.href);
|
|
16355
18843
|
}
|
|
16356
18844
|
};
|
|
16357
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18845
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React3__default.default.Fragment, { children: [
|
|
16358
18846
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16359
18847
|
BreadcrumbItem_default,
|
|
16360
18848
|
{
|
|
@@ -16699,7 +19187,7 @@ function HeaderNav({ data = [], styles }) {
|
|
|
16699
19187
|
}
|
|
16700
19188
|
var HeaderNav_default = HeaderNav;
|
|
16701
19189
|
function useClickOutside(ref, fun) {
|
|
16702
|
-
|
|
19190
|
+
React3.useEffect(() => {
|
|
16703
19191
|
const listener = (e) => {
|
|
16704
19192
|
if (!ref.current || ref.current.contains(e.target)) {
|
|
16705
19193
|
return;
|
|
@@ -16740,8 +19228,8 @@ var HeaderNavGroup = ({
|
|
|
16740
19228
|
styles,
|
|
16741
19229
|
children
|
|
16742
19230
|
}) => {
|
|
16743
|
-
const [collapsed, setCollapsed] =
|
|
16744
|
-
const headerNavGroupRef =
|
|
19231
|
+
const [collapsed, setCollapsed] = React3.useState(true);
|
|
19232
|
+
const headerNavGroupRef = React3.useRef(null);
|
|
16745
19233
|
useClickOutside(headerNavGroupRef, () => setCollapsed(true));
|
|
16746
19234
|
const handleNavigation = () => {
|
|
16747
19235
|
if (to) {
|
|
@@ -16964,8 +19452,8 @@ var MenuGroup = ({
|
|
|
16964
19452
|
style,
|
|
16965
19453
|
...rest
|
|
16966
19454
|
}) => {
|
|
16967
|
-
const [collapsed, setCollapsed] =
|
|
16968
|
-
|
|
19455
|
+
const [collapsed, setCollapsed] = React3.useState(!defaultOpen);
|
|
19456
|
+
React3.useEffect(() => {
|
|
16969
19457
|
if (defaultOpen !== void 0) {
|
|
16970
19458
|
setCollapsed(!defaultOpen);
|
|
16971
19459
|
}
|
|
@@ -17082,12 +19570,12 @@ var Menu = ({
|
|
|
17082
19570
|
defaultMenuElements,
|
|
17083
19571
|
currentPath
|
|
17084
19572
|
}) => {
|
|
17085
|
-
const normalizedItems =
|
|
17086
|
-
const selected =
|
|
19573
|
+
const normalizedItems = React3.useMemo(() => assignKeys(items), [items]);
|
|
19574
|
+
const selected = React3.useMemo(() => {
|
|
17087
19575
|
if (!currentPath) return void 0;
|
|
17088
19576
|
return findSelectedKey(normalizedItems, currentPath);
|
|
17089
19577
|
}, [currentPath, normalizedItems]);
|
|
17090
|
-
const parentMap =
|
|
19578
|
+
const parentMap = React3.useMemo(
|
|
17091
19579
|
() => buildParentMap(normalizedItems),
|
|
17092
19580
|
[normalizedItems]
|
|
17093
19581
|
);
|
|
@@ -17240,8 +19728,8 @@ function RouteTabs({
|
|
|
17240
19728
|
const currentPath = window.location.pathname;
|
|
17241
19729
|
return navData.find((tab) => tab.to === currentPath)?.to || navData[0]?.to;
|
|
17242
19730
|
};
|
|
17243
|
-
const [activeTab, setActiveTab] =
|
|
17244
|
-
|
|
19731
|
+
const [activeTab, setActiveTab] = React3.useState(getActiveTab);
|
|
19732
|
+
React3.useEffect(() => {
|
|
17245
19733
|
if (mode !== "route") return;
|
|
17246
19734
|
const handlePopState = () => {
|
|
17247
19735
|
setActiveTab(getActiveTab());
|
|
@@ -17338,7 +19826,7 @@ function Modal({
|
|
|
17338
19826
|
}) {
|
|
17339
19827
|
const eui = useEUIConfig();
|
|
17340
19828
|
const resolvedShape = shape ?? eui?.config?.global?.shape ?? "square";
|
|
17341
|
-
const modalRef =
|
|
19829
|
+
const modalRef = React3.useRef(null);
|
|
17342
19830
|
useClickOutside(
|
|
17343
19831
|
modalRef,
|
|
17344
19832
|
enableCloseOnClickOutside ? handleOnClose : void 0
|
|
@@ -17353,7 +19841,7 @@ function Modal({
|
|
|
17353
19841
|
leave: "transition duration-100 ease-out",
|
|
17354
19842
|
leaveFrom: "transform scale-200 opacity-100",
|
|
17355
19843
|
leaveTo: "transform scale-95 opacity-0",
|
|
17356
|
-
as:
|
|
19844
|
+
as: React3.Fragment,
|
|
17357
19845
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-eui-dark-900/90 top-0 bottom-0 left-0 right-0 z-50 fixed inset-0 flex items-center justify-center overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17358
19846
|
"div",
|
|
17359
19847
|
{
|
|
@@ -17407,8 +19895,8 @@ var GlowWrapper = ({
|
|
|
17407
19895
|
className = "",
|
|
17408
19896
|
hideOnLeave = true
|
|
17409
19897
|
}) => {
|
|
17410
|
-
const ref =
|
|
17411
|
-
const handleMove =
|
|
19898
|
+
const ref = React3.useRef(null);
|
|
19899
|
+
const handleMove = React3.useCallback(
|
|
17412
19900
|
(e) => {
|
|
17413
19901
|
const el = ref.current;
|
|
17414
19902
|
if (!el) return;
|
|
@@ -17430,7 +19918,7 @@ var GlowWrapper = ({
|
|
|
17430
19918
|
},
|
|
17431
19919
|
[glowSize, glowColor]
|
|
17432
19920
|
);
|
|
17433
|
-
const handleLeave =
|
|
19921
|
+
const handleLeave = React3.useCallback(() => {
|
|
17434
19922
|
const el = ref.current;
|
|
17435
19923
|
if (!el || !hideOnLeave) return;
|
|
17436
19924
|
el.style.setProperty("--glow-x", `-999px`);
|
|
@@ -17475,8 +19963,8 @@ function InfiniteScrollTrigger({
|
|
|
17475
19963
|
threshold = 0,
|
|
17476
19964
|
onLoadMore
|
|
17477
19965
|
}) {
|
|
17478
|
-
const triggerRef =
|
|
17479
|
-
|
|
19966
|
+
const triggerRef = React3.useRef(null);
|
|
19967
|
+
React3.useEffect(() => {
|
|
17480
19968
|
const element = triggerRef.current;
|
|
17481
19969
|
if (!element || !hasMore || isLoading) {
|
|
17482
19970
|
return;
|
|
@@ -17502,7 +19990,7 @@ function InfiniteScrollTrigger({
|
|
|
17502
19990
|
}
|
|
17503
19991
|
var InfiniteScrollTrigger_default = InfiniteScrollTrigger;
|
|
17504
19992
|
function ShowMore({ text, limit }) {
|
|
17505
|
-
const [showMore, setShowMore] =
|
|
19993
|
+
const [showMore, setShowMore] = React3.useState(false);
|
|
17506
19994
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
17507
19995
|
showMore ? text : `${text.substring(0, limit)}`,
|
|
17508
19996
|
text.length > limit && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
@@ -17530,8 +20018,8 @@ function CommentComposer({
|
|
|
17530
20018
|
loading,
|
|
17531
20019
|
onSubmit
|
|
17532
20020
|
}) {
|
|
17533
|
-
const [value, setValue] =
|
|
17534
|
-
const [focused, setFocused] =
|
|
20021
|
+
const [value, setValue] = React3.useState("");
|
|
20022
|
+
const [focused, setFocused] = React3.useState(false);
|
|
17535
20023
|
async function handleSubmit() {
|
|
17536
20024
|
const content = value.trim();
|
|
17537
20025
|
if (!content) {
|
|
@@ -17786,7 +20274,7 @@ function CommentHeader({ comment, config }) {
|
|
|
17786
20274
|
}
|
|
17787
20275
|
var CommentHeader_default = CommentHeader;
|
|
17788
20276
|
var useDrawer = (defaultVisibility = true) => {
|
|
17789
|
-
const [show, setShow] =
|
|
20277
|
+
const [show, setShow] = React3.useState(defaultVisibility);
|
|
17790
20278
|
const openDrawer = () => {
|
|
17791
20279
|
setShow((prev) => !prev);
|
|
17792
20280
|
};
|
|
@@ -17801,7 +20289,7 @@ var useDrawer = (defaultVisibility = true) => {
|
|
|
17801
20289
|
};
|
|
17802
20290
|
var useDrawer_default = useDrawer;
|
|
17803
20291
|
var useModal = () => {
|
|
17804
|
-
const [show, setShow] =
|
|
20292
|
+
const [show, setShow] = React3.useState(false);
|
|
17805
20293
|
const handleOpenModal = () => {
|
|
17806
20294
|
setShow(true);
|
|
17807
20295
|
};
|
|
@@ -17849,7 +20337,7 @@ function CommentMenu({
|
|
|
17849
20337
|
onDelete,
|
|
17850
20338
|
onReport
|
|
17851
20339
|
}) {
|
|
17852
|
-
const ref =
|
|
20340
|
+
const ref = React3.useRef(null);
|
|
17853
20341
|
useClickOutside(ref, () => setOpen(false));
|
|
17854
20342
|
const items = [];
|
|
17855
20343
|
if (canEdit) {
|
|
@@ -17977,11 +20465,11 @@ function CommentItem({
|
|
|
17977
20465
|
onDelete,
|
|
17978
20466
|
onReport
|
|
17979
20467
|
}) {
|
|
17980
|
-
const [collapsed, setCollapsed] =
|
|
17981
|
-
const [isReplying, setIsReplying] =
|
|
17982
|
-
const [menuOpen, setMenuOpen] =
|
|
17983
|
-
const [loadingReplies, setLoadingReplies] =
|
|
17984
|
-
const [repliesLoaded, setRepliesLoaded] =
|
|
20468
|
+
const [collapsed, setCollapsed] = React3.useState(true);
|
|
20469
|
+
const [isReplying, setIsReplying] = React3.useState(false);
|
|
20470
|
+
const [menuOpen, setMenuOpen] = React3.useState(false);
|
|
20471
|
+
const [loadingReplies, setLoadingReplies] = React3.useState(false);
|
|
20472
|
+
const [repliesLoaded, setRepliesLoaded] = React3.useState(false);
|
|
17985
20473
|
const resolvedDepth = Math.min(depth, config.maxDepth);
|
|
17986
20474
|
const {
|
|
17987
20475
|
Header: HeaderComponent = CommentHeader_default,
|
|
@@ -18145,18 +20633,18 @@ function CommentThread({
|
|
|
18145
20633
|
onDelete,
|
|
18146
20634
|
onReport
|
|
18147
20635
|
}) {
|
|
18148
|
-
const [comments, setComments] =
|
|
18149
|
-
const [isLoadingComments, setIsLoadingComments] =
|
|
18150
|
-
const [replyCache, setReplyCache] =
|
|
20636
|
+
const [comments, setComments] = React3.useState([]);
|
|
20637
|
+
const [isLoadingComments, setIsLoadingComments] = React3.useState(true);
|
|
20638
|
+
const [replyCache, setReplyCache] = React3.useState(
|
|
18151
20639
|
{}
|
|
18152
20640
|
);
|
|
18153
|
-
const replyCacheRef =
|
|
20641
|
+
const replyCacheRef = React3.useRef(replyCache);
|
|
18154
20642
|
const ComposerComponent = components?.Composer ?? CommentComposer_default;
|
|
18155
20643
|
const resolvedConfig = {
|
|
18156
20644
|
...DEFAULT_COMMENT_THREAD_CONFIG,
|
|
18157
20645
|
...config
|
|
18158
20646
|
};
|
|
18159
|
-
|
|
20647
|
+
React3.useEffect(() => {
|
|
18160
20648
|
async function loadComments() {
|
|
18161
20649
|
try {
|
|
18162
20650
|
const result = await dataSource.getComments({
|
|
@@ -18170,10 +20658,10 @@ function CommentThread({
|
|
|
18170
20658
|
}
|
|
18171
20659
|
void loadComments();
|
|
18172
20660
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
18173
|
-
|
|
20661
|
+
React3.useEffect(() => {
|
|
18174
20662
|
replyCacheRef.current = replyCache;
|
|
18175
20663
|
}, [replyCache]);
|
|
18176
|
-
|
|
20664
|
+
React3.useEffect(() => {
|
|
18177
20665
|
let cancelled = false;
|
|
18178
20666
|
async function refreshLoadedReplies() {
|
|
18179
20667
|
const parentIds = Object.keys(replyCacheRef.current);
|
|
@@ -18209,13 +20697,13 @@ function CommentThread({
|
|
|
18209
20697
|
cancelled = true;
|
|
18210
20698
|
};
|
|
18211
20699
|
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18212
|
-
|
|
20700
|
+
React3.useEffect(() => {
|
|
18213
20701
|
if (!updatedComment) {
|
|
18214
20702
|
return;
|
|
18215
20703
|
}
|
|
18216
20704
|
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18217
20705
|
}, [updatedComment]);
|
|
18218
|
-
|
|
20706
|
+
React3.useEffect(() => {
|
|
18219
20707
|
if (!deletedComment) {
|
|
18220
20708
|
return;
|
|
18221
20709
|
}
|
|
@@ -18429,13 +20917,13 @@ function SliderItem({
|
|
|
18429
20917
|
}
|
|
18430
20918
|
var SliderItem_default = SliderItem;
|
|
18431
20919
|
function Slider({ isLoading, isSuccess, coverArt, screenshots }) {
|
|
18432
|
-
const [images, setImages] =
|
|
20920
|
+
const [images, setImages] = React3.useState([
|
|
18433
20921
|
{
|
|
18434
20922
|
img: coverArt,
|
|
18435
20923
|
selected: true
|
|
18436
20924
|
}
|
|
18437
20925
|
]);
|
|
18438
|
-
|
|
20926
|
+
React3.useEffect(() => {
|
|
18439
20927
|
setImages([
|
|
18440
20928
|
{
|
|
18441
20929
|
img: coverArt,
|
|
@@ -18443,7 +20931,7 @@ function Slider({ isLoading, isSuccess, coverArt, screenshots }) {
|
|
|
18443
20931
|
}
|
|
18444
20932
|
]);
|
|
18445
20933
|
}, [isSuccess]);
|
|
18446
|
-
|
|
20934
|
+
React3.useEffect(() => {
|
|
18447
20935
|
if (screenshots) {
|
|
18448
20936
|
const selectableScreenshots = [];
|
|
18449
20937
|
screenshots.forEach((item) => {
|
|
@@ -18455,8 +20943,8 @@ function Slider({ isLoading, isSuccess, coverArt, screenshots }) {
|
|
|
18455
20943
|
setImages((prev) => [...prev, ...selectableScreenshots]);
|
|
18456
20944
|
}
|
|
18457
20945
|
}, [isSuccess]);
|
|
18458
|
-
const [displayImg, setDisplayImg] =
|
|
18459
|
-
|
|
20946
|
+
const [displayImg, setDisplayImg] = React3.useState(coverArt);
|
|
20947
|
+
React3.useEffect(() => {
|
|
18460
20948
|
setDisplayImg(coverArt);
|
|
18461
20949
|
}, [coverArt]);
|
|
18462
20950
|
const displayImageHandler = (itemIndex, img) => {
|
|
@@ -18568,7 +21056,7 @@ function WorldMapCountryTable({
|
|
|
18568
21056
|
title = "Country Breakdown",
|
|
18569
21057
|
data
|
|
18570
21058
|
}) {
|
|
18571
|
-
const enrichedData =
|
|
21059
|
+
const enrichedData = React3.useMemo(() => {
|
|
18572
21060
|
const mapped = data.map((item) => {
|
|
18573
21061
|
const countryMeta = COUNTRIES.find((c) => c.code === item.code);
|
|
18574
21062
|
return {
|
|
@@ -18581,11 +21069,11 @@ function WorldMapCountryTable({
|
|
|
18581
21069
|
});
|
|
18582
21070
|
return mapped.sort((a, b) => b.value - a.value);
|
|
18583
21071
|
}, [data]);
|
|
18584
|
-
const total =
|
|
21072
|
+
const total = React3.useMemo(
|
|
18585
21073
|
() => enrichedData.reduce((sum, i) => sum + i.value, 0),
|
|
18586
21074
|
[enrichedData]
|
|
18587
21075
|
);
|
|
18588
|
-
const finalData =
|
|
21076
|
+
const finalData = React3.useMemo(() => {
|
|
18589
21077
|
return enrichedData.map((item) => ({
|
|
18590
21078
|
...item,
|
|
18591
21079
|
percent: total > 0 ? item.value / total * 100 : 0
|
|
@@ -18830,7 +21318,7 @@ var TNDropdownGroup = ({
|
|
|
18830
21318
|
navigate,
|
|
18831
21319
|
className
|
|
18832
21320
|
}) => {
|
|
18833
|
-
const [open, setOpen] =
|
|
21321
|
+
const [open, setOpen] = React3.useState(true);
|
|
18834
21322
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
18835
21323
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
18836
21324
|
"div",
|
|
@@ -18919,8 +21407,8 @@ var TNGroup = ({
|
|
|
18919
21407
|
components,
|
|
18920
21408
|
selected
|
|
18921
21409
|
}) => {
|
|
18922
|
-
const [open, setOpen] =
|
|
18923
|
-
const timeoutRef =
|
|
21410
|
+
const [open, setOpen] = React3.useState(false);
|
|
21411
|
+
const timeoutRef = React3.useRef(null);
|
|
18924
21412
|
const handleEnter = () => {
|
|
18925
21413
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
18926
21414
|
setOpen(true);
|
|
@@ -19057,7 +21545,7 @@ function SidebarLayout({
|
|
|
19057
21545
|
header = /* @__PURE__ */ jsxRuntime.jsx(Header, {}),
|
|
19058
21546
|
footer = /* @__PURE__ */ jsxRuntime.jsx(Footer, {})
|
|
19059
21547
|
}) {
|
|
19060
|
-
const [showSidebar, setShowSidebar] =
|
|
21548
|
+
const [showSidebar, setShowSidebar] = React3.useState(true);
|
|
19061
21549
|
return /* @__PURE__ */ jsxRuntime.jsx(GenericLayout_default, { children: /* @__PURE__ */ jsxRuntime.jsx(Layout, { children: /* @__PURE__ */ jsxRuntime.jsx(Layout, { flexDirection: "horizontal", children: /* @__PURE__ */ jsxRuntime.jsxs(Content, { sidebarVisible: showSidebar, styles: "theme-bg-md pt-[60px]", children: [
|
|
19062
21550
|
/* @__PURE__ */ jsxRuntime.jsx(ContentArea_default, { children }),
|
|
19063
21551
|
footer
|
|
@@ -19111,7 +21599,7 @@ function ScrollToTop({
|
|
|
19111
21599
|
behavior = "smooth",
|
|
19112
21600
|
target
|
|
19113
21601
|
}) {
|
|
19114
|
-
|
|
21602
|
+
React3.useEffect(() => {
|
|
19115
21603
|
if (target) {
|
|
19116
21604
|
target.scrollTo({
|
|
19117
21605
|
top: 0,
|
|
@@ -19129,11 +21617,14 @@ function ScrollToTop({
|
|
|
19129
21617
|
var ScrollToTop_default = ScrollToTop;
|
|
19130
21618
|
|
|
19131
21619
|
exports.Accordion = Accordion_default;
|
|
21620
|
+
exports.AreaGraph = AreaGraph;
|
|
19132
21621
|
exports.AsyncComponentWrapper = AsyncComponentWrapper_default;
|
|
19133
21622
|
exports.Avatar = Avatar;
|
|
19134
21623
|
exports.Backdrop = Backdrop_default;
|
|
19135
21624
|
exports.Badge = Badge;
|
|
19136
21625
|
exports.BarChart = BarChart_default;
|
|
21626
|
+
exports.BarGraph = BarGraph;
|
|
21627
|
+
exports.BaseGraphDataSource = BaseGraphDataSource;
|
|
19137
21628
|
exports.Block = Block_default;
|
|
19138
21629
|
exports.BlockGroup = BlockGroup_default;
|
|
19139
21630
|
exports.BoxNav = BoxNav_default;
|
|
@@ -19155,8 +21646,11 @@ exports.CloudinaryProvider = CloudinaryProvider;
|
|
|
19155
21646
|
exports.CloudinaryVideo = CloudinaryVideo_default;
|
|
19156
21647
|
exports.Code = Code;
|
|
19157
21648
|
exports.CommentThread = CommentThread_default;
|
|
21649
|
+
exports.Configurator = Configurator;
|
|
21650
|
+
exports.ConfiguratorError = ConfiguratorError;
|
|
19158
21651
|
exports.Content = Content;
|
|
19159
21652
|
exports.ContentArea = ContentArea_default;
|
|
21653
|
+
exports.DEFAULT_GRAPH_THEME = DEFAULT_GRAPH_THEME;
|
|
19160
21654
|
exports.DataView = DataView;
|
|
19161
21655
|
exports.DataViewTable = DataViewTable_default;
|
|
19162
21656
|
exports.DateSelector = DateSelector_default;
|
|
@@ -19179,12 +21673,40 @@ exports.FooterNavItemContext = FooterNavItemContext;
|
|
|
19179
21673
|
exports.FooterNavItemTitle = FooterNavItemTitle;
|
|
19180
21674
|
exports.Form = Form;
|
|
19181
21675
|
exports.FormResponse = FormResponse_default;
|
|
21676
|
+
exports.GRAPH_COLOR_PALETTE = GRAPH_COLOR_PALETTE;
|
|
21677
|
+
exports.GRAPH_DARK_THEME = GRAPH_DARK_THEME;
|
|
21678
|
+
exports.GRAPH_DATA_MODES = GRAPH_DATA_MODES;
|
|
21679
|
+
exports.GRAPH_DEFAULT_ACTIVE_DOT_RADIUS = GRAPH_DEFAULT_ACTIVE_DOT_RADIUS;
|
|
21680
|
+
exports.GRAPH_DEFAULT_ANIMATION_DURATION = GRAPH_DEFAULT_ANIMATION_DURATION;
|
|
21681
|
+
exports.GRAPH_DEFAULT_BAR_RADIUS = GRAPH_DEFAULT_BAR_RADIUS;
|
|
21682
|
+
exports.GRAPH_DEFAULT_DOT_RADIUS = GRAPH_DEFAULT_DOT_RADIUS;
|
|
21683
|
+
exports.GRAPH_DEFAULT_HEIGHT = GRAPH_DEFAULT_HEIGHT;
|
|
21684
|
+
exports.GRAPH_DEFAULT_MARGIN = GRAPH_DEFAULT_MARGIN;
|
|
21685
|
+
exports.GRAPH_DEFAULT_MAX_REALTIME_POINTS = GRAPH_DEFAULT_MAX_REALTIME_POINTS;
|
|
21686
|
+
exports.GRAPH_DEFAULT_POLLING_INTERVAL = GRAPH_DEFAULT_POLLING_INTERVAL;
|
|
21687
|
+
exports.GRAPH_DEFAULT_STROKE_WIDTH = GRAPH_DEFAULT_STROKE_WIDTH;
|
|
21688
|
+
exports.GRAPH_EMPTY_MESSAGE = GRAPH_EMPTY_MESSAGE;
|
|
21689
|
+
exports.GRAPH_ERROR_MESSAGE = GRAPH_ERROR_MESSAGE;
|
|
21690
|
+
exports.GRAPH_LIGHT_THEME = GRAPH_LIGHT_THEME;
|
|
21691
|
+
exports.GRAPH_LOADING_MESSAGE = GRAPH_LOADING_MESSAGE;
|
|
21692
|
+
exports.GRAPH_STATUSES = GRAPH_STATUSES;
|
|
21693
|
+
exports.GRAPH_STATUS_COLORS = GRAPH_STATUS_COLORS;
|
|
21694
|
+
exports.GRAPH_VALUE_FORMATS = GRAPH_VALUE_FORMATS;
|
|
21695
|
+
exports.GaugeGraph = GaugeGraph;
|
|
19182
21696
|
exports.GenericLayout = GenericLayout_default;
|
|
19183
21697
|
exports.GlowWrapper = GlowWrapper_default;
|
|
19184
21698
|
exports.Graph = Graph;
|
|
19185
|
-
exports.
|
|
19186
|
-
exports.
|
|
19187
|
-
exports.
|
|
21699
|
+
exports.GraphContainer = GraphContainer;
|
|
21700
|
+
exports.GraphContext = GraphContext;
|
|
21701
|
+
exports.GraphEmptyState = GraphEmptyState;
|
|
21702
|
+
exports.GraphErrorState = GraphErrorState;
|
|
21703
|
+
exports.GraphHeader = GraphHeader;
|
|
21704
|
+
exports.GraphLegend = GraphLegend;
|
|
21705
|
+
exports.GraphLoadingState = GraphLoadingState;
|
|
21706
|
+
exports.GraphPanel = GraphPanel;
|
|
21707
|
+
exports.GraphProvider = GraphProvider;
|
|
21708
|
+
exports.GraphToolbar = GraphToolbar;
|
|
21709
|
+
exports.GraphTooltip = GraphTooltip;
|
|
19188
21710
|
exports.Grid = Grid_default;
|
|
19189
21711
|
exports.Header = Header;
|
|
19190
21712
|
exports.HeaderNav = HeaderNav_default;
|
|
@@ -19207,6 +21729,7 @@ exports.Label = Label;
|
|
|
19207
21729
|
exports.Layout = Layout;
|
|
19208
21730
|
exports.Lead = Lead;
|
|
19209
21731
|
exports.LineChart = LineChart_default;
|
|
21732
|
+
exports.LineGraph = LineGraph;
|
|
19210
21733
|
exports.Link = Link;
|
|
19211
21734
|
exports.List = List_default;
|
|
19212
21735
|
exports.ListItem = ListItem_default;
|
|
@@ -19225,13 +21748,17 @@ exports.NumericRating = NumericRating_default;
|
|
|
19225
21748
|
exports.Overline = Overline;
|
|
19226
21749
|
exports.Paragraph = Paragraph;
|
|
19227
21750
|
exports.PieChart = PieChart_default;
|
|
21751
|
+
exports.PieGraph = PieGraph;
|
|
21752
|
+
exports.PollingGraphDataSource = PollingGraphDataSource;
|
|
19228
21753
|
exports.PriceTag = PriceTag;
|
|
19229
21754
|
exports.ProgressBar = ProgressBar;
|
|
19230
21755
|
exports.ProgressBarRating = ProgressBarRating_default;
|
|
19231
21756
|
exports.Quote = Quote;
|
|
19232
21757
|
exports.Radio = Radio_default;
|
|
21758
|
+
exports.RealtimeGraphDataSource = RealtimeGraphDataSource;
|
|
19233
21759
|
exports.RouteTab = RouteTab_default;
|
|
19234
21760
|
exports.RouteTabs = RouteTabs_default;
|
|
21761
|
+
exports.ScatterGraph = ScatterGraph;
|
|
19235
21762
|
exports.ScrollToTop = ScrollToTop_default;
|
|
19236
21763
|
exports.Section = Section;
|
|
19237
21764
|
exports.Select = Select_default;
|
|
@@ -19245,6 +21772,8 @@ exports.Slider = Slider_default;
|
|
|
19245
21772
|
exports.StarRating = StarRating_default;
|
|
19246
21773
|
exports.StarRatingDistribution = StarRatingDistribution_default;
|
|
19247
21774
|
exports.StarRatingInput = StarRatingInput_default;
|
|
21775
|
+
exports.StatGraph = StatGraph;
|
|
21776
|
+
exports.StaticGraphDataSource = StaticGraphDataSource;
|
|
19248
21777
|
exports.Switch = Switch_default;
|
|
19249
21778
|
exports.TNDropdown = TNDropdown;
|
|
19250
21779
|
exports.TNDropdownItem = TNDropdownItem;
|
|
@@ -19259,7 +21788,7 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
19259
21788
|
exports.ThemeSwitch = ThemeSwitch;
|
|
19260
21789
|
exports.TitleBanner = TitleBanner;
|
|
19261
21790
|
exports.Toast = Toast;
|
|
19262
|
-
exports.Tooltip =
|
|
21791
|
+
exports.Tooltip = Tooltip9;
|
|
19263
21792
|
exports.TopNav = TopNav;
|
|
19264
21793
|
exports.Transition = Transition4;
|
|
19265
21794
|
exports.TransitionDropdown = TransitionDropdown_default;
|
|
@@ -19272,27 +21801,45 @@ exports.WorldMapCountryTable = WorldMapCountryTable;
|
|
|
19272
21801
|
exports.YoutubeVideoPlayer = YoutubeVideo_default;
|
|
19273
21802
|
exports.addReplyToCache = addReplyToCache;
|
|
19274
21803
|
exports.applyReactionState = applyReactionState;
|
|
21804
|
+
exports.assertAbsoluteURL = assertAbsoluteURL;
|
|
21805
|
+
exports.buildURL = buildURL;
|
|
19275
21806
|
exports.cn = cn;
|
|
19276
|
-
exports.
|
|
19277
|
-
exports.
|
|
19278
|
-
exports.
|
|
21807
|
+
exports.createConfigurator = createConfigurator;
|
|
21808
|
+
exports.createInitialGraphState = createInitialGraphState;
|
|
21809
|
+
exports.createURLResolver = createURLResolver;
|
|
19279
21810
|
exports.decrementReplyCount = decrementReplyCount;
|
|
19280
21811
|
exports.enumValues = enumValues;
|
|
19281
21812
|
exports.formatCommentDate = formatCommentDate;
|
|
21813
|
+
exports.formatConfigError = formatConfigError;
|
|
21814
|
+
exports.formatGraphValue = formatGraphValue;
|
|
21815
|
+
exports.getAllowedOrigins = getAllowedOrigins;
|
|
21816
|
+
exports.getBrowserHref = getBrowserHref;
|
|
21817
|
+
exports.getBrowserOrigin = getBrowserOrigin;
|
|
21818
|
+
exports.getBrowserRedirectURL = getBrowserRedirectURL;
|
|
19282
21819
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
19283
|
-
exports.getLayout = getLayout;
|
|
19284
21820
|
exports.getOptimisticDislikeState = getOptimisticDislikeState;
|
|
19285
21821
|
exports.getOptimisticLikeState = getOptimisticLikeState;
|
|
21822
|
+
exports.getSafeRedirect = getSafeRedirect;
|
|
21823
|
+
exports.graphReducer = graphReducer;
|
|
19286
21824
|
exports.incrementReplyCount = incrementReplyCount;
|
|
19287
21825
|
exports.isMatch = isMatch;
|
|
19288
21826
|
exports.isRenderFn = isRenderFn;
|
|
21827
|
+
exports.limitRealtimePoints = limitRealtimePoints;
|
|
19289
21828
|
exports.normalize = normalize;
|
|
19290
|
-
exports.
|
|
21829
|
+
exports.normalizeGraphData = normalizeGraphData;
|
|
21830
|
+
exports.normalizeGraphDataPoint = normalizeGraphDataPoint;
|
|
21831
|
+
exports.parseJson = parseJson;
|
|
21832
|
+
exports.parseJsonRecord = parseJsonRecord;
|
|
21833
|
+
exports.parseUrlMap = parseUrlMap;
|
|
19291
21834
|
exports.removeComment = removeComment;
|
|
19292
21835
|
exports.removeCommentTreeFromCache = removeCommentTreeFromCache;
|
|
21836
|
+
exports.replaceRealtimePoints = replaceRealtimePoints;
|
|
19293
21837
|
exports.resolveAppearanceStyles = resolveAppearanceStyles;
|
|
21838
|
+
exports.resolveGraphColor = resolveGraphColor;
|
|
21839
|
+
exports.resolveGraphColors = resolveGraphColors;
|
|
19294
21840
|
exports.resolveWithGlobal = resolveWithGlobal;
|
|
19295
21841
|
exports.sendToast = sendToast;
|
|
21842
|
+
exports.toConfiguratorError = toConfiguratorError;
|
|
19296
21843
|
exports.updateComment = updateComment;
|
|
19297
21844
|
exports.updateReplyCacheComment = updateReplyCacheComment;
|
|
19298
21845
|
exports.useClickOutside = useClickOutside;
|
|
@@ -19300,6 +21847,12 @@ exports.useCloudinaryConfig = useCloudinaryConfig;
|
|
|
19300
21847
|
exports.useCurrentTheme = useCurrentTheme_default;
|
|
19301
21848
|
exports.useDrawer = useDrawer_default;
|
|
19302
21849
|
exports.useEUIConfig = useEUIConfig;
|
|
21850
|
+
exports.useGraphContext = useGraphContext;
|
|
21851
|
+
exports.useGraphData = useGraphData;
|
|
21852
|
+
exports.useGraphPolling = useGraphPolling;
|
|
21853
|
+
exports.useGraphRealtime = useGraphRealtime;
|
|
21854
|
+
exports.useGraphSeries = useGraphSeries;
|
|
21855
|
+
exports.useGraphTheme = useGraphTheme;
|
|
19303
21856
|
exports.useIsMobile = useIsMobile_default;
|
|
19304
21857
|
exports.useModal = useModal_default;
|
|
19305
21858
|
exports.useTheme = useTheme_default;
|