rsuite 5.33.1 → 5.34.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/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [5.34.0](https://github.com/rsuite/rsuite/compare/v5.33.1...v5.34.0) (2023-05-19)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **DatePicker:** added stack styles to datepicker styles ([#3195](https://github.com/rsuite/rsuite/issues/3195)) ([b3ed580](https://github.com/rsuite/rsuite/commit/b3ed580867db2e5205e71475c593e7d17ff04b49))
6
+ - **SelectPicker:** prevent error when listProps.itemSize is a number ([#3193](https://github.com/rsuite/rsuite/issues/3193)) ([151df47](https://github.com/rsuite/rsuite/commit/151df474b15ab4651d4ee5777b66018e58837816))
7
+
8
+ ### Features
9
+
10
+ - **Timeline:** add isItemActive prop ([#3198](https://github.com/rsuite/rsuite/issues/3198)) ([377930f](https://github.com/rsuite/rsuite/commit/377930f3498c59834a424417c136499866aacec2))
11
+
1
12
  ## [5.33.1](https://github.com/rsuite/rsuite/compare/v5.33.0...v5.33.1) (2023-05-12)
2
13
 
3
14
  ### Bug Fixes
@@ -2,6 +2,7 @@
2
2
  @import '../../styles/mixins/listbox';
3
3
  @import '../../Button/styles/mixin';
4
4
  @import '../../Picker/styles/mixin';
5
+ @import '../../Stack/styles/index';
5
6
  @import 'mixin';
6
7
 
7
8
  // DatePicker Picker
@@ -42,7 +42,7 @@
42
42
  }
43
43
  }
44
44
 
45
- &-item-last &-item-dot::before {
45
+ &-item-active &-item-dot::before {
46
46
  background-color: var(--rs-timeline-indicator-active-bg);
47
47
  }
48
48
 
@@ -8,9 +8,18 @@ export interface TimelineProps extends WithAsProps {
8
8
  align?: 'left' | 'right' | 'alternate';
9
9
  /** Timeline endless **/
10
10
  endless?: boolean;
11
+ /**
12
+ * Whether an item is active (with highlighted dot).
13
+ *
14
+ * @default
15
+ * The last item is marked active.
16
+ */
17
+ isItemActive?: (index: number, totalItemsCount: number) => boolean;
11
18
  }
12
19
  interface TimelineComponent extends RsRefForwardingComponent<'div', TimelineProps> {
13
20
  Item: typeof TimelineItem;
21
+ ACTIVE_FIRST: (index: number, totalItemsCount: number) => boolean;
22
+ ACTIVE_LAST: (index: number, totalItemsCount: number) => boolean;
14
23
  }
15
24
  declare const Timeline: TimelineComponent;
16
25
  export default Timeline;
@@ -29,7 +29,9 @@ var Timeline = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
29
29
  _props$align = props.align,
30
30
  align = _props$align === void 0 ? 'left' : _props$align,
31
31
  endless = props.endless,
32
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["children", "as", "classPrefix", "className", "align", "endless"]);
32
+ _props$isItemActive = props.isItemActive,
33
+ isItemActive = _props$isItemActive === void 0 ? Timeline.ACTIVE_LAST : _props$isItemActive,
34
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["children", "as", "classPrefix", "className", "align", "endless", "isItemActive"]);
33
35
 
34
36
  var _useClassNames = (0, _utils.useClassNames)(classPrefix),
35
37
  merge = _useClassNames.merge,
@@ -52,11 +54,20 @@ var Timeline = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
52
54
  }), _utils.ReactChildren.mapCloneElement(children, function (_child, index) {
53
55
  return {
54
56
  last: index + 1 === count,
57
+ INTERNAL_active: isItemActive(index, count),
55
58
  align: align
56
59
  };
57
60
  }));
58
61
  });
59
62
 
63
+ Timeline.ACTIVE_FIRST = function (index) {
64
+ return index === 0;
65
+ };
66
+
67
+ Timeline.ACTIVE_LAST = function (index, totalItemsCount) {
68
+ return index === totalItemsCount - 1;
69
+ };
70
+
60
71
  Timeline.Item = _TimelineItem.default;
61
72
  Timeline.displayName = 'Timeline';
