@synerise/ds-utils 1.8.0 → 1.9.0

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,18 @@
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.9.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-utils@1.8.1...@synerise/ds-utils@1.9.0) (2026-05-22)
7
+
8
+ ### Features
9
+
10
+ - **modal:** migration from antd ([3588b65](https://github.com/synerise/synerise-design/commit/3588b65fbe67838fed4ee5125090ad47d334e04b))
11
+
12
+ ## [1.8.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-utils@1.8.0...@synerise/ds-utils@1.8.1) (2026-05-04)
13
+
14
+ ### Bug Fixes
15
+
16
+ - add exports field to all component packages for correct ESM detection ([6eccfde](https://github.com/synerise/synerise-design/commit/6eccfde8f2dd73c59860793231fbd7bcd61813b4))
17
+
6
18
  # [1.8.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-utils@1.7.1...@synerise/ds-utils@1.8.0) (2026-04-10)
7
19
 
8
20
  ### Features
package/README.md CHANGED
@@ -18,6 +18,7 @@ List of utils:
18
18
  - useCombinedRefs,
19
19
  - useDelimiterEscape,
20
20
  - useElementInView,
21
+ - useFocusTrap,
21
22
  - useIsMounted,
22
23
  - useKeyboardShortcuts,
23
24
  - useLatestRef,
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { useOnClickOutside, type HandledEventsType, } from './useOnClickOutside/
4
4
  export { renderWithHighlight } from './renderWithHighlight/renderWithHighlight';
5
5
  export { useStableId } from './useStableId/useStableId';
6
6
  export { useDebounce } from './useDebounce/useDebounce';
7
- export { default as selectColorByLetter } from './selectColorByLetter/selectColorByLetter';
7
+ export { default as selectColorByLetter, type ColorObject, } from './selectColorByLetter/selectColorByLetter';
8
8
  export { default as focusWithArrowKeys } from './focusWithArrowKeys/focusWithArrowKeys';
9
9
  export { default as escapeRegEx } from './regex/regex';
10
10
  export { default as doubleClickListener } from './doubleClickListener/doubleClickListener';
@@ -26,5 +26,6 @@ export * from './useTraceUpdate';
26
26
  export * from './getPopupContainer';
27
27
  export * from './useLatestRef';
28
28
  export * from './useDelimiterEscape/useDelimiterEscape';
29
+ export { useFocusTrap } from './useFocusTrap/useFocusTrap';
29
30
  export declare const NOOP: () => void;
30
31
  export type { DataAttributes, ExactlyOne, LiteralStringUnion, WithHTMLAttributes, DeepPartial, RequiredProps, ObjectStringKeys, } from './types/types';
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ import { useTraceUpdate } from "./useTraceUpdate/index.js";
27
27
  import { getClosest, getPopupContainer } from "./getPopupContainer/getPopupContainer.js";
28
28
  import { useLatestRef } from "./useLatestRef/useLatestRef.js";
29
29
  import { useDelimiterEscape } from "./useDelimiterEscape/useDelimiterEscape.js";
30
+ import { useFocusTrap } from "./useFocusTrap/useFocusTrap.js";
30
31
  const NOOP = () => {
31
32
  };
32
33
  export {
@@ -49,6 +50,7 @@ export {
49
50
  useDebounce,
50
51
  useDelimiterEscape,
51
52
  default13 as useElementInView,
53
+ useFocusTrap,
52
54
  useIsMounted,
53
55
  useKeyboardShortcuts,
54
56
  useLatestRef,
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'react';
2
+ export declare const useFocusTrap: (containerRef: RefObject<HTMLElement | null>, active: boolean) => void;
@@ -0,0 +1,46 @@
1
+ import { useEffect } from "react";
2
+ const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
3
+ const useFocusTrap = (containerRef, active) => {
4
+ useEffect(() => {
5
+ if (!active) {
6
+ return;
7
+ }
8
+ const container = containerRef.current;
9
+ if (!container) {
10
+ return;
11
+ }
12
+ const previouslyFocused = document.activeElement;
13
+ const focusable = container.querySelectorAll(FOCUSABLE_SELECTOR);
14
+ if (focusable.length > 0) {
15
+ focusable[0].focus();
16
+ } else {
17
+ container.focus();
18
+ }
19
+ const handleTabTrap = (e) => {
20
+ if (e.key !== "Tab") {
21
+ return;
22
+ }
23
+ const currentFocusable = container.querySelectorAll(FOCUSABLE_SELECTOR);
24
+ if (currentFocusable.length === 0) {
25
+ return;
26
+ }
27
+ const first = currentFocusable[0];
28
+ const last = currentFocusable[currentFocusable.length - 1];
29
+ if (e.shiftKey && document.activeElement === first) {
30
+ e.preventDefault();
31
+ last.focus();
32
+ } else if (!e.shiftKey && document.activeElement === last) {
33
+ e.preventDefault();
34
+ first.focus();
35
+ }
36
+ };
37
+ document.addEventListener("keydown", handleTabTrap);
38
+ return () => {
39
+ document.removeEventListener("keydown", handleTabTrap);
40
+ previouslyFocused?.focus();
41
+ };
42
+ }, [containerRef, active]);
43
+ };
44
+ export {
45
+ useFocusTrap
46
+ };
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@synerise/ds-utils",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Utils UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
7
7
  "main": "dist/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./dist/*.js": "./dist/*.js",
15
+ "./dist/*": "./dist/*.js"
16
+ },
8
17
  "files": [
9
18
  "/dist",
10
19
  "CHANGELOG.md",
@@ -21,6 +30,7 @@
21
30
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
22
31
  "prepublish": "pnpm run build",
23
32
  "test": "vitest run",
33
+ "test:watch": "vitest",
24
34
  "types": "tsc --noEmit",
25
35
  "check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
26
36
  "upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
@@ -34,11 +44,13 @@
34
44
  "latinize": "^0.5.0",
35
45
  "uuid": "^8.3.2"
36
46
  },
47
+ "devDependencies": {
48
+ "vitest": "^4"
49
+ },
37
50
  "peerDependencies": {
38
51
  "@synerise/ds-core": "^1",
39
52
  "react": ">=16.9.0 <= 18.3.1",
40
- "styled-components": "^5.3.3",
41
- "vitest": "4"
53
+ "styled-components": "^5.3.3"
42
54
  },
43
- "gitHead": "ce3c6d75efe8573a2b274853636f959b75a6cd32"
55
+ "gitHead": "f257f56d8991010593efd5ea9915335e813671a6"
44
56
  }