@sereno-ds/ui 0.24.0 → 0.25.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,8 +1,16 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
3
4
  import { sx } from "../_internal/style";
4
- function BottomNav({ items = [], value, onChange, style, ...rest }) {
5
- return /* @__PURE__ */ jsx(
5
+ const BottomNavContext = React.createContext(null);
6
+ function useBottomNavContext(component) {
7
+ const ctx = React.useContext(BottomNavContext);
8
+ if (!ctx) throw new Error(`<BottomNav.${component}> must be rendered inside <BottomNav>.`);
9
+ return ctx;
10
+ }
11
+ function BottomNavRoot({ value, onChange, children, style, ...rest }) {
12
+ const ctx = { value, onChange };
13
+ return /* @__PURE__ */ jsx(BottomNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
6
14
  "nav",
7
15
  {
8
16
  ...rest,
@@ -15,57 +23,61 @@ function BottomNav({ items = [], value, onChange, style, ...rest }) {
15
23
  borderTop: "var(--border-width-hairline) solid var(--border-default)",
16
24
  ...style
17
25
  }),
18
- children: items.map((it) => {
19
- const active = value === it.value;
20
- return /* @__PURE__ */ jsxs(
21
- "button",
26
+ children
27
+ }
28
+ ) });
29
+ }
30
+ function Item({ value, label, icon, badge }) {
31
+ const { value: activeValue, onChange } = useBottomNavContext("Item");
32
+ const active = activeValue === value;
33
+ return /* @__PURE__ */ jsxs(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ "aria-current": active ? "page" : void 0,
38
+ onClick: () => onChange?.(value),
39
+ style: sx({
40
+ flex: 1,
41
+ display: "flex",
42
+ flexDirection: "column",
43
+ alignItems: "center",
44
+ justifyContent: "center",
45
+ gap: 4,
46
+ border: "none",
47
+ background: "transparent",
48
+ cursor: "pointer",
49
+ outline: "none",
50
+ position: "relative",
51
+ color: active ? "var(--text-brand)" : "var(--text-muted)",
52
+ transition: "var(--transition-control)"
53
+ }),
54
+ children: [
55
+ /* @__PURE__ */ jsxs("span", { style: sx({ display: "flex", position: "relative" }), children: [
56
+ icon,
57
+ badge && /* @__PURE__ */ jsx(
58
+ "span",
59
+ {
60
+ style: sx({ position: "absolute", top: -3, right: -5, minWidth: 8, height: 8, borderRadius: "999px", background: "var(--interactive-accent)" })
61
+ }
62
+ )
63
+ ] }),
64
+ /* @__PURE__ */ jsx(
65
+ "span",
22
66
  {
23
- onClick: () => onChange && onChange(it.value),
24
67
  style: sx({
25
- flex: 1,
26
- display: "flex",
27
- flexDirection: "column",
28
- alignItems: "center",
29
- justifyContent: "center",
30
- gap: 4,
31
- border: "none",
32
- background: "transparent",
33
- cursor: "pointer",
34
- outline: "none",
35
- position: "relative",
36
- color: active ? "var(--text-brand)" : "var(--text-muted)",
37
- transition: "var(--transition-control)"
68
+ fontFamily: "var(--font-body)",
69
+ fontSize: "var(--text-2xs)",
70
+ fontWeight: active ? "var(--weight-semibold)" : "var(--weight-medium)",
71
+ letterSpacing: "var(--tracking-snug)"
38
72
  }),
39
- children: [
40
- /* @__PURE__ */ jsxs("span", { style: sx({ display: "flex", position: "relative" }), children: [
41
- it.icon,
42
- it.badge && /* @__PURE__ */ jsx(
43
- "span",
44
- {
45
- style: sx({ position: "absolute", top: -3, right: -5, minWidth: 8, height: 8, borderRadius: "999px", background: "var(--interactive-accent)" })
46
- }
47
- )
48
- ] }),
49
- /* @__PURE__ */ jsx(
50
- "span",
51
- {
52
- style: sx({
53
- fontFamily: "var(--font-body)",
54
- fontSize: "var(--text-2xs)",
55
- fontWeight: active ? "var(--weight-semibold)" : "var(--weight-medium)",
56
- letterSpacing: "var(--tracking-snug)"
57
- }),
58
- children: it.label
59
- }
60
- )
61
- ]
62
- },
63
- it.value
64
- );
65
- })
73
+ children: label
74
+ }
75
+ )
76
+ ]
66
77
  }
