@vrobots/storybook 0.2.11 → 0.2.12

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@
23
23
  "@storybook/addon-themes": "^10.2.16",
24
24
  "@tanstack/react-table": "^8.21.3",
25
25
  "axios": "^1.13.4",
26
+ "chart.js": "^4.5.1",
26
27
  "motion": "^12.34.0",
27
28
  "next": "^16.2.4",
28
29
  "next-themes": "^0.4.6",
@@ -0,0 +1,8 @@
1
+ import { ChartDataset, Point, ChartDatasetCustomTypesPerDataset, ChartOptions, ChartType } from "chart.js";
2
+ export interface IChart {
3
+ labels: string[];
4
+ type: ChartType;
5
+ datasets: ChartDataset<"line", (number | Point | null)[]>[] | ChartDatasetCustomTypesPerDataset<"line", (number | Point | null)[]>[];
6
+ options?: ChartOptions;
7
+ }
8
+ export declare const Chart: ({ labels, type, datasets, options, }: IChart) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import ChartJs from "chart.js/auto";
4
+ import { useColorMode } from "./ui/color-mode";
5
+ export const Chart = ({ labels, type, datasets, options, }) => {
6
+ const chartRef = useRef(null);
7
+ const { colorMode } = useColorMode();
8
+ useEffect(() => {
9
+ const isDarkMode = colorMode === "dark";
10
+ const borderColorLight = 'rgba(100,100,100,1)';
11
+ const borderColorDark = 'rgba(200,200,200,1)';
12
+ const borderColor = isDarkMode ? borderColorDark : borderColorLight;
13
+ const gridColorLight = 'rgba(100,100,100,0.4)';
14
+ const gridColorDark = 'rgba(200,200,200,0.4)';
15
+ const gridColor = isDarkMode ? gridColorDark : gridColorLight;
16
+ const ticksColorLight = '#333';
17
+ const ticksColorDark = '#fff';
18
+ const ticksColor = isDarkMode ? ticksColorDark : ticksColorLight;
19
+ const scales = {
20
+ y: {
21
+ border: {
22
+ color: borderColor,
23
+ },
24
+ grid: {
25
+ color: gridColor,
26
+ },
27
+ ticks: {
28
+ color: ticksColor,
29
+ },
30
+ },
31
+ x: {
32
+ border: {
33
+ color: borderColor,
34
+ },
35
+ grid: {
36
+ color: gridColor,
37
+ },
38
+ ticks: {
39
+ color: ticksColor,
40
+ },
41
+ },
42
+ };
43
+ if (chartRef.current) {
44
+ const currentChart = ChartJs.getChart(chartRef.current);
45
+ currentChart?.destroy();
46
+ }
47
+ new ChartJs(chartRef.current, {
48
+ type,
49
+ data: {
50
+ labels,
51
+ datasets,
52
+ },
53
+ options: {
54
+ ...options,
55
+ scales,
56
+ color: ticksColor,
57
+ responsive: true,
58
+ maintainAspectRatio: false,
59
+ },
60
+ });
61
+ }, [
62
+ labels,
63
+ type,
64
+ datasets,
65
+ options,
66
+ colorMode,
67
+ ]);
68
+ return (_jsx("canvas", { ref: chartRef }));
69
+ };
@@ -15,7 +15,7 @@ export const Loader = ({ isLoading, isFullscreen, component, hideBackground, chi
15
15
  zIndex: 100000,
16
16
  maxHeight: '100vh',
17
17
  display: 'flex',
18
- }, bgColor: !hideBackground ? { _light: 'blue.50', _dark: 'gray.900' } : 'transparent', children: _jsxs(Box, { m: 'auto', children: [component && component, _jsx(Spinner, { position: 'static', m: 'auto' })] }) }));
18
+ }, bgColor: !hideBackground ? { _light: 'rgba(255, 255, 255, 0.5)', _dark: 'rgba(0, 0, 0, 0.5)' } : 'transparent', children: _jsxs(Box, { m: 'auto', children: [component && component, _jsx(Spinner, { position: 'static', m: 'auto' })] }) }));
19
19
  }
20
20
  return children ?? null;
21
21
  };
