@bouko/react 2.6.4 → 2.6.6

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.
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn, opacitize } from "@bouko/style";
3
3
  export default function IconButton({ style, color = "--color-accent", icon, action, disabled = false }) {
4
- return (_jsx("button", { className: cn("hover:brightness-115 disabled:!cursor-not-allowed", style), style: styles(color), onClick: action, disabled: !action || disabled, children: icon }, void 0));
4
+ return (_jsx("button", { className: cn("flex hover:brightness-115 disabled:!cursor-not-allowed", style), style: styles(color), onClick: action, disabled: !action || disabled, children: icon }, void 0));
5
5
  }
6
6
  const styles = (color) => ({
7
- display: "flex",
8
7
  justifyContent: "center",
9
8
  itemsCenter: "center",
10
9
  padding: "0.5rem",
@@ -3,11 +3,8 @@ export declare const getFilesData: (files: File[]) => Promise<{
3
3
  mimetype: string;
4
4
  data?: string | undefined;
5
5
  }[]>;
6
- export declare const getFileData: (file: File) => Promise<{
7
- filename: string;
8
- mimetype: string;
9
- data?: string | undefined;
10
- }>;
6
+ export declare function getFileData(file: File): Promise<string>;
7
+ export declare function getFileData(file: File | undefined): Promise<string | undefined>;
11
8
  export declare const bufferToFile: (buffer: ArrayBuffer, name?: string | undefined) => Promise<File>;
12
9
  export declare const getAudioDuration: (file: File) => Promise<number>;
13
10
  export declare function getBase64(image: string): Promise<string>;
@@ -14,19 +14,16 @@ export const getFilesData = (files) => Promise.all(files.map((file) => {
14
14
  reader.readAsDataURL(file);
15
15
  });
16
16
  }));
17
- export const getFileData = (file) => new Promise((resolve, reject) => {
18
- const reader = new FileReader();
19
- reader.onload = () => {
20
- const base64 = reader.result?.toString().split(",")[1]; // Remove data prefix
21
- return resolve({
22
- filename: file.name,
23
- mimetype: file.type,
24
- data: base64,
25
- });
26
- };
27
- reader.onerror = reject;
28
- reader.readAsDataURL(file);
29
- });
17
+ export async function getFileData(file) {
18
+ if (!file)
19
+ return;
20
+ return new Promise((resolve, reject) => {
21
+ const reader = new FileReader();
22
+ reader.onload = () => resolve(reader.result);
23
+ reader.onerror = reject;
24
+ reader.readAsDataURL(file);
25
+ });
26
+ }
30
27
  async function detectFileExtension(buffer) {
31
28
  const type = await fileTypeFromBuffer(buffer);
32
29
  if (!type)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.6.4",
4
+ "version": "2.6.6",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",