@bouko/react 2.7.9 → 2.8.1

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.
@@ -0,0 +1,4 @@
1
+ import type { RefObject } from "react";
2
+ export type DivRef = RefObject<HTMLDivElement | null>;
3
+ export type AudioRef = RefObject<HTMLAudioElement | null>;
4
+ export declare function withAudio(ref: AudioRef, fn: (el: HTMLAudioElement) => void): void;
@@ -0,0 +1,6 @@
1
+ export function withAudio(ref, fn) {
2
+ const el = ref.current;
3
+ if (!el)
4
+ return;
5
+ return fn(el);
6
+ }
@@ -3,3 +3,4 @@ export { default as useContainer } from "./element/container";
3
3
  export { default as useResize } from "./element/resize";
4
4
  export { default as useInterval } from "./clock/interval";
5
5
  export { default as useSound } from "./audio/sound";
6
+ export { withAudio, type DivRef, type AudioRef } from "./element/with-audio";
@@ -3,3 +3,4 @@ export { default as useContainer } from "./element/container";
3
3
  export { default as useResize } from "./element/resize";
4
4
  export { default as useInterval } from "./clock/interval";
5
5
  export { default as useSound } from "./audio/sound";
6
+ export { withAudio } from "./element/with-audio";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.7.9",
4
+ "version": "2.8.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",