@glass-sdk/liquid-glass 0.0.1 → 0.0.2

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.
Files changed (109) hide show
  1. package/README.md +133 -494
  2. package/dist/core/concentric.js +86 -0
  3. package/dist/core/materials.js +41 -0
  4. package/dist/core/morph-path.js +206 -0
  5. package/dist/core/optics.js +7 -0
  6. package/dist/core/progressive.js +35 -0
  7. package/dist/{concentric-COCiG9DQ.js → core/shape.js} +1 -85
  8. package/dist/core/spring.js +78 -0
  9. package/dist/core/union.js +117 -0
  10. package/dist/core.js +6 -9
  11. package/dist/dom/compose-layers.js +54 -0
  12. package/dist/dom/compound-field.js +23 -0
  13. package/dist/dom/control-motion.js +101 -0
  14. package/dist/dom/engine.js +7 -0
  15. package/dist/dom/exit-handoff.js +14 -0
  16. package/dist/dom/filter-bounds.js +87 -0
  17. package/dist/dom/filter-budget.js +45 -0
  18. package/dist/dom/filter-groups.js +38 -0
  19. package/dist/dom/filter-paint-root.js +41 -0
  20. package/dist/dom/filter-patch.js +129 -0
  21. package/dist/dom/filter-reach.js +36 -0
  22. package/dist/dom/filter-stages.js +7 -0
  23. package/dist/dom/fixed-shape.js +20 -0
  24. package/dist/dom/foreground.js +36 -0
  25. package/dist/dom/interaction.js +129 -0
  26. package/dist/dom/lens-layers.js +163 -0
  27. package/dist/dom/map-blend.js +8 -0
  28. package/dist/dom/map-encoder.js +47 -0
  29. package/dist/dom/map-encoder.worker.js +16 -0
  30. package/dist/dom/map-encoding.js +17 -0
  31. package/dist/dom/map-image.js +34 -0
  32. package/dist/dom/map-store.js +189 -0
  33. package/dist/dom/maps.js +131 -0
  34. package/dist/dom/material-graph.js +52 -0
  35. package/dist/dom/morph.js +296 -0
  36. package/dist/dom/page-zoom.js +46 -0
  37. package/dist/dom/png.js +105 -0
  38. package/dist/dom/progressive.js +299 -0
  39. package/dist/dom/renderer.js +6 -0
  40. package/dist/dom/sampling-bounds.js +22 -0
  41. package/dist/dom/selection.js +106 -0
  42. package/dist/dom/shape-layout.js +199 -0
  43. package/dist/dom/shared-backdrop.js +41 -0
  44. package/dist/dom/ticker.js +103 -0
  45. package/dist/dom/warm.js +108 -0
  46. package/dist/dom.js +694 -2
  47. package/dist/gpu/geometry.js +9 -0
  48. package/dist/gpu/maps.js +8 -0
  49. package/dist/gpu/planes.js +4 -0
  50. package/dist/gpu.js +213 -2
  51. package/dist/index.js +10 -932
  52. package/dist/react/button.js +23 -0
  53. package/dist/react/control-thumb.js +50 -0
  54. package/dist/react/menu.js +159 -0
  55. package/dist/react/merged-ref.js +18 -0
  56. package/dist/react/progressive.js +73 -0
  57. package/dist/react/scene.js +122 -0
  58. package/dist/react/shape.js +93 -0
  59. package/dist/react/surface.js +69 -0
  60. package/dist/react/tabs.js +94 -0
  61. package/dist/react/toolbar.js +145 -0
  62. package/dist/react/value-control-motion.js +9 -0
  63. package/dist/react/value-controls.js +176 -0
  64. package/dist/styles.css +19 -0
  65. package/dist/types/core/optics.d.ts +0 -1
  66. package/dist/types/core/spring.d.ts +1 -1
  67. package/dist/types/dom/compose-layers.d.ts +15 -0
  68. package/dist/types/dom/compound-field.d.ts +35 -0
  69. package/dist/types/dom/engine.d.ts +9 -0
  70. package/dist/types/dom/exit-handoff.d.ts +7 -0
  71. package/dist/types/dom/filter-bounds.d.ts +1 -1
  72. package/dist/types/dom/filter-budget.d.ts +20 -0
  73. package/dist/types/dom/filter-groups.d.ts +25 -0
  74. package/dist/types/dom/filter-paint-root.d.ts +9 -0
  75. package/dist/types/dom/filter-patch.d.ts +3 -8
  76. package/dist/types/dom/filter-reach.d.ts +23 -0
  77. package/dist/types/dom/filter-stages.d.ts +5 -0
  78. package/dist/types/dom/index.d.ts +3 -0
  79. package/dist/types/dom/lens-layers.d.ts +68 -0
  80. package/dist/types/dom/map-blend.d.ts +22 -0
  81. package/dist/types/dom/map-encoding.d.ts +1 -1
  82. package/dist/types/dom/map-image.d.ts +5 -2
  83. package/dist/types/dom/maps.d.ts +5 -5
  84. package/dist/types/dom/material-graph.d.ts +22 -0
  85. package/dist/types/dom/morph.d.ts +8 -0
  86. package/dist/types/dom/page-zoom.d.ts +18 -0
  87. package/dist/types/dom/png.d.ts +2 -0
  88. package/dist/types/dom/progressive.d.ts +29 -1
  89. package/dist/types/dom/renderer.d.ts +4 -0
  90. package/dist/types/dom/sampling-bounds.d.ts +10 -0
  91. package/dist/types/dom/shared-backdrop.d.ts +19 -0
  92. package/dist/types/dom/warm.d.ts +4 -1
  93. package/dist/types/gpu/geometry.d.ts +17 -0
  94. package/dist/types/gpu/index.d.ts +4 -16
  95. package/dist/types/gpu/planes.d.ts +2 -0
  96. package/dist/types/react/button.d.ts +11 -0
  97. package/dist/types/react/index.d.ts +14 -149
  98. package/dist/types/react/menu.d.ts +29 -0
  99. package/dist/types/react/progressive.d.ts +15 -0
  100. package/dist/types/react/scene.d.ts +35 -0
  101. package/dist/types/react/surface.d.ts +35 -0
  102. package/dist/types/react/tabs.d.ts +29 -0
  103. package/dist/types/react/toolbar.d.ts +21 -0
  104. package/package.json +1 -1
  105. package/dist/dom-CKc8vDTR.js +0 -2532
  106. package/dist/gpu-Co5Y89mh.js +0 -244
  107. package/dist/map-encoder.worker-DO1drw0Y.js +0 -16
  108. package/dist/materials-DVPgteZ9.js +0 -234
  109. package/dist/types/dom/progressive-maps.d.ts +0 -6
