@ultraviolet/plus 0.19.2 → 0.20.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.
@@ -32,7 +32,8 @@ const NavigationContext = react.createContext({
32
32
  },
33
33
  allowNavigationResize: true,
34
34
  setAllowNavigationResize: () => {
35
- }
35
+ },
36
+ shouldAnimate: false
36
37
  });
37
38
  const useNavigation = () => react.useContext(NavigationContext);
38
39
  const NavigationProvider = ({
@@ -44,7 +45,8 @@ const NavigationProvider = ({
44
45
  pinLimit = 7,
45
46
  onExpandChange,
46
47
  initialWidth = constants.NAVIGATION_WIDTH,
47
- initialAllowNavigationResize = true
48
+ initialAllowNavigationResize = true,
49
+ animation: shouldAnimate = false
48
50
  }) => {
49
51
  const [expanded, setExpanded] = react.useState(initialExpanded);
50
52
  const [pinnedItems, setPinnedItems] = react.useState(initialPinned ?? []);
@@ -67,12 +69,16 @@ const NavigationProvider = ({
67
69
  if (navigationRef.current) {
68
70
  navigationRef.current.style.width = "";
69
71
  }
70
- setAnimation(expanded ? "collapse" : "expand");
71
- setTimeout(() => {
72
+ if (shouldAnimate) {
73
+ setAnimation(expanded ? "collapse" : "expand");
74
+ setTimeout(() => {
75
+ setExpanded(toggle !== void 0 ? toggle : !expanded);
76
+ setAnimation(false);
77
+ }, constants.ANIMATION_DURATION);
78
+ } else {
72
79
  setExpanded(toggle !== void 0 ? toggle : !expanded);
73
- setAnimation(false);
74
- }, constants.ANIMATION_DURATION);
75
- }, [expanded, onExpandChange, setAnimation, setExpanded]);
80
+ }
81
+ }, [expanded, onExpandChange, shouldAnimate]);
76
82
  const pinItem = react.useCallback((item) => {
77
83
  const newValue = [...pinnedItems, item];
78
84
  setPinnedItems(newValue);
@@ -109,8 +115,9 @@ const NavigationProvider = ({
109
115
  items,
110
116
  setPinnedItems,
111
117
  allowNavigationResize,
112
- setAllowNavigationResize
113
- }), [expanded, toggleExpand, pinnedItems, pinItem, unpinItem, pinnedFeature, locales, pinLimit, animation, width, reorderItems, items, allowNavigationResize]);
118
+ setAllowNavigationResize,
119
+ shouldAnimate
120
+ }), [expanded, toggleExpand, pinnedItems, pinItem, unpinItem, pinnedFeature, locales, pinLimit, animation, width, reorderItems, items, allowNavigationResize, shouldAnimate]);
114
121
  return /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value, children });
115
122
  };
116
123
  exports.NavigationContext = NavigationContext;
@@ -40,6 +40,7 @@ type ContextProps = {
40
40
  setPinnedItems: (value: string[]) => void;
41
41
  allowNavigationResize: boolean;
42
42
  setAllowNavigationResize: (value: boolean) => void;
43
+ shouldAnimate?: boolean;
43
44
  };
44
45
  export declare const NavigationContext: import("react").Context<ContextProps>;
45
46
  export declare const useNavigation: () => ContextProps;
@@ -75,6 +76,10 @@ type NavigationProviderProps = {
75
76
  * This boolean will define if the navigation can be resized or not.
76
77
  */
77
78
  initialAllowNavigationResize?: boolean;
79
+ /**
80
+ * Enable or disable the animation of the navigation
81
+ */
82
+ animation?: boolean;
78
83
  };
79
- export declare const NavigationProvider: ({ children, pinnedFeature, initialPinned, initialExpanded, locales, pinLimit, onExpandChange, initialWidth, initialAllowNavigationResize, }: NavigationProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
84
+ export declare const NavigationProvider: ({ children, pinnedFeature, initialPinned, initialExpanded, locales, pinLimit, onExpandChange, initialWidth, initialAllowNavigationResize, animation: shouldAnimate, }: NavigationProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
80
85
  export {};
@@ -30,7 +30,8 @@ const NavigationContext = createContext({
30
30
  },
31
31
  allowNavigationResize: true,
32
32
  setAllowNavigationResize: () => {
33
- }
33
+ },
34
+ shouldAnimate: false
34
35
  });
35
36
  const useNavigation = () => useContext(NavigationContext);
36
37
  const NavigationProvider = ({
@@ -42,7 +43,8 @@ const NavigationProvider = ({
42
43
  pinLimit = 7,
43
44
  onExpandChange,
44
45
  initialWidth = NAVIGATION_WIDTH,
45
- initialAllowNavigationResize = true
46
+ initialAllowNavigationResize = true,
47
+ animation: shouldAnimate = false
46
48
  }) => {
47
49
  const [expanded, setExpanded] = useState(initialExpanded);
48
50
  const [pinnedItems, setPinnedItems] = useState(initialPinned ?? []);
@@ -65,12 +67,16 @@ const NavigationProvider = ({
65
67
  if (navigationRef.current) {
66
68
  navigationRef.current.style.width = "";
67
69
  }
68
- setAnimation(expanded ? "collapse" : "expand");
69
- setTimeout(() => {
70
+ if (shouldAnimate) {
71
+ setAnimation(expanded ? "collapse" : "expand");
72
+ setTimeout(() => {
73
+ setExpanded(toggle !== void 0 ? toggle : !expanded);
74
+ setAnimation(false);
75
+ }, ANIMATION_DURATION);
76
+ } else {
70
77
  setExpanded(toggle !== void 0 ? toggle : !expanded);
71
- setAnimation(false);
72
- }, ANIMATION_DURATION);
73
- }, [expanded, onExpandChange, setAnimation, setExpanded]);
78
+ }
79
+ }, [expanded, onExpandChange, shouldAnimate]);
74
80
  const pinItem = useCallback((item) => {
75
81
  const newValue = [...pinnedItems, item];
76
82
  setPinnedItems(newValue);
@@ -107,8 +113,9 @@ const NavigationProvider = ({
107
113
  items,
108
114
  setPinnedItems,
109
115
  allowNavigationResize,
110
- setAllowNavigationResize
111
- }), [expanded, toggleExpand, pinnedItems, pinItem, unpinItem, pinnedFeature, locales, pinLimit, animation, width, reorderItems, items, allowNavigationResize]);
116
+ setAllowNavigationResize,
117
+ shouldAnimate
118
+ }), [expanded, toggleExpand, pinnedItems, pinItem, unpinItem, pinnedFeature, locales, pinLimit, animation, width, reorderItems, items, allowNavigationResize, shouldAnimate]);
112
119
  return /* @__PURE__ */ jsx(NavigationContext.Provider, { value, children });
113
120
  };
114
121
  export {