@shipfox/react-ui 0.17.0 → 0.19.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.
- package/dist/components/calendar/calendar.js +12 -12
- package/dist/components/count-up/count-up.d.ts +14 -0
- package/dist/components/count-up/count-up.js +98 -0
- package/dist/components/count-up/count-up.stories.js +568 -0
- package/dist/components/count-up/index.d.ts +2 -0
- package/dist/components/count-up/index.js +3 -0
- package/dist/components/dashboard/components/kpi-card.d.ts +8 -9
- package/dist/components/dashboard/components/kpi-card.js +29 -44
- package/dist/components/dashboard/index.d.ts +1 -6
- package/dist/components/dashboard/index.js +0 -11
- package/dist/components/dashboard/pages/analytics-page.d.ts +0 -18
- package/dist/components/dashboard/pages/analytics-page.js +83 -37
- package/dist/components/dashboard/pages/jobs-page.d.ts +0 -18
- package/dist/components/dashboard/pages/jobs-page.js +27 -24
- package/dist/components/dashboard/table/table-wrapper.d.ts +21 -24
- package/dist/components/dashboard/table/table-wrapper.js +38 -51
- package/dist/components/date-picker/date-picker.d.ts +1 -0
- package/dist/components/date-picker/date-picker.js +20 -4
- package/dist/components/date-picker/date-picker.stories.js +16 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.d.ts +1 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.js +51 -23
- package/dist/components/dropdown-input/dropdown-input.d.ts +25 -0
- package/dist/components/dropdown-input/dropdown-input.js +188 -0
- package/dist/components/dropdown-input/dropdown-input.stories.js +240 -0
- package/dist/components/dropdown-input/index.d.ts +2 -0
- package/dist/components/dropdown-input/index.js +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/input/input.d.ts +6 -3
- package/dist/components/input/input.js +27 -11
- package/dist/components/input/input.stories.js +66 -0
- package/dist/components/item/item.stories.js +3 -3
- package/dist/components/table/data-table.d.ts +8 -1
- package/dist/components/table/data-table.js +5 -4
- package/dist/components/table/table-column-header.d.ts +14 -1
- package/dist/components/table/table-column-header.js +12 -5
- package/dist/components/table/table-pagination.d.ts +14 -1
- package/dist/components/table/table-pagination.js +6 -2
- package/dist/components/table/table.js +3 -3
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -5,34 +5,34 @@ import { cn } from '../../utils/cn.js';
|
|
|
5
5
|
export function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
6
6
|
return /*#__PURE__*/ _jsx(DayPicker, {
|
|
7
7
|
showOutsideDays: showOutsideDays,
|
|
8
|
-
className: cn('
|
|
8
|
+
className: cn('transition-colors', className),
|
|
9
9
|
classNames: {
|
|
10
|
-
months: 'flex flex-col sm:flex-row gap-
|
|
11
|
-
month: 'space-y-16 relative',
|
|
12
|
-
month_caption: 'flex items-center justify-center mb-8 px-4 relative h-32',
|
|
10
|
+
months: 'flex flex-col sm:flex-row gap-0',
|
|
11
|
+
month: 'space-y-16 relative p-16 border-r border-border-neutral-base-component last:border-r-0',
|
|
12
|
+
month_caption: 'flex items-center justify-center mb-8 px-4 relative h-32 bg-background-field-base rounded-8 shadow-tooltip',
|
|
13
13
|
caption_label: 'text-sm font-medium text-foreground-neutral-base',
|
|
14
14
|
nav: 'flex items-center gap-4 fixed left-0 top-16 w-full z-10',
|
|
15
|
-
button_previous: cn('size-32 bg-transparent p-0 absolute left-16 top-0', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-
|
|
16
|
-
button_next: cn('size-32 bg-transparent p-0 absolute right-16 top-0', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-
|
|
15
|
+
button_previous: cn('size-32 bg-transparent p-0 absolute left-16 top-0 cursor-pointer', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-muted', 'hover:bg-transparent hover:text-foreground-neutral-subtle', 'active:bg-transparent', 'transition-colors outline-none', 'focus-visible:shadow-border-interactive-with-active', 'disabled:pointer-events-none disabled:opacity-50'),
|
|
16
|
+
button_next: cn('size-32 bg-transparent p-0 absolute right-16 top-0 cursor-pointer', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-muted', 'hover:bg-transparent hover:text-foreground-neutral-subtle', 'active:bg-transparent', 'transition-colors outline-none', 'focus-visible:shadow-border-interactive-with-active', 'disabled:pointer-events-none disabled:opacity-50'),
|
|
17
17
|
month_grid: 'w-full border-collapse mt-8',
|
|
18
|
-
weekdays: 'flex
|
|
18
|
+
weekdays: 'flex gap-8',
|
|
19
19
|
weekday: 'text-foreground-neutral-subtle text-xs font-medium w-36 h-32 flex items-center justify-center',
|
|
20
|
-
week: 'flex mt-
|
|
20
|
+
week: 'flex mt-8 gap-8',
|
|
21
21
|
day: cn('relative text-center size-36 p-0 text-sm font-normal [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none', '[&:last-child[data-selected=true]_button]:rounded-r-6', props.showWeekNumber ? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-6' : '[&:first-child[data-selected=true]_button]:rounded-l-6'),
|
|
22
22
|
day_button: cn('size-36 p-0 text-sm font-normal rounded-6', 'inline-flex items-center justify-center', 'hover:bg-background-button-transparent-hover', 'focus-visible:shadow-border-interactive-with-active', 'transition-colors outline-none', 'aria-selected:opacity-100'),
|
|
23
23
|
range_start: 'day-range-start rounded-6',
|
|
24
24
|
range_end: 'day-range-end rounded-6',
|
|
25
|
-
selected: cn('bg-foreground-highlight-interactive/80 !text-foreground-neutral-
|
|
26
|
-
today: cn('
|
|
25
|
+
selected: cn('bg-foreground-highlight-interactive/80 !text-foreground-neutral-on-inverted font-medium rounded-6', 'hover:bg-foreground-highlight-interactive-hover/80', 'focus:bg-foreground-highlight-interactive/80'),
|
|
26
|
+
today: cn('relative font-medium rounded-6', 'after:absolute after:bottom-[6px] after:left-1/2 after:-translate-x-1/2', 'after:size-[3px] after:rounded-full after:bg-[var(--color-primary-400)]'),
|
|
27
27
|
outside: 'day-outside text-foreground-neutral-muted',
|
|
28
28
|
disabled: 'text-foreground-neutral-disabled opacity-30 cursor-not-allowed',
|
|
29
|
-
range_middle: cn('aria-selected:bg-
|
|
29
|
+
range_middle: cn('aria-selected:bg-background-highlight-base aria-selected:!text-foreground-highlight-interactive'),
|
|
30
30
|
hidden: 'invisible',
|
|
31
31
|
...classNames
|
|
32
32
|
},
|
|
33
33
|
components: {
|
|
34
34
|
Chevron: ({ orientation })=>{
|
|
35
|
-
const iconName = orientation === 'left' ? '
|
|
35
|
+
const iconName = orientation === 'left' ? 'arrowLeftSFill' : 'arrowRightSFill';
|
|
36
36
|
return /*#__PURE__*/ _jsx(Icon, {
|
|
37
37
|
name: iconName,
|
|
38
38
|
className: "size-20"
|
|
@@ -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
|