@@ -1,4 +1,4 @@
1
- /** Encode GPU readback pixels, never DOM content. The atlas holds four planes
1
+ /** Encode GPU readback pixels, never DOM content. The atlas holds its planes
2
2
  * stacked vertically. Each plane yields its full image followed, for capsule
3
3
  * maps, by its left, middle, and right slices. Everything runs on the CPU of
4
4
  * whichever thread calls it. */
@@ -1,6 +1,9 @@
1
- import type { MapGeometry } from "../gpu/index.js";
1
+ import type { MapGeometry } from "../gpu/geometry.js";
2
2
  import type { MaterialMaps } from "./maps.js";
3
- export type MapPlane = "displacement" | "mask" | "highlight" | "outline";
3
+ export type MapPlane = "field" | "overlay";
4
+ /** Map resources belong to a surface, even when its material branch is
5
+ * regrouped as another surface enters, moves nearby, or is absorbed. */
6
+ export declare const surfaceMapResult: (serial: number, plane: MapPlane) => string;
4
7
  /** Beyond two heights, Lisse capsule ends are independent of its width.
5
8
  * Bake one longer capsule and reuse its ends instead of readback per frame. */
6
9
  export declare function capsuleMapGeometry(g: MapGeometry): MapGeometry | undefined;
@@ -1,10 +1,10 @@
1
- import type { MapGeometry } from "../gpu/index.js";
1
+ import type { MapGeometry } from "../gpu/geometry.js";
2
2
  import type { MapPlane } from "./map-image.js";
