1
1
import { useEvent , useMergedState } from '@rc-component/util' ;
2
+ import cls from 'classnames' ;
2
3
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect' ;
3
4
import omit from '@rc-component/util/lib/omit' ;
4
5
import pickAttrs from '@rc-component/util/lib/pickAttrs' ;
@@ -35,6 +36,7 @@ import useRangeValue, { useInnerValue } from './hooks/useRangeValue';
35
36
import useShowNow from './hooks/useShowNow' ;
36
37
import Popup , { type PopupShowTimeConfig } from './Popup' ;
37
38
import RangeSelector , { type SelectorIdType } from './Selector/RangeSelector' ;
39
+ import useSemantic from '../hooks/useSemantic' ;
38
40
39
41
function separateConfig < T > ( config : T | [ T , T ] | null | undefined , defaultConfig : T ) : [ T , T ] {
40
42
const singleConfig = config ?? defaultConfig ;
@@ -158,8 +160,9 @@ function RangePicker<DateType extends object = any>(
158
160
const {
159
161
// Style
160
162
prefixCls,
161
- styles,
162
- classNames,
163
+ rootClassName,
164
+ styles : propStyles ,
165
+ classNames : propClassNames ,
163
166
164
167
// Value
165
168
defaultValue,
@@ -224,6 +227,9 @@ function RangePicker<DateType extends object = any>(
224
227
// ========================= Refs =========================
225
228
const selectorRef = usePickerRef ( ref ) ;
226
229
230
+ // ======================= Semantic =======================
231
+ const [ mergedClassNames , mergedStyles ] = useSemantic ( propClassNames , propStyles ) ;
232
+
227
233
// ========================= Open =========================
228
234
const [ mergedOpen , setMergeOpen ] = useOpen ( open , defaultOpen , disabled , onOpenChange ) ;
229
235
@@ -562,6 +568,8 @@ function RangePicker<DateType extends object = any>(
562
568
'className' ,
563
569
'onPanelChange' ,
564
570
'disabledTime' ,
571
+ 'classNames' ,
572
+ 'styles' ,
565
573
] ) ;
566
574
return restProps ;
567
575
} , [ filledProps ] ) ;
@@ -693,10 +701,18 @@ function RangePicker<DateType extends object = any>(
693
701
generateConfig,
694
702
button : components . button ,
695
703
input : components . input ,
696
- styles ,
697
- classNames ,
704
+ classNames : mergedClassNames ,
705
+ styles : mergedStyles ,
698
706
} ) ,
699
- [ prefixCls , locale , generateConfig , components . button , components . input , classNames , styles ] ,
707
+ [
708
+ prefixCls ,
709
+ locale ,
710
+ generateConfig ,
711
+ components . button ,
712
+ components . input ,
713
+ mergedClassNames ,
714
+ mergedStyles ,
715
+ ] ,
700
716
) ;
701
717
702
718
// ======================== Effect ========================
@@ -755,8 +771,8 @@ function RangePicker<DateType extends object = any>(
755
771
< PickerTrigger
756
772
{ ...pickTriggerProps ( filledProps ) }
757
773
popupElement = { panel }
758
- popupStyle = { styles . popup }
759
- popupClassName = { classNames . popup }
774
+ popupStyle = { mergedStyles . popup . root }
775
+ popupClassName = { cls ( rootClassName , mergedClassNames . popup . root ) }
760
776
// Visible
761
777
visible = { mergedOpen }
762
778
onClose = { onPopupClose }
@@ -768,6 +784,12 @@ function RangePicker<DateType extends object = any>(
768
784
{ ...filledProps }
769
785
// Ref
770
786
ref = { selectorRef }
787
+ // Style
788
+ className = { cls ( filledProps . className , rootClassName , mergedClassNames . root ) }
789
+ style = { {
790
+ ...mergedStyles . root ,
791
+ ...filledProps . style ,
792
+ } }
771
793
// Icon
772
794
suffixIcon = { suffixIcon }
773
795
// Active
0 commit comments