@jordan-mace/chaser-design-system 1.2.7 → 1.2.8
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/Accordion/Accordion.d.ts +5 -6
- package/dist/components/Accordion/Accordion.js +4 -4
- package/dist/components/Alert/Alert.d.ts +2 -1
- package/dist/components/Avatar/Avatar.d.ts +2 -2
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Badge/Badge.d.ts +3 -2
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +4 -3
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +2 -1
- package/dist/components/Checkbox/Checkbox.d.ts +145 -0
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Collapse/Collapse.d.ts +3 -3
- package/dist/components/Combobox/Combobox.d.ts +3 -2
- package/dist/components/Combobox/Combobox.js +15 -8
- package/dist/components/Container/Container.d.ts +155 -3
- package/dist/components/Divider/Divider.d.ts +3 -2
- package/dist/components/Divider/Divider.js +3 -1
- package/dist/components/Drawer/Drawer.d.ts +4 -2
- package/dist/components/Drawer/Drawer.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +3 -2
- package/dist/components/DropdownMenu/DropdownMenu.js +6 -3
- package/dist/components/EmptyState/EmptyState.d.ts +3 -3
- package/dist/components/EmptyState/EmptyState.js +1 -1
- package/dist/components/FileUpload/FileUpload.d.ts +3 -2
- package/dist/components/FileUpload/FileUpload.js +8 -4
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Grid/Grid.d.ts +154 -5
- package/dist/components/Grid/Grid.js +4 -4
- package/dist/components/Icon/Icon.d.ts +2 -2
- package/dist/components/Input/Input.d.ts +2 -1
- package/dist/components/Kbd/Kbd.d.ts +3 -3
- package/dist/components/List/List.d.ts +3 -2
- package/dist/components/List/List.js +2 -2
- package/dist/components/List/ListItem.d.ts +3 -2
- package/dist/components/List/ListItem.js +2 -2
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/Navbar/Navbar.d.ts +2 -1
- package/dist/components/Navbar/NavbarItem.d.ts +2 -1
- package/dist/components/NumberInput/NumberInput.d.ts +3 -2
- package/dist/components/Pagination/Pagination.d.ts +4 -2
- package/dist/components/Pagination/Pagination.js +6 -3
- package/dist/components/Popover/Popover.d.ts +3 -2
- package/dist/components/Popover/Popover.js +2 -1
- package/dist/components/Progress/Progress.d.ts +3 -2
- package/dist/components/Radio/Radio.d.ts +145 -0
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.d.ts +3 -3
- package/dist/components/Select/Select.d.ts +145 -0
- package/dist/components/Separator/Separator.d.ts +4 -3
- package/dist/components/Separator/Separator.js +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +3 -2
- package/dist/components/Spinner/Spinner.d.ts +3 -2
- package/dist/components/Spinner/Spinner.js +1 -1
- package/dist/components/Stack/Stack.d.ts +156 -5
- package/dist/components/Stepper/Stepper.d.ts +3 -2
- package/dist/components/Table/Table.d.ts +3 -4
- package/dist/components/Table/Table.js +6 -6
- package/dist/components/Tabs/Tabs.d.ts +3 -3
- package/dist/components/Tabs/Tabs.js +2 -2
- package/dist/components/Tag/Tag.d.ts +2 -2
- package/dist/components/Text/Header.d.ts +2 -2
- package/dist/components/Text/P.d.ts +2 -2
- package/dist/components/TextArea/TextArea.d.ts +2 -1
- package/dist/components/Toggle/Toggle.d.ts +3 -2
- package/dist/components/Toggle/Toggle.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +3 -2
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +4 -4
- package/dist/components/VisuallyHidden/VisuallyHidden.js +1 -1
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.tsx +21 -16
- package/src/components/Alert/Alert.tsx +11 -7
- package/src/components/Avatar/Avatar.tsx +16 -14
- package/src/components/Badge/Badge.tsx +8 -6
- package/src/components/Breadcrumb/Breadcrumb.tsx +7 -10
- package/src/components/Button/Button.tsx +9 -11
- package/src/components/Card/Card.tsx +8 -10
- package/src/components/Checkbox/Checkbox.tsx +11 -8
- package/src/components/Collapse/Collapse.tsx +12 -9
- package/src/components/Combobox/Combobox.tsx +60 -31
- package/src/components/Container/Container.tsx +4 -3
- package/src/components/Divider/Divider.tsx +9 -5
- package/src/components/Drawer/Drawer.tsx +20 -13
- package/src/components/DropdownMenu/DropdownMenu.tsx +37 -15
- package/src/components/EmptyState/EmptyState.tsx +9 -12
- package/src/components/FileUpload/FileUpload.tsx +61 -45
- package/src/components/Form/Form.tsx +6 -8
- package/src/components/Grid/Grid.tsx +18 -13
- package/src/components/Icon/Icon.tsx +7 -6
- package/src/components/Input/Input.tsx +7 -8
- package/src/components/Kbd/Kbd.tsx +5 -4
- package/src/components/List/List.tsx +6 -2
- package/src/components/List/ListItem.tsx +6 -2
- package/src/components/Modal/Modal.tsx +16 -5
- package/src/components/Navbar/Navbar.tsx +2 -1
- package/src/components/Navbar/NavbarItem.tsx +2 -1
- package/src/components/NumberInput/NumberInput.tsx +29 -22
- package/src/components/Pagination/Pagination.tsx +39 -28
- package/src/components/Popover/Popover.tsx +37 -21
- package/src/components/Progress/Progress.tsx +39 -38
- package/src/components/Radio/Radio.tsx +12 -6
- package/src/components/ScrollArea/ScrollArea.tsx +9 -10
- package/src/components/Select/Select.tsx +12 -7
- package/src/components/Separator/Separator.tsx +8 -14
- package/src/components/Skeleton/Skeleton.tsx +11 -13
- package/src/components/Spinner/Spinner.tsx +15 -11
- package/src/components/Stack/Stack.tsx +34 -15
- package/src/components/Stepper/Stepper.tsx +19 -17
- package/src/components/Table/Table.tsx +31 -21
- package/src/components/Tabs/Tabs.tsx +14 -10
- package/src/components/Tag/Tag.tsx +8 -7
- package/src/components/Text/Header.tsx +6 -5
- package/src/components/Text/P.tsx +5 -4
- package/src/components/TextArea/TextArea.tsx +7 -8
- package/src/components/Toggle/Toggle.tsx +16 -7
- package/src/components/Tooltip/Tooltip.tsx +16 -11
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +7 -8
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
3
|
+
export type TextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & Sprinkles & {
|
|
3
4
|
label?: string;
|
|
4
5
|
fullWidth?: boolean;
|
|
5
6
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
2
3
|
export type ToggleSize = 'small' | 'medium' | 'large';
|
|
3
|
-
export
|
|
4
|
+
export type ToggleProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'checked' | 'onChange'> & Sprinkles & {
|
|
4
5
|
checked?: boolean;
|
|
5
6
|
onChange?: (checked: boolean) => void;
|
|
6
7
|
size?: ToggleSize;
|
|
7
8
|
label?: string;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
9
10
|
declare const Toggle: ({ checked, onChange, size, label, disabled, id, ...props }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default Toggle;
|
|
@@ -12,6 +12,6 @@ const Toggle = ({ checked = false, onChange, size = 'medium', label, disabled =
|
|
|
12
12
|
onChange(e.target.checked);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
return (_jsxs(Box, { as: "div", className: toggle, children: [_jsxs(Box, { as: "label", htmlFor: toggleId, className: toggleLabel, children: [_jsx(Box, { as: "input", type: "checkbox", id: toggleId, checked: checked, onChange: handleChange, disabled: disabled, className: toggleInput, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-checked": checked, role: "switch", ...props }), _jsx(Box, { as: "span", className: clsx(toggleTrack, toggleSizes[size], checked ? toggleTrackChecked : toggleTrackUnchecked), "data-size": size, children: _jsx(Box, { as: "span", className: clsx(toggleThumb, toggleThumbSizes[size], checked ? toggleThumbChecked : toggleThumbUnchecked) }) }), _jsx(Box, { as: "span", className: toggleFocusRing, "data-focused": isFocused, "aria-hidden": "true" })] }), label && _jsx(Box, { as: "span", marginLeft: "small", children: label })] }));
|
|
15
|
+
return (_jsxs(Box, { as: "div", className: toggle, children: [_jsxs(Box, { as: "label", htmlFor: toggleId, className: toggleLabel, children: [_jsx(Box, { as: "input", type: "checkbox", id: toggleId, checked: checked, onChange: handleChange, disabled: disabled, className: toggleInput, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-checked": checked, role: "switch", ...props }), _jsx(Box, { as: "span", className: clsx(toggleTrack, toggleSizes[size], checked ? toggleTrackChecked : toggleTrackUnchecked), "data-size": size, children: _jsx(Box, { as: "span", className: clsx(toggleThumb, toggleThumbSizes[size], checked ? toggleThumbChecked : toggleThumbUnchecked) }) }), _jsx(Box, { as: "span", className: toggleFocusRing, "data-focused": isFocused, "aria-hidden": "true" })] }), label && (_jsx(Box, { as: "span", marginLeft: "small", children: label }))] }));
|
|
16
16
|
};
|
|
17
17
|
export default Toggle;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
2
3
|
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
-
export
|
|
4
|
+
export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & Sprinkles & {
|
|
4
5
|
content: string;
|
|
5
6
|
position?: TooltipPosition;
|
|
6
7
|
showArrow?: boolean;
|
|
7
8
|
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
9
10
|
declare const Tooltip: ({ content, position, showArrow, children, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default Tooltip;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
3
|
+
export type VisuallyHiddenProps = Sprinkles & {
|
|
3
4
|
children: React.ReactNode;
|
|
4
5
|
as?: React.ElementType;
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
declare const VisuallyHidden: ({ children, as: Component, className, ...props }: VisuallyHiddenProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
6
|
+
};
|
|
7
|
+
declare const VisuallyHidden: ({ children, as: Component, ...props }: VisuallyHiddenProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
8
8
|
export default VisuallyHidden;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { visuallyHidden } from './styles.css';
|
|
3
|
-
const VisuallyHidden = ({ children, as: Component = 'span',
|
|
3
|
+
const VisuallyHidden = ({ children, as: Component = 'span', ...props }) => {
|
|
4
4
|
return React.createElement(Component, {
|
|
5
5
|
className: visuallyHidden,
|
|
6
6
|
...props,
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
accordionGroup,
|
|
10
10
|
} from './styles.css';
|
|
11
11
|
import Box from '../Box';
|
|
12
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
12
13
|
|
|
13
14
|
type AccordionContextType = {
|
|
14
15
|
allowMultiple?: boolean;
|
|
@@ -22,16 +23,16 @@ const AccordionContext = createContext<AccordionContextType>({
|
|
|
22
23
|
toggleItem: () => {},
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
type AccordionProps =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
26
|
+
type AccordionProps = React.HTMLAttributes<HTMLDivElement> &
|
|
27
|
+
Sprinkles & {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
allowMultiple?: boolean;
|
|
30
|
+
};
|
|
30
31
|
|
|
31
32
|
const Accordion = ({
|
|
32
33
|
children,
|
|
33
34
|
allowMultiple = false,
|
|
34
|
-
|
|
35
|
+
...props
|
|
35
36
|
}: AccordionProps) => {
|
|
36
37
|
const [expandedItems, setExpandedItems] = useState<Set<string>>(new Set());
|
|
37
38
|
|
|
@@ -52,10 +53,13 @@ const Accordion = ({
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
return (
|
|
55
|
-
<AccordionContext.Provider
|
|
56
|
+
<AccordionContext.Provider
|
|
57
|
+
value={{ allowMultiple, expandedItems, toggleItem }}
|
|
58
|
+
>
|
|
56
59
|
<Box
|
|
57
|
-
className={clsx(accordionGroup, className)}
|
|
60
|
+
className={clsx(accordionGroup, props.className)}
|
|
58
61
|
width="100%"
|
|
62
|
+
{...props}
|
|
59
63
|
>
|
|
60
64
|
{children}
|
|
61
65
|
</Box>
|
|
@@ -63,18 +67,18 @@ const Accordion = ({
|
|
|
63
67
|
);
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
type AccordionItemProps =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
70
|
+
type AccordionItemProps = React.HTMLAttributes<HTMLDivElement> &
|
|
71
|
+
Sprinkles & {
|
|
72
|
+
value: string;
|
|
73
|
+
title: string;
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
};
|
|
72
76
|
|
|
73
77
|
const AccordionItem = ({
|
|
74
78
|
value,
|
|
75
79
|
title,
|
|
76
80
|
children,
|
|
77
|
-
|
|
81
|
+
...props
|
|
78
82
|
}: AccordionItemProps) => {
|
|
79
83
|
const { expandedItems, toggleItem } = useContext(AccordionContext);
|
|
80
84
|
const isExpanded = expandedItems.has(value);
|
|
@@ -86,12 +90,13 @@ const AccordionItem = ({
|
|
|
86
90
|
return (
|
|
87
91
|
<Box
|
|
88
92
|
as="div"
|
|
89
|
-
className={clsx(accordionItem, className)}
|
|
93
|
+
className={clsx(accordionItem, props.className)}
|
|
90
94
|
width="100%"
|
|
91
95
|
marginBottom="small"
|
|
92
96
|
border="small"
|
|
93
97
|
borderRadius="large"
|
|
94
98
|
overflow="hidden"
|
|
99
|
+
{...props}
|
|
95
100
|
>
|
|
96
101
|
<Box
|
|
97
102
|
as="button"
|
|
@@ -7,13 +7,15 @@ import {
|
|
|
7
7
|
} from './styles.css';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import Box from '../Box';
|
|
10
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
10
11
|
|
|
11
|
-
type AlertProps = React.HTMLAttributes<HTMLDivElement> &
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type AlertProps = React.HTMLAttributes<HTMLDivElement> &
|
|
13
|
+
Sprinkles & {
|
|
14
|
+
severity?: 'success' | 'warning' | 'error' | 'info';
|
|
15
|
+
dismissible?: boolean;
|
|
16
|
+
onDismiss?: () => void;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
const Alert = ({
|
|
19
21
|
severity = 'info',
|
|
@@ -29,7 +31,9 @@ const Alert = ({
|
|
|
29
31
|
className={clsx(alert, alertVariants[severity], props.className)}
|
|
30
32
|
{...props}
|
|
31
33
|
>
|
|
32
|
-
<Box as="div" className={alertContent}>
|
|
34
|
+
<Box as="div" className={alertContent}>
|
|
35
|
+
{children}
|
|
36
|
+
</Box>
|
|
33
37
|
{dismissible && onDismiss && (
|
|
34
38
|
<Box
|
|
35
39
|
as="button"
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
avatar,
|
|
5
|
+
avatarImage,
|
|
6
|
+
avatarWithImage,
|
|
7
|
+
avatarWrapper,
|
|
8
|
+
} from './styles.css';
|
|
4
9
|
import Box from '../Box';
|
|
10
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
5
11
|
|
|
6
|
-
type AvatarProps =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
type AvatarProps = React.HTMLAttributes<HTMLDivElement> &
|
|
13
|
+
Sprinkles & {
|
|
14
|
+
alt?: string;
|
|
15
|
+
src?: string;
|
|
16
|
+
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
fallback?: string;
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
const Avatar = ({
|
|
16
22
|
alt,
|
|
@@ -38,11 +44,7 @@ const Avatar = ({
|
|
|
38
44
|
const initials = children || fallback;
|
|
39
45
|
|
|
40
46
|
return (
|
|
41
|
-
<Box
|
|
42
|
-
className={clsx(sizeClass, className)}
|
|
43
|
-
role="img"
|
|
44
|
-
aria-label={alt}
|
|
45
|
-
>
|
|
47
|
+
<Box className={clsx(sizeClass, className)} role="img" aria-label={alt}>
|
|
46
48
|
{initials}
|
|
47
49
|
</Box>
|
|
48
50
|
);
|
|
@@ -8,16 +8,18 @@ import {
|
|
|
8
8
|
} from './styles.css';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import Box from '../Box';
|
|
11
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
11
12
|
|
|
12
13
|
export type BadgeVariant = 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
13
14
|
export type BadgeSize = 'small' | 'medium' | 'large';
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
17
|
+
Sprinkles & {
|
|
18
|
+
variant?: BadgeVariant;
|
|
19
|
+
size?: BadgeSize;
|
|
20
|
+
dot?: boolean;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
};
|
|
21
23
|
|
|
22
24
|
const Badge = ({
|
|
23
25
|
variant = 'default',
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
breadcrumbCurrent,
|
|
10
10
|
} from './styles.css';
|
|
11
11
|
import Box from '../Box';
|
|
12
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
12
13
|
|
|
13
14
|
type BreadcrumbItem = {
|
|
14
15
|
label: string;
|
|
@@ -16,17 +17,13 @@ type BreadcrumbItem = {
|
|
|
16
17
|
current?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
type BreadcrumbProps =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
20
|
+
type BreadcrumbProps = React.HTMLAttributes<HTMLDivElement> &
|
|
21
|
+
Sprinkles & {
|
|
22
|
+
items: BreadcrumbItem[];
|
|
23
|
+
separator?: string;
|
|
24
|
+
};
|
|
24
25
|
|
|
25
|
-
const Breadcrumb = ({
|
|
26
|
-
items,
|
|
27
|
-
className,
|
|
28
|
-
separator = '/',
|
|
29
|
-
}: BreadcrumbProps) => {
|
|
26
|
+
const Breadcrumb = ({ items, className, separator = '/' }: BreadcrumbProps) => {
|
|
30
27
|
return (
|
|
31
28
|
<Box
|
|
32
29
|
as="nav"
|
|
@@ -2,13 +2,15 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { button, buttonVariants } from './styles.css';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Box from '../Box';
|
|
5
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
5
6
|
|
|
6
|
-
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
8
|
+
Sprinkles & {
|
|
9
|
+
variant: 'primary' | 'secondary';
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
label?: string;
|
|
12
|
+
fullWidth?: boolean;
|
|
13
|
+
};
|
|
12
14
|
|
|
13
15
|
const Button = ({ label, ...props }: ButtonProps) => {
|
|
14
16
|
return (
|
|
@@ -16,11 +18,7 @@ const Button = ({ label, ...props }: ButtonProps) => {
|
|
|
16
18
|
as="button"
|
|
17
19
|
borderRadius="large"
|
|
18
20
|
width={props.fullWidth ? '100%' : undefined}
|
|
19
|
-
className={clsx(
|
|
20
|
-
buttonVariants[props.variant],
|
|
21
|
-
button,
|
|
22
|
-
props.className,
|
|
23
|
-
)}
|
|
21
|
+
className={clsx(buttonVariants[props.variant], button, props.className)}
|
|
24
22
|
{...props}
|
|
25
23
|
>
|
|
26
24
|
{props.children || label}
|
|
@@ -2,12 +2,14 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { card, cardVariants } from './styles.css';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Box from '../Box';
|
|
5
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
5
6
|
|
|
6
|
-
type CardProps = React.HTMLAttributes<HTMLDivElement> &
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
type CardProps = React.HTMLAttributes<HTMLDivElement> &
|
|
8
|
+
Sprinkles & {
|
|
9
|
+
variant?: 'elevated' | 'outlined' | 'filled';
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
padding?: 'none' | 'small' | 'medium' | 'large';
|
|
12
|
+
};
|
|
11
13
|
|
|
12
14
|
const Card = ({
|
|
13
15
|
variant = 'elevated',
|
|
@@ -19,11 +21,7 @@ const Card = ({
|
|
|
19
21
|
as="div"
|
|
20
22
|
borderRadius="large"
|
|
21
23
|
padding={padding !== 'none' ? padding : undefined}
|
|
22
|
-
className={clsx(
|
|
23
|
-
cardVariants[variant],
|
|
24
|
-
card,
|
|
25
|
-
props.className,
|
|
26
|
-
)}
|
|
24
|
+
className={clsx(cardVariants[variant], card, props.className)}
|
|
27
25
|
{...props}
|
|
28
26
|
>
|
|
29
27
|
{props.children}
|
|
@@ -2,14 +2,13 @@ import clsx from 'clsx';
|
|
|
2
2
|
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
3
3
|
import { checkboxContainer, checkboxInput, checkboxLabel } from './styles.css';
|
|
4
4
|
import Box from '../Box';
|
|
5
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
5
6
|
|
|
6
|
-
type CheckboxProps = Omit<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
indeterminate?: boolean;
|
|
12
|
-
};
|
|
7
|
+
type CheckboxProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> &
|
|
8
|
+
Sprinkles & {
|
|
9
|
+
label?: string;
|
|
10
|
+
indeterminate?: boolean;
|
|
11
|
+
};
|
|
13
12
|
|
|
14
13
|
const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
15
14
|
({ label, className, indeterminate, ...props }, ref) => {
|
|
@@ -47,7 +46,11 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
|
47
46
|
style={{ width: '18px', height: '18px' }}
|
|
48
47
|
{...props}
|
|
49
48
|
/>
|
|
50
|
-
{label &&
|
|
49
|
+
{label && (
|
|
50
|
+
<Box as="span" className={checkboxLabel}>
|
|
51
|
+
{label}
|
|
52
|
+
</Box>
|
|
53
|
+
)}
|
|
51
54
|
</Box>
|
|
52
55
|
);
|
|
53
56
|
},
|
|
@@ -6,17 +6,18 @@ import {
|
|
|
6
6
|
collapseAnimation,
|
|
7
7
|
} from './styles.css';
|
|
8
8
|
import Box from '../Box';
|
|
9
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
9
10
|
|
|
10
11
|
export type CollapseAnimation = 'height' | 'opacity' | 'both';
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
13
|
+
export type CollapseProps = React.HTMLAttributes<HTMLDivElement> &
|
|
14
|
+
Sprinkles & {
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
animation?: CollapseAnimation;
|
|
18
|
+
duration?: number;
|
|
19
|
+
onAnimationEnd?: () => void;
|
|
20
|
+
};
|
|
20
21
|
|
|
21
22
|
const Collapse = ({
|
|
22
23
|
isOpen,
|
|
@@ -26,7 +27,9 @@ const Collapse = ({
|
|
|
26
27
|
className,
|
|
27
28
|
onAnimationEnd,
|
|
28
29
|
}: CollapseProps) => {
|
|
29
|
-
const [height, setHeight] = useState<number | undefined>(
|
|
30
|
+
const [height, setHeight] = useState<number | undefined>(
|
|
31
|
+
isOpen ? undefined : 0,
|
|
32
|
+
);
|
|
30
33
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
31
34
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
32
35
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
comboboxErrorMessage,
|
|
17
17
|
} from './styles.css';
|
|
18
18
|
import Box from '../Box';
|
|
19
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
19
20
|
|
|
20
21
|
export interface ComboboxOption {
|
|
21
22
|
value: string;
|
|
@@ -23,23 +24,30 @@ export interface ComboboxOption {
|
|
|
23
24
|
disabled?: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
export type ComboboxProps = Omit<
|
|
28
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
29
|
+
'onChange' | 'value'
|
|
30
|
+
> &
|
|
31
|
+
Sprinkles & {
|
|
32
|
+
label?: string;
|
|
33
|
+
options: ComboboxOption[];
|
|
34
|
+
value?: string;
|
|
35
|
+
onChange?: (value: string, option: ComboboxOption | null) => void;
|
|
36
|
+
onInputChange?: (inputValue: string) => void;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
hint?: string;
|
|
39
|
+
error?: boolean;
|
|
40
|
+
errorMessage?: string;
|
|
41
|
+
fullWidth?: boolean;
|
|
42
|
+
clearable?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
filterFn?: (option: ComboboxOption, inputValue: string) => boolean;
|
|
45
|
+
};
|
|
41
46
|
|
|
42
|
-
const defaultFilterFn = (
|
|
47
|
+
const defaultFilterFn = (
|
|
48
|
+
option: ComboboxOption,
|
|
49
|
+
inputValue: string,
|
|
50
|
+
): boolean => {
|
|
43
51
|
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
44
52
|
};
|
|
45
53
|
|
|
@@ -66,7 +74,7 @@ const Combobox = ({
|
|
|
66
74
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
67
75
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
68
76
|
|
|
69
|
-
const selectedOption = options.find(opt => opt.value === value);
|
|
77
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
70
78
|
|
|
71
79
|
useEffect(() => {
|
|
72
80
|
if (selectedOption) {
|
|
@@ -76,11 +84,16 @@ const Combobox = ({
|
|
|
76
84
|
}
|
|
77
85
|
}, [selectedOption, isOpen]);
|
|
78
86
|
|
|
79
|
-
const filteredOptions = options.filter(option =>
|
|
87
|
+
const filteredOptions = options.filter((option) =>
|
|
88
|
+
filterFn(option, inputValue),
|
|
89
|
+
);
|
|
80
90
|
|
|
81
91
|
useEffect(() => {
|
|
82
92
|
const handleClickOutside = (event: MouseEvent) => {
|
|
83
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
containerRef.current &&
|
|
95
|
+
!containerRef.current.contains(event.target as Node)
|
|
96
|
+
) {
|
|
84
97
|
setIsOpen(false);
|
|
85
98
|
if (selectedOption) {
|
|
86
99
|
setInputValue(selectedOption.label);
|
|
@@ -108,7 +121,7 @@ const Combobox = ({
|
|
|
108
121
|
|
|
109
122
|
const handleOptionClick = (option: ComboboxOption) => {
|
|
110
123
|
if (option.disabled) return;
|
|
111
|
-
|
|
124
|
+
|
|
112
125
|
setInputValue(option.label);
|
|
113
126
|
setIsOpen(false);
|
|
114
127
|
onChange?.(option.value, option);
|
|
@@ -131,17 +144,21 @@ const Combobox = ({
|
|
|
131
144
|
if (!isOpen) {
|
|
132
145
|
setIsOpen(true);
|
|
133
146
|
}
|
|
134
|
-
setHighlightedIndex(prev =>
|
|
135
|
-
prev < filteredOptions.length - 1 ? prev + 1 : prev
|
|
147
|
+
setHighlightedIndex((prev) =>
|
|
148
|
+
prev < filteredOptions.length - 1 ? prev + 1 : prev,
|
|
136
149
|
);
|
|
137
150
|
break;
|
|
138
151
|
case 'ArrowUp':
|
|
139
152
|
e.preventDefault();
|
|
140
|
-
setHighlightedIndex(prev => (prev > 0 ? prev - 1 : prev));
|
|
153
|
+
setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : prev));
|
|
141
154
|
break;
|
|
142
155
|
case 'Enter':
|
|
143
156
|
e.preventDefault();
|
|
144
|
-
if (
|
|
157
|
+
if (
|
|
158
|
+
isOpen &&
|
|
159
|
+
highlightedIndex >= 0 &&
|
|
160
|
+
filteredOptions[highlightedIndex]
|
|
161
|
+
) {
|
|
145
162
|
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
146
163
|
} else {
|
|
147
164
|
setIsOpen(!isOpen);
|
|
@@ -158,16 +175,21 @@ const Combobox = ({
|
|
|
158
175
|
}
|
|
159
176
|
};
|
|
160
177
|
|
|
161
|
-
const displayValue =
|
|
178
|
+
const displayValue =
|
|
179
|
+
selectedOption && !isOpen ? selectedOption.label : inputValue;
|
|
162
180
|
|
|
163
181
|
return (
|
|
164
|
-
<Box
|
|
182
|
+
<Box
|
|
183
|
+
className={comboboxContainer}
|
|
184
|
+
ref={containerRef}
|
|
185
|
+
width={fullWidth ? '100%' : undefined}
|
|
186
|
+
>
|
|
165
187
|
{label && (
|
|
166
188
|
<Box as="label" className={comboboxLabel}>
|
|
167
189
|
{label}
|
|
168
190
|
</Box>
|
|
169
191
|
)}
|
|
170
|
-
|
|
192
|
+
|
|
171
193
|
<Box position="relative">
|
|
172
194
|
<Box
|
|
173
195
|
as="input"
|
|
@@ -188,10 +210,14 @@ const Combobox = ({
|
|
|
188
210
|
aria-expanded={isOpen}
|
|
189
211
|
aria-autocomplete="list"
|
|
190
212
|
aria-controls={isOpen ? 'combobox-listbox' : undefined}
|
|
191
|
-
aria-activedescendant={
|
|
213
|
+
aria-activedescendant={
|
|
214
|
+
highlightedIndex >= 0
|
|
215
|
+
? `option-${filteredOptions[highlightedIndex]?.value}`
|
|
216
|
+
: undefined
|
|
217
|
+
}
|
|
192
218
|
{...props}
|
|
193
219
|
/>
|
|
194
|
-
|
|
220
|
+
|
|
195
221
|
{clearable && inputValue && !disabled && (
|
|
196
222
|
<Box
|
|
197
223
|
as="button"
|
|
@@ -203,7 +229,7 @@ const Combobox = ({
|
|
|
203
229
|
×
|
|
204
230
|
</Box>
|
|
205
231
|
)}
|
|
206
|
-
|
|
232
|
+
|
|
207
233
|
<Box className={comboboxArrow} aria-hidden="true">
|
|
208
234
|
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
|
209
235
|
<path d="M6 8L1 3h10z" />
|
|
@@ -238,7 +264,10 @@ const Combobox = ({
|
|
|
238
264
|
aria-selected={option.value === value}
|
|
239
265
|
aria-disabled={option.disabled}
|
|
240
266
|
style={{
|
|
241
|
-
backgroundColor:
|
|
267
|
+
backgroundColor:
|
|
268
|
+
index === highlightedIndex
|
|
269
|
+
? 'var(--highlight-color, #f3f4f6)'
|
|
270
|
+
: undefined,
|
|
242
271
|
}}
|
|
243
272
|
>
|
|
244
273
|
{option.label}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import Box from '../Box';
|
|
3
|
+
import { Sprinkles } from '../../styles/sprinkles.css';
|
|
3
4
|
|
|
4
5
|
export type ContainerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export type ContainerProps = Sprinkles & {
|
|
7
8
|
size?: ContainerSize;
|
|
8
9
|
centerContent?: boolean;
|
|
9
10
|
children?: React.ReactNode;
|
|
10
11
|
className?: string;
|
|
11
12
|
style?: React.CSSProperties;
|
|
12
|
-
}
|
|
13
|
+
};
|
|
13
14
|
|
|
14
15
|
const sizeMap: Record<ContainerSize, string> = {
|
|
15
16
|
sm: '640px',
|
|
@@ -39,7 +40,7 @@ const Container = forwardRef<HTMLElement, ContainerProps>(
|
|
|
39
40
|
{children}
|
|
40
41
|
</Box>
|
|
41
42
|
);
|
|
42
|
-
}
|
|
43
|
+
},
|
|
43
44
|
);
|
|
44
45
|
|
|
45
46
|
Container.displayName = 'Container';
|