3
3
  export interface MaterialMaps {
4
- displacement: string;
5
- mask: string;
6
- highlight: string;
7
- outline: string;
4
+ /** Displacement in red and green, shape coverage in alpha. */
5
+ field: string;
6
+ /** Rim shade with the highlight over it. */
7
+ overlay: string;
8
8
  duration: number;
9
9
  /** Capsule maps reused at any width: CSS cap width, plane height, and slices. */
10
10
  capsule?: {
@@ -0,0 +1,22 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ /** Regular glass refracts a frosted copy of its backdrop: a blur lightened
3
+ * (darkened in dark appearance) by a wider fill blur. */
4
+ export declare function frostMarkup(p: string, input: string, o: MaterialOptions, soften?: number): {
5
+ markup: string;
6
+ result: string;
7
+ };
8
+ /** The material's tone curve applied to `${p}refracted`, written to `${p}color`. */
9
+ export declare function toneMarkup(p: string, o: MaterialOptions, nested: boolean): string;
10
+ /** Tint as linear RGB channels, when it is a hex color. */
11
+ export declare function tintChannels(o: MaterialOptions): number[] | undefined;
12
+ /** Colored glass transmits luminance, rather than mixing neutral backdrop RGB
13
+ * into a weak overlay. A pale backdrop can brighten the pigment without
14
+ * removing its chroma; dark detail stays visible. Reads `${p}color`. */
15
+ export declare function tintMarkup(p: string, o: MaterialOptions, tint: number[]): {
16
+ markup: string;
17
+ color: string;
18
+ };
19
+ /** The overlay's light is white (0.82 in dark appearance) over a black rim.
20
+ * Scaling its color recolors the light alone and keeps the coverage the WGSL
21
+ * renderer computed. */
22
+ export declare function overlayTintMarkup(input: string, result: string, o: MaterialOptions, tint: number[]): string;
@@ -29,12 +29,16 @@ export interface LensFrame extends Box {
29
29
  export interface GeometryAnimator extends SurfaceAnimator {
30
30
  /** The animated outline, or undefined when the surface rests at its layout box. */
31
31
  geometry(): LensFrame | undefined;
32
+ /** Source of a joined detachment, retained while the popup rests open. */
33
+ detachedSource(): Element | undefined;
32
34
  /** Shapes along the current animation's path. A new array starts a new path. */
33
35
  waypoints(): readonly LensWaypoint[];
34
36
  /** Material opacity while materializing or leaving a non-glass source. */
35
37
  opacity(): number;
36
38
  /** Waiting for the maps of its path before moving. */
37
39
  pending(): boolean;
40
+ /** Initial popup placement has not settled enough to request its maps. */
41
+ positioning(): boolean;
38
42
  }
39
43
  /** How a surface relates to the glass it grows out of. */
40
44
  export type GlassMorph = "become" | "detach";
@@ -58,7 +62,11 @@ export interface GeometryMotionOptions {
58
62
  /** Grow out of the source when attached. `false` only runs the exit back
59
63
  * into it, for an element that was already in place. Default: true. */
60
64
  enter?: boolean;
65
+ /** Submenus fade in place and share the previous sibling's outline. */
66
+ submenu?: boolean;
61
67
  }
68
+ /** Keep the current panel while Base UI waits to open a hovered sibling. */
69
+ export declare function prepareSubmenuHandoff(trigger: HTMLElement): () => void;
62
70
  /** Animate a surface's optical outline independently of its layout box.
63
71
  * Entry grows the glass out of a source shape along a planned path; Base UI
64
72
  * `data-ending-style` runs the same path back before the popup unmounts, so
@@ -0,0 +1,18 @@
1
+ /** Whether pinch magnification is active. WebKit repaints a magnified page
2
+ * whole, but fails tiles at a magnified element's edge whose filter region
3
+ * reaches far past it, so repaint padding must stay off while magnified. */
4
+ export declare function magnified(): boolean;
5
+ /** Device pixels per CSS pixel that WebKit filters render at: pinch
6
+ * magnification enlarges the page's tiles but not its filter buffers. */
7
+ export declare function filterPixelRatio(): number;
8
+ /** WebKit splits a composited layer into tiles once its size, outsets
9
+ * included, times pinch magnification passes 2048 points (1280, or 1024 under
10
+ * memory pressure, on iOS). Each tile then filters its own region, and tiles
11
+ * fail where that region misses the filter's primitives. Largest outsets, in
12
+ * CSS pixels, that keep a `width` × `height` element in one layer. */
13
+ export declare function untiledOutsets(width: number, height: number, margin?: number): number;
14
+ /** The factor WebKit's page zoom applies to filter user space; 1 elsewhere. */
15
+ export declare function pageZoom(): number;
16
+ /** Scale the user-space lengths of every primitive, leaving the filter's
17
+ * own bounding-box region alone. */
18
+ export declare function zoomFilterMarkup(markup: string, zoom: number): string;
@@ -5,3 +5,5 @@ export declare function base64(bytes: Uint8Array): string;
5
5
  /** A `data:` URL: Chromium resolves it synchronously for `feImage`, where a
6
6
  * `blob:` URL would leave the material blank for a frame. */
7
7
  export declare function pngDataUrl(width: number, height: number, rgba: Uint8Array, stride?: number): Promise<string>;
8
+ /** An uncompressed PNG `data:` URL, available at once for tiny images. */
9
+ export declare function pngDataUrlSync(width: number, height: number, rgba: Uint8Array): string;
@@ -1,14 +1,42 @@
1
- import type { GlassBlurEdge, ProgressiveBlurOptions } from "../core/progressive.js";
1
+ import type { GlassBlurEdge, PhysicalEdge, ProgressiveBlurOptions } from "../core/progressive.js";
2
2
  export type GlassScrollTarget = HTMLElement | (() => HTMLElement | null);
3
3
  export interface ScrollEdgesOptions extends Omit<ProgressiveBlurOptions, "edge"> {
4
4
  /** Scrollport to blur. Only this element is filtered; siblings stay sharp. */
5
5
  target: GlassScrollTarget;
6
6
  edges?: readonly GlassBlurEdge[];
7
7
  }
8
+ interface Box {
9
+ x: number;
10
+ y: number;
11
+ width: number;
12
+ height: number;
13
+ }
14
+ export type FilterEngine = "chromium" | "webkit" | "gecko";
15
+ export interface ProgressiveRegion extends Box {
16
+ edge: PhysicalEdge;
17
+ blur: number;
18
+ refraction: number;
19
+ }
20
+ /** A flood over the edge half of a region, blurred along the depth with
21
+ * σ = depth / 6, rises as Φ(6u − 3) across it. These tables map that ramp
22
+ * to each level's weight. Floods, blurs, transfers and composites are the
23
+ * primitives Gecko renders on the GPU; an image anywhere in the graph sends
24
+ * the whole element to its software fallback. */
25
+ export declare const rampTables: string[];
26
+ export declare function maskUrl(token: string): string | undefined;
27
+ /** One filter graph that keeps the sharp source and blurs only near edges. */
28
+ export declare function progressiveGraph(id: string, regions: ProgressiveRegion[], width: number, height: number, target?: FilterEngine): string;
8
29
  export declare function createProgressiveLayer(root: HTMLElement, onError: (error: Error) => void, viewportMode?: boolean): {
9
30
  add(element: HTMLElement, options?: ProgressiveBlurOptions): () => void;
10
31
  addScroll(options: ScrollEdgesOptions): () => void;
11
32
  count(): number;
33
+ /** Regions blurred directly on the scene's own target, as of the last update. */
34
+ regions(): readonly ProgressiveRegion[];
35
+ operations(): number;
36
+ outsets(): number;
37
+ scrollsContent(): boolean;
38
+ error(): Error | undefined;
12
39
  update(content: HTMLElement | null): string;
13
40
  dispose(): void;
14
41
  };
42
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialRenderer } from "../gpu/index.js";
2
+ /** The GPU renderer, and vgpu with it, load on first use rather than with the
3
+ * page, so an app's initial bundle carries neither. */
4
+ export declare function getMaterialRenderer(): Promise<MaterialRenderer>;
@@ -0,0 +1,10 @@
1
+ import type { FilterBounds } from "./filter-bounds.js";
2
+ /** Source pixels a displacement map can read, including its image border.
3
+ * `box` is the positioned feImage rectangle, including the two-pixel map
4
+ * border. Only a symmetric Lisse field may opt into the inward bound;
5
+ * arbitrary outlines and outward (negative) refraction keep full reach. */
6
+ export declare function refractionSamplingBounds(box: FilterBounds, amount: number, symmetric?: boolean): FilterBounds;
7
+ /** Combine independently proven sampling regions. Arithmetic map blends
8
+ * can quantize premultiplied channels at low alpha; callers must use full
9
+ * reach for such blends unless their opaque coverage is known to coincide. */
10
+ export declare function unionSamplingBounds(boxes: readonly FilterBounds[]): FilterBounds;
@@ -0,0 +1,19 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { FilterBounds } from "./filter-bounds.js";
3
+ interface BackdropConsumer<T> {
4
+ key: T;
5
+ /** Stable material-unit identity, independent of the other consumers. */
6
+ id: string;
7
+ options: MaterialOptions;
8
+ bounds: FilterBounds;
9
+ /** Additional glass layers sampled alongside SourceGraphic. */
10
+ inputs: readonly unknown[];
11
+ }
12
+ interface BackdropMaterial {
13
+ result: string;
14
+ markup: string;
15
+ }
16
+ /** Regular glass reading the same unmodified backdrop can reuse its two
17
+ * blurs and their mix. Refraction, tone, tint and coverage remain per lens. */
18
+ export declare function sharedBackdropMaterials<T>(consumers: readonly BackdropConsumer<T>[], soften: number): Map<T, BackdropMaterial>;
19
+ export {};
@@ -1,4 +1,6 @@
1
1
  import type { MaterialMaps } from "./maps.js";
2
+ /** First-use grace shared by map admission and scene animation readiness. */
3
+ export declare const mapWarmup = 50;
2
4
  /** Chromium draws a newly referenced filter image blank until it has been
3
5
  * loaded and decoded for painting, which reads as the glass blinking when an
4
6
  * animation switches maps. A warmer paints every new map once, through its
@@ -6,7 +8,8 @@ import type { MaterialMaps } from "./maps.js";
6
8
  * prepared, so the image is ready by the time a surface switches to it. */
7
9
  export declare function createMapWarmer(root: HTMLElement): {
8
10
  warm(maps: MaterialMaps): void;
9
- /** Whether every image of these maps has been painted here already. */
11
+ /** Whether these maps completed a preparation attempt and its grace
12
+ * period. Browser filter painting itself has no completion signal. */
10
13
  has(maps: MaterialMaps): boolean;
11
14
  /** Whether a node is part of the warmer's own markup. */
12
15
  owns(node: Node): boolean;
@@ -0,0 +1,17 @@
1
+ import type { GlassRadius } from "../core/shape.js";
2
+ import type { ShapePoint } from "../core/concentric.js";
3
+ export interface MapGeometry {
4
+ /** Resolved convex outline for container-relative glass, in local CSS pixels. */
5
+ outline?: ShapePoint[];
6
+ width: number;
7
+ height: number;
8
+ radius: GlassRadius;
9
+ dpr?: number;
10
+ appearance?: "light" | "dark";
11
+ }
12
+ export declare const maxAtlasRows = 8192;
13
+ /** Pixels per CSS pixel a map is rendered at. Maps are stretched to their
14
+ * surface when drawn, so a surface too large for the atlas at the display's
15
+ * ratio, such as a full-height panel on a 2x or 3x display, renders at a
16
+ * lower ratio instead of failing. */
17
+ export declare function mapScale(g: MapGeometry): number;
@@ -1,15 +1,8 @@
1
- import type { ShapePoint } from "../core/concentric.js";
2
- import type { GlassRadius } from "../core/shape.js";
3
1
  import type { Gpu, ShaderSource } from "vgpu";
4
- export interface MapGeometry {
5
- /** Resolved convex outline for container-relative glass, in local CSS pixels. */
6
- outline?: ShapePoint[];
7
- width: number;
8
- height: number;
9
- radius: GlassRadius;
10
- dpr?: number;
11
- appearance?: "light" | "dark";
12
- }
2
+ export { mapPlanes } from "./planes.js";
3
+ import type { MapGeometry } from "./geometry.js";
4
+ export { mapScale } from "./geometry.js";
5
+ export type { MapGeometry } from "./geometry.js";
13
6
  export interface MapPixels {
14
7
  width: number;
15
8
  height: number;
@@ -26,9 +19,6 @@ export declare class MaterialRenderer {
26
19
  private readonly slots;
27
20
  private queue;
28
21
  private flushing;
29
- private progressiveAtlas?;
30
- private progressiveEffect?;
31
- private progressivePending;
32
22
  /** Resolves once the device has completed its first submission. A fresh
33
23
  * device's first work is held back while the page keeps painting, so the
34
24
  * renderer warms itself up as soon as it exists rather than during a
@@ -39,8 +29,6 @@ export declare class MaterialRenderer {
39
29
  private flush;
40
30
  private slot;
41
31
  private draw;
42
- /** Baked 256 × 8 profile atlas: seven weights and one displacement row. */
43
- renderProgressive(axis: 0 | 1, reverse: boolean): Promise<MapPixels>;
44
32
  dispose(): void;
45
33
  }
46
34
  export declare function getMaterialRenderer(): Promise<MaterialRenderer>;
@@ -0,0 +1,2 @@
1
+ /** Planes per map: field (displacement and coverage) and overlay (rim and light). */
2
+ export declare const mapPlanes = 2;
@@ -0,0 +1,11 @@
1
+ import type { CSSProperties, ComponentPropsWithRef } from "react";
2
+ import { Button } from "@base-ui/react/button";
3
+ import type { MaterialOptions } from "../core/materials.js";
4
+ import type { GlassMotionProps } from "./surface.js";
5
+ export type GlassButtonSize = "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
6
+ export interface GlassButtonProps extends Omit<ComponentPropsWithRef<typeof Button>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion"> {
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ size?: GlassButtonSize;
10
+ }
11
+ export declare function GlassButton({ material, appearance, radius, refraction, tint, interactive, motion, size, className, style, children, ...props }: GlassButtonProps): import("react").JSX.Element;
@@ -1,155 +1,20 @@
1
1
  export { GlassShape, GlassShapeContainer, GlassCorner } from "./shape.js";
2
2
  export type { GlassShapeProps, GlassCornerProps } from "./shape.js";
3
- import type { CSSProperties, ComponentPropsWithRef, HTMLAttributes, ReactNode, Ref, RefObject } from "react";
4
- import { Button } from "@base-ui/react/button";
5
- import { Tabs } from "@base-ui/react/tabs";
6
- import { Menu } from "@base-ui/react/menu";
7
- import { Toolbar } from "@base-ui/react/toolbar";
8
- import { useRender } from "@base-ui/react/use-render";
9
- import type { GlassSceneOptions, GlassMotion, GlassMorph } from "../dom/index.js";
10
- import type { MaterialOptions } from "../core/materials.js";
11
3
  export type { GlassMotion, GlassMorph } from "../dom/index.js";
12
- import type { GlassBlurEdge, ProgressiveBlurOptions } from "../core/progressive.js";
13
4
  export type { GlassBlurEdge, ProgressiveBlurOptions } from "../core/progressive.js";
14
- /** The motion level a glass component inherits from its scene. */
15
- export declare function useGlassMotion(motion?: GlassMotion): GlassMotion;
16
- /** Ref for live foreground DOM; registration adds no material or GPU maps. */
17
- export declare function useGlassForeground(): (element: HTMLElement | null) => (() => void) | undefined;
18
- export interface GlassForegroundProps extends HTMLAttributes<HTMLElement> {
19
- render?: Parameters<typeof useRender>[0]["render"];
20
- ref?: Ref<HTMLElement>;
21
- }
22
- /** Content above the backdrop that refracts through higher glass surfaces. */
23
- export declare function GlassForeground({ render, ref, ...props }: GlassForegroundProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
24
- export interface GlassSceneProps extends ComponentPropsWithRef<"div">, GlassSceneOptions, Pick<MaterialOptions, "material" | "appearance"> {
25
- /** Motion for every glass component in the scene. `full` still follows the
26
- * system reduced-motion setting, which removes elasticity and travel. */
27
- motion?: GlassMotion;
28
- }
29
- export declare function GlassScene({ children, className, onDiagnostic, maxSurfaces, ref, material, appearance, motion, ...props }: GlassSceneProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
- export interface GlassContentProps extends ComponentPropsWithRef<"div"> {
31
- /** Flow content determines scene height; overlay is the default for backdrops. */
32
- layout?: "overlay" | "flow";
33
- }
34
- export declare function GlassContent({ layout, className, ref, ...props }: GlassContentProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
35
- /** How a glass surface moves. Every option is available to any surface. */
36
- export interface GlassMotionProps {
37
- /** Respond to touch and pointer input: grow under a press, stretch toward a
38
- * drag, settle with overshoot on release, and light up beneath the pointer. */
39
- interactive?: boolean;
40
- /** Grow out of this element when mounted, and shrink back into it when a
41
- * Base UI popup closes. */
42
- morphFrom?: RefObject<Element | null> | (() => Element | null | undefined);
43
- /** How the surface relates to the glass it grows from. `become`: the
44
- * source's glass is this surface; its content withdraws while the surface
45
- * is present. `detach`: the surface leaves the source's glass as a drop,
46
- * joined by a liquid neck until they part. Default: a glass source is
47
- * become; a source inside glass, such as a toolbar button, is detached from. */
48
- morph?: GlassMorph;
49
- /** How far a detaching surface stays joined to its glass by a liquid neck,
50
- * in pixels. `0` grows a plain shape with no union. Default: 18. */
51
- neck?: number;
52
- /** Grow out of `morphFrom` when mounted. `false` keeps only the exit, for
53
- * an element that is already in place. Default: true. */
54
- morphEnter?: boolean;
55
- /** Spring the glass outline when the surface's layout box changes. */
56
- fluid?: boolean;
57
- /** Override the scene's motion level for this surface. */
58
- motion?: GlassMotion;
59
- }
60
- export interface GlassSurfaceProps extends HTMLAttributes<HTMLElement>, MaterialOptions, GlassMotionProps {
61
- render?: useRender.RenderProp;
62
- ref?: Ref<HTMLElement>;
63
- }
64
- /** Pass a shadcn component with render={<Button/>}; geometry follows its real DOM. */
65
- export declare function GlassSurface({ material, appearance, radius, concentric, refraction, tint, interactive, morphFrom, morph, neck, morphEnter, fluid, motion, render, ref, children, className, style, ...props }: GlassSurfaceProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
66
- export type GlassButtonSize = "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
67
- export interface GlassButtonProps extends Omit<ComponentPropsWithRef<typeof Button>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion"> {
68
- className?: string;
69
- style?: CSSProperties;
70
- size?: GlassButtonSize;
71
- }
72
- export declare function GlassButton({ material, appearance, radius, refraction, tint, interactive, motion, size, className, style, children, ...props }: GlassButtonProps): import("react").JSX.Element;
73
- export interface GlassToolbarProps extends Omit<ComponentPropsWithRef<typeof Toolbar.Root>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion"> {
74
- className?: string;
75
- style?: CSSProperties;
76
- }
77
- export declare function GlassToolbar({ material, appearance, radius, refraction, tint, interactive, motion, className, style, children, ...props }: GlassToolbarProps): import("react").JSX.Element;
78
- export interface GlassToolbarButtonProps extends ComponentPropsWithRef<typeof Toolbar.Button> {
79
- /** Icon controls remain square; default controls fit their text. */
80
- size?: "icon" | "default";
81
- }
82
- export declare function GlassToolbarButton({ className, size, ...props }: GlassToolbarButtonProps): import("react").JSX.Element;
83
- export declare const GlassToolbarLink: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/toolbar").ToolbarLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
84
- export declare const GlassToolbarGroup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/toolbar").ToolbarGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
85
- export interface GlassToolbarSpacerProps extends Omit<ComponentPropsWithRef<"span">, "children"> {
86
- /** Flexible spacers fill available space; fixed spacers keep a standard gap. */
87
- sizing?: "fixed" | "flexible";
88
- }
89
- export declare function GlassToolbarSpacer({ sizing, className, ...props }: GlassToolbarSpacerProps): import("react").JSX.Element;
90
- export declare const GlassTabsRoot: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/tabs").TabsRootProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
91
- export declare const GlassTabsContent: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/tabs").TabsPanelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
92
- export interface GlassTabsListProps extends Omit<ComponentPropsWithRef<typeof Tabs.List>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion"> {
93
- className?: string;
94
- style?: CSSProperties;
95
- size?: "default" | "sm" | "lg";
96
- }
97
- export declare function GlassTabsList({ material, appearance, radius, refraction, tint, interactive, motion, size, className, style, children, ...props }: GlassTabsListProps): import("react").JSX.Element;
98
- export declare function GlassTabsIndicator({ material, appearance, radius, refraction, tint, motion, className, style, ref, ...props }: Omit<ComponentPropsWithRef<typeof Tabs.Indicator>, "className" | "style"> & MaterialOptions & Pick<GlassMotionProps, "motion"> & {
99
- className?: string;
100
- style?: CSSProperties;
101
- }): import("react").JSX.Element;
102
- export declare function GlassTabsTrigger({ children, className, ...props }: ComponentPropsWithRef<typeof Tabs.Tab>): import("react").JSX.Element;
103
- export interface GlassTabsProps extends Omit<ComponentPropsWithRef<typeof Tabs.Root>, "children" | "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion"> {
104
- items: readonly {
105
- value: string;
106
- label: ReactNode;
107
- disabled?: boolean;
108
- }[];
109
- "aria-label"?: string;
110
- className?: string;
111
- style?: CSSProperties;
112
- size?: "default" | "sm" | "lg";
113
- }
114
- export declare function GlassTabs({ items, defaultValue, material, appearance, radius, refraction, tint, interactive, motion, size, className, "aria-label": label, ...props }: GlassTabsProps): import("react").JSX.Element;
115
- export declare function GlassMenu<Payload>(props: Menu.Root.Props<Payload>): import("react").JSX.Element;
116
- export declare function GlassMenuTrigger<Payload>({ ref, ...props }: Menu.Trigger.Props<Payload> & {
117
- ref?: Ref<HTMLElement>;
118
- }): import("react").JSX.Element;
119
- export declare function GlassMenuSubmenu(props: Menu.SubmenuRoot.Props): import("react").JSX.Element;
120
- export declare function GlassMenuSubmenuTrigger({ ref, delay, ...props }: ComponentPropsWithRef<typeof Menu.SubmenuTrigger>): import("react").JSX.Element;
121
- export declare const GlassMenuGroup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
122
- export declare function GlassMenuGroupLabel(props: ComponentPropsWithRef<typeof Menu.GroupLabel>): import("react").JSX.Element;
123
- export declare const GlassMenuSeparator: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/separator").SeparatorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
124
- export declare function GlassMenuCheckboxItem(props: ComponentPropsWithRef<typeof Menu.CheckboxItem>): import("react").JSX.Element;
125
- export declare const GlassMenuRadioGroup: import("react").NamedExoticComponent<Omit<import("@base-ui/react/menu").MenuRadioGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
126
- export declare function GlassMenuRadioItem(props: ComponentPropsWithRef<typeof Menu.RadioItem>): import("react").JSX.Element;
127
- type GlassMenuPositioningProps = Pick<ComponentPropsWithRef<typeof Menu.Positioner>, "side" | "align" | "sideOffset" | "alignOffset" | "collisionAvoidance">;
128
- export interface GlassMenuContentProps extends GlassMenuPositioningProps, Omit<ComponentPropsWithRef<typeof Menu.Popup>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion" | "morph" | "neck"> {
129
- className?: string;
130
- style?: CSSProperties;
131
- positionerProps?: Omit<ComponentPropsWithRef<typeof Menu.Positioner>, "children">;
132
- portalProps?: Omit<ComponentPropsWithRef<typeof Menu.Portal>, "children" | "container">;
133
- }
134
- export declare function GlassMenuContent({ children, className, style, material, appearance, radius, refraction, tint, interactive, motion, morph, neck, side, align, sideOffset, alignOffset, collisionAvoidance, positionerProps, portalProps, ...props }: GlassMenuContentProps): import("react").JSX.Element;
135
- export declare function GlassMenuItem(props: ComponentPropsWithRef<typeof Menu.Item>): import("react").JSX.Element;
136
- /** A submenu uses the same glass surface and positioning as a root menu. It
137
- * grows out of its item as a plain shape: a neck to the parent menu would
138
- * cost a traced union per frame of the path, for a shape that is meant to
139
- * appear the moment the pointer rests on its item. */
140
- export declare function GlassMenuSubmenuContent(props: GlassMenuContentProps): import("react").JSX.Element;
141
- export interface GlassProgressiveBlurProps extends ProgressiveBlurOptions, Omit<ComponentPropsWithRef<"div">, "children"> {
142
- children?: never;
143
- }
144
- /** A decorative region affecting the scene's explicit GlassContent only. */
145
- export declare function GlassProgressiveBlur({ edge, size, blur, refraction, disabled, className, style, ref, ...props }: GlassProgressiveBlurProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
146
- export interface GlassScrollEdgesProps extends Omit<ProgressiveBlurOptions, "edge"> {
147
- /** The existing scroll container. Does not create or replace scrolling. */
148
- target: RefObject<HTMLElement | null>;
149
- edges?: readonly GlassBlurEdge[];
150
- }
151
- /** Filters only the target scrollport. Place floating controls outside that
152
- * element to keep them sharp; no extra viewport wrapper is required. */
153
- export declare function GlassScrollEdges({ target, edges, size, blur, refraction, disabled }: GlassScrollEdgesProps): null;
5
+ export { GlassScene, GlassContent, GlassForeground, useGlassForeground, useGlassMotion } from "./scene.js";
6
+ export type { GlassSceneProps, GlassContentProps, GlassForegroundProps } from "./scene.js";
7
+ export { GlassSurface } from "./surface.js";
8
+ export type { GlassSurfaceProps, GlassMotionProps } from "./surface.js";
9
+ export { GlassButton } from "./button.js";
10
+ export type { GlassButtonProps, GlassButtonSize } from "./button.js";
11
+ export { GlassToolbar, GlassToolbarButton, GlassToolbarLink, GlassToolbarGroup, GlassToolbarSpacer } from "./toolbar.js";
12
+ export type { GlassToolbarProps, GlassToolbarButtonProps, GlassToolbarSpacerProps } from "./toolbar.js";
13
+ export { GlassTabs, GlassTabsRoot, GlassTabsList, GlassTabsIndicator, GlassTabsTrigger, GlassTabsContent } from "./tabs.js";
14
+ export type { GlassTabsProps, GlassTabsListProps } from "./tabs.js";
15
+ export { GlassMenu, GlassMenuTrigger, GlassMenuContent, GlassMenuItem, GlassMenuGroup, GlassMenuGroupLabel, GlassMenuSeparator, GlassMenuCheckboxItem, GlassMenuRadioGroup, GlassMenuRadioItem, GlassMenuSubmenu, GlassMenuSubmenuTrigger, GlassMenuSubmenuContent, } from "./menu.js";
16
+ export type { GlassMenuContentProps } from "./menu.js";
17
+ export { GlassProgressiveBlur, GlassScrollEdges } from "./progressive.js";
18
+ export type { GlassProgressiveBlurProps, GlassScrollEdgesProps } from "./progressive.js";
154
19
  export { GlassSlider, GlassSwitch } from "./value-controls.js";
155
20
  export type { GlassSliderProps, GlassSwitchProps } from "./value-controls.js";
@@ -0,0 +1,29 @@
1
+ import type { CSSProperties, ComponentPropsWithRef, Ref } from "react";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import type { MaterialOptions } from "../core/materials.js";
4
+ import type { GlassMotionProps } from "./surface.js";
5
+ export declare function GlassMenu<Payload>(props: Menu.Root.Props<Payload>): import("react").JSX.Element;
6
+ export declare function GlassMenuTrigger<Payload>({ ref, ...props }: Menu.Trigger.Props<Payload> & {
7
+ ref?: Ref<HTMLElement>;
8
+ }): import("react").JSX.Element;
9
+ export declare function GlassMenuSubmenu(props: Menu.SubmenuRoot.Props): import("react").JSX.Element;
10
+ export declare function GlassMenuSubmenuTrigger({ ref, delay, onPointerEnter, onPointerLeave, onFocus, onBlur, ...props }: ComponentPropsWithRef<typeof Menu.SubmenuTrigger>): import("react").JSX.Element;
11
+ export declare const GlassMenuGroup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
12
+ export declare function GlassMenuGroupLabel(props: ComponentPropsWithRef<typeof Menu.GroupLabel>): import("react").JSX.Element;
13
+ export declare const GlassMenuSeparator: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/separator").SeparatorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
14
+ export declare function GlassMenuCheckboxItem(props: ComponentPropsWithRef<typeof Menu.CheckboxItem>): import("react").JSX.Element;
15
+ export declare const GlassMenuRadioGroup: import("react").NamedExoticComponent<Omit<import("@base-ui/react/menu").MenuRadioGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
16
+ export declare function GlassMenuRadioItem(props: ComponentPropsWithRef<typeof Menu.RadioItem>): import("react").JSX.Element;
17
+ type GlassMenuPositioningProps = Pick<ComponentPropsWithRef<typeof Menu.Positioner>, "side" | "align" | "sideOffset" | "alignOffset" | "collisionAvoidance">;
18
+ export interface GlassMenuContentProps extends GlassMenuPositioningProps, Omit<ComponentPropsWithRef<typeof Menu.Popup>, "className" | "style">, MaterialOptions, Pick<GlassMotionProps, "interactive" | "motion" | "morph" | "neck"> {
19
+ className?: string;
20
+ style?: CSSProperties;
21
+ positionerProps?: Omit<ComponentPropsWithRef<typeof Menu.Positioner>, "children">;
22
+ portalProps?: Omit<ComponentPropsWithRef<typeof Menu.Portal>, "children" | "container">;
23
+ }
24
+ export declare function GlassMenuContent({ children, className, style, material, appearance, radius, refraction, tint, interactive, motion, morph, neck, side, align, sideOffset, alignOffset, collisionAvoidance, positionerProps, portalProps, ...props }: GlassMenuContentProps): import("react").JSX.Element;
25
+ export declare function GlassMenuItem(props: ComponentPropsWithRef<typeof Menu.Item>): import("react").JSX.Element;
26
+ /** Submenus fade beside their parent. Moving between siblings morphs the
27
+ * existing panel into the next panel's position and size. */
28
+ export declare function GlassMenuSubmenuContent(props: GlassMenuContentProps): import("react").JSX.Element;
29
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ComponentPropsWithRef, RefObject } from "react";
2
+ import type { GlassBlurEdge, ProgressiveBlurOptions } from "../core/progressive.js";
3
+ export interface GlassProgressiveBlurProps extends ProgressiveBlurOptions, Omit<ComponentPropsWithRef<"div">, "children"> {
4
+ children?: never;
5
+ }
6
+ /** A decorative region affecting the scene's explicit GlassContent only. */
7
+ export declare function GlassProgressiveBlur({ edge, size, blur, refraction, disabled, className, style, ref, ...props }: GlassProgressiveBlurProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
8
+ export interface GlassScrollEdgesProps extends Omit<ProgressiveBlurOptions, "edge"> {
9
+ /** The existing scroll container. Does not create or replace scrolling. */
10
+ target: RefObject<HTMLElement | null>;
11
+ edges?: readonly GlassBlurEdge[];
12
+ }
13
+ /** Filters only the target scrollport. Place floating controls outside that
14
+ * element to keep them sharp; no extra viewport wrapper is required. */
15
+ export declare function GlassScrollEdges({ target, edges, size, blur, refraction, disabled }: GlassScrollEdgesProps): null;
@@ -0,0 +1,35 @@
1
+ import type { ComponentPropsWithRef, HTMLAttributes, Ref } from "react";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import type { GlassSceneController, GlassSceneOptions, GlassMotion } from "../dom/index.js";
4
+ import type { MaterialOptions } from "../core/materials.js";
5
+ interface SceneContextValue {
6
+ controller: GlassSceneController;
7
+ root: HTMLElement | null;
8
+ maxSurfaces: number;
9
+ material: MaterialOptions["material"];
10
+ appearance: MaterialOptions["appearance"];
11
+ motion: GlassMotion;
12
+ }
13
+ /** The motion level a glass component inherits from its scene. */
14
+ export declare function useGlassMotion(motion?: GlassMotion): GlassMotion;
15
+ export declare function useScene(): SceneContextValue;
16
+ /** Ref for live foreground DOM; registration adds no material or GPU maps. */
17
+ export declare function useGlassForeground(): (element: HTMLElement | null) => (() => void) | undefined;
18
+ export interface GlassForegroundProps extends HTMLAttributes<HTMLElement> {
19
+ render?: Parameters<typeof useRender>[0]["render"];
20
+ ref?: Ref<HTMLElement>;
21
+ }
22
+ /** Content above the backdrop that refracts through higher glass surfaces. */
23
+ export declare function GlassForeground({ render, ref, ...props }: GlassForegroundProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
24
+ export interface GlassSceneProps extends ComponentPropsWithRef<"div">, GlassSceneOptions, Pick<MaterialOptions, "material" | "appearance"> {
25
+ /** Motion for every glass component in the scene. `full` still follows the
26
+ * system reduced-motion setting, which removes elasticity and travel. */
27
+ motion?: GlassMotion;
28
+ }
29
+ export declare function GlassScene({ children, className, onDiagnostic, maxSurfaces, ref, material, appearance, motion, ...props }: GlassSceneProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
+ export interface GlassContentProps extends ComponentPropsWithRef<"div"> {
31
+ /** Flow determines scene height; scroll is a native scrollport filling the scene. */
32
+ layout?: "overlay" | "flow" | "scroll";
33
+ }
34
+ export declare function GlassContent({ layout, className, ref, ...props }: GlassContentProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
35
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { HTMLAttributes, Ref, RefObject } from "react";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import type { GlassMotion, GlassMorph } from "../dom/index.js";
4
+ import type { MaterialOptions } from "../core/materials.js";
5
+ /** How a glass surface moves. Every option is available to any surface. */
6
+ export interface GlassMotionProps {
7
+ /** Respond to touch and pointer input: grow under a press, stretch toward a
8
+ * drag, settle with overshoot on release, and light up beneath the pointer. */
9
+ interactive?: boolean;
10
+ /** Grow out of this element when mounted, and shrink back into it when a
11
+ * Base UI popup closes. */
12
+ morphFrom?: RefObject<Element | null> | (() => Element | null | undefined);
13
+ /** How the surface relates to the glass it grows from. `become`: the
14
+ * source's glass is this surface; its content withdraws while the surface
15
+ * is present. `detach`: the surface leaves the source's glass as a drop,
16
+ * joined by a liquid neck until they part. Default: a glass source is
17
+ * become; a source inside glass, such as a toolbar button, is detached from. */
18
+ morph?: GlassMorph;
19
+ /** How far a detaching surface stays joined to its glass by a liquid neck,
20
+ * in pixels. `0` grows a plain shape with no union. Default: 18. */
21
+ neck?: number;
22
+ /** Grow out of `morphFrom` when mounted. `false` keeps only the exit, for
23
+ * an element that is already in place. Default: true. */
24
+ morphEnter?: boolean;
25
+ /** Spring the glass outline when the surface's layout box changes. */
26
+ fluid?: boolean;
27
+ /** Override the scene's motion level for this surface. */
28
+ motion?: GlassMotion;
29
+ }
30
+ export interface GlassSurfaceProps extends HTMLAttributes<HTMLElement>, MaterialOptions, GlassMotionProps {
31
+ render?: useRender.RenderProp;
32
+ ref?: Ref<HTMLElement>;
33
+ }
34
+ /** Pass a shadcn component with render={<Button/>}; geometry follows its real DOM. */
35
+ export declare function GlassSurface({ material, appearance, radius, concentric, refraction, tint, interactive, morphFrom, morph, neck, morphEnter, fluid, motion, render, ref, children, className, style, ...props }: GlassSurfaceProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;