Skip to content

Commit

Permalink
feat: add use client directive (#7702)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud authored Oct 3, 2024
1 parent 8452a69 commit 6b5a24f
Show file tree
Hide file tree
Showing 163 changed files with 358 additions and 34 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-compiler": "0.0.0-experimental-56229e1-20240813",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-server-components": "^1.2.0",
"eslint-plugin-unicorn": "^55.0.0",
"husky": "^9.1.6",
"jest": "^29.7.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/vkui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (!E2E_TEST || !E2E_PLAYGROUND_HELPERS) {

module.exports = {
root: false,
extends: ['plugin:react-hooks/recommended'],
extends: ['plugin:react-hooks/recommended', 'plugin:react-server-components/recommended'],
plugins: ['import', '@project-tools/vkui', 'unicorn'],
parserOptions: {
project: './tsconfig.eslint.json',
Expand Down Expand Up @@ -177,6 +177,7 @@ module.exports = {
],
},
],
'react-server-components/use-client': 'off',
},
},

Expand All @@ -186,6 +187,7 @@ module.exports = {
'no-restricted-properties': 'off',
'no-restricted-globals': 'off',
'react/display-name': 'off',
'react-server-components/use-client': 'off',
},
},

Expand Down Expand Up @@ -215,6 +217,7 @@ module.exports = {
],
},
],
'react-server-components/use-client': 'off',
},
},

Expand Down Expand Up @@ -244,6 +247,7 @@ module.exports = {
],
},
],
'react-server-components/use-client': 'off',
},
},

Expand All @@ -252,6 +256,7 @@ module.exports = {
rules: {
'import/no-default-export': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'react-server-components/use-client': 'off',
},
},
],
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { useCustomEnsuredControl } from '../../hooks/useEnsuredControl';
import { useObjectMemo } from '../../hooks/useObjectMemo';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useExternRef } from '../../hooks/useExternRef';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Accordion/AccordionSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon24ChevronDown, Icon24ChevronUp } from '@vkontakte/icons';
import { callMultiple } from '../../lib/callMultiple';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/ActionSheet/ActionSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { noop } from '@vkontakte/vkjs';
import { useAdaptivityWithJSMediaQueries } from '../../hooks/useAdaptivityWithJSMediaQueries';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivityWithJSMediaQueries } from '../../hooks/useAdaptivityWithJSMediaQueries';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivityWithJSMediaQueries } from '../../hooks/useAdaptivityWithJSMediaQueries';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames, noop } from '@vkontakte/vkjs';
import { useAdaptivityWithJSMediaQueries } from '../../hooks/useAdaptivityWithJSMediaQueries';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { useAdaptivityConditionalRender } from '../../hooks/useAdaptivityConditionalRender';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { getSizeX, isCompactByViewHeight, isCompactByViewWidth } from '../../lib/adaptivity';
import type { HasChildren } from '../../types';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon20Cancel } from '@vkontakte/icons';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Alert/AlertAction.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { usePlatform } from '../../hooks/usePlatform';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Alert/AlertActions.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { usePlatform } from '../../hooks/usePlatform';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Alert/AlertTypography.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { usePlatform } from '../../hooks/usePlatform';
import type { HasChildren } from '../../types';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/AppRoot/AppRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/AppRoot/AppRootPortal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { useAppearance } from '../../hooks/useAppearance';
import { useIsClient } from '../../hooks/useIsClient';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/AppRoot/ScrollContext.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { noop } from '@vkontakte/vkjs';
import { clamp } from '../../helpers/math';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { ImageBase, type ImageBaseBadgeProps, ImageBaseContext } from '../../ImageBase/ImageBase';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import {
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon24Cancel, Icon24Chevron, Icon24Dismiss, Icon24DismissDark } from '@vkontakte/icons';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/BaseGallery/BaseGallery.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivityHasPointer } from '../../hooks/useAdaptivityHasPointer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivityHasPointer } from '../../../hooks/useAdaptivityHasPointer';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { isSameDay, isSameMonth } from 'date-fns';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CalendarDay/CalendarDay.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { ENABLE_KEYBOARD_INPUT_EVENT_NAME } from '../../hooks/useKeyboardInputTracker';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CalendarDays/CalendarDays.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { isSameDay, isSameMonth } from 'date-fns';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import {
Icon12Dropdown,
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CalendarRange/CalendarRange.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import {
addMonths,
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CalendarTime/CalendarTime.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { setHours, setMinutes } from 'date-fns';
import { AdaptivityProvider } from '../AdaptivityProvider/AdaptivityProvider';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CardGrid/CardGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import type { HasComponent, HTMLAttributesWithRootRef } from '../../types';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CardScroll/CardScroll.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useDOM } from '../../lib/dom';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Cell/Cell.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import type { SwappedItemRange } from '../../hooks/useDraggableWithDomApi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import {
Icon20CheckBoxOff,
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Cell/CellDragger/CellDragger.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Icon24Reorder, Icon24ReorderIos } from '@vkontakte/icons';
import { classNames } from '@vkontakte/vkjs';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import {
Icon20CheckBoxIndetermanate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../../hooks/useAdaptivity';
import { Tappable } from '../../Tappable/Tappable';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/ChipsInput/ChipsInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useExternRef } from '../../hooks/useExternRef';
import { ChipsInputBase } from '../ChipsInputBase/ChipsInputBase';
import type { ChipOption, ChipsInputBaseProps } from '../ChipsInputBase/types';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/ChipsInputBase/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon16Cancel } from '@vkontakte/icons';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { isHTMLElement } from '@vkontakte/vkui-floating-ui/utils/dom';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/ChipsSelect/ChipsSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { type MouseEventHandler } from 'react';
import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Clickable/Clickable.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames, noop } from '@vkontakte/vkjs';
import { useFocusVisible } from '../../hooks/useFocusVisible';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { IconAppearanceProvider } from '@vkontakte/icons';
import { useAutoDetectAppearance } from '../../hooks/useAutoDetectAppearance';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { useObjectMemo } from '../../hooks/useObjectMemo';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import type { HTMLAttributesWithRootRef } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CustomScrollView/ScrollX.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { stopPropagation } from '../../lib/utils';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CustomScrollView/ScrollY.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { stopPropagation } from '../../lib/utils';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/CustomSelect/CustomSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames, debounce } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon16Cancel } from '@vkontakte/icons';
import { stopPropagation } from '../../lib/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon16Done } from '@vkontakte/icons';
import { classNames, hasReactNode } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/DateInput/DateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon16Clear, Icon20CalendarOutline } from '@vkontakte/icons';
import { classNames } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { leadingZero } from '@vkontakte/vkjs';
import { clamp } from '../../helpers/math';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Icon16Clear, Icon20CalendarOutline } from '@vkontakte/icons';
import { classNames } from '@vkontakte/vkjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/DropZone/DropZone.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { callMultiple } from '../../lib/callMultiple';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/DropdownIcon/DropdownIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import {
Icon20ChevronUp,
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Epic/Epic.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { getNavId } from '../../lib/getNavId';
Expand Down
2 changes: 2 additions & 0 deletions packages/vkui/src/components/Epic/ScrollSaver.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { useIsomorphicLayoutEffect } from '../../lib/useIsomorphicLayoutEffect';
import type { HasChildren } from '../../types';
Expand Down
Loading

0 comments on commit 6b5a24f

Please sign in to comment.