@bouko/react 2.5.5 → 2.5.7
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/assets/icons/check copy.svg +6 -0
- package/dist/assets/icons/check-circle copy.svg +6 -0
- package/dist/assets/icons/chevron copy.svg +6 -0
- package/dist/assets/icons/paperclip copy.svg +6 -0
- package/dist/assets/icons/spinner copy.svg +6 -0
- package/dist/assets/icons/x-circle copy.svg +6 -0
- package/dist/colors/core.d.ts +10 -0
- package/dist/colors/core.js +25 -0
- package/dist/colors/index.d.ts +26 -0
- package/dist/colors/index.js +43 -0
- package/dist/colors/types.d.ts +11 -0
- package/dist/colors/types.js +7 -0
- package/dist/components/animate/configs.d.ts +136 -136
- package/dist/components/animate/configs.js +62 -62
- package/dist/components/animate/index.d.ts +54 -54
- package/dist/components/animate/index.js +33 -33
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +18 -18
- package/dist/components/badge.d.ts +5 -0
- package/dist/components/badge.js +4 -0
- package/dist/components/button/ghost.d.ts +7 -7
- package/dist/components/button/ghost.js +8 -8
- package/dist/components/button/icon.d.ts +9 -0
- package/dist/components/button/icon.js +19 -0
- package/dist/components/button/load.d.ts +10 -11
- package/dist/components/button/load.js +35 -35
- package/dist/components/button/normal.d.ts +11 -11
- package/dist/components/button/normal.js +39 -38
- package/dist/components/button.d.ts +10 -10
- package/dist/components/button.js +22 -22
- package/dist/components/carousel/index.d.ts +11 -11
- package/dist/components/carousel/index.js +19 -19
- 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/flex.d.ts +16 -0
- package/dist/components/flex.js +8 -0
- package/dist/components/form/fields.d.ts +16 -0
- package/dist/components/form/fields.js +21 -0
- package/dist/components/form/footer.js +2 -2
- package/dist/components/form/functions.d.ts +1 -1
- package/dist/components/form/functions.js +28 -28
- package/dist/components/form/loaders.d.ts +3 -0
- package/dist/components/form/loaders.js +11 -0
- package/dist/components/form/test-next.d.ts +1 -0
- package/dist/components/form/test-next.js +6 -0
- 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 +25 -25
- package/dist/components/heading/page.js +23 -23
- package/dist/components/index.d.ts +13 -12
- package/dist/components/index.js +13 -12
- package/dist/components/input.d.ts +37 -37
- package/dist/components/input.js +40 -40
- package/dist/components/layout/fade.d.ts +7 -7
- package/dist/components/layout/fade.js +15 -15
- package/dist/components/layout/flex.d.ts +16 -16
- package/dist/components/layout/flex.js +42 -42
- package/dist/components/layout/heading.d.ts +3 -1
- 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 -12
- package/dist/components/search/index.d.ts +6 -0
- package/dist/components/search/index.js +12 -0
- package/dist/components/search-bar.d.ts +13 -14
- package/dist/components/search-bar.js +22 -22
- package/dist/components/select.d.ts +6 -6
- package/dist/components/select.js +24 -24
- package/dist/components/text/badge.d.ts +16 -16
- package/dist/components/text/badge.js +28 -28
- 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 +23 -23
- package/dist/components/waveform/index.d.ts +8 -8
- package/dist/components/waveform/index.js +11 -11
- package/dist/components/waveform/patterns.d.ts +1 -1
- package/dist/components/waveform/patterns.js +27 -27
- package/dist/core/classes.d.ts +0 -0
- package/dist/core/classes.js +1 -0
- 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 +15 -14
- package/dist/core/types.js +2 -2
- package/dist/core/variants.d.ts +5 -0
- package/dist/core/variants.js +6 -0
- package/dist/format/index.d.ts +2 -0
- package/dist/format/index.js +33 -0
- package/dist/hooks/audio/sound.d.ts +1 -1
- package/dist/hooks/audio/sound.js +6 -6
- package/dist/hooks/clock/interval.d.ts +8 -8
- package/dist/hooks/clock/interval.js +25 -25
- package/dist/hooks/color.d.ts +7 -0
- package/dist/hooks/color.js +8 -0
- package/dist/hooks/element/container.d.ts +4 -5
- 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 -4
- package/dist/hooks/index.js +4 -4
- package/dist/index.d.ts +14 -14
- package/dist/index.js +14 -14
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
style?: string;
|
|
3
|
-
label: string;
|
|
4
|
-
value: boolean;
|
|
5
|
-
update: (x: boolean) => void;
|
|
6
|
-
};
|
|
7
|
-
export default function Checkbox({ style, label, value, update }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
1
|
+
type Props = {
|
|
2
|
+
style?: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: boolean;
|
|
5
|
+
update: (x: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
export default function Checkbox({ style, label, value, update }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Check from "../assets/icons/check.svg";
|
|
3
|
-
import { cn } from "@bouko/style";
|
|
4
|
-
export default function Checkbox({ style, label, value, update }) {
|
|
5
|
-
const isChecked = !!value;
|
|
6
|
-
return (_jsxs("div", { className: cn(styles.container, style), children: [_jsx("div", { className: cn(styles.box, isChecked && "bg-accent"), onClick: () => update(!isChecked), children: isChecked && _jsx(Check, { className: styles.check }
|
|
7
|
-
}
|
|
8
|
-
const styles = {
|
|
9
|
-
container: "flex gap-3 items-center",
|
|
10
|
-
box: "flex justify-center items-center size-4 min-w-4 hover:bg-accent border rounded border-border-light duration-200 cursor-pointer",
|
|
11
|
-
check: "size-2 text-background",
|
|
12
|
-
label: "text-xs text-primary-dark"
|
|
13
|
-
};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Check from "../assets/icons/check.svg";
|
|
3
|
+
import { cn } from "@bouko/style";
|
|
4
|
+
export default function Checkbox({ style, label, value, update }) {
|
|
5
|
+
const isChecked = !!value;
|
|
6
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [_jsx("div", { className: cn(styles.box, isChecked && "bg-accent"), onClick: () => update(!isChecked), children: isChecked && _jsx(Check, { className: styles.check }) }), _jsx("span", { className: styles.label, children: label })] }));
|
|
7
|
+
}
|
|
8
|
+
const styles = {
|
|
9
|
+
container: "flex gap-3 items-center",
|
|
10
|
+
box: "flex justify-center items-center size-4 min-w-4 hover:bg-accent border rounded border-border-light duration-200 cursor-pointer",
|
|
11
|
+
check: "size-2 text-background",
|
|
12
|
+
label: "text-xs text-primary-dark"
|
|
13
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
label: ReactNode;
|
|
4
|
-
action: () => void;
|
|
5
|
-
};
|
|
6
|
-
export default function Dropdown({ options, children }: {
|
|
7
|
-
options: Option[];
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Option = {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
action: () => void;
|
|
5
|
+
};
|
|
6
|
+
export default function Dropdown({ options, children }: {
|
|
7
|
+
options: Option[];
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
-
export default function Dropdown({ options, children }) {
|
|
6
|
-
const [isOpen, setOpen] = useState(false);
|
|
7
|
-
const boom = (action) => {
|
|
8
|
-
action();
|
|
9
|
-
setOpen(false);
|
|
10
|
-
};
|
|
11
|
-
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { onClick: () => setOpen(true), children: children }
|
|
12
|
-
}
|
|
13
|
-
const styles = {
|
|
14
|
-
container: "relative shrink-0",
|
|
15
|
-
subcontainer: "flex flex-col gap-1 w-full",
|
|
16
|
-
label: "text-xs text-slate-600",
|
|
17
|
-
trigger: "flex justify-between items-center px-3 py-2 bg-slate-200/50 hover:bg-slate-200/80 border border-slate-300 outline-blue-500 rounded text-sm duration-200 cursor-pointer",
|
|
18
|
-
dropdown: "absolute mt-2 z-50 flex flex-col items-end justify-end gap-1 w-full bg-slate-950 rounded border border-border-dark p-3 pr-4 text-sm max-h-46 overflow-y-auto"
|
|
19
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
export default function Dropdown({ options, children }) {
|
|
6
|
+
const [isOpen, setOpen] = useState(false);
|
|
7
|
+
const boom = (action) => {
|
|
8
|
+
action();
|
|
9
|
+
setOpen(false);
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { onClick: () => setOpen(true), children: children }), _jsx(AnimatePresence, { children: isOpen && (_jsx(motion.div, { className: styles.dropdown, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: options.map(({ label, action }, i) => (_jsx("div", { className: "cursor-pointer duration-200 hover:brightness-115", onClick: () => boom(action), children: label }, i))) }, "dropdown")) })] }));
|
|
12
|
+
}
|
|
13
|
+
const styles = {
|
|
14
|
+
container: "relative shrink-0",
|
|
15
|
+
subcontainer: "flex flex-col gap-1 w-full",
|
|
16
|
+
label: "text-xs text-slate-600",
|
|
17
|
+
trigger: "flex justify-between items-center px-3 py-2 bg-slate-200/50 hover:bg-slate-200/80 border border-slate-300 outline-blue-500 rounded text-sm duration-200 cursor-pointer",
|
|
18
|
+
dropdown: "absolute mt-2 z-50 flex flex-col items-end justify-end gap-1 w-full bg-slate-950 rounded border border-border-dark p-3 pr-4 text-sm max-h-46 overflow-y-auto"
|
|
19
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
export default function FadeCarousel({ items }: {
|
|
3
|
-
items: ReactNode[];
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export default function FadeCarousel({ items }: {
|
|
3
|
+
items: ReactNode[];
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
-
export default function FadeCarousel({ items }) {
|
|
6
|
-
const [index, setIndex] = useState(0);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const interval = setInterval(() => {
|
|
9
|
-
setIndex((prev) => (prev + 1) % items.length);
|
|
10
|
-
}, 2000);
|
|
11
|
-
return () => clearInterval(interval);
|
|
12
|
-
}, []);
|
|
13
|
-
return (_jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { className: "absolute", transition: { duration: 0.5 }, initial: { opacity: 0, y: 5 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -5 }, children: items[index] }, index) }
|
|
14
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
export default function FadeCarousel({ items }) {
|
|
6
|
+
const [index, setIndex] = useState(0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const interval = setInterval(() => {
|
|
9
|
+
setIndex((prev) => (prev + 1) % items.length);
|
|
10
|
+
}, 2000);
|
|
11
|
+
return () => clearInterval(interval);
|
|
12
|
+
}, []);
|
|
13
|
+
return (_jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { className: "absolute", transition: { duration: 0.5 }, initial: { opacity: 0, y: 5 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -5 }, children: items[index] }, index) }));
|
|
14
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
label?: string;
|
|
4
|
-
style?: string;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
note?: ReactNode;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export default function Field({ style, label, required, note, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
type Props = InputHTMLAttributes<HTMLInputElement> & {
|
|
3
|
+
label?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
note?: ReactNode;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export default function Field({ style, label, required, note, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
package/dist/components/field.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "@bouko/style";
|
|
3
|
-
export default function Field({ style, label, required = true, note, children }) {
|
|
4
|
-
return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }
|
|
5
|
-
}
|
|
6
|
-
const styles = {
|
|
7
|
-
container: "flex flex-col shrink-0 gap-1 w-full overflow-hidden",
|
|
8
|
-
label: "text-xs text-primary-dark",
|
|
9
|
-
note: "mt-1 text-xs text-slate-500 whitespace-pre-line"
|
|
10
|
-
};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@bouko/style";
|
|
3
|
+
export default function Field({ style, label, required = true, note, children }) {
|
|
4
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), children, note && _jsx("span", { className: styles.note, children: note })] }));
|
|
5
|
+
}
|
|
6
|
+
const styles = {
|
|
7
|
+
container: "flex flex-col shrink-0 gap-1 w-full overflow-hidden",
|
|
8
|
+
label: "text-xs text-primary-dark",
|
|
9
|
+
note: "mt-1 text-xs text-slate-500 whitespace-pre-line"
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Field, Option } from "./types";
|
|
2
|
+
export type FormBuilderField<T = unknown> = (Omit<Field<T>, "value" | "update"> & {
|
|
3
|
+
id: string;
|
|
4
|
+
element: string;
|
|
5
|
+
rows?: number;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
options?: Option[];
|
|
8
|
+
})[][];
|
|
9
|
+
type Props<T> = {
|
|
10
|
+
id?: string;
|
|
11
|
+
fields: FormBuilderField<T>;
|
|
12
|
+
data: T;
|
|
13
|
+
setField: (x: string, y: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
export default function Fields<T>({ fields, data, setField }: Props<T>): Promise<import("react/jsx-runtime").JSX.Element[]>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RowBox } from "../layout/flex";
|
|
3
|
+
import Input from "../input";
|
|
4
|
+
import Select from "../select";
|
|
5
|
+
import TextArea from "../textarea";
|
|
6
|
+
import MultipleChoice from "../multiple-choice";
|
|
7
|
+
import Attachment from "../attachment";
|
|
8
|
+
export default async function Fields({ fields, data, setField }) {
|
|
9
|
+
return fields.map((row, i) => (_jsx(RowBox, { style: "w-full gap-5 overflow-hidden", children: row.map(({ element, id, rows, label, placeholder, disabled, options, required, note }) => {
|
|
10
|
+
if (element === "input")
|
|
11
|
+
return (_jsx(Input, { id: id, styles: { container: "flex-1" }, label: label, placeholder: placeholder, value: data[id], update: x => setField(id, x), disabled: disabled, note: note, required: required }, id));
|
|
12
|
+
else if (element === "select")
|
|
13
|
+
return (_jsx(Select, { id: id, label: label, placeholder: placeholder, options: options || [], value: data[id], update: x => setField(id, x), note: note, required: required }, id));
|
|
14
|
+
else if (element === "textarea")
|
|
15
|
+
return (_jsx(TextArea, { id: id, label: label, placeholder: placeholder, rows: rows, value: data[id], update: x => setField(id, x), note: note, required: required }, id));
|
|
16
|
+
else if (element === "multiple-choice")
|
|
17
|
+
return (_jsx(MultipleChoice, { id: id, label: label, options: options || [], value: data[id], update: x => setField(id, x), note: note, required: required }, id));
|
|
18
|
+
else if (element === "attachment")
|
|
19
|
+
return (_jsx(Attachment, { id: id, label: label, value: data[id], update: x => setField(id, x), note: note, required: required }, id));
|
|
20
|
+
}) }, i)));
|
|
21
|
+
}
|
|
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Button } from "../button";
|
|
5
5
|
import { RowBox } from "../layout/flex";
|
|
6
|
-
import CheckCircle from "
|
|
7
|
-
import Spinner from "
|
|
6
|
+
import CheckCircle from "../../assets/icons/check-circle.svg";
|
|
7
|
+
import Spinner from "../../assets/icons/spinner.svg";
|
|
8
8
|
export default function FormFooter({ data, validator, submit, clear }) {
|
|
9
9
|
const isValid = validator.safeParse(data).success;
|
|
10
10
|
const [isLoading, setLoading] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const parseData: <T extends Record<string, unknown>>(data: T) => T;
|
|
1
|
+
export declare const parseData: <T extends Record<string, unknown>>(data: T) => T;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export const parseData = (data) => {
|
|
2
|
-
const copy = JSON.parse(JSON.stringify(data));
|
|
3
|
-
for (const [key, value] of Object.entries(data)) {
|
|
4
|
-
if (key === "created_at")
|
|
5
|
-
copy[key] = new Date(value);
|
|
6
|
-
else if (key === "timestamp")
|
|
7
|
-
copy[key] = new Date(value.replaceAll("'", ""));
|
|
8
|
-
else if (parseAllowedDate(value))
|
|
9
|
-
copy[key] = new Date(value);
|
|
10
|
-
}
|
|
11
|
-
return copy;
|
|
12
|
-
};
|
|
13
|
-
function parseAllowedDate(input) {
|
|
14
|
-
// ISO 8601 strict (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss+hh:mm)
|
|
15
|
-
const isoStrictRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2}))?$/;
|
|
16
|
-
// MySQL/Postgres style with space + offset without colon (YYYY-MM-DD HH:mm:ss+hhmm)
|
|
17
|
-
const spaceOffsetRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{4}$/;
|
|
18
|
-
let normalized = input;
|
|
19
|
-
if (spaceOffsetRegex.test(input)) {
|
|
20
|
-
// Convert to ISO by replacing space with T and adding colon in offset
|
|
21
|
-
normalized = input.replace(" ", "T").replace(/([+-]\d{2})(\d{2})$/, "$1:$2");
|
|
22
|
-
}
|
|
23
|
-
else if (!isoStrictRegex.test(input)) {
|
|
24
|
-
return null; // Not allowed format
|
|
25
|
-
}
|
|
26
|
-
const date = new Date(normalized);
|
|
27
|
-
return !isNaN(date.getTime()) ? date : null;
|
|
28
|
-
}
|
|
1
|
+
export const parseData = (data) => {
|
|
2
|
+
const copy = JSON.parse(JSON.stringify(data));
|
|
3
|
+
for (const [key, value] of Object.entries(data)) {
|
|
4
|
+
if (key === "created_at")
|
|
5
|
+
copy[key] = new Date(value);
|
|
6
|
+
else if (key === "timestamp")
|
|
7
|
+
copy[key] = new Date(value.replaceAll("'", ""));
|
|
8
|
+
else if (parseAllowedDate(value))
|
|
9
|
+
copy[key] = new Date(value);
|
|
10
|
+
}
|
|
11
|
+
return copy;
|
|
12
|
+
};
|
|
13
|
+
function parseAllowedDate(input) {
|
|
14
|
+
// ISO 8601 strict (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss+hh:mm)
|
|
15
|
+
const isoStrictRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2}))?$/;
|
|
16
|
+
// MySQL/Postgres style with space + offset without colon (YYYY-MM-DD HH:mm:ss+hhmm)
|
|
17
|
+
const spaceOffsetRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{4}$/;
|
|
18
|
+
let normalized = input;
|
|
19
|
+
if (spaceOffsetRegex.test(input)) {
|
|
20
|
+
// Convert to ISO by replacing space with T and adding colon in offset
|
|
21
|
+
normalized = input.replace(" ", "T").replace(/([+-]\d{2})(\d{2})$/, "$1:$2");
|
|
22
|
+
}
|
|
23
|
+
else if (!isoStrictRegex.test(input)) {
|
|
24
|
+
return null; // Not allowed format
|
|
25
|
+
}
|
|
26
|
+
const date = new Date(normalized);
|
|
27
|
+
return !isNaN(date.getTime()) ? date : null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
export async function loadJson(name) {
|
|
4
|
+
const file = await fs.readFile(process.cwd() + "/assets/" + name + ".json", "utf-8");
|
|
5
|
+
return JSON.parse(file);
|
|
6
|
+
}
|
|
7
|
+
export async function loadForm(name) {
|
|
8
|
+
if (!name)
|
|
9
|
+
throw new Error("Form not found");
|
|
10
|
+
return loadJson(`forms/${name}`);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadJson<T>(name: string): Promise<T>;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { ReactNode, Dispatch, SetStateAction } from "react";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
data: T;
|
|
5
|
-
update: SetState<T>;
|
|
6
|
-
setField: (x: string, value: unknown) => void;
|
|
7
|
-
clear: () => void;
|
|
8
|
-
};
|
|
9
|
-
export
|
|
10
|
-
id: string;
|
|
11
|
-
element: string;
|
|
12
|
-
rows?: number;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
options?: Option[];
|
|
15
|
-
})[][];
|
|
16
|
-
export
|
|
17
|
-
id?: string;
|
|
18
|
-
label?: string;
|
|
19
|
-
style?: string;
|
|
20
|
-
value?: K;
|
|
21
|
-
update: SetState<T>;
|
|
22
|
-
required?: boolean;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
note?: ReactNode;
|
|
25
|
-
};
|
|
26
|
-
export
|
|
27
|
-
id: string;
|
|
28
|
-
label?: string;
|
|
29
|
-
active?: boolean;
|
|
30
|
-
select?: () => void;
|
|
31
|
-
};
|
|
32
|
-
export
|
|
33
|
-
options: Option[];
|
|
34
|
-
};
|
|
35
|
-
export
|
|
36
|
-
data: T;
|
|
37
|
-
};
|
|
38
|
-
export
|
|
1
|
+
import type { ReactNode, Dispatch, SetStateAction } from "react";
|
|
2
|
+
export type SetState<T> = Dispatch<SetStateAction<T>>;
|
|
3
|
+
export type FormSection<T> = {
|
|
4
|
+
data: T;
|
|
5
|
+
update: SetState<T>;
|
|
6
|
+
setField: (x: string, value: unknown) => void;
|
|
7
|
+
clear: () => void;
|
|
8
|
+
};
|
|
9
|
+
export type FormBuilderField<T = unknown> = (Omit<Field<T>, "value" | "update"> & {
|
|
10
|
+
id: string;
|
|
11
|
+
element: string;
|
|
12
|
+
rows?: number;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
options?: Option[];
|
|
15
|
+
})[][];
|
|
16
|
+
export type Field<T, K = string> = {
|
|
17
|
+
id?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
style?: string;
|
|
20
|
+
value?: K;
|
|
21
|
+
update: SetState<T>;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
note?: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
export type Option = {
|
|
27
|
+
id: string;
|
|
28
|
+
label?: string;
|
|
29
|
+
active?: boolean;
|
|
30
|
+
select?: () => void;
|
|
31
|
+
};
|
|
32
|
+
export type OptionField<T> = Field<T> & {
|
|
33
|
+
options: Option[];
|
|
34
|
+
};
|
|
35
|
+
export type Form<T> = {
|
|
36
|
+
data: T;
|
|
37
|
+
};
|
|
38
|
+
export type FormSubmit<T> = (data: T, clear?: () => void) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
badge?: string;
|
|
4
|
-
title: ReactNode;
|
|
5
|
-
subtitle?: ReactNode;
|
|
6
|
-
style?: Styles;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
container?: string;
|
|
10
|
-
badge?: string;
|
|
11
|
-
title?: string;
|
|
12
|
-
subtitle?: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Text heading with badge, title, subtitle.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} badge - Little note above the title (optional).
|
|
18
|
-
* @param {ReactNode} title - Main title content.
|
|
19
|
-
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
20
|
-
* @param {Styles} style - Additional styles (optional).
|
|
21
|
-
**/
|
|
22
|
-
export default function Heading({ badge, title, subtitle, style }: Props): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export {};
|
|
24
|
-
/**
|
|
25
|
-
* Problems
|
|
26
|
-
*
|
|
27
|
-
* - Perfect `Badge`
|
|
28
|
-
* - Long `subtitle` style
|
|
29
|
-
**/
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
badge?: string;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
subtitle?: ReactNode;
|
|
6
|
+
style?: Styles;
|
|
7
|
+
};
|
|
8
|
+
type Styles = {
|
|
9
|
+
container?: string;
|
|
10
|
+
badge?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Text heading with badge, title, subtitle.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} badge - Little note above the title (optional).
|
|
18
|
+
* @param {ReactNode} title - Main title content.
|
|
19
|
+
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
20
|
+
* @param {Styles} style - Additional styles (optional).
|
|
21
|
+
**/
|
|
22
|
+
export default function Heading({ badge, title, subtitle, style }: Props): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
/**
|
|
25
|
+
* Problems
|
|
26
|
+
*
|
|
27
|
+
* - Perfect `Badge`
|
|
28
|
+
* - Long `subtitle` style
|
|
29
|
+
**/
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { mergeStyles } from "@bouko/style";
|
|
3
|
-
import { RowBox, ColumnBox } from "../layout/flex";
|
|
4
|
-
import { Badge } from "../text/badge";
|
|
5
|
-
/**
|
|
6
|
-
* Text heading with badge, title, subtitle.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} badge - Little note above the title (optional).
|
|
9
|
-
* @param {ReactNode} title - Main title content.
|
|
10
|
-
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
11
|
-
* @param {Styles} style - Additional styles (optional).
|
|
12
|
-
**/
|
|
13
|
-
export default function Heading({ badge, title, subtitle, style = {} }) {
|
|
14
|
-
const styles = mergeStyles(base, style);
|
|
15
|
-
return (_jsxs(ColumnBox, { style: styles.container, children: [_jsx(Badge, { style: styles.badge, children: badge }
|
|
16
|
-
}
|
|
17
|
-
const base = {
|
|
18
|
-
container: "items-center",
|
|
19
|
-
badge: "mb-2",
|
|
20
|
-
title: "items-center gap-2 text-xl sm:text-2xl 2xl:text-3xl font-bold text-primary",
|
|
21
|
-
subtitle: "items-center gap-2 max-sm:text-sm 2xl:text-lg text-center text-primary-light dark:text-primary-dark"
|
|
22
|
-
};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { mergeStyles } from "@bouko/style";
|
|
3
|
+
import { RowBox, ColumnBox } from "../layout/flex";
|
|
4
|
+
import { Badge } from "../text/badge";
|
|
5
|
+
/**
|
|
6
|
+
* Text heading with badge, title, subtitle.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} badge - Little note above the title (optional).
|
|
9
|
+
* @param {ReactNode} title - Main title content.
|
|
10
|
+
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
11
|
+
* @param {Styles} style - Additional styles (optional).
|
|
12
|
+
**/
|
|
13
|
+
export default function Heading({ badge, title, subtitle, style = {} }) {
|
|
14
|
+
const styles = mergeStyles(base, style);
|
|
15
|
+
return (_jsxs(ColumnBox, { style: styles.container, children: [_jsx(Badge, { style: styles.badge, children: badge }), _jsx(RowBox, { style: styles.title, children: title }), _jsx(RowBox, { style: styles.subtitle, children: subtitle })] }));
|
|
16
|
+
}
|
|
17
|
+
const base = {
|
|
18
|
+
container: "items-center",
|
|
19
|
+
badge: "mb-2",
|
|
20
|
+
title: "items-center gap-2 text-xl sm:text-2xl 2xl:text-3xl font-bold text-primary",
|
|
21
|
+
subtitle: "items-center gap-2 max-sm:text-sm 2xl:text-lg text-center text-primary-light dark:text-primary-dark"
|
|
22
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
style?: Styles;
|
|
4
|
-
badge?: string;
|
|
5
|
-
icon?: ReactNode;
|
|
6
|
-
title: string;
|
|
7
|
-
subtitle?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
container?: string;
|
|
11
|
-
badge?: string;
|
|
12
|
-
title?: string;
|
|
13
|
-
subtitle?: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Text heading with badge, title, subtitle.
|
|
17
|
-
*
|
|
18
|
-
* @param {Styles} style - Additional styles. (optional)
|
|
19
|
-
* @param {string} badge - Little note above the title. (optional)
|
|
20
|
-
* @param {ReactNode} icon - Component displayed left of title. (optional)
|
|
21
|
-
* @param {string} title - Main title content.
|
|
22
|
-
* @param {string} subtitle - Subtitle content. (optional)
|
|
23
|
-
**/
|
|
24
|
-
export default function PageHeading({ style, badge, icon, title, subtitle }: Props): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export {};
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
style?: Styles;
|
|
4
|
+
badge?: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
title: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
};
|
|
9
|
+
type Styles = {
|
|
10
|
+
container?: string;
|
|
11
|
+
badge?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Text heading with badge, title, subtitle.
|
|
17
|
+
*
|
|
18
|
+
* @param {Styles} style - Additional styles. (optional)
|
|
19
|
+
* @param {string} badge - Little note above the title. (optional)
|
|
20
|
+
* @param {ReactNode} icon - Component displayed left of title. (optional)
|
|
21
|
+
* @param {string} title - Main title content.
|
|
22
|
+
* @param {string} subtitle - Subtitle content. (optional)
|
|
23
|
+
**/
|
|
24
|
+
export default function PageHeading({ style, badge, icon, title, subtitle }: Props): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|