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
3 changes: 2 additions & 1 deletion src/PickerPanel/PanelBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function PanelBody<DateType extends object = any>(props: PanelBod
<td
key={col}
title={title}
className={classNames(cellPrefixCls, {
className={classNames(cellPrefixCls, pickerClassNames?.popupItem, {
[`${cellPrefixCls}-disabled`]: disabled,
[`${cellPrefixCls}-hover`]: (hoverValue || []).some((date) =>
isSame(generateConfig, locale, currentDate, date, type),
Expand All @@ -142,6 +142,7 @@ export default function PanelBody<DateType extends object = any>(props: PanelBod
matchValues(currentDate),
...getCellClassName(currentDate),
})}
style={styles?.popupItem}
onClick={() => {
if (!disabled) {
onSelect(currentDate);
Expand Down
2 changes: 1 addition & 1 deletion src/PickerPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export interface SinglePickerPanelProps<DateType extends object = any>
onChange?: (date: DateType) => void;
}

type PanelSemanticName = 'popupBody' | 'popupContent';
type PanelSemanticName = 'popupBody' | 'popupContent' | 'popupItem';
export type PickerPanelProps<DateType extends object = any> = BasePickerPanelProps<DateType> & {
/** multiple selection. Not support time or datetime picker */
multiple?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export type Components<DateType extends object = any> = Partial<
>;

// ========================= Picker =========================
export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent';
export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent' | 'popupItem';

export type CustomFormat<DateType> = (value: DateType) => string;

Expand Down
10 changes: 10 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1355,31 +1355,38 @@ describe('Picker.Basic', () => {
popup: 'custom-popup',
popupBody: 'custom-body',
popupContent: 'custom-content',
popupItem: 'custom-item',
};
const customStyles = {
popup: { color: 'red' },
popupBody: { color: 'green' },
popupContent: { color: 'blue' },
popupItem: { color: 'yellow' },
};
render(<DayPicker classNames={customClassNames} styles={customStyles} open />);

expect(document.querySelector('.rc-picker-dropdown')).toHaveClass(customClassNames.popup);
expect(document.querySelector('.rc-picker-dropdown')).toHaveStyle(customStyles.popup);
const content = document.querySelector('.rc-picker-content');
const body = document.querySelector('.rc-picker-body');
const item = document.querySelector('.rc-picker-cell');
expect(content).toHaveClass(customClassNames.popupContent);
expect(content).toHaveStyle(customStyles.popupContent);
expect(body).toHaveClass(customClassNames.popupBody);
expect(body).toHaveStyle(customStyles.popupBody);
expect(item).toHaveClass(customClassNames.popupItem);
expect(item).toHaveStyle(customStyles.popupItem);
});
it('support classNames and styles for panel', () => {
const customClassNames = {
popupBody: 'custom-body',
popupContent: 'custom-content',
popupItem: 'custom-item',
};
const customStyles = {
popupBody: { color: 'green' },
popupContent: { color: 'blue' },
popupItem: { color: 'yellow' },
};
render(
<PickerPanel
Expand All @@ -1391,10 +1398,13 @@ describe('Picker.Basic', () => {
);
const content = document.querySelector('.rc-picker-content');
const body = document.querySelector('.rc-picker-body');
const item = document.querySelector('.rc-picker-cell');
expect(content).toHaveClass(customClassNames.popupContent);
expect(content).toHaveStyle(customStyles.popupContent);
expect(body).toHaveClass(customClassNames.popupBody);
expect(body).toHaveStyle(customStyles.popupBody);
expect(item).toHaveClass(customClassNames.popupItem);
expect(item).toHaveStyle(customStyles.popupItem);
});
it('showTime config should have format', () => {
render(
Expand Down