@zakisheriff/liquid-glass 0.1.2 → 0.2.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.
- package/README.md +51 -569
- package/dist/index.css +670 -1339
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +191 -79
- package/dist/index.d.ts +191 -79
- package/dist/index.js +1764 -701
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1752 -697
- package/dist/index.mjs.map +1 -1
- package/package.json +36 -16
package/dist/index.d.mts
CHANGED
|
@@ -1,99 +1,83 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
3
|
interface GlassButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
-
/**
|
|
4
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
6
5
|
intensity?: number;
|
|
7
|
-
/** CSS colour
|
|
6
|
+
/** Any CSS colour. Tints the label, or the fill for `filled`. */
|
|
8
7
|
tint?: string;
|
|
9
|
-
/**
|
|
8
|
+
/** Light bloom under the finger while pressed. Default true. */
|
|
10
9
|
shimmer?: boolean;
|
|
11
|
-
/**
|
|
10
|
+
/** Rim bevel scale (1–4). Wider bevels bend more of the backdrop. Default 1. */
|
|
12
11
|
thickness?: number;
|
|
13
|
-
/**
|
|
12
|
+
/** Height preset: 36 / 44 / 52 px. Default 'md'. */
|
|
14
13
|
size?: 'sm' | 'md' | 'lg';
|
|
15
|
-
/**
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* `default` regular glass · `clear` (alias `ghost`) see-through glass ·
|
|
16
|
+
* `filled` accent-coloured · `destructive` red label.
|
|
17
|
+
*/
|
|
18
|
+
variant?: 'default' | 'ghost' | 'clear' | 'filled' | 'destructive';
|
|
19
|
+
/** Leading icon. With no children the button becomes a circle. */
|
|
20
|
+
icon?: React$1.ReactNode;
|
|
17
21
|
children?: React$1.ReactNode;
|
|
18
22
|
}
|
|
19
|
-
/**
|
|
20
|
-
* A glassmorphic button component inspired by the wabi.ai approach.
|
|
21
|
-
*
|
|
22
|
-
* Renders a 3‑layer structure:
|
|
23
|
-
* 1. `.lg-root` — outer wrapper for layout and stacking context
|
|
24
|
-
* 2. `.lg-surface` — interactive `<button>` with backdrop‑filter, box‑shadow,
|
|
25
|
-
* and a `::after` conic‑gradient border ring
|
|
26
|
-
* 3. `.lg-shadow` — decorative blurred gradient sitting behind the surface
|
|
27
|
-
*/
|
|
28
23
|
declare const GlassButton: React$1.ForwardRefExoticComponent<GlassButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
29
24
|
|
|
30
25
|
interface GlassCardProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
31
|
-
/**
|
|
26
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
32
27
|
intensity?: number;
|
|
33
|
-
/** CSS colour
|
|
28
|
+
/** CSS colour washed over the glass. */
|
|
34
29
|
tint?: string;
|
|
35
|
-
/**
|
|
30
|
+
/** Kept for API compatibility. */
|
|
36
31
|
shimmer?: boolean;
|
|
37
|
-
/**
|
|
32
|
+
/** Rim bevel scale (1–4). Default 1. */
|
|
38
33
|
thickness?: number;
|
|
39
|
-
/**
|
|
34
|
+
/** Inner padding. Default '24px'. */
|
|
40
35
|
padding?: string;
|
|
41
|
-
/**
|
|
36
|
+
/** Corner radius. Default '28px'. */
|
|
42
37
|
radius?: string;
|
|
38
|
+
/** `regular` frosted panel (default) or `clear` see-through glass. */
|
|
39
|
+
variant?: 'regular' | 'clear';
|
|
43
40
|
children?: React$1.ReactNode;
|
|
44
41
|
}
|
|
45
|
-
/**
|
|
46
|
-
* A glassmorphic card / container component.
|
|
47
|
-
*
|
|
48
|
-
* Uses the same 3‑layer wabi.ai glass architecture as GlassButton but with
|
|
49
|
-
* customisable border‑radius for rectangular containers and a generous
|
|
50
|
-
* content area.
|
|
51
|
-
*/
|
|
42
|
+
/** A refracting glass panel for grouping content. */
|
|
52
43
|
declare const GlassCard: React$1.ForwardRefExoticComponent<GlassCardProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
53
44
|
|
|
54
45
|
interface GlassInputProps extends Omit<React$1.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
55
|
-
/**
|
|
46
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
56
47
|
intensity?: number;
|
|
57
|
-
/**
|
|
48
|
+
/** Colour for the caret and focus glow. */
|
|
58
49
|
tint?: string;
|
|
59
|
-
/** Placeholder text for the input. */
|
|
60
50
|
placeholder?: string;
|
|
61
|
-
/** Controlled value. */
|
|
62
51
|
value?: string;
|
|
63
|
-
/** Change handler. */
|
|
64
52
|
onChange?: (e: React$1.ChangeEvent<HTMLInputElement>) => void;
|
|
65
|
-
/**
|
|
53
|
+
/** Small label above the field. */
|
|
66
54
|
label?: string;
|
|
55
|
+
/** Leading icon. `type="search"` gets a magnifier by default. */
|
|
56
|
+
icon?: React$1.ReactNode;
|
|
57
|
+
/** Trailing accessory, e.g. a microphone glyph. */
|
|
58
|
+
trailing?: React$1.ReactNode;
|
|
59
|
+
/** Called by the clear button. Without it, clearing emits an empty `onChange`. */
|
|
60
|
+
onClear?: () => void;
|
|
67
61
|
}
|
|
68
|
-
/**
|
|
69
|
-
* A glassmorphic text input with floating label and edge‑diffraction focus glow.
|
|
70
|
-
*
|
|
71
|
-
* Uses the same 3‑layer wabi.ai structure as other Liquid Glass components.
|
|
72
|
-
* On focus the conic‑gradient border animates and a pulsing box‑shadow with
|
|
73
|
-
* hue‑rotate creates a prismatic edge‑diffraction effect.
|
|
74
|
-
*/
|
|
62
|
+
/** iOS 26 search / text field on regular glass. */
|
|
75
63
|
declare const GlassInput: React$1.ForwardRefExoticComponent<GlassInputProps & React$1.RefAttributes<HTMLInputElement>>;
|
|
76
64
|
|
|
77
65
|
interface GlassSheetProps {
|
|
78
66
|
/** Whether the sheet is open. */
|
|
79
67
|
open: boolean;
|
|
80
|
-
/**
|
|
68
|
+
/** Called when the user dismisses the sheet (scrim, Escape, or swipe down). */
|
|
81
69
|
onClose?: () => void;
|
|
82
|
-
/**
|
|
70
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
83
71
|
intensity?: number;
|
|
84
|
-
/** CSS colour
|
|
72
|
+
/** CSS colour washed over the glass. */
|
|
85
73
|
tint?: string;
|
|
74
|
+
/** Accessible name for the dialog. */
|
|
75
|
+
'aria-label'?: string;
|
|
86
76
|
children?: React$1.ReactNode;
|
|
87
77
|
}
|
|
88
78
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* When `open` is `true` a scrim fades in and the glass sheet slides up from the
|
|
92
|
-
* bottom of the viewport. Clicking the scrim or pressing Escape calls `onClose`.
|
|
93
|
-
* A drag handle is rendered at the top of the sheet.
|
|
94
|
-
*
|
|
95
|
-
* Mount/unmount is handled via CSS transitions — the component stays in the DOM
|
|
96
|
-
* while its exit animation plays, then unmounts.
|
|
79
|
+
* iOS 26 floating sheet. Rises on a spring, can be flicked or dragged down to
|
|
80
|
+
* dismiss, and rubber-bands when pulled up.
|
|
97
81
|
*/
|
|
98
82
|
declare const GlassSheet: React$1.FC<GlassSheetProps>;
|
|
99
83
|
|
|
@@ -102,49 +86,88 @@ interface GlassNavItem {
|
|
|
102
86
|
icon?: React$1.ReactNode;
|
|
103
87
|
}
|
|
104
88
|
interface GlassNavProps {
|
|
105
|
-
/**
|
|
89
|
+
/** Tabs to render. Icons sit above labels, like the iOS 26 tab bar. */
|
|
106
90
|
items: GlassNavItem[];
|
|
107
|
-
/** Zero
|
|
91
|
+
/** Zero-based index of the selected tab. Default 0. */
|
|
108
92
|
activeIndex?: number;
|
|
109
|
-
/** Called when the
|
|
93
|
+
/** Called when a tab is tapped, or when the lens is dragged onto one. */
|
|
110
94
|
onChange?: (index: number) => void;
|
|
111
|
-
/**
|
|
95
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
112
96
|
intensity?: number;
|
|
97
|
+
className?: string;
|
|
98
|
+
style?: React$1.CSSProperties;
|
|
99
|
+
'aria-label'?: string;
|
|
113
100
|
}
|
|
114
101
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* A translucent active‑indicator slides between items via a spring‑like
|
|
118
|
-
* cubic‑bezier transition. Each item has subtle hover and press effects.
|
|
102
|
+
* The iOS 26 floating tab bar. Press a tab and the selection inflates into a
|
|
103
|
+
* liquid lens you can drag across the bar; let go and it drops into place.
|
|
119
104
|
*/
|
|
120
105
|
declare const GlassNav: React$1.FC<GlassNavProps>;
|
|
121
106
|
|
|
122
|
-
interface
|
|
123
|
-
|
|
107
|
+
interface GlassSegmentedOption {
|
|
108
|
+
label: string;
|
|
109
|
+
icon?: React$1.ReactNode;
|
|
110
|
+
}
|
|
111
|
+
interface GlassSegmentedProps {
|
|
112
|
+
/** Segment labels, or `{ label, icon }` objects. */
|
|
113
|
+
options: Array<string | GlassSegmentedOption>;
|
|
114
|
+
/** Zero-based index of the selected segment. */
|
|
115
|
+
value: number;
|
|
116
|
+
onChange?: (index: number) => void;
|
|
117
|
+
/** 36px (default) or compact 28px. */
|
|
118
|
+
size?: 'sm' | 'md';
|
|
119
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
120
|
+
intensity?: number;
|
|
121
|
+
className?: string;
|
|
122
|
+
style?: React$1.CSSProperties;
|
|
123
|
+
'aria-label'?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* iOS 26 segmented control. The whole control swells under the finger and the
|
|
127
|
+
* selection lifts into a clear lens that can be dragged between segments.
|
|
128
|
+
*/
|
|
129
|
+
declare const GlassSegmented: React$1.FC<GlassSegmentedProps>;
|
|
130
|
+
|
|
131
|
+
interface GlassSliderProps extends Omit<React$1.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'value' | 'min' | 'max'> {
|
|
132
|
+
value?: number;
|
|
133
|
+
min?: number;
|
|
134
|
+
max?: number;
|
|
135
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
124
136
|
intensity?: number;
|
|
125
|
-
/**
|
|
137
|
+
/** Fill colour. Defaults to the accent blue (white in block mode). */
|
|
126
138
|
tint?: string;
|
|
127
|
-
/**
|
|
139
|
+
/** Kept for API compatibility. */
|
|
128
140
|
shimmer?: boolean;
|
|
129
|
-
/**
|
|
141
|
+
/** Kept for API compatibility. */
|
|
130
142
|
thickness?: number;
|
|
131
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* `true` (default): thin iOS track with a glass thumb that lifts into a lens.
|
|
145
|
+
* `false`: Control Center block that fills and stretches under the finger.
|
|
146
|
+
*/
|
|
132
147
|
showThumb?: boolean;
|
|
133
|
-
/** Icon
|
|
148
|
+
/** Icon shown inside the block slider. */
|
|
134
149
|
icon?: React$1.ReactNode;
|
|
135
|
-
/**
|
|
150
|
+
/** Label shown inside the block slider. */
|
|
136
151
|
label?: string;
|
|
137
|
-
/** Custom callback for slider value changes. */
|
|
138
152
|
onChange?: (value: number) => void;
|
|
139
153
|
}
|
|
154
|
+
declare const GlassSlider: React$1.ForwardRefExoticComponent<GlassSliderProps & React$1.RefAttributes<HTMLInputElement>>;
|
|
155
|
+
|
|
156
|
+
interface GlassSwitchProps extends Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue'> {
|
|
157
|
+
checked?: boolean;
|
|
158
|
+
defaultChecked?: boolean;
|
|
159
|
+
onChange?: (checked: boolean) => void;
|
|
160
|
+
/** On-state colour. Defaults to system green. */
|
|
161
|
+
tint?: string;
|
|
162
|
+
/** Refraction strength from 1 (subtle) to 10 (heavy). Default 5. */
|
|
163
|
+
intensity?: number;
|
|
164
|
+
}
|
|
140
165
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* 1. Control block mode (showThumb={false}): Filled like a volume/brightness slider.
|
|
145
|
-
* 2. Classic track mode (showThumb={true}): Sleek track with a glowing liquid glass bead thumb.
|
|
166
|
+
* iOS 26 switch. Touch the knob and it inflates into a clear lens that hangs
|
|
167
|
+
* over the track, refracting it; drag it across or tap, and it drops back
|
|
168
|
+
* into a white pill with a jelly wobble.
|
|
146
169
|
*/
|
|
147
|
-
declare const
|
|
170
|
+
declare const GlassSwitch: React$1.ForwardRefExoticComponent<GlassSwitchProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
148
171
|
|
|
149
172
|
interface LiquidGlassFilterProps {
|
|
150
173
|
children?: React$1.ReactNode;
|
|
@@ -154,7 +177,96 @@ interface LiquidGlassFilterProps {
|
|
|
154
177
|
* Wrap your app (or the section using glass components) with this provider.
|
|
155
178
|
* If not used, glass components will auto-inject a local filter.
|
|
156
179
|
*/
|
|
157
|
-
declare function LiquidGlassFilter({ children }: LiquidGlassFilterProps):
|
|
180
|
+
declare function LiquidGlassFilter({ children }: LiquidGlassFilterProps): React$1.JSX.Element;
|
|
181
|
+
|
|
182
|
+
type GlassKind = 'surface' | 'lens';
|
|
183
|
+
interface GlassShape {
|
|
184
|
+
/** `surface` bends the backdrop inward at the rim (bars, buttons, cards).
|
|
185
|
+
* `lens` is a thick droplet: magnifies, bends outward and splits colour. */
|
|
186
|
+
kind?: GlassKind;
|
|
187
|
+
/** Width of the curved rim in px. */
|
|
188
|
+
bezel?: number;
|
|
189
|
+
/** Optical depth of the glass in px; deeper bends more. */
|
|
190
|
+
thickness?: number;
|
|
191
|
+
/** Index of refraction. Glass ≈ 1.5. */
|
|
192
|
+
ior?: number;
|
|
193
|
+
/** Interior magnification (lens only). 1 = none. */
|
|
194
|
+
zoom?: number;
|
|
195
|
+
/** Chromatic split strength, 0–1. */
|
|
196
|
+
dispersion?: number;
|
|
197
|
+
/** Overall displacement multiplier. */
|
|
198
|
+
strength?: number;
|
|
199
|
+
}
|
|
200
|
+
/** Only Chromium runs SVG filters inside `backdrop-filter`. */
|
|
201
|
+
declare function canRefractBackdrop(): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Bakes refraction for `ref`'s current box (untransformed) and keeps it fresh
|
|
204
|
+
* on resize. Writes `--lg-filter` (Chromium) and `--lg-rim` on the element.
|
|
205
|
+
*
|
|
206
|
+
* `mirror` names the content that sits beneath the glass. Where the browser
|
|
207
|
+
* can't refract the live backdrop (Safari, Firefox), a live copy of it is
|
|
208
|
+
* refracted inside the glass instead, so lenses still bend light everywhere.
|
|
209
|
+
*/
|
|
210
|
+
declare function useRefraction(ref: React.RefObject<HTMLElement | null>, shape?: GlassShape, enabled?: boolean, mirror?: React.RefObject<HTMLElement | null>): void;
|
|
211
|
+
|
|
212
|
+
interface PressOptions {
|
|
213
|
+
/** Swell on touch as a fraction (0.14 = 14%). Defaults to iOS sizing: small
|
|
214
|
+
* circles swell ~20%, wide pills ~10%. Mouse presses swell a little less. */
|
|
215
|
+
grow?: number;
|
|
216
|
+
/** How far (px) the shape may lean toward a drag. */
|
|
217
|
+
lean?: number;
|
|
218
|
+
/** Max anisotropic stretch while dragging (0.1 = 10%). */
|
|
219
|
+
stretch?: number;
|
|
220
|
+
disabled?: boolean;
|
|
221
|
+
}
|
|
222
|
+
declare function usePress(ref: React.RefObject<HTMLElement | null>, options?: PressOptions): void;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Closed-form damped harmonic springs, stepped on a shared rAF loop.
|
|
226
|
+
*
|
|
227
|
+
* Each spring is solved analytically per frame (no Euler drift), so stiff
|
|
228
|
+
* presses stay stable and soft releases wobble exactly as tuned.
|
|
229
|
+
*/
|
|
230
|
+
interface SpringConfig {
|
|
231
|
+
/** Spring constant k (mass is 1). */
|
|
232
|
+
stiffness: number;
|
|
233
|
+
/** Damping coefficient c. ζ = c / (2√k); below 1 it overshoots. */
|
|
234
|
+
damping: number;
|
|
235
|
+
}
|
|
236
|
+
interface Spring {
|
|
237
|
+
readonly value: number;
|
|
238
|
+
readonly velocity: number;
|
|
239
|
+
readonly target: number;
|
|
240
|
+
/** Animate toward `target`. `instant` jumps there. */
|
|
241
|
+
set(target: number, instant?: boolean): void;
|
|
242
|
+
/** Change the feel mid-flight without losing velocity. */
|
|
243
|
+
tune(config: SpringConfig): void;
|
|
244
|
+
/** Give the spring a kick (px/s or units/s). */
|
|
245
|
+
impulse(velocity: number): void;
|
|
246
|
+
stop(): void;
|
|
247
|
+
}
|
|
248
|
+
declare function createSpring(initial: number, config: SpringConfig, onUpdate: (value: number, velocity: number) => void): Spring;
|
|
249
|
+
/** Converts Apple-style (response, dampingFraction) into k/c. */
|
|
250
|
+
declare function springFrom(response: number, dampingFraction: number): SpringConfig;
|
|
251
|
+
/** Feel presets tuned against iOS 26 screen recordings. */
|
|
252
|
+
declare const SPRINGS: {
|
|
253
|
+
/** Finger down: quick, almost no overshoot. */
|
|
254
|
+
readonly press: SpringConfig;
|
|
255
|
+
/** Finger up: soft settle with the gentle jelly wobble. */
|
|
256
|
+
readonly release: SpringConfig;
|
|
257
|
+
/** Following the finger during a drag. */
|
|
258
|
+
readonly drag: SpringConfig;
|
|
259
|
+
/** Sliding into a new slot after release. */
|
|
260
|
+
readonly snap: SpringConfig;
|
|
261
|
+
/** Lens inflating out of a selection pill. */
|
|
262
|
+
readonly lift: SpringConfig;
|
|
263
|
+
/** Lens deflating back into a pill: visibly wobbly. */
|
|
264
|
+
readonly settle: SpringConfig;
|
|
265
|
+
/** Colour cross-fades. */
|
|
266
|
+
readonly fade: SpringConfig;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
declare function haptic(): void;
|
|
158
270
|
|
|
159
271
|
interface UseGlassEffectOptions {
|
|
160
272
|
intensity?: number;
|
|
@@ -184,4 +296,4 @@ interface GlassAnimationState {
|
|
|
184
296
|
}
|
|
185
297
|
declare function useGlassAnimation(): GlassAnimationState;
|
|
186
298
|
|
|
187
|
-
export { type GlassAnimationState, GlassButton, type GlassButtonProps, GlassCard, type GlassCardProps, GlassInput, type GlassInputProps, GlassNav, type GlassNavProps, GlassSheet, type GlassSheetProps, GlassSlider, type GlassSliderProps, LiquidGlassFilter, type LiquidGlassFilterProps, type UseGlassEffectOptions, useGlassAnimation, useGlassEffect };
|
|
299
|
+
export { type GlassAnimationState, GlassButton, type GlassButtonProps, GlassCard, type GlassCardProps, GlassInput, type GlassInputProps, type GlassKind, GlassNav, type GlassNavItem, type GlassNavProps, GlassSegmented, type GlassSegmentedOption, type GlassSegmentedProps, type GlassShape, GlassSheet, type GlassSheetProps, GlassSlider, type GlassSliderProps, GlassSwitch, type GlassSwitchProps, LiquidGlassFilter, type LiquidGlassFilterProps, type PressOptions, SPRINGS, type Spring, type SpringConfig, type UseGlassEffectOptions, canRefractBackdrop, createSpring, haptic, springFrom, useGlassAnimation, useGlassEffect, usePress, useRefraction };
|