Skip to content

refactor:datepicker #6245

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

Merged
merged 1 commit into from
Feb 12, 2023
Merged
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: 11 additions & 2 deletions components/date-picker/generatePicker/generateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { FormItemInputContext, useInjectFormItemContext } from '../../form/FormI
import omit from '../../_util/omit';
import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils';

//CSSINJS
import useStyle from '../style';

export default function generateRangePicker<DateType, ExtraProps = {}>(
generateConfig: GenerateConfig<DateType>,
extraProps: ExtraProps,
Expand Down Expand Up @@ -58,6 +61,10 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
'picker',
props,
);

// style
const [wrapSSR, hashId] = useStyle(prefixCls);

const pickerRef = ref();
expose({
focus: () => {
Expand Down Expand Up @@ -166,7 +173,7 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
{formItemInputContext.hasFeedback && formItemInputContext.feedbackIcon}
</>
);
return (
return wrapSSR(
<VCRangePicker
dateRender={dateRender}
renderExtraFooter={renderExtraFooter}
Expand Down Expand Up @@ -202,6 +209,7 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
formItemInputContext.hasFeedback,
),
attrs.class,
hashId.value,
)}
locale={locale!.lang}
prefixCls={pre}
Expand All @@ -213,14 +221,15 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
superNextIcon={slots.superNextIcon?.() || <span class={`${pre}-super-next-icon`} />}
components={Components}
direction={direction.value}
dropdownClassName={classNames(hashId.value)}
onChange={onChange}
onOpenChange={onOpenChange}
onFocus={onFocus}
onBlur={onBlur}
onPanelChange={onPanelChange}
onOk={onOk}
onCalendarChange={onCalendarChange}
/>
/>,
);
};
},
Expand Down
15 changes: 12 additions & 3 deletions components/date-picker/generatePicker/generateSinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import devWarning from '../../vc-util/devWarning';
import { FormItemInputContext, useInjectFormItemContext } from '../../form/FormItemContext';
import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils';

//CSSINJS
import useStyle from '../style';

export default function generateSinglePicker<DateType, ExtraProps = {}>(
generateConfig: GenerateConfig<DateType>,
extraProps: ExtraProps,
Expand Down Expand Up @@ -67,6 +70,10 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
'picker',
props,
);

// style
const [wrapSSR, hashId] = useStyle(prefixCls);

const pickerRef = ref();
expose({
focus: () => {
Expand Down Expand Up @@ -156,7 +163,7 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
id = formItemContext.id.value,
...restProps
} = p;
const showTime = p.showTime === '' ? true : p.showTime;
const showTime = (p as any).showTime === '' ? true : p.showTime;
const { format } = p as any;

let additionalOverrideProps: any = {};
Expand Down Expand Up @@ -185,7 +192,7 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
{formItemInputContext.hasFeedback && formItemInputContext.feedbackIcon}
</>
);
return (
return wrapSSR(
<RCPicker
monthCellRender={monthCellRender}
dateRender={dateRender}
Expand Down Expand Up @@ -217,6 +224,7 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
formItemInputContext.hasFeedback,
),
attrs.class,
hashId.value,
)}
prefixCls={pre}
getPopupContainer={attrs.getCalendarContainer || getPopupContainer.value}
Expand All @@ -227,13 +235,14 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
superNextIcon={slots.superNextIcon?.() || <span class={`${pre}-super-next-icon`} />}
components={Components}
direction={direction.value}
dropdownClassName={classNames(hashId.value)}
onChange={onChange}
onOpenChange={onOpenChange}
onFocus={onFocus}
onBlur={onBlur}
onPanelChange={onPanelChange}
onOk={onOk}
/>
/>,
);
};
},
Expand Down
Loading