rsuite 5.50.0 → 5.51.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/CheckTreePicker/styles/index.less +3 -3
  3. package/DatePicker/styles/index.less +1 -1
  4. package/Form/styles/mixin.less +1 -2
  5. package/InputGroup/styles/index.less +0 -14
  6. package/InputPicker/styles/index.less +1 -1
  7. package/Picker/styles/index.less +2 -2
  8. package/Picker/styles/mixin.less +3 -3
  9. package/TagInput/styles/index.less +1 -1
  10. package/TagPicker/styles/index.less +5 -1
  11. package/TreePicker/styles/index.less +2 -2
  12. package/cjs/@types/common.d.ts +8 -0
  13. package/cjs/AutoComplete/AutoComplete.js +14 -11
  14. package/cjs/AutoComplete/Combobox.d.ts +8 -0
  15. package/cjs/AutoComplete/Combobox.js +31 -0
  16. package/cjs/Calendar/CalendarContainer.js +35 -37
  17. package/cjs/Cascader/Cascader.js +12 -11
  18. package/cjs/Cascader/DropdownMenu.d.ts +3 -20
  19. package/cjs/Cascader/DropdownMenu.js +48 -48
  20. package/cjs/Cascader/TreeView.d.ts +24 -0
  21. package/cjs/Cascader/TreeView.js +174 -0
  22. package/cjs/CheckPicker/CheckPicker.js +9 -8
  23. package/cjs/CheckTreePicker/CheckTreeNode.d.ts +2 -2
  24. package/cjs/CheckTreePicker/CheckTreeNode.js +31 -59
  25. package/cjs/CheckTreePicker/CheckTreePicker.js +20 -20
  26. package/cjs/DatePicker/DatePicker.js +5 -6
  27. package/cjs/DateRangePicker/DateRangePicker.js +3 -4
  28. package/cjs/Form/Form.d.ts +14 -0
  29. package/cjs/Form/Form.js +39 -30
  30. package/cjs/Form/FormContext.d.ts +1 -0
  31. package/cjs/FormControl/FormControl.js +40 -18
  32. package/cjs/FormGroup/FormGroup.js +2 -1
  33. package/cjs/InputPicker/InputPicker.js +46 -29
  34. package/cjs/InputPicker/InputSearch.js +3 -15
  35. package/cjs/InputPicker/TagList.d.ts +3 -0
  36. package/cjs/InputPicker/TagList.js +29 -0
  37. package/cjs/InputPicker/TextBox.d.ts +18 -0
  38. package/cjs/InputPicker/TextBox.js +48 -0
  39. package/cjs/MultiCascader/MultiCascader.js +13 -10
  40. package/cjs/MultiCascader/{DropdownMenu.d.ts → TreeView.d.ts} +3 -3
  41. package/cjs/MultiCascader/{DropdownMenu.js → TreeView.js} +77 -74
  42. package/{esm/Picker/DropdownMenuCheckItem.d.ts → cjs/Picker/ListCheckItem.d.ts} +3 -3
  43. package/cjs/Picker/{DropdownMenuCheckItem.js → ListCheckItem.js} +14 -30
  44. package/{esm/Picker/DropdownMenuItem.d.ts → cjs/Picker/ListItem.d.ts} +4 -4
  45. package/cjs/Picker/{DropdownMenuItem.js → ListItem.js} +15 -24
  46. package/cjs/Picker/ListItemGroup.d.ts +6 -0
  47. package/cjs/Picker/{DropdownMenuGroup.js → ListItemGroup.js} +3 -9
  48. package/cjs/Picker/Listbox.d.ts +35 -0
  49. package/cjs/Picker/{DropdownMenu.js → Listbox.js} +49 -64
  50. package/cjs/Picker/{PickerOverlay.d.ts → PickerPopup.d.ts} +3 -3
  51. package/cjs/Picker/{PickerOverlay.js → PickerPopup.js} +9 -7
  52. package/cjs/Picker/PickerToggle.d.ts +1 -1
  53. package/cjs/Picker/PickerToggle.js +16 -9
  54. package/cjs/Picker/PickerToggleTrigger.d.ts +15 -0
  55. package/cjs/Picker/PickerToggleTrigger.js +21 -5
  56. package/cjs/Picker/SearchBar.js +7 -9
  57. package/cjs/Picker/TreeView.d.ts +7 -0
  58. package/cjs/Picker/TreeView.js +31 -0
  59. package/cjs/Picker/hooks/index.d.ts +6 -0
  60. package/cjs/Picker/hooks/index.js +18 -0
  61. package/cjs/Picker/hooks/useCombobox.d.ts +7 -0
  62. package/cjs/Picker/hooks/useCombobox.js +22 -0
  63. package/cjs/Picker/hooks/useFocusItemValue.d.ts +30 -0
  64. package/cjs/Picker/hooks/useFocusItemValue.js +246 -0
  65. package/cjs/Picker/hooks/usePickerClassName.d.ts +21 -0
  66. package/cjs/Picker/hooks/usePickerClassName.js +39 -0
  67. package/cjs/Picker/{usePickerRef.d.ts → hooks/usePickerRef.d.ts} +2 -2
  68. package/cjs/Picker/{usePickerRef.js → hooks/usePickerRef.js} +1 -1
  69. package/cjs/Picker/hooks/useSearch.d.ts +18 -0
  70. package/cjs/Picker/hooks/useSearch.js +57 -0
  71. package/cjs/Picker/hooks/useToggleKeyDownEvent.d.ts +25 -0
  72. package/cjs/Picker/hooks/useToggleKeyDownEvent.js +101 -0
  73. package/cjs/Picker/index.d.ts +7 -6
  74. package/cjs/Picker/index.js +26 -19
  75. package/cjs/Picker/propTypes.d.ts +0 -6
  76. package/cjs/Picker/propTypes.js +0 -5
  77. package/cjs/Picker/utils.d.ts +2 -96
  78. package/cjs/Picker/utils.js +1 -406
  79. package/cjs/SelectPicker/SelectPicker.js +8 -8
  80. package/cjs/TagInput/index.js +4 -0
  81. package/cjs/TreePicker/TreeNode.d.ts +2 -2
  82. package/cjs/TreePicker/TreeNode.js +22 -56
  83. package/cjs/TreePicker/TreePicker.js +19 -20
  84. package/dist/rsuite-no-reset-rtl.css +109 -117
  85. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  86. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  87. package/dist/rsuite-no-reset.css +109 -117
  88. package/dist/rsuite-no-reset.min.css +1 -1
  89. package/dist/rsuite-no-reset.min.css.map +1 -1
  90. package/dist/rsuite-rtl.css +109 -117
  91. package/dist/rsuite-rtl.min.css +1 -1
  92. package/dist/rsuite-rtl.min.css.map +1 -1
  93. package/dist/rsuite.css +109 -117
  94. package/dist/rsuite.js +184 -74
  95. package/dist/rsuite.js.map +1 -1
  96. package/dist/rsuite.min.css +1 -1
  97. package/dist/rsuite.min.css.map +1 -1
  98. package/dist/rsuite.min.js +1 -1
  99. package/dist/rsuite.min.js.map +1 -1
  100. package/esm/@types/common.d.ts +8 -0
  101. package/esm/AutoComplete/AutoComplete.js +15 -12
  102. package/esm/AutoComplete/Combobox.d.ts +8 -0
  103. package/esm/AutoComplete/Combobox.js +25 -0
  104. package/esm/Calendar/CalendarContainer.js +37 -39
  105. package/esm/Cascader/Cascader.js +13 -12
  106. package/esm/Cascader/DropdownMenu.d.ts +3 -20
  107. package/esm/Cascader/DropdownMenu.js +50 -49
  108. package/esm/Cascader/TreeView.d.ts +24 -0
  109. package/esm/Cascader/TreeView.js +167 -0
  110. package/esm/CheckPicker/CheckPicker.js +10 -9
  111. package/esm/CheckTreePicker/CheckTreeNode.d.ts +2 -2
  112. package/esm/CheckTreePicker/CheckTreeNode.js +33 -61
  113. package/esm/CheckTreePicker/CheckTreePicker.js +21 -21
  114. package/esm/DatePicker/DatePicker.js +5 -6
  115. package/esm/DateRangePicker/DateRangePicker.js +3 -4
  116. package/esm/Form/Form.d.ts +14 -0
  117. package/esm/Form/Form.js +41 -32
  118. package/esm/Form/FormContext.d.ts +1 -0
  119. package/esm/FormControl/FormControl.js +39 -17
  120. package/esm/FormGroup/FormGroup.js +3 -2
  121. package/esm/InputPicker/InputPicker.js +47 -30
  122. package/esm/InputPicker/InputSearch.js +4 -15
  123. package/esm/InputPicker/TagList.d.ts +3 -0
  124. package/esm/InputPicker/TagList.js +23 -0
  125. package/esm/InputPicker/TextBox.d.ts +18 -0
  126. package/esm/InputPicker/TextBox.js +42 -0
  127. package/esm/MultiCascader/MultiCascader.js +14 -11
  128. package/esm/MultiCascader/{DropdownMenu.d.ts → TreeView.d.ts} +3 -3
  129. package/esm/MultiCascader/{DropdownMenu.js → TreeView.js} +79 -75
  130. package/{cjs/Picker/DropdownMenuCheckItem.d.ts → esm/Picker/ListCheckItem.d.ts} +3 -3
  131. package/esm/Picker/{DropdownMenuCheckItem.js → ListCheckItem.js} +15 -30
  132. package/{cjs/Picker/DropdownMenuItem.d.ts → esm/Picker/ListItem.d.ts} +4 -4
  133. package/esm/Picker/{DropdownMenuItem.js → ListItem.js} +16 -24
  134. package/esm/Picker/ListItemGroup.d.ts +6 -0
  135. package/esm/Picker/{DropdownMenuGroup.js → ListItemGroup.js} +3 -9
  136. package/esm/Picker/Listbox.d.ts +35 -0
  137. package/esm/Picker/{DropdownMenu.js → Listbox.js} +50 -64
  138. package/esm/Picker/{PickerOverlay.d.ts → PickerPopup.d.ts} +3 -3
  139. package/esm/Picker/{PickerOverlay.js → PickerPopup.js} +10 -8
  140. package/esm/Picker/PickerToggle.d.ts +1 -1
  141. package/esm/Picker/PickerToggle.js +16 -9
  142. package/esm/Picker/PickerToggleTrigger.d.ts +15 -0
  143. package/esm/Picker/PickerToggleTrigger.js +20 -5
  144. package/esm/Picker/SearchBar.js +8 -9
  145. package/esm/Picker/TreeView.d.ts +7 -0
  146. package/esm/Picker/TreeView.js +25 -0
  147. package/esm/Picker/hooks/index.d.ts +6 -0
  148. package/esm/Picker/hooks/index.js +7 -0
  149. package/esm/Picker/hooks/useCombobox.d.ts +7 -0
  150. package/esm/Picker/hooks/useCombobox.js +17 -0
  151. package/esm/Picker/hooks/useFocusItemValue.d.ts +30 -0
  152. package/esm/Picker/hooks/useFocusItemValue.js +240 -0
  153. package/esm/Picker/hooks/usePickerClassName.d.ts +21 -0
  154. package/esm/Picker/hooks/usePickerClassName.js +33 -0
  155. package/esm/Picker/{usePickerRef.d.ts → hooks/usePickerRef.d.ts} +2 -2
  156. package/esm/Picker/{usePickerRef.js → hooks/usePickerRef.js} +1 -1
  157. package/esm/Picker/hooks/useSearch.d.ts +18 -0
  158. package/esm/Picker/hooks/useSearch.js +51 -0
  159. package/esm/Picker/hooks/useToggleKeyDownEvent.d.ts +25 -0
  160. package/esm/Picker/hooks/useToggleKeyDownEvent.js +96 -0
  161. package/esm/Picker/index.d.ts +7 -6
  162. package/esm/Picker/index.js +7 -6
  163. package/esm/Picker/propTypes.d.ts +0 -6
  164. package/esm/Picker/propTypes.js +0 -5
  165. package/esm/Picker/utils.d.ts +2 -96
  166. package/esm/Picker/utils.js +2 -401
  167. package/esm/SelectPicker/SelectPicker.js +9 -9
  168. package/esm/TagInput/index.js +4 -0
  169. package/esm/TreePicker/TreeNode.d.ts +2 -2
  170. package/esm/TreePicker/TreeNode.js +24 -58
  171. package/esm/TreePicker/TreePicker.js +20 -21
  172. package/package.json +1 -1
  173. package/styles/variables.less +1 -3
  174. package/cjs/Picker/DropdownMenu.d.ts +0 -59
  175. package/cjs/Picker/DropdownMenuGroup.d.ts +0 -6
  176. package/esm/Picker/DropdownMenu.d.ts +0 -59
  177. package/esm/Picker/DropdownMenuGroup.d.ts +0 -6
