@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
|
@@ -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;
|
package/lib/PickerPanel/index.js
CHANGED
|
@@ -264,16 +264,19 @@ function PickerPanel(props, ref) {
|
|
|
264
264
|
var PanelComponent = components[internalMode] || DefaultComponents[internalMode] || _DatePanel.default;
|
|
265
265
|
|
|
266
266
|
// ======================== Context =========================
|
|
267
|
-
var
|
|
268
|
-
|
|
267
|
+
var sharedPanelContext = React.useMemo(function () {
|
|
268
|
+
var _ref2, _pickerClassNames$pop, _ref3, _pickerStyles$popup;
|
|
269
|
+
return {
|
|
270
|
+
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 : {},
|
|
271
|
+
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 : {}
|
|
272
|
+
};
|
|
273
|
+
}, [pickerClassNames, panelClassNames, pickerStyles, panelStyles]);
|
|
269
274
|
var parentHackContext = React.useContext(_context2.PickerHackContext);
|
|
270
275
|
var pickerPanelContext = React.useMemo(function () {
|
|
271
276
|
return _objectSpread(_objectSpread({}, parentHackContext), {}, {
|
|
272
|
-
hideHeader: hideHeader
|
|
273
|
-
classNames: mergedClassNames,
|
|
274
|
-
styles: mergedStyles
|
|
277
|
+
hideHeader: hideHeader
|
|
275
278
|
});
|
|
276
|
-
}, [parentHackContext, hideHeader
|
|
279
|
+
}, [parentHackContext, hideHeader]);
|
|
277
280
|
|
|
278
281
|
// ======================== Warnings ========================
|
|
279
282
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -293,7 +296,9 @@ function PickerPanel(props, ref) {
|
|
|
293
296
|
'disabledDate', 'minDate', 'maxDate',
|
|
294
297
|
// Hover
|
|
295
298
|
'onHover']);
|
|
296
|
-
return /*#__PURE__*/React.createElement(_context2.
|
|
299
|
+
return /*#__PURE__*/React.createElement(_context2.SharedPanelContext.Provider, {
|
|
300
|
+
value: sharedPanelContext
|
|
301
|
+
}, /*#__PURE__*/React.createElement(_context2.PickerHackContext.Provider, {
|
|
297
302
|
value: pickerPanelContext
|
|
298
303
|
}, /*#__PURE__*/React.createElement("div", {
|
|
299
304
|
ref: rootRef,
|
|
@@ -326,7 +331,7 @@ function PickerPanel(props, ref) {
|
|
|
326
331
|
,
|
|
327
332
|
hoverRangeValue: hoverRangeDate,
|
|
328
333
|
hoverValue: hoverValue
|
|
329
|
-
}))));
|
|
334
|
+
})))));
|
|
330
335
|
}
|
|
331
336
|
var RefPanelPicker = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(PickerPanel));
|
|
332
337
|
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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useSemantic;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
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); }
|
|
14
|
+
/**
|
|
15
|
+
* Convert `classNames` & `styles` to a fully filled object
|
|
16
|
+
*/
|
|
17
|
+
function useSemantic(classNames, styles) {
|
|
18
|
+
return (0, _react.useMemo)(function () {
|
|
19
|
+
var mergedClassNames = _objectSpread(_objectSpread({}, classNames), {}, {
|
|
20
|
+
popup: (classNames === null || classNames === void 0 ? void 0 : classNames.popup) || {}
|
|
21
|
+
});
|
|
22
|
+
var mergedStyles = _objectSpread(_objectSpread({}, styles), {}, {
|
|
23
|
+
popup: (styles === null || styles === void 0 ? void 0 : styles.popup) || {}
|
|
24
|
+
});
|
|
25
|
+
return [mergedClassNames, mergedStyles];
|
|
26
|
+
}, [classNames, styles]);
|
|
27
|
+
}
|
package/lib/interface.d.ts
CHANGED
|
@@ -201,19 +201,25 @@ 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';
|
|
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 PanelSemanticName = 'root' | 'header' | 'body' | 'content' | 'item' | 'footer';
|
|
210
211
|
export interface SharedPickerProps<DateType extends object = any> extends SharedHTMLAttrs, Pick<SharedPanelProps<DateType>, 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'> {
|
|
211
212
|
direction?: 'ltr' | 'rtl';
|
|
212
213
|
prefixCls?: string;
|
|
213
214
|
className?: string;
|
|
214
215
|
style?: React.CSSProperties;
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
rootClassName?: string;
|
|
217
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
|
|
218
|
+
popup?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
|
|
219
|
+
};
|
|
220
|
+
classNames?: Partial<Record<SemanticName, string>> & {
|
|
221
|
+
popup?: Partial<Record<PanelSemanticName, string>>;
|
|
222
|
+
};
|
|
217
223
|
locale: Locale;
|
|
218
224
|
generateConfig: GenerateConfig<DateType>;
|
|
219
225
|
picker?: PickerMode;
|
|
@@ -2,4 +2,4 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare function getClearIcon(prefixCls: string, allowClear?: boolean | {
|
|
4
4
|
clearIcon?: ReactNode;
|
|
5
|
-
}, clearIcon?: ReactNode): string | number | true |
|
|
5
|
+
}, clearIcon?: ReactNode): string | number | true | React.JSX.Element | Iterable<ReactNode>;
|