@rescui/menu 0.14.2-RUI-308-Fix-select-issues-405b9fa40.12 → 0.15.1

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.
@@ -1,132 +1,247 @@
1
1
  "use client";
2
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
- import { useState, useCallback, useRef, useEffect } from 'react';
2
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
3
+ import { c } from 'react-compiler-runtime';
4
+ import { useState, useRef, useEffect } from 'react';
4
5
  import { getFirstItem, getLastItem, getPrevItem, getNextItem, htmlElementsComparator } from './navigation-utils.js';
5
6
 
6
7
  function getSortedItems(itemsSet) {
7
8
  return Array.from(itemsSet.values()).sort(htmlElementsComparator);
8
9
  }
9
10
 
10
- function useMenuKeyboardNavigation(_ref) {
11
- let {
11
+ function useMenuKeyboardNavigation(t0) {
12
+ const $ = c(14);
13
+ const {
12
14
  activateFirstItem
13
- } = _ref;
15
+ } = t0;
14
16
  const [currentActiveItemEl, setCurrentActiveItemEl] = useState(null);
15
- const setCurrentActiveItemAndFocus = useCallback(function (el) {
16
- let {
17
- scroll = false
18
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
- setCurrentActiveItemEl(el ?? null);
20
-
21
- if (el) {
22
- el.focus({
23
- preventScroll: !scroll
24
- });
25
- }
26
- }, []);
27
- const menuItemsSet = useRef(new Set());
17
+ let t1;
18
+
19
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t1 = (el, t2) => {
21
+ const {
22
+ scroll: t3
23
+ } = t2 === undefined ? {} : t2;
24
+ const scroll = t3 === undefined ? false : t3;
25
+ setCurrentActiveItemEl(el ?? null);
26
+
27
+ if (el) {
28
+ el.focus({
29
+ preventScroll: !scroll
30
+ });
31
+ }
32
+ };
33
+
34
+ $[0] = t1;
35
+ } else {
36
+ t1 = $[0];
37
+ }
38
+
39
+ const setCurrentActiveItemAndFocus = t1;
40
+ let t2;
41
+
42
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
43
+ t2 = new Set();
44
+ $[1] = t2;
45
+ } else {
46
+ t2 = $[1];
47
+ }
48
+
49
+ const menuItemsSet = useRef(t2);
28
50
  const activateFirstItemTimeoutIdRef = useRef(null);
29
- const scheduleActivateFirstItem = useCallback(() => {
30
- if (activateFirstItemTimeoutIdRef.current) {
31
- clearTimeout(activateFirstItemTimeoutIdRef.current);
32
- }
33
-
34
- activateFirstItemTimeoutIdRef.current = setTimeout(() => {
35
- setCurrentActiveItemAndFocus(getFirstItem(getSortedItems(menuItemsSet.current)));
36
- }, 50);
37
- }, [setCurrentActiveItemAndFocus]);
38
- const registerItem = useCallback(ref => {
39
- if (!ref || menuItemsSet.current.has(ref)) {
40
- return;
41
- }
42
-
43
- menuItemsSet.current.add(ref);
44
-
45
- if (activateFirstItem) {
46
- scheduleActivateFirstItem();
47
- }
48
- }, [activateFirstItem, scheduleActivateFirstItem]);
49
- const unregisterItem = useCallback(ref => {
50
- menuItemsSet.current.delete(ref);
51
- }, []);
52
- useEffect(() => {
53
- return () => {
51
+ let t3;
52
+
53
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
54
+ t3 = () => {
55
+ if (activateFirstItemTimeoutIdRef.current) {
56
+ clearTimeout(activateFirstItemTimeoutIdRef.current);
57
+ }
58
+
59
+ activateFirstItemTimeoutIdRef.current = setTimeout(() => {
60
+ setCurrentActiveItemAndFocus(getFirstItem(getSortedItems(menuItemsSet.current)));
61
+ }, 50);
62
+ };
63
+
64
+ $[2] = t3;
65
+ } else {
66
+ t3 = $[2];
67
+ }
68
+
69
+ const scheduleActivateFirstItem = t3;
70
+ let t4;
71
+
72
+ if ($[3] !== activateFirstItem) {
73
+ t4 = ref => {
74
+ if (!ref || menuItemsSet.current.has(ref)) {
75
+ return;
76
+ }
77
+
78
+ menuItemsSet.current.add(ref);
79
+
80
+ if (activateFirstItem) {
81
+ scheduleActivateFirstItem();
82
+ }
83
+ };
84
+
85
+ $[3] = activateFirstItem;
86
+ $[4] = t4;
87
+ } else {
88
+ t4 = $[4];
89
+ }
90
+
91
+ const registerItem = t4;
92
+ let t5;
93
+
94
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
95
+ t5 = ref_0 => {
96
+ menuItemsSet.current.delete(ref_0);
97
+ };
98
+
99
+ $[5] = t5;
100
+ } else {
101
+ t5 = $[5];
102
+ }
103
+
104
+ const unregisterItem = t5;
105
+ let t6;
106
+ let t7;
107
+
108
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
109
+ t6 = () => () => {
54
110
  if (activateFirstItemTimeoutIdRef.current) {
55
111
  clearTimeout(activateFirstItemTimeoutIdRef.current);
56
112
  }
57
113
 
58
114
  menuItemsSet.current.clear();
59
115
  };
60
- }, []);
61
- const handleItemFocus = useCallback(ref => {
62
- if (!ref) {
63
- return;
64
- }
65
-
66
- setCurrentActiveItemEl(ref);
67
- }, [setCurrentActiveItemEl]);
68
- const handleItemKeyDown = useCallback( // eslint-disable-next-line complexity
69
- (e, ref) => {
70
- var _context;
71
-
72
- if (!_includesInstanceProperty(_context = ['ArrowDown', 'ArrowUp', 'Home', 'End', ' ', 'Enter']).call(_context, e.key)) {
73
- return;
74
- }
75
-
76
- const items = getSortedItems(menuItemsSet.current);
77
-
78
- switch (e.key) {
79
- case 'ArrowDown':
80
- e.preventDefault();
81
- setCurrentActiveItemAndFocus(getNextItem(items, ref), {
82
- scroll: true
83
- });
84
- break;
85
116
 
86
- case 'ArrowUp':
87
- e.preventDefault();
88
- setCurrentActiveItemAndFocus(getPrevItem(items, ref), {
89
- scroll: true
90
- });
91
- break;
117
+ t7 = [];
118
+ $[6] = t6;
119
+ $[7] = t7;
120
+ } else {
121
+ t6 = $[6];
122
+ t7 = $[7];
123
+ }
124
+
125
+ useEffect(t6, t7);
126
+ let t8;
127
+
128
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
129
+ t8 = ref_1 => {
130
+ if (!ref_1) {
131
+ return;
132
+ }
92
133
 
93
- case 'Home':
94
- e.preventDefault();
95
- setCurrentActiveItemAndFocus(getFirstItem(items), {
96
- scroll: true
97
- });
98
- break;
134
+ setCurrentActiveItemEl(ref_1);
135
+ };
99
136
 
100
- case 'End':
101
- e.preventDefault();
102
- setCurrentActiveItemAndFocus(getLastItem(items), {
103
- scroll: true
104
- });
105
- break;
106
-
107
- case ' ':
108
- case 'Enter':
109
- e.preventDefault();
110
- ref?.click?.();
111
- break;
112
- }
113
- }, [setCurrentActiveItemAndFocus]);
114
- const handleItemMouseEnter = useCallback(ref => {
115
- if (!ref) {
116
- return;
117
- }
118
-
119
- setCurrentActiveItemAndFocus(ref);
120
- }, [setCurrentActiveItemAndFocus]);
121
- return {
122
- currentActiveItemEl,
123
- setCurrentActiveItemEl,
124
- registerItem,
125
- unregisterItem,
126
- handleItemFocus,
127
- handleItemKeyDown,
128
- handleItemMouseEnter
129
- };
137
+ $[8] = t8;
138
+ } else {
139
+ t8 = $[8];
140
+ }
141
+
142
+ const handleItemFocus = t8;
143
+ let t9;
144
+
145
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
146
+ t9 = (e, ref_2) => {
147
+ var _context;
148
+
149
+ if (!_includesInstanceProperty(_context = ["ArrowDown", "ArrowUp", "Home", "End", " ", "Enter"]).call(_context, e.key)) {
150
+ return;
151
+ }
152
+
153
+ const items = getSortedItems(menuItemsSet.current);
154
+
155
+ bb44: switch (e.key) {
156
+ case "ArrowDown":
157
+ {
158
+ e.preventDefault();
159
+ setCurrentActiveItemAndFocus(getNextItem(items, ref_2), {
160
+ scroll: true
161
+ });
162
+ break bb44;
163
+ }
164
+
165
+ case "ArrowUp":
166
+ {
167
+ e.preventDefault();
168
+ setCurrentActiveItemAndFocus(getPrevItem(items, ref_2), {
169
+ scroll: true
170
+ });
171
+ break bb44;
172
+ }
173
+
174
+ case "Home":
175
+ {
176
+ e.preventDefault();
177
+ setCurrentActiveItemAndFocus(getFirstItem(items), {
178
+ scroll: true
179
+ });
180
+ break bb44;
181
+ }
182
+
183
+ case "End":
184
+ {
185
+ e.preventDefault();
186
+ setCurrentActiveItemAndFocus(getLastItem(items), {
187
+ scroll: true
188
+ });
189
+ break bb44;
190
+ }
191
+
192
+ case " ":
193
+ case "Enter":
194
+ {
195
+ e.preventDefault();
196
+ ref_2?.click?.();
197
+ break bb44;
198
+ }
199
+ }
200
+ };
201
+
202
+ $[9] = t9;
203
+ } else {
204
+ t9 = $[9];
205
+ }
206
+
207
+ const handleItemKeyDown = t9;
208
+ let t10;
209
+
210
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
211
+ t10 = ref_3 => {
212
+ if (!ref_3) {
213
+ return;
214
+ }
215
+
216
+ setCurrentActiveItemAndFocus(ref_3);
217
+ };
218
+
219
+ $[10] = t10;
220
+ } else {
221
+ t10 = $[10];
222
+ }
223
+
224
+ const handleItemMouseEnter = t10;
225
+ let t11;
226
+
227
+ if ($[11] !== currentActiveItemEl || $[12] !== registerItem) {
228
+ t11 = {
229
+ currentActiveItemEl,
230
+ setCurrentActiveItemEl,
231
+ registerItem,
232
+ unregisterItem,
233
+ handleItemFocus,
234
+ handleItemKeyDown,
235
+ handleItemMouseEnter
236
+ };
237
+ $[11] = currentActiveItemEl;
238
+ $[12] = registerItem;
239
+ $[13] = t11;
240
+ } else {
241
+ t11 = $[13];
242
+ }
243
+
244
+ return t11;
130
245
  }
