@shipfox/react-ui 0.16.0 → 0.18.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 (51) hide show
  1. package/dist/components/card/card.d.ts +24 -0
  2. package/dist/components/card/card.js +56 -0
  3. package/dist/components/card/card.stories.js +216 -0
  4. package/dist/components/card/index.d.ts +2 -0
  5. package/dist/components/card/index.js +3 -0
  6. package/dist/components/count-up/count-up.d.ts +14 -0
  7. package/dist/components/count-up/count-up.js +98 -0
  8. package/dist/components/count-up/count-up.stories.js +568 -0
  9. package/dist/components/count-up/index.d.ts +2 -0
  10. package/dist/components/count-up/index.js +3 -0
  11. package/dist/components/dashboard/components/charts/bar-chart.d.ts +8 -17
  12. package/dist/components/dashboard/components/charts/bar-chart.js +127 -81
  13. package/dist/components/dashboard/components/charts/bar-chart.stories.js +287 -0
  14. package/dist/components/dashboard/components/charts/chart-tooltip.js +13 -12
  15. package/dist/components/dashboard/components/charts/colors.d.ts +3 -2
  16. package/dist/components/dashboard/components/charts/colors.js +5 -2
  17. package/dist/components/dashboard/components/charts/index.d.ts +1 -0
  18. package/dist/components/dashboard/components/charts/index.js +1 -0
  19. package/dist/components/dashboard/components/charts/line-chart.d.ts +7 -16
  20. package/dist/components/dashboard/components/charts/line-chart.js +132 -108
  21. package/dist/components/dashboard/components/charts/line-chart.stories.js +257 -0
  22. package/dist/components/dashboard/components/charts/utils.d.ts +13 -0
  23. package/dist/components/dashboard/components/charts/utils.js +18 -0
  24. package/dist/components/dashboard/components/kpi-card.d.ts +8 -9
  25. package/dist/components/dashboard/components/kpi-card.js +26 -44
  26. package/dist/components/dashboard/index.d.ts +2 -7
  27. package/dist/components/dashboard/index.js +0 -11
  28. package/dist/components/dashboard/pages/analytics-page.d.ts +0 -18
  29. package/dist/components/dashboard/pages/analytics-page.js +83 -37
  30. package/dist/components/dashboard/pages/jobs-page.d.ts +0 -18
  31. package/dist/components/dashboard/pages/jobs-page.js +27 -24
  32. package/dist/components/dashboard/table/table-wrapper.d.ts +21 -24
  33. package/dist/components/dashboard/table/table-wrapper.js +38 -51
  34. package/dist/components/empty-state/empty-state.d.ts +10 -0
  35. package/dist/components/empty-state/empty-state.js +40 -0
  36. package/dist/components/empty-state/empty-state.stories.js +74 -0
  37. package/dist/components/empty-state/index.d.ts +2 -0
  38. package/dist/components/empty-state/index.js +3 -0
  39. package/dist/components/index.d.ts +4 -0
  40. package/dist/components/index.js +4 -0
  41. package/dist/components/item/item.stories.js +3 -3
  42. package/dist/components/table/data-table.d.ts +12 -1
  43. package/dist/components/table/data-table.js +84 -71
  44. package/dist/components/table/table-column-header.d.ts +14 -1
  45. package/dist/components/table/table-column-header.js +12 -5
  46. package/dist/components/table/table-pagination.d.ts +14 -1
  47. package/dist/components/table/table-pagination.js +6 -2
  48. package/dist/components/table/table.js +3 -3
  49. package/dist/components/table/table.stories.components.js +6 -28
  50. package/dist/styles.css +1 -1
  51. package/package.json +3 -3