67
78
  );
68
79
  }
80
+ const BottomNav = Object.assign(BottomNavRoot, { Item });
69
81
  export {
70
82
  BottomNav
71
83
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/navigation/BottomNav.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\nexport interface BottomNavItem {\n value: string;\n label: string;\n icon?: React.ReactNode;\n badge?: boolean;\n}\n\n/** Mobile primary navigation — 3–5 destinations, 64px tall, translucent blurred surface. */\nexport interface BottomNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {\n items: BottomNavItem[];\n value?: string;\n onChange?: (value: string) => void;\n}\n\nexport function BottomNav({ items = [], value, onChange, style, ...rest }: BottomNavProps) {\n return (\n <nav\n {...rest}\n style={sx({\n display: 'flex',\n alignItems: 'stretch',\n height: 'var(--bottom-nav-height)',\n background: 'color-mix(in srgb,var(--bg-surface) 88%,transparent)',\n backdropFilter: 'blur(12px)',\n borderTop: 'var(--border-width-hairline) solid var(--border-default)',\n ...style,\n })}\n >\n {items.map((it) => {\n const active = value === it.value;\n return (\n <button\n key={it.value}\n onClick={() => onChange && onChange(it.value)}\n style={sx({\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n border: 'none',\n background: 'transparent',\n cursor: 'pointer',\n outline: 'none',\n position: 'relative',\n color: active ? 'var(--text-brand)' : 'var(--text-muted)',\n transition: 'var(--transition-control)',\n })}\n >\n <span style={sx({ display: 'flex', position: 'relative' })}>\n {it.icon}\n {it.badge && (\n <span\n style={sx({ position: 'absolute', top: -3, right: -5, minWidth: 8, height: 8, borderRadius: '999px', background: 'var(--interactive-accent)' })}\n />\n )}\n </span>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: active ? 'var(--weight-semibold)' : 'var(--weight-medium)',\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {it.label}\n </span>\n </button>\n );\n })}\n </nav>\n );\n}"],"mappings":";AAuDY,SAGI,KAHJ;AApDZ,SAAS,UAAU;AAgBZ,SAAS,UAAU,EAAE,QA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QAoCV;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/navigation/BottomNav.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Mobile primary navigation — a **compound component**. 3 to 5 destinations,\n * 64px tall, translucent blurred surface.\n *\n * ```tsx\n * <BottomNav value={tab} onChange={setTab}>\n * <BottomNav.Item value=\"agenda\" label=\"Calendar\" icon={<Calendar size={22} />} />\n * <BottomNav.Item value=\"clients\" label=\"Clients\" icon={<Users size={22} />} badge />\n * </BottomNav>\n * ```\n */\nexport interface BottomNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {\n value?: string;\n onChange?: (value: string) => void;\n children: React.ReactNode;\n}\n\nexport interface BottomNavItemProps {\n value: string;\n label: string;\n icon?: React.ReactNode;\n badge?: boolean;\n}\n\ninterface BottomNavContextValue {\n value?: string;\n onChange?: (value: string) => void;\n}\n\nconst BottomNavContext = React.createContext<BottomNavContextValue | null>(null);\n\nfunction useBottomNavContext(component: string): BottomNavContextValue {\n const ctx = React.useContext(BottomNavContext);\n if (!ctx) throw new Error(`<BottomNav.${component}> must be rendered inside <BottomNav>.`);\n return ctx;\n}\n\nfunction BottomNavRoot({ value, onChange, children, style, ...rest }: BottomNavProps) {\n const ctx: BottomNavContextValue = { value, onChange };\n return (\n <BottomNavContext.Provider value={ctx}>\n <nav\n {...rest}\n style={sx({\n display: 'flex',\n alignItems: 'stretch',\n height: 'var(--bottom-nav-height)',\n background: 'color-mix(in srgb,var(--bg-surface) 88%,transparent)',\n backdropFilter: 'blur(12px)',\n borderTop: 'var(--border-width-hairline) solid var(--border-default)',\n ...style,\n })}\n >\n {children}\n </nav>\n </BottomNavContext.Provider>\n );\n}\n\nfunction Item({ value, label, icon, badge }: BottomNavItemProps) {\n const { value: activeValue, onChange } = useBottomNavContext('Item');\n const active = activeValue === value;\n return (\n <button\n type=\"button\"\n aria-current={active ? 'page' : undefined}\n onClick={() => onChange?.(value)}\n style={sx({\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n border: 'none',\n background: 'transparent',\n cursor: 'pointer',\n outline: 'none',\n position: 'relative',\n color: active ? 'var(--text-brand)' : 'var(--text-muted)',\n transition: 'var(--transition-control)',\n })}\n >\n <span style={sx({ display: 'flex', position: 'relative' })}>\n {icon}\n {badge && (\n <span\n style={sx({ position: 'absolute', top: -3, right: -5, minWidth: 8, height: 8, borderRadius: '999px', background: 'var(--interactive-accent)' })}\n />\n )}\n </span>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: active ? 'var(--weight-semibold)' : 'var(--weight-medium)',\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {label}\n </span>\n </button>\n );\n}\n\nexport const BottomNav = Object.assign(BottomNavRoot, { Item });\n"],"mappings":";AA8CM,cA0CA,YA1CA;AA5CN,YAAY,WAAW;AACvB,SAAS,UAAU;AA+BnB,MAAM,mBAAmB,MAAM,cAA4C,IAAI;AAE/E,SAAS,oBAAoB,WAA0C;AACrE,QAAM,MAAM,MAAM,WAAW,gBAAgB;AAC7C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,cAAc,SAAS,wCAAwC;AACzF,SAAO;AACT;AAEA,SAAS,cAAc,EAAE,OAAO,UAAU,UAAU,OAAO,GAAG,KAAK,GAAmB;AACpF,QAAM,MAA6B,EAAE,OAAO,SAAS;AACrD,SACE,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,KAChC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,WAAW;AAAA,QACX,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH,GACF;AAEJ;AAEA,SAAS,KAAK,EAAE,OAAO,OAAO,MAAM,MAAM,GAAuB;AAC/D,QAAM,EAAE,OAAO,aAAa,SAAS,IAAI,oBAAoB,MAAM;AACnE,QAAM,SAAS,gBAAgB;AAC/B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,gBAAc,SAAS,SAAS;AAAA,MAChC,SAAS,MAAM,WAAW,KAAK;AAAA,MAC/B,OAAO,GAAG;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,UAAU;AAAA,QACV,OAAO,SAAS,sBAAsB;AAAA,QACtC,YAAY;AAAA,MACd,CAAC;AAAA,MAED;AAAA,6BAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,UAAU,WAAW,CAAC,GACtD;AAAA;AAAA,UACA,SACC;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG,EAAE,UAAU,YAAY,KAAK,IAAI,OAAO,IAAI,UAAU,GAAG,QAAQ,GAAG,cAAc,SAAS,YAAY,4BAA4B,CAAC;AAAA;AAAA,UAChJ;AAAA,WAEJ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,UAAU;AAAA,cACV,YAAY,SAAS,2BAA2B;AAAA,cAChD,eAAe;AAAA,YACjB,CAAC;AAAA,YAEA;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ;AAEO,MAAM,YAAY,OAAO,OAAO,eAAe,EAAE,KAAK,CAAC;","names":[]}
@@ -1,28 +1,27 @@
1
1
  import * as React from 'react';
2
2
 
3
- interface SidebarNavSubItem {
4
- value: string;
5
- label: string;
6
- count?: number;
7
- }
8
- interface SidebarNavItem {
9
- value: string;
10
- label: string;
11
- /** A Lucide icon passed as a node — sized by the caller. */
12
- icon?: React.ReactNode;
13
- count?: number;
14
- /** Render this leaf as a real link (routing, new-tab, SSR-active) via `linkComponent`. */
15
- href?: string;
16
- /** Second-level items. A parent with children toggles them; it is not a destination itself. */
17
- children?: SidebarNavSubItem[];
18
- }
19
- interface SidebarNavSection {
20
- /** Small uppercase heading above the block. Omit for an unlabelled group — the divider still shows. */
21
- label?: string;
22
- items: SidebarNavItem[];
23
- }
3
+ /**
4
+ * Desktop primary navigation — a **compound component**, the counterpart to
5
+ * `BottomNav`. Grouped sections with dividers, an optional second level per
6
+ * item, and a collapse toggle that drops it to a 72px icon rail.
7
+ *
8
+ * ```tsx
9
+ * <SidebarNav value={view} onChange={setView} header={<Wordmark />}>
10
+ * <SidebarNav.Section label="Workspace">
11
+ * <SidebarNav.Item value="agenda" label="Calendar" icon={<Calendar size={18} />} />
12
+ * <SidebarNav.Item value="finance" label="Finance" icon={<Wallet size={18} />}>
13
+ * <SidebarNav.SubItem value="finance:incoming" label="Incoming" />
14
+ * <SidebarNav.SubItem value="finance:payouts" label="Payouts" count={3} />
15
+ * </SidebarNav.Item>
16
+ * </SidebarNav.Section>
17
+ * </SidebarNav>
18
+ * ```
19
+ *
20
+ * `Item` is not a destination once it has `SubItem` children — it toggles
21
+ * them instead (an inline accordion when expanded, a hover flyout on the
22
+ * collapsed rail).
23
+ */
24
24
  interface SidebarNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
25
- sections: SidebarNavSection[];
26
25
  value?: string;
27
26
  onChange?: (value: string) => void;
28
27
  /** Controlled collapse (icon-only rail). */
@@ -41,13 +40,39 @@ interface SidebarNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onCha
41
40
  };
