@timmbr/ui 1.3.0 → 1.3.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/dist/components/NavHeader/NavHeader.d.ts.map +1 -1
- package/dist/components/NavHeader/NavHeader.js +22 -7
- package/dist/components/NavHeader/subcomponents/NavActions.js +1 -1
- package/dist/components/NavHeader/subcomponents/NavBrand.d.ts.map +1 -1
- package/dist/components/NavHeader/subcomponents/NavBrand.js +5 -7
- package/dist/components/NavHeader/subcomponents/NavMegaMenu.js +2 -2
- package/dist/components/NavHeader/subcomponents/NavMobileSearchDrawer.js +4 -4
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavHeader.d.ts","sourceRoot":"","sources":["../../../src/components/NavHeader/NavHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"NavHeader.d.ts","sourceRoot":"","sources":["../../../src/components/NavHeader/NavHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,mBAAmB,CAAC;AAa3B,eAAO,MAAM,SAAS,oFAqpBrB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,MAAM,oFAAY,CAAC"}
|
|
@@ -65,16 +65,28 @@ const NavHeader = React.forwardRef(
|
|
|
65
65
|
const globalMotion = useGlobalAnimation();
|
|
66
66
|
const { shouldAnimate, motionClass } = resolveMotion(motionProp, globalMotion);
|
|
67
67
|
const isOfferBannerVisible = shorthandShowOfferBanner !== void 0 ? shorthandShowOfferBanner : typeof offerBanner === "object" && offerBanner !== null && "show" in offerBanner ? offerBanner.show ?? true : Boolean(offerBanner);
|
|
68
|
-
const navigationConfig =
|
|
69
|
-
|
|
68
|
+
const navigationConfig = React.useMemo(
|
|
69
|
+
() => Array.isArray(navigation) ? { items: navigation } : navigation ?? {},
|
|
70
|
+
[navigation]
|
|
71
|
+
);
|
|
72
|
+
const navItems = React.useMemo(
|
|
73
|
+
() => shorthandItems ?? navigationConfig.items ?? [],
|
|
74
|
+
[shorthandItems, navigationConfig.items]
|
|
75
|
+
);
|
|
70
76
|
const isNavItemsVisible = shorthandShowNavItems !== void 0 ? shorthandShowNavItems : navigationConfig.show ?? true;
|
|
71
|
-
const maxVisibleNavItems = shorthandMaxVisibleNavItems
|
|
77
|
+
const maxVisibleNavItems = shorthandMaxVisibleNavItems ?? navigationConfig.maxVisibleItems;
|
|
72
78
|
const controlledActiveId = shorthandActiveItemId !== void 0 ? shorthandActiveItemId : navigationConfig.activeItemId;
|
|
73
79
|
const defaultActiveItemId = shorthandDefaultActiveItemId !== void 0 ? shorthandDefaultActiveItemId : navigationConfig.defaultActiveItemId ?? null;
|
|
74
80
|
const onActiveItemChange = shorthandOnActiveItemChange ?? navigationConfig.onActiveItemChange;
|
|
75
|
-
const searchConfig =
|
|
81
|
+
const searchConfig = React.useMemo(
|
|
82
|
+
() => typeof search === "object" && search !== null ? search : {},
|
|
83
|
+
[search]
|
|
84
|
+
);
|
|
76
85
|
const isSearchVisible = shorthandShowSearch !== void 0 ? shorthandShowSearch : searchConfig.show ?? Boolean(search);
|
|
77
|
-
const actionsConfig =
|
|
86
|
+
const actionsConfig = React.useMemo(
|
|
87
|
+
() => Array.isArray(actions) ? { items: actions } : actions ?? {},
|
|
88
|
+
[actions]
|
|
89
|
+
);
|
|
78
90
|
const actionItems = actionsConfig.items;
|
|
79
91
|
const isActionsVisible = shorthandShowActions !== void 0 ? shorthandShowActions : actionsConfig.show ?? true;
|
|
80
92
|
const maxVisibleActions = shorthandMaxVisibleActions !== void 0 ? shorthandMaxVisibleActions : actionsConfig.maxVisible;
|
|
@@ -83,7 +95,10 @@ const NavHeader = React.forwardRef(
|
|
|
83
95
|
const profileAction = shorthandProfileAction ?? actionsConfig.profile;
|
|
84
96
|
const wishlistAction = shorthandWishlistAction ?? actionsConfig.wishlist;
|
|
85
97
|
const cartAction = shorthandCartAction ?? actionsConfig.cart;
|
|
86
|
-
const mobileConfig =
|
|
98
|
+
const mobileConfig = React.useMemo(
|
|
99
|
+
() => mobile ?? {},
|
|
100
|
+
[mobile]
|
|
101
|
+
);
|
|
87
102
|
const tabSliderOption = mobileConfig.tabSlider;
|
|
88
103
|
const tabSliderConfig = typeof tabSliderOption === "object" && tabSliderOption !== null ? tabSliderOption : {};
|
|
89
104
|
const isMobileTabSliderEnabled = shorthandMobileTabSlider !== void 0 ? shorthandMobileTabSlider : typeof tabSliderOption === "boolean" ? tabSliderOption : tabSliderConfig.show ?? true;
|
|
@@ -237,7 +252,7 @@ const NavHeader = React.forwardRef(
|
|
|
237
252
|
window.removeEventListener("resize", handleResize);
|
|
238
253
|
resizeObserver?.disconnect();
|
|
239
254
|
};
|
|
240
|
-
}, [maxVisibleActions, navItems.length, search]);
|
|
255
|
+
}, [maxVisibleActions, navItems.length, search, isSearchVisible]);
|
|
241
256
|
const [uncontrolledMobileActiveId, setUncontrolledMobileActiveId] = React.useState(
|
|
242
257
|
defaultMobileActiveItemId
|
|
243
258
|
);
|
|
@@ -111,7 +111,7 @@ const NavActions = ({
|
|
|
111
111
|
if (items.length <= limit) {
|
|
112
112
|
return { visibleActions: items, overflowActions: [] };
|
|
113
113
|
}
|
|
114
|
-
const countToKeep =
|
|
114
|
+
const countToKeep = Math.max(1, limit - 1);
|
|
115
115
|
const hasPriorities = items.some((i) => i.priority);
|
|
116
116
|
if (!hasPriorities) {
|
|
117
117
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavBrand.d.ts","sourceRoot":"","sources":["../../../../src/components/NavHeader/subcomponents/NavBrand.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"NavBrand.d.ts","sourceRoot":"","sources":["../../../../src/components/NavHeader/subcomponents/NavBrand.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiG5C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -41,19 +41,17 @@ const NavBrand = ({
|
|
|
41
41
|
children: logo
|
|
42
42
|
}
|
|
43
43
|
),
|
|
44
|
-
|
|
44
|
+
showMini && /* @__PURE__ */ jsx(
|
|
45
45
|
motion.div,
|
|
46
46
|
{
|
|
47
|
-
initial: false,
|
|
47
|
+
initial: shouldAnimate ? { opacity: 0, scale: 0.92 } : false,
|
|
48
48
|
animate: shouldAnimate ? {
|
|
49
|
-
opacity:
|
|
50
|
-
scale:
|
|
49
|
+
opacity: 1,
|
|
50
|
+
scale: 1
|
|
51
51
|
} : void 0,
|
|
52
52
|
transition: { duration: 0.2, ease: [0.16, 1, 0.3, 1] },
|
|
53
53
|
className: cn(
|
|
54
|
-
"absolute inset-0 flex items-center justify-center shrink-0",
|
|
55
|
-
showMini ? "pointer-events-auto" : "pointer-events-none",
|
|
56
|
-
!shouldAnimate && (showMini ? "opacity-100" : "opacity-0"),
|
|
54
|
+
"absolute inset-0 flex items-center justify-center shrink-0 pointer-events-auto",
|
|
57
55
|
motionClass
|
|
58
56
|
),
|
|
59
57
|
children: miniLogo
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { AnimatePresence, motion,
|
|
4
|
+
import { AnimatePresence, motion, fadeSlideDownVariants, getTransition } from '@timmbr/motion';
|
|
5
5
|
import { cn } from '@timmbr/utils';
|
|
6
6
|
import { megaMenuCardVariants } from '../NavHeader.styles.js';
|
|
7
7
|
|
|
@@ -50,7 +50,7 @@ const NavMegaMenu = ({
|
|
|
50
50
|
initial: shouldAnimate ? "hidden" : false,
|
|
51
51
|
animate: shouldAnimate ? "visible" : void 0,
|
|
52
52
|
exit: shouldAnimate ? "exit" : void 0,
|
|
53
|
-
variants: shouldAnimate ?
|
|
53
|
+
variants: shouldAnimate ? fadeSlideDownVariants : void 0,
|
|
54
54
|
transition: getTransition("fast"),
|
|
55
55
|
style: widthStyle,
|
|
56
56
|
"data-slot": "nav-megamenu-card",
|
|
@@ -71,10 +71,10 @@ const NavMobileSearchDrawer = ({
|
|
|
71
71
|
role: "dialog",
|
|
72
72
|
"aria-modal": "true",
|
|
73
73
|
"aria-label": "Search drawer",
|
|
74
|
-
initial: shouldAnimate ? { opacity: 0, y: "
|
|
75
|
-
animate: shouldAnimate ? { opacity: 1, y: 0 } : void 0,
|
|
76
|
-
exit: shouldAnimate ? { opacity: 0, y: "
|
|
77
|
-
transition: { duration: 0.
|
|
74
|
+
initial: shouldAnimate ? { opacity: 0, y: "100%" } : false,
|
|
75
|
+
animate: shouldAnimate ? { opacity: 1, y: "0%" } : void 0,
|
|
76
|
+
exit: shouldAnimate ? { opacity: 0, y: "100%" } : void 0,
|
|
77
|
+
transition: { duration: 0.28, ease: [0.32, 0.72, 0, 1] },
|
|
78
78
|
className: cn(mobileSearchDrawerVariants(), motionClass),
|
|
79
79
|
"data-slot": "nav-mobile-search-drawer",
|
|
80
80
|
children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timmbr/ui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "High-performance, Next.js App Router-compatible UI design system components for Timmbr",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@radix-ui/react-tooltip": "^1.2.16",
|
|
43
43
|
"class-variance-authority": "^0.7.1",
|
|
44
44
|
"@timmbr/hooks": "1.0.0-beta",
|
|
45
|
-
"@timmbr/
|
|
45
|
+
"@timmbr/motion": "1.1.0",
|
|
46
46
|
"@timmbr/utils": "1.1.0",
|
|
47
47
|
"@timmbr/icons": "1.2.0",
|
|
48
|
-
"@timmbr/
|
|
48
|
+
"@timmbr/theme": "1.1.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"next": ">=13.0.0 || >=14.0.0 || >=15.0.0 || >=16.0.0",
|