@rc-component/picker 1.2.4 → 1.4.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 (48) hide show
  1. package/README.md +3 -1
  2. package/es/PickerInput/Popup/Footer.js +7 -4
  3. package/es/PickerInput/RangePicker.js +31 -12
  4. package/es/PickerInput/Selector/Icon.js +4 -4
  5. package/es/PickerInput/Selector/Input.js +6 -5
  6. package/es/PickerInput/Selector/RangeSelector.js +5 -5
  7. package/es/PickerInput/Selector/SingleSelector/index.js +5 -5
  8. package/es/PickerInput/SinglePicker.js +31 -12
  9. package/es/PickerInput/context.d.ts +4 -3
  10. package/es/PickerInput/hooks/useFilledProps.d.ts +1 -1
  11. package/es/PickerInput/hooks/useFilledProps.js +3 -0
  12. package/es/PickerPanel/PanelBody.js +10 -10
  13. package/es/PickerPanel/PanelHeader.js +9 -6
  14. package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +7 -8
  15. package/es/PickerPanel/TimePanel/TimePanelBody/index.js +6 -6
  16. package/es/PickerPanel/context.d.ts +9 -3
  17. package/es/PickerPanel/context.js +10 -0
  18. package/es/PickerPanel/index.d.ts +2 -11
  19. package/es/PickerPanel/index.js +14 -9
  20. package/es/hooks/useSemantic.d.ts +13 -0
  21. package/es/hooks/useSemantic.js +21 -0
  22. package/es/interface.d.ts +16 -3
  23. package/es/locale/te_IN.d.ts +3 -0
  24. package/es/locale/te_IN.js +33 -0
  25. package/lib/PickerInput/Popup/Footer.js +5 -2
  26. package/lib/PickerInput/RangePicker.js +31 -12
  27. package/lib/PickerInput/Selector/Icon.js +3 -3
  28. package/lib/PickerInput/Selector/Input.js +5 -4
  29. package/lib/PickerInput/Selector/RangeSelector.js +3 -3
  30. package/lib/PickerInput/Selector/SingleSelector/index.js +3 -3
  31. package/lib/PickerInput/SinglePicker.js +31 -12
  32. package/lib/PickerInput/context.d.ts +4 -3
  33. package/lib/PickerInput/hooks/useFilledProps.d.ts +1 -1
  34. package/lib/PickerInput/hooks/useFilledProps.js +3 -0
  35. package/lib/PickerPanel/PanelBody.js +9 -9
  36. package/lib/PickerPanel/PanelHeader.js +4 -1
  37. package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +5 -6
  38. package/lib/PickerPanel/TimePanel/TimePanelBody/index.js +5 -5
  39. package/lib/PickerPanel/context.d.ts +9 -3
  40. package/lib/PickerPanel/context.js +11 -1
  41. package/lib/PickerPanel/index.d.ts +2 -11
  42. package/lib/PickerPanel/index.js +13 -8
  43. package/lib/hooks/useSemantic.d.ts +13 -0
  44. package/lib/hooks/useSemantic.js +27 -0
  45. package/lib/interface.d.ts +16 -3
  46. package/lib/locale/te_IN.d.ts +3 -0
  47. package/lib/locale/te_IN.js +39 -0
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -54,6 +54,7 @@ render(<Picker />, mountNode);
54
54
  | autoFocus | boolean | false | whether auto focus |
55
55
  | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection |
56
56
  | picker | time \| date \| week \| month \| year | | control which kind of panel should be shown |
57
+ | previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change |
57
58
  | format | String \| String[] | depends on whether you set timePicker and your locale | use to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display |
58
59
  | use12Hours | boolean | false | 12 hours display mode |
59
60
  | value | moment | | current value like input's value |
@@ -102,7 +103,7 @@ render(<Picker />, mountNode);
102
103
  ### RangePicker
103
104
 
104
105
  | Property | Type | Default | Description |
