@bouko/react 2.3.6 → 2.3.8
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/components/animate/configs.d.ts +136 -136
- package/dist/components/animate/configs.js +62 -62
- package/dist/components/animate/index.d.ts +12 -12
- package/dist/components/animate/index.js +7 -7
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +18 -19
- package/dist/components/button/load.d.ts +10 -10
- package/dist/components/button/load.js +35 -35
- package/dist/components/button.d.ts +10 -10
- package/dist/components/button.js +22 -22
- package/dist/components/carousel/index.d.ts +7 -7
- package/dist/components/carousel/index.js +15 -15
- package/dist/components/checkbox.d.ts +8 -8
- package/dist/components/checkbox.js +13 -13
- package/dist/components/dropdown/normal.d.ts +10 -10
- package/dist/components/dropdown/normal.js +19 -19
- package/dist/components/fade-carousel.d.ts +4 -4
- package/dist/components/fade-carousel.js +14 -14
- package/dist/components/field.d.ts +10 -10
- package/dist/components/field.js +10 -10
- package/dist/components/form/footer.js +2 -2
- package/dist/components/form/types.d.ts +38 -38
- package/dist/components/form/types.js +1 -1
- package/dist/components/heading/normal.d.ts +29 -29
- package/dist/components/heading/normal.js +22 -22
- package/dist/components/heading/page.d.ts +1 -1
- package/dist/components/heading/page.js +5 -5
- package/dist/components/index.d.ts +11 -12
- package/dist/components/index.js +11 -12
- package/dist/components/input.d.ts +11 -11
- package/dist/components/input.js +6 -6
- package/dist/components/layout/fade.d.ts +6 -6
- package/dist/components/layout/fade.js +14 -14
- package/dist/components/layout/flex.d.ts +16 -16
- package/dist/components/layout/flex.js +42 -40
- package/dist/components/layout/heading.d.ts +1 -3
- package/dist/components/layout/heading.js +2 -2
- package/dist/components/layout/separator.d.ts +3 -3
- package/dist/components/layout/separator.js +5 -5
- package/dist/components/list/index.d.ts +2 -2
- package/dist/components/list/index.js +2 -2
- package/dist/components/list/item.d.ts +9 -9
- package/dist/components/list/item.js +7 -7
- package/dist/components/list/variants/bullet.d.ts +9 -9
- package/dist/components/list/variants/bullet.js +16 -16
- package/dist/components/list/variants/number.d.ts +10 -10
- package/dist/components/list/variants/number.js +18 -18
- package/dist/components/multiple-choice.d.ts +2 -2
- package/dist/components/multiple-choice.js +12 -13
- package/dist/components/search-bar.d.ts +12 -12
- package/dist/components/search-bar.js +14 -14
- package/dist/components/select.d.ts +6 -6
- package/dist/components/select.js +24 -25
- package/dist/components/text/badge.d.ts +11 -11
- package/dist/components/text/badge.js +18 -17
- package/dist/components/textarea.d.ts +7 -7
- package/dist/components/textarea.js +11 -11
- package/dist/components/upload/file.d.ts +8 -8
- package/dist/components/upload/file.js +15 -15
- package/dist/core/format.d.ts +3 -3
- package/dist/core/format.js +34 -34
- package/dist/core/functions.d.ts +13 -13
- package/dist/core/functions.js +79 -79
- package/dist/core/types.d.ts +11 -11
- package/dist/core/types.js +2 -2
- package/dist/hooks/audio/sound.d.ts +1 -0
- package/dist/hooks/audio/sound.js +6 -0
- package/dist/hooks/clock/interval.d.ts +1 -1
- package/dist/hooks/clock/interval.js +20 -20
- package/dist/hooks/element/container.d.ts +5 -4
- package/dist/hooks/element/container.js +7 -7
- package/dist/hooks/element/resize.d.ts +1 -1
- package/dist/hooks/element/resize.js +12 -12
- package/dist/hooks/index.d.ts +4 -3
- package/dist/hooks/index.js +4 -3
- package/dist/index.d.ts +14 -14
- package/dist/index.js +14 -14
- package/package.json +5 -31
- package/dist/assets/icons/check copy.svg +0 -6
- package/dist/assets/icons/check-circle copy.svg +0 -6
- package/dist/assets/icons/chevron copy.svg +0 -6
- package/dist/assets/icons/paperclip copy.svg +0 -6
- package/dist/assets/icons/spinner copy.svg +0 -6
- package/dist/assets/icons/x-circle copy.svg +0 -6
- package/dist/components/badge.d.ts +0 -5
- package/dist/components/badge.js +0 -4
- package/dist/components/flex.d.ts +0 -16
- package/dist/components/flex.js +0 -8
- package/dist/components/form/fields.d.ts +0 -16
- package/dist/components/form/fields.js +0 -21
- package/dist/components/form/loaders.d.ts +0 -3
- package/dist/components/form/loaders.js +0 -11
- package/dist/components/form/test-next.d.ts +0 -1
- package/dist/components/form/test-next.js +0 -6
- package/dist/components/search/index.d.ts +0 -6
- package/dist/components/search/index.js +0 -12
- package/dist/hooks/color.d.ts +0 -7
- package/dist/hooks/color.js +0 -8
package/dist/core/format.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
const delimiterConfig = [
|
|
4
|
-
{ delimiter: "**", render: (text, key) => _jsx("span", { className: "font-bold", children: text }, key) },
|
|
5
|
-
{ delimiter: "~~", render: (text, key) => _jsx("span", { className: "font-semibold", children: text }, key) },
|
|
6
|
-
{ delimiter: "^^", render: (text, key) => _jsx("span", { className: "text-accent", children: text }, key) },
|
|
7
|
-
];
|
|
8
|
-
const escapeRegex = (str) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
9
|
-
const delimiters = delimiterConfig.map(({ delimiter }) => escapeRegex(delimiter) + ".*?" + escapeRegex(delimiter)).join("|");
|
|
10
|
-
const WRAPPED_TEXT_REGEX = new RegExp(`(${delimiters})`, "g");
|
|
11
|
-
export const rn = (...elements) => (_jsx(Fragment, { children: elements.map((x, i) => (_jsx(Fragment, { children: x }, i))) }));
|
|
12
|
-
const isWrapped = (x, wrapper) => x.startsWith(wrapper) && x.endsWith(wrapper);
|
|
13
|
-
export const formatText = (text) => {
|
|
14
|
-
const parts = text
|
|
15
|
-
.split(WRAPPED_TEXT_REGEX)
|
|
16
|
-
.filter(Boolean);
|
|
17
|
-
const formatted = parts.map((x, i) => {
|
|
18
|
-
if (isWrapped(x, "**")) {
|
|
19
|
-
// Remove only the first and last occurrence of the delimiter
|
|
20
|
-
const content = x.slice(2, -2);
|
|
21
|
-
return _jsx("span", { className: "font-bold", children: content }, i);
|
|
22
|
-
}
|
|
23
|
-
else if (isWrapped(x, "~~")) {
|
|
24
|
-
const content = x.slice(2, -2);
|
|
25
|
-
return _jsx("span", { className: "font-semibold", children: content }, i);
|
|
26
|
-
}
|
|
27
|
-
else if (isWrapped(x, "^^")) {
|
|
28
|
-
const content = x.slice(2, -2);
|
|
29
|
-
return _jsx("span", { className: "text-accent", children: content }, i);
|
|
30
|
-
}
|
|
31
|
-
return x;
|
|
32
|
-
});
|
|
33
|
-
return _jsx("span", { children: formatted });
|
|
34
|
-
};
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
const delimiterConfig = [
|
|
4
|
+
{ delimiter: "**", render: (text, key) => _jsx("span", { className: "font-bold", children: text }, key) },
|
|
5
|
+
{ delimiter: "~~", render: (text, key) => _jsx("span", { className: "font-semibold", children: text }, key) },
|
|
6
|
+
{ delimiter: "^^", render: (text, key) => _jsx("span", { className: "text-accent", children: text }, key) },
|
|
7
|
+
];
|
|
8
|
+
const escapeRegex = (str) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
9
|
+
const delimiters = delimiterConfig.map(({ delimiter }) => escapeRegex(delimiter) + ".*?" + escapeRegex(delimiter)).join("|");
|
|
10
|
+
const WRAPPED_TEXT_REGEX = new RegExp(`(${delimiters})`, "g");
|
|
11
|
+
export const rn = (...elements) => (_jsx(Fragment, { children: elements.map((x, i) => (_jsx(Fragment, { children: x }, i))) }, void 0));
|
|
12
|
+
const isWrapped = (x, wrapper) => x.startsWith(wrapper) && x.endsWith(wrapper);
|
|
13
|
+
export const formatText = (text) => {
|
|
14
|
+
const parts = text
|
|
15
|
+
.split(WRAPPED_TEXT_REGEX)
|
|
16
|
+
.filter(Boolean);
|
|
17
|
+
const formatted = parts.map((x, i) => {
|
|
18
|
+
if (isWrapped(x, "**")) {
|
|
19
|
+
// Remove only the first and last occurrence of the delimiter
|
|
20
|
+
const content = x.slice(2, -2);
|
|
21
|
+
return _jsx("span", { className: "font-bold", children: content }, i);
|
|
22
|
+
}
|
|
23
|
+
else if (isWrapped(x, "~~")) {
|
|
24
|
+
const content = x.slice(2, -2);
|
|
25
|
+
return _jsx("span", { className: "font-semibold", children: content }, i);
|
|
26
|
+
}
|
|
27
|
+
else if (isWrapped(x, "^^")) {
|
|
28
|
+
const content = x.slice(2, -2);
|
|
29
|
+
return _jsx("span", { className: "text-accent", children: content }, i);
|
|
30
|
+
}
|
|
31
|
+
return x;
|
|
32
|
+
});
|
|
33
|
+
return _jsx("span", { children: formatted }, void 0);
|
|
34
|
+
};
|
package/dist/core/functions.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare const getFilesData: (files: File[]) => Promise<{
|
|
2
|
-
filename: string;
|
|
3
|
-
mimetype: string;
|
|
4
|
-
data?: string;
|
|
5
|
-
}[]>;
|
|
6
|
-
export declare const getFileData: (file: File) => Promise<{
|
|
7
|
-
filename: string;
|
|
8
|
-
mimetype: string;
|
|
9
|
-
data?: string;
|
|
10
|
-
}>;
|
|
11
|
-
export declare const bufferToFile: (buffer:
|
|
12
|
-
export declare const getAudioDuration: (file: File) => Promise<number>;
|
|
13
|
-
export declare function getBase64(image: string): Promise<string>;
|
|
1
|
+
export declare const getFilesData: (files: File[]) => Promise<{
|
|
2
|
+
filename: string;
|
|
3
|
+
mimetype: string;
|
|
4
|
+
data?: string | undefined;
|
|
5
|
+
}[]>;
|
|
6
|
+
export declare const getFileData: (file: File) => Promise<{
|
|
7
|
+
filename: string;
|
|
8
|
+
mimetype: string;
|
|
9
|
+
data?: string | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const bufferToFile: (buffer: ArrayBuffer, name?: string | undefined) => Promise<File>;
|
|
12
|
+
export declare const getAudioDuration: (file: File) => Promise<number>;
|
|
13
|
+
export declare function getBase64(image: string): Promise<string>;
|
package/dist/core/functions.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { fileTypeFromBuffer } from "file-type";
|
|
2
|
-
export const getFilesData = (files) => Promise.all(files.map((file) => {
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
const reader = new FileReader();
|
|
5
|
-
reader.onload = () => {
|
|
6
|
-
const base64 = reader.result?.toString().split(",")[1]; // Remove data prefix
|
|
7
|
-
return resolve({
|
|
8
|
-
filename: file.name,
|
|
9
|
-
mimetype: file.type,
|
|
10
|
-
data: base64,
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
reader.onerror = reject;
|
|
14
|
-
reader.readAsDataURL(file);
|
|
15
|
-
});
|
|
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
|
-
});
|
|
30
|
-
async function detectFileExtension(buffer) {
|
|
31
|
-
const type = await fileTypeFromBuffer(buffer);
|
|
32
|
-
if (!type)
|
|
33
|
-
return null;
|
|
34
|
-
return type;
|
|
35
|
-
}
|
|
36
|
-
export const bufferToFile = async (buffer, name) => {
|
|
37
|
-
const type = await detectFileExtension(buffer);
|
|
38
|
-
if (!type)
|
|
39
|
-
throw new Error("Couldn't get type from buffer");
|
|
40
|
-
return new File([buffer], `${name ?? "file"}.${type.ext}`, {
|
|
41
|
-
type: type.mime,
|
|
42
|
-
lastModified: Date.now()
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
export const getAudioDuration = (file) => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
const url = URL.createObjectURL(file);
|
|
48
|
-
const audio = new Audio(url);
|
|
49
|
-
audio.addEventListener("loadedmetadata", () => {
|
|
50
|
-
const durationMs = audio.duration * 1000;
|
|
51
|
-
URL.revokeObjectURL(url);
|
|
52
|
-
resolve(durationMs);
|
|
53
|
-
});
|
|
54
|
-
audio.addEventListener("error", (e) => {
|
|
55
|
-
URL.revokeObjectURL(url);
|
|
56
|
-
reject(new Error("Failed to load audio metadata"));
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
export async function getBase64(image) {
|
|
61
|
-
if (image.startsWith("data:")) {
|
|
62
|
-
return image; // already a base64 data URL
|
|
63
|
-
}
|
|
64
|
-
const res = await fetch(image);
|
|
65
|
-
const blob = await res.blob();
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
const reader = new FileReader();
|
|
68
|
-
reader.onloadend = () => {
|
|
69
|
-
if (typeof reader.result === "string") {
|
|
70
|
-
resolve(reader.result);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
reject(new Error("Failed to read image as base64"));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
reader.onerror = reject;
|
|
77
|
-
reader.readAsDataURL(blob);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
1
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
2
|
+
export const getFilesData = (files) => Promise.all(files.map((file) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const reader = new FileReader();
|
|
5
|
+
reader.onload = () => {
|
|
6
|
+
const base64 = reader.result?.toString().split(",")[1]; // Remove data prefix
|
|
7
|
+
return resolve({
|
|
8
|
+
filename: file.name,
|
|
9
|
+
mimetype: file.type,
|
|
10
|
+
data: base64,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
reader.onerror = reject;
|
|
14
|
+
reader.readAsDataURL(file);
|
|
15
|
+
});
|
|
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
|
+
});
|
|
30
|
+
async function detectFileExtension(buffer) {
|
|
31
|
+
const type = await fileTypeFromBuffer(buffer);
|
|
32
|
+
if (!type)
|
|
33
|
+
return null;
|
|
34
|
+
return type;
|
|
35
|
+
}
|
|
36
|
+
export const bufferToFile = async (buffer, name) => {
|
|
37
|
+
const type = await detectFileExtension(buffer);
|
|
38
|
+
if (!type)
|
|
39
|
+
throw new Error("Couldn't get type from buffer");
|
|
40
|
+
return new File([buffer], `${name ?? "file"}.${type.ext}`, {
|
|
41
|
+
type: type.mime,
|
|
42
|
+
lastModified: Date.now()
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export const getAudioDuration = (file) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const url = URL.createObjectURL(file);
|
|
48
|
+
const audio = new Audio(url);
|
|
49
|
+
audio.addEventListener("loadedmetadata", () => {
|
|
50
|
+
const durationMs = audio.duration * 1000;
|
|
51
|
+
URL.revokeObjectURL(url);
|
|
52
|
+
resolve(durationMs);
|
|
53
|
+
});
|
|
54
|
+
audio.addEventListener("error", (e) => {
|
|
55
|
+
URL.revokeObjectURL(url);
|
|
56
|
+
reject(new Error("Failed to load audio metadata"));
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export async function getBase64(image) {
|
|
61
|
+
if (image.startsWith("data:")) {
|
|
62
|
+
return image; // already a base64 data URL
|
|
63
|
+
}
|
|
64
|
+
const res = await fetch(image);
|
|
65
|
+
const blob = await res.blob();
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const reader = new FileReader();
|
|
68
|
+
reader.onloadend = () => {
|
|
69
|
+
if (typeof reader.result === "string") {
|
|
70
|
+
resolve(reader.result);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
reject(new Error("Failed to read image as base64"));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
reader.onerror = reject;
|
|
77
|
+
reader.readAsDataURL(blob);
|
|
78
|
+
});
|
|
79
|
+
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Common props for React components.
|
|
4
|
-
*
|
|
5
|
-
* @property style - Tailwind class name(s) (optional)
|
|
6
|
-
* @property children - React children nodes (optional)
|
|
7
|
-
**/
|
|
8
|
-
export type Component = {
|
|
9
|
-
style?: string;
|
|
10
|
-
children?: ReactNode;
|
|
11
|
-
};
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Common props for React components.
|
|
4
|
+
*
|
|
5
|
+
* @property style - Tailwind class name(s) (optional)
|
|
6
|
+
* @property children - React children nodes (optional)
|
|
7
|
+
**/
|
|
8
|
+
export declare type Component = {
|
|
9
|
+
style?: string;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
package/dist/core/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
// clean
|
|
1
|
+
export {};
|
|
2
|
+
// clean
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useSound(filename?: string): import("use-sound/dist/types").PlayFunction | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useInterval(action: () => Promise<boolean | void>, delay: number, deps?: unknown[]): void;
|
|
1
|
+
export default function useInterval(action: () => Promise<boolean | void>, delay: number, deps?: unknown[]): void;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
export default function useInterval(action, delay, deps = []) {
|
|
4
|
-
const ref = useRef(async () => false);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
ref.current = action;
|
|
7
|
-
}, [action]);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (deps.some(v => v === undefined || v === null))
|
|
10
|
-
return;
|
|
11
|
-
const tick = async () => {
|
|
12
|
-
const stop = await ref.current();
|
|
13
|
-
if (stop && id)
|
|
14
|
-
clearInterval(id);
|
|
15
|
-
};
|
|
16
|
-
const id = setInterval(tick, delay);
|
|
17
|
-
tick();
|
|
18
|
-
return () => clearInterval(id);
|
|
19
|
-
}, [delay, ...deps]);
|
|
20
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
export default function useInterval(action, delay, deps = []) {
|
|
4
|
+
const ref = useRef(async () => false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
ref.current = action;
|
|
7
|
+
}, [action]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (deps.some(v => v === undefined || v === null))
|
|
10
|
+
return;
|
|
11
|
+
const tick = async () => {
|
|
12
|
+
const stop = await ref.current();
|
|
13
|
+
if (stop && id)
|
|
14
|
+
clearInterval(id);
|
|
15
|
+
};
|
|
16
|
+
const id = setInterval(tick, delay);
|
|
17
|
+
tick();
|
|
18
|
+
return () => clearInterval(id);
|
|
19
|
+
}, [delay, ...deps]);
|
|
20
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export default function useContainer(): {
|
|
3
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
4
|
+
container: HTMLElement | null | undefined;
|
|
5
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
export default function useContainer() {
|
|
4
|
-
const ref = useRef(null);
|
|
5
|
-
const container = ref.current?.parentElement;
|
|
6
|
-
return { ref, container };
|
|
7
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
export default function useContainer() {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
const container = ref.current?.parentElement;
|
|
6
|
+
return { ref, container };
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useResizeObserver(element: HTMLElement | null | undefined, action: () => void): void;
|
|
1
|
+
export default function useResizeObserver(element: HTMLElement | null | undefined, action: () => void): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
export default function useResizeObserver(element, action) {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
if (!element)
|
|
6
|
-
return;
|
|
7
|
-
const observer = new ResizeObserver(action);
|
|
8
|
-
observer.observe(element);
|
|
9
|
-
action();
|
|
10
|
-
return () => observer.disconnect();
|
|
11
|
-
}, [element, action]);
|
|
12
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
export default function useResizeObserver(element, action) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!element)
|
|
6
|
+
return;
|
|
7
|
+
const observer = new ResizeObserver(action);
|
|
8
|
+
observer.observe(element);
|
|
9
|
+
action();
|
|
10
|
+
return () => observer.disconnect();
|
|
11
|
+
}, [element, action]);
|
|
12
|
+
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { default as useContainer } from "./element/container";
|
|
2
|
-
export { default as useResize } from "./element/resize";
|
|
3
|
-
export { default as useInterval } from "./clock/interval";
|
|
1
|
+
export { default as useContainer } from "./element/container";
|
|
2
|
+
export { default as useResize } from "./element/resize";
|
|
3
|
+
export { default as useInterval } from "./clock/interval";
|
|
4
|
+
export { default as useSound } from "./audio/sound";
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { default as useContainer } from "./element/container";
|
|
2
|
-
export { default as useResize } from "./element/resize";
|
|
3
|
-
export { default as useInterval } from "./clock/interval";
|
|
1
|
+
export { default as useContainer } from "./element/container";
|
|
2
|
+
export { default as useResize } from "./element/resize";
|
|
3
|
+
export { default as useInterval } from "./clock/interval";
|
|
4
|
+
export { default as useSound } from "./audio/sound";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { default as Input } from "./components/input";
|
|
2
|
-
export { default as TextArea } from "./components/textarea";
|
|
3
|
-
export { default as Select } from "./components/select";
|
|
4
|
-
export { default as MultipleChoice } from "./components/multiple-choice";
|
|
5
|
-
export { default as Attachment } from "./components/attachment";
|
|
6
|
-
export { default as CheckBox } from "./components/checkbox";
|
|
7
|
-
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
-
export * from "./components";
|
|
9
|
-
export * from "./components/button";
|
|
10
|
-
export * from "./components/search-bar";
|
|
11
|
-
export * from "./core/types";
|
|
12
|
-
export * from "./core/functions";
|
|
13
|
-
export * from "./core/format";
|
|
14
|
-
export * from "./hooks";
|
|
1
|
+
export { default as Input } from "./components/input";
|
|
2
|
+
export { default as TextArea } from "./components/textarea";
|
|
3
|
+
export { default as Select } from "./components/select";
|
|
4
|
+
export { default as MultipleChoice } from "./components/multiple-choice";
|
|
5
|
+
export { default as Attachment } from "./components/attachment";
|
|
6
|
+
export { default as CheckBox } from "./components/checkbox";
|
|
7
|
+
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
+
export * from "./components";
|
|
9
|
+
export * from "./components/button";
|
|
10
|
+
export * from "./components/search-bar";
|
|
11
|
+
export * from "./core/types";
|
|
12
|
+
export * from "./core/functions";
|
|
13
|
+
export * from "./core/format";
|
|
14
|
+
export * from "./hooks";
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { default as Input } from "./components/input";
|
|
2
|
-
export { default as TextArea } from "./components/textarea";
|
|
3
|
-
export { default as Select } from "./components/select";
|
|
4
|
-
export { default as MultipleChoice } from "./components/multiple-choice";
|
|
5
|
-
export { default as Attachment } from "./components/attachment";
|
|
6
|
-
export { default as CheckBox } from "./components/checkbox";
|
|
7
|
-
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
-
export * from "./components";
|
|
9
|
-
export * from "./components/button";
|
|
10
|
-
export * from "./components/search-bar";
|
|
11
|
-
export * from "./core/types";
|
|
12
|
-
export * from "./core/functions";
|
|
13
|
-
export * from "./core/format";
|
|
14
|
-
export * from "./hooks";
|
|
1
|
+
export { default as Input } from "./components/input";
|
|
2
|
+
export { default as TextArea } from "./components/textarea";
|
|
3
|
+
export { default as Select } from "./components/select";
|
|
4
|
+
export { default as MultipleChoice } from "./components/multiple-choice";
|
|
5
|
+
export { default as Attachment } from "./components/attachment";
|
|
6
|
+
export { default as CheckBox } from "./components/checkbox";
|
|
7
|
+
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
+
export * from "./components";
|
|
9
|
+
export * from "./components/button";
|
|
10
|
+
export * from "./components/search-bar";
|
|
11
|
+
export * from "./core/types";
|
|
12
|
+
export * from "./core/functions";
|
|
13
|
+
export * from "./core/format";
|
|
14
|
+
export * from "./hooks";
|
package/package.json
CHANGED
|
@@ -1,66 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/react",
|
|
4
|
-
|
|
5
|
-
"version": "2.3.6",
|
|
6
|
-
|
|
4
|
+
"version": "2.3.8",
|
|
7
5
|
"main": "./dist/index.js",
|
|
8
|
-
|
|
9
6
|
"types": "./dist/index.d.ts",
|
|
10
|
-
|
|
11
7
|
"license": "MIT",
|
|
12
|
-
|
|
13
8
|
"files": [
|
|
14
|
-
|
|
15
9
|
"dist"
|
|
16
|
-
|
|
17
10
|
],
|
|
18
|
-
|
|
19
11
|
"publishConfig": {
|
|
20
|
-
|
|
21
12
|
"access": "public"
|
|
22
|
-
|
|
23
13
|
},
|
|
24
|
-
|
|
25
14
|
"author": "",
|
|
26
|
-
|
|
27
15
|
"description": "",
|
|
28
|
-
|
|
29
16
|
"engines": {},
|
|
30
17
|
|
|
31
18
|
"scripts": {
|
|
32
|
-
|
|
33
19
|
"build": "tsc"
|
|
34
|
-
|
|
35
20
|
},
|
|
36
21
|
|
|
37
22
|
"dependencies": {
|
|
38
|
-
|
|
39
23
|
"@bouko/audio": "^0.1.0",
|
|
40
|
-
|
|
41
24
|
"@bouko/style": "^0.1.7",
|
|
42
|
-
|
|
43
25
|
"clsx": "^2.1.1",
|
|
44
|
-
|
|
45
26
|
"file-type": "^21.0.0",
|
|
46
|
-
|
|
47
27
|
"framer-motion": "^12.23.6",
|
|
48
|
-
|
|
49
28
|
"ms": "^2.1.3",
|
|
50
|
-
|
|
51
29
|
"tailwind-merge": "^3.3.1",
|
|
52
|
-
|
|
53
30
|
"tailwind-variants": "^1.0.0",
|
|
54
|
-
|
|
55
31
|
"zod": "^4.0.13"
|
|
56
|
-
|
|
57
32
|
},
|
|
58
33
|
|
|
59
34
|
"devDependencies": {
|
|
60
|
-
|
|
61
|
-
"dependency-cruiser": "^17.0.1"
|
|
62
|
-
|
|
35
|
+
"@types/react": "^19.1.10",
|
|
36
|
+
"dependency-cruiser": "^17.0.1",
|
|
37
|
+
"react": "^19.1.1"
|
|
63
38
|
}
|
|
64
39
|
|
|
65
|
-
}
|
|
66
|
-
|
|
40
|
+
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-111 111-47-47c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l64 64c9.4 9.4 24.6 9.4 33.9 0L369 209z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M364.2 83.8c-24.4-24.4-64-24.4-88.4 0l-184 184c-42.1 42.1-42.1 110.3 0 152.4s110.3 42.1 152.4 0l152-152c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-152 152c-64 64-167.6 64-231.6 0s-64-167.6 0-231.6l184-184c46.3-46.3 121.3-46.3 167.6 0s46.3 121.3 0 167.6l-176 176c-28.6 28.6-75 28.6-103.6 0s-28.6-75 0-103.6l144-144c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-144 144c-6.7 6.7-6.7 17.7 0 24.4s17.7 6.7 24.4 0l176-176c24.4-24.4 24.4-64 0-88.4z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em" height="1em">
|
|
2
|
-
<path
|
|
3
|
-
d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
|
|
4
|
-
fill="currentColor"
|
|
5
|
-
/>
|
|
6
|
-
</svg>
|
package/dist/components/badge.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export default function Badge({ style, children }) {
|
|
3
|
-
return (_jsx("span", { className: "w-min px-3 py-1 bg-accent/20 border border-accent-dark rounded-full text-xs text-accent-dark font-semibold", children: children }));
|
|
4
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
type Props = Position & {
|
|
3
|
-
style?: string;
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
};
|
|
6
|
-
type Position = {
|
|
7
|
-
center?: boolean;
|
|
8
|
-
centerX?: boolean;
|
|
9
|
-
centerY?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare function ColumnBox({ style, center, centerX, centerY, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare function RowBox({ style, children }: {
|
|
13
|
-
style?: string;
|
|
14
|
-
children: ReactNode;
|
|
15
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export {};
|
package/dist/components/flex.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "@bouko/style";
|
|
3
|
-
export function ColumnBox({ style, center, centerX, centerY, children }) {
|
|
4
|
-
return (_jsx("div", { className: cn("flex flex-col", center && "items-center justify-center", centerX && "items-center", centerY && "justify-center", style), children: children }));
|
|
5
|
-
}
|
|
6
|
-
export function RowBox({ style, children }) {
|
|
7
|
-
return (_jsx("div", { className: cn("flex", style), children: children }));
|
|
8
|
-
}
|