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
41 changes: 26 additions & 15 deletions packages/react-calendar/src/Flex.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Children, cloneElement } from 'react';

type FlexProps = React.HTMLAttributes<HTMLDivElement> & {
type FlexProps = React.HTMLAttributes<HTMLUListElement> & {
// biome-ignore lint/suspicious/noExplicitAny: Too complex to type
children: React.ReactElement<any>[];
className?: string;
Expand All @@ -26,32 +26,43 @@ export default function Flex({
...otherProps
}: FlexProps): React.ReactElement {
return (
<div
<ul
className={className}
style={{
display: 'flex',
flexDirection: direction,
flexWrap: wrap ? 'wrap' : 'nowrap',
margin: 0,
padding: 0,
...style,
}}
{...otherProps}
>
{Children.map(children, (child, index) => {
const marginInlineStart = offset && index === 0 ? toPercent((100 * offset) / count) : null;

return cloneElement(child, {
...child.props,
style: {
flexBasis: toPercent(100 / count),
flexShrink: 0,
flexGrow: 0,
overflow: 'hidden',
marginLeft: marginInlineStart,
marginInlineStart: marginInlineStart,
marginInlineEnd: 0,
},
});
return (
<li
style={{
display: 'flex',
flexBasis: toPercent(100 / count),
flexShrink: 0,
flexGrow: 0,
overflow: 'hidden',
marginLeft: marginInlineStart || undefined,
marginInlineStart: marginInlineStart || undefined,
marginInlineEnd: 0,
}}
>
{cloneElement(child, {
...child.props,
style: {
flex: 1,
},
})}
</li>
);
})}
</div>
</ul>
);
}
1 change: 1 addition & 0 deletions packages/react-calendar/src/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default function Tile(props: TileProps): React.ReactElement {
onMouseOver={onMouseOver ? () => onMouseOver(date) : undefined}
style={style}
type="button"
aria-pressed={!!classes?.find((classString) => classString.indexOf('--active') != -1 || classString.indexOf('--hasActive') != -1)}
>
{formatAbbr ? <abbr aria-label={formatAbbr(locale, date)}>{children}</abbr> : children}
{tileContent}
Expand Down