glasslikeui 0.2.2 → 1.0.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.
Files changed (79) hide show
  1. package/README.md +214 -0
  2. package/dist/actions/a11ySync.d.ts +9 -0
  3. package/dist/actions/a11ySync.js +49 -0
  4. package/dist/actions/deviceMotion.d.ts +31 -0
  5. package/dist/actions/deviceMotion.js +142 -0
  6. package/dist/actions/dragSnap.d.ts +47 -0
  7. package/dist/actions/dragSnap.js +222 -0
  8. package/dist/actions/index.d.ts +5 -0
  9. package/dist/actions/index.js +5 -0
  10. package/dist/actions/scrollEdge.d.ts +21 -0
  11. package/dist/actions/scrollEdge.js +61 -0
  12. package/dist/actions/viewTransition.d.ts +23 -0
  13. package/dist/actions/viewTransition.js +34 -0
  14. package/dist/components/glass/Glass.svelte +164 -0
  15. package/dist/components/glass/Glass.svelte.d.ts +19 -0
  16. package/dist/components/glass/GlassCard.svelte +12 -5
  17. package/dist/components/glass/GlassCard.svelte.d.ts +4 -2
  18. package/dist/components/glass/GlassDimLayer.svelte +37 -0
  19. package/dist/components/glass/GlassDimLayer.svelte.d.ts +8 -0
  20. package/dist/components/glass/GlassEffectContainer.svelte +58 -0
  21. package/dist/components/glass/GlassEffectContainer.svelte.d.ts +12 -0
  22. package/dist/components/glass/GlassMorph.svelte +42 -0
  23. package/dist/components/glass/GlassMorph.svelte.d.ts +10 -0
  24. package/dist/components/glass/GlassSection.svelte +11 -5
  25. package/dist/components/glass/GlassSection.svelte.d.ts +4 -2
  26. package/dist/components/glass/LensFilters.svelte +41 -0
  27. package/dist/components/glass/LensFilters.svelte.d.ts +18 -0
  28. package/dist/components/glass/Sheet.svelte +70 -40
  29. package/dist/components/glass/Sheet.svelte.d.ts +6 -2
  30. package/dist/components/glass/index.d.ts +5 -5
  31. package/dist/components/glass/index.js +5 -5
  32. package/dist/components/index.d.ts +1 -1
  33. package/dist/components/index.js +1 -1
  34. package/dist/components/interactive/Badge.svelte +3 -11
  35. package/dist/components/interactive/Badge.svelte.d.ts +2 -2
  36. package/dist/components/interactive/Button.svelte +9 -32
  37. package/dist/components/interactive/Button.svelte.d.ts +4 -4
  38. package/dist/components/interactive/IconButton.svelte +3 -14
  39. package/dist/components/interactive/IconButton.svelte.d.ts +4 -4
  40. package/dist/components/interactive/TabView.svelte +5 -4
  41. package/dist/components/interactive/TabView.svelte.d.ts +1 -1
  42. package/dist/components/layout/Divider.svelte.d.ts +1 -1
  43. package/dist/components/layout/Grid.svelte.d.ts +1 -1
  44. package/dist/components/layout/HStack.svelte.d.ts +1 -1
  45. package/dist/components/layout/ScrollView.svelte +27 -4
  46. package/dist/components/layout/ScrollView.svelte.d.ts +5 -1
  47. package/dist/components/layout/Spacer.svelte.d.ts +1 -1
  48. package/dist/components/layout/VStack.svelte.d.ts +1 -1
  49. package/dist/components/layout/ZStack.svelte.d.ts +1 -1
  50. package/dist/components/list/List.svelte +3 -3
  51. package/dist/components/list/List.svelte.d.ts +1 -1
  52. package/dist/components/list/ListRow.svelte.d.ts +1 -1
  53. package/dist/components/media/SymbolImage.svelte.d.ts +1 -1
  54. package/dist/components/navigation/NavigationBar.svelte +113 -24
  55. package/dist/components/navigation/NavigationBar.svelte.d.ts +2 -1
  56. package/dist/components/navigation/NavigationLink.svelte.d.ts +1 -1
  57. package/dist/components/typography/Text.svelte +3 -2
  58. package/dist/components/typography/Text.svelte.d.ts +2 -2
  59. package/dist/constants/colors.js +2 -2
  60. package/dist/constants/index.d.ts +1 -5
  61. package/dist/constants/index.js +1 -5
  62. package/dist/constants/sizes.js +4 -4
  63. package/dist/constants/variants.d.ts +23 -0
  64. package/dist/constants/variants.js +18 -0
  65. package/dist/icons/index.js +10 -7
  66. package/dist/index.d.ts +2 -4
  67. package/dist/index.js +2 -7
  68. package/dist/styles/glasslikeui.css +192 -0
  69. package/dist/styles/lens.css +93 -0
  70. package/dist/styles/squircle.css +17 -0
  71. package/dist/styles/typography.css +27 -0
  72. package/dist/test-setup.d.ts +1 -0
  73. package/dist/test-setup.js +6 -0
  74. package/package.json +19 -7
  75. package/dist/components/glass/LiquidGlass.svelte +0 -123
  76. package/dist/components/glass/LiquidGlass.svelte.d.ts +0 -17
  77. package/dist/constants/materials.d.ts +0 -13
  78. package/dist/constants/materials.js +0 -43
  79. package/dist/styles/liquidglass.css +0 -139
