@vvedantb/ui 0.75.5 → 0.77.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.
@@ -1278,6 +1278,60 @@ export const MessageBranchPage = t0 => {
1278
1278
  }
1279
1279
  return t3;
1280
1280
  };
1281
+ /**
1282
+ * A small card of message actions laid over the top right corner of a message.
1283
+ * It takes no layout space. It shows on hover or focus of the nearest `group`
1284
+ * ancestor, and stays up while a menu inside it is open. Put it in a
1285
+ * `group relative` wrapper around the message.
1286
+ */
1287
+ export const MessageCornerToolbar = t0 => {
1288
+ const $ = _c(11);
1289
+ let children;
1290
+ let className;
1291
+ let props;
1292
+ if ($[0] !== t0) {
1293
+ ({
1294
+ className,
1295
+ children,
1296
+ ...props
1297
+ } = t0);
1298
+ $[0] = t0;
1299
+ $[1] = children;
1300
+ $[2] = className;
1301
+ $[3] = props;
1302
+ } else {
1303
+ children = $[1];
1304
+ className = $[2];
1305
+ props = $[3];
1306
+ }
1307
+ const merge = useCn();
1308
+ let t1;
1309
+ if ($[4] !== className || $[5] !== merge) {
1310
+ t1 = merge("pointer-events-none absolute -top-8 right-2 z-10 flex items-center gap-0.5 rounded-control bg-popover p-0.5 opacity-0 smooth-shadow-ring-md transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100", className);
1311
+ $[4] = className;
1312
+ $[5] = merge;
1313
+ $[6] = t1;
1314
+ } else {
1315
+ t1 = $[6];
1316
+ }
1317
+ let t2;
1318
+ if ($[7] !== children || $[8] !== props || $[9] !== t1) {
1319
+ t2 = /*#__PURE__*/_jsx("div", {
1320
+ role: "toolbar",
1321
+ "aria-label": "Message actions",
1322
+ className: t1,
1323
+ ...props,
1324
+ children: children
1325
+ });
1326
+ $[7] = children;
1327
+ $[8] = props;
1328
+ $[9] = t1;
1329
+ $[10] = t2;
1330
+ } else {
1331
+ t2 = $[10];
1332
+ }
1333
+ return t2;
1334
+ };
1281
1335
  export const MessageToolbar = t0 => {
1282
1336
  const $ = _c(11);
1283
1337
  let children;
@@ -4,24 +4,52 @@ import { cn } from "../utils/cn.js";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  const UiConfigContext = /*#__PURE__*/React.createContext({});
6
6
  function UiConfigProvider(t0) {
7
- const $ = _c(3);
7
+ const $ = _c(6);
8
8
  const {
9
9
  config,
10
+ surface,
10
11
  children
11
12
  } = t0;
12
13
  let t1;
13
- if ($[0] !== children || $[1] !== config) {
14
- t1 = /*#__PURE__*/_jsx(UiConfigContext.Provider, {
14
+ let t2;
15
+ if ($[0] !== surface) {
16
+ t1 = () => {
17
+ if (!surface || typeof document === "undefined") {
18
+ return;
19
+ }
20
+ const root = document.documentElement;
21
+ const previous = root.getAttribute("data-surface");
22
+ root.setAttribute("data-surface", surface);
23
+ return () => {
24
+ if (previous === null) {
25
+ root.removeAttribute("data-surface");
26
+ } else {
27
+ root.setAttribute("data-surface", previous);
28
+ }
29
+ };
30
+ };
31
+ t2 = [surface];
32
+ $[0] = surface;
33
+ $[1] = t1;
34
+ $[2] = t2;
35
+ } else {
36
+ t1 = $[1];
37
+ t2 = $[2];
38
+ }
39
+ React.useLayoutEffect(t1, t2);
40
+ let t3;
41
+ if ($[3] !== children || $[4] !== config) {
42
+ t3 = /*#__PURE__*/_jsx(UiConfigContext.Provider, {
15
43
  value: config,
16
44
  children: children
17
45
  });
18
- $[0] = children;
19
- $[1] = config;
20
- $[2] = t1;
46
+ $[3] = children;
47
+ $[4] = config;
48
+ $[5] = t3;
21
49
  } else {
22
- t1 = $[2];
50
+ t3 = $[5];
23
51
  }
24
- return t1;
52
+ return t3;
25
53
  }
26
54
  function useUiConfig(name) {
27
55
  return React.useContext(UiConfigContext)[name];
@@ -0,0 +1,30 @@
1
+ /*
2
+ * @vvedantb/ui/tokens/css/surface-flat.css: the flat surface style.
3
+ * UiConfigProvider sets data-surface on the root element. The default is
4
+ * glass. With data-surface="flat", the rules below remove the glass rim,
5
+ * highlight and drop shadow that components carry as utility classes.
6
+ * Rule 1 clears the highlight overlay (an ::after pseudo-element).
7
+ * Rule 2 clears elements that carry the highlight as their own box-shadow.
8
+ * The tab pill is plain CSS and has its own rule.
9
+ */
10
+
11
+ :root[data-surface="flat"] [class*="after:shadow-[inset"]::after {
12
+ box-shadow: none !important;
13
+ }
14
+
15
+ :root[data-surface="flat"]
16
+ :is([class*="inset_1.5px_1.5px_1px"], [class*="inset_1px_1px_1px"]):not(
17
+ [class*="after:shadow-[inset"]
18
+ ) {
19
+ box-shadow: none !important;
20
+ }
21
+
22
+ :root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill {
23
+ background: var(--tabs-pill-bg) !important;
24
+ backdrop-filter: none !important;
25
+ box-shadow: none !important;
26
+ }
27
+
28
+ :root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill::after {
29
+ display: none !important;
30
+ }
@@ -36,6 +36,7 @@
36
36
  @import "./css/motion.css";
37
37
  @import "./css/type-scale.css";
38
38
  @import "./css/tabs.css";
39
+ @import "./css/surface-flat.css";
39
40
 
40
41
  @custom-variant dark (&:where(.dark, .dark *));
41
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.75.5",
3
+ "version": "0.77.0",
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",
@@ -555,6 +555,33 @@ export const MessageBranchPage = ({
555
555
  </ButtonGroupText>
556
556
  );
557
557
  };
558
+ export type MessageCornerToolbarProps = ComponentProps<"div">;
559
+ /**
560
+ * A small card of message actions laid over the top right corner of a message.
561
+ * It takes no layout space. It shows on hover or focus of the nearest `group`
562
+ * ancestor, and stays up while a menu inside it is open. Put it in a
563
+ * `group relative` wrapper around the message.
564
+ */
565
+ export const MessageCornerToolbar = ({
566
+ className,
567
+ children,
568
+ ...props
569
+ }: MessageCornerToolbarProps) => {
570
+ const merge = useCn();
571
+ return (
572
+ <div
573
+ role="toolbar"
574
+ aria-label="Message actions"
575
+ className={merge(
576
+ "pointer-events-none absolute -top-8 right-2 z-10 flex items-center gap-0.5 rounded-control bg-popover p-0.5 opacity-0 smooth-shadow-ring-md transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100",
577
+ className,
578
+ )}
579
+ {...props}
580
+ >
581
+ {children}
582
+ </div>
583
+ );
584
+ };
558
585
  export type MessageToolbarProps = ComponentProps<"div">;
559
586
  export const MessageToolbar = ({
560
587
  className,
package/src/client.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { cn } from "./utils/cn";
2
2
  export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
3
- export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
3
+ export type { UiConfig, UiConfigProviderProps, UiSurface } from "./ui/ui-config";
4
4
  export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
5
5
  export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
6
6
  export * from "./ui/surface-classes";
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { cn } from "./utils/cn";
2
2
  export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
3
- export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
3
+ export type { UiConfig, UiConfigProviderProps, UiSurface } from "./ui/ui-config";
4
4
  export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
5
5
  export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
6
6
  export * from "./ui/surface-classes";
@@ -122,10 +122,23 @@ const UiConfigContext = React.createContext<UiConfig>({});
122
122
 
123
123
  export interface UiConfigProviderProps {
124
124
  config: UiConfig;
125
+ surface?: UiSurface;
125
126
  children?: React.ReactNode;
126
127
  }
127
128
 
128
- function UiConfigProvider({ config, children }: UiConfigProviderProps) {
129
+ export type UiSurface = "glass" | "flat";
130
+
131
+ function UiConfigProvider({ config, surface, children }: UiConfigProviderProps) {
132
+ React.useLayoutEffect(() => {
133
+ if (!surface || typeof document === "undefined") return;
134
+ const root = document.documentElement;
135
+ const previous = root.getAttribute("data-surface");
136
+ root.setAttribute("data-surface", surface);
137
+ return () => {
138
+ if (previous === null) root.removeAttribute("data-surface");
139
+ else root.setAttribute("data-surface", previous);
140
+ };
141
+ }, [surface]);
129
142
  return <UiConfigContext.Provider value={config}>{children}</UiConfigContext.Provider>;
130
143
  }
131
144
 
@@ -0,0 +1,30 @@
1
+ /*
2
+ * @vvedantb/ui/tokens/css/surface-flat.css: the flat surface style.
3
+ * UiConfigProvider sets data-surface on the root element. The default is
4
+ * glass. With data-surface="flat", the rules below remove the glass rim,
5
+ * highlight and drop shadow that components carry as utility classes.
6
+ * Rule 1 clears the highlight overlay (an ::after pseudo-element).
7
+ * Rule 2 clears elements that carry the highlight as their own box-shadow.
8
+ * The tab pill is plain CSS and has its own rule.
9
+ */
10
+
11
+ :root[data-surface="flat"] [class*="after:shadow-[inset"]::after {
12
+ box-shadow: none !important;
13
+ }
14
+
15
+ :root[data-surface="flat"]
16
+ :is([class*="inset_1.5px_1.5px_1px"], [class*="inset_1px_1px_1px"]):not(
17
+ [class*="after:shadow-[inset"]
18
+ ) {
19
+ box-shadow: none !important;
20
+ }
21
+
22
+ :root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill {
23
+ background: var(--tabs-pill-bg) !important;
24
+ backdrop-filter: none !important;
25
+ box-shadow: none !important;
26
+ }
27
+
28
+ :root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill::after {
29
+ display: none !important;
30
+ }
@@ -36,6 +36,7 @@
36
36
  @import "./css/motion.css";
37
37
  @import "./css/type-scale.css";
38
38
  @import "./css/tabs.css";
39
+ @import "./css/surface-flat.css";
39
40
 
40
41
  @custom-variant dark (&:where(.dark, .dark *));
41
42