@donotdev/ui 0.3.0 → 0.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.
@@ -1,37 +1,38 @@
1
1
  import type { ReactNode } from 'react';
2
2
  /** Props for the HeaderMenu component. */
3
3
  export interface HeaderMenuProps {
4
- /** Content to display (buttons, controls, etc.) */
4
+ /** Header controls: inline from laptop up, in the burger panel below */
5
5
  children: ReactNode;
6
6
  /** Additional CSS classes for trigger button */
7
7
  className?: string;
8
8
  }
9
9
  /**
10
- * HeaderMenu - Dropdown menu component for header controls
10
+ * HeaderMenu - Header controls that collapse into a hamburger
11
11
  *
12
- * Displays content in a dropdown menu with responsive grid layout.
13
- * Layout presets decide when to use this component based on breakpoint.
12
+ * Renders `children` inline (`display: contents`, so they sit in the parent row with
13
+ * its gap) and a hamburger whose panel renders the same children while open. Both are
14
+ * in the server HTML; HeaderMenu.css shows the hamburger below the laptop breakpoint
15
+ * (1024px, the split of `useBreakpoint('isMobileOrTablet')`) and the inline controls
16
+ * from it up. No JS breakpoint, no hydration swap: usable at every width.
14
17
  *
15
- * Labels are forced visible via CSS (.dndev-menu-content forces labels visible).
16
- * No cloneElement needed - pure CSS solution.
18
+ * The panel is a Popover, not a DropdownMenu: menu items swallow the clicks of the
19
+ * controls inside them and keep keyboard focus on the item wrapper, which broke
20
+ * nested popups (AuthHeader's provider menu or dialog, LanguageSelector, an account
21
+ * DropdownMenu). Labels are forced visible in the panel (.dndev-menu-content).
22
+ * The panel sits just above the header, so dialogs and menus opened from it show above it.
17
23
  *
18
- * @version 0.1.0
24
+ * @version 0.2.0
19
25
  * @since 0.0.1
20
26
  * @author AMBROISE PARK Consulting
21
27
  *
22
28
  * @example
23
29
  * ```tsx
24
- * // In layout preset:
25
- * const isMobileOrTablet = useBreakpoint('isMobileOrTablet');
26
- * {isMobileOrTablet ? (
30
+ * // Inline on laptop and desktop, burger on mobile and tablet:
27
31
  * <HeaderMenu>
28
- * <AuthHeader />
29
- * <LanguageSelector />
30
- * <ThemeToggle />
32
+ * <AuthHeader />
33
+ * <LanguageSelector />
34
+ * <ThemeToggle />
31
35
  * </HeaderMenu>
32
- * ) : (
33
- * <>{rightContent}</>
34
- * )}
35
36
  * ```
36
37
  */
37
38
  export declare const HeaderMenu: ({ children, className }: HeaderMenuProps) => import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/HeaderMenu.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,UAAU,GAAI,yBAAyB,eAAe,gCAclE,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"HeaderMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/HeaderMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAInD,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,QAAQ,EAAE,SAAS,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,UAAU,GAAI,yBAAyB,eAAe,gCAgClE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,47 +1,75 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  // packages/ui/src/components/layout/components/header/HeaderMenu.tsx
3
4
  /**
4
5
  * @fileoverview HeaderMenu component
5
- * @description Dropdown menu for header controls with responsive grid layout
6
+ * @description Header controls inline on laptop and desktop, behind a hamburger below
6
7
  *
7
8
  * Features:
8
- * - DropdownMenu with responsive grid layout
9
- * - Adapts to any number of buttons
9
+ * - Children inline from the laptop breakpoint up, in a burger panel below
10
+ * - CSS-only switch (HeaderMenu.css): both are in the server HTML, no hydration swap
11
+ * - Nested popups (DropdownMenu, Dialog…) open and work from inside the panel
10
12
  * - Reusable across all layout presets
11
13
  *
12
- * @version 0.1.0
14
+ * @version 0.2.0
13
15
  * @since 0.0.1
14
16
  * @author AMBROISE PARK Consulting
15
17
  */
16
- import { MoreHorizontal } from 'lucide-react';
17
- import { Button, BUTTON_VARIANT, DropdownMenu } from '@donotdev/components';
18
+ import { Menu } from 'lucide-react';
19
+ import { useState } from 'react';
20
+ import { Button, BUTTON_VARIANT, Popover, Stack } from '@donotdev/components';
18
21
  /**
19
- * HeaderMenu - Dropdown menu component for header controls
22
+ * Whether a click inside the burger panel ends the interaction.
20
23
  *
21
- * Displays content in a dropdown menu with responsive grid layout.
22
- * Layout presets decide when to use this component based on breakpoint.
24
+ * The panel renders its own copy of the children, so closing it unmounts any popup
25
+ * they opened. It stays open for a popup trigger (`aria-expanded`: DropdownMenu,
26
+ * Dialog, Popover, Select triggers) and for clicks inside a nested dialog, which is
27
+ * portaled outside the panel. Any other click (a plain control, a nested menu choice)
28
+ * closes it, as a menu item does.
29
+ */
30
+ function endsInteraction({ target, currentTarget, }) {
31
+ if (!(target instanceof Element) || target.closest('[aria-expanded]')) {
32
+ return false;
33
+ }
34
+ if (currentTarget.contains(target))
35
+ return true;
36
+ return !target.closest('[role="dialog"], [role="alertdialog"]');
37
+ }
38
+ /**
39
+ * HeaderMenu - Header controls that collapse into a hamburger
40
+ *
41
+ * Renders `children` inline (`display: contents`, so they sit in the parent row with
42
+ * its gap) and a hamburger whose panel renders the same children while open. Both are
43
+ * in the server HTML; HeaderMenu.css shows the hamburger below the laptop breakpoint
44
+ * (1024px, the split of `useBreakpoint('isMobileOrTablet')`) and the inline controls
45
+ * from it up. No JS breakpoint, no hydration swap: usable at every width.
23
46
  *
24
- * Labels are forced visible via CSS (.dndev-menu-content forces labels visible).
25
- * No cloneElement needed - pure CSS solution.
47
+ * The panel is a Popover, not a DropdownMenu: menu items swallow the clicks of the
48
+ * controls inside them and keep keyboard focus on the item wrapper, which broke
49
+ * nested popups (AuthHeader's provider menu or dialog, LanguageSelector, an account
50
+ * DropdownMenu). Labels are forced visible in the panel (.dndev-menu-content).
51
+ * The panel sits just above the header, so dialogs and menus opened from it show above it.
26
52
  *
27
- * @version 0.1.0
53
+ * @version 0.2.0
28
54
  * @since 0.0.1
29
55
  * @author AMBROISE PARK Consulting
30
56
  *
31
57
  * @example
32
58
  * ```tsx
33
- * // In layout preset:
34
- * const isMobileOrTablet = useBreakpoint('isMobileOrTablet');
35
- * {isMobileOrTablet ? (
59
+ * // Inline on laptop and desktop, burger on mobile and tablet:
36
60
  * <HeaderMenu>
37
- * <AuthHeader />
38
- * <LanguageSelector />
39
- * <ThemeToggle />
61
+ * <AuthHeader />
62
+ * <LanguageSelector />
63
+ * <ThemeToggle />
40
64
  * </HeaderMenu>
41
- * ) : (
42
- * <>{rightContent}</>
43
- * )}
44
65
  * ```
45
66
  */
46
- export const HeaderMenu = ({ children, className }) => (_jsx(DropdownMenu, { trigger: _jsx(Button, { variant: BUTTON_VARIANT.GHOST, icon: MoreHorizontal, "aria-label": "Menu", className: className }), contentAlign: "end", children: children }));
67
+ export const HeaderMenu = ({ children, className }) => {
68
+ const [open, setOpen] = useState(false);
69
+ const closeAfterAction = (event) => {
70
+ if (endsInteraction(event))
71
+ setOpen(false);
72
+ };
73
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "dndev-header-menu-inline", children: children }), _jsx("div", { className: "dndev-header-menu-burger", children: _jsx(Popover, { open: open, onOpenChange: setOpen, align: "end", className: "dndev-menu-content dndev-header-menu-panel", trigger: _jsx(Button, { variant: BUTTON_VARIANT.GHOST, icon: Menu, "aria-label": "Menu", className: className }), children: _jsx(Stack, { gap: "none", onClick: closeAfterAction, children: children }) }) })] }));
74
+ };
47
75
  export default HeaderMenu;
