rsuite 5.33.0 → 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 +20 -0
- package/DatePicker/styles/index.less +1 -0
- package/Timeline/styles/index.less +1 -1
- package/cjs/Carousel/Carousel.js +12 -2
- package/cjs/CheckPicker/CheckPicker.js +6 -2
- package/cjs/DatePicker/DatePicker.js +1 -1
- package/cjs/InputPicker/InputPicker.js +7 -2
- package/cjs/MultiCascader/MultiCascader.js +1 -0
- package/cjs/Picker/DropdownMenu.d.ts +1 -0
- package/cjs/Picker/DropdownMenu.js +19 -6
- package/cjs/Picker/utils.d.ts +2 -0
- package/cjs/Picker/utils.js +8 -1
- package/cjs/SelectPicker/SelectPicker.js +7 -2
- package/cjs/Timeline/Timeline.d.ts +9 -0
- package/cjs/Timeline/Timeline.js +12 -1
- package/cjs/Timeline/TimelineItem.d.ts +18 -1
- package/cjs/Timeline/TimelineItem.js +5 -3
- package/cjs/Windowing/List.js +11 -2
- package/cjs/utils/getDataGroupBy.d.ts +4 -1
- package/cjs/utils/getDataGroupBy.js +12 -24
- package/cjs/utils/index.d.ts +0 -1
- package/cjs/utils/index.js +1 -6
- package/cjs/utils/treeUtils.d.ts +8 -2
- package/cjs/utils/treeUtils.js +48 -14
- package/dist/rsuite-no-reset-rtl.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +1 -1
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +1 -1
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +1 -1
- package/dist/rsuite.js +59 -19
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Carousel/Carousel.js +13 -3
- package/esm/CheckPicker/CheckPicker.js +5 -2
- package/esm/DatePicker/DatePicker.js +1 -1
- package/esm/InputPicker/InputPicker.js +6 -2
- package/esm/MultiCascader/MultiCascader.js +1 -0
- package/esm/Picker/DropdownMenu.d.ts +1 -0
- package/esm/Picker/DropdownMenu.js +17 -5
- package/esm/Picker/utils.d.ts +2 -0
- package/esm/Picker/utils.js +8 -1
- package/esm/SelectPicker/SelectPicker.js +6 -2
- package/esm/Timeline/Timeline.d.ts +9 -0
- package/esm/Timeline/Timeline.js +13 -1
- package/esm/Timeline/TimelineItem.d.ts +18 -1
- package/esm/Timeline/TimelineItem.js +5 -3
- package/esm/Windowing/List.js +12 -3
- package/esm/utils/getDataGroupBy.d.ts +4 -1
- package/esm/utils/getDataGroupBy.js +13 -24
- package/esm/utils/index.d.ts +0 -1
- package/esm/utils/index.js +0 -1
- package/esm/utils/treeUtils.d.ts +8 -2
- package/esm/utils/treeUtils.js +43 -15
- package/package.json +3 -3
package/esm/Carousel/Carousel.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
import React, { useState, useMemo, useCallback, useRef } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { useClassNames, useCustom, guid, ReactChildren, useTimeout, mergeRefs, useControlled } from '../utils';
|
|
6
|
+
import { useClassNames, useCustom, guid, ReactChildren, useTimeout, mergeRefs, useControlled, useUpdateEffect } from '../utils';
|
|
7
7
|
var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
8
|
var _sliderStyles, _ref;
|
|
9
9
|
|
|
@@ -43,13 +43,23 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
43
43
|
|
|
44
44
|
var _useControlled = useControlled(activeIndexProp, defaultActiveIndex),
|
|
45
45
|
activeIndex = _useControlled[0],
|
|
46
|
-
setActiveIndex = _useControlled[1]
|
|
46
|
+
setActiveIndex = _useControlled[1],
|
|
47
|
+
isControlled = _useControlled[2];
|
|
47
48
|
|
|
48
49
|
var _useState = useState(0),
|
|
49
50
|
lastIndex = _useState[0],
|
|
50
51
|
setLastIndex = _useState[1];
|
|
51
52
|
|
|
52
|
-
var rootRef = useRef(null);
|
|
53
|
+
var rootRef = useRef(null);
|
|
54
|
+
useUpdateEffect(function () {
|
|
55
|
+
// When the index is controlled, the index is not updated when the number of children changes.
|
|
56
|
+
if (isControlled) {
|
|
57
|
+
return;
|
|
58
|
+
} // Reset the index when the number of children changes.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
setActiveIndex(0);
|
|
62
|
+
}, [children, isControlled]); // Set a timer for automatic playback.
|
|
53
63
|
// `autoplay` needs to be cast to boolean type to avoid undefined parameters.
|
|
54
64
|
|
|
55
65
|
var _useTimeout = useTimeout(function () {
|
|
@@ -14,7 +14,8 @@ import omit from 'lodash/omit';
|
|
|
14
14
|
import pick from 'lodash/pick';
|
|
15
15
|
import isNil from 'lodash/isNil';
|
|
16
16
|
import { filterNodesOfTree } from '../utils/treeUtils';
|
|
17
|
-
import { createChainedFunction,
|
|
17
|
+
import { createChainedFunction, useClassNames, shallowEqual, useCustom, useControlled, mergeRefs } from '../utils';
|
|
18
|
+
import { getDataGroupBy } from '../utils/getDataGroupBy';
|
|
18
19
|
import { DropdownMenu, DropdownMenuCheckItem as DropdownMenuItem, PickerToggle, PickerOverlay, SearchBar, SelectedElement, PickerToggleTrigger, useFocusItemValue, usePickerClassName, useSearch, usePublicMethods, useToggleKeyDownEvent, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
|
|
19
20
|
var emptyArray = [];
|
|
20
21
|
var CheckPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -321,8 +322,10 @@ var CheckPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
321
322
|
dropdownMenuItemAs: DropdownMenuItem,
|
|
322
323
|
activeItemValues: value,
|
|
323
324
|
focusItemValue: focusItemValue,
|
|
324
|
-
data: [].concat(filteredStickyItems, items)
|
|
325
|
+
data: [].concat(filteredStickyItems, items) // `group` is redundant so long as `groupBy` exists
|
|
326
|
+
,
|
|
325
327
|
group: !isUndefined(groupBy),
|
|
328
|
+
groupBy: groupBy,
|
|
326
329
|
onSelect: handleItemSelect,
|
|
327
330
|
onGroupTitleClick: onGroupTitleClick,
|
|
328
331
|
virtualized: virtualized
|
|
@@ -89,7 +89,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
89
89
|
value = _useControlled[0],
|
|
90
90
|
setValue = _useControlled[1];
|
|
91
91
|
|
|
92
|
-
var _useCalendarDate = useCalendarDate(
|
|
92
|
+
var _useCalendarDate = useCalendarDate(value, calendarDefaultDate),
|
|
93
93
|
calendarDate = _useCalendarDate.calendarDate,
|
|
94
94
|
setCalendarDate = _useCalendarDate.setCalendarDate,
|
|
95
95
|
resetCalendarDate = _useCalendarDate.resetCalendarDate;
|
|
@@ -18,7 +18,8 @@ import getWidth from 'dom-lib/getWidth';
|
|
|
18
18
|
import shallowEqual from '../utils/shallowEqual';
|
|
19
19
|
import { filterNodesOfTree } from '../utils/treeUtils';
|
|
20
20
|
import Plaintext from '../Plaintext';
|
|
21
|
-
import { createChainedFunction, tplTransform,
|
|
21
|
+
import { createChainedFunction, tplTransform, useClassNames, useCustom, useControlled, mergeRefs, isOneOf, KEY_VALUES } from '../utils';
|
|
22
|
+
import { getDataGroupBy } from '../utils/getDataGroupBy';
|
|
22
23
|
import { DropdownMenu, DropdownMenuItem, DropdownMenuCheckItem, PickerToggle, PickerOverlay, PickerToggleTrigger, useFocusItemValue, usePickerClassName, useSearch, usePublicMethods, useToggleKeyDownEvent, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
|
|
23
24
|
import Tag from '../Tag';
|
|
24
25
|
import InputAutosize from './InputAutosize';
|
|
@@ -623,8 +624,11 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
623
624
|
activeItemValues: multi ? value : [value],
|
|
624
625
|
focusItemValue: focusItemValue,
|
|
625
626
|
maxHeight: menuMaxHeight,
|
|
626
|
-
data: items
|
|
627
|
+
data: items // FIXME-Doma
|
|
628
|
+
// `group` is redundant so long as `groupBy` exists
|
|
629
|
+
,
|
|
627
630
|
group: !isUndefined(groupBy),
|
|
631
|
+
groupBy: groupBy,
|
|
628
632
|
onSelect: multi ? handleCheckTag : handleSelectItem // fixme don't use any
|
|
629
633
|
,
|
|
630
634
|
renderMenuGroup: renderMenuGroup,
|
|
@@ -225,6 +225,7 @@ var MultiCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
225
225
|
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : (_triggerRef$current$u = _triggerRef$current.updatePosition) === null || _triggerRef$current$u === void 0 ? void 0 : _triggerRef$current$u.call(_triggerRef$current);
|
|
226
226
|
}, [onSelect, getChildren, childrenKey, inline, addFlattenData, addColumn, removeColumnByIndex]);
|
|
227
227
|
var handleCheck = useCallback(function (node, event, checked) {
|
|
228
|
+
console.log('handleCheck');
|
|
228
229
|
var nodeValue = node[valueKey];
|
|
229
230
|
var nextValue = [];
|
|
230
231
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import _get from "lodash/get";
|
|
3
4
|
|
|
4
5
|
var _this = this;
|
|
5
6
|
|
|
@@ -22,6 +23,7 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
22
23
|
var _props$data = props.data,
|
|
23
24
|
data = _props$data === void 0 ? [] : _props$data,
|
|
24
25
|
group = props.group,
|
|
26
|
+
groupBy = props.groupBy,
|
|
25
27
|
_props$maxHeight = props.maxHeight,
|
|
26
28
|
maxHeight = _props$maxHeight === void 0 ? 320 : _props$maxHeight,
|
|
27
29
|
_props$activeItemValu = props.activeItemValues,
|
|
@@ -50,7 +52,7 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
50
52
|
renderMenuItem = props.renderMenuItem,
|
|
51
53
|
onGroupTitleClick = props.onGroupTitleClick,
|
|
52
54
|
onSelect = props.onSelect,
|
|
53
|
-
rest = _objectWithoutPropertiesLoose(props, ["data", "group", "maxHeight", "activeItemValues", "disabledItemValues", "classPrefix", "valueKey", "labelKey", "virtualized", "listProps", "listRef", "className", "style", "focusItemValue", "dropdownMenuItemClassPrefix", "dropdownMenuItemAs", "rowHeight", "rowGroupHeight", "renderMenuGroup", "renderMenuItem", "onGroupTitleClick", "onSelect"]);
|
|
55
|
+
rest = _objectWithoutPropertiesLoose(props, ["data", "group", "groupBy", "maxHeight", "activeItemValues", "disabledItemValues", "classPrefix", "valueKey", "labelKey", "virtualized", "listProps", "listRef", "className", "style", "focusItemValue", "dropdownMenuItemClassPrefix", "dropdownMenuItemAs", "rowHeight", "rowGroupHeight", "renderMenuGroup", "renderMenuItem", "onGroupTitleClick", "onSelect"]);
|
|
54
56
|
|
|
55
57
|
var _useClassNames = useClassNames(classPrefix),
|
|
56
58
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
@@ -180,11 +182,21 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
180
182
|
};
|
|
181
183
|
|
|
182
184
|
var filteredItems = group ? data.filter(function (item) {
|
|
183
|
-
|
|
184
|
-
var _item$parent;
|
|
185
|
+
var _item$parent;
|
|
185
186
|
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
// Display group title items
|
|
188
|
+
if (item[KEY_GROUP]) return true; // Display items under the unfolded group
|
|
189
|
+
// FIXME-Doma
|
|
190
|
+
// `groupBy` is bound to be string when `group` is true
|
|
191
|
+
// because `group` is actually redundant as a prop
|
|
192
|
+
// It could simply be derived from `groupBy` value
|
|
193
|
+
|
|
194
|
+
var groupValue = _get(item, groupBy, '') || ( // FIXME-Doma
|
|
195
|
+
// Usage of `item.parent` is strongly discouraged
|
|
196
|
+
// It's only here for legacy support
|
|
197
|
+
// Remove once `item.parent` is completely removed across related components
|
|
198
|
+
(_item$parent = item.parent) === null || _item$parent === void 0 ? void 0 : _item$parent[KEY_GROUP_TITLE]);
|
|
199
|
+
return !foldedGroupKeys.includes(groupValue);
|
|
188
200
|
}) : data;
|
|
189
201
|
var rowCount = filteredItems.length;
|
|
190
202
|
useMount(function () {
|
package/esm/Picker/utils.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export interface ToggleKeyDownEventProps {
|
|
|
73
73
|
overlayRef?: React.RefObject<any>;
|
|
74
74
|
searchInputRef?: React.RefObject<any>;
|
|
75
75
|
active?: boolean;
|
|
76
|
+
readOnly?: boolean;
|
|
77
|
+
disabled?: boolean;
|
|
76
78
|
onExit?: (event: any) => void;
|
|
77
79
|
onKeyDown?: (event: any) => void;
|
|
78
80
|
onOpen?: () => void;
|
package/esm/Picker/utils.js
CHANGED
|
@@ -403,6 +403,8 @@ export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
|
|
|
403
403
|
overlayRef = props.overlayRef,
|
|
404
404
|
searchInputRef = props.searchInputRef,
|
|
405
405
|
active = props.active,
|
|
406
|
+
readOnly = props.readOnly,
|
|
407
|
+
disabled = props.disabled,
|
|
406
408
|
onExit = props.onExit,
|
|
407
409
|
onOpen = props.onOpen,
|
|
408
410
|
onClose = props.onClose,
|
|
@@ -431,6 +433,11 @@ export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
|
|
|
431
433
|
handleOpen();
|
|
432
434
|
}, [active, handleOpen, handleClose]);
|
|
433
435
|
var onToggle = useCallback(function (event) {
|
|
436
|
+
// Keyboard events should not be processed when readOnly and disabled are set.
|
|
437
|
+
if (readOnly || disabled) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
434
441
|
if (event.target === (targetRef === null || targetRef === void 0 ? void 0 : targetRef.current)) {
|
|
435
442
|
// enter
|
|
436
443
|
if (toggle && event.key === KEY_VALUES.ENTER) {
|
|
@@ -480,7 +487,7 @@ export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
|
|
|
480
487
|
|
|
481
488
|
|
|
482
489
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
483
|
-
}, [
|
|
490
|
+
}, [readOnly, disabled, targetRef, overlayRef, onKeyDown, toggle, handleToggleDropdown, onExit, onMenuKeyDown, searchInputRef, onMenuPressEnter, onMenuPressBackspace, handleClose]);
|
|
484
491
|
return onToggle;
|
|
485
492
|
};
|
|
486
493
|
|
|
@@ -11,7 +11,8 @@ import isUndefined from 'lodash/isUndefined';
|
|
|
11
11
|
import isNil from 'lodash/isNil';
|
|
12
12
|
import isFunction from 'lodash/isFunction';
|
|
13
13
|
import omit from 'lodash/omit';
|
|
14
|
-
import { createChainedFunction,
|
|
14
|
+
import { createChainedFunction, useCustom, useClassNames, useControlled, mergeRefs, shallowEqual } from '../utils';
|
|
15
|
+
import { getDataGroupBy } from '../utils/getDataGroupBy';
|
|
15
16
|
import { DropdownMenu, DropdownMenuItem, PickerToggle, PickerToggleTrigger, PickerOverlay, SearchBar, useFocusItemValue, usePickerClassName, useSearch, usePublicMethods, useToggleKeyDownEvent, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
|
|
16
17
|
var emptyArray = [];
|
|
17
18
|
var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -260,8 +261,11 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
260
261
|
dropdownMenuItemAs: DropdownMenuItem,
|
|
261
262
|
activeItemValues: [value],
|
|
262
263
|
focusItemValue: focusItemValue,
|
|
263
|
-
data: items
|
|
264
|
+
data: items // FIXME-Doma
|
|
265
|
+
// `group` is redundant so long as `groupBy` exists
|
|
266
|
+
,
|
|
264
267
|
group: !isUndefined(groupBy),
|
|
268
|
+
groupBy: groupBy,
|
|
265
269
|
onSelect: handleItemSelect,
|
|
266
270
|
onGroupTitleClick: onGroupTitleClick,
|
|
267
271
|
virtualized: virtualized
|
|
@@ -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;
|
package/esm/Timeline/Timeline.js
CHANGED
|
@@ -15,7 +15,9 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
15
15
|
_props$align = props.align,
|
|
16
16
|
align = _props$align === void 0 ? 'left' : _props$align,
|
|
17
17
|
endless = props.endless,
|
|
18
|
-
|
|
18
|
+
_props$isItemActive = props.isItemActive,
|
|
19
|
+
isItemActive = _props$isItemActive === void 0 ? Timeline.ACTIVE_LAST : _props$isItemActive,
|
|
20
|
+
rest = _objectWithoutPropertiesLoose(props, ["children", "as", "classPrefix", "className", "align", "endless", "isItemActive"]);
|
|
19
21
|
|
|
20
22
|
var _useClassNames = useClassNames(classPrefix),
|
|
21
23
|
merge = _useClassNames.merge,
|
|
@@ -37,10 +39,20 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
37
39
|
}), ReactChildren.mapCloneElement(children, function (_child, index) {
|
|
38
40
|
return {
|
|
39
41
|
last: index + 1 === count,
|
|
42
|
+
INTERNAL_active: isItemActive(index, count),
|
|
40
43
|
align: align
|
|
41
44
|
};
|
|
42
45
|
}));
|
|
43
46
|
});
|
|
47
|
+
|
|
48
|
+
Timeline.ACTIVE_FIRST = function (index) {
|
|
49
|
+
return index === 0;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Timeline.ACTIVE_LAST = function (index, totalItemsCount) {
|
|
53
|
+
return index === totalItemsCount - 1;
|
|
54
|
+
};
|
|
55
|
+
|
|
44
56
|
Timeline.Item = TimelineItem;
|
|
45
57
|
Timeline.displayName = 'Timeline';
|
|
46
58
|
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
|
-
/**
|
|
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;
|
|
@@ -9,11 +9,12 @@ var TimelineItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
9
9
|
children = props.children,
|
|
10
10
|
_props$classPrefix = props.classPrefix,
|
|
11
11
|
classPrefix = _props$classPrefix === void 0 ? 'timeline-item' : _props$classPrefix,
|
|
12
|
-
|
|
12
|
+
DEPRECATED_last = props.last,
|
|
13
13
|
className = props.className,
|
|
14
14
|
dot = props.dot,
|
|
15
15
|
time = props.time,
|
|
16
|
-
|
|
16
|
+
INTERNAL_active = props.INTERNAL_active,
|
|
17
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "last", "className", "dot", "time", "INTERNAL_active"]);
|
|
17
18
|
|
|
18
19
|
var _useClassNames = useClassNames(classPrefix),
|
|
19
20
|
merge = _useClassNames.merge,
|
|
@@ -21,7 +22,8 @@ var TimelineItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
21
22
|
prefix = _useClassNames.prefix;
|
|
22
23
|
|
|
23
24
|
var classes = merge(className, withClassPrefix({
|
|
24
|
-
last:
|
|
25
|
+
last: DEPRECATED_last,
|
|
26
|
+
active: INTERNAL_active
|
|
25
27
|
}));
|
|
26
28
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
27
29
|
ref: ref,
|
package/esm/Windowing/List.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useRef, useImperativeHandle, useCallback } from 'react';
|
|
3
|
+
import React, { useRef, useImperativeHandle, useCallback, useMemo } from 'react';
|
|
4
4
|
import { VariableSizeList } from 'react-window';
|
|
5
5
|
import { useCustom } from '../utils';
|
|
6
6
|
var List = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
7
7
|
var rowHeight = props.rowHeight,
|
|
8
8
|
_props$as = props.as,
|
|
9
9
|
Component = _props$as === void 0 ? VariableSizeList : _props$as,
|
|
10
|
-
|
|
10
|
+
itemSizeProp = props.itemSize,
|
|
11
|
+
rest = _objectWithoutPropertiesLoose(props, ["rowHeight", "as", "itemSize"]);
|
|
11
12
|
|
|
12
13
|
var listRef = useRef(null);
|
|
13
14
|
|
|
@@ -43,8 +44,16 @@ var List = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
43
44
|
index: index
|
|
44
45
|
}) : rowHeight || 0;
|
|
45
46
|
}, [rowHeight]);
|
|
47
|
+
var itemSize = useMemo(function () {
|
|
48
|
+
if (typeof itemSizeProp === 'function') return itemSizeProp;
|
|
49
|
+
return function () {
|
|
50
|
+
return itemSizeProp;
|
|
51
|
+
};
|
|
52
|
+
}, [itemSizeProp]);
|
|
46
53
|
|
|
47
|
-
var compatibleProps = _extends({
|
|
54
|
+
var compatibleProps = _extends({
|
|
55
|
+
itemSize: itemSize
|
|
56
|
+
}, rest);
|
|
48
57
|
|
|
49
58
|
if (rowHeight) {
|
|
50
59
|
compatibleProps.itemSize = Component === VariableSizeList ? setRowHeight : rowHeight;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const KEY_GROUP: string | symbol;
|
|
2
2
|
export declare const KEY_GROUP_TITLE = "groupTitle";
|
|
3
|
-
export
|
|
3
|
+
export declare function getDataGroupBy<T>(data: readonly T[], key: string, sort?: (isGroup: boolean) => <T>(a: T, b: T) => number): (T | {
|
|
4
|
+
groupTitle: string;
|
|
5
|
+
children: T[];
|
|
6
|
+
})[];
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import _groupBy from "lodash/groupBy";
|
|
2
|
+
import { WalkTreeStrategy, flattenTree } from '../utils/treeUtils';
|
|
3
3
|
var hasSymbol = typeof Symbol === 'function';
|
|
4
4
|
export var KEY_GROUP = hasSymbol ? Symbol('_$grouped') : '_$grouped';
|
|
5
5
|
export var KEY_GROUP_TITLE = 'groupTitle';
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
data = [];
|
|
9
|
-
}
|
|
6
|
+
export function getDataGroupBy(data, key, sort) {
|
|
7
|
+
var groupMap = _groupBy(data, key);
|
|
10
8
|
|
|
11
|
-
var tempData = {};
|
|
12
9
|
var isSort = typeof sort === 'function';
|
|
13
|
-
|
|
14
|
-
// this will allow getting data using dot notation
|
|
15
|
-
// i.e groupBy="country.name" as country will be a nested object
|
|
16
|
-
// to the item and the name will be nested key to the country object
|
|
17
|
-
// can be used with values in arrays, i.e groupBy="addresses.0.country.name"
|
|
18
|
-
var groupByValue = _get(item, key, '');
|
|
19
|
-
|
|
20
|
-
if (!tempData[groupByValue]) {
|
|
21
|
-
tempData[groupByValue] = [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
tempData[groupByValue].push(item);
|
|
25
|
-
});
|
|
26
|
-
var nextData = Object.entries(tempData).map(function (_ref) {
|
|
10
|
+
var groups = Object.entries(groupMap).map(function (_ref) {
|
|
27
11
|
var _ref2;
|
|
28
12
|
|
|
29
13
|
var groupTitle = _ref[0],
|
|
@@ -34,8 +18,13 @@ export default function getDataGroupBy(data, key, sort) {
|
|
|
34
18
|
});
|
|
35
19
|
|
|
36
20
|
if (isSort) {
|
|
37
|
-
|
|
38
|
-
}
|
|
21
|
+
groups.sort(sort(true));
|
|
22
|
+
} // Use DFS traverse
|
|
23
|
+
// Because I want the result to be [group, child, child, group, child, child]
|
|
24
|
+
// rather than [group, group, child, child, child, child]
|
|
25
|
+
|
|
39
26
|
|
|
40
|
-
return
|
|
27
|
+
return flattenTree(groups, function (group) {
|
|
28
|
+
return group.children;
|
|
29
|
+
}, WalkTreeStrategy.DFS);
|
|
41
30
|
}
|
package/esm/utils/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export { default as ReactChildren } from './ReactChildren';
|
|
|
12
12
|
export { default as tplTransform } from './tplTransform';
|
|
13
13
|
export { default as ajaxUpload } from './ajaxUpload';
|
|
14
14
|
export { default as previewFile } from './previewFile';
|
|
15
|
-
export { default as getDataGroupBy } from './getDataGroupBy';
|
|
16
15
|
export { default as clone } from './clone';
|
|
17
16
|
export { default as placementPolyfill } from './placementPolyfill';
|
|
18
17
|
export { default as getDOMNode } from './getDOMNode';
|
package/esm/utils/index.js
CHANGED
|
@@ -14,7 +14,6 @@ export { default as ReactChildren } from './ReactChildren';
|
|
|
14
14
|
export { default as tplTransform } from './tplTransform';
|
|
15
15
|
export { default as ajaxUpload } from './ajaxUpload';
|
|
16
16
|
export { default as previewFile } from './previewFile';
|
|
17
|
-
export { default as getDataGroupBy } from './getDataGroupBy';
|
|
18
17
|
export { default as clone } from './clone';
|
|
19
18
|
export { default as placementPolyfill } from './placementPolyfill';
|
|
20
19
|
export { default as getDOMNode } from './getDOMNode';
|
package/esm/utils/treeUtils.d.ts
CHANGED
|
@@ -21,7 +21,13 @@ export declare function shouldShowNodeByParentExpanded<T>(expandItemValues?: T[]
|
|
|
21
21
|
* Use {@link flattenTree} instead.
|
|
22
22
|
*/
|
|
23
23
|
export declare function UNSAFE_flattenTree<TItem>(tree: TItem[], childrenKey?: string, executor?: (node: any, index: number) => any): TItem[];
|
|
24
|
-
export declare
|
|
24
|
+
export declare enum WalkTreeStrategy {
|
|
25
|
+
DFS = 0,
|
|
26
|
+
BFS = 1
|
|
27
|
+
}
|
|
28
|
+
export declare function flattenTree<T>(rootNodes: readonly T[], getChildren: (node: T) => readonly T[] | undefined, walkStrategy?: WalkTreeStrategy): T[];
|
|
29
|
+
export declare function walkTreeBfs<T>(rootNodes: readonly T[], getChildren: (node: T) => readonly T[] | undefined, callback: (node: T) => void): void;
|
|
30
|
+
export declare function walkTreeDfs<T>(rootNodes: readonly T[], getChildren: (node: T) => readonly T[] | undefined, callback: (node: T) => void): void;
|
|
25
31
|
/**
|
|
26
32
|
* get all ancestor nodes of given node
|
|
27
33
|
* @param {*} node
|
|
@@ -293,6 +299,6 @@ export declare function getParentMap<T extends Record<string, unknown>>(items: r
|
|
|
293
299
|
*/
|
|
294
300
|
export declare function getKeyParentMap<T extends Record<string, unknown>, K = React.Key>(items: readonly T[], getKey: (item: T) => K, getChildren: (item: T) => readonly T[] | undefined): Map<K, T>;
|
|
295
301
|
/**
|
|
296
|
-
* Returns an array indicating the
|
|
302
|
+
* Returns an array indicating the hierarchy path from root towards `target` item
|
|
297
303
|
*/
|
|
298
304
|
export declare function getPathTowardsItem<T>(target: T | undefined, getParent: (item: T) => T | undefined): T[];
|
package/esm/utils/treeUtils.js
CHANGED
|
@@ -81,15 +81,33 @@ export function UNSAFE_flattenTree(tree, childrenKey, executor) {
|
|
|
81
81
|
traverse(tree, null);
|
|
82
82
|
return flattenData;
|
|
83
83
|
}
|
|
84
|
-
export
|
|
84
|
+
export var WalkTreeStrategy;
|
|
85
|
+
|
|
86
|
+
(function (WalkTreeStrategy) {
|
|
87
|
+
WalkTreeStrategy[WalkTreeStrategy["DFS"] = 0] = "DFS";
|
|
88
|
+
WalkTreeStrategy[WalkTreeStrategy["BFS"] = 1] = "BFS";
|
|
89
|
+
})(WalkTreeStrategy || (WalkTreeStrategy = {}));
|
|
90
|
+
|
|
91
|
+
export function flattenTree(rootNodes, getChildren, walkStrategy) {
|
|
92
|
+
if (walkStrategy === void 0) {
|
|
93
|
+
walkStrategy = WalkTreeStrategy.BFS;
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
var result = [];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
|
|
98
|
+
if (walkStrategy === WalkTreeStrategy.BFS) {
|
|
99
|
+
walkTreeBfs(rootNodes, getChildren, function (node) {
|
|
100
|
+
return result.push(node);
|
|
101
|
+
});
|
|
102
|
+
} else if (walkStrategy === WalkTreeStrategy.DFS) {
|
|
103
|
+
walkTreeDfs(rootNodes, getChildren, function (node) {
|
|
104
|
+
return result.push(node);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
89
108
|
return result;
|
|
90
109
|
}
|
|
91
|
-
|
|
92
|
-
function walkTree(rootNodes, getChildren, callback) {
|
|
110
|
+
export function walkTreeBfs(rootNodes, getChildren, callback) {
|
|
93
111
|
for (var queue = [].concat(rootNodes); queue.length > 0;) {
|
|
94
112
|
var _node = queue.shift();
|
|
95
113
|
|
|
@@ -101,12 +119,22 @@ function walkTree(rootNodes, getChildren, callback) {
|
|
|
101
119
|
}
|
|
102
120
|
}
|
|
103
121
|
}
|
|
122
|
+
export function walkTreeDfs(rootNodes, getChildren, callback) {
|
|
123
|
+
for (var _iterator = _createForOfIteratorHelperLoose(rootNodes), _step; !(_step = _iterator()).done;) {
|
|
124
|
+
var _node2 = _step.value;
|
|
125
|
+
callback(_node2);
|
|
126
|
+
var children = getChildren(_node2);
|
|
127
|
+
|
|
128
|
+
if (children) {
|
|
129
|
+
walkTreeDfs(children, getChildren, callback);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
104
133
|
/**
|
|
105
134
|
* get all ancestor nodes of given node
|
|
106
135
|
* @param {*} node
|
|
107
136
|
*/
|
|
108
137
|
|
|
109
|
-
|
|
110
138
|
export function getNodeParents(node, parentKey, valueKey) {
|
|
111
139
|
if (parentKey === void 0) {
|
|
112
140
|
parentKey = 'parent';
|
|
@@ -342,10 +370,10 @@ export function findNodeOfTree(data, check) {
|
|
|
342
370
|
var _item3 = nodes[i];
|
|
343
371
|
|
|
344
372
|
if (_isArray(_item3.children)) {
|
|
345
|
-
var
|
|
373
|
+
var _node3 = findNode(_item3.children);
|
|
346
374
|
|
|
347
|
-
if (
|
|
348
|
-
return
|
|
375
|
+
if (_node3) {
|
|
376
|
+
return _node3;
|
|
349
377
|
}
|
|
350
378
|
}
|
|
351
379
|
|
|
@@ -1113,8 +1141,8 @@ export function getParentMap(items, getChildren) {
|
|
|
1113
1141
|
var children = getChildren(_item5);
|
|
1114
1142
|
|
|
1115
1143
|
if (children) {
|
|
1116
|
-
for (var
|
|
1117
|
-
var child =
|
|
1144
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(children), _step2; !(_step2 = _iterator2()).done;) {
|
|
1145
|
+
var child = _step2.value;
|
|
1118
1146
|
map.set(child, _item5);
|
|
1119
1147
|
queue.push(child);
|
|
1120
1148
|
}
|
|
@@ -1141,8 +1169,8 @@ export function getKeyParentMap(items, getKey, getChildren) {
|
|
|
1141
1169
|
var children = getChildren(_item6);
|
|
1142
1170
|
|
|
1143
1171
|
if (children) {
|
|
1144
|
-
for (var
|
|
1145
|
-
var child =
|
|
1172
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(children), _step3; !(_step3 = _iterator3()).done;) {
|
|
1173
|
+
var child = _step3.value;
|
|
1146
1174
|
map.set(getKey(child), _item6);
|
|
1147
1175
|
queue.push(child);
|
|
1148
1176
|
}
|
|
@@ -1152,7 +1180,7 @@ export function getKeyParentMap(items, getKey, getChildren) {
|
|
|
1152
1180
|
return map;
|
|
1153
1181
|
}
|
|
1154
1182
|
/**
|
|
1155
|
-
* Returns an array indicating the
|
|
1183
|
+
* Returns an array indicating the hierarchy path from root towards `target` item
|
|
1156
1184
|
*/
|
|
1157
1185
|
|
|
1158
1186
|
export function getPathTowardsItem(target, getParent) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.34.0",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react-use-set": "^1.0.0",
|
|
40
40
|
"react-window": "^1.8.8",
|
|
41
|
-
"rsuite-table": "^5.10.
|
|
42
|
-
"schema-typed": "^2.1.
|
|
41
|
+
"rsuite-table": "^5.10.5",
|
|
42
|
+
"schema-typed": "^2.1.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.8.0",
|