@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,20 +1,21 @@
1
1
  import * as React from 'react';
2
2
 
3
- interface StepperStep {
4
- /** Stable identifier; falls back to the array index when omitted. */
5
- value?: string;
6
- /** Short label — shown next to the step counter for the current step. */
7
- label: string;
8
- }
9
3
  /**
10
- * Progress indicator for a linear multi-step flow (onboarding, guided setup).
11
- * Renders the segment track plus a `<counter> · <label>` line (a dot separates
12
- * the counter from the current step's label). The counter defaults to
13
- * `Step N of M` — the DS ships no localised copy; pass `stepLabel` for another
14
- * language.
4
+ * Progress indicator for a linear multi-step flow — a **compound component**
5
+ * (onboarding, guided setup). Renders the segment track plus a
6
+ * `<counter> · <label>` line (a dot separates the counter from the current
7
+ * step's label). The counter defaults to `Step N of M` — the DS ships no
8
+ * localised copy; pass `stepLabel` for another language.
9
+ *
10
+ * ```tsx
11
+ * <Stepper current={step} onStepClick={setStep}>
12
+ * <Stepper.Step label="Your profile" />
13
+ * <Stepper.Step label="First service" />
14
+ * <Stepper.Step label="Your schedule" />
15
+ * </Stepper>
16
+ * ```
15
17
  */
