@rc-component/picker 1.2.3 → 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.
- package/es/PickerInput/Popup/Footer.js +7 -4
- package/es/PickerInput/RangePicker.js +21 -8
- package/es/PickerInput/Selector/Icon.js +6 -2
- package/es/PickerInput/Selector/Input.js +8 -4
- package/es/PickerInput/Selector/RangeSelector.js +7 -4
- package/es/PickerInput/Selector/SingleSelector/index.js +7 -4
- package/es/PickerInput/Selector/hooks/useClearIcon.d.ts +1 -1
- package/es/PickerInput/SinglePicker.js +21 -8
- package/es/PickerInput/context.d.ts +4 -3
- package/es/PickerPanel/PanelBody.js +10 -10
- package/es/PickerPanel/PanelHeader.js +9 -6
- package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +6 -3
- package/es/PickerPanel/TimePanel/TimePanelBody/index.js +5 -1
- package/es/PickerPanel/context.d.ts +9 -3
- package/es/PickerPanel/context.js +10 -0
- package/es/PickerPanel/index.d.ts +1 -2
- package/es/PickerPanel/index.js +14 -9
- package/es/hooks/useSemantic.d.ts +13 -0
- package/es/hooks/useSemantic.js +21 -0
- package/es/interface.d.ts +9 -3
- package/es/utils/getClearIcon.d.ts +1 -1
- package/lib/PickerInput/Popup/Footer.js +5 -2
- package/lib/PickerInput/RangePicker.js +21 -8
- package/lib/PickerInput/Selector/Icon.js +6 -2
- package/lib/PickerInput/Selector/Input.js +6 -2
- package/lib/PickerInput/Selector/RangeSelector.js +5 -2
- package/lib/PickerInput/Selector/SingleSelector/index.js +5 -2
- package/lib/PickerInput/Selector/hooks/useClearIcon.d.ts +1 -1
- package/lib/PickerInput/SinglePicker.js +21 -8
- package/lib/PickerInput/context.d.ts +4 -3
- package/lib/PickerPanel/PanelBody.js +9 -9
- package/lib/PickerPanel/PanelHeader.js +4 -1
- package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +5 -2
- package/lib/PickerPanel/TimePanel/TimePanelBody/index.js +5 -1
- package/lib/PickerPanel/context.d.ts +9 -3
- package/lib/PickerPanel/context.js +11 -1
- package/lib/PickerPanel/index.d.ts +1 -2
- package/lib/PickerPanel/index.js +13 -8
- package/lib/hooks/useSemantic.d.ts +13 -0
- package/lib/hooks/useSemantic.js +27 -0
- package/lib/interface.d.ts +9 -3
- package/lib/utils/getClearIcon.d.ts +1 -1
- 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
|
|
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:
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
529
|
-
|
|
537
|
+
classNames: mergedClassNames,
|
|
538
|
+
styles: mergedStyles
|
|
530
539
|
};
|
|
531
|
-
}, [prefixCls, locale, generateConfig, components.button, components.input,
|
|
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:
|
|
583
|
-
popupClassName:
|
|
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,14 +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 cls from 'classnames';
|
|
8
9
|
export default function Icon(props) {
|
|
9
10
|
var icon = props.icon,
|
|
10
11
|
type = props.type,
|
|
11
12
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
12
13
|
var _React$useContext = React.useContext(PickerContext),
|
|
13
|
-
prefixCls = _React$useContext.prefixCls
|
|
14
|
+
prefixCls = _React$useContext.prefixCls,
|
|
15
|
+
classNames = _React$useContext.classNames,
|
|
16
|
+
styles = _React$useContext.styles;
|
|
14
17
|
return icon ? /*#__PURE__*/React.createElement("span", _extends({
|
|
15
|
-
className: "".concat(prefixCls, "-").concat(type)
|
|
18
|
+
className: cls("".concat(prefixCls, "-").concat(type), classNames.suffix),
|
|
19
|
+
style: styles.suffix
|
|
16
20
|
}, restProps), icon) : null;
|
|
17
21
|
}
|
|
18
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
|
|
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";
|
|
@@ -62,7 +62,9 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
62
62
|
var _React$useContext = React.useContext(PickerContext),
|
|
63
63
|
prefixCls = _React$useContext.prefixCls,
|
|
64
64
|
_React$useContext$inp = _React$useContext.input,
|
|
65
|
-
Component = _React$useContext$inp === void 0 ? 'input' : _React$useContext$inp
|
|
65
|
+
Component = _React$useContext$inp === void 0 ? 'input' : _React$useContext$inp,
|
|
66
|
+
classNames = _React$useContext.classNames,
|
|
67
|
+
styles = _React$useContext.styles;
|
|
66
68
|
var inputPrefixCls = "".concat(prefixCls, "-input");
|
|
67
69
|
|
|
68
70
|
// ======================== Value =========================
|
|
@@ -354,7 +356,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
354
356
|
} : {};
|
|
355
357
|
return /*#__PURE__*/React.createElement("div", {
|
|
356
358
|
ref: holderRef,
|
|
357
|
-
className:
|
|
359
|
+
className: cls(inputPrefixCls, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped), className)
|
|
358
360
|
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
359
361
|
ref: inputRef,
|
|
360
362
|
"aria-invalid": invalid,
|
|
@@ -366,7 +368,9 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
366
368
|
}, inputProps, {
|
|
367
369
|
// Value
|
|
368
370
|
value: inputValue,
|
|
369
|
-
onChange: onInternalChange
|
|
371
|
+
onChange: onInternalChange,
|
|
372
|
+
className: classNames.input,
|
|
373
|
+
style: styles.input
|
|
370
374
|
})), /*#__PURE__*/React.createElement(Icon, {
|
|
371
375
|
type: "suffix",
|
|
372
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
|
|
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';
|
|
@@ -70,7 +70,9 @@ function RangeSelector(props, ref) {
|
|
|
70
70
|
|
|
71
71
|
// ======================== Prefix ========================
|
|
72
72
|
var _React$useContext = React.useContext(PickerContext),
|
|
73
|
-
prefixCls = _React$useContext.prefixCls
|
|
73
|
+
prefixCls = _React$useContext.prefixCls,
|
|
74
|
+
classNames = _React$useContext.classNames,
|
|
75
|
+
styles = _React$useContext.styles;
|
|
74
76
|
|
|
75
77
|
// ========================== Id ==========================
|
|
76
78
|
var ids = React.useMemo(function () {
|
|
@@ -167,7 +169,7 @@ function RangeSelector(props, ref) {
|
|
|
167
169
|
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
168
170
|
onResize: syncActiveOffset
|
|
169
171
|
}, /*#__PURE__*/React.createElement("div", _extends({}, rootProps, {
|
|
170
|
-
className:
|
|
172
|
+
className: cls(prefixCls, "".concat(prefixCls, "-range"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled.every(function (i) {
|
|
171
173
|
return i;
|
|
172
174
|
})), "".concat(prefixCls, "-invalid"), invalid.some(function (i) {
|
|
173
175
|
return i;
|
|
@@ -185,7 +187,8 @@ function RangeSelector(props, ref) {
|
|
|
185
187
|
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
|
|
186
188
|
}
|
|
187
189
|
}), prefix && /*#__PURE__*/React.createElement("div", {
|
|
188
|
-
className: "".concat(prefixCls, "-prefix")
|
|
190
|
+
className: cls("".concat(prefixCls, "-prefix"), classNames.prefix),
|
|
191
|
+
style: styles.prefix
|
|
189
192
|
}, prefix), /*#__PURE__*/React.createElement(Input, _extends({
|
|
190
193
|
ref: inputStartRef
|
|
191
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
|
|
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";
|
|
@@ -69,7 +69,9 @@ function SingleSelector(props, ref) {
|
|
|
69
69
|
|
|
70
70
|
// ======================== Prefix ========================
|
|
71
71
|
var _React$useContext = React.useContext(PickerContext),
|
|
72
|
-
prefixCls = _React$useContext.prefixCls
|
|
72
|
+
prefixCls = _React$useContext.prefixCls,
|
|
73
|
+
classNames = _React$useContext.classNames,
|
|
74
|
+
styles = _React$useContext.styles;
|
|
73
75
|
|
|
74
76
|
// ========================= Refs =========================
|
|
75
77
|
var rootRef = React.useRef();
|
|
@@ -162,7 +164,7 @@ function SingleSelector(props, ref) {
|
|
|
162
164
|
|
|
163
165
|
// ======================== Render ========================
|
|
164
166
|
return /*#__PURE__*/React.createElement("div", _extends({}, rootProps, {
|
|
165
|
-
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),
|
|
166
168
|
style: style,
|
|
167
169
|
ref: rootRef,
|
|
168
170
|
onClick: onClick
|
|
@@ -177,7 +179,8 @@ function SingleSelector(props, ref) {
|
|
|
177
179
|
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
|
|
178
180
|
}
|
|
179
181
|
}), prefix && /*#__PURE__*/React.createElement("div", {
|
|
180
|
-
className: "".concat(prefixCls, "-prefix")
|
|
182
|
+
className: cls("".concat(prefixCls, "-prefix"), classNames.prefix),
|
|
183
|
+
style: styles.prefix
|
|
181
184
|
}, prefix), selectorNode);
|
|
182
185
|
}
|
|
183
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 |
|
|
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
|
-
|
|
58
|
-
|
|
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
|
-
|
|
451
|
-
|
|
459
|
+
classNames: mergedClassNames,
|
|
460
|
+
styles: mergedStyles
|
|
452
461
|
};
|
|
453
|
-
}, [prefixCls, locale, generateConfig, components.button, components.input,
|
|
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:
|
|
487
|
-
popupClassName:
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
153
|
-
style: styles
|
|
152
|
+
className: cls("".concat(prefixCls, "-body"), classNames.body),
|
|
153
|
+
style: styles.body
|
|
154
154
|
}, /*#__PURE__*/React.createElement("table", {
|
|
155
|
-
className:
|
|
156
|
-
style: styles
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
131
|
+
className: cls(superNextBtnCls, disabledSuperOffsetNext && "".concat(superNextBtnCls, "-disabled")),
|
|
129
132
|
disabled: disabledSuperOffsetNext,
|
|
130
133
|
style: hideNext ? HIDDEN_STYLE : {}
|
|
131
134
|
}, superNextIcon));
|
|
@@ -12,7 +12,7 @@ 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
|
|
15
|
+
import cls from 'classnames';
|
|
16
16
|
import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
17
17
|
import * as React from 'react';
|
|
18
18
|
import { usePanelContext } from "../../context";
|
|
@@ -40,7 +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
|
|
43
|
+
locale = _usePanelContext.locale,
|
|
44
|
+
classNames = _usePanelContext.classNames,
|
|
45
|
+
styles = _usePanelContext.styles;
|
|
44
46
|
var panelPrefixCls = "".concat(prefixCls, "-time-panel");
|
|
45
47
|
var cellPrefixCls = "".concat(prefixCls, "-time-panel-cell");
|
|
46
48
|
|
|
@@ -119,7 +121,8 @@ export default function TimeColumn(props) {
|
|
|
119
121
|
}, label);
|
|
120
122
|
return /*#__PURE__*/React.createElement("li", {
|
|
121
123
|
key: unitValue,
|
|
122
|
-
|
|
124
|
+
style: styles.item,
|
|
125
|
+
className: cls(cellPrefixCls, classNames.item, _defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-selected"), value === unitValue), "".concat(cellPrefixCls, "-disabled"), disabled)),
|
|
123
126
|
onClick: function onClick() {
|
|
124
127
|
if (!disabled) {
|
|
125
128
|
onChange(unitValue);
|
|
@@ -10,6 +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 cls from 'classnames';
|
|
13
14
|
function isAM(hour) {
|
|
14
15
|
return hour < 12;
|
|
15
16
|
}
|
|
@@ -22,6 +23,8 @@ export default function TimePanelBody(props) {
|
|
|
22
23
|
changeOnScroll = props.changeOnScroll;
|
|
23
24
|
var _usePanelContext = usePanelContext(),
|
|
24
25
|
prefixCls = _usePanelContext.prefixCls,
|
|
26
|
+
classNames = _usePanelContext.classNames,
|
|
27
|
+
styles = _usePanelContext.styles,
|
|
25
28
|
values = _usePanelContext.values,
|
|
26
29
|
generateConfig = _usePanelContext.generateConfig,
|
|
27
30
|
locale = _usePanelContext.locale,
|
|
@@ -244,7 +247,8 @@ export default function TimePanelBody(props) {
|
|
|
244
247
|
changeOnScroll: changeOnScroll
|
|
245
248
|
};
|
|
246
249
|
return /*#__PURE__*/React.createElement("div", {
|
|
247
|
-
className: "".concat(prefixCls, "-content")
|
|
250
|
+
className: cls("".concat(prefixCls, "-content"), classNames.content),
|
|
251
|
+
style: styles.content
|
|
248
252
|
}, showHour && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
249
253
|
units: hourUnits,
|
|
250
254
|
value: hour,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { PanelMode,
|
|
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
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
export var SharedPanelContext = /*#__PURE__*/React.createContext(null);
|
|
2
3
|
/** Used for each single Panel. e.g. DatePanel */
|
|
3
4
|
export var PanelContext = /*#__PURE__*/React.createContext(null);
|
|
4
5
|
export function usePanelContext() {
|
|
@@ -9,6 +10,8 @@ export function usePanelContext() {
|
|
|
9
10
|
* Get shared props for the SharedPanelProps interface.
|
|
10
11
|
*/
|
|
11
12
|
export function useInfo(props, panelType) {
|
|
13
|
+
// TODO: this is not good to get from each props.
|
|
14
|
+
// Should move to `SharedPanelContext` instead.
|
|
12
15
|
var prefixCls = props.prefixCls,
|
|
13
16
|
generateConfig = props.generateConfig,
|
|
14
17
|
locale = props.locale,
|
|
@@ -27,6 +30,11 @@ export function useInfo(props, panelType) {
|
|
|
27
30
|
superPrevIcon = props.superPrevIcon,
|
|
28
31
|
superNextIcon = props.superNextIcon;
|
|
29
32
|
|
|
33
|
+
// ======================= Context ========================
|
|
34
|
+
var _React$useContext = React.useContext(SharedPanelContext),
|
|
35
|
+
classNames = _React$useContext.classNames,
|
|
36
|
+
styles = _React$useContext.styles;
|
|
37
|
+
|
|
30
38
|
// ========================= MISC =========================
|
|
31
39
|
var now = generateConfig.getNow();
|
|
32
40
|
|
|
@@ -36,6 +44,8 @@ export function useInfo(props, panelType) {
|
|
|
36
44
|
values: values,
|
|
37
45
|
pickerValue: pickerValue,
|
|
38
46
|
prefixCls: prefixCls,
|
|
47
|
+
classNames: classNames,
|
|
48
|
+
styles: styles,
|
|
39
49
|
disabledDate: disabledDate,
|
|
40
50
|
minDate: minDate,
|
|
41
51
|
maxDate: maxDate,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { CellRender, Components, Locale, OnPanelChange, PanelMode, PickerMode, SharedPanelProps, SharedTimeProps } from '../interface';
|
|
2
|
+
import type { CellRender, Components, Locale, OnPanelChange, PanelMode, PanelSemanticName, PickerMode, SharedPanelProps, SharedTimeProps } from '../interface';
|
|
3
3
|
export interface PickerPanelRef {
|
|
4
4
|
nativeElement: HTMLDivElement;
|
|
5
5
|
}
|
|
@@ -43,7 +43,6 @@ export interface SinglePickerPanelProps<DateType extends object = any> extends B
|
|
|
43
43
|
value?: DateType | null;
|
|
44
44
|
onChange?: (date: DateType) => void;
|
|
45
45
|
}
|
|
46
|
-
type PanelSemanticName = 'popupBody' | 'popupContent' | 'popupItem';
|
|
47
46
|
export type PickerPanelProps<DateType extends object = any> = BasePickerPanelProps<DateType> & {
|
|
48
47
|
/** multiple selection. Not support time or datetime picker */
|
|
49
48
|
multiple?: boolean;
|