@@ -0,0 +1,9 @@
1
+ import { CardRootProps } from "@chakra-ui/react";
2
+ export interface TotalProps {
3
+ title: string;
4
+ total: number;
5
+ colorTotal?: string;
6
+ colorTital?: string;
7
+ cardProps?: CardRootProps;
8
+ }
9
+ export declare const Total: ({ title, total, colorTotal, colorTital, cardProps }: TotalProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Card } from "@chakra-ui/react";
3
+ import { useState } from "react";
4
+ import utils from "../utils";
5
+ export const Total = ({ title, total, colorTotal, colorTital, cardProps }) => {
6
+ const [count, setCount] = useState(0);
7
+ const isAdding = count < total;
8
+ if (count !== total) {
9
+ setTimeout(() => {
10
+ setCount(prevCount => {
11
+ const isDiffGreaterThan10000 = isAdding
12
+ ? total - prevCount > 10000
13
+ : prevCount - total > 10000;
14
+ const isDiffGreaterThan1000 = isAdding
15
+ ? total - prevCount > 1000
16
+ : prevCount - total > 1000;
17
+ const isDiffGreaterThan100 = isAdding
18
+ ? total - prevCount > 100
19
+ : prevCount - total > 100;
20
+ const count = isDiffGreaterThan10000
21
+ ? 10000
22
+ : isDiffGreaterThan1000
23
+ ? 1000
24
+ : isDiffGreaterThan100
25
+ ? 100
26
+ : 1;
27
+ return isAdding ? prevCount + count : count;
28
+ });
29
+ }, 1);
30
+ }
31
+ return (_jsx(Card.Root, { display: 'flex', pt: 1, pb: 2, bgColor: 'transparent', ...cardProps, children: _jsxs(Card.Body, { children: [_jsx(Card.Title, { textAlign: 'center', color: colorTotal, children: utils.format.number(count) }), _jsx(Card.Description, { textAlign: 'center', fontWeight: 'bold', color: colorTital, children: title })] }) }));
32
+ };
@@ -1,3 +1,6 @@
1
1
  import { BoxProps } from "@chakra-ui/react";
2
- export declare const FormRoot: (props: BoxProps) => import("react/jsx-runtime").JSX.Element;
2
+ export interface FormRootProps extends BoxProps {
3
+ isLoading?: boolean;
4
+ }
5
+ export declare const FormRoot: ({ isLoading, ...props }: FormRootProps) => import("react/jsx-runtime").JSX.Element;
3
6
  export default FormRoot;
