@rescui/chip-list 0.13.6 → 0.14.1-RUI-296-Build-docs-md-files-for-each-docs-section-2a311c841.18

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.
@@ -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,2 @@
1
+ import React from 'react';
2
+ export declare const useSafeId: typeof React.useId;
@@ -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.6",
3
+ "version": "0.14.1-RUI-296-Build-docs-md-files-for-each-docs-section-2a311c841.18+2a311c841",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -24,15 +24,15 @@
24
24
  "react": ">=16.8.0 <20"
25
25
  },
26
26
  "devDependencies": {
27
- "@rescui/colors": "^0.3.0",
28
- "@rescui/scripts": "^0.5.1",
29
- "@rescui/typography": "^0.26.0",
30
- "@rescui/visual-regression": "^0.1.4"
27
+ "@rescui/colors": "0.3.1-RUI-296-Build-docs-md-files-for-each-docs-section-2a311c841.53+2a311c841",
28
+ "@rescui/scripts": "0.5.2",
29
+ "@rescui/typography": "0.27.1-RUI-296-Build-docs-md-files-for-each-docs-section-2a311c841.18+2a311c841",
30
+ "@rescui/visual-regression": "0.1.4"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "rescui-scripts build && yarn run build-pcss-api",
34
34
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
35
35
  },
36
36
  "nx": {},
37
- "gitHead": "faa7a838502974c16bdf773ab001002d1b8dcca8"
37
+ "gitHead": "2a311c841551a48c46895aff5609fe099bbe1a61"
38
38
  }