@eleventheye/asui 2.7.2 → 2.7.3
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ASNavBarItem.d.ts","sourceRoot":"","sources":["../../../src/asnavbar/navbaritem/ASNavBarItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ASNavBarItem.d.ts","sourceRoot":"","sources":["../../../src/asnavbar/navbaritem/ASNavBarItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgG7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -8,6 +8,7 @@ const astheme_1 = tslib_1.__importDefault(require("../../astheme"));
|
|
|
8
8
|
const styles_1 = require("../styles");
|
|
9
9
|
const styles_2 = require("./styles");
|
|
10
10
|
const ASNavBarItem = ({ className = '', theme = astheme_1.default, displayText = '---', icon, selected = false, itemId, itemIndex = 0, size = apptypes_1.ComponentSize.Medium, onItemClick = () => undefined, onItemResized = () => undefined, }) => {
|
|
11
|
+
const tapDebounceRef = (0, react_1.useRef)('None');
|
|
11
12
|
const [navItemSizeInitialized, setNavSizeInitialized] = (0, react_1.useState)(false);
|
|
12
13
|
const navItemWidthRef = (0, react_1.useRef)(0);
|
|
13
14
|
const navBarItemRef = (0, react_1.useRef)(null);
|
|
@@ -44,6 +45,25 @@ const ASNavBarItem = ({ className = '', theme = astheme_1.default, displayText =
|
|
|
44
45
|
(0, react_1.useEffect)(() => {
|
|
45
46
|
isNavBarItemSelected.current = selected;
|
|
46
47
|
}, [selected]);
|
|
47
|
-
|
|
48
|
+
const onTap = (e) => {
|
|
49
|
+
if (tapDebounceRef.current === 'None') {
|
|
50
|
+
tapDebounceRef.current = 'Down';
|
|
51
|
+
const btnEl = e.currentTarget;
|
|
52
|
+
btnEl.ariaPressed = 'true';
|
|
53
|
+
onItemClickHandler(e);
|
|
54
|
+
btnEl.releasePointerCapture(e.pointerId);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onTapRelease = (e) => {
|
|
58
|
+
if (tapDebounceRef.current === 'Down') {
|
|
59
|
+
tapDebounceRef.current = 'Up';
|
|
60
|
+
const btnEl = e.currentTarget;
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
btnEl.ariaPressed = 'false';
|
|
63
|
+
tapDebounceRef.current = 'None';
|
|
64
|
+
}, 400);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(styles_2.ASNavBarItemStyled, { id: itemId, theme: theme, title: displayText, ref: navBarItemRef, className: `${className} ${size}`, "$selected": selected, onPointerDown: onTap, onPointerUp: onTapRelease, children: [icon && ((0, jsx_runtime_1.jsx)(styles_1.ASNavBarLeadingIconPadding, { theme: theme, "$selected": selected, "aria-invalid": true, "aria-hidden": true, children: icon })), displayText] }));
|
|
48
68
|
};
|
|
49
69
|
exports.default = ASNavBarItem;
|