105
- | --- | --- | --- | --- |
106
+ | --- | --- | --- | --- | --- |
106
107
  | prefixCls | String | rc-picker | prefixCls of this component |
107
108
  | className | String | '' | additional css class of root dom |
108
109
  | style | React.CSSProperties | | additional style of root dom node |
@@ -112,6 +113,7 @@ render(<Picker />, mountNode);
112
113
  | defaultPickerValue | moment | | Set default display picker view date |
113
114
  | separator | String | '~' | set separator between inputs |
114
115
  | picker | time \| date \| week \| month \| year | | control which kind of panel |
116
+ | previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change |
115
117
  | placeholder | [String, String] | | placeholder of date input |
116
118
  | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection |
117
119
  | showTime.defaultValue | [moment, moment] | | to set default time of selected date |
@@ -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,10 @@ 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,
79
+ previewValue = filledProps.previewValue,
76
80
  defaultValue = filledProps.defaultValue,
77
81
  value = filledProps.value,
78
82
  needConfirm = filledProps.needConfirm,
@@ -113,6 +117,12 @@ function RangePicker(props, ref) {
113
117
  // ========================= Refs =========================
114
118
  var selectorRef = usePickerRef(ref);
115
119
 
120
+ // ======================= Semantic =======================
121
+ var _useSemantic = useSemantic(propClassNames, propStyles),
122
+ _useSemantic2 = _slicedToArray(_useSemantic, 2),
123
+ mergedClassNames = _useSemantic2[0],
124
+ mergedStyles = _useSemantic2[1];
125
+
116
126
  // ========================= Open =========================
117
127
  var _useOpen = useOpen(open, defaultOpen, disabled, onOpenChange),
118
128
  _useOpen2 = _slicedToArray(_useOpen, 2),
@@ -331,12 +341,18 @@ function RangePicker(props, ref) {
331
341
  _React$useState6 = _slicedToArray(_React$useState5, 2),
332
342
  activeInfo = _React$useState6[0],
333
343
  setActiveInfo = _React$useState6[1];
344
+ var onSetHover = function onSetHover(date, source) {
345
+ if (previewValue !== 'hover') {
346
+ return;
347
+ }
348
+ setInternalHoverValues(date);
349
+ setHoverSource(source);
350
+ };
334
351
 
335
352
  // ======================= Presets ========================
336
353
  var presetList = usePresets(presets, ranges);
337
354
  var onPresetHover = function onPresetHover(nextValues) {
338
- setInternalHoverValues(nextValues);
339
- setHoverSource('preset');
355
+ onSetHover(nextValues, 'preset');
340
356
  };
341
357
  var onPresetSubmit = function onPresetSubmit(nextValues) {
342
358
  var passed = triggerSubmitChange(nextValues);
@@ -352,8 +368,7 @@ function RangePicker(props, ref) {
352
368
 
353
369
  // ======================== Panel =========================
354
370
  var onPanelHover = function onPanelHover(date) {
355
- setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null);
356
- setHoverSource('cell');
371
+ onSetHover(date ? fillCalendarValue(date, activeIndex) : null, 'cell');
357
372
  };
358
373
 
359
374
  // >>> Focus
@@ -401,7 +416,7 @@ function RangePicker(props, ref) {
401
416
  });
402
417
  var panelProps = React.useMemo(function () {
403
418
  var domProps = pickAttrs(filledProps, false);
404
- var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime']));
419
+ var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime', 'classNames', 'styles']));
405
420
  return restProps;
406
421
  }, [filledProps]);
407
422
 
@@ -525,10 +540,10 @@ function RangePicker(props, ref) {
525
540
  generateConfig: generateConfig,
526
541
  button: components.button,
527
542
  input: components.input,
528
- styles: styles,
529
- classNames: classNames
543
+ classNames: mergedClassNames,
544
+ styles: mergedStyles
530
545
  };
531
- }, [prefixCls, locale, generateConfig, components.button, components.input, classNames, styles]);
546
+ }, [prefixCls, locale, generateConfig, components.button, components.input, mergedClassNames, mergedStyles]);
532
547
 
