@stacksjs/stx 0.1.16 → 0.2.3
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/dist/a11y.d.ts +109 -5
- package/dist/analytics.d.ts +40 -0
- package/dist/animation.d.ts +91 -1
- package/dist/app.d.ts +51 -0
- package/dist/ast.d.ts +286 -0
- package/dist/async-components.d.ts +101 -0
- package/dist/auth.d.ts +1 -3
- package/dist/browser-composables.d.ts +314 -0
- package/dist/build-optimizer.d.ts +126 -0
- package/dist/build-views.d.ts +37 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/index.d.ts +60 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +7 -0
- package/dist/cli.js +10885 -1203
- package/dist/client/directive.d.ts +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/router.d.ts +36 -0
- package/dist/client/stx-router.browser.d.ts +0 -0
- package/dist/client-script.d.ts +22 -0
- package/dist/component-hmr.d.ts +120 -0
- package/dist/components.d.ts +23 -1
- package/dist/composables/index.d.ts +277 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-broadcast-channel.d.ts +58 -0
- package/dist/composables/use-clipboard.d.ts +34 -0
- package/dist/composables/use-cookie.d.ts +70 -0
- package/dist/composables/use-device-orientation.d.ts +109 -0
- package/dist/composables/use-event-source.d.ts +77 -0
- package/dist/composables/use-eye-dropper.d.ts +107 -0
- package/dist/composables/use-fetch.d.ts +84 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-idle.d.ts +84 -0
- package/dist/composables/use-intersection-observer.d.ts +81 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-mouse.d.ts +64 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-notification.d.ts +89 -0
- package/dist/composables/use-permissions.d.ts +109 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-share.d.ts +70 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-storage.d.ts +64 -0
- package/dist/composables/use-text-selection.d.ts +97 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-websocket.d.ts +69 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables.d.ts +268 -0
- package/dist/composition-api.d.ts +190 -0
- package/dist/computed.d.ts +137 -0
- package/dist/conditionals.d.ts +14 -2
- package/dist/config.d.ts +36 -3
- package/dist/craft-bridge.d.ts +319 -0
- package/dist/craft-compiler.d.ts +229 -0
- package/dist/craft-components.d.ts +411 -0
- package/dist/craft-entry.d.ts +5 -0
- package/dist/craft-ssr.d.ts +134 -0
- package/dist/craft.js +1553 -0
- package/dist/csp.d.ts +229 -0
- package/dist/database.d.ts +407 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +4 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/index.d.ts +84 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/dev-server/crosswind.d.ts +54 -0
- package/dist/dev-server/index.d.ts +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/native-window.d.ts +40 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/terminal-colors.d.ts +60 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/types.d.ts +92 -0
- package/dist/dev-server.d.ts +21 -0
- package/dist/devtools.d.ts +142 -0
- package/dist/directive-api.d.ts +111 -0
- package/dist/dynamic-components.d.ts +14 -0
- package/dist/edge-runtime.d.ts +200 -0
- package/dist/env.d.ts +9 -0
- package/dist/error-boundaries.d.ts +71 -0
- package/dist/error-handling.d.ts +1 -101
- package/dist/errors/codes.d.ts +99 -0
- package/dist/errors/formatter.d.ts +64 -0
- package/dist/errors/index.d.ts +56 -0
- package/dist/errors/logger.d.ts +74 -0
- package/dist/errors/sanitizer.d.ts +43 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events.d.ts +106 -0
- package/dist/expressions.d.ts +86 -11
- package/dist/formatter.d.ts +4 -0
- package/dist/forms-validation.d.ts +173 -0
- package/dist/forms.d.ts +157 -8
- package/dist/head.d.ts +225 -0
- package/dist/heatmap.d.ts +125 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hydration-runtime.d.ts +47 -0
- package/dist/hydration.d.ts +161 -0
- package/dist/i18n.d.ts +240 -4
- package/dist/image-optimization/build-plugin.d.ts +53 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/index.d.ts +86 -0
- package/dist/image-optimization/processor.d.ts +112 -0
- package/dist/includes.d.ts +94 -9
- package/dist/index.d.ts +63 -3
- package/dist/index.js +11604 -1318
- package/dist/init.d.ts +32 -2
- package/dist/interactive.d.ts +14 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/jsx-runtime.d.ts +110 -0
- package/dist/keep-alive.d.ts +87 -0
- package/dist/lazy-loader.d.ts +122 -0
- package/dist/loading-indicator.d.ts +40 -0
- package/dist/loops.d.ts +22 -1
- package/dist/media/client/blur-up.d.ts +65 -0
- package/dist/media/client/index.d.ts +77 -0
- package/dist/media/client/lazy-load.d.ts +73 -0
- package/dist/media/client/upload-handler.d.ts +79 -0
- package/dist/media/image/component.d.ts +46 -0
- package/dist/media/image/directive.d.ts +9 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/index.d.ts +118 -0
- package/dist/media/image/placeholder.d.ts +78 -0
- package/dist/media/image/processor/cache.d.ts +32 -0
- package/dist/media/image/processor/index.d.ts +12 -0
- package/dist/media/image/processor/optimizer.d.ts +13 -0
- package/dist/media/image/processor/responsive.d.ts +17 -0
- package/dist/media/image/srcset.d.ts +158 -0
- package/dist/media/index.d.ts +295 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/protected/component.d.ts +34 -0
- package/dist/media/protected/index.d.ts +34 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/shared/cache.d.ts +54 -0
- package/dist/media/shared/hash.d.ts +24 -0
- package/dist/media/shared/index.d.ts +2 -0
- package/dist/media/types.d.ts +1051 -0
- package/dist/media/upload/component.d.ts +23 -0
- package/dist/media/upload/index.d.ts +1 -0
- package/dist/media/video/directive.d.ts +9 -0
- package/dist/media/video/index.d.ts +47 -0
- package/dist/media/video/processor/cache.d.ts +33 -0
- package/dist/media/video/processor/index.d.ts +21 -0
- package/dist/media/video/processor/streaming.d.ts +19 -0
- package/dist/media/video/processor/thumbnail.d.ts +28 -0
- package/dist/media/video/processor/transcoder.d.ts +9 -0
- package/dist/middleware.d.ts +42 -3
- package/dist/native-build.d.ts +74 -0
- package/dist/parser/directive-parser.d.ts +79 -0
- package/dist/parser/expression-parser.d.ts +59 -0
- package/dist/parser/index.d.ts +35 -0
- package/dist/parser/tokenizer.d.ts +81 -0
- package/dist/partial-hydration.d.ts +88 -0
- package/dist/performance-utils.d.ts +146 -3
- package/dist/plugin-system.d.ts +128 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/precompiler.d.ts +108 -0
- package/dist/production-build.d.ts +199 -0
- package/dist/props.d.ts +199 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/directives.d.ts +29 -0
- package/dist/pwa/icons.d.ts +39 -0
- package/dist/pwa/index.d.ts +59 -0
- package/dist/pwa/inject.d.ts +22 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/precache.d.ts +29 -0
- package/dist/pwa/service-worker.d.ts +21 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox.d.ts +52 -0
- package/dist/pwa.d.ts +51 -0
- package/dist/pwa.js +8124 -0
- package/dist/reactive-bindings.d.ts +24 -0
- package/dist/reactive.d.ts +100 -0
- package/dist/reactivity.d.ts +253 -0
- package/dist/route-middleware.d.ts +232 -0
- package/dist/router.d.ts +31 -0
- package/dist/routes.d.ts +0 -7
- package/dist/runtime.d.ts +140 -0
- package/dist/safe-evaluator.d.ts +117 -3
- package/dist/scaffolding.d.ts +113 -0
- package/dist/seo.d.ts +120 -7
- package/dist/server-components.d.ts +134 -0
- package/dist/signals.d.ts +501 -0
- package/dist/slots.d.ts +63 -0
- package/dist/source-maps.d.ts +117 -0
- package/dist/ssg.d.ts +157 -0
- package/dist/ssg.js +6831 -0
- package/dist/ssr.d.ts +107 -0
- package/dist/state-management.d.ts +324 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/analytics.d.ts +92 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/bookmarks.d.ts +53 -0
- package/dist/story/bun-test.d.ts +44 -0
- package/dist/story/cli.d.ts +34 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/index.d.ts +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/scanner.d.ts +13 -0
- package/dist/story/collect/tree.d.ts +17 -0
- package/dist/story/commands/build.d.ts +14 -0
- package/dist/story/commands/dev.d.ts +16 -0
- package/dist/story/commands/index.d.ts +6 -0
- package/dist/story/commands/preview.d.ts +15 -0
- package/dist/story/compiled-output.d.ts +26 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/config-watcher.d.ts +26 -0
- package/dist/story/config.d.ts +26 -0
- package/dist/story/context.d.ts +21 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/crosswind.d.ts +29 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/hmr.d.ts +64 -0
- package/dist/story/hot-swap.d.ts +35 -0
- package/dist/story/index.d.ts +51 -0
- package/dist/story/interactions.d.ts +52 -0
- package/dist/story/keyboard-shortcuts.d.ts +34 -0
- package/dist/story/output.d.ts +85 -0
- package/dist/story/performance.d.ts +76 -0
- package/dist/story/presets.d.ts +62 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/renderer.d.ts +53 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search.d.ts +45 -0
- package/dist/story/server.d.ts +21 -0
- package/dist/story/setup.d.ts +47 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/testing.d.ts +58 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/types.d.ts +249 -0
- package/dist/story/ui/code-panel.d.ts +42 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/index.d.ts +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/streaming.d.ts +82 -2
- package/dist/suspense.d.ts +83 -0
- package/dist/teleport.d.ts +9 -0
- package/dist/testing.d.ts +289 -0
- package/dist/transitions.d.ts +87 -0
- package/dist/type-checker.d.ts +109 -0
- package/dist/types/component-types.d.ts +129 -0
- package/dist/types/config-types.d.ts +336 -0
- package/dist/types/context-types.d.ts +99 -0
- package/dist/types/csp-types.d.ts +79 -0
- package/dist/types/directive-types.d.ts +259 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/pwa-types.d.ts +218 -0
- package/dist/types.d.ts +1 -315
- package/dist/typescript-templates.d.ts +178 -0
- package/dist/utils.d.ts +52 -6
- package/dist/validator.d.ts +77 -0
- package/dist/variable-extractor.d.ts +39 -0
- package/dist/view-composers.d.ts +154 -9
- package/dist/virtual-scrolling.d.ts +103 -0
- package/dist/visual-editor.d.ts +209 -0
- package/dist/visual-testing.d.ts +109 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +16 -0
- package/dist/web-components/css-scoping.d.ts +54 -0
- package/dist/web-components/index.d.ts +20 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components.d.ts +222 -2
- package/dist/x-element.d.ts +35 -0
- package/package.json +41 -10
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observe element intersection with viewport or container
|
|
3
|
+
*/
|
|
4
|
+
export declare function useIntersectionObserver(target: Element | (() => Element | null) | null, callback?: IntersectionCallback, options?: IntersectionObserverOptions): IntersectionObserverRef;
|
|
5
|
+
/**
|
|
6
|
+
* Simple visibility check - returns true when element is in viewport
|
|
7
|
+
*/
|
|
8
|
+
export declare function useElementVisibility(target: Element | (() => Element | null) | null, options?: Omit<IntersectionObserverOptions, 'once'>): {
|
|
9
|
+
get: () => boolean
|
|
10
|
+
subscribe: (fn: (visible: boolean) => void) => () => void
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Lazy load handler - triggers callback once when element becomes visible
|
|
14
|
+
*/
|
|
15
|
+
export declare function useLazyLoad(target: Element | (() => Element | null) | null, onVisible: () => void, options?: Omit<IntersectionObserverOptions, 'once'>): { stop: () => void };
|
|
16
|
+
/**
|
|
17
|
+
* Infinite scroll handler - triggers callback when sentinel element is visible
|
|
18
|
+
*/
|
|
19
|
+
export declare function useInfiniteScroll(sentinel: Element | (() => Element | null) | null, loadMore: () => void | Promise<void>, options?: IntersectionObserverOptions & {
|
|
20
|
+
/** Debounce time in ms */
|
|
21
|
+
debounce?: number
|
|
22
|
+
}): {
|
|
23
|
+
stop: () => void
|
|
24
|
+
start: () => void
|
|
25
|
+
isLoading: () => boolean
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Track multiple elements' visibility
|
|
29
|
+
*/
|
|
30
|
+
export declare function useIntersectionObserverMultiple(targets: Element[] | (() => Element[]), callback: (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void, options?: Omit<IntersectionObserverOptions, 'once'>): {
|
|
31
|
+
stop: () => void
|
|
32
|
+
start: () => void
|
|
33
|
+
observe: (element: Element) => void
|
|
34
|
+
unobserve: (element: Element) => void
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* useIntersectionObserver - Reactive Intersection Observer API
|
|
38
|
+
*
|
|
39
|
+
* Track element visibility for lazy loading, infinite scroll, and animations.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Basic visibility tracking
|
|
44
|
+
* const { isVisible, stop } = useIntersectionObserver(element)
|
|
45
|
+
*
|
|
46
|
+
* // Lazy loading images
|
|
47
|
+
* useIntersectionObserver(imgElement, (entry) => {
|
|
48
|
+
* if (entry.isIntersecting) {
|
|
49
|
+
* imgElement.src = imgElement.dataset.src
|
|
50
|
+
* }
|
|
51
|
+
* }, { once: true })
|
|
52
|
+
*
|
|
53
|
+
* // Infinite scroll
|
|
54
|
+
* useIntersectionObserver(sentinelElement, () => {
|
|
55
|
+
* loadMoreItems()
|
|
56
|
+
* }, { rootMargin: '100px' })
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare interface IntersectionObserverOptions {
|
|
60
|
+
root?: Element | Document | null
|
|
61
|
+
rootMargin?: string
|
|
62
|
+
threshold?: number | number[]
|
|
63
|
+
once?: boolean
|
|
64
|
+
immediate?: boolean
|
|
65
|
+
}
|
|
66
|
+
export declare interface IntersectionState {
|
|
67
|
+
isIntersecting: boolean
|
|
68
|
+
intersectionRatio: number
|
|
69
|
+
boundingClientRect: DOMRectReadOnly | null
|
|
70
|
+
intersectionRect: DOMRectReadOnly | null
|
|
71
|
+
isVisible: boolean
|
|
72
|
+
entry: IntersectionObserverEntry | null
|
|
73
|
+
}
|
|
74
|
+
export declare interface IntersectionObserverRef {
|
|
75
|
+
get: () => IntersectionState
|
|
76
|
+
subscribe: (fn: (state: IntersectionState) => void) => () => void
|
|
77
|
+
isVisible: () => boolean
|
|
78
|
+
stop: () => void
|
|
79
|
+
start: () => void
|
|
80
|
+
}
|
|
81
|
+
declare type IntersectionCallback = (entry: IntersectionObserverEntry, observer: IntersectionObserver) => void
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track keyboard state
|
|
3
|
+
*/
|
|
4
|
+
export declare function useKeyboard(options?: KeyboardOptions): KeyboardRef;
|
|
5
|
+
/**
|
|
6
|
+
* Register a hotkey handler
|
|
7
|
+
*/
|
|
8
|
+
export declare function useHotkey(hotkey: string | string[], callback: HotkeyCallback, options?: HotkeyOptions): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a specific key is currently pressed
|
|
11
|
+
*/
|
|
12
|
+
export declare function useKeyPressed(key: string, options?: KeyboardOptions): {
|
|
13
|
+
get: () => boolean
|
|
14
|
+
subscribe: (fn: (pressed: boolean) => void) => () => void
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Detect key sequences (like Konami code)
|
|
18
|
+
*/
|
|
19
|
+
export declare function useKeySequence(sequence: string[], callback: () => void, options?: { timeout?: number; target?: Window | HTMLElement | Document | null }): () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Common keyboard shortcuts helper
|
|
22
|
+
*/
|
|
23
|
+
export declare const shortcuts: {
|
|
24
|
+
save: 'ctrl+s';
|
|
25
|
+
undo: 'ctrl+z';
|
|
26
|
+
redo: 'ctrl+shift+z';
|
|
27
|
+
copy: 'ctrl+c';
|
|
28
|
+
paste: 'ctrl+v';
|
|
29
|
+
cut: 'ctrl+x';
|
|
30
|
+
selectAll: 'ctrl+a';
|
|
31
|
+
find: 'ctrl+f';
|
|
32
|
+
replace: 'ctrl+h';
|
|
33
|
+
newTab: 'ctrl+t';
|
|
34
|
+
closeTab: 'ctrl+w';
|
|
35
|
+
refresh: 'ctrl+r';
|
|
36
|
+
escape: 'escape';
|
|
37
|
+
enter: 'enter';
|
|
38
|
+
// Mac alternatives
|
|
39
|
+
saveMac: 'meta+s';
|
|
40
|
+
undoMac: 'meta+z';
|
|
41
|
+
redoMac: 'meta+shift+z';
|
|
42
|
+
copyMac: 'meta+c';
|
|
43
|
+
pasteMac: 'meta+v';
|
|
44
|
+
cutMac: 'meta+x'
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* useKeyboard - Reactive keyboard input tracking
|
|
48
|
+
*
|
|
49
|
+
* Track keyboard state, handle hotkeys, and manage keyboard shortcuts.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* // Track all keyboard state
|
|
54
|
+
* const keyboard = useKeyboard()
|
|
55
|
+
* keyboard.subscribe(state => {
|
|
56
|
+
* if (state.ctrl && state.pressed.has('s')) {
|
|
57
|
+
* console.log('Ctrl+S pressed!')
|
|
58
|
+
* }
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
61
|
+
* // Simple hotkey
|
|
62
|
+
* useHotkey('ctrl+s', (e) => {
|
|
63
|
+
* e.preventDefault()
|
|
64
|
+
* save()
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* // Check if specific key is pressed
|
|
68
|
+
* const isSpacePressed = useKeyPressed('Space')
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare interface KeyboardState {
|
|
72
|
+
pressed: Set<string>
|
|
73
|
+
lastKey: string | null
|
|
74
|
+
lastEvent: KeyboardEvent | null
|
|
75
|
+
ctrl: boolean
|
|
76
|
+
alt: boolean
|
|
77
|
+
shift: boolean
|
|
78
|
+
meta: boolean
|
|
79
|
+
timestamp: number
|
|
80
|
+
}
|
|
81
|
+
export declare interface KeyboardOptions {
|
|
82
|
+
target?: Window | HTMLElement | Document | null
|
|
83
|
+
capture?: boolean
|
|
84
|
+
passive?: boolean
|
|
85
|
+
}
|
|
86
|
+
export declare interface KeyboardRef {
|
|
87
|
+
get: () => KeyboardState
|
|
88
|
+
subscribe: (fn: (state: KeyboardState) => void) => () => void
|
|
89
|
+
isPressed: (key: string) => boolean
|
|
90
|
+
stop: () => void
|
|
91
|
+
}
|
|
92
|
+
export declare interface HotkeyOptions {
|
|
93
|
+
target?: Window | HTMLElement | Document | null
|
|
94
|
+
preventDefault?: boolean
|
|
95
|
+
stopPropagation?: boolean
|
|
96
|
+
ignoreRepeat?: boolean
|
|
97
|
+
keyup?: boolean
|
|
98
|
+
ignoreInputs?: boolean
|
|
99
|
+
}
|
|
100
|
+
declare type HotkeyCallback = (event: KeyboardEvent) => void
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a reactive media query
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const isDark = useMediaQuery('(prefers-color-scheme: dark)')
|
|
7
|
+
* const isMobile = useMediaQuery('(max-width: 768px)')
|
|
8
|
+
*
|
|
9
|
+
* isDark.subscribe((matches) => {
|
|
10
|
+
* console.log('Dark mode:', matches)
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function useMediaQuery(query: string): MediaQueryRef;
|
|
15
|
+
/**
|
|
16
|
+
* Reactive dark mode preference
|
|
17
|
+
*/
|
|
18
|
+
export declare function usePreferredDark(): MediaQueryRef;
|
|
19
|
+
/**
|
|
20
|
+
* Reactive light mode preference
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePreferredLight(): MediaQueryRef;
|
|
23
|
+
/**
|
|
24
|
+
* Reactive reduced motion preference
|
|
25
|
+
*/
|
|
26
|
+
export declare function usePreferredReducedMotion(): MediaQueryRef;
|
|
27
|
+
/**
|
|
28
|
+
* Reactive contrast preference
|
|
29
|
+
*/
|
|
30
|
+
export declare function usePreferredContrast(): MediaQueryRef;
|
|
31
|
+
/**
|
|
32
|
+
* Reactive breakpoint helpers
|
|
33
|
+
*/
|
|
34
|
+
export declare function useBreakpoint(breakpoint: keyof typeof breakpoints): MediaQueryRef;
|
|
35
|
+
export declare function useIsMobile(): MediaQueryRef;
|
|
36
|
+
export declare function useIsTablet(): MediaQueryRef;
|
|
37
|
+
export declare function useIsDesktop(): MediaQueryRef;
|
|
38
|
+
/**
|
|
39
|
+
* Common breakpoints
|
|
40
|
+
*/
|
|
41
|
+
export declare const breakpoints: {
|
|
42
|
+
sm: '(min-width: 640px)';
|
|
43
|
+
md: '(min-width: 768px)';
|
|
44
|
+
lg: '(min-width: 1024px)';
|
|
45
|
+
xl: '(min-width: 1280px)';
|
|
46
|
+
'2xl': '(min-width: 1536px)'
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* useMediaQuery - Reactive media query composable
|
|
50
|
+
*
|
|
51
|
+
* Provides reactive tracking of CSS media queries.
|
|
52
|
+
*/
|
|
53
|
+
export declare interface MediaQueryRef {
|
|
54
|
+
matches: boolean
|
|
55
|
+
subscribe: (callback: (matches: boolean) => void) => () => void
|
|
56
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track mouse position globally or within a target
|
|
3
|
+
*/
|
|
4
|
+
export declare function useMouse(options?: MouseOptions): MouseRef;
|
|
5
|
+
/**
|
|
6
|
+
* Track mouse position relative to an element
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMouseInElement(element: HTMLElement | (() => HTMLElement | null) | null, options?: Omit<MouseOptions, 'target'>): ElementMouseRef;
|
|
9
|
+
/**
|
|
10
|
+
* Track pointer (unified mouse + touch + pen)
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePointer(options?: MouseOptions): MouseRef;
|
|
13
|
+
/**
|
|
14
|
+
* useMouse - Reactive mouse/pointer position tracking
|
|
15
|
+
*
|
|
16
|
+
* Track mouse position, movement, and button states.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const mouse = useMouse()
|
|
21
|
+
* mouse.subscribe(state => {
|
|
22
|
+
* console.log(`Mouse at ${state.x}, ${state.y}`)
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Track within a specific element
|
|
26
|
+
* const elementMouse = useMouseInElement(myElement)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare interface MouseState {
|
|
30
|
+
x: number
|
|
31
|
+
y: number
|
|
32
|
+
pageX: number
|
|
33
|
+
pageY: number
|
|
34
|
+
clientX: number
|
|
35
|
+
clientY: number
|
|
36
|
+
movementX: number
|
|
37
|
+
movementY: number
|
|
38
|
+
buttons: number
|
|
39
|
+
isPressed: boolean
|
|
40
|
+
isInside: boolean
|
|
41
|
+
}
|
|
42
|
+
export declare interface MouseOptions {
|
|
43
|
+
target?: Window | HTMLElement | null
|
|
44
|
+
touch?: boolean
|
|
45
|
+
resetOnLeave?: boolean
|
|
46
|
+
type?: 'page' | 'client' | 'screen' | 'movement'
|
|
47
|
+
}
|
|
48
|
+
export declare interface MouseRef {
|
|
49
|
+
get: () => MouseState
|
|
50
|
+
subscribe: (fn: (state: MouseState) => void) => () => void
|
|
51
|
+
stop: () => void
|
|
52
|
+
}
|
|
53
|
+
export declare interface ElementMouseState extends MouseState {
|
|
54
|
+
elementX: number
|
|
55
|
+
elementY: number
|
|
56
|
+
elementWidth: number
|
|
57
|
+
elementHeight: number
|
|
58
|
+
isOutside: boolean
|
|
59
|
+
}
|
|
60
|
+
export declare interface ElementMouseRef {
|
|
61
|
+
get: () => ElementMouseState
|
|
62
|
+
subscribe: (fn: (state: ElementMouseState) => void) => () => void
|
|
63
|
+
stop: () => void
|
|
64
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if MutationObserver is supported
|
|
3
|
+
*/
|
|
4
|
+
export declare function isMutationObserverSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Create a reactive mutation observer
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const observer = useMutationObserver({
|
|
11
|
+
* attributes: true,
|
|
12
|
+
* childList: true,
|
|
13
|
+
* onMutate: (mutations) => {
|
|
14
|
+
* mutations.forEach(m => console.log('Mutation:', m.type))
|
|
15
|
+
* }
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // Start observing an element
|
|
19
|
+
* observer.observe(document.getElementById('my-element'))
|
|
20
|
+
*
|
|
21
|
+
* // Subscribe to state changes
|
|
22
|
+
* observer.subscribe((state) => {
|
|
23
|
+
* console.log('Latest mutations:', state.mutations)
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Stop observing
|
|
27
|
+
* observer.disconnect()
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function useMutationObserver(options?: MutationObserverOptions): MutationObserverRef;
|
|
31
|
+
/**
|
|
32
|
+
* Watch for attribute changes on an element
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* useAttributeObserver(
|
|
37
|
+
* document.getElementById('my-element'),
|
|
38
|
+
* ['class', 'data-state'],
|
|
39
|
+
* (attr, oldValue, newValue) => {
|
|
40
|
+
* console.log(`${attr} changed from ${oldValue} to ${newValue}`)
|
|
41
|
+
* }
|
|
42
|
+
* )
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useAttributeObserver(target: Element | null, attributeNames: string[], callback: (attributeName: string, oldValue: string | null, newValue: string | null) => void): () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Watch for child node changes
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* useChildListObserver(
|
|
52
|
+
* document.getElementById('container'),
|
|
53
|
+
* (added, removed) => {
|
|
54
|
+
* console.log('Added:', added.length, 'Removed:', removed.length)
|
|
55
|
+
* }
|
|
56
|
+
* )
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function useChildListObserver(target: Element | null, callback: (added: Node[], removed: Node[]) => void, options?: { subtree?: boolean }): () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Watch for text content changes
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* useTextObserver(
|
|
66
|
+
* document.getElementById('editable'),
|
|
67
|
+
* (oldText, newText) => {
|
|
68
|
+
* console.log(`Text changed from "${oldText}" to "${newText}"`)
|
|
69
|
+
* }
|
|
70
|
+
* )
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function useTextObserver(target: Element | null, callback: (oldText: string | null, newText: string) => void): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Mutation Observer Composables
|
|
76
|
+
*
|
|
77
|
+
* Reactive utilities for observing DOM mutations.
|
|
78
|
+
*/
|
|
79
|
+
export declare interface MutationObserverState {
|
|
80
|
+
isSupported: boolean
|
|
81
|
+
isObserving: boolean
|
|
82
|
+
mutations: MutationRecord[]
|
|
83
|
+
}
|
|
84
|
+
export declare interface MutationObserverOptions {
|
|
85
|
+
attributes?: boolean
|
|
86
|
+
attributeFilter?: string[]
|
|
87
|
+
attributeOldValue?: boolean
|
|
88
|
+
characterData?: boolean
|
|
89
|
+
characterDataOldValue?: boolean
|
|
90
|
+
childList?: boolean
|
|
91
|
+
subtree?: boolean
|
|
92
|
+
onMutate?: (mutations: MutationRecord[]) => void
|
|
93
|
+
}
|
|
94
|
+
export declare interface MutationObserverRef {
|
|
95
|
+
get: () => MutationObserverState
|
|
96
|
+
subscribe: (fn: (state: MutationObserverState) => void) => () => void
|
|
97
|
+
observe: (target: Element | null) => void
|
|
98
|
+
disconnect: () => void
|
|
99
|
+
takeRecords: () => MutationRecord[]
|
|
100
|
+
isSupported: () => boolean
|
|
101
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a reactive network status tracker
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const network = useNetwork()
|
|
7
|
+
*
|
|
8
|
+
* network.subscribe((state) => {
|
|
9
|
+
* if (state.isOffline) {
|
|
10
|
+
* showOfflineMessage()
|
|
11
|
+
* }
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* if (network.effectiveType === '2g') {
|
|
15
|
+
* loadLowQualityImages()
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function useNetwork(): NetworkRef;
|
|
20
|
+
/**
|
|
21
|
+
* Simple online/offline tracker
|
|
22
|
+
*/
|
|
23
|
+
export declare function useOnline(): { isOnline: boolean; subscribe: (cb: (online: boolean) => void) => () => void };
|
|
24
|
+
/**
|
|
25
|
+
* useNetwork - Reactive network status composables
|
|
26
|
+
*
|
|
27
|
+
* Provides reactive tracking of network connectivity and information.
|
|
28
|
+
*/
|
|
29
|
+
export declare interface NetworkState {
|
|
30
|
+
isOnline: boolean
|
|
31
|
+
isOffline: boolean
|
|
32
|
+
type: string | null
|
|
33
|
+
effectiveType: '2g' | '3g' | '4g' | 'slow-2g' | null
|
|
34
|
+
downlink: number | null
|
|
35
|
+
rtt: number | null
|
|
36
|
+
saveData: boolean
|
|
37
|
+
}
|
|
38
|
+
export declare interface NetworkRef extends NetworkState {
|
|
39
|
+
subscribe: (callback: (state: NetworkState) => void) => () => void
|
|
40
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive notification controller
|
|
3
|
+
*/
|
|
4
|
+
export declare function useNotification(): NotificationRef;
|
|
5
|
+
/**
|
|
6
|
+
* Simple notification helper
|
|
7
|
+
*/
|
|
8
|
+
export declare function notify(title: string, options?: NotificationOptions): Promise<Notification | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if notifications are supported and permitted
|
|
11
|
+
*/
|
|
12
|
+
export declare function canNotify(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Request notification permission
|
|
15
|
+
*/
|
|
16
|
+
export declare function requestNotificationPermission(): Promise<NotificationPermission>;
|
|
17
|
+
/**
|
|
18
|
+
* Show notification with common patterns
|
|
19
|
+
*/
|
|
20
|
+
export declare const notifications: {
|
|
21
|
+
/** Success notification */
|
|
22
|
+
success: (message: string, options?: NotificationOptions) => unknown;
|
|
23
|
+
/** Error notification */
|
|
24
|
+
error: (message: string, options?: NotificationOptions) => unknown;
|
|
25
|
+
/** Warning notification */
|
|
26
|
+
warning: (message: string, options?: NotificationOptions) => unknown;
|
|
27
|
+
/** Info notification */
|
|
28
|
+
info: (message: string, options?: NotificationOptions) => unknown
|
|
29
|
+
};
|
|
30
|
+
export declare interface NotificationState {
|
|
31
|
+
permission: NotificationPermission
|
|
32
|
+
isSupported: boolean
|
|
33
|
+
}
|
|
34
|
+
export declare interface NotificationOptions {
|
|
35
|
+
body?: string
|
|
36
|
+
icon?: string
|
|
37
|
+
badge?: string
|
|
38
|
+
image?: string
|
|
39
|
+
tag?: string
|
|
40
|
+
requireInteraction?: boolean
|
|
41
|
+
renotify?: boolean
|
|
42
|
+
silent?: boolean
|
|
43
|
+
vibrate?: number | number[]
|
|
44
|
+
data?: unknown
|
|
45
|
+
autoClose?: number
|
|
46
|
+
dir?: 'auto' | 'ltr' | 'rtl'
|
|
47
|
+
lang?: string
|
|
48
|
+
actions?: NotificationAction[]
|
|
49
|
+
timestamp?: number
|
|
50
|
+
}
|
|
51
|
+
export declare interface NotificationAction {
|
|
52
|
+
action: string
|
|
53
|
+
title: string
|
|
54
|
+
icon?: string
|
|
55
|
+
}
|
|
56
|
+
export declare interface NotificationRef {
|
|
57
|
+
get: () => NotificationState
|
|
58
|
+
subscribe: (fn: (state: NotificationState) => void) => () => void
|
|
59
|
+
isSupported: () => boolean
|
|
60
|
+
permission: () => NotificationPermission
|
|
61
|
+
requestPermission: () => Promise<NotificationPermission>
|
|
62
|
+
show: (title: string, options?: NotificationOptions) => Notification | null
|
|
63
|
+
close: (tag: string) => void
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* useNotification - Web Notifications API wrapper
|
|
67
|
+
*
|
|
68
|
+
* Display native browser notifications with reactive permission state.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const { permission, isSupported, show, requestPermission } = useNotification()
|
|
73
|
+
*
|
|
74
|
+
* // Request permission
|
|
75
|
+
* await requestPermission()
|
|
76
|
+
*
|
|
77
|
+
* // Show notification
|
|
78
|
+
* const notification = show('Hello!', {
|
|
79
|
+
* body: 'This is a notification',
|
|
80
|
+
* icon: '/icon.png',
|
|
81
|
+
* })
|
|
82
|
+
*
|
|
83
|
+
* // Handle click
|
|
84
|
+
* notification?.addEventListener('click', () => {
|
|
85
|
+
* window.focus()
|
|
86
|
+
* })
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export type NotificationPermission = 'default' | 'granted' | 'denied'
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query a single permission
|
|
3
|
+
*/
|
|
4
|
+
export declare function usePermission(name: PermissionName): PermissionRef;
|
|
5
|
+
/**
|
|
6
|
+
* Query multiple permissions at once
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePermissions(names: PermissionName[]): MultiPermissionRef;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a permission is granted
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPermissionGranted(name: PermissionName): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Check if camera permission is granted
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasCameraPermission(): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if microphone permission is granted
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasMicrophonePermission(): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if geolocation permission is granted
|
|
23
|
+
*/
|
|
24
|
+
export declare function hasGeolocationPermission(): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if notifications permission is granted
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasNotificationPermission(): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Request camera and microphone permissions by accessing media
|
|
31
|
+
*/
|
|
32
|
+
export declare function requestMediaPermissions(options?: { video?: boolean; audio?: boolean }): Promise<{ granted: boolean; stream?: MediaStream; error?: Error }>;
|
|
33
|
+
/**
|
|
34
|
+
* Common permission groups
|
|
35
|
+
*/
|
|
36
|
+
export declare const permissionGroups: {
|
|
37
|
+
media: readonly ['camera', unknown];
|
|
38
|
+
location: readonly [unknown];
|
|
39
|
+
notifications: readonly ['notifications', unknown];
|
|
40
|
+
sensors: readonly ['accelerometer', 'gyroscope', unknown];
|
|
41
|
+
clipboard: readonly ['clipboard-read', unknown]
|
|
42
|
+
};
|
|
43
|
+
export declare interface PermissionStatus {
|
|
44
|
+
state: PermissionState
|
|
45
|
+
isGranted: boolean
|
|
46
|
+
isDenied: boolean
|
|
47
|
+
isPrompt: boolean
|
|
48
|
+
}
|
|
49
|
+
export declare interface PermissionRef {
|
|
50
|
+
get: () => PermissionStatus
|
|
51
|
+
subscribe: (fn: (status: PermissionStatus) => void) => () => void
|
|
52
|
+
query: () => Promise<PermissionStatus>
|
|
53
|
+
isSupported: () => boolean
|
|
54
|
+
}
|
|
55
|
+
export declare interface MultiPermissionRef {
|
|
56
|
+
get: () => Record<string, PermissionStatus>
|
|
57
|
+
subscribe: (fn: (states: Record<string, PermissionStatus>) => void) => () => void
|
|
58
|
+
queryAll: () => Promise<Record<string, PermissionStatus>>
|
|
59
|
+
isSupported: () => boolean
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* usePermissions - Permissions API wrapper
|
|
63
|
+
*
|
|
64
|
+
* Query and monitor browser permission states for various APIs.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // Check camera permission
|
|
69
|
+
* const camera = usePermission('camera')
|
|
70
|
+
* camera.subscribe(state => {
|
|
71
|
+
* console.log('Camera permission:', state.state) // 'granted', 'denied', 'prompt'
|
|
72
|
+
* })
|
|
73
|
+
*
|
|
74
|
+
* // Check multiple permissions
|
|
75
|
+
* const permissions = usePermissions(['camera', 'microphone', 'geolocation'])
|
|
76
|
+
* permissions.subscribe(states => {
|
|
77
|
+
* console.log('Camera:', states.camera)
|
|
78
|
+
* console.log('Microphone:', states.microphone)
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export type PermissionName = | 'accelerometer'
|
|
83
|
+
| 'accessibility-events'
|
|
84
|
+
| 'ambient-light-sensor'
|
|
85
|
+
| 'background-fetch'
|
|
86
|
+
| 'background-sync'
|
|
87
|
+
| 'bluetooth'
|
|
88
|
+
| 'camera'
|
|
89
|
+
| 'clipboard-read'
|
|
90
|
+
| 'clipboard-write'
|
|
91
|
+
| 'device-info'
|
|
92
|
+
| 'display-capture'
|
|
93
|
+
| 'geolocation'
|
|
94
|
+
| 'gyroscope'
|
|
95
|
+
| 'magnetometer'
|
|
96
|
+
| 'microphone'
|
|
97
|
+
| 'midi'
|
|
98
|
+
| 'nfc'
|
|
99
|
+
| 'notifications'
|
|
100
|
+
| 'payment-handler'
|
|
101
|
+
| 'periodic-background-sync'
|
|
102
|
+
| 'persistent-storage'
|
|
103
|
+
| 'push'
|
|
104
|
+
| 'screen-wake-lock'
|
|
105
|
+
| 'speaker-selection'
|
|
106
|
+
| 'storage-access'
|
|
107
|
+
| 'window-management'
|
|
108
|
+
| 'xr-spatial-tracking'
|
|
109
|
+
export type PermissionState = 'granted' | 'denied' | 'prompt'
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observe element size changes
|
|
3
|
+
*/
|
|
4
|
+
export declare function useResizeObserver(target: Element | (() => Element | null) | null, callback?: (entries: ResizeObserverEntry[]) => void, options?: ResizeObserverOptions): ResizeObserverRef;
|
|
5
|
+
/**
|
|
6
|
+
* Observe multiple elements
|
|
7
|
+
*/
|
|
8
|
+
export declare function useResizeObserverMultiple(targets: Element[] | (() => Element[]), callback?: (entries: ResizeObserverEntry[]) => void, options?: ResizeObserverOptions): ResizeObserverRef & { states: () => Map<Element, ResizeObserverState> };
|
|
9
|
+
/**
|
|
10
|
+
* Get element dimensions reactively
|
|
11
|
+
*/
|
|
12
|
+
export declare function useElementSize(target: Element | (() => Element | null) | null): {
|
|
13
|
+
get: () => { width: number; height: number }
|
|
14
|
+
subscribe: (fn: (size: { width: number; height: number }) => void) => () => void
|
|
15
|
+
isSupported: () => boolean
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Check if ResizeObserver is supported (standalone function)
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasResizeObserver(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* useResizeObserver - Resize Observer API wrapper
|
|
23
|
+
*
|
|
24
|
+
* Monitor element size changes reactively.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const observer = useResizeObserver(element)
|
|
29
|
+
* observer.subscribe(entries => {
|
|
30
|
+
* console.log('Size changed:', entries[0].contentRect)
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* // With callback
|
|
34
|
+
* useResizeObserver(element, (entries) => {
|
|
35
|
+
* console.log('Width:', entries[0].contentRect.width)
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare interface ResizeObserverSize {
|
|
40
|
+
width: number
|
|
41
|
+
height: number
|
|
42
|
+
inlineSize: number
|
|
43
|
+
blockSize: number
|
|
44
|
+
}
|
|
45
|
+
export declare interface ResizeObserverState {
|
|
46
|
+
contentRect: DOMRectReadOnly | null
|
|
47
|
+
contentBoxSize: ResizeObserverSize | null
|
|
48
|
+
borderBoxSize: ResizeObserverSize | null
|
|
49
|
+
devicePixelContentBoxSize: ResizeObserverSize | null
|
|
50
|
+
}
|
|
51
|
+
export declare interface ResizeObserverOptions {
|
|
52
|
+
box?: 'content-box' | 'border-box' | 'device-pixel-content-box'
|
|
53
|
+
}
|
|
54
|
+
export declare interface ResizeObserverRef {
|
|
55
|
+
get: () => ResizeObserverState
|
|
56
|
+
subscribe: (fn: (entries: ResizeObserverEntry[]) => void) => () => void
|
|
57
|
+
observe: () => void
|
|
58
|
+
disconnect: () => void
|
|
59
|
+
isSupported: () => boolean
|
|
60
|
+
}
|