@northslopetech/altitude-ui 2.0.14 → 2.0.17

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.mjs CHANGED
@@ -1470,7 +1470,7 @@ var Statement = ({
1470
1470
  )
1471
1471
  }
1472
1472
  );
1473
- var Table = ({
1473
+ var TableIcon = ({
1474
1474
  className,
1475
1475
  variant = "dark",
1476
1476
  ...props
@@ -3018,20 +3018,828 @@ var DropdownMenuShortcut = ({
3018
3018
  );
3019
3019
  };
3020
3020
  DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
3021
+
3022
+ // src/components/ui/charts/chart-legend.tsx
3023
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
3024
+ function ChartLegend({
3025
+ items,
3026
+ x = 0,
3027
+ y = 550,
3028
+ className = ""
3029
+ }) {
3030
+ return /* @__PURE__ */ jsx12("foreignObject", { x, y, width: "100%", height: "40", children: /* @__PURE__ */ jsx12(
3031
+ "div",
3032
+ {
3033
+ className: `flex justify-center items-center gap-6 ${className}`,
3034
+ style: { height: "100%" },
3035
+ children: items.map(({ key, color, label }) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
3036
+ /* @__PURE__ */ jsx12("div", { className: "w-3 h-3", style: { backgroundColor: color } }),
3037
+ /* @__PURE__ */ jsx12(Typography, { variant: "body-xs", children: label || key })
3038
+ ] }, key))
3039
+ }
3040
+ ) });
3041
+ }
3042
+
3043
+ // src/lib/chart-utils.ts
3044
+ var CHART_COLORS = {
3045
+ // Status colors
3046
+ SUCCESS: "var(--color-success)",
3047
+ ERROR: "var(--color-error)",
3048
+ WARNING: "var(--color-warning)",
3049
+ SECONDARY: "var(--color-secondary)",
3050
+ // Primary brand colors
3051
+ PRIMARY: "var(--color-primary)",
3052
+ // Categorical palette from altitude-tokens
3053
+ CATEGORICAL: [
3054
+ "var(--color-chart-color-palette-categorical-1)",
3055
+ "var(--color-chart-color-palette-categorical-2)",
3056
+ "var(--color-chart-color-palette-categorical-3)",
3057
+ "var(--color-chart-color-palette-categorical-4)",
3058
+ "var(--color-chart-color-palette-categorical-5)"
3059
+ ],
3060
+ // Performance palette from altitude-tokens
3061
+ PERFORMANCE: [
3062
+ "var(--color-chart-color-palette-performance-1)",
3063
+ "var(--color-chart-color-palette-performance-2)",
3064
+ "var(--color-chart-color-palette-performance-3)",
3065
+ "var(--color-chart-color-palette-performance-4)",
3066
+ "var(--color-chart-color-palette-performance-5)"
3067
+ ],
3068
+ // Heatmap palette from altitude-tokens
3069
+ HEATMAP: [
3070
+ "var(--color-chart-color-palette-heatmap-1)",
3071
+ "var(--color-chart-color-palette-heatmap-2)",
3072
+ "var(--color-chart-color-palette-heatmap-3)",
3073
+ "var(--color-chart-color-palette-heatmap-4)",
3074
+ "var(--color-chart-color-palette-heatmap-5)"
3075
+ ]
3076
+ };
3077
+ var COLOR_SCHEMES = {
3078
+ passFail: {
3079
+ PASS: CHART_COLORS.SUCCESS,
3080
+ FAIL: CHART_COLORS.ERROR
3081
+ },
3082
+ targetVsAchieved: {
3083
+ TARGET: CHART_COLORS.SECONDARY,
3084
+ ACHIEVED: CHART_COLORS.SUCCESS
3085
+ },
3086
+ performance: {
3087
+ HIGH: CHART_COLORS.PERFORMANCE[0],
3088
+ MEDIUM_HIGH: CHART_COLORS.PERFORMANCE[1],
3089
+ MEDIUM: CHART_COLORS.PERFORMANCE[2],
3090
+ MEDIUM_LOW: CHART_COLORS.PERFORMANCE[3],
3091
+ LOW: CHART_COLORS.PERFORMANCE[4]
3092
+ }
3093
+ };
3094
+ var CHART_CONSTANTS = {
3095
+ // Standard chart dimensions
3096
+ STANDARD_HEIGHT: 400,
3097
+ LARGE_HEIGHT: 500,
3098
+ SMALL_HEIGHT: 300,
3099
+ // Chart margins
3100
+ MARGIN: {
3101
+ top: 20,
3102
+ right: 30,
3103
+ left: 20,
3104
+ bottom: 5
3105
+ },
3106
+ // Axis dimensions
3107
+ AXIS_HEIGHT_STANDARD: 30,
3108
+ AXIS_HEIGHT_ROTATED: 60,
3109
+ AXIS_WIDTH_STANDARD: 60,
3110
+ AXIS_WIDTH_YAXIS: 80,
3111
+ // Pie chart constants
3112
+ PIE_CHART_CENTER_X: 300,
3113
+ PIE_CHART_CENTER_Y: 200
3114
+ };
3115
+ var getSeriesColor = (index) => {
3116
+ return CHART_COLORS.CATEGORICAL[index % CHART_COLORS.CATEGORICAL.length] || CHART_COLORS.PRIMARY;
3117
+ };
3118
+ var getPerformanceColor = (index) => {
3119
+ return CHART_COLORS.PERFORMANCE[index % CHART_COLORS.PERFORMANCE.length] || CHART_COLORS.PRIMARY;
3120
+ };
3121
+ var getHeatmapColor = (index) => {
3122
+ return CHART_COLORS.HEATMAP[index % CHART_COLORS.HEATMAP.length] || CHART_COLORS.PRIMARY;
3123
+ };
3124
+ var createLegendItems = (colorScheme) => {
3125
+ return Object.entries(colorScheme).map(([key, color]) => ({
3126
+ key,
3127
+ color,
3128
+ label: key
3129
+ }));
3130
+ };
3131
+ var calculateYAxisWidth = (data, yAxisKey) => {
3132
+ if (!data || data.length === 0) return CHART_CONSTANTS.AXIS_WIDTH_YAXIS;
3133
+ const maxLength = Math.max(
3134
+ ...data.map((item) => {
3135
+ const value = item[yAxisKey];
3136
+ return String(value || "").length;
3137
+ })
3138
+ );
3139
+ return Math.max(maxLength * 8 + 20, CHART_CONSTANTS.AXIS_WIDTH_YAXIS);
3140
+ };
3141
+ var formatPercentage = (value, decimals = 1) => {
3142
+ return `${(value * 100).toFixed(decimals)}%`;
3143
+ };
3144
+ var formatLargeNumber = (value) => {
3145
+ if (value >= 1e6) {
3146
+ return `${(value / 1e6).toFixed(1)}M`;
3147
+ }
3148
+ if (value >= 1e3) {
3149
+ return `${(value / 1e3).toFixed(1)}K`;
3150
+ }
3151
+ return value.toString();
3152
+ };
3153
+
3154
+ // src/components/ui/charts/chart-labels.tsx
3155
+ import { jsx as jsx13 } from "react/jsx-runtime";
3156
+ var createCustomXAxisLabel = (text, yOffset = 40) => {
3157
+ const CustomXAxisLabel = ({ viewBox }) => {
3158
+ if (!viewBox) return null;
3159
+ const { x, y, width } = viewBox;
3160
+ return /* @__PURE__ */ jsx13("g", { children: /* @__PURE__ */ jsx13("foreignObject", { x, y: y + yOffset, width, height: 20, children: /* @__PURE__ */ jsx13("div", { className: "flex justify-center w-full", children: /* @__PURE__ */ jsx13(Typography, { variant: "label-xs-bold", className: "text-secondary", children: text }) }) }) });
3161
+ };
3162
+ CustomXAxisLabel.displayName = "CustomXAxisLabel";
3163
+ return CustomXAxisLabel;
3164
+ };
3165
+ var createCustomYAxisLabel = (text, leftMargin) => {
3166
+ const CustomYAxisLabel = ({ viewBox }) => {
3167
+ if (!viewBox) return null;
3168
+ const { x, y, height } = viewBox;
3169
+ const offset = leftMargin ? leftMargin + 10 : 110;
3170
+ return /* @__PURE__ */ jsx13("g", { children: /* @__PURE__ */ jsx13("foreignObject", { x: x - offset, y, width: 100, height, children: /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-center h-full transform -rotate-90 whitespace-nowrap", children: /* @__PURE__ */ jsx13(Typography, { variant: "label-xs-bold", className: "text-secondary", children: text }) }) }) });
3171
+ };
3172
+ CustomYAxisLabel.displayName = "CustomYAxisLabel";
3173
+ return CustomYAxisLabel;
3174
+ };
3175
+ var createCustomYAxisRightLabel = (text) => {
3176
+ const CustomYAxisRightLabel = ({ viewBox }) => {
3177
+ if (!viewBox) return null;
3178
+ const { x, y, width, height } = viewBox;
3179
+ return /* @__PURE__ */ jsx13("g", { children: /* @__PURE__ */ jsx13("foreignObject", { x: x + width - 70, y, width: 120, height, children: /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-center h-full transform rotate-90 whitespace-nowrap", children: /* @__PURE__ */ jsx13(Typography, { variant: "label-xs-bold", className: "text-secondary", children: text }) }) }) });
3180
+ };
3181
+ CustomYAxisRightLabel.displayName = "CustomYAxisRightLabel";
3182
+ return CustomYAxisRightLabel;
3183
+ };
3184
+ var customXAxisTick = (props) => {
3185
+ const { x, y, payload } = props;
3186
+ return /* @__PURE__ */ jsx13("g", { transform: `translate(${x},${y})`, children: /* @__PURE__ */ jsx13(
3187
+ "foreignObject",
3188
+ {
3189
+ x: -20,
3190
+ y: 5,
3191
+ width: 40,
3192
+ height: 20,
3193
+ style: { overflow: "visible" },
3194
+ children: /* @__PURE__ */ jsx13(
3195
+ "div",
3196
+ {
3197
+ className: "flex items-start justify-center h-full",
3198
+ style: { overflow: "visible" },
3199
+ children: /* @__PURE__ */ jsx13(
3200
+ Typography,
3201
+ {
3202
+ variant: "body-xs",
3203
+ className: "text-secondary whitespace-nowrap",
3204
+ children: payload.value
3205
+ }
3206
+ )
3207
+ }
3208
+ )
3209
+ }
3210
+ ) });
3211
+ };
3212
+ var customXAxisTickRotated = (props) => {
3213
+ const { x, y, payload } = props;
3214
+ return /* @__PURE__ */ jsx13("g", { transform: `translate(${x},${y})`, children: /* @__PURE__ */ jsx13(
3215
+ "text",
3216
+ {
3217
+ x: 0,
3218
+ y: 0,
3219
+ dy: 10,
3220
+ textAnchor: "end",
3221
+ fill: "currentColor",
3222
+ transform: "rotate(-45)",
3223
+ className: "text-secondary",
3224
+ style: { fontSize: "12px" },
3225
+ children: payload.value
3226
+ }
3227
+ ) });
3228
+ };
3229
+ var customYAxisTick = (props) => {
3230
+ const { x, y, payload } = props;
3231
+ const text = String(payload.value);
3232
+ const estimatedWidth = Math.max(text.length * 8, 80);
3233
+ return /* @__PURE__ */ jsx13(
3234
+ "foreignObject",
3235
+ {
3236
+ x: x - estimatedWidth + 5,
3237
+ y: y - 6,
3238
+ width: estimatedWidth,
3239
+ height: 15,
3240
+ children: /* @__PURE__ */ jsx13("div", { className: "flex justify-end w-full", children: /* @__PURE__ */ jsx13(Typography, { variant: "body-xs", className: "text-secondary", children: payload.value }) })
3241
+ }
3242
+ );
3243
+ };
3244
+
3245
+ // src/components/ui/charts/chart-tooltip.tsx
3246
+ import { Fragment, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
3247
+ function TooltipContainer({
3248
+ children,
3249
+ className = ""
3250
+ }) {
3251
+ return /* @__PURE__ */ jsx14(
3252
+ "div",
3253
+ {
3254
+ className: `bg-light border border-subtle rounded p-2.5 text-dark ${className}`,
3255
+ children
3256
+ }
3257
+ );
3258
+ }
3259
+ function TooltipItem({
3260
+ color,
3261
+ label,
3262
+ value,
3263
+ className = ""
3264
+ }) {
3265
+ return /* @__PURE__ */ jsxs10(Fragment, { children: [
3266
+ /* @__PURE__ */ jsx14("br", {}),
3267
+ /* @__PURE__ */ jsxs10(Typography, { variant: "label-sm", className, children: [
3268
+ /* @__PURE__ */ jsx14(
3269
+ "span",
3270
+ {
3271
+ className: "inline-block w-3 h-3 mr-1.5",
3272
+ style: { backgroundColor: color }
3273
+ }
3274
+ ),
3275
+ label,
3276
+ ": ",
3277
+ value
3278
+ ] })
3279
+ ] });
3280
+ }
3281
+ function GenericTooltip({
3282
+ title,
3283
+ items,
3284
+ className = ""
3285
+ }) {
3286
+ return /* @__PURE__ */ jsxs10(TooltipContainer, { className, children: [
3287
+ title && /* @__PURE__ */ jsx14(Typography, { variant: "label-sm-bold", children: title }),
3288
+ items.map((item, index) => /* @__PURE__ */ jsx14(
3289
+ TooltipItem,
3290
+ {
3291
+ color: item.color,
3292
+ label: item.label,
3293
+ value: item.value
3294
+ },
3295
+ index
3296
+ ))
3297
+ ] });
3298
+ }
3299
+
3300
+ // src/components/ui/charts/bar-chart.tsx
3301
+ import { forwardRef as forwardRef12 } from "react";
3302
+ import {
3303
+ BarChart as RechartsBarChart,
3304
+ Bar,
3305
+ XAxis,
3306
+ YAxis,
3307
+ Tooltip,
3308
+ ResponsiveContainer
3309
+ } from "recharts";
3310
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
3311
+ var BarChart = forwardRef12(
3312
+ ({
3313
+ data,
3314
+ xAxisKey,
3315
+ yAxisKey,
3316
+ title,
3317
+ xAxisLabel,
3318
+ yAxisLabel,
3319
+ barColor = CHART_COLORS.PRIMARY,
3320
+ className = "",
3321
+ rotateXAxisLabels = false,
3322
+ showLegend = false,
3323
+ legendItems = [],
3324
+ onDataPointClick,
3325
+ layout = "horizontal",
3326
+ xAxisType = "category",
3327
+ yAxisType = "number",
3328
+ barDataKey
3329
+ }, ref) => {
3330
+ const handleClick = (data2) => {
3331
+ if (onDataPointClick && data2 && typeof data2 === "object") {
3332
+ onDataPointClick(data2);
3333
+ }
3334
+ };
3335
+ const defaultLegendItems = showLegend && legendItems.length === 0 ? [{ key: yAxisKey, color: barColor, label: yAxisKey }] : legendItems;
3336
+ const hasData = data && data.length > 0;
3337
+ return /* @__PURE__ */ jsxs11(
3338
+ "div",
3339
+ {
3340
+ ref,
3341
+ className: `bg-light border border-subtle mx-6 ${className}`,
3342
+ children: [
3343
+ /* @__PURE__ */ jsx15("div", { className: "flex items-center justify-between px-3 py-2 border-b border-subtle", children: /* @__PURE__ */ jsx15(Typography, { variant: "label-sm-bold", children: title }) }),
3344
+ /* @__PURE__ */ jsx15("div", { className: "pt-2 px-2", children: hasData ? /* @__PURE__ */ jsx15(
3345
+ ResponsiveContainer,
3346
+ {
3347
+ width: "100%",
3348
+ height: CHART_CONSTANTS.STANDARD_HEIGHT,
3349
+ children: /* @__PURE__ */ jsxs11(
3350
+ RechartsBarChart,
3351
+ {
3352
+ data,
3353
+ margin: {
3354
+ ...CHART_CONSTANTS.MARGIN,
3355
+ left: 24,
3356
+ bottom: rotateXAxisLabels ? 60 : 50
3357
+ },
3358
+ onClick: handleClick,
3359
+ layout,
3360
+ children: [
3361
+ /* @__PURE__ */ jsx15(
3362
+ XAxis,
3363
+ {
3364
+ dataKey: xAxisKey,
3365
+ type: xAxisType,
3366
+ axisLine: false,
3367
+ tickLine: false,
3368
+ tick: rotateXAxisLabels ? customXAxisTickRotated : customXAxisTick,
3369
+ interval: 0,
3370
+ height: rotateXAxisLabels ? CHART_CONSTANTS.AXIS_HEIGHT_ROTATED : CHART_CONSTANTS.AXIS_HEIGHT_STANDARD,
3371
+ width: CHART_CONSTANTS.AXIS_WIDTH_STANDARD,
3372
+ label: xAxisLabel ? createCustomXAxisLabel(xAxisLabel, 80) : void 0
3373
+ }
3374
+ ),
3375
+ /* @__PURE__ */ jsx15(
3376
+ YAxis,
3377
+ {
3378
+ axisLine: false,
3379
+ tickLine: false,
3380
+ tick: customYAxisTick,
3381
+ label: yAxisLabel ? createCustomYAxisLabel(yAxisLabel, 40) : void 0,
3382
+ dataKey: yAxisKey,
3383
+ type: yAxisType
3384
+ }
3385
+ ),
3386
+ /* @__PURE__ */ jsx15(
3387
+ Tooltip,
3388
+ {
3389
+ content: ({
3390
+ active,
3391
+ payload,
3392
+ label
3393
+ }) => {
3394
+ if (active && payload && payload.length) {
3395
+ return /* @__PURE__ */ jsx15(
3396
+ GenericTooltip,
3397
+ {
3398
+ title: label?.toString(),
3399
+ items: payload.map((entry) => ({
3400
+ color: entry.color || barColor,
3401
+ label: entry.name || yAxisKey,
3402
+ value: entry.value || 0
3403
+ }))
3404
+ }
3405
+ );
3406
+ }
3407
+ return null;
3408
+ }
3409
+ }
3410
+ ),
3411
+ /* @__PURE__ */ jsx15(
3412
+ Bar,
3413
+ {
3414
+ dataKey: barDataKey || yAxisKey,
3415
+ fill: barColor,
3416
+ name: barDataKey || yAxisKey
3417
+ }
3418
+ ),
3419
+ showLegend && defaultLegendItems.length > 0 && /* @__PURE__ */ jsx15(ChartLegend, { items: defaultLegendItems })
3420
+ ]
3421
+ }
3422
+ )
3423
+ }
3424
+ ) : /* @__PURE__ */ jsx15("div", { className: "flex items-center justify-center h-[500px]", children: /* @__PURE__ */ jsx15(Typography, { variant: "body-md", className: "text-secondary", children: "No data is available" }) }) })
3425
+ ]
3426
+ }
3427
+ );
3428
+ }
3429
+ );
3430
+ BarChart.displayName = "BarChart";
3431
+
3432
+ // src/components/ui/charts/line-chart.tsx
3433
+ import { forwardRef as forwardRef13 } from "react";
3434
+ import {
3435
+ LineChart as RechartsLineChart,
3436
+ Line,
3437
+ XAxis as XAxis2,
3438
+ YAxis as YAxis2,
3439
+ Tooltip as Tooltip2,
3440
+ ResponsiveContainer as ResponsiveContainer2
3441
+ } from "recharts";
3442
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
3443
+ var LineChart = forwardRef13(
3444
+ ({
3445
+ data,
3446
+ xAxisKey,
3447
+ series,
3448
+ title,
3449
+ xAxisLabel,
3450
+ yAxisLabel,
3451
+ onDataPointClick,
3452
+ className = "",
3453
+ showLegend = true,
3454
+ legendItems = []
3455
+ }, ref) => {
3456
+ const handleClick = (data2) => {
3457
+ if (onDataPointClick && data2 && typeof data2 === "object") {
3458
+ onDataPointClick(data2);
3459
+ }
3460
+ };
3461
+ const defaultLegendItems = legendItems.length > 0 ? legendItems : createLegendItems(
3462
+ series.reduce(
3463
+ (acc, s, index) => ({
3464
+ ...acc,
3465
+ [s.dataKey]: s.color || getSeriesColor(index)
3466
+ }),
3467
+ {}
3468
+ )
3469
+ );
3470
+ const hasData = data && data.length > 0;
3471
+ return /* @__PURE__ */ jsxs12(
3472
+ "div",
3473
+ {
3474
+ ref,
3475
+ className: `bg-light border border-subtle mx-6 ${className}`,
3476
+ children: [
3477
+ /* @__PURE__ */ jsx16("div", { className: "flex items-center justify-between px-3 py-2 border-b border-subtle", children: /* @__PURE__ */ jsx16(Typography, { variant: "label-sm-bold", children: title }) }),
3478
+ /* @__PURE__ */ jsx16("div", { className: "pt-2 px-2", children: hasData ? /* @__PURE__ */ jsx16(
3479
+ ResponsiveContainer2,
3480
+ {
3481
+ width: "100%",
3482
+ height: CHART_CONSTANTS.STANDARD_HEIGHT,
3483
+ children: /* @__PURE__ */ jsxs12(
3484
+ RechartsLineChart,
3485
+ {
3486
+ data,
3487
+ margin: {
3488
+ ...CHART_CONSTANTS.MARGIN,
3489
+ left: 24,
3490
+ bottom: 50
3491
+ },
3492
+ onClick: handleClick,
3493
+ children: [
3494
+ /* @__PURE__ */ jsx16(
3495
+ XAxis2,
3496
+ {
3497
+ dataKey: xAxisKey,
3498
+ axisLine: false,
3499
+ tickLine: false,
3500
+ tick: customXAxisTick,
3501
+ interval: 0,
3502
+ height: CHART_CONSTANTS.AXIS_HEIGHT_STANDARD,
3503
+ label: xAxisLabel ? createCustomXAxisLabel(xAxisLabel) : void 0
3504
+ }
3505
+ ),
3506
+ /* @__PURE__ */ jsx16(
3507
+ YAxis2,
3508
+ {
3509
+ axisLine: false,
3510
+ tickLine: false,
3511
+ tick: customYAxisTick,
3512
+ label: yAxisLabel ? createCustomYAxisLabel(yAxisLabel, 40) : void 0
3513
+ }
3514
+ ),
3515
+ /* @__PURE__ */ jsx16(
3516
+ Tooltip2,
3517
+ {
3518
+ content: ({
3519
+ active,
3520
+ payload,
3521
+ label
3522
+ }) => {
3523
+ if (active && payload && payload.length) {
3524
+ return /* @__PURE__ */ jsx16(
3525
+ GenericTooltip,
3526
+ {
3527
+ title: label?.toString(),
3528
+ items: payload.map((entry) => ({
3529
+ color: entry.color || CHART_COLORS.PRIMARY,
3530
+ label: entry.name || entry.dataKey || "",
3531
+ value: entry.value || 0
3532
+ }))
3533
+ }
3534
+ );
3535
+ }
3536
+ return null;
3537
+ }
3538
+ }
3539
+ ),
3540
+ series.map((s, index) => /* @__PURE__ */ jsx16(
3541
+ Line,
3542
+ {
3543
+ type: "monotone",
3544
+ dataKey: s.dataKey,
3545
+ stroke: s.color || getSeriesColor(index),
3546
+ strokeWidth: s.strokeWidth || 2,
3547
+ dot: s.dot !== false ? { r: 4 } : false,
3548
+ activeDot: s.activeDot !== false ? { r: 6 } : false
3549
+ },
3550
+ s.dataKey
3551
+ )),
3552
+ showLegend && defaultLegendItems.length > 0 && /* @__PURE__ */ jsx16(ChartLegend, { items: defaultLegendItems })
3553
+ ]
3554
+ }
3555
+ )
3556
+ }
3557
+ ) : /* @__PURE__ */ jsx16("div", { className: "flex items-center justify-center h-[500px]", children: /* @__PURE__ */ jsx16(Typography, { variant: "body-md", className: "text-secondary", children: "No data is available" }) }) })
3558
+ ]
3559
+ }
3560
+ );
3561
+ }
3562
+ );
3563
+ LineChart.displayName = "LineChart";
3564
+
3565
+ // src/components/ui/charts/pie-chart.tsx
3566
+ import { forwardRef as forwardRef14 } from "react";
3567
+ import { PieChart as RechartsPieChart, Pie, Cell, Tooltip as Tooltip3 } from "recharts";
3568
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
3569
+ var PieChart = forwardRef14(
3570
+ ({
3571
+ data,
3572
+ title,
3573
+ onDataPointClick,
3574
+ className = "",
3575
+ showLegend = true,
3576
+ legendItems = [],
3577
+ innerRadius = "40%",
3578
+ outerRadius = "70%",
3579
+ showLabels = true
3580
+ }, ref) => {
3581
+ const handleClick = (data2) => {
3582
+ if (onDataPointClick && data2 && typeof data2 === "object") {
3583
+ onDataPointClick(data2);
3584
+ }
3585
+ };
3586
+ const defaultLegendItems = legendItems.length > 0 ? legendItems : createLegendItems(
3587
+ data.reduce(
3588
+ (acc, item, index) => ({
3589
+ ...acc,
3590
+ [item.name]: item.color || getSeriesColor(index)
3591
+ }),
3592
+ {}
3593
+ )
3594
+ );
3595
+ const hasData = data && data.length > 0;
3596
+ return /* @__PURE__ */ jsxs13(
3597
+ "div",
3598
+ {
3599
+ ref,
3600
+ className: `bg-light border border-subtle mx-6 ${className}`,
3601
+ children: [
3602
+ /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-between px-3 py-2 border-b border-subtle", children: /* @__PURE__ */ jsx17(Typography, { variant: "label-sm-bold", children: title }) }),
3603
+ /* @__PURE__ */ jsx17("div", { className: "pt-2 px-2", children: hasData ? /* @__PURE__ */ jsx17("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxs13(
3604
+ RechartsPieChart,
3605
+ {
3606
+ width: 600,
3607
+ height: CHART_CONSTANTS.LARGE_HEIGHT,
3608
+ children: [
3609
+ /* @__PURE__ */ jsx17(
3610
+ Pie,
3611
+ {
3612
+ data,
3613
+ innerRadius,
3614
+ outerRadius,
3615
+ dataKey: "value",
3616
+ cy: CHART_CONSTANTS.PIE_CHART_CENTER_Y,
3617
+ cx: CHART_CONSTANTS.PIE_CHART_CENTER_X,
3618
+ label: showLabels,
3619
+ labelLine: false,
3620
+ onClick: handleClick,
3621
+ children: data.map((entry, index) => /* @__PURE__ */ jsx17(
3622
+ Cell,
3623
+ {
3624
+ fill: entry.color || getSeriesColor(index)
3625
+ },
3626
+ `cell-${index}`
3627
+ ))
3628
+ }
3629
+ ),
3630
+ /* @__PURE__ */ jsx17(
3631
+ Tooltip3,
3632
+ {
3633
+ content: ({
3634
+ active,
3635
+ payload
3636
+ }) => {
3637
+ if (active && payload && payload.length && payload[0]) {
3638
+ const data2 = payload[0].payload;
3639
+ return /* @__PURE__ */ jsx17(
3640
+ GenericTooltip,
3641
+ {
3642
+ title: data2.name,
3643
+ items: [
3644
+ {
3645
+ color: data2.color || CHART_COLORS.PRIMARY,
3646
+ label: "Value",
3647
+ value: data2.value
3648
+ }
3649
+ ]
3650
+ }
3651
+ );
3652
+ }
3653
+ return null;
3654
+ }
3655
+ }
3656
+ ),
3657
+ showLegend && defaultLegendItems.length > 0 && /* @__PURE__ */ jsx17(ChartLegend, { items: defaultLegendItems, y: 400 })
3658
+ ]
3659
+ }
3660
+ ) }) : /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-center h-[500px]", children: /* @__PURE__ */ jsx17(Typography, { variant: "body-md", className: "text-secondary", children: "No data is available" }) }) })
3661
+ ]
3662
+ }
3663
+ );
3664
+ }
3665
+ );
3666
+ PieChart.displayName = "PieChart";
3667
+
3668
+ // src/components/ui/table.tsx
3669
+ import { useCallback as useCallback2 } from "react";
3670
+ import {
3671
+ flexRender
3672
+ } from "@tanstack/react-table";
3673
+ import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
3674
+ function Table({
3675
+ table,
3676
+ className,
3677
+ showPagination = false,
3678
+ paginationClassName
3679
+ }) {
3680
+ const currentPage = table.getState().pagination.pageIndex;
3681
+ const pageSize = table.getState().pagination.pageSize;
3682
+ const totalPages = table.getPageCount();
3683
+ const totalRows = table.getFilteredRowModel().rows.length;
3684
+ const showingText = totalRows > 0 ? "Showing " + (currentPage * pageSize + 1) + "-" + Math.min((currentPage + 1) * pageSize, totalRows) + " of " + totalRows + " results" : "No results found";
3685
+ const handlePreviousPage = useCallback2(() => {
3686
+ table.previousPage();
3687
+ }, [table]);
3688
+ const handleNextPage = useCallback2(() => {
3689
+ table.nextPage();
3690
+ }, [table]);
3691
+ const handlePageChange = useCallback2(
3692
+ (pageIndex) => {
3693
+ table.setPageIndex(pageIndex);
3694
+ },
3695
+ [table]
3696
+ );
3697
+ const handlePageSizeChange = useCallback2(
3698
+ (value) => {
3699
+ table.setPageSize(Number(value));
3700
+ },
3701
+ [table]
3702
+ );
3703
+ return /* @__PURE__ */ jsxs14("div", { children: [
3704
+ /* @__PURE__ */ jsx18("div", { className: cn("overflow-x-auto", className), children: /* @__PURE__ */ jsxs14("table", { className: "min-w-full divide-y divide-border", children: [
3705
+ /* @__PURE__ */ jsx18("thead", { className: "bg-dark text-light", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx18("tr", { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx18("th", { className: "px-6 py-3 text-left", children: /* @__PURE__ */ jsxs14(
3706
+ "div",
3707
+ {
3708
+ className: `flex items-center space-x-1 ${header.column.getCanSort() ? "cursor-pointer select-none" : ""}`,
3709
+ onClick: header.column.getToggleSortingHandler(),
3710
+ children: [
3711
+ /* @__PURE__ */ jsx18(
3712
+ Typography,
3713
+ {
3714
+ variant: "label-xs",
3715
+ className: "text-light uppercase tracking-wider",
3716
+ children: flexRender(
3717
+ header.column.columnDef.header,
3718
+ header.getContext()
3719
+ )
3720
+ }
3721
+ ),
3722
+ header.column.getCanSort() && /* @__PURE__ */ jsxs14("span", { className: "ml-1", children: [
3723
+ header.column.getIsSorted() === "asc" && /* @__PURE__ */ jsx18(ChevronUp, { className: "w-4 h-4 text-light" }),
3724
+ header.column.getIsSorted() === "desc" && /* @__PURE__ */ jsx18(ChevronDown, { className: "w-4 h-4 text-light" })
3725
+ ] })
3726
+ ]
3727
+ }
3728
+ ) }, header.id)) }, headerGroup.id)) }),
3729
+ /* @__PURE__ */ jsx18("tbody", { className: "bg-light divide-y divide-border", children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx18("tr", { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx18("td", { className: "px-6 py-4 whitespace-nowrap", children: /* @__PURE__ */ jsx18(Typography, { variant: "body-sm", children: flexRender(
3730
+ cell.column.columnDef.cell,
3731
+ cell.getContext()
3732
+ ) }) }, cell.id)) }, row.id)) })
3733
+ ] }) }),
3734
+ showPagination && /* @__PURE__ */ jsxs14(
3735
+ "div",
3736
+ {
3737
+ className: cn(
3738
+ "flex items-center justify-between px-6 py-3 bg-light border-t border-subtle",
3739
+ paginationClassName
3740
+ ),
3741
+ children: [
3742
+ /* @__PURE__ */ jsx18("div", { className: "flex items-center", children: /* @__PURE__ */ jsx18(Typography, { variant: "body-sm", className: "text-secondary", children: showingText }) }),
3743
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center space-x-1", children: [
3744
+ /* @__PURE__ */ jsx18(
3745
+ Button,
3746
+ {
3747
+ variant: "ghost",
3748
+ size: "sm",
3749
+ onClick: handlePreviousPage,
3750
+ disabled: !table.getCanPreviousPage(),
3751
+ className: "p-2",
3752
+ children: /* @__PURE__ */ jsx18(ChevronLeft, { className: "w-4 h-4" })
3753
+ }
3754
+ ),
3755
+ Array.from(
3756
+ { length: Math.min(5, table.getPageCount()) },
3757
+ (_, i) => {
3758
+ let pageNumber;
3759
+ if (totalPages <= 5) {
3760
+ pageNumber = i;
3761
+ } else if (currentPage <= 2) {
3762
+ pageNumber = i;
3763
+ } else if (currentPage >= totalPages - 3) {
3764
+ pageNumber = totalPages - 5 + i;
3765
+ } else {
3766
+ pageNumber = currentPage - 2 + i;
3767
+ }
3768
+ const isActive = pageNumber === currentPage;
3769
+ return /* @__PURE__ */ jsx18(
3770
+ Button,
3771
+ {
3772
+ variant: isActive ? "default" : "ghost",
3773
+ size: "sm",
3774
+ onClick: () => handlePageChange(pageNumber),
3775
+ className: "min-w-8 h-8 p-0",
3776
+ children: pageNumber + 1
3777
+ },
3778
+ pageNumber
3779
+ );
3780
+ }
3781
+ ),
3782
+ table.getPageCount() > 5 && currentPage < totalPages - 3 && /* @__PURE__ */ jsxs14(Fragment2, { children: [
3783
+ /* @__PURE__ */ jsx18("span", { className: "px-1 text-secondary", children: "..." }),
3784
+ /* @__PURE__ */ jsx18(Typography, { variant: "body-sm", className: "text-secondary", children: totalPages })
3785
+ ] }),
3786
+ /* @__PURE__ */ jsx18(
3787
+ Button,
3788
+ {
3789
+ variant: "ghost",
3790
+ size: "sm",
3791
+ onClick: handleNextPage,
3792
+ disabled: !table.getCanNextPage(),
3793
+ className: "p-2",
3794
+ children: /* @__PURE__ */ jsx18(ChevronRight, { className: "w-4 h-4" })
3795
+ }
3796
+ )
3797
+ ] }),
3798
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-3 w-48", children: [
3799
+ /* @__PURE__ */ jsx18(
3800
+ Typography,
3801
+ {
3802
+ variant: "body-sm",
3803
+ className: "text-secondary whitespace-nowrap",
3804
+ children: "Rows per page:"
3805
+ }
3806
+ ),
3807
+ /* @__PURE__ */ jsxs14(
3808
+ Select,
3809
+ {
3810
+ value: table.getState().pagination.pageSize.toString(),
3811
+ onValueChange: handlePageSizeChange,
3812
+ children: [
3813
+ /* @__PURE__ */ jsx18(SelectTrigger, { className: "min-w-0 h-8", children: /* @__PURE__ */ jsx18(SelectValue, {}) }),
3814
+ /* @__PURE__ */ jsx18(SelectContent, { children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ jsx18(SelectItem, { value: size.toString(), children: size }, size)) })
3815
+ ]
3816
+ }
3817
+ )
3818
+ ] })
3819
+ ]
3820
+ }
3821
+ )
3822
+ ] });
3823
+ }
3021
3824
  export {
3022
3825
  ArrowDown,
3023
3826
  ArrowLeft,
3024
3827
  ArrowRight,
3025
3828
  ArrowUp,
3026
3829
  Badge,
3830
+ BarChart,
3027
3831
  Bell,
3028
3832
  Bookmark,
3029
3833
  Button,
3834
+ CHART_COLORS,
3835
+ CHART_CONSTANTS,
3836
+ COLOR_SCHEMES,
3030
3837
  Calendar,
3031
3838
  CaretDown,
3032
3839
  CaretLeft,
3033
3840
  CaretRight,
3034
3841
  CaretUp,
3842
+ ChartLegend,
3035
3843
  Chat,
3036
3844
  Check,
3037
3845
  CheckIcon,
@@ -3072,6 +3880,7 @@ export {
3072
3880
  Filter,
3073
3881
  FilterDescending,
3074
3882
  FormField,
3883
+ GenericTooltip,
3075
3884
  GraphBar,
3076
3885
  GraphDonut,
3077
3886
  GraphLine,
@@ -3080,6 +3889,7 @@ export {
3080
3889
  Home,
3081
3890
  Information,
3082
3891
  TypedInput as Input,
3892
+ LineChart,
3083
3893
  Location,
3084
3894
  Lock,
3085
3895
  Logout,
@@ -3087,6 +3897,7 @@ export {
3087
3897
  Minus,
3088
3898
  MoreMenu,
3089
3899
  Phone,
3900
+ PieChart,
3090
3901
  Plus,
3091
3902
  QuestionCircle,
3092
3903
  Select,
@@ -3103,10 +3914,13 @@ export {
3103
3914
  Star,
3104
3915
  Statement,
3105
3916
  Table,
3917
+ TableIcon,
3106
3918
  Tabs,
3107
3919
  TabsContent,
3108
3920
  TabsList,
3109
3921
  TabsTrigger,
3922
+ TooltipContainer,
3923
+ TooltipItem,
3110
3924
  Trash,
3111
3925
  Typography,
3112
3926
  Upload,
@@ -3117,7 +3931,20 @@ export {
3117
3931
  X,
3118
3932
  badgeVariants,
3119
3933
  buttonVariants,
3934
+ calculateYAxisWidth,
3120
3935
  checkboxVariants,
3936
+ createCustomXAxisLabel,
3937
+ createCustomYAxisLabel,
3938
+ createCustomYAxisRightLabel,
3939
+ createLegendItems,
3940
+ customXAxisTick,
3941
+ customXAxisTickRotated,
3942
+ customYAxisTick,
3943
+ formatLargeNumber,
3944
+ formatPercentage,
3945
+ getHeatmapColor,
3946
+ getPerformanceColor,
3947
+ getSeriesColor,
3121
3948
  inputVariants,
3122
3949
  selectTriggerVariants,
3123
3950
  tabsVariants,