@rescui/chip-list 0.13.5-RUI-280-Update-select-component-downshift-2f40ef205.67 → 0.13.6-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66
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/lib/chip-list-multi.d.ts +54 -45
- package/lib/chip-list-multi.js +9 -1
- package/lib/chip-list.d.ts +56 -29
- package/lib/chip-list.js +13 -0
- package/lib/index.css +65 -46
- package/lib/index.d.ts +6 -6
- package/lib/parts/chip-list-base.d.ts +31 -24
- package/lib/parts/chip-list-base.js +60 -4
- package/lib/parts/chip-list-context.d.ts +3 -4
- package/lib/parts/chip-list-context.js +2 -1
- package/lib/parts/chip-list.p.module.css.js +24 -23
- package/lib/parts/chip.d.ts +36 -34
- package/lib/parts/chip.js +91 -30
- package/lib/parts/deep-map.d.ts +2 -2
- package/lib/parts/types.d.ts +19 -9
- package/lib/parts/use-items-ids.d.ts +14 -10
- package/lib/parts/use-items-ids.js +64 -12
- package/lib/parts/use-roving-tab-index.d.ts +9 -0
- package/lib/parts/use-roving-tab-index.js +73 -0
- package/lib/parts/use-safe-id.d.ts +2 -0
- package/lib/parts/use-safe-id.js +15 -0
- package/package.json +4 -4
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
|
+
import React from 'react'; // eslint-disable-next-line complexity
|
|
3
|
+
|
|
4
|
+
const getNextItemId = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
currentItemId,
|
|
7
|
+
itemsCount,
|
|
8
|
+
key
|
|
9
|
+
} = _ref;
|
|
10
|
+
|
|
11
|
+
if (itemsCount <= 0) {
|
|
12
|
+
return currentItemId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (key === 'Home') {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (key === 'End') {
|
|
20
|
+
return itemsCount - 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (key === 'ArrowLeft') {
|
|
24
|
+
return currentItemId <= 0 ? itemsCount - 1 : currentItemId - 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (key === 'ArrowRight') {
|
|
28
|
+
return currentItemId >= itemsCount - 1 ? 0 : currentItemId + 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return currentItemId;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const useRovingTabIndex = _ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
enabled,
|
|
37
|
+
selectedId,
|
|
38
|
+
tabRefs
|
|
39
|
+
} = _ref2;
|
|
40
|
+
const [currentTabStopId, setCurrentTabStopId] = React.useState(selectedId ?? 0);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (typeof selectedId !== 'undefined') {
|
|
43
|
+
setCurrentTabStopId(selectedId);
|
|
44
|
+
}
|
|
45
|
+
}, [selectedId]);
|
|
46
|
+
const onTabKeyDown = React.useCallback((e, itemId) => {
|
|
47
|
+
var _context;
|
|
48
|
+
|
|
49
|
+
if (!enabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!_includesInstanceProperty(_context = ['ArrowLeft', 'ArrowRight', 'Home', 'End']).call(_context, e.key)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const itemsCount = tabRefs?.current.size ?? 0;
|
|
58
|
+
const nextItemId = getNextItemId({
|
|
59
|
+
currentItemId: itemId,
|
|
60
|
+
itemsCount,
|
|
61
|
+
key: e.key
|
|
62
|
+
});
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
setCurrentTabStopId(nextItemId);
|
|
65
|
+
tabRefs?.current.get(nextItemId)?.focus();
|
|
66
|
+
}, [enabled, tabRefs]);
|
|
67
|
+
return {
|
|
68
|
+
currentTabStopId,
|
|
69
|
+
onTabKeyDown
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { useRovingTabIndex };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const useFallbackId = () => {
|
|
4
|
+
const id = useRef(null);
|
|
5
|
+
|
|
6
|
+
if (id.current === null) {
|
|
7
|
+
id.current = useFallbackId.counter++;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return id.current.toString();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
useFallbackId.counter = 0;
|
|
14
|
+
const useSafeId = React.useId ?? useFallbackId;
|
|
15
|
+
export { useSafeId };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/chip-list",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"react": ">=16.8.0 <20"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@rescui/colors": "0.3.1-RUI-
|
|
27
|
+
"@rescui/colors": "0.3.1-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.79+8f54dec0a",
|
|
28
28
|
"@rescui/scripts": "0.5.1",
|
|
29
|
-
"@rescui/typography": "0.
|
|
29
|
+
"@rescui/typography": "0.25.1-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66+8f54dec0a",
|
|
30
30
|
"@rescui/visual-regression": "0.1.4"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
35
35
|
},
|
|
36
36
|
"nx": {},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "8f54dec0a450da30835485cba2edfd0037cccd25"
|
|
38
38
|
}
|