@kala-ui/react-app 0.1.0-beta.4 → 0.1.0-beta.5

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 (101) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/app-shell/app-shell.d.ts +8 -46
  3. package/dist/components/app-shell/app-shell.js +41 -42
  4. package/dist/components/app-shell/app-shell.types.d.ts +45 -0
  5. package/dist/components/app-shell/app-shell.types.js +2 -0
  6. package/dist/components/app-shell/index.d.ts +1 -0
  7. package/dist/components/charts/area-chart.d.ts +1 -1
  8. package/dist/components/charts/area-chart.js +4 -3
  9. package/dist/components/charts/bar-chart.d.ts +1 -1
  10. package/dist/components/charts/bar-chart.js +4 -3
  11. package/dist/components/charts/chart-skeleton.d.ts +0 -21
  12. package/dist/components/charts/chart-skeleton.js +2 -1
  13. package/dist/components/charts/chart-utils.d.ts +56 -0
  14. package/dist/components/charts/chart-utils.js +135 -0
  15. package/dist/components/charts/chart.d.ts +3 -1
  16. package/dist/components/charts/chart.js +13 -3
  17. package/dist/components/charts/chart.types.d.ts +3 -0
  18. package/dist/components/charts/donut-chart.d.ts +1 -1
  19. package/dist/components/charts/donut-chart.js +4 -3
  20. package/dist/components/charts/index.d.ts +1 -1
  21. package/dist/components/charts/index.js +1 -1
  22. package/dist/components/charts/line-chart.d.ts +1 -1
  23. package/dist/components/charts/line-chart.js +4 -3
  24. package/dist/components/charts/radial-bar-chart.d.ts +1 -1
  25. package/dist/components/charts/radial-bar-chart.js +4 -3
  26. package/dist/components/data-table/data-table.js +1 -1
  27. package/dist/components/data-table/index.d.ts +1 -1
  28. package/dist/components/data-table/index.js +1 -1
  29. package/dist/components/data-table/use-table-state.d.ts +29 -0
  30. package/dist/components/data-table/use-table-state.js +312 -0
  31. package/dist/components/dnd/dnd.d.ts +16 -98
  32. package/dist/components/dnd/dnd.js +30 -2
  33. package/dist/components/dnd/dnd.types.d.ts +92 -0
  34. package/dist/components/dnd/dnd.types.js +7 -0
  35. package/dist/components/dnd/index.d.ts +2 -1
  36. package/dist/components/dnd/index.js +1 -1
  37. package/dist/components/footer/footer.d.ts +2 -37
  38. package/dist/components/footer/footer.js +18 -2
  39. package/dist/components/footer/footer.types.d.ts +25 -0
  40. package/dist/components/footer/footer.types.js +2 -0
  41. package/dist/components/footer/index.d.ts +1 -1
  42. package/dist/components/header/header.js +5 -11
  43. package/dist/components/metric-card/index.d.ts +2 -1
  44. package/dist/components/metric-card/metric-card-skeleton.js +2 -1
  45. package/dist/components/metric-card/metric-card.d.ts +2 -14
  46. package/dist/components/metric-card/metric-card.js +22 -28
  47. package/dist/components/metric-card/metric-card.types.d.ts +3 -0
  48. package/dist/components/nav-link/index.d.ts +2 -1
  49. package/dist/components/nav-link/index.js +1 -1
  50. package/dist/components/nav-link/nav-link.d.ts +1 -33
  51. package/dist/components/nav-link/nav-link.js +17 -9
  52. package/dist/components/nav-link/nav-link.types.d.ts +23 -0
  53. package/dist/components/nav-link/nav-link.types.js +2 -0
  54. package/dist/components/navigation/index.d.ts +1 -1
  55. package/dist/components/navigation/navigation.d.ts +1 -24
  56. package/dist/components/navigation/navigation.js +7 -17
  57. package/dist/components/navigation/navigation.types.d.ts +15 -0
  58. package/dist/components/navigation/navigation.types.js +2 -0
  59. package/dist/components/session-card/index.d.ts +2 -1
  60. package/dist/components/session-card/index.js +1 -1
  61. package/dist/components/session-card/session-card-skeleton.d.ts +3 -1
  62. package/dist/components/session-card/session-card-skeleton.js +3 -2
  63. package/dist/components/session-card/session-card.d.ts +3 -26
  64. package/dist/components/session-card/session-card.js +23 -8
  65. package/dist/components/session-card/session-card.types.d.ts +26 -0
  66. package/dist/components/session-card/session-card.types.js +2 -0
  67. package/dist/components/sidebar/sidebar.js +5 -11
  68. package/dist/components/social-login-button/index.d.ts +3 -1
  69. package/dist/components/social-login-button/index.js +2 -1
  70. package/dist/components/social-login-button/social-login-button.d.ts +2 -20
  71. package/dist/components/social-login-button/social-login-button.js +9 -11
  72. package/dist/components/social-login-button/social-login-button.types.d.ts +28 -0
  73. package/dist/components/social-login-button/social-login-button.types.js +2 -0
  74. package/dist/components/social-login-button/social-login-buttons.d.ts +4 -0
  75. package/dist/components/social-login-button/social-login-buttons.js +18 -0
  76. package/dist/components/user-menu-dropdown/index.d.ts +2 -1
  77. package/dist/components/user-menu-dropdown/index.js +1 -1
  78. package/dist/components/user-menu-dropdown/user-menu-dropdown.d.ts +2 -31
  79. package/dist/components/user-menu-dropdown/user-menu-dropdown.js +14 -2
  80. package/dist/components/user-menu-dropdown/user-menu-dropdown.types.d.ts +16 -0
  81. package/dist/components/user-menu-dropdown/user-menu-dropdown.types.js +2 -0
  82. package/dist/config/app-shell.d.ts +13 -0
  83. package/dist/config/app-shell.js +20 -0
  84. package/dist/config/charts.d.ts +23 -0
  85. package/dist/config/charts.js +23 -0
  86. package/dist/config/footer.d.ts +16 -0
  87. package/dist/config/footer.js +16 -0
  88. package/dist/config/index.d.ts +7 -0
  89. package/dist/config/index.js +7 -0
  90. package/dist/config/metric-card.d.ts +26 -0
  91. package/dist/config/metric-card.js +34 -0
  92. package/dist/config/session-card.d.ts +32 -0
  93. package/dist/config/session-card.js +32 -0
  94. package/dist/config/social-login-button.d.ts +15 -0
  95. package/dist/config/social-login-button.js +15 -0
  96. package/dist/config/user-menu-dropdown.d.ts +10 -0
  97. package/dist/config/user-menu-dropdown.js +10 -0
  98. package/dist/index.d.ts +0 -1
  99. package/dist/index.js +0 -1
  100. package/dist/styles/app.css +9 -53
  101. package/package.json +24 -28
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @kala-ui/react-app
2
2
 
