Skip to content

Commit a1fcf9d

Browse files
authored
chore: bump trigger version (#910)
* chore: bump trigger version * fix: ts error * test: remove ResizeObserver mock setup * chore: update package name to @rc-component/picker * chore: update tsconfig path
1 parent ec4f698 commit a1fcf9d

35 files changed

+78
-202
lines changed

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "rc-picker",
2+
"name": "@rc-component/picker",
33
"version": "4.11.2",
44
"description": "React date & time picker",
55
"keywords": [
@@ -29,7 +29,7 @@
2929
"build": "dumi build",
3030
"compile": "father build && lessc assets/index.less assets/index.css",
3131
"gh-pages": "npm run build && father doc deploy",
32-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
32+
"prepublishOnly": "npm run compile && rc-np",
3333
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
3434
"lint:tsc": "tsc -p tsconfig.json --noEmit",
3535
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
@@ -39,18 +39,18 @@
3939
"prepare": "npx husky"
4040
},
4141
"dependencies": {
42-
"@babel/runtime": "^7.24.7",
43-
"@rc-component/trigger": "^2.0.0",
42+
"@rc-component/resize-observer": "^1.0.0",
43+
"@rc-component/trigger": "^3.0.0",
44+
"@rc-component/util": "^1.2.1",
4445
"classnames": "^2.2.1",
45-
"rc-overflow": "^1.3.2",
46-
"rc-resize-observer": "^1.4.0",
47-
"rc-util": "^5.43.0"
46+
"rc-overflow": "^1.3.2"
4847
},
4948
"engines": {
5049
"node": ">=8.x"
5150
},
5251
"devDependencies": {
5352
"@rc-component/father-plugin": "^1.0.0",
53+
"@rc-component/np":"^1.0.3",
5454
"@testing-library/react": "^16.0.0",
5555
"@types/classnames": "^2.2.9",
5656
"@types/jest": "^29.4.0",
@@ -76,7 +76,6 @@
7676
"mockdate": "^3.0.2",
7777
"moment": "^2.24.0",
7878
"moment-timezone": "^0.5.45",
79-
"np": "^10.0.2",
8079
"prettier": "^3.1.0",
8180
"rc-test": "^7.0.9",
8281
"react": "^18.2.0",

src/PickerInput/Popup/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import ResizeObserver, { type ResizeObserverProps } from 'rc-resize-observer';
2+
import ResizeObserver, { type ResizeObserverProps } from '@rc-component/resize-observer';
33
import * as React from 'react';
44
import type {
55
RangeTimeProps,

src/PickerInput/RangePicker.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { useEvent, useMergedState } from 'rc-util';
2-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
3-
import omit from 'rc-util/lib/omit';
4-
import pickAttrs from 'rc-util/lib/pickAttrs';
5-
import warning from 'rc-util/lib/warning';
1+
import { useEvent, useMergedState } from '@rc-component/util';
2+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
3+
import omit from '@rc-component/util/lib/omit';
4+
import pickAttrs from '@rc-component/util/lib/pickAttrs';
5+
import warning from '@rc-component/util/lib/warning';
66
import * as React from 'react';
77
import type {
88
BaseInfo,

src/PickerInput/Selector/Input.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classNames from 'classnames';
2-
import { useEvent } from 'rc-util';
3-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
4-
import raf from 'rc-util/lib/raf';
2+
import { useEvent } from '@rc-component/util';
3+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
4+
import raf from '@rc-component/util/lib/raf';
55
import * as React from 'react';
66
import { leftPad } from '../../utils/miscUtil';
77
import PickerContext from '../context';

src/PickerInput/Selector/RangeSelector.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import classNames from 'classnames';
2-
import ResizeObserver from 'rc-resize-observer';
3-
import { useEvent } from 'rc-util';
2+
import ResizeObserver from '@rc-component/resize-observer';
3+
import { useEvent } from '@rc-component/util';
44
import * as React from 'react';
55
import type { RangePickerRef, SelectorProps } from '../../interface';
66
import PickerContext from '../context';

src/PickerInput/Selector/hooks/useClearIcon.tsx

+1-2
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 { ReactNode } from 'react';
33
import * as React from 'react';
44

@@ -22,4 +22,3 @@ export function fillClearIcon(
2222

2323
return config.clearIcon || clearIcon || <span className={`${prefixCls}-clear-btn`} />;
2424
}
25-

src/PickerInput/Selector/hooks/useInputProps.ts

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { warning } from 'rc-util';
2-
import pickAttrs from 'rc-util/lib/pickAttrs';
1+
import { warning } from '@rc-component/util';
2+
import pickAttrs from '@rc-component/util/lib/pickAttrs';
33
import * as React from 'react';
44
import type { SelectorProps } from '../../../interface';
55
import { formatValue } from '../../../utils/dateUtil';
@@ -86,12 +86,7 @@ export default function useInputProps<DateType extends object = any>(
8686
const firstFormat = format[0];
8787

8888
const getText = React.useCallback(
89-
(date: DateType) =>
90-
formatValue(date, {
91-
locale,
92-
format: firstFormat,
93-
generateConfig,
94-
}),
89+
(date: DateType) => formatValue(date, { locale, format: firstFormat, generateConfig }),
9590
[locale, generateConfig, firstFormat],
9691
);
9792

@@ -131,10 +126,7 @@ export default function useInputProps<DateType extends object = any>(
131126
return index !== undefined ? propValue[index] : propValue;
132127
}
133128

134-
const pickedAttrs = pickAttrs(props, {
135-
aria: true,
136-
data: true,
137-
});
129+
const pickedAttrs = pickAttrs(props, { aria: true, data: true });
138130

139131
const inputProps = {
140132
...pickedAttrs,
@@ -198,9 +190,7 @@ export default function useInputProps<DateType extends object = any>(
198190
onInvalid(!!text, index);
199191
},
200192
onHelp: () => {
201-
onOpenChange(true, {
202-
index,
203-
});
193+
onOpenChange(true, { index });
204194
},
205195
onKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => {
206196
let prevented = false;
@@ -218,9 +208,7 @@ export default function useInputProps<DateType extends object = any>(
218208
if (!event.defaultPrevented && !prevented) {
219209
switch (event.key) {
220210
case 'Escape':
221-
onOpenChange(false, {
222-
index,
223-
});
211+
onOpenChange(false, { index });
224212
break;
225213
case 'Enter':
226214
if (!open) {
@@ -232,9 +220,7 @@ export default function useInputProps<DateType extends object = any>(
232220
},
233221

234222
// ============ Post Props ============
235-
...postProps?.({
236-
valueTexts,
237-
}),
223+
...postProps?.({ valueTexts }),
238224
};
239225

240226
// ============== Clean Up ==============

src/PickerInput/SinglePicker.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useEvent, useMergedState } from 'rc-util';
2-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
3-
import omit from 'rc-util/lib/omit';
4-
import pickAttrs from 'rc-util/lib/pickAttrs';
1+
import { useEvent, useMergedState } from '@rc-component/util';
2+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
3+
import omit from '@rc-component/util/lib/omit';
4+
import pickAttrs from '@rc-component/util/lib/pickAttrs';
55
import * as React from 'react';
66
import useToggleDates from '../hooks/useToggleDates';
77
import type {

src/PickerInput/hooks/useCellRender.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from 'rc-util';
1+
import { warning } from '@rc-component/util';
22
import * as React from 'react';
33
import type { CellRender, CellRenderInfo, SharedPickerProps } from '../../interface';
44

@@ -36,11 +36,7 @@ export default function useCellRender<DateType extends object = any>(
3636

3737
// Cell render
3838
const onInternalCellRender: CellRender<DateType> = React.useCallback(
39-
(date, info) =>
40-
mergedCellRender(date, {
41-
...info,
42-
range,
43-
}),
39+
(date, info) => mergedCellRender(date, { ...info, range }),
4440
[mergedCellRender, range],
4541
);
4642

src/PickerInput/hooks/useDelayState.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useEvent, useMergedState } from 'rc-util';
2-
import raf from 'rc-util/lib/raf';
1+
import { useEvent, useMergedState } from '@rc-component/util';
2+
import raf from '@rc-component/util/lib/raf';
33
import React from 'react';
44

55
/**
@@ -11,9 +11,7 @@ export default function useDelayState<T>(
1111
defaultValue?: T,
1212
onChange?: (next: T) => void,
1313
): [state: T, setState: (nextState: T, immediately?: boolean) => void] {
14-
const [state, setState] = useMergedState<T>(defaultValue, {
15-
value,
16-
});
14+
const [state, setState] = useMergedState<T>(defaultValue, { value });
1715

1816
const nextValueRef = React.useRef<T>(value);
1917

src/PickerInput/hooks/useDisabledBoundary.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEvent } from 'rc-util';
1+
import { useEvent } from '@rc-component/util';
22
import type { GenerateConfig } from '../../generate';
33
import { isSame } from '../../utils/dateUtil';
44
import type { DisabledDate, InternalMode, Locale } from '../../interface';

src/PickerInput/hooks/useFilledProps.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from 'rc-util';
1+
import { warning } from '@rc-component/util';
22
import * as React from 'react';
33
import useLocale from '../../hooks/useLocale';
44
import { fillShowTimeConfig, getTimeProps } from '../../hooks/useTimeConfig';
@@ -167,10 +167,7 @@ export default function useFilledProps<
167167
styles,
168168
classNames,
169169
order,
170-
components: {
171-
input: inputRender,
172-
...components,
173-
},
170+
components: { input: inputRender, ...components },
174171
clearIcon: fillClearIcon(prefixCls, allowClear, clearIcon),
175172
showTime: mergedShowTime,
176173
value: values,

src/PickerInput/hooks/useInvalidate.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEvent } from 'rc-util';
1+
import { useEvent } from '@rc-component/util';
22
import type { GenerateConfig } from '../../generate';
33
import type {
44
PanelMode,
@@ -19,10 +19,7 @@ export default function useInvalidate<DateType extends object = any>(
1919
// Check disabled date
2020
const isInvalidate = useEvent(
2121
(date: DateType, info?: { from?: DateType; activeIndex: number }) => {
22-
const outsideInfo = {
23-
type: picker,
24-
...info,
25-
};
22+
const outsideInfo = { type: picker, ...info };
2623
delete outsideInfo.activeIndex;
2724

2825
if (
@@ -37,9 +34,7 @@ export default function useInvalidate<DateType extends object = any>(
3734
if ((picker === 'date' || picker === 'time') && showTime) {
3835
const range = info && info.activeIndex === 1 ? 'end' : 'start';
3936
const { disabledHours, disabledMinutes, disabledSeconds, disabledMilliseconds } =
40-
showTime.disabledTime?.(date, range, {
41-
from: outsideInfo.from,
42-
}) || {};
37+
showTime.disabledTime?.(date, range, { from: outsideInfo.from }) || {};
4338

4439
const {
4540
disabledHours: legacyDisabledHours,

src/PickerInput/hooks/useLockEffect.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useLayoutUpdateEffect } from 'rc-util/lib/hooks/useLayoutEffect';
2-
import raf from 'rc-util/lib/raf';
1+
import { useLayoutUpdateEffect } from '@rc-component/util/lib/hooks/useLayoutEffect';
2+
import raf from '@rc-component/util/lib/raf';
33
import * as React from 'react';
44

55
/**

src/PickerInput/hooks/usePresets.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import warning from 'rc-util/lib/warning';
2+
import warning from '@rc-component/util/lib/warning';
33
import type { ValueDate } from '../../interface';
44

55
export default function usePresets<DateType = any>(
@@ -14,10 +14,7 @@ export default function usePresets<DateType = any>(
1414
if (legacyRanges) {
1515
warning(false, '`ranges` is deprecated. Please use `presets` instead.');
1616

17-
return Object.entries(legacyRanges).map(([label, value]) => ({
18-
label,
19-
value,
20-
}));
17+
return Object.entries(legacyRanges).map(([label, value]) => ({ label, value }));
2118
}
2219

2320
return [];

src/PickerInput/hooks/useRangePickerValue.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useMergedState } from 'rc-util';
2-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
1+
import { useMergedState } from '@rc-component/util';
2+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
33
import * as React from 'react';
44
import type { GenerateConfig } from '../../generate';
55
import type { InternalMode, Locale, PanelMode } from '../../interface';
@@ -74,9 +74,7 @@ export default function useRangePickerValue<DateType extends object, ValueType e
7474
// PickerValue state
7575
const [mergedStartPickerValue, setStartPickerValue] = useMergedState(
7676
() => getDefaultPickerValue(0),
77-
{
78-
value: startPickerValue,
79-
},
77+
{ value: startPickerValue },
8078
);
8179

8280
const [mergedEndPickerValue, setEndPickerValue] = useMergedState(() => getDefaultPickerValue(1), {

src/PickerInput/hooks/useRangeValue.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEvent, useMergedState } from 'rc-util';
1+
import { useEvent, useMergedState } from '@rc-component/util';
22
import * as React from 'react';
33
import type { GenerateConfig } from '../../generate';
44
import useSyncState from '../../hooks/useSyncState';
@@ -117,9 +117,7 @@ export function useInnerValue<ValueType extends DateType[], DateType extends obj
117117
onOk?: (dates: ValueType) => void,
118118
) {
119119
// This is the root value which will sync with controlled or uncontrolled value
120-
const [innerValue, setInnerValue] = useMergedState(defaultValue, {
121-
value,
122-
});
120+
const [innerValue, setInnerValue] = useMergedState(defaultValue, { value });
123121
const mergedValue = innerValue || (EMPTY_VALUE as ValueType);
124122

125123
// ========================= Inner Values =========================
@@ -148,9 +146,7 @@ export function useInnerValue<ValueType extends DateType[], DateType extends obj
148146
// Trigger calendar change event
149147
if (onCalendarChange) {
150148
const cellTexts = getDateTexts(clone);
151-
onCalendarChange(clone, cellTexts, {
152-
range: isSameStart ? 'end' : 'start',
153-
});
149+
onCalendarChange(clone, cellTexts, { range: isSameStart ? 'end' : 'start' });
154150
}
155151
}
156152
},

src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
2+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
33
import * as React from 'react';
44
import { usePanelContext } from '../../context';
55
import useScrollTo from './useScrollTo';

src/PickerPanel/TimePanel/TimePanelBody/useScrollTo.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { useEvent } from 'rc-util';
2-
import raf from 'rc-util/lib/raf';
3-
import isVisible from 'rc-util/lib/Dom/isVisible';
1+
import { useEvent } from '@rc-component/util';
2+
import raf from '@rc-component/util/lib/raf';
3+
import isVisible from '@rc-component/util/lib/Dom/isVisible';
44
import * as React from 'react';
55

66
const SPEED_PTG = 1 / 3;

src/PickerPanel/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import { useEvent, useMergedState, warning } from 'rc-util';
2+
import { useEvent, useMergedState, warning } from '@rc-component/util';
33
import * as React from 'react';
44
import useLocale from '../hooks/useLocale';
55
import { fillShowTimeConfig, getTimeProps } from '../hooks/useTimeConfig';

src/PickerTrigger/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function PickerTrigger({
8989
popupPlacement={realPlacement}
9090
builtinPlacements={builtinPlacements}
9191
prefixCls={dropdownPrefixCls}
92-
popupTransitionName={transitionName}
92+
popupMotion={{ motionName: transitionName }}
9393
popup={popupElement}
9494
popupAlign={popupAlign}
9595
popupVisible={visible}

src/generate/moment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Moment } from 'moment';
22
import moment from 'moment';
3-
import { noteOnce } from 'rc-util/lib/warning';
3+
import { noteOnce } from '@rc-component/util/lib/warning';
44
import type { GenerateConfig } from '.';
55

66
const generateConfig: GenerateConfig<Moment> = {

src/hooks/useTimeInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from 'rc-util';
1+
import { warning } from '@rc-component/util';
22
import * as React from 'react';
33
import type { GenerateConfig } from '../generate';
44
import type { DisabledTimes, SharedTimeProps } from '../interface';

src/utils/warnUtil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { DisabledTimes, PickerMode } from '../interface';
2-
import warning from 'rc-util/lib/warning';
2+
import warning from '@rc-component/util/lib/warning';
33

44
export interface WarningProps extends DisabledTimes {
55
picker?: PickerMode;

0 commit comments

Comments
 (0)