131
246
 
132
247
  export { useMenuKeyboardNavigation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/menu",
3
- "version": "0.14.2-RUI-308-Fix-select-issues-405b9fa40.12+405b9fa40",
3
+ "version": "0.15.1",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -18,19 +18,19 @@
18
18
  "dependencies": {
19
19
  "@babel/runtime-corejs3": "^7.26.0",
20
20
  "classnames": "^2.2.6",
21
- "nanoid": "^3.3.3"
21
+ "react-compiler-runtime": "^1.0.0"
22
22
  },
23
23
  "peerDependencies": {
24
- "@rescui/ui-contexts": "^0.6.0",
24
+ "@rescui/ui-contexts": "^0.7.0",
25
25
  "prop-types": "^15",
26
- "react": ">=16.8.0 <20"
26
+ "react": ">=17.0.0 <20"
27
27
  },
28
28
  "devDependencies": {
29
- "@rescui/colors": "0.3.4-RUI-308-Fix-select-issues-405b9fa40.12+405b9fa40",
30
- "@rescui/postcss-preset-library": "0.2.3",
31
- "@rescui/scripts": "0.5.2",
32
- "@rescui/typography": "0.27.5-RUI-308-Fix-select-issues-405b9fa40.12+405b9fa40",
33
- "@rescui/visual-regression": "0.1.4",
29
+ "@rescui/colors": "^0.3.4",
30
+ "@rescui/postcss-preset-library": "^0.2.3",
31
+ "@rescui/scripts": "^0.5.3",
32
+ "@rescui/typography": "^0.28.1",
33
+ "@rescui/visual-regression": "^0.1.4",
34
34
  "postcss": "^8.3.0"
35
35
  },
36
36
  "scripts": {
@@ -38,5 +38,5 @@
38
38
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
39
39
  },
40
40
  "nx": {},
41
- "gitHead": "405b9fa40886b0ab6709c9185e8214599d2d792e"
41
+ "gitHead": "ce4c6c5e3fd5aede0006f6ef8e655fc0ab394c0f"
42
42
  }