From 7e855e24b7d26e60ce7b2ed2bcf096fda5444bc1 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Tue, 13 Oct 2026 17:24:51 +0300 Subject: [PATCH 1/9] feat!: update uikit --- .storybook/decorators/withMobile.tsx | 12 -- .storybook/decorators/withTheme.tsx | 14 +- .storybook/preview.tsx | 3 +- README.md | 25 ++- jest.config.js | 4 +- package-lock.json | 153 +++++++----------- package.json | 13 +- src/components/AdaptiveTabs/AdaptiveTabs.tsx | 48 +++--- src/components/AdaptiveTabs/README.md | 2 +- .../__stories__/AdaptiveTabsItems.tsx | 4 +- .../ChangelogDialog/ChangelogDialog.tsx | 9 +- src/components/ChangelogDialog/README.md | 33 ++-- .../__stories__/ChangelogDialog.stories.tsx | 18 ++- .../__tests__/ChangelogDialog.test.tsx | 33 ++-- src/components/ConfirmDialog/README.md | 24 +-- .../__stories__/ConfirmDialog.stories.tsx | 2 +- .../CookieConsent/ConsentManager.ts | 2 +- .../__stories__/CookieConsent.stories.tsx | 3 - .../__tests__/ConsentManager.test.ts | 24 +++ .../components/ConsentPopup/ConsentPopup.tsx | 6 +- .../components/ConsentPopup/types.ts | 2 - .../MobileGalleryActions.tsx | 25 ++- src/components/Gallery/i18n/en.json | 3 +- src/components/Gallery/i18n/ru.json | 3 +- src/components/ItemSelector/ItemSelector.scss | 27 +++- src/components/ItemSelector/ItemSelector.tsx | 135 +++++++++++++--- src/components/ItemSelector/README.md | 5 +- .../__stories__/ItemSelector.stories.tsx | 12 -- .../__tests__/ItemSelector.test.tsx | 65 ++++++++ src/components/Notification/Notification.tsx | 2 +- .../Notification/NotificationWithSwipe.tsx | 2 +- .../__stories__/Notifications.stories.tsx | 14 +- .../Notifications/__stories__/mockData.tsx | 27 ++-- .../OnboardingMenu/OnboardingMenu.scss | 13 ++ .../OnboardingMenu/OnboardingMenu.tsx | 5 +- src/components/PromoSheet/PromoSheet.scss | 14 ++ src/components/PromoSheet/PromoSheet.tsx | 20 +-- src/components/PromoSheet/README.md | 30 ++-- .../PromoSheet/__tests__/PromoSheet.test.tsx | 20 ++- src/components/Reactions/Reaction.tsx | 4 +- src/components/Reactions/Reactions.tsx | 9 +- .../Reactions/ReactionsContainer.tsx | 2 +- .../__stories__/Reactions.stories.tsx | 20 +-- .../Reactions/__tests__/mock/mockHooks.tsx | 2 +- .../ShareListItem/ShareListItem.tsx | 4 +- src/components/SharePopover/SharePopover.scss | 3 +- src/components/SharePopover/SharePopover.tsx | 80 +++++---- .../__stories__/SharePopover.stories.tsx | 6 - .../__tests__/SharePopover.test.tsx | 52 ++++++ src/components/StoreBadge/README.md | 25 ++- src/components/StoreBadge/StoreBadge.tsx | 5 +- src/components/Stories/README.md | 2 + src/components/Stories/Stories.tsx | 14 +- .../Stories/__stories__/Stories.stories.tsx | 4 +- .../StoriesLayout/StoriesLayout.tsx | 2 +- src/components/StoriesGroup/README.md | 2 + src/components/StoriesGroup/StoriesGroup.tsx | 12 +- .../StoriesPreview/StoriesPreview.tsx | 8 +- .../TokenizedInput/TokenizedInput.scss | 22 +-- .../__stories__/DebounceShowcaseTemplate.tsx | 2 +- .../__stories__/MultipleInputTemplate.tsx | 2 +- .../Suggestions/SuggestionsList.tsx | 34 ++-- .../__tests__/SuggestionsList.test.tsx | 42 +++++ .../hooks/__tests__/useSuggestions.test.tsx | 30 ++++ .../Suggestions/hooks/useSuggestions.ts | 2 +- .../hooks/useTokenizedInputInfo.ts | 2 +- src/components/TokenizedInput/i18n/en.json | 3 +- src/components/TokenizedInput/i18n/ru.json | 3 +- .../TokenizedInput/undoredo-manager.ts | 2 +- test-utils/utils.tsx | 11 +- 70 files changed, 801 insertions(+), 466 deletions(-) delete mode 100644 .storybook/decorators/withMobile.tsx create mode 100644 src/components/CookieConsent/__tests__/ConsentManager.test.ts create mode 100644 src/components/ItemSelector/__tests__/ItemSelector.test.tsx create mode 100644 src/components/SharePopover/__tests__/SharePopover.test.tsx create mode 100644 src/components/TokenizedInput/components/Suggestions/__tests__/SuggestionsList.test.tsx diff --git a/.storybook/decorators/withMobile.tsx b/.storybook/decorators/withMobile.tsx deleted file mode 100644 index 85e79767..00000000 --- a/.storybook/decorators/withMobile.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import {MobileProvider} from '@gravity-ui/uikit'; -import type {Decorator} from '@storybook/react'; - -export const withMobile: Decorator = (Story, context) => { - const platform = context.globals.platform; - - return ( - - - - ); -}; diff --git a/.storybook/decorators/withTheme.tsx b/.storybook/decorators/withTheme.tsx index 09c2da20..64d1979d 100644 --- a/.storybook/decorators/withTheme.tsx +++ b/.storybook/decorators/withTheme.tsx @@ -1,10 +1,16 @@ -import {ThemeProvider} from '@gravity-ui/uikit'; +import {Provider} from '@gravity-ui/uikit'; import type {Decorator} from '@storybook/react'; export const withTheme: Decorator = (Story, context) => { return ( - - - + + + ); }; diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index a4fbc00c..2475f6b7 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -7,12 +7,11 @@ import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport'; import type {Preview} from '@storybook/react'; import {withLang} from './decorators/withLang'; -import {withMobile} from './decorators/withMobile'; import {withStrictMode} from './decorators/withStrictMode'; import {withTheme} from './decorators/withTheme'; const preview: Preview = { - decorators: [withLang, withMobile, withTheme, withStrictMode], + decorators: [withLang, withTheme, withStrictMode], parameters: { jsx: {showFunctions: true}, viewport: { diff --git a/README.md b/README.md index 53ec534c..bbfe6aed 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,38 @@ npm install @gravity-ui/components ## Usage -`@gravity-ui/uikit` is a peer dependency: install it, import its styles once at the app entry point, and wrap the app in `ThemeProvider`. The components in this package render unstyled without that setup. +`@gravity-ui/uikit` 8 and React 18/19 are required. Install the current UIKit 8 prerelease with `npm install @gravity-ui/uikit@beta`. + +`@gravity-ui/uikit` is a peer dependency: install it, import its styles once at the app entry point, and wrap the app in `Provider`. The components in this package render unstyled without that setup. ```tsx -import {ThemeProvider, TextInput} from '@gravity-ui/uikit'; +import {Provider, TextInput} from '@gravity-ui/uikit'; import {FormRow} from '@gravity-ui/components'; import '@gravity-ui/uikit/styles/fonts.css'; import '@gravity-ui/uikit/styles/styles.css'; export function App() { return ( - + - + ); } ``` +### Migrating to UIKit 8 + +- Replace the application-level `ThemeProvider` with `Provider`. +- Use `onOpenChange` instead of `onClose` in `ConfirmDialog` and `ChangelogDialog`. `ConfirmDialog` accepts the new Dialog props, including `maxWidth` and `fullWidth` instead of `size`. +- Remove `disableHeightTransition` from `ChangelogDialog` and cookie consent popup settings; UIKit no longer animates content height. +- `Stories` and `StoriesGroup` keep `onClose`, with optional event/reason arguments and UIKit 8 reasons (`escape-key`, `outside-press`, `click`). +- Remove `moreControlProps.virtualizationThreshold` from `AdaptiveTabs`; its dropdowns use `ListVirtualizer`. +- Pass native HTML attributes directly to button/link props, including `StoreBadge`, instead of `extraProps`. Use UIKit 8 Button views in custom story actions. + +See the [UIKit 8 migration guide](https://github.com/gravity-ui/uikit/blob/next/docs/migration-to-v8.md) for the underlying API changes. This package uses the new List, Menu, and Popover APIs without the legacy entry point. + ### Confirmation dialog ```tsx @@ -42,7 +55,7 @@ import {ConfirmDialog} from '@gravity-ui/components'; textButtonCancel="Cancel" onClickButtonApply={handleDelete} onClickButtonCancel={() => setOpen(false)} - onClose={() => setOpen(false)} + onOpenChange={setOpen} />; ``` @@ -97,7 +110,7 @@ The composite-component layer of Gravity UI — ready-made form rows, confirmati ### Common pitfalls -- **Nothing is styled without uikit setup.** Install `@gravity-ui/uikit`, import `@gravity-ui/uikit/styles/styles.css` (plus `fonts.css`) once, and wrap the app in `ThemeProvider` — this package ships no global styles of its own. +- **Nothing is styled without uikit setup.** Install `@gravity-ui/uikit`, import `@gravity-ui/uikit/styles/styles.css` (plus `fonts.css`) once, and wrap the app in `Provider` — this package ships no global styles of its own. - **`FormRow` does not render the input.** Pass the control as `children` and link it with `fieldId` matching the control's `id`; the `label` prop is the label text, not a `