16
18
  interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {
17
- steps: StepperStep[];
18
19
  /** Zero-based index of the active step. */
19
20
  current?: number;
20
21
  /** When provided, completed and current steps become clickable (back-navigation only). */
@@ -27,7 +28,20 @@ interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {
27
28
  * show only the current step's `label`.
28
29
  */
29
30
  stepLabel?: (current: number, total: number) => React.ReactNode;
31
+ children: React.ReactNode;
32
+ }
33
+ interface StepperStepProps {
34
+ /** Stable identifier — not read by `Stepper` itself, only for the caller's own use (e.g. a React `key`). */
35
+ value?: string;
36
+ /** Short label — shown next to the step counter while this step is active. */
37
+ label: string;
38
+ /** Set by the root via `cloneElement` — this step's position among its siblings. Not for consumers to pass. */
39
+ index?: number;
30
40
  }
31
- declare function Stepper({ steps, current, onStepClick, variant, stepLabel, style, ...rest }: StepperProps): React.JSX.Element;
41
+ declare function StepperRoot({ current, onStepClick, variant, stepLabel, children, style, ...rest }: StepperProps): React.JSX.Element;
42
+ declare function Step({ label, index }: StepperStepProps): React.JSX.Element;
43
+ declare const Stepper: typeof StepperRoot & {
44
+ Step: typeof Step;
45
+ };
32
46
 
33
- export { Stepper, type StepperProps, type StepperStep };
47
+ export { Stepper, type StepperProps, type StepperStepProps };
@@ -1,86 +1,117 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
3
4
  import { sx } from "../_internal/style";
4
5
  const defaultStepLabel = (current, total) => `Step ${current} of ${total}`;
5
- function Stepper({ steps = [], current = 0, onStepClick, variant = "bar", stepLabel = defaultStepLabel, style, ...rest }) {
6
+ const StepperContext = React.createContext(null);
7
+ function useStepperContext(component) {
8
+ const ctx = React.useContext(StepperContext);
9
+ if (!ctx) throw new Error(`<Stepper.${component}> must be rendered inside <Stepper>.`);
10
+ return ctx;
11
+ }
12
+ function StepperRoot({ current = 0, onStepClick, variant = "bar", stepLabel = defaultStepLabel, children, style, ...rest }) {
6
13
  const dots = variant === "dots";
7
- const clickable = typeof onStepClick === "function";
8
- return /* @__PURE__ */ jsxs("div", { ...rest, style: sx({ display: "flex", flexDirection: "column", gap: "var(--space-3)", ...style }), children: [
9
- /* @__PURE__ */ jsx("div", { style: sx({ display: "flex", gap: dots ? "var(--space-2)" : "var(--space-1)", alignItems: "center" }), children: steps.map((s, i) => {
10
- const done = i < current;
11
- const active = i === current;
12
- const reachable = clickable && i <= current;
13
- const common = {
14
- flex: dots ? "0 0 auto" : 1,
15
- border: "none",
16
- padding: 0,
17
- cursor: reachable ? "pointer" : "default",
18
- background: done || active ? "var(--interactive-primary)" : "var(--border-default)",
19
- transition: "background-color var(--duration-normal) var(--ease-standard)"
20
- };
21
- return dots ? /* @__PURE__ */ jsx(
22
- "button",
23
- {
24
- "aria-label": s.label,
25
- "aria-current": active ? "step" : void 0,
26
- disabled: !reachable,
27
- onClick: () => reachable && onStepClick && onStepClick(i),
28
- style: sx({ ...common, width: active ? 24 : 8, height: 8, borderRadius: "var(--radius-pill)" })
29
- },
30
- s.value || i
31
- ) : /* @__PURE__ */ jsx(
32
- "button",
33
- {
34
- "aria-label": s.label,
35
- "aria-current": active ? "step" : void 0,
36
- disabled: !reachable,
37
- onClick: () => reachable && onStepClick && onStepClick(i),
38
- style: sx({ ...common, height: 3, borderRadius: "var(--radius-pill)" })
39
- },
40
- s.value || i
41
- );
42
- }) }),
43
- steps[current] && /* @__PURE__ */ jsxs("div", { style: sx({ display: "flex", alignItems: "center", gap: "var(--space-2)", minWidth: 0 }), children: [
44
- (() => {
45
- const counter = stepLabel(current + 1, steps.length);
46
- return counter == null ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
14
+ const items = React.Children.toArray(children);
15
+ const activeLabel = items[current]?.props.label;
16
+ const ctx = { current, onStepClick, variant };
17
+ return /* @__PURE__ */ jsx(StepperContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs("div", { ...rest, style: sx({ display: "flex", flexDirection: "column", gap: "var(--space-3)", ...style }), children: [
18
+ /* @__PURE__ */ jsx("div", { style: sx({ display: "flex", gap: dots ? "var(--space-2)" : "var(--space-1)", alignItems: "center" }), children: items.map((child, i) => React.cloneElement(child, { index: i, key: child.key ?? i })) }),
19
+ activeLabel !== void 0 && /* @__PURE__ */ jsxs(
20
+ "div",
21
+ {
22
+ style: sx({
23
+ display: "flex",
24
+ alignItems: "center",
25
+ gap: "var(--space-2)",
26
+ minWidth: 0,
27
+ animation: "sereno-fade-in var(--duration-fast) var(--ease-out)"
28
+ }),
29
+ children: [
30
+ (() => {
31
+ const counter = stepLabel(current + 1, items.length);
32
+ return counter == null ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
33
+ /* @__PURE__ */ jsx(
34
+ "span",
35
+ {
36
+ style: sx({
37
+ flex: "0 0 auto",
38
+ fontFamily: "var(--font-body)",
39
+ fontSize: "var(--text-2xs)",
40
+ fontWeight: "var(--weight-bold)",
41
+ letterSpacing: "var(--tracking-wide)",
42
+ textTransform: "uppercase",
43
+ color: "var(--text-muted)"
44
+ }),
45
+ children: counter
46
+ }
47
+ ),
48
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: sx({ flex: "0 0 auto", width: 3, height: 3, borderRadius: "999px", background: "var(--border-strong)" }) })
49
+ ] });
50
+ })(),
47
51
  /* @__PURE__ */ jsx(
48
52
  "span",
49
53
  {
50
54
  style: sx({
51
- flex: "0 0 auto",
55
+ minWidth: 0,
56
+ overflow: "hidden",
57
+ textOverflow: "ellipsis",
58
+ whiteSpace: "nowrap",
52
59
  fontFamily: "var(--font-body)",
53
- fontSize: "var(--text-2xs)",
54
- fontWeight: "var(--weight-bold)",
55
- letterSpacing: "var(--tracking-wide)",
56
- textTransform: "uppercase",
57
- color: "var(--text-muted)"
60
+ fontSize: "var(--text-sm)",
61
+ fontWeight: "var(--weight-semibold)",
62
+ color: "var(--text-primary)"
58
63
  }),
59
- children: counter
64
+ children: activeLabel
60
65
  }
61
- ),
62
- /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: sx({ flex: "0 0 auto", width: 3, height: 3, borderRadius: "999px", background: "var(--border-strong)" }) })
63
- ] });
64
- })(),
65
- /* @__PURE__ */ jsx(
66
- "span",
67
- {
68
- style: sx({
69
- minWidth: 0,
70
- overflow: "hidden",
71
- textOverflow: "ellipsis",
72
- whiteSpace: "nowrap",
73
- fontFamily: "var(--font-body)",
74
- fontSize: "var(--text-sm)",
75
- fontWeight: "var(--weight-semibold)",
76
- color: "var(--text-primary)"
77
- }),
78
- children: steps[current].label
79
- }
80
- )
81
- ] })
82
- ] });
66
+ )
67
+ ]
68
+ },
69
+ current
70
+ )
71
+ ] }) });
72
+ }
73
+ function Step({ label, index }) {
74
+ const { current, onStepClick, variant } = useStepperContext("Step");
75
+ const dots = variant === "dots";
76
+ const i = index ?? 0;
77
+ const done = i < current;
78
+ const active = i === current;
79
+ const reachable = typeof onStepClick === "function" && i <= current;
80
+ const common = {
81
+ flex: dots ? "0 0 auto" : 1,
82
+ border: "none",
83
+ padding: 0,
84
+ cursor: reachable ? "pointer" : "default",
85
+ background: done || active ? "var(--interactive-primary)" : "var(--border-default)",
86
+ transition: "background-color var(--duration-normal) var(--ease-standard)"
87
+ };
88
+ return dots ? /* @__PURE__ */ jsx(
89
+ "button",
90
+ {
91
+ "aria-label": label,
92
+ "aria-current": active ? "step" : void 0,
93
+ disabled: !reachable,
94
+ onClick: () => reachable && onStepClick(i),
95
+ style: sx({
96
+ ...common,
97
+ width: active ? 24 : 8,
98
+ height: 8,
99
+ borderRadius: "var(--radius-pill)",
100
+ transition: `${common.transition}, width var(--duration-normal) var(--ease-standard)`
101
+ })
102
+ }
103
+ ) : /* @__PURE__ */ jsx(
104
+ "button",
105
+ {
106
+ "aria-label": label,
107
+ "aria-current": active ? "step" : void 0,
108
+ disabled: !reachable,
109
+ onClick: () => reachable && onStepClick(i),
110
+ style: sx({ ...common, height: 3, borderRadius: "var(--radius-pill)" })
111
+ }
112
+ );
83
113
  }
