@hot-updater/console 0.36.7 → 1.0.0-rc.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/.output/nitro.json +1 -1
- package/.output/public/assets/AnalyticsCapabilityContext-BCke57-7.js +1 -0
- package/.output/public/assets/BundleActivityChart-CnsBe_1J.js +42 -0
- package/.output/public/assets/BundleIdDisplay-Dky75zLU.js +1 -0
- package/.output/public/assets/alert-C-1KvDW8.js +1 -0
- package/.output/public/assets/analytics-Bqz0c-BT.js +1 -0
- package/.output/public/assets/analytics-api-CJdrTLLO.js +1 -0
- package/.output/public/assets/api-B_Rh-uzC.js +1 -0
- package/.output/public/assets/api-keys-BurCFhzH.js +1 -0
- package/.output/public/assets/api-keys-api-BEDJdQg3.js +1 -0
- package/.output/public/assets/badge-Bf0fZ-Gx.js +1 -0
- package/.output/public/assets/chart-no-axes-combined-FaYMGmQS.js +1 -0
- package/.output/public/assets/createServerFn-gM2-LFBy.js +3 -0
- package/.output/public/assets/dialog-BS60BRr2.js +1 -0
- package/.output/public/assets/dist-DspNKfMj.js +1 -0
- package/.output/public/assets/download-O-yNBc9H.js +1 -0
- package/.output/public/assets/field-Buq148-A.js +1 -0
- package/.output/public/assets/index-kFhd2S78.js +10 -0
- package/.output/public/assets/installations-BrQ-od41.js +2 -0
- package/.output/public/assets/installations-CGlZ3ROz.js +1 -0
- package/.output/public/assets/lazyRouteComponent-rPzgA7S-.js +1 -0
- package/.output/public/assets/loader-circle-DCYF-wJl.js +1 -0
- package/.output/public/assets/preload-helper-TKOBYGYD.js +1 -0
- package/.output/public/assets/refresh-cw-n8XYbPPj.js +1 -0
- package/.output/public/assets/routes-CrdokJ80.js +1 -0
- package/.output/public/assets/routes-DcQnVajO.js +2 -0
- package/.output/public/assets/search-DLhbWw3W.js +1 -0
- package/.output/public/assets/shield-check-DE_hVuHu.js +1 -0
- package/.output/public/assets/signing-HRexfjsH.js +1 -0
- package/.output/public/assets/styles-eB4EtvFS.css +2 -0
- package/.output/public/assets/table-D8CLieHX.js +1 -0
- package/.output/public/assets/textarea-YJLTVAoq.js +1 -0
- package/.output/public/assets/useMutation-JsGVjQMY.js +1 -0
- package/.output/public/assets/useOpenInteractionType-4cRD5xO0.js +1 -0
- package/.output/server/__23tanstack-start-server-fn-resolver-DBP9TQ7K.mjs +146 -0
- package/.output/server/_libs/@base-ui/react+[...].mjs +16124 -0
- package/.output/server/_libs/@reduxjs/toolkit+[...].mjs +1554 -0
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +41 -10
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +132 -0
- package/.output/server/_libs/d3-array.mjs +231 -0
- package/.output/server/_libs/d3-color.mjs +330 -0
- package/.output/server/_libs/d3-format.mjs +252 -0
- package/.output/server/_libs/d3-interpolate.mjs +207 -0
- package/.output/server/_libs/d3-path.mjs +77 -0
- package/.output/server/_libs/d3-scale+[...].mjs +1907 -0
- package/.output/server/_libs/d3-shape.mjs +818 -0
- package/.output/server/_libs/decimal.js-light.mjs +884 -0
- package/.output/server/_libs/es-toolkit.mjs +1134 -0
- package/.output/server/_libs/eventemitter3.mjs +236 -0
- package/.output/server/_libs/immer.mjs +532 -0
- package/.output/server/_libs/lucide-react.mjs +141 -13
- package/.output/server/_libs/next-themes.mjs +2 -2
- package/.output/server/_libs/react-redux+[...].mjs +205 -0
- package/.output/server/_libs/recharts+[...].mjs +14117 -0
- package/.output/server/_libs/sonner.mjs +2 -2
- package/.output/server/_libs/tanstack__query-core.mjs +114 -1
- package/.output/server/_libs/tanstack__react-query.mjs +3 -4
- package/.output/server/_runtime.mjs +10 -1
- package/.output/server/_ssr/AnalyticsCapabilityContext-ui4DX8GO.mjs +15 -0
- package/.output/server/_ssr/BundleActivityChart-BiB9ZORH.mjs +288 -0
- package/.output/server/_ssr/BundleIdDisplay-Czk6iR6p.mjs +13 -0
- package/.output/server/_ssr/alert-Dim3MGY5.mjs +86 -0
- package/.output/server/_ssr/analytics-DtMTn8fn.mjs +858 -0
- package/.output/server/_ssr/analytics-api-Cg1M5v_H.mjs +71 -0
- package/.output/server/_ssr/analytics-input-fRRRn0uA.mjs +96 -0
- package/.output/server/_ssr/analytics-rpc-DY5uXvHT.mjs +155 -0
- package/.output/server/_ssr/api-BTSv1tZb.mjs +282 -0
- package/.output/server/_ssr/api-keys-BnM_o2nS.mjs +300 -0
- package/.output/server/_ssr/api-keys-api-CIywsSF5.mjs +60 -0
- package/.output/server/_ssr/api-keys-rpc-BSp1wkIV.mjs +136 -0
- package/.output/server/_ssr/api-rpc-cG5wd_tO.mjs +1468 -0
- package/.output/server/_ssr/auth-BF8mbAgF.mjs +21 -0
- package/.output/server/_ssr/auth-rpc-BrJ6obHJ.mjs +24 -0
- package/.output/server/_ssr/auth.server-DwKoZoQM.mjs +50 -0
- package/.output/server/_ssr/badge-DCxbEeof.mjs +26 -0
- package/.output/server/_ssr/bundle-signing-rpc-COoQhW8E.mjs +16 -0
- package/.output/server/_ssr/bundle-signing.server-D5u8KkMp.mjs +51 -0
- package/.output/server/_ssr/config-Dv8qLDZ0.mjs +13 -0
- package/.output/server/_ssr/config.server-DEiLhKmy.mjs +361 -0
- package/.output/server/_ssr/{createServerFn-DzU0k62V.mjs → createServerFn-B2hcXoPM.mjs} +1 -1
- package/.output/server/_ssr/createServerRpc-DB29C_5p.mjs +12 -0
- package/.output/server/_ssr/{sidebar-Cv_H0_Jv.mjs → createSsrRpc-9P0S0lJ3.mjs} +68 -50
- package/.output/server/_ssr/databaseRows-CwbNwYSl.mjs +166 -0
- package/.output/server/_ssr/deleteBundle-Cu_XOMt0.mjs +66 -0
- package/.output/server/_ssr/dialog-CQuRMNZ4.mjs +170 -0
- package/.output/server/_ssr/dist-BVSLTpoP.mjs +250 -0
- package/.output/server/_ssr/downloadBundle-CNnYxYO2.mjs +24 -0
- package/.output/server/_ssr/{empty-plugin-adapters-B4HCzgmM.mjs → empty-plugin-adapters-B5QvGpEl.mjs} +1 -1
- package/.output/server/_ssr/field-DRIXKjZG.mjs +74 -0
- package/.output/server/_ssr/{getBundleChildren-CVtSiH5t.mjs → getBundleChildren-BcRMFoDF.mjs} +10 -18
- package/.output/server/_ssr/installations-B-azgAvX.mjs +19 -0
- package/.output/server/_ssr/installations-Ctvzp2JH.mjs +535 -0
- package/.output/server/_ssr/router-C-KUBfOi.mjs +513 -0
- package/.output/server/_ssr/routes-BM4ht9jb.mjs +2286 -0
- package/.output/server/_ssr/routes-Z7TwC6nC.mjs +37 -0
- package/.output/server/_ssr/runtime.server-awTLiiXW.mjs +527 -0
- package/.output/server/_ssr/server-BjzmvXnO.mjs +7468 -0
- package/.output/server/_ssr/signing-k8GxyBDF.mjs +202 -0
- package/.output/server/_ssr/ssr.mjs +4 -5740
- package/.output/server/_ssr/start-DpViQGnt.mjs +4 -0
- package/.output/server/_ssr/table-v1yCvYo7.mjs +53 -0
- package/.output/server/_ssr/textarea-DYHnskhb.mjs +14 -0
- package/.output/server/_ssr/uuidv7-BbJ-9D_I.mjs +31 -0
- package/.output/server/_tanstack-start-manifest_v-CH4StzJu.mjs +108 -0
- package/.output/server/index.mjs +256 -53
- package/README.md +29 -8
- package/lib/index.d.mts +36 -0
- package/lib/index.mjs +4 -0
- package/lib/vite-internal.mjs +127 -0
- package/lib/vite.d.mts +10 -0
- package/lib/vite.mjs +5 -0
- package/package.json +51 -29
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/logo.svg +1 -0
- package/public/manifest.json +30 -0
- package/public/robots.txt +3 -0
- package/src/components/AppSidebar.tsx +159 -0
- package/src/components/BundleIdDisplay.tsx +18 -0
- package/src/components/ChannelBadge.tsx +31 -0
- package/src/components/ConsoleAccessPage.tsx +122 -0
- package/src/components/EnabledStatusIcon.tsx +54 -0
- package/src/components/HashValueDisplay.tsx +85 -0
- package/src/components/HotUpdaterLogo.tsx +30 -0
- package/src/components/NotFoundPage.tsx +33 -0
- package/src/components/PlatformIcon.tsx +39 -0
- package/src/components/RolloutPercentageBadge.tsx +28 -0
- package/src/components/ThemeProvider.tsx +116 -0
- package/src/components/TimestampDisplay.tsx +41 -0
- package/src/components/features/analytics/ActivityChart.tsx +150 -0
- package/src/components/features/analytics/AnalyticsCapabilityContext.tsx +24 -0
- package/src/components/features/analytics/AnalyticsControls.tsx +115 -0
- package/src/components/features/analytics/AnalyticsErrorAlert.tsx +21 -0
- package/src/components/features/analytics/AnalyticsOverview.tsx +208 -0
- package/src/components/features/analytics/BundleDistribution.tsx +133 -0
- package/src/components/features/analytics/BundleSelector.tsx +114 -0
- package/src/components/features/analytics/InstallationHistoryCard.tsx +248 -0
- package/src/components/features/analytics/InstallationMatchesCard.tsx +132 -0
- package/src/components/features/analytics/InstallationPageHeader.tsx +138 -0
- package/src/components/features/analytics/InstallationPagination.tsx +48 -0
- package/src/components/features/analytics/InstallationSearch.tsx +230 -0
- package/src/components/features/analytics/UpdateOutcomes.tsx +147 -0
- package/src/components/features/api-keys/ApiKeysPage.tsx +377 -0
- package/src/components/features/bundles/BundleActivityChart.tsx +193 -0
- package/src/components/features/bundles/BundleAnalyticsSummary.tsx +123 -0
- package/src/components/features/bundles/BundleChildrenPanel.tsx +201 -0
- package/src/components/features/bundles/BundleMetadata.tsx +136 -0
- package/src/components/features/bundles/RolloutCohortsDialog.tsx +201 -0
- package/src/components/features/channels/ChannelManagementDialog.tsx +228 -0
- package/src/components/features/releases/ReleaseEditorSheet.tsx +879 -0
- package/src/components/features/releases/ReleaseStateBadge.tsx +20 -0
- package/src/components/features/signing/BundleSigningPage.tsx +247 -0
- package/src/components/ui/alert-dialog.tsx +185 -0
- package/src/components/ui/alert.tsx +76 -0
- package/src/components/ui/badge.tsx +49 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +89 -0
- package/src/components/ui/chart.tsx +371 -0
- package/src/components/ui/combobox.tsx +303 -0
- package/src/components/ui/dialog.tsx +156 -0
- package/src/components/ui/dropdown-menu.tsx +270 -0
- package/src/components/ui/field.tsx +235 -0
- package/src/components/ui/input-group.tsx +147 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +25 -0
- package/src/components/ui/progress.tsx +84 -0
- package/src/components/ui/select.tsx +205 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +132 -0
- package/src/components/ui/sidebar.tsx +779 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +56 -0
- package/src/components/ui/sonner.tsx +45 -0
- package/src/components/ui/switch.tsx +25 -0
- package/src/components/ui/table.tsx +114 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/toggle-group.tsx +89 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +66 -0
- package/src/hooks/use-mobile.ts +30 -0
- package/src/index.ts +48 -0
- package/src/lib/analytics-api.ts +145 -0
- package/src/lib/analytics-error.ts +19 -0
- package/src/lib/analytics-input.ts +187 -0
- package/src/lib/analytics-overview.ts +170 -0
- package/src/lib/analytics-rpc.ts +218 -0
- package/src/lib/api-keys-api.ts +69 -0
- package/src/lib/api-keys-rpc.ts +87 -0
- package/src/lib/api-rpc.ts +478 -0
- package/src/lib/api.ts +444 -0
- package/src/lib/auth-rpc.ts +16 -0
- package/src/lib/bundle-signing-api.ts +14 -0
- package/src/lib/bundle-signing-rpc.ts +16 -0
- package/src/lib/constants.ts +1 -0
- package/src/lib/git.ts +51 -0
- package/src/lib/server/auth.server.ts +43 -0
- package/src/lib/server/bundle-signing.server.ts +100 -0
- package/src/lib/server/config.server.ts +109 -0
- package/src/lib/server/console-runtime.server.ts +70 -0
- package/src/lib/server/deleteBundle.ts +145 -0
- package/src/lib/server/downloadBundle.ts +46 -0
- package/src/lib/server/getBundleChildren.ts +130 -0
- package/src/lib/server/listReleases.ts +61 -0
- package/src/lib/server/releaseActivity.ts +27 -0
- package/src/lib/server/releaseReachability.ts +95 -0
- package/src/lib/server/runtime.server.ts +172 -0
- package/src/lib/utils.ts +9 -0
- package/src/logo.svg +1 -0
- package/src/routeTree.gen.ts +199 -0
- package/src/router.tsx +21 -0
- package/src/routes/-installations-search.ts +19 -0
- package/src/routes/-releases-search.ts +74 -0
- package/src/routes/__root.tsx +174 -0
- package/src/routes/analytics.tsx +139 -0
- package/src/routes/api/auth/$.ts +19 -0
- package/src/routes/api/bundles/$bundleId/download.ts +17 -0
- package/src/routes/api-keys.tsx +37 -0
- package/src/routes/index.tsx +982 -0
- package/src/routes/installations.tsx +194 -0
- package/src/routes/signing.tsx +37 -0
- package/src/styles.css +152 -0
- package/src/virtual-modules.d.ts +21 -0
- package/src/vite-env.d.ts +1 -0
- package/src/vite-internal.ts +195 -0
- package/src/vite.ts +12 -0
- package/.output/public/assets/dist-DJX53faP.js +0 -3
- package/.output/public/assets/index-Iylis5kY.js +0 -10
- package/.output/public/assets/routes-HT21hs0C.js +0 -54
- package/.output/public/assets/styles-C0Re4quB.css +0 -2
- package/.output/server/__23tanstack-start-server-fn-resolver-CgwgZ0-i.mjs +0 -66
- package/.output/server/_libs/@floating-ui/core+[...].mjs +0 -698
- package/.output/server/_libs/@floating-ui/dom+[...].mjs +0 -644
- package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +0 -839
- package/.output/server/_libs/@radix-ui/react-alert-dialog+[...].mjs +0 -2138
- package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +0 -308
- package/.output/server/_libs/@radix-ui/react-select+[...].mjs +0 -1038
- package/.output/server/_libs/@tanstack/devtools-event-client+[...].mjs +0 -196
- package/.output/server/_libs/@tanstack/form-core+[...].mjs +0 -3228
- package/.output/server/_libs/@tanstack/react-form+[...].mjs +0 -430
- package/.output/server/_libs/@tanstack/react-table+[...].mjs +0 -2382
- package/.output/server/_libs/radix-ui__number.mjs +0 -6
- package/.output/server/_libs/radix-ui__primitive.mjs +0 -9
- package/.output/server/_libs/radix-ui__react-arrow.mjs +0 -23
- package/.output/server/_libs/radix-ui__react-collection.mjs +0 -78
- package/.output/server/_libs/radix-ui__react-direction.mjs +0 -13
- package/.output/server/_libs/radix-ui__react-label.mjs +0 -22
- package/.output/server/_libs/radix-ui__react-separator.mjs +0 -30
- package/.output/server/_libs/radix-ui__react-slider.mjs +0 -510
- package/.output/server/_libs/radix-ui__react-switch.mjs +0 -157
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +0 -493
- package/.output/server/_ssr/api-rpc-BIbDUKSz.mjs +0 -292
- package/.output/server/_ssr/config.server-BSS366KT.mjs +0 -41
- package/.output/server/_ssr/deleteBundle-BgbZTtpW.mjs +0 -141
- package/.output/server/_ssr/dist-KboydRVk.mjs +0 -120
- package/.output/server/_ssr/router-C3hqEy3k.mjs +0 -307
- package/.output/server/_ssr/routes-B0lQvvlC.mjs +0 -3048
- package/.output/server/_ssr/start-02sLteYG.mjs +0 -4
- package/.output/server/_ssr/storageProfile-FVkjPoGb.mjs +0 -9
- package/.output/server/_tanstack-start-manifest_v-Bpx52WOU.mjs +0 -20
- package/.output/server/node_modules/tslib/modules/index.js +0 -70
- package/.output/server/node_modules/tslib/modules/package.json +0 -3
- package/.output/server/node_modules/tslib/package.json +0 -47
- package/.output/server/node_modules/tslib/tslib.js +0 -484
- package/.output/server/package.json +0 -9
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
"rounded-xl border bg-card text-card-foreground shadow",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-slot="card-title"
|
|
32
|
+
className={cn("font-semibold leading-none tracking-tight", className)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
data-slot="card-description"
|
|
42
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
data-slot="card-action"
|
|
52
|
+
className={cn(
|
|
53
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
data-slot="card-content"
|
|
65
|
+
className={cn("p-6 pt-0", className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="card-footer"
|
|
75
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
Card,
|
|
83
|
+
CardHeader,
|
|
84
|
+
CardFooter,
|
|
85
|
+
CardTitle,
|
|
86
|
+
CardAction,
|
|
87
|
+
CardDescription,
|
|
88
|
+
CardContent,
|
|
89
|
+
};
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
import type { TooltipValueType } from "recharts";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
8
|
+
const THEMES = { light: "", dark: ".dark" } as const;
|
|
9
|
+
|
|
10
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
|
|
11
|
+
type TooltipNameType = number | string;
|
|
12
|
+
|
|
13
|
+
export type ChartConfig = Record<
|
|
14
|
+
string,
|
|
15
|
+
{
|
|
16
|
+
label?: React.ReactNode;
|
|
17
|
+
icon?: React.ComponentType;
|
|
18
|
+
} & (
|
|
19
|
+
| { color?: string; theme?: never }
|
|
20
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
21
|
+
)
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
type ChartContextProps = {
|
|
25
|
+
config: ChartConfig;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
29
|
+
|
|
30
|
+
function useChart() {
|
|
31
|
+
const context = React.useContext(ChartContext);
|
|
32
|
+
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return context;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ChartContainer({
|
|
41
|
+
id,
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
config,
|
|
45
|
+
initialDimension = INITIAL_DIMENSION,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<"div"> & {
|
|
48
|
+
config: ChartConfig;
|
|
49
|
+
children: React.ComponentProps<
|
|
50
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
51
|
+
>["children"];
|
|
52
|
+
initialDimension?: {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
};
|
|
56
|
+
}) {
|
|
57
|
+
const uniqueId = React.useId();
|
|
58
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ChartContext.Provider value={{ config }}>
|
|
62
|
+
<div
|
|
63
|
+
data-slot="chart"
|
|
64
|
+
data-chart={chartId}
|
|
65
|
+
className={cn(
|
|
66
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<ChartStyle id={chartId} config={config} />
|
|
72
|
+
<RechartsPrimitive.ResponsiveContainer
|
|
73
|
+
initialDimension={initialDimension}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
77
|
+
</div>
|
|
78
|
+
</ChartContext.Provider>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
83
|
+
const colorConfig = Object.entries(config).filter(
|
|
84
|
+
([, config]) => config.theme ?? config.color,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!colorConfig.length) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<style
|
|
93
|
+
dangerouslySetInnerHTML={{
|
|
94
|
+
__html: Object.entries(THEMES)
|
|
95
|
+
.map(
|
|
96
|
+
([theme, prefix]) => `
|
|
97
|
+
${prefix} [data-chart=${id}] {
|
|
98
|
+
${colorConfig
|
|
99
|
+
.map(([key, itemConfig]) => {
|
|
100
|
+
const color =
|
|
101
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
|
102
|
+
itemConfig.color;
|
|
103
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
104
|
+
})
|
|
105
|
+
.join("\n")}
|
|
106
|
+
}
|
|
107
|
+
`,
|
|
108
|
+
)
|
|
109
|
+
.join("\n"),
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
116
|
+
|
|
117
|
+
function ChartTooltipContent({
|
|
118
|
+
active,
|
|
119
|
+
payload,
|
|
120
|
+
className,
|
|
121
|
+
indicator = "dot",
|
|
122
|
+
hideLabel = false,
|
|
123
|
+
hideIndicator = false,
|
|
124
|
+
label,
|
|
125
|
+
labelFormatter,
|
|
126
|
+
labelClassName,
|
|
127
|
+
formatter,
|
|
128
|
+
color,
|
|
129
|
+
nameKey,
|
|
130
|
+
labelKey,
|
|
131
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
132
|
+
React.ComponentProps<"div"> & {
|
|
133
|
+
hideLabel?: boolean;
|
|
134
|
+
hideIndicator?: boolean;
|
|
135
|
+
indicator?: "line" | "dot" | "dashed";
|
|
136
|
+
nameKey?: string;
|
|
137
|
+
labelKey?: string;
|
|
138
|
+
} & Omit<
|
|
139
|
+
RechartsPrimitive.DefaultTooltipContentProps<
|
|
140
|
+
TooltipValueType,
|
|
141
|
+
TooltipNameType
|
|
142
|
+
>,
|
|
143
|
+
"accessibilityLayer"
|
|
144
|
+
>) {
|
|
145
|
+
const { config } = useChart();
|
|
146
|
+
|
|
147
|
+
const tooltipLabel = React.useMemo(() => {
|
|
148
|
+
if (hideLabel || !payload?.length) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const [item] = payload;
|
|
153
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
154
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
155
|
+
const value =
|
|
156
|
+
!labelKey && typeof label === "string"
|
|
157
|
+
? (config[label]?.label ?? label)
|
|
158
|
+
: itemConfig?.label;
|
|
159
|
+
|
|
160
|
+
if (labelFormatter) {
|
|
161
|
+
return (
|
|
162
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
163
|
+
{labelFormatter(value, payload)}
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!value) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
|
173
|
+
}, [
|
|
174
|
+
label,
|
|
175
|
+
labelFormatter,
|
|
176
|
+
payload,
|
|
177
|
+
hideLabel,
|
|
178
|
+
labelClassName,
|
|
179
|
+
config,
|
|
180
|
+
labelKey,
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
if (!active || !payload?.length) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div
|
|
191
|
+
className={cn(
|
|
192
|
+
"grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs/relaxed shadow-xl",
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
{!nestLabel ? tooltipLabel : null}
|
|
197
|
+
<div className="grid gap-1.5">
|
|
198
|
+
{payload
|
|
199
|
+
.filter((item) => item.type !== "none")
|
|
200
|
+
.map((item, index) => {
|
|
201
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
|
|
202
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
203
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color;
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div
|
|
207
|
+
key={index}
|
|
208
|
+
className={cn(
|
|
209
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
210
|
+
indicator === "dot" && "items-center",
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
214
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
215
|
+
) : (
|
|
216
|
+
<>
|
|
217
|
+
{itemConfig?.icon ? (
|
|
218
|
+
<itemConfig.icon />
|
|
219
|
+
) : (
|
|
220
|
+
!hideIndicator && (
|
|
221
|
+
<div
|
|
222
|
+
className={cn(
|
|
223
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
224
|
+
{
|
|
225
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
226
|
+
"w-1": indicator === "line",
|
|
227
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
228
|
+
indicator === "dashed",
|
|
229
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
230
|
+
},
|
|
231
|
+
)}
|
|
232
|
+
style={
|
|
233
|
+
{
|
|
234
|
+
"--color-bg": indicatorColor,
|
|
235
|
+
"--color-border": indicatorColor,
|
|
236
|
+
} as React.CSSProperties
|
|
237
|
+
}
|
|
238
|
+
/>
|
|
239
|
+
)
|
|
240
|
+
)}
|
|
241
|
+
<div
|
|
242
|
+
className={cn(
|
|
243
|
+
"flex flex-1 justify-between gap-2 leading-none",
|
|
244
|
+
nestLabel ? "items-end" : "items-center",
|
|
245
|
+
)}
|
|
246
|
+
>
|
|
247
|
+
<div className="grid gap-1.5">
|
|
248
|
+
{nestLabel ? tooltipLabel : null}
|
|
249
|
+
<span className="text-muted-foreground">
|
|
250
|
+
{itemConfig?.label ?? item.name}
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
{item.value != null && (
|
|
254
|
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
255
|
+
{typeof item.value === "number"
|
|
256
|
+
? item.value.toLocaleString()
|
|
257
|
+
: String(item.value)}
|
|
258
|
+
</span>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
</>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
);
|
|
265
|
+
})}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
272
|
+
|
|
273
|
+
function ChartLegendContent({
|
|
274
|
+
className,
|
|
275
|
+
hideIcon = false,
|
|
276
|
+
payload,
|
|
277
|
+
verticalAlign = "bottom",
|
|
278
|
+
nameKey,
|
|
279
|
+
}: React.ComponentProps<"div"> & {
|
|
280
|
+
hideIcon?: boolean;
|
|
281
|
+
nameKey?: string;
|
|
282
|
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
283
|
+
const { config } = useChart();
|
|
284
|
+
|
|
285
|
+
if (!payload?.length) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<div
|
|
291
|
+
className={cn(
|
|
292
|
+
"flex items-center justify-center gap-4",
|
|
293
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
294
|
+
className,
|
|
295
|
+
)}
|
|
296
|
+
>
|
|
297
|
+
{payload
|
|
298
|
+
.filter((item) => item.type !== "none")
|
|
299
|
+
.map((item, index) => {
|
|
300
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`;
|
|
301
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<div
|
|
305
|
+
key={index}
|
|
306
|
+
className={cn(
|
|
307
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
|
|
308
|
+
)}
|
|
309
|
+
>
|
|
310
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
311
|
+
<itemConfig.icon />
|
|
312
|
+
) : (
|
|
313
|
+
<div
|
|
314
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
315
|
+
style={{
|
|
316
|
+
backgroundColor: item.color,
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
)}
|
|
320
|
+
{itemConfig?.label}
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
})}
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getPayloadConfigFromPayload(
|
|
329
|
+
config: ChartConfig,
|
|
330
|
+
payload: unknown,
|
|
331
|
+
key: string,
|
|
332
|
+
) {
|
|
333
|
+
if (typeof payload !== "object" || payload === null) {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const payloadPayload =
|
|
338
|
+
"payload" in payload &&
|
|
339
|
+
typeof payload.payload === "object" &&
|
|
340
|
+
payload.payload !== null
|
|
341
|
+
? payload.payload
|
|
342
|
+
: undefined;
|
|
343
|
+
|
|
344
|
+
let configLabelKey: string = key;
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
key in payload &&
|
|
348
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
349
|
+
) {
|
|
350
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
351
|
+
} else if (
|
|
352
|
+
payloadPayload &&
|
|
353
|
+
key in payloadPayload &&
|
|
354
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
355
|
+
) {
|
|
356
|
+
configLabelKey = payloadPayload[
|
|
357
|
+
key as keyof typeof payloadPayload
|
|
358
|
+
] as string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
ChartContainer,
|
|
366
|
+
ChartTooltip,
|
|
367
|
+
ChartTooltipContent,
|
|
368
|
+
ChartLegend,
|
|
369
|
+
ChartLegendContent,
|
|
370
|
+
ChartStyle,
|
|
371
|
+
};
|