533
548
  // ======================== Effect ========================
534
549
  // >>> Mode
@@ -579,8 +594,8 @@ function RangePicker(props, ref) {
579
594
  value: context
580
595
  }, /*#__PURE__*/React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
581
596
  popupElement: panel,
582
- popupStyle: styles.popup,
583
- popupClassName: classNames.popup
597
+ popupStyle: mergedStyles.popup.root,
598
+ popupClassName: cls(rootClassName, mergedClassNames.popup.root)
584
599
  // Visible
585
600
  ,
586
601
  visible: mergedOpen,
@@ -593,6 +608,10 @@ function RangePicker(props, ref) {
593
608
  , _extends({}, filledProps, {
594
609
  // Ref
595
610
  ref: selectorRef
611
+ // Style
612
+ ,
613
+ className: cls(filledProps.className, rootClassName, mergedClassNames.root),
614
+ style: _objectSpread(_objectSpread({}, mergedStyles.root), filledProps.style)
596
615
  // Icon
597
616
  ,
598
617
  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);
@@ -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,10 @@ 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,
62
+ previewValue = _ref.previewValue,
59
63
  order = _ref.order,
60
64
  defaultValue = _ref.defaultValue,
61
65
  value = _ref.value,
@@ -107,6 +111,12 @@ function Picker(props, ref) {
107
111
  }
108
112
  var toggleDates = useToggleDates(generateConfig, locale, internalPicker);
109
113
 
114
+ // ======================= Semantic =======================
115
+ var _useSemantic = useSemantic(propClassNames, propStyles),
116
+ _useSemantic2 = _slicedToArray(_useSemantic, 2),
117
+ mergedClassNames = _useSemantic2[0],
118
+ mergedStyles = _useSemantic2[1];
119
+
110
120
  // ========================= Open =========================
111
121
  var _useOpen = useOpen(open, defaultOpen, [disabled], onOpenChange),
112
122
  _useOpen2 = _slicedToArray(_useOpen, 2),
@@ -280,6 +290,13 @@ function Picker(props, ref) {
280
290
  setInternalHoverValue(null);
281
291
  }
282
292
  }, [mergedOpen]);
293
+ var onSetHover = function onSetHover(date, source) {
294
+ if (previewValue !== 'hover') {
295
+ return;
296
+ }
297
+ setInternalHoverValue(date);
298
+ setHoverSource(source);
299
+ };
283
300
 
284
301
  // ========================================================
285
302
  // == Panels ==
@@ -287,8 +304,7 @@ function Picker(props, ref) {
287
304
  // ======================= Presets ========================
288
305
  var presetList = usePresets(presets);
289
306
  var onPresetHover = function onPresetHover(nextValue) {
290
- setInternalHoverValue(nextValue);
291
- setHoverSource('preset');
307
+ onSetHover(nextValue, 'preset');
292
308
  };
293
309
 
294
310
  // TODO: handle this
@@ -307,8 +323,7 @@ function Picker(props, ref) {
307
323
 
308
324
  // ======================== Panel =========================
309
325
  var onPanelHover = function onPanelHover(date) {
310
- setInternalHoverValue(date);
311
- setHoverSource('cell');
326
+ onSetHover(date, 'cell');
312
327
  };
313
328
 
314
329
  // >>> Focus
@@ -350,7 +365,7 @@ function Picker(props, ref) {
350
365
 
351
366
  var panelProps = React.useMemo(function () {
352
367
  var domProps = pickAttrs(filledProps, false);
353
- var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange']));
368
+ var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'classNames', 'styles']));
354
369
  return _objectSpread(_objectSpread({}, restProps), {}, {
355
370
  multiple: filledProps.multiple
356
371
  });
@@ -447,10 +462,10 @@ function Picker(props, ref) {
447
462
  generateConfig: generateConfig,
448
463
  button: components.button,
449
464
  input: components.input,
450
- styles: styles,
451
- classNames: classNames
465
+ classNames: mergedClassNames,
466
+ styles: mergedStyles
452
467
  };
453
- }, [prefixCls, locale, generateConfig, components.button, components.input, styles, classNames]);
468
+ }, [prefixCls, locale, generateConfig, components.button, components.input, mergedClassNames, mergedStyles]);
454
469
 
