@vvedantb/ui 0.58.1 → 0.59.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.
package/README.md CHANGED
@@ -1246,7 +1246,7 @@ Rail-variant pieces (all work without the rail variant too, except the first):
1246
1246
  - **Dock motion of the sidebar panel.** In `variant="rail"` the panel shrinks into the `RailCollapseTile` on hide and grows back out on show, and the main content slides with the sidebar width. `panelMotion="none"` on `AppShell` turns it off (a rail-only input: a type error on `"floating"`). For a toggle of your own (a hotkey, a context setter) call `toggleShellPanel(collapsed, toggle)`, or `popOutShellPanel(hide)` and `popInShellPanelNextFrame()`. For a tile of your own, spread `shellDockTileProps` on it.
1247
1247
  - **`dockPopIn`, `dockNudge`, `dockPopOut`, `slideWith`, `slideNextResize`** (`DockEdge`, `DOCK_MOTION_EVENT`, `DockMotionEvent`, `dockMotionOff`): the same motion for any panel that docks into a tile. All of it stops with `MotionProvider reducedMotion` and `PageMotionProvider disabled`: a show is instant and a hide runs at once.
1248
1248
  - **`ButtonTrack`** (`buttonTrackClass`): a trough for a group of flat buttons, for page header actions (`direction="row"`, default) or tools under a side rail (`direction="column"`). It renders nothing visible when empty.
1249
- - **`SidePanelTabs`**: tabs on a rail beside a content card, for a side panel. `SidePanelTabs.Frame({ collapsed, rail })` holds a `SidePanelTabs.Rail` with a `SidePanelTabs.List({ value, onValueChange })` of `SidePanelTabs.Tab({ value, label, icon, activeIcon, layout, count, indicator, onReselect })`. From `md` up the rail is on the right edge and an arrow on the card points at the active tab; below `md` the tabs are a strip on top. `collapsed` hides the card and leaves the rail (`SIDE_PANEL_RAIL_WIDTH_PX`, 44; `SIDE_PANEL_RAIL_LABELLED_WIDTH_PX`, 76). Close it with `popOutSidePanel(root, collapse)`. It does not depend on the `AppShell` variant. The rail is on the right only.
1249
+ - **`SidePanelTabs`**: tabs on a rail beside a content card, for a side panel. `SidePanelTabs.Frame({ collapsed, rail })` holds a `SidePanelTabs.Rail` with a `SidePanelTabs.List({ value, onValueChange })` of `SidePanelTabs.Tab({ value, label, icon, activeIcon, layout, count, indicator, onReselect })`. From `md` up the rail is on the right edge and an arrow on the card points at the active tab; below `md` the tabs are a strip on top. `collapsed` hides the card and leaves the rail (`SIDE_PANEL_RAIL_WIDTH_PX`, 44; `SIDE_PANEL_RAIL_LABELLED_WIDTH_PX`, 76). Close it with `popOutSidePanel(root, collapse)`. It does not depend on the `AppShell` variant. The rail is on the right only. The card is `bg-surface md:rounded-surface`. The tab trough is `bg-default`, and in dark (and `.dark.neutral`) it takes the card tone (`dark:bg-surface`) so the `bg-segment` pill stands out; `Sidebar.RailGroup` and `ButtonTrack` troughs do the same.
1250
1250
 
