Skip to content

Commit c50337e

Browse files
authored
fix: rc-util import logic (#812)
1 parent db242f1 commit c50337e

14 files changed

+23
-38
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ pnpm-lock.yaml
4040
.env.local
4141
.dumi
4242

43-
bun.lockb
43+
bun.lockb
44+
bun.lock

jest.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ const compileModules = [
88
'tween-one',
99
'@babel',
1010
'@ant-design',
11+
'@rc-component/resize-observer',
1112
];
1213

1314
const ignoreList = [];
1415

1516
// cnpm use `_` as prefix
16-
['', '_'].forEach((prefix) => {
17-
compileModules.forEach((module) => {
17+
['', '_'].forEach(prefix => {
18+
compileModules.forEach(module => {
1819
ignoreList.push(`${prefix}${module}`);
1920
});
2021
});

src/TabNavList/OperationNode.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classNames from 'classnames';
22
import Dropdown from '@rc-component/dropdown';
33
import Menu, { MenuItem } from '@rc-component/menu';
4-
import KeyCode from 'rc-util/lib/KeyCode';
4+
import KeyCode from '@rc-component/util/lib/KeyCode';
55
import * as React from 'react';
66
import { useEffect, useState } from 'react';
77
import type { EditableConfig, Tab, TabsLocale, MoreProps } from '../interface';

src/TabNavList/index.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* eslint-disable react-hooks/exhaustive-deps */
21
import classNames from 'classnames';
3-
import ResizeObserver from 'rc-resize-observer';
4-
import useEvent from 'rc-util/lib/hooks/useEvent';
5-
import { useComposeRef } from 'rc-util/lib/ref';
2+
import ResizeObserver from '@rc-component/resize-observer';
3+
import useEvent from '@rc-component/util/lib/hooks/useEvent';
4+
import { useComposeRef } from '@rc-component/util/lib/ref';
65
import * as React from 'react';
76
import { useEffect, useRef, useState } from 'react';
87
import TabContext from '../TabContext';

src/Tabs.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role
22
import classNames from 'classnames';
3-
import useMergedState from 'rc-util/lib/hooks/useMergedState';
4-
import isMobile from 'rc-util/lib/isMobile';
3+
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
4+
import isMobile from '@rc-component/util/lib/isMobile';
55
import * as React from 'react';
66
import { useEffect, useState } from 'react';
77
import TabContext from './TabContext';

src/hooks/useAnimateConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warning from 'rc-util/lib/warning';
1+
import warning from '@rc-component/util/lib/warning';
22
import type { TabsProps } from '..';
33
import type { AnimatedConfig } from '../interface';
44

src/hooks/useIndicator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import raf from 'rc-util/lib/raf';
1+
import raf from '@rc-component/util/lib/raf';
22
import React, { useEffect, useRef, useState } from 'react';
33
import type { TabOffset } from '../interface';
44

src/hooks/useUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLayoutUpdateEffect } from 'rc-util/lib/hooks/useLayoutEffect';
1+
import { useLayoutUpdateEffect } from '@rc-component/util/lib/hooks/useLayoutEffect';
22
import { useRef, useState } from 'react';
33

44
/**

tests/common/util.tsx

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-invalid-this */
22
import { act } from '@testing-library/react';
3-
import { _rs as onEsResize } from 'rc-resize-observer/es/utils/observerUtil';
4-
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
3+
import { _rs as onEsResize } from '@rc-component/resize-observer/es/utils/observerUtil';
4+
import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil';
55
import React from 'react';
66
import Tabs from '../../src';
77
import type { TabsProps } from '../../src/Tabs';
@@ -67,18 +67,6 @@ export function getOffsetSizeFunc(info: HackInfo = {}) {
6767
return this.querySelector('.rc-tabs-nav-add') ? more + add : more;
6868
}
6969

70-
// if (this.className.includes('rc-tabs-nav-list')) {
71-
// return info.list || 5 * 20 + 10;
72-
// }
73-
// if (this.className.includes('rc-tabs-nav-add')) {
74-
// return info.add || 10;
75-
// }
76-
// if (this.className.includes('rc-tabs-nav-operations')) {
77-
// return info.operation || 10;
78-
// }
79-
// if (this.className.includes('rc-tabs-nav-more')) {
80-
// return info.more || 10;
81-
// }
8270
if (this.className.includes('rc-tabs-dropdown')) {
8371
return dropdown;
8472
}
@@ -158,10 +146,6 @@ export function getTabs(props: TabsProps = null) {
158146
);
159147
}
160148

161-
// export function triggerResize(wrapper: ReactWrapper) {
162-
// (wrapper.find('.rc-tabs-nav').find('ResizeObserver').first().props() as any).onResize();
163-
// }
164-
165149
export const triggerResize = (container: Element) => {
166150
const target = container.querySelector('.rc-tabs-nav');
167151

tests/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '@testing-library/dom';
22
import { act, fireEvent, render, screen } from '@testing-library/react';
3-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
3+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
44
import React from 'react';
55
import Tabs from '../src';
66
import type { TabsProps } from '../src/Tabs';

tests/mobile.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { render } from '@testing-library/react';
2-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
2+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
33
import React from 'react';
44
import { act } from 'react-dom/test-utils';
55
import type { TabsProps } from '../src';
66
import Tabs from '../src';
77
import { btnOffsetPosition, getOffsetSizeFunc, getTransformX } from './common/util';
88

9-
jest.mock('rc-util/lib/isMobile', () => () => true);
9+
jest.mock('@rc-component/util/lib/isMobile', () => () => true);
1010

1111
describe('Tabs.Mobile', () => {
1212
const tabCount = 100;

tests/operation-overflow.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-invalid-this */
22
import { render } from '@testing-library/react';
3-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
3+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
44
import { act } from 'react-dom/test-utils';
55
import { getOffsetSizeFunc, getTabs, triggerResize } from './common/util';
66

tests/overflow.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { act, fireEvent, render } from '@testing-library/react';
2-
import KeyCode from 'rc-util/lib/KeyCode';
3-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
2+
import KeyCode from '@rc-component/util/lib/KeyCode';
3+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
44
import React from 'react';
55
import type { TabsProps } from '../src';
66
import Tabs from '../src';

tests/rtl.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render } from '@testing-library/react';
2-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
2+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
33
import { act } from 'react-dom/test-utils';
44
import { getOffsetSizeFunc, getTabs, getTransformX, triggerResize } from './common/util';
55

0 commit comments

Comments
 (0)