package/README.md CHANGED
@@ -1 +1,215 @@
1
1
  # GlassLikeUI
2
+
3
+ Svelte component library with frosted glass materials. Pseudo-element
4
+ lensing, two-axis variant API, drag-snap sheets, View Transitions morph,
5
+ accessibility-aware out of the box, cross-platform typography.
6
+
7
+ Svelte 5 only. MIT licensed.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install glasslikeui
13
+ ```
14
+
15
+ Peer dependency: `svelte ^5.0.0`.
16
+
17
+ ## Setup
18
+
19
+ Mount `LensFilters` once near the root of your app, and import the
20
+ stylesheets you want:
21
+
22
+ ```svelte
23
+ <script>
24
+ import { LensFilters } from 'glasslikeui';
25
+ import 'glasslikeui/glasslikeui.css';
26
+ import 'glasslikeui/lens.css';
27
+ import 'glasslikeui/squircle.css';
28
+ import 'glasslikeui/typography.css';
29
+ </script>
30
+
31
+ <LensFilters />
32
+ <!-- rest of app -->
33
+ ```
34
+
35
+ Optional: wire browser accessibility prefs into the library's fallback
36
+ attributes on non-Safari browsers:
37
+
38
+ ```svelte
39
+ <script>
40
+ import { onMount } from 'svelte';
41
+ import { syncAccessibilityPreferences } from 'glasslikeui';
42
+ onMount(() => syncAccessibilityPreferences());
43
+ </script>
44
+ ```
45
+
46
+ ## Basic use
47
+
48
+ ```svelte
49
+ <script>
50
+ import { Glass, Button } from 'glasslikeui';
51
+ </script>
52
+
53
+ <Glass variant="regular" intensity="standard">
54
+ {#snippet children()}
55
+ <h2>Frosted card</h2>
56
+ <Button variant="filled">Action</Button>
57
+ {/snippet}
58
+ </Glass>
59
+ ```
60
+
61
+ ## Variants and intensity
62
+
63
+ `Glass` (and its consumers: `GlassCard`, `GlassSection`, `List`,
64
+ `TabView`) takes two orthogonal props:
65
+
66
+ - `variant` -- `regular` (default) or `clear`. Clear requires a
67
+ `<GlassDimLayer />` companion for legibility.
68
+ - `intensity` -- `subtle`, `standard` (default), or `prominent`.
69
+ Controls blur, edge displacement, and saturation together.
70
+
71
+ ## Components
72
+
73
+ | Component | Purpose |
74
+ | ------------------------ | ------------------------------------------------ |
75
+ | `Glass` | Core frosted surface. |
76
+ | `GlassCard` | Header / body / footer card. |
77
+ | `GlassSection` | Titled section block. |
78
+ | `GlassEffectContainer` | Groups glass siblings with shared shadow. |
79
+ | `GlassDimLayer` | Required under `variant="clear"`. |
80
+ | `GlassMorph` | Tag a subtree for View Transitions morph. |
81
+ | `LensFilters` | SVG filter defs (mount once). |
82
+ | `Sheet` | Bottom sheet with detents + drag-to-snap. |
83
+ | `NavigationBar` | Top chrome; supports `largeTitle` collapse. |
84
+ | `NavigationLink` | Pill-style link. |
85
+ | `TabView` | Floating tab bar. |
86
+ | `Button` / `IconButton` | `filled` / `outlined` / `plain` / `tinted` / `destructive`. |
87
+ | `Badge` | `default` / `accent`. |
88
+ | `Text` | Dynamic-Type-aware text. |
89
+ | `List` / `ListRow` | Grouped list with insets. |
90
+ | `HStack` / `VStack` / `ZStack` / `Grid` / `Spacer` / `Divider` / `ScrollView` | Layout primitives. |
91
+ | `SymbolImage` | SVG icon renderer. |
92
+
93
+ ## Actions
94
+
95
+ | Export | Purpose |
96
+ | -------------------------------- | ------------------------------------------------------ |
97
+ | `scrollEdge` | Fade a scroll container at edges meeting glass chrome. |
98
+ | `dragSnap` | Detent-based drag gesture (used by `Sheet`). |
99
+ | `deviceMotion` | Ties the glass highlight angle to device tilt. |
100
+ | `withGlassTransition` | Wraps a DOM update in a view transition. |
101
+ | `syncAccessibilityPreferences` | Bridges `prefers-*` media to data-attrs at `:root`. |
102
+ | `requestMotionPermission` | Triggers the iOS user-gesture permission flow. |
103
+
104
+ ## Device motion (opt-in)
105
+
106
+ The `motion` prop on `Glass` ties the highlight angle to the device's
107
+ tilt. iOS Safari requires a **user-gesture permission grant** before
108
+ tilt events fire. You MUST call `requestMotionPermission()` from a
109
+ click or tap handler -- not from `onMount`, an effect, or module init.
110
+
111
+ ```svelte
112
+ <script>
113
+ import { Glass, requestMotionPermission } from 'glasslikeui';
114
+
115
+ let permission = $state('pending');
116
+
117
+ async function enable() {
118
+ permission = await requestMotionPermission();
119
+ // 'granted' | 'denied' | 'unavailable'
120
+ }
121
+ </script>
122
+
123
+ {#if permission === 'pending'}
124
+ <button onclick={enable}>Enable tilt effect</button>
125
+ {/if}
126
+
127
+ <Glass motion={permission === 'granted'}>
128
+ {#snippet children()}...{/snippet}
129
+ </Glass>
130
+ ```
131
+
132
+ Requirements:
133
+
134
+ - **User gesture** -- call inside `onclick` / `ontap` / form handler.
135
+ Called outside a gesture, iOS silently returns `denied` without
136
+ showing the prompt.
137
+ - **HTTPS** -- `http://localhost` works for dev; plain HTTP on a real
138
+ device does not expose the API.
139
+ - **Per-origin** -- granted or denied once, then remembered. A denied
140
+ decision can only be reset by the user in
141
+ Settings -> Safari -> Advanced.
142
+ - **Non-iOS browsers** (Android Chrome, desktop Chrome / Firefox /
143
+ Safari) grant access implicitly; the helper returns `'granted'`
144
+ without any prompt on those.
145
+ - **Unsupported browsers** (no `DeviceOrientationEvent`) -- helper
146
+ returns `'unavailable'` and the action is a no-op.
147
+
148
+ ## Icons
149
+
150
+ A small SF-symbol-inspired set ships in `ICONS`. Register your own
151
+ before rendering:
152
+
153
+ ```ts
154
+ import { registerIcons } from 'glasslikeui';
155
+ registerIcons({
156
+ 'custom-symbol': '<path d="..." />'
157
+ });
158
+ ```
159
+
160
+ ## Accessibility
161
+
162
+ Native preference handling with zero config:
163
+
164
+ - `prefers-reduced-transparency` -- surfaces go opaque, blur off
165
+ - `prefers-contrast: more` -- thicker borders, higher opacity
166
+ - `prefers-reduced-motion` -- transitions and motion highlights off
167
+
168
+ Cross-browser fallback attributes (flip at `:root`):
169
+
170
+ - `data-reduced-transparency="true"`
171
+ - `data-contrast="more"`
172
+ - `data-reduced-motion="true"`
173
+
174
+ Call `syncAccessibilityPreferences()` to manage these automatically.
175
+
176
+ ## Theming
177
+
178
+ All design tokens are CSS custom properties. Toggle dark / light with
179
+ the `data-theme` attribute on `:root`:
180
+
181
+ ```html
182
+ <html data-theme="light">...</html>
183
+ ```
184
+
185
+ Override any token via your own stylesheet, e.g.:
186
+
187
+ ```css
188
+ :root {
189
+ --color-accent: #FF6A00;
190
+ --glass-radius-lg: 28px;
191
+ }
192
+ ```
193
+
194
+ ## Browser support
195
+
196
+ | Browser | Support |
197
+ | ---------------------- | ----------------------------------------------------- |
198
+ | Chrome / Edge 111+ | Full. |
199
+ | Safari 16.4+ | Full, including native `prefers-reduced-transparency`.|
200
+ | Firefox 115+ | Full. 103-114 works without edge lensing. |
201
+ | Older | Opaque fallback via `@supports not`. |
202
+ | SSR | All actions guard `typeof window`. |
203
+
204
+ ## Build / test
205
+
206
+ ```sh
207
+ npm run package # svelte-package build
208
+ npm test # vitest once
209
+ npm run test:watch # vitest watch
210
+ npm run test:coverage # with v8 coverage
211
+ ```
212
+
213
+ ## License
214
+
215
+ MIT. See `LICENSE`.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sync browser accessibility preferences (reduced transparency, more contrast,
3
+ * reduced motion) onto data-attributes on the document root. Call once at app
4
+ * startup so the library's CSS fallbacks activate in browsers that don't
5
+ * support the matching @media queries natively.
6
+ *
7
+ * Returns a cleanup function. Call it to detach the listeners.
8
+ */
9
+ export declare function syncAccessibilityPreferences(): () => void;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Sync browser accessibility preferences (reduced transparency, more contrast,
3
+ * reduced motion) onto data-attributes on the document root. Call once at app
4
+ * startup so the library's CSS fallbacks activate in browsers that don't
5
+ * support the matching @media queries natively.
6
+ *
7
+ * Returns a cleanup function. Call it to detach the listeners.
8
+ */
9
+ var MAPPINGS = [
10
+ { media: '(prefers-reduced-transparency: reduce)', attr: 'data-reduced-transparency' },
11
+ { media: '(prefers-contrast: more)', attr: 'data-contrast', value: 'more' },
12
+ { media: '(prefers-reduced-motion: reduce)', attr: 'data-reduced-motion' }
13
+ ];
14
+ export function syncAccessibilityPreferences() {
15
+ if (typeof window === 'undefined' ||
16
+ typeof document === 'undefined' ||
17
+ typeof window.matchMedia !== 'function') {
18
+ return function () { };
19
+ }
20
+ var cleanups = MAPPINGS.map(function (_a) {
21
+ var media = _a.media, attr = _a.attr, value = _a.value;
22
+ var mql = window.matchMedia(media);
23
+ var apply = function () {
24
+ if (mql.matches) {
25
+ document.documentElement.setAttribute(attr, value !== null && value !== void 0 ? value : 'true');
26
+ }
27
+ else {
28
+ document.documentElement.removeAttribute(attr);
29
+ }
30
+ };
31
+ apply();
32
+ if (typeof mql.addEventListener === 'function') {
33
+ mql.addEventListener('change', apply);
34
+ return function () { return mql.removeEventListener('change', apply); };
35
+ }
36
+ // Legacy Safari support
37
+ if (typeof mql.addListener === 'function') {
38
+ mql.addListener(apply);
39
+ return function () { return mql.removeListener(apply); };
40
+ }
41
+ return function () { };
42
+ });
43
+ return function () {
44
+ for (var _i = 0, cleanups_1 = cleanups; _i < cleanups_1.length; _i++) {
45
+ var fn = cleanups_1[_i];
46
+ fn();
47
+ }
48
+ };
49
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Svelte action: rotate glass highlight angle based on device tilt.
3
+ *
4
+ * iOS 13+ requires a user-gesture permission grant before DeviceOrientation
5
+ * events fire. Call `requestMotionPermission()` from a click or tap handler,
6
+ * NOT from onMount / an effect / module init, or iOS will silently deny.
7
+ * HTTPS is also required on real devices; http://localhost works for dev.
8
+ *
9
+ * Non-iOS browsers (Android Chrome, desktop Chrome/Firefox/Safari) grant
10
+ * access implicitly; the helper resolves to 'granted' without any prompt.
11
+ *
12
+ * Usage:
13
+ * <button onclick={async () => (permission = await requestMotionPermission())}>
14
+ * Enable motion
15
+ * </button>
16
+ * <div use:deviceMotion>...glass surface...</div>
17
+ */
18
+ export interface DeviceMotionOptions {
19
+ /** Multiplier on orientation angle. Default 1. */
20
+ sensitivity?: number;
21
+ /** Base angle when device is flat. Default 135deg. */
22
+ baseAngle?: number;
23
+ /** Skip updates when this is true. */
24
+ disabled?: boolean;
25
+ }
26
+ export declare function requestMotionPermission(): Promise<'granted' | 'denied' | 'unavailable'>;
27
+ export declare function isDeviceMotionSupported(): boolean;
28
+ export declare function deviceMotion(node: HTMLElement, initialOptions?: DeviceMotionOptions): {
29
+ update(newOptions: DeviceMotionOptions): void;
30
+ destroy(): void;
31
+ };
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Svelte action: rotate glass highlight angle based on device tilt.
3
+ *
4
+ * iOS 13+ requires a user-gesture permission grant before DeviceOrientation
5
+ * events fire. Call `requestMotionPermission()` from a click or tap handler,
6
+ * NOT from onMount / an effect / module init, or iOS will silently deny.
7
+ * HTTPS is also required on real devices; http://localhost works for dev.
8
+ *
9
+ * Non-iOS browsers (Android Chrome, desktop Chrome/Firefox/Safari) grant
10
+ * access implicitly; the helper resolves to 'granted' without any prompt.
11
+ *
12
+ * Usage:
13
+ * <button onclick={async () => (permission = await requestMotionPermission())}>
14
+ * Enable motion
15
+ * </button>
16
+ * <div use:deviceMotion>...glass surface...</div>
17
+ */
18
+ var __assign = (this && this.__assign) || function () {
19
+ __assign = Object.assign || function(t) {
20
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
21
+ s = arguments[i];
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
23
+ t[p] = s[p];
24
+ }
25
+ return t;
26
+ };
27
+ return __assign.apply(this, arguments);
28
+ };
29
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
+ return new (P || (P = Promise))(function (resolve, reject) {
32
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
36
+ });
37
+ };
38
+ var __generator = (this && this.__generator) || function (thisArg, body) {
39
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
41
+ function verb(n) { return function (v) { return step([n, v]); }; }
42
+ function step(op) {
43
+ if (f) throw new TypeError("Generator is already executing.");
44
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
45
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
46
+ if (y = 0, t) op = [op[0] & 2, t.value];
47
+ switch (op[0]) {
48
+ case 0: case 1: t = op; break;
49
+ case 4: _.label++; return { value: op[1], done: false };
50
+ case 5: _.label++; y = op[1]; op = [0]; continue;
51
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
52
+ default:
53
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
54
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
55
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
56
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
57
+ if (t[2]) _.ops.pop();
58
+ _.trys.pop(); continue;
59
+ }
60
+ op = body.call(thisArg, _);
61
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
62
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
63
+ }
64
+ };
65
+ export function requestMotionPermission() {
66
+ return __awaiter(this, void 0, Promise, function () {
67
+ var ctor, result, _a;
68
+ return __generator(this, function (_b) {
69
+ switch (_b.label) {
70
+ case 0:
71
+ if (typeof window === 'undefined' || typeof DeviceOrientationEvent === 'undefined') {
72
+ return [2 /*return*/, 'unavailable'];
73
+ }
74
+ ctor = DeviceOrientationEvent;
75
+ if (typeof ctor.requestPermission !== 'function') {
76
+ // Non-iOS browsers grant access implicitly.
77
+ return [2 /*return*/, 'granted'];
78
+ }
79
+ _b.label = 1;
80
+ case 1:
81
+ _b.trys.push([1, 3, , 4]);
82
+ return [4 /*yield*/, ctor.requestPermission()];
83
+ case 2:
84
+ result = _b.sent();
85
+ return [2 /*return*/, result === 'granted' ? 'granted' : 'denied'];
86
+ case 3:
87
+ _a = _b.sent();
88
+ return [2 /*return*/, 'denied'];
89
+ case 4: return [2 /*return*/];
90
+ }
91
+ });
92
+ });
93
+ }
94
+ export function isDeviceMotionSupported() {
95
+ return typeof window !== 'undefined' && typeof DeviceOrientationEvent !== 'undefined';
96
+ }
97
+ export function deviceMotion(node, initialOptions) {
98
+ if (initialOptions === void 0) { initialOptions = {}; }
99
+ var options = __assign({}, initialOptions);
100
+ if (!isDeviceMotionSupported()) {
101
+ return {
102
+ update: function (newOptions) {
103
+ options = __assign({}, newOptions);
104
+ },
105
+ destroy: function () { }
106
+ };
107
+ }
108
+ var pendingGamma = 0;
109
+ var rafHandle = null;
110
+ function onOrientation(event) {
111
+ var _a, _b;
112
+ if (options.disabled)
113
+ return;
114
+ var gamma = (_a = event.gamma) !== null && _a !== void 0 ? _a : 0;
115
+ pendingGamma = gamma * ((_b = options.sensitivity) !== null && _b !== void 0 ? _b : 1);
116
+ if (rafHandle === null && typeof requestAnimationFrame === 'function') {
117
+ rafHandle = requestAnimationFrame(flush);
118
+ }
119
+ else if (typeof requestAnimationFrame !== 'function') {
120
+ flush();
121
+ }
122
+ }
123
+ function flush() {
124
+ var _a;
125
+ rafHandle = null;
126
+ var base = (_a = options.baseAngle) !== null && _a !== void 0 ? _a : 135;
127
+ node.style.setProperty('--glass-highlight-angle', "".concat(base + pendingGamma, "deg"));
128
+ }
129
+ window.addEventListener('deviceorientation', onOrientation);
130
+ return {
131
+ update: function (newOptions) {
132
+ options = __assign({}, newOptions);
133
+ },
134
+ destroy: function () {
135
+ window.removeEventListener('deviceorientation', onOrientation);
136
+ if (rafHandle !== null && typeof cancelAnimationFrame === 'function') {
137
+ cancelAnimationFrame(rafHandle);
138
+ }
139
+ node.style.removeProperty('--glass-highlight-angle');
140
+ }
141
+ };
142
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Svelte action: drag-to-snap gesture.
3
+ *
4
+ * Attaches pointer handlers to a handle element and drags a target surface
5
+ * between a set of named detent positions. Velocity-based snap on release,
6
+ * rubber-band feel when dragged past bounds.
7
+ *
8
+ * Usage:
9
+ * <div use:dragSnap={{
10
+ * target: sheetEl,
11
+ * detents: [0.25, 0.5, 0.9],
12
+ * initial: 1,
13
+ * onSnap: (i) => currentDetent = i
14
+ * }}>...</div>
15
+ */
16
+ export interface DragSnapOptions {
17
+ /** Element whose transform is manipulated. If omitted, uses the node itself. */
18
+ target?: HTMLElement | null;
19
+ /** Detent positions as viewport-height fractions (0..1). Higher = taller sheet. */
20
+ detents: number[];
21
+ /** Initial detent index. */
22
+ initial?: number;
23
+ /** Called when drag snaps to a detent. */
24
+ onSnap?: (index: number, fraction: number) => void;
25
+ /** Called each animation frame during drag. */
26
+ onDrag?: (offsetY: number, currentFraction: number) => void;
27
+ /** Rubber-band coefficient when past max detent. Default 0.3. */
28
+ rubberBand?: number;
29
+ /** px/s threshold for velocity-based snap. Default 500. */
30
+ velocityThreshold?: number;
31
+ /** Skip drag when target is a scrollable container whose scrollTop > 0. Default true. */
32
+ respectScroll?: boolean;
33
+ /** Disable the gesture. */
34
+ disabled?: boolean;
35
+ }
36
+ export declare function dragSnap(node: HTMLElement, initialOptions: DragSnapOptions): {
37
+ update(newOptions: DragSnapOptions): void;
38
+ destroy(): void;
39
+ };
40
+ export declare const DEFAULT_DETENT_FRACTIONS: {
41
+ readonly small: 0.25;
42
+ readonly medium: 0.5;
43
+ readonly large: 0.9;
44
+ readonly fullscreen: 1;
45
+ };
46
+ export type SheetDetentName = keyof typeof DEFAULT_DETENT_FRACTIONS;
47
+ export declare function detentFractions(names: readonly SheetDetentName[]): number[];