@bouku/core 0.0.1 → 0.0.2
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/button/_.d.ts +2 -0
- package/dist/components/button/_.js +10 -0
- package/dist/components/button/copy.d.ts +6 -0
- package/dist/components/button/copy.js +16 -0
- package/dist/components/button/normal.d.ts +11 -0
- package/dist/components/button/normal.js +48 -0
- package/dist/components/date/_.d.ts +1 -0
- package/dist/components/date/_.js +8 -0
- package/dist/components/date/time-ago.d.ts +7 -0
- package/dist/components/date/time-ago.js +13 -0
- package/dist/components/dropdown/normal.d.ts +10 -0
- package/dist/components/dropdown/normal.js +22 -0
- package/dist/components/fade/_.d.ts +1 -0
- package/dist/components/fade/_.js +8 -0
- package/dist/components/fade/circle.d.ts +10 -0
- package/dist/components/fade/circle.js +8 -0
- package/dist/components/heading/_.d.ts +2 -0
- package/dist/components/heading/_.js +10 -0
- package/dist/components/heading/normal.d.ts +24 -0
- package/dist/components/heading/normal.js +26 -0
- package/dist/components/heading/page.d.ts +25 -0
- package/dist/components/heading/page.js +26 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.js +45 -0
- package/dist/components/information/_.d.ts +1 -0
- package/dist/components/information/_.js +8 -0
- package/dist/components/information/card.d.ts +7 -0
- package/dist/components/information/card.js +20 -0
- package/dist/components/layout/_.d.ts +2 -0
- package/dist/components/layout/_.js +10 -0
- package/dist/components/layout/absolute.d.ts +9 -0
- package/dist/components/layout/absolute.js +12 -0
- package/dist/components/layout/fade.d.ts +7 -0
- package/dist/components/layout/fade.js +20 -0
- package/dist/components/layout/flex.d.ts +17 -0
- package/dist/components/layout/flex.js +49 -0
- package/dist/components/layout/footer.d.ts +15 -0
- package/dist/components/layout/footer.js +13 -0
- package/dist/components/layout/media-row.d.ts +15 -0
- package/dist/components/layout/media-row.js +11 -0
- package/dist/components/layout/rnd.d.ts +10 -0
- package/dist/components/layout/rnd.js +32 -0
- package/dist/components/layout/scroll-box.d.ts +14 -0
- package/dist/components/layout/scroll-box.js +11 -0
- package/dist/components/layout/section.d.ts +15 -0
- package/dist/components/layout/section.js +19 -0
- package/dist/components/layout/separator.d.ts +3 -0
- package/dist/components/layout/separator.js +8 -0
- package/dist/components/link/_.d.ts +1 -0
- package/dist/components/link/_.js +8 -0
- package/dist/components/link/tab.d.ts +22 -0
- package/dist/components/link/tab.js +30 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/list/index.js +10 -0
- package/dist/components/list/item.d.ts +9 -0
- package/dist/components/list/item.js +9 -0
- package/dist/components/list/search-bar.d.ts +14 -0
- package/dist/components/list/search-bar.js +33 -0
- package/dist/components/list/variants/bullet.d.ts +9 -0
- package/dist/components/list/variants/bullet.js +21 -0
- package/dist/components/list/variants/number.d.ts +10 -0
- package/dist/components/list/variants/number.js +23 -0
- package/dist/components/pagination/index.d.ts +9 -0
- package/dist/components/pagination/index.js +21 -0
- package/dist/components/progress/_.d.ts +1 -0
- package/dist/components/progress/_.js +8 -0
- package/dist/components/progress/bar.d.ts +4 -0
- package/dist/components/progress/bar.js +12 -0
- package/dist/components/table/_.d.ts +1 -0
- package/dist/components/table/_.js +8 -0
- package/dist/components/table/normal.d.ts +7 -0
- package/dist/components/table/normal.js +20 -0
- package/dist/components/text/_.d.ts +2 -0
- package/dist/components/text/_.js +10 -0
- package/dist/components/text/badge.d.ts +18 -0
- package/dist/components/text/badge.js +42 -0
- package/dist/components/text/input.d.ts +39 -0
- package/dist/components/text/input.js +50 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -1
- package/package.json +2 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MediaRow = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const flex_1 = require("./flex");
|
|
9
|
+
const badge_1 = __importDefault(require("../text/badge"));
|
|
10
|
+
const MediaRow = ({ media, title, subtitle, badge, styles = {}, }) => ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: `items-center gap-3 ${styles.container ?? ""}`, children: [(0, jsx_runtime_1.jsx)("img", { src: media, className: "size-10 w-10 h-10 border border-border rounded", alt: title }), (0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: "gap-px min-w-0", children: [(0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: "items-center gap-2 min-w-0", children: [(0, jsx_runtime_1.jsx)("span", { className: `text-primary text-sm font-semibold truncate ${styles.title ?? ""}`, children: title }), badge && (0, jsx_runtime_1.jsx)(badge_1.default, { size: "xs", children: badge })] }), subtitle && ((0, jsx_runtime_1.jsx)("span", { className: `text-xs text-primary-dark ${styles.subtitle}`, children: subtitle }))] })] }));
|
|
11
|
+
exports.MediaRow = MediaRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
style?: string;
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
minWidth?: number;
|
|
6
|
+
update: (min: number, size: number) => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export default function RnD({ style, min, max, minWidth, update, children }: Props): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = RnD;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_rnd_1 = require("react-rnd");
|
|
7
|
+
const style_1 = require("@bouko/style");
|
|
8
|
+
function RnD({ style, min, max, minWidth, update, children }) {
|
|
9
|
+
const gapSize = max - min;
|
|
10
|
+
const handleResize = (x, width) => {
|
|
11
|
+
update(x, width);
|
|
12
|
+
};
|
|
13
|
+
const handleDrag = (x) => {
|
|
14
|
+
update(x, gapSize);
|
|
15
|
+
};
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(react_rnd_1.Rnd, { ...opts(min, max, minWidth), className: (0, style_1.cn)("flex! justify-center items-center overflow-hidden", style), size: { width: gapSize, height: "100%" }, position: { x: min, y: 0 }, onResize: (e, dir, ref, d, pos) => handleResize(pos.x, ref.offsetWidth), onDragStop: (e, d) => handleDrag(d.x), children: children }));
|
|
17
|
+
}
|
|
18
|
+
const opts = (min, max, minWidth) => ({
|
|
19
|
+
bounds: "parent",
|
|
20
|
+
axis: "x",
|
|
21
|
+
minWidth: minWidth || 30,
|
|
22
|
+
default: {
|
|
23
|
+
x: min,
|
|
24
|
+
y: 0,
|
|
25
|
+
width: max - min,
|
|
26
|
+
height: "100%"
|
|
27
|
+
},
|
|
28
|
+
enableResizing: {
|
|
29
|
+
left: true,
|
|
30
|
+
right: true
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from "react";
|
|
2
|
+
type RowProps<T> = {
|
|
3
|
+
data: T;
|
|
4
|
+
hovered: boolean;
|
|
5
|
+
setHovered: Dispatch<SetStateAction<number | null>>;
|
|
6
|
+
index: number;
|
|
7
|
+
};
|
|
8
|
+
type Props<T> = {
|
|
9
|
+
style?: string;
|
|
10
|
+
items: T[];
|
|
11
|
+
element: React.ComponentType<RowProps<T>>;
|
|
12
|
+
};
|
|
13
|
+
export declare function ScrollBox<T>({ style, items, element: Row }: Props<T>): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScrollBox = ScrollBox;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const style_1 = require("@bouko/style");
|
|
7
|
+
const flex_1 = require("./flex");
|
|
8
|
+
function ScrollBox({ style, items, element: Row }) {
|
|
9
|
+
const [hoveredIndex, setHoveredIndex] = (0, react_1.useState)(null);
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(flex_1.ColumnBox, { style: (0, style_1.cn)("grow gap-1 w-full overflow-y-auto", style), children: items.map((x, i) => ((0, jsx_runtime_1.jsx)(Row, { data: x, hovered: hoveredIndex === i, setHovered: setHoveredIndex, index: i }, i))) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Settings Section Component.
|
|
4
|
+
*
|
|
5
|
+
* Generic layout wrapper used to group related settings or content
|
|
6
|
+
* under a titled section with a visual separator for consistency.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} title - The section title displayed at top.
|
|
9
|
+
* @param {ReactNode} content - Rendered below the separator.
|
|
10
|
+
**/
|
|
11
|
+
declare const Section: ({ title, content }: {
|
|
12
|
+
title: string;
|
|
13
|
+
content: ReactNode;
|
|
14
|
+
}) => import("react").JSX.Element;
|
|
15
|
+
export default Section;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const flex_1 = require("./flex");
|
|
5
|
+
/**
|
|
6
|
+
* Settings Section Component.
|
|
7
|
+
*
|
|
8
|
+
* Generic layout wrapper used to group related settings or content
|
|
9
|
+
* under a titled section with a visual separator for consistency.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} title - The section title displayed at top.
|
|
12
|
+
* @param {ReactNode} content - Rendered below the separator.
|
|
13
|
+
**/
|
|
14
|
+
const Section = ({ title, content }) => ((0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: styles.container, children: [title, (0, jsx_runtime_1.jsx)("hr", { className: styles.separator }), content] }));
|
|
15
|
+
const styles = {
|
|
16
|
+
container: "gap-2 items-start text-primary",
|
|
17
|
+
separator: "mb-2 w-full text-border-dark"
|
|
18
|
+
};
|
|
19
|
+
exports.default = Section;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Separator;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const style_1 = require("@bouko/style");
|
|
6
|
+
function Separator({ style }) {
|
|
7
|
+
return (0, jsx_runtime_1.jsx)("hr", { className: (0, style_1.cn)("w-full text-border-dark", style) });
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NavTab } from "./tab";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NavTab = void 0;
|
|
7
|
+
var tab_1 = require("./tab");
|
|
8
|
+
Object.defineProperty(exports, "NavTab", { enumerable: true, get: function () { return __importDefault(tab_1).default; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab Navigation Component.
|
|
3
|
+
*
|
|
4
|
+
* A `TabItem` wrapper that integrates with React Router.
|
|
5
|
+
* Derives active state from the current URL and renders a
|
|
6
|
+
* navigable tab using a router `<Link>`.
|
|
7
|
+
*
|
|
8
|
+
* Behavior:
|
|
9
|
+
* - Builds a route from the provided `id` (/[id]).
|
|
10
|
+
* - Marks tab as active when the pathname includes that route.
|
|
11
|
+
* - Delegates all visual rendering to `TabItem`.
|
|
12
|
+
* - Nested routes keep the parent tab active.
|
|
13
|
+
*
|
|
14
|
+
* @param id - Route identifier used to construct the URL.
|
|
15
|
+
* @param props - Remaining `NavItem` props forwarded to `TabItem`.
|
|
16
|
+
**/
|
|
17
|
+
declare const NavTab: ({ id, ...props }: Omit<NavItem, "isActive">) => import("react").JSX.Element;
|
|
18
|
+
type NavItem = {
|
|
19
|
+
id: string;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
};
|
|
22
|
+
export default NavTab;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
5
|
+
/**
|
|
6
|
+
* Tab Navigation Component.
|
|
7
|
+
*
|
|
8
|
+
* A `TabItem` wrapper that integrates with React Router.
|
|
9
|
+
* Derives active state from the current URL and renders a
|
|
10
|
+
* navigable tab using a router `<Link>`.
|
|
11
|
+
*
|
|
12
|
+
* Behavior:
|
|
13
|
+
* - Builds a route from the provided `id` (/[id]).
|
|
14
|
+
* - Marks tab as active when the pathname includes that route.
|
|
15
|
+
* - Delegates all visual rendering to `TabItem`.
|
|
16
|
+
* - Nested routes keep the parent tab active.
|
|
17
|
+
*
|
|
18
|
+
* @param id - Route identifier used to construct the URL.
|
|
19
|
+
* @param props - Remaining `NavItem` props forwarded to `TabItem`.
|
|
20
|
+
**/
|
|
21
|
+
const NavTab = ({ id, ...props }) => {
|
|
22
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
23
|
+
const route = "/" + id;
|
|
24
|
+
const isActive = location.pathname.includes(route);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: route, children: (0, jsx_runtime_1.jsx)(Base, { isActive: isActive, ...props }) }));
|
|
26
|
+
};
|
|
27
|
+
function Base({ isActive }) {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: isActive }));
|
|
29
|
+
}
|
|
30
|
+
exports.default = NavTab;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NumberList = exports.BulletList = void 0;
|
|
7
|
+
var bullet_1 = require("./variants/bullet");
|
|
8
|
+
Object.defineProperty(exports, "BulletList", { enumerable: true, get: function () { return __importDefault(bullet_1).default; } });
|
|
9
|
+
var number_1 = require("./variants/number");
|
|
10
|
+
Object.defineProperty(exports, "NumberList", { enumerable: true, get: function () { return __importDefault(number_1).default; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
marker: ReactNode;
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
index: number;
|
|
6
|
+
centerMarker?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function Item({ marker, content, centerMarker, index }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Item;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const style_1 = require("@bouko/style");
|
|
6
|
+
;
|
|
7
|
+
function Item({ marker, content, centerMarker, index }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)("flex items-start text-sm", centerMarker && "items-center"), children: [marker, content] }, index));
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Props<T> = {
|
|
2
|
+
style?: Styles;
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
trigger?: React.ReactNode;
|
|
5
|
+
submit: (query: string) => void;
|
|
6
|
+
oops?: (x: string) => void;
|
|
7
|
+
};
|
|
8
|
+
type Styles = {
|
|
9
|
+
container?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
trigger?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function SearchBar<T>({ style, placeholder, trigger, submit, oops }: Props<T>): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SearchBar = SearchBar;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const input_1 = __importDefault(require("../text/input"));
|
|
11
|
+
const fade_1 = __importDefault(require("../layout/fade"));
|
|
12
|
+
const flex_1 = require("../layout/flex");
|
|
13
|
+
const normal_1 = __importDefault(require("../button/normal"));
|
|
14
|
+
const style_1 = require("@bouko/style");
|
|
15
|
+
function SearchBar({ style = {}, placeholder, trigger, submit, oops = console.log }) {
|
|
16
|
+
const [query, setQuery] = (0, react_1.useState)("");
|
|
17
|
+
const styles = (0, style_1.mergeStyles)(base, style);
|
|
18
|
+
const search = async () => {
|
|
19
|
+
if (query === "")
|
|
20
|
+
return;
|
|
21
|
+
try {
|
|
22
|
+
await submit(query);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
oops(err.message);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: styles.container, children: [(0, jsx_runtime_1.jsx)(fade_1.default, { style: "grow", gradient: "from-slate-950", children: (0, jsx_runtime_1.jsx)(input_1.default, { variant: "ghost", style: styles.input, placeholder: placeholder, value: query, update: setQuery, onEnter: search }) }), trigger && ((0, jsx_runtime_1.jsx)(normal_1.default, { variant: "ghost", style: style?.trigger, action: search, disabled: query === "", children: trigger }))] }));
|
|
29
|
+
}
|
|
30
|
+
const base = {
|
|
31
|
+
container: "items-center gap-3 sm:gap-5 w-xl max-w-full pl-4 sm:pl-5 pr-2 sm:pr-4 py-2 sm:py-3 bg-slate-950 border border-border rounded-md",
|
|
32
|
+
input: "text-base sm:text-lg tracking-wide"
|
|
33
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
style?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
items: ReactNode[];
|
|
6
|
+
centerMarker?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function BulletList({ style, title, items, centerMarker }: Props): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = BulletList;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const item_1 = __importDefault(require("../item"));
|
|
10
|
+
const style_1 = require("@bouko/style");
|
|
11
|
+
;
|
|
12
|
+
function BulletList({ style, title, items, centerMarker }) {
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)(styles.base, style), children: [!!title && (0, jsx_runtime_1.jsx)("span", { className: styles.title, children: title }), (0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles.base, style, !!title && "ml-2"), children: items.map((x, i) => ((0, jsx_runtime_1.jsx)(item_1.default, { marker: (0, jsx_runtime_1.jsx)(Marker, {}), content: x, index: i, centerMarker: centerMarker }, i))) })] }, title));
|
|
14
|
+
}
|
|
15
|
+
function Marker() {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: "mr-3 text-accent", children: "\u2022" }));
|
|
17
|
+
}
|
|
18
|
+
const styles = {
|
|
19
|
+
base: "flex flex-col gap-1 w-full",
|
|
20
|
+
title: "mb-1 text-base"
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
style?: string;
|
|
4
|
+
marker?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
items: ReactNode[];
|
|
7
|
+
centerMarker?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default function NumberList({ style, marker, title, items, centerMarker }: Props): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = NumberList;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const item_1 = __importDefault(require("../item"));
|
|
10
|
+
const style_1 = require("@bouko/style");
|
|
11
|
+
;
|
|
12
|
+
function NumberList({ style, marker, title, items, centerMarker }) {
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)(styles.base, style), children: [!!title && (0, jsx_runtime_1.jsx)("span", { className: styles.title, children: title }), (0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles.base, style, !!title && "ml-2"), children: items.map((x, i) => ((0, jsx_runtime_1.jsx)(item_1.default, { marker: (0, jsx_runtime_1.jsx)(Marker, { style: marker, x: i + 1 }), content: x, index: i, centerMarker: centerMarker }, i))) }, "content")] }, "list"));
|
|
14
|
+
}
|
|
15
|
+
function Marker({ style, x }) {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles.marker, style), children: (0, jsx_runtime_1.jsx)("span", { className: styles.label, children: x }) }));
|
|
17
|
+
}
|
|
18
|
+
const styles = {
|
|
19
|
+
base: "flex flex-col gap-6 w-full text-primary-dark",
|
|
20
|
+
title: "mb-1 text-base text-primary",
|
|
21
|
+
marker: "flex justify-center items-center mt-1 mr-6 min-w-7 w-7 aspect-square bg-radial-[at_50%_75%] from-accent-light to-accent to-accent-dark to-90% border border-accent-darker rounded-full shadow-glow-soft",
|
|
22
|
+
label: "font-bold text-background-lighter select-none"
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = Pagination;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const chevron_left_svg_1 = __importDefault(require("../../assets/icons/chevron-left.svg"));
|
|
9
|
+
const chevron_right_svg_1 = __importDefault(require("../../assets/icons/chevron-right.svg"));
|
|
10
|
+
const flex_1 = require("../layout/flex");
|
|
11
|
+
const normal_1 = require("../button/normal");
|
|
12
|
+
const style_1 = require("@bouko/style");
|
|
13
|
+
function Pagination({ style, page, prev, next, totalPages = 99 }) {
|
|
14
|
+
const canPrev = page > 1;
|
|
15
|
+
const canNext = totalPages > 0 ? page < totalPages : true;
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: (0, style_1.cn)(s.container, style), children: [(0, jsx_runtime_1.jsx)(normal_1.Button, { size: "xs", style: "rounded-none rounded-l-sm", action: prev, disabled: !canPrev, children: (0, jsx_runtime_1.jsx)(chevron_left_svg_1.default, {}) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-px justify-center items-center w-11 h-6 px-2 bg-border-dark/20 border-y border-border-dark text-xs font-medium", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-primary", children: page }), "/", (0, jsx_runtime_1.jsx)("span", { className: "text-primary-darker", children: totalPages || 99 })] }), (0, jsx_runtime_1.jsx)(normal_1.Button, { size: "xs", style: "rounded-none rounded-r-sm", action: next, disabled: !canNext, children: (0, jsx_runtime_1.jsx)(chevron_right_svg_1.default, {}) })] }));
|
|
17
|
+
}
|
|
18
|
+
const s = {
|
|
19
|
+
container: "justify-center items-center text-primary-darker select-none",
|
|
20
|
+
subcontainer: "gap-2",
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ProgressBar } from "./bar";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProgressBar = void 0;
|
|
7
|
+
var bar_1 = require("./bar");
|
|
8
|
+
Object.defineProperty(exports, "ProgressBar", { enumerable: true, get: function () { return __importDefault(bar_1).default; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ProgressBar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const style_1 = require("@bouko/style");
|
|
6
|
+
function ProgressBar({ value, style }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(s.container, style), children: (0, jsx_runtime_1.jsx)("div", { className: s.filled, style: { width: (value * 100) + "%" } }) }));
|
|
8
|
+
}
|
|
9
|
+
const s = {
|
|
10
|
+
container: "flex grow h-1 rounded-full bg-surface overflow-hidden",
|
|
11
|
+
filled: "h-full bg-accent"
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Table } from "./normal";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Table = void 0;
|
|
7
|
+
var normal_1 = require("./normal");
|
|
8
|
+
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return __importDefault(normal_1).default; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = Table;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const flex_1 = require("../layout/flex");
|
|
7
|
+
const _1 = require("../button/_");
|
|
8
|
+
const ts_1 = require("@bouko/ts");
|
|
9
|
+
const style_1 = require("@bouko/style");
|
|
10
|
+
function Table({ columns, items }) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: s.table, children: [(0, jsx_runtime_1.jsx)(flex_1.RowBox, { style: s.header, children: columns.map((x, i) => ((0, jsx_runtime_1.jsx)(flex_1.RowBox, { style: (0, style_1.cn)(s.columnLabel, i === 0 ? "justify-start" : i === columns.length - 1 ? "justify-end" : "justify-center"), children: x }, i))) }), (0, jsx_runtime_1.jsx)(flex_1.ColumnBox, { style: s.rows, children: items.map((x, i) => ((0, jsx_runtime_1.jsx)(flex_1.RowBox, { style: (0, style_1.cn)(s.row, i % 2 === 0 && "bg-surface", i === 0 ? "border-none" : i === items.length - 1 ? "border-none" : "border-b"), children: columns.map((key, j) => ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: (0, style_1.cn)(s.cell, j === 0 ? "justify-start" : j === columns.length - 1 ? "justify-end" : "justify-center"), children: [key === "id" ? (0, ts_1.shortenStr)(x[key]) : (x[key] ?? "N/A"), key === "id" && (0, jsx_runtime_1.jsx)(_1.CopyButton, { style: "text-primary-dark", value: (x["id"] || "N/A").toString() })] }, j))) }, i))) })] }));
|
|
12
|
+
}
|
|
13
|
+
const s = {
|
|
14
|
+
table: "grow w-full border border-border rounded-md overflow-hidden",
|
|
15
|
+
header: "w-full px-4 py-3 bg-background-light border-b border-border",
|
|
16
|
+
columnLabel: "flex-1 uppercase text-primary-dark font-light text-sm",
|
|
17
|
+
rows: "grow overflow-y-auto no-scrollbar",
|
|
18
|
+
row: "w-full px-4 py-4 border-b border-border",
|
|
19
|
+
cell: "flex-1 items-center gap-2"
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Input = exports.Badge = void 0;
|
|
7
|
+
var badge_1 = require("./badge");
|
|
8
|
+
Object.defineProperty(exports, "Badge", { enumerable: true, get: function () { return __importDefault(badge_1).default; } });
|
|
9
|
+
var input_1 = require("./input");
|
|
10
|
+
Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return __importDefault(input_1).default; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Component } from "../../utils";
|
|
2
|
+
type Props = Component & {
|
|
3
|
+
color?: string;
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
size?: "xs" | "sm" | "md";
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Color-themed badge component.
|
|
9
|
+
*
|
|
10
|
+
* To use a CSS variable it must exist and be passed in the
|
|
11
|
+
* form `--variable-name`. Any other format may cause unexpected
|
|
12
|
+
* results. CSS variables use 'color-mix' which is not supported in
|
|
13
|
+
* some old browsers such as Safari 15.3 and Internet Explorer.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} color - Color of badge. (optional, default = accent)
|
|
16
|
+
**/
|
|
17
|
+
export declare function Badge({ style, color, size, icon, children }: Props): import("react").JSX.Element | null;
|
|
18
|
+
export default Badge;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Badge = Badge;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const style_1 = require("@bouko/style");
|
|
6
|
+
const tailwind_variants_1 = require("tailwind-variants");
|
|
7
|
+
/**
|
|
8
|
+
* Color-themed badge component.
|
|
9
|
+
*
|
|
10
|
+
* To use a CSS variable it must exist and be passed in the
|
|
11
|
+
* form `--variable-name`. Any other format may cause unexpected
|
|
12
|
+
* results. CSS variables use 'color-mix' which is not supported in
|
|
13
|
+
* some old browsers such as Safari 15.3 and Internet Explorer.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} color - Color of badge. (optional, default = accent)
|
|
16
|
+
**/
|
|
17
|
+
function Badge({ style, color = "--color-accent", size = "md", icon, children }) {
|
|
18
|
+
if (!children)
|
|
19
|
+
return null;
|
|
20
|
+
if (color === "future")
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 test-badge", children: [icon && (0, jsx_runtime_1.jsx)("div", { className: "text-primary-dark", children: icon }), (0, jsx_runtime_1.jsx)("span", { children: children })] }));
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, style_1.cn)(base({ size }), style), style: styles(color), children: children }));
|
|
23
|
+
}
|
|
24
|
+
const styles = (color) => ({
|
|
25
|
+
background: (0, style_1.opacitize)(color),
|
|
26
|
+
border: `1px solid var(${color})`,
|
|
27
|
+
borderRadius: "calc(infinity * 1px)",
|
|
28
|
+
textAlign: "center",
|
|
29
|
+
fontWeight: "600",
|
|
30
|
+
color: "var(--color-primary)"
|
|
31
|
+
});
|
|
32
|
+
const base = (0, tailwind_variants_1.tv)({
|
|
33
|
+
base: "w-min",
|
|
34
|
+
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
xs: "px-1 py-px text-[0.5rem]",
|
|
37
|
+
sm: "px-1 py-px text-xs",
|
|
38
|
+
md: "px-2 py-1 text-sm"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.default = Badge;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type FieldProps<T> = {
|
|
3
|
+
id?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
style?: string;
|
|
6
|
+
value?: T;
|
|
7
|
+
update?: (x: T) => void;
|
|
8
|
+
updateForm?: (id: string, x: T) => void;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
note?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
type Variant = "normal" | "ghost";
|
|
14
|
+
type Props<T> = FieldProps<T> & {
|
|
15
|
+
type?: "text" | "number" | "email" | "password";
|
|
16
|
+
variant?: Variant;
|
|
17
|
+
style?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
onEnter?: (x: string) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Text field component.
|
|
23
|
+
*
|
|
24
|
+
* Wraps the native `input` element with custom styling and validation.
|
|
25
|
+
* It displays an optional label and note, and can be marked as required.
|
|
26
|
+
* Optional callback for when the user presses `Enter` key.
|
|
27
|
+
* The value is controlled externally via props, usually `useState`.
|
|
28
|
+
*
|
|
29
|
+
* Variants:
|
|
30
|
+
* - `normal`: Standard input with primary color scheme.
|
|
31
|
+
* - `ghost`: Transparent for injecting input inside other component.
|
|
32
|
+
*
|
|
33
|
+
* @param {Variant} variant - Visual style variant. (optional, default = normal)
|
|
34
|
+
* @param {string} style - Additional class names for styling. (optional)
|
|
35
|
+
* @param {string} placeholder - Placeholder text for the input. (optional)
|
|
36
|
+
* @param {Function} onEnter - Callback when `Enter` key is pressed. (optional)
|
|
37
|
+
**/
|
|
38
|
+
export default function Input<T>({ id, type, variant, style, value, update, updateForm, onEnter, disabled, placeholder, ...props }: Props<T>): import("react").JSX.Element;
|
|
39
|
+
export {};
|