@vizejs/composable 0.426.3 → 0.428.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/dist/abort-signal.d.mts +1 -1
- package/dist/active-element.d.mts +37 -0
- package/dist/active-element.mjs +56 -0
- package/dist/animate.d.mts +114 -0
- package/dist/animate.mjs +157 -0
- package/dist/battery.d.mts +61 -0
- package/dist/battery.mjs +90 -0
- package/dist/breakpoints.d.mts +82 -0
- package/dist/breakpoints.mjs +91 -0
- package/dist/catalog-BeTXFKxF.d.mts +4188 -0
- package/dist/catalog-r4Z5nptX.mjs +5144 -0
- package/dist/catalog.d.mts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/color-mode.d.mts +131 -0
- package/dist/color-mode.mjs +133 -0
- package/dist/computed-async.d.mts +63 -0
- package/dist/computed-async.mjs +43 -0
- package/dist/computed-with-control.d.mts +44 -0
- package/dist/computed-with-control.mjs +54 -0
- package/dist/create-event-hook.d.mts +77 -0
- package/dist/create-event-hook.mjs +66 -0
- package/dist/create-global-state.d.mts +24 -0
- package/dist/create-global-state.mjs +34 -0
- package/dist/create-injection-state.d.mts +51 -0
- package/dist/create-injection-state.mjs +19 -0
- package/dist/create-shared-composable.d.mts +38 -0
- package/dist/create-shared-composable.mjs +54 -0
- package/dist/device-motion.d.mts +71 -0
- package/dist/device-motion.mjs +75 -0
- package/dist/device-orientation.d.mts +82 -0
- package/dist/device-orientation.mjs +86 -0
- package/dist/device-pixel-ratio.d.mts +45 -0
- package/dist/device-pixel-ratio.mjs +50 -0
- package/dist/document-visibility.mjs +6 -2
- package/dist/draggable.d.mts +121 -0
- package/dist/draggable.mjs +153 -0
- package/dist/element-bounding.d.mts +87 -0
- package/dist/element-bounding.mjs +95 -0
- package/dist/element-by-point.d.mts +70 -0
- package/dist/element-by-point.mjs +69 -0
- package/dist/element-hover.d.mts +42 -0
- package/dist/element-hover.mjs +70 -0
- package/dist/element-ref.d.mts +34 -0
- package/dist/element-ref.mjs +23 -0
- package/dist/element-target-Crpxl4D9.d.mts +60 -0
- package/dist/element-target.d.mts +2 -0
- package/dist/element-target.mjs +58 -0
- package/dist/event-listener.mjs +7 -3
- package/dist/focus.d.mts +69 -0
- package/dist/focus.mjs +124 -0
- package/dist/fps.d.mts +59 -0
- package/dist/fps.mjs +64 -0
- package/dist/geolocation.d.mts +98 -0
- package/dist/geolocation.mjs +86 -0
- package/dist/i18n.d.mts +237 -0
- package/dist/i18n.mjs +215 -0
- package/dist/icu-message.d.mts +235 -0
- package/dist/icu-message.mjs +343 -0
- package/dist/idle.d.mts +79 -0
- package/dist/idle.mjs +90 -0
- package/dist/index.d.mts +172 -6
- package/dist/index.mjs +173 -7
- package/dist/infinite-scroll.d.mts +56 -0
- package/dist/infinite-scroll.mjs +72 -0
- package/dist/intersection-observer.d.mts +122 -0
- package/dist/intersection-observer.mjs +117 -0
- package/dist/magic-keys.d.mts +121 -0
- package/dist/magic-keys.mjs +163 -0
- package/dist/math.d.mts +96 -0
- package/dist/math.mjs +84 -0
- package/dist/media-query.d.mts +3 -1
- package/dist/media-query.mjs +5 -3
- package/dist/mouse-in-element.d.mts +49 -0
- package/dist/mouse-in-element.mjs +66 -0
- package/dist/mouse.d.mts +77 -0
- package/dist/mouse.mjs +100 -0
- package/dist/mutation-observer.d.mts +98 -0
- package/dist/mutation-observer.mjs +69 -0
- package/dist/network.d.mts +96 -0
- package/dist/network.mjs +117 -0
- package/dist/on-click-outside.d.mts +69 -0
- package/dist/on-click-outside.mjs +115 -0
- package/dist/on-key-stroke.d.mts +71 -0
- package/dist/on-key-stroke.mjs +79 -0
- package/dist/on-long-press.d.mts +82 -0
- package/dist/on-long-press.mjs +105 -0
- package/dist/on-start-typing.d.mts +44 -0
- package/dist/on-start-typing.mjs +61 -0
- package/dist/page-leave.d.mts +26 -0
- package/dist/page-leave.mjs +40 -0
- package/dist/parent-element.d.mts +16 -0
- package/dist/parent-element.mjs +27 -0
- package/dist/pinch.d.mts +73 -0
- package/dist/pinch.mjs +138 -0
- package/dist/pointer-lock.d.mts +79 -0
- package/dist/pointer-lock.mjs +126 -0
- package/dist/pointer.d.mts +78 -0
- package/dist/pointer.mjs +95 -0
- package/dist/preferences.d.mts +55 -0
- package/dist/preferences.mjs +63 -0
- package/dist/preferred-languages.d.mts +43 -0
- package/dist/preferred-languages.mjs +44 -0
- package/dist/reactify.d.mts +28 -0
- package/dist/reactify.mjs +7 -0
- package/dist/ref-auto-reset.d.mts +47 -0
- package/dist/ref-auto-reset.mjs +70 -0
- package/dist/ref-debounced.d.mts +29 -0
- package/dist/ref-debounced.mjs +29 -0
- package/dist/ref-default.d.mts +27 -0
- package/dist/ref-default.mjs +33 -0
- package/dist/resize-observer.d.mts +96 -0
- package/dist/resize-observer.mjs +111 -0
- package/dist/resolver.d.mts +124 -0
- package/dist/resolver.mjs +138 -0
- package/dist/retry-async.d.mts +2 -2
- package/dist/retry-delay-DYsdq4SE.d.mts +73 -0
- package/dist/retry-delay.d.mts +1 -72
- package/dist/screen-orientation.d.mts +77 -0
- package/dist/screen-orientation.mjs +74 -0
- package/dist/scroll-lock.d.mts +37 -0
- package/dist/scroll-lock.mjs +50 -0
- package/dist/scroll.d.mts +158 -0
- package/dist/scroll.mjs +172 -0
- package/dist/standard-schema-DmNgFVK5.d.mts +107 -0
- package/dist/standard-schema.d.mts +2 -0
- package/dist/standard-schema.mjs +60 -0
- package/dist/swipe.d.mts +125 -0
- package/dist/swipe.mjs +225 -0
- package/dist/sync-ref.d.mts +80 -0
- package/dist/sync-ref.mjs +43 -0
- package/dist/text-selection.d.mts +46 -0
- package/dist/text-selection.mjs +62 -0
- package/dist/textarea-autosize.d.mts +58 -0
- package/dist/textarea-autosize.mjs +54 -0
- package/dist/timeout-scheduler-CI8RVLZs.d.mts +18 -0
- package/dist/timeout-scheduler.d.mts +1 -17
- package/dist/to-reactive.d.mts +26 -0
- package/dist/to-reactive.mjs +46 -0
- package/dist/transition.d.mts +125 -0
- package/dist/transition.mjs +266 -0
- package/dist/until.d.mts +177 -0
- package/dist/until.mjs +111 -0
- package/dist/use-array.d.mts +112 -0
- package/dist/use-array.mjs +90 -0
- package/dist/use-async-queue.d.mts +109 -0
- package/dist/use-async-queue.mjs +96 -0
- package/dist/use-async-state.d.mts +86 -0
- package/dist/use-async-state.mjs +41 -0
- package/dist/use-barcode-detector.d.mts +159 -0
- package/dist/use-barcode-detector.mjs +143 -0
- package/dist/use-bluetooth.d.mts +164 -0
- package/dist/use-bluetooth.mjs +183 -0
- package/dist/use-broadcast-channel.d.mts +115 -0
- package/dist/use-broadcast-channel.mjs +121 -0
- package/dist/use-builtin-ai.d.mts +342 -0
- package/dist/use-builtin-ai.mjs +261 -0
- package/dist/use-clipboard.d.mts +169 -0
- package/dist/use-clipboard.mjs +226 -0
- package/dist/use-compression-stream.d.mts +173 -0
- package/dist/use-compression-stream.mjs +166 -0
- package/dist/use-confirm-dialog.d.mts +70 -0
- package/dist/use-confirm-dialog.mjs +57 -0
- package/dist/use-contact-picker.d.mts +117 -0
- package/dist/use-contact-picker.mjs +103 -0
- package/dist/use-cookie.d.mts +196 -0
- package/dist/use-cookie.mjs +259 -0
- package/dist/use-countdown.d.mts +85 -0
- package/dist/use-countdown.mjs +74 -0
- package/dist/use-css-var.d.mts +96 -0
- package/dist/use-css-var.mjs +104 -0
- package/dist/use-cycle-list.d.mts +76 -0
- package/dist/use-cycle-list.mjs +39 -0
- package/dist/use-date-format.d.mts +103 -0
- package/dist/use-date-format.mjs +147 -0
- package/dist/use-date-time-format.d.mts +75 -0
- package/dist/use-date-time-format.mjs +53 -0
- package/dist/use-debounced.d.mts +1 -1
- package/dist/use-display-media.d.mts +62 -0
- package/dist/use-display-media.mjs +46 -0
- package/dist/use-display-names.d.mts +75 -0
- package/dist/use-display-names.mjs +52 -0
- package/dist/use-document-title.d.mts +88 -0
- package/dist/use-document-title.mjs +100 -0
- package/dist/use-drop-zone.d.mts +128 -0
- package/dist/use-drop-zone.mjs +154 -0
- package/dist/use-event-source.d.mts +184 -0
- package/dist/use-event-source.mjs +226 -0
- package/dist/use-eye-dropper.d.mts +79 -0
- package/dist/use-eye-dropper.mjs +68 -0
- package/dist/use-favicon.d.mts +78 -0
- package/dist/use-favicon.mjs +68 -0
- package/dist/use-fetch.d.mts +230 -0
- package/dist/use-fetch.mjs +263 -0
- package/dist/use-field.d.mts +107 -0
- package/dist/use-field.mjs +117 -0
- package/dist/use-file-dialog.d.mts +139 -0
- package/dist/use-file-dialog.mjs +101 -0
- package/dist/use-file-system-access.d.mts +184 -0
- package/dist/use-file-system-access.mjs +151 -0
- package/dist/use-form-field-props.d.mts +235 -0
- package/dist/use-form-field-props.mjs +164 -0
- package/dist/use-form.d.mts +324 -0
- package/dist/use-form.mjs +482 -0
- package/dist/use-fullscreen.d.mts +104 -0
- package/dist/use-fullscreen.mjs +95 -0
- package/dist/use-gamepad.d.mts +242 -0
- package/dist/use-gamepad.mjs +218 -0
- package/dist/use-hid.d.mts +160 -0
- package/dist/use-hid.mjs +156 -0
- package/dist/use-id-generator.d.mts +44 -0
- package/dist/use-id-generator.mjs +38 -0
- package/dist/use-image.d.mts +125 -0
- package/dist/use-image.mjs +109 -0
- package/dist/use-indexed-db.d.mts +207 -0
- package/dist/use-indexed-db.mjs +251 -0
- package/dist/use-interval-BA55gTHT.d.mts +140 -0
- package/dist/use-interval.d.mts +2 -0
- package/dist/use-interval.mjs +100 -0
- package/dist/use-list-format.d.mts +60 -0
- package/dist/use-list-format.mjs +40 -0
- package/dist/use-machine.d.mts +90 -0
- package/dist/use-machine.mjs +78 -0
- package/dist/use-map.d.mts +90 -0
- package/dist/use-map.mjs +70 -0
- package/dist/use-media-controls.d.mts +198 -0
- package/dist/use-media-controls.mjs +264 -0
- package/dist/use-memoize.d.mts +73 -0
- package/dist/use-memoize.mjs +28 -0
- package/dist/use-mounted.d.mts +24 -0
- package/dist/use-mounted.mjs +29 -0
- package/dist/use-navigation-api.d.mts +360 -0
- package/dist/use-navigation-api.mjs +231 -0
- package/dist/use-notification.d.mts +139 -0
- package/dist/use-notification.mjs +131 -0
- package/dist/use-now.d.mts +137 -0
- package/dist/use-now.mjs +44 -0
- package/dist/use-number-format.d.mts +73 -0
- package/dist/use-number-format.mjs +58 -0
- package/dist/use-object-url.d.mts +47 -0
- package/dist/use-object-url.mjs +54 -0
- package/dist/use-offset-pagination.d.mts +91 -0
- package/dist/use-offset-pagination.mjs +80 -0
- package/dist/use-payment-request.d.mts +239 -0
- package/dist/use-payment-request.mjs +206 -0
- package/dist/use-performance-observer.d.mts +285 -0
- package/dist/use-performance-observer.mjs +132 -0
- package/dist/use-permission.d.mts +99 -0
- package/dist/use-permission.mjs +92 -0
- package/dist/use-plural-rules.d.mts +79 -0
- package/dist/use-plural-rules.mjs +59 -0
- package/dist/use-push-subscription.d.mts +154 -0
- package/dist/use-push-subscription.mjs +146 -0
- package/dist/use-queue.d.mts +89 -0
- package/dist/use-queue.mjs +116 -0
- package/dist/use-raf-fn.d.mts +87 -0
- package/dist/use-raf-fn.mjs +99 -0
- package/dist/use-relative-time-format.d.mts +111 -0
- package/dist/use-relative-time-format.mjs +119 -0
- package/dist/use-request-idle-callback.d.mts +122 -0
- package/dist/use-request-idle-callback.mjs +147 -0
- package/dist/use-route-query.d.mts +149 -0
- package/dist/use-route-query.mjs +86 -0
- package/dist/use-scheduler-post-task.d.mts +156 -0
- package/dist/use-scheduler-post-task.mjs +182 -0
- package/dist/use-screen-details.d.mts +205 -0
- package/dist/use-screen-details.mjs +188 -0
- package/dist/use-script-tag.d.mts +162 -0
- package/dist/use-script-tag.mjs +171 -0
- package/dist/use-segmenter.d.mts +78 -0
- package/dist/use-segmenter.mjs +66 -0
- package/dist/use-selection.d.mts +125 -0
- package/dist/use-selection.mjs +77 -0
- package/dist/use-serial.d.mts +165 -0
- package/dist/use-serial.mjs +205 -0
- package/dist/use-service-worker.d.mts +177 -0
- package/dist/use-service-worker.mjs +178 -0
- package/dist/use-set.d.mts +96 -0
- package/dist/use-set.mjs +74 -0
- package/dist/use-share.d.mts +92 -0
- package/dist/use-share.mjs +99 -0
- package/dist/use-sorted-locale.d.mts +62 -0
- package/dist/use-sorted-locale.mjs +52 -0
- package/dist/use-sorted.d.mts +29 -0
- package/dist/use-sorted.mjs +14 -0
- package/dist/use-speech-recognition.d.mts +150 -0
- package/dist/use-speech-recognition.mjs +168 -0
- package/dist/use-speech-synthesis.d.mts +148 -0
- package/dist/use-speech-synthesis.mjs +152 -0
- package/dist/use-stack.d.mts +83 -0
- package/dist/use-stack.mjs +93 -0
- package/dist/use-stepper.d.mts +79 -0
- package/dist/use-stepper.mjs +52 -0
- package/dist/use-storage-estimate.d.mts +151 -0
- package/dist/use-storage-estimate.mjs +170 -0
- package/dist/use-storage.d.mts +214 -0
- package/dist/use-storage.mjs +415 -0
- package/dist/use-style-tag.d.mts +102 -0
- package/dist/use-style-tag.mjs +91 -0
- package/dist/use-supported.d.mts +23 -0
- package/dist/use-supported.mjs +26 -0
- package/dist/use-throttled.d.mts +1 -1
- package/dist/use-time-ago.d.mts +163 -0
- package/dist/use-time-ago.mjs +95 -0
- package/dist/use-timeout.d.mts +122 -0
- package/dist/use-timeout.mjs +65 -0
- package/dist/use-url-hash.d.mts +88 -0
- package/dist/use-url-hash.mjs +145 -0
- package/dist/use-url-search-params.d.mts +223 -0
- package/dist/use-url-search-params.mjs +295 -0
- package/dist/use-usb.d.mts +212 -0
- package/dist/use-usb.mjs +137 -0
- package/dist/use-user-activation.d.mts +83 -0
- package/dist/use-user-activation.mjs +113 -0
- package/dist/use-user-media.d.mts +194 -0
- package/dist/use-user-media.mjs +214 -0
- package/dist/use-v-model.d.mts +113 -0
- package/dist/use-v-model.mjs +40 -0
- package/dist/use-vibrate.d.mts +81 -0
- package/dist/use-vibrate.mjs +90 -0
- package/dist/use-view-transition.d.mts +106 -0
- package/dist/use-view-transition.mjs +101 -0
- package/dist/use-visual-viewport.d.mts +105 -0
- package/dist/use-visual-viewport.mjs +104 -0
- package/dist/use-wake-lock.d.mts +96 -0
- package/dist/use-wake-lock.mjs +106 -0
- package/dist/use-web-authn.d.mts +404 -0
- package/dist/use-web-authn.mjs +323 -0
- package/dist/use-web-locks.d.mts +180 -0
- package/dist/use-web-locks.mjs +136 -0
- package/dist/use-web-midi.d.mts +148 -0
- package/dist/use-web-midi.mjs +140 -0
- package/dist/use-web-vitals.d.mts +142 -0
- package/dist/use-web-vitals.mjs +248 -0
- package/dist/use-websocket.d.mts +218 -0
- package/dist/use-websocket.mjs +257 -0
- package/dist/use-worker-fn.d.mts +119 -0
- package/dist/use-worker-fn.mjs +162 -0
- package/dist/virtual-list.d.mts +105 -0
- package/dist/virtual-list.mjs +128 -0
- package/dist/watch-debounced.d.mts +84 -0
- package/dist/watch-debounced.mjs +84 -0
- package/dist/watch-ignorable.d.mts +47 -0
- package/dist/watch-ignorable.mjs +61 -0
- package/dist/watch-once.d.mts +29 -0
- package/dist/watch-once.mjs +10 -0
- package/dist/watch-pausable.d.mts +51 -0
- package/dist/watch-pausable.mjs +23 -0
- package/dist/watch-source.d.mts +29 -0
- package/dist/watch-source.mjs +1 -0
- package/dist/watch-throttled.d.mts +70 -0
- package/dist/watch-throttled.mjs +94 -0
- package/dist/whenever.d.mts +39 -0
- package/dist/whenever.mjs +41 -0
- package/dist/window-size.d.mts +87 -0
- package/dist/window-size.mjs +65 -0
- package/package.json +846 -5
- package/registry/files/abort-signal.ts +292 -0
- package/registry/files/active-element.ts +93 -0
- package/registry/files/animate.ts +322 -0
- package/registry/files/async-resource.ts +190 -0
- package/registry/files/battery.ts +166 -0
- package/registry/files/breakpoints.ts +166 -0
- package/registry/files/capability.ts +171 -0
- package/registry/files/color-mode.ts +274 -0
- package/registry/files/computed-async.ts +123 -0
- package/registry/files/computed-with-control.ts +80 -0
- package/registry/files/create-event-hook.ts +139 -0
- package/registry/files/create-global-state.ts +34 -0
- package/registry/files/create-injection-state.ts +75 -0
- package/registry/files/create-shared-composable.ts +74 -0
- package/registry/files/device-motion.ts +152 -0
- package/registry/files/device-orientation.ts +168 -0
- package/registry/files/device-pixel-ratio.ts +100 -0
- package/registry/files/disposal-scope.ts +201 -0
- package/registry/files/document-visibility.ts +152 -0
- package/registry/files/draggable.ts +273 -0
- package/registry/files/element-bounding.ts +175 -0
- package/registry/files/element-by-point.ts +149 -0
- package/registry/files/element-hover.ts +104 -0
- package/registry/files/element-ref.ts +58 -0
- package/registry/files/element-target.ts +99 -0
- package/registry/files/event-listener.ts +188 -0
- package/registry/files/focus.ts +181 -0
- package/registry/files/fps.ts +133 -0
- package/registry/files/geolocation.ts +214 -0
- package/registry/files/i18n.ts +524 -0
- package/registry/files/icu-message.ts +701 -0
- package/registry/files/idle.ts +176 -0
- package/registry/files/infinite-scroll.ts +135 -0
- package/registry/files/intersection-observer.ts +261 -0
- package/registry/files/locale.ts +148 -0
- package/registry/files/magic-keys.ts +298 -0
- package/registry/files/math.ts +175 -0
- package/registry/files/media-query.ts +102 -0
- package/registry/files/mouse-in-element.ts +107 -0
- package/registry/files/mouse.ts +167 -0
- package/registry/files/mutation-observer.ts +183 -0
- package/registry/files/network.ts +229 -0
- package/registry/files/on-click-outside.ts +178 -0
- package/registry/files/on-key-stroke.ts +135 -0
- package/registry/files/on-long-press.ts +188 -0
- package/registry/files/on-start-typing.ts +88 -0
- package/registry/files/page-leave.ts +57 -0
- package/registry/files/parent-element.ts +29 -0
- package/registry/files/pinch.ts +187 -0
- package/registry/files/pointer-lock.ts +232 -0
- package/registry/files/pointer.ts +153 -0
- package/registry/files/preferences.ts +98 -0
- package/registry/files/preferred-languages.ts +88 -0
- package/registry/files/reactify.ts +39 -0
- package/registry/files/ref-auto-reset.ts +102 -0
- package/registry/files/ref-debounced.ts +34 -0
- package/registry/files/ref-default.ts +35 -0
- package/registry/files/resize-observer.ts +220 -0
- package/registry/files/retry-async.ts +261 -0
- package/registry/files/retry-delay.ts +132 -0
- package/registry/files/scope.ts +21 -0
- package/registry/files/screen-orientation.ts +165 -0
- package/registry/files/scroll-lock.ts +80 -0
- package/registry/files/scroll.ts +338 -0
- package/registry/files/standard-schema.ts +163 -0
- package/registry/files/swipe.ts +321 -0
- package/registry/files/sync-ref.ts +166 -0
- package/registry/files/temporal.ts +182 -0
- package/registry/files/text-selection.ts +110 -0
- package/registry/files/textarea-autosize.ts +114 -0
- package/registry/files/timeout-scheduler.ts +16 -0
- package/registry/files/to-reactive.ts +44 -0
- package/registry/files/transition.ts +271 -0
- package/registry/files/until.ts +352 -0
- package/registry/files/use-array.ts +201 -0
- package/registry/files/use-async-queue.ts +278 -0
- package/registry/files/use-async-state.ts +139 -0
- package/registry/files/use-barcode-detector.ts +321 -0
- package/registry/files/use-bluetooth.ts +409 -0
- package/registry/files/use-broadcast-channel.ts +250 -0
- package/registry/files/use-builtin-ai.ts +674 -0
- package/registry/files/use-clipboard.ts +425 -0
- package/registry/files/use-compression-stream.ts +364 -0
- package/registry/files/use-confirm-dialog.ts +137 -0
- package/registry/files/use-contact-picker.ts +246 -0
- package/registry/files/use-cookie.ts +500 -0
- package/registry/files/use-countdown.ts +161 -0
- package/registry/files/use-counter.ts +147 -0
- package/registry/files/use-css-var.ts +191 -0
- package/registry/files/use-cycle-list.ts +136 -0
- package/registry/files/use-date-format.ts +281 -0
- package/registry/files/use-date-time-format.ts +113 -0
- package/registry/files/use-debounced.ts +163 -0
- package/registry/files/use-display-media.ts +89 -0
- package/registry/files/use-display-names.ts +122 -0
- package/registry/files/use-document-title.ts +196 -0
- package/registry/files/use-drop-zone.ts +287 -0
- package/registry/files/use-event-source.ts +470 -0
- package/registry/files/use-eye-dropper.ts +134 -0
- package/registry/files/use-favicon.ts +140 -0
- package/registry/files/use-fetch.ts +578 -0
- package/registry/files/use-field.ts +247 -0
- package/registry/files/use-file-dialog.ts +257 -0
- package/registry/files/use-file-system-access.ts +383 -0
- package/registry/files/use-form-field-props.ts +381 -0
- package/registry/files/use-form.ts +980 -0
- package/registry/files/use-fullscreen.ts +214 -0
- package/registry/files/use-gamepad.ts +463 -0
- package/registry/files/use-hid.ts +359 -0
- package/registry/files/use-history.ts +231 -0
- package/registry/files/use-id-generator.ts +61 -0
- package/registry/files/use-image.ts +253 -0
- package/registry/files/use-indexed-db.ts +508 -0
- package/registry/files/use-interval.ts +253 -0
- package/registry/files/use-list-format.ts +85 -0
- package/registry/files/use-machine.ts +171 -0
- package/registry/files/use-map.ts +145 -0
- package/registry/files/use-media-controls.ts +545 -0
- package/registry/files/use-memoize.ts +118 -0
- package/registry/files/use-mounted.ts +30 -0
- package/registry/files/use-navigation-api.ts +641 -0
- package/registry/files/use-notification.ts +285 -0
- package/registry/files/use-now.ts +194 -0
- package/registry/files/use-number-format.ts +120 -0
- package/registry/files/use-object-url.ts +87 -0
- package/registry/files/use-offset-pagination.ts +168 -0
- package/registry/files/use-payment-request.ts +465 -0
- package/registry/files/use-performance-observer.ts +469 -0
- package/registry/files/use-permission.ts +220 -0
- package/registry/files/use-plural-rules.ts +134 -0
- package/registry/files/use-previous.ts +62 -0
- package/registry/files/use-push-subscription.ts +352 -0
- package/registry/files/use-queue.ts +197 -0
- package/registry/files/use-raf-fn.ts +176 -0
- package/registry/files/use-relative-time-format.ts +201 -0
- package/registry/files/use-request-idle-callback.ts +278 -0
- package/registry/files/use-route-query.ts +300 -0
- package/registry/files/use-scheduler-post-task.ts +397 -0
- package/registry/files/use-screen-details.ts +393 -0
- package/registry/files/use-script-tag.ts +341 -0
- package/registry/files/use-segmenter.ts +147 -0
- package/registry/files/use-selection.ts +233 -0
- package/registry/files/use-serial.ts +404 -0
- package/registry/files/use-service-worker.ts +413 -0
- package/registry/files/use-set.ts +154 -0
- package/registry/files/use-share.ts +168 -0
- package/registry/files/use-sorted-locale.ts +130 -0
- package/registry/files/use-sorted.ts +49 -0
- package/registry/files/use-speech-recognition.ts +357 -0
- package/registry/files/use-speech-synthesis.ts +333 -0
- package/registry/files/use-stack.ts +164 -0
- package/registry/files/use-stepper.ts +166 -0
- package/registry/files/use-storage-estimate.ts +352 -0
- package/registry/files/use-storage.ts +635 -0
- package/registry/files/use-style-tag.ts +200 -0
- package/registry/files/use-supported.ts +26 -0
- package/registry/files/use-throttled.ts +215 -0
- package/registry/files/use-time-ago.ts +276 -0
- package/registry/files/use-timeout.ts +218 -0
- package/registry/files/use-toggle.ts +54 -0
- package/registry/files/use-url-hash.ts +280 -0
- package/registry/files/use-url-search-params.ts +497 -0
- package/registry/files/use-usb.ts +395 -0
- package/registry/files/use-user-activation.ts +215 -0
- package/registry/files/use-user-media.ts +422 -0
- package/registry/files/use-v-model.ts +210 -0
- package/registry/files/use-vibrate.ts +174 -0
- package/registry/files/use-view-transition.ts +229 -0
- package/registry/files/use-visual-viewport.ts +228 -0
- package/registry/files/use-wake-lock.ts +206 -0
- package/registry/files/use-web-authn.ts +793 -0
- package/registry/files/use-web-locks.ts +363 -0
- package/registry/files/use-web-midi.ts +306 -0
- package/registry/files/use-web-vitals.ts +409 -0
- package/registry/files/use-websocket.ts +553 -0
- package/registry/files/use-worker-fn.ts +306 -0
- package/registry/files/virtual-list.ts +230 -0
- package/registry/files/watch-debounced.ts +206 -0
- package/registry/files/watch-ignorable.ts +128 -0
- package/registry/files/watch-once.ts +46 -0
- package/registry/files/watch-pausable.ts +93 -0
- package/registry/files/watch-source.ts +51 -0
- package/registry/files/watch-throttled.ts +201 -0
- package/registry/files/whenever.ts +70 -0
- package/registry/files/window-size.ts +151 -0
- package/registry/registry.json +5792 -0
- package/dist/catalog-D2AL3xYl.d.mts +0 -523
- package/dist/catalog-D5SYCsgW.mjs +0 -549
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ScrollTargetValue, UseScrollOptions } from "./scroll.mjs";
|
|
2
|
+
import { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/infinite-scroll.d.ts
|
|
5
|
+
/** Edge that triggers loading in {@link useInfiniteScroll}. */
|
|
6
|
+
type InfiniteScrollDirection = "top" | "bottom" | "left" | "right";
|
|
7
|
+
/** Options for {@link useInfiniteScroll}. */
|
|
8
|
+
interface UseInfiniteScrollOptions extends Omit<UseScrollOptions, "offset"> {
|
|
9
|
+
/**
|
|
10
|
+
* Distance in CSS pixels from the edge that triggers loading.
|
|
11
|
+
*
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
readonly distance?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Edge that triggers loading.
|
|
17
|
+
*
|
|
18
|
+
* @default "bottom"
|
|
19
|
+
*/
|
|
20
|
+
readonly direction?: InfiniteScrollDirection;
|
|
21
|
+
/**
|
|
22
|
+
* Return `false` to stop loading (for example once every page is loaded).
|
|
23
|
+
*
|
|
24
|
+
* @default () => true
|
|
25
|
+
*/
|
|
26
|
+
readonly canLoadMore?: MaybeRefOrGetter<boolean>;
|
|
27
|
+
}
|
|
28
|
+
/** Reactive state returned by {@link useInfiniteScroll}. */
|
|
29
|
+
interface InfiniteScrollControls {
|
|
30
|
+
/** Whether `onLoadMore` is running. */
|
|
31
|
+
readonly isLoading: Readonly<Ref<boolean>>;
|
|
32
|
+
/**
|
|
33
|
+
* Re-check the edge and load when it is still within `distance` (call after
|
|
34
|
+
* the list was replaced).
|
|
35
|
+
*/
|
|
36
|
+
readonly reset: () => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load more content when a scroll container reaches an edge.
|
|
40
|
+
*
|
|
41
|
+
* Built on `useScroll`: when the configured edge is within `distance`,
|
|
42
|
+
* `onLoadMore` runs; concurrent calls are prevented, and after each load the
|
|
43
|
+
* edge is re-measured so short pages keep loading until the container
|
|
44
|
+
* overflows or `canLoadMore` returns `false`. Loader errors propagate to the
|
|
45
|
+
* returned promise of the internal run but never leave `isLoading` stuck.
|
|
46
|
+
* No loading happens during server rendering.
|
|
47
|
+
*
|
|
48
|
+
* @param target Reactive scroll container (element, component, or window).
|
|
49
|
+
* @param onLoadMore Loader invoked at the edge.
|
|
50
|
+
* @param options Edge, distance, gating, and {@link useScroll} options.
|
|
51
|
+
* @default options {}
|
|
52
|
+
* @returns Loading flag and a manual re-check.
|
|
53
|
+
*/
|
|
54
|
+
declare function useInfiniteScroll(target: MaybeRefOrGetter<ScrollTargetValue>, onLoadMore: () => unknown, options?: UseInfiniteScrollOptions): InfiniteScrollControls;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { InfiniteScrollControls, InfiniteScrollDirection, UseInfiniteScrollOptions, useInfiniteScroll };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { useScroll } from "./scroll.mjs";
|
|
3
|
+
import { nextTick, readonly, ref, toValue, watch } from "vue";
|
|
4
|
+
//#region src/infinite-scroll.ts
|
|
5
|
+
/**
|
|
6
|
+
* Load more content when a scroll container reaches an edge.
|
|
7
|
+
*
|
|
8
|
+
* Built on `useScroll`: when the configured edge is within `distance`,
|
|
9
|
+
* `onLoadMore` runs; concurrent calls are prevented, and after each load the
|
|
10
|
+
* edge is re-measured so short pages keep loading until the container
|
|
11
|
+
* overflows or `canLoadMore` returns `false`. Loader errors propagate to the
|
|
12
|
+
* returned promise of the internal run but never leave `isLoading` stuck.
|
|
13
|
+
* No loading happens during server rendering.
|
|
14
|
+
*
|
|
15
|
+
* @param target Reactive scroll container (element, component, or window).
|
|
16
|
+
* @param onLoadMore Loader invoked at the edge.
|
|
17
|
+
* @param options Edge, distance, gating, and {@link useScroll} options.
|
|
18
|
+
* @default options {}
|
|
19
|
+
* @returns Loading flag and a manual re-check.
|
|
20
|
+
*/
|
|
21
|
+
function useInfiniteScroll(target, onLoadMore, options = {}) {
|
|
22
|
+
const { distance = 0, direction = "bottom", canLoadMore = true, ...scrollOptions } = options;
|
|
23
|
+
const isLoading = ref(false);
|
|
24
|
+
const scroll = useScroll(target, {
|
|
25
|
+
...scrollOptions,
|
|
26
|
+
offset: { [direction]: distance }
|
|
27
|
+
});
|
|
28
|
+
let disposed = false;
|
|
29
|
+
const check = async () => {
|
|
30
|
+
if (disposed || isLoading.value || !toValue(canLoadMore)) return;
|
|
31
|
+
if (!scroll.arrivedState[direction] || !hasContainer(target)) return;
|
|
32
|
+
isLoading.value = true;
|
|
33
|
+
const before = contentSize(target);
|
|
34
|
+
try {
|
|
35
|
+
await onLoadMore();
|
|
36
|
+
} finally {
|
|
37
|
+
isLoading.value = false;
|
|
38
|
+
}
|
|
39
|
+
await nextTick();
|
|
40
|
+
if (disposed) return;
|
|
41
|
+
scroll.measure();
|
|
42
|
+
const after = contentSize(target);
|
|
43
|
+
if (after === void 0 || after !== before) check();
|
|
44
|
+
};
|
|
45
|
+
const stop = watch(() => [scroll.arrivedState[direction], toValue(canLoadMore)], () => void check(), { immediate: true });
|
|
46
|
+
tryOnScopeDispose(() => {
|
|
47
|
+
disposed = true;
|
|
48
|
+
stop.stop();
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
isLoading: readonly(isLoading),
|
|
52
|
+
reset: () => {
|
|
53
|
+
scroll.measure();
|
|
54
|
+
check();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function hasContainer(target) {
|
|
59
|
+
const value = toValue(target);
|
|
60
|
+
return value !== null && value !== void 0;
|
|
61
|
+
}
|
|
62
|
+
function contentSize(target) {
|
|
63
|
+
const value = toValue(target);
|
|
64
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
65
|
+
const element = "scrollHeight" in value ? value : "documentElement" in value ? value.documentElement : "document" in value && typeof value.document === "object" && value.document !== null ? Reflect.get(value.document, "documentElement") : "$el" in value ? value.$el : void 0;
|
|
66
|
+
if (typeof element !== "object" || element === null) return void 0;
|
|
67
|
+
const height = Reflect.get(element, "scrollHeight");
|
|
68
|
+
const width = Reflect.get(element, "scrollWidth");
|
|
69
|
+
return typeof height === "number" && typeof width === "number" ? `${String(height)}x${String(width)}` : void 0;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { useInfiniteScroll };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { n as MaybeElementTarget, r as MaybeElementTargets } from "./element-target-Crpxl4D9.mjs";
|
|
2
|
+
import { ComponentPublicInstance, MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/intersection-observer.d.ts
|
|
5
|
+
/** Runtime capability that supplies the `IntersectionObserver` constructor. */
|
|
6
|
+
interface IntersectionObserverHost {
|
|
7
|
+
/** `IntersectionObserver` constructor, absent in unsupported runtimes. */
|
|
8
|
+
readonly IntersectionObserver?: new (callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => IntersectionObserver;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Intersection root: an element target, a document, or `null`/`undefined`
|
|
12
|
+
* for the top-level viewport.
|
|
13
|
+
*/
|
|
14
|
+
type IntersectionRoot = MaybeRefOrGetter<Element | Document | ComponentPublicInstance | null | undefined>;
|
|
15
|
+
/** Options for {@link useIntersectionObserver}. */
|
|
16
|
+
interface UseIntersectionObserverOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Ancestor (or document) whose box is used as the viewport.
|
|
19
|
+
*
|
|
20
|
+
* @default undefined (the top-level viewport)
|
|
21
|
+
*/
|
|
22
|
+
readonly root?: IntersectionRoot;
|
|
23
|
+
/**
|
|
24
|
+
* Margin grown or shrunk around the root box, in CSS margin syntax.
|
|
25
|
+
*
|
|
26
|
+
* @default "0px"
|
|
27
|
+
*/
|
|
28
|
+
readonly rootMargin?: MaybeRefOrGetter<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Visible-ratio thresholds that trigger the callback.
|
|
31
|
+
*
|
|
32
|
+
* @default 0
|
|
33
|
+
*/
|
|
34
|
+
readonly threshold?: MaybeRefOrGetter<number | readonly number[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Start observing during composable creation. When `false`, call `resume`.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
readonly immediate?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Reactive constructor capability for alternate runtimes and tests.
|
|
43
|
+
*
|
|
44
|
+
* @default globalThis when it provides `IntersectionObserver`
|
|
45
|
+
*/
|
|
46
|
+
readonly host?: MaybeRefOrGetter<IntersectionObserverHost | null | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Target resolution timing. `"post"` observes template refs after mount.
|
|
49
|
+
*
|
|
50
|
+
* @default "post"
|
|
51
|
+
*/
|
|
52
|
+
readonly flush?: "pre" | "post" | "sync";
|
|
53
|
+
}
|
|
54
|
+
/** Controls returned by {@link useIntersectionObserver}. */
|
|
55
|
+
interface IntersectionObserverControls {
|
|
56
|
+
/** Whether the host provides `IntersectionObserver`. `false` during server rendering. */
|
|
57
|
+
readonly isSupported: Readonly<Ref<boolean>>;
|
|
58
|
+
/** Whether observation is currently requested (not paused or stopped). */
|
|
59
|
+
readonly isActive: Readonly<Ref<boolean>>;
|
|
60
|
+
/** Disconnect the observer while keeping the ability to `resume`. */
|
|
61
|
+
readonly pause: () => void;
|
|
62
|
+
/** Reconnect after `pause` (or start when created with `immediate: false`). */
|
|
63
|
+
readonly resume: () => void;
|
|
64
|
+
/** Disconnect permanently. Later `resume` calls are ignored. Idempotent. */
|
|
65
|
+
readonly stop: () => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Observe the intersection of reactive elements with a root.
|
|
69
|
+
*
|
|
70
|
+
* One observer is created per combination of resolved targets, root,
|
|
71
|
+
* margin, and threshold; changing any of them disconnects the previous
|
|
72
|
+
* observer first. During server rendering `isSupported` is `false` and the
|
|
73
|
+
* callback never runs. The observer is disconnected when the owning scope
|
|
74
|
+
* stops.
|
|
75
|
+
*
|
|
76
|
+
* @param targets Reactive element target or list of targets.
|
|
77
|
+
* @param callback Native `IntersectionObserver` callback.
|
|
78
|
+
* @param options Root, margin, thresholds, capability, and timing.
|
|
79
|
+
* @default options {}
|
|
80
|
+
* @returns Support/activity flags and pause/resume/stop controls.
|
|
81
|
+
*/
|
|
82
|
+
declare function useIntersectionObserver(targets: MaybeElementTargets, callback: IntersectionObserverCallback, options?: UseIntersectionObserverOptions): IntersectionObserverControls;
|
|
83
|
+
/** Options for {@link useElementVisibility}. */
|
|
84
|
+
interface UseElementVisibilityOptions extends Omit<UseIntersectionObserverOptions, "immediate"> {
|
|
85
|
+
/**
|
|
86
|
+
* Visibility exposed before the first observation and during server
|
|
87
|
+
* rendering. Keep it identical on server and client.
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
readonly initialValue?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Stop observing after the element becomes visible for the first time.
|
|
94
|
+
*
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
readonly once?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/** Reactive state returned by {@link useElementVisibility}. */
|
|
100
|
+
interface ElementVisibilityControls {
|
|
101
|
+
/** Whether the element currently intersects the root. */
|
|
102
|
+
readonly isVisible: Readonly<Ref<boolean>>;
|
|
103
|
+
/** Whether the host provides `IntersectionObserver`. */
|
|
104
|
+
readonly isSupported: Readonly<Ref<boolean>>;
|
|
105
|
+
/** Stop observing. Idempotent. */
|
|
106
|
+
readonly stop: () => void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track whether an element is visible inside the viewport (or a root).
|
|
110
|
+
*
|
|
111
|
+
* Uses the latest intersection entry, so rapid enter/leave sequences settle
|
|
112
|
+
* on the final state. With `once`, the observer disconnects after the first
|
|
113
|
+
* visible entry and `isVisible` stays `true`.
|
|
114
|
+
*
|
|
115
|
+
* @param target Reactive element target.
|
|
116
|
+
* @param options Initial value, one-shot mode, and observer options.
|
|
117
|
+
* @default options {}
|
|
118
|
+
* @returns Reactive visibility plus controls.
|
|
119
|
+
*/
|
|
120
|
+
declare function useElementVisibility(target: MaybeElementTarget, options?: UseElementVisibilityOptions): ElementVisibilityControls;
|
|
121
|
+
//#endregion
|
|
122
|
+
export { ElementVisibilityControls, IntersectionObserverControls, IntersectionObserverHost, IntersectionRoot, UseElementVisibilityOptions, UseIntersectionObserverOptions, useElementVisibility, useIntersectionObserver };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { resolveElement, resolveElements } from "./element-target.mjs";
|
|
3
|
+
import { hasInjectionContext, onMounted, readonly, ref, shallowRef, toValue, watch } from "vue";
|
|
4
|
+
//#region src/intersection-observer.ts
|
|
5
|
+
/**
|
|
6
|
+
* Observe the intersection of reactive elements with a root.
|
|
7
|
+
*
|
|
8
|
+
* One observer is created per combination of resolved targets, root,
|
|
9
|
+
* margin, and threshold; changing any of them disconnects the previous
|
|
10
|
+
* observer first. During server rendering `isSupported` is `false` and the
|
|
11
|
+
* callback never runs. The observer is disconnected when the owning scope
|
|
12
|
+
* stops.
|
|
13
|
+
*
|
|
14
|
+
* @param targets Reactive element target or list of targets.
|
|
15
|
+
* @param callback Native `IntersectionObserver` callback.
|
|
16
|
+
* @param options Root, margin, thresholds, capability, and timing.
|
|
17
|
+
* @default options {}
|
|
18
|
+
* @returns Support/activity flags and pause/resume/stop controls.
|
|
19
|
+
*/
|
|
20
|
+
function useIntersectionObserver(targets, callback, options = {}) {
|
|
21
|
+
const isSupported = ref(false);
|
|
22
|
+
const isActive = ref(options.immediate ?? true);
|
|
23
|
+
let stopped = false;
|
|
24
|
+
let stopWatch;
|
|
25
|
+
const mounted = shallowRef(!hasInjectionContext());
|
|
26
|
+
if (!mounted.value) onMounted(() => {
|
|
27
|
+
mounted.value = true;
|
|
28
|
+
});
|
|
29
|
+
const host = () => !mounted.value ? void 0 : options.host === void 0 ? browserIntersectionObserverHost() : toValue(options.host);
|
|
30
|
+
isSupported.value = host()?.IntersectionObserver !== void 0;
|
|
31
|
+
const connect = () => {
|
|
32
|
+
stopWatch = watch(() => [
|
|
33
|
+
host(),
|
|
34
|
+
resolveElements(targets),
|
|
35
|
+
resolveRoot(options.root),
|
|
36
|
+
toValue(options.rootMargin) ?? "0px",
|
|
37
|
+
toValue(options.threshold) ?? 0
|
|
38
|
+
], ([currentHost, elements, root, rootMargin, threshold], _previous, onCleanup) => {
|
|
39
|
+
const Observer = currentHost?.IntersectionObserver;
|
|
40
|
+
isSupported.value = Observer !== void 0;
|
|
41
|
+
if (!Observer || elements.length === 0) return;
|
|
42
|
+
const observer = new Observer(callback, {
|
|
43
|
+
root,
|
|
44
|
+
rootMargin,
|
|
45
|
+
threshold: typeof threshold === "number" ? threshold : [...threshold]
|
|
46
|
+
});
|
|
47
|
+
for (const element of elements) observer.observe(element);
|
|
48
|
+
onCleanup(() => observer.disconnect());
|
|
49
|
+
}, {
|
|
50
|
+
immediate: true,
|
|
51
|
+
flush: options.flush ?? "post"
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const pause = () => {
|
|
55
|
+
stopWatch?.stop();
|
|
56
|
+
stopWatch = void 0;
|
|
57
|
+
isActive.value = false;
|
|
58
|
+
};
|
|
59
|
+
const resume = () => {
|
|
60
|
+
if (stopped || stopWatch) return;
|
|
61
|
+
isActive.value = true;
|
|
62
|
+
connect();
|
|
63
|
+
};
|
|
64
|
+
const stop = () => {
|
|
65
|
+
stopped = true;
|
|
66
|
+
pause();
|
|
67
|
+
};
|
|
68
|
+
if (isActive.value) connect();
|
|
69
|
+
tryOnScopeDispose(stop);
|
|
70
|
+
return {
|
|
71
|
+
isSupported: readonly(isSupported),
|
|
72
|
+
isActive: readonly(isActive),
|
|
73
|
+
pause,
|
|
74
|
+
resume,
|
|
75
|
+
stop
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Track whether an element is visible inside the viewport (or a root).
|
|
80
|
+
*
|
|
81
|
+
* Uses the latest intersection entry, so rapid enter/leave sequences settle
|
|
82
|
+
* on the final state. With `once`, the observer disconnects after the first
|
|
83
|
+
* visible entry and `isVisible` stays `true`.
|
|
84
|
+
*
|
|
85
|
+
* @param target Reactive element target.
|
|
86
|
+
* @param options Initial value, one-shot mode, and observer options.
|
|
87
|
+
* @default options {}
|
|
88
|
+
* @returns Reactive visibility plus controls.
|
|
89
|
+
*/
|
|
90
|
+
function useElementVisibility(target, options = {}) {
|
|
91
|
+
const isVisible = ref(options.initialValue ?? false);
|
|
92
|
+
const controls = useIntersectionObserver(target, (entries) => {
|
|
93
|
+
let latest;
|
|
94
|
+
for (const entry of entries) if (!latest || entry.time >= latest.time) latest = entry;
|
|
95
|
+
if (!latest) return;
|
|
96
|
+
isVisible.value = latest.isIntersecting;
|
|
97
|
+
if (options.once && latest.isIntersecting) controls.stop();
|
|
98
|
+
}, options);
|
|
99
|
+
return {
|
|
100
|
+
isVisible: readonly(isVisible),
|
|
101
|
+
isSupported: controls.isSupported,
|
|
102
|
+
stop: controls.stop
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function resolveRoot(root) {
|
|
106
|
+
if (root === void 0) return null;
|
|
107
|
+
const value = toValue(root);
|
|
108
|
+
return isDocumentNode(value) ? value : resolveElement(value);
|
|
109
|
+
}
|
|
110
|
+
function isDocumentNode(value) {
|
|
111
|
+
return typeof value === "object" && value !== null && "nodeType" in value && value.nodeType === 9;
|
|
112
|
+
}
|
|
113
|
+
function browserIntersectionObserverHost() {
|
|
114
|
+
return typeof IntersectionObserver === "function" ? globalThis : void 0;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { useElementVisibility, useIntersectionObserver };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/magic-keys.d.ts
|
|
4
|
+
/** Modifier key names recognized in combos (after alias resolution). */
|
|
5
|
+
type ModifierKeyName = "control" | "shift" | "alt" | "meta";
|
|
6
|
+
/**
|
|
7
|
+
* Validate a key combo string at the type level.
|
|
8
|
+
*
|
|
9
|
+
* Combos join lowercase-insensitive key names with `+` or `_`
|
|
10
|
+
* (`"ctrl+s"`, `"shift_arrowup"`). Empty segments such as `"ctrl+"` or
|
|
11
|
+
* `"+s"` resolve to `never`, turning typos into compile errors. Non-literal
|
|
12
|
+
* `string` values are accepted unchanged.
|
|
13
|
+
*/
|
|
14
|
+
type KeyCombo<Combo extends string> = string extends Combo ? string : Combo extends "" ? never : Combo extends `${infer Head}${"+" | "_"}${infer Tail}` ? Head extends "" ? never : Tail extends "" ? never : KeyCombo<Tail> extends never ? never : Combo : Combo;
|
|
15
|
+
/** Default aliases resolved before matching combos. */
|
|
16
|
+
declare const DEFAULT_KEY_ALIASES: {
|
|
17
|
+
readonly ctrl: "control";
|
|
18
|
+
readonly command: "meta";
|
|
19
|
+
readonly cmd: "meta";
|
|
20
|
+
readonly option: "alt";
|
|
21
|
+
readonly esc: "escape";
|
|
22
|
+
readonly up: "arrowup";
|
|
23
|
+
readonly down: "arrowdown";
|
|
24
|
+
readonly left: "arrowleft";
|
|
25
|
+
readonly right: "arrowright";
|
|
26
|
+
readonly " ": "space";
|
|
27
|
+
readonly spacebar: "space";
|
|
28
|
+
};
|
|
29
|
+
/** Options shared by the keyboard composables. */
|
|
30
|
+
interface UseKeyboardTargetOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Event target that receives `keydown`/`keyup`.
|
|
33
|
+
*
|
|
34
|
+
* @default globalThis.window when available
|
|
35
|
+
*/
|
|
36
|
+
readonly target?: MaybeRefOrGetter<EventTarget | null | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Register passive listeners.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
readonly passive?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Options for {@link useMagicKeys}. */
|
|
45
|
+
interface UseMagicKeysOptions extends UseKeyboardTargetOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Extra aliases merged over {@link DEFAULT_KEY_ALIASES}. Keys and values are
|
|
48
|
+
* matched case-insensitively.
|
|
49
|
+
*
|
|
50
|
+
* @default {}
|
|
51
|
+
*/
|
|
52
|
+
readonly aliasMap?: Readonly<Record<string, string>>;
|
|
53
|
+
/**
|
|
54
|
+
* Called for every `keydown`/`keyup` after the pressed set has been
|
|
55
|
+
* updated. Useful for `preventDefault()` with `passive: false`.
|
|
56
|
+
*
|
|
57
|
+
* @default undefined
|
|
58
|
+
*/
|
|
59
|
+
readonly onEventFired?: (event: KeyboardEvent) => void;
|
|
60
|
+
}
|
|
61
|
+
/** Reactive keyboard state returned by {@link useMagicKeys}. */
|
|
62
|
+
interface MagicKeys {
|
|
63
|
+
/** Normalized names (`event.key` and `event.code`, lowercase) currently pressed. */
|
|
64
|
+
readonly current: ReadonlySet<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Proxy of combo refs created lazily on property access, e.g.
|
|
67
|
+
* `const { shift, ctrl_s } = keys.combos`.
|
|
68
|
+
*/
|
|
69
|
+
readonly combos: Readonly<Record<string, ComputedRef<boolean>>>;
|
|
70
|
+
/**
|
|
71
|
+
* Create (or reuse) a ref that is `true` while every key of the combo is
|
|
72
|
+
* pressed.
|
|
73
|
+
*
|
|
74
|
+
* @param combo Key combo such as `"ctrl+shift+p"`.
|
|
75
|
+
* @returns Readonly computed ref.
|
|
76
|
+
*/
|
|
77
|
+
readonly isPressed: <const Combo extends string>(combo: Combo & KeyCombo<Combo>) => ComputedRef<boolean>;
|
|
78
|
+
/** Forget every pressed key (for example after a modal steals focus). */
|
|
79
|
+
readonly reset: () => void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Normalize a key name the way combos are matched.
|
|
83
|
+
*
|
|
84
|
+
* @param name Raw `KeyboardEvent.key`/`code` or combo segment.
|
|
85
|
+
* @param aliases Alias table (keys lowercased).
|
|
86
|
+
* @default aliases DEFAULT_KEY_ALIASES
|
|
87
|
+
* @returns Lowercase, alias-resolved name.
|
|
88
|
+
*/
|
|
89
|
+
declare function normalizeKeyName(name: string, aliases?: Readonly<Record<string, string>>): string;
|
|
90
|
+
/**
|
|
91
|
+
* Track pressed keys and expose reactive key combos.
|
|
92
|
+
*
|
|
93
|
+
* Both `event.key` and `event.code` are recorded (lowercased), so `"a"` and
|
|
94
|
+
* `"keya"` both match. Because some platforms (notably macOS with `meta`)
|
|
95
|
+
* swallow `keyup` for other keys while a modifier is held, releasing a
|
|
96
|
+
* modifier clears every non-modifier key; losing window focus clears
|
|
97
|
+
* everything. Nothing is pressed during server rendering, and listeners are
|
|
98
|
+
* removed with the owning reactive scope.
|
|
99
|
+
*
|
|
100
|
+
* @param options Target, passivity, aliases, and event hook.
|
|
101
|
+
* @default options {}
|
|
102
|
+
* @returns Pressed set, lazily created combo refs, and controls.
|
|
103
|
+
*/
|
|
104
|
+
declare function useMagicKeys(options?: UseMagicKeysOptions): MagicKeys;
|
|
105
|
+
/** Key filter accepted by {@link useKeyPressed}. */
|
|
106
|
+
type KeyFilter = string | readonly string[] | ((event: KeyboardEvent) => boolean);
|
|
107
|
+
/**
|
|
108
|
+
* Track whether any key matching a filter is held down.
|
|
109
|
+
*
|
|
110
|
+
* String filters are normalized like combos (`"esc"` matches `Escape`) and
|
|
111
|
+
* compared against both `event.key` and `event.code`. The state resets on
|
|
112
|
+
* window blur and during server rendering is always `false`.
|
|
113
|
+
*
|
|
114
|
+
* @param filter Key name(s) or predicate.
|
|
115
|
+
* @param options Target and passivity.
|
|
116
|
+
* @default options {}
|
|
117
|
+
* @returns Readonly ref that is `true` while a matching key is held.
|
|
118
|
+
*/
|
|
119
|
+
declare function useKeyPressed(filter: KeyFilter, options?: UseKeyboardTargetOptions): Readonly<Ref<boolean>>;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { DEFAULT_KEY_ALIASES, KeyCombo, KeyFilter, MagicKeys, ModifierKeyName, UseKeyboardTargetOptions, UseMagicKeysOptions, normalizeKeyName, useKeyPressed, useMagicKeys };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { computed, reactive, readonly, ref, toValue, watch } from "vue";
|
|
3
|
+
//#region src/magic-keys.ts
|
|
4
|
+
/** Default aliases resolved before matching combos. */
|
|
5
|
+
const DEFAULT_KEY_ALIASES = {
|
|
6
|
+
ctrl: "control",
|
|
7
|
+
command: "meta",
|
|
8
|
+
cmd: "meta",
|
|
9
|
+
option: "alt",
|
|
10
|
+
esc: "escape",
|
|
11
|
+
up: "arrowup",
|
|
12
|
+
down: "arrowdown",
|
|
13
|
+
left: "arrowleft",
|
|
14
|
+
right: "arrowright",
|
|
15
|
+
" ": "space",
|
|
16
|
+
spacebar: "space"
|
|
17
|
+
};
|
|
18
|
+
const modifierNames = new Set([
|
|
19
|
+
"control",
|
|
20
|
+
"shift",
|
|
21
|
+
"alt",
|
|
22
|
+
"meta"
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a key name the way combos are matched.
|
|
26
|
+
*
|
|
27
|
+
* @param name Raw `KeyboardEvent.key`/`code` or combo segment.
|
|
28
|
+
* @param aliases Alias table (keys lowercased).
|
|
29
|
+
* @default aliases DEFAULT_KEY_ALIASES
|
|
30
|
+
* @returns Lowercase, alias-resolved name.
|
|
31
|
+
*/
|
|
32
|
+
function normalizeKeyName(name, aliases = DEFAULT_KEY_ALIASES) {
|
|
33
|
+
const lower = name.toLowerCase();
|
|
34
|
+
return (aliases[lower] ?? lower).toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Track pressed keys and expose reactive key combos.
|
|
38
|
+
*
|
|
39
|
+
* Both `event.key` and `event.code` are recorded (lowercased), so `"a"` and
|
|
40
|
+
* `"keya"` both match. Because some platforms (notably macOS with `meta`)
|
|
41
|
+
* swallow `keyup` for other keys while a modifier is held, releasing a
|
|
42
|
+
* modifier clears every non-modifier key; losing window focus clears
|
|
43
|
+
* everything. Nothing is pressed during server rendering, and listeners are
|
|
44
|
+
* removed with the owning reactive scope.
|
|
45
|
+
*
|
|
46
|
+
* @param options Target, passivity, aliases, and event hook.
|
|
47
|
+
* @default options {}
|
|
48
|
+
* @returns Pressed set, lazily created combo refs, and controls.
|
|
49
|
+
*/
|
|
50
|
+
function useMagicKeys(options = {}) {
|
|
51
|
+
const aliases = { ...DEFAULT_KEY_ALIASES };
|
|
52
|
+
for (const [alias, key] of Object.entries(options.aliasMap ?? {})) aliases[alias.toLowerCase()] = key.toLowerCase();
|
|
53
|
+
const current = reactive(/* @__PURE__ */ new Set());
|
|
54
|
+
const cache = /* @__PURE__ */ new Map();
|
|
55
|
+
const namesOf = (event) => {
|
|
56
|
+
const names = /* @__PURE__ */ new Set();
|
|
57
|
+
if (event.key) names.add(normalizeKeyName(event.key, aliases));
|
|
58
|
+
if (event.code) names.add(normalizeKeyName(event.code, aliases));
|
|
59
|
+
return [...names];
|
|
60
|
+
};
|
|
61
|
+
const reset = () => current.clear();
|
|
62
|
+
const onKey = (event) => {
|
|
63
|
+
if (!isKeyboardEvent(event)) return;
|
|
64
|
+
const names = namesOf(event);
|
|
65
|
+
if (event.type === "keydown") for (const name of names) current.add(name);
|
|
66
|
+
else {
|
|
67
|
+
for (const name of names) current.delete(name);
|
|
68
|
+
if (names.some((name) => modifierNames.has(name))) {
|
|
69
|
+
for (const name of current) if (!modifierNames.has(name)) current.delete(name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
options.onEventFired?.(event);
|
|
73
|
+
};
|
|
74
|
+
const stop = watch(() => options.target === void 0 ? browserWindow() : toValue(options.target), (target, _previous, onCleanup) => {
|
|
75
|
+
if (!target) return;
|
|
76
|
+
const listenerOptions = { passive: options.passive ?? true };
|
|
77
|
+
target.addEventListener("keydown", onKey, listenerOptions);
|
|
78
|
+
target.addEventListener("keyup", onKey, listenerOptions);
|
|
79
|
+
target.addEventListener("blur", reset, { passive: true });
|
|
80
|
+
onCleanup(() => {
|
|
81
|
+
target.removeEventListener("keydown", onKey);
|
|
82
|
+
target.removeEventListener("keyup", onKey);
|
|
83
|
+
target.removeEventListener("blur", reset);
|
|
84
|
+
reset();
|
|
85
|
+
});
|
|
86
|
+
}, { immediate: true });
|
|
87
|
+
tryOnScopeDispose(() => stop.stop());
|
|
88
|
+
const comboRef = (combo) => {
|
|
89
|
+
const key = combo.toLowerCase();
|
|
90
|
+
const cached = cache.get(key);
|
|
91
|
+
if (cached) return cached;
|
|
92
|
+
const parts = key.split(/[+_]/).filter((part) => part !== "").map((part) => normalizeKeyName(part, aliases));
|
|
93
|
+
const pressed = computed(() => parts.length > 0 && parts.every((part) => current.has(part)));
|
|
94
|
+
cache.set(key, pressed);
|
|
95
|
+
return pressed;
|
|
96
|
+
};
|
|
97
|
+
const combos = new Proxy({}, {
|
|
98
|
+
get: (_target, property) => typeof property === "string" ? comboRef(property) : void 0,
|
|
99
|
+
has: (_target, property) => typeof property === "string"
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
current: readonly(current),
|
|
103
|
+
combos,
|
|
104
|
+
isPressed: (combo) => comboRef(combo),
|
|
105
|
+
reset
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track whether any key matching a filter is held down.
|
|
110
|
+
*
|
|
111
|
+
* String filters are normalized like combos (`"esc"` matches `Escape`) and
|
|
112
|
+
* compared against both `event.key` and `event.code`. The state resets on
|
|
113
|
+
* window blur and during server rendering is always `false`.
|
|
114
|
+
*
|
|
115
|
+
* @param filter Key name(s) or predicate.
|
|
116
|
+
* @param options Target and passivity.
|
|
117
|
+
* @default options {}
|
|
118
|
+
* @returns Readonly ref that is `true` while a matching key is held.
|
|
119
|
+
*/
|
|
120
|
+
function useKeyPressed(filter, options = {}) {
|
|
121
|
+
const held = /* @__PURE__ */ new Set();
|
|
122
|
+
const pressed = ref(false);
|
|
123
|
+
const names = typeof filter === "function" ? void 0 : new Set((typeof filter === "string" ? [filter] : filter).map((name) => normalizeKeyName(name)));
|
|
124
|
+
const matches = (event) => names === void 0 ? typeof filter === "function" && filter(event) : names.has(normalizeKeyName(event.key)) || names.has(normalizeKeyName(event.code));
|
|
125
|
+
const identity = (event) => event.code || event.key;
|
|
126
|
+
const onDown = (event) => {
|
|
127
|
+
if (!isKeyboardEvent(event) || !matches(event)) return;
|
|
128
|
+
held.add(identity(event));
|
|
129
|
+
pressed.value = true;
|
|
130
|
+
};
|
|
131
|
+
const onUp = (event) => {
|
|
132
|
+
if (!isKeyboardEvent(event)) return;
|
|
133
|
+
held.delete(identity(event));
|
|
134
|
+
pressed.value = held.size > 0;
|
|
135
|
+
};
|
|
136
|
+
const reset = () => {
|
|
137
|
+
held.clear();
|
|
138
|
+
pressed.value = false;
|
|
139
|
+
};
|
|
140
|
+
const stop = watch(() => options.target === void 0 ? browserWindow() : toValue(options.target), (target, _previous, onCleanup) => {
|
|
141
|
+
if (!target) return;
|
|
142
|
+
const listenerOptions = { passive: options.passive ?? true };
|
|
143
|
+
target.addEventListener("keydown", onDown, listenerOptions);
|
|
144
|
+
target.addEventListener("keyup", onUp, listenerOptions);
|
|
145
|
+
target.addEventListener("blur", reset, { passive: true });
|
|
146
|
+
onCleanup(() => {
|
|
147
|
+
target.removeEventListener("keydown", onDown);
|
|
148
|
+
target.removeEventListener("keyup", onUp);
|
|
149
|
+
target.removeEventListener("blur", reset);
|
|
150
|
+
reset();
|
|
151
|
+
});
|
|
152
|
+
}, { immediate: true });
|
|
153
|
+
tryOnScopeDispose(() => stop.stop());
|
|
154
|
+
return readonly(pressed);
|
|
155
|
+
}
|
|
156
|
+
function isKeyboardEvent(event) {
|
|
157
|
+
return "key" in event && "code" in event;
|
|
158
|
+
}
|
|
159
|
+
function browserWindow() {
|
|
160
|
+
return typeof window !== "undefined" ? window : void 0;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { DEFAULT_KEY_ALIASES, normalizeKeyName, useKeyPressed, useMagicKeys };
|