Skip to content

Commit

Permalink
fix react 19 types
Browse files Browse the repository at this point in the history
  • Loading branch information
lerte committed Jun 16, 2024
1 parent 6f1890a commit 4ed7577
Show file tree
Hide file tree
Showing 21 changed files with 1,119 additions and 1,144 deletions.
8 changes: 6 additions & 2 deletions packages/actify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.12.7",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"autoprefixer": "^10.4.19",
Expand All @@ -52,6 +52,10 @@
"tslib": "^2.6.2",
"typescript": "^5.4.5"
},
"overrides": {
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc"
},
"dependencies": {
"@floating-ui/react": "^0.26.13",
"clsx": "^2.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const AccordionRoot = (props: AccordionRootProps) => {
isValidElement(child) &&
cloneElement(child, {
index,
// @ts-ignore
...child.props
})
)}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Accordion/AccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const AccordionItem = (props: AccordionItemProps) => {
isValidElement(child) &&
cloneElement(child, {
index,
// @ts-ignore
...child.props
})
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Icons = ({ children }: { children: React.ReactNode }) => {
isValidElement(child) &&
index <= 3 &&
cloneElement(child, {
// @ts-ignore
...child.props,
className: 'cursor-pointer'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { tv } from 'tailwind-variants'
import { useBottomSheets } from './BottomSheetsContext'

const scrim = tv({
base: 'z-50 bg-black/40 dark:bg-[rgba(3,3,3,.8)]'
base: 'z-50 bg-[rgba(0,0,0,0.32)]'
})

const rootVariants = tv({
Expand Down Expand Up @@ -65,6 +65,7 @@ const Content = ({
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
// @ts-ignore
onClick={() => setOpen?.(false)}
className={rootVariants({ className })}
>
Expand All @@ -78,8 +79,9 @@ const Content = ({
exit={{
transform: 'translateY(100%)'
}}
// @ts-ignore
className={innerVariants()}
onClick={(e) => e.stopPropagation()}
onClick={(e: Event) => e.stopPropagation()}
>
<div className="inline-flex h-9 w-full cursor-grab flex-col items-center justify-start gap-3 p-4 bg-surface rounded-t-[100px]">
<div className="h-1 w-8 bg-outline/40 rounded-[100px]"></div>
Expand All @@ -92,7 +94,7 @@ const Content = ({
)}
</AnimatePresence>,
container
)
) as React.ReactNode
}

export { Content }
10 changes: 7 additions & 3 deletions packages/actify/src/components/Carousel/CarouselContent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use client'
import { wrap } from 'popmotion'

import { AnimatePresence, motion } from 'framer-motion'
import React, { Children, isValidElement, useEffect } from 'react'

import { twMerge } from 'tailwind-merge'
import { useCarousel } from './CarouselContext'
import { motion, AnimatePresence } from 'framer-motion'
import React, { Children, useEffect, isValidElement } from 'react'
import { wrap } from 'popmotion'

const variants = {
enter: (direction: number) => {
Expand Down Expand Up @@ -54,7 +56,9 @@ const CarouselContent = ({ children }: React.ComponentProps<'div'>) => {
if (current == index) {
return (
<MotionComponent
// @ts-ignore
{...child.props}
// @ts-ignore
className={twMerge(child.props.className, 'absolute')}
variants={variants}
key={page}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Chips/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Chip = (props: ChipProps) => {
isValidElement(child) &&
cloneElement(child, {
index,
// @ts-ignore
...child.props
})
)}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Chips/FilterChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ const FilterChip = (props: FilterChipProps) => {
>
<motion.div
layout
// @ts-ignore
onClick={handleClick}
className={container({ selected, disabled })}
>
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Field/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Field = (props: FieldProps) => {
easings: [cubicBezier(0.2, 0, 0, 1)]
}}
aria-hidden={!visible}
// @ts-ignore
className={clsx(
styles['label'],
!visible && styles['visible'],
Expand Down
2 changes: 2 additions & 0 deletions packages/actify/src/components/Lists/ListGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const ListGroup = (props: ListItemProps) => {
{hovered && (
<motion.div
layoutId={layoutId}
// @ts-ignore
className="h-14 absolute inset-0 bg-surface-variant z-[-1]"
/>
)}
Expand All @@ -60,6 +61,7 @@ const ListGroup = (props: ListItemProps) => {
(child) =>
isValidElement(child) &&
cloneElement(child, {
// @ts-ignore
...child.props
})
)}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Lists/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const ListItem = (props: ListItemProps) => {
<motion.div
layoutId={layoutId}
transition={transition}
// @ts-ignore
className="absolute inset-0 bg-surface-variant z-[-1]"
/>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Lists/ListItemLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ListItemLink = (props: ListItemProps) => {
{children == current && (
<motion.div
layoutId={layoutId}
// @ts-ignore
className="absolute inset-0 bg-secondary/25 z-[-1]"
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const DrawerActivator = (props: DrawerActivatorProps) => {
return cloneElement(children, {
ref,
...rest,
// @ts-ignore
...children.props,
role: 'button',
onClick: handleClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { tv } from 'tailwind-variants'
import { useDrawer } from './DrawerContext'

const scrim = tv({
base: 'z-50 bg-black/40'
base: 'z-50 bg-[rgba(0,0,0,0.32)]'
})

const rootVariants = tv({
Expand Down Expand Up @@ -159,10 +159,12 @@ const DrawerContent = ({ style, className, children }: DrawerContentProps) => {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
// @ts-ignore
className={rootVariants({ open })}
>
<motion.div
{...getAnimationProps()}
// @ts-ignore
className={contentVariants({ placement, className })}
>
{children}
Expand All @@ -173,7 +175,7 @@ const DrawerContent = ({ style, className, children }: DrawerContentProps) => {
)}
</AnimatePresence>,
container
)
) as React.ReactNode
}

export { DrawerContent }
10 changes: 5 additions & 5 deletions packages/actify/src/components/Ripple/Ripple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const Ripple = (props: RippleProps) => {
const rippleSize = useRef('')
const rippleScale = useRef('')
const initialSize = useRef(0)
const growAnimation = useRef<Animation>()
const rippleStartEvent = useRef<PointerEvent>()
const growAnimation = useRef<Animation>(null)
const rippleStartEvent = useRef<PointerEvent>(null)
const checkBoundsAfterContextMenu = useRef(false)

const isTouch = ({ pointerType }: PointerEvent) => {
Expand Down Expand Up @@ -124,7 +124,7 @@ const Ripple = (props: RippleProps) => {
return { x: pageX - documentX, y: pageY - documentY }
}

const getTranslationCoordinates = (positionEvent?: Event) => {
const getTranslationCoordinates = (positionEvent?: Event | null) => {
const { height, width } = ref.current!.getBoundingClientRect()
// end in the center
const endPoint = {
Expand All @@ -151,7 +151,7 @@ const Ripple = (props: RippleProps) => {
return { startPoint, endPoint }
}

const startPressAnimation = (positionEvent?: Event) => {
const startPressAnimation = (positionEvent?: Event | null) => {
if (!ref.current) {
return
}
Expand Down Expand Up @@ -183,7 +183,7 @@ const Ripple = (props: RippleProps) => {
}

const endPressAnimation = async () => {
rippleStartEvent.current = undefined
rippleStartEvent.current = null
state.current = State.INACTIVE
const animation = growAnimation.current
let pressAnimationPlayState = Infinity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { tv } from 'tailwind-variants'
import { useSideSheets } from './SideSheetsContext'

const scrim = tv({
base: 'z-50 bg-black/40 dark:bg-[rgba(3,3,3,.8)]'
base: 'z-50 bg-[rgba(0,0,0,0.32)]'
})

const rootVariants = tv({
Expand Down Expand Up @@ -65,6 +65,7 @@ const Content = (props: ContentProps) => {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
// @ts-ignore
onClick={() => setOpen?.(false)}
className={rootVariants({ className })}
>
Expand All @@ -78,16 +79,17 @@ const Content = (props: ContentProps) => {
exit={{
transform: 'translateX(100%)'
}}
// @ts-ignore
className={innerVariants()}
onClick={(e) => e.stopPropagation()}
onClick={(e: Event) => e.stopPropagation()}
>
{children}
</motion.div>
</motion.div>
)}
</AnimatePresence>,
container
)
) as React.ReactNode
}

export { Content }
5 changes: 4 additions & 1 deletion packages/actify/src/components/Slot/Slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Slot = (props: SlotProps) => {

if (slottable) {
// the new element to render is the one passed as a child of `Slottable`
// @ts-ignore
const newElement = slottable.props.children as React.ReactNode

const newChildren = childrenArray.map((child) => {
Expand All @@ -26,7 +27,8 @@ const Slot = (props: SlotProps) => {
if (React.Children.count(newElement) > 1)
return React.Children.only(null)
return React.isValidElement(newElement)
? (newElement.props.children as React.ReactNode)
? // @ts-ignore
(newElement.props.children as React.ReactNode)
: null
} else {
return child
Expand Down Expand Up @@ -65,6 +67,7 @@ const SlotClone = (props: SlotCloneProps) => {

if (React.isValidElement(children)) {
return React.cloneElement(children, {
// @ts-ignore
...mergeProps(slotProps, children.props),
// @ts-ignore
ref: forwardedRef
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const Tab = (props: TabProps) => {
{activeTabIndex == index && (
<motion.div
layoutId={layoutId}
// @ts-ignore
className="absolute -z-10 w-full bottom-0"
>
<div className="h-0.5 rounded-lg w-full bg-primary"></div>
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Tabs/TabsBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const TabsBody = (props: TabsBodyProps) => {
isValidElement(child) &&
cloneElement(child, {
index,
// @ts-ignore
...child.props
})
)}
Expand Down
1 change: 1 addition & 0 deletions packages/actify/src/components/Tabs/TabsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const TabsHeader = (props: TabsHeaderProps) => {
isValidElement(child) &&
cloneElement(child, {
index,
// @ts-ignore
...child.props
})
)}
Expand Down
Loading

0 comments on commit 4ed7577

Please sign in to comment.