@rc-component/picker 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/es/PickerInput/Popup/Footer.js +7 -4
  2. package/es/PickerInput/RangePicker.js +21 -8
  3. package/es/PickerInput/Selector/Icon.js +4 -4
  4. package/es/PickerInput/Selector/Input.js +6 -5
  5. package/es/PickerInput/Selector/RangeSelector.js +5 -5
  6. package/es/PickerInput/Selector/SingleSelector/index.js +5 -5
  7. package/es/PickerInput/Selector/hooks/useClearIcon.d.ts +1 -1
  8. package/es/PickerInput/SinglePicker.js +21 -8
  9. package/es/PickerInput/context.d.ts +4 -3
  10. package/es/PickerPanel/PanelBody.js +10 -10
  11. package/es/PickerPanel/PanelHeader.js +9 -6
  12. package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +7 -8
  13. package/es/PickerPanel/TimePanel/TimePanelBody/index.js +6 -6
  14. package/es/PickerPanel/context.d.ts +9 -3
  15. package/es/PickerPanel/context.js +10 -0
  16. package/es/PickerPanel/index.d.ts +1 -2
  17. package/es/PickerPanel/index.js +14 -9
  18. package/es/hooks/useSemantic.d.ts +13 -0
  19. package/es/hooks/useSemantic.js +21 -0
  20. package/es/interface.d.ts +9 -3
  21. package/es/utils/getClearIcon.d.ts +1 -1
  22. package/lib/PickerInput/Popup/Footer.js +5 -2
  23. package/lib/PickerInput/RangePicker.js +21 -8
  24. package/lib/PickerInput/Selector/Icon.js +3 -3
  25. package/lib/PickerInput/Selector/Input.js +5 -4
  26. package/lib/PickerInput/Selector/RangeSelector.js +3 -3
  27. package/lib/PickerInput/Selector/SingleSelector/index.js +3 -3
  28. package/lib/PickerInput/Selector/hooks/useClearIcon.d.ts +1 -1
  29. package/lib/PickerInput/SinglePicker.js +21 -8
  30. package/lib/PickerInput/context.d.ts +4 -3
  31. package/lib/PickerPanel/PanelBody.js +9 -9
  32. package/lib/PickerPanel/PanelHeader.js +4 -1
  33. package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +5 -6
  34. package/lib/PickerPanel/TimePanel/TimePanelBody/index.js +5 -5
  35. package/lib/PickerPanel/context.d.ts +9 -3
  36. package/lib/PickerPanel/context.js +11 -1
  37. package/lib/PickerPanel/index.d.ts +1 -2
  38. package/lib/PickerPanel/index.js +13 -8
  39. package/lib/hooks/useSemantic.d.ts +13 -0
  40. package/lib/hooks/useSemantic.js +27 -0
  41. package/lib/interface.d.ts +9 -3
  42. package/lib/utils/getClearIcon.d.ts +1 -1
  43. package/package.json +1 -1
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import classNames from 'classnames';
7
+ import cls from 'classnames';
8
8
  import * as React from 'react';
9
9
  import useTimeInfo from "../../hooks/useTimeInfo";
10
10
  import PickerContext from "../context";