@@ -1,6 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Card } from "@chakra-ui/react";
3
- export const FormRoot = (props) => {
4
- return (_jsx(Box, { as: "form", display: "flex", justifyContent: "center", alignItems: "center", height: `100%`, bg: "neu.bg", px: 4, ...props, children: _jsx(Box, { layerStyle: "neuRaised", minW: { base: "100%", sm: "460px" }, maxW: "560px", bg: { _light: 'white', _dark: 'black' }, children: _jsx(Card.Root, { m: { base: 6, md: 8 }, bg: 'transparent', border: 'none', ...props, children: _jsx(Card.Body, { children: props.children }) }) }) }));
3
+ import { Loader } from "../Loader";
4
+ export const FormRoot = ({ isLoading = false, ...props }) => {
5
+ return (_jsxs(Box, { as: "form", display: "flex", justifyContent: "center", alignItems: "center", height: `100%`, bg: "neu.bg", px: 4, ...props, children: [_jsx(Loader, { isLoading: isLoading }), _jsx(Box, { layerStyle: "neuRaised", p: { base: 6, md: 8 }, minW: { base: "100%", sm: "460px" }, maxW: "560px", bg: { _light: 'white', _dark: 'black' }, children: _jsx(Card.Root, { bg: 'transparent', border: 'none', ...props, children: _jsx(Card.Body, { children: props.children }) }) })] }));
5
6
  };
6
7
  export default FormRoot;
@@ -3,7 +3,7 @@ export * from "./SecondFactorAuth";
3
3
  export * from "./FileUploader";
4
4
  declare const Form: {
5
5
  (): null;
6
- Root: (props: import("@chakra-ui/react").BoxProps) => import("react/jsx-runtime").JSX.Element;
6
+ Root: ({ isLoading, ...props }: import("./Form.Root").FormRootProps) => import("react/jsx-runtime").JSX.Element;
7
7
  Title: ({ title }: {
8
8
  title: string;
9
9
  }) => import("react/jsx-runtime").JSX.Element;
@@ -4,6 +4,7 @@ export * from './ui/tooltip';
4
4
  export * from './Accordion';
5
5
  export * from './AvatarIconMenu';
6
6
  export * from './Breadcrumbs';
7
+ export * from './Chart';
7
8
  export * from './Display';
8
9
  export * from './FoldersAndFiles';
9
10
  export * from './Frame';
@@ -15,6 +16,7 @@ export * from './Page';
15
16
  export * from './Section';
16
17
  export * from './Sidebar';
17
18
  export * from './Timeline';
19
+ export * from './Total';
18
20
  export * from './VerifyAction';
19
21
  export * from './form/Login';
20
22
  export * from './form/SecondFactorAuth';
@@ -4,6 +4,7 @@ export * from './ui/tooltip';
4
4
  export * from './Accordion';
5
5
  export * from './AvatarIconMenu';
6
6
  export * from './Breadcrumbs';
7
+ export * from './Chart';
7
8
  export * from './Display';
8
9
  export * from './FoldersAndFiles';
9
10
  export * from './Frame';
@@ -15,6 +16,7 @@ export * from './Page';
15
16
  export * from './Section';
16
17
  export * from './Sidebar';
17
18
  export * from './Timeline';
19
+ export * from './Total';
18
20
  export * from './VerifyAction';
19
21
  export * from './form/Login';
20
22
  export * from './form/SecondFactorAuth';
@@ -0,0 +1,27 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ labels, type, datasets, options, }: import("../components").IChart) => import("react/jsx-runtime").JSX.Element;
5
+ tags: string[];
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ decorators: ((Story: import("storybook/internal/csf").PartialStoryFn<import("@storybook/react").ReactRenderer, {
10
+ labels: string[];
11
+ type: import("chart.js").ChartType;
12
+ datasets: import("chart.js").ChartDataset<"line", (number | import("chart.js").Point | null)[]>[] | import("chart.js").ChartDatasetCustomTypesPerDataset<"line", (number | import("chart.js").Point | null)[]>[];
13
+ options?: import("chart.js").ChartOptions | undefined;
14
+ }>) => import("react/jsx-runtime").JSX.Element)[];
15
+ args: {
16
+ labels: string[];
17
+ type: "line";
18
+ datasets: never[];
19
+ };
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+ export declare const Line: Story;
24
+ export declare const MultiLine: Story;
25
+ export declare const Bar: Story;
26
+ export declare const Radar: Story;
27
+ export declare const Doughnut: Story;
@@ -0,0 +1,136 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@chakra-ui/react';
3
+ import { Chart } from '../components';
4
+ const meta = {
5
+ title: 'Data Visualization/Chart',
6
+ component: Chart,
7
+ tags: ['autodocs'],
8
+ parameters: {
9
+ layout: 'centered',
10
+ },
11
+ decorators: [
12
+ (Story) => (_jsx(Box, { width: "640px", height: "400px", children: _jsx(Story, {}) })),
13
+ ],
14
+ args: {
15
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
16
+ type: 'line',
17
+ datasets: [],
18
+ },
19
+ };
20
+ export default meta;
21
+ export const Line = {
22
+ args: {
23
+ type: 'line',
24
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
25
+ datasets: [
26
+ {
27
+ label: 'Revenue',
28
+ data: [12000, 19000, 14000, 22000, 18000, 27000],
29
+ borderColor: 'rgba(99, 179, 237, 1)',
30
+ backgroundColor: 'rgba(99, 179, 237, 0.15)',
31
+ tension: 0.4,
32
+ fill: true,
33
+ },
34
+ ],
35
+ },
36
+ };
37
+ export const MultiLine = {
38
+ name: 'Line — Multiple Series',
39
+ args: {
40
+ type: 'line',
41
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
42
+ datasets: [
43
+ {
44
+ label: 'Claims Submitted',
45
+ data: [340, 410, 390, 480, 420, 510],
46
+ borderColor: 'rgba(99, 179, 237, 1)',
47
+ backgroundColor: 'rgba(99, 179, 237, 0.1)',
48
+ tension: 0.4,
49
+ fill: false,
50
+ },
51
+ {
52
+ label: 'Claims Approved',
53
+ data: [300, 380, 350, 440, 390, 470],
54
+ borderColor: 'rgba(154, 230, 180, 1)',
55
+ backgroundColor: 'rgba(154, 230, 180, 0.1)',
56
+ tension: 0.4,
57
+ fill: false,
58
+ },
59
+ {
60
+ label: 'Claims Denied',
61
+ data: [40, 30, 40, 40, 30, 40],
62
+ borderColor: 'rgba(252, 129, 129, 1)',
63
+ backgroundColor: 'rgba(252, 129, 129, 0.1)',
64
+ tension: 0.4,
65
+ fill: false,
66
+ },
67
+ ],
68
+ },
69
+ };
70
+ export const Bar = {
71
+ args: {
72
+ type: 'bar',
73
+ labels: ['Q1', 'Q2', 'Q3', 'Q4'],
74
+ datasets: [
75
+ {
76
+ label: 'Billed',
77
+ data: [84000, 97000, 110000, 128000],
78
+ backgroundColor: 'rgba(99, 179, 237, 0.7)',
79
+ borderColor: 'rgba(99, 179, 237, 1)',
80
+ borderWidth: 1,
81
+ },
82
+ {
83
+ label: 'Collected',
84
+ data: [72000, 88000, 98000, 115000],
85
+ backgroundColor: 'rgba(154, 230, 180, 0.7)',
86
+ borderColor: 'rgba(154, 230, 180, 1)',
87
+ borderWidth: 1,
88
+ },
89
+ ],
90
+ },
91
+ };
92
+ export const Radar = {
93
+ args: {
94
+ type: 'radar',
95
+ labels: ['Coding Accuracy', 'Submission Speed', 'Denial Rate', 'Collection Rate', 'Documentation', 'Compliance'],
96
+ datasets: [
97
+ {
98
+ label: 'Current Period',
99
+ data: [85, 72, 60, 90, 78, 95],
100
+ borderColor: 'rgba(99, 179, 237, 1)',
101
+ backgroundColor: 'rgba(99, 179, 237, 0.25)',
102
+ },
103
+ {
104
+ label: 'Prior Period',
105
+ data: [70, 65, 55, 80, 70, 88],
106
+ borderColor: 'rgba(197, 160, 252, 1)',
107
+ backgroundColor: 'rgba(197, 160, 252, 0.2)',
108
+ },
109
+ ],
110
+ },
111
+ };
112
+ export const Doughnut = {
113
+ args: {
114
+ type: 'doughnut',
115
+ labels: ['Approved', 'Pending', 'Denied', 'Appealed'],
116
+ datasets: [
117
+ {
118
+ label: 'Claims',
119
+ data: [620, 140, 80, 35],
120
+ backgroundColor: [
121
+ 'rgba(154, 230, 180, 0.8)',
122
+ 'rgba(251, 211, 141, 0.8)',
123
+ 'rgba(252, 129, 129, 0.8)',
124
+ 'rgba(99, 179, 237, 0.8)',
125
+ ],
126
+ borderColor: [
127
+ 'rgba(154, 230, 180, 1)',
128
+ 'rgba(251, 211, 141, 1)',
129
+ 'rgba(252, 129, 129, 1)',
130
+ 'rgba(99, 179, 237, 1)',
131
+ ],
132
+ borderWidth: 1,
133
+ },
134
+ ],
135
+ },
136
+ };
@@ -0,0 +1,21 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ title, total, colorTotal, colorTital, cardProps }: import("../components").TotalProps) => import("react/jsx-runtime").JSX.Element;
5
+ tags: string[];
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ args: {
10
+ title: string;
11
+ total: number;
12
+ };
13
+ };
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+ export declare const Default: Story;
17
+ export declare const LargeNumber: Story;
18
+ export declare const WithColors: Story;
19
+ export declare const NegativeTotal: Story;
20
+ export declare const Zero: Story;
21
+ export declare const Dashboard: Story;
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { HStack } from '@chakra-ui/react';
3
+ import { Total } from '../components';
4
+ const meta = {
5
+ title: 'Data Display/Total',
6
+ component: Total,
7
+ tags: ['autodocs'],
8
+ parameters: {
9
+ layout: 'centered',
10
+ },
11
+ args: {
12
+ title: 'Total Claims',
13
+ total: 1284,
14
+ },
15
+ };
16
+ export default meta;
17
+ export const Default = {
18
+ args: {
19
+ title: 'Total Claims',
20
+ total: 1284,
21
+ },
22
+ };
23
+ export const LargeNumber = {
24
+ name: 'Large Number — animates in steps',
25
+ args: {
26
+ title: 'Revenue',
27
+ total: 1250000,
28
+ },
29
+ };
30
+ export const WithColors = {
31
+ name: 'With Custom Colors',
32
+ args: {
33
+ title: 'Approved',
34
+ total: 947,
35
+ colorTotal: 'green.500',
36
+ colorTital: 'green.400',
37
+ },
38
+ };
39
+ export const NegativeTotal = {
40
+ name: 'Negative / Decremented Value',
41
+ args: {
42
+ title: 'Outstanding Balance',
43
+ total: -340,
44
+ colorTotal: 'red.500',
45
+ colorTital: 'red.400',
46
+ },
47
+ };
48
+ export const Zero = {
49
+ args: {
50
+ title: 'Denied Claims',
51
+ total: 0,
52
+ },
53
+ };
54
+ export const Dashboard = {
55
+ name: 'Dashboard — Multiple Totals',
56
+ render: () => (_jsxs(HStack, { gap: 6, align: "stretch", children: [_jsx(Total, { title: "Submitted", total: 1284, colorTotal: "blue.400", colorTital: "blue.300" }), _jsx(Total, { title: "Approved", total: 947, colorTotal: "green.500", colorTital: "green.400" }), _jsx(Total, { title: "Pending", total: 210, colorTotal: "orange.400", colorTital: "orange.300" }), _jsx(Total, { title: "Denied", total: 127, colorTotal: "red.500", colorTital: "red.400" })] })),
57
+ args: {},
58
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@
23
23
  "@storybook/addon-themes": "^10.2.16",
24
24
  "@tanstack/react-table": "^8.21.3",
25
25
  "axios": "^1.13.4",
26
+ "chart.js": "^4.5.1",
26
27
  "motion": "^12.34.0",
27
28
  "next": "^16.2.4",
28
29
  "next-themes": "^0.4.6",