Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(react): migrate to react 19 rc #3796

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions examples/next-advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@emotion/styled": "11.11.5",
"@ultraviolet/ui": "workspace:*",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515",
"react-schemaorg": "2.0.0",
"react-syntax-highlighter": "15.5.0",
"react-use-clipboard": "1.0.9",
Expand Down
4 changes: 2 additions & 2 deletions examples/next-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@ultraviolet/icons": "workspace:*",
"@ultraviolet/ui": "workspace:*",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515",
"react-schemaorg": "2.0.0",
"react-syntax-highlighter": "15.5.0",
"react-use-clipboard": "1.0.9",
Expand Down
4 changes: 2 additions & 2 deletions examples/next-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@emotion/styled": "11.11.5",
"@ultraviolet/ui": "workspace:*",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515",
"react-schemaorg": "2.0.0",
"react-syntax-highlighter": "15.5.0",
"react-use-clipboard": "1.0.9",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
"jest-axe": "8.0.0",
"lint-staged": "15.2.5",
"postcss": "8.4.38",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515",
"read-pkg": "9.0.1",
"regenerator-runtime": "0.14.1",
"require-from-string": "2.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"@utils/test": "workspace:*",
"react": "18.3.1",
"react-dom": "18.3.1"
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515"
},
"dependencies": {
"@babel/runtime": "7.24.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"peerDependencies": {
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"react": "18.3.1",
"react-dom": "18.3.1"
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515"
},
"devDependencies": {
"@babel/core": "7.24.7",
Expand Down
135 changes: 65 additions & 70 deletions packages/icons/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { css } from '@emotion/react'
import styled from '@emotion/styled'
import type { consoleLightTheme as theme } from '@ultraviolet/themes'
import type { FunctionComponent, SVGProps } from 'react'
import { forwardRef, useMemo } from 'react'
import type { FunctionComponent, Ref, SVGProps } from 'react'
import { useMemo } from 'react'
import capitalize from '../../utils/capitalize'
import { ICONS } from './Icons'
import { SMALL_ICONS } from './SmallIcons'
Expand All @@ -23,7 +23,7 @@
const sizeStyles = ({
size,
}: {
size: number | string | 'small' | 'large'

Check warning on line 26 in packages/icons/src/components/Icon/index.tsx

View workflow job for this annotation

GitHub Actions / lint

"small" is overridden by string in this union type

Check warning on line 26 in packages/icons/src/components/Icon/index.tsx

View workflow job for this annotation

GitHub Actions / lint

"large" is overridden by string in this union type
}) => {
if (size === 'small' || size === 16) {
return css`
Expand Down Expand Up @@ -67,7 +67,7 @@
shouldForwardProp: prop =>
!['size', 'sentiment', 'prominence', 'disabled'].includes(prop),
})<{
sentiment: Color | string

Check warning on line 70 in packages/icons/src/components/Icon/index.tsx

View workflow job for this annotation

GitHub Actions / lint

"success" | "danger" | "primary" | "secondary" | "neutral" | "warning" | "info" is overridden by string in this union type
size: number | string
prominence: ProminenceProps
disabled?: boolean
Expand Down Expand Up @@ -114,17 +114,18 @@
/**
* ⚠️`string` and `number` are deprecated. Use `small` and `large` only.
*/
size?: number | string | 'small' | 'large'

Check warning on line 117 in packages/icons/src/components/Icon/index.tsx

View workflow job for this annotation

GitHub Actions / lint

"small" is overridden by string in this union type

Check warning on line 117 in packages/icons/src/components/Icon/index.tsx

View workflow job for this annotation

GitHub Actions / lint

"large" is overridden by string in this union type
name?: IconName
prominence?: ProminenceProps
/**
* @deprecated use `sentiment` property instead
*/
color?: Color
color?: Color | string
sentiment?: Color
variant?: 'outlined' | 'filled'
'data-testid'?: string
disabled?: boolean
ref?: Ref<SVGSVGElement>
} & Pick<
SVGProps<SVGSVGElement>,
'className' | 'stroke' | 'cursor' | 'strokeWidth'
Expand All @@ -133,70 +134,64 @@
/**
* Icon component is our set of system icons in the design system. All of them are SVGs.
*/
export const Icon = forwardRef<SVGSVGElement, IconProps>(
(
{
name = 'alert',
color = 'currentColor',
sentiment,
size = '1em',
prominence = 'default',
className,
'data-testid': dataTestId,
stroke,
variant = 'filled',
cursor,
strokeWidth,
disabled,
},
ref,
) => {
const computedSentiment = sentiment ?? color
const SystemIcon = useMemo(() => {
if (size === 'small' || size === 16) {
return StyledIcon(
SMALL_ICONS[variant][name] || SMALL_ICONS.filled.alert,
)
}

return StyledIcon(ICONS[variant][name] || ICONS.filled.alert)
}, [name, size, variant])

/**
* @deprecated to be removed in next major
*/
const defaultViewBox = useMemo(() => {
if (
[
'asterisk',
'close-circle-outline',
'drag-variant',
'expand-more',
'send',
'switch_orga',
].includes(name)
) {
return '0 0 24 24'
}
if (size === 'small' || size === 16) return '0 0 16 16'

return '0 0 20 20'
}, [name, size])

return (
<SystemIcon
ref={ref}
sentiment={computedSentiment}
prominence={prominence}
size={size}
viewBox={defaultViewBox}
className={className}
data-testid={dataTestId}
stroke={stroke}
cursor={cursor}
strokeWidth={strokeWidth}
disabled={disabled}
/>
)
},
)
export const Icon = ({
name = 'alert',
color = 'currentColor',
sentiment,
size = '1em',
prominence = 'default',
className,
'data-testid': dataTestId,
stroke,
variant = 'filled',
cursor,
strokeWidth,
disabled,
ref,
}: IconProps) => {
const computedSentiment = sentiment ?? color
const SystemIcon = useMemo(() => {
if (size === 'small' || size === 16) {
return StyledIcon(SMALL_ICONS[variant][name] || SMALL_ICONS.filled.alert)
}

return StyledIcon(ICONS[variant][name] || ICONS.filled.alert)
}, [name, size, variant])

/**
* @deprecated to be removed in next major
*/
const defaultViewBox = useMemo(() => {
if (
[
'asterisk',
'close-circle-outline',
'drag-variant',
'expand-more',
'send',
'switch_orga',
].includes(name)
) {
return '0 0 24 24'
}
if (size === 'small' || size === 16) return '0 0 16 16'

return '0 0 20 20'
}, [name, size])

return (
<SystemIcon
ref={ref}
sentiment={computedSentiment}
prominence={prominence}
size={size}
viewBox={defaultViewBox}
className={className}
data-testid={dataTestId}
stroke={stroke}
cursor={cursor}
strokeWidth={strokeWidth}
disabled={disabled}
/>
)
}
4 changes: 2 additions & 2 deletions packages/illustrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"peerDependencies": {
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"react": "18.3.1",
"react-dom": "18.3.1"
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515"
},
"dependencies": {
"@ultraviolet/themes": "workspace:*"
Expand Down
8 changes: 4 additions & 4 deletions packages/plus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"peerDependencies": {
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"react": "18.3.1",
"react-dom": "18.3.1"
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515"
},
"devDependencies": {
"@babel/core": "7.24.7",
Expand All @@ -77,8 +77,8 @@
"@ultraviolet/icons": "workspace:*",
"@ultraviolet/illustrations": "workspace:*",
"@utils/test": "workspace:*",
"react": "18.3.1",
"react-dom": "18.3.1"
"react": "19.0.0-rc-915b914b3a-20240515",
"react-dom": "19.0.0-rc-915b914b3a-20240515"
},
"dependencies": {
"@uiw/codemirror-extensions-langs": "4.22.2",
Expand Down
Loading
Loading