1251
1251
  ```tsx
1252
1252
  <SidePanelTabs.Frame
@@ -7,7 +7,7 @@ import { cn } from "../../src/utils/cn.js";
7
7
  * pill tone. Empty, it takes no space.
8
8
  */
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export const buttonTrackClass = "flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
10
+ export const buttonTrackClass = "flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden dark:bg-surface [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
11
11
  /** A group of icon buttons on one trough, for example the actions of a page header. */
12
12
  export function ButtonTrack(t0) {
13
13
  const $ = _c(10);
@@ -199,7 +199,7 @@ function Frame(t0) {
199
199
  const t6 = collapsed && "md:hidden";
200
200
  let t7;
201
201
  if ($[7] !== cardClassName || $[8] !== t6) {
202
- t7 = cn("relative min-h-0 min-w-0 flex-1 overflow-hidden bg-surface md:my-2 md:mr-1.5 md:rounded-lg", t6, cardClassName);
202
+ t7 = cn("relative min-h-0 min-w-0 flex-1 overflow-hidden bg-surface md:my-2 md:mr-1.5 md:rounded-surface", t6, cardClassName);
203
203
  $[7] = cardClassName;
204
204
  $[8] = t6;
205
205
  $[9] = t7;
@@ -338,7 +338,7 @@ function List(t0) {
338
338
  const t4 = labelled && "md:w-full";
339
339
  let t5;
340
340
  if ($[10] !== listClassName || $[11] !== t4) {
341
- t5 = cn("scrollbar-none h-auto max-w-full justify-start gap-1 overflow-x-auto rounded-xl border-0 bg-default p-0.5 shadow-none md:max-w-none md:flex-col md:overflow-x-hidden md:overflow-y-auto [&>.t-tabs-pill]:bg-segment", t4, listClassName);
341
+ t5 = cn("scrollbar-none h-auto max-w-full justify-start gap-1 overflow-x-auto rounded-xl border-0 bg-default p-0.5 shadow-none dark:bg-surface md:max-w-none md:flex-col md:overflow-x-hidden md:overflow-y-auto [&>.t-tabs-pill]:bg-segment", t4, listClassName);
342
342
  $[10] = listClassName;
343
343
  $[11] = t4;
344
344
  $[12] = t5;
@@ -348,6 +348,8 @@ function List(t0) {
348
348
  let t6;
349
349
  if ($[13] !== children || $[14] !== t3 || $[15] !== t5) {
350
350
  t6 = /*#__PURE__*/_jsx(TabsList, {
351
+ variant: "segmented",
352
+ pillMotion: "xy",
351
353
  "aria-label": t3,
352
354
  className: t5,
353
355
  children: children
@@ -32,7 +32,7 @@ export function railTileStateClass(active, grouped = false) {
32
32
  * 4px padding, so the trough corners stay concentric with the pill at any
33
33
  * `--radius`. A plain `rounded-xl` is a fixed 12px, smaller than a 16px pill.
34
34
  */
35
- export const railGroupClass = "relative isolate flex flex-col items-center gap-1 rounded-[calc(var(--radius-lg)+0.25rem)] bg-default p-1";
35
+ export const railGroupClass = "relative isolate flex flex-col items-center gap-1 rounded-[calc(var(--radius-lg)+0.25rem)] bg-default p-1 dark:bg-surface";
36
36
 
37
37
  /** The `RailGroup` sliding pill: the segmented tabs pill, with the tile radius. */
38
38
  export const railGroupPillClass = "t-tabs-pill rounded-lg bg-segment";
@@ -28,9 +28,10 @@ const tabsListSizeClasses = {
28
28
  };
29
29
  const TabsListVariantContext = /*#__PURE__*/React.createContext("pills");
30
30
  const TabsList = /*#__PURE__*/React.forwardRef((t0, ref) => {
31
- const $ = _c(34);
31
+ const $ = _c(35);
32
32
  let children;
33
33
  let className;
34
+ let pillMotionProp;
34
35
  let props;
35
36
  let size;
36
37
  let variantProp;
@@ -40,42 +41,45 @@ const TabsList = /*#__PURE__*/React.forwardRef((t0, ref) => {
40
41
  children,
41
42
  variant: variantProp,
42
43
  size,
44
+ pillMotion: pillMotionProp,
43
45
  ...props
44
46
  } = t0);
45
47
  $[0] = t0;
46
48
  $[1] = children;
47
49
  $[2] = className;
48
- $[3] = props;
49
- $[4] = size;
50
- $[5] = variantProp;
50
+ $[3] = pillMotionProp;
51
+ $[4] = props;
52
+ $[5] = size;
53
+ $[6] = variantProp;
51
54
  } else {
52
55
  children = $[1];
53
56
  className = $[2];
54
- props = $[3];
55
- size = $[4];
56
- variantProp = $[5];
57
+ pillMotionProp = $[3];
58
+ props = $[4];
59
+ size = $[5];
60
+ variantProp = $[6];
57
61
  }
58
62
  const config = useUiConfig("Tabs");
59
63
  const cn = useCn();
60
64
  const variant = variantProp ?? config?.variant ?? "pills";
61
- const pillMotion = config?.pillMotion ?? "x";
65
+ const pillMotion = pillMotionProp ?? config?.pillMotion ?? "x";
62
66
  const listRef = React.useRef(null);
63
67
  const pillRef = React.useRef(null);
64
68
  const pillReadyRef = React.useRef(false);
65
69
  let t1;
66
- if ($[6] !== ref) {
70
+ if ($[7] !== ref) {
67
71
  t1 = node => {
68
72
  listRef.current = node;
69
73
  assignRef(ref, node);
70
74
  };
71
- $[6] = ref;
72
- $[7] = t1;
75
+ $[7] = ref;
76
+ $[8] = t1;
73
77
  } else {
74
- t1 = $[7];
78
+ t1 = $[8];
75
79
  }
76
80
  const mergedRef = t1;
77
81
  let t2;
78
- if ($[8] !== pillMotion) {
82
+ if ($[9] !== pillMotion) {
79
83
  t2 = () => {
80
84
  const list = listRef.current;
81
85
  const pill = pillRef.current;
@@ -118,57 +122,57 @@ const TabsList = /*#__PURE__*/React.forwardRef((t0, ref) => {
118
122
  mutationObserver.disconnect();
119
123
  };
120
124
  };
121
- $[8] = pillMotion;
122
- $[9] = t2;
125
+ $[9] = pillMotion;
126
+ $[10] = t2;
123
127
  } else {
124
- t2 = $[9];
128
+ t2 = $[10];
125
129
  }
126
130
  let t3;
127
- if ($[10] !== pillMotion || $[11] !== variant) {
131
+ if ($[11] !== pillMotion || $[12] !== variant) {
128
132
  t3 = [variant, pillMotion];
129
- $[10] = pillMotion;
130
- $[11] = variant;
131
- $[12] = t3;
133
+ $[11] = pillMotion;
134
+ $[12] = variant;
135
+ $[13] = t3;
132
136
  } else {
133
- t3 = $[12];
137
+ t3 = $[13];
134
138
  }
135
139
  React.useLayoutEffect(t2, t3);
136
140
  let t4;
137
- if ($[13] !== config?.classes?.list || $[14] !== variant) {
141
+ if ($[14] !== config?.classes?.list || $[15] !== variant) {
138
142
  t4 = config?.classes?.list ?? [variant === "soft" ? "flex flex-wrap items-center justify-center gap-1.5" : "t-tabs max-sm:max-w-full max-sm:justify-center-safe max-sm:overflow-x-auto max-sm:scrollbar-none", variant === "segmented" && "t-tabs--segmented", variant === "pills" && "t-tabs--pills"];
139
- $[13] = config?.classes?.list;
140
- $[14] = variant;
141
- $[15] = t4;
143
+ $[14] = config?.classes?.list;
144
+ $[15] = variant;
145
+ $[16] = t4;
142
146
  } else {
143
- t4 = $[15];
147
+ t4 = $[16];
144
148
  }
145
149
  const t5 = config?.classes?.size?.[size ?? "default"] ?? tabsListSizeClasses[size ?? "default"];
146
150
  let t6;
147
- if ($[16] !== className || $[17] !== cn || $[18] !== t4 || $[19] !== t5) {
151
+ if ($[17] !== className || $[18] !== cn || $[19] !== t4 || $[20] !== t5) {
148
152
  t6 = cn(t4, t5, className);
149
- $[16] = className;
150
- $[17] = cn;
151
- $[18] = t4;
152
- $[19] = t5;
153
- $[20] = t6;
153
+ $[17] = className;
154
+ $[18] = cn;
155
+ $[19] = t4;
156
+ $[20] = t5;
157
+ $[21] = t6;
154
158
  } else {
155
- t6 = $[20];
159
+ t6 = $[21];
156
160
  }
157
161
  let t7;
158
- if ($[21] !== config?.classes?.pill || $[22] !== variant) {
162
+ if ($[22] !== config?.classes?.pill || $[23] !== variant) {
159
163
  t7 = variant === "segmented" ? /*#__PURE__*/_jsx("span", {
160
164
  ref: pillRef,
161
165
  className: config?.classes?.pill ?? "t-tabs-pill",
162
166
  "aria-hidden": "true"
163
167
  }) : null;
164
- $[21] = config?.classes?.pill;
165
- $[22] = variant;
166
- $[23] = t7;
168
+ $[22] = config?.classes?.pill;
169
+ $[23] = variant;
170
+ $[24] = t7;
167
171
  } else {
168
- t7 = $[23];
172
+ t7 = $[24];
169
173
  }
170
174
  let t8;
171
- if ($[24] !== children || $[25] !== mergedRef || $[26] !== props || $[27] !== t6 || $[28] !== t7 || $[29] !== variant) {
175
+ if ($[25] !== children || $[26] !== mergedRef || $[27] !== props || $[28] !== t6 || $[29] !== t7 || $[30] !== variant) {
172
176
  t8 = /*#__PURE__*/_jsxs(TabsPrimitive.List, {
173
177
  ref: mergedRef,
174
178
  className: t6,
@@ -176,27 +180,27 @@ const TabsList = /*#__PURE__*/React.forwardRef((t0, ref) => {
176
180
  ...props,
177
181
  children: [t7, children]
178
182
  });
179
- $[24] = children;
180
- $[25] = mergedRef;
181
- $[26] = props;
182
- $[27] = t6;
183
- $[28] = t7;
184
- $[29] = variant;
185
- $[30] = t8;
183
+ $[25] = children;
184
+ $[26] = mergedRef;
185
+ $[27] = props;
186
+ $[28] = t6;
187
+ $[29] = t7;
188
+ $[30] = variant;
189
+ $[31] = t8;
186
190
  } else {
187
- t8 = $[30];
191
+ t8 = $[31];
188
192
  }
189
193
  let t9;
190
- if ($[31] !== t8 || $[32] !== variant) {
194
+ if ($[32] !== t8 || $[33] !== variant) {
191
195
  t9 = /*#__PURE__*/_jsx(TabsListVariantContext, {
192
196
  value: variant,
193
197
  children: t8
194
198
  });
195
- $[31] = t8;
196
- $[32] = variant;
197
- $[33] = t9;
199
+ $[32] = t8;
200
+ $[33] = variant;
201
+ $[34] = t9;
198
202
  } else {
199
- t9 = $[33];
203
+ t9 = $[34];
200
204
  }
201
205
  return t9;
202
206
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.58.1",
3
+ "version": "0.59.1",
4
4
  "license": "MIT",
5
5
  "description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
6
6
  "type": "module",
@@ -7,7 +7,7 @@ import { cn } from "../../src/utils/cn";
7
7
  * pill tone. Empty, it takes no space.
8
8
  */
9
9
  export const buttonTrackClass =
10
- "flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
10
+ "flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden dark:bg-surface [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
11
11
 
12
12
  export type ButtonTrackProps = ComponentPropsWithoutRef<"div"> & {
13
13
  /** `"column"` stacks the buttons from `md` up (a side rail). Default `"row"`. */
@@ -168,7 +168,7 @@ function Frame({ collapsed = false, rail, children, className, cardClassName, ar
168
168
  ref={cardRef}
169
169
  data-side-panel-card=""
170
170
  className={cn(
171
- "relative min-h-0 min-w-0 flex-1 overflow-hidden bg-surface md:my-2 md:mr-1.5 md:rounded-lg",
171
+ "relative min-h-0 min-w-0 flex-1 overflow-hidden bg-surface md:my-2 md:mr-1.5 md:rounded-surface",
172
172
  collapsed && "md:hidden",
173
173
  cardClassName,
174
174
  )}
@@ -227,10 +227,14 @@ function List({ value, onValueChange, labelled = false, className, listClassName
227
227
  onValueChange={onValueChange}
228
228
  className={cn("min-w-0 flex-1 md:flex md:min-h-0 md:w-full md:flex-col md:items-center md:justify-center-safe", className)}
229
229
  >
230
+ {/* Always segmented, whatever `UiConfig.Tabs` says: the rail needs the
231
+ sliding pill. `xy`: the rail is a row below `md`, a column above. */}
230
232
  <TabsList
233
+ variant="segmented"
234
+ pillMotion="xy"
231
235
  aria-label={props["aria-label"]}
232
236
  className={cn(
233
- "scrollbar-none h-auto max-w-full justify-start gap-1 overflow-x-auto rounded-xl border-0 bg-default p-0.5 shadow-none md:max-w-none md:flex-col md:overflow-x-hidden md:overflow-y-auto [&>.t-tabs-pill]:bg-segment",
237
+ "scrollbar-none h-auto max-w-full justify-start gap-1 overflow-x-auto rounded-xl border-0 bg-default p-0.5 shadow-none dark:bg-surface md:max-w-none md:flex-col md:overflow-x-hidden md:overflow-y-auto [&>.t-tabs-pill]:bg-segment",
234
238
  labelled && "md:w-full",
235
239
  listClassName,
236
240
  )}
@@ -35,7 +35,7 @@ export function railTileStateClass(active: boolean, grouped = false): string {
35
35
  * `--radius`. A plain `rounded-xl` is a fixed 12px, smaller than a 16px pill.
36
36
  */
37
37
  export const railGroupClass =
38
- "relative isolate flex flex-col items-center gap-1 rounded-[calc(var(--radius-lg)+0.25rem)] bg-default p-1";
38
+ "relative isolate flex flex-col items-center gap-1 rounded-[calc(var(--radius-lg)+0.25rem)] bg-default p-1 dark:bg-surface";
39
39
 
40
40
  /** The `RailGroup` sliding pill: the segmented tabs pill, with the tile radius. */
41
41
  export const railGroupPillClass = "t-tabs-pill rounded-lg bg-segment";
package/src/ui/tabs.tsx CHANGED
@@ -47,12 +47,14 @@ const TabsList = React.forwardRef<
47
47
  variant?: TabsListVariant;
48
48
  /** `sm` makes the triggers smaller. No classes for `default`. */
49
49
  size?: TabsListSize;
50
+ /** How the segmented pill moves. Overrides `UiConfig.Tabs.pillMotion`. */
51
+ pillMotion?: TabsPillMotion;
50
52
  }
51
- >(({ className, children, variant: variantProp, size, ...props }, ref) => {
53
+ >(({ className, children, variant: variantProp, size, pillMotion: pillMotionProp, ...props }, ref) => {
52
54
  const config = useUiConfig("Tabs");
53
55
  const cn = useCn();
54
56
  const variant = variantProp ?? config?.variant ?? "pills";
55
- const pillMotion = config?.pillMotion ?? "x";
57
+ const pillMotion = pillMotionProp ?? config?.pillMotion ?? "x";
56
58
  const listRef = React.useRef<React.ComponentRef<
57
59
  typeof TabsPrimitive.List
58
60
  > | null>(null);