42
41
  /** Component used to render items that carry `href` (e.g. Next's `Link`). Defaults to `'a'`. */
43
42
  linkComponent?: React.ElementType;
43
+ children: React.ReactNode;
44
44
  }
45
- /**
46
- * Desktop primary navigation — the counterpart to `BottomNav`. Grouped sections
47
- * with dividers, an optional second level per item, and a collapse toggle that
48
- * drops it to a 72px icon rail. Controlled: `value` / `onChange` for the active
49
- * destination, `collapsed` / `onCollapsedChange` for the rail state.
50
- */
51
- declare function SidebarNav({ sections, value, onChange, collapsed: collapsedProp, defaultCollapsed, onCollapsedChange, collapsible, header, footer, labels, linkComponent, style, ...rest }: SidebarNavProps): React.JSX.Element;
45
+ interface SidebarNavSectionProps {
46
+ /** Small uppercase heading above the block. Omit for an unlabelled group — the divider still shows. */
47
+ label?: string;
48
+ children: React.ReactNode;
49
+ }
50
+ interface SidebarNavItemProps {
51
+ value: string;
52
+ label: string;
53
+ /** A Lucide icon passed as a node — sized by the caller. */
54
+ icon?: React.ReactNode;
55
+ count?: number;
56
+ /** Render this leaf as a real link (routing, new-tab, SSR-active) via `linkComponent`. */
57
+ href?: string;
58
+ /** `SidebarNav.SubItem`s — a second level. Present ⇒ this item is not a destination itself, it toggles them. */
59
+ children?: React.ReactNode;
60
+ }
61
+ interface SidebarNavSubItemProps {
62
+ value: string;
63
+ label: string;
64
+ count?: number;
65
+ /** Set by the parent `Item` when rendering this into the collapsed rail's flyout popover — not for consumers to pass. */
66
+ compact?: boolean;
67
+ }
68
+ declare function SidebarNavRoot({ value, onChange, collapsed: collapsedProp, defaultCollapsed, onCollapsedChange, collapsible, header, footer, labels, linkComponent, children, style, ...rest }: SidebarNavProps): React.JSX.Element;
69
+ declare function Section({ label, children }: SidebarNavSectionProps): React.JSX.Element;
70
+ declare function Item({ value, label, icon, count, href, children }: SidebarNavItemProps): React.JSX.Element;
71
+ declare function SubItem({ value, label, count, compact }: SidebarNavSubItemProps): React.JSX.Element;
72
+ declare const SidebarNav: typeof SidebarNavRoot & {
73
+ Section: typeof Section;
74
+ Item: typeof Item;
75
+ SubItem: typeof SubItem;
76
+ };
52
77
 
53
- export { SidebarNav, type SidebarNavItem, type SidebarNavProps, type SidebarNavSection, type SidebarNavSubItem };
78
+ export { SidebarNav, type SidebarNavItemProps, type SidebarNavProps, type SidebarNavSectionProps, type SidebarNavSubItemProps };