@timmbr/ui 1.1.0 → 1.3.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/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/Alert/Alert.types.d.ts +2 -4
- package/dist/components/Alert/Alert.types.d.ts.map +1 -1
- package/dist/components/AlertDialog/AlertDialog.d.ts +16 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts.map +1 -0
- package/dist/components/AlertDialog/AlertDialog.js +94 -0
- package/dist/components/AlertDialog/AlertDialog.styles.d.ts +8 -0
- package/dist/components/AlertDialog/AlertDialog.styles.d.ts.map +1 -0
- package/dist/components/AlertDialog/AlertDialog.styles.js +25 -0
- package/dist/components/AlertDialog/AlertDialog.types.d.ts +16 -0
- package/dist/components/AlertDialog/AlertDialog.types.d.ts.map +1 -0
- package/dist/components/AlertDialog/index.d.ts +4 -0
- package/dist/components/AlertDialog/index.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.styles.d.ts +1 -1
- package/dist/components/Dialog/Dialog.d.ts +2 -1
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.js +8 -6
- package/dist/components/Dialog/Dialog.styles.d.ts +1 -0
- package/dist/components/Dialog/Dialog.styles.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.styles.js +7 -4
- package/dist/components/Dialog/Dialog.types.d.ts +4 -6
- package/dist/components/Dialog/Dialog.types.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.types.d.ts +3 -6
- package/dist/components/Drawer/Drawer.types.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.types.d.ts +1 -2
- package/dist/components/Dropdown/Dropdown.types.d.ts.map +1 -1
- package/dist/components/FormField/FormField.js +3 -3
- package/dist/components/ImageUpload/ImageUpload.d.ts +4 -0
- package/dist/components/ImageUpload/ImageUpload.d.ts.map +1 -0
- package/dist/components/ImageUpload/ImageUpload.helpers.d.ts +30 -0
- package/dist/components/ImageUpload/ImageUpload.helpers.d.ts.map +1 -0
- package/dist/components/ImageUpload/ImageUpload.helpers.js +95 -0
- package/dist/components/ImageUpload/ImageUpload.js +365 -0
- package/dist/components/ImageUpload/ImageUpload.styles.d.ts +17 -0
- package/dist/components/ImageUpload/ImageUpload.styles.d.ts.map +1 -0
- package/dist/components/ImageUpload/ImageUpload.styles.js +72 -0
- package/dist/components/ImageUpload/ImageUpload.types.d.ts +112 -0
- package/dist/components/ImageUpload/ImageUpload.types.d.ts.map +1 -0
- package/dist/components/ImageUpload/index.d.ts +6 -0
- package/dist/components/ImageUpload/index.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadDropzone.d.ts +25 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadDropzone.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadDropzone.js +106 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadIcons.d.ts +6 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadIcons.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadIcons.js +61 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadModal.d.ts +12 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadModal.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadModal.js +137 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadSinglePreview.d.ts +14 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadSinglePreview.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadSinglePreview.js +142 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadThumbnailCard.d.ts +23 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadThumbnailCard.d.ts.map +1 -0
- package/dist/components/ImageUpload/subcomponents/ImageUploadThumbnailCard.js +139 -0
- package/dist/components/ImageUpload/subcomponents/index.d.ts +6 -0
- package/dist/components/ImageUpload/subcomponents/index.d.ts.map +1 -0
- package/dist/components/Input/Input.js +3 -3
- package/dist/components/List/List.types.d.ts +2 -4
- package/dist/components/List/List.types.d.ts.map +1 -1
- package/dist/components/NavHeader/NavHeader.context.d.ts +20 -0
- package/dist/components/NavHeader/NavHeader.context.d.ts.map +1 -0
- package/dist/components/NavHeader/NavHeader.context.js +13 -0
- package/dist/components/NavHeader/NavHeader.d.ts +8 -0
- package/dist/components/NavHeader/NavHeader.d.ts.map +1 -0
- package/dist/components/NavHeader/NavHeader.helpers.d.ts +13 -0
- package/dist/components/NavHeader/NavHeader.helpers.d.ts.map +1 -0
- package/dist/components/NavHeader/NavHeader.helpers.js +14 -0
- package/dist/components/NavHeader/NavHeader.js +532 -0
- package/dist/components/NavHeader/NavHeader.styles.d.ts +67 -0
- package/dist/components/NavHeader/NavHeader.styles.d.ts.map +1 -0
- package/dist/components/NavHeader/NavHeader.styles.js +123 -0
- package/dist/components/NavHeader/NavHeader.types.d.ts +321 -0
- package/dist/components/NavHeader/NavHeader.types.d.ts.map +1 -0
- package/dist/components/NavHeader/index.d.ts +11 -0
- package/dist/components/NavHeader/index.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavActionOverflow.d.ts +13 -0
- package/dist/components/NavHeader/subcomponents/NavActionOverflow.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavActionOverflow.js +169 -0
- package/dist/components/NavHeader/subcomponents/NavActions.d.ts +22 -0
- package/dist/components/NavHeader/subcomponents/NavActions.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavActions.js +228 -0
- package/dist/components/NavHeader/subcomponents/NavBrand.d.ts +12 -0
- package/dist/components/NavHeader/subcomponents/NavBrand.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavBrand.js +96 -0
- package/dist/components/NavHeader/subcomponents/NavItems.d.ts +15 -0
- package/dist/components/NavHeader/subcomponents/NavItems.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavItems.js +141 -0
- package/dist/components/NavHeader/subcomponents/NavItemsOverflow.d.ts +13 -0
- package/dist/components/NavHeader/subcomponents/NavItemsOverflow.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavItemsOverflow.js +165 -0
- package/dist/components/NavHeader/subcomponents/NavMegaMenu.d.ts +12 -0
- package/dist/components/NavHeader/subcomponents/NavMegaMenu.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavMegaMenu.js +73 -0
- package/dist/components/NavHeader/subcomponents/NavMobileSearchDrawer.d.ts +16 -0
- package/dist/components/NavHeader/subcomponents/NavMobileSearchDrawer.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavMobileSearchDrawer.js +149 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabContent.d.ts +11 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabContent.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabContent.js +40 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabSlider.d.ts +13 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabSlider.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavMobileTabSlider.js +111 -0
- package/dist/components/NavHeader/subcomponents/NavSearch.d.ts +15 -0
- package/dist/components/NavHeader/subcomponents/NavSearch.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/NavSearch.js +222 -0
- package/dist/components/NavHeader/subcomponents/OfferBanner.d.ts +11 -0
- package/dist/components/NavHeader/subcomponents/OfferBanner.d.ts.map +1 -0
- package/dist/components/NavHeader/subcomponents/OfferBanner.js +92 -0
- package/dist/components/Popover/Popover.types.d.ts +1 -2
- package/dist/components/Popover/Popover.types.d.ts.map +1 -1
- package/dist/components/Radio/Radio.js +3 -3
- package/dist/components/Select/Select.js +3 -3
- package/dist/components/Stat/Stat.types.d.ts +3 -6
- package/dist/components/Stat/Stat.types.d.ts.map +1 -1
- package/dist/components/Table/Table.types.d.ts +7 -14
- package/dist/components/Table/Table.types.d.ts.map +1 -1
- package/dist/components/Textarea/Textarea.js +3 -3
- package/dist/components/Toast/Toast.js +1 -1
- package/dist/components/Toast/Toast.types.d.ts +1 -2
- package/dist/components/Toast/Toast.types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -2
- package/package.json +5 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
const offerBannerVariants = cva(
|
|
4
|
+
"w-full bg-[#1A1714] text-[#F7F1E6] font-title text-xs font-semibold uppercase tracking-[0.14em] py-2 px-4 flex items-center justify-center relative transition-all duration-200 z-50 border-b border-black/20"
|
|
5
|
+
);
|
|
6
|
+
const navHeaderVariants = cva(
|
|
7
|
+
"w-full bg-[var(--color-bg-2,#F7F1E6)] text-[var(--color-grey-800,#3C3C3C)] border-b border-[#E7DFD3] relative z-40 transition-colors",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
sticky: {
|
|
11
|
+
true: "sticky top-0 shadow-sm backdrop-blur-md bg-[var(--color-bg-2,#F7F1E6)]/95",
|
|
12
|
+
false: "relative"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
sticky: false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
const navHeaderContainerVariants = cva(
|
|
21
|
+
"mx-auto px-4 sm:px-6 lg:px-8 h-[74px] flex items-center justify-between gap-4 lg:gap-8 transition-all",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
maxWidth: {
|
|
25
|
+
sm: "max-w-screen-sm",
|
|
26
|
+
md: "max-w-screen-md",
|
|
27
|
+
lg: "max-w-screen-lg",
|
|
28
|
+
xl: "max-w-[1280px]",
|
|
29
|
+
"2xl": "max-w-[1440px]",
|
|
30
|
+
full: "max-w-full"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
maxWidth: "2xl"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const navHeaderItemVariants = cva(
|
|
39
|
+
"font-sans font-bold text-[13.5px] xl:text-[14.5px] 2xl:text-[15px] text-[#404040] hover:text-[#C0643A] transition-colors relative py-2 px-1 xl:px-1.5 flex items-center gap-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded select-none cursor-pointer whitespace-nowrap",
|
|
40
|
+
{
|
|
41
|
+
variants: {
|
|
42
|
+
active: {
|
|
43
|
+
true: "text-[#C0643A]",
|
|
44
|
+
false: "text-[#404040]"
|
|
45
|
+
},
|
|
46
|
+
disabled: {
|
|
47
|
+
true: "opacity-40 cursor-not-allowed pointer-events-none",
|
|
48
|
+
false: ""
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
active: false,
|
|
53
|
+
disabled: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
const navActionVariants = cva(
|
|
58
|
+
"group flex flex-col items-center justify-center gap-[3.5px] min-w-[36px] sm:min-w-[40px] lg:min-w-[52px] text-[#3C3C3C] hover:text-[#C0643A] transition-colors relative focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 rounded py-1 px-1 lg:px-1.5 select-none cursor-pointer",
|
|
59
|
+
{
|
|
60
|
+
variants: {
|
|
61
|
+
active: {
|
|
62
|
+
true: "text-[#C0643A]",
|
|
63
|
+
false: "text-[#3C3C3C]"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
defaultVariants: {
|
|
67
|
+
active: false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
const megaMenuCardVariants = cva(
|
|
72
|
+
"w-full max-w-[1216px] mx-auto bg-[#FFFFFE] border border-grey-200/80 shadow-2xl rounded-b-xl z-50 overflow-hidden"
|
|
73
|
+
);
|
|
74
|
+
const searchPopoverCardVariants = cva(
|
|
75
|
+
"absolute top-full left-0 right-0 w-full mt-2 bg-white border border-grey-200 shadow-2xl rounded-2xl p-4 sm:p-5 z-50 text-left"
|
|
76
|
+
);
|
|
77
|
+
const actionOverflowPopoverVariants = cva(
|
|
78
|
+
"absolute top-full right-0 mt-3 w-60 bg-white border border-[#E7DFD3] shadow-2xl rounded-2xl p-2 z-50 text-left overflow-hidden divide-y divide-grey-100"
|
|
79
|
+
);
|
|
80
|
+
const actionOverflowItemVariants = cva(
|
|
81
|
+
"w-full flex items-center justify-between gap-3 px-3 py-2.5 text-xs font-semibold text-[#3C3C3C] hover:text-[#C0643A] hover:bg-[#F7F1E6]/60 rounded-xl transition-colors cursor-pointer text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#C0643A]",
|
|
82
|
+
{
|
|
83
|
+
variants: {
|
|
84
|
+
disabled: {
|
|
85
|
+
true: "opacity-40 cursor-not-allowed pointer-events-none",
|
|
86
|
+
false: ""
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
defaultVariants: {
|
|
90
|
+
disabled: false
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
const mobileTabSliderVariants = cva(
|
|
95
|
+
"w-full overflow-x-auto flex items-center gap-6 px-4 py-2 border-b border-[#E7DFD3] bg-[var(--color-bg-2,#F7F1E6)] select-none scroll-smooth [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"
|
|
96
|
+
);
|
|
97
|
+
const mobileTabItemVariants = cva(
|
|
98
|
+
"relative font-sans text-xs sm:text-sm tracking-tight whitespace-nowrap py-1.5 px-1 font-semibold transition-colors cursor-pointer select-none",
|
|
99
|
+
{
|
|
100
|
+
variants: {
|
|
101
|
+
active: {
|
|
102
|
+
true: "text-[#C0643A] font-bold",
|
|
103
|
+
false: "text-grey-600 hover:text-grey-900"
|
|
104
|
+
},
|
|
105
|
+
disabled: {
|
|
106
|
+
true: "opacity-40 cursor-not-allowed pointer-events-none",
|
|
107
|
+
false: ""
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
defaultVariants: {
|
|
111
|
+
active: false,
|
|
112
|
+
disabled: false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
const mobileTabContentPanelVariants = cva(
|
|
117
|
+
"w-full bg-[#FFFFFE] border-b border-[#E7DFD3] shadow-md overflow-hidden"
|
|
118
|
+
);
|
|
119
|
+
const mobileSearchDrawerVariants = cva(
|
|
120
|
+
"fixed inset-0 z-[9999] h-[100dvh] w-screen bg-[var(--color-bg-2,#F7F1E6)] flex flex-col overflow-hidden"
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
export { actionOverflowItemVariants, actionOverflowPopoverVariants, megaMenuCardVariants, mobileSearchDrawerVariants, mobileTabContentPanelVariants, mobileTabItemVariants, mobileTabSliderVariants, navActionVariants, navHeaderContainerVariants, navHeaderItemVariants, navHeaderVariants, offerBannerVariants, searchPopoverCardVariants };
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { MotionProp, MotionProps } from '../../types/motion';
|
|
3
|
+
/**
|
|
4
|
+
* Offer / Announcement banner configuration shown above the navigation header.
|
|
5
|
+
*/
|
|
6
|
+
export interface OfferBannerConfig {
|
|
7
|
+
/** Master toggle to show or hide the offer banner */
|
|
8
|
+
show?: boolean;
|
|
9
|
+
/** Text or content displayed in the offer banner */
|
|
10
|
+
content: React.ReactNode;
|
|
11
|
+
/** Optional destination link href */
|
|
12
|
+
href?: string;
|
|
13
|
+
/** Target zone key corresponding to TimmbrConfigProvider zones (e.g. 'store', 'docs') */
|
|
14
|
+
zone?: string;
|
|
15
|
+
/** If true, navigation will be treated as cross-zone */
|
|
16
|
+
crossZone?: boolean;
|
|
17
|
+
/** Whether the banner includes a dismiss button */
|
|
18
|
+
dismissible?: boolean;
|
|
19
|
+
/** Callback fired when user clicks the dismiss button */
|
|
20
|
+
onDismiss?: () => void;
|
|
21
|
+
/** Optional right-side CTA button or coupon element */
|
|
22
|
+
action?: React.ReactNode;
|
|
23
|
+
/** Custom background or text className */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Branding configuration for the header logo.
|
|
28
|
+
*/
|
|
29
|
+
export interface NavHeaderBranding {
|
|
30
|
+
/** Full brand logo shown when search is closed */
|
|
31
|
+
logo: React.ReactNode;
|
|
32
|
+
/** Compact or mini brand logo shown when search expands */
|
|
33
|
+
miniLogo?: React.ReactNode;
|
|
34
|
+
/** Destination link for the brand logo. Defaults to '/' */
|
|
35
|
+
href?: string;
|
|
36
|
+
/** Target zone key for cross-zone branding link */
|
|
37
|
+
zone?: string;
|
|
38
|
+
/** Accessible label or alt text */
|
|
39
|
+
alt?: string;
|
|
40
|
+
/** Custom logo wrapper className */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Click handler for branding */
|
|
43
|
+
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Individual navigation item.
|
|
47
|
+
* Supports direct links (internal or cross-zone) OR rich popover / mega-menu dropdowns.
|
|
48
|
+
*/
|
|
49
|
+
export interface NavHeaderItem {
|
|
50
|
+
/** Unique identifier for the item */
|
|
51
|
+
id: string;
|
|
52
|
+
/** Label displayed on the navbar */
|
|
53
|
+
label: React.ReactNode;
|
|
54
|
+
/** Optional link destination. If omitted and content is provided, item acts as popover trigger */
|
|
55
|
+
href?: string;
|
|
56
|
+
/** Target zone for cross-zone navigation */
|
|
57
|
+
zone?: string;
|
|
58
|
+
/** Explicit flag to force cross-zone navigation */
|
|
59
|
+
crossZone?: boolean;
|
|
60
|
+
/** Rich popover or mega-menu content. If provided, renders dropdown below header */
|
|
61
|
+
content?: React.ReactNode;
|
|
62
|
+
/** Width mode of the popover: 'container' (1216px centered), 'full' (100vw), 'dropdown' (anchor-aligned), or explicit number */
|
|
63
|
+
popoverWidth?: 'container' | 'full' | 'dropdown' | number;
|
|
64
|
+
/** Optional badge displayed adjacent to the label */
|
|
65
|
+
badge?: React.ReactNode;
|
|
66
|
+
/** Whether this item is visually disabled */
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** Accessible aria-label for the nav item */
|
|
69
|
+
ariaLabel?: string;
|
|
70
|
+
/** Custom className for the nav item trigger */
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Popular search chip/tag configuration.
|
|
75
|
+
*/
|
|
76
|
+
export interface PopularSearchTag {
|
|
77
|
+
id?: string;
|
|
78
|
+
label: string;
|
|
79
|
+
href?: string;
|
|
80
|
+
zone?: string;
|
|
81
|
+
onClick?: (tag: PopularSearchTag) => void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for the expandable search bar and its suggestions popover.
|
|
85
|
+
*/
|
|
86
|
+
export interface NavSearchConfig {
|
|
87
|
+
/** Master toggle to show or hide the search feature and trigger */
|
|
88
|
+
show?: boolean;
|
|
89
|
+
/** Search input placeholder text */
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
/** Controlled search input value */
|
|
92
|
+
value?: string;
|
|
93
|
+
/** Uncontrolled default search input value */
|
|
94
|
+
defaultValue?: string;
|
|
95
|
+
/** Callback fired when search input value changes */
|
|
96
|
+
onChange?: (value: string) => void;
|
|
97
|
+
/** Callback fired when user submits search (e.g. presses Enter) */
|
|
98
|
+
onSubmit?: (query: string) => void;
|
|
99
|
+
/** Controlled open state for search expansion */
|
|
100
|
+
isOpen?: boolean;
|
|
101
|
+
/** Uncontrolled default open state */
|
|
102
|
+
defaultOpen?: boolean;
|
|
103
|
+
/** Callback fired when search expands or collapses */
|
|
104
|
+
onOpenChange?: (open: boolean) => void;
|
|
105
|
+
/** Custom popover content rendered below the search input */
|
|
106
|
+
popoverContent?: React.ReactNode;
|
|
107
|
+
/** Custom suggestions node rendered inside search drawer */
|
|
108
|
+
suggestions?: React.ReactNode;
|
|
109
|
+
/** Optional preconfigured popular search suggestions */
|
|
110
|
+
popularSearches?: PopularSearchTag[];
|
|
111
|
+
/** Title for the popular searches section. Defaults to "Popular Searches" */
|
|
112
|
+
popularSearchesTitle?: string;
|
|
113
|
+
/** Callback fired when user clicks a popular search chip */
|
|
114
|
+
onPopularSearchClick?: (tag: PopularSearchTag) => void;
|
|
115
|
+
/** Custom aria-label for search input */
|
|
116
|
+
ariaLabel?: string;
|
|
117
|
+
/** Display mode for search on mobile/tablet viewports (< 1024px). Defaults to 'bar' */
|
|
118
|
+
mobileMode?: 'bar' | 'icon' | 'auto';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Header action item (e.g. Profile, Wishlist, Cart, Notifications).
|
|
122
|
+
*/
|
|
123
|
+
export interface NavActionItem {
|
|
124
|
+
id: string;
|
|
125
|
+
/** Action label (e.g. "PROFILE", "WISH LIST(0)", "CART(0)") */
|
|
126
|
+
label: React.ReactNode;
|
|
127
|
+
/** Action icon element rendered above the label */
|
|
128
|
+
icon: React.ReactNode;
|
|
129
|
+
/** Optional link destination */
|
|
130
|
+
href?: string;
|
|
131
|
+
/** Optional zone for cross-zone linking */
|
|
132
|
+
zone?: string;
|
|
133
|
+
/** Explicit cross-zone toggle */
|
|
134
|
+
crossZone?: boolean;
|
|
135
|
+
/** Badge counter or indicator */
|
|
136
|
+
badge?: React.ReactNode | number;
|
|
137
|
+
/** Click handler */
|
|
138
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
139
|
+
/** Accessible aria-label */
|
|
140
|
+
ariaLabel?: string;
|
|
141
|
+
/** Custom action className */
|
|
142
|
+
className?: string;
|
|
143
|
+
/** Whether the action item is visually disabled */
|
|
144
|
+
disabled?: boolean;
|
|
145
|
+
/** Priority level determining which items resist collapsing into overflow */
|
|
146
|
+
priority?: 'high' | 'normal' | 'low';
|
|
147
|
+
/** Optional custom renderer for complex items */
|
|
148
|
+
render?: (props: {
|
|
149
|
+
item: NavActionItem;
|
|
150
|
+
isOverflow: boolean;
|
|
151
|
+
}) => React.ReactNode;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Navigation items and desktop mega-menu configuration object.
|
|
155
|
+
*/
|
|
156
|
+
export interface NavNavigationConfig {
|
|
157
|
+
/** Primary navigation category items */
|
|
158
|
+
items?: NavHeaderItem[];
|
|
159
|
+
/** Master toggle to show or hide the navigation items bar */
|
|
160
|
+
show?: boolean;
|
|
161
|
+
/** Maximum number of nav items displayed before collapsing into three-dot overflow */
|
|
162
|
+
maxVisibleItems?: number;
|
|
163
|
+
/** Controlled active navigation item ID for open mega-menu */
|
|
164
|
+
activeItemId?: string | null;
|
|
165
|
+
/** Default active navigation item ID (uncontrolled) */
|
|
166
|
+
defaultActiveItemId?: string | null;
|
|
167
|
+
/** Callback fired when the active mega-menu item changes */
|
|
168
|
+
onActiveItemChange?: (id: string | null) => void;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Action buttons section configuration object.
|
|
172
|
+
*/
|
|
173
|
+
export interface NavActionsConfig {
|
|
174
|
+
/** Array of custom action buttons */
|
|
175
|
+
items?: NavActionItem[];
|
|
176
|
+
/** Master toggle to show or hide the actions section */
|
|
177
|
+
show?: boolean;
|
|
178
|
+
/** Maximum number of action items displayed before collapsing to overflow ('auto' | number) */
|
|
179
|
+
maxVisible?: number | 'auto';
|
|
180
|
+
/** Custom overflow menu button configuration */
|
|
181
|
+
overflow?: {
|
|
182
|
+
label?: React.ReactNode;
|
|
183
|
+
icon?: React.ReactNode;
|
|
184
|
+
};
|
|
185
|
+
/** Pre-configured profile action */
|
|
186
|
+
profile?: Partial<NavActionItem>;
|
|
187
|
+
/** Pre-configured wishlist action with optional badge count */
|
|
188
|
+
wishlist?: Partial<NavActionItem> & {
|
|
189
|
+
count?: number;
|
|
190
|
+
};
|
|
191
|
+
/** Pre-configured cart action with optional badge count */
|
|
192
|
+
cart?: Partial<NavActionItem> & {
|
|
193
|
+
count?: number;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Mobile and tablet responsive navigation (< 1024px) configuration object.
|
|
198
|
+
*/
|
|
199
|
+
export interface NavMobileConfig {
|
|
200
|
+
/**
|
|
201
|
+
* Horizontal category tab slider configuration or boolean toggle.
|
|
202
|
+
*/
|
|
203
|
+
tabSlider?: boolean | {
|
|
204
|
+
show?: boolean;
|
|
205
|
+
activeItemId?: string | null;
|
|
206
|
+
defaultActiveItemId?: string | null;
|
|
207
|
+
onActiveItemChange?: (id: string | null) => void;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Mobile search configuration (bar pill or icon trigger, full-screen drawer state).
|
|
211
|
+
*/
|
|
212
|
+
search?: {
|
|
213
|
+
mode?: 'bar' | 'icon' | 'auto';
|
|
214
|
+
open?: boolean;
|
|
215
|
+
defaultOpen?: boolean;
|
|
216
|
+
onOpenChange?: (open: boolean) => void;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export interface NavHeaderProps extends MotionProps, Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
220
|
+
/**
|
|
221
|
+
* Brand logos configuration (full logo and mini logo for search expansion).
|
|
222
|
+
*/
|
|
223
|
+
branding: NavHeaderBranding;
|
|
224
|
+
/**
|
|
225
|
+
* Maximum container width for the navigation bar and mega-menu.
|
|
226
|
+
* Defaults to '2xl' (max-w-[1216px]).
|
|
227
|
+
*/
|
|
228
|
+
containerMaxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
229
|
+
/**
|
|
230
|
+
* Whether the header stays sticky at the top of the viewport.
|
|
231
|
+
* Defaults to false.
|
|
232
|
+
*/
|
|
233
|
+
sticky?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Custom router link component override (e.g. Next.js Link, Remix Link, or custom router).
|
|
236
|
+
*/
|
|
237
|
+
linkComponent?: React.ComponentType<{
|
|
238
|
+
href: string;
|
|
239
|
+
children: React.ReactNode;
|
|
240
|
+
className?: string;
|
|
241
|
+
[key: string]: any;
|
|
242
|
+
}>;
|
|
243
|
+
/**
|
|
244
|
+
* Custom slot rendered at the far right of the navigation bar.
|
|
245
|
+
*/
|
|
246
|
+
rightContent?: React.ReactNode;
|
|
247
|
+
/**
|
|
248
|
+
* Offer / Announcement banner above header.
|
|
249
|
+
* Pass an OfferBannerConfig object, a custom ReactNode, or false to disable.
|
|
250
|
+
*/
|
|
251
|
+
offerBanner?: OfferBannerConfig | React.ReactNode | boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Modular primary navigation configuration object or items array.
|
|
254
|
+
*/
|
|
255
|
+
navigation?: NavNavigationConfig | NavHeaderItem[];
|
|
256
|
+
/**
|
|
257
|
+
* Modular search feature configuration object or boolean toggle.
|
|
258
|
+
*/
|
|
259
|
+
search?: NavSearchConfig | boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Modular actions configuration object or action items array.
|
|
262
|
+
*/
|
|
263
|
+
actions?: NavActionsConfig | NavActionItem[];
|
|
264
|
+
/**
|
|
265
|
+
* Modular mobile and tablet responsive configuration object.
|
|
266
|
+
*/
|
|
267
|
+
mobile?: NavMobileConfig;
|
|
268
|
+
/** Shorthand master toggle for the offer banner. Defaults to true. */
|
|
269
|
+
showOfferBanner?: boolean;
|
|
270
|
+
/** Shorthand navigation items array. */
|
|
271
|
+
items?: NavHeaderItem[];
|
|
272
|
+
/** Shorthand master toggle for the navigation items section. Defaults to true. */
|
|
273
|
+
showNavItems?: boolean;
|
|
274
|
+
/** Shorthand maximum number of nav items displayed before collapsing into three-dot overflow. */
|
|
275
|
+
maxVisibleNavItems?: number;
|
|
276
|
+
/** Shorthand controlled active navigation item ID for open mega-menu. */
|
|
277
|
+
activeItemId?: string | null;
|
|
278
|
+
/** Shorthand default active navigation item ID (uncontrolled). */
|
|
279
|
+
defaultActiveItemId?: string | null;
|
|
280
|
+
/** Shorthand callback fired when the active mega-menu item changes. */
|
|
281
|
+
onActiveItemChange?: (id: string | null) => void;
|
|
282
|
+
/** Shorthand master toggle for the search feature and trigger. Defaults to true. */
|
|
283
|
+
showSearch?: boolean;
|
|
284
|
+
/** Shorthand master toggle for the action buttons section. Defaults to true. */
|
|
285
|
+
showActions?: boolean;
|
|
286
|
+
/** Shorthand maximum number of action items displayed before collapsing into overflow. */
|
|
287
|
+
maxVisibleActions?: number | 'auto';
|
|
288
|
+
/** Shorthand custom label for the overflow menu action button. Defaults to 'MORE'. */
|
|
289
|
+
overflowActionLabel?: React.ReactNode;
|
|
290
|
+
/** Shorthand custom icon for the overflow menu action button. Defaults to MoreHorizontal. */
|
|
291
|
+
overflowActionIcon?: React.ReactNode;
|
|
292
|
+
/** Shorthand profile action configuration. */
|
|
293
|
+
profileAction?: Partial<NavActionItem>;
|
|
294
|
+
/** Shorthand wishlist action configuration with optional badge count. */
|
|
295
|
+
wishlistAction?: Partial<NavActionItem> & {
|
|
296
|
+
count?: number;
|
|
297
|
+
};
|
|
298
|
+
/** Shorthand cart action configuration with optional badge count. */
|
|
299
|
+
cartAction?: Partial<NavActionItem> & {
|
|
300
|
+
count?: number;
|
|
301
|
+
};
|
|
302
|
+
/** Shorthand toggle for mobile horizontal tab slider. Defaults to true. */
|
|
303
|
+
mobileTabSlider?: boolean;
|
|
304
|
+
/** Shorthand search display style on mobile/tablet screens (< 1024px). */
|
|
305
|
+
mobileSearchMode?: 'bar' | 'icon' | 'auto';
|
|
306
|
+
/** Shorthand controlled active item ID for the mobile tab slider. */
|
|
307
|
+
mobileActiveItemId?: string | null;
|
|
308
|
+
/** Shorthand default active item ID for the mobile tab slider (uncontrolled). */
|
|
309
|
+
defaultMobileActiveItemId?: string | null;
|
|
310
|
+
/** Shorthand callback fired when the active mobile tab item changes. */
|
|
311
|
+
onMobileActiveItemChange?: (id: string | null) => void;
|
|
312
|
+
/** Shorthand controlled open state for the full-screen mobile search drawer. */
|
|
313
|
+
mobileSearchOpen?: boolean;
|
|
314
|
+
/** Shorthand default open state for the full-screen mobile search drawer. */
|
|
315
|
+
defaultMobileSearchOpen?: boolean;
|
|
316
|
+
/** Shorthand callback fired when the mobile search drawer opens or closes. */
|
|
317
|
+
onMobileSearchOpenChange?: (open: boolean) => void;
|
|
318
|
+
/** Custom motion prop override. */
|
|
319
|
+
motion?: MotionProp;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=NavHeader.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavHeader.types.d.ts","sourceRoot":"","sources":["../../../src/components/NavHeader/NavHeader.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oDAAoD;IACpD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yFAAyF;IACzF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,uDAAuD;IACvD,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EA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eader, Header } from './NavHeader';
|
|
2
|
+
export type { NavHeaderProps, NavHeaderItem, NavHeaderBranding, OfferBannerConfig, NavSearchConfig, PopularSearchTag, NavActionItem, } from './NavHeader.types';
|
|
3
|
+
export { useNavHeaderContext } from './NavHeader.context';
|
|
4
|
+
export { offerBannerVariants, navHeaderVariants, navHeaderContainerVariants, navHeaderItemVariants, navActionVariants, megaMenuCardVariants, searchPopoverCardVariants, } from './NavHeader.styles';
|
|
5
|
+
export { OfferBanner } from './subcomponents/OfferBanner';
|
|
6
|
+
export { NavBrand } from './subcomponents/NavBrand';
|
|
7
|
+
export { NavItems } from './subcomponents/NavItems';
|
|
8
|
+
export { NavMegaMenu } from './subcomponents/NavMegaMenu';
|
|
9
|
+
export { NavSearch } from './subcomponents/NavSearch';
|
|
10
|
+
export { NavActions } from './subcomponents/NavActions';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NavHeader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NavActionItem } from '../NavHeader.types';
|
|
3
|
+
export interface NavActionOverflowProps {
|
|
4
|
+
items: NavActionItem[];
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
shouldAnimate?: boolean;
|
|
8
|
+
motionClass?: string;
|
|
9
|
+
linkComponent?: React.ComponentType<any>;
|
|
10
|
+
}
|
|
11
|
+
export declare const NavActionOverflow: React.FC<NavActionOverflowProps>;
|
|
12
|
+
export default NavActionOverflow;
|
|
13
|
+
//# sourceMappingURL=NavActionOverflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavActionOverflow.d.ts","sourceRoot":"","sources":["../../../../src/components/NavHeader/subcomponents/NavActionOverflow.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,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,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAiM9D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { AnimatePresence, motion } from '@timmbr/motion';
|
|
5
|
+
import { MoreHorizontal } from '@timmbr/icons';
|
|
6
|
+
import { cn } from '@timmbr/utils';
|
|
7
|
+
import { navActionVariants, actionOverflowItemVariants, actionOverflowPopoverVariants } from '../NavHeader.styles.js';
|
|
8
|
+
import { resolveNavDestination, isCrossZoneNavigation } from '../NavHeader.helpers.js';
|
|
9
|
+
import { useTimmbrConfig } from '../../../providers/TimmbrConfigProvider.js';
|
|
10
|
+
|
|
11
|
+
const NavActionOverflow = ({
|
|
12
|
+
items,
|
|
13
|
+
label = "MORE",
|
|
14
|
+
icon,
|
|
15
|
+
shouldAnimate = true,
|
|
16
|
+
motionClass,
|
|
17
|
+
linkComponent: CustomLink
|
|
18
|
+
}) => {
|
|
19
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
20
|
+
const containerRef = React.useRef(null);
|
|
21
|
+
const config = useTimmbrConfig();
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (!isOpen) return;
|
|
24
|
+
const handleClickOutside = (e) => {
|
|
25
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
26
|
+
setIsOpen(false);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handleKeyDown = (e) => {
|
|
30
|
+
if (e.key === "Escape") {
|
|
31
|
+
setIsOpen(false);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
35
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
36
|
+
return () => {
|
|
37
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
38
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
39
|
+
};
|
|
40
|
+
}, [isOpen]);
|
|
41
|
+
if (!items || items.length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const totalBadges = items.reduce((acc, curr) => {
|
|
45
|
+
if (typeof curr.badge === "number") return acc + curr.badge;
|
|
46
|
+
if (typeof curr.badge === "string") {
|
|
47
|
+
const parsed = parseInt(curr.badge, 10);
|
|
48
|
+
return acc + (isNaN(parsed) ? 1 : parsed);
|
|
49
|
+
}
|
|
50
|
+
if (curr.badge) return acc + 1;
|
|
51
|
+
return acc;
|
|
52
|
+
}, 0);
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "relative inline-flex items-center", "data-slot": "nav-action-overflow", children: [
|
|
54
|
+
/* @__PURE__ */ jsxs(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
type: "button",
|
|
58
|
+
"aria-label": "More navigation actions",
|
|
59
|
+
"aria-expanded": isOpen,
|
|
60
|
+
"aria-haspopup": "menu",
|
|
61
|
+
onClick: () => setIsOpen((prev) => !prev),
|
|
62
|
+
className: cn(
|
|
63
|
+
navActionVariants({ active: isOpen }),
|
|
64
|
+
!shouldAnimate && "transition-none",
|
|
65
|
+
motionClass
|
|
66
|
+
),
|
|
67
|
+
"data-slot": "nav-action-overflow-trigger",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
70
|
+
icon ?? /* @__PURE__ */ jsx(MoreHorizontal, { size: 22, className: "shrink-0 stroke-[1.8]" }),
|
|
71
|
+
totalBadges > 0 && /* @__PURE__ */ jsx(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
className: "absolute -top-1 -right-2 min-w-[16px] h-4 px-1 rounded-full bg-[#C0643A] text-white text-[10px] font-bold flex items-center justify-center",
|
|
75
|
+
"aria-label": `${totalBadges} items in overflow menu`,
|
|
76
|
+
children: totalBadges
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ jsx("span", { className: "hidden lg:inline font-sans font-bold text-[10px] tracking-[0.0926em] uppercase whitespace-nowrap", children: label })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ jsx(
|
|
85
|
+
motion.div,
|
|
86
|
+
{
|
|
87
|
+
initial: shouldAnimate ? { opacity: 0, y: 6, scale: 0.97 } : false,
|
|
88
|
+
animate: shouldAnimate ? { opacity: 1, y: 0, scale: 1 } : void 0,
|
|
89
|
+
exit: shouldAnimate ? { opacity: 0, y: 6, scale: 0.97 } : void 0,
|
|
90
|
+
transition: { duration: 0.18, ease: [0.25, 1, 0.5, 1] },
|
|
91
|
+
className: cn(
|
|
92
|
+
actionOverflowPopoverVariants(),
|
|
93
|
+
!shouldAnimate && "transition-none",
|
|
94
|
+
motionClass
|
|
95
|
+
),
|
|
96
|
+
role: "menu",
|
|
97
|
+
"aria-orientation": "vertical",
|
|
98
|
+
"data-slot": "nav-action-overflow-popover",
|
|
99
|
+
children: /* @__PURE__ */ jsx("div", { className: "py-1 flex flex-col gap-0.5", children: items.map((item) => {
|
|
100
|
+
if (item.render) {
|
|
101
|
+
return /* @__PURE__ */ jsx("div", { role: "menuitem", children: item.render({ item, isOverflow: true }) }, item.id);
|
|
102
|
+
}
|
|
103
|
+
const resolvedHref = resolveNavDestination(item.href, item.zone, config.zones?.zones);
|
|
104
|
+
const requiresCrossZone = isCrossZoneNavigation(item.zone, config.zones?.currentZone, item.crossZone);
|
|
105
|
+
const itemRowContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 truncate", children: [
|
|
107
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-grey-500 group-hover:text-[#C0643A] transition-colors", children: item.icon }),
|
|
108
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: item.label })
|
|
109
|
+
] }),
|
|
110
|
+
typeof item.badge !== "undefined" && item.badge !== null && /* @__PURE__ */ jsx("span", { className: "shrink-0 px-1.5 py-0.5 rounded-full bg-[#C0643A] text-white text-[10px] font-bold", children: item.badge })
|
|
111
|
+
] });
|
|
112
|
+
const itemClass = cn(
|
|
113
|
+
actionOverflowItemVariants({ disabled: item.disabled }),
|
|
114
|
+
"group",
|
|
115
|
+
item.className
|
|
116
|
+
);
|
|
117
|
+
const handleClick = (e) => {
|
|
118
|
+
item.onClick?.(e);
|
|
119
|
+
setIsOpen(false);
|
|
120
|
+
};
|
|
121
|
+
if (resolvedHref && !item.disabled) {
|
|
122
|
+
if (CustomLink && !requiresCrossZone) {
|
|
123
|
+
return /* @__PURE__ */ jsx(
|
|
124
|
+
CustomLink,
|
|
125
|
+
{
|
|
126
|
+
href: resolvedHref,
|
|
127
|
+
"aria-label": item.ariaLabel,
|
|
128
|
+
role: "menuitem",
|
|
129
|
+
className: itemClass,
|
|
130
|
+
onClick: handleClick,
|
|
131
|
+
children: itemRowContent
|
|
132
|
+
},
|
|
133
|
+
item.id
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ jsx(
|
|
137
|
+
"a",
|
|
138
|
+
{
|
|
139
|
+
href: resolvedHref,
|
|
140
|
+
"aria-label": item.ariaLabel,
|
|
141
|
+
"data-cross-zone": requiresCrossZone ? "true" : void 0,
|
|
142
|
+
role: "menuitem",
|
|
143
|
+
className: itemClass,
|
|
144
|
+
onClick: handleClick,
|
|
145
|
+
children: itemRowContent
|
|
146
|
+
},
|
|
147
|
+
item.id
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return /* @__PURE__ */ jsx(
|
|
151
|
+
"button",
|
|
152
|
+
{
|
|
153
|
+
type: "button",
|
|
154
|
+
role: "menuitem",
|
|
155
|
+
disabled: item.disabled,
|
|
156
|
+
"aria-label": item.ariaLabel,
|
|
157
|
+
onClick: handleClick,
|
|
158
|
+
className: itemClass,
|
|
159
|
+
children: itemRowContent
|
|
160
|
+
},
|
|
161
|
+
item.id
|
|
162
|
+
);
|
|
163
|
+
}) })
|
|
164
|
+
}
|
|
165
|
+
) })
|
|
166
|
+
] });
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export { NavActionOverflow };
|