rsuite 5.18.1-beta.4 → 5.19.0-beta.5

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.
@@ -123,6 +123,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
123
123
  defaultOpen: defaultOpen,
124
124
  menuButtonText: title,
125
125
  renderMenuButton: renderMenuButton,
126
+ disabled: disabled,
126
127
  openMenuOn: menuButtonTriggers,
127
128
  renderMenuPopup: function renderMenuPopup(_ref, popupRef) {
128
129
  var open = _ref.open,
@@ -200,7 +200,7 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
200
200
  "aria-placeholder": typeof children === 'string' ? children : undefined
201
201
  }, label && /*#__PURE__*/React.createElement("span", {
202
202
  className: prefix('label')
203
- }, label, ": "), children) : null, showCleanButton && /*#__PURE__*/React.createElement(CloseButton, {
203
+ }, label), children) : null, showCleanButton && /*#__PURE__*/React.createElement(CloseButton, {
204
204
  className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["clean"]))),
205
205
  tabIndex: -1,
206
206
  locale: {
@@ -52,8 +52,12 @@ var SidenavItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
52
52
  prefix = _useClassNames.prefix;
53
53
 
54
54
  var selected = activeProp !== null && activeProp !== void 0 ? activeProp : !isNil(eventKey) && shallowEqual(activeKey, eventKey);
55
+ var whisperRef = React.useRef(null);
55
56
  var handleClick = useCallback(function (event) {
57
+ var _whisperRef$current;
58
+
56
59
  if (disabled) return;
60
+ (_whisperRef$current = whisperRef.current) === null || _whisperRef$current === void 0 ? void 0 : _whisperRef$current.close();
57
61
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(eventKey, event);
58
62
  onSelectFromNav === null || onSelectFromNav === void 0 ? void 0 : onSelectFromNav(eventKey, event);
59
63
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
@@ -63,7 +67,8 @@ var SidenavItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
63
67
  return /*#__PURE__*/React.createElement(Whisper, {
64
68
  trigger: "hover",
65
69
  speaker: /*#__PURE__*/React.createElement(Tooltip, null, tooltip),
66
- placement: "right"
70
+ placement: "right",
71
+ ref: whisperRef
67
72
  }, function (triggerProps, triggerRef) {
68
73
  return /*#__PURE__*/React.createElement(MenuItem, {
69
74
  selected: selected,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { WithAsProps } from '../@types/common';
2
+ import { RsRefForwardingComponent, WithAsProps } from '../@types/common';
3
+ import StackItem from './StackItem';
3
4
  export interface StackProps extends WithAsProps {
4
5
  /**
5
6
  * The direction of the children in the stack.
@@ -22,5 +23,8 @@ export interface StackProps extends WithAsProps {
22
23
  */
23
24
  wrap?: boolean;
24
25
  }
25
- declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<HTMLDivElement>>;
26
+ export interface StackComponent extends RsRefForwardingComponent<'div', StackProps> {
27
+ Item: typeof StackItem;
28
+ }
29
+ declare const Stack: StackComponent;
26
30
  export default Stack;
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { useClassNames, useCustom, isSupportFlexGap } from '../utils';
6
+ import StackItem from './StackItem';
6
7
  var Stack = /*#__PURE__*/React.forwardRef(function (props, ref) {
7
8
  var _itemStyles;
8
9
 
@@ -32,7 +33,6 @@ var Stack = /*#__PURE__*/React.forwardRef(function (props, ref) {
32
33
 
33
34
  var classes = merge(className, withClassPrefix());
34
35
  var isSupportGridGap = isSupportFlexGap();
35
- var count = React.Children.count(children);
36
36
  var gridGap = Array.isArray(spacing) ? spacing : [spacing, 0];
37
37
  var itemStyles = (_itemStyles = {}, _itemStyles[rtl ? 'marginLeft' : 'marginRight'] = gridGap[0], _itemStyles.marginBottom = gridGap[1], _itemStyles);
38
38
 
@@ -43,19 +43,30 @@ var Stack = /*#__PURE__*/React.forwardRef(function (props, ref) {
43
43
  flexWrap: wrap ? 'wrap' : undefined,
44
44
  gap: isSupportGridGap ? spacing : undefined
45
45
  }, style);
46
+ /*
47
+ * toArray remove undefined, null and boolean
48
+ */
46
49
 
50
+
51
+ var filterChildren = React.Children.toArray(children);
52
+ var count = filterChildren.length;
47
53
  return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
48
54
  ref: ref,
49
55
  className: classes,
50
56
  style: styles
51
- }), React.Children.map(children, function (child, index) {
52
- var childNode = /*#__PURE__*/React.createElement("div", {
57
+ }), React.Children.map(filterChildren, function (child, index) {
58
+ var childNode = child.type !== StackItem ? /*#__PURE__*/React.createElement(StackItem, {
59
+ key: index,
53
60
  className: prefix('item'),
54
61
  style: !isSupportGridGap ? itemStyles : undefined
55
- }, child);
62
+ }, child) : /*#__PURE__*/React.cloneElement(child, {
63
+ className: merge(prefix('item'), child.props.className),
64
+ style: !isSupportGridGap ? _extends({}, itemStyles, child.props.style) : child.props.style
65
+ });
56
66
  return [childNode, index < count - 1 ? divider : null];
57
67
  }));
58
68
  });
69
+ Stack.Item = StackItem;
59
70
  Stack.displayName = 'Stack';
60
71
  Stack.propTypes = {
61
72
  className: PropTypes.string,
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { WithAsProps } from '../@types/common';
4
+ export interface StackItemProps extends WithAsProps {
5
+ alignSelf?: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';
6
+ flex?: React.CSSProperties['flex'];
7
+ grow?: React.CSSProperties['flexGrow'];
8
+ shrink?: React.CSSProperties['flexShrink'];
9
+ basis?: React.CSSProperties['flexBasis'];
10
+ order?: React.CSSProperties['order'];
11
+ }
12
+ declare function StackItem(props: StackItemProps): JSX.Element;
13
+ declare namespace StackItem {
14
+ var displayName: string;
15
+ var propTypes: {
16
+ className: PropTypes.Requireable<string>;
17
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
+ alignSelf: PropTypes.Requireable<string>;
19
+ flex: PropTypes.Requireable<string | number>;
20
+ grow: PropTypes.Requireable<number>;
21
+ shrink: PropTypes.Requireable<number>;
22
+ order: PropTypes.Requireable<number>;
23
+ basis: PropTypes.Requireable<string>;
24
+ };
25
+ }
26
+ export default StackItem;
@@ -0,0 +1,42 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ export default function StackItem(props) {
6
+ var _props$as = props.as,
7
+ Component = _props$as === void 0 ? 'div' : _props$as,
8
+ style = props.style,
9
+ className = props.className,
10
+ alignSelf = props.alignSelf,
11
+ flex = props.flex,
12
+ grow = props.grow,
13
+ shrink = props.shrink,
14
+ order = props.order,
15
+ basis = props.basis,
16
+ rest = _objectWithoutPropertiesLoose(props, ["as", "style", "className", "alignSelf", "flex", "grow", "shrink", "order", "basis"]);
17
+
18
+ return /*#__PURE__*/React.createElement(Component, _extends({
19
+ className: className,
20
+ style: _extends({
21
+ alignSelf: alignSelf,
22
+ order: order
23
+ }, flex ? {
24
+ flex: flex
25
+ } : {
26
+ flexGrow: grow,
27
+ flexShrink: shrink,
28
+ flexBasis: basis
29
+ }, style)
30
+ }, rest));
31
+ }
32
+ StackItem.displayName = 'StackItem';
33
+ StackItem.propTypes = {
34
+ className: PropTypes.string,
35
+ children: PropTypes.node,
36
+ alignSelf: PropTypes.oneOf(['flex-start', 'flex-end', 'center', 'baseline', 'stretch']),
37
+ flex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
38
+ grow: PropTypes.number,
39
+ shrink: PropTypes.number,
40
+ order: PropTypes.number,
41
+ basis: PropTypes.string
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.18.1-beta.4",
3
+ "version": "5.19.0-beta.5",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -24,15 +24,15 @@
24
24
  "url": "git@github.com:rsuite/rsuite.git"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/runtime": "^7.8.4",
27
+ "@babel/runtime": "^7.18.9",
28
28
  "@juggle/resize-observer": "^3.3.1",
29
29
  "@rsuite/icons": "^1.0.2",
30
- "@types/chai": "^4.2.18",
31
- "@types/lodash": "^4.14.134",
30
+ "@types/chai": "^4.3.3",
31
+ "@types/lodash": "^4.14.184",
32
32
  "@types/prop-types": "^15.7.4",
33
33
  "@types/react-window": "^1.8.5",
34
34
  "classnames": "^2.3.1",
35
- "date-fns": "^2.13.0",
35
+ "date-fns": "^2.29.2",
36
36
  "dom-lib": "^3.1.2",
37
37
  "lodash": "^4.17.11",
38
38
  "prop-types": "^15.8.1",