@agg-market/ui 0.0.1
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/badge.d.mts +26 -0
- package/dist/badge.d.ts +26 -0
- package/dist/badge.js +70 -0
- package/dist/badge.mjs +9 -0
- package/dist/button.d.mts +20 -0
- package/dist/button.d.ts +20 -0
- package/dist/button.js +197 -0
- package/dist/button.mjs +8 -0
- package/dist/card.d.mts +8 -0
- package/dist/card.d.ts +8 -0
- package/dist/card.js +84 -0
- package/dist/card.mjs +7 -0
- package/dist/chart.d.mts +40 -0
- package/dist/chart.d.ts +40 -0
- package/dist/chart.js +418 -0
- package/dist/chart.mjs +8 -0
- package/dist/chunk-2PGUPOXY.mjs +285 -0
- package/dist/chunk-3DV3D2LH.mjs +155 -0
- package/dist/chunk-44UEI6KD.mjs +280 -0
- package/dist/chunk-4ADCXJE6.mjs +297 -0
- package/dist/chunk-4GSXVVSA.mjs +64 -0
- package/dist/chunk-4NK2FNAG.mjs +581 -0
- package/dist/chunk-4XWCYUV3.mjs +355 -0
- package/dist/chunk-5MN6ZNFA.mjs +355 -0
- package/dist/chunk-6RRBINER.mjs +50 -0
- package/dist/chunk-765JPQDG.mjs +280 -0
- package/dist/chunk-7CD7GIZC.mjs +850 -0
- package/dist/chunk-7XRKA6XF.mjs +462 -0
- package/dist/chunk-AOFP74IB.mjs +850 -0
- package/dist/chunk-BNDFQPHF.mjs +9 -0
- package/dist/chunk-C4OI72SM.mjs +14 -0
- package/dist/chunk-CB2MLGCJ.mjs +279 -0
- package/dist/chunk-CKTAVEW2.mjs +212 -0
- package/dist/chunk-DA6KZWSK.mjs +807 -0
- package/dist/chunk-DBD5GHHD.mjs +147 -0
- package/dist/chunk-DQ6XFBYJ.mjs +37 -0
- package/dist/chunk-FACIYUNK.mjs +217 -0
- package/dist/chunk-FUJQIYOF.mjs +37 -0
- package/dist/chunk-FZTAHWOS.mjs +82 -0
- package/dist/chunk-GC3QIIH7.mjs +112 -0
- package/dist/chunk-GPBLZGJ2.mjs +136 -0
- package/dist/chunk-H4LELROL.mjs +262 -0
- package/dist/chunk-H7P6DIX4.mjs +262 -0
- package/dist/chunk-H7YEBGYY.mjs +42 -0
- package/dist/chunk-HJOBAMDU.mjs +142 -0
- package/dist/chunk-IJG5I642.mjs +462 -0
- package/dist/chunk-IY2AA3OL.mjs +50 -0
- package/dist/chunk-J6L5BLKX.mjs +136 -0
- package/dist/chunk-J7OETCZ7.mjs +147 -0
- package/dist/chunk-JLLMIPIX.mjs +42 -0
- package/dist/chunk-KBRLFTJT.mjs +741 -0
- package/dist/chunk-KDBYDMYV.mjs +64 -0
- package/dist/chunk-L6E6Q4C4.mjs +217 -0
- package/dist/chunk-LY6474C4.mjs +297 -0
- package/dist/chunk-M23S2DVV.mjs +581 -0
- package/dist/chunk-MG243DSX.mjs +44 -0
- package/dist/chunk-MRHSN2B7.mjs +279 -0
- package/dist/chunk-MXWRCVRJ.mjs +285 -0
- package/dist/chunk-NFYS557L.mjs +481 -0
- package/dist/chunk-NNSY462N.mjs +212 -0
- package/dist/chunk-OUOIDPGX.mjs +25 -0
- package/dist/chunk-P5PFQX75.mjs +31 -0
- package/dist/chunk-P674XRDY.mjs +481 -0
- package/dist/chunk-PAQ542ER.mjs +170 -0
- package/dist/chunk-QE46DVJG.mjs +323 -0
- package/dist/chunk-QXFDXXDB.mjs +792 -0
- package/dist/chunk-R3DRVI4J.mjs +741 -0
- package/dist/chunk-TTOR7JCT.mjs +155 -0
- package/dist/chunk-V5WIYMKS.mjs +25 -0
- package/dist/chunk-VAZE267Q.mjs +82 -0
- package/dist/chunk-VLIJ7PQK.mjs +792 -0
- package/dist/chunk-VYNVBJK6.mjs +44 -0
- package/dist/chunk-WIWJ6DIE.mjs +323 -0
- package/dist/chunk-XDAEEJYR.mjs +142 -0
- package/dist/chunk-YUIZZ6XE.mjs +31 -0
- package/dist/connect-button.d.mts +40 -0
- package/dist/connect-button.d.ts +40 -0
- package/dist/connect-button.js +1815 -0
- package/dist/connect-button.mjs +14 -0
- package/dist/event-list-item-details.d.mts +11 -0
- package/dist/event-list-item-details.d.ts +11 -0
- package/dist/event-list-item-details.js +2140 -0
- package/dist/event-list-item-details.mjs +19 -0
- package/dist/event-list-item-details.types-CMbXOrT-.d.ts +53 -0
- package/dist/event-list-item-details.types-CxWr4Qn1.d.ts +53 -0
- package/dist/event-list-item-details.types-DRi99PZq.d.mts +53 -0
- package/dist/event-list-item-details.types-DekJKeMD.d.mts +53 -0
- package/dist/event-list-item.d.mts +10 -0
- package/dist/event-list-item.d.ts +10 -0
- package/dist/event-list-item.js +2097 -0
- package/dist/event-list-item.mjs +17 -0
- package/dist/event-list-item.types-B1490EQm.d.mts +46 -0
- package/dist/event-list-item.types-B1490EQm.d.ts +46 -0
- package/dist/event-list-item.types-Y6IeJ4e4.d.mts +46 -0
- package/dist/event-list-item.types-Y6IeJ4e4.d.ts +46 -0
- package/dist/event-list.d.mts +9 -0
- package/dist/event-list.d.ts +9 -0
- package/dist/event-list.js +3151 -0
- package/dist/event-list.mjs +20 -0
- package/dist/event-list.types-Bpp6Vn-t.d.mts +13 -0
- package/dist/event-list.types-Bpp6Vn-t.d.ts +13 -0
- package/dist/event-list.types-CkAAUqwW.d.mts +13 -0
- package/dist/event-list.types-CkAAUqwW.d.ts +13 -0
- package/dist/event-market-page.d.mts +52 -0
- package/dist/event-market-page.d.ts +52 -0
- package/dist/event-market-page.js +5369 -0
- package/dist/event-market-page.mjs +29 -0
- package/dist/hello-world.d.mts +8 -0
- package/dist/hello-world.d.ts +8 -0
- package/dist/hello-world.js +80 -0
- package/dist/hello-world.mjs +8 -0
- package/dist/home-page.d.mts +51 -0
- package/dist/home-page.d.ts +51 -0
- package/dist/home-page.js +3415 -0
- package/dist/home-page.mjs +21 -0
- package/dist/icon.d.mts +123 -0
- package/dist/icon.d.ts +123 -0
- package/dist/icon.js +922 -0
- package/dist/icon.mjs +57 -0
- package/dist/index.d.mts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +8184 -0
- package/dist/index.mjs +307 -0
- package/dist/loading-icon.d.mts +14 -0
- package/dist/loading-icon.d.ts +14 -0
- package/dist/loading-icon.js +115 -0
- package/dist/loading-icon.mjs +8 -0
- package/dist/market-details.d.mts +73 -0
- package/dist/market-details.d.ts +73 -0
- package/dist/market-details.js +3923 -0
- package/dist/market-details.mjs +22 -0
- package/dist/modal.d.mts +66 -0
- package/dist/modal.d.ts +66 -0
- package/dist/modal.js +317 -0
- package/dist/modal.mjs +9 -0
- package/dist/number-value.d.mts +14 -0
- package/dist/number-value.d.ts +14 -0
- package/dist/number-value.js +67 -0
- package/dist/number-value.mjs +7 -0
- package/dist/onboarding-modal.d.mts +88 -0
- package/dist/onboarding-modal.d.ts +88 -0
- package/dist/onboarding-modal.js +2242 -0
- package/dist/onboarding-modal.mjs +24 -0
- package/dist/place-order.d.mts +20 -0
- package/dist/place-order.d.ts +20 -0
- package/dist/place-order.js +2916 -0
- package/dist/place-order.mjs +18 -0
- package/dist/registry-CVn79H3I.d.mts +106 -0
- package/dist/registry-CVn79H3I.d.ts +106 -0
- package/dist/search.d.mts +69 -0
- package/dist/search.d.ts +69 -0
- package/dist/search.js +1465 -0
- package/dist/search.mjs +12 -0
- package/dist/select.d.mts +19 -0
- package/dist/select.d.ts +19 -0
- package/dist/select.js +920 -0
- package/dist/select.mjs +11 -0
- package/dist/settlement.d.mts +16 -0
- package/dist/settlement.d.ts +16 -0
- package/dist/settlement.js +1769 -0
- package/dist/settlement.mjs +15 -0
- package/dist/skeleton.d.mts +22 -0
- package/dist/skeleton.d.ts +22 -0
- package/dist/skeleton.js +523 -0
- package/dist/skeleton.mjs +10 -0
- package/dist/styles.css +2 -0
- package/dist/switch-button.d.mts +21 -0
- package/dist/switch-button.d.ts +21 -0
- package/dist/switch-button.js +184 -0
- package/dist/switch-button.mjs +7 -0
- package/dist/tabs.d.mts +27 -0
- package/dist/tabs.d.ts +27 -0
- package/dist/tabs.js +1708 -0
- package/dist/tabs.mjs +12 -0
- package/dist/tailwind.css +2 -0
- package/dist/types-8VUuQVZq.d.mts +387 -0
- package/dist/types-8VUuQVZq.d.ts +387 -0
- package/dist/types-CayJ8tWA.d.mts +3 -0
- package/dist/types-CayJ8tWA.d.ts +3 -0
- package/dist/typography.d.mts +16 -0
- package/dist/typography.d.ts +16 -0
- package/dist/typography.js +62 -0
- package/dist/typography.mjs +7 -0
- package/dist/venue-logo.d.mts +12 -0
- package/dist/venue-logo.d.ts +12 -0
- package/dist/venue-logo.js +350 -0
- package/dist/venue-logo.mjs +10 -0
- package/dist/venue-logo.types-4hmCg3D3.d.ts +17 -0
- package/dist/venue-logo.types-B1iPJgiD.d.mts +17 -0
- package/dist/venue-logo.types-Bg8eXtGp.d.ts +17 -0
- package/dist/venue-logo.types-QNDwiQ77.d.mts +17 -0
- package/package.json +195 -0
package/dist/chart.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
|
|
47
|
+
// src/primitives/chart/index.tsx
|
|
48
|
+
var chart_exports = {};
|
|
49
|
+
__export(chart_exports, {
|
|
50
|
+
LineChart: () => LineChart
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(chart_exports);
|
|
53
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
54
|
+
var import_hooks2 = require("@agg-market/hooks");
|
|
55
|
+
var import_react2 = require("react");
|
|
56
|
+
var import_liveline = require("liveline");
|
|
57
|
+
|
|
58
|
+
// src/primitives/switch-button/index.tsx
|
|
59
|
+
var import_react = require("react");
|
|
60
|
+
var import_hooks = require("@agg-market/hooks");
|
|
61
|
+
|
|
62
|
+
// src/shared/utils.ts
|
|
63
|
+
var cn = (...values) => values.filter(Boolean).join(" ");
|
|
64
|
+
var getMotionClassName = (enabled, ...values) => {
|
|
65
|
+
if (!enabled)
|
|
66
|
+
return void 0;
|
|
67
|
+
return cn(...values);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/primitives/switch-button/index.tsx
|
|
71
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
|
+
var resolveActiveIndex = (options, value) => {
|
|
73
|
+
const activeIndex = options.findIndex((option) => option.value === value);
|
|
74
|
+
if (activeIndex >= 0)
|
|
75
|
+
return activeIndex;
|
|
76
|
+
return 0;
|
|
77
|
+
};
|
|
78
|
+
var resolveNextEnabledIndex = (options, currentIndex, direction) => {
|
|
79
|
+
if (options.length <= 1)
|
|
80
|
+
return currentIndex;
|
|
81
|
+
const step = direction === "next" ? 1 : -1;
|
|
82
|
+
for (let offset = 1; offset <= options.length; offset += 1) {
|
|
83
|
+
const candidateIndex = (currentIndex + step * offset + options.length) % options.length;
|
|
84
|
+
const candidate = options[candidateIndex];
|
|
85
|
+
if (candidate && !candidate.disabled) {
|
|
86
|
+
return candidateIndex;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return currentIndex;
|
|
90
|
+
};
|
|
91
|
+
var SwitchButton = ({
|
|
92
|
+
options,
|
|
93
|
+
value,
|
|
94
|
+
onValueChange,
|
|
95
|
+
ariaLabel,
|
|
96
|
+
className
|
|
97
|
+
}) => {
|
|
98
|
+
const { enableAnimations } = (0, import_hooks.useSdkUiConfig)();
|
|
99
|
+
const activeIndex = (0, import_react.useMemo)(() => {
|
|
100
|
+
return resolveActiveIndex(options, value);
|
|
101
|
+
}, [options, value]);
|
|
102
|
+
const [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
|
|
103
|
+
const [lastAnimatedIndex, setLastAnimatedIndex] = (0, import_react.useState)(activeIndex);
|
|
104
|
+
(0, import_react.useEffect)(() => {
|
|
105
|
+
if (lastAnimatedIndex === activeIndex) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setLastAnimatedIndex(activeIndex);
|
|
109
|
+
if (!enableAnimations) {
|
|
110
|
+
setIsAnimating(false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setIsAnimating(true);
|
|
114
|
+
const timeoutId = window.setTimeout(() => {
|
|
115
|
+
setIsAnimating(false);
|
|
116
|
+
}, 350);
|
|
117
|
+
return () => {
|
|
118
|
+
window.clearTimeout(timeoutId);
|
|
119
|
+
};
|
|
120
|
+
}, [activeIndex, enableAnimations, lastAnimatedIndex]);
|
|
121
|
+
if (options.length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const handleKeyDown = (event, optionIndex) => {
|
|
125
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
const nextOptionIndex = resolveNextEnabledIndex(
|
|
130
|
+
options,
|
|
131
|
+
optionIndex,
|
|
132
|
+
event.key === "ArrowRight" ? "next" : "previous"
|
|
133
|
+
);
|
|
134
|
+
const nextOption = options[nextOptionIndex];
|
|
135
|
+
if (!nextOption || nextOption.disabled) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
onValueChange(nextOption.value);
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
className: cn(
|
|
144
|
+
"inline-flex min-w-0 rounded-agg-full bg-agg-secondary-hover font-agg-sans",
|
|
145
|
+
className
|
|
146
|
+
),
|
|
147
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: "relative grid min-w-0 flex-1 items-center",
|
|
151
|
+
style: {
|
|
152
|
+
gridTemplateColumns: `repeat(${options.length}, minmax(0, 1fr))`
|
|
153
|
+
},
|
|
154
|
+
role: "tablist",
|
|
155
|
+
"aria-label": ariaLabel,
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
className: cn(
|
|
161
|
+
"pointer-events-none absolute inset-y-0 left-0 rounded-agg-full border-2 border-agg-primary bg-agg-secondary",
|
|
162
|
+
getMotionClassName(
|
|
163
|
+
enableAnimations,
|
|
164
|
+
"transition-transform duration-[450ms] ease-[cubic-bezier(0.77,0,0.175,1)]"
|
|
165
|
+
)
|
|
166
|
+
),
|
|
167
|
+
style: {
|
|
168
|
+
width: `${100 / options.length}%`,
|
|
169
|
+
transform: `translateX(${activeIndex * 100}%) scaleX(${isAnimating ? 1.08 : 1})`
|
|
170
|
+
},
|
|
171
|
+
"aria-hidden": "true"
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
options.map((option, optionIndex) => {
|
|
175
|
+
var _a;
|
|
176
|
+
const isActive = optionIndex === activeIndex;
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
type: "button",
|
|
181
|
+
role: "tab",
|
|
182
|
+
"aria-selected": isActive,
|
|
183
|
+
"aria-label": (_a = option.ariaLabel) != null ? _a : void 0,
|
|
184
|
+
tabIndex: isActive ? 0 : -1,
|
|
185
|
+
disabled: option.disabled,
|
|
186
|
+
className: cn(
|
|
187
|
+
"relative z-10 min-w-0 rounded-agg-full px-5 py-1.5 font-agg-sans text-agg-base leading-agg-6 text-agg-foreground",
|
|
188
|
+
getMotionClassName(enableAnimations, "transition-colors duration-300"),
|
|
189
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover",
|
|
190
|
+
"disabled:cursor-not-allowed disabled:text-agg-muted-foreground",
|
|
191
|
+
isActive ? "font-agg-bold" : "font-agg-normal"
|
|
192
|
+
),
|
|
193
|
+
onClick: () => {
|
|
194
|
+
if (option.disabled || isActive) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
onValueChange(option.value);
|
|
198
|
+
},
|
|
199
|
+
onKeyDown: (event) => {
|
|
200
|
+
handleKeyDown(event, optionIndex);
|
|
201
|
+
},
|
|
202
|
+
children: option.label
|
|
203
|
+
},
|
|
204
|
+
option.value
|
|
205
|
+
);
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
SwitchButton.displayName = "SwitchButton";
|
|
214
|
+
|
|
215
|
+
// src/primitives/chart/index.tsx
|
|
216
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
217
|
+
var normalizeSeries = (series) => {
|
|
218
|
+
return series.map((seriesItem) => {
|
|
219
|
+
const pointsByTime = /* @__PURE__ */ new Map();
|
|
220
|
+
seriesItem.points.forEach((point) => {
|
|
221
|
+
if (!Number.isFinite(point.time) || !Number.isFinite(point.value)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
pointsByTime.set(Math.floor(point.time), point.value);
|
|
225
|
+
});
|
|
226
|
+
const sortedPoints = [...pointsByTime.entries()].sort((left, right) => left[0] - right[0]).map(([time, value]) => ({
|
|
227
|
+
time,
|
|
228
|
+
value
|
|
229
|
+
}));
|
|
230
|
+
return __spreadProps(__spreadValues({}, seriesItem), {
|
|
231
|
+
points: sortedPoints
|
|
232
|
+
});
|
|
233
|
+
}).filter((seriesItem) => seriesItem.points.length > 0);
|
|
234
|
+
};
|
|
235
|
+
var defaultValueFormatter = (value) => {
|
|
236
|
+
return `${Math.round(value)}%`;
|
|
237
|
+
};
|
|
238
|
+
var defaultTimeFormatter = (timestamp) => {
|
|
239
|
+
return import_dayjs.default.unix(timestamp).format("MMM D");
|
|
240
|
+
};
|
|
241
|
+
var toLivelinePoints = (points) => {
|
|
242
|
+
return points.map((point) => ({
|
|
243
|
+
time: point.time,
|
|
244
|
+
value: point.value
|
|
245
|
+
}));
|
|
246
|
+
};
|
|
247
|
+
var resolveWindowSeconds = (normalizedSeries) => {
|
|
248
|
+
const timestamps = normalizedSeries.flatMap(
|
|
249
|
+
(seriesItem) => seriesItem.points.map((point) => point.time)
|
|
250
|
+
);
|
|
251
|
+
if (timestamps.length <= 1)
|
|
252
|
+
return 30;
|
|
253
|
+
const minTimestamp = Math.min(...timestamps);
|
|
254
|
+
const maxTimestamp = Math.max(...timestamps);
|
|
255
|
+
const span = maxTimestamp - minTimestamp;
|
|
256
|
+
if (!Number.isFinite(span) || span <= 0)
|
|
257
|
+
return 30;
|
|
258
|
+
return Math.max(1, Math.floor(span));
|
|
259
|
+
};
|
|
260
|
+
var resolveLatestValue = (points) => {
|
|
261
|
+
const latestPoint = points[points.length - 1];
|
|
262
|
+
if (!latestPoint)
|
|
263
|
+
return 0;
|
|
264
|
+
return latestPoint.value;
|
|
265
|
+
};
|
|
266
|
+
var resolveActiveSeriesId = (series, activeSeriesId) => {
|
|
267
|
+
var _a, _b;
|
|
268
|
+
if (activeSeriesId) {
|
|
269
|
+
const matchingSeries = series.find((seriesItem) => seriesItem.id === activeSeriesId);
|
|
270
|
+
if (matchingSeries) {
|
|
271
|
+
return matchingSeries.id;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return (_b = (_a = series[0]) == null ? void 0 : _a.id) != null ? _b : "";
|
|
275
|
+
};
|
|
276
|
+
var formatDefaultSeriesLabel = (seriesItem) => {
|
|
277
|
+
return seriesItem.id.charAt(0).toUpperCase() + seriesItem.id.slice(1);
|
|
278
|
+
};
|
|
279
|
+
var renderDefaultSeriesControls = ({
|
|
280
|
+
series,
|
|
281
|
+
activeSeriesId,
|
|
282
|
+
handleSeriesChange,
|
|
283
|
+
defaultSeriesSwitchClassName,
|
|
284
|
+
seriesSwitchAriaLabel,
|
|
285
|
+
formatSeriesOptionAriaLabel
|
|
286
|
+
}) => {
|
|
287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
288
|
+
SwitchButton,
|
|
289
|
+
{
|
|
290
|
+
ariaLabel: seriesSwitchAriaLabel,
|
|
291
|
+
className: defaultSeriesSwitchClassName,
|
|
292
|
+
options: series.map((seriesItem) => ({
|
|
293
|
+
value: seriesItem.id,
|
|
294
|
+
label: formatDefaultSeriesLabel(seriesItem),
|
|
295
|
+
ariaLabel: formatSeriesOptionAriaLabel(formatDefaultSeriesLabel(seriesItem))
|
|
296
|
+
})),
|
|
297
|
+
value: activeSeriesId,
|
|
298
|
+
onValueChange: handleSeriesChange
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
var resolveSelectedSeries = (series, activeSeriesId) => {
|
|
303
|
+
const availableSeriesIds = new Set(series.map((seriesItem) => seriesItem.id));
|
|
304
|
+
if (!availableSeriesIds.has(activeSeriesId)) {
|
|
305
|
+
return series[0];
|
|
306
|
+
}
|
|
307
|
+
return series.find((seriesItem) => seriesItem.id === activeSeriesId);
|
|
308
|
+
};
|
|
309
|
+
var LineChart = ({
|
|
310
|
+
series,
|
|
311
|
+
height = 280,
|
|
312
|
+
width,
|
|
313
|
+
classNames,
|
|
314
|
+
isLoading = false,
|
|
315
|
+
showSeriesControls = true,
|
|
316
|
+
renderSeriesControls
|
|
317
|
+
}) => {
|
|
318
|
+
var _a, _b;
|
|
319
|
+
const labels = (0, import_hooks2.useLabels)();
|
|
320
|
+
const { theme } = (0, import_hooks2.useSdkUiConfig)();
|
|
321
|
+
const normalizedSeries = (0, import_react2.useMemo)(() => {
|
|
322
|
+
return normalizeSeries(series);
|
|
323
|
+
}, [series]);
|
|
324
|
+
const [activeSeriesId, setActiveSeriesId] = (0, import_react2.useState)(
|
|
325
|
+
() => resolveActiveSeriesId(normalizedSeries, null)
|
|
326
|
+
);
|
|
327
|
+
(0, import_react2.useEffect)(() => {
|
|
328
|
+
setActiveSeriesId(
|
|
329
|
+
(currentActiveSeriesId) => resolveActiveSeriesId(normalizedSeries, currentActiveSeriesId)
|
|
330
|
+
);
|
|
331
|
+
}, [normalizedSeries]);
|
|
332
|
+
const livelineTheme = theme;
|
|
333
|
+
const handleSeriesChange = (seriesId) => {
|
|
334
|
+
setActiveSeriesId(seriesId);
|
|
335
|
+
};
|
|
336
|
+
const primarySeries = (0, import_react2.useMemo)(() => {
|
|
337
|
+
return resolveSelectedSeries(normalizedSeries, activeSeriesId);
|
|
338
|
+
}, [activeSeriesId, normalizedSeries]);
|
|
339
|
+
const primaryData = (0, import_react2.useMemo)(() => {
|
|
340
|
+
if (!primarySeries) {
|
|
341
|
+
return [];
|
|
342
|
+
}
|
|
343
|
+
return toLivelinePoints(primarySeries.points);
|
|
344
|
+
}, [primarySeries]);
|
|
345
|
+
const primaryValue = (0, import_react2.useMemo)(() => {
|
|
346
|
+
if (!primarySeries) {
|
|
347
|
+
return 0;
|
|
348
|
+
}
|
|
349
|
+
return resolveLatestValue(primarySeries.points);
|
|
350
|
+
}, [primarySeries]);
|
|
351
|
+
const livelineSeries = (0, import_react2.useMemo)(() => {
|
|
352
|
+
return normalizedSeries.map((seriesItem) => ({
|
|
353
|
+
id: seriesItem.id,
|
|
354
|
+
color: seriesItem.color,
|
|
355
|
+
data: toLivelinePoints(seriesItem.points),
|
|
356
|
+
value: resolveLatestValue(seriesItem.points)
|
|
357
|
+
}));
|
|
358
|
+
}, [normalizedSeries]);
|
|
359
|
+
const windowSeconds = (0, import_react2.useMemo)(() => {
|
|
360
|
+
return resolveWindowSeconds(normalizedSeries);
|
|
361
|
+
}, [normalizedSeries]);
|
|
362
|
+
const seriesControls = showSeriesControls && normalizedSeries.length > 0 ? (_a = renderSeriesControls == null ? void 0 : renderSeriesControls({
|
|
363
|
+
series: normalizedSeries,
|
|
364
|
+
activeSeriesId,
|
|
365
|
+
handleSeriesChange
|
|
366
|
+
})) != null ? _a : normalizedSeries.length > 1 ? renderDefaultSeriesControls({
|
|
367
|
+
series: normalizedSeries,
|
|
368
|
+
activeSeriesId,
|
|
369
|
+
handleSeriesChange,
|
|
370
|
+
defaultSeriesSwitchClassName: classNames == null ? void 0 : classNames.defaultSeriesSwitch,
|
|
371
|
+
seriesSwitchAriaLabel: labels.common.lineChartSeriesSwitchAria,
|
|
372
|
+
formatSeriesOptionAriaLabel: labels.common.lineChartSeriesOptionAria
|
|
373
|
+
}) : null : null;
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn("w-full", classNames == null ? void 0 : classNames.root), style: { width }, children: [
|
|
375
|
+
!isLoading && seriesControls ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: cn("mb-3", classNames == null ? void 0 : classNames.controls), children: seriesControls }) : null,
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
377
|
+
"div",
|
|
378
|
+
{
|
|
379
|
+
className: cn(
|
|
380
|
+
"overflow-hidden [&>div:not(.agg-livechart):first-of-type]:hidden!",
|
|
381
|
+
classNames == null ? void 0 : classNames.chartViewport
|
|
382
|
+
),
|
|
383
|
+
style: { height },
|
|
384
|
+
role: "img",
|
|
385
|
+
"aria-label": labels.common.lineChartAria,
|
|
386
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
387
|
+
import_liveline.Liveline,
|
|
388
|
+
{
|
|
389
|
+
className: cn("h-full w-full agg-livechart", classNames == null ? void 0 : classNames.liveline),
|
|
390
|
+
data: primaryData,
|
|
391
|
+
value: primaryValue,
|
|
392
|
+
series: livelineSeries,
|
|
393
|
+
color: (_b = primarySeries == null ? void 0 : primarySeries.color) != null ? _b : "var(--agg-color-primary)",
|
|
394
|
+
theme: livelineTheme,
|
|
395
|
+
grid: true,
|
|
396
|
+
momentum: false,
|
|
397
|
+
pulse: false,
|
|
398
|
+
window: windowSeconds,
|
|
399
|
+
formatValue: defaultValueFormatter,
|
|
400
|
+
formatTime: defaultTimeFormatter,
|
|
401
|
+
padding: {
|
|
402
|
+
top: 12,
|
|
403
|
+
right: 80,
|
|
404
|
+
bottom: 28,
|
|
405
|
+
left: 12
|
|
406
|
+
},
|
|
407
|
+
loading: isLoading
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
)
|
|
412
|
+
] });
|
|
413
|
+
};
|
|
414
|
+
LineChart.displayName = "LineChart";
|
|
415
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
416
|
+
0 && (module.exports = {
|
|
417
|
+
LineChart
|
|
418
|
+
});
|