@synerise/ds-utils 1.0.0 → 1.0.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-utils@1.0.0...@synerise/ds-utils@1.0.1) (2025-03-18)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-utils
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.32.3](https://github.com/synerise/synerise-design/compare/@synerise/ds-utils@0.32.2...@synerise/ds-utils@0.32.3) (2025-03-10)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-utils
@@ -14,7 +14,7 @@ var focusWithArrowKeys = function focusWithArrowKeys(keyDownEvent, focusableItem
14
14
  if (isItemFocused) {
15
15
  var nextSibling = activeElement.nextElementSibling;
16
16
  var hasFocusableChildren = hasFocusableElementInside(activeElement, selector);
17
- elementToFocusOn = nextSibling !== null && !hasFocusableChildren ? nextSibling : focusableElements[activeElementIndex + 1];
17
+ elementToFocusOn = nextSibling !== null && hasFocusableChildren ? nextSibling : focusableElements[activeElementIndex + 1];
18
18
  } else {
19
19
  elementToFocusOn = document.querySelector("." + focusableItemClass);
20
20
  }
@@ -30,7 +30,7 @@ var focusWithArrowKeys = function focusWithArrowKeys(keyDownEvent, focusableItem
30
30
  var _elementToFocusOn;
31
31
  if (isItemFocused) {
32
32
  var prevSibling = activeElement.previousElementSibling;
33
- _elementToFocusOn = prevSibling !== null && !hasFocusableElementInside(prevSibling, selector) ? prevSibling : focusableElements[activeElementIndex - 1];
33
+ _elementToFocusOn = prevSibling !== null && hasFocusableElementInside(prevSibling, selector) ? prevSibling : focusableElements[activeElementIndex - 1];
34
34
  }
35
35
  if (_elementToFocusOn) {
36
36
  _elementToFocusOn.focus();
package/dist/index.d.ts CHANGED
@@ -14,7 +14,9 @@ export { default as usePrevious } from './usePrevious/usePrevious';
14
14
  export { default as useElementInView } from './useElementInView/useElementInView';
15
15
  export { default as useOverscrollBlock } from './useOverscrollBlock/useOverscrollBlock';
16
16
  export { default as useResizeToFit } from './useResizeToFit/useResizeToFit';
17
+ export * from './useScrollContain/useScrollContain';
17
18
  export * from './useSearchResults';
19
+ export * from './useKeyboardShortcuts/useKeyboardShortcuts';
18
20
  export * from './omitKeys/omitKeys';
19
21
  export * from './useTraceUpdate';
20
22
  export * from './getPopupContainer';
package/dist/index.js CHANGED
@@ -14,7 +14,9 @@ export { default as usePrevious } from './usePrevious/usePrevious';
14
14
  export { default as useElementInView } from './useElementInView/useElementInView';
15
15
  export { default as useOverscrollBlock } from './useOverscrollBlock/useOverscrollBlock';
16
16
  export { default as useResizeToFit } from './useResizeToFit/useResizeToFit';
17
+ export * from './useScrollContain/useScrollContain';
17
18
  export * from './useSearchResults';
19
+ export * from './useKeyboardShortcuts/useKeyboardShortcuts';
18
20
  export * from './omitKeys/omitKeys';
19
21
  export * from './useTraceUpdate';
20
22
  export * from './getPopupContainer';
@@ -0,0 +1,3 @@
1
+ type ShortcutsConfig = Record<string, (event: KeyboardEvent) => void>;
2
+ export declare const useKeyboardShortcuts: (keyConfig: ShortcutsConfig) => void;
3
+ export {};
@@ -0,0 +1,12 @@
1
+ import { useEffect } from 'react';
2
+ export var useKeyboardShortcuts = function useKeyboardShortcuts(keyConfig) {
3
+ useEffect(function () {
4
+ var keyboardShortcuts = function keyboardShortcuts(event) {
5
+ keyConfig[event.key] && keyConfig[event.key](event);
6
+ };
7
+ document.addEventListener('keydown', keyboardShortcuts);
8
+ return function () {
9
+ document.removeEventListener('keydown', keyboardShortcuts);
10
+ };
11
+ }, [keyConfig]);
12
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useScrollContain: <ElementType extends HTMLElement>() => import("react").RefObject<ElementType>;
@@ -0,0 +1,19 @@
1
+ import { useEffect, useRef } from 'react';
2
+ export var useScrollContain = function useScrollContain() {
3
+ var elementRef = useRef(null);
4
+ useEffect(function () {
5
+ var blockWheel = function blockWheel(event) {
6
+ event.stopPropagation();
7
+ event.preventDefault();
8
+ };
9
+ var element;
10
+ if (elementRef.current) {
11
+ element = elementRef.current;
12
+ element.addEventListener('wheel', blockWheel);
13
+ }
14
+ return function () {
15
+ element && element.removeEventListener('wheel', blockWheel);
16
+ };
17
+ }, []);
18
+ return elementRef;
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Utils UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -41,5 +41,5 @@
41
41
  "react": ">=16.9.0 <= 18.3.1",
42
42
  "styled-components": "^5.3.3"
43
43
  },
44
- "gitHead": "e4c3690238a44b584b9ea41e4aa52b1eec42174b"
44
+ "gitHead": "218110f61f4371bc04d793b2b976b71d14e99e76"
45
45
  }