Skip to content
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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,16 @@
"@rc-component/resize-observer": "^1.0.0",
"@rc-component/trigger": "^3.0.0",
"@rc-component/util": "^1.3.0",
"classnames": "^2.2.1",
"clsx": "^2.1.1",
"rc-overflow": "^1.3.2"
},
"engines": {
"node": ">=8.x"
},
"devDependencies": {
"devDependencies": {
"@rc-component/father-plugin": "^1.0.0",
"@rc-component/np":"^1.0.3",
"@rc-component/np": "^1.0.3",
"@testing-library/react": "^16.0.0",
"@types/classnames": "^2.2.9",
"@types/jest": "^29.4.0",
"@types/luxon": "^3.2.0",
"@types/node": "^24.5.2",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.8",
"coveralls": "^3.0.6",
Expand Down Expand Up @@ -103,5 +100,8 @@
"moment": {
"optional": true
}
},
"engines": {
"node": ">=8.x"
}
}
6 changes: 3 additions & 3 deletions src/PickerInput/Popup/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import * as React from 'react';
import type { GenerateConfig } from '../../generate';
import useTimeInfo from '../../hooks/useTimeInfo';
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function Footer(props: FooterProps) {
const presetNode = showNow && (
<li className={nowPrefixCls}>
<a
className={cls(nowBtnPrefixCls, nowDisabled && `${nowBtnPrefixCls}-disabled`)}
className={clsx(nowBtnPrefixCls, nowDisabled && `${nowBtnPrefixCls}-disabled`)}
aria-disabled={nowDisabled}
onClick={onInternalNow}
>
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function Footer(props: FooterProps) {

return (
<div
className={cls(`${prefixCls}-footer`, classNames.popup.footer)}
className={clsx(`${prefixCls}-footer`, classNames.popup.footer)}
style={styles.popup.footer}
>
{extraNode && <div className={`${prefixCls}-footer-extra`}>{extraNode}</div>}
Expand Down
6 changes: 3 additions & 3 deletions src/PickerInput/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames';
import { clsx } from 'clsx';
import ResizeObserver, { type ResizeObserverProps } from '@rc-component/resize-observer';
import * as React from 'react';
import type {
Expand Down Expand Up @@ -213,7 +213,7 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
<div
onMouseDown={onPanelMouseDown}
tabIndex={-1}
className={classNames(
className={clsx(
containerPrefixCls,
// Used for Today Button style, safe to remove if no need
`${prefixCls}-${internalMode}-panel-container`,
Expand All @@ -238,7 +238,7 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
<div
onMouseDown={onPanelMouseDown}
ref={wrapperRef}
className={classNames(`${prefixCls}-range-wrapper`, `${prefixCls}-${picker}-range-wrapper`)}
className={clsx(`${prefixCls}-range-wrapper`, `${prefixCls}-${picker}-range-wrapper`)}
>
<div ref={arrowRef} className={`${prefixCls}-range-arrow`} style={{ left: arrowOffset }} />

Expand Down
11 changes: 4 additions & 7 deletions src/PickerInput/RangePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEvent, useControlledState } from '@rc-component/util';
import cls from 'classnames';
import { clsx } from 'clsx';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import omit from '@rc-component/util/lib/omit';
import pickAttrs from '@rc-component/util/lib/pickAttrs';
Expand Down Expand Up @@ -777,7 +777,7 @@ function RangePicker<DateType extends object = any>(
{...pickTriggerProps(filledProps)}
popupElement={panel}
popupStyle={mergedStyles.popup.root}
popupClassName={cls(rootClassName, mergedClassNames.popup.root)}
popupClassName={clsx(rootClassName, mergedClassNames.popup.root)}
// Visible
visible={mergedOpen}
onClose={onPopupClose}
Expand All @@ -790,11 +790,8 @@ function RangePicker<DateType extends object = any>(
// Ref
ref={selectorRef}
// Style
className={cls(filledProps.className, rootClassName, mergedClassNames.root)}
style={{
...mergedStyles.root,
...filledProps.style,
}}
className={clsx(filledProps.className, rootClassName, mergedClassNames.root)}
style={{ ...mergedStyles.root, ...filledProps.style }}
// Icon
suffixIcon={suffixIcon}
// Active
Expand Down
4 changes: 2 additions & 2 deletions src/PickerInput/Selector/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import PickerContext from '../context';
import cls from 'classnames';
import { clsx } from 'clsx';

export interface IconProps extends React.HtmlHTMLAttributes<HTMLElement> {
icon?: React.ReactNode;
Expand All @@ -13,7 +13,7 @@ export default function Icon(props: IconProps) {

return icon ? (
<span
className={cls(`${prefixCls}-${type}`, classNames.suffix)}
className={clsx(`${prefixCls}-${type}`, classNames.suffix)}
style={styles.suffix}
{...restProps}
>
Expand Down
8 changes: 4 additions & 4 deletions src/PickerInput/Selector/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import { useEvent } from '@rc-component/util';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import raf from '@rc-component/util/lib/raf';
Expand Down Expand Up @@ -95,8 +95,8 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => {
}, [value]);

// ========================= Refs =========================
const holderRef = React.useRef<HTMLDivElement>();
const inputRef = React.useRef<HTMLInputElement>();
const holderRef = React.useRef<HTMLDivElement>(null);
const inputRef = React.useRef<HTMLInputElement>(null);

React.useImperativeHandle(ref, () => ({
nativeElement: holderRef.current,
Expand Down Expand Up @@ -383,7 +383,7 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => {
return (
<div
ref={holderRef}
className={cls(
className={clsx(
inputPrefixCls,
{
[`${inputPrefixCls}-active`]: active && showActiveCls,
Expand Down
6 changes: 3 additions & 3 deletions src/PickerInput/Selector/RangeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import ResizeObserver from '@rc-component/resize-observer';
import { useEvent } from '@rc-component/util';
import * as React from 'react';
Expand Down Expand Up @@ -211,7 +211,7 @@ function RangeSelector<DateType extends object = any>(
<ResizeObserver onResize={syncActiveOffset}>
<div
{...rootProps}
className={cls(
className={clsx(
prefixCls,
`${prefixCls}-range`,
{
Expand Down Expand Up @@ -239,7 +239,7 @@ function RangeSelector<DateType extends object = any>(
}}
>
{prefix && (
<div className={cls(`${prefixCls}-prefix`, classNames.prefix)} style={styles.prefix}>
<div className={clsx(`${prefixCls}-prefix`, classNames.prefix)} style={styles.prefix}>
{prefix}
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/PickerInput/Selector/SingleSelector/MultipleDates.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames';
import { clsx } from 'clsx';
import Overflow from 'rc-overflow';
import * as React from 'react';
import type { PickerProps } from '../../SinglePicker';
Expand Down Expand Up @@ -36,7 +36,7 @@ export default function MultipleDates<DateType extends object = any>(
function renderSelector(content: React.ReactNode, onClose?: React.MouseEventHandler) {
return (
<span
className={classNames(`${selectionCls}-item`)}
className={clsx(`${selectionCls}-item`)}
title={typeof content === 'string' ? content : null}
>
<span className={`${selectionCls}-item-content`}>{content}</span>
Expand Down
6 changes: 3 additions & 3 deletions src/PickerInput/Selector/SingleSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import * as React from 'react';
import type { InternalMode, PickerRef, SelectorProps } from '../../../interface';
import { isSame } from '../../../utils/dateUtil';
Expand Down Expand Up @@ -201,7 +201,7 @@ function SingleSelector<DateType extends object = any>(
return (
<div
{...rootProps}
className={cls(
className={clsx(
prefixCls,
{
[`${prefixCls}-multiple`]: multiple,
Expand All @@ -226,7 +226,7 @@ function SingleSelector<DateType extends object = any>(
}}
>
{prefix && (
<div className={cls(`${prefixCls}-prefix`, classNames.prefix)} style={styles.prefix}>
<div className={clsx(`${prefixCls}-prefix`, classNames.prefix)} style={styles.prefix}>
{prefix}
</div>
)}
Expand Down
11 changes: 4 additions & 7 deletions src/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEvent, useControlledState } from '@rc-component/util';
import cls from 'classnames';
import { clsx } from 'clsx';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import omit from '@rc-component/util/lib/omit';
import pickAttrs from '@rc-component/util/lib/pickAttrs';
Expand Down Expand Up @@ -638,7 +638,7 @@ function Picker<DateType extends object = any>(
{...pickTriggerProps(filledProps)}
popupElement={panel}
popupStyle={mergedStyles.popup.root}
popupClassName={cls(rootClassName, mergedClassNames.popup.root)}
popupClassName={clsx(rootClassName, mergedClassNames.popup.root)}
// Visible
visible={mergedOpen}
onClose={onPopupClose}
Expand All @@ -649,11 +649,8 @@ function Picker<DateType extends object = any>(
// Ref
ref={selectorRef}
// Style
className={cls(filledProps.className, rootClassName, mergedClassNames.root)}
style={{
...mergedStyles.root,
...filledProps.style,
}}
className={clsx(filledProps.className, rootClassName, mergedClassNames.root)}
style={{ ...mergedStyles.root, ...filledProps.style }}
// Icon
suffixIcon={suffixIcon}
removeIcon={removeIcon}
Expand Down
6 changes: 3 additions & 3 deletions src/PickerPanel/DatePanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames';
import { clsx } from 'clsx';
import * as React from 'react';
import type { PanelMode, SharedPanelProps } from '../../interface';
import {
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function DatePanel<DateType extends object = any>(props: DatePane
return (
<td
key="week"
className={classNames(cellPrefixCls, `${cellPrefixCls}-week`, {
className={clsx(cellPrefixCls, `${cellPrefixCls}-week`, {
[`${cellPrefixCls}-disabled`]: disabled,
})}
// Operation: Same as code in PanelBody
Expand Down Expand Up @@ -183,7 +183,7 @@ export default function DatePanel<DateType extends object = any>(props: DatePane
// ========================= Render =========================
return (
<PanelContext.Provider value={info}>
<div className={classNames(panelPrefixCls, showWeek && `${panelPrefixCls}-show-week`)}>
<div className={clsx(panelPrefixCls, showWeek && `${panelPrefixCls}-show-week`)}>
{/* Header */}
<PanelHeader<DateType>
offset={(distance) => generateConfig.addMonth(pickerValue, distance)}
Expand Down
8 changes: 4 additions & 4 deletions src/PickerPanel/PanelBody.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import * as React from 'react';
import type { DisabledDate } from '../interface';
import { formatValue, isInRange, isSame } from '../utils/dateUtil';
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function PanelBody<DateType extends object = any>(props: PanelBod
<td
key={col}
title={title}
className={cls(cellPrefixCls, classNames.item, {
className={clsx(cellPrefixCls, classNames.item, {
[`${cellPrefixCls}-disabled`]: disabled,
[`${cellPrefixCls}-hover`]: (hoverValue || []).some((date) =>
isSame(generateConfig, locale, currentDate, date, type),
Expand Down Expand Up @@ -184,8 +184,8 @@ export default function PanelBody<DateType extends object = any>(props: PanelBod

// ============================== Render ==============================
return (
<div className={cls(`${prefixCls}-body`, classNames.body)} style={styles.body}>
<table className={cls(`${prefixCls}-content`, classNames.content)} style={styles.content}>
<div className={clsx(`${prefixCls}-body`, classNames.body)} style={styles.body}>
<table className={clsx(`${prefixCls}-content`, classNames.content)} style={styles.content}>
{headerCells && (
<thead>
<tr>{headerCells}</tr>
Expand Down
18 changes: 12 additions & 6 deletions src/PickerPanel/PanelHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import * as React from 'react';
import { isSameOrAfter } from '../utils/dateUtil';
import { PickerHackContext, usePanelContext } from './context';
Expand Down Expand Up @@ -120,14 +120,17 @@ function PanelHeader<DateType extends object>(props: HeaderProps<DateType>) {
const superNextBtnCls = `${headerPrefixCls}-super-next-btn`;

return (
<div className={cls(headerPrefixCls, classNames.header)} style={styles.header}>
<div className={clsx(headerPrefixCls, classNames.header)} style={styles.header}>
{superOffset && (
<button
type="button"
aria-label={locale.previousYear}
onClick={() => onSuperOffset(-1)}
tabIndex={-1}
className={cls(superPrevBtnCls, disabledSuperOffsetPrev && `${superPrevBtnCls}-disabled`)}
className={clsx(
superPrevBtnCls,
disabledSuperOffsetPrev && `${superPrevBtnCls}-disabled`,
)}
disabled={disabledSuperOffsetPrev}
style={hidePrev ? HIDDEN_STYLE : {}}
>
Expand All @@ -140,7 +143,7 @@ function PanelHeader<DateType extends object>(props: HeaderProps<DateType>) {
aria-label={locale.previousMonth}
onClick={() => onOffset(-1)}
tabIndex={-1}
className={cls(prevBtnCls, disabledOffsetPrev && `${prevBtnCls}-disabled`)}
className={clsx(prevBtnCls, disabledOffsetPrev && `${prevBtnCls}-disabled`)}
disabled={disabledOffsetPrev}
style={hidePrev ? HIDDEN_STYLE : {}}
>
Expand All @@ -154,7 +157,7 @@ function PanelHeader<DateType extends object>(props: HeaderProps<DateType>) {
aria-label={locale.nextMonth}
onClick={() => onOffset(1)}
tabIndex={-1}
className={cls(nextBtnCls, disabledOffsetNext && `${nextBtnCls}-disabled`)}
className={clsx(nextBtnCls, disabledOffsetNext && `${nextBtnCls}-disabled`)}
disabled={disabledOffsetNext}
style={hideNext ? HIDDEN_STYLE : {}}
>
Expand All @@ -167,7 +170,10 @@ function PanelHeader<DateType extends object>(props: HeaderProps<DateType>) {
aria-label={locale.nextYear}
onClick={() => onSuperOffset(1)}
tabIndex={-1}
className={cls(superNextBtnCls, disabledSuperOffsetNext && `${superNextBtnCls}-disabled`)}
className={clsx(
superNextBtnCls,
disabledSuperOffsetNext && `${superNextBtnCls}-disabled`,
)}
disabled={disabledSuperOffsetNext}
style={hideNext ? HIDDEN_STYLE : {}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cls from 'classnames';
import { clsx } from 'clsx';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import * as React from 'react';
import { usePanelContext } from '../../context';
Expand Down Expand Up @@ -104,7 +104,7 @@ export default function TimeColumn<DateType extends object>(props: TimeUnitColum
<li
key={unitValue}
style={styles.item}
className={cls(cellPrefixCls, classNames.item, {
className={clsx(cellPrefixCls, classNames.item, {
[`${cellPrefixCls}-selected`]: value === unitValue,
[`${cellPrefixCls}-disabled`]: disabled,
})}
Expand Down
4 changes: 2 additions & 2 deletions src/PickerPanel/TimePanel/TimePanelBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { SharedPanelProps, SharedTimeProps } from '../../../interface';
import { formatValue } from '../../../utils/dateUtil';
import { PickerHackContext, usePanelContext } from '../../context';
import TimeColumn, { type Unit } from './TimeColumn';
import cls from 'classnames';
import { clsx } from 'clsx';

function isAM(hour: number) {
return hour < 12;
Expand Down Expand Up @@ -271,7 +271,7 @@ export default function TimePanelBody<DateType extends object = any>(
};

return (
<div className={cls(`${prefixCls}-content`, classNames.content)} style={styles.content}>
<div className={clsx(`${prefixCls}-content`, classNames.content)} style={styles.content}>
{showHour && (
<TimeColumn
units={hourUnits}
Expand Down
Loading