Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ enableHardenedMode: false
enableScripts: false

nodeLinker: node-modules

packageExtensions:
"eslint-plugin-jsx-a11y@*":
peerDependencies:
eslint: "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 || ^10"
4 changes: 3 additions & 1 deletion components/AriaTable/AriaTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const Tr = forwardRef<ElementRef<typeof StyledTr>, AriaTrProps>(
const [isCollapsed, setIsCollapsed] = useState(false);

if (!asChild) {
// eslint-disable-next-line @eslint-react/no-children-to-array
const arrayChildren = Children.toArray(children);
const hasColSpanChildren = arrayChildren.some((child) => {
if (!isValidElement(child)) {
Expand Down Expand Up @@ -154,12 +155,13 @@ export const Tr = forwardRef<ElementRef<typeof StyledTr>, AriaTrProps>(
</Box>
</Td>
) : null,
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line @eslint-react/exhaustive-deps
[isCollapsed],
);

const renderedChildren = useMemo(() => {
if (asChild) {
// eslint-disable-next-line @eslint-react/no-clone-element
return cloneElement(
children as any,
{
Expand Down
2 changes: 1 addition & 1 deletion components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Interactive: StoryFn<typeof BadgeForStory> = (args) => (
<Flex css={{ gap: '$3' }}>
<Badge {...args}>Default</Badge>
{COLORS.map((color) => (
<Badge {...args} variant={color}>
<Badge key={color} {...args} variant={color}>
{color}
</Badge>
))}
Expand Down
2 changes: 1 addition & 1 deletion components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const Badge = React.forwardRef<React.ElementRef<typeof StyledButtonBadge>
return asChild ? StyledButtonBadgeSlot : StyledButtonBadge;
}
return asChild ? StyledSpanBadgeSlot : StyledSpanBadge;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line @eslint-react/exhaustive-deps
}, [asChild]);

return <Component {...props} ref={forwardedRef} />;
Expand Down
4 changes: 2 additions & 2 deletions components/DateTimePicker/DateTimePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Component: Meta<typeof DateTimePickerForStory> = {
};

const DateTimePickerTemplate: StoryFn<typeof DateTimePickerForStory> = (args) => {
const [selectedDates, onDatesChange] = useState<Date[]>([]);
const [selectedDates, setSelectedDates] = useState<Date[]>([]);
const [minDate] = useState(() => new Date(args.minDate || Date.now()));

return (
Expand All @@ -53,7 +53,7 @@ const DateTimePickerTemplate: StoryFn<typeof DateTimePickerForStory> = (args) =>
minDate,
}}
calendar={{ mode: args.calendarMode, startDay: 1 }}
onDatesChange={onDatesChange}
onDatesChange={setSelectedDates}
selectedDates={selectedDates}
/>
<Flex direction="column" css={{ gap: '2px' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ const Component: Meta<typeof DateTimePickerInputForStory> = {
};

const DateTimePickerTemplate: StoryFn<typeof DateTimePickerInputForStory> = (args) => {
const [selectedDates, onDatesChange] = useState<Date[]>([]);
const [selectedDates, setSelectedDates] = useState<Date[]>([]);
const [minDate] = useState(() => new Date());

return (
<form>
<Flex direction="column" gap={3}>
<DateTimePickerInputForStory
{...args}
calendar={{ startDay: 1 }}
dates={{ minDate: new Date() }}
dates={{ minDate }}
inputCSS={{ width: '100%' }}
onChange={onDatesChange}
onChange={setSelectedDates}
/>
<Flex direction="column" css={{ gap: '2px' }}>
<Label htmlFor="selected-dates">Selected date:</Label>
Expand Down
6 changes: 3 additions & 3 deletions components/DateTimePickerInput/DateTimePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const DateTimePickerInput = React.forwardRef<
const arrowRef = useRef(null);

const [inputValue, setInputValue] = useState<string>('');
const [selectedDates, onDatesChange] = useState<Date[]>([]);
const [selectedDates, setSelectedDates] = useState<Date[]>([]);
const [isPickerOpen, setIsPickerOpen] = useState(false);

const middleware = useMemo(
Expand Down Expand Up @@ -159,7 +159,7 @@ export const DateTimePickerInput = React.forwardRef<
const newDates = (value as string)
.split(',')
.map((d) => parse(d.trim(), formatStr, new Date()));
onDatesChange(newDates);
setSelectedDates(newDates);
if (onChange) onChange(newDates);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
Expand All @@ -183,7 +183,7 @@ export const DateTimePickerInput = React.forwardRef<
{...pickerProps}
css={pickerCSS}
onDatesChange={(d) => {
onDatesChange(d);
setSelectedDates(d);
setInputValue(d.map((date) => format(date, formatStr)).join(', '));
if (onChange) onChange(d);
}}
Expand Down
3 changes: 3 additions & 0 deletions components/Heading/Heading.vanilla.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function createHeadingComponent<C extends ElementType>(
type HeadingComponent = PolymorphicComponent<C, HeadingProps<ElementType>>;

const HeadingImpl = forwardRef(
// Safe: factory is called once at module load (e.g. `export const H1 = createHeading(...)`),
// not inside a render, so HeadingImpl gets a stable reference; no remount on re-render.
// eslint-disable-next-line @eslint-react/component-hook-factories
<E extends ElementType = C>(
{ as, className, css, style, transform, ...props }: HeadingProps<E>,
ref?: PolymorphicRef<E>,
Expand Down
7 changes: 4 additions & 3 deletions components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ export const Ul = React.forwardRef<React.ElementRef<typeof StyledUl>, ListProps>
);

export interface OrderedListProps
extends ComponentProps<typeof StyledOl>,
VariantProps<typeof StyledOl> {
extends ComponentProps<typeof StyledOl>, VariantProps<typeof StyledOl> {
interactive?: boolean;
}

Expand Down Expand Up @@ -187,7 +186,8 @@ const ControlsWrapper = styled('div', {
});

export interface ListItemProps
extends ComponentProps<typeof StyledLi>,
extends
ComponentProps<typeof StyledLi>,
VariantProps<typeof StyledLi>,
VariantProps<typeof Flex> {
controls?: ReactNode;
Expand All @@ -196,6 +196,7 @@ export const Li = React.forwardRef<React.ElementRef<typeof StyledLi>, ListItemPr
({ children, controls, align, justify, direction, gap, wrap, ...props }, forwardedRef) => {
const { interactive } = useContext(ListContext);

// eslint-disable-next-line @eslint-react/no-children-to-array
const childArray = React.Children.toArray(children);
const nestedLists = childArray.filter(
(child) => React.isValidElement(child) && (child.type === Ul || child.type === Ol),
Expand Down
15 changes: 6 additions & 9 deletions components/NavigationTree/NavigationTreeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';

import { CSS } from '../../stitches.config';
import { NavigationContainer, NavigationContainerProps } from '../Navigation';
import { NavigationTreeContext } from './NavigationTreeContext';

export interface NavigationTreeProps {
children: React.ReactNode;
Expand All @@ -19,13 +20,9 @@ export const NavigationTreeContainer = ({
fullWidth = false,
...props
}: NavigationTreeProps & NavigationContainerProps) => {
const renderChildren = React.Children.map(children, (child) => {
return React.cloneElement(child as React.ReactElement, {
defaultCollapseIcon,
defaultExpandIcon,
fullWidth,
});
});

return <NavigationContainer {...props}>{renderChildren}</NavigationContainer>;
return (
<NavigationTreeContext.Provider value={{ defaultCollapseIcon, defaultExpandIcon, fullWidth }}>
<NavigationContainer {...props}>{children}</NavigationContainer>
</NavigationTreeContext.Provider>
);
};
16 changes: 16 additions & 0 deletions components/NavigationTree/NavigationTreeContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ChevronDownIcon, ChevronRightIcon } from '@radix-ui/react-icons';
import React from 'react';

interface NavigationTreeContextValue {
defaultExpandIcon: React.ReactNode;
defaultCollapseIcon: React.ReactNode;
fullWidth: boolean;
}

export const NavigationTreeContext = React.createContext<NavigationTreeContextValue>({
defaultExpandIcon: <ChevronRightIcon />,
defaultCollapseIcon: <ChevronDownIcon />,
fullWidth: false,
});

export const useNavigationTree = () => React.useContext(NavigationTreeContext);
15 changes: 7 additions & 8 deletions components/NavigationTree/NavigationTreeDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

import { CSS } from '../../stitches.config';
import { NavigationDrawer, NavigationDrawerProps } from '../Navigation';
import { NavigationTreeContext, useNavigationTree } from './NavigationTreeContext';

export interface NavigationTreeDrawerProps {
children: React.ReactNode;
Expand All @@ -14,15 +15,13 @@ export const NavigationTreeDrawer = ({
fullWidth = false,
...props
}: NavigationTreeDrawerProps & NavigationDrawerProps) => {
const renderChildren = React.Children.map(children, (child) => {
return React.cloneElement(child as React.ReactElement, {
fullWidth,
});
});
const parentCtx = useNavigationTree();

return (
<NavigationDrawer fullWidth={fullWidth} {...props}>
{renderChildren}
</NavigationDrawer>
<NavigationTreeContext.Provider value={{ ...parentCtx, fullWidth }}>
<NavigationDrawer fullWidth={fullWidth} {...props}>
{children}
</NavigationDrawer>
</NavigationTreeContext.Provider>
);
};
12 changes: 4 additions & 8 deletions components/NavigationTree/NavigationTreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ import { Flex } from '../Flex';
import { NavigationItem, NavigationItemProps } from '../Navigation';
import { Text } from '../Text';
import { NavigationTreeContainer } from './NavigationTreeContainer';
import { useNavigationTree } from './NavigationTreeContext';

export interface NavigationTreeItemProps {
label: string | ReactNode;
subtitle?: string;
children?: React.ReactNode;
defaultExpanded?: boolean;
onClick?: () => void;
defaultExpandIcon?: React.ReactNode;
defaultCollapseIcon?: React.ReactNode;
customExpandIcon?: React.ReactNode;
customCollapseIcon?: React.ReactNode;
nestedChildrenLevel?: number;
fullWidth?: boolean;
}

export const NavigationTreeItem = ({
Expand All @@ -27,16 +25,14 @@ export const NavigationTreeItem = ({
children,
onClick,
defaultExpanded = false,
defaultCollapseIcon,
defaultExpandIcon,
customCollapseIcon,
customExpandIcon,
nestedChildrenLevel = 1,
fullWidth = false,
...props
}: NavigationTreeItemProps & NavigationItemProps) => {
const { defaultCollapseIcon, defaultExpandIcon, fullWidth } = useNavigationTree();
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
const isExpandable = useMemo(() => React.Children.count(children) > 0, [children]);
const isExpandable = useMemo(() => !!children, [children]);
const hasStartAdornment = useMemo(() => !!props.startAdornment, [props.startAdornment]);
const usedStartAdornment = useMemo(
() =>
Expand Down Expand Up @@ -70,7 +66,7 @@ export const NavigationTreeItem = ({
},
},
};
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line @eslint-react/exhaustive-deps
}, [isExpandable, nestedChildrenLevel]);

const focusStyle = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions components/SidePanel/SidePanel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ Basic.args = {

export const CombinedWithModal: StoryFn<typeof SidePanel> = (args) => {
const [open, setOpen] = useState(false);
const [isModalOpen, setModalOpen] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);

return (
<>
<Dialog open={isModalOpen} onOpenChange={(isModalOpen) => setModalOpen(isModalOpen)}>
<Dialog open={isModalOpen} onOpenChange={(isModalOpen) => setIsModalOpen(isModalOpen)}>
<DialogPortal>
<DialogOverlay />
<DialogContent>
Expand All @@ -102,7 +102,7 @@ export const CombinedWithModal: StoryFn<typeof SidePanel> = (args) => {
</Dialog>

<SidePanel {...args} open={open} onOpenChange={(isOpen) => setOpen(isOpen)}>
<Content ctaLabel="Open modal" onClickBtn={() => setModalOpen(true)} />
<Content ctaLabel="Open modal" onClickBtn={() => setIsModalOpen(true)} />
</SidePanel>

<Box>
Expand Down
12 changes: 6 additions & 6 deletions components/Skeleton/Skeleton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const Typographies: StoryFn<typeof SkeletonForStory> = () => (
</H6>

{TEXT_SIZES.map((size) => (
<FaencyText size={size}>
<FaencyText key={size} size={size}>
<Skeleton variant="text" />
</FaencyText>
))}
Expand All @@ -102,7 +102,7 @@ const AVATAR_SIZES = ['1', '2', '3', '4', '5', '6'] as const;
export const Avatars: StoryFn<typeof SkeletonForStory> = () => (
<Flex gap="3" align="center">
{AVATAR_SIZES.map((size) => (
<Flex gap="3" align="center" direction="column">
<Flex key={size} gap="3" align="center" direction="column">
<Skeleton variant="circle">
<Avatar size={size} />
</Skeleton>
Expand Down Expand Up @@ -187,15 +187,15 @@ export const Customs: StoryFn<typeof SkeletonForStory> = () => (
<Flex direction="column" gap={2} css={{ flex: 1 }}>
{Array(10)
.fill(0)
.map(() => (
<Skeleton variant="text" />
.map((_, i) => (
<Skeleton key={i} variant="text" />
))}
</Flex>
<Flex direction="column" gap={2} css={{ flex: 1 }}>
{Array(10)
.fill(0)
.map(() => (
<Skeleton variant="text" />
.map((_, i) => (
<Skeleton key={i} variant="text" />
))}
</Flex>
</Flex>
Expand Down
2 changes: 2 additions & 0 deletions components/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const Transform: StoryFn<typeof TextForStory> = ({ ...args }) => (
</TextForStory>
{VARIANT_PARENTS.map((color) => (
<Flex
key={color}
direction="column"
align="center"
justify="center"
Expand Down Expand Up @@ -137,6 +138,7 @@ export const Size: StoryFn<typeof TextForStory> = ({ ...args }) => (
</TextForStory>
{SIZE_PARENTS.map((fontSize) => (
<Flex
key={fontSize}
css={{
fontSize,
border: '1px dashed $hiContrast',
Expand Down
Loading