@clicktap/ui 0.14.19 → 0.14.25
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/components/ContextMenu/ContextMenu.js +1 -1
- package/components/Dialog/Dialog.js +1 -1
- package/components/DialogTrigger/DialogTrigger.js +1 -1
- package/components/Drawer/Drawer.js +1 -1
- package/components/ModalOverlay/ModalOverlay.js +1 -1
- package/components/PinInput/PinInput.js +1 -1
- package/components/Select/Select.js +1 -1
- package/components/Tabs/Tabs.context.d.ts +3 -0
- package/package.json +1 -1
- package/components/Accordion/Accordion.tsx +0 -82
- package/components/Accordion/index.ts +0 -3
- package/components/Avatar/Avatar.stories.tsx +0 -99
- package/components/Avatar/Avatar.tsx +0 -120
- package/components/Avatar/Avatar.types.ts +0 -3
- package/components/Avatar/AvatarGroup/AvatarGroup.tsx +0 -32
- package/components/Avatar/AvatarGroup/AvatarGroup.types.ts +0 -8
- package/components/Avatar/index.ts +0 -4
- package/components/Badge/Badge.stories.tsx +0 -72
- package/components/Badge/Badge.tsx +0 -169
- package/components/Badge/Badge.types.ts +0 -3
- package/components/Badge/index.ts +0 -2
- package/components/Breadcrumbs/BreadcrumbEllipsis.tsx +0 -47
- package/components/Breadcrumbs/BreadcrumbEllipsis.types.ts +0 -5
- package/components/Breadcrumbs/BreadcrumbItem.tsx +0 -23
- package/components/Breadcrumbs/BreadcrumbItem.types.ts +0 -3
- package/components/Breadcrumbs/BreadcrumbLink.tsx +0 -30
- package/components/Breadcrumbs/BreadcrumbLink.types.ts +0 -3
- package/components/Breadcrumbs/BreadcrumbSeparator.tsx +0 -41
- package/components/Breadcrumbs/BreadcrumbSeparator.types.ts +0 -9
- package/components/Breadcrumbs/Breadcrumbs.tsx +0 -28
- package/components/Breadcrumbs/Breadcrumbs.types.ts +0 -6
- package/components/Breadcrumbs/index.ts +0 -10
- package/components/Button/Button.tsx +0 -72
- package/components/Button/Button.types.ts +0 -7
- package/components/Button/index.ts +0 -2
- package/components/Card/Card.tsx +0 -15
- package/components/Card/Card.types.ts +0 -3
- package/components/Card/index.ts +0 -2
- package/components/Checkbox/Checkbox.tsx +0 -122
- package/components/Checkbox/Checkbox.types.ts +0 -15
- package/components/Checkbox/index.ts +0 -2
- package/components/Collapsible/Collapsible.tsx +0 -34
- package/components/Collapsible/Collapsible.types.ts +0 -5
- package/components/Collapsible/CollapsibleTrigger.tsx +0 -57
- package/components/Collapsible/CollapsibleTrigger.types.ts +0 -14
- package/components/Collapsible/index.ts +0 -10
- package/components/Container/Container.tsx +0 -26
- package/components/Container/Container.types.ts +0 -3
- package/components/Container/index.ts +0 -2
- package/components/ContextMenu/ContextMenu.tsx +0 -74
- package/components/ContextMenu/ContextMenu.types.ts +0 -17
- package/components/ContextMenu/index.ts +0 -2
- package/components/CreditCardExpirationInput/CreditCardExpirationInput.tsx +0 -115
- package/components/CreditCardExpirationInput/CreditCardExpirationInput.types.ts +0 -10
- package/components/CreditCardExpirationInput/index.ts +0 -2
- package/components/CreditCardInput/CreditCardInput.tsx +0 -147
- package/components/CreditCardInput/CreditCardInput.types.ts +0 -12
- package/components/CreditCardInput/index.ts +0 -2
- package/components/DateInput/DateInput.tsx +0 -81
- package/components/DateInput/DateInput.types.ts +0 -15
- package/components/DateInput/index.ts +0 -2
- package/components/DateTimeFormat/DateTimeFormat.tsx +0 -16
- package/components/DateTimeFormat/DateTimeFormat.types.ts +0 -7
- package/components/DateTimeFormat/index.ts +0 -2
- package/components/Dialog/Dialog.tsx +0 -65
- package/components/Dialog/Dialog.types.ts +0 -9
- package/components/Dialog/index.ts +0 -2
- package/components/DialogTrigger/DialogTrigger.tsx +0 -45
- package/components/DialogTrigger/DialogTrigger.types.ts +0 -6
- package/components/DialogTrigger/index.ts +0 -5
- package/components/Divider/Divider.stories.tsx +0 -37
- package/components/Divider/Divider.tsx +0 -34
- package/components/Divider/Divider.types.ts +0 -5
- package/components/Divider/index.ts +0 -2
- package/components/DobInput/DobInput.tsx +0 -120
- package/components/DobInput/index.ts +0 -2
- package/components/Drawer/Drawer.tsx +0 -126
- package/components/Drawer/Drawer.types.ts +0 -11
- package/components/Drawer/index.ts +0 -2
- package/components/Icon/Account.tsx +0 -50
- package/components/Icon/Cart.tsx +0 -43
- package/components/Icon/Checkmark.tsx +0 -34
- package/components/Icon/Cross.tsx +0 -36
- package/components/Icon/DownArrow.tsx +0 -23
- package/components/Icon/Hamburger.tsx +0 -23
- package/components/Icon/Icon.types.ts +0 -8
- package/components/Icon/LinkArrow.tsx +0 -32
- package/components/Icon/Minus.tsx +0 -20
- package/components/Icon/Plus.tsx +0 -20
- package/components/Icon/Search.tsx +0 -36
- package/components/Icon/Trash.tsx +0 -27
- package/components/Icon/Verified.tsx +0 -20
- package/components/Icon/index.ts +0 -14
- package/components/Image/Image.tsx +0 -32
- package/components/Image/index.ts +0 -2
- package/components/Input/Input.tsx +0 -109
- package/components/Input/Input.types.ts +0 -17
- package/components/Input/index.ts +0 -2
- package/components/Link/Link.stories.tsx +0 -96
- package/components/Link/Link.tsx +0 -39
- package/components/Link/Link.types.ts +0 -3
- package/components/Link/index.ts +0 -2
- package/components/Loader/CircularEasing.tsx +0 -66
- package/components/Loader/CircularEasing.types.ts +0 -8
- package/components/Loader/Pulse.tsx +0 -45
- package/components/Loader/Pulse.types.ts +0 -5
- package/components/Loader/index.ts +0 -4
- package/components/Menu/ContextMenu.tsx +0 -83
- package/components/Menu/Menu.tsx +0 -143
- package/components/Menu/Menu.types.ts +0 -44
- package/components/Menu/index.ts +0 -4
- package/components/Meter/Meter.stories.tsx +0 -111
- package/components/Meter/Meter.tsx +0 -68
- package/components/Meter/Meter.types.ts +0 -10
- package/components/Meter/index.ts +0 -2
- package/components/Modal/Modal.tsx +0 -16
- package/components/Modal/Modal.types.ts +0 -6
- package/components/Modal/index.ts +0 -2
- package/components/ModalOverlay/ModalOverlay.tsx +0 -121
- package/components/ModalOverlay/ModalOverlay.types.ts +0 -18
- package/components/ModalOverlay/index.ts +0 -2
- package/components/NumberFormat/NumberFormat.tsx +0 -19
- package/components/NumberFormat/NumberFormat.types.ts +0 -8
- package/components/NumberFormat/index.ts +0 -2
- package/components/NumberInput/NumberInput.tsx +0 -164
- package/components/NumberInput/NumberInput.types.ts +0 -22
- package/components/NumberInput/index.ts +0 -2
- package/components/NumberTicker/DigitResolver.tsx +0 -119
- package/components/NumberTicker/DigitResolver.types.ts +0 -18
- package/components/NumberTicker/NumberTicker.tsx +0 -56
- package/components/NumberTicker/NumberTicker.types.ts +0 -96
- package/components/NumberTicker/hooks/useColumnTransition.ts +0 -36
- package/components/NumberTicker/hooks/useNumberDelta.ts +0 -19
- package/components/NumberTicker/hooks/useNumberTicker.ts +0 -36
- package/components/NumberTicker/index.ts +0 -10
- package/components/Pagination/Pagination.tsx +0 -44
- package/components/Pagination/index.ts +0 -2
- package/components/PasswordCheck/PasswordCheck.tsx +0 -59
- package/components/PasswordCheck/PasswordCheck.types.ts +0 -4
- package/components/PasswordCheck/PasswordCheck.utils.ts +0 -47
- package/components/PasswordCheck/index.ts +0 -2
- package/components/PhoneInput/PhoneInput.tsx +0 -191
- package/components/PhoneInput/index.ts +0 -2
- package/components/PinInput/PinInput.tsx +0 -318
- package/components/PinInput/PinInput.types.ts +0 -21
- package/components/PinInput/index.ts +0 -2
- package/components/Progressbar/CircularProgressbar.tsx +0 -71
- package/components/Progressbar/CircularProgressbar.types.ts +0 -10
- package/components/Progressbar/LinearProgressbar.tsx +0 -75
- package/components/Progressbar/LinearProgressbar.types.ts +0 -11
- package/components/Progressbar/index.ts +0 -4
- package/components/Radio/Radio.tsx +0 -88
- package/components/Radio/Radio.types.ts +0 -16
- package/components/Radio/index.ts +0 -2
- package/components/RadioGroup/RadioGroup.tsx +0 -49
- package/components/RadioGroup/RadioGroup.types.ts +0 -7
- package/components/RadioGroup/index.ts +0 -2
- package/components/Select/Option.tsx +0 -32
- package/components/Select/Option.types.ts +0 -3
- package/components/Select/Select.tsx +0 -272
- package/components/Select/Select.types.ts +0 -48
- package/components/Select/index.ts +0 -8
- package/components/Skeleton/Skeleton.tsx +0 -15
- package/components/Skeleton/Skeleton.types.ts +0 -3
- package/components/Skeleton/index.ts +0 -2
- package/components/Slider/Slider.tsx +0 -110
- package/components/Slider/Slider.types.ts +0 -11
- package/components/Slider/index.ts +0 -2
- package/components/Switch/Switch.tsx +0 -63
- package/components/Switch/Switch.types.ts +0 -8
- package/components/Switch/index.ts +0 -2
- package/components/Table/Table.tsx +0 -52
- package/components/Table/Table.types.ts +0 -22
- package/components/Table/index.ts +0 -2
- package/components/Tabs/Tab.tsx +0 -118
- package/components/Tabs/Tab.types.ts +0 -10
- package/components/Tabs/TabList.tsx +0 -51
- package/components/Tabs/TabList.types.ts +0 -12
- package/components/Tabs/TabPanel.tsx +0 -19
- package/components/Tabs/TabPanel.types.ts +0 -3
- package/components/Tabs/Tabs.context.tsx +0 -9
- package/components/Tabs/Tabs.tsx +0 -39
- package/components/Tabs/Tabs.types.ts +0 -3
- package/components/Tabs/index.ts +0 -9
- package/components/TimeInput/TimeInput.stories.tsx +0 -125
- package/components/TimeInput/TimeInput.tsx +0 -81
- package/components/TimeInput/TimeInput.types.ts +0 -15
- package/components/TimeInput/index.ts +0 -2
- package/components/ToggleButton/ToggleButton.stories.tsx +0 -89
- package/components/ToggleButton/ToggleButton.tsx +0 -69
- package/components/ToggleButton/ToggleButton.types.ts +0 -6
- package/components/ToggleButton/index.ts +0 -2
- package/components/Tooltip/Tooltip.tsx +0 -59
- package/components/Tooltip/Tooltip.types.ts +0 -3
- package/components/Tooltip/index.ts +0 -2
- package/components/UploadImage/UploadImage.tsx +0 -206
- package/components/UploadImage/UploadImage.types.ts +0 -15
- package/components/UploadImage/index.ts +0 -2
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Group,
|
|
5
|
-
NumberField,
|
|
6
|
-
Button,
|
|
7
|
-
Input,
|
|
8
|
-
Text,
|
|
9
|
-
FieldError,
|
|
10
|
-
Label,
|
|
11
|
-
} from 'react-aria-components';
|
|
12
|
-
import { cn } from '../../utils/cn';
|
|
13
|
-
import type { NumberInputProps } from './NumberInput.types';
|
|
14
|
-
|
|
15
|
-
const DecrementIcon = (
|
|
16
|
-
<svg
|
|
17
|
-
width="16"
|
|
18
|
-
height="16"
|
|
19
|
-
viewBox="0 0 24 24"
|
|
20
|
-
fill="none"
|
|
21
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
22
|
-
>
|
|
23
|
-
<path
|
|
24
|
-
d="M5 12H19"
|
|
25
|
-
stroke="currentColor"
|
|
26
|
-
strokeWidth="2"
|
|
27
|
-
strokeLinecap="round"
|
|
28
|
-
strokeLinejoin="round"
|
|
29
|
-
/>
|
|
30
|
-
</svg>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const IncrementIcon = (
|
|
34
|
-
<svg
|
|
35
|
-
width="16"
|
|
36
|
-
height="16"
|
|
37
|
-
viewBox="0 0 24 24"
|
|
38
|
-
fill="none"
|
|
39
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
40
|
-
>
|
|
41
|
-
<path
|
|
42
|
-
d="M12 5V19M5 12H19"
|
|
43
|
-
stroke="currentColor"
|
|
44
|
-
strokeWidth="2"
|
|
45
|
-
strokeLinecap="round"
|
|
46
|
-
strokeLinejoin="round"
|
|
47
|
-
/>
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
export function NumberInput({
|
|
52
|
-
label,
|
|
53
|
-
description,
|
|
54
|
-
errorMessage,
|
|
55
|
-
isInvalid,
|
|
56
|
-
isReadOnly,
|
|
57
|
-
slots,
|
|
58
|
-
className,
|
|
59
|
-
classNames,
|
|
60
|
-
...props
|
|
61
|
-
}: NumberInputProps) {
|
|
62
|
-
const groupClasses = [
|
|
63
|
-
'group-hover:border-slate-400',
|
|
64
|
-
'group-disabled:border-slate-200',
|
|
65
|
-
'group-invalid:border-red-500 group-invalid:bg-red-100 group-invalid:text-red-600',
|
|
66
|
-
'group-invalid:group-hover:border-red-600',
|
|
67
|
-
'group-invalid:group-focus:border-red-600',
|
|
68
|
-
];
|
|
69
|
-
const buttonClasses = [
|
|
70
|
-
'flex items-center justify-center shrink-0',
|
|
71
|
-
'rounded-md border-solid border',
|
|
72
|
-
'font-semibold text-sm',
|
|
73
|
-
'w-10 h-10 py-0 px-0 cursor-pointer disabled:cursor-default',
|
|
74
|
-
'transition-all duration-200 ease-in-out',
|
|
75
|
-
'focus:outline-2 focus:outline focus:outline-slate-200 pressed:scale-95',
|
|
76
|
-
'bg-transparent hover:bg-transparent focus:bg-transparent disabled:bg-transparent',
|
|
77
|
-
'border-slate-300 hover:border-slate-400 focus:border-slate-400 disabled:border-slate-200',
|
|
78
|
-
'text-slate-900 disabled:text-slate-500',
|
|
79
|
-
'group-aria-readonly:bg-slate-100 group-aria-readonly:text-slate-500 group-aria-readonly:border-slate-200 group-aria-readonly:cursor-default',
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<NumberField
|
|
84
|
-
isInvalid={isInvalid}
|
|
85
|
-
isReadOnly={isReadOnly}
|
|
86
|
-
className={cn('flex flex-col w-full', className)}
|
|
87
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
88
|
-
{...props}
|
|
89
|
-
>
|
|
90
|
-
<Label className={cn('flex text-slate-500 text-sm', classNames?.label)}>
|
|
91
|
-
{label}
|
|
92
|
-
</Label>
|
|
93
|
-
|
|
94
|
-
<Group
|
|
95
|
-
isInvalid={isInvalid}
|
|
96
|
-
aria-readonly={isReadOnly}
|
|
97
|
-
className={cn(
|
|
98
|
-
'flex rounded-md group',
|
|
99
|
-
'focus-within:outline-2 focus-within:outline focus-within:outline-slate-200',
|
|
100
|
-
'focus-within:invalid:outline-2 focus-within:invalid:outline focus-within:invalid:outline-slate-200',
|
|
101
|
-
'disabled:bg-slate-100',
|
|
102
|
-
classNames?.group
|
|
103
|
-
)}
|
|
104
|
-
>
|
|
105
|
-
<Button
|
|
106
|
-
slot="decrement"
|
|
107
|
-
className={cn(
|
|
108
|
-
buttonClasses,
|
|
109
|
-
groupClasses,
|
|
110
|
-
'border-r-0 rounded-r-none',
|
|
111
|
-
classNames?.decrementBtn
|
|
112
|
-
)}
|
|
113
|
-
>
|
|
114
|
-
{slots?.decrementIcon || DecrementIcon}
|
|
115
|
-
</Button>
|
|
116
|
-
|
|
117
|
-
<Input
|
|
118
|
-
className={cn(
|
|
119
|
-
'border-solid border border-slate-300 text-center',
|
|
120
|
-
'text-sm text-slate-900 placeholder-slate-400',
|
|
121
|
-
'h-10 px-2 py-0 m-0 w-full',
|
|
122
|
-
'bg-white',
|
|
123
|
-
'transition-all duration-200 ease-in-out',
|
|
124
|
-
'hover:border-slate-400',
|
|
125
|
-
'focus:outline-0 focus:border-slate-400',
|
|
126
|
-
'disabled:border-slate-200 disabled:bg-slate-100',
|
|
127
|
-
'invalid:border-red-500 invalid:bg-red-100 invalid:text-red-600',
|
|
128
|
-
'invalid:hover:border-red-600 invalid:focus:border-red-600',
|
|
129
|
-
groupClasses,
|
|
130
|
-
classNames?.input
|
|
131
|
-
)}
|
|
132
|
-
/>
|
|
133
|
-
|
|
134
|
-
<Button
|
|
135
|
-
slot="increment"
|
|
136
|
-
className={cn(
|
|
137
|
-
buttonClasses,
|
|
138
|
-
groupClasses,
|
|
139
|
-
'border-l-0 rounded-l-none',
|
|
140
|
-
classNames?.incrementBtn
|
|
141
|
-
)}
|
|
142
|
-
>
|
|
143
|
-
{slots?.incrementIcon || IncrementIcon}
|
|
144
|
-
</Button>
|
|
145
|
-
</Group>
|
|
146
|
-
|
|
147
|
-
{description && (
|
|
148
|
-
<Text
|
|
149
|
-
className={cn('flex text-slate-500 text-sm', classNames?.description)}
|
|
150
|
-
slot="description"
|
|
151
|
-
>
|
|
152
|
-
{description}
|
|
153
|
-
</Text>
|
|
154
|
-
)}
|
|
155
|
-
<FieldError
|
|
156
|
-
className={cn('flex text-red-500 text-sm', classNames?.error)}
|
|
157
|
-
>
|
|
158
|
-
{errorMessage}
|
|
159
|
-
</FieldError>
|
|
160
|
-
</NumberField>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default NumberInput;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { NumberFieldProps, ValidationResult } from 'react-aria-components';
|
|
3
|
-
import type { SlotsToClasses } from '../../types/SlotsToClasses';
|
|
4
|
-
|
|
5
|
-
export interface NumberInputProps extends NumberFieldProps {
|
|
6
|
-
label?: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
errorMessage?: string | ((validation: ValidationResult) => string);
|
|
9
|
-
slots?: {
|
|
10
|
-
decrementIcon?: ReactNode;
|
|
11
|
-
incrementIcon?: ReactNode;
|
|
12
|
-
};
|
|
13
|
-
classNames?: SlotsToClasses<
|
|
14
|
-
| 'label'
|
|
15
|
-
| 'input'
|
|
16
|
-
| 'description'
|
|
17
|
-
| 'error'
|
|
18
|
-
| 'incrementBtn'
|
|
19
|
-
| 'decrementBtn'
|
|
20
|
-
| 'group'
|
|
21
|
-
>;
|
|
22
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { memo, useId, useMemo, useCallback, useState } from 'react';
|
|
4
|
-
import { motion } from 'framer-motion';
|
|
5
|
-
import type { DigitProps, DigitResolverProps } from './DigitResolver.types';
|
|
6
|
-
import { useColumnTransition } from './hooks/useColumnTransition';
|
|
7
|
-
|
|
8
|
-
const NUMBER_REGEX = /^-?\d*\.?\d+$/;
|
|
9
|
-
|
|
10
|
-
function Digit({
|
|
11
|
-
digit,
|
|
12
|
-
tickerMotionProps,
|
|
13
|
-
transition,
|
|
14
|
-
updateTransition,
|
|
15
|
-
}: DigitProps) {
|
|
16
|
-
const [position, setPosition] = useState(0);
|
|
17
|
-
|
|
18
|
-
const updatePosition = useCallback(
|
|
19
|
-
(node: HTMLDivElement) => {
|
|
20
|
-
if (node !== null) {
|
|
21
|
-
setPosition(node.clientHeight * parseInt(digit, 10));
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
[digit]
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<span className="relative h-auto block" ref={updatePosition} aria-hidden>
|
|
29
|
-
<motion.span
|
|
30
|
-
className="absolute block bottom-0 h-[1000%]"
|
|
31
|
-
initial={{ x: 0, y: position }}
|
|
32
|
-
animate={{ x: 0, y: position }}
|
|
33
|
-
transition={{ ...transition }}
|
|
34
|
-
onAnimationComplete={updateTransition}
|
|
35
|
-
style={{ fontFeatureSettings: 'tnum' }}
|
|
36
|
-
>
|
|
37
|
-
{[9, 8, 7, 6, 5, 4, 3, 2, 1, 0].map((i) => (
|
|
38
|
-
<motion.span
|
|
39
|
-
className="block text-[inherit] leading-[inherit] tabular-nums"
|
|
40
|
-
key={i}
|
|
41
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
42
|
-
{...tickerMotionProps}
|
|
43
|
-
>
|
|
44
|
-
{i}
|
|
45
|
-
</motion.span>
|
|
46
|
-
))}
|
|
47
|
-
</motion.span>
|
|
48
|
-
<motion.span
|
|
49
|
-
className="block text-[inherit] leading-[inherit] invisible"
|
|
50
|
-
aria-hidden
|
|
51
|
-
>
|
|
52
|
-
0
|
|
53
|
-
</motion.span>
|
|
54
|
-
</span>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const DigitMemo = memo(Digit);
|
|
59
|
-
|
|
60
|
-
export function DigitResolver({
|
|
61
|
-
delta,
|
|
62
|
-
digits,
|
|
63
|
-
isNegative,
|
|
64
|
-
tickerMotionProps,
|
|
65
|
-
...transitionConfig
|
|
66
|
-
}: DigitResolverProps) {
|
|
67
|
-
const id = useId();
|
|
68
|
-
const motionProps = useMemo(
|
|
69
|
-
() =>
|
|
70
|
-
typeof tickerMotionProps === 'function'
|
|
71
|
-
? tickerMotionProps({ delta })
|
|
72
|
-
: tickerMotionProps,
|
|
73
|
-
[delta, tickerMotionProps]
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const columnTransition = useColumnTransition({
|
|
77
|
-
...transitionConfig,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
{isNegative && (
|
|
83
|
-
<motion.span
|
|
84
|
-
className="block text-[inherit] leading-[inherit] tabular-nums"
|
|
85
|
-
aria-hidden
|
|
86
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
87
|
-
{...motionProps}
|
|
88
|
-
>
|
|
89
|
-
-
|
|
90
|
-
</motion.span>
|
|
91
|
-
)}
|
|
92
|
-
{digits.map((digit, idx) =>
|
|
93
|
-
NUMBER_REGEX.test(digit) ? (
|
|
94
|
-
<DigitMemo
|
|
95
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
96
|
-
key={`${id}_${idx}`}
|
|
97
|
-
digit={digit}
|
|
98
|
-
tickerMotionProps={motionProps}
|
|
99
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
100
|
-
{...columnTransition}
|
|
101
|
-
/>
|
|
102
|
-
) : (
|
|
103
|
-
<motion.span
|
|
104
|
-
className="block text-[inherit] leading-[inherit] tabular-nums"
|
|
105
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
106
|
-
key={`${id}_${idx}`}
|
|
107
|
-
aria-hidden
|
|
108
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
109
|
-
{...motionProps}
|
|
110
|
-
>
|
|
111
|
-
{digit}
|
|
112
|
-
</motion.span>
|
|
113
|
-
)
|
|
114
|
-
)}
|
|
115
|
-
</>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default DigitResolver;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { MotionProps, Transition } from 'framer-motion';
|
|
2
|
-
import { NumberTickerProps, TickerMotionProps } from './NumberTicker.types';
|
|
3
|
-
|
|
4
|
-
export type DigitResolverProps = Pick<
|
|
5
|
-
NumberTickerProps,
|
|
6
|
-
'tickerMotionProps' | 'skipFirstAnimation' | 'transition'
|
|
7
|
-
> &
|
|
8
|
-
TickerMotionProps & {
|
|
9
|
-
digits: string[];
|
|
10
|
-
isNegative: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type DigitProps = Pick<NumberTickerProps, 'tickerMotionProps'> & {
|
|
14
|
-
digit: string;
|
|
15
|
-
tickerMotionProps: MotionProps | undefined;
|
|
16
|
-
transition: Transition;
|
|
17
|
-
updateTransition: () => void;
|
|
18
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { motion } from 'framer-motion';
|
|
4
|
-
import { cn } from '../../utils/cn';
|
|
5
|
-
import type { NumberTickerProps } from './NumberTicker.types';
|
|
6
|
-
import { useNumberDelta } from './hooks/useNumberDelta';
|
|
7
|
-
import { useNumberTicker } from './hooks/useNumberTicker';
|
|
8
|
-
import { DigitResolver } from './DigitResolver';
|
|
9
|
-
|
|
10
|
-
export function NumberTicker({
|
|
11
|
-
value,
|
|
12
|
-
asLocal,
|
|
13
|
-
localeConfig,
|
|
14
|
-
precision,
|
|
15
|
-
slots,
|
|
16
|
-
skipFirstAnimation,
|
|
17
|
-
transition,
|
|
18
|
-
tickerMotionProps,
|
|
19
|
-
className,
|
|
20
|
-
...props
|
|
21
|
-
}: NumberTickerProps) {
|
|
22
|
-
const { digits, isNegative } = useNumberTicker({
|
|
23
|
-
value,
|
|
24
|
-
asLocal,
|
|
25
|
-
localeConfig,
|
|
26
|
-
precision,
|
|
27
|
-
});
|
|
28
|
-
const delta = useNumberDelta(value);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<motion.span
|
|
32
|
-
className={cn(
|
|
33
|
-
'flex h-auto flex-row flex-nowrap overflow-hidden relative text-[inherit]',
|
|
34
|
-
className
|
|
35
|
-
)}
|
|
36
|
-
aria-valuenow={value}
|
|
37
|
-
layout
|
|
38
|
-
layoutRoot
|
|
39
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
40
|
-
{...props}
|
|
41
|
-
>
|
|
42
|
-
{slots?.startContent}
|
|
43
|
-
<DigitResolver
|
|
44
|
-
isNegative={isNegative}
|
|
45
|
-
digits={digits}
|
|
46
|
-
tickerMotionProps={tickerMotionProps}
|
|
47
|
-
skipFirstAnimation={skipFirstAnimation}
|
|
48
|
-
transition={transition}
|
|
49
|
-
delta={delta}
|
|
50
|
-
/>
|
|
51
|
-
{slots?.endContent}
|
|
52
|
-
</motion.span>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default NumberTicker;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { MotionProps, Transition } from 'framer-motion';
|
|
2
|
-
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
export type TickerMotionProps = {
|
|
5
|
-
delta: 'increase' | 'decrease' | 'same';
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type TransitionConfig = {
|
|
9
|
-
/**
|
|
10
|
-
* Whether the NumberTicker animation on render
|
|
11
|
-
* @default true
|
|
12
|
-
*/
|
|
13
|
-
skipFirstAnimation?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* The transition props to modify the NumberTicker animation.
|
|
16
|
-
* Use the framer motion transition API to create your own transition.
|
|
17
|
-
*/
|
|
18
|
-
transition?: Transition;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface NumberTickerConfig {
|
|
22
|
-
value: number;
|
|
23
|
-
/**
|
|
24
|
-
* Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
|
|
25
|
-
* @default 2
|
|
26
|
-
*/
|
|
27
|
-
precision?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Whether the NumberTicker value as Intl.NumberFormat
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
asLocal?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The configuration for the NumberTicker value as Intl.NumberFormat
|
|
35
|
-
* By default the object {
|
|
36
|
-
locale: 'en-US',
|
|
37
|
-
options: {
|
|
38
|
-
style: 'currency',
|
|
39
|
-
currency: 'USD',
|
|
40
|
-
minimumFractionDigits: 2,
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
*/
|
|
44
|
-
localeConfig?: {
|
|
45
|
-
locale?: string;
|
|
46
|
-
options?: Intl.NumberFormatOptions | undefined;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type NumberTickerProps = NumberTickerConfig &
|
|
51
|
-
TransitionConfig & {
|
|
52
|
-
style?: CSSProperties;
|
|
53
|
-
className?: string;
|
|
54
|
-
slots?: {
|
|
55
|
-
/**
|
|
56
|
-
* Element to be rendered in the left side of the NumberTicker.
|
|
57
|
-
*/
|
|
58
|
-
startContent?: ReactNode;
|
|
59
|
-
/**
|
|
60
|
-
* Element to be rendered in the right side of the NumberTicker.
|
|
61
|
-
*/
|
|
62
|
-
endContent?: ReactNode;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The motion props to modify the each Ticker animation.
|
|
67
|
-
* Use the framer motion API to create your own animation. With the possible to use the delta value
|
|
68
|
-
* Example:
|
|
69
|
-
*
|
|
70
|
-
* const getColor = (delta: TickerMotionProps) => {
|
|
71
|
-
switch (d) {
|
|
72
|
-
case 'increase':
|
|
73
|
-
return '#48ff0b';
|
|
74
|
-
case 'decrease':
|
|
75
|
-
return '#F22613';
|
|
76
|
-
default:
|
|
77
|
-
return '#fff';
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
<NumberTicker
|
|
82
|
-
tickerMotionProps={({ delta }) => ({
|
|
83
|
-
animate: {
|
|
84
|
-
color: [getColor(delta), '#fff'],
|
|
85
|
-
transition: {
|
|
86
|
-
duration: 2,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
})}
|
|
90
|
-
/>
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
tickerMotionProps?:
|
|
94
|
-
| MotionProps
|
|
95
|
-
| ((props: TickerMotionProps) => MotionProps);
|
|
96
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Transition } from 'framer-motion';
|
|
2
|
-
import { useState, useMemo, useCallback } from 'react';
|
|
3
|
-
import { TransitionConfig } from '../NumberTicker.types';
|
|
4
|
-
|
|
5
|
-
export const useColumnTransition = ({
|
|
6
|
-
skipFirstAnimation = true,
|
|
7
|
-
transition: transitionProps,
|
|
8
|
-
}: TransitionConfig) => {
|
|
9
|
-
const [firstAnimation, setFirstAnimation] = useState(skipFirstAnimation);
|
|
10
|
-
|
|
11
|
-
const transition = useMemo<Transition>(() => {
|
|
12
|
-
return firstAnimation
|
|
13
|
-
? {
|
|
14
|
-
duration: 0.1,
|
|
15
|
-
}
|
|
16
|
-
: {
|
|
17
|
-
...(transitionProps || {
|
|
18
|
-
type: 'spring',
|
|
19
|
-
stiffness: 50,
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
}, [firstAnimation, transitionProps]);
|
|
23
|
-
|
|
24
|
-
const updateTransition = useCallback(() => {
|
|
25
|
-
if (skipFirstAnimation) {
|
|
26
|
-
setFirstAnimation(false);
|
|
27
|
-
}
|
|
28
|
-
}, [skipFirstAnimation]);
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
transition,
|
|
32
|
-
updateTransition,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default useColumnTransition;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useNumberDelta = (value = 0) => {
|
|
4
|
-
const ref = useRef(value);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
ref.current = value;
|
|
7
|
-
}, [value]);
|
|
8
|
-
|
|
9
|
-
switch (true) {
|
|
10
|
-
case value > ref.current:
|
|
11
|
-
return 'increase';
|
|
12
|
-
case value < ref.current:
|
|
13
|
-
return 'decrease';
|
|
14
|
-
default:
|
|
15
|
-
return 'same';
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default useNumberDelta;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { NumberTickerConfig } from '../NumberTicker.types';
|
|
3
|
-
|
|
4
|
-
export const useNumberTicker = ({
|
|
5
|
-
value = 0,
|
|
6
|
-
asLocal = false,
|
|
7
|
-
localeConfig = {
|
|
8
|
-
locale: 'en-US',
|
|
9
|
-
options: {
|
|
10
|
-
style: 'currency',
|
|
11
|
-
currency: 'USD',
|
|
12
|
-
minimumFractionDigits: 2,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
precision = 2,
|
|
16
|
-
}: NumberTickerConfig) => {
|
|
17
|
-
const parsed = parseFloat(`${Math.max(Math.abs(value), 0)}`).toFixed(
|
|
18
|
-
precision ?? 0
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const number = asLocal
|
|
22
|
-
? new Intl.NumberFormat(localeConfig?.locale, {
|
|
23
|
-
...localeConfig?.options,
|
|
24
|
-
}).format(parseFloat(parsed))
|
|
25
|
-
: parsed;
|
|
26
|
-
|
|
27
|
-
return useMemo(
|
|
28
|
-
() => ({
|
|
29
|
-
digits: number.split(''),
|
|
30
|
-
isNegative: value < 0,
|
|
31
|
-
}),
|
|
32
|
-
[number, value]
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default useNumberTicker;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { DigitResolver } from './DigitResolver';
|
|
2
|
-
export { NumberTicker } from './NumberTicker';
|
|
3
|
-
|
|
4
|
-
export type { DigitProps, DigitResolverProps } from './DigitResolver.types';
|
|
5
|
-
export type {
|
|
6
|
-
NumberTickerConfig,
|
|
7
|
-
NumberTickerProps,
|
|
8
|
-
TickerMotionProps,
|
|
9
|
-
TransitionConfig,
|
|
10
|
-
} from './NumberTicker.types';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Pagination as UiPagination } from '@nextui-org/pagination';
|
|
4
|
-
import type { PaginationProps } from '@nextui-org/pagination';
|
|
5
|
-
import { cn } from '../../utils/cn';
|
|
6
|
-
|
|
7
|
-
const controlClassNames = cn(
|
|
8
|
-
'w-8 h-8 flex justify-center items-center cursor-pointer shadow-none',
|
|
9
|
-
'border border-slate-200 data-[disabled=true]:border-0',
|
|
10
|
-
'rounded transition-colors duration-300 data-[focus-visible="true"]:outline-white data-[focus-visible="true"]:outline-offset-4',
|
|
11
|
-
'hover:bg-slate-50 data-[disabled=true]:bg-slate-100 data-[disabled=true]:text-slate-400',
|
|
12
|
-
'[&>svg]:w-4.5 [&>svg]:h-auto'
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export function Pagination({
|
|
16
|
-
showControls = true,
|
|
17
|
-
className,
|
|
18
|
-
classNames,
|
|
19
|
-
...rest
|
|
20
|
-
}: PaginationProps) {
|
|
21
|
-
return (
|
|
22
|
-
<UiPagination
|
|
23
|
-
showControls={showControls}
|
|
24
|
-
className={cn('text-slate-600', className)}
|
|
25
|
-
classNames={{
|
|
26
|
-
wrapper: cn('flex flex-nowrap gap-2 lg:gap-3', classNames?.wrapper),
|
|
27
|
-
item: cn(
|
|
28
|
-
'w-8 h-8 flex text-sm justify-center items-center cursor-pointer rounded shadow-none',
|
|
29
|
-
'border-solid border border-slate-100 bg-transparent transition-colors duration-300',
|
|
30
|
-
'data-[active=true]:bg-slate-500 data-[active=true]:text-white data-[focus-visible="true"]:outline-white data-[focus-visible="true"]:outline-offset-4',
|
|
31
|
-
'[&[data-hover=true]:not([data-active=true])]:border-slate-200',
|
|
32
|
-
classNames?.item
|
|
33
|
-
),
|
|
34
|
-
prev: cn(controlClassNames, classNames?.prev),
|
|
35
|
-
next: cn(controlClassNames, classNames?.next),
|
|
36
|
-
ellipsis: cn('w-4 h-4.5 scale-110 translate-y-1', classNames?.ellipsis),
|
|
37
|
-
}}
|
|
38
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
39
|
-
{...rest}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default Pagination;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { cn } from '../../utils/cn';
|
|
4
|
-
import type { PasswordCheckProps } from './PasswordCheck.types';
|
|
5
|
-
import { checkStrength, getProgressText } from './PasswordCheck.utils';
|
|
6
|
-
|
|
7
|
-
export function PasswordCheck({
|
|
8
|
-
value,
|
|
9
|
-
variant = 'default',
|
|
10
|
-
}: PasswordCheckProps) {
|
|
11
|
-
const strength = checkStrength(value);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<div
|
|
16
|
-
className={cn(
|
|
17
|
-
'relative w-full flex gap-x-2',
|
|
18
|
-
variant === 'default' && 'mb-8 -mt-1'
|
|
19
|
-
)}
|
|
20
|
-
>
|
|
21
|
-
{Array.from({ length: 5 }, (_, idx) => idx).map((v, idx) => (
|
|
22
|
-
<div
|
|
23
|
-
className={cn(
|
|
24
|
-
'grow shrink basis-1/5 h-1 rounded-full transition-colors duration-700 ease bg-slate-200',
|
|
25
|
-
strength <= idx && 'bg-slate-600',
|
|
26
|
-
(strength === 1 || strength === 2) && 'bg-red-600',
|
|
27
|
-
strength === 3 && 'bg-yellow-600',
|
|
28
|
-
strength === 4 && 'bg-green-600',
|
|
29
|
-
strength === 5 && 'bg-blue-600'
|
|
30
|
-
)}
|
|
31
|
-
key={v}
|
|
32
|
-
/>
|
|
33
|
-
))}
|
|
34
|
-
{variant === 'default' && (
|
|
35
|
-
<div
|
|
36
|
-
className={cn(
|
|
37
|
-
'inline-flex gap-x-1 absolute top-0 left-0 text-xs translate-y-2/4 text-slate-950',
|
|
38
|
-
strength ? 'opacity-100' : 'opacity-0'
|
|
39
|
-
)}
|
|
40
|
-
>
|
|
41
|
-
<span>Password Strength:</span>
|
|
42
|
-
<span
|
|
43
|
-
className={cn(
|
|
44
|
-
(strength === 1 || strength === 2) && 'text-red-600',
|
|
45
|
-
strength === 3 && 'text-yellow-600',
|
|
46
|
-
strength === 4 && 'text-green-600',
|
|
47
|
-
strength === 5 && 'text-blue-600'
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
{getProgressText(strength)}
|
|
51
|
-
</span>
|
|
52
|
-
</div>
|
|
53
|
-
)}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default PasswordCheck;
|