114
+ const Stepper = Object.assign(StepperRoot, { Step });
84
115
  export {
85
116
  Stepper
86
117
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/navigation/Stepper.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\nexport interface StepperStep {\n /** Stable identifier; falls back to the array index when omitted. */\n value?: string;\n /** Short label — shown next to the step counter for the current step. */\n label: string;\n}\n\n/**\n * Progress indicator for a linear multi-step flow (onboarding, guided setup).\n * Renders the segment track plus a `<counter> · <label>` line (a dot separates\n * the counter from the current step's label). The counter defaults to\n * `Step N of M` — the DS ships no localised copy; pass `stepLabel` for another\n * language.\n */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n steps: StepperStep[];\n /** Zero-based index of the active step. */\n current?: number;\n /** When provided, completed and current steps become clickable (back-navigation only). */\n onStepClick?: (index: number) => void;\n /** `bar` = full-width segments (desktop wizards). `dots` = compact pills (mobile). */\n variant?: 'bar' | 'dots';\n /**\n * Formats the step counter (both args 1-based / total). Default:\n * `` `Step ${current} of ${total}` ``. Return `null` to drop the counter and\n * show only the current step's `label`.\n */\n stepLabel?: (current: number, total: number) => React.ReactNode;\n}\n\nconst defaultStepLabel = (current: number, total: number) => `Step ${current} of ${total}`;\n\nexport function Stepper({ steps = [], current = 0, onStepClick, variant = 'bar', stepLabel = defaultStepLabel, style, ...rest }: StepperProps) {\n const dots = variant === 'dots';\n const clickable = typeof onStepClick === 'function';\n return (\n <div {...rest} style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)', ...style })}>\n <div style={sx({ display: 'flex', gap: dots ? 'var(--space-2)' : 'var(--space-1)', alignItems: 'center' })}>\n {steps.map((s, i) => {\n const done = i < current;\n const active = i === current;\n const reachable = clickable && i <= current;\n const common = {\n flex: dots ? '0 0 auto' : 1,\n border: 'none',\n padding: 0,\n cursor: reachable ? 'pointer' : 'default',\n background: done || active ? 'var(--interactive-primary)' : 'var(--border-default)',\n transition: 'background-color var(--duration-normal) var(--ease-standard)',\n };\n return dots ? (\n <button\n key={s.value || i}\n aria-label={s.label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick && onStepClick(i)}\n style={sx({ ...common, width: active ? 24 : 8, height: 8, borderRadius: 'var(--radius-pill)' })}\n />\n ) : (\n <button\n key={s.value || i}\n aria-label={s.label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick && onStepClick(i)}\n style={sx({ ...common, height: 3, borderRadius: 'var(--radius-pill)' })}\n />\n );\n })}\n </div>\n {steps[current] && (\n <div style={sx({ display: 'flex', alignItems: 'center', gap: 'var(--space-2)', minWidth: 0 })}>\n {(() => {\n const counter = stepLabel(current + 1, steps.length);\n return counter == null ? null : (\n <>\n <span\n style={sx({\n flex: '0 0 auto',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-wide)',\n textTransform: 'uppercase',\n color: 'var(--text-muted)',\n })}\n >\n {counter}\n </span>\n <span aria-hidden style={sx({ flex: '0 0 auto', width: 3, height: 3, borderRadius: '999px', background: 'var(--border-strong)' })} />\n </>\n );\n })()}\n <span\n style={sx({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n })}\n >\n {steps[current].label}\n </span>\n </div>\n )}\n </div>\n );\n}"],"mappings":";AAwDY,SAyBE,UAzBF,KAyBE,YAzBF;AArDZ,SAAS,UAAU;AAgCnB,MAAM,mBAAmB,CAAC,SAAiB,UAAkB,QAAQ,OAAO,OAAO,KAAK;AAEjF,SAAS,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU,GAAG,aAAa,UAAU,OAAO,YAAY,kBAAkB,OAAO,GAAG,KAAK,GAAiB;AAC7I,QAAM,OAAO,YAAY;AACzB,QAAM,YAAY,OAAO,gBAAgB;AACzC,SACE,qBAAC,SAAK,GAAG,MAAM,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,kBAAkB,GAAG,MAAM,CAAC,GACpG;AAAA,wBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,OAAO,mBAAmB,kBAAkB,YAAY,SAAS,CAAC,GACtG,gBAAM,IAAI,CAAC,GAAG,MAAM;AACnB,YAAM,OAAO,IAAI;AACjB,YAAM,SAAS,MAAM;AACrB,YAAM,YAAY,aAAa,KAAK;AACpC,YAAM,SAAS;AAAA,QACb,MAAM,OAAO,aAAa;AAAA,QAC1B,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,QAAQ,YAAY,YAAY;AAAA,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AAA,WACrI;AAAA,MAEJ,GAAG;AAAA,MACH;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG;AAAA,YACR,UAAU;AAAA,YACV,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO;AAAA,UACT,CAAC;AAAA,UAEA,gBAAM,OAAO,EAAE;AAAA;AAAA,MAClB;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/navigation/Stepper.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Progress indicator for a linear multi-step flow — a **compound component**\n * (onboarding, guided setup). Renders the segment track plus a\n * `<counter> · <label>` line (a dot separates the counter from the current\n * step's label). The counter defaults to `Step N of M` — the DS ships no\n * localised copy; pass `stepLabel` for another language.\n *\n * ```tsx\n * <Stepper current={step} onStepClick={setStep}>\n * <Stepper.Step label=\"Your profile\" />\n * <Stepper.Step label=\"First service\" />\n * <Stepper.Step label=\"Your schedule\" />\n * </Stepper>\n * ```\n */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Zero-based index of the active step. */\n current?: number;\n /** When provided, completed and current steps become clickable (back-navigation only). */\n onStepClick?: (index: number) => void;\n /** `bar` = full-width segments (desktop wizards). `dots` = compact pills (mobile). */\n variant?: 'bar' | 'dots';\n /**\n * Formats the step counter (both args 1-based / total). Default:\n * `` `Step ${current} of ${total}` ``. Return `null` to drop the counter and\n * show only the current step's `label`.\n */\n stepLabel?: (current: number, total: number) => React.ReactNode;\n children: React.ReactNode;\n}\n\nexport interface StepperStepProps {\n /** Stable identifier — not read by `Stepper` itself, only for the caller's own use (e.g. a React `key`). */\n value?: string;\n /** Short label — shown next to the step counter while this step is active. */\n label: string;\n /** Set by the root via `cloneElement` — this step's position among its siblings. Not for consumers to pass. */\n index?: number;\n}\n\ninterface StepperContextValue {\n current: number;\n onStepClick?: (index: number) => void;\n variant: 'bar' | 'dots';\n}\n\nconst defaultStepLabel = (current: number, total: number) => `Step ${current} of ${total}`;\n\nconst StepperContext = React.createContext<StepperContextValue | null>(null);\n\nfunction useStepperContext(component: string): StepperContextValue {\n const ctx = React.useContext(StepperContext);\n if (!ctx) throw new Error(`<Stepper.${component}> must be rendered inside <Stepper>.`);\n return ctx;\n}\n\nfunction StepperRoot({ current = 0, onStepClick, variant = 'bar', stepLabel = defaultStepLabel, children, style, ...rest }: StepperProps) {\n const dots = variant === 'dots';\n // Steps render their own segment (DOM order does the layout, like `Tabs.Tab`);\n // the root only needs each one's position (to compare against `current`) and,\n // for the line below the track, the active one's `label`.\n const items = React.Children.toArray(children) as React.ReactElement<StepperStepProps>[];\n const activeLabel = items[current]?.props.label;\n\n const ctx: StepperContextValue = { current, onStepClick, variant };\n\n return (\n <StepperContext.Provider value={ctx}>\n <div {...rest} style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)', ...style })}>\n <div style={sx({ display: 'flex', gap: dots ? 'var(--space-2)' : 'var(--space-1)', alignItems: 'center' })}>\n {items.map((child, i) => React.cloneElement(child, { index: i, key: child.key ?? i }))}\n </div>\n {activeLabel !== undefined && (\n <div\n key={current}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n minWidth: 0,\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-out)',\n })}\n >\n {(() => {\n const counter = stepLabel(current + 1, items.length);\n return counter == null ? null : (\n <>\n <span\n style={sx({\n flex: '0 0 auto',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-wide)',\n textTransform: 'uppercase',\n color: 'var(--text-muted)',\n })}\n >\n {counter}\n </span>\n <span aria-hidden style={sx({ flex: '0 0 auto', width: 3, height: 3, borderRadius: '999px', background: 'var(--border-strong)' })} />\n </>\n );\n })()}\n <span\n style={sx({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n })}\n >\n {activeLabel}\n </span>\n </div>\n )}\n </div>\n </StepperContext.Provider>\n );\n}\n\nfunction Step({ label, index }: StepperStepProps) {\n const { current, onStepClick, variant } = useStepperContext('Step');\n const dots = variant === 'dots';\n const i = index ?? 0;\n const done = i < current;\n const active = i === current;\n const reachable = typeof onStepClick === 'function' && i <= current;\n const common = {\n flex: dots ? '0 0 auto' : 1,\n border: 'none',\n padding: 0,\n cursor: reachable ? 'pointer' : 'default',\n background: done || active ? 'var(--interactive-primary)' : 'var(--border-default)',\n transition: 'background-color var(--duration-normal) var(--ease-standard)',\n };\n return dots ? (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({\n ...common,\n width: active ? 24 : 8,\n height: 8,\n borderRadius: 'var(--radius-pill)',\n transition: `${common.transition}, width var(--duration-normal) var(--ease-standard)`,\n })}\n />\n ) : (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({ ...common, height: 3, borderRadius: 'var(--radius-pill)' })}\n />\n );\n}\n\nexport const Stepper = Object.assign(StepperRoot, { Step });\n"],"mappings":";AA0EQ,SAiBQ,UAjBR,KAiBQ,YAjBR;AAxER,YAAY,WAAW;AACvB,SAAS,UAAU;AAgDnB,MAAM,mBAAmB,CAAC,SAAiB,UAAkB,QAAQ,OAAO,OAAO,KAAK;AAExF,MAAM,iBAAiB,MAAM,cAA0C,IAAI;AAE3E,SAAS,kBAAkB,WAAwC;AACjE,QAAM,MAAM,MAAM,WAAW,cAAc;AAC3C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,YAAY,SAAS,sCAAsC;AACrF,SAAO;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,MACX,SAAS,MAAM,aAAa,YAAa,CAAC;AAAA,MAC1C,OAAO,GAAG,EAAE,GAAG,QAAQ,QAAQ,GAAG,cAAc,qBAAqB,CAAC;AAAA;AAAA,EACxE;AAEJ;AAEO,MAAM,UAAU,OAAO,OAAO,aAAa,EAAE,KAAK,CAAC;","names":[]}
@@ -1,23 +1,54 @@
1
1
  import * as React from 'react';
2
2
 
3
- interface TabItem {
4
- value: string;
5
- label: string;
6
- icon?: React.ReactNode;
7
- count?: number;
8
- }
9
3
  /**
10
- * Horizontal section switcher. `underline` for page-level sections, `pill` for
11
- * filters inside a panel. When the tabs overflow their width the strip scrolls
12
- * horizontally, with a chevron on whichever side has more.
4
+ * Horizontal section switcher — a **compound component**. `underline` for
5
+ * page-level sections, `pill` for filters inside a panel. When the tabs
6
+ * overflow their width the strip scrolls horizontally, with a chevron on
7
+ * whichever side has more; picking a tab scrolls it into view.
8
+ *
9
+ * ```tsx
10
+ * <Tabs value={tab} onChange={setTab} variant="pill">
11
+ * <Tabs.List>
12
+ * <Tabs.Tab value="today" count={5}>Today</Tabs.Tab>
13
+ * <Tabs.Tab value="week" count={23}>Week</Tabs.Tab>
14
+ * </Tabs.List>
15
+ * <Tabs.Panel value="today">…</Tabs.Panel>
16
+ * <Tabs.Panel value="week">…</Tabs.Panel>
17
+ * </Tabs>
18
+ * ```
19
+ *
20
+ * `Tabs.Panel` is optional — nothing requires it. Render your own content
21
+ * next to `Tabs.List`, keyed off the controlled `value`, if that reads
22
+ * better for the screen.
13
23
  */
14
- interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
15
- items: TabItem[];
24
+ interface TabsProps {
16
25
  value?: string;
17
26
  onChange?: (value: string) => void;
18
27
  variant?: 'underline' | 'pill';
19
28
  fullWidth?: boolean;
29
+ children: React.ReactNode;
30
+ }
31
+ interface TabsListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
32
+ children: React.ReactNode;
33
+ }
34
+ interface TabsTabProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onClick'> {
35
+ value: string;
36
+ icon?: React.ReactNode;
37
+ count?: number;
38
+ children: React.ReactNode;
39
+ }
40
+ interface TabsPanelProps extends React.HTMLAttributes<HTMLDivElement> {
41
+ value: string;
42
+ children: React.ReactNode;
20
43
  }
21
- declare function Tabs({ items, value, onChange, variant, fullWidth, style, ...rest }: TabsProps): React.JSX.Element;
44
+ declare function TabsRoot({ value, onChange, variant, fullWidth, children }: TabsProps): React.JSX.Element;
45
+ declare function List({ children, style, ...rest }: TabsListProps): React.JSX.Element;
46
+ declare function Tab({ value, icon, count, children, style, ...rest }: TabsTabProps): React.JSX.Element;
47
+ declare function Panel({ value, children, ...rest }: TabsPanelProps): React.JSX.Element | null;
48
+ declare const Tabs: typeof TabsRoot & {
49
+ List: typeof List;
50
+ Tab: typeof Tab;
51
+ Panel: typeof Panel;
52
+ };
22
53
 
23
- export { type TabItem, Tabs, type TabsProps };
54
+ export { Tabs, type TabsListProps, type TabsPanelProps, type TabsProps, type TabsTabProps };