Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Philibeaux <[email protected]>
  • Loading branch information
philibea committed Dec 16, 2024
1 parent 6e17823 commit 8f24686
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/icons/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type IconProps = {
/**
* IconV2 component is our set of system icons in the design system. All of them are SVGs.
*/

export const Icon = forwardRef<SVGSVGElement, IconProps>(
(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled'
import { Icon, Stack } from '@ultraviolet/ui'
import type { ReactNode } from 'react'
import type { JSX, ReactNode } from 'react'
import { Children, cloneElement, isValidElement, useMemo } from 'react'
import { LineThrough } from './Components/LineThrough'
import { Strong } from './Components/Strong'
Expand Down
2 changes: 1 addition & 1 deletion packages/plus/src/components/EstimateCost/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Alert } from '@ultraviolet/ui'
import type { ComponentProps, ReactNode } from 'react'
import type { ComponentProps, JSX, ReactNode } from 'react'
import type EstimateCostLocales from './locales/en'

export type EstimateCostProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/plus/src/components/Navigation/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const StickyFooter = styled.div`

type FooterProps = {
onToggleExpand: NavigationProps['onToggleExpand']
contentRef: RefObject<HTMLDivElement>
contentRef: RefObject<HTMLDivElement | null>
}

export const Footer = ({ onToggleExpand, contentRef }: FooterProps) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/plus/src/components/Navigation/NavigationContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export const NavigationContent = ({
shouldAnimate,
} = context

const sliderRef = useRef<HTMLDivElement>(null)
const contentRef = useRef<HTMLDivElement>(null)
const sliderRef = useRef<HTMLDivElement | null>(null)
const contentRef = useRef<HTMLDivElement | null>(null)

// It will handle the resize of the navigation when the user drag the vertical bar
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Dispatch, ReactNode, Reducer, RefObject } from 'react'
import type { Dispatch, ReactNode, RefObject } from 'react'
import {
createContext,
useCallback,
Expand Down Expand Up @@ -33,7 +33,7 @@ type ContextProps = {
unpinItem: (item: string) => string[]
pinnedItems: string[]
pinLimit: number
navigationRef: RefObject<HTMLDivElement>
navigationRef: RefObject<HTMLDivElement | null>
locales: Record<keyof typeof NavigationLocales, string>
width: number
setWidth: (width: number) => void
Expand Down Expand Up @@ -156,14 +156,14 @@ export const NavigationProvider = ({

// This is used to store the items that are registered in the navigation
// This way we can retrieve items with their active state in pinned feature
const [items, registerItem] = useReducer<Reducer<Items, Items>>(
const [items, registerItem] = useReducer(
(oldState: Items, newState: Items) => ({
...oldState,
...newState,
}),
{},
)
const navigationRef = useRef<HTMLDivElement>(null)
const navigationRef = useRef<HTMLDivElement | null>(null)

// This function will be triggered when expand/collapse button is clicked
const toggleExpand = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export const AutoFocus: StoryFn = props => (
<TextInputV2 placeholder="placeholder" />
<TextInputV2
placeholder="placeholder"
ref={ref => setTimeout(() => ref?.focus(), 1)}
ref={ref => {
if (ref) {
setTimeout(() => ref?.focus(), 1)
}
}}
/>
</div>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { StoryFn } from '@storybook/react'
import { useState } from 'react'
import type { NumberInputV2 } from '../index'
import { Template } from './Template.stories'
import { NumberInputV2 } from '..'

export const MinMax: StoryFn<typeof NumberInputV2> = args => {
export const Template: StoryFn<typeof NumberInputV2> = props => {
const [value, setValue] = useState<number | null>(10)

return <Template {...args} value={value} onChange={setValue} />
return <NumberInputV2 {...props} value={value} onChange={setValue} />
}

export const MinMax = Template.bind({})

MinMax.args = {
id: 'number-input',
label: 'Number Input',
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/src/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useRef,
useState,
} from 'react'
import type { HTMLAttributes, ReactElement, ReactNode } from 'react'
import type { ComponentProps, HTMLAttributes, ReactNode } from 'react'
import { StyledTabButton, Tab } from './Tab'
import { TabMenu } from './TabMenu'
import { TabMenuItem } from './TabMenuItem'
Expand Down Expand Up @@ -143,10 +143,10 @@ export const Tabs = ({

// mapping of tab children to avoid using subtitle props
const menuItemChildren = Children.map(children, child => {
if (isValidElement<typeof Tab>(child)) {
return cloneElement(child as ReactElement, {
if (isValidElement<ComponentProps<typeof Tab>>(child)) {
return cloneElement(child, {
...child.props,
// subtitle: null,
subtitle: null,
})
}

Expand Down

0 comments on commit 8f24686

Please sign in to comment.