@@ -0,0 +1,24 @@
1
+ import { Header, Text } from '../../components/typography';
2
+ import type { ComponentProps } from 'react';
3
+ export interface CardProps extends ComponentProps<'div'> {
4
+ }
5
+ export declare function Card({ className, children, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
6
+ export interface CardHeaderProps extends ComponentProps<'div'> {
7
+ }
8
+ export declare function CardHeader({ className, children, ...props }: CardHeaderProps): import("react/jsx-runtime").JSX.Element;
9
+ export interface CardTitleProps extends ComponentProps<typeof Header> {
10
+ }
11
+ export declare function CardTitle({ className, children, variant, ...props }: CardTitleProps): import("react/jsx-runtime").JSX.Element;
12
+ export interface CardDescriptionProps extends ComponentProps<typeof Text> {
13
+ }
14
+ export declare function CardDescription({ className, children, size, ...props }: CardDescriptionProps): import("react/jsx-runtime").JSX.Element;
15
+ export interface CardActionProps extends ComponentProps<'div'> {
16
+ }
17
+ export declare function CardAction({ className, children, ...props }: CardActionProps): import("react/jsx-runtime").JSX.Element;
18
+ export interface CardContentProps extends ComponentProps<'div'> {
19
+ }
20
+ export declare function CardContent({ className, children, ...props }: CardContentProps): import("react/jsx-runtime").JSX.Element;
21
+ export interface CardFooterProps extends ComponentProps<'div'> {
22
+ }
23
+ export declare function CardFooter({ className, children, ...props }: CardFooterProps): import("react/jsx-runtime").JSX.Element;
24
+ //# sourceMappingURL=card.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Header, Text } from '../../components/typography/index.js';
3
+ import { cn } from '../../utils/cn.js';
4
+ export function Card({ className, children, ...props }) {
5
+ return /*#__PURE__*/ _jsx("div", {
6
+ className: cn('p-12 rounded-8 bg-background-neutral-base border border-border-neutral-base flex flex-col gap-16', className),
7
+ ...props,
8
+ children: children
9
+ });
10
+ }
11
+ export function CardHeader({ className, children, ...props }) {
12
+ return /*#__PURE__*/ _jsx("div", {
13
+ className: cn('flex flex-col gap-4', className),
14
+ ...props,
15
+ children: children
16
+ });
17
+ }
18
+ export function CardTitle({ className, children, variant = 'h3', ...props }) {
19
+ return /*#__PURE__*/ _jsx(Header, {
20
+ variant: variant,
21
+ className: cn('text-foreground-neutral-base', className),
22
+ ...props,
23
+ children: children
24
+ });
25
+ }
26
+ export function CardDescription({ className, children, size = 'sm', ...props }) {
27
+ return /*#__PURE__*/ _jsx(Text, {
28
+ size: size,
29
+ className: cn('text-foreground-neutral-muted', className),
30
+ ...props,
31
+ children: children
32
+ });
33
+ }
34
+ export function CardAction({ className, children, ...props }) {
35
+ return /*#__PURE__*/ _jsx("div", {
36
+ className: cn('ml-auto', className),
37
+ ...props,
38
+ children: children
39
+ });
40
+ }
41
+ export function CardContent({ className, children, ...props }) {
42
+ return /*#__PURE__*/ _jsx("div", {
43
+ className: cn('flex-1', className),
44
+ ...props,
45
+ children: children
46
+ });
47
+ }
48
+ export function CardFooter({ className, children, ...props }) {
49
+ return /*#__PURE__*/ _jsx("div", {
50
+ className: cn('flex items-center gap-8', className),
51
+ ...props,
52
+ children: children
53
+ });
54
+ }
55
+
56
+ //# sourceMappingURL=card.js.map
@@ -0,0 +1,216 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '../../components/button/index.js';
3
+ import { Input } from '../../components/input/index.js';
4
+ import { Label } from '../../components/label/index.js';
5
+ import { Text } from '../../components/typography/index.js';
6
+ import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './card.js';
7
+ const meta = {
8
+ title: 'Components/Card',
9
+ component: Card,
10
+ tags: [
11
+ 'autodocs'
12
+ ],
13
+ parameters: {
14
+ layout: 'centered'
15
+ }
16
+ };
17
+ export default meta;
18
+ export const Default = {
19
+ render: ()=>/*#__PURE__*/ _jsx("div", {
20
+ className: "w-400",
21
+ children: /*#__PURE__*/ _jsxs(Card, {
22
+ children: [
23
+ /*#__PURE__*/ _jsxs(CardHeader, {
24
+ children: [
25
+ /*#__PURE__*/ _jsx(CardTitle, {
26
+ children: "Card Title"
27
+ }),
28
+ /*#__PURE__*/ _jsx(CardDescription, {
29
+ children: "This is a description of the card content."
30
+ })
31
+ ]
32
+ }),
33
+ /*#__PURE__*/ _jsx(CardContent, {
34
+ children: /*#__PURE__*/ _jsx(Text, {
35
+ children: "Card content goes here. This is where the main information is displayed."
36
+ })
37
+ })
38
+ ]
39
+ })
40
+ })
41
+ };
42
+ export const WithFooter = {
43
+ render: ()=>/*#__PURE__*/ _jsx("div", {
44
+ className: "w-400",
45
+ children: /*#__PURE__*/ _jsxs(Card, {
46
+ children: [
47
+ /*#__PURE__*/ _jsxs(CardHeader, {
48
+ children: [
49
+ /*#__PURE__*/ _jsx(CardTitle, {
50
+ children: "Card with Footer"
51
+ }),
52
+ /*#__PURE__*/ _jsx(CardDescription, {
53
+ children: "This card includes a footer with actions."
54
+ })
55
+ ]
56
+ }),
57
+ /*#__PURE__*/ _jsx(CardContent, {
58
+ children: /*#__PURE__*/ _jsx(Text, {
59
+ children: "Main content area with important information."
60
+ })
61
+ }),
62
+ /*#__PURE__*/ _jsxs(CardFooter, {
63
+ children: [
64
+ /*#__PURE__*/ _jsx(Button, {
65
+ variant: "secondary",
66
+ size: "sm",
67
+ children: "Cancel"
68
+ }),
69
+ /*#__PURE__*/ _jsx(Button, {
70
+ size: "sm",
71
+ children: "Save"
72
+ })
73
+ ]
74
+ })
75
+ ]
76
+ })
77
+ })
78
+ };
79
+ export const WithAction = {
80
+ render: ()=>/*#__PURE__*/ _jsx("div", {
81
+ className: "w-400",
82
+ children: /*#__PURE__*/ _jsxs(Card, {
83
+ children: [
84
+ /*#__PURE__*/ _jsx(CardHeader, {
85
+ children: /*#__PURE__*/ _jsxs("div", {
86
+ className: "flex items-start justify-between gap-16",
87
+ children: [
88
+ /*#__PURE__*/ _jsxs("div", {
89
+ className: "flex flex-col gap-4 flex-1",
90
+ children: [
91
+ /*#__PURE__*/ _jsx(CardTitle, {
92
+ children: "Card with Action"
93
+ }),
94
+ /*#__PURE__*/ _jsx(CardDescription, {
95
+ children: "This card has an action button in the header."
96
+ })
97
+ ]
98
+ }),
99
+ /*#__PURE__*/ _jsx(CardAction, {
100
+ children: /*#__PURE__*/ _jsx(Button, {
101
+ variant: "transparent",
102
+ size: "sm",
103
+ children: "Edit"
104
+ })
105
+ })
106
+ ]
107
+ })
108
+ }),
109
+ /*#__PURE__*/ _jsx(CardContent, {
110
+ children: /*#__PURE__*/ _jsx(Text, {
111
+ children: "Content that can be edited using the action button."
112
+ })
113
+ })
114
+ ]
115
+ })
116
+ })
117
+ };
118
+ export const LoginForm = {
119
+ render: ()=>/*#__PURE__*/ _jsx("div", {
120
+ className: "w-400",
121
+ children: /*#__PURE__*/ _jsxs(Card, {
122
+ children: [
123
+ /*#__PURE__*/ _jsx(CardHeader, {
124
+ children: /*#__PURE__*/ _jsxs("div", {
125
+ className: "flex items-start justify-between gap-16",
126
+ children: [
127
+ /*#__PURE__*/ _jsxs("div", {
128
+ className: "flex flex-col gap-4 flex-1",
129
+ children: [
130
+ /*#__PURE__*/ _jsx(CardTitle, {
131
+ children: "Login to your account"
132
+ }),
133
+ /*#__PURE__*/ _jsx(CardDescription, {
134
+ children: "Enter your email below to login to your account"
135
+ })
136
+ ]
137
+ }),
138
+ /*#__PURE__*/ _jsx(CardAction, {
139
+ children: /*#__PURE__*/ _jsx(Button, {
140
+ variant: "transparent",
141
+ size: "sm",
142
+ children: "Sign Up"
143
+ })
144
+ })
145
+ ]
146
+ })
147
+ }),
148
+ /*#__PURE__*/ _jsx(CardContent, {
149
+ children: /*#__PURE__*/ _jsxs("form", {
150
+ className: "flex flex-col gap-16",
151
+ children: [
152
+ /*#__PURE__*/ _jsxs("div", {
153
+ className: "grid gap-6",
154
+ children: [
155
+ /*#__PURE__*/ _jsx(Label, {
156
+ htmlFor: "email",
157
+ children: "Email"
158
+ }),
159
+ /*#__PURE__*/ _jsx(Input, {
160
+ id: "email",
161
+ type: "email",
162
+ placeholder: "m@example.com",
163
+ required: true
164
+ })
165
+ ]
166
+ }),
167
+ /*#__PURE__*/ _jsxs("div", {
168
+ className: "grid gap-6",
169
+ children: [
170
+ /*#__PURE__*/ _jsxs("div", {
171
+ className: "flex items-center",
172
+ children: [
173
+ /*#__PURE__*/ _jsx(Label, {
174
+ htmlFor: "password",
175
+ children: "Password"
176
+ }),
177
+ /*#__PURE__*/ _jsx(Button, {
178
+ variant: "transparent",
179
+ size: "xs",
180
+ className: "ml-auto",
181
+ children: "Forgot password?"
182
+ })
183
+ ]
184
+ }),
185
+ /*#__PURE__*/ _jsx(Input, {
186
+ id: "password",
187
+ type: "password",
188
+ required: true
189
+ })
190
+ ]
191
+ })
192
+ ]
193
+ })
194
+ }),
195
+ /*#__PURE__*/ _jsxs(CardFooter, {
196
+ className: "flex-col gap-8",
197
+ children: [
198
+ /*#__PURE__*/ _jsx(Button, {
199
+ type: "submit",
200
+ className: "w-full",
201
+ children: "Login"
202
+ }),
203
+ /*#__PURE__*/ _jsx(Button, {
204
+ type: "submit",
205
+ variant: "secondary",
206
+ className: "w-full",
207
+ children: "Login with Google"
208
+ })
209
+ ]
210
+ })
211
+ ]
212
+ })
213
+ })
214
+ };
215
+
216
+ //# sourceMappingURL=card.stories.js.map
@@ -0,0 +1,2 @@
1
+ export * from './card';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './card.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ export interface CountUpProps {
2
+ to: number;
3
+ from?: number;
4
+ direction?: 'up' | 'down';
5
+ delay?: number;
6
+ duration?: number;
7
+ className?: string;
8
+ startWhen?: boolean;
9
+ separator?: string;
10
+ onStart?: () => void;
11
+ onEnd?: () => void;
12
+ }
13
+ export declare function CountUp({ to, from, direction, delay, duration, className, startWhen, separator, onStart, onEnd, }: CountUpProps): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=count-up.d.ts.map
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useInView, useMotionValue, useSpring } from 'framer-motion';
3
+ import { useCallback, useEffect, useRef } from 'react';
4
+ export function CountUp({ to, from = 0, direction = 'up', delay = 0, duration = 2, className = '', startWhen = true, separator = '', onStart, onEnd }) {
5
+ const ref = useRef(null);
6
+ const motionValue = useMotionValue(direction === 'down' ? to : from);
7
+ const damping = 20 + 40 * (1 / duration);
8
+ const stiffness = 100 * (1 / duration);
9
+ const springValue = useSpring(motionValue, {
10
+ damping,
11
+ stiffness
12
+ });
13
+ const isInView = useInView(ref, {
14
+ once: true,
15
+ margin: '0px'
16
+ });
17
+ const getDecimalPlaces = (num)=>{
18
+ const str = num.toString();
19
+ if (str.includes('.')) {
20
+ const decimals = str.split('.')[1];
21
+ if (parseInt(decimals, 10) !== 0) {
22
+ return decimals.length;
23
+ }
24
+ }
25
+ return 0;
26
+ };
27
+ const maxDecimals = Math.max(getDecimalPlaces(from), getDecimalPlaces(to));
28
+ const formatValue = useCallback((latest)=>{
29
+ const hasDecimals = maxDecimals > 0;
30
+ const options = {
31
+ useGrouping: !!separator,
32
+ minimumFractionDigits: hasDecimals ? maxDecimals : 0,
33
+ maximumFractionDigits: hasDecimals ? maxDecimals : 0
34
+ };
35
+ const formattedNumber = Intl.NumberFormat('en-US', options).format(latest);
36
+ return separator ? formattedNumber.replace(/,/g, separator) : formattedNumber;
37
+ }, [
38
+ maxDecimals,
39
+ separator
40
+ ]);
41
+ useEffect(()=>{
42
+ if (ref.current) {
43
+ ref.current.textContent = formatValue(direction === 'down' ? to : from);
44
+ }
45
+ }, [
46
+ from,
47
+ to,
48
+ direction,
49
+ formatValue
50
+ ]);
51
+ useEffect(()=>{
52
+ if (isInView && startWhen) {
53
+ if (typeof onStart === 'function') {
54
+ onStart();
55
+ }
56
+ const timeoutId = setTimeout(()=>{
57
+ motionValue.set(direction === 'down' ? from : to);
58
+ }, delay * 1000);
59
+ const durationTimeoutId = setTimeout(()=>{
60
+ if (typeof onEnd === 'function') {
61
+ onEnd();
62
+ }
63
+ }, delay * 1000 + duration * 1000);
64
+ return ()=>{
65
+ clearTimeout(timeoutId);
66
+ clearTimeout(durationTimeoutId);
67
+ };
68
+ }
69
+ }, [
70
+ isInView,
71
+ startWhen,
72
+ motionValue,
73
+ direction,
74
+ from,
75
+ to,
76
+ delay,
77
+ onStart,
78
+ onEnd,
79
+ duration
80
+ ]);
81
+ useEffect(()=>{
82
+ const unsubscribe = springValue.on('change', (latest)=>{
83
+ if (ref.current) {
84
+ ref.current.textContent = formatValue(latest);
85
+ }
86
+ });
87
+ return ()=>unsubscribe();
88
+ }, [
89
+ springValue,
90
+ formatValue
91
+ ]);
92
+ return /*#__PURE__*/ _jsx("span", {
93
+ className: className,
94
+ ref: ref
95
+ });
96
+ }
97
+
98
+ //# sourceMappingURL=count-up.js.map