3
+ ## 0.1.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5ecd609]
8
+ - Updated dependencies [ed367cc]
9
+ - @kala-ui/react@0.1.0-beta.4
10
+
3
11
  ## 0.1.0-beta.4
4
12
 
5
13
  ### Patch Changes
@@ -1,30 +1,11 @@
1
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;
2
+ import type { AppShellAsideProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarProps, AppShellProps } from "./app-shell.types";
3
+ declare function AppShellBase({ children, className, style, slotStyles: slotStylesRaw, header, navbar, aside, footer, padding, ref, ...props }: AppShellProps): React.JSX.Element;
4
+ declare function AppShellHeader({ ref, className, withBorder, slotStyles: slotStylesRaw, ...props }: AppShellHeaderProps): React.JSX.Element | null;
5
+ declare function AppShellNavbar({ ref, className, withBorder, slotStyles: slotStylesRaw, ...props }: AppShellNavbarProps): React.JSX.Element | null;
6
+ declare function AppShellAside({ ref, className, withBorder, slotStyles: slotStylesRaw, ...props }: AppShellAsideProps): React.JSX.Element | null;
7
+ declare function AppShellMain({ ref, className, slotStyles: slotStylesRaw, ...props }: AppShellMainProps): React.JSX.Element;
8
+ declare function AppShellFooter({ ref, className, withBorder, slotStyles: slotStylesRaw, ...props }: AppShellFooterProps): React.JSX.Element | null;
28
9
  export declare const AppShell: typeof AppShellBase & {
29
10
  Header: typeof AppShellHeader;
30
11
  Navbar: typeof AppShellNavbar;
@@ -32,23 +13,4 @@ export declare const AppShell: typeof AppShellBase & {
32
13
  Aside: typeof AppShellAside;
33
14
  Footer: typeof AppShellFooter;
34
15
  };
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 {};
16
+ export type { AppShellAsideProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarProps, AppShellProps, } from "./app-shell.types";
@@ -1,19 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Box } from "@kala-ui/react/box";
4
+ import { useSlotStyles } from "@kala-ui/react/kala-provider";
5
+ import { applySlot } from "@kala-ui/react/lib/slot-styles";
4
6
  import { cn } from "@kala-ui/react/lib/utils";