62
73
  Timeline.propTypes = {
@@ -1,7 +1,18 @@
1
1
  import React from 'react';
2
2
  import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
3
3
  export interface TimelineItemProps extends WithAsProps {
4
- /** Whether the last item */
4
+ /**
5
+ * Whether the last item
6
+ *
7
+ * @internal
8
+ * This props is supposed to be used only by Timeline component internally
9
+ * User should never rely on this prop
10
+ *
11
+ * @deprecated
12
+ * This prop was used to indicate whether an item is the last item so that it gets highlighted.
13
+ * Now we can specify whether an item should be highlighted individually.
14
+ * Use {@link INTERNAL_active} instead
15
+ */
5
16
  last?: boolean;
6
17
  /** Customizing the Timeline item */
7
18
  dot?: React.ReactNode;
@@ -11,6 +22,12 @@ export interface TimelineItemProps extends WithAsProps {
11
22
  as?: React.ElementType;
12
23
  /** Customized time of timeline **/
13
24
  time?: React.ReactNode;
25
+ /**
26
+ * @internal
27
+ * This props is supposed to be used only by Timeline component internally
28
+ * User should never rely on this prop
29
+ */
30
+ INTERNAL_active?: boolean;
14
31
  }
15
32
  declare const TimelineItem: RsRefForwardingComponent<'div', TimelineItemProps>;
16
33
  export default TimelineItem;
@@ -21,11 +21,12 @@ var TimelineItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
21
21
  children = props.children,
22
22
  _props$classPrefix = props.classPrefix,
23
23
  classPrefix = _props$classPrefix === void 0 ? 'timeline-item' : _props$classPrefix,
24
- last = props.last,
24
+ DEPRECATED_last = props.last,
25
25
  className = props.className,
26
26
  dot = props.dot,
27
27
  time = props.time,
28
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "children", "classPrefix", "last", "className", "dot", "time"]);
28
+ INTERNAL_active = props.INTERNAL_active,
29
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "children", "classPrefix", "last", "className", "dot", "time", "INTERNAL_active"]);
29
30
 
30
31
  var _useClassNames = (0, _utils.useClassNames)(classPrefix),
31
32
  merge = _useClassNames.merge,
@@ -33,7 +34,8 @@ var TimelineItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
33
34
  prefix = _useClassNames.prefix;
34
35
 
35
36
  var classes = merge(className, withClassPrefix({
36
- last: last
37
+ last: DEPRECATED_last,
38
+ active: INTERNAL_active
37
39
  }));
38
40
  return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
39
41
  ref: ref,
@@ -21,7 +21,8 @@ var List = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
21
21
  var rowHeight = props.rowHeight,
22
22
  _props$as = props.as,
23
23
  Component = _props$as === void 0 ? _reactWindow.VariableSizeList : _props$as,
24
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["rowHeight", "as"]);
24
+ itemSizeProp = props.itemSize,
25
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["rowHeight", "as", "itemSize"]);
25
26
  var listRef = (0, _react.useRef)(null);
26
27
 
27
28
  var _useCustom = (0, _utils.useCustom)(),
@@ -56,7 +57,15 @@ var List = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
56
57
  index: index
57
58
  }) : rowHeight || 0;
58
59
  }, [rowHeight]);
59
- var compatibleProps = (0, _extends2.default)({}, rest);
60
+ var itemSize = (0, _react.useMemo)(function () {
61
+ if (typeof itemSizeProp === 'function') return itemSizeProp;
62
+ return function () {
63
+ return itemSizeProp;
64
+ };
65
+ }, [itemSizeProp]);
66
+ var compatibleProps = (0, _extends2.default)({
67
+ itemSize: itemSize
68
+ }, rest);
60
69
 
61
70
  if (rowHeight) {
62
71
  compatibleProps.itemSize = Component === _reactWindow.VariableSizeList ? setRowHeight : rowHeight;
@@ -14770,7 +14770,7 @@ textarea.rs-picker-menu .rs-picker-search-bar .rs-picker-search-bar-input {
14770
14770
  .rs-timeline-item-custom-dot::before {
14771
14771
  display: none;
14772
14772
  }
14773
- .rs-timeline-item-last .rs-timeline-item-dot::before {
14773
+ .rs-timeline-item-active .rs-timeline-item-dot::before {
14774
14774
  background-color: #3498ff;
14775
14775
  background-color: var(--rs-timeline-indicator-active-bg);
14776
14776
  }