Skip to content

Commit 5920043

Browse files
committed
chore: clean up
1 parent 433adac commit 5920043

File tree

6 files changed

+67
-247
lines changed

6 files changed

+67
-247
lines changed

src/PickerInput/Popup/index.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type {
88
ValueDate,
99
} from '../../interface';
1010
import { toArray } from '../../utils/miscUtil';
11-
import { getRealPlacement, getOffsetUnit } from '../../utils/uiUtil';
1211
import PickerContext from '../context';
1312
import Footer, { type FooterProps } from './Footer';
1413
import PopupPanel, { type PopupPanelProps } from './PopupPanel';
@@ -33,7 +32,6 @@ export interface PopupProps<DateType extends object = any, PresetValue = DateTyp
3332

3433
// Range
3534
activeInfo?: [activeInputLeft: number, activeInputRight: number, selectorWidth: number];
36-
placement?: string;
3735
// Direction
3836
direction?: 'ltr' | 'rtl';
3937

@@ -60,7 +58,6 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
6058
range,
6159
multiple,
6260
activeInfo = [0, 0, 0],
63-
placement,
6461

6562
// Presets
6663
presets,
@@ -99,8 +96,8 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
9996
const [arrowOffset, setArrowOffset] = React.useState<number>(0);
10097

10198
const onResize: ResizeObserverProps['onResize'] = (info) => {
102-
if (info.offsetWidth) {
103-
setContainerWidth(info.offsetWidth);
99+
if (info.width) {
100+
setContainerWidth(info.width);
104101
}
105102
};
106103

@@ -122,15 +119,12 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
122119

123120
// Container Offset
124121
if (containerWidth < selectorWidth) {
125-
if (rtl) {
126-
const offset = wrapperRect.right - (activeInputRight - arrowWidth + containerWidth);
127-
const safeOffset = Math.max(0, offset);
128-
setContainerOffset(safeOffset);
129-
} else {
130-
const offset = activeInputLeft + arrowWidth - wrapperRect.left - containerWidth;
131-
const safeOffset = Math.max(0, offset);
132-
setContainerOffset(safeOffset);
133-
}
122+
const offset = rtl
123+
? wrapperRect.right - (activeInputRight - arrowWidth + containerWidth)
124+
: activeInputLeft + arrowWidth - wrapperRect.left - containerWidth;
125+
126+
const safeOffset = Math.max(0, offset);
127+
setContainerOffset(safeOffset);
134128
} else {
135129
setContainerOffset(0);
136130
}

src/PickerInput/RangePicker.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ function RangePicker<DateType extends object = any>(
160160
prefixCls,
161161
styles,
162162
classNames,
163-
placement,
164163

165164
// Value
166165
defaultValue,
@@ -578,7 +577,6 @@ function RangePicker<DateType extends object = any>(
578577
range
579578
multiplePanel={multiplePanel}
580579
activeInfo={activeInfo}
581-
placement={placement}
582580
// Disabled
583581
disabledDate={mergedDisabledDate}
584582
// Focus

src/PickerInput/Selector/RangeSelector.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import useInputProps from './hooks/useInputProps';
88
import useRootProps from './hooks/useRootProps';
99
import Icon, { ClearIcon } from './Icon';
1010
import Input, { type InputRef } from './Input';
11-
// import { getOffsetUnit, getRealPlacement } from '../../utils/uiUtil';
1211

1312
export type SelectorIdType =
1413
| string
@@ -175,9 +174,6 @@ function RangeSelector<DateType extends object = any>(
175174
});
176175

177176
// ====================== ActiveBar =======================
178-
// const realPlacement = getRealPlacement(placement, rtl);
179-
// const offsetUnit = getOffsetUnit(realPlacement, rtl);
180-
// const placementRight = realPlacement?.toLowerCase().endsWith('right');
181177
const [activeBarStyle, setActiveBarStyle] = React.useState<React.CSSProperties>({
182178
position: 'absolute',
183179
width: 0,
@@ -186,23 +182,13 @@ function RangeSelector<DateType extends object = any>(
186182
const syncActiveOffset = useEvent(() => {
187183
const input = getInput(activeIndex);
188184
if (input) {
189-
const { offsetWidth, offsetParent } = input.nativeElement;
190-
// const parentWidth = (offsetParent as HTMLElement)?.offsetWidth || 0;
191-
// const activeOffset = placementRight ? parentWidth - offsetWidth - offsetLeft : offsetLeft;
192-
// setActiveBarStyle(({ insetInlineStart, insetInlineEnd, ...rest }) => ({
193-
// ...rest,
194-
// width: offsetWidth,
195-
// [offsetUnit]: activeOffset
196-
// }));
197-
// onActiveOffset(activeOffset);
198-
199185
const inputRect = input.nativeElement.getBoundingClientRect();
200186
const parentRect = rootRef.current.getBoundingClientRect();
201187

202188
const rectOffset = inputRect.left - parentRect.left;
203189
setActiveBarStyle((ori) => ({
204190
...ori,
205-
width: offsetWidth,
191+
width: inputRect.width,
206192
left: rectOffset,
207193
}));
208194
onActiveInfo([inputRect.left, inputRect.right, parentRect.width]);

src/utils/uiUtil.ts

Lines changed: 0 additions & 206 deletions
This file was deleted.

tests/__snapshots__/range.spec.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ exports[`Picker.Range use dateRender and monthCellRender in date range picker 1`
236236
</div>
237237
<div
238238
class="rc-picker-active-bar"
239-
style="position: absolute; left: 0px;"
239+
style="position: absolute; width: 0px; left: 0px;"
240240
/>
241241
</div>
242242
</div>
@@ -1293,7 +1293,7 @@ exports[`Picker.Range use dateRender and monthCellRender in month range picker 1
12931293
</div>
12941294
<div
12951295
class="rc-picker-active-bar"
1296-
style="position: absolute; left: 0px;"
1296+
style="position: absolute; width: 0px; left: 0px;"
12971297
/>
12981298
</div>
12991299
</div>

0 commit comments

Comments
 (0)