rsuite 5.38.0 → 5.40.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/Nav/styles/index.less +10 -11
- package/SelectPicker/styles/index.less +8 -4
- package/cjs/CheckTreePicker/CheckTreePicker.js +1 -1
- package/cjs/CheckTreePicker/utils.d.ts +1 -1
- package/cjs/CheckTreePicker/utils.js +2 -2
- package/cjs/SelectPicker/Listbox.d.ts +34 -0
- package/cjs/SelectPicker/Listbox.js +263 -0
- package/cjs/SelectPicker/ListboxOption.d.ts +11 -0
- package/cjs/SelectPicker/ListboxOption.js +50 -0
- package/cjs/SelectPicker/ListboxOptionGroup.d.ts +9 -0
- package/cjs/SelectPicker/ListboxOptionGroup.js +69 -0
- package/cjs/SelectPicker/SelectPicker.js +33 -36
- package/cjs/Windowing/List.d.ts +2 -2
- package/cjs/locales/index.d.ts +1 -0
- package/cjs/locales/index.js +6 -2
- package/cjs/locales/ne_NP.d.ts +117 -0
- package/cjs/locales/ne_NP.js +89 -0
- package/cjs/utils/getDataGroupBy.d.ts +23 -0
- package/cjs/utils/getDataGroupBy.js +33 -0
- package/cjs/utils/treeUtils.d.ts +1 -1
- package/cjs/utils/treeUtils.js +8 -8
- package/dist/rsuite-no-reset-rtl.css +22 -11
- 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 +22 -11
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +22 -11
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +22 -11
- package/dist/rsuite.js +53 -20
- 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/CheckTreePicker/CheckTreePicker.js +1 -1
- package/esm/CheckTreePicker/utils.d.ts +1 -1
- package/esm/CheckTreePicker/utils.js +2 -2
- package/esm/SelectPicker/Listbox.d.ts +34 -0
- package/esm/SelectPicker/Listbox.js +240 -0
- package/esm/SelectPicker/ListboxOption.d.ts +11 -0
- package/esm/SelectPicker/ListboxOption.js +37 -0
- package/esm/SelectPicker/ListboxOptionGroup.d.ts +9 -0
- package/esm/SelectPicker/ListboxOptionGroup.js +53 -0
- package/esm/SelectPicker/SelectPicker.js +33 -36
- package/esm/Windowing/List.d.ts +2 -2
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +2 -1
- package/esm/locales/ne_NP.d.ts +117 -0
- package/esm/locales/ne_NP.js +79 -0
- package/esm/utils/getDataGroupBy.d.ts +23 -0
- package/esm/utils/getDataGroupBy.js +32 -0
- package/esm/utils/treeUtils.d.ts +1 -1
- package/esm/utils/treeUtils.js +8 -8
- package/locales/ne_NP/package.json +7 -0
- package/package.json +2 -2
- package/styles/mixins/listbox.less +2 -0
|
@@ -213,7 +213,7 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
return getFormattedTree(
|
|
216
|
+
return getFormattedTree(flattenNodes, filteredData, {
|
|
217
217
|
childrenKey: childrenKey,
|
|
218
218
|
cascade: cascade
|
|
219
219
|
}).map(function (node) {
|
|
@@ -37,7 +37,7 @@ export declare function isEveryFirstLevelNodeUncheckable(nodes: TreeNodesType, u
|
|
|
37
37
|
* @param {*} node
|
|
38
38
|
*/
|
|
39
39
|
export declare function isNodeUncheckable(node: any, props: Required<Pick<CheckTreePickerProps, 'uncheckableItemValues' | 'valueKey'>>): boolean;
|
|
40
|
-
export declare function getFormattedTree(data: any[],
|
|
40
|
+
export declare function getFormattedTree(nodes: TreeNodesType, data: any[], props: Required<Pick<CheckTreePickerProps, 'childrenKey' | 'cascade'>>): any[];
|
|
41
41
|
export declare function getDisabledState(nodes: TreeNodesType, node: TreeNodeType, props: Required<Pick<CheckTreePickerProps, 'disabledItemValues' | 'valueKey'>>): boolean;
|
|
42
42
|
export declare function getCheckTreePickerDefaultValue(value: any[], uncheckableItemValues: any[]): any[];
|
|
43
43
|
export declare function getSelectedItems(nodes: TreeNodesType, values: ValueType): TreeNodeType[];
|
|
@@ -101,7 +101,7 @@ export function isNodeUncheckable(node, props) {
|
|
|
101
101
|
return node[valueKey] === value;
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
export function getFormattedTree(
|
|
104
|
+
export function getFormattedTree(nodes, data, props) {
|
|
105
105
|
var childrenKey = props.childrenKey,
|
|
106
106
|
cascade = props.cascade;
|
|
107
107
|
return data.map(function (node) {
|
|
@@ -125,7 +125,7 @@ export function getFormattedTree(data, nodes, props) {
|
|
|
125
125
|
formatted.checkState = checkState;
|
|
126
126
|
|
|
127
127
|
if (((_node$childrenKey = node[childrenKey]) === null || _node$childrenKey === void 0 ? void 0 : _node$childrenKey.length) > 0) {
|
|
128
|
-
formatted[childrenKey] = getFormattedTree(formatted[childrenKey],
|
|
128
|
+
formatted[childrenKey] = getFormattedTree(nodes, formatted[childrenKey], props);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListProps, ListHandle } from '../Windowing';
|
|
3
|
+
import { CompareFn, Group } from '../utils/getDataGroupBy';
|
|
4
|
+
import { StandardProps } from '../@types/common';
|
|
5
|
+
interface ListboxProps<T, K> extends StandardProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
6
|
+
classPrefix: string;
|
|
7
|
+
options: readonly T[];
|
|
8
|
+
getOptionKey?: (option: T) => K;
|
|
9
|
+
sort?: <B extends boolean>(isGroup: B) => B extends true ? CompareFn<Group<T>> : CompareFn<T>;
|
|
10
|
+
groupBy?: string;
|
|
11
|
+
disabledOptionKeys?: readonly K[];
|
|
12
|
+
selectedOptionKey?: K;
|
|
13
|
+
activeOptionKey?: K;
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
labelKey?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
optionClassPrefix?: string;
|
|
19
|
+
rowHeight?: number;
|
|
20
|
+
rowGroupHeight?: number;
|
|
21
|
+
virtualized?: boolean;
|
|
22
|
+
listProps?: Partial<ListProps>;
|
|
23
|
+
listRef?: React.Ref<ListHandle>;
|
|
24
|
+
/** Custom selected option */
|
|
25
|
+
renderMenuItem?: (itemLabel: React.ReactNode, item: any) => React.ReactNode;
|
|
26
|
+
renderMenuGroup?: (title: React.ReactNode, item: any) => React.ReactNode;
|
|
27
|
+
onSelect?: (value: K, item: T, event: React.MouseEvent) => void;
|
|
28
|
+
onGroupTitleClick?: (event: React.MouseEvent) => void;
|
|
29
|
+
}
|
|
30
|
+
declare type ListboxComponent = <T, K>(p: ListboxProps<T, K> & {
|
|
31
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
32
|
+
}) => JSX.Element;
|
|
33
|
+
declare const Listbox: ListboxComponent;
|
|
34
|
+
export default Listbox;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import isUndefined from 'lodash/isUndefined';
|
|
5
|
+
import getPosition from 'dom-lib/getPosition';
|
|
6
|
+
import scrollTop from 'dom-lib/scrollTop';
|
|
7
|
+
import getHeight from 'dom-lib/getHeight';
|
|
8
|
+
import { List, AutoSizer } from '../Windowing';
|
|
9
|
+
import shallowEqual from '../utils/shallowEqual';
|
|
10
|
+
import { mergeRefs, useClassNames, useMount } from '../utils';
|
|
11
|
+
import ListboxOptionGroup from './ListboxOptionGroup';
|
|
12
|
+
import { groupOptions } from '../utils/getDataGroupBy';
|
|
13
|
+
import ListboxOption from './ListboxOption';
|
|
14
|
+
var Listbox = /*#__PURE__*/React.forwardRef(function Listbox(props, ref) {
|
|
15
|
+
var _props$options = props.options,
|
|
16
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
17
|
+
getOptionKey = props.getOptionKey,
|
|
18
|
+
groupBy = props.groupBy,
|
|
19
|
+
sort = props.sort,
|
|
20
|
+
_props$maxHeight = props.maxHeight,
|
|
21
|
+
maxHeight = _props$maxHeight === void 0 ? 320 : _props$maxHeight,
|
|
22
|
+
selectedOptionKey = props.selectedOptionKey,
|
|
23
|
+
_props$disabledOption = props.disabledOptionKeys,
|
|
24
|
+
disabledOptionKeys = _props$disabledOption === void 0 ? [] : _props$disabledOption,
|
|
25
|
+
_props$classPrefix = props.classPrefix,
|
|
26
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu' : _props$classPrefix,
|
|
27
|
+
_props$labelKey = props.labelKey,
|
|
28
|
+
labelKey = _props$labelKey === void 0 ? 'label' : _props$labelKey,
|
|
29
|
+
virtualized = props.virtualized,
|
|
30
|
+
listProps = props.listProps,
|
|
31
|
+
virtualizedListRef = props.listRef,
|
|
32
|
+
className = props.className,
|
|
33
|
+
style = props.style,
|
|
34
|
+
activeOptionKey = props.activeOptionKey,
|
|
35
|
+
optionClassPrefix = props.optionClassPrefix,
|
|
36
|
+
_props$rowHeight = props.rowHeight,
|
|
37
|
+
rowHeight = _props$rowHeight === void 0 ? 36 : _props$rowHeight,
|
|
38
|
+
_props$rowGroupHeight = props.rowGroupHeight,
|
|
39
|
+
rowGroupHeight = _props$rowGroupHeight === void 0 ? 48 : _props$rowGroupHeight,
|
|
40
|
+
renderMenuGroup = props.renderMenuGroup,
|
|
41
|
+
renderMenuItem = props.renderMenuItem,
|
|
42
|
+
onGroupTitleClick = props.onGroupTitleClick,
|
|
43
|
+
onSelect = props.onSelect,
|
|
44
|
+
rest = _objectWithoutPropertiesLoose(props, ["options", "getOptionKey", "groupBy", "sort", "maxHeight", "selectedOptionKey", "disabledOptionKeys", "classPrefix", "labelKey", "virtualized", "listProps", "listRef", "className", "style", "activeOptionKey", "optionClassPrefix", "rowHeight", "rowGroupHeight", "renderMenuGroup", "renderMenuItem", "onGroupTitleClick", "onSelect"]);
|
|
45
|
+
|
|
46
|
+
var group = typeof groupBy !== 'undefined';
|
|
47
|
+
|
|
48
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
49
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
50
|
+
prefix = _useClassNames.prefix,
|
|
51
|
+
merge = _useClassNames.merge;
|
|
52
|
+
|
|
53
|
+
var classes = merge(className, withClassPrefix('items', {
|
|
54
|
+
grouped: group
|
|
55
|
+
}));
|
|
56
|
+
var menuBodyContainerRef = useRef(null);
|
|
57
|
+
var listRef = useRef(null);
|
|
58
|
+
|
|
59
|
+
var _useState = useState([]),
|
|
60
|
+
foldedGroupKeys = _useState[0],
|
|
61
|
+
setFoldedGroupKeys = _useState[1];
|
|
62
|
+
|
|
63
|
+
var handleGroupTitleClick = useCallback(function (key, event) {
|
|
64
|
+
var _listRef$current;
|
|
65
|
+
|
|
66
|
+
var nextGroupKeys = foldedGroupKeys.filter(function (item) {
|
|
67
|
+
return item !== key;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (nextGroupKeys.length === foldedGroupKeys.length) {
|
|
71
|
+
nextGroupKeys.push(key);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setFoldedGroupKeys(nextGroupKeys);
|
|
75
|
+
onGroupTitleClick === null || onGroupTitleClick === void 0 ? void 0 : onGroupTitleClick(event); // See example https://codesandbox.io/s/grouped-list-with-sticky-headers-shgok?fontsize=14&file=/index.js:1314-1381
|
|
76
|
+
|
|
77
|
+
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.resetAfterIndex(0); // use group index to reduce calculation
|
|
78
|
+
}, [onGroupTitleClick, foldedGroupKeys]);
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
var container = menuBodyContainerRef.current;
|
|
81
|
+
|
|
82
|
+
if (!container) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var activeItem = container.querySelector("." + prefix('item-focus'));
|
|
87
|
+
|
|
88
|
+
if (!activeItem) {
|
|
89
|
+
activeItem = container.querySelector("." + prefix('item-active'));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!activeItem) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var position = getPosition(activeItem, container);
|
|
97
|
+
var sTop = scrollTop(container);
|
|
98
|
+
var sHeight = getHeight(container);
|
|
99
|
+
|
|
100
|
+
if (sTop > position.top) {
|
|
101
|
+
scrollTop(container, Math.max(0, position.top - 20));
|
|
102
|
+
} else if (position.top > sTop + sHeight) {
|
|
103
|
+
scrollTop(container, Math.max(0, position.top - sHeight + 32));
|
|
104
|
+
}
|
|
105
|
+
}, [activeOptionKey, menuBodyContainerRef, prefix]);
|
|
106
|
+
useMount(function scrollToSelectedOption() {
|
|
107
|
+
if (virtualized && selectedOptionKey) {
|
|
108
|
+
if (typeof groupBy === 'undefined') {
|
|
109
|
+
var _listRef$current2;
|
|
110
|
+
|
|
111
|
+
var selectedOptionIndex = options.findIndex(function (option) {
|
|
112
|
+
return (getOptionKey === null || getOptionKey === void 0 ? void 0 : getOptionKey(option)) === selectedOptionKey;
|
|
113
|
+
});
|
|
114
|
+
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.scrollToItem(selectedOptionIndex);
|
|
115
|
+
} else {
|
|
116
|
+
var _listRef$current3;
|
|
117
|
+
|
|
118
|
+
var groups = groupOptions(options, groupBy, sort === null || sort === void 0 ? void 0 : sort(false), sort === null || sort === void 0 ? void 0 : sort(true));
|
|
119
|
+
var selectedGroupIndex = groups.findIndex(function (group) {
|
|
120
|
+
return group.key === selectedOptionKey;
|
|
121
|
+
}); // TODO-Doma
|
|
122
|
+
// This only scrolls the list to the group, not to the selected item within the group
|
|
123
|
+
// .scrollToItem does not support specifying an px offset
|
|
124
|
+
// Find a way to scroll to the selected item within the group
|
|
125
|
+
|
|
126
|
+
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.scrollToItem(selectedGroupIndex);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var renderOption = useCallback(function (option) {
|
|
131
|
+
var _getOptionKey;
|
|
132
|
+
|
|
133
|
+
var optionKey = (_getOptionKey = getOptionKey === null || getOptionKey === void 0 ? void 0 : getOptionKey(option)) !== null && _getOptionKey !== void 0 ? _getOptionKey : JSON.stringify(option);
|
|
134
|
+
var label = option[labelKey];
|
|
135
|
+
var disabled = disabledOptionKeys === null || disabledOptionKeys === void 0 ? void 0 : disabledOptionKeys.some(function (disabledValue) {
|
|
136
|
+
return shallowEqual(disabledValue, optionKey);
|
|
137
|
+
});
|
|
138
|
+
var selected = shallowEqual(selectedOptionKey, optionKey);
|
|
139
|
+
var focus = !isUndefined(activeOptionKey) && shallowEqual(activeOptionKey, optionKey);
|
|
140
|
+
return /*#__PURE__*/React.createElement(ListboxOption, {
|
|
141
|
+
key: optionKey,
|
|
142
|
+
disabled: disabled,
|
|
143
|
+
selected: selected,
|
|
144
|
+
active: focus,
|
|
145
|
+
"data-key": optionKey,
|
|
146
|
+
classPrefix: optionClassPrefix,
|
|
147
|
+
onClick: function onClick(event) {
|
|
148
|
+
if (!disabled) {
|
|
149
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(optionKey, option, event);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, renderMenuItem ? renderMenuItem(label, option) : label);
|
|
153
|
+
}, [getOptionKey, labelKey, disabledOptionKeys, selectedOptionKey, activeOptionKey, optionClassPrefix, renderMenuItem, onSelect]);
|
|
154
|
+
var renderOptions = useCallback(function (options) {
|
|
155
|
+
return options.map(function (option) {
|
|
156
|
+
return renderOption(option);
|
|
157
|
+
});
|
|
158
|
+
}, [renderOption]);
|
|
159
|
+
var renderOptionGroup = useCallback(function (group) {
|
|
160
|
+
var groupKey = group.key;
|
|
161
|
+
var expanded = !foldedGroupKeys.includes(groupKey);
|
|
162
|
+
return /*#__PURE__*/React.createElement(ListboxOptionGroup, {
|
|
163
|
+
key: groupKey,
|
|
164
|
+
title: renderMenuGroup ? renderMenuGroup(groupKey, group) : groupKey,
|
|
165
|
+
classPrefix: 'picker-menu-group',
|
|
166
|
+
expanded: expanded,
|
|
167
|
+
onClickTitle: function onClickTitle(e) {
|
|
168
|
+
return handleGroupTitleClick(group.key, e);
|
|
169
|
+
}
|
|
170
|
+
}, renderOptions(group.options));
|
|
171
|
+
}, [foldedGroupKeys, handleGroupTitleClick, renderMenuGroup, renderOptions]);
|
|
172
|
+
var renderOptionGroups = useCallback(function (groupKey) {
|
|
173
|
+
var groups = groupOptions(options, groupKey, sort === null || sort === void 0 ? void 0 : sort(false), sort === null || sort === void 0 ? void 0 : sort(true));
|
|
174
|
+
return groups.map(function (group) {
|
|
175
|
+
return renderOptionGroup(group);
|
|
176
|
+
});
|
|
177
|
+
}, [options, renderOptionGroup, sort]);
|
|
178
|
+
var renderVirtualizedOptions = useCallback(function () {
|
|
179
|
+
return /*#__PURE__*/React.createElement(AutoSizer, {
|
|
180
|
+
defaultHeight: maxHeight,
|
|
181
|
+
style: {
|
|
182
|
+
width: 'auto',
|
|
183
|
+
height: 'auto'
|
|
184
|
+
}
|
|
185
|
+
}, function (_ref) {
|
|
186
|
+
var height = _ref.height;
|
|
187
|
+
return /*#__PURE__*/React.createElement(List, _extends({
|
|
188
|
+
ref: mergeRefs(listRef, virtualizedListRef),
|
|
189
|
+
height: height || maxHeight,
|
|
190
|
+
itemCount: options.length,
|
|
191
|
+
itemSize: rowHeight
|
|
192
|
+
}, listProps), function (_ref2) {
|
|
193
|
+
var index = _ref2.index;
|
|
194
|
+
return renderOption(options[index]);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}, [listProps, maxHeight, options, renderOption, rowHeight, virtualizedListRef]); // Example of rendering option groups in VariableSizeList
|
|
198
|
+
// https://github.com/bvaughn/react-window/issues/358
|
|
199
|
+
|
|
200
|
+
var renderVirtualizedOptionGroups = useCallback(function (groupKey) {
|
|
201
|
+
var groups = groupOptions(options, groupKey, sort === null || sort === void 0 ? void 0 : sort(false), sort === null || sort === void 0 ? void 0 : sort(true));
|
|
202
|
+
return /*#__PURE__*/React.createElement(AutoSizer, {
|
|
203
|
+
defaultHeight: maxHeight,
|
|
204
|
+
style: {
|
|
205
|
+
width: 'auto',
|
|
206
|
+
height: 'auto'
|
|
207
|
+
}
|
|
208
|
+
}, function (_ref3) {
|
|
209
|
+
var height = _ref3.height;
|
|
210
|
+
return /*#__PURE__*/React.createElement(List, _extends({
|
|
211
|
+
ref: mergeRefs(listRef, virtualizedListRef),
|
|
212
|
+
height: height || maxHeight,
|
|
213
|
+
itemCount: groups.length,
|
|
214
|
+
itemSize: function itemSize(index) {
|
|
215
|
+
var item = groups[index];
|
|
216
|
+
var expanded = !foldedGroupKeys.includes(item.key);
|
|
217
|
+
|
|
218
|
+
if (expanded) {
|
|
219
|
+
return item.options.length * rowHeight + rowGroupHeight;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return rowGroupHeight;
|
|
223
|
+
}
|
|
224
|
+
}, listProps), function (_ref4) {
|
|
225
|
+
var index = _ref4.index;
|
|
226
|
+
return renderOptionGroup(groups[index]);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}, [foldedGroupKeys, listProps, maxHeight, options, renderOptionGroup, rowGroupHeight, rowHeight, sort, virtualizedListRef]);
|
|
230
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
231
|
+
role: "listbox"
|
|
232
|
+
}, rest, {
|
|
233
|
+
className: classes,
|
|
234
|
+
ref: mergeRefs(menuBodyContainerRef, ref),
|
|
235
|
+
style: _extends({}, style, {
|
|
236
|
+
maxHeight: maxHeight
|
|
237
|
+
})
|
|
238
|
+
}), typeof groupBy === 'undefined' ? virtualized ? renderVirtualizedOptions() : renderOptions(options) : virtualized ? renderVirtualizedOptionGroups(groupBy) : renderOptionGroups(groupBy));
|
|
239
|
+
});
|
|
240
|
+
export default Listbox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StandardProps } from '../@types/common';
|
|
3
|
+
interface ListboxOptionProps extends StandardProps, React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
title?: string;
|
|
8
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ListboxOption: React.ForwardRefExoticComponent<ListboxOptionProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default ListboxOption;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { useClassNames } from '../utils';
|
|
5
|
+
var ListboxOption = /*#__PURE__*/React.forwardRef(function ListboxOption(props, ref) {
|
|
6
|
+
var selected = props.selected,
|
|
7
|
+
_props$classPrefix = props.classPrefix,
|
|
8
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu-item' : _props$classPrefix,
|
|
9
|
+
children = props.children,
|
|
10
|
+
className = props.className,
|
|
11
|
+
disabled = props.disabled,
|
|
12
|
+
active = props.active,
|
|
13
|
+
onKeyDown = props.onKeyDown,
|
|
14
|
+
rest = _objectWithoutPropertiesLoose(props, ["selected", "classPrefix", "children", "className", "disabled", "active", "onKeyDown"]);
|
|
15
|
+
|
|
16
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
17
|
+
withClassPrefix = _useClassNames.withClassPrefix;
|
|
18
|
+
|
|
19
|
+
var classes = withClassPrefix({
|
|
20
|
+
active: selected,
|
|
21
|
+
focus: active,
|
|
22
|
+
disabled: disabled
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
25
|
+
ref: ref,
|
|
26
|
+
role: "option",
|
|
27
|
+
"aria-selected": selected || undefined,
|
|
28
|
+
"aria-disabled": disabled
|
|
29
|
+
}, rest, {
|
|
30
|
+
className: className,
|
|
31
|
+
onKeyDown: disabled ? undefined : onKeyDown
|
|
32
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
className: classes
|
|
34
|
+
}, children));
|
|
35
|
+
});
|
|
36
|
+
ListboxOption.displayName = 'Listbox.Option';
|
|
37
|
+
export default ListboxOption;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StandardProps } from '../@types/common';
|
|
3
|
+
interface ListboxOptionGroupProps extends StandardProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
expanded?: boolean;
|
|
6
|
+
onClickTitle?: React.MouseEventHandler;
|
|
7
|
+
}
|
|
8
|
+
declare const ListboxOptionGroup: React.ForwardRefExoticComponent<ListboxOptionGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default ListboxOptionGroup;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
|
|
5
|
+
var _templateObject, _templateObject2;
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { useClassNames } from '../utils';
|
|
10
|
+
import ArrowDown from '@rsuite/icons/legacy/ArrowDown';
|
|
11
|
+
import useUniqueId from '../utils/useUniqueId';
|
|
12
|
+
var ListboxOptionGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
13
|
+
var _props$classPrefix = props.classPrefix,
|
|
14
|
+
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu-group' : _props$classPrefix,
|
|
15
|
+
title = props.title,
|
|
16
|
+
children = props.children,
|
|
17
|
+
className = props.className,
|
|
18
|
+
_props$expanded = props.expanded,
|
|
19
|
+
expanded = _props$expanded === void 0 ? true : _props$expanded,
|
|
20
|
+
onClickTitle = props.onClickTitle,
|
|
21
|
+
rest = _objectWithoutPropertiesLoose(props, ["classPrefix", "title", "children", "className", "expanded", "onClickTitle"]);
|
|
22
|
+
|
|
23
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
24
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
25
|
+
prefix = _useClassNames.prefix,
|
|
26
|
+
merge = _useClassNames.merge;
|
|
27
|
+
|
|
28
|
+
var classes = merge(className, withClassPrefix());
|
|
29
|
+
var groupId = useUniqueId('listbox-group-');
|
|
30
|
+
var labelId = groupId + '-label';
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
32
|
+
role: "group",
|
|
33
|
+
id: groupId,
|
|
34
|
+
"aria-expanded": expanded,
|
|
35
|
+
"aria-labelledby": labelId
|
|
36
|
+
}, rest, {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: classNames(classes, {
|
|
39
|
+
folded: !expanded
|
|
40
|
+
})
|
|
41
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["title"]))),
|
|
43
|
+
tabIndex: -1,
|
|
44
|
+
onClick: onClickTitle
|
|
45
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
id: labelId
|
|
47
|
+
}, title), /*#__PURE__*/React.createElement(ArrowDown, {
|
|
48
|
+
"aria-hidden": true,
|
|
49
|
+
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["caret"])))
|
|
50
|
+
})), children);
|
|
51
|
+
});
|
|
52
|
+
ListboxOptionGroup.displayName = 'Listbox.OptionGroup';
|
|
53
|
+
export default ListboxOptionGroup;
|
|
@@ -7,13 +7,12 @@ var _templateObject;
|
|
|
7
7
|
import React, { useRef, useState, useCallback } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import pick from 'lodash/pick';
|
|
10
|
-
import isUndefined from 'lodash/isUndefined';
|
|
11
10
|
import isNil from 'lodash/isNil';
|
|
12
11
|
import isFunction from 'lodash/isFunction';
|
|
13
12
|
import omit from 'lodash/omit';
|
|
14
13
|
import { createChainedFunction, useCustom, useClassNames, useControlled, mergeRefs, shallowEqual } from '../utils';
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
14
|
+
import { PickerToggle, PickerToggleTrigger, PickerOverlay, SearchBar, useFocusItemValue, usePickerClassName, useSearch, usePublicMethods, useToggleKeyDownEvent, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
|
|
15
|
+
import Listbox from './Listbox';
|
|
17
16
|
var emptyArray = [];
|
|
18
17
|
var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
18
|
var _props$as = props.as,
|
|
@@ -233,40 +232,38 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
233
232
|
top: top
|
|
234
233
|
});
|
|
235
234
|
|
|
236
|
-
var
|
|
235
|
+
var menu = function () {
|
|
236
|
+
if (!filteredData.length) {
|
|
237
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
238
|
+
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["none"])))
|
|
239
|
+
}, locale === null || locale === void 0 ? void 0 : locale.noResultsText);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return /*#__PURE__*/React.createElement(Listbox, {
|
|
243
|
+
options: filteredData,
|
|
244
|
+
getOptionKey: function getOptionKey(option) {
|
|
245
|
+
return option[valueKey];
|
|
246
|
+
},
|
|
247
|
+
id: id ? id + "-listbox" : undefined,
|
|
248
|
+
listProps: listProps,
|
|
249
|
+
listRef: listRef,
|
|
250
|
+
disabledOptionKeys: disabledItemValues,
|
|
251
|
+
labelKey: labelKey,
|
|
252
|
+
renderMenuGroup: renderMenuGroup,
|
|
253
|
+
renderMenuItem: renderMenuItem,
|
|
254
|
+
maxHeight: menuMaxHeight,
|
|
255
|
+
classPrefix: 'picker-select-menu',
|
|
256
|
+
optionClassPrefix: 'picker-select-menu-item',
|
|
257
|
+
selectedOptionKey: value,
|
|
258
|
+
activeOptionKey: focusItemValue,
|
|
259
|
+
groupBy: groupBy,
|
|
260
|
+
sort: sort,
|
|
261
|
+
onSelect: handleItemSelect,
|
|
262
|
+
onGroupTitleClick: onGroupTitleClick,
|
|
263
|
+
virtualized: virtualized
|
|
264
|
+
});
|
|
265
|
+
}();
|
|
237
266
|
|
|
238
|
-
if (groupBy) {
|
|
239
|
-
items = getDataGroupBy(items, groupBy, sort);
|
|
240
|
-
} else if (typeof sort === 'function') {
|
|
241
|
-
items = items.sort(sort(false));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
var menu = items.length ? /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
245
|
-
id: id ? id + "-listbox" : undefined,
|
|
246
|
-
listProps: listProps,
|
|
247
|
-
listRef: listRef,
|
|
248
|
-
disabledItemValues: disabledItemValues,
|
|
249
|
-
valueKey: valueKey,
|
|
250
|
-
labelKey: labelKey,
|
|
251
|
-
renderMenuGroup: renderMenuGroup,
|
|
252
|
-
renderMenuItem: renderMenuItem,
|
|
253
|
-
maxHeight: menuMaxHeight,
|
|
254
|
-
classPrefix: 'picker-select-menu',
|
|
255
|
-
dropdownMenuItemClassPrefix: 'picker-select-menu-item',
|
|
256
|
-
dropdownMenuItemAs: DropdownMenuItem,
|
|
257
|
-
activeItemValues: [value],
|
|
258
|
-
focusItemValue: focusItemValue,
|
|
259
|
-
data: items // FIXME-Doma
|
|
260
|
-
// `group` is redundant so long as `groupBy` exists
|
|
261
|
-
,
|
|
262
|
-
group: !isUndefined(groupBy),
|
|
263
|
-
groupBy: groupBy,
|
|
264
|
-
onSelect: handleItemSelect,
|
|
265
|
-
onGroupTitleClick: onGroupTitleClick,
|
|
266
|
-
virtualized: virtualized
|
|
267
|
-
}) : /*#__PURE__*/React.createElement("div", {
|
|
268
|
-
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["none"])))
|
|
269
|
-
}, locale === null || locale === void 0 ? void 0 : locale.noResultsText);
|
|
270
267
|
return /*#__PURE__*/React.createElement(PickerOverlay, {
|
|
271
268
|
ref: mergeRefs(overlayRef, speakerRef),
|
|
272
269
|
autoWidth: menuAutoWidth,
|
package/esm/Windowing/List.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { VariableSizeList, ListItemKeySelector, ListOnScrollProps, ListOnItemsRe
|
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
3
|
export interface ListProps<T = any> extends WithAsProps {
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated use itemSize instead
|
|
5
|
+
* @deprecated use {@link itemSize} instead
|
|
6
6
|
* Either a fixed row height (number) or a function that returns the height of a row given its index: ({ index: number }): number
|
|
7
7
|
*/
|
|
8
8
|
rowHeight?: number | (({ index: number }: {
|
|
@@ -34,7 +34,7 @@ export interface ListProps<T = any> extends WithAsProps {
|
|
|
34
34
|
*/
|
|
35
35
|
onScroll?: (props: ListOnScrollProps) => void;
|
|
36
36
|
}
|
|
37
|
-
export interface ListHandle extends
|
|
37
|
+
export interface ListHandle extends Pick<VariableSizeList, 'resetAfterIndex' | 'scrollTo' | 'scrollToItem'> {
|
|
38
38
|
/**
|
|
39
39
|
* @deprecated use scrollToItem instead
|
|
40
40
|
* Ensure row is visible. This method can be used to safely scroll back to a cell that a user has scrolled away from even if it was previously scrolled to.
|
package/esm/locales/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { default as zhTW } from './zh_TW';
|
|
|
21
21
|
export { default as faIR } from './fa_IR';
|
|
22
22
|
export { default as frFR } from './fr_FR';
|
|
23
23
|
export { default as jaJP } from './ja_JP';
|
|
24
|
+
export { default as neNP } from './ne_NP';
|
|
24
25
|
declare type PickKeys<T> = {
|
|
25
26
|
[keys in keyof T]?: T[keys];
|
|
26
27
|
};
|
package/esm/locales/index.js
CHANGED
|
@@ -19,4 +19,5 @@ export { default as zhCN } from './zh_CN';
|
|
|
19
19
|
export { default as zhTW } from './zh_TW';
|
|
20
20
|
export { default as faIR } from './fa_IR';
|
|
21
21
|
export { default as frFR } from './fr_FR';
|
|
22
|
-
export { default as jaJP } from './ja_JP';
|
|
22
|
+
export { default as jaJP } from './ja_JP';
|
|
23
|
+
export { default as neNP } from './ne_NP';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
common: {
|
|
3
|
+
loading: string;
|
|
4
|
+
emptyMessage: string;
|
|
5
|
+
};
|
|
6
|
+
Plaintext: {
|
|
7
|
+
unfilled: string;
|
|
8
|
+
notSelected: string;
|
|
9
|
+
notUploaded: string;
|
|
10
|
+
};
|
|
11
|
+
Pagination: {
|
|
12
|
+
more: string;
|
|
13
|
+
prev: string;
|
|
14
|
+
next: string;
|
|
15
|
+
first: string;
|
|
16
|
+
last: string;
|
|
17
|
+
limit: string;
|
|
18
|
+
total: string;
|
|
19
|
+
skip: string;
|
|
20
|
+
};
|
|
21
|
+
Calendar: {
|
|
22
|
+
sunday: string;
|
|
23
|
+
monday: string;
|
|
24
|
+
tuesday: string;
|
|
25
|
+
wednesday: string;
|
|
26
|
+
thursday: string;
|
|
27
|
+
friday: string;
|
|
28
|
+
saturday: string;
|
|
29
|
+
ok: string;
|
|
30
|
+
today: string;
|
|
31
|
+
yesterday: string;
|
|
32
|
+
hours: string;
|
|
33
|
+
minutes: string;
|
|
34
|
+
seconds: string;
|
|
35
|
+
/**
|
|
36
|
+
* Format of the string is based on Unicode Technical Standard #35:
|
|
37
|
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
38
|
+
**/
|
|
39
|
+
formattedMonthPattern: string;
|
|
40
|
+
formattedDayPattern: string;
|
|
41
|
+
dateLocale: any;
|
|
42
|
+
};
|
|
43
|
+
DatePicker: {
|
|
44
|
+
sunday: string;
|
|
45
|
+
monday: string;
|
|
46
|
+
tuesday: string;
|
|
47
|
+
wednesday: string;
|
|
48
|
+
thursday: string;
|
|
49
|
+
friday: string;
|
|
50
|
+
saturday: string;
|
|
51
|
+
ok: string;
|
|
52
|
+
today: string;
|
|
53
|
+
yesterday: string;
|
|
54
|
+
hours: string;
|
|
55
|
+
minutes: string;
|
|
56
|
+
seconds: string;
|
|
57
|
+
/**
|
|
58
|
+
* Format of the string is based on Unicode Technical Standard #35:
|
|
59
|
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
60
|
+
**/
|
|
61
|
+
formattedMonthPattern: string;
|
|
62
|
+
formattedDayPattern: string;
|
|
63
|
+
dateLocale: any;
|
|
64
|
+
};
|
|
65
|
+
DateRangePicker: {
|
|
66
|
+
last7Days: string;
|
|
67
|
+
sunday: string;
|
|
68
|
+
monday: string;
|
|
69
|
+
tuesday: string;
|
|
70
|
+
wednesday: string;
|
|
71
|
+
thursday: string;
|
|
72
|
+
friday: string;
|
|
73
|
+
saturday: string;
|
|
74
|
+
ok: string;
|
|
75
|
+
today: string;
|
|
76
|
+
yesterday: string;
|
|
77
|
+
hours: string;
|
|
78
|
+
minutes: string;
|
|
79
|
+
seconds: string;
|
|
80
|
+
/**
|
|
81
|
+
* Format of the string is based on Unicode Technical Standard #35:
|
|
82
|
+
* https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
83
|
+
**/
|
|
84
|
+
formattedMonthPattern: string;
|
|
85
|
+
formattedDayPattern: string;
|
|
86
|
+
dateLocale: any;
|
|
87
|
+
};
|
|
88
|
+
Picker: {
|
|
89
|
+
noResultsText: string;
|
|
90
|
+
placeholder: string;
|
|
91
|
+
searchPlaceholder: string;
|
|
92
|
+
checkAll: string;
|
|
93
|
+
};
|
|
94
|
+
InputPicker: {
|
|
95
|
+
newItem: string;
|
|
96
|
+
createOption: string;
|
|
97
|
+
};
|
|
98
|
+
Uploader: {
|
|
99
|
+
inited: string;
|
|
100
|
+
progress: string;
|
|
101
|
+
error: string;
|
|
102
|
+
complete: string;
|
|
103
|
+
emptyFile: string;
|
|
104
|
+
upload: string;
|
|
105
|
+
};
|
|
106
|
+
CloseButton: {
|
|
107
|
+
closeLabel: string;
|
|
108
|
+
};
|
|
109
|
+
Breadcrumb: {
|
|
110
|
+
expandText: string;
|
|
111
|
+
};
|
|
112
|
+
Toggle: {
|
|
113
|
+
on: string;
|
|
114
|
+
off: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export default _default;
|