@kala-ui/react-app 0.1.0-beta.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +36 -0
  4. package/dist/components/app-shell/app-shell.d.ts +54 -0
  5. package/dist/components/app-shell/app-shell.js +91 -0
  6. package/dist/components/app-shell/index.d.ts +1 -0
  7. package/dist/components/app-shell/index.js +2 -0
  8. package/dist/components/charts/area-chart.d.ts +6 -0
  9. package/dist/components/charts/area-chart.js +172 -0
  10. package/dist/components/charts/bar-chart.d.ts +6 -0
  11. package/dist/components/charts/bar-chart.js +153 -0
  12. package/dist/components/charts/chart-skeleton.d.ts +36 -0
  13. package/dist/components/charts/chart-skeleton.js +13 -0
  14. package/dist/components/charts/chart.d.ts +25 -0
  15. package/dist/components/charts/chart.js +48 -0
  16. package/dist/components/charts/chart.types.d.ts +196 -0
  17. package/dist/components/charts/chart.types.js +6 -0
  18. package/dist/components/charts/donut-chart.d.ts +7 -0
  19. package/dist/components/charts/donut-chart.js +146 -0
  20. package/dist/components/charts/index.d.ts +14 -0
  21. package/dist/components/charts/index.js +15 -0
  22. package/dist/components/charts/line-chart.d.ts +6 -0
  23. package/dist/components/charts/line-chart.js +158 -0
  24. package/dist/components/charts/radial-bar-chart.d.ts +6 -0
  25. package/dist/components/charts/radial-bar-chart.js +115 -0
  26. package/dist/components/charts/theme-utils.d.ts +77 -0
  27. package/dist/components/charts/theme-utils.js +243 -0
  28. package/dist/components/charts/use-theme-aware-chart.d.ts +12 -0
  29. package/dist/components/charts/use-theme-aware-chart.js +68 -0
  30. package/dist/components/charts/utils.d.ts +56 -0
  31. package/dist/components/charts/utils.js +135 -0
  32. package/dist/components/data-table/column-filters.d.ts +14 -0
  33. package/dist/components/data-table/column-filters.js +51 -0
  34. package/dist/components/data-table/column-header-filter.d.ts +14 -0
  35. package/dist/components/data-table/column-header-filter.js +75 -0
  36. package/dist/components/data-table/data-table-body-rows.d.ts +23 -0
  37. package/dist/components/data-table/data-table-body-rows.js +43 -0
  38. package/dist/components/data-table/data-table-filter-chips.d.ts +14 -0
  39. package/dist/components/data-table/data-table-filter-chips.js +42 -0
  40. package/dist/components/data-table/data-table-header-row.d.ts +21 -0
  41. package/dist/components/data-table/data-table-header-row.js +35 -0
  42. package/dist/components/data-table/data-table-skeleton.d.ts +49 -0
  43. package/dist/components/data-table/data-table-skeleton.js +32 -0
  44. package/dist/components/data-table/data-table-toolbar.d.ts +18 -0
  45. package/dist/components/data-table/data-table-toolbar.js +25 -0
  46. package/dist/components/data-table/data-table.d.ts +23 -0
  47. package/dist/components/data-table/data-table.js +250 -0
  48. package/dist/components/data-table/data-table.types.d.ts +305 -0
  49. package/dist/components/data-table/data-table.types.js +6 -0
  50. package/dist/components/data-table/index.d.ts +6 -0
  51. package/dist/components/data-table/index.js +6 -0
  52. package/dist/components/data-table/pagination-nav.d.ts +15 -0
  53. package/dist/components/data-table/pagination-nav.js +23 -0
  54. package/dist/components/data-table/useTableState.d.ts +29 -0
  55. package/dist/components/data-table/useTableState.js +312 -0
  56. package/dist/components/dnd/dnd.d.ts +118 -0
  57. package/dist/components/dnd/dnd.js +128 -0
  58. package/dist/components/dnd/index.d.ts +1 -0
  59. package/dist/components/dnd/index.js +2 -0
  60. package/dist/components/footer/footer.d.ts +37 -0
  61. package/dist/components/footer/footer.js +8 -0
  62. package/dist/components/footer/index.d.ts +2 -0
  63. package/dist/components/footer/index.js +2 -0
  64. package/dist/components/header/header-skeleton.d.ts +54 -0
  65. package/dist/components/header/header-skeleton.js +23 -0
  66. package/dist/components/header/header.d.ts +40 -0
  67. package/dist/components/header/header.js +77 -0
  68. package/dist/components/header/header.types.d.ts +39 -0
  69. package/dist/components/header/header.types.js +2 -0
  70. package/dist/components/header/index.d.ts +4 -0
  71. package/dist/components/header/index.js +3 -0
  72. package/dist/components/metric-card/index.d.ts +2 -0
  73. package/dist/components/metric-card/index.js +3 -0
  74. package/dist/components/metric-card/metric-card-skeleton.d.ts +32 -0
  75. package/dist/components/metric-card/metric-card-skeleton.js +29 -0
  76. package/dist/components/metric-card/metric-card.d.ts +16 -0
  77. package/dist/components/metric-card/metric-card.js +55 -0
  78. package/dist/components/metric-card/metric-card.types.d.ts +14 -0
  79. package/dist/components/metric-card/metric-card.types.js +2 -0
  80. package/dist/components/nav-link/index.d.ts +1 -0
  81. package/dist/components/nav-link/index.js +2 -0
  82. package/dist/components/nav-link/nav-link.d.ts +26 -0
  83. package/dist/components/nav-link/nav-link.js +23 -0
  84. package/dist/components/navigation/index.d.ts +4 -0
  85. package/dist/components/navigation/index.js +3 -0
  86. package/dist/components/navigation/navigation-skeleton.d.ts +54 -0
  87. package/dist/components/navigation/navigation-skeleton.js +23 -0
  88. package/dist/components/navigation/navigation.d.ts +26 -0
  89. package/dist/components/navigation/navigation.js +44 -0
  90. package/dist/components/session-card/index.d.ts +2 -0
  91. package/dist/components/session-card/index.js +3 -0
  92. package/dist/components/session-card/session-card-skeleton.d.ts +31 -0
  93. package/dist/components/session-card/session-card-skeleton.js +28 -0
  94. package/dist/components/session-card/session-card.d.ts +27 -0
  95. package/dist/components/session-card/session-card.js +67 -0
  96. package/dist/components/sidebar/index.d.ts +3 -0
  97. package/dist/components/sidebar/index.js +3 -0
  98. package/dist/components/sidebar/sidebar-skeleton.d.ts +54 -0
  99. package/dist/components/sidebar/sidebar-skeleton.js +23 -0
  100. package/dist/components/sidebar/sidebar.d.ts +46 -0
  101. package/dist/components/sidebar/sidebar.js +69 -0
  102. package/dist/components/social-login-button/index.d.ts +1 -0
  103. package/dist/components/social-login-button/index.js +2 -0
  104. package/dist/components/social-login-button/social-login-button.d.ts +20 -0
  105. package/dist/components/social-login-button/social-login-button.js +57 -0
  106. package/dist/components/social-login-buttons/index.d.ts +1 -0
  107. package/dist/components/social-login-buttons/index.js +2 -0
  108. package/dist/components/social-login-buttons/social-login-buttons.d.ts +34 -0
  109. package/dist/components/social-login-buttons/social-login-buttons.js +18 -0
  110. package/dist/components/sparkline-chart/index.d.ts +2 -0
  111. package/dist/components/sparkline-chart/index.js +2 -0
  112. package/dist/components/sparkline-chart/sparkline-chart.d.ts +51 -0
  113. package/dist/components/sparkline-chart/sparkline-chart.js +134 -0
  114. package/dist/components/user-menu-dropdown/index.d.ts +1 -0
  115. package/dist/components/user-menu-dropdown/index.js +2 -0
  116. package/dist/components/user-menu-dropdown/user-menu-dropdown.d.ts +31 -0
  117. package/dist/components/user-menu-dropdown/user-menu-dropdown.js +27 -0
  118. package/dist/index.d.ts +16 -0
  119. package/dist/index.js +19 -0
  120. package/dist/lib/active-path.d.ts +5 -0
  121. package/dist/lib/active-path.js +12 -0
  122. package/dist/styles/app.css +2125 -0
  123. package/package.json +164 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @kala-ui/react-app
