Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RangeSelector): add -input-start and -input-end className to differ inputs #901

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/PickerInput/Selector/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem

const Input = React.forwardRef<InputRef, InputProps>((props, ref) => {
const {
className,
active,
showActiveCls = true,
suffixIcon,
Expand Down Expand Up @@ -377,10 +378,14 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => {
return (
<div
ref={holderRef}
className={classNames(inputPrefixCls, {
[`${inputPrefixCls}-active`]: active && showActiveCls,
[`${inputPrefixCls}-placeholder`]: helped,
})}
className={classNames(
inputPrefixCls,
{
[`${inputPrefixCls}-active`]: active && showActiveCls,
[`${inputPrefixCls}-placeholder`]: helped,
},
className,
)}
>
<Component
ref={inputRef}
Expand Down
6 changes: 4 additions & 2 deletions src/PickerInput/Selector/RangeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ function RangeSelector<DateType extends object = any>(
if (input) {
const { offsetWidth, offsetLeft, offsetParent } = input.nativeElement;
const parentWidth = (offsetParent as HTMLElement)?.offsetWidth || 0;
const activeOffset = placementRight ? (parentWidth - offsetWidth - offsetLeft) : offsetLeft;
const activeOffset = placementRight ? parentWidth - offsetWidth - offsetLeft : offsetLeft;
setActiveBarStyle(({ insetInlineStart, insetInlineEnd, ...rest }) => ({
...rest,
width: offsetWidth,
[offsetUnit]: activeOffset
[offsetUnit]: activeOffset,
}));
onActiveOffset(activeOffset);
}
Expand Down Expand Up @@ -243,6 +243,7 @@ function RangeSelector<DateType extends object = any>(
<Input
ref={inputStartRef}
{...getInputProps(0)}
className={`${prefixCls}-input-start`}
autoFocus={startAutoFocus}
tabIndex={tabIndex}
date-range="start"
Expand All @@ -251,6 +252,7 @@ function RangeSelector<DateType extends object = any>(
<Input
ref={inputEndRef}
{...getInputProps(1)}
className={`${prefixCls}-input-end`}
autoFocus={endAutoFocus}
tabIndex={tabIndex}
date-range="end"
Expand Down
24 changes: 12 additions & 12 deletions tests/__snapshots__/range.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`Picker.Range icon 1`] = `
class="rc-picker rc-picker-range"
>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -22,7 +22,7 @@ exports[`Picker.Range icon 1`] = `
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand Down Expand Up @@ -61,7 +61,7 @@ exports[`Picker.Range onPanelChange is array args should render correctly in pla
class="rc-picker rc-picker-range rc-picker-focused"
>
<div
class="rc-picker-input rc-picker-input-active"
class="rc-picker-input rc-picker-input-active rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -77,7 +77,7 @@ exports[`Picker.Range onPanelChange is array args should render correctly in pla
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand All @@ -101,7 +101,7 @@ exports[`Picker.Range onPanelChange is array args should render correctly in rtl
class="rc-picker rc-picker-range rc-picker-rtl"
>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -117,7 +117,7 @@ exports[`Picker.Range onPanelChange is array args should render correctly in rtl
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand All @@ -142,7 +142,7 @@ exports[`Picker.Range panelRender 1`] = `
class="rc-picker rc-picker-range"
>
<div
class="rc-picker-input rc-picker-input-active"
class="rc-picker-input rc-picker-input-active rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -158,7 +158,7 @@ exports[`Picker.Range panelRender 1`] = `
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand Down Expand Up @@ -208,7 +208,7 @@ exports[`Picker.Range use dateRender and monthCellRender in date range picker 1`
class="rc-picker rc-picker-range rc-picker-focused"
>
<div
class="rc-picker-input rc-picker-input-active"
class="rc-picker-input rc-picker-input-active rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -224,7 +224,7 @@ exports[`Picker.Range use dateRender and monthCellRender in date range picker 1`
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand Down Expand Up @@ -1265,7 +1265,7 @@ exports[`Picker.Range use dateRender and monthCellRender in month range picker 1
class="rc-picker rc-picker-range rc-picker-focused"
>
<div
class="rc-picker-input rc-picker-input-active"
class="rc-picker-input rc-picker-input-active rc-picker-input-start"
>
<input
aria-invalid="false"
Expand All @@ -1281,7 +1281,7 @@ exports[`Picker.Range use dateRender and monthCellRender in month range picker 1
~
</div>
<div
class="rc-picker-input"
class="rc-picker-input rc-picker-input-end"
>
<input
aria-invalid="false"
Expand Down
Loading