diff --git a/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch b/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch new file mode 100644 index 0000000000..33e4db3261 --- /dev/null +++ b/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch @@ -0,0 +1,12 @@ +diff --git a/types.d.ts b/types.d.ts +index 498bb694de2e6a62f14d3fe998dc538aff920fc6..719f0ea55bb472e2df0e38a06df88d5ad6156b44 100644 +--- a/types.d.ts ++++ b/types.d.ts +@@ -1,5 +1,7 @@ + // Internal helper types + ++import type { JSX } from "react/jsx-runtime"; ++ + /** + * This is the global JSX.ElementType if it’s defined, otherwise never. + */ diff --git a/package.json b/package.json index c80cba15f2..0ebce03a5c 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "@types/jest": "^29.5.14", "@types/jest-axe": "^3.5.9", "@types/node": "^22.10.1", - "@types/react": "^18.3.12", - "@types/react-dom": "^18.3.1", + "@types/react": "^19.0.1", + "@types/react-dom": "^19.0.1", "@types/webpack": "^5.28.5", "@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/parser": "^7.5.0", @@ -100,7 +100,8 @@ "yargs": "^17.7.2" }, "resolutions": { - "markdown-to-jsx@npm:^6.11.4": "^7.5.0" + "markdown-to-jsx@npm:^6.11.4": "^7.5.0", + "@types/mdx@npm:^2.0.0": "patch:@types/mdx@npm%3A2.0.13#~/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch" }, "scripts": { "docs:styleguide": "yarn workspace @project-docs/styleguide run start", diff --git a/packages/vkui/package.json b/packages/vkui/package.json index 3c7b65d24a..0078e7c368 100644 --- a/packages/vkui/package.json +++ b/packages/vkui/package.json @@ -77,8 +77,8 @@ "generate:css-custom-medias": "node scripts/generateCSSCustomMedias.mjs" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" }, "dependencies": { "@swc/helpers": "^0.5.15", diff --git a/packages/vkui/src/components/ActionSheet/types.ts b/packages/vkui/src/components/ActionSheet/types.ts index ea2dc0b82b..bd81c3a1ef 100644 --- a/packages/vkui/src/components/ActionSheet/types.ts +++ b/packages/vkui/src/components/ActionSheet/types.ts @@ -2,7 +2,7 @@ import type * as React from 'react'; import type { PlacementWithAuto } from '../../lib/floating/types/common'; import { type FocusTrapProps } from '../FocusTrap/FocusTrap'; -export type ToggleRef = Element | null | undefined | React.RefObject; +export type ToggleRef = Element | null | undefined | React.RefObject; export interface SharedDropdownProps extends FocusTrapProps { closing: boolean; diff --git a/packages/vkui/src/components/AppRoot/AppRoot.test.tsx b/packages/vkui/src/components/AppRoot/AppRoot.test.tsx index b1e01b0d74..9798505132 100644 --- a/packages/vkui/src/components/AppRoot/AppRoot.test.tsx +++ b/packages/vkui/src/components/AppRoot/AppRoot.test.tsx @@ -170,7 +170,7 @@ describe('AppRoot', () => { describe('portalRoot prop', () => { it('should accept custom portal root', () => { const customPortalRoot = document.createElement('div'); - let portalRoot: React.MutableRefObject = React.createRef(); + let portalRoot: React.RefObject = React.createRef(); const contextCallback = jest.fn().mockImplementation((ctx) => { portalRoot.current = ctx.portalRoot ?? null; return null; diff --git a/packages/vkui/src/components/AppRoot/AppRoot.tsx b/packages/vkui/src/components/AppRoot/AppRoot.tsx index a1fb5a6e20..f47161cde8 100644 --- a/packages/vkui/src/components/AppRoot/AppRoot.tsx +++ b/packages/vkui/src/components/AppRoot/AppRoot.tsx @@ -40,7 +40,7 @@ export interface AppRootProps extends React.HTMLAttributes { /** * Кастомный root-элемент портала */ - portalRoot?: HTMLElement | React.RefObject | null; + portalRoot?: HTMLElement | React.RefObject | null; /** * Отключает рендер всплывающих компонентов в отдельном контейнере */ diff --git a/packages/vkui/src/components/AppRoot/AppRootContext.ts b/packages/vkui/src/components/AppRoot/AppRootContext.ts index 0322b4ade8..d33bcc577e 100644 --- a/packages/vkui/src/components/AppRoot/AppRootContext.ts +++ b/packages/vkui/src/components/AppRoot/AppRootContext.ts @@ -2,8 +2,8 @@ import * as React from 'react'; import { type AppRootUserSelectMode, type SafeAreaInsets } from './types'; export interface AppRootContextInterface { - appRoot: React.RefObject; - portalRoot?: HTMLElement | React.RefObject | null; + appRoot: React.RefObject; + portalRoot?: HTMLElement | React.RefObject | null; safeAreaInsets?: SafeAreaInsets; embedded: boolean; mode: 'partial' | 'embedded' | 'full'; diff --git a/packages/vkui/src/components/AppRoot/AppRootPortal.tsx b/packages/vkui/src/components/AppRoot/AppRootPortal.tsx index 1ac57d3eac..62b8e5a0f5 100644 --- a/packages/vkui/src/components/AppRoot/AppRootPortal.tsx +++ b/packages/vkui/src/components/AppRoot/AppRootPortal.tsx @@ -18,7 +18,7 @@ export interface AppRootPortalProps extends HasChildren { * * По умолчанию в качестве портала будет использован `document.body` */ - usePortal?: boolean | HTMLElement | React.RefObject | null; + usePortal?: boolean | HTMLElement | React.RefObject | null; className?: string; } diff --git a/packages/vkui/src/components/AppRoot/ScrollContext.test.tsx b/packages/vkui/src/components/AppRoot/ScrollContext.test.tsx index 2d8bef5309..9370472b90 100644 --- a/packages/vkui/src/components/AppRoot/ScrollContext.test.tsx +++ b/packages/vkui/src/components/AppRoot/ScrollContext.test.tsx @@ -11,7 +11,7 @@ import { } from './ScrollContext'; type ChildWithContextProps = { - contextRef?: RefObject; + contextRef?: RefObject; beforeScrollLockFn?: VoidFunction; }; const ChildWithContext = ({ contextRef, beforeScrollLockFn }: ChildWithContextProps) => { diff --git a/packages/vkui/src/components/AppRoot/ScrollContext.tsx b/packages/vkui/src/components/AppRoot/ScrollContext.tsx index 93c80091de..d96d8eedcd 100644 --- a/packages/vkui/src/components/AppRoot/ScrollContext.tsx +++ b/packages/vkui/src/components/AppRoot/ScrollContext.tsx @@ -81,7 +81,7 @@ function useScrollLockController(enableScrollLock: () => void, disableScrollLock } export interface ScrollControllerProps extends HasChildren { - elRef: React.RefObject; + elRef: React.RefObject; } export const GlobalScrollController = ({ children }: ScrollControllerProps): React.ReactNode => { diff --git a/packages/vkui/src/components/AspectRatio/AspectRatio.tsx b/packages/vkui/src/components/AspectRatio/AspectRatio.tsx index 92e23313a1..efbb13e73d 100644 --- a/packages/vkui/src/components/AspectRatio/AspectRatio.tsx +++ b/packages/vkui/src/components/AspectRatio/AspectRatio.tsx @@ -23,7 +23,11 @@ export interface AspectRatioProps extends Omit, * @since 5.5.0 * @see https://vkcom.github.io/VKUI/#/AspectRatio */ -export function AspectRatio({ ratio, mode = 'stretch', ...props }: AspectRatioProps): JSX.Element { +export function AspectRatio({ + ratio, + mode = 'stretch', + ...props +}: AspectRatioProps): React.JSX.Element { const style: React.CSSProperties & CSSCustomProperties = { '--vkui_internal--aspect_ratio': String(ratio), }; diff --git a/packages/vkui/src/components/ChipsInput/useChipsInput.ts b/packages/vkui/src/components/ChipsInput/useChipsInput.ts index 1d505fefe0..54a368ba72 100644 --- a/packages/vkui/src/components/ChipsInput/useChipsInput.ts +++ b/packages/vkui/src/components/ChipsInput/useChipsInput.ts @@ -84,7 +84,7 @@ export const useChipsInput = ({ addOptionFromInput: (inputValue: string) => void; removeOption: (newValue: O | ChipOptionValue) => void; clearOptions: () => void; - inputRef: React.RefObject; + inputRef: React.RefObject<(HTMLInputElement & SimulateReactInputTargetState) | null>; inputValue: string; onInputChange: (e: React.ChangeEvent) => any; clearInput: () => void; @@ -96,7 +96,7 @@ export const useChipsInput = ({ onChange, }); - const inputRef = React.useRef(null); + const inputRef = React.useRef<(HTMLInputElement & SimulateReactInputTargetState) | null>(null); const [inputValue, setInputChange] = useEnsuredControl({ disabled, value: inputValueProp, diff --git a/packages/vkui/src/components/ChipsSelect/useChipsSelect.ts b/packages/vkui/src/components/ChipsSelect/useChipsSelect.ts index 74df82578f..8dc5051f34 100644 --- a/packages/vkui/src/components/ChipsSelect/useChipsSelect.ts +++ b/packages/vkui/src/components/ChipsSelect/useChipsSelect.ts @@ -97,7 +97,7 @@ export const useChipsSelect = ({ addOptionFromInput: (inputValue: string) => void; removeOption: (newValue: ChipOptionValue | O) => void; clearOptions: () => void; - inputRef: React.RefObject; + inputRef: React.RefObject<(HTMLInputElement & SimulateReactInputTargetState) | null>; clearInput: () => void; } => { const { value, inputValue, onInputChange, ...restChipsInputProps } = useChipsInput({ diff --git a/packages/vkui/src/components/Clickable/useState.tsx b/packages/vkui/src/components/Clickable/useState.tsx index e37d26854f..fd4f5ca303 100644 --- a/packages/vkui/src/components/Clickable/useState.tsx +++ b/packages/vkui/src/components/Clickable/useState.tsx @@ -142,7 +142,7 @@ interface UseActiveProps extends Pick; + lockStateRef: React.RefObject; setParentStateLock: (v: boolean) => void; } @@ -245,7 +245,7 @@ function useLockState( function useLockRef( setParentStateLockBubbling: (v: boolean) => void, -): readonly [React.MutableRefObject, (v: boolean) => void, (...args: any[]) => void] { +): readonly [React.RefObject, (v: boolean) => void, (...args: any[]) => void] { const lockStateRef = React.useRef(false); const setStateLockBubblingImmediate = React.useCallback( diff --git a/packages/vkui/src/components/Clickable/useStateWithDelay.tsx b/packages/vkui/src/components/Clickable/useStateWithDelay.tsx index 01587ef22b..c22bd365c6 100644 --- a/packages/vkui/src/components/Clickable/useStateWithDelay.tsx +++ b/packages/vkui/src/components/Clickable/useStateWithDelay.tsx @@ -41,7 +41,7 @@ export function useStateWithDelay( onStateChange: (v: S) => void = noop, ): [S, DispatchWithDelay>] { const [value, setValue] = React.useState(initialState); - const timeout = React.useRef>(); + const timeout = React.useRef>(undefined); const handleSetValue = React.useCallback( (nextValue: React.SetStateAction) => { diff --git a/packages/vkui/src/components/CustomSelect/CustomSelect.test.tsx b/packages/vkui/src/components/CustomSelect/CustomSelect.test.tsx index f4b243f682..8e8fe8a9a0 100644 --- a/packages/vkui/src/components/CustomSelect/CustomSelect.test.tsx +++ b/packages/vkui/src/components/CustomSelect/CustomSelect.test.tsx @@ -1182,7 +1182,7 @@ describe('CustomSelect', () => { it('check input should close popover and reset selected option', async () => { jest.useFakeTimers(); - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; @@ -1231,7 +1231,7 @@ describe('CustomSelect', () => { 'should open dropdown when keydown %s', async (key) => { jest.useFakeTimers(); - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; render( @@ -1277,7 +1277,7 @@ describe('CustomSelect', () => { it('should call onInputChange callback when change input', async () => { jest.useFakeTimers(); - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; const onInputChange = jest.fn(); @@ -1302,7 +1302,7 @@ describe('CustomSelect', () => { }); it('check scroll to bottom to element', async () => { - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; @@ -1335,7 +1335,7 @@ describe('CustomSelect', () => { }); it('check scroll to up', async () => { - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; @@ -1368,7 +1368,7 @@ describe('CustomSelect', () => { }); it('should not hover disabled option', async () => { - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; render( @@ -1392,7 +1392,7 @@ describe('CustomSelect', () => { }); it('should not call select option when not focus to option', async () => { - const inputRef: React.RefObject = { + const inputRef: React.RefObject = { current: null, }; const onChange = jest.fn(); diff --git a/packages/vkui/src/components/CustomSelectDropdown/CustomSelectDropdown.tsx b/packages/vkui/src/components/CustomSelectDropdown/CustomSelectDropdown.tsx index b14b709bf9..70a274de9b 100644 --- a/packages/vkui/src/components/CustomSelectDropdown/CustomSelectDropdown.tsx +++ b/packages/vkui/src/components/CustomSelectDropdown/CustomSelectDropdown.tsx @@ -11,7 +11,7 @@ export interface CustomSelectDropdownProps extends HTMLAttributesWithRootRef, Pick, HasDataAttribute { - targetRef: React.RefObject; + targetRef: React.RefObject; placement?: Placement; scrollBoxRef?: React.Ref; fetching?: boolean; diff --git a/packages/vkui/src/components/Epic/Epic.tsx b/packages/vkui/src/components/Epic/Epic.tsx index eab4fb81ed..d18e4c2286 100644 --- a/packages/vkui/src/components/Epic/Epic.tsx +++ b/packages/vkui/src/components/Epic/Epic.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { classNames } from '@vkontakte/vkjs'; -import { getNavId } from '../../lib/getNavId'; +import { getNavId, type NavIdProps } from '../../lib/getNavId'; import { warnOnce } from '../../lib/warnOnce'; import type { HTMLAttributesWithRootRef } from '../../types'; import { RootComponent } from '../RootComponent/RootComponent'; @@ -30,8 +30,10 @@ export const Epic = ({ const story = (React.Children.toArray(children).find( - (story) => React.isValidElement(story) && getNavId(story.props, warn) === activeStory, - ) as React.ReactElement | undefined) ?? null; + (story) => + React.isValidElement(story) && + getNavId((story as React.ReactElement).props, warn) === activeStory, + ) as Array> | undefined) ?? null; return ( { baselineComponent(FixedLayout); it('check update width by parent width', async () => { - const parentRef: MutableRefObject = { + const parentRef: RefObject = { current: null, }; - const layoutRef: MutableRefObject = { + const layoutRef: RefObject = { current: null, }; let parentWidth = 500; @@ -59,10 +59,10 @@ describe('FixedLayout', () => { }); it('check update width by column width', async () => { - const colRef: MutableRefObject = { + const colRef: RefObject = { current: null, }; - const layoutRef: MutableRefObject = { + const layoutRef: RefObject = { current: null, }; let colWidth = 280; @@ -113,7 +113,7 @@ describe('FixedLayout', () => { className: styles.verticalBottom, }, ])('should have className $className when use props $props', ({ props, className }) => { - const layoutRef: MutableRefObject = { + const layoutRef: RefObject = { current: null, }; render( diff --git a/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.stories.tsx b/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.stories.tsx index 3b67eaaec7..c6d7483d80 100644 --- a/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.stories.tsx +++ b/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.stories.tsx @@ -37,7 +37,7 @@ type Story = StoryObj; export const Playground: Story = { render: function Render(args) { const [commonFriends, setCommonFriends] = React.useState([]); - const timer = React.useRef>(); + const timer = React.useRef | undefined>(undefined); React.useEffect(() => { // Эмуляция загрузки diff --git a/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.test.tsx b/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.test.tsx index 15c5ade482..421fa752f0 100644 --- a/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.test.tsx +++ b/packages/vkui/src/components/HorizontalScroll/HorizontalScroll.test.tsx @@ -102,7 +102,7 @@ describe('HorizontalScroll', () => { }); it('click on arrow right should change scrollLeft', async () => { - const ref: React.MutableRefObject = { + const ref: React.RefObject = { current: null, }; render( @@ -130,7 +130,7 @@ describe('HorizontalScroll', () => { }); it('click on arrow left should change scrollLeft', async () => { - const ref: React.MutableRefObject = { + const ref: React.RefObject = { current: null, }; render( @@ -161,7 +161,7 @@ describe('HorizontalScroll', () => { }); it('use custom scroll function to left and right', async () => { - const ref: React.MutableRefObject = { + const ref: React.RefObject = { current: null, }; render( @@ -197,7 +197,7 @@ describe('HorizontalScroll', () => { }); it('scroll by arrow', () => { - const ref: React.MutableRefObject = { + const ref: React.RefObject = { current: null, }; render( diff --git a/packages/vkui/src/components/ImageBase/ImageBaseOverlay/hooks.ts b/packages/vkui/src/components/ImageBase/ImageBaseOverlay/hooks.ts index 617c261d04..4a140b21e6 100644 --- a/packages/vkui/src/components/ImageBase/ImageBaseOverlay/hooks.ts +++ b/packages/vkui/src/components/ImageBase/ImageBaseOverlay/hooks.ts @@ -2,7 +2,7 @@ import * as React from 'react'; import { useFocusWithin } from '../../../hooks/useFocusWithin'; import { useIsomorphicLayoutEffect } from '../../../lib/useIsomorphicLayoutEffect'; -export function useNonInteractiveOverlayProps(rootRef: React.MutableRefObject) { +export function useNonInteractiveOverlayProps(rootRef: React.RefObject) { const focusWithin = useFocusWithin(rootRef); const [nonInteractiveFocusShown, setNonInteractiveFocusShown] = React.useState(false); diff --git a/packages/vkui/src/components/ImageBase/validators.ts b/packages/vkui/src/components/ImageBase/validators.ts index 17a1dde20f..30c5a446d0 100644 --- a/packages/vkui/src/components/ImageBase/validators.ts +++ b/packages/vkui/src/components/ImageBase/validators.ts @@ -1,3 +1,4 @@ +import type * as React from 'react'; import { warnOnce } from '../../lib/warnOnce'; import { getBadgeIconSizeByImageBaseSize, @@ -32,15 +33,15 @@ function parseIconSizeByWidthProp(width: unknown): number | null { return size > 0 ? size : null; } -function getElementDisplayName(element: JSX.Element): string | null { +function getElementDisplayName(element: React.JSX.Element): string | null { return element.type.displayName ?? null; } -function getElementWidthProp(element: JSX.Element): number | string | null { +function getElementWidthProp(element: React.JSX.Element): number | string | null { return element.props.width ?? null; } -function getIconSizeByElement(element: JSX.Element): number | null { +function getIconSizeByElement(element: React.JSX.Element): number | null { const sizeByDisplayName = parseIconSizeByDisplayName(getElementDisplayName(element)); const sizeByWidth = parseIconSizeByWidthProp(getElementWidthProp(element)); return sizeByWidth ? sizeByWidth : sizeByDisplayName; @@ -48,7 +49,7 @@ function getIconSizeByElement(element: JSX.Element): number | null { interface IconProp { name: string; - value: JSX.Element; + value: React.JSX.Element; } interface SelectorFn { diff --git a/packages/vkui/src/components/ModalRoot/ModalRoot.stories.tsx b/packages/vkui/src/components/ModalRoot/ModalRoot.stories.tsx index 88b9f3a5c1..169911d797 100644 --- a/packages/vkui/src/components/ModalRoot/ModalRoot.stories.tsx +++ b/packages/vkui/src/components/ModalRoot/ModalRoot.stories.tsx @@ -132,7 +132,7 @@ export const Managing: Story = { export const ModalDynamicHeight: Story = { render: function Render() { const [isLoading, setIsLoading] = React.useState(true); - const timer = React.useRef>(); + const timer = React.useRef | undefined>(undefined); React.useEffect(() => { timer.current = setTimeout(() => { diff --git a/packages/vkui/src/components/ModalRoot/ModalRoot.test.tsx b/packages/vkui/src/components/ModalRoot/ModalRoot.test.tsx index 22d1dd21f9..b7aead7790 100644 --- a/packages/vkui/src/components/ModalRoot/ModalRoot.test.tsx +++ b/packages/vkui/src/components/ModalRoot/ModalRoot.test.tsx @@ -223,10 +223,11 @@ describe(ModalRoot, () => { }); describe('focus', () => { - let modalPageRef: React.RefObject = React.createRef(); - let modalCardRef: React.RefObject = React.createRef(); - let modalPageWithInputRef: React.RefObject = React.createRef(); - let inputInnerModalPageRef: React.RefObject = + let modalPageRef: React.RefObject = React.createRef(); + let modalCardRef: React.RefObject = React.createRef(); + let modalPageWithInputRef: React.RefObject = + React.createRef(); + let inputInnerModalPageRef: React.RefObject = React.createRef(); let modals: React.ReactElement[] = []; diff --git a/packages/vkui/src/components/ModalRoot/ModalRootContext.tsx b/packages/vkui/src/components/ModalRoot/ModalRootContext.tsx index e60c954c3b..d842b13588 100644 --- a/packages/vkui/src/components/ModalRoot/ModalRootContext.tsx +++ b/packages/vkui/src/components/ModalRoot/ModalRootContext.tsx @@ -10,7 +10,9 @@ import type { ModalRootContextInterface } from './types'; * * @private */ -export const ModalRootOverlayContext = createContext>({ current: null }); +export const ModalRootOverlayContext = createContext>({ + current: null, +}); export const ModalRootContext = createContext({ updateModalHeight: noop, diff --git a/packages/vkui/src/components/PlatformProvider/PlatformProvider.test.tsx b/packages/vkui/src/components/PlatformProvider/PlatformProvider.test.tsx index 05510263f5..5b05cfe7c6 100644 --- a/packages/vkui/src/components/PlatformProvider/PlatformProvider.test.tsx +++ b/packages/vkui/src/components/PlatformProvider/PlatformProvider.test.tsx @@ -1,29 +1,18 @@ -'use no memo'; - -import { render } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; import { ConfigProvider } from '../ConfigProvider/ConfigProvider'; -import { - type ConfigProviderContextInterface, - useConfigProvider, -} from '../ConfigProvider/ConfigProviderContext'; +import { useConfigProvider } from '../ConfigProvider/ConfigProviderContext'; import { PlatformProvider } from './PlatformProvider'; describe('PlatformProvider', () => { it('override config context', () => { - let config: ConfigProviderContextInterface | undefined; - const ReadConfig = () => { - config = useConfigProvider(); - return null; - }; - - render( - - - - - , - ); + const { result } = renderHook(useConfigProvider, { + wrapper: ({ children }) => ( + + {children} + + ), + }); - expect(config).toEqual(expect.objectContaining({ platform: 'ios' })); + expect(result.current).toEqual(expect.objectContaining({ platform: 'ios' })); }); }); diff --git a/packages/vkui/src/components/Popper/Popper.tsx b/packages/vkui/src/components/Popper/Popper.tsx index 533973e7d3..6d8eaa86c0 100644 --- a/packages/vkui/src/components/Popper/Popper.tsx +++ b/packages/vkui/src/components/Popper/Popper.tsx @@ -81,7 +81,7 @@ export interface PopperCommonProps } export interface PopperProps extends PopperCommonProps { - targetRef: React.RefObject | VirtualElement; + targetRef: React.RefObject | VirtualElement; } /** diff --git a/packages/vkui/src/components/PullToRefresh/PullToRefresh.tsx b/packages/vkui/src/components/PullToRefresh/PullToRefresh.tsx index c514ed9b17..ab72742038 100644 --- a/packages/vkui/src/components/PullToRefresh/PullToRefresh.tsx +++ b/packages/vkui/src/components/PullToRefresh/PullToRefresh.tsx @@ -99,7 +99,7 @@ export const PullToRefresh = ({ } }, [touchDown, resetRefreshingState]); - const waitFetchingTimeoutId = React.useRef(); + const waitFetchingTimeoutId = React.useRef>(undefined); useIsomorphicLayoutEffect(() => { const prevIsFetching = prevIsFetchingRef.current; diff --git a/packages/vkui/src/components/Root/Root.tsx b/packages/vkui/src/components/Root/Root.tsx index 2439c14c3c..af2f192ec3 100644 --- a/packages/vkui/src/components/Root/Root.tsx +++ b/packages/vkui/src/components/Root/Root.tsx @@ -51,7 +51,7 @@ export const Root = ({ const { animate } = React.useContext(SplitColContext); const disableAnimation = !transitionMotionEnabled || !animate; - const views = React.Children.toArray(children) as React.ReactElement[]; + const views = React.Children.toArray(children) as Array>; const [{ prevView, activeView, transition, isBack }, _setState] = React.useState({ activeView: _activeView, @@ -127,7 +127,9 @@ export const Root = ({ return (
viewId && (viewNodes[viewId] = e)} + ref={(e) => { + viewId && (viewNodes[viewId] = e); + }} onAnimationEnd={isTransitionTarget ? onAnimationEnd : undefined} className={classNames( styles.view, diff --git a/packages/vkui/src/components/SegmentedControl/SegmentedControl.tsx b/packages/vkui/src/components/SegmentedControl/SegmentedControl.tsx index e642ddff4d..4adec99f86 100644 --- a/packages/vkui/src/components/SegmentedControl/SegmentedControl.tsx +++ b/packages/vkui/src/components/SegmentedControl/SegmentedControl.tsx @@ -25,7 +25,7 @@ export interface SegmentedControlOptionInterface * Рекомендуется использовать только иконки с размером 20 */ before?: React.ReactNode; - label: React.ReactChild; + label: React.ReactNode; value: SegmentedControlValue; } diff --git a/packages/vkui/src/components/Skeleton/Skeleton.tsx b/packages/vkui/src/components/Skeleton/Skeleton.tsx index 5b0c4619cc..4f6fb5e6c0 100644 --- a/packages/vkui/src/components/Skeleton/Skeleton.tsx +++ b/packages/vkui/src/components/Skeleton/Skeleton.tsx @@ -62,7 +62,7 @@ function useSkeletonSyncAnimation(disableAnimation: boolean, duration = 1.5) { /** * Вычисляет позицию скелетона */ -function useSkeletonPosition(rootRef: React.MutableRefObject) { +function useSkeletonPosition(rootRef: React.RefObject) { const { document, window } = useDOM(); const [[skeletonGradientLeft, prevSkeletonGradientLeft], setSkeletonGradientLeft] = useStateWithPrev('0'); diff --git a/packages/vkui/src/components/Snackbar/Snackbar.tsx b/packages/vkui/src/components/Snackbar/Snackbar.tsx index 8eef0b1444..556dc1ff17 100644 --- a/packages/vkui/src/components/Snackbar/Snackbar.tsx +++ b/packages/vkui/src/components/Snackbar/Snackbar.tsx @@ -112,7 +112,7 @@ export const Snackbar: React.FC & { Basic: typeof Basic } = ({ const shiftDataRef = React.useRef(null); const rafRef = React.useRef | null>(null); - const closeTimeoutIdRef = React.useRef>(); + const closeTimeoutIdRef = React.useRef | undefined>(undefined); const mediaQueries = useMediaQueries(); const [animationState, animationHandlers] = useCSSKeyframesAnimationController( open ? 'enter' : 'exit', diff --git a/packages/vkui/src/components/SplitCol/SplitColContext.tsx b/packages/vkui/src/components/SplitCol/SplitColContext.tsx index ca4050d9e6..6021c9cc75 100644 --- a/packages/vkui/src/components/SplitCol/SplitColContext.tsx +++ b/packages/vkui/src/components/SplitCol/SplitColContext.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; export interface SplitColContextProps { - colRef: React.RefObject | null; + colRef: React.RefObject | null; animate: boolean; } diff --git a/packages/vkui/src/components/Textarea/useResizeTextarea.ts b/packages/vkui/src/components/Textarea/useResizeTextarea.ts index 0781353c28..f549a5d88d 100644 --- a/packages/vkui/src/components/Textarea/useResizeTextarea.ts +++ b/packages/vkui/src/components/Textarea/useResizeTextarea.ts @@ -3,9 +3,9 @@ import * as React from 'react'; export function useResizeTextarea( onResize: ((el: HTMLTextAreaElement) => void) | undefined, grow: boolean, -): readonly [React.RefObject, () => void] { - const elementRef = React.useRef(null); - const currentScrollHeight = React.useRef(); +): readonly [React.RefObject, () => void] { + const elementRef = React.useRef(null); + const currentScrollHeight = React.useRef(undefined); const resizeElement = React.useCallback( (el: HTMLTextAreaElement) => { diff --git a/packages/vkui/src/components/View/View.tsx b/packages/vkui/src/components/View/View.tsx index 4e99750fcc..fc65b5bda3 100644 --- a/packages/vkui/src/components/View/View.tsx +++ b/packages/vkui/src/components/View/View.tsx @@ -116,8 +116,8 @@ export const View = ({ const prevSwipeBackPrevPanel = usePrevious(swipeBackPrevPanel); const prevOnTransition = usePrevious(onTransition); - const panels = (React.Children.toArray(children) as React.ReactElement[]).filter( - (panel: React.ReactElement) => { + const panels = (React.Children.toArray(children) as Array>).filter( + (panel) => { const panelId = getNavId(panel.props, warn); return ( @@ -325,7 +325,9 @@ export const View = ({ !prevSwipingBack && !prevBrowserSwipe ) { - const firstLayerId = (React.Children.toArray(children) as React.ReactElement[]) + const firstLayerId = ( + React.Children.toArray(children) as Array> + ) .map((panel) => getNavId(panel.props, warn)) .find((id) => id === prevActivePanel || id === activePanelProp); @@ -459,7 +461,7 @@ export const View = ({ onEnd={iOSSwipeBackSimulationEnabled ? handleTouchEndForIOSSwipeBackSimulation : undefined} >
- {panels.map((panel: React.ReactElement) => { + {panels.map((panel) => { const panelId = getNavId(panel.props, warn); const isPanelActive = panelId === activePanel; @@ -496,7 +498,9 @@ export const View = ({ )} onTransitionEnd={isSwipeBackTarget ? handleSwipeBackTargetTransitionEnd : undefined} onAnimationEnd={isAnimatedTarget ? handleAnimatedTargetAnimationEnd : undefined} - ref={(el) => panelId !== undefined && (panelNodes.current[panelId] = el)} + ref={(el) => { + panelId !== undefined && (panelNodes.current[panelId] = el); + }} style={calcPanelSwipeStyles(isSwipeBackPrev, isSwipeBackNext)} key={panelId} > diff --git a/packages/vkui/src/components/View/ViewInfinite.tsx b/packages/vkui/src/components/View/ViewInfinite.tsx index ebff3fcb93..4bb480afcc 100644 --- a/packages/vkui/src/components/View/ViewInfinite.tsx +++ b/packages/vkui/src/components/View/ViewInfinite.tsx @@ -139,7 +139,7 @@ class ViewInfiniteComponent extends React.Component< } get panels() { - return React.Children.toArray(this.props.children) as React.ReactElement[]; + return React.Children.toArray(this.props.children) as Array>; } panelNodes: { [id: string]: HTMLDivElement | null } = {}; @@ -624,7 +624,7 @@ class ViewInfiniteComponent extends React.Component< } >
- {panels.map((panel: React.ReactElement) => { + {panels.map((panel) => { const panelId = getNavId(panel.props, warn); const isPrev = panelId === prevPanel || panelId === swipeBackPrevPanel; const compensateScroll = @@ -646,7 +646,9 @@ class ViewInfiniteComponent extends React.Component< swipeBackResult === 'fail' && styles.panelSwipeBackFailed, )} onAnimationEnd={isTransitionTarget ? this.transitionEndHandler : undefined} - ref={(el) => panelId !== undefined && (this.panelNodes[panelId] = el)} + ref={(el) => { + panelId !== undefined && (this.panelNodes[panelId] = el); + }} style={this.calcPanelSwipeStyles(panelId)} key={panelId} > diff --git a/packages/vkui/src/helpers/getMergedSameEventsByProps.ts b/packages/vkui/src/helpers/getMergedSameEventsByProps.ts index 526c6c7108..edbda79041 100644 --- a/packages/vkui/src/helpers/getMergedSameEventsByProps.ts +++ b/packages/vkui/src/helpers/getMergedSameEventsByProps.ts @@ -16,7 +16,7 @@ const isFunctionExistInProps = >( * @private */ export const getMergedSameEventsByProps = < - T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor, + T extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor, MainProps extends React.ComponentProps, OnlyFnPropsByMain extends PickOnlyFunctionProps, >( diff --git a/packages/vkui/src/hooks/useDateInput.ts b/packages/vkui/src/hooks/useDateInput.ts index 33565cc36d..93a88b4ec7 100644 --- a/packages/vkui/src/hooks/useDateInput.ts +++ b/packages/vkui/src/hooks/useDateInput.ts @@ -6,7 +6,7 @@ import { useGlobalEventListener } from './useGlobalEventListener'; export interface UseDateInputDependencies { maxElement: number; - refs: Array>; + refs: Array>; autoFocus?: boolean; disabled?: boolean; value?: D; @@ -33,8 +33,8 @@ export function useDateInput({ value, onCalendarOpenChanged, }: UseDateInputDependencies): { - rootRef: React.RefObject; - calendarRef: React.RefObject; + rootRef: React.RefObject; + calendarRef: React.RefObject; open: boolean; openCalendar: () => void; closeCalendar: () => void; @@ -48,8 +48,8 @@ export function useDateInput({ } { const { document } = useDOM(); const { value: open, setTrue: openCalendar, setFalse: closeCalendar } = useBooleanState(false); - const rootRef = React.useRef(null); - const calendarRef = React.useRef(null); + const rootRef = React.useRef(null); + const calendarRef = React.useRef(null); const [internalValue, setInternalValue] = React.useState([]); const [focusedElement, setFocusedElement] = React.useState(null); const { window } = useDOM(); diff --git a/packages/vkui/src/hooks/useDirection.ts b/packages/vkui/src/hooks/useDirection.ts index 07012d30cb..80a0116fb0 100644 --- a/packages/vkui/src/hooks/useDirection.ts +++ b/packages/vkui/src/hooks/useDirection.ts @@ -35,11 +35,11 @@ type WritingMode = 'horizontal-tb' | 'vertical-rl' | 'vertical-lr'; * ``` */ export function useDirection(): [ - React.RefObject, + React.RefObject, Direction | undefined, WritingMode | undefined, ] { - const ref = React.useRef(null); + const ref = React.useRef(null); const [direction, setDirection] = React.useState(undefined); const [writingMode, setWritingMode] = React.useState(undefined); diff --git a/packages/vkui/src/hooks/useDraggableWithDomApi/types.ts b/packages/vkui/src/hooks/useDraggableWithDomApi/types.ts index e58f799423..af5f956de8 100644 --- a/packages/vkui/src/hooks/useDraggableWithDomApi/types.ts +++ b/packages/vkui/src/hooks/useDraggableWithDomApi/types.ts @@ -25,7 +25,7 @@ export type SiblingItem = { export type SwappedItemRange = { from: number; to: number }; export interface UseDraggableProps { - elRef: React.MutableRefObject; + elRef: React.RefObject; onDragFinish?: (value: SwappedItemRange) => void; } diff --git a/packages/vkui/src/hooks/useEnsuredControl.ts b/packages/vkui/src/hooks/useEnsuredControl.ts index 02642eaadb..2944f92d27 100644 --- a/packages/vkui/src/hooks/useEnsuredControl.ts +++ b/packages/vkui/src/hooks/useEnsuredControl.ts @@ -50,7 +50,7 @@ export function useCustomEnsuredControl({ const isControlled = value !== undefined; const [localValue, setLocalValue] = React.useState(defaultValue); - const preservedControlledValueRef = React.useRef(); + const preservedControlledValueRef = React.useRef(undefined); useIsomorphicLayoutEffect(() => { preservedControlledValueRef.current = value; }); diff --git a/packages/vkui/src/hooks/useExternRef.test.tsx b/packages/vkui/src/hooks/useExternRef.test.tsx index 43ec13ce5e..ffbd0d8101 100644 --- a/packages/vkui/src/hooks/useExternRef.test.tsx +++ b/packages/vkui/src/hooks/useExternRef.test.tsx @@ -18,7 +18,7 @@ describe(useExternRef, () => { render(); }); it('keeps inner ref.current up-to-date', () => { - let firstRef: React.MutableRefObject | undefined = undefined; + let firstRef: React.RefObject | undefined = undefined; let counter = 0; const RefForwarder = (props: HasRef) => { const ref = useExternRef(props.getRef); @@ -27,7 +27,19 @@ describe(useExternRef, () => { ref.current = counter; return null; }; - render( null} />).rerender( null} />); + render( + { + null; + }} + />, + ).rerender( + { + null; + }} + />, + ); expect((firstRef as any)?.current).toBe(counter); }); }); diff --git a/packages/vkui/src/hooks/useExternRef.ts b/packages/vkui/src/hooks/useExternRef.ts index 302ca0c7b6..5f4111ce6a 100644 --- a/packages/vkui/src/hooks/useExternRef.ts +++ b/packages/vkui/src/hooks/useExternRef.ts @@ -1,7 +1,7 @@ import * as React from 'react'; import { setRef } from '../lib/utils'; -class ExternalRef implements React.MutableRefObject { +class ExternalRef implements React.RefObject { #element: T | null = null; readonly #externRefs = new Set>(); @@ -45,7 +45,7 @@ class ExternalRef implements React.MutableRefObject { export function useExternRef( ...externRefs: Array | undefined | false> -): React.MutableRefObject { +): React.RefObject { const ref = React.useRef | null>(null); if (ref.current === null) { ref.current = new ExternalRef(externRefs); diff --git a/packages/vkui/src/hooks/useFocusTrap.ts b/packages/vkui/src/hooks/useFocusTrap.ts index a79c1684e7..b234eb27f8 100644 --- a/packages/vkui/src/hooks/useFocusTrap.ts +++ b/packages/vkui/src/hooks/useFocusTrap.ts @@ -112,7 +112,7 @@ export type UseFocusTrapProps = { * @private */ export const useFocusTrap = ( - ref: RefObject, + ref: RefObject, { mount = true, disabled = false, diff --git a/packages/vkui/src/hooks/useGlobalOnClickOutside.ts b/packages/vkui/src/hooks/useGlobalOnClickOutside.ts index 94c182b851..fb198ba835 100644 --- a/packages/vkui/src/hooks/useGlobalOnClickOutside.ts +++ b/packages/vkui/src/hooks/useGlobalOnClickOutside.ts @@ -8,7 +8,7 @@ import { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect'; * @private */ export const useGlobalOnClickOutside = < - T extends React.RefObject | undefined | null, + T extends React.RefObject | undefined | null, ElementType extends Element = Element, >( callback: (event: MouseEvent) => void, diff --git a/packages/vkui/src/hooks/useKeyboardInputTracker.ts b/packages/vkui/src/hooks/useKeyboardInputTracker.ts index 74da859edc..0bdade38e9 100644 --- a/packages/vkui/src/hooks/useKeyboardInputTracker.ts +++ b/packages/vkui/src/hooks/useKeyboardInputTracker.ts @@ -29,7 +29,7 @@ const EVENT_OPTIONS = { * * @private */ -export function useKeyboardInputTracker(): React.MutableRefObject { +export function useKeyboardInputTracker(): React.RefObject { const { document } = useDOM(); const keyboardFocusingStartedRef = React.useRef(false); diff --git a/packages/vkui/src/hooks/useMutationObserver.ts b/packages/vkui/src/hooks/useMutationObserver.ts index e60981f52c..9156a5326e 100644 --- a/packages/vkui/src/hooks/useMutationObserver.ts +++ b/packages/vkui/src/hooks/useMutationObserver.ts @@ -3,7 +3,7 @@ import { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect'; import { useStableCallback } from './useStableCallback'; export const useMutationObserver = ( - ref: React.MutableRefObject | React.RefObject | null, + ref: React.RefObject | null, callback: () => void, ): void => { const stableCallback = useStableCallback(callback); diff --git a/packages/vkui/src/hooks/useNativeFormResetListener.ts b/packages/vkui/src/hooks/useNativeFormResetListener.ts index 9c3e3b8a18..fb432df172 100644 --- a/packages/vkui/src/hooks/useNativeFormResetListener.ts +++ b/packages/vkui/src/hooks/useNativeFormResetListener.ts @@ -2,7 +2,7 @@ import type * as React from 'react'; import { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect'; export const useNativeFormResetListener = ( - ref: React.RefObject, + ref: React.RefObject, handler: (event: Event) => void, ): void => { useIsomorphicLayoutEffect(() => { diff --git a/packages/vkui/src/hooks/usePatchChildren.test.tsx b/packages/vkui/src/hooks/usePatchChildren.test.tsx index 239de5993b..cac129c756 100644 --- a/packages/vkui/src/hooks/usePatchChildren.test.tsx +++ b/packages/vkui/src/hooks/usePatchChildren.test.tsx @@ -19,8 +19,8 @@ const ComponentWithForwardRef = React.forwardRef< >((props, ref) =>
); type WrapperWithUsePatchChildrenRefProps = { - childRef?: React.RefObject; - refHook?: React.RefObject; + childRef?: React.RefObject; + refHook?: React.RefObject; } & React.HTMLAttributes; const WrapperWithUsePatchChildrenRef = ({ diff --git a/packages/vkui/src/hooks/usePatchChildren.ts b/packages/vkui/src/hooks/usePatchChildren.ts index d030c71525..5b3f6bb7d1 100644 --- a/packages/vkui/src/hooks/usePatchChildren.ts +++ b/packages/vkui/src/hooks/usePatchChildren.ts @@ -19,14 +19,7 @@ type InjectProps = Omit, keyof React.DOMAttributes type ExpectedReactElement = React.ReactElement & React.DOMAttributes>; -type ChildrenElement = - | ExpectedReactElement - | React.ReactText - | React.ReactFragment - | React.ReactPortal - | boolean - | null - | undefined; +type ChildrenElement = ExpectedReactElement | React.ReactNode; /** * Хук позволяет пропатчить переданный компонент так, чтобы можно было получить ссылку на его @@ -55,7 +48,7 @@ export const usePatchChildren = ( children?: ChildrenElement, injectProps?: InjectProps, externRef?: React.Ref, -): [React.MutableRefObject, ChildrenElement | undefined] => { +): [React.RefObject, ChildrenElement | undefined] => { const isValidElementResult = isValidNotReactFragmentElement(children); const isDOMTypeElementResult = isValidElementResult && diff --git a/packages/vkui/src/hooks/usePrevious.ts b/packages/vkui/src/hooks/usePrevious.ts index 05014a6a0b..eeda071c43 100644 --- a/packages/vkui/src/hooks/usePrevious.ts +++ b/packages/vkui/src/hooks/usePrevious.ts @@ -4,7 +4,7 @@ import * as React from 'react'; * @deprecated постарайтесь избавится от этого хука или используйте `useStateWithPrev` */ export function usePrevious(value: T): T | undefined { - const ref = React.useRef(); + const ref = React.useRef(undefined); React.useEffect(() => { ref.current = value; diff --git a/packages/vkui/src/hooks/useResizeObserver.ts b/packages/vkui/src/hooks/useResizeObserver.ts index c71484e7a1..d1a14885b4 100644 --- a/packages/vkui/src/hooks/useResizeObserver.ts +++ b/packages/vkui/src/hooks/useResizeObserver.ts @@ -7,7 +7,7 @@ import { useStableCallback } from './useStableCallback'; * Хук вызывает переданный коллбэк при изменении размеров элемента. */ export function useResizeObserver( - ref: React.MutableRefObject | React.RefObject | null, + ref: React.RefObject | null, callback: (element: HTMLElement) => void, ): void { const stableCallback = useStableCallback(callback); diff --git a/packages/vkui/src/hooks/useStateWithPrev.ts b/packages/vkui/src/hooks/useStateWithPrev.ts index c7bc6debc1..578ea6e32d 100644 --- a/packages/vkui/src/hooks/useStateWithPrev.ts +++ b/packages/vkui/src/hooks/useStateWithPrev.ts @@ -35,9 +35,5 @@ function reducer( export function useStateWithPrev( initialState: T | (() => T), ): [[T, T | undefined], React.Dispatch>] { - return React.useReducer>, undefined>( - reducer, - undefined, - () => initializer(initialState), - ); + return React.useReducer(reducer, undefined, () => initializer(initialState)); } diff --git a/packages/vkui/src/hooks/useSyncHTMLWithBaseVKUIClasses.ts b/packages/vkui/src/hooks/useSyncHTMLWithBaseVKUIClasses.ts index 30f5f5ba15..a5d613592d 100644 --- a/packages/vkui/src/hooks/useSyncHTMLWithBaseVKUIClasses.ts +++ b/packages/vkui/src/hooks/useSyncHTMLWithBaseVKUIClasses.ts @@ -10,7 +10,7 @@ export function useSyncHTMLWithBaseVKUIClasses({ enable, layout, }: { - appRootRef: React.RefObject; + appRootRef: React.RefObject; mode: AppRootMode; layout?: AppRootLayout; enable: boolean; diff --git a/packages/vkui/src/hooks/useSyncHTMLWithTokens.ts b/packages/vkui/src/hooks/useSyncHTMLWithTokens.ts index 382d934822..5f7118f871 100644 --- a/packages/vkui/src/hooks/useSyncHTMLWithTokens.ts +++ b/packages/vkui/src/hooks/useSyncHTMLWithTokens.ts @@ -5,7 +5,7 @@ export function useSyncHTMLWithTokens({ appRootRef, enable, }: { - appRootRef: React.RefObject; + appRootRef: React.RefObject; enable: boolean; }) { const tokenClassName = useTokensClassName(); diff --git a/packages/vkui/src/lib/animation/useCSSTransition.ts b/packages/vkui/src/lib/animation/useCSSTransition.ts index c194ae4665..9cdee2dd96 100644 --- a/packages/vkui/src/lib/animation/useCSSTransition.ts +++ b/packages/vkui/src/lib/animation/useCSSTransition.ts @@ -32,7 +32,7 @@ export type UseCSSTransitionOptions = { export type UseCSSTransition = [ state: UseCSSTransitionState, { - ref: React.RefObject; + ref: React.RefObject; onTransitionEnd?: TransitionEventHandler; }, ]; diff --git a/packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts b/packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts index 182cd2952f..091b0e7a76 100644 --- a/packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts +++ b/packages/vkui/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts @@ -74,7 +74,7 @@ export const useFloatingWithInteractions = const blockMouseEnterRef = React.useRef(false); const blockFocusRef = React.useRef(false); - const blurTimeoutRef = React.useRef>(); + const blurTimeoutRef = React.useRef | undefined>(undefined); const handleCloseOnReferenceClickOutsideDisabled = disabled || disableCloseOnClickOutside || willBeHide || !shownLocalState.shown; diff --git a/packages/vkui/src/lib/utils.ts b/packages/vkui/src/lib/utils.ts index a5ef07940a..5162a19eff 100644 --- a/packages/vkui/src/lib/utils.ts +++ b/packages/vkui/src/lib/utils.ts @@ -14,12 +14,12 @@ export function setRef(element: T, ref?: React.Ref): void { if (typeof ref === 'function') { ref(element); } else { - (ref as React.MutableRefObject).current = element; + (ref as React.RefObject).current = element; } } } -export function multiRef(...refs: Array | undefined>): React.RefObject { +export function multiRef(...refs: Array | undefined>): React.RefObject { let current: T | null = null; return { get current() { diff --git a/styleguide/Components/Frame/Frame.js b/styleguide/Components/Frame/Frame.js index ffa778add4..b3dcf3274d 100644 --- a/styleguide/Components/Frame/Frame.js +++ b/styleguide/Components/Frame/Frame.js @@ -1,5 +1,4 @@ import * as React from 'react'; -import PropTypes from 'prop-types'; import ReactFrame, { useFrame } from 'react-frame-component'; import { PanelSpinner } from '@vkui'; import { DOMContext } from '@vkui/lib/dom'; @@ -89,10 +88,3 @@ export const Frame = ({ children, style, colorSchemeOptions, themeName }) => { ); }; - -Frame.propTypes = { - style: PropTypes.shape({ - width: PropTypes.number.isRequired, - height: PropTypes.number.isRequired, - }), -}; diff --git a/styleguide/Components/Section/SectionRenderer.js b/styleguide/Components/Section/SectionRenderer.js index 0aa67fd82e..b0bf3e2274 100644 --- a/styleguide/Components/Section/SectionRenderer.js +++ b/styleguide/Components/Section/SectionRenderer.js @@ -1,7 +1,6 @@ import * as React from 'react'; import Markdown from '@rsg-components/Markdown'; import SectionHeading from '@rsg-components/SectionHeading'; -import PropTypes from 'prop-types'; export const SectionRenderer = (allProps) => { const { @@ -38,17 +37,4 @@ export const SectionRenderer = (allProps) => { ); }; -SectionRenderer.propTypes = { - name: PropTypes.string, - description: PropTypes.string, - slug: PropTypes.string.isRequired, - content: PropTypes.node, - contentTitle: PropTypes.string, - components: PropTypes.node, - sections: PropTypes.node, - isolated: PropTypes.bool, - depth: PropTypes.number.isRequired, - pagePerSection: PropTypes.bool, -}; - export default SectionRenderer; diff --git a/styleguide/Components/Section/index.js b/styleguide/Components/Section/index.js index fb8241fee9..2f9e043faf 100644 --- a/styleguide/Components/Section/index.js +++ b/styleguide/Components/Section/index.js @@ -3,7 +3,6 @@ import Components from '@rsg-components/Components'; import { useStyleGuideContext } from '@rsg-components/Context'; import Examples from '@rsg-components/Examples'; import Sections from '@rsg-components/Sections'; -import PropTypes from 'prop-types'; import SectionRenderer from './SectionRenderer'; const Section = ({ section, depth }) => { @@ -55,9 +54,4 @@ const Section = ({ section, depth }) => { ); }; -Section.propTypes = { - section: PropTypes.any.isRequired, - depth: PropTypes.number.isRequired, -}; - export default Section; diff --git a/styleguide/package.json b/styleguide/package.json index 3fec9674d9..02fd3ee56c 100644 --- a/styleguide/package.json +++ b/styleguide/package.json @@ -11,7 +11,6 @@ }, "devDependencies": { "lodash-es": "^4.17.21", - "prop-types": "^15.8.1", "react": "*", "react-children-utilities": "^2.10.0", "react-docgen-typescript": "^2.2.2", diff --git a/styleguide/webpack.config.js b/styleguide/webpack.config.js index b4bb7be4ef..1079634713 100644 --- a/styleguide/webpack.config.js +++ b/styleguide/webpack.config.js @@ -19,9 +19,4 @@ module.exports = merge(webpackCommonConfig, { '@vkui': path.resolve(__dirname, `../${VKUI_PACKAGE.PATHS.SRC_DIR}`), }, }, - externals: [ - { - 'prop-types': 'prop-types', - }, - ], }); diff --git a/yarn.lock b/yarn.lock index 59fe3d5605..a7689599aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2059,7 +2059,6 @@ __metadata: resolution: "@project-docs/styleguide@workspace:styleguide" dependencies: lodash-es: "npm:^4.17.21" - prop-types: "npm:^15.8.1" react: "npm:*" react-children-utilities: "npm:^2.10.0" react-docgen-typescript: "npm:^2.2.2" @@ -3647,13 +3646,20 @@ __metadata: languageName: node linkType: hard -"@types/mdx@npm:^2.0.0": +"@types/mdx@npm:2.0.13": version: 2.0.13 resolution: "@types/mdx@npm:2.0.13" checksum: 10/b73ed5f08114879b9590dc6a9ee8b648643c57c708583cd24b2bc3cc8961361fc63139ac7e9291e7b3b6e6b45707749d01d6f9727ddec5533df75dc3b90871a4 languageName: node linkType: hard +"@types/mdx@patch:@types/mdx@npm%3A2.0.13#~/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch": + version: 2.0.13 + resolution: "@types/mdx@patch:@types/mdx@npm%3A2.0.13#~/.yarn/patches/@types-mdx-npm-2.0.13-52981f86f6.patch::version=2.0.13&hash=33b980" + checksum: 10/0a192f673424ac0c27cd05773bb5f3274b2cf351d1ba420f856ea1e114c2ad29d09a816e256a034a9388d3a2e8756a3169bfe55aeeca8614a323481d9de90969 + languageName: node + linkType: hard + "@types/mime@npm:^1": version: 1.3.5 resolution: "@types/mime@npm:1.3.5" @@ -3737,13 +3743,6 @@ __metadata: languageName: node linkType: hard -"@types/prop-types@npm:*": - version: 15.7.13 - resolution: "@types/prop-types@npm:15.7.13" - checksum: 10/8935cad87c683c665d09a055919d617fe951cb3b2d5c00544e3a913f861a2bd8d2145b51c9aa6d2457d19f3107ab40784c40205e757232f6a80cc8b1c815513c - languageName: node - linkType: hard - "@types/qs@npm:*": version: 6.9.17 resolution: "@types/qs@npm:6.9.17" @@ -3758,12 +3757,12 @@ __metadata: languageName: node linkType: hard -"@types/react-dom@npm:^18.3.1": - version: 18.3.1 - resolution: "@types/react-dom@npm:18.3.1" +"@types/react-dom@npm:^19.0.1": + version: 19.0.1 + resolution: "@types/react-dom@npm:19.0.1" dependencies: "@types/react": "npm:*" - checksum: 10/33f9ba79b26641ddf00a8699c30066b7e3573ab254e97475bf08f82fab83a6d3ce8d4ebad86afeb49bb8df3374390a9ba93125cece33badc4b3e8f7eac3c84d8 + checksum: 10/59d0704e445a3e0d034ef016c92dc1bbec0ba6c1af084bf6de18f0ac3abd18a632961b7fd48668c519137d0bd7bfa77a8135a66c2725d4b7f68b830be263a564 languageName: node linkType: hard @@ -3776,13 +3775,12 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:*, @types/react@npm:^18.3.12": - version: 18.3.12 - resolution: "@types/react@npm:18.3.12" +"@types/react@npm:*, @types/react@npm:^19.0.1": + version: 19.0.1 + resolution: "@types/react@npm:19.0.1" dependencies: - "@types/prop-types": "npm:*" csstype: "npm:^3.0.2" - checksum: 10/c9bbdfeacd5347d2240e0d2cb5336bc57dbc1b9ff557b6c4024b49df83419e4955553518169d3736039f1b62608e15b35762a6c03d49bd86e33add4b43b19033 + checksum: 10/930dd4904047059c48ae64a90fc5e8078b5bac0a14c9d927917e5a07e88e4e5073ddc944cbde90a955f9f815c23b7112caea63e407bc423913073bedecb097aa languageName: node linkType: hard @@ -4341,8 +4339,8 @@ __metadata: "@types/jest": "npm:^29.5.14" "@types/jest-axe": "npm:^3.5.9" "@types/node": "npm:^22.10.1" - "@types/react": "npm:^18.3.12" - "@types/react-dom": "npm:^18.3.1" + "@types/react": "npm:^19.0.1" + "@types/react-dom": "npm:^19.0.1" "@types/webpack": "npm:^5.28.5" "@typescript-eslint/eslint-plugin": "npm:^7.5.0" "@typescript-eslint/parser": "npm:^7.5.0" @@ -4461,8 +4459,8 @@ __metadata: storybook: "npm:8.4.7" ts-node: "npm:*" peerDependencies: - react: ^18.2.0 - react-dom: ^18.2.0 + react: ^18.2.0 || ^19.0.0 + react-dom: ^18.2.0 || ^19.0.0 languageName: unknown linkType: soft