2
+
3
+ ## 0.1.0-beta.0
4
+
5
+ ### Added
6
+
7
+ - New package splitting Kala UI along architectural lines: standard UI primitives live in `@kala-ui/react`; this package holds the app-level composites.
8
+ - **Application chrome**: `AppShell`, `Header`, `Sidebar`, `Footer`, `Navigation`, `NavLink` (+ `isActivePath` helper).
9
+ - **Data composites**: `DataTable` (sorting, filtering, pagination, selection, bulk actions, server-side mode), `Dnd` sortable lists/boards (dnd-kit).
10
+ - **Charts**: theme-aware ApexCharts wrappers — `AreaChart`, `BarChart`, `LineChart`, `DonutChart`, `RadialBarChart`, `SparklineChart`.
11
+ - **Widgets**: `MetricCard`, `SessionCard`, `UserMenuDropdown`, `SocialLoginButton`, `SocialLoginButtons`.
12
+ - Utilities-only stylesheet (`@kala-ui/react-app/styles`) — theme, tokens, preflight and helpers ship once via `@kala-ui/react/styles`.
13
+ - React Server Component support: every component module is emitted with a `"use client"` banner; `dist/lib` stays server-safe.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kala UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @kala-ui/react-app
2
+
3
+ App-level composite components for [Kala UI](https://github.com/krr2020/kala-ui) — opinionated, multi-component application patterns built on the `@kala-ui/react` primitives.
4
+
5
+ ## What's inside
6
+
7
+ - **Application chrome** — `AppShell`, `Header`, `Sidebar`, `Footer`, `Navigation`, `NavLink`
8
+ - **Data-heavy composites** — `DataTable` (sorting / filtering / pagination / selection / server-side), `Dnd` (dnd-kit sortable lists and boards)
9
+ - **Charts** — `AreaChart`, `BarChart`, `LineChart`, `DonutChart`, `RadialBarChart`, `SparklineChart` (ApexCharts wrappers, theme-aware)
10
+ - **Dashboard & domain widgets** — `MetricCard`, `SessionCard`, `UserMenuDropdown`, `SocialLoginButton(s)`
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @kala-ui/react-app @kala-ui/react
16
+ ```
17
+
18
+ Import the core stylesheet first, then this package's utilities:
19
+
20
+ ```css
21
+ @import "@kala-ui/react/styles";
22
+ @import "@kala-ui/react-app/styles";
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```tsx
28
+ import { Button, ThemeProvider } from "@kala-ui/react";
29
+ import { AppShell, DataTable } from "@kala-ui/react-app";
30
+ ```
31
+
32
+ See the repository README and [THEMING.md](https://github.com/krr2020/kala-ui/blob/main/THEMING.md) for theming, dark mode and framework integration.
33
+
34
+ ## License
35
+
36
+ MIT
@@ -0,0 +1,54 @@
1
+ import * as React from "react";
2
+ export interface AppShellProps extends React.ComponentProps<"div"> {
3
+ /** Header configuration */
4
+ header?: {
5
+ height: number | string;
6
+ };
7
+ /**
8
+ * Navbar configuration. The navbar sits off-canvas below `breakpoint`
9
+ * and reserves Main's left padding from it upward.
10
+ */
11
+ navbar?: {
12
+ width: number | string;
13
+ breakpoint?: "sm" | "md" | "lg" | "xl";
14
+ };
15
+ /** Aside configuration. Mirrors the navbar on the right edge. */
16
+ aside?: {
17
+ width: number | string;
18
+ breakpoint?: "sm" | "md" | "lg" | "xl";
19
+ };
20
+ /** Footer configuration */
21
+ footer?: {
22
+ height: number | string;
23
+ };
24
+ /** Padding for the main content */
25
+ padding?: "none" | "xs" | "sm" | "md" | "lg" | "xl";
26
+ }
27
+ declare function AppShellBase({ children, className, header, navbar, aside, footer, padding, ref, ...props }: AppShellProps): React.JSX.Element;
28
+ export declare const AppShell: typeof AppShellBase & {
29
+ Header: typeof AppShellHeader;
30
+ Navbar: typeof AppShellNavbar;
31
+ Main: typeof AppShellMain;
32
+ Aside: typeof AppShellAside;
33
+ Footer: typeof AppShellFooter;
34
+ };
35
+ export interface AppShellHeaderProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
36
+ withBorder?: boolean;
37
+ }
38
+ declare function AppShellHeader({ ref, className, withBorder, ...props }: AppShellHeaderProps): React.JSX.Element | null;
39
+ export interface AppShellNavbarProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
40
+ withBorder?: boolean;
41
+ }
42
+ declare function AppShellNavbar({ ref, className, withBorder, ...props }: AppShellNavbarProps): React.JSX.Element | null;
43
+ export interface AppShellAsideProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
44
+ withBorder?: boolean;
45
+ }
46
+ declare function AppShellAside({ ref, className, withBorder, ...props }: AppShellAsideProps): React.JSX.Element | null;
47
+ export interface AppShellMainProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
48
+ }
49
+ declare function AppShellMain({ ref, className, ...props }: AppShellMainProps): React.JSX.Element;
50
+ export interface AppShellFooterProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
51
+ withBorder?: boolean;
52
+ }
53
+ declare function AppShellFooter({ ref, className, withBorder, ...props }: AppShellFooterProps): React.JSX.Element | null;
54
+ export {};
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Box } from "@kala-ui/react/box";
4
+ import { cn } from "@kala-ui/react/lib/utils";
5
+ import * as React from "react";
6
+ const AppShellContext = React.createContext({});
7
+ function AppShellBase({ children, className, header, navbar, aside, footer, padding = "md", ref, ...props }) {
8
+ // Convert padding to Tailwind class or CSS value
9
+ const _paddingClasses = {
10
+ none: "p-0",
11
+ xs: "p-2",
12
+ sm: "p-3",
13
+ md: "p-4",
14
+ lg: "p-6",
15
+ xl: "p-8",
16
+ };
17
+ const cssVars = {
18
+ "--app-shell-header-height": typeof header?.height === "number"
19
+ ? `${header.height}px`
20
+ : (header?.height ?? "0px"),
21
+ "--app-shell-footer-height": typeof footer?.height === "number"
22
+ ? `${footer.height}px`
23
+ : (footer?.height ?? "0px"),
24
+ "--app-shell-navbar-width": typeof navbar?.width === "number"
25
+ ? `${navbar.width}px`
26
+ : (navbar?.width ?? "0px"),
27
+ "--app-shell-aside-width": typeof aside?.width === "number"
28
+ ? `${aside.width}px`
29
+ : (aside?.width ?? "0px"),
30
+ };
31
+ return (_jsx(AppShellContext.Provider, { value: { header, navbar, aside, footer, padding }, children: _jsx(Box, { ref: ref, className: cn("flex min-h-screen flex-col bg-background text-foreground", className), style: cssVars, ...props, children: children }) }));
32
+ }
33
+ export const AppShell = Object.assign(AppShellBase, {
34
+ Header: AppShellHeader,
35
+ Navbar: AppShellNavbar,
36
+ Main: AppShellMain,
37
+ Aside: AppShellAside,
38
+ Footer: AppShellFooter,
39
+ });
40
+ function AppShellHeader({ ref, className, withBorder = true, ...props }) {
41
+ const { header } = React.useContext(AppShellContext);
42
+ if (!header)
43
+ return null;
44
+ return (_jsx(Box, { as: "header", ref: ref, className: cn("fixed top-0 left-0 right-0 z-50 flex items-center bg-background px-4", withBorder && "border-b", className), style: { height: "var(--app-shell-header-height)" }, ...props }));
45
+ }
46
+ function AppShellNavbar({ ref, className, withBorder = true, ...props }) {
47
+ const { navbar } = React.useContext(AppShellContext);
48
+ if (!navbar)
49
+ return null;
50
+ // Off-canvas below the configured breakpoint, docked from it upward.
51
+ const variant = `${navbar.breakpoint ?? "md"}:`;
52
+ return (_jsx(Box, { as: "nav", ref: ref, className: cn("fixed left-0 z-40 flex flex-col bg-background transition-transform duration-300 ease-in-out", withBorder && "border-r", "-translate-x-full", `${variant}translate-x-0`, className), style: {
53
+ width: "var(--app-shell-navbar-width)",
54
+ top: "var(--app-shell-header-height)",
55
+ height: "calc(100vh - var(--app-shell-header-height))",
56
+ }, ...props }));
57
+ }
58
+ function AppShellAside({ ref, className, withBorder = true, ...props }) {
59
+ const { aside } = React.useContext(AppShellContext);
60
+ if (!aside)
61
+ return null;
62
+ const variant = `${aside.breakpoint ?? "md"}:`;
63
+ return (_jsx(Box, { as: "aside", ref: ref, className: cn("fixed right-0 z-40 flex flex-col bg-background transition-transform duration-300 ease-in-out", withBorder && "border-l", "translate-x-full", `${variant}translate-x-0`, className), style: {
64
+ width: "var(--app-shell-aside-width)",
65
+ top: "var(--app-shell-header-height)",
66
+ height: "calc(100vh - var(--app-shell-header-height))",
67
+ }, ...props }));
68
+ }
69
+ function AppShellMain({ ref, className, ...props }) {
70
+ const { header, navbar, aside, footer, padding } = React.useContext(AppShellContext);
71
+ const paddingClasses = {
72
+ none: "p-0",
73
+ xs: "p-2",
74
+ sm: "p-3",
75
+ md: "p-4",
76
+ lg: "p-6",
77
+ xl: "p-8",
78
+ };
79
+ return (_jsx(Box, { as: "main", ref: ref, className: cn("flex-1 transition-all duration-300 ease-in-out", padding && paddingClasses[padding], header && "pt-[var(--app-shell-header-height)]", footer && "pb-[var(--app-shell-footer-height)]",
80
+ // Side offsets only reserve space while the fixed panels are
81
+ // actually docked (breakpoint and up).
82
+ navbar &&
83
+ `${navbar.breakpoint ?? "md"}:pl-[var(--app-shell-navbar-width)]`, aside &&
84
+ `${aside.breakpoint ?? "md"}:pr-[var(--app-shell-aside-width)]`, className), ...props }));
85
+ }
86
+ function AppShellFooter({ ref, className, withBorder = true, ...props }) {
87
+ const { footer } = React.useContext(AppShellContext);
88
+ if (!footer)
89
+ return null;
90
+ return (_jsx(Box, { as: "footer", ref: ref, className: cn("fixed bottom-0 left-0 right-0 z-50 flex items-center bg-background px-4", withBorder && "border-t", className), style: { height: "var(--app-shell-footer-height)" }, ...props }));
91
+ }
@@ -0,0 +1 @@
1
+ export * from "./app-shell";
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export * from "./app-shell.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Area Chart Component
3
+ * Beautiful area charts with gradient fills, perfect for time series and trends
4
+ */
5
+ import type { AreaChartProps } from "./chart.types";
6
+ export declare function AreaChart({ series, categories, colors, height, width, className, title, subtitle, toolbar, animations, curve, stacked, dataLabels, yAxisLabel, referenceLines, isLoading, emptyMessage, options: customOptions, }: AreaChartProps): import("react").JSX.Element;
@@ -0,0 +1,172 @@
1
+ "use client";
2
+ /**
3
+ * Area Chart Component
4
+ * Beautiful area charts with gradient fills, perfect for time series and trends
5
+ */
6
+ "use client";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { cn } from "@kala-ui/react/lib/utils";
9
+ import { useMemo } from "react";
10
+ import { Chart, getTooltipTheme } from "./chart.js";
11
+ import { useThemeAwareChart } from "./use-theme-aware-chart.js";
12
+ import { getDefaultChartOptions } from "./utils.js";
13
+ /**
14
+ * Check if series data is empty (no series or all series have empty data arrays)
15
+ */
16
+ function isSeriesEmpty(series) {
17
+ if (series.length === 0)
18
+ return true;
19
+ return series.every((s) => !s.data || (Array.isArray(s.data) && s.data.length === 0));
20
+ }
21
+ export function AreaChart({ series, categories, colors, height = 350, width = "100%", className, title, subtitle, toolbar = false, animations = true, curve = "smooth", stacked = false, dataLabels = false, yAxisLabel, referenceLines = [], isLoading, emptyMessage, options: customOptions, }) {
22
+ const { colors: themeColors } = useThemeAwareChart();
23
+ const isEmpty = !isLoading && isSeriesEmpty(series);
24
+ const chartOptions = useMemo(() => {
25
+ const baseOptions = getDefaultChartOptions();
26
+ // Use theme-aware colors if not provided
27
+ const chartColors = colors || themeColors.mixed;
28
+ const options = {
29
+ ...baseOptions,
30
+ chart: {
31
+ ...baseOptions.chart,
32
+ type: "area",
33
+ stacked,
34
+ toolbar: {
35
+ show: toolbar,
36
+ tools: {
37
+ download: true,
38
+ selection: true,
39
+ zoom: true,
40
+ zoomin: true,
41
+ zoomout: true,
42
+ pan: true,
43
+ reset: true,
44
+ },
45
+ },
46
+ animations: {
47
+ enabled: animations,
48
+ speed: 800,
49
+ },
50
+ },
51
+ colors: chartColors,
52
+ dataLabels: {
53
+ enabled: dataLabels,
54
+ },
55
+ stroke: {
56
+ curve,
57
+ width: 2,
58
+ },
59
+ fill: {
60
+ type: "gradient",
61
+ gradient: {
62
+ shadeIntensity: 1,
63
+ opacityFrom: 0.7,
64
+ opacityTo: 0.2,
65
+ stops: [0, 90, 100],
66
+ },
67
+ },
68
+ xaxis: {
69
+ categories,
70
+ labels: {
71
+ style: {
72
+ colors: "var(--muted-foreground)",
73
+ fontSize: "12px",
74
+ },
75
+ },
76
+ axisBorder: {
77
+ color: "var(--border)",
78
+ },
79
+ axisTicks: {
80
+ color: "var(--border)",
81
+ },
82
+ },
83
+ yaxis: {
84
+ ...(yAxisLabel && {
85
+ title: {
86
+ text: yAxisLabel,
87
+ style: {
88
+ color: "var(--muted-foreground)",
89
+ fontSize: "12px",
90
+ },
91
+ },
92
+ }),
93
+ labels: {
94
+ style: {
95
+ colors: "var(--muted-foreground)",
96
+ fontSize: "12px",
97
+ },
98
+ },
99
+ },
100
+ grid: {
101
+ borderColor: "var(--border)",
102
+ strokeDashArray: 3,
103
+ },
104
+ tooltip: {
105
+ theme: getTooltipTheme(),
106
+ x: {
107
+ show: true,
108
+ },
109
+ y: {
110
+ formatter: (value) => value.toLocaleString(),
111
+ },
112
+ },
113
+ legend: {
114
+ position: "top",
115
+ horizontalAlign: "right",
116
+ labels: {
117
+ colors: "var(--foreground)",
118
+ },
119
+ },
120
+ ...(title && {
121
+ title: {
122
+ text: title,
123
+ style: {
124
+ fontSize: "16px",
125
+ fontWeight: "600",
126
+ color: "var(--foreground)",
127
+ },
128
+ },
129
+ }),
130
+ ...(subtitle && {
131
+ subtitle: {
132
+ text: subtitle,
133
+ style: {
134
+ fontSize: "12px",
135
+ color: "var(--muted-foreground)",
136
+ },
137
+ },
138
+ }),
139
+ annotations: {
140
+ yaxis: referenceLines.map((line) => ({
141
+ y: line.value,
142
+ borderColor: line.color || themeColors.destructive[0],
143
+ strokeDashArray: line.dashArray || 3,
144
+ label: {
145
+ text: line.label || "",
146
+ style: {
147
+ color: "var(--destructive-foreground)",
148
+ background: line.color || themeColors.destructive[0],
149
+ },
150
+ },
151
+ })),
152
+ },
153
+ ...customOptions,
154
+ };
155
+ return options;
156
+ }, [
157
+ colors,
158
+ themeColors,
159
+ categories,
160
+ toolbar,
161
+ animations,
162
+ curve,
163
+ stacked,
164
+ dataLabels,
165
+ yAxisLabel,
166
+ title,
167
+ subtitle,
168
+ referenceLines,
169
+ customOptions,
170
+ ]);
171
+ return (_jsx(Chart, { className: cn("w-full", className), options: chartOptions, series: series, type: "area", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
172
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Bar Chart Component
3
+ * Vertical and horizontal bar charts for comparing values across categories
4
+ */
5
+ import type { BarChartProps } from "./chart.types";
6
+ export declare function BarChart({ series, categories, colors, height, width, className, title, subtitle, toolbar, animations, horizontal, stacked, dataLabels, barWidth, isLoading, emptyMessage, options: customOptions, }: BarChartProps): import("react").JSX.Element;
@@ -0,0 +1,153 @@
1
+ "use client";
2
+ /**
3
+ * Bar Chart Component
4
+ * Vertical and horizontal bar charts for comparing values across categories
5
+ */
6
+ "use client";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { cn } from "@kala-ui/react/lib/utils";
9
+ import { useMemo } from "react";
10
+ import { Chart, getTooltipTheme } from "./chart.js";
11
+ import { useThemeAwareChart } from "./use-theme-aware-chart.js";
12
+ import { getDefaultChartOptions } from "./utils.js";
13
+ /**
14
+ * Check if series data is empty (no series or all series have empty data arrays)
15
+ */
16
+ function isSeriesEmpty(series) {
17
+ if (series.length === 0)
18
+ return true;
19
+ return series.every((s) => !s.data || (Array.isArray(s.data) && s.data.length === 0));
20
+ }
21
+ export function BarChart({ series, categories, colors, height = 350, width = "100%", className, title, subtitle, toolbar = false, animations = true, horizontal = false, stacked = false, dataLabels = false, barWidth = 70, isLoading, emptyMessage, options: customOptions, }) {
22
+ const { colors: themeColors } = useThemeAwareChart();
23
+ const isEmpty = !isLoading && isSeriesEmpty(series);
24
+ const chartOptions = useMemo(() => {
25
+ const baseOptions = getDefaultChartOptions();
26
+ // Use theme-aware colors if not provided
27
+ const chartColors = colors || themeColors.mixed;
28
+ const options = {
29
+ ...baseOptions,
30
+ chart: {
31
+ ...baseOptions.chart,
32
+ type: "bar",
33
+ stacked,
34
+ toolbar: {
35
+ show: toolbar,
36
+ tools: {
37
+ download: true,
38
+ selection: true,
39
+ zoom: true,
40
+ zoomin: true,
41
+ zoomout: true,
42
+ pan: true,
43
+ reset: true,
44
+ },
45
+ },
46
+ animations: {
47
+ enabled: animations,
48
+ speed: 800,
49
+ },
50
+ },
51
+ colors: chartColors,
52
+ plotOptions: {
53
+ bar: {
54
+ horizontal,
55
+ borderRadius: 4,
56
+ columnWidth: `${barWidth}%`,
57
+ barHeight: `${barWidth}%`,
58
+ dataLabels: {
59
+ position: horizontal ? "top" : "center",
60
+ },
61
+ },
62
+ },
63
+ dataLabels: {
64
+ enabled: dataLabels,
65
+ style: {
66
+ fontSize: "12px",
67
+ colors: ["var(--foreground)"],
68
+ },
69
+ },
70
+ stroke: {
71
+ show: true,
72
+ width: 1,
73
+ colors: ["transparent"],
74
+ },
75
+ xaxis: {
76
+ categories,
77
+ labels: {
78
+ style: {
79
+ colors: "var(--muted-foreground)",
80
+ fontSize: "12px",
81
+ },
82
+ },
83
+ axisBorder: {
84
+ color: "var(--border)",
85
+ },
86
+ axisTicks: {
87
+ color: "var(--border)",
88
+ },
89
+ },
90
+ yaxis: {
91
+ labels: {
92
+ style: {
93
+ colors: "var(--muted-foreground)",
94
+ fontSize: "12px",
95
+ },
96
+ formatter: (value) => value.toLocaleString(),
97
+ },
98
+ },
99
+ grid: {
100
+ borderColor: "var(--border)",
101
+ strokeDashArray: 3,
102
+ },
103
+ tooltip: {
104
+ theme: getTooltipTheme(),
105
+ y: {
106
+ formatter: (value) => value.toLocaleString(),
107
+ },
108
+ },
109
+ legend: {
110
+ position: "top",
111
+ horizontalAlign: "right",
112
+ labels: {
113
+ colors: "var(--foreground)",
114
+ },
115
+ },
116
+ ...(title && {
117
+ title: {
118
+ text: title,
119
+ style: {
120
+ fontSize: "16px",
121
+ fontWeight: "600",
122
+ color: "var(--foreground)",
123
+ },
124
+ },
125
+ }),
126
+ ...(subtitle && {
127
+ subtitle: {
128
+ text: subtitle,
129
+ style: {
130
+ fontSize: "12px",
131
+ color: "var(--muted-foreground)",
132
+ },
133
+ },
134
+ }),
135
+ ...customOptions,
136
+ };
137
+ return options;
138
+ }, [
139
+ colors,
140
+ themeColors,
141
+ categories,
142
+ horizontal,
143
+ stacked,
144
+ dataLabels,
145
+ barWidth,
146
+ toolbar,
147
+ animations,
148
+ title,
149
+ subtitle,
150
+ customOptions,
151
+ ]);
152
+ return (_jsx(Chart, { className: cn("w-full", className), options: chartOptions, series: series, type: "bar", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
153
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Chart Skeleton Component
3
+ * Provides a loading placeholder that matches chart components structure
4
+ * including chart area, legend, and optional table below
5
+ */
6
+ export interface ChartSkeletonProps {
7
+ /**
8
+ * Height of the chart area (default: 350)
9
+ */
10
+ height?: number;
11
+ /**
12
+ * Show legend skeleton (default: true)
13
+ */
14
+ showLegend?: boolean;
15
+ /**
16
+ * Number of legend items to show (default: 4)
17
+ */
18
+ legendCount?: number;
19
+ /**
20
+ * Show table skeleton below chart
21
+ */
22
+ showTable?: boolean;
23
+ /**
24
+ * Number of table rows to show (default: 5)
25
+ */
26
+ tableRows?: number;
27
+ /**
28
+ * Number of table columns to show (default: 3)
29
+ */
30
+ tableColumns?: number;
31
+ /**
32
+ * Custom CSS class
33
+ */
34
+ className?: string;
35
+ }
36
+ export declare function ChartSkeleton({ height, showLegend, legendCount, showTable, tableRows, tableColumns, className, }: ChartSkeletonProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * Chart Skeleton Component
5
+ * Provides a loading placeholder that matches chart components structure
6
+ * including chart area, legend, and optional table below
7
+ */
8
+ import { cn } from "@kala-ui/react/lib/utils";
9
+ import { Skeleton } from "@kala-ui/react/skeleton";
10
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@kala-ui/react/table";
11
+ export function ChartSkeleton({ height = 350, showLegend = true, legendCount = 4, showTable = false, tableRows = 5, tableColumns = 3, className, }) {
12
+ return (_jsxs("div", { className: cn("w-full space-y-4", className), children: [_jsx("div", { className: "w-full rounded-lg border bg-card kala-surface-card", style: { height: `${height}px` }, children: _jsx("div", { className: "flex items-center justify-center h-full", children: _jsx(Skeleton, { className: "h-full w-full" }) }) }), showLegend && (_jsx("div", { className: "flex gap-4 justify-center mt-4", children: Array.from({ length: legendCount }).map((_, i) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-3 w-3 rounded-full" }), _jsx(Skeleton, { className: "h-4 w-16" })] }, `legend-${i}`))) })), showTable && (_jsx("div", { className: "mt-6", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: Array.from({ length: tableColumns }).map((_, index) => (_jsx(TableHead, { children: _jsx(Skeleton, { className: "h-4 w-24" }) }, `header-${index}`))) }) }), _jsx(TableBody, { children: Array.from({ length: tableRows }).map((_, rowIndex) => (_jsx(TableRow, { className: "border-0", children: Array.from({ length: tableColumns }).map((_, colIndex) => (_jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-20" }) }, `cell-${rowIndex}-${colIndex}`))) }, `row-${rowIndex}`))) })] }) }))] }));
13
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Base Chart Component
3
+ * React component for ApexCharts with built-in loading and empty states
4
+ */
5
+ import type { Props } from "react-apexcharts";
6
+ import type { ChartSkeletonConfig } from "./chart.types";
7
+ export interface ChartProps extends Props {
8
+ className?: string;
9
+ isLoading?: boolean;
10
+ isEmpty?: boolean;
11
+ emptyMessage?: string;
12
+ skeletonConfig?: ChartSkeletonConfig;
13
+ skeleton?: React.ReactNode;
14
+ }
15
+ /**
16
+ * Get tooltip theme from DOM safely (SSR-compatible)
17
+ */
18
+ declare function getTooltipTheme(): "dark" | "light";
19
+ /**
20
+ * Base Chart Component - use this as the foundation for all charts
21
+ * Provides consistent styling, loading skeleton, and empty state
22
+ */
23
+ export declare function Chart({ className, isLoading, isEmpty, emptyMessage, skeletonConfig, skeleton, ...props }: ChartProps): import("react").JSX.Element;
24
+ export { ChartSkeleton } from "./chart-skeleton";
25
+ export { getTooltipTheme };