tycho-components 0.0.15-SNAPSHOT-7 → 0.0.15-SNAPSHOT-8

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,5 +1,8 @@
1
1
  declare const UsabilityUtils: {
2
2
  attachCloseToEscape: (handleClose: () => void) => () => void;
3
+ executeOnEnter: (event: React.KeyboardEvent<HTMLDivElement>, fn: () => void) => void;
4
+ isMobile: () => boolean;
5
+ goToAnchor: (anchorId: string, e: any) => void;
3
6
  isDesktop: () => boolean;
4
7
  };
5
8
  export default UsabilityUtils;
@@ -1,4 +1,11 @@
1
1
  const isDesktop = () => import.meta.env.VITE_APP_ENV === 'desktop';
2
+ const goToAnchor = (anchorId, e) => {
3
+ e.preventDefault();
4
+ const anchorElement = document.getElementById(anchorId);
5
+ if (anchorElement) {
6
+ anchorElement.scrollIntoView({ behavior: 'smooth' });
7
+ }
8
+ };
2
9
  const attachCloseToEscape = (handleClose) => {
3
10
  const closeOnEscape = (e) => {
4
11
  if (e.keyCode === 27)
@@ -7,8 +14,19 @@ const attachCloseToEscape = (handleClose) => {
7
14
  window.addEventListener('keydown', closeOnEscape);
8
15
  return () => window.removeEventListener('keydown', closeOnEscape);
9
16
  };
17
+ const executeOnEnter = (event, fn) => {
18
+ if (event.key === 'Enter') {
19
+ event.preventDefault();
20
+ event.stopPropagation();
21
+ fn();
22
+ }
23
+ };
24
+ const isMobile = () => window.innerWidth < 768;
10
25
  const UsabilityUtils = {
11
26
  attachCloseToEscape,
27
+ executeOnEnter,
28
+ isMobile,
29
+ goToAnchor,
12
30
  isDesktop,
13
31
  };
14
32
  export default UsabilityUtils;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.15-SNAPSHOT-7",
4
+ "version": "0.0.15-SNAPSHOT-8",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {