@softure-ai/theme-notion 0.32.0 → 0.33.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/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ Newest first. Each version lists what changed for an app that uses the theme. Wh
4
4
  production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done").
6
6
 
7
+ ## 0.33.0
8
+
9
+ - `DialogContent` and `SheetContent` (#1476): on open they focus the first form field (`input` other than hidden,
10
+ `select`, `textarea`, `[role=combobox]`, not disabled) instead of the first focusable element, so a dialog whose
11
+ first focusable is a help `TooltipTrigger` opens with no tooltip over the form. With no field Radix's default focus
12
+ stays; an app's own `onOpenAutoFocus` runs first and keeps control when it prevents the default.
13
+ - Migration: an app that focused the first field itself in `onOpenAutoFocus` (to keep a tooltip shut) drops the
14
+ handler.
15
+ - `TabBar` (#1477): when the tabs overflow the strip (a phone), the strip scrolls itself, never the page, so the
16
+ current tab is whole on load (a deep link to a late tab) and whenever `current` changes, with a fade's width of room
17
+ so no fade covers it; nothing moves when it is already in view. Each edge that hides tabs fades out (a static 32 px
18
+ mask) and is marked on the nav with `data-overflow-start` / `data-overflow-end`, so a tab cut at the edge reads as a
19
+ scrollable list. `TabBar` is now a client component; its props are unchanged.
20
+ - Migration: an app that scrolled the current tab into view itself, or drew its own edge fade, drops that code.
21
+
7
22
  ## 0.32.0
8
23
 
9
24
  - `FoldRow` (#1463): the bar and its opened content share one 8 px horizontal inset. The summary is padded `px-2`
package/README.md CHANGED
@@ -116,6 +116,10 @@ name outside a `CommandDialog`; without it the field has none), `SortableList in
116
116
  edge, so put content padding on its children (`SheetHeader`, `SheetFooter`, an inner `div`). An app pads its own
117
117
  screen roots with the same classes: `pt-[env(safe-area-inset-top)]`, `pb-[env(safe-area-inset-bottom)]`,
118
118
  `pl-[env(safe-area-inset-left)]`, `pr-[env(safe-area-inset-right)]`.
119
+ - `DialogContent` and `SheetContent` focus their first form field on open (`input`, `select`, `textarea` or a
120
+ `combobox`, not disabled), not the first focusable element, so a help `TooltipTrigger` beside a label does not open
121
+ its tooltip over the form. With no field Radix's default focus stays; an app's `onOpenAutoFocus` runs first and
122
+ keeps control when it calls `event.preventDefault()`. Tab onto the trigger still shows the tooltip.
119
123
  - Figures, bar segments and box edges take a **tone** by what they mean: `default` (text colour), `success` (green,
120
124
  done), `warning` (orange, to do), `danger` (red, owed or failing), `muted` (gray, out of play). `TONE_COLORS` gives
121
125
  a tone's palette colour (`null` for `default`); `TONE_TEXT`, `TONE_FILL` and `TONE_EDGE` give literal class names
@@ -171,7 +175,9 @@ and zoom; one row per document with its type, size and an "available offline" ma
171
175
  (`DropdownMenuContent size="touch"`, or `size="touch"` on a `DropdownMenuItem`, `DropdownMenuCheckboxItem`,
172
176
  `DropdownMenuRadioItem` or `DropdownMenuSubTrigger`) and the tabs (`TabsList size="touch"` grows to its triggers,
173
177
  each at least 44 × 44, or `TabsTrigger size="touch"`). `TabBar size="touch"` draws every tab link at least 44 × 44 (`data-size="touch"`), and its
174
- `tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). `Switch size="touch"` is a 44 × 44 square that draws the same 26 × 16 track
178
+ `tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). When its tabs overflow the strip (a phone), `TabBar` scrolls the strip itself, never the page, so the current tab is
179
+ whole on load and whenever `current` changes, and fades each edge that hides tabs (`data-overflow-start`,
180
+ `data-overflow-end` on the nav, a static 32 px mask, so nothing moves under reduced motion). `Switch size="touch"` is a 44 × 44 square that draws the same 26 × 16 track
175
181
  inside it and keeps the track's place in the layout (negative margins), so a phone taps the whole square; `className="md:m-0
176
182
  md:h-4 md:w-[26px]"` brings the plain switch back on a desktop. `AccordionTrigger size="touch"` is at least 44 px high
177
183
  whatever its padding, and `DialogContent closeButtonSize="touch"` draws the close button 44 × 44 around the same
@@ -0,0 +1,7 @@
1
+ /**
2
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
3
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
4
+ * With no field, Radix's default focus stays.
5
+ */
6
+ export declare function withFirstFieldFocus(onOpenAutoFocus: ((event: Event) => void) | undefined): (event: Event) => void;
7
+ //# sourceMappingURL=focus-first-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-first-field.d.ts","sourceRoot":"","sources":["../../src/lib/focus-first-field.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,GACpD,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CASxB"}
@@ -0,0 +1,39 @@
1
+ // The form controls a dialog or sheet focuses on open, ahead of any button before them (a tooltip trigger beside a
2
+ // label opens its tooltip on focus, #1476).
3
+ const FIELD_SELECTOR = [
4
+ 'input:not([type="hidden"]):not(:disabled)',
5
+ "select:not(:disabled)",
6
+ "textarea:not(:disabled)",
7
+ '[role="combobox"]:not(:disabled):not([aria-disabled="true"])',
8
+ ].join(", ");
9
+ function findFirstField(container) {
10
+ for (const candidate of container.querySelectorAll(FIELD_SELECTOR)) {
11
+ if (candidate.closest("[hidden], [inert]") === null)
12
+ return candidate;
13
+ }
14
+ return null;
15
+ }
16
+ function focusField(field) {
17
+ field.focus({ preventScroll: true });
18
+ // Selected as Radix selects the first text input it focuses.
19
+ if (field instanceof HTMLInputElement && document.activeElement === field)
20
+ field.select();
21
+ }
22
+ /**
23
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
24
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
25
+ * With no field, Radix's default focus stays.
26
+ */
27
+ export function withFirstFieldFocus(onOpenAutoFocus) {
28
+ return (event) => {
29
+ onOpenAutoFocus?.(event);
30
+ if (event.defaultPrevented || !(event.currentTarget instanceof Element))
31
+ return;
32
+ const field = findFirstField(event.currentTarget);
33
+ if (field === null)
34
+ return;
35
+ event.preventDefault();
36
+ focusField(field);
37
+ };
38
+ }
39
+ //# sourceMappingURL=focus-first-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-first-field.js","sourceRoot":"","sources":["../../src/lib/focus-first-field.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,4CAA4C;AAC5C,MAAM,cAAc,GAAG;IACrB,2CAA2C;IAC3C,uBAAuB;IACvB,yBAAyB;IACzB,8DAA8D;CAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,SAAS,cAAc,CAAC,SAAkB;IACxC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,gBAAgB,CAAc,cAAc,CAAC,EAAE,CAAC;QAChF,IAAI,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI;YAAE,OAAO,SAAS,CAAA;IACvE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAkB;IACpC,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACpC,6DAA6D;IAC7D,IAAI,KAAK,YAAY,gBAAgB,IAAI,QAAQ,CAAC,aAAa,KAAK,KAAK;QAAE,KAAK,CAAC,MAAM,EAAE,CAAA;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,eAAqD;IAErD,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,eAAe,EAAE,CAAC,KAAK,CAAC,CAAA;QACxB,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,YAAY,OAAO,CAAC;YAAE,OAAM;QAC/E,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QACjD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAM;QAC1B,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,UAAU,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC,CAAA;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  export interface TabBarItem<Key extends string> {
3
3
  readonly key: Key;
4
4
  readonly label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,UAAU,CAAC,GAAG,SAAS,MAAM;IAE5C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM;IAE7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAGpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAQD,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,+BA2BpH"}
1
+ {"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAI1E,MAAM,WAAW,UAAU,CAAC,GAAG,SAAS,MAAM;IAE5C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM;IAE7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAGpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAwDD,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,+BA6BpH"}
@@ -1,10 +1,60 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
2
4
  import { cn } from "../lib/utils.js";
3
5
  const TAB_CLASS = "relative inline-flex h-control-height items-center gap-1.5 rounded-md px-2 text-ui-medium whitespace-nowrap text-muted-foreground transition-colors duration-120 after:absolute after:inset-x-0 after:-bottom-1 after:h-0.5 after:bg-foreground after:opacity-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-[current=page]:text-foreground aria-[current=page]:after:opacity-100 [&_svg]:size-4 [&_svg]:shrink-0";
4
6
  const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
7
+ // Static fades (no motion, so nothing to drop under prefers-reduced-motion) on each edge that hides tabs.
8
+ const NAV_CLASS = "overflow-x-auto border-b border-border data-overflow-start:mask-l-from-[calc(100%---spacing(8))] data-overflow-end:mask-r-from-[calc(100%---spacing(8))]";
9
+ // Marks each edge that hides tabs (`data-overflow-start`, `data-overflow-end`); a pixel of rounding is not overflow.
10
+ function markOverflowEdges(strip) {
11
+ strip.toggleAttribute("data-overflow-start", strip.scrollLeft > 1);
12
+ strip.toggleAttribute("data-overflow-end", strip.scrollWidth - strip.clientWidth - strip.scrollLeft > 1);
13
+ }
14
+ // The edge fade's width (`--spacing(8)` in NAV_CLASS): the current tab keeps this much room, so no fade covers it.
15
+ const FADE_WIDTH_PX = 32;
16
+ // Scrolls the strip itself (never the page) just far enough that the current tab is whole and clear of the fades.
17
+ function scrollTabIntoStrip(strip, current) {
18
+ const link = [...strip.querySelectorAll("a[data-tab]")].find((candidate) => candidate.dataset["tab"] === current);
19
+ if (link === undefined)
20
+ return;
21
+ const linkBox = link.getBoundingClientRect();
22
+ const start = linkBox.left - strip.getBoundingClientRect().left + strip.scrollLeft;
23
+ const end = start + linkBox.width;
24
+ const maxScroll = Math.max(0, strip.scrollWidth - strip.clientWidth);
25
+ if (start < strip.scrollLeft)
26
+ strip.scrollLeft = Math.max(0, start - FADE_WIDTH_PX);
27
+ else if (end > strip.scrollLeft + strip.clientWidth)
28
+ strip.scrollLeft = Math.min(maxScroll, end + FADE_WIDTH_PX - strip.clientWidth);
29
+ }
30
+ // Keeps the current tab in view (on mount and when it changes) and the overflow marks in step (on scroll and resize).
31
+ function useStripScroll(strip, current) {
32
+ useEffect(() => {
33
+ const element = strip.current;
34
+ if (element === null)
35
+ return;
36
+ const markEdges = () => markOverflowEdges(element);
37
+ element.addEventListener("scroll", markEdges, { passive: true });
38
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(markEdges);
39
+ observer?.observe(element);
40
+ return () => {
41
+ element.removeEventListener("scroll", markEdges);
42
+ observer?.disconnect();
43
+ };
44
+ }, [strip]);
45
+ useEffect(() => {
46
+ const element = strip.current;
47
+ if (element === null)
48
+ return;
49
+ scrollTabIntoStrip(element, current);
50
+ markOverflowEdges(element);
51
+ }, [strip, current]);
52
+ }
5
53
  // A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
6
54
  export function TabBar({ label, tabs, current, size = "default", tabClassName }) {
7
55
  const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
8
- return (_jsx("nav", { "aria-label": label, "data-slot": "tab-bar", className: "overflow-x-auto border-b border-border", children: _jsx("ul", { className: "flex gap-1 pb-1", children: tabs.map((tab) => (_jsx("li", { children: _jsxs("a", { href: tab.href, className: linkClass, "data-tab": tab.key, "data-size": size === "touch" ? "touch" : undefined, "aria-current": tab.key === current ? "page" : undefined, children: [tab.icon, tab.label, tab.count === undefined ? null : (_jsx("span", { "data-slot": "tab-bar-count", className: "rounded-xs bg-accent px-1 text-small text-muted-foreground tabular-nums", children: tab.count }))] }) }, tab.key))) }) }));
56
+ const stripRef = useRef(null);
57
+ useStripScroll(stripRef, current);
58
+ return (_jsx("nav", { ref: stripRef, "aria-label": label, "data-slot": "tab-bar", className: NAV_CLASS, children: _jsx("ul", { className: "flex gap-1 pb-1", children: tabs.map((tab) => (_jsx("li", { children: _jsxs("a", { href: tab.href, className: linkClass, "data-tab": tab.key, "data-size": size === "touch" ? "touch" : undefined, "aria-current": tab.key === current ? "page" : undefined, children: [tab.icon, tab.label, tab.count === undefined ? null : (_jsx("span", { "data-slot": "tab-bar-count", className: "rounded-xs bg-accent px-1 text-small text-muted-foreground tabular-nums", children: tab.count }))] }) }, tab.key))) }) }));
9
59
  }
10
60
  //# sourceMappingURL=TabBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../src/notion/TabBar.ts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AK,EAAE,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,sHAAsH;AACtH,MAAM,UAAU,MAAM,CAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,YAAY,EAAoB;IACnH,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,IAAI,eAAe,EAAE,YAAY,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAClD,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CACL,cAAK,GAAG,EAAE,QAAQ,gBAAc,KAAK,eAAY,SAAS,EAAC,SAAS,EAAE,SAAS,YAC7E,aAAI,SAAS,EAAC,iBAAiB,YAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,uBACE,aACE,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,SAAS,EAAE,SAAS,cACV,GAAG,CAAC,GAAG,eACN,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,kBACnC,GAAG,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAErD,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChC,4BAAgB,eAAe,EAAC,SAAS,EAAC,yEAAyE,YAChH,GAAG,CAAC,KAAK,GACL,CACR,IACC,IAfG,GAAG,CAAC,GAAG,CAgBX,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogP
5
5
  declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
6
6
  declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
- declare function DialogContent({ className, children, showCloseButton, closeLabel, closeButtonSize, size, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
8
+ declare function DialogContent({ className, children, showCloseButton, closeLabel, closeButtonSize, size, onOpenAutoFocus, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
9
9
  showCloseButton?: boolean;
10
10
  closeLabel?: string;
11
11
  closeButtonSize?: "default" | "touch";
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpD,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,qBAEnD;AAED,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAEtD;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,MAAM,CAAC,qBAErD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAEpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAWtD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,eAAsB,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T,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,qBAkBA;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAQpD;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,qBAQ1D;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
package/dist/ui/dialog.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { en as messages } from "../messages/en.js";
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import { XIcon } from "lucide-react";
7
8
  import { Dialog as DialogPrimitive } from "radix-ui";
@@ -21,8 +22,8 @@ function DialogClose({ ...props }) {
21
22
  function DialogOverlay({ className, ...props }) {
22
23
  return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn("fixed inset-0 z-50 bg-overlay duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
23
24
  }
24
- function DialogContent({ className, children, showCloseButton = true, closeLabel = messages.dialog.close, closeButtonSize = "default", size = "default", ...props }) {
25
- return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2", size === "lg" &&
25
+ function DialogContent({ className, children, showCloseButton = true, closeLabel = messages.dialog.close, closeButtonSize = "default", size = "default", onOpenAutoFocus, ...props }) {
26
+ return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", onOpenAutoFocus: withFirstFieldFocus(onOpenAutoFocus), className: cn("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", size === "wide" && "lg:max-w-1/2", size === "lg" &&
26
27
  "flex h-[calc(100dvh-2rem)] flex-col overflow-y-auto sm:h-3/4 sm:max-w-3/4 lg:h-1/2 lg:min-h-96 lg:max-w-1/2", size === "sm" && "max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-md", className), ...props, children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", className: cn("absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", closeButtonSize === "touch" &&
27
28
  "top-0.5 right-0.5 inline-flex size-touch-target items-center justify-center rounded-md"), children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] }))] })] }));
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,SAAS,MAAM,CAAC,EACd,GAAG,KAAK,EAC0C;IAClD,OAAO,KAAC,eAAe,CAAC,IAAI,iBAAW,QAAQ,KAAK,KAAK,GAAI,CAAA;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EAC6C;IACrD,OAAO,KAAC,eAAe,CAAC,OAAO,iBAAW,gBAAgB,KAAK,KAAK,GAAI,CAAA;AAC1E,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C;IACpD,OAAO,KAAC,eAAe,CAAC,MAAM,iBAAW,eAAe,KAAK,KAAK,GAAI,CAAA;AACxE,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C;IACnD,OAAO,KAAC,eAAe,CAAC,KAAK,iBAAW,cAAc,KAAK,KAAK,GAAI,CAAA;AACtE,CAAC;AAED,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C;IACrD,OAAO,CACL,KAAC,eAAe,CAAC,OAAO,iBACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,oKAAoK,EACpK,SAA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,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAA"}
@@ -3,7 +3,7 @@ import { Dialog as SheetPrimitive } from "radix-ui";
3
3
  declare function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>): React.JSX.Element;
4
4
  declare function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>): React.JSX.Element;
5
5
  declare function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>): React.JSX.Element;
6
- declare function SheetContent({ className, children, side, showCloseButton, closeLabel, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
6
+ declare function SheetContent({ className, children, side, showCloseButton, closeLabel, onOpenAutoFocus, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
7
7
  side?: "top" | "right" | "bottom" | "left";
8
8
  showCloseButton?: boolean;
9
9
  closeLabel?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/ui/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAEnD,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,qBAE5E;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAErD;AAED,iBAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,qB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jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { en as messages } from "../messages/en.js";
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import { XIcon } from "lucide-react";
7
8
  import { Dialog as SheetPrimitive } from "radix-ui";
@@ -20,8 +21,8 @@ function SheetPortal({ ...props }) {
20
21
  function SheetOverlay({ className, ...props }) {
21
22
  return (_jsx(SheetPrimitive.Overlay, { "data-slot": "sheet-overlay", className: cn("fixed inset-0 z-50 bg-overlay data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
22
23
  }
23
- function SheetContent({ className, children, side = "right", showCloseButton = true, closeLabel = messages.sheet.close, ...props }) {
24
- return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", className: cn("fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500", side === "right" &&
24
+ function SheetContent({ className, children, side = "right", showCloseButton = true, closeLabel = messages.sheet.close, onOpenAutoFocus, ...props }) {
25
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", onOpenAutoFocus: withFirstFieldFocus(onOpenAutoFocus), className: cn("fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500", side === "right" &&
25
26
  "inset-y-0 right-0 h-full pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", side === "left" &&
26
27
  "inset-y-0 left-0 h-full pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", side === "top" &&
27
28
  "inset-x-0 top-0 h-auto pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pl-[env(safe-area-inset-left)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", side === "bottom" &&
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../src/ui/sheet.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAEnD,SAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAoD;IAC3E,OAAO,KAAC,cAAc,CAAC,IAAI,iBAAW,OAAO,KAAK,KAAK,GAAI,CAAA;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C;IACpD,OAAO,KAAC,cAAc,CAAC,OAAO,iBAAW,eAAe,KAAK,KAAK,GAAI,CAAA;AACxE,CAAC;AAED,SAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EAC0C;IAClD,OAAO,KAAC,cAAc,CAAC,KAAK,iBAAW,aAAa,KAAK,KAAK,GAAI,CAAA;AACpE,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C;IACnD,OAAO,KAAC,cAAc,CAAC,MAAM,iBAAW,cAAc,KAAK,KAAK,GAAI,CAAA;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,EAC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gBAAgB,GACjB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/theme-notion",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,39 @@
1
+ // The form controls a dialog or sheet focuses on open, ahead of any button before them (a tooltip trigger beside a
2
+ // label opens its tooltip on focus, #1476).
3
+ const FIELD_SELECTOR = [
4
+ 'input:not([type="hidden"]):not(:disabled)',
5
+ "select:not(:disabled)",
6
+ "textarea:not(:disabled)",
7
+ '[role="combobox"]:not(:disabled):not([aria-disabled="true"])',
8
+ ].join(", ")
9
+
10
+ function findFirstField(container: Element): HTMLElement | null {
11
+ for (const candidate of container.querySelectorAll<HTMLElement>(FIELD_SELECTOR)) {
12
+ if (candidate.closest("[hidden], [inert]") === null) return candidate
13
+ }
14
+ return null
15
+ }
16
+
17
+ function focusField(field: HTMLElement): void {
18
+ field.focus({ preventScroll: true })
19
+ // Selected as Radix selects the first text input it focuses.
20
+ if (field instanceof HTMLInputElement && document.activeElement === field) field.select()
21
+ }
22
+
23
+ /**
24
+ * An `onOpenAutoFocus` handler for a Radix dialog or sheet content: it runs the app's own handler first, then, unless
25
+ * that prevented the default, focuses the first form field inside the content instead of the first focusable element.
26
+ * With no field, Radix's default focus stays.
27
+ */
28
+ export function withFirstFieldFocus(
29
+ onOpenAutoFocus: ((event: Event) => void) | undefined
30
+ ): (event: Event) => void {
31
+ return (event) => {
32
+ onOpenAutoFocus?.(event)
33
+ if (event.defaultPrevented || !(event.currentTarget instanceof Element)) return
34
+ const field = findFirstField(event.currentTarget)
35
+ if (field === null) return
36
+ event.preventDefault()
37
+ focusField(field)
38
+ }
39
+ }
@@ -1,4 +1,6 @@
1
- import type { ReactNode } from "react";
1
+ "use client";
2
+
3
+ import { useEffect, useRef, type ReactNode, type RefObject } from "react";
2
4
 
3
5
  import { cn } from "../lib/utils.js";
4
6
 
@@ -30,11 +32,61 @@ const TAB_CLASS =
30
32
 
31
33
  const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
32
34
 
35
+ // Static fades (no motion, so nothing to drop under prefers-reduced-motion) on each edge that hides tabs.
36
+ const NAV_CLASS =
37
+ "overflow-x-auto border-b border-border data-overflow-start:mask-l-from-[calc(100%---spacing(8))] data-overflow-end:mask-r-from-[calc(100%---spacing(8))]";
38
+
39
+ // Marks each edge that hides tabs (`data-overflow-start`, `data-overflow-end`); a pixel of rounding is not overflow.
40
+ function markOverflowEdges(strip: HTMLElement) {
41
+ strip.toggleAttribute("data-overflow-start", strip.scrollLeft > 1);
42
+ strip.toggleAttribute("data-overflow-end", strip.scrollWidth - strip.clientWidth - strip.scrollLeft > 1);
43
+ }
44
+
45
+ // The edge fade's width (`--spacing(8)` in NAV_CLASS): the current tab keeps this much room, so no fade covers it.
46
+ const FADE_WIDTH_PX = 32;
47
+
48
+ // Scrolls the strip itself (never the page) just far enough that the current tab is whole and clear of the fades.
49
+ function scrollTabIntoStrip(strip: HTMLElement, current: string) {
50
+ const link = [...strip.querySelectorAll<HTMLElement>("a[data-tab]")].find((candidate) => candidate.dataset["tab"] === current);
51
+ if (link === undefined) return;
52
+ const linkBox = link.getBoundingClientRect();
53
+ const start = linkBox.left - strip.getBoundingClientRect().left + strip.scrollLeft;
54
+ const end = start + linkBox.width;
55
+ const maxScroll = Math.max(0, strip.scrollWidth - strip.clientWidth);
56
+ if (start < strip.scrollLeft) strip.scrollLeft = Math.max(0, start - FADE_WIDTH_PX);
57
+ else if (end > strip.scrollLeft + strip.clientWidth) strip.scrollLeft = Math.min(maxScroll, end + FADE_WIDTH_PX - strip.clientWidth);
58
+ }
59
+
60
+ // Keeps the current tab in view (on mount and when it changes) and the overflow marks in step (on scroll and resize).
61
+ function useStripScroll(strip: RefObject<HTMLElement | null>, current: string) {
62
+ useEffect(() => {
63
+ const element = strip.current;
64
+ if (element === null) return;
65
+ const markEdges = () => markOverflowEdges(element);
66
+ element.addEventListener("scroll", markEdges, { passive: true });
67
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(markEdges);
68
+ observer?.observe(element);
69
+ return () => {
70
+ element.removeEventListener("scroll", markEdges);
71
+ observer?.disconnect();
72
+ };
73
+ }, [strip]);
74
+
75
+ useEffect(() => {
76
+ const element = strip.current;
77
+ if (element === null) return;
78
+ scrollTabIntoStrip(element, current);
79
+ markOverflowEdges(element);
80
+ }, [strip, current]);
81
+ }
82
+
33
83
  // A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
34
84
  export function TabBar<Key extends string>({ label, tabs, current, size = "default", tabClassName }: TabBarProps<Key>) {
35
85
  const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
86
+ const stripRef = useRef<HTMLElement | null>(null);
87
+ useStripScroll(stripRef, current);
36
88
  return (
37
- <nav aria-label={label} data-slot="tab-bar" className="overflow-x-auto border-b border-border">
89
+ <nav ref={stripRef} aria-label={label} data-slot="tab-bar" className={NAV_CLASS}>
38
90
  <ul className="flex gap-1 pb-1">
39
91
  {tabs.map((tab) => (
40
92
  <li key={tab.key}>
package/src/ui/dialog.tsx CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from "react"
4
4
  import { en as messages } from "../messages/en.js"
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js"
5
6
  import { cn } from "../lib/utils.js"
6
7
  import { XIcon } from "lucide-react"
7
8
  import { Dialog as DialogPrimitive } from "radix-ui"
@@ -55,6 +56,7 @@ function DialogContent({
55
56
  closeLabel = messages.dialog.close,
56
57
  closeButtonSize = "default",
57
58
  size = "default",
59
+ onOpenAutoFocus,
58
60
  ...props
59
61
  }: React.ComponentProps<typeof DialogPrimitive.Content> & {
60
62
  showCloseButton?: boolean
@@ -72,6 +74,7 @@ function DialogContent({
72
74
  <DialogOverlay />
73
75
  <DialogPrimitive.Content
74
76
  data-slot="dialog-content"
77
+ onOpenAutoFocus={withFirstFieldFocus(onOpenAutoFocus)}
75
78
  className={cn(
76
79
  "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-popover p-6 text-popover-foreground shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
77
80
  size === "wide" && "lg:max-w-1/2",
package/src/ui/sheet.tsx CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from "react"
4
4
  import { en as messages } from "../messages/en.js"
5
+ import { withFirstFieldFocus } from "../lib/focus-first-field.js"
5
6
  import { cn } from "../lib/utils.js"
6
7
  import { XIcon } from "lucide-react"
7
8
  import { Dialog as SheetPrimitive } from "radix-ui"
@@ -50,6 +51,7 @@ function SheetContent({
50
51
  side = "right",
51
52
  showCloseButton = true,
52
53
  closeLabel = messages.sheet.close,
54
+ onOpenAutoFocus,
53
55
  ...props
54
56
  }: React.ComponentProps<typeof SheetPrimitive.Content> & {
55
57
  side?: "top" | "right" | "bottom" | "left"
@@ -62,6 +64,7 @@ function SheetContent({
62
64
  <SheetOverlay />
63
65
  <SheetPrimitive.Content
64
66
  data-slot="sheet-content"
67
+ onOpenAutoFocus={withFirstFieldFocus(onOpenAutoFocus)}
65
68
  className={cn(
66
69
  "fixed z-50 flex flex-col gap-4 bg-popover text-popover-foreground shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",
67
70
  side === "right" &&