@rc-component/picker 1.2.0 → 1.2.2

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.
@@ -104,11 +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, _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function (date) {
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) {
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
113
  onClick: function onClick() {
113
114
  if (!disabled) {
114
115
  onSelect(currentDate);
@@ -43,12 +43,15 @@ 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';
46
47
  export type PickerPanelProps<DateType extends object = any> = BasePickerPanelProps<DateType> & {
47
48
  /** multiple selection. Not support time or datetime picker */
48
49
  multiple?: boolean;
49
50
  defaultValue?: DateType | DateType[] | null;
50
51
  value?: DateType | DateType[] | null;
51
52
  onChange?: (date: DateType | DateType[]) => void;
53
+ styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
54
+ classNames?: Partial<Record<PanelSemanticName, string>>;
52
55
  };
53
56
  declare const _default: <DateType extends object = any>(props: BasePickerPanelProps<DateType> & {
54
57
  /** multiple selection. Not support time or datetime picker */
@@ -56,5 +59,7 @@ declare const _default: <DateType extends object = any>(props: BasePickerPanelPr
56
59
  defaultValue?: DateType | DateType[];
57
60
  value?: DateType | DateType[];
58
61
  onChange?: (date: DateType | DateType[]) => void;
62
+ styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
63
+ classNames?: Partial<Record<PanelSemanticName, string>>;
59
64
  } & React.RefAttributes<PickerPanelRef>) => React.ReactElement;
60
65
  export default _default;
@@ -45,7 +45,9 @@ var DefaultComponents = {
45
45
  time: TimePanel
46
46
  };
47
47
  function PickerPanel(props, ref) {
48
- var locale = props.locale,
48
+ var panelClassNames = props.classNames,
49
+ panelStyles = props.styles,
50
+ locale = props.locale,
49
51
  generateConfig = props.generateConfig,
50
52
  direction = props.direction,
51
53
  prefixCls = props.prefixCls,
@@ -77,7 +79,7 @@ function PickerPanel(props, ref) {
77
79
  var _ref = React.useContext(PickerContext) || {},
78
80
  contextPrefixCls = _ref.prefixCls,
79
81
  pickerClassNames = _ref.classNames,
80
- styles = _ref.styles;
82
+ pickerStyles = _ref.styles;
81
83
 
82
84
  // ======================== prefixCls ========================
83
85
  var mergedPrefixCls = contextPrefixCls || prefixCls || 'rc-picker';
@@ -253,14 +255,16 @@ function PickerPanel(props, ref) {
253
255
  var PanelComponent = components[internalMode] || DefaultComponents[internalMode] || DatePanel;
254
256
 
255
257
  // ======================== Context =========================
258
+ var mergedStyles = pickerStyles !== null && pickerStyles !== void 0 ? pickerStyles : panelStyles;
259
+ var mergedClassNames = pickerClassNames !== null && pickerClassNames !== void 0 ? pickerClassNames : panelClassNames;
256
260
  var parentHackContext = React.useContext(PickerHackContext);
257
261
  var pickerPanelContext = React.useMemo(function () {
258
262
  return _objectSpread(_objectSpread({}, parentHackContext), {}, {
259
263
  hideHeader: hideHeader,
260
- classNames: pickerClassNames,
261
- styles: styles
264
+ classNames: mergedClassNames,
265
+ styles: mergedStyles
262
266
  });
263
- }, [parentHackContext, hideHeader, pickerClassNames, styles]);
267
+ }, [parentHackContext, hideHeader, mergedClassNames, mergedStyles]);
264
268
 
265
269
  // ======================== Warnings ========================
266
270
  if (process.env.NODE_ENV !== 'production') {
package/es/interface.d.ts CHANGED
@@ -201,7 +201,7 @@ 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';
204
+ export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent' | 'popupItem';
205
205
  export type CustomFormat<DateType> = (value: DateType) => string;
206
206
  export type FormatType<DateType = any> = string | CustomFormat<DateType>;
207
207
  export type SharedHTMLAttrs = Omit<React.InputHTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange' | 'placeholder' | 'id' | 'onInvalid' | 'disabled' | 'onFocus' | 'onBlur' | 'onSelect' | 'min' | 'max' | 'onKeyDown' | 'size' | 'prefix'>;
@@ -113,11 +113,12 @@ function PanelBody(props) {
113
113
  rowNode.push( /*#__PURE__*/React.createElement("td", {
114
114
  key: col,
115
115
  title: title,
116
- className: (0, _classnames.default)(cellPrefixCls, _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function (date) {
116
+ className: (0, _classnames.default)(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) {
117
117
  return (0, _dateUtil.isSame)(generateConfig, locale, currentDate, date, type);
118
118
  })), "".concat(cellPrefixCls, "-in-range"), inRange && !rangeStart && !rangeEnd), "".concat(cellPrefixCls, "-range-start"), rangeStart), "".concat(cellPrefixCls, "-range-end"), rangeEnd), "".concat(prefixCls, "-cell-selected"), !hoverRangeValue &&
119
119
  // WeekPicker use row instead
120
120
  type !== 'week' && matchValues(currentDate)), getCellClassName(currentDate))),
121
+ style: styles === null || styles === void 0 ? void 0 : styles.popupItem,
121
122
  onClick: function onClick() {
122
123
  if (!disabled) {
123
124
  onSelect(currentDate);
@@ -43,12 +43,15 @@ 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';
46
47
  export type PickerPanelProps<DateType extends object = any> = BasePickerPanelProps<DateType> & {
47
48
  /** multiple selection. Not support time or datetime picker */
48
49
  multiple?: boolean;
49
50
  defaultValue?: DateType | DateType[] | null;
50
51
  value?: DateType | DateType[] | null;
51
52
  onChange?: (date: DateType | DateType[]) => void;
53
+ styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
54
+ classNames?: Partial<Record<PanelSemanticName, string>>;
52
55
  };
53
56
  declare const _default: <DateType extends object = any>(props: BasePickerPanelProps<DateType> & {
54
57
  /** multiple selection. Not support time or datetime picker */
@@ -56,5 +59,7 @@ declare const _default: <DateType extends object = any>(props: BasePickerPanelPr
56
59
  defaultValue?: DateType | DateType[];
57
60
  value?: DateType | DateType[];
58
61
  onChange?: (date: DateType | DateType[]) => void;
62
+ styles?: Partial<Record<PanelSemanticName, React.CSSProperties>>;
63
+ classNames?: Partial<Record<PanelSemanticName, string>>;
59
64
  } & React.RefAttributes<PickerPanelRef>) => React.ReactElement;
60
65
  export default _default;
@@ -54,7 +54,9 @@ var DefaultComponents = {
54
54
  time: _TimePanel.default
55
55
  };
56
56
  function PickerPanel(props, ref) {
57
- var locale = props.locale,
57
+ var panelClassNames = props.classNames,
58
+ panelStyles = props.styles,
59
+ locale = props.locale,
58
60
  generateConfig = props.generateConfig,
59
61
  direction = props.direction,
60
62
  prefixCls = props.prefixCls,
@@ -86,7 +88,7 @@ function PickerPanel(props, ref) {
86
88
  var _ref = React.useContext(_context.default) || {},
87
89
  contextPrefixCls = _ref.prefixCls,
88
90
  pickerClassNames = _ref.classNames,
89
- styles = _ref.styles;
91
+ pickerStyles = _ref.styles;
90
92
 
91
93
  // ======================== prefixCls ========================
92
94
  var mergedPrefixCls = contextPrefixCls || prefixCls || 'rc-picker';
@@ -262,14 +264,16 @@ function PickerPanel(props, ref) {
262
264
  var PanelComponent = components[internalMode] || DefaultComponents[internalMode] || _DatePanel.default;
263
265
 
264
266
  // ======================== Context =========================
267
+ var mergedStyles = pickerStyles !== null && pickerStyles !== void 0 ? pickerStyles : panelStyles;
268
+ var mergedClassNames = pickerClassNames !== null && pickerClassNames !== void 0 ? pickerClassNames : panelClassNames;
265
269
  var parentHackContext = React.useContext(_context2.PickerHackContext);
266
270
  var pickerPanelContext = React.useMemo(function () {
267
271
  return _objectSpread(_objectSpread({}, parentHackContext), {}, {
268
272
  hideHeader: hideHeader,
269
- classNames: pickerClassNames,
270
- styles: styles
273
+ classNames: mergedClassNames,
274
+ styles: mergedStyles
271
275
  });
272
- }, [parentHackContext, hideHeader, pickerClassNames, styles]);
276
+ }, [parentHackContext, hideHeader, mergedClassNames, mergedStyles]);
273
277
 
274
278
  // ======================== Warnings ========================
275
279
  if (process.env.NODE_ENV !== 'production') {
@@ -201,7 +201,7 @@ 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';
204
+ export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent' | 'popupItem';
205
205
  export type CustomFormat<DateType> = (value: DateType) => string;
206
206
  export type FormatType<DateType = any> = string | CustomFormat<DateType>;
207
207
  export type SharedHTMLAttrs = Omit<React.InputHTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange' | 'placeholder' | 'id' | 'onInvalid' | 'disabled' | 'onFocus' | 'onBlur' | 'onSelect' | 'min' | 'max' | 'onKeyDown' | 'size' | 'prefix'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/picker",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "React date & time picker",
5
5
  "keywords": [
6
6
  "react",