5
7
  import * as React from "react";
8
+ import { appShellStyles } from "../../config/app-shell.js";
6
9
  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
- };
10
+ function AppShellBase({ children, className, style, slotStyles: slotStylesRaw, header, navbar, aside, footer, padding = "md", ref, ...props }) {
11
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
17
12
  const cssVars = {
18
13
  "--app-shell-header-height": typeof header?.height === "number"
19
14
  ? `${header.height}px`
@@ -28,64 +23,68 @@ function AppShellBase({ children, className, header, navbar, aside, footer, padd
28
23
  ? `${aside.width}px`
29
24
  : (aside?.width ?? "0px"),
30
25
  };
31
- return (_jsx(AppShellContext.Provider, { "data-kala-component": "app-shell-base", 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 }) }));
26
+ const root = applySlot(cn(appShellStyles.base, className), slotStyles?.root);
27
+ return (_jsx(AppShellContext.Provider, { "data-kala-component": "app-shell-base", value: { header, navbar, aside, footer, padding }, children: _jsx(Box, { "data-kala-component": "app-shell", ref: ref, className: root.className, style: { ...cssVars, ...root.style }, ...props, children: children }) }));
32
28
  }
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 }) {
29
+ // --- Subcomponents ---
30
+ function AppShellHeader({ ref, className, withBorder = true, slotStyles: slotStylesRaw, ...props }) {
41
31
  const { header } = React.useContext(AppShellContext);
32
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
42
33
  if (!header)
43
34
  return null;
44
- return (_jsx(Box, { "data-kala-component": "app-shell-header", 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 }));
35
+ const part = applySlot(cn(appShellStyles.header, withBorder && appShellStyles.headerBorder, className), slotStyles?.header);
36
+ return (_jsx(Box, { "data-kala-component": "app-shell-header", as: "header", ref: ref, className: part.className, style: { height: "var(--app-shell-header-height)", ...part.style }, ...props }));
45
37
  }
46
- function AppShellNavbar({ ref, className, withBorder = true, ...props }) {
38
+ function AppShellNavbar({ ref, className, withBorder = true, slotStyles: slotStylesRaw, ...props }) {
47
39
  const { navbar } = React.useContext(AppShellContext);
40
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
48
41
  if (!navbar)
49
42
  return null;
50
- // Off-canvas below the configured breakpoint, docked from it upward.
51
43
  const variant = `${navbar.breakpoint ?? "md"}:`;
52
- return (_jsx(Box, { "data-kala-component": "app-shell-navbar", 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: {
44
+ const part = applySlot(cn(appShellStyles.navbar, withBorder && appShellStyles.navbarBorder, "-translate-x-full", `${variant}translate-x-0`, className), slotStyles?.navbar);
45
+ return (_jsx(Box, { "data-kala-component": "app-shell-navbar", as: "nav", ref: ref, className: part.className, style: {
53
46
  width: "var(--app-shell-navbar-width)",
54
47
  top: "var(--app-shell-header-height)",
55
48
  height: "calc(100vh - var(--app-shell-header-height))",
49
+ ...part.style,
56
50
  }, ...props }));
57
51
  }
58
- function AppShellAside({ ref, className, withBorder = true, ...props }) {
52
+ function AppShellAside({ ref, className, withBorder = true, slotStyles: slotStylesRaw, ...props }) {
59
53
  const { aside } = React.useContext(AppShellContext);
54
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
60
55
  if (!aside)
61
56
  return null;
62
57
  const variant = `${aside.breakpoint ?? "md"}:`;
63
- return (_jsx(Box, { "data-kala-component": "app-shell-aside", 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: {
58
+ const part = applySlot(cn(appShellStyles.aside, withBorder && appShellStyles.asideBorder, "translate-x-full", `${variant}translate-x-0`, className), slotStyles?.aside);
59
+ return (_jsx(Box, { "data-kala-component": "app-shell-aside", as: "aside", ref: ref, className: part.className, style: {
64
60
  width: "var(--app-shell-aside-width)",
65
61
  top: "var(--app-shell-header-height)",
66
62
  height: "calc(100vh - var(--app-shell-header-height))",
63
+ ...part.style,
67
64
  }, ...props }));
68
65
  }
69
- function AppShellMain({ ref, className, ...props }) {
66
+ function AppShellMain({ ref, className, slotStyles: slotStylesRaw, ...props }) {
70
67
  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, { "data-kala-component": "app-shell-main", 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 }));
68
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
69
+ const part = applySlot(cn(appShellStyles.main, padding && appShellStyles.padding[padding], header && "pt-[var(--app-shell-header-height)]", footer && "pb-[var(--app-shell-footer-height)]",
70
+ // Side offsets only reserve space while the fixed panels are
71
+ // actually docked (breakpoint and up).
72
+ navbar &&
73
+ `${navbar.breakpoint ?? "md"}:pl-[var(--app-shell-navbar-width)]`, aside && `${aside.breakpoint ?? "md"}:pr-[var(--app-shell-aside-width)]`, className), slotStyles?.main);
74
+ return (_jsx(Box, { "data-kala-component": "app-shell-main", as: "main", ref: ref, className: part.className, style: part.style, ...props }));
85
75
  }
86
- function AppShellFooter({ ref, className, withBorder = true, ...props }) {
76
+ function AppShellFooter({ ref, className, withBorder = true, slotStyles: slotStylesRaw, ...props }) {
87
77
  const { footer } = React.useContext(AppShellContext);
78
+ const slotStyles = useSlotStyles("app-shell", slotStylesRaw);
88
79
  if (!footer)
89
80
  return null;
90
- return (_jsx(Box, { "data-kala-component": "app-shell-footer", 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 }));
81
+ const part = applySlot(cn(appShellStyles.footer, withBorder && appShellStyles.footerBorder, className), slotStyles?.footer);
82
+ return (_jsx(Box, { "data-kala-component": "app-shell-footer", as: "footer", ref: ref, className: part.className, style: { height: "var(--app-shell-footer-height)", ...part.style }, ...props }));
91
83
  }
84
+ export const AppShell = Object.assign(AppShellBase, {
85
+ Header: AppShellHeader,
86
+ Navbar: AppShellNavbar,
87
+ Main: AppShellMain,
88
+ Aside: AppShellAside,
89
+ Footer: AppShellFooter,
90
+ });
@@ -0,0 +1,45 @@
1
+ import type { SlotStyles } from "@kala-ui/react/lib/slot-styles";
2
+ import type * as React from "react";
3
+ export interface AppShellProps extends React.ComponentProps<"div"> {
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?: {
21
+ height: number | string;
22
+ };
23
+ padding?: "none" | "xs" | "sm" | "md" | "lg" | "xl";
24
+ /** Per-part overrides: root, header, navbar, aside, main, footer. */
25
+ slotStyles?: SlotStyles;
26
+ }
27
+ export interface AppShellHeaderProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
28
+ withBorder?: boolean;
29
+ slotStyles?: SlotStyles;
30
+ }
31
+ export interface AppShellNavbarProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
32
+ withBorder?: boolean;
33
+ slotStyles?: SlotStyles;
34
+ }
35
+ export interface AppShellAsideProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
36
+ withBorder?: boolean;
37
+ slotStyles?: SlotStyles;
38
+ }
39
+ export interface AppShellMainProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
40
+ slotStyles?: SlotStyles;
41
+ }
42
+ export interface AppShellFooterProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLElement> {
43
+ withBorder?: boolean;
44
+ slotStyles?: SlotStyles;
45
+ }
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export {};
@@ -1 +1,2 @@
1
1
  export * from "./app-shell";
2
+ export type { AppShellAsideProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarProps, AppShellProps, } from "./app-shell.types";
@@ -3,4 +3,4 @@
3
3
  * Beautiful area charts with gradient fills, perfect for time series and trends
4
4
  */
5
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;
6
+ export declare function AreaChart({ series, categories, colors, height, width, className, title, subtitle, toolbar, animations, curve, stacked, dataLabels, yAxisLabel, referenceLines, slotStyles, isLoading, emptyMessage, options: customOptions, }: AreaChartProps): import("react").JSX.Element;
@@ -7,9 +7,10 @@
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  import { cn } from "@kala-ui/react/lib/utils";
9
9
  import { useMemo } from "react";
10
+ import { chartStyles } from "../../config/charts.js";
10
11
  import { Chart, getTooltipTheme } from "./chart.js";
11
12
  import { useThemeAwareChart } from "./use-theme-aware-chart.js";
12
- import { getDefaultChartOptions } from "./utils.js";
13
+ import { getDefaultChartOptions } from "./chart-utils.js";
13
14
  /**
14
15
  * Check if series data is empty (no series or all series have empty data arrays)
15
16
  */
@@ -18,7 +19,7 @@ function isSeriesEmpty(series) {
18
19
  return true;
19
20
  return series.every((s) => !s.data || (Array.isArray(s.data) && s.data.length === 0));
20
21
  }
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
+ 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 = [], slotStyles, isLoading, emptyMessage, options: customOptions, }) {
22
23
  const { colors: themeColors } = useThemeAwareChart();
23
24
  const isEmpty = !isLoading && isSeriesEmpty(series);
24
25
  const chartOptions = useMemo(() => {
@@ -168,5 +169,5 @@ export function AreaChart({ series, categories, colors, height = 350, width = "1
168
169
  referenceLines,
169
170
  customOptions,
170
171
  ]);
171
- return (_jsx(Chart, { "data-kala-component": "charts-area-chart", className: cn("w-full", className), options: chartOptions, series: series, type: "area", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
172
+ return (_jsx(Chart, { "data-kala-component": "charts-area-chart", className: cn(chartStyles.root, className), slotStyles: slotStyles, options: chartOptions, series: series, type: "area", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
172
173
  }
@@ -3,4 +3,4 @@
3
3
  * Vertical and horizontal bar charts for comparing values across categories
4
4
  */
5
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;
6
+ export declare function BarChart({ series, categories, colors, height, width, className, title, subtitle, toolbar, animations, horizontal, stacked, dataLabels, barWidth, slotStyles, isLoading, emptyMessage, options: customOptions, }: BarChartProps): import("react").JSX.Element;
@@ -7,9 +7,10 @@
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  import { cn } from "@kala-ui/react/lib/utils";
9
9
  import { useMemo } from "react";
10
+ import { chartStyles } from "../../config/charts.js";
10
11
  import { Chart, getTooltipTheme } from "./chart.js";
11
12
  import { useThemeAwareChart } from "./use-theme-aware-chart.js";
12
- import { getDefaultChartOptions } from "./utils.js";
13
+ import { getDefaultChartOptions } from "./chart-utils.js";
13
14
  /**
14
15
  * Check if series data is empty (no series or all series have empty data arrays)
15
16
  */
@@ -18,7 +19,7 @@ function isSeriesEmpty(series) {
18
19
  return true;
19
20
  return series.every((s) => !s.data || (Array.isArray(s.data) && s.data.length === 0));
20
21
  }
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
+ 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, slotStyles, isLoading, emptyMessage, options: customOptions, }) {
22
23
  const { colors: themeColors } = useThemeAwareChart();
23
24
  const isEmpty = !isLoading && isSeriesEmpty(series);
24
25
  const chartOptions = useMemo(() => {
@@ -149,5 +150,5 @@ export function BarChart({ series, categories, colors, height = 350, width = "10
149
150
  subtitle,
150
151
  customOptions,
151
152
  ]);
152
- return (_jsx(Chart, { "data-kala-component": "charts-bar-chart", className: cn("w-full", className), options: chartOptions, series: series, type: "bar", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
153
+ return (_jsx(Chart, { "data-kala-component": "charts-bar-chart", className: cn(chartStyles.root, className), slotStyles: slotStyles, options: chartOptions, series: series, type: "bar", height: height, width: width, isLoading: isLoading, isEmpty: isEmpty, emptyMessage: emptyMessage }));
153
154
  }
@@ -4,33 +4,12 @@
4
4
  * including chart area, legend, and optional table below
5
5
  */
6
6
  export interface ChartSkeletonProps {
7
- /**
8
- * Height of the chart area (default: 350)
9
- */
10
7
  height?: number;
11
- /**
12
- * Show legend skeleton (default: true)
13
- */
14
8
  showLegend?: boolean;
15
- /**
16
- * Number of legend items to show (default: 4)
17
- */
18
9
  legendCount?: number;
19
- /**
20
- * Show table skeleton below chart
21
- */
22
10
  showTable?: boolean;
23
- /**
24
- * Number of table rows to show (default: 5)
25
- */
26
11
  tableRows?: number;
27
- /**
28
- * Number of table columns to show (default: 3)
29
- */
30
12
  tableColumns?: number;
31
- /**
32
- * Custom CSS class
33
- */
34
13
  className?: string;
35
14
  }
36
15
  export declare function ChartSkeleton({ height, showLegend, legendCount, showTable, tableRows, tableColumns, className, }: ChartSkeletonProps): import("react").JSX.Element;
@@ -8,6 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  import { cn } from "@kala-ui/react/lib/utils";
9
9
  import { Skeleton } from "@kala-ui/react/skeleton";
10
10
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@kala-ui/react/table";
11
+ import { chartSkeletonStyles } from "../../config/charts.js";
11
12
  export function ChartSkeleton({ height = 350, showLegend = true, legendCount = 4, showTable = false, tableRows = 5, tableColumns = 3, className, }) {
12
- return (_jsxs("div", { "data-kala-component": "charts-chart-skeleton", 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
+ return (_jsxs("div", { "data-kala-component": "charts-chart-skeleton", className: cn(chartSkeletonStyles.root, className), children: [_jsx("div", { className: chartSkeletonStyles.frame, style: { height: `${height}px` }, children: _jsx("div", { className: chartSkeletonStyles.frameInner, children: _jsx(Skeleton, { className: chartSkeletonStyles.frameFill }) }) }), showLegend && (_jsx("div", { className: chartSkeletonStyles.legendRow, children: Array.from({ length: legendCount }).map((_, i) => (_jsxs("div", { className: chartSkeletonStyles.legendItem, children: [_jsx(Skeleton, { className: chartSkeletonStyles.legendDot }), _jsx(Skeleton, { className: chartSkeletonStyles.legendLabel })] }, `legend-${i}`))) })), showTable && (_jsx("div", { className: chartSkeletonStyles.tableWrap, children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: Array.from({ length: tableColumns }).map((_, index) => (_jsx(TableHead, { children: _jsx(Skeleton, { className: chartSkeletonStyles.tableHead }) }, `header-${index}`))) }) }), _jsx(TableBody, { children: Array.from({ length: tableRows }).map((_, rowIndex) => (_jsx(TableRow, { className: chartSkeletonStyles.tableRow, children: Array.from({ length: tableColumns }).map((_, colIndex) => (_jsx(TableCell, { children: _jsx(Skeleton, { className: chartSkeletonStyles.tableCell }) }, `cell-${rowIndex}-${colIndex}`))) }, `row-${rowIndex}`))) })] }) }))] }));
13
14
  }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Chart Utilities
3
+ * Helper functions and default configurations for charts
4
+ */
5
+ import type { ApexOptions } from "apexcharts";
6
+ /**
7
+ * Get default chart options that match our design system
8
+ * @param theme - Optional theme override, otherwise detects from DOM
9
+ */
10
+ export declare function getDefaultChartOptions(theme?: "light" | "dark" | "neutral" | "accent"): ApexOptions;
11
+ /**
12
+ * Default color palette matching design tokens
13
+ * @param theme - Optional theme override, otherwise detects from DOM
14
+ * @deprecated Use getChartColors() instead for theme-aware colors
15
+ */
16
+ export declare function defaultColors(theme?: "light" | "dark" | "neutral" | "accent"): {
17
+ primary: import("./theme-utils").ColorPalette;
18
+ success: import("./theme-utils").ColorPalette;
19
+ warning: import("./theme-utils").ColorPalette;
20
+ destructive: import("./theme-utils").ColorPalette;
21
+ info: import("./theme-utils").ColorPalette;
22
+ mixed: import("./theme-utils").ColorPalette;
23
+ };
24
+ /**
25
+ * Format number with appropriate units
26
+ */
27
+ export declare function formatNumber(value: number): string;
28
+ /**
29
+ * Format currency values
30
+ */
31
+ export declare function formatCurrency(value: number, currency?: string): string;
32
+ /**
33
+ * Format percentage values
34
+ */
35
+ export declare function formatPercentage(value: number, decimals?: number): string;
36
+ /**
37
+ * Generate gradient colors for area charts
38
+ */
39
+ export declare function createGradient(_color: string, opacity?: number): {
40
+ type: "gradient";
41
+ gradient: {
42
+ shadeIntensity: number;
43
+ opacityFrom: number;
44
+ opacityTo: number;
45
+ stops: number[];
46
+ };
47
+ };
48
+ /**
49
+ * Get responsive breakpoints for charts
50
+ */
51
+ export declare function getResponsiveOptions(): ApexResponsive[];
52
+ interface ApexResponsive {
53
+ breakpoint: number;
54
+ options: ApexOptions;
55
+ }
56
+ export {};
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ /**
3
+ * Chart Utilities
4
+ * Helper functions and default configurations for charts
5
+ */
6
+ import { getChartColors, getThemeAwareChartOptions } from "./theme-utils.js";
7
+ /**
8
+ * Get default chart options that match our design system
9
+ * @param theme - Optional theme override, otherwise detects from DOM
10
+ */
11
+ export function getDefaultChartOptions(theme) {
12
+ const themeColors = getChartColors(theme);
13
+ const themeOptions = getThemeAwareChartOptions(theme);
14
+ return {
15
+ chart: {
16
+ fontFamily: "inherit",
17
+ foreColor: "var(--muted-foreground)",
18
+ background: "transparent",
19
+ toolbar: {
20
+ show: false,
21
+ },
22
+ zoom: {
23
+ enabled: false,
24
+ },
25
+ },
26
+ grid: {
27
+ borderColor: themeColors.grid,
28
+ strokeDashArray: 3,
29
+ xaxis: {
30
+ lines: {
31
+ show: false,
32
+ },
33
+ },
34
+ },
35
+ dataLabels: {
36
+ enabled: false,
37
+ },
38
+ tooltip: {
39
+ theme: themeOptions.tooltip.theme,
40
+ },
41
+ legend: {
42
+ labels: {
43
+ colors: themeOptions.legend.labels.colors,
44
+ },
45
+ },
46
+ };
47
+ }
48
+ /**
49
+ * Default color palette matching design tokens
50
+ * @param theme - Optional theme override, otherwise detects from DOM
51
+ * @deprecated Use getChartColors() instead for theme-aware colors
52
+ */
53
+ export function defaultColors(theme) {
54
+ const colors = getChartColors(theme);
55
+ return {
56
+ primary: colors.primary,
57
+ success: colors.success,
58
+ warning: colors.warning,
59
+ destructive: colors.destructive,
60
+ info: colors.info,
61
+ mixed: colors.mixed,
62
+ };
63
+ }
64
+ /**
65
+ * Format number with appropriate units
66
+ */
67
+ export function formatNumber(value) {
68
+ if (value >= 1000000) {
69
+ return `${(value / 1000000).toFixed(1)}M`;
70
+ }
71
+ if (value >= 1000) {
72
+ return `${(value / 1000).toFixed(1)}K`;
73
+ }
74
+ return value.toFixed(0);
75
+ }
76
+ /**
77
+ * Format currency values
78
+ */
79
+ export function formatCurrency(value, currency = "USD") {
80
+ return new Intl.NumberFormat("en-US", {
81
+ style: "currency",
82
+ currency,
83
+ minimumFractionDigits: 0,
84
+ maximumFractionDigits: 2,
85
+ }).format(value);
86
+ }
87
+ /**
88
+ * Format percentage values
89
+ */
90
+ export function formatPercentage(value, decimals = 1) {
91
+ return `${value.toFixed(decimals)}%`;
92
+ }
93
+ /**
94
+ * Generate gradient colors for area charts
95
+ */
96
+ export function createGradient(_color, opacity = 0.7) {
97
+ return {
98
+ type: "gradient",
99
+ gradient: {
100
+ shadeIntensity: 1,
101
+ opacityFrom: opacity,
102
+ opacityTo: opacity * 0.3,
103
+ stops: [0, 90, 100],
104
+ },
105
+ };
106
+ }
107
+ /**
108
+ * Get responsive breakpoints for charts
109
+ */
110
+ export function getResponsiveOptions() {
111
+ return [
112
+ {
113
+ breakpoint: 768,
114
+ options: {
115
+ chart: {
116
+ height: 300,
117
+ },
118
+ legend: {
119
+ position: "bottom",
120
+ },
121
+ },
122
+ },
123
+ {
124
+ breakpoint: 480,
125
+ options: {
126
+ chart: {
127
+ height: 250,
128
+ },
129
+ legend: {
130
+ show: false,
131
+ },
132
+ },
133
+ },
134
+ ];
135
+ }
@@ -11,6 +11,8 @@ export interface ChartProps extends Props {
11
11
  emptyMessage?: string;
12
12
  skeletonConfig?: ChartSkeletonConfig;
13
13
  skeleton?: React.ReactNode;
14
+ /** Per-part overrides: root, empty, emptyIcon, emptyText. */
15
+ slotStyles?: import("@kala-ui/react/lib/slot-styles").SlotStyles;
14
16
  }
15
17
  /**
16
18
  * Get tooltip theme from DOM safely (SSR-compatible)
@@ -20,6 +22,6 @@ declare function getTooltipTheme(): "dark" | "light";
20
22
  * Base Chart Component - use this as the foundation for all charts
21
23
  * Provides consistent styling, loading skeleton, and empty state
22
24
  */
23
- export declare function Chart({ className, isLoading, isEmpty, emptyMessage, skeletonConfig, skeleton, ...props }: ChartProps): import("react").JSX.Element;
25
+ export declare function Chart({ className, isLoading, isEmpty, emptyMessage, skeletonConfig, skeleton, slotStyles: slotStylesRaw, ...props }: ChartProps): import("react").JSX.Element;
24
26
  export { ChartSkeleton } from "./chart-skeleton";
25
27
  export { getTooltipTheme };
@@ -4,8 +4,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
4
4
  * Base Chart Component
5
5
  * React component for ApexCharts with built-in loading and empty states
6
6
  */
7
+ import { useSlotStyles } from "@kala-ui/react/kala-provider";
8
+ import { applySlot } from "@kala-ui/react/lib/slot-styles";
7
9
  import { cn } from "@kala-ui/react/lib/utils";
8
10
  import { lazy, Suspense } from "react";
11
+ import { chartStyles } from "../../config/charts.js";
9
12
  import { ChartSkeleton } from "./chart-skeleton.js";
10
13
  // apexcharts touches `window` at module scope, so importing it statically
11
14
  // crashes any SSR framework on the first render — and the root barrel
@@ -24,7 +27,10 @@ function getTooltipTheme() {
24
27
  * Base Chart Component - use this as the foundation for all charts
25
28
  * Provides consistent styling, loading skeleton, and empty state
26
29
  */
27
- export function Chart({ className, isLoading, isEmpty, emptyMessage = "No data available", skeletonConfig, skeleton, ...props }) {
30
+ export function Chart({ className, isLoading, isEmpty, emptyMessage = "No data available", skeletonConfig, skeleton, slotStyles: slotStylesRaw, ...props }) {
31
+ const slotStyles = useSlotStyles("charts", slotStylesRaw);
32
+ const { "data-kala-component": _marker, ...chartProps } = props;
33
+ const markerProps = { "data-kala-component": _marker };
28
34
  // Render skeleton if loading
29
35
  if (isLoading) {
30
36
  if (skeleton) {
@@ -32,6 +38,9 @@ export function Chart({ className, isLoading, isEmpty, emptyMessage = "No data a
32
38
  }
33
39
  return (_jsx(ChartSkeleton, { "data-kala-component": "charts-chart", ...(skeletonConfig || {}), className: className }));
34
40
  }
41
+ const emptyPart = applySlot(chartStyles.empty, slotStyles?.empty);
42
+ const emptyIcon = applySlot(chartStyles.emptyIcon, slotStyles?.emptyIcon);
43
+ const emptyText = applySlot(chartStyles.emptyText, slotStyles?.emptyText);
35
44
  // Render empty state when no data
36
45
  if (isEmpty) {
37
46
  // Height may arrive as a number (px) or a CSS length string ("20rem",
@@ -40,9 +49,10 @@ export function Chart({ className, isLoading, isEmpty, emptyMessage = "No data a
40
49
  const height = typeof configuredHeight === "number"
41
50
  ? `${configuredHeight}px`
42
51
  : configuredHeight;
43
- return (_jsxs("div", { "data-kala-component": "charts-chart", className: cn("w-full flex flex-col items-center justify-center text-center rounded-lg border bg-card text-muted-foreground", className), style: { height }, children: [_jsxs("svg", { className: "mb-3 h-10 w-10 opacity-40", fill: "none", role: "img", "aria-label": "Chart empty state", stroke: "currentColor", viewBox: "0 0 24 24", children: [_jsx("title", { children: "No chart data" }), _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M3 13h2v8H3zM9 9h2v12H9zM15 5h2v16h-2zM21 1h2v20h-2z" })] }), _jsx("p", { className: "text-sm", children: emptyMessage })] }));
52
+ return (_jsxs("div", { "data-kala-component": "charts-chart", className: cn(emptyPart.className, className), style: { height, ...emptyPart.style }, children: [_jsxs("svg", { className: emptyIcon.className, fill: "none", role: "img", "aria-label": "Chart empty state", stroke: "currentColor", viewBox: "0 0 24 24", children: [_jsx("title", { children: "No chart data" }), _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M3 13h2v8H3zM9 9h2v12H9zM15 5h2v16h-2zM21 1h2v20h-2z" })] }), _jsx("p", { className: emptyText.className, children: emptyMessage })] }));
44
53
  }
45
- return (_jsx("div", { "data-kala-component": "charts-chart", className: cn("w-full", className), children: _jsx(Suspense, { fallback: skeleton ?? (_jsx(ChartSkeleton, { ...(skeletonConfig || {}), className: className })), children: _jsx(ReactApexChart, { ...props }) }) }));
54
+ const root = applySlot(cn(chartStyles.root, className), slotStyles?.root);
55
+ return (_jsx("div", { "data-kala-component": _marker ?? "charts-chart", className: root.className, style: root.style, children: _jsx(Suspense, { fallback: skeleton ?? (_jsx(ChartSkeleton, { ...(skeletonConfig || {}), className: className })), children: _jsx(ReactApexChart, { ...chartProps }) }) }));
46
56
  }
47
57
  export { ChartSkeleton } from "./chart-skeleton.js";
48
58
  export { getTooltipTheme };