@@ -3734,7 +3734,11 @@ em {
3734
3734
 
3735
3735
  /* href: stretched link. The title is the <a href>; its ::after covers the whole
3736
3736
  card so the tile is clickable, while controls inside stay above it. The body
3737
- must not be the containing block, or the hit area would stop at the cover. */
3737
+ must not be the containing block, or the hit area would stop at the cover.
3738
+ The lift list must name every control root and its value: a group whose own
3739
+ opacity (e.g. a disabled QuantityStepper, role="group") makes it a stacking
3740
+ context paints below the overlay, and an <output> value would be covered, so
3741
+ taps there would open the link instead of reaching the control. */
3738
3742
  .dndev-card[data-has-link='true'] > .dndev-card-body {
3739
3743
  position: static;
3740
3744
  }
@@ -3770,6 +3774,9 @@ em {
3770
3774
  textarea,
3771
3775
  label,
3772
3776
  [role='button'],
3777
+ [role='group'],
3778
+ fieldset,
3779
+ output,
3773
3780
  [tabindex]
3774
3781
  ):not(.dndev-card-link) {
3775
3782
  position: relative;
@@ -3815,9 +3822,25 @@ em {
3815
3822
  overflow: hidden;
3816
3823
  z-index: 0;
3817
3824
  width: 100%;
3825
+ }
3826
+
3827
+ /* Opt-in fill behind the media (coverBackground); transparent paints nothing. */
3828
+ .dndev-card-cover[data-background='muted'] {
3818
3829
  background: var(--muted);
3819
3830
  }
3820
3831
 
3832
+ .dndev-card-cover[data-background='primary'] {
3833
+ background: var(--primary);
3834
+ }
3835
+
3836
+ .dndev-card-cover[data-background='secondary'] {
3837
+ background: var(--secondary);
3838
+ }
3839
+
3840
+ .dndev-card-cover[data-background='accent'] {
3841
+ background: var(--accent);
3842
+ }
3843
+
3821
3844
  /* Cover-only: fill the card completely. Card root owns the aspect-ratio. */
3822
3845
  .dndev-card-cover:not([data-has-body='true']) {
3823
3846
  position: absolute;
@@ -3838,14 +3861,12 @@ em {
3838
3861
  object-fit: cover;
3839
3862
  }
3840
3863
 
3841
- /* Contain: whole image visible on the muted cover background (cut-outs), inset
3842
- proportionally so a packshot never touches the frame. */
3864
+ /* Contain: whole image visible at full frame size, no inset (cut-outs;
3865
+ `coverBackground` opts into a fill). */
3843
3866
  .dndev-card-cover[data-fit='contain'] > img:not(.dndev-card-cover-hover),
3844
3867
  .dndev-card-cover[data-fit='contain'] > picture > img:not(.dndev-card-cover-hover) {
3845
3868
  -o-object-fit: contain;
3846
3869
  object-fit: contain;
3847
- box-sizing: border-box;
3848
- padding: 8%;
3849
3870
  }
3850
3871
 
3851
3872
  /* Hover view: stacked over the cover, crossfades in on hover / keyboard focus. */
@@ -5552,7 +5573,6 @@ em {
5552
5573
  width: 100%;
5553
5574
  overflow: hidden;
5554
5575
  border-radius: var(--radius-surface);
5555
- background-color: var(--muted);
5556
5576
  }
5557
5577
 
5558
5578
  .image-gallery__main--lightbox {
@@ -5706,9 +5726,29 @@ em {
5706
5726
  .image-gallery__thumbnail-image[data-fit='contain'] {
5707
5727
  -o-object-fit: contain;
5708
5728
  object-fit: contain;
5729
+ }
5730
+
5731
+ /* Opt-in fill (background prop); transparent paints nothing. Thumbnails only fill when contained. */
5732
+ .image-gallery__main[data-background='muted'],
5733
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='muted'] {
5709
5734
  background-color: var(--muted);
5710
5735
  }
5711
5736
 
5737
+ .image-gallery__main[data-background='primary'],
5738
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='primary'] {
5739
+ background-color: var(--primary);
5740
+ }
5741
+
5742
+ .image-gallery__main[data-background='secondary'],
5743
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='secondary'] {
5744
+ background-color: var(--secondary);
5745
+ }
5746
+
5747
+ .image-gallery__main[data-background='accent'],
5748
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='accent'] {
5749
+ background-color: var(--accent);
5750
+ }
5751
+
5712
5752
  /* Responsive adjustments */
5713
5753
  @media (max-width: 640px) {
5714
5754
  .image-gallery__thumbnail {
@@ -8499,7 +8539,6 @@ input[type='number'] {
8499
8539
  touch-action: pan-y pinch-zoom;
8500
8540
  }
8501
8541
 
8502
- .dndev-swipe-action-toggle,
8503
8542
  .dndev-swipe-action-delete {
8504
8543
  display: flex;
8505
8544
  align-items: center;
@@ -8512,12 +8551,6 @@ input[type='number'] {
8512
8551
  touch-action: manipulation;
8513
8552
  }
8514
8553
 
8515
- .dndev-swipe-action-toggle {
8516
- flex-shrink: 0;
8517
- background: var(--background);
8518
- color: var(--foreground);
8519
- }
8520
-
8521
8554
  /* Native overflow clips the closed action and progressively reveals its paint.
8522
8555
  Inert/disabled/ARIA state gates interaction until the open endpoint. */
8523
8556
  .dndev-swipe-action-delete {
@@ -13535,6 +13568,39 @@ footer[role='contentinfo']:not([data-custom]) a:not(.dndev-interactive):hover {
13535
13568
  border-radius: 0;
13536
13569
  }
13537
13570
 
13571
+ /* HeaderMenu - controls inline from laptop up, hamburger below */
13572
+
13573
+ /* packages/ui/src/components/layout/components/header/HeaderMenu.css */
13574
+
13575
+ /* HeaderMenu: controls inline from laptop up, hamburger below.
13576
+ 1024px = BREAKPOINT_THRESHOLDS.laptop, the useBreakpoint('isMobileOrTablet') split
13577
+ (CSS variables don't work in @media). Both are in the server HTML: no hydration swap. */
13578
+
13579
+ /* Inline controls join the parent row (its gap and alignment) */
13580
+ .dndev-header-menu-inline {
13581
+ display: contents;
13582
+ }
13583
+
13584
+ .dndev-header-menu-burger {
13585
+ display: none;
13586
+ }
13587
+
13588
+ /* Burger panel: above the header it drops from, below the dialogs (--z-modal) and
13589
+ menus (--z-tooltip) its controls open */
13590
+ .dndev-header-menu-panel {
13591
+ z-index: calc(var(--z-header) + 1);
13592
+ }
13593
+
13594
+ @media (width < 1024px) {
13595
+ .dndev-header-menu-inline {
13596
+ display: none;
13597
+ }
13598
+
13599
+ .dndev-header-menu-burger {
13600
+ display: contents;
13601
+ }
13602
+ }
13603
+
13538
13604
  /* AppIcon - header icon styling */
13539
13605
  .app-icon-header {
13540
13606
  display: inline-flex;
package/dist/dndev.css CHANGED
@@ -3733,7 +3733,11 @@ em {
3733
3733
 
3734
3734
  /* href: stretched link. The title is the <a href>; its ::after covers the whole
3735
3735
  card so the tile is clickable, while controls inside stay above it. The body
3736
- must not be the containing block, or the hit area would stop at the cover. */
3736
+ must not be the containing block, or the hit area would stop at the cover.
3737
+ The lift list must name every control root and its value: a group whose own
3738
+ opacity (e.g. a disabled QuantityStepper, role="group") makes it a stacking
3739
+ context paints below the overlay, and an <output> value would be covered, so
3740
+ taps there would open the link instead of reaching the control. */
3737
3741
  .dndev-card[data-has-link='true'] > .dndev-card-body {
3738
3742
  position: static;
3739
3743
  }
@@ -3769,6 +3773,9 @@ em {
3769
3773
  textarea,
3770
3774
  label,
3771
3775
  [role='button'],
3776
+ [role='group'],
3777
+ fieldset,
3778
+ output,
3772
3779
  [tabindex]
3773
3780
  ):not(.dndev-card-link) {
3774
3781
  position: relative;
@@ -3814,9 +3821,25 @@ em {
3814
3821
  overflow: hidden;
3815
3822
  z-index: 0;
3816
3823
  width: 100%;
3824
+ }
3825
+
3826
+ /* Opt-in fill behind the media (coverBackground); transparent paints nothing. */
3827
+ .dndev-card-cover[data-background='muted'] {
3817
3828
  background: var(--muted);
3818
3829
  }
3819
3830
 
3831
+ .dndev-card-cover[data-background='primary'] {
3832
+ background: var(--primary);
3833
+ }
3834
+
3835
+ .dndev-card-cover[data-background='secondary'] {
3836
+ background: var(--secondary);
3837
+ }
3838
+
3839
+ .dndev-card-cover[data-background='accent'] {
3840
+ background: var(--accent);
3841
+ }
3842
+
3820
3843
  /* Cover-only: fill the card completely. Card root owns the aspect-ratio. */
3821
3844
  .dndev-card-cover:not([data-has-body='true']) {
3822
3845
  position: absolute;
@@ -3837,14 +3860,12 @@ em {
3837
3860
  object-fit: cover;
3838
3861
  }
3839
3862
 
3840
- /* Contain: whole image visible on the muted cover background (cut-outs), inset
3841
- proportionally so a packshot never touches the frame. */
3863
+ /* Contain: whole image visible at full frame size, no inset (cut-outs;
3864
+ `coverBackground` opts into a fill). */
3842
3865
  .dndev-card-cover[data-fit='contain'] > img:not(.dndev-card-cover-hover),
3843
3866
  .dndev-card-cover[data-fit='contain'] > picture > img:not(.dndev-card-cover-hover) {
3844
3867
  -o-object-fit: contain;
3845
3868
  object-fit: contain;
3846
- box-sizing: border-box;
3847
- padding: 8%;
3848
3869
  }
3849
3870
 
3850
3871
  /* Hover view: stacked over the cover, crossfades in on hover / keyboard focus. */
@@ -5551,7 +5572,6 @@ em {
5551
5572
  width: 100%;
5552
5573
  overflow: hidden;
5553
5574
  border-radius: var(--radius-surface);
5554
- background-color: var(--muted);
5555
5575
  }
5556
5576
 
5557
5577
  .image-gallery__main--lightbox {
@@ -5705,9 +5725,29 @@ em {
5705
5725
  .image-gallery__thumbnail-image[data-fit='contain'] {
5706
5726
  -o-object-fit: contain;
5707
5727
  object-fit: contain;
5728
+ }
5729
+
5730
+ /* Opt-in fill (background prop); transparent paints nothing. Thumbnails only fill when contained. */
5731
+ .image-gallery__main[data-background='muted'],
5732
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='muted'] {
5708
5733
  background-color: var(--muted);
5709
5734
  }
5710
5735
 
5736
+ .image-gallery__main[data-background='primary'],
5737
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='primary'] {
5738
+ background-color: var(--primary);
5739
+ }
5740
+
5741
+ .image-gallery__main[data-background='secondary'],
5742
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='secondary'] {
5743
+ background-color: var(--secondary);
5744
+ }
5745
+
5746
+ .image-gallery__main[data-background='accent'],
5747
+ .image-gallery__thumbnail-image[data-fit='contain'][data-background='accent'] {
5748
+ background-color: var(--accent);
5749
+ }
5750
+
5711
5751
  /* Responsive adjustments */
5712
5752
  @media (max-width: 640px) {
5713
5753
  .image-gallery__thumbnail {
@@ -8498,7 +8538,6 @@ input[type='number'] {
8498
8538
  touch-action: pan-y pinch-zoom;
8499
8539
  }
8500
8540
 
8501
- .dndev-swipe-action-toggle,
8502
8541
  .dndev-swipe-action-delete {
8503
8542
  display: flex;
8504
8543
  align-items: center;
@@ -8511,12 +8550,6 @@ input[type='number'] {
8511
8550
  touch-action: manipulation;
8512
8551
  }
8513
8552
 
8514
- .dndev-swipe-action-toggle {
8515
- flex-shrink: 0;
8516
- background: var(--background);
8517
- color: var(--foreground);
8518
- }
8519
-
8520
8553
  /* Native overflow clips the closed action and progressively reveals its paint.
8521
8554
  Inert/disabled/ARIA state gates interaction until the open endpoint. */
8522
8555
  .dndev-swipe-action-delete {
@@ -13534,6 +13567,39 @@ footer[role='contentinfo']:not([data-custom]) a:not(.dndev-interactive):hover {
13534
13567
  border-radius: 0;
13535
13568
  }
13536
13569
 
13570
+ /* HeaderMenu - controls inline from laptop up, hamburger below */
13571
+
13572
+ /* packages/ui/src/components/layout/components/header/HeaderMenu.css */
13573
+
13574
+ /* HeaderMenu: controls inline from laptop up, hamburger below.
13575
+ 1024px = BREAKPOINT_THRESHOLDS.laptop, the useBreakpoint('isMobileOrTablet') split
13576
+ (CSS variables don't work in @media). Both are in the server HTML: no hydration swap. */
13577
+
13578
+ /* Inline controls join the parent row (its gap and alignment) */
13579
+ .dndev-header-menu-inline {
13580
+ display: contents;
13581
+ }
13582
+
13583
+ .dndev-header-menu-burger {
13584
+ display: none;
13585
+ }
13586
+
13587
+ /* Burger panel: above the header it drops from, below the dialogs (--z-modal) and
13588
+ menus (--z-tooltip) its controls open */
13589
+ .dndev-header-menu-panel {
13590
+ z-index: calc(var(--z-header) + 1);
13591
+ }
13592
+
13593
+ @media (width < 1024px) {
13594
+ .dndev-header-menu-inline {
13595
+ display: none;
13596
+ }
13597
+
13598
+ .dndev-header-menu-burger {
13599
+ display: contents;
13600
+ }
13601
+ }
13602
+
13537
13603
  /* AppIcon - header icon styling */
13538
13604
  .app-icon-header {
13539
13605
  display: inline-flex;