Skip to content

Commit 9b946fe

Browse files
committed
feat: support semantic for pannel
1 parent 001190e commit 9b946fe

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/PickerPanel/index.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,26 @@ export interface SinglePickerPanelProps<DateType extends object = any>
127127
onChange?: (date: DateType) => void;
128128
}
129129

130+
type PanelSemanticName = 'popupBody' | 'popupContent';
130131
export type PickerPanelProps<DateType extends object = any> = BasePickerPanelProps<DateType> & {
131132
/** multiple selection. Not support time or datetime picker */
132133
multiple?: boolean;
133134

134135
defaultValue?: DateType | DateType[] | null;
135136
value?: DateType | DateType[] | null;
136137
onChange?: (date: DateType | DateType[]) => void;
138+
styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
139+
classNames?: Partial<Record<PanelSemanticName, string>>;
137140
};
138141

139142
function PickerPanel<DateType extends object = any>(
140143
props: PickerPanelProps<DateType>,
141144
ref: React.Ref<PickerPanelRef>,
142145
) {
143146
const {
147+
classNames: panelClassNames,
148+
styles: panelStyles,
149+
144150
locale,
145151
generateConfig,
146152

@@ -187,7 +193,7 @@ function PickerPanel<DateType extends object = any>(
187193
const {
188194
prefixCls: contextPrefixCls,
189195
classNames: pickerClassNames,
190-
styles,
196+
styles: pickerStyles,
191197
} = React.useContext(PickerContext) || {};
192198

193199
// ======================== prefixCls ========================
@@ -372,10 +378,17 @@ function PickerPanel<DateType extends object = any>(
372378
DatePanel) as typeof DatePanel;
373379

374380
// ======================== Context =========================
381+
const mergedStyles = pickerStyles ?? panelStyles;
382+
const mergedClassNames = pickerClassNames ?? panelClassNames;
375383
const parentHackContext = React.useContext(PickerHackContext);
376384
const pickerPanelContext = React.useMemo(
377-
() => ({ ...parentHackContext, hideHeader, classNames: pickerClassNames, styles }),
378-
[parentHackContext, hideHeader, pickerClassNames, styles],
385+
() => ({
386+
...parentHackContext,
387+
hideHeader,
388+
classNames: mergedClassNames,
389+
styles: mergedStyles,
390+
}),
391+
[parentHackContext, hideHeader, mergedClassNames, mergedStyles],
379392
);
380393

381394
// ======================== Warnings ========================

0 commit comments

Comments
 (0)