@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.
- package/README.md +3 -1
- package/es/PickerInput/Popup/Footer.js +7 -4
- package/es/PickerInput/RangePicker.js +31 -12
- package/es/PickerInput/Selector/Icon.js +4 -4
- package/es/PickerInput/Selector/Input.js +6 -5
- package/es/PickerInput/Selector/RangeSelector.js +5 -5
- package/es/PickerInput/Selector/SingleSelector/index.js +5 -5
- package/es/PickerInput/SinglePicker.js +31 -12
- package/es/PickerInput/context.d.ts +4 -3
- package/es/PickerInput/hooks/useFilledProps.d.ts +1 -1
- package/es/PickerInput/hooks/useFilledProps.js +3 -0
- package/es/PickerPanel/PanelBody.js +10 -10
- package/es/PickerPanel/PanelHeader.js +9 -6
- package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +7 -8
- package/es/PickerPanel/TimePanel/TimePanelBody/index.js +6 -6
- package/es/PickerPanel/context.d.ts +9 -3
- package/es/PickerPanel/context.js +10 -0
- package/es/PickerPanel/index.d.ts +2 -11
- 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 +16 -3
- package/es/locale/te_IN.d.ts +3 -0
- package/es/locale/te_IN.js +33 -0
- package/lib/PickerInput/Popup/Footer.js +5 -2
- package/lib/PickerInput/RangePicker.js +31 -12
- package/lib/PickerInput/Selector/Icon.js +3 -3
- package/lib/PickerInput/Selector/Input.js +5 -4
- package/lib/PickerInput/Selector/RangeSelector.js +3 -3
- package/lib/PickerInput/Selector/SingleSelector/index.js +3 -3
- package/lib/PickerInput/SinglePicker.js +31 -12
- package/lib/PickerInput/context.d.ts +4 -3
- package/lib/PickerInput/hooks/useFilledProps.d.ts +1 -1
- package/lib/PickerInput/hooks/useFilledProps.js +3 -0
- package/lib/PickerPanel/PanelBody.js +9 -9
- package/lib/PickerPanel/PanelHeader.js +4 -1
- package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +5 -6
- package/lib/PickerPanel/TimePanel/TimePanelBody/index.js +5 -5
- package/lib/PickerPanel/context.d.ts +9 -3
- package/lib/PickerPanel/context.js +11 -1
- package/lib/PickerPanel/index.d.ts +2 -11
- 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 +16 -3
- package/lib/locale/te_IN.d.ts +3 -0
- package/lib/locale/te_IN.js +39 -0
- package/package.json +1 -1
|
@@ -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
|
|
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 {
|
|
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
|
-
|
|
45
|
-
|
|
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
|
|
126
|
-
className:
|
|
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
|
|
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:
|
|
251
|
-
style: styles
|
|
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,
|
|
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;
|
|
@@ -53,13 +52,5 @@ export type PickerPanelProps<DateType extends object = any> = BasePickerPanelPro
|
|
|
53
52
|
styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
|
|
54
53
|
classNames?: Partial<Record<PanelSemanticName, string>>;
|
|
55
54
|
};
|
|
56
|
-
declare const _default: <DateType extends object = any>(props:
|
|
57
|
-
/** multiple selection. Not support time or datetime picker */
|
|
58
|
-
multiple?: boolean;
|
|
59
|
-
defaultValue?: DateType | DateType[];
|
|
60
|
-
value?: DateType | DateType[];
|
|
61
|
-
onChange?: (date: DateType | DateType[]) => void;
|
|
62
|
-
styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
|
|
63
|
-
classNames?: Partial<Record<PanelSemanticName, string>>;
|
|
64
|
-
} & React.RefAttributes<PickerPanelRef>) => React.ReactElement;
|
|
55
|
+
declare const _default: <DateType extends object = any>(props: PickerPanelProps<DateType> & React.RefAttributes<PickerPanelRef>) => React.ReactElement;
|
|
65
56
|
export default _default;
|
package/es/PickerPanel/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import PickerContext from "../PickerInput/context";
|
|
|
25
25
|
import useCellRender from "../PickerInput/hooks/useCellRender";
|
|
26
26
|
import { isSame } from "../utils/dateUtil";
|
|
27
27
|
import { pickProps, toArray } from "../utils/miscUtil";
|
|
28
|
-
import { PickerHackContext } from "./context";
|
|
28
|
+
import { PickerHackContext, SharedPanelContext } from "./context";
|
|
29
29
|
import DatePanel from "./DatePanel";
|
|
30
30
|
import DateTimePanel from "./DateTimePanel";
|
|
31
31
|
import DecadePanel from "./DecadePanel";
|
|
@@ -255,16 +255,19 @@ function PickerPanel(props, ref) {
|
|
|
255
255
|
var PanelComponent = components[internalMode] || DefaultComponents[internalMode] || DatePanel;
|
|
256
256
|
|
|
257
257
|
// ======================== Context =========================
|
|
258
|
-
var
|
|
259
|
-
|
|
258
|
+
var sharedPanelContext = React.useMemo(function () {
|
|
259
|
+
var _ref2, _pickerClassNames$pop, _ref3, _pickerStyles$popup;
|
|
260
|
+
return {
|
|
261
|
+
classNames: (_ref2 = (_pickerClassNames$pop = pickerClassNames === null || pickerClassNames === void 0 ? void 0 : pickerClassNames.popup) !== null && _pickerClassNames$pop !== void 0 ? _pickerClassNames$pop : panelClassNames) !== null && _ref2 !== void 0 ? _ref2 : {},
|
|
262
|
+
styles: (_ref3 = (_pickerStyles$popup = pickerStyles === null || pickerStyles === void 0 ? void 0 : pickerStyles.popup) !== null && _pickerStyles$popup !== void 0 ? _pickerStyles$popup : panelStyles) !== null && _ref3 !== void 0 ? _ref3 : {}
|
|
263
|
+
};
|
|
264
|
+
}, [pickerClassNames, panelClassNames, pickerStyles, panelStyles]);
|
|
260
265
|
var parentHackContext = React.useContext(PickerHackContext);
|
|
261
266
|
var pickerPanelContext = React.useMemo(function () {
|
|
262
267
|
return _objectSpread(_objectSpread({}, parentHackContext), {}, {
|
|
263
|
-
hideHeader: hideHeader
|
|
264
|
-
classNames: mergedClassNames,
|
|
265
|
-
styles: mergedStyles
|
|
268
|
+
hideHeader: hideHeader
|
|
266
269
|
});
|
|
267
|
-
}, [parentHackContext, hideHeader
|
|
270
|
+
}, [parentHackContext, hideHeader]);
|
|
268
271
|
|
|
269
272
|
// ======================== Warnings ========================
|
|
270
273
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -284,7 +287,9 @@ function PickerPanel(props, ref) {
|
|
|
284
287
|
'disabledDate', 'minDate', 'maxDate',
|
|
285
288
|
// Hover
|
|
286
289
|
'onHover']);
|
|
287
|
-
return /*#__PURE__*/React.createElement(
|
|
290
|
+
return /*#__PURE__*/React.createElement(SharedPanelContext.Provider, {
|
|
291
|
+
value: sharedPanelContext
|
|
292
|
+
}, /*#__PURE__*/React.createElement(PickerHackContext.Provider, {
|
|
288
293
|
value: pickerPanelContext
|
|
289
294
|
}, /*#__PURE__*/React.createElement("div", {
|
|
290
295
|
ref: rootRef,
|
|
@@ -317,7 +322,7 @@ function PickerPanel(props, ref) {
|
|
|
317
322
|
,
|
|
318
323
|
hoverRangeValue: hoverRangeDate,
|
|
319
324
|
hoverValue: hoverValue
|
|
320
|
-
}))));
|
|
325
|
+
})))));
|
|
321
326
|
}
|
|
322
327
|
var RefPanelPicker = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(PickerPanel));
|
|
323
328
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SharedPickerProps } from '../interface';
|
|
2
|
+
export type FilledPanelClassNames = NonNullable<SharedPickerProps['classNames']>['popup'];
|
|
3
|
+
export type FilledPanelStyles = NonNullable<SharedPickerProps['styles']>['popup'];
|
|
4
|
+
export type FilledClassNames = NonNullable<SharedPickerProps['classNames']> & {
|
|
5
|
+
popup: FilledPanelClassNames;
|
|
6
|
+
};
|
|
7
|
+
export type FilledStyles = NonNullable<SharedPickerProps['styles']> & {
|
|
8
|
+
popup: FilledPanelStyles;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Convert `classNames` & `styles` to a fully filled object
|
|
12
|
+
*/
|
|
13
|
+
export default function useSemantic(classNames?: SharedPickerProps['classNames'], styles?: SharedPickerProps['styles']): readonly [FilledClassNames, FilledStyles];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Convert `classNames` & `styles` to a fully filled object
|
|
10
|
+
*/
|
|
11
|
+
export default function useSemantic(classNames, styles) {
|
|
12
|
+
return useMemo(function () {
|
|
13
|
+
var mergedClassNames = _objectSpread(_objectSpread({}, classNames), {}, {
|
|
14
|
+
popup: (classNames === null || classNames === void 0 ? void 0 : classNames.popup) || {}
|
|
15
|
+
});
|
|
16
|
+
var mergedStyles = _objectSpread(_objectSpread({}, styles), {}, {
|
|
17
|
+
popup: (styles === null || styles === void 0 ? void 0 : styles.popup) || {}
|
|
18
|
+
});
|
|
19
|
+
return [mergedClassNames, mergedStyles];
|
|
20
|
+
}, [classNames, styles]);
|
|
21
|
+
}
|
package/es/interface.d.ts
CHANGED
|
@@ -201,19 +201,26 @@ export type Components<DateType extends object = any> = Partial<Record<InternalM
|
|
|
201
201
|
button?: React.ComponentType<any> | string;
|
|
202
202
|
input?: React.ComponentType<any> | string;
|
|
203
203
|
}>;
|
|
204
|
-
export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent' | 'popupItem' | 'suffix' | 'prefix' | 'input';
|
|
205
204
|
export type CustomFormat<DateType> = (value: DateType) => string;
|
|
206
205
|
export type FormatType<DateType = any> = string | CustomFormat<DateType>;
|
|
207
206
|
export type SharedHTMLAttrs = Omit<React.InputHTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange' | 'placeholder' | 'id' | 'onInvalid' | 'disabled' | 'onFocus' | 'onBlur' | 'onSelect' | 'min' | 'max' | 'onKeyDown' | 'size' | 'prefix'>;
|
|
208
207
|
export type PickerFocusEventHandler = (e: React.FocusEvent<HTMLElement>, info: BaseInfo) => void;
|
|
209
208
|
export type LegacyOnKeyDown = (event: React.KeyboardEvent<HTMLElement>, preventDefault: VoidFunction) => void;
|
|
209
|
+
export type SemanticName = 'root' | 'prefix' | 'input' | 'suffix';
|
|
210
|
+
export type PreviewValueType = 'hover';
|
|
211
|
+
export type PanelSemanticName = 'root' | 'header' | 'body' | 'content' | 'item' | 'footer';
|
|
210
212
|
export interface SharedPickerProps<DateType extends object = any> extends SharedHTMLAttrs, Pick<SharedPanelProps<DateType>, 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'> {
|
|
211
213
|
direction?: 'ltr' | 'rtl';
|
|
212
214
|
prefixCls?: string;
|
|
213
215
|
className?: string;
|
|
214
216
|
style?: React.CSSProperties;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
rootClassName?: string;
|
|
218
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
|
|
219
|
+
popup?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
|
|
220
|
+
};
|
|
221
|
+
classNames?: Partial<Record<SemanticName, string>> & {
|
|
222
|
+
popup?: Partial<Record<PanelSemanticName, string>>;
|
|
223
|
+
};
|
|
217
224
|
locale: Locale;
|
|
218
225
|
generateConfig: GenerateConfig<DateType>;
|
|
219
226
|
picker?: PickerMode;
|
|
@@ -275,6 +282,12 @@ export interface SharedPickerProps<DateType extends object = any> extends Shared
|
|
|
275
282
|
* This is only used for strong a11y requirement which do not want modify after blur.
|
|
276
283
|
*/
|
|
277
284
|
preserveInvalidOnBlur?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* When the user selects the date hover option, the value of the input field undergoes a temporary change.
|
|
287
|
+
* `false` will not preview value.
|
|
288
|
+
* `hover` will preview value when hover.
|
|
289
|
+
*/
|
|
290
|
+
previewValue?: false | PreviewValueType;
|
|
278
291
|
transitionName?: string;
|
|
279
292
|
components?: Components<DateType>;
|
|
280
293
|
/** @deprecated Please use `components.input` instead. */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { commonLocale } from "./common";
|
|
8
|
+
var locale = _objectSpread(_objectSpread({}, commonLocale), {}, {
|
|
9
|
+
locale: 'te_IN',
|
|
10
|
+
today: 'నేడు',
|
|
11
|
+
now: 'ఇప్పుడు',
|
|
12
|
+
backToToday: 'తిరిగి నేటికి',
|
|
13
|
+
ok: 'సరే',
|
|
14
|
+
clear: 'స్పష్టమైన',
|
|
15
|
+
week: 'వారం',
|
|
16
|
+
month: 'నెల',
|
|
17
|
+
year: 'సంవత్సరం',
|
|
18
|
+
timeSelect: 'సమయం ఎంపిక',
|
|
19
|
+
dateSelect: 'తేదీ ఎంపిక',
|
|
20
|
+
weekSelect: 'వారం ఎంపిక',
|
|
21
|
+
monthSelect: 'నెల ఎంపిక',
|
|
22
|
+
yearSelect: 'సంవత్సరం ఎంపిక',
|
|
23
|
+
decadeSelect: 'దశాబ్దం ఎంపిక',
|
|
24
|
+
previousMonth: 'మునుపటి నెల',
|
|
25
|
+
nextMonth: 'వచ్చే నెల',
|
|
26
|
+
previousYear: 'మునుపటి సంవత్సరం',
|
|
27
|
+
nextYear: 'తదుపరి సంవత్సరం',
|
|
28
|
+
previousDecade: 'మునుపటి దశాబ్దం',
|
|
29
|
+
nextDecade: 'తదుపరి దశాబ్దం',
|
|
30
|
+
previousCentury: 'మునుపటి శతాబ్దం',
|
|
31
|
+
nextCentury: 'తదుపరి శతాబ్దం'
|
|
32
|
+
});
|
|
33
|
+
export default locale;
|
|
@@ -34,7 +34,9 @@ function Footer(props) {
|
|
|
34
34
|
prefixCls = _React$useContext.prefixCls,
|
|
35
35
|
locale = _React$useContext.locale,
|
|
36
36
|
_React$useContext$but = _React$useContext.button,
|
|
37
|
-
Button = _React$useContext$but === void 0 ? 'button' : _React$useContext$but
|
|
37
|
+
Button = _React$useContext$but === void 0 ? 'button' : _React$useContext$but,
|
|
38
|
+
classNames = _React$useContext.classNames,
|
|
39
|
+
styles = _React$useContext.styles;
|
|
38
40
|
|
|
39
41
|
// >>> Now
|
|
40
42
|
var now = generateConfig.getNow();
|
|
@@ -81,7 +83,8 @@ function Footer(props) {
|
|
|
81
83
|
return null;
|
|
82
84
|
}
|
|
83
85
|
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: "".concat(prefixCls, "-footer")
|
|
86
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-footer"), classNames.popup.footer),
|
|
87
|
+
style: styles.popup.footer
|
|
85
88
|
}, extraNode && /*#__PURE__*/React.createElement("div", {
|
|
86
89
|
className: "".concat(prefixCls, "-footer-extra")
|
|
87
90
|
}, extraNode), rangeNode);
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _util = require("@rc-component/util");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
10
|
var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
|
|
10
11
|
var _omit = _interopRequireDefault(require("@rc-component/util/lib/omit"));
|
|
11
12
|
var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
|
|
@@ -28,6 +29,7 @@ var _useRangeValue3 = _interopRequireWildcard(require("./hooks/useRangeValue"));
|
|
|
28
29
|
var _useShowNow = _interopRequireDefault(require("./hooks/useShowNow"));
|
|
29
30
|
var _Popup = _interopRequireDefault(require("./Popup"));
|
|
30
31
|
var _RangeSelector = _interopRequireDefault(require("./Selector/RangeSelector"));
|
|
32
|
+
var _useSemantic3 = _interopRequireDefault(require("../hooks/useSemantic"));
|
|
31
33
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
32
34
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
33
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -80,8 +82,10 @@ function RangePicker(props, ref) {
|
|
|
80
82
|
maskFormat = _useFilledProps2[4],
|
|
81
83
|
isInvalidateDate = _useFilledProps2[5];
|
|
82
84
|
var prefixCls = filledProps.prefixCls,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
rootClassName = filledProps.rootClassName,
|
|
86
|
+
propStyles = filledProps.styles,
|
|
87
|
+
propClassNames = filledProps.classNames,
|
|
88
|
+
previewValue = filledProps.previewValue,
|
|
85
89
|
defaultValue = filledProps.defaultValue,
|
|
86
90
|
value = filledProps.value,
|
|
87
91
|
needConfirm = filledProps.needConfirm,
|
|
@@ -122,6 +126,12 @@ function RangePicker(props, ref) {
|
|
|
122
126
|
// ========================= Refs =========================
|
|
123
127
|
var selectorRef = (0, _usePickerRef.default)(ref);
|
|
124
128
|
|
|
129
|
+
// ======================= Semantic =======================
|
|
130
|
+
var _useSemantic = (0, _useSemantic3.default)(propClassNames, propStyles),
|
|
131
|
+
_useSemantic2 = _slicedToArray(_useSemantic, 2),
|
|
132
|
+
mergedClassNames = _useSemantic2[0],
|
|
133
|
+
mergedStyles = _useSemantic2[1];
|
|
134
|
+
|
|
125
135
|
// ========================= Open =========================
|
|
126
136
|
var _useOpen = (0, _useOpen3.default)(open, defaultOpen, disabled, onOpenChange),
|
|
127
137
|
_useOpen2 = _slicedToArray(_useOpen, 2),
|
|
@@ -340,12 +350,18 @@ function RangePicker(props, ref) {
|
|
|
340
350
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
341
351
|
activeInfo = _React$useState6[0],
|
|
342
352
|
setActiveInfo = _React$useState6[1];
|
|
353
|
+
var onSetHover = function onSetHover(date, source) {
|
|
354
|
+
if (previewValue !== 'hover') {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
setInternalHoverValues(date);
|
|
358
|
+
setHoverSource(source);
|
|
359
|
+
};
|
|
343
360
|
|
|
344
361
|
// ======================= Presets ========================
|
|
345
362
|
var presetList = (0, _usePresets.default)(presets, ranges);
|
|
346
363
|
var onPresetHover = function onPresetHover(nextValues) {
|
|
347
|
-
|
|
348
|
-
setHoverSource('preset');
|
|
364
|
+
onSetHover(nextValues, 'preset');
|
|
349
365
|
};
|
|
350
366
|
var onPresetSubmit = function onPresetSubmit(nextValues) {
|
|
351
367
|
var passed = triggerSubmitChange(nextValues);
|
|
@@ -361,8 +377,7 @@ function RangePicker(props, ref) {
|
|
|
361
377
|
|
|
362
378
|
// ======================== Panel =========================
|
|
363
379
|
var onPanelHover = function onPanelHover(date) {
|
|
364
|
-
|
|
365
|
-
setHoverSource('cell');
|
|
380
|
+
onSetHover(date ? fillCalendarValue(date, activeIndex) : null, 'cell');
|
|
366
381
|
};
|
|
367
382
|
|
|
368
383
|
// >>> Focus
|
|
@@ -410,7 +425,7 @@ function RangePicker(props, ref) {
|
|
|
410
425
|
});
|
|
411
426
|
var panelProps = React.useMemo(function () {
|
|
412
427
|
var domProps = (0, _pickAttrs.default)(filledProps, false);
|
|
413
|
-
var restProps = (0, _omit.default)(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime']));
|
|
428
|
+
var restProps = (0, _omit.default)(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange', 'disabledTime', 'classNames', 'styles']));
|
|
414
429
|
return restProps;
|
|
415
430
|
}, [filledProps]);
|
|
416
431
|
|
|
@@ -534,10 +549,10 @@ function RangePicker(props, ref) {
|
|
|
534
549
|
generateConfig: generateConfig,
|
|
535
550
|
button: components.button,
|
|
536
551
|
input: components.input,
|
|
537
|
-
|
|
538
|
-
|
|
552
|
+
classNames: mergedClassNames,
|
|
553
|
+
styles: mergedStyles
|
|
539
554
|
};
|
|
540
|
-
}, [prefixCls, locale, generateConfig, components.button, components.input,
|
|
555
|
+
}, [prefixCls, locale, generateConfig, components.button, components.input, mergedClassNames, mergedStyles]);
|
|
541
556
|
|
|
542
557
|
// ======================== Effect ========================
|
|
543
558
|
// >>> Mode
|
|
@@ -588,8 +603,8 @@ function RangePicker(props, ref) {
|
|
|
588
603
|
value: context
|
|
589
604
|
}, /*#__PURE__*/React.createElement(_PickerTrigger.default, _extends({}, (0, _util2.pickTriggerProps)(filledProps), {
|
|
590
605
|
popupElement: panel,
|
|
591
|
-
popupStyle:
|
|
592
|
-
popupClassName:
|
|
606
|
+
popupStyle: mergedStyles.popup.root,
|
|
607
|
+
popupClassName: (0, _classnames.default)(rootClassName, mergedClassNames.popup.root)
|
|
593
608
|
// Visible
|
|
594
609
|
,
|
|
595
610
|
visible: mergedOpen,
|
|
@@ -602,6 +617,10 @@ function RangePicker(props, ref) {
|
|
|
602
617
|
, _extends({}, filledProps, {
|
|
603
618
|
// Ref
|
|
604
619
|
ref: selectorRef
|
|
620
|
+
// Style
|
|
621
|
+
,
|
|
622
|
+
className: (0, _classnames.default)(filledProps.className, rootClassName, mergedClassNames.root),
|
|
623
|
+
style: _objectSpread(_objectSpread({}, mergedStyles.root), filledProps.style)
|
|
605
624
|
// Icon
|
|
606
625
|
,
|
|
607
626
|
suffixIcon: suffixIcon
|
|
@@ -23,11 +23,11 @@ function Icon(props) {
|
|
|
23
23
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
24
24
|
var _React$useContext = React.useContext(_context.default),
|
|
25
25
|
prefixCls = _React$useContext.prefixCls,
|
|
26
|
-
|
|
26
|
+
classNames = _React$useContext.classNames,
|
|
27
27
|
styles = _React$useContext.styles;
|
|
28
28
|
return icon ? /*#__PURE__*/React.createElement("span", _extends({
|
|
29
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-").concat(type),
|
|
30
|
-
style: styles
|
|
29
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-").concat(type), classNames.suffix),
|
|
30
|
+
style: styles.suffix
|
|
31
31
|
}, restProps), icon) : null;
|
|
32
32
|
}
|
|
33
33
|
function ClearIcon(_ref) {
|
|
@@ -71,7 +71,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
71
71
|
prefixCls = _React$useContext.prefixCls,
|
|
72
72
|
_React$useContext$inp = _React$useContext.input,
|
|
73
73
|
Component = _React$useContext$inp === void 0 ? 'input' : _React$useContext$inp,
|
|
74
|
-
|
|
74
|
+
classNames = _React$useContext.classNames,
|
|
75
75
|
styles = _React$useContext.styles;
|
|
76
76
|
var inputPrefixCls = "".concat(prefixCls, "-input");
|
|
77
77
|
|
|
@@ -364,8 +364,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
364
364
|
} : {};
|
|
365
365
|
return /*#__PURE__*/React.createElement("div", {
|
|
366
366
|
ref: holderRef,
|
|
367
|
-
className: (0, _classnames.default)(inputPrefixCls,
|
|
368
|
-
style: styles === null || styles === void 0 ? void 0 : styles.input
|
|
367
|
+
className: (0, _classnames.default)(inputPrefixCls, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped), className)
|
|
369
368
|
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
370
369
|
ref: inputRef,
|
|
371
370
|
"aria-invalid": invalid,
|
|
@@ -377,7 +376,9 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
377
376
|
}, inputProps, {
|
|
378
377
|
// Value
|
|
379
378
|
value: inputValue,
|
|
380
|
-
onChange: onInternalChange
|
|
379
|
+
onChange: onInternalChange,
|
|
380
|
+
className: classNames.input,
|
|
381
|
+
style: styles.input
|
|
381
382
|
})), /*#__PURE__*/React.createElement(_Icon.default, {
|
|
382
383
|
type: "suffix",
|
|
383
384
|
icon: suffixIcon
|
|
@@ -80,7 +80,7 @@ function RangeSelector(props, ref) {
|
|
|
80
80
|
// ======================== Prefix ========================
|
|
81
81
|
var _React$useContext = React.useContext(_context.default),
|
|
82
82
|
prefixCls = _React$useContext.prefixCls,
|
|
83
|
-
|
|
83
|
+
classNames = _React$useContext.classNames,
|
|
84
84
|
styles = _React$useContext.styles;
|
|
85
85
|
|
|
86
86
|
// ========================== Id ==========================
|
|
@@ -196,8 +196,8 @@ function RangeSelector(props, ref) {
|
|
|
196
196
|
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
|
|
197
197
|
}
|
|
198
198
|
}), prefix && /*#__PURE__*/React.createElement("div", {
|
|
199
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-prefix"),
|
|
200
|
-
style: styles
|
|
199
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-prefix"), classNames.prefix),
|
|
200
|
+
style: styles.prefix
|
|
201
201
|
}, prefix), /*#__PURE__*/React.createElement(_Input.default, _extends({
|
|
202
202
|
ref: inputStartRef
|
|
203
203
|
}, getInputProps(0), {
|
|
@@ -79,7 +79,7 @@ function SingleSelector(props, ref) {
|
|
|
79
79
|
// ======================== Prefix ========================
|
|
80
80
|
var _React$useContext = React.useContext(_context.default),
|
|
81
81
|
prefixCls = _React$useContext.prefixCls,
|
|
82
|
-
|
|
82
|
+
classNames = _React$useContext.classNames,
|
|
83
83
|
styles = _React$useContext.styles;
|
|
84
84
|
|
|
85
85
|
// ========================= Refs =========================
|
|
@@ -188,8 +188,8 @@ function SingleSelector(props, ref) {
|
|
|
188
188
|
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
|
|
189
189
|
}
|
|
190
190
|
}), prefix && /*#__PURE__*/React.createElement("div", {
|
|
191
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-prefix"),
|
|
192
|
-
style: styles
|
|
191
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-prefix"), classNames.prefix),
|
|
192
|
+
style: styles.prefix
|
|
193
193
|
}, prefix), selectorNode);
|
|
194
194
|
}
|
|
195
195
|
var RefSingleSelector = /*#__PURE__*/React.forwardRef(SingleSelector);
|