@@ -1,33 +1,11 @@
1
1
  import React from 'react';
2
- import { OverlayTriggerHandle } from './PickerToggleTrigger';
3
- import { TypeAttributes } from '../@types/common';
4
- import type { ListHandle } from '../Windowing';
5
2
  export interface NodeKeys {
6
3
  valueKey: string;
7
4
  childrenKey: string;
8
5
  }
9
6
  export declare function createConcatChildrenFunction<T = any>(node: any, nodeValue?: any, nodeKeys?: NodeKeys): (data: T[], children: T[]) => T[];
10
7
  export declare function shouldDisplay(label: React.ReactNode, searchKeyword: string): boolean;
11
- export interface PickerClassNameProps {
12
- name?: string;
13
- classPrefix: string;
14
- className?: string;
15
- placement?: TypeAttributes.Placement;
16
- appearance?: 'default' | 'subtle';
17
- cleanable?: boolean;
18
- block?: boolean;
19
- disabled?: boolean;
20
- countable?: boolean;
21
- readOnly?: boolean;
22
- plaintext?: boolean;
23
- hasValue?: boolean;
24
- classes?: any;
25
- }
26
- /**
27
- * The className of the assembled Toggle is on the Picker.
28
- */
29
- export declare function usePickerClassName(props: PickerClassNameProps): [string, string[]];
30
- export interface EventsProps {
8
+ export interface KeyboardEvents {
31
9
  down?: React.KeyboardEventHandler;
32
10
  up?: React.KeyboardEventHandler;
33
11
  enter?: React.KeyboardEventHandler;
@@ -41,76 +19,4 @@ export interface EventsProps {
41
19
  * @param event Keyboard event object
42
20
  * @param events Event callback functions
43
21
  */
44
- export declare function onMenuKeyDown(event: React.KeyboardEvent, events: EventsProps): void;
45
- export interface FocusItemValueProps<T = unknown> {
46
- target: HTMLElement | null | (() => HTMLElement | null);
47
- data?: T[];
48
- valueKey?: string;
49
- focusableQueryKey?: string;
50
- defaultLayer?: number;
51
- rtl?: boolean;
52
- callback?: (value: any, event: React.KeyboardEvent) => void;
53
- getParent?: (node: T) => T | undefined;
54
- }
55
- /**
56
- * A hook that manages the focus state of the option.
57
- * @param defaultFocusItemValue
58
- * @param props
59
- */
60
- export declare const useFocusItemValue: <T, D>(defaultFocusItemValue: T | null | undefined, props: FocusItemValueProps<D>) => {
61
- focusItemValue: T | null | undefined;
62
- setFocusItemValue: React.Dispatch<React.SetStateAction<T | null | undefined>>;
63
- layer: number;
64
- setLayer: React.Dispatch<React.SetStateAction<number>>;
65
- keys: any[];
66
- setKeys: React.Dispatch<React.SetStateAction<any[]>>;
67
- onKeyDown: (event: any) => void;
68
- };
69
- export interface ToggleKeyDownEventProps {
70
- toggle?: boolean;
71
- trigger: React.RefObject<any>;
72
- target: React.RefObject<any>;
73
- overlay?: React.RefObject<any>;
74
- searchInput?: React.RefObject<any>;
75
- active?: boolean;
76
- readOnly?: boolean;
77
- disabled?: boolean;
78
- onExit?: (event: any) => void;
79
- onKeyDown?: (event: any) => void;
80
- onOpen?: () => void;
81
- onClose?: () => void;
82
- onMenuKeyDown?: (event: any) => void;
83
- onMenuPressEnter?: (event: any) => void;
84
- onMenuPressBackspace?: (event: any) => void;
85
- [key: string]: any;
86
- }
87
- /**
88
- * A hook to control the toggle keyboard operation
89
- * @param props
90
- */
91
- export declare const useToggleKeyDownEvent: (props: ToggleKeyDownEventProps) => (...args: any[]) => any;
92
- interface SearchOptions<T> {
93
- labelKey: string;
94
- searchBy?: (keyword: string, label: any, item: T) => boolean;
95
- callback?: (keyword: string, data: T[], event: React.SyntheticEvent) => void;
96
- }
97
- declare type UseSearchResult<T> = {
98
- searchKeyword: string;
99
- filteredData: T[];
100
- checkShouldDisplay: (item: T, keyword?: string) => boolean;
101
- handleSearch: (searchKeyword: string, event: React.SyntheticEvent) => void;
102
- resetSearch: () => void;
103
- };
104
- /**
105
- * A hook that handles search filter options
106
- */
107
- export declare function useSearch<T>(data: readonly T[], props: SearchOptions<T>): UseSearchResult<T>;
108
- export interface PickerDependentParameters {
109
- triggerRef?: React.RefObject<OverlayTriggerHandle>;
110
- rootRef?: React.RefObject<HTMLElement>;
111
- overlayRef?: React.RefObject<HTMLElement>;
112
- targetRef?: React.RefObject<HTMLElement>;
113
- listRef?: React.RefObject<ListHandle>;
114
- inline?: boolean;
115
- }
116
- export {};
22
+ export declare function onMenuKeyDown(event: React.KeyboardEvent, events: KeyboardEvents): void;
@@ -1,15 +1,8 @@
1
1
  'use client';
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- import React, { useState, useCallback, useMemo } from 'react';
4
- import kebabCase from 'lodash/kebabCase';
2
+ import React from 'react';
5
3
  import trim from 'lodash/trim';
6
- import isFunction from 'lodash/isFunction';
7
- import isUndefined from 'lodash/isUndefined';
8
- import omit from 'lodash/omit';
9
- import find from 'lodash/find';
10
4
  import { findNodeOfTree } from '../utils/treeUtils';
11
- import { KEY_VALUES, useClassNames, shallowEqual, reactToString, placementPolyfill, useEventCallback } from '../utils';
12
- import { getHeight } from 'dom-lib';
5
+ import { KEY_VALUES, reactToString } from '../utils';
13
6
  var defaultNodeKeys = {
14
7
  valueKey: 'value',
15
8
  childrenKey: 'children'
@@ -44,33 +37,6 @@ export function shouldDisplay(label, searchKeyword) {
44
37
  }
45
38
  return false;
46
39
  }
47
- /**
48
- * The className of the assembled Toggle is on the Picker.
49
- */
50
- export function usePickerClassName(props) {
51
- var _withClassPrefix;
52
- var name = props.name,
53
- classPrefix = props.classPrefix,
54
- className = props.className,
55
- placement = props.placement,
56
- appearance = props.appearance,
57
- cleanable = props.cleanable,
58
- block = props.block,
59
- disabled = props.disabled,
60
- countable = props.countable,
61
- readOnly = props.readOnly,
62
- plaintext = props.plaintext,
63
- hasValue = props.hasValue,
64
- rest = _objectWithoutPropertiesLoose(props, ["name", "classPrefix", "className", "placement", "appearance", "cleanable", "block", "disabled", "countable", "readOnly", "plaintext", "hasValue"]);
65
- var _useClassNames = useClassNames(classPrefix),
66
- withClassPrefix = _useClassNames.withClassPrefix,
67
- merge = _useClassNames.merge;
68
- var classes = merge(className, withClassPrefix(name, appearance, 'toggle-wrapper', (_withClassPrefix = {}, _withClassPrefix["placement-" + kebabCase(placementPolyfill(placement))] = placement, _withClassPrefix['read-only'] = readOnly, _withClassPrefix['has-value'] = hasValue, _withClassPrefix.cleanable = cleanable, _withClassPrefix.block = block, _withClassPrefix.disabled = disabled, _withClassPrefix.countable = countable, _withClassPrefix.plaintext = plaintext, _withClassPrefix)));
69
-
70
- // Those props that're used for composing the className
71
- var usedClassNamePropKeys = Object.keys(omit(props, [].concat(Object.keys(rest || {}), ['disabled', 'readOnly', 'plaintext', 'name'])));
72
- return [classes, usedClassNamePropKeys];
73
- }
74
40
  /**
75
41
  * Handling keyboard events...
76
42
  * @param event Keyboard event object
@@ -119,369 +85,4 @@ export function onMenuKeyDown(event, events) {
119
85
  break;
120
86
  default:
121
87
  }
122
- }
123
- /**
124
- * Checks if the element has a vertical scrollbar.
125
- */
126
- function hasVerticalScroll(element) {
127
- var scrollHeight = element.scrollHeight,
128
- clientHeight = element.clientHeight;
129
- return scrollHeight > clientHeight;
130
- }
131
-
132
- /**
133
- * Checks if the element is within the visible area of the container
134
- */
135
- function isVisible(element, container, direction) {
136
- if (!hasVerticalScroll(container)) {
137
- return true;
138
- }
139
- var _element$getBoundingC = element.getBoundingClientRect(),
140
- top = _element$getBoundingC.top,
141
- bottom = _element$getBoundingC.bottom,
142
- height = _element$getBoundingC.height;
143
- var _container$getBoundin = container.getBoundingClientRect(),
144
- containerTop = _container$getBoundin.top,
145
- containerBottom = _container$getBoundin.bottom;
146
- if (direction === 'top') {
147
- return top + height > containerTop;
148
- }
149
- return bottom - height < containerBottom;
150
- }
151
- function scrollTo(container, direction, step) {
152
- var scrollTop = container.scrollTop;
153
- container.scrollTop = direction === 'top' ? scrollTop - step : scrollTop + step;
154
- }
155
-
156
- /**
157
- * A hook that manages the focus state of the option.
158
- * @param defaultFocusItemValue
159
- * @param props
160
- */
161
- export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props) {
162
- var _props$valueKey = props.valueKey,
163
- valueKey = _props$valueKey === void 0 ? 'value' : _props$valueKey,
164
- _props$focusableQuery = props.focusableQueryKey,
165
- focusableQueryKey = _props$focusableQuery === void 0 ? '[data-key][aria-disabled="false"]' : _props$focusableQuery,
166
- _props$defaultLayer = props.defaultLayer,
167
- defaultLayer = _props$defaultLayer === void 0 ? 0 : _props$defaultLayer,
168
- data = props.data,
169
- target = props.target,
170
- rtl = props.rtl,
171
- callback = props.callback,
172
- _props$getParent = props.getParent,
173
- getParent = _props$getParent === void 0 ? function (item) {
174
- return item === null || item === void 0 ? void 0 : item.parent;
175
- } : _props$getParent;
176
- var _useState = useState(defaultFocusItemValue),
177
- focusItemValue = _useState[0],
178
- setFocusItemValue = _useState[1];
179
- var _useState2 = useState(defaultLayer),
180
- layer = _useState2[0],
181
- setLayer = _useState2[1];
182
- var _useState3 = useState([]),
183
- keys = _useState3[0],
184
- setKeys = _useState3[1];
185
- var focusCallback = useCallback(function (value, event) {
186
- var menu = isFunction(target) ? target() : target;
187
- var focusElement = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-key=\"" + value + "\"]");
188
- focusElement === null || focusElement === void 0 ? void 0 : focusElement.focus();
189
- callback === null || callback === void 0 ? void 0 : callback(value, event);
190
- }, [callback, target]);
191
- var getScrollContainer = useCallback(function () {
192
- var menu = isFunction(target) ? target() : target;
193
-
194
- // For Cascader and MutiCascader
195
- var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + layer + "\"]");
196
- if (subMenu) {
197
- return subMenu;
198
- }
199
-
200
- // For SelectPicker、CheckPicker、Autocomplete、InputPicker、TagPicker
201
- return menu === null || menu === void 0 ? void 0 : menu.querySelector('[role="listbox"]');
202
- }, [layer, target]);
203
-
204
- /**
205
- * Get the elements visible in all options.
206
- */
207
- var getFocusableMenuItems = useCallback(function () {
208
- if (!target) {
209
- return [];
210
- }
211
- var currentKeys = keys;
212
- if (layer < 1) {
213
- var popup = isFunction(target) ? target() : target;
214
- var rootMenu = popup === null || popup === void 0 ? void 0 : popup.querySelector('[data-layer="0"]');
215
- if (rootMenu) {
216
- var _rootMenu$querySelect;
217
- currentKeys = Array.from((_rootMenu$querySelect = rootMenu.querySelectorAll(focusableQueryKey)) !== null && _rootMenu$querySelect !== void 0 ? _rootMenu$querySelect : []).map(function (item) {
218
- var _item$dataset;
219
- return (_item$dataset = item.dataset) === null || _item$dataset === void 0 ? void 0 : _item$dataset.key;
220
- });
221
- } else {
222
- var _popup$querySelectorA;
223
- currentKeys = Array.from((_popup$querySelectorA = popup === null || popup === void 0 ? void 0 : popup.querySelectorAll(focusableQueryKey)) !== null && _popup$querySelectorA !== void 0 ? _popup$querySelectorA : []).map(function (item) {
224
- var _item$dataset2;
225
- return (_item$dataset2 = item.dataset) === null || _item$dataset2 === void 0 ? void 0 : _item$dataset2.key;
226
- });
227
- }
228
- }
229
-
230
- // 1. It is necessary to traverse the `keys` instead of `data` here to preserve the order of the array.
231
- // 2. The values ​​in `keys` are all string, so the corresponding value of `data` should also be converted to string
232
- return currentKeys.map(function (key) {
233
- return find(data, function (i) {
234
- return "" + i[valueKey] === key;
235
- });
236
- });
237
- }, [data, focusableQueryKey, keys, target, valueKey, layer]);
238
-
239
- /**
240
- * Get the index of the focus item.
241
- */
242
- var findFocusItemIndex = useCallback(function (callback) {
243
- var items = getFocusableMenuItems();
244
- for (var i = 0; i < items.length; i += 1) {
245
- var _items$i;
246
- if (shallowEqual(focusItemValue, (_items$i = items[i]) === null || _items$i === void 0 ? void 0 : _items$i[valueKey])) {
247
- callback(items, i);
248
- return;
249
- }
250
- }
251
- callback(items, -1);
252
- }, [focusItemValue, getFocusableMenuItems, valueKey]);
253
- var scrollListItem = useCallback(function (direction, itemValue, willOverflow) {
254
- var container = getScrollContainer();
255
- var item = container === null || container === void 0 ? void 0 : container.querySelector("[data-key=\"" + itemValue + "\"]");
256
- if (willOverflow && container) {
257
- var scrollHeight = container.scrollHeight,
258
- clientHeight = container.clientHeight;
259
- container.scrollTop = direction === 'top' ? scrollHeight - clientHeight : 0;
260
- return;
261
- }
262
- if (item && container) {
263
- if (!isVisible(item, container, direction)) {
264
- var height = getHeight(item);
265
- scrollTo(container, direction, height);
266
- }
267
- }
268
- }, [getScrollContainer]);
269
- var focusNextMenuItem = useCallback(function (event) {
270
- findFocusItemIndex(function (items, index) {
271
- var willOverflow = index + 2 > items.length;
272
- var nextIndex = willOverflow ? 0 : index + 1;
273
- var focusItem = items[nextIndex];
274
- if (!isUndefined(focusItem)) {
275
- setFocusItemValue(focusItem[valueKey]);
276
- focusCallback(focusItem[valueKey], event);
277
- scrollListItem('bottom', focusItem[valueKey], willOverflow);
278
- }
279
- });
280
- }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
281
- var focusPrevMenuItem = useCallback(function (event) {
282
- findFocusItemIndex(function (items, index) {
283
- var willOverflow = index === 0;
284
- var nextIndex = willOverflow ? items.length - 1 : index - 1;
285
- var focusItem = items[nextIndex];
286
- if (!isUndefined(focusItem)) {
287
- setFocusItemValue(focusItem[valueKey]);
288
- focusCallback(focusItem[valueKey], event);
289
- scrollListItem('top', focusItem[valueKey], willOverflow);
290
- }
291
- });
292
- }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
293
- var getSubMenuKeys = useCallback(function (nextLayer) {
294
- var menu = isFunction(target) ? target() : target;
295
- var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
296
- if (subMenu) {
297
- var _Array$from;
298
- return (_Array$from = Array.from(subMenu.querySelectorAll(focusableQueryKey))) === null || _Array$from === void 0 ? void 0 : _Array$from.map(function (item) {
299
- var _item$dataset3;
300
- return (_item$dataset3 = item.dataset) === null || _item$dataset3 === void 0 ? void 0 : _item$dataset3.key;
301
- });
302
- }
303
- return null;
304
- }, [focusableQueryKey, target]);
305
- var focusNextLevelMenu = useCallback(function (event) {
306
- var nextLayer = layer + 1;
307
- var nextKeys = getSubMenuKeys(nextLayer);
308
- if (nextKeys) {
309
- setKeys(nextKeys);
310
- setLayer(nextLayer);
311
- setFocusItemValue(nextKeys[0]);
312
- focusCallback(nextKeys[0], event);
313
- }
314
- }, [focusCallback, getSubMenuKeys, layer]);
315
- var focusPrevLevelMenu = useCallback(function (event) {
316
- var nextLayer = layer - 1;
317
- var nextKeys = getSubMenuKeys(nextLayer);
318
- if (nextKeys) {
319
- var _getParent;
320
- setKeys(nextKeys);
321
- setLayer(nextLayer);
322
- var focusItem = findNodeOfTree(data, function (item) {
323
- return item[valueKey] === focusItemValue;
324
- });
325
- var parentItemValue = (_getParent = getParent(focusItem)) === null || _getParent === void 0 ? void 0 : _getParent[valueKey];
326
- if (parentItemValue) {
327
- setFocusItemValue(parentItemValue);
328
- focusCallback(parentItemValue, event);
329
- }
330
- }
331
- }, [focusCallback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
332
- var handleKeyDown = useCallback(function (event) {
333
- var _onMenuKeyDown;
334
- onMenuKeyDown(event, (_onMenuKeyDown = {
335
- down: focusNextMenuItem,
336
- up: focusPrevMenuItem
337
- }, _onMenuKeyDown[rtl ? 'left' : 'right'] = focusNextLevelMenu, _onMenuKeyDown[rtl ? 'right' : 'left'] = focusPrevLevelMenu, _onMenuKeyDown));
338
- }, [focusNextLevelMenu, focusNextMenuItem, focusPrevLevelMenu, focusPrevMenuItem, rtl]);
339
- return {
340
- focusItemValue: focusItemValue,
341
- setFocusItemValue: setFocusItemValue,
342
- layer: layer,
343
- setLayer: setLayer,
344
- keys: keys,
345
- setKeys: setKeys,
346
- onKeyDown: handleKeyDown
347
- };
348
- };
349
- /**
350
- * A hook to control the toggle keyboard operation
351
- * @param props
352
- */
353
- export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
354
- var _props$toggle = props.toggle,
355
- toggle = _props$toggle === void 0 ? true : _props$toggle,
356
- trigger = props.trigger,
357
- target = props.target,
358
- overlay = props.overlay,
359
- searchInput = props.searchInput,
360
- active = props.active,
361
- readOnly = props.readOnly,
362
- disabled = props.disabled,
363
- loading = props.loading,
364
- onExit = props.onExit,
365
- onOpen = props.onOpen,
366
- onClose = props.onClose,
367
- onKeyDown = props.onKeyDown,
368
- onMenuKeyDown = props.onMenuKeyDown,
369
- onMenuPressEnter = props.onMenuPressEnter,
370
- onMenuPressBackspace = props.onMenuPressBackspace;
371
- var handleClose = useEventCallback(function () {
372
- var _trigger$current, _trigger$current$clos, _trigger$current2, _trigger$current2$foc;
373
- (_trigger$current = trigger.current) === null || _trigger$current === void 0 ? void 0 : (_trigger$current$clos = _trigger$current.close) === null || _trigger$current$clos === void 0 ? void 0 : _trigger$current$clos.call(_trigger$current);
374
-
375
- // The focus is on the trigger button after closing
376
- (_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 ? void 0 : (_trigger$current2$foc = _trigger$current2.focus) === null || _trigger$current2$foc === void 0 ? void 0 : _trigger$current2$foc.call(_trigger$current2);
377
- onClose === null || onClose === void 0 ? void 0 : onClose();
378
- });
379
- var handleOpen = useEventCallback(function () {
380
- var _trigger$current3, _trigger$current3$ope;
381
- (_trigger$current3 = trigger.current) === null || _trigger$current3 === void 0 ? void 0 : (_trigger$current3$ope = _trigger$current3.open) === null || _trigger$current3$ope === void 0 ? void 0 : _trigger$current3$ope.call(_trigger$current3);
382
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
383
- });
384
- var handleToggleDropdown = useEventCallback(function () {
385
- if (active) {
386
- handleClose();
387
- return;
388
- }
389
- handleOpen();
390
- });
391
- var onToggle = useEventCallback(function (event) {
392
- // Keyboard events should not be processed when readOnly and disabled are set.
393
- if (readOnly || disabled || loading) {
394
- return;
395
- }
396
- if (event.target === (target === null || target === void 0 ? void 0 : target.current)) {
397
- // enter
398
- if (toggle && event.key === KEY_VALUES.ENTER) {
399
- handleToggleDropdown();
400
- }
401
-
402
- // delete
403
- if (event.key === KEY_VALUES.BACKSPACE) {
404
- onExit === null || onExit === void 0 ? void 0 : onExit(event);
405
- }
406
- }
407
- if (overlay !== null && overlay !== void 0 && overlay.current) {
408
- // The keyboard operation callback on the menu.
409
- onMenuKeyDown === null || onMenuKeyDown === void 0 ? void 0 : onMenuKeyDown(event);
410
- if (event.key === KEY_VALUES.ENTER) {
411
- onMenuPressEnter === null || onMenuPressEnter === void 0 ? void 0 : onMenuPressEnter(event);
412
- }
413
-
414
- /**
415
- * There is no callback when typing the Backspace key in the search box.
416
- * The default is to remove search keywords
417
- */
418
- if (event.key === KEY_VALUES.BACKSPACE && event.target !== (searchInput === null || searchInput === void 0 ? void 0 : searchInput.current)) {
419
- onMenuPressBackspace === null || onMenuPressBackspace === void 0 ? void 0 : onMenuPressBackspace(event);
420
- }
421
-
422
- // The search box gets focus when typing characters and numbers.
423
- if (event.key.length === 1 && /\w/.test(event.key)) {
424
- var _event$target;
425
- // Exclude Input
426
- // eg: <SelectPicker renderExtraFooter={() => <Input />} />
427
- if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) !== 'INPUT') {
428
- var _searchInput$current;
429
- searchInput === null || searchInput === void 0 ? void 0 : (_searchInput$current = searchInput.current) === null || _searchInput$current === void 0 ? void 0 : _searchInput$current.focus();
430
- }
431
- }
432
- }
433
- if (event.key === KEY_VALUES.ESC || event.key === KEY_VALUES.TAB) {
434
- handleClose();
435
- }
436
-
437
- // Native event callback
438
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
439
- });
440
- return onToggle;
441
- };
442
- /**
443
- * A hook that handles search filter options
444
- */
445
- export function useSearch(data, props) {
446
- var labelKey = props.labelKey,
447
- searchBy = props.searchBy,
448
- callback = props.callback; // Use search keywords to filter options.
449
- var _useState4 = useState(''),
450
- searchKeyword = _useState4[0],
451
- setSearchKeyword = _useState4[1];
452
- var resetSearch = useCallback(function () {
453
- setSearchKeyword('');
454
- }, []);
455
-
456
- /**
457
- * Index of keyword in `label`
458
- * @param {node} label
459
- */
460
- var checkShouldDisplay = useCallback(function (item, keyword) {
461
- var checkValue = typeof item === 'object' ? item === null || item === void 0 ? void 0 : item[labelKey] : String(item);
462
- var _keyword = isUndefined(keyword) ? searchKeyword : keyword;
463
- if (typeof searchBy === 'function') {
464
- return searchBy(_keyword, checkValue, item);
465
- }
466
- return shouldDisplay(checkValue, _keyword);
467
- }, [labelKey, searchBy, searchKeyword]);
468
- var filteredData = useMemo(function () {
469
- return data.filter(function (item) {
470
- return checkShouldDisplay(item, searchKeyword);
471
- });
472
- }, [checkShouldDisplay, data, searchKeyword]);
473
- var handleSearch = function handleSearch(searchKeyword, event) {
474
- var filteredData = data.filter(function (item) {
475
- return checkShouldDisplay(item, searchKeyword);
476
- });
477
- setSearchKeyword(searchKeyword);
478
- callback === null || callback === void 0 ? void 0 : callback(searchKeyword, filteredData, event);
479
- };
480
- return {
481
- searchKeyword: searchKeyword,
482
- filteredData: filteredData,
483
- checkShouldDisplay: checkShouldDisplay,
484
- handleSearch: handleSearch,
485
- resetSearch: resetSearch
486
- };
487
88
  }
@@ -12,7 +12,7 @@ import isFunction from 'lodash/isFunction';
12
12
  import omit from 'lodash/omit';
13
13
  import { createChainedFunction, useCustom, useClassNames, useControlled, useEventCallback, mergeRefs, shallowEqual } from '../utils';
14
14
  import { getDataGroupBy } from '../utils/getDataGroupBy';
15
- import { DropdownMenu, DropdownMenuItem, PickerToggle, PickerToggleTrigger, PickerOverlay, SearchBar, useFocusItemValue, usePickerClassName, useSearch, useToggleKeyDownEvent, usePickerRef, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
15
+ import { Listbox, ListItem, PickerToggle, PickerToggleTrigger, PickerPopup, SearchBar, useFocusItemValue, usePickerClassName, useSearch, useToggleKeyDownEvent, usePickerRef, pickTriggerPropKeys, omitTriggerPropKeys, listPickerPropTypes } from '../Picker';
16
16
  var emptyArray = [];
17
17
  /**
18
18
  * The `SelectPicker` component is used to select an item from a list of data.
@@ -203,7 +203,7 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
203
203
  hasValue = false;
204
204
  }
205
205
  }
206
- var renderDropdownMenu = function renderDropdownMenu(positionProps, speakerRef) {
206
+ var renderPopup = function renderPopup(positionProps, speakerRef) {
207
207
  var left = positionProps.left,
208
208
  top = positionProps.top,
209
209
  className = positionProps.className;
@@ -220,8 +220,7 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
220
220
  } else if (typeof sort === 'function') {
221
221
  items = items.sort(sort(false));
222
222
  }
223
- var menu = items.length ? /*#__PURE__*/React.createElement(DropdownMenu, {
224
- id: id ? id + "-listbox" : undefined,
223
+ var menu = items.length ? /*#__PURE__*/React.createElement(Listbox, {
225
224
  listProps: listProps,
226
225
  listRef: list,
227
226
  disabledItemValues: disabledItemValues,
@@ -231,8 +230,8 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
231
230
  renderMenuItem: renderMenuItem,
232
231
  maxHeight: menuMaxHeight,
233
232
  classPrefix: 'picker-select-menu',
234
- dropdownMenuItemClassPrefix: 'picker-select-menu-item',
235
- dropdownMenuItemAs: DropdownMenuItem,
233
+ listItemClassPrefix: 'picker-select-menu-item',
234
+ listItemAs: ListItem,
236
235
  activeItemValues: [value],
237
236
  focusItemValue: focusItemValue,
238
237
  data: items
@@ -247,7 +246,7 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
247
246
  }) : /*#__PURE__*/React.createElement("div", {
248
247
  className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["none"])))
249
248
  }, locale === null || locale === void 0 ? void 0 : locale.noResultsText);
250
- return /*#__PURE__*/React.createElement(PickerOverlay, {
249
+ return /*#__PURE__*/React.createElement(PickerPopup, {
251
250
  ref: mergeRefs(overlay, speakerRef),
252
251
  autoWidth: menuAutoWidth,
253
252
  className: classes,
@@ -271,18 +270,18 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
271
270
  classes = _usePickerClassName[0],
272
271
  usedClassNamePropKeys = _usePickerClassName[1];
273
272
  return /*#__PURE__*/React.createElement(PickerToggleTrigger, {
273
+ id: id,
274
274
  pickerProps: pick(props, pickTriggerPropKeys),
275
275
  ref: trigger,
276
276
  placement: placement,
277
277
  onEntered: createChainedFunction(handleEntered, onEntered),
278
278
  onExited: createChainedFunction(handleExited, onExited),
279
- speaker: renderDropdownMenu
279
+ speaker: renderPopup
280
280
  }, /*#__PURE__*/React.createElement(Component, {
281
281
  className: classes,
282
282
  style: style,
283
283
  ref: root
284
284
  }, /*#__PURE__*/React.createElement(PickerToggle, _extends({}, omit(rest, [].concat(omitTriggerPropKeys, usedClassNamePropKeys)), {
285
- id: id,
286
285
  ref: target,
287
286
  appearance: appearance,
288
287
  onClean: createChainedFunction(handleClean, onClean),
@@ -292,6 +291,7 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
292
291
  cleanable: cleanable && !disabled,
293
292
  hasValue: hasValue,
294
293
  inputValue: value !== null && value !== void 0 ? value : '',
294
+ focusItemValue: focusItemValue,
295
295
  active: active,
296
296
  placement: placement
297
297
  }), selectedElement || (locale === null || locale === void 0 ? void 0 : locale.placeholder))));
@@ -38,6 +38,10 @@ var TagInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
38
38
  return /*#__PURE__*/React.createElement(InputPickerContext.Provider, {
39
39
  value: contextValue
40
40
  }, /*#__PURE__*/React.createElement(InputPicker, _extends({}, rest, {
41
+ "aria-haspopup": false,
42
+ "aria-expanded": undefined,
43
+ "aria-controls": undefined,
44
+ "aria-keyshortcuts": trigger,
41
45
  value: value,
42
46
  defaultValue: defaultValue,
43
47
  data: data,
@@ -23,8 +23,8 @@ export interface TreeNodeProps extends WithAsProps {
23
23
  style?: React.CSSProperties;
24
24
  onExpand?: (nodeData: any) => void;
25
25
  onSelect?: (nodeData: any, event: React.SyntheticEvent) => void;
26
- onRenderTreeIcon?: (nodeData: any) => React.ReactNode;
27
- onRenderTreeNode?: (nodeData: any) => React.ReactNode;
26
+ renderTreeIcon?: (nodeData: any) => React.ReactNode;
27
+ renderTreeNode?: (nodeData: any) => React.ReactNode;
28
28
  onDragStart?: (data: any, event: React.DragEvent<any>) => void;
29
29
  onDragEnter?: (data: any, event: React.DragEvent<any>) => void;
30
30
  onDragOver?: (data: any, event: React.DragEvent<any>) => void;