@synerise/ds-tray 1.1.42 → 1.1.43

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,12 @@
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.1.43](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tray@1.1.42...@synerise/ds-tray@1.1.43) (2026-06-27)
7
+
8
+ ### Bug Fixes
9
+
10
+ - memoize TrayProvider context value and useTray result ([d06d9f3](https://github.com/Synerise/synerise-design/commit/d06d9f3f5226c832945d185f9f0cb0b8b6664390))
11
+
6
12
  ## [1.1.42](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tray@1.1.41...@synerise/ds-tray@1.1.42) (2026-06-17)
7
13
 
8
14
  **Note:** Version bump only for package @synerise/ds-tray
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useState, useCallback, useMemo } from "react";
3
3
  import { TrayContext } from "../contexts/TrayContext.js";
4
4
  const TrayProvider = ({
5
5
  children
6
6
  }) => {
7
7
  const [trayState, setTrayState] = useState({});
8
- const openTray = (id, data) => {
8
+ const openTray = useCallback((id, data) => {
9
9
  setTrayState((prev) => ({
10
10
  ...prev,
11
11
  [id]: {
@@ -13,8 +13,8 @@ const TrayProvider = ({
13
13
  data
14
14
  }
15
15
  }));
16
- };
17
- const closeTray = (id) => {
16
+ }, []);
17
+ const closeTray = useCallback((id) => {
18
18
  setTrayState((prev) => ({
19
19
  ...prev,
20
20
  [id]: {
@@ -22,18 +22,19 @@ const TrayProvider = ({
22
22
  isOpen: false
23
23
  }
24
24
  }));
25
- };
26
- const getTrayState = (id) => {
25
+ }, []);
26
+ const getTrayState = useCallback((id) => {
27
27
  return trayState[id] || {
28
28
  isOpen: false,
29
29
  data: null
30
30
  };
31
- };
32
- return /* @__PURE__ */ jsx(TrayContext.Provider, { value: {
31
+ }, [trayState]);
32
+ const value = useMemo(() => ({
33
33
  openTray,
34
34
  closeTray,
35
35
  getTrayState
36
- }, children });
36
+ }), [openTray, closeTray, getTrayState]);
37
+ return /* @__PURE__ */ jsx(TrayContext.Provider, { value, children });
37
38
  };
38
39
  export {
39
40
  TrayProvider
@@ -1,13 +1,14 @@
1
+ import { useMemo } from "react";
1
2
  import { useTrayContext } from "./useTrayContext.js";
2
3
  const useTray = () => {
3
4
  const {
4
5
  openTray,
5
6
  closeTray
6
7
  } = useTrayContext();
7
- return {
8
+ return useMemo(() => ({
8
9
  open: openTray,
9
10
  close: closeTray
10
- };
11
+ }), [openTray, closeTray]);
11
12
  };
12
13
  export {
13
14
  useTray
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-tray",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "Tray UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -52,5 +52,5 @@
52
52
  "styled-components": "^5.3.3",
53
53
  "vitest": "4"
54
54
  },
55
- "gitHead": "d8c64070f58f14e3fb1bfbcbf00d1e3b8fd51eb8"
55
+ "gitHead": "dfd892acc1d02abebcf661db3fb32f0fc4b6c354"
56
56
  }