@@ -24,7 +24,9 @@ export default function Footer(props) {
24
24
  prefixCls = _React$useContext.prefixCls,
25
25
  locale = _React$useContext.locale,
26
26
  _React$useContext$but = _React$useContext.button,
27
- Button = _React$useContext$but === void 0 ? 'button' : _React$useContext$but;
27
+ Button = _React$useContext$but === void 0 ? 'button' : _React$useContext$but,
28
+ classNames = _React$useContext.classNames,
29
+ styles = _React$useContext.styles;
28
30
 
29
31
  // >>> Now
30
32
  var now = generateConfig.getNow();
@@ -50,7 +52,7 @@ export default function Footer(props) {
50
52
  var presetNode = showNow && /*#__PURE__*/React.createElement("li", {
51
53
  className: nowPrefixCls
52
54
  }, /*#__PURE__*/React.createElement("a", {
53
- className: classNames(nowBtnPrefixCls, nowDisabled && "".concat(nowBtnPrefixCls, "-disabled")),
55
+ className: cls(nowBtnPrefixCls, nowDisabled && "".concat(nowBtnPrefixCls, "-disabled")),
54
56
  "aria-disabled": nowDisabled,
55
57
  onClick: onInternalNow
56
58
  }, internalMode === 'date' ? locale.today : locale.now));
@@ -71,7 +73,8 @@ export default function Footer(props) {
71
73
  return null;
72
74
  }
73
75
  return /*#__PURE__*/React.createElement("div", {
74
- className: "".concat(prefixCls, "-footer")
76
+ className: cls("".concat(prefixCls, "-footer"), classNames.popup.footer),
77
+ style: styles.popup.footer
75
78
  }, extraNode && /*#__PURE__*/React.createElement("div", {
76
79
  className: "".concat(prefixCls, "-footer-extra")
77
80
  }, extraNode), rangeNode);
@@ -16,6 +16,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
16
16
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  import { useEvent, useMergedState } from '@rc-component/util';
19
+ import cls from 'classnames';
19
20
  import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
20
21
  import omit from "@rc-component/util/es/omit";
21
22
  import pickAttrs from "@rc-component/util/es/pickAttrs";
@@ -38,6 +39,7 @@ import useRangeValue, { useInnerValue } from "./hooks/useRangeValue";
38
39
  import useShowNow from "./hooks/useShowNow";
39
40
  import Popup from "./Popup";
40
41
  import RangeSelector from "./Selector/RangeSelector";
42
+ import useSemantic from "../hooks/useSemantic";
41
43
  function separateConfig(config, defaultConfig) {
42
44
  var singleConfig = config !== null && config !== void 0 ? config : defaultConfig;
43
45
  if (Array.isArray(singleConfig)) {
@@ -71,8 +73,9 @@ function RangePicker(props, ref) {
71
73
  maskFormat = _useFilledProps2[4],
72
74
  isInvalidateDate = _useFilledProps2[5];
73
75
  var prefixCls = filledProps.prefixCls,
74
- styles = filledProps.styles,
75
- classNames = filledProps.classNames,
76
+ rootClassName = filledProps.rootClassName,
77
+ propStyles = filledProps.styles,
78
+ propClassNames = filledProps.classNames,
76
79
  defaultValue = filledProps.defaultValue,
77
80
  value = filledProps.value,
78
81
  needConfirm = filledProps.needConfirm,
@@ -113,6 +116,12 @@ function RangePicker(props, ref) {
113
116
  // ========================= Refs =========================
114
117
  var selectorRef = usePickerRef(ref);
115
118
 
119
+ // ======================= Semantic =======================
120
+ var _useSemantic = useSemantic(propClassNames, propStyles),
121
+ _useSemantic2 = _slicedToArray(_useSemantic, 2),
122
+ mergedClassNames = _useSemantic2[0],
123
+ mergedStyles = _useSemantic2[1];
124
+
116
125
  // ========================= Open =========================
117
126
  var _useOpen = useOpen(open, defaultOpen, disabled, onOpenChange),
118
127
  _useOpen2 = _slicedToArray(_useOpen, 2),
@@ -401,7 +410,7 @@ function RangePicker(props, ref) {
401
410
  });
402
411
  var panelProps = React.useMemo(function () {
403
412
  var domProps = pickAttrs(filledProps, false);
404
- var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime']));
413
+ var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime', 'classNames', 'styles']));
405
414
  return restProps;
406
415
  }, [filledProps]);
407
416
 
@@ -525,10 +534,10 @@ function RangePicker(props, ref) {
525
534
  generateConfig: generateConfig,
526
535
  button: components.button,
527
536
  input: components.input,
528
- styles: styles,
529
- classNames: classNames
537
+ classNames: mergedClassNames,
538
+ styles: mergedStyles
530
539
  };
531
- }, [prefixCls, locale, generateConfig, components.button, components.input, classNames, styles]);
540
+ }, [prefixCls, locale, generateConfig, components.button, components.input, mergedClassNames, mergedStyles]);
532
541
 
533
542
  // ======================== Effect ========================
534
543
  // >>> Mode
@@ -579,8 +588,8 @@ function RangePicker(props, ref) {
579
588
  value: context
580
589
  }, /*#__PURE__*/React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
581
590
  popupElement: panel,
582
- popupStyle: styles.popup,
583
- popupClassName: classNames.popup
591
+ popupStyle: mergedStyles.popup.root,
592
+ popupClassName: cls(rootClassName, mergedClassNames.popup.root)
584
593
  // Visible
585
594
  ,
586
595
  visible: mergedOpen,
@@ -593,6 +602,10 @@ function RangePicker(props, ref) {
593
602
  , _extends({}, filledProps, {
594
603
  // Ref
595
604
  ref: selectorRef
605
+ // Style
606
+ ,
607
+ className: cls(filledProps.className, rootClassName, mergedClassNames.root),
608
+ style: _objectSpread(_objectSpread({}, mergedStyles.root), filledProps.style)
596
609
  // Icon
597
610
  ,
598
611
  suffixIcon: suffixIcon
@@ -5,18 +5,18 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
  import * as React from 'react';
7
7
  import PickerContext from "../context";
8
- import classNames from 'classnames';
8
+ import cls from 'classnames';
9
9
  export default function Icon(props) {
10
10
  var icon = props.icon,
11
11
  type = props.type,
12
12
  restProps = _objectWithoutProperties(props, _excluded);
13
13
  var _React$useContext = React.useContext(PickerContext),
14
14
  prefixCls = _React$useContext.prefixCls,
15
- iconClassNames = _React$useContext.classNames,
15
+ classNames = _React$useContext.classNames,
16
16
  styles = _React$useContext.styles;
17
17
  return icon ? /*#__PURE__*/React.createElement("span", _extends({
18
- className: classNames("".concat(prefixCls, "-").concat(type), iconClassNames === null || iconClassNames === void 0 ? void 0 : iconClassNames.suffix),
19
- style: styles === null || styles === void 0 ? void 0 : styles.suffix
18
+ className: cls("".concat(prefixCls, "-").concat(type), classNames.suffix),
19
+ style: styles.suffix
20
20
  }, restProps), icon) : null;
21
21
  }
22
22
  export function ClearIcon(_ref) {
@@ -12,7 +12,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
14
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
- import classNames from 'classnames';
15
+ import cls from 'classnames';
16
16
  import { useEvent } from '@rc-component/util';
17
17
  import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
18
18
  import raf from "@rc-component/util/es/raf";
@@ -63,7 +63,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
63
63
  prefixCls = _React$useContext.prefixCls,
64
64
  _React$useContext$inp = _React$useContext.input,
65
65
  Component = _React$useContext$inp === void 0 ? 'input' : _React$useContext$inp,
66
- inputClassNames = _React$useContext.classNames,
66
+ classNames = _React$useContext.classNames,
67
67
  styles = _React$useContext.styles;
68
68
  var inputPrefixCls = "".concat(prefixCls, "-input");
69
69
 
@@ -356,8 +356,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
356
356
  } : {};
357
357
  return /*#__PURE__*/React.createElement("div", {
358
358
  ref: holderRef,
359
- className: classNames(inputPrefixCls, inputClassNames === null || inputClassNames === void 0 ? void 0 : inputClassNames.input, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped), className),
360
- style: styles === null || styles === void 0 ? void 0 : styles.input
359
+ className: cls(inputPrefixCls, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped), className)
361
360
  }, /*#__PURE__*/React.createElement(Component, _extends({
362
361
  ref: inputRef,
363
362
  "aria-invalid": invalid,
@@ -369,7 +368,9 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
369
368
  }, inputProps, {
370
369
  // Value
371
370
  value: inputValue,
372
- onChange: onInternalChange
371
+ onChange: onInternalChange,
372
+ className: classNames.input,
373
+ style: styles.input
373
374
  })), /*#__PURE__*/React.createElement(Icon, {
374
375
  type: "suffix",
375
376
  icon: suffixIcon
@@ -15,7 +15,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
- import classNames from 'classnames';
18
+ import cls from 'classnames';
19
19
  import ResizeObserver from '@rc-component/resize-observer';
20
20
  import { useEvent } from '@rc-component/util';
21
21
  import * as React from 'react';
@@ -71,7 +71,7 @@ function RangeSelector(props, ref) {
71
71
  // ======================== Prefix ========================
72
72
  var _React$useContext = React.useContext(PickerContext),
73
73
  prefixCls = _React$useContext.prefixCls,
74
- selectorClassNames = _React$useContext.classNames,
74
+ classNames = _React$useContext.classNames,
75
75
  styles = _React$useContext.styles;
76
76
 
77
77
  // ========================== Id ==========================
@@ -169,7 +169,7 @@ function RangeSelector(props, ref) {
169
169
  return /*#__PURE__*/React.createElement(ResizeObserver, {
170
170
  onResize: syncActiveOffset
171
171
  }, /*#__PURE__*/React.createElement("div", _extends({}, rootProps, {
172
- className: classNames(prefixCls, "".concat(prefixCls, "-range"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled.every(function (i) {
172
+ className: cls(prefixCls, "".concat(prefixCls, "-range"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled.every(function (i) {
173
173
  return i;
174
174
  })), "".concat(prefixCls, "-invalid"), invalid.some(function (i) {
175
175
  return i;
@@ -187,8 +187,8 @@ function RangeSelector(props, ref) {
187
187
  _onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
188
188
  }
189
189
  }), prefix && /*#__PURE__*/React.createElement("div", {
190
- className: classNames("".concat(prefixCls, "-prefix"), selectorClassNames === null || selectorClassNames === void 0 ? void 0 : selectorClassNames.prefix),
191
- style: styles === null || styles === void 0 ? void 0 : styles.prefix
190
+ className: cls("".concat(prefixCls, "-prefix"), classNames.prefix),
191
+ style: styles.prefix
192
192
  }, prefix), /*#__PURE__*/React.createElement(Input, _extends({
193
193
  ref: inputStartRef
194
194
  }, getInputProps(0), {
@@ -14,7 +14,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
16
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
17
- import classNames from 'classnames';
17
+ import cls from 'classnames';
18
18
  import * as React from 'react';
19
19
  import { isSame } from "../../../utils/dateUtil";
20
20
  import PickerContext from "../../context";
@@ -70,7 +70,7 @@ function SingleSelector(props, ref) {
70
70
  // ======================== Prefix ========================
71
71
  var _React$useContext = React.useContext(PickerContext),
72
72
  prefixCls = _React$useContext.prefixCls,
73
- selectorClassNames = _React$useContext.classNames,
73
+ classNames = _React$useContext.classNames,
74
74
  styles = _React$useContext.styles;
75
75
 
76
76
  // ========================= Refs =========================
@@ -164,7 +164,7 @@ function SingleSelector(props, ref) {
164
164
 
165
165
  // ======================== Render ========================
166
166
  return /*#__PURE__*/React.createElement("div", _extends({}, rootProps, {
167
- className: classNames(prefixCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-multiple"), multiple), "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-invalid"), invalid), "".concat(prefixCls, "-rtl"), rtl), className),
167
+ className: cls(prefixCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-multiple"), multiple), "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-invalid"), invalid), "".concat(prefixCls, "-rtl"), rtl), className),
168
168
  style: style,
169
169
  ref: rootRef,
170
170
  onClick: onClick
@@ -179,8 +179,8 @@ function SingleSelector(props, ref) {
179
179
  _onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
180
180
  }
181
181
  }), prefix && /*#__PURE__*/React.createElement("div", {
182
- className: classNames("".concat(prefixCls, "-prefix"), selectorClassNames === null || selectorClassNames === void 0 ? void 0 : selectorClassNames.prefix),
183
- style: styles === null || styles === void 0 ? void 0 : styles.prefix
182
+ className: cls("".concat(prefixCls, "-prefix"), classNames.prefix),
183
+ style: styles.prefix
184
184
  }, prefix), selectorNode);
185
185
  }
186
186
  var RefSingleSelector = /*#__PURE__*/React.forwardRef(SingleSelector);
@@ -5,4 +5,4 @@ import * as React from 'react';
5
5
  */
6
6
  export declare function fillClearIcon(prefixCls: string, allowClear?: boolean | {
7
7
  clearIcon?: ReactNode;
8
- }, clearIcon?: ReactNode): string | number | true | Iterable<ReactNode> | React.JSX.Element;
8
+ }, clearIcon?: ReactNode): string | number | true | React.JSX.Element | Iterable<ReactNode>;
@@ -16,6 +16,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
16
16
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  import { useEvent, useMergedState } from '@rc-component/util';
19
+ import cls from 'classnames';
19
20
  import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
20
21
  import omit from "@rc-component/util/es/omit";
21
22
  import pickAttrs from "@rc-component/util/es/pickAttrs";
@@ -37,6 +38,7 @@ import useRangeValue, { useInnerValue } from "./hooks/useRangeValue";
37
38
  import useShowNow from "./hooks/useShowNow";
38
39
  import Popup from "./Popup";
39
40
  import SingleSelector from "./Selector/SingleSelector";
41
+ import useSemantic from "../hooks/useSemantic";
40
42
 
41
43
  // TODO: isInvalidateDate with showTime.disabledTime should not provide `range` prop
42
44
 
@@ -54,8 +56,9 @@ function Picker(props, ref) {
54
56
  isInvalidateDate = _useFilledProps2[5];
55
57
  var _ref = filledProps,
56
58
  prefixCls = _ref.prefixCls,
57
- styles = _ref.styles,
58
- classNames = _ref.classNames,
59
+ rootClassName = _ref.rootClassName,
60
+ propStyles = _ref.styles,
61
+ propClassNames = _ref.classNames,
59
62
  order = _ref.order,
60
63
  defaultValue = _ref.defaultValue,
61
64
  value = _ref.value,
@@ -107,6 +110,12 @@ function Picker(props, ref) {
107
110
  }
108
111
  var toggleDates = useToggleDates(generateConfig, locale, internalPicker);
109
112
 
113
+ // ======================= Semantic =======================
114
+ var _useSemantic = useSemantic(propClassNames, propStyles),
115
+ _useSemantic2 = _slicedToArray(_useSemantic, 2),
116
+ mergedClassNames = _useSemantic2[0],
117
+ mergedStyles = _useSemantic2[1];
118
+
110
119
  // ========================= Open =========================
111
120
  var _useOpen = useOpen(open, defaultOpen, [disabled], onOpenChange),
112
121
  _useOpen2 = _slicedToArray(_useOpen, 2),
@@ -350,7 +359,7 @@ function Picker(props, ref) {
350
359
 
351
360
  var panelProps = React.useMemo(function () {
352
361
  var domProps = pickAttrs(filledProps, false);
353
- var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange']));
362
+ var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'classNames', 'styles']));
354
363
  return _objectSpread(_objectSpread({}, restProps), {}, {
355
364
  multiple: filledProps.multiple
356
365
  });
@@ -447,10 +456,10 @@ function Picker(props, ref) {
447
456
  generateConfig: generateConfig,
448
457
  button: components.button,
449
458
  input: components.input,
450
- styles: styles,
451
- classNames: classNames
459
+ classNames: mergedClassNames,
460
+ styles: mergedStyles
452
461
  };
453
- }, [prefixCls, locale, generateConfig, components.button, components.input, styles, classNames]);
462
+ }, [prefixCls, locale, generateConfig, components.button, components.input, mergedClassNames, mergedStyles]);
454
463
 
455
464
  // ======================== Effect ========================
456
465
  // >>> Mode
@@ -483,8 +492,8 @@ function Picker(props, ref) {
483
492
  value: context
484
493
  }, /*#__PURE__*/React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
485
494
  popupElement: panel,
486
- popupStyle: styles.popup,
487
- popupClassName: classNames.popup
495
+ popupStyle: mergedStyles.popup.root,
496
+ popupClassName: cls(rootClassName, mergedClassNames.popup.root)
488
497
  // Visible
489
498
  ,
490
499
  visible: mergedOpen,
@@ -494,6 +503,10 @@ function Picker(props, ref) {
494
503
  , _extends({}, filledProps, {
495
504
  // Ref
496
505
  ref: selectorRef
506
+ // Style
507
+ ,
508
+ className: cls(filledProps.className, rootClassName, mergedClassNames.root),
509
+ style: _objectSpread(_objectSpread({}, mergedStyles.root), filledProps.style)
497
510
  // Icon
498
511
  ,
499
512
  suffixIcon: suffixIcon,
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { GenerateConfig } from '../generate';
3
- import type { Components, Locale, SemanticStructure } from '../interface';
3
+ import type { Components, Locale } from '../interface';
4
+ import type { FilledClassNames, FilledStyles } from '../hooks/useSemantic';
4
5
  export interface PickerContextProps<DateType = any> {
5
6
  prefixCls: string;
6
7
  locale: Locale;
@@ -8,8 +9,8 @@ export interface PickerContextProps<DateType = any> {
8
9
  /** Customize button component */
9
10
  button?: Components['button'];
10
11
  input?: Components['input'];
11
- styles?: Partial<Record<SemanticStructure, React.CSSProperties>>;
12
- classNames?: Partial<Record<SemanticStructure, string>>;
12
+ classNames: FilledClassNames;
13
+ styles: FilledStyles;
13
14
  }
14
15
  declare const PickerContext: React.Context<PickerContextProps<any>>;
15
16
  export default PickerContext;
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import classNames from 'classnames';
13
+ import cls from 'classnames';
14
14
  import * as React from 'react';
15
15
  import { formatValue, isInRange, isSame } from "../utils/dateUtil";
16
16
  import { PickerHackContext, usePanelContext } from "./context";
@@ -30,6 +30,8 @@ export default function PanelBody(props) {
30
30
  disabledDate = props.disabledDate;
31
31
  var _usePanelContext = usePanelContext(),
32
32
  prefixCls = _usePanelContext.prefixCls,
33
+ classNames = _usePanelContext.classNames,
34
+ styles = _usePanelContext.styles,
33
35
  type = _usePanelContext.panelType,
34
36
  now = _usePanelContext.now,
35
37
  contextDisabledDate = _usePanelContext.disabledDate,
@@ -46,9 +48,7 @@ export default function PanelBody(props) {
46
48
 
47
49
  // ============================= Context ==============================
48
50
  var _React$useContext = React.useContext(PickerHackContext),
49
- onCellDblClick = _React$useContext.onCellDblClick,
50
- pickerClassNames = _React$useContext.classNames,
51
- styles = _React$useContext.styles;
51
+ onCellDblClick = _React$useContext.onCellDblClick;
52
52
 
53
53
  // ============================== Value ===============================
54
54
  var matchValues = function matchValues(date) {
@@ -104,12 +104,12 @@ export default function PanelBody(props) {
104
104
  rowNode.push( /*#__PURE__*/React.createElement("td", {
105
105
  key: col,
106
106
  title: title,
107
- className: classNames(cellPrefixCls, pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popupItem, _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function (date) {
107
+ className: cls(cellPrefixCls, classNames.item, _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function (date) {
108
108
  return isSame(generateConfig, locale, currentDate, date, type);
109
109
  })), "".concat(cellPrefixCls, "-in-range"), inRange && !rangeStart && !rangeEnd), "".concat(cellPrefixCls, "-range-start"), rangeStart), "".concat(cellPrefixCls, "-range-end"), rangeEnd), "".concat(prefixCls, "-cell-selected"), !hoverRangeValue &&
110
110
  // WeekPicker use row instead
111
111
  type !== 'week' && matchValues(currentDate)), getCellClassName(currentDate))),
112
- style: styles === null || styles === void 0 ? void 0 : styles.popupItem,
112
+ style: styles.item,
113
113
  onClick: function onClick() {
114
114
  if (!disabled) {
115
115
  onSelect(currentDate);
@@ -149,10 +149,10 @@ export default function PanelBody(props) {
149
149
 
150
150
  // ============================== Render ==============================
151
151
  return /*#__PURE__*/React.createElement("div", {
152
- className: classNames("".concat(prefixCls, "-body"), pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popupBody),
153
- style: styles === null || styles === void 0 ? void 0 : styles.popupBody
152
+ className: cls("".concat(prefixCls, "-body"), classNames.body),
153
+ style: styles.body
154
154
  }, /*#__PURE__*/React.createElement("table", {
155
- className: classNames("".concat(prefixCls, "-content"), pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popupContent),
156
- style: styles === null || styles === void 0 ? void 0 : styles.popupContent
155
+ className: cls("".concat(prefixCls, "-content"), classNames.content),
156
+ style: styles.content
157
157
  }, headerCells && /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, headerCells)), /*#__PURE__*/React.createElement("tbody", null, rows)));
158
158
  }
@@ -1,4 +1,4 @@
1
- import classNames from 'classnames';
1
+ import cls from 'classnames';
2
2
  import * as React from 'react';
3
3
  import { isSameOrAfter } from "../utils/dateUtil";
4
4
  import { PickerHackContext, usePanelContext } from "./context";
@@ -14,6 +14,8 @@ function PanelHeader(props) {
14
14
  children = props.children;
15
15
  var _usePanelContext = usePanelContext(),
16
16
  prefixCls = _usePanelContext.prefixCls,
17
+ classNames = _usePanelContext.classNames,
18
+ styles = _usePanelContext.styles,
17
19
  _usePanelContext$prev = _usePanelContext.prevIcon,
18
20
  prevIcon = _usePanelContext$prev === void 0 ? "\u2039" : _usePanelContext$prev,
19
21
  _usePanelContext$next = _usePanelContext.nextIcon,
@@ -85,7 +87,8 @@ function PanelHeader(props) {
85
87
  var superPrevBtnCls = "".concat(headerPrefixCls, "-super-prev-btn");
86
88
  var superNextBtnCls = "".concat(headerPrefixCls, "-super-next-btn");
87
89
  return /*#__PURE__*/React.createElement("div", {
88
- className: headerPrefixCls
90
+ className: cls(headerPrefixCls, classNames.header),
91
+ style: styles.header
89
92
  }, superOffset && /*#__PURE__*/React.createElement("button", {
90
93
  type: "button",
91
94
  "aria-label": locale.previousYear,
@@ -93,7 +96,7 @@ function PanelHeader(props) {
93
96
  return onSuperOffset(-1);
94
97
  },
95
98
  tabIndex: -1,
96
- className: classNames(superPrevBtnCls, disabledSuperOffsetPrev && "".concat(superPrevBtnCls, "-disabled")),
99
+ className: cls(superPrevBtnCls, disabledSuperOffsetPrev && "".concat(superPrevBtnCls, "-disabled")),
97
100
  disabled: disabledSuperOffsetPrev,
98
101
  style: hidePrev ? HIDDEN_STYLE : {}
99
102
  }, superPrevIcon), offset && /*#__PURE__*/React.createElement("button", {
@@ -103,7 +106,7 @@ function PanelHeader(props) {
103
106
  return onOffset(-1);
104
107
  },
105
108
  tabIndex: -1,
106
- className: classNames(prevBtnCls, disabledOffsetPrev && "".concat(prevBtnCls, "-disabled")),
109
+ className: cls(prevBtnCls, disabledOffsetPrev && "".concat(prevBtnCls, "-disabled")),
107
110
  disabled: disabledOffsetPrev,
108
111
  style: hidePrev ? HIDDEN_STYLE : {}
109
112
  }, prevIcon), /*#__PURE__*/React.createElement("div", {
@@ -115,7 +118,7 @@ function PanelHeader(props) {
115
118
  return onOffset(1);
116
119
  },
117
120
  tabIndex: -1,
118
- className: classNames(nextBtnCls, disabledOffsetNext && "".concat(nextBtnCls, "-disabled")),
121
+ className: cls(nextBtnCls, disabledOffsetNext && "".concat(nextBtnCls, "-disabled")),
119
122
  disabled: disabledOffsetNext,
120
123
  style: hideNext ? HIDDEN_STYLE : {}
121
124
  }, nextIcon), superOffset && /*#__PURE__*/React.createElement("button", {
@@ -125,7 +128,7 @@ function PanelHeader(props) {
125
128
  return onSuperOffset(1);
126
129
  },
127
130
  tabIndex: -1,
128
- className: classNames(superNextBtnCls, disabledSuperOffsetNext && "".concat(superNextBtnCls, "-disabled")),
131
+ className: cls(superNextBtnCls, disabledSuperOffsetNext && "".concat(superNextBtnCls, "-disabled")),
129
132
  disabled: disabledSuperOffsetNext,
130
133
  style: hideNext ? HIDDEN_STYLE : {}
131
134
  }, superNextIcon));
@@ -12,10 +12,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
12
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
13
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
- import classNames from 'classnames';
15
+ import cls from 'classnames';
16
16
  import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
17
17
  import * as React from 'react';
18
- import { PickerHackContext, usePanelContext } from "../../context";
18
+ import { usePanelContext } from "../../context";
19
19
  import useScrollTo from "./useScrollTo";
20
20
  var SCROLL_DELAY = 300;
21
21
  // Not use JSON.stringify to avoid dead loop
@@ -40,10 +40,9 @@ export default function TimeColumn(props) {
40
40
  prefixCls = _usePanelContext.prefixCls,
41
41
  cellRender = _usePanelContext.cellRender,
42
42
  now = _usePanelContext.now,
43
- locale = _usePanelContext.locale;
44
- var _React$useContext = React.useContext(PickerHackContext),
45
- pickerClassNames = _React$useContext.classNames,
46
- styles = _React$useContext.styles;
43
+ locale = _usePanelContext.locale,
44
+ classNames = _usePanelContext.classNames,
45
+ styles = _usePanelContext.styles;
47
46
  var panelPrefixCls = "".concat(prefixCls, "-time-panel");
48
47
  var cellPrefixCls = "".concat(prefixCls, "-time-panel-cell");
49
48
 
@@ -122,8 +121,8 @@ export default function TimeColumn(props) {
122
121
  }, label);
123
122
  return /*#__PURE__*/React.createElement("li", {
124
123
  key: unitValue,
125
- style: styles === null || styles === void 0 ? void 0 : styles.popupItem,
126
- className: classNames(cellPrefixCls, pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popupItem, _defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-selected"), value === unitValue), "".concat(cellPrefixCls, "-disabled"), disabled)),
124
+ style: styles.item,
125
+ className: cls(cellPrefixCls, classNames.item, _defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-selected"), value === unitValue), "".concat(cellPrefixCls, "-disabled"), disabled)),
127
126
  onClick: function onClick() {
128
127
  if (!disabled) {
129
128
  onChange(unitValue);
@@ -10,7 +10,7 @@ import useTimeInfo from "../../../hooks/useTimeInfo";
10
10
  import { formatValue } from "../../../utils/dateUtil";
11
11
  import { PickerHackContext, usePanelContext } from "../../context";
12
12
  import TimeColumn from "./TimeColumn";
13
- import classNames from 'classnames';
13
+ import cls from 'classnames';
14
14
  function isAM(hour) {
15
15
  return hour < 12;
16
16
  }
@@ -23,6 +23,8 @@ export default function TimePanelBody(props) {
23
23
  changeOnScroll = props.changeOnScroll;
24
24
  var _usePanelContext = usePanelContext(),
25
25
  prefixCls = _usePanelContext.prefixCls,
26
+ classNames = _usePanelContext.classNames,
27
+ styles = _usePanelContext.styles,
26
28
  values = _usePanelContext.values,
27
29
  generateConfig = _usePanelContext.generateConfig,
28
30
  locale = _usePanelContext.locale,
@@ -32,9 +34,7 @@ export default function TimePanelBody(props) {
32
34
  pickerValue = _usePanelContext.pickerValue;
33
35
  var value = (values === null || values === void 0 ? void 0 : values[0]) || null;
34
36
  var _React$useContext = React.useContext(PickerHackContext),
35
- onCellDblClick = _React$useContext.onCellDblClick,
36
- pickerClassNames = _React$useContext.classNames,
37
- styles = _React$useContext.styles;
37
+ onCellDblClick = _React$useContext.onCellDblClick;
38
38
 
39
39
  // ========================== Info ==========================
40
40
  var _useTimeInfo = useTimeInfo(generateConfig, props, value),
@@ -247,8 +247,8 @@ export default function TimePanelBody(props) {
247
247
  changeOnScroll: changeOnScroll
248
248
  };
249
249
  return /*#__PURE__*/React.createElement("div", {
250
- className: classNames("".concat(prefixCls, "-content"), pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popupContent),
251
- style: styles === null || styles === void 0 ? void 0 : styles.popupContent
250
+ className: cls("".concat(prefixCls, "-content"), classNames.content),
251
+ style: styles.content
252
252
  }, showHour && /*#__PURE__*/React.createElement(TimeColumn, _extends({
253
253
  units: hourUnits,
254
254
  value: hour,
@@ -1,9 +1,17 @@
1
1
  import * as React from 'react';
2
- import type { PanelMode, SemanticStructure, SharedPanelProps } from '../interface';
2
+ import type { PanelMode, SharedPanelProps } from '../interface';
3
+ import type { FilledPanelClassNames, FilledPanelStyles } from '../hooks/useSemantic';
4
+ export interface SharedPanelContextProps {
5
+ classNames: FilledPanelClassNames;
6
+ styles: FilledPanelStyles;
7
+ }
8
+ export declare const SharedPanelContext: React.Context<SharedPanelContextProps>;
3
9
  export interface PanelContextProps<DateType extends object = any> extends Pick<SharedPanelProps<DateType>, 'prefixCls' | 'cellRender' | 'generateConfig' | 'locale' | 'onSelect' | 'hoverValue' | 'hoverRangeValue' | 'onHover' | 'values' | 'pickerValue' | 'disabledDate' | 'minDate' | 'maxDate' | 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'> {
4
10
  /** Tell current panel type */
5
11
  panelType: PanelMode;
6
12
  now: DateType;
13
+ classNames: FilledPanelClassNames;
14
+ styles: FilledPanelStyles;
7
15
  }
8
16
  /** Used for each single Panel. e.g. DatePanel */
9
17
  export declare const PanelContext: React.Context<PanelContextProps<any>>;
@@ -17,8 +25,6 @@ export interface PickerHackContextProps {
17
25
  hideNext?: boolean;
18
26
  hideHeader?: boolean;
19
27
  onCellDblClick?: () => void;
20
- styles?: Partial<Record<SemanticStructure, React.CSSProperties>>;
21
- classNames?: Partial<Record<SemanticStructure, string>>;
22
28
  }
23
29
  /**
24
30
  * Internal usage for RangePicker to not to show the operation arrow