From f5c9f2befb4687f7815f58be8f7ec48a56432eea Mon Sep 17 00:00:00 2001 From: dengfuping Date: Fri, 20 Oct 2023 16:40:32 +0800 Subject: [PATCH] improve(codemod): Add more components and types for @alipay/ob-ui => @oceanbase/ui --- .../obui.input.js | 2 +- .../obui.output.js | 2 +- .../obui-to-oceanbase-design-and-ui.js | 24 +++++++++++++++++++ packages/ui/src/Ranger/QuickPicker.tsx | 4 ++-- packages/ui/src/Ranger/Ranger.tsx | 4 ++-- packages/ui/src/Ranger/index.ts | 3 +++ packages/ui/src/TreeSearch/index.tsx | 4 ++-- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.js b/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.js index 060137c00..ca9aea27f 100644 --- a/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.js +++ b/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Alert, Button, BackgroundTaskManager, BackgroundTaskManagerConstants, BasicLayout, Boundary, ConfigProvider, Login, PageContainer, theme } from '@alipay/ob-ui'; +import { Alert, Button, BackgroundTaskManager, BackgroundTaskManagerConstants, BasicLayout, Boundary, ConfigProvider, ContentWithQuestion, IconFont, Login, PageContainer, Ranger, theme, TreeSearch } from '@alipay/ob-ui'; import type { BackgroundTaskManagerRef, ITaskMgrPreset, ITaskMgrQueue, TaskMgrID } from '@alipay/ob-ui'; import type { BasicLayoutProps } from '@alipay/ob-ui/es/BasicLayout'; import type { LoginProps } from '@alipay/ob-ui/es/Login'; diff --git a/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.js b/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.js index fa517be15..807aaeb67 100644 --- a/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.js +++ b/packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.js @@ -1,6 +1,6 @@ import React from 'react'; import { Alert, Button, ConfigProvider, theme } from '@oceanbase/design'; -import { BackgroundTaskManager, BackgroundTaskManagerConstants, BasicLayout, Boundary, Login, PageContainer } from '@oceanbase/ui'; +import { BackgroundTaskManager, BackgroundTaskManagerConstants, BasicLayout, Boundary, ContentWithQuestion, IconFont, Login, PageContainer, Ranger, TreeSearch } from '@oceanbase/ui'; import type { BackgroundTaskManagerRef, ITaskMgrPreset, ITaskMgrQueue, TaskMgrID } from '@oceanbase/ui'; import type { BasicLayoutProps } from '@oceanbase/ui/es/BasicLayout'; import type { LoginProps } from '@oceanbase/ui/es/Login'; diff --git a/packages/codemod/transforms/obui-to-oceanbase-design-and-ui.js b/packages/codemod/transforms/obui-to-oceanbase-design-and-ui.js index b2635b46a..751fd4764 100644 --- a/packages/codemod/transforms/obui-to-oceanbase-design-and-ui.js +++ b/packages/codemod/transforms/obui-to-oceanbase-design-and-ui.js @@ -19,14 +19,24 @@ module.exports = (file, api, options) => { 'ContentWithQuestion', 'Dialog', 'DocDialog', + 'FullscreenBox', + 'Highlight', 'GraphToolbar', + 'IconFont', 'Login', 'Lottie', 'NavMenu', + 'Password', + 'Ranger', + 'SideTip', + 'TaskGraph', + 'TreeSearch', + 'Welcome', ], types: [ 'PageContainerProps', 'ActionProps', + // BackgroundTaskManager 'BackgroundTaskManagerProps', 'BackgroundTaskManagerRef', 'ITaskMgrPreset', @@ -38,10 +48,24 @@ module.exports = (file, api, options) => { 'ContentWithQuestionProps', 'DialogProps', 'DocDialogProps', + 'FullscreenBoxProps', 'GraphToolbarProps', + 'HighlightProps', + 'IconFontProps', 'LoginProps', 'LottieProps', 'NavMenuProps', + 'PasswordProps', + // Ranger + 'RangerProps', + 'QuickPickerProps', + 'SideTipProps', + 'TaskGraphProps', + // TreeSearch + 'TreeSearchProps', + 'TreeSearchRef', + 'Node', + 'WelcomeProps', ], paths: ['/locale/', '/locale/'], }, diff --git a/packages/ui/src/Ranger/QuickPicker.tsx b/packages/ui/src/Ranger/QuickPicker.tsx index c885509c7..361ed8173 100644 --- a/packages/ui/src/Ranger/QuickPicker.tsx +++ b/packages/ui/src/Ranger/QuickPicker.tsx @@ -22,7 +22,7 @@ interface SelectProps { export type QuickType = 'select' | 'dropdown'; -interface IProps extends LocaleWrapperProps { +interface QuickPickerProps extends LocaleWrapperProps { selects: RangeOption[]; type?: QuickType; onChange: (range: RangeValue) => void; @@ -92,7 +92,7 @@ const RangeSelect = ({ selects, onChange, value, customable, locale = {}, size } ); }; -export default (props: IProps) => { +export default (props: QuickPickerProps) => { const { type = 'select', name, diff --git a/packages/ui/src/Ranger/Ranger.tsx b/packages/ui/src/Ranger/Ranger.tsx index 1eed762c9..990780166 100644 --- a/packages/ui/src/Ranger/Ranger.tsx +++ b/packages/ui/src/Ranger/Ranger.tsx @@ -31,7 +31,7 @@ export type RangeDateValue = { range: RangeValue; }; -interface IProps extends Omit { +interface RangerProps extends Omit { // 数据相关 selects?: RangeOption[]; defaultQuickValue?: string; @@ -49,7 +49,7 @@ interface IProps extends Omit { +const Ranger = (props: RangerProps) => { const { selects = [NEAR_1_MINUTES, NEAR_30_MINUTES, NEAR_1_HOURS], value, diff --git a/packages/ui/src/Ranger/index.ts b/packages/ui/src/Ranger/index.ts index 3097599de..41183816d 100644 --- a/packages/ui/src/Ranger/index.ts +++ b/packages/ui/src/Ranger/index.ts @@ -27,6 +27,9 @@ import { import QuickPicker from './QuickPicker'; import InternalRanger from './Ranger'; +export * from './QuickPicker'; +export * from './Ranger'; + const Ranger = InternalRanger; // 内置 ranges diff --git a/packages/ui/src/TreeSearch/index.tsx b/packages/ui/src/TreeSearch/index.tsx index 24f292a5d..516e906b0 100644 --- a/packages/ui/src/TreeSearch/index.tsx +++ b/packages/ui/src/TreeSearch/index.tsx @@ -32,7 +32,7 @@ export interface TreeSearchRef { invertSelect: () => void; } -interface IProps { +interface TreeSearchProps { treeData: Node[]; titleRender?: (nodeData: DataNode) => React.ReactNode; checkable?: boolean; @@ -50,7 +50,7 @@ interface IProps { searchStyle?: {}; } -export default forwardRef( +export default forwardRef( ( { treeData = [],