@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,83 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { cloneElement } from 'react';
|
|
4
|
-
import { AnimatePresence } from 'framer-motion';
|
|
5
|
-
import { cn } from '../../utils/cn';
|
|
6
|
-
import { Menu } from './Menu';
|
|
7
|
-
import type { MenuProps } from './Menu.types';
|
|
8
|
-
|
|
9
|
-
export function ContextMenu({
|
|
10
|
-
slots,
|
|
11
|
-
role = 'tooltip',
|
|
12
|
-
arrow,
|
|
13
|
-
...rest
|
|
14
|
-
}: MenuProps) {
|
|
15
|
-
const arrowConfig = {
|
|
16
|
-
width: 24,
|
|
17
|
-
height: 8,
|
|
18
|
-
className: cn('fill-slate-50', arrow?.className),
|
|
19
|
-
...arrow,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const ContentSlot = slots?.submenu
|
|
23
|
-
? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
24
|
-
cloneElement(slots?.submenu, {
|
|
25
|
-
...slots.submenu.props,
|
|
26
|
-
})
|
|
27
|
-
: null;
|
|
28
|
-
|
|
29
|
-
const SubmenuSlot = slots?.contentRoot ? (
|
|
30
|
-
cloneElement(
|
|
31
|
-
slots.contentRoot,
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
33
|
-
{
|
|
34
|
-
...slots.contentRoot.props,
|
|
35
|
-
},
|
|
36
|
-
ContentSlot
|
|
37
|
-
)
|
|
38
|
-
) : (
|
|
39
|
-
<div className="relative rounded-md py-4 px-6 bg-gray-50 shadow">
|
|
40
|
-
{ContentSlot}
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<AnimatePresence>
|
|
46
|
-
<Menu
|
|
47
|
-
role={role}
|
|
48
|
-
arrow={arrowConfig}
|
|
49
|
-
hidden={{
|
|
50
|
-
opacity: 0,
|
|
51
|
-
y: -5,
|
|
52
|
-
visibility: 'hidden',
|
|
53
|
-
transition: {
|
|
54
|
-
type: 'spring',
|
|
55
|
-
duration: 0.3,
|
|
56
|
-
bounce: 0,
|
|
57
|
-
},
|
|
58
|
-
}}
|
|
59
|
-
visible={{
|
|
60
|
-
opacity: 1,
|
|
61
|
-
y: 0,
|
|
62
|
-
visibility: 'visible',
|
|
63
|
-
transition: {
|
|
64
|
-
type: 'spring',
|
|
65
|
-
duration: 0.75,
|
|
66
|
-
bounce: 0,
|
|
67
|
-
staggerChildren: 0.075,
|
|
68
|
-
delayChildren: 0.1,
|
|
69
|
-
},
|
|
70
|
-
}}
|
|
71
|
-
slots={{
|
|
72
|
-
submenu: SubmenuSlot,
|
|
73
|
-
submenuRoot: slots?.submenuRoot,
|
|
74
|
-
content: slots?.content,
|
|
75
|
-
}}
|
|
76
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
77
|
-
{...rest}
|
|
78
|
-
/>
|
|
79
|
-
</AnimatePresence>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default ContextMenu;
|
package/components/Menu/Menu.tsx
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { cloneElement, useState, useRef, useId } from 'react';
|
|
4
|
-
import { motion } from 'framer-motion';
|
|
5
|
-
import {
|
|
6
|
-
flip,
|
|
7
|
-
shift,
|
|
8
|
-
arrow as arrowMiddleware,
|
|
9
|
-
offset as offsetMiddleware,
|
|
10
|
-
useFocus,
|
|
11
|
-
useRole,
|
|
12
|
-
useFloating,
|
|
13
|
-
useInteractions,
|
|
14
|
-
useHover,
|
|
15
|
-
useClick,
|
|
16
|
-
useDismiss,
|
|
17
|
-
useDelayGroupContext,
|
|
18
|
-
useDelayGroup,
|
|
19
|
-
FloatingArrow,
|
|
20
|
-
autoUpdate,
|
|
21
|
-
} from '@floating-ui/react';
|
|
22
|
-
import type { ButtonProps } from 'react-aria-components';
|
|
23
|
-
import type { MenuProps } from './Menu.types';
|
|
24
|
-
|
|
25
|
-
export function Menu({
|
|
26
|
-
closeDelay = 300,
|
|
27
|
-
offset = 20,
|
|
28
|
-
openDelay = 0,
|
|
29
|
-
placement = 'bottom-start',
|
|
30
|
-
slots,
|
|
31
|
-
trigger = ['hover', 'focus'],
|
|
32
|
-
withArrow = true,
|
|
33
|
-
arrow,
|
|
34
|
-
role = 'dialog',
|
|
35
|
-
visible = {},
|
|
36
|
-
hidden = {},
|
|
37
|
-
floatingOptions = {},
|
|
38
|
-
isOpen,
|
|
39
|
-
onOpenChange,
|
|
40
|
-
}: MenuProps) {
|
|
41
|
-
const [isOpenUncontrolled, setIsOpenUncontrolled] = useState(false);
|
|
42
|
-
const arrowRef = useRef(null);
|
|
43
|
-
const id = useId();
|
|
44
|
-
const { x, y, strategy, refs, context } = useFloating({
|
|
45
|
-
placement,
|
|
46
|
-
middleware: [
|
|
47
|
-
offsetMiddleware(offset),
|
|
48
|
-
flip(),
|
|
49
|
-
shift(),
|
|
50
|
-
arrowMiddleware({
|
|
51
|
-
element: arrowRef,
|
|
52
|
-
}),
|
|
53
|
-
],
|
|
54
|
-
open: isOpen || isOpenUncontrolled,
|
|
55
|
-
onOpenChange: onOpenChange || setIsOpenUncontrolled,
|
|
56
|
-
whileElementsMounted: autoUpdate,
|
|
57
|
-
...floatingOptions,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const dismissConfig = useDismiss(context);
|
|
61
|
-
const roleConfig = useRole(context, {
|
|
62
|
-
role,
|
|
63
|
-
});
|
|
64
|
-
const { delay: delayGroup } = useDelayGroupContext();
|
|
65
|
-
const delay = {
|
|
66
|
-
open: openDelay,
|
|
67
|
-
close: closeDelay,
|
|
68
|
-
};
|
|
69
|
-
const hoverConfig = useHover(context, { delay: delayGroup || delay });
|
|
70
|
-
const focusConfig = useFocus(context);
|
|
71
|
-
const clickConfig = useClick(context);
|
|
72
|
-
|
|
73
|
-
const interactions = [
|
|
74
|
-
trigger.find((value) => value === 'hover') ? hoverConfig : undefined,
|
|
75
|
-
trigger.find((value) => value === 'click') ? clickConfig : undefined,
|
|
76
|
-
trigger.find((value) => value === 'focus') ? focusConfig : undefined,
|
|
77
|
-
dismissConfig,
|
|
78
|
-
roleConfig,
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
const { getReferenceProps, getFloatingProps } = useInteractions(interactions);
|
|
82
|
-
|
|
83
|
-
useDelayGroup(context, { id });
|
|
84
|
-
|
|
85
|
-
// https://github.com/floating-ui/floating-ui/issues/2646
|
|
86
|
-
const { onClick, ...referenceProps } = getReferenceProps();
|
|
87
|
-
const keyboardEvents = String(
|
|
88
|
-
(slots?.content?.props as ButtonProps).className
|
|
89
|
-
).includes('pressable')
|
|
90
|
-
? { onPress: onClick }
|
|
91
|
-
: { onClick };
|
|
92
|
-
|
|
93
|
-
const ContentSlot = slots?.content ? (
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
95
|
-
cloneElement(slots.content, {
|
|
96
|
-
...slots.content.props,
|
|
97
|
-
ref: refs.setReference,
|
|
98
|
-
...referenceProps,
|
|
99
|
-
...keyboardEvents,
|
|
100
|
-
})
|
|
101
|
-
) : (
|
|
102
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
103
|
-
<div ref={refs.setReference} {...getReferenceProps()}>
|
|
104
|
-
Menu Action
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const SubmenuSlot = slots?.submenu ? (
|
|
109
|
-
<motion.nav
|
|
110
|
-
ref={refs.setFloating}
|
|
111
|
-
style={{
|
|
112
|
-
position: strategy,
|
|
113
|
-
top: y ?? 0,
|
|
114
|
-
left: x ?? 0,
|
|
115
|
-
width: 'max-content',
|
|
116
|
-
zIndex: 50,
|
|
117
|
-
}}
|
|
118
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
119
|
-
{...getFloatingProps()}
|
|
120
|
-
variants={{ hidden, visible }}
|
|
121
|
-
initial="hidden"
|
|
122
|
-
animate={isOpen || isOpenUncontrolled ? 'visible' : 'hidden'}
|
|
123
|
-
>
|
|
124
|
-
{withArrow && (
|
|
125
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
126
|
-
<FloatingArrow ref={arrowRef} context={context} {...arrow} />
|
|
127
|
-
)}
|
|
128
|
-
|
|
129
|
-
{slots.submenu}
|
|
130
|
-
</motion.nav>
|
|
131
|
-
) : (
|
|
132
|
-
<nav>Submenu</nav>
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<>
|
|
137
|
-
{ContentSlot}
|
|
138
|
-
{SubmenuSlot}
|
|
139
|
-
</>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export default Menu;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Variant } from 'framer-motion';
|
|
2
|
-
import type { ReactElement } from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
MiddlewareState,
|
|
5
|
-
Placement,
|
|
6
|
-
FloatingArrowProps,
|
|
7
|
-
UseRoleProps,
|
|
8
|
-
UseFloatingOptions,
|
|
9
|
-
} from '@floating-ui/react';
|
|
10
|
-
|
|
11
|
-
type Trigger = 'click' | 'hover' | 'focus';
|
|
12
|
-
|
|
13
|
-
/** from floating-ui docs https://floating-ui.com/docs/offset */
|
|
14
|
-
interface AxesOffsets {
|
|
15
|
-
mainAxis?: number;
|
|
16
|
-
crossAxis?: number;
|
|
17
|
-
alignmentAxis?: number | null;
|
|
18
|
-
}
|
|
19
|
-
type Options =
|
|
20
|
-
| number
|
|
21
|
-
| AxesOffsets
|
|
22
|
-
| ((state: MiddlewareState) => number | AxesOffsets);
|
|
23
|
-
|
|
24
|
-
export interface MenuProps {
|
|
25
|
-
closeDelay?: number;
|
|
26
|
-
offset?: Options;
|
|
27
|
-
openDelay?: number;
|
|
28
|
-
placement?: Placement;
|
|
29
|
-
slots?: {
|
|
30
|
-
content?: ReactElement;
|
|
31
|
-
contentRoot?: ReactElement;
|
|
32
|
-
submenuRoot?: ReactElement;
|
|
33
|
-
submenu?: ReactElement;
|
|
34
|
-
};
|
|
35
|
-
trigger?: Trigger[];
|
|
36
|
-
withArrow?: boolean;
|
|
37
|
-
arrow?: Omit<FloatingArrowProps, 'context'>;
|
|
38
|
-
role?: UseRoleProps['role'];
|
|
39
|
-
visible?: Variant;
|
|
40
|
-
hidden?: Variant;
|
|
41
|
-
floatingOptions?: UseFloatingOptions;
|
|
42
|
-
isOpen?: boolean;
|
|
43
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
44
|
-
}
|
package/components/Menu/index.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { Meter } from './Meter';
|
|
4
|
-
import { Button } from '../Button/Button';
|
|
5
|
-
import { MeterProps } from './Meter.types';
|
|
6
|
-
|
|
7
|
-
type Story = StoryObj<typeof Meter>;
|
|
8
|
-
|
|
9
|
-
function Component({ children, value: v, ...props }: MeterProps) {
|
|
10
|
-
const [value, setValue] = useState(v || 0);
|
|
11
|
-
|
|
12
|
-
const increase = () =>
|
|
13
|
-
setValue(value === props?.maxValue ? props?.maxValue : value + 10);
|
|
14
|
-
|
|
15
|
-
const decrease = () =>
|
|
16
|
-
setValue(value === props?.minValue ? props?.minValue : value - 10);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (v) setValue(v);
|
|
20
|
-
}, [v]);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
style={{
|
|
25
|
-
display: 'flex',
|
|
26
|
-
flexDirection: 'column',
|
|
27
|
-
gap: '2rem',
|
|
28
|
-
margin: '2rem 0',
|
|
29
|
-
}}
|
|
30
|
-
>
|
|
31
|
-
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
|
32
|
-
<Meter value={value} {...props} />
|
|
33
|
-
|
|
34
|
-
<div
|
|
35
|
-
style={{
|
|
36
|
-
display: 'flex',
|
|
37
|
-
gap: '2rem',
|
|
38
|
-
justifyContent: 'center',
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
<Button size="sm" onPress={decrease}>
|
|
42
|
-
-
|
|
43
|
-
</Button>
|
|
44
|
-
<Button size="sm" onPress={increase}>
|
|
45
|
-
+
|
|
46
|
-
</Button>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const meta: Meta<typeof Meter> = {
|
|
53
|
-
component: Component,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default meta;
|
|
57
|
-
|
|
58
|
-
export const Base: Story = {
|
|
59
|
-
argTypes: {
|
|
60
|
-
label: {
|
|
61
|
-
control: 'text',
|
|
62
|
-
description: 'The content to display as label',
|
|
63
|
-
},
|
|
64
|
-
showValue: {
|
|
65
|
-
control: 'boolean',
|
|
66
|
-
description: 'Whether the value show',
|
|
67
|
-
},
|
|
68
|
-
formatOptions: {
|
|
69
|
-
control: 'object',
|
|
70
|
-
description: 'The display format of the value label.',
|
|
71
|
-
},
|
|
72
|
-
valueLabel: {
|
|
73
|
-
control: 'text',
|
|
74
|
-
description:
|
|
75
|
-
'The content to display as the value's label (e.g. 1 of 4)',
|
|
76
|
-
},
|
|
77
|
-
value: {
|
|
78
|
-
control: 'number',
|
|
79
|
-
description: 'The current value (controlled).',
|
|
80
|
-
},
|
|
81
|
-
minValue: {
|
|
82
|
-
control: 'number',
|
|
83
|
-
description: 'The smallest value allowed for the input.',
|
|
84
|
-
},
|
|
85
|
-
maxValue: {
|
|
86
|
-
control: 'number',
|
|
87
|
-
description: 'The largest value allowed for the input.',
|
|
88
|
-
},
|
|
89
|
-
style: {
|
|
90
|
-
control: 'object',
|
|
91
|
-
description:
|
|
92
|
-
'The inline style for the element. A function may be provided to compute the style based on component state.',
|
|
93
|
-
},
|
|
94
|
-
className: {
|
|
95
|
-
control: 'text',
|
|
96
|
-
description:
|
|
97
|
-
'The CSS className for the element. A function may be provided to compute the class based on component state.',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
args: {
|
|
101
|
-
label: '',
|
|
102
|
-
showValue: true,
|
|
103
|
-
formatOptions: { style: 'percent' },
|
|
104
|
-
valueLabel: '',
|
|
105
|
-
value: 0,
|
|
106
|
-
minValue: 0,
|
|
107
|
-
maxValue: 100,
|
|
108
|
-
style: {},
|
|
109
|
-
className: '',
|
|
110
|
-
},
|
|
111
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Meter as AriaMeter, Label } from 'react-aria-components';
|
|
4
|
-
import { motion } from 'framer-motion';
|
|
5
|
-
import { cn } from '../../utils/cn';
|
|
6
|
-
import type { MeterProps } from './Meter.types';
|
|
7
|
-
|
|
8
|
-
export function Meter({
|
|
9
|
-
label,
|
|
10
|
-
showValue = true,
|
|
11
|
-
value = 0,
|
|
12
|
-
minValue = 0,
|
|
13
|
-
maxValue = 100,
|
|
14
|
-
formatOptions = { style: 'percent' },
|
|
15
|
-
className,
|
|
16
|
-
classNames,
|
|
17
|
-
...props
|
|
18
|
-
}: MeterProps) {
|
|
19
|
-
return (
|
|
20
|
-
<AriaMeter
|
|
21
|
-
className={cn('flex flex-col gap-2', className)}
|
|
22
|
-
value={value}
|
|
23
|
-
minValue={minValue}
|
|
24
|
-
maxValue={maxValue}
|
|
25
|
-
formatOptions={formatOptions}
|
|
26
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
{({ percentage, valueText }) => (
|
|
30
|
-
<div
|
|
31
|
-
className={cn(
|
|
32
|
-
'flex justify-between items-center gap-4',
|
|
33
|
-
classNames?.labelWrapper
|
|
34
|
-
)}
|
|
35
|
-
>
|
|
36
|
-
{label && (
|
|
37
|
-
<Label className={cn('text-sm', classNames?.label)}>{label}</Label>
|
|
38
|
-
)}
|
|
39
|
-
<div
|
|
40
|
-
className={cn(
|
|
41
|
-
'flex-auto h-2.5 rounded-md bg-slate-300 forced-color-adjust-none overflow-hidden',
|
|
42
|
-
classNames?.trackWrapepr
|
|
43
|
-
)}
|
|
44
|
-
>
|
|
45
|
-
<motion.div
|
|
46
|
-
className={cn('h-full bg-slate-800', classNames?.track)}
|
|
47
|
-
initial={{ width: `${percentage}%` }}
|
|
48
|
-
animate={{ width: `${percentage}%` }}
|
|
49
|
-
transition={{
|
|
50
|
-
type: 'spring',
|
|
51
|
-
bounce: 0,
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
{showValue && (
|
|
56
|
-
<span
|
|
57
|
-
className={cn('text-sm tabular-nums ml-auto', classNames?.value)}
|
|
58
|
-
>
|
|
59
|
-
{valueText}
|
|
60
|
-
</span>
|
|
61
|
-
)}
|
|
62
|
-
</div>
|
|
63
|
-
)}
|
|
64
|
-
</AriaMeter>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default Meter;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { MeterProps as AriaMeterProps } from 'react-aria-components';
|
|
2
|
-
import type { SlotsToClasses } from '../../types/SlotsToClasses';
|
|
3
|
-
|
|
4
|
-
export type MeterProps = AriaMeterProps & {
|
|
5
|
-
label?: string;
|
|
6
|
-
showValue?: boolean;
|
|
7
|
-
classNames?: SlotsToClasses<
|
|
8
|
-
'label' | 'value' | 'labelWrapper' | 'track' | 'trackWrapepr'
|
|
9
|
-
>;
|
|
10
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Modal as UIModal } from 'react-aria-components';
|
|
4
|
-
import { cn } from '../../utils/cn';
|
|
5
|
-
import type { ModalProps } from './Modal.types';
|
|
6
|
-
|
|
7
|
-
export function Modal({ children, className, ...props }: ModalProps) {
|
|
8
|
-
return (
|
|
9
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
10
|
-
<UIModal {...props} className={cn('absolute inset-1/2', className)}>
|
|
11
|
-
{children}
|
|
12
|
-
</UIModal>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default Modal;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { forwardRef, useId } from 'react';
|
|
4
|
-
import type { Dispatch, ReactNode, Ref, SetStateAction } from 'react';
|
|
5
|
-
import { ModalOverlay as UIModalOverlay } from 'react-aria-components';
|
|
6
|
-
import { AnimatePresence, motion } from 'framer-motion';
|
|
7
|
-
import { useDialogTrigger } from '../DialogTrigger/DialogTrigger';
|
|
8
|
-
/** @todo this probably belongs in Modal instead of DialogTrigger */
|
|
9
|
-
import type { DriverAnimationState } from '../DialogTrigger/DialogTrigger.types';
|
|
10
|
-
import { cn } from '../../utils/cn';
|
|
11
|
-
import type { ModalOverlayProps } from './ModalOverlay.types';
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const ForwardedModalOverlay = forwardRef<HTMLElement, any>(
|
|
15
|
-
({ style, ...props }, ref: Ref<HTMLElement>) => {
|
|
16
|
-
// Separate the dynamic style logic
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
18
|
-
const ariaStyle = typeof style === 'function' ? style(props) : style;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
// Pass only static styles to framer-motion
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, react/jsx-props-no-spreading
|
|
23
|
-
<UIModalOverlay {...props} ref={ref} style={ariaStyle} />
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const MotionModalOverlay = motion.create(ForwardedModalOverlay);
|
|
29
|
-
|
|
30
|
-
function InnerModalOverlay({
|
|
31
|
-
animate,
|
|
32
|
-
animation,
|
|
33
|
-
setAnimation,
|
|
34
|
-
className,
|
|
35
|
-
animationVariants,
|
|
36
|
-
children,
|
|
37
|
-
...props
|
|
38
|
-
}: ModalOverlayProps & {
|
|
39
|
-
animate: string;
|
|
40
|
-
animation: string;
|
|
41
|
-
setAnimation: Dispatch<SetStateAction<DriverAnimationState>>;
|
|
42
|
-
}) {
|
|
43
|
-
const id = useId();
|
|
44
|
-
|
|
45
|
-
// extract key from props to avoid spreading it
|
|
46
|
-
const { key, ...restProps } = props;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<MotionModalOverlay
|
|
50
|
-
key={key || id}
|
|
51
|
-
isExiting={animation === 'hidden'}
|
|
52
|
-
onAnimationComplete={(currentAnimation: DriverAnimationState) => {
|
|
53
|
-
setAnimation((a) =>
|
|
54
|
-
currentAnimation === 'hidden' && a === 'hidden' ? 'unmounted' : a
|
|
55
|
-
);
|
|
56
|
-
}}
|
|
57
|
-
variants={
|
|
58
|
-
animationVariants || {
|
|
59
|
-
hidden: {
|
|
60
|
-
opacity: 0,
|
|
61
|
-
backdropFilter: 'blur(0px)',
|
|
62
|
-
transition: {
|
|
63
|
-
delay: 0.08,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
visible: {
|
|
67
|
-
opacity: 1,
|
|
68
|
-
backdropFilter: 'blur(8px)',
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
initial="hidden"
|
|
73
|
-
animate={animate}
|
|
74
|
-
exit="hidden"
|
|
75
|
-
className={cn(
|
|
76
|
-
'bg-black/30',
|
|
77
|
-
'fixed top-0 left-0',
|
|
78
|
-
'z-50',
|
|
79
|
-
'w-screen h-[var(--visual-viewport-height)]',
|
|
80
|
-
className
|
|
81
|
-
)}
|
|
82
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
83
|
-
{...restProps}
|
|
84
|
-
>
|
|
85
|
-
{children as ReactNode}
|
|
86
|
-
</MotionModalOverlay>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function ModalOverlay(props: ModalOverlayProps) {
|
|
91
|
-
const { isOpen } = props;
|
|
92
|
-
const { animation, setAnimation } = useDialogTrigger();
|
|
93
|
-
|
|
94
|
-
if (isOpen !== undefined) {
|
|
95
|
-
return (
|
|
96
|
-
<AnimatePresence>
|
|
97
|
-
{isOpen && (
|
|
98
|
-
<InnerModalOverlay
|
|
99
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
100
|
-
{...props}
|
|
101
|
-
animate="visible"
|
|
102
|
-
animation={animation}
|
|
103
|
-
setAnimation={setAnimation}
|
|
104
|
-
/>
|
|
105
|
-
)}
|
|
106
|
-
</AnimatePresence>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<InnerModalOverlay
|
|
112
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
113
|
-
{...props}
|
|
114
|
-
animate={animation}
|
|
115
|
-
animation={animation}
|
|
116
|
-
setAnimation={setAnimation}
|
|
117
|
-
/>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default ModalOverlay;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Key, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
ModalOverlayProps as UiModalOverlayProps,
|
|
4
|
-
ModalRenderProps,
|
|
5
|
-
} from 'react-aria-components';
|
|
6
|
-
import type { MotionStyle, Variant } from 'framer-motion';
|
|
7
|
-
|
|
8
|
-
export interface ModalOverlayProps
|
|
9
|
-
extends Omit<UiModalOverlayProps, 'children' | 'style' | 'onAnimationStart'> {
|
|
10
|
-
key?: Key;
|
|
11
|
-
style?: MotionStyle;
|
|
12
|
-
animationVariants?: { visible: Variant; hidden: Variant };
|
|
13
|
-
children:
|
|
14
|
-
| ReactNode
|
|
15
|
-
| ((
|
|
16
|
-
values: ModalRenderProps & { defaultChildren: ReactNode }
|
|
17
|
-
) => ReactNode);
|
|
18
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { NumberFormatProps } from './NumberFormat.types';
|
|
4
|
-
|
|
5
|
-
export function NumberFormat({
|
|
6
|
-
locale = 'en-US',
|
|
7
|
-
style = 'decimal',
|
|
8
|
-
fallback = '-',
|
|
9
|
-
children,
|
|
10
|
-
...options
|
|
11
|
-
}: NumberFormatProps) {
|
|
12
|
-
return children
|
|
13
|
-
? new Intl.NumberFormat(locale, { ...options, style }).format(
|
|
14
|
-
Number(children)
|
|
15
|
-
)
|
|
16
|
-
: fallback;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default NumberFormat;
|