455
470
  // ======================== Effect ========================
456
471
  // >>> Mode
@@ -483,8 +498,8 @@ function Picker(props, ref) {
483
498
  value: context
484
499
  }, /*#__PURE__*/React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
485
500
  popupElement: panel,
486
- popupStyle: styles.popup,
487
- popupClassName: classNames.popup
501
+ popupStyle: mergedStyles.popup.root,
502
+ popupClassName: cls(rootClassName, mergedClassNames.popup.root)
488
503
  // Visible
489
504
  ,
490
505
  visible: mergedOpen,
@@ -494,6 +509,10 @@ function Picker(props, ref) {
494
509
  , _extends({}, filledProps, {
495
510
  // Ref
496
511
  ref: selectorRef
512
+ // Style
513
+ ,
514
+ className: cls(filledProps.className, rootClassName, mergedClassNames.root),
515
+ style: _objectSpread(_objectSpread({}, mergedStyles.root), filledProps.style)
497
516
  // Icon
498
517
  ,
499
518
  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;
@@ -2,7 +2,7 @@ import type { FormatType, InternalMode, PickerMode } from '../../interface';
2
2
  import type { RangePickerProps } from '../RangePicker';
3
3
  import useInvalidate from './useInvalidate';
4
4
  type UseInvalidate<DateType extends object = any> = typeof useInvalidate<DateType>;
5
- type PickedProps<DateType extends object = any> = Pick<RangePickerProps<DateType>, 'generateConfig' | 'locale' | 'picker' | 'prefixCls' | 'styles' | 'classNames' | 'order' | 'components' | 'inputRender' | 'clearIcon' | 'allowClear' | 'needConfirm' | 'format' | 'inputReadOnly' | 'disabledDate' | 'minDate' | 'maxDate' | 'defaultOpenValue'> & {
5
+ type PickedProps<DateType extends object = any> = Pick<RangePickerProps<DateType>, 'generateConfig' | 'locale' | 'picker' | 'prefixCls' | 'styles' | 'classNames' | 'order' | 'components' | 'inputRender' | 'clearIcon' | 'allowClear' | 'needConfirm' | 'format' | 'inputReadOnly' | 'disabledDate' | 'minDate' | 'maxDate' | 'defaultOpenValue' | 'previewValue'> & {
6
6
  multiple?: boolean;
7
7
  showTime?: any;
8
8
  value?: any;
@@ -45,6 +45,8 @@ export default function useFilledProps(props, updater) {
45
45
  picker = _props$picker === void 0 ? 'date' : _props$picker,
46
46
  _props$prefixCls = props.prefixCls,
47
47
  prefixCls = _props$prefixCls === void 0 ? 'rc-picker' : _props$prefixCls,
48
+ _props$previewValue = props.previewValue,
49
+ previewValue = _props$previewValue === void 0 ? 'hover' : _props$previewValue,
48
50
  _props$styles = props.styles,
49
51
  styles = _props$styles === void 0 ? {} : _props$styles,
50
52
  _props$classNames = props.classNames,
@@ -110,6 +112,7 @@ export default function useFilledProps(props, updater) {
110
112
  // ======================== Props =========================
111
113
  var filledProps = React.useMemo(function () {
112
114
  return _objectSpread(_objectSpread({}, props), {}, {
115
+ previewValue: previewValue,
113
116
  prefixCls: prefixCls,
114
117
  locale: mergedLocale,
115
118
  picker: picker,
@@ -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));