@bouku/core 0.1.2 → 0.1.4

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.
Files changed (34) hide show
  1. package/dist/components/button/normal.js +2 -2
  2. package/dist/components/fade/circle.js +1 -1
  3. package/dist/components/heading/normal.js +1 -1
  4. package/dist/components/heading/page.js +1 -1
  5. package/dist/components/layout/absolute.js +1 -1
  6. package/dist/components/layout/fade.js +1 -1
  7. package/dist/components/layout/flex.js +1 -1
  8. package/dist/components/layout/footer.js +1 -1
  9. package/dist/components/layout/rnd.js +1 -1
  10. package/dist/components/layout/scroll-box.js +1 -1
  11. package/dist/components/layout/section.js +1 -1
  12. package/dist/components/layout/separator.js +1 -1
  13. package/dist/components/list/item.js +1 -1
  14. package/dist/components/list/search-bar.js +1 -1
  15. package/dist/components/list/variants/bullet.d.ts +2 -2
  16. package/dist/components/list/variants/bullet.js +1 -1
  17. package/dist/components/list/variants/number.js +1 -1
  18. package/dist/components/pagination/index.js +1 -1
  19. package/dist/components/progress/bar.js +1 -1
  20. package/dist/components/table/index.js +1 -1
  21. package/dist/components/table/row.d.ts +1 -1
  22. package/dist/components/table/sorter.d.ts +1 -1
  23. package/dist/components/text/badge.js +1 -1
  24. package/dist/components/text/input.js +1 -1
  25. package/dist/utils/functions/_.d.ts +1 -0
  26. package/dist/utils/functions/_.js +1 -0
  27. package/dist/utils/functions/style.d.ts +31 -0
  28. package/dist/utils/functions/style.js +71 -0
  29. package/dist/utils/functions/text.js +2 -2
  30. package/dist/utils/hooks/router.d.ts +2 -1
  31. package/dist/utils/hooks/router.js +15 -5
  32. package/dist/utils/hooks/state.d.ts +1 -8
  33. package/dist/utils/hooks/state.js +5 -9
  34. package/package.json +3 -3
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Button = Button;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
- const style_1 = require("@bouko/style");
9
+ const style_1 = require("../../utils/functions/style");
10
10
  const tailwind_variants_1 = require("tailwind-variants");
11
11
  const spinner_svg_1 = __importDefault(require("../../assets/icons/spinner.svg"));
12
12
  function Button({ style, size, variant, icon, children, disabled, action }) {
@@ -39,7 +39,7 @@ const styles = (0, tailwind_variants_1.tv)({
39
39
  surface: "bg-surface border-border text-primary",
40
40
  accent: "bg-accent border-accent-dark text-background",
41
41
  outline: "bg-transparent border-accent text-accent",
42
- ghost: "bg-transparent border-transparent text-primary",
42
+ ghost: "bg-transparent border-transparent text-primary-dark",
43
43
  error: "bg-error border-error-dark text-background",
44
44
  future: "backdrop-blur-sm test-button"
45
45
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = CircleFade;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  function CircleFade({ className, style }) {
7
7
  return ((0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)("absolute size-24 bg-radial from-background", className), style: style }));
8
8
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Heading;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  const flex_1 = require("../layout/flex");
7
7
  const badge_1 = require("../text/badge");
8
8
  /**
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = PageHeading;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  const flex_1 = require("../layout/flex");
7
7
  const badge_1 = require("../text/badge");
8
8
  /**
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = AbsoluteBox;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  function AbsoluteBox({ pos, style, ref, children }) {
7
7
  return ((0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles.container, pos), ref: ref, children: (0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles.subcontainer, style), children: children }) }));
8
8
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FadeBox = FadeBox;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  const tailwind_variants_1 = require("tailwind-variants");
7
7
  function FadeBox({ style, direction = "up", gradient, children }) {
8
8
  return ((0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)("relative", style), children: [children, (0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)(styles({ direction }), gradient) })] }));
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RowBox = RowBox;
4
4
  exports.ColumnBox = ColumnBox;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
- const style_1 = require("@bouko/style");
6
+ const style_1 = require("../../utils/functions/style");
7
7
  const tailwind_variants_1 = require("tailwind-variants");
8
8
  /**
9
9
  * Flex containers with configurable alignment and styling.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Footer = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const flex_1 = require("./flex");
6
- const style_1 = require("@bouko/style");
6
+ const style_1 = require("../../utils/functions/style");
7
7
  const Footer = ({ Left, Center, Right }) => ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: style, equal: true, children: [(0, jsx_runtime_1.jsx)(flex_1.RowBox, { style: "justify-start items-center", children: Left }), (0, jsx_runtime_1.jsx)(flex_1.RowBox, { style: "justify-center items-center", children: Center }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-center", children: Right })] }));
8
8
  exports.Footer = Footer;
9
9
  const style = (0, style_1.css)({
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.default = RnD;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_rnd_1 = require("react-rnd");
7
- const style_1 = require("@bouko/style");
7
+ const style_1 = require("../../utils/functions/style");
8
8
  function RnD({ style, min, max, minWidth, update, children }) {
9
9
  const gapSize = max - min;
10
10
  const handleResize = (x, width) => {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ScrollBox = ScrollBox;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const style_1 = require("@bouko/style");
6
+ const style_1 = require("../../utils/functions/style");
7
7
  const flex_1 = require("./flex");
8
8
  function ScrollBox({ style, items, element: Row }) {
9
9
  const [hoveredIndex, setHoveredIndex] = (0, react_1.useState)(null);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const flex_1 = require("./flex");
5
5
  const separator_1 = require("./separator");
6
- const style_1 = require("@bouko/style");
6
+ const style_1 = require("../../utils/functions/style");
7
7
  /**
8
8
  * Layout Section Component.
9
9
  *
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Separator = Separator;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  function Separator({ style }) {
7
7
  return (0, jsx_runtime_1.jsx)("hr", { className: (0, style_1.cn)("w-full text-border-dark", style) });
8
8
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Item;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  ;
7
7
  function Item({ marker, content, centerMarker, index }) {
8
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));
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SearchBar = SearchBar;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const react_1 = require("react");
10
+ const style_1 = require("../../utils/functions/style");
10
11
  const input_1 = __importDefault(require("../text/input"));
11
12
  const fade_1 = __importDefault(require("../layout/fade"));
12
13
  const flex_1 = require("../layout/flex");
13
14
  const normal_1 = __importDefault(require("../button/normal"));
14
- const style_1 = require("@bouko/style");
15
15
  function SearchBar({ style = {}, placeholder, trigger, submit, oops = console.log }) {
16
16
  const [query, setQuery] = (0, react_1.useState)("");
17
17
  const styles = (0, style_1.mergeStyles)(base, style);
@@ -1,9 +1,9 @@
1
- import React, { type ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  interface Props {
3
3
  style?: string;
4
4
  title?: string;
5
5
  items: ReactNode[];
6
6
  centerMarker?: boolean;
7
7
  }
8
- export default function BulletList({ style, title, items, centerMarker }: Props): React.JSX.Element;
8
+ export default function BulletList({ style, title, items, centerMarker }: Props): import("react").JSX.Element;
9
9
  export {};
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.default = BulletList;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const item_1 = __importDefault(require("../item"));
10
- const style_1 = require("@bouko/style");
10
+ const style_1 = require("../../../utils/functions/style");
11
11
  ;
12
12
  function BulletList({ style, title, items, centerMarker }) {
13
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));
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.default = NumberList;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const item_1 = __importDefault(require("../item"));
10
- const style_1 = require("@bouko/style");
10
+ const style_1 = require("../../../utils/functions/style");
11
11
  ;
12
12
  function NumberList({ style, marker, title, items, centerMarker }) {
13
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"));
@@ -9,7 +9,7 @@ const chevron_left_svg_1 = __importDefault(require("../../assets/icons/chevron-l
9
9
  const chevron_right_svg_1 = __importDefault(require("../../assets/icons/chevron-right.svg"));
10
10
  const flex_1 = require("../layout/flex");
11
11
  const normal_1 = require("../button/normal");
12
- const style_1 = require("@bouko/style");
12
+ const style_1 = require("../../utils/functions/style");
13
13
  function Pagination({ style, page, prev, next, totalPages = 99 }) {
14
14
  const canPrev = page > 1;
15
15
  const canNext = totalPages > 0 ? page < totalPages : true;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = ProgressBar;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  function ProgressBar({ value, style }) {
7
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
8
  }
@@ -8,7 +8,7 @@ const flex_1 = require("../layout/flex");
8
8
  const header_1 = require("./header");
9
9
  const row_1 = require("./row");
10
10
  const ts_helper_kit_1 = require("ts-helper-kit");
11
- const style_1 = require("@bouko/style");
11
+ const style_1 = require("../../utils/functions/style");
12
12
  function Table({ style, title, config: initConfig, items }) {
13
13
  const { sortedItems, ...sortOptions } = (0, sorter_1.useSort)(items);
14
14
  const config = parseConfig(initConfig);
@@ -10,6 +10,6 @@ interface Props<T> {
10
10
  count: number;
11
11
  }
12
12
  export type Row = Record<string, CellValue>;
13
- export type CellValue = string | number | boolean | object;
13
+ export type CellValue = string | number | boolean | object | null;
14
14
  export declare function TableRow<T extends Row>({ config, data, count }: Props<T>): import("react").JSX.Element;
15
15
  export {};
@@ -1,4 +1,4 @@
1
- type CellValue = string | number | boolean | object;
1
+ import type { CellValue } from "./row";
2
2
  type SortDirection = "asc" | "desc";
3
3
  export declare function useSort<T extends Record<string, CellValue>>(items: T[]): {
4
4
  sortedItems: T[];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Badge = Badge;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  const tailwind_variants_1 = require("tailwind-variants");
7
7
  /**
8
8
  * Color-themed badge component.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Input;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const style_1 = require("@bouko/style");
5
+ const style_1 = require("../../utils/functions/style");
6
6
  const tailwind_variants_1 = require("tailwind-variants");
7
7
  function Field({ style, label, required = true, note, children }) {
8
8
  return ((0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)(fieldStyles.container, style), children: [label && (0, jsx_runtime_1.jsxs)("span", { className: fieldStyles.label, children: [label, " ", !required ? (0, jsx_runtime_1.jsx)("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), children, note && (0, jsx_runtime_1.jsx)("span", { className: fieldStyles.note, children: note })] }));
@@ -1,2 +1,3 @@
1
1
  export * from "./element";
2
+ export * from "./style";
2
3
  export * from "./text";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./element"), exports);
18
+ __exportStar(require("./style"), exports);
18
19
  __exportStar(require("./text"), exports);
@@ -0,0 +1,31 @@
1
+ import type { StringMap } from "ts-helper-kit";
2
+ import type { ClassValue } from "clsx";
3
+ /**
4
+ * Combines Tailwind styles into a properly merged
5
+ * and formatted string using `clsx` and `twMerge`.
6
+ *
7
+ * @param styles - Class values to combine.
8
+ * @returns A single merged class string.
9
+ **/
10
+ export declare const cn: (...styles: ClassValue[]) => string;
11
+ /**
12
+ * Converts an object of Tailwind styles into a merged
13
+ * class string. Useful for breaking up long styles.
14
+ *
15
+ * @param styles - A map of keys to class strings.
16
+ * @returns A single merged class string.
17
+ **/
18
+ export declare const css: (styles: StringMap) => string;
19
+ /**
20
+ * Merges two style objects by combining matching
21
+ * keys with `cn`. Useful for components that receive
22
+ * custom styles as a prop.
23
+ *
24
+ * @param a - The base styles.
25
+ * @param b - The styles to merge into the base.
26
+ * @returns A new style object with merged class values.
27
+ **/
28
+ export declare const mergeStyles: (a: StringMap, b: StringMap) => {
29
+ [x: string]: string;
30
+ };
31
+ export declare function opacitize(color: string, opacity?: number): string;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeStyles = exports.css = exports.cn = void 0;
4
+ exports.opacitize = opacitize;
5
+ const clsx_1 = require("clsx");
6
+ const tailwind_merge_1 = require("tailwind-merge");
7
+ /**
8
+ * Combines Tailwind styles into a properly merged
9
+ * and formatted string using `clsx` and `twMerge`.
10
+ *
11
+ * @param styles - Class values to combine.
12
+ * @returns A single merged class string.
13
+ **/
14
+ const cn = (...styles) => (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(styles));
15
+ exports.cn = cn;
16
+ /**
17
+ * Converts an object of Tailwind styles into a merged
18
+ * class string. Useful for breaking up long styles.
19
+ *
20
+ * @param styles - A map of keys to class strings.
21
+ * @returns A single merged class string.
22
+ **/
23
+ const css = (styles) => (0, exports.cn)(...Object.values(styles));
24
+ exports.css = css;
25
+ /**
26
+ * Merges two style objects by combining matching
27
+ * keys with `cn`. Useful for components that receive
28
+ * custom styles as a prop.
29
+ *
30
+ * @param a - The base styles.
31
+ * @param b - The styles to merge into the base.
32
+ * @returns A new style object with merged class values.
33
+ **/
34
+ const mergeStyles = (a, b) => {
35
+ const merged = { ...a };
36
+ for (const [key, value] of Object.entries(b)) {
37
+ if (merged[key])
38
+ merged[key] = (0, exports.cn)(merged[key], value);
39
+ else
40
+ merged[key] = value;
41
+ }
42
+ return merged;
43
+ };
44
+ exports.mergeStyles = mergeStyles;
45
+ function opacitize(color, opacity = 0.5) {
46
+ if (color.startsWith("var("))
47
+ return `
48
+ color-mix(
49
+ in srgb,
50
+ ${color} ${opacity * 100}%,
51
+ transparent
52
+ )
53
+ `;
54
+ const { r, g, b } = parseHex(color);
55
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
56
+ }
57
+ ;
58
+ const parseHex = (input) => {
59
+ let hex = input.replace("#", "");
60
+ if (hex.length === 3)
61
+ hex = palindrome(hex);
62
+ return {
63
+ r: parseInt(hex.substring(0, 2), 16),
64
+ g: parseInt(hex.substring(2, 4), 16),
65
+ b: parseInt(hex.substring(4, 6), 16)
66
+ };
67
+ };
68
+ const palindrome = (str) => str
69
+ .split("")
70
+ .map(c => c + c)
71
+ .join("");
@@ -4,7 +4,7 @@ exports.linkify = void 0;
4
4
  exports.formatText = formatText;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_router_dom_1 = require("react-router-dom");
7
- const ts_1 = require("@bouko/ts");
7
+ const ts_helper_kit_1 = require("ts-helper-kit");
8
8
  const delimiterConfig = [
9
9
  {
10
10
  key: "**",
@@ -20,7 +20,7 @@ const delimiterConfig = [
20
20
  },
21
21
  ];
22
22
  const delimiterPattern = delimiterConfig.map(({ key }) => {
23
- const escaped = (0, ts_1.escapeRegex)(key);
23
+ const escaped = (0, ts_helper_kit_1.escapeRegex)(key);
24
24
  return `${escaped}.*?${escaped}`;
25
25
  }).join("|");
26
26
  const linkPattern = String.raw `\[[^\]]+\]\([^)]+\)`;
@@ -2,4 +2,5 @@ export declare function useRouter<T>(): {
2
2
  navigate: import("react-router").NavigateFunction;
3
3
  params: T;
4
4
  };
5
- export declare const useSearchParam: (key: string) => string | null;
5
+ export declare function useUrlParam<T = string>(key: string): T;
6
+ export declare function useSearchParam<T>(key: string): T;
@@ -1,15 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSearchParam = void 0;
4
3
  exports.useRouter = useRouter;
4
+ exports.useUrlParam = useUrlParam;
5
+ exports.useSearchParam = useSearchParam;
5
6
  const react_router_dom_1 = require("react-router-dom");
6
7
  function useRouter() {
7
8
  const navigate = (0, react_router_dom_1.useNavigate)();
8
9
  const params = (0, react_router_dom_1.useParams)();
9
10
  return { navigate, params };
10
11
  }
11
- const useSearchParam = (key) => {
12
+ function useUrlParam(key) {
13
+ const params = (0, react_router_dom_1.useParams)();
14
+ const value = params[key];
15
+ if (!value)
16
+ throw new Error("Missing URL param: " + key);
17
+ return value;
18
+ }
19
+ function useSearchParam(key) {
12
20
  const [params] = (0, react_router_dom_1.useSearchParams)();
13
- return params.get(key);
14
- };
15
- exports.useSearchParam = useSearchParam;
21
+ const value = params.get(key);
22
+ if (!value)
23
+ throw new Error("Missing URL search param: " + key);
24
+ return value;
25
+ }
@@ -1,11 +1,4 @@
1
- type Options<T> = {
2
- fetcher: () => Promise<T>;
3
- updater: (x?: T) => Promise<T | null>;
4
- };
5
- export declare function useValue<T>({ fetcher, updater }: Options<T>): {
6
- value: T | null;
7
- update: (x?: T) => Promise<void>;
8
- };
1
+ export declare function useValue<T>(getValue: () => Promise<T>): T | null;
9
2
  export declare function useList<T extends {
10
3
  id?: string;
11
4
  }>(initial?: T[]): {
@@ -4,17 +4,13 @@ exports.useValue = useValue;
4
4
  exports.useList = useList;
5
5
  exports.useMap = useMap;
6
6
  const react_1 = require("react");
7
- function useValue({ fetcher, updater }) {
7
+ function useValue(getValue) {
8
8
  const [value, setValue] = (0, react_1.useState)(null);
9
9
  (0, react_1.useEffect)(() => {
10
- fetcher()
11
- .then(setValue);
12
- }, []);
13
- const update = async (x) => {
14
- const res = await updater(x);
15
- setValue(res || null);
16
- };
17
- return { value, update };
10
+ if (!value)
11
+ getValue().then(setValue);
12
+ }, [value]);
13
+ return value;
18
14
  }
19
15
  function useList(initial = []) {
20
16
  const [items, setItems] = (0, react_1.useState)(initial);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bouku/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -24,12 +24,12 @@
24
24
  "build": "tsc"
25
25
  },
26
26
  "dependencies": {
27
- "@bouko/style": "^0.2.1",
28
- "@bouko/ts": "^0.5.0",
27
+ "clsx": "^2.1.1",
29
28
  "framer-motion": "^12.23.6",
30
29
  "react-rnd": "^10.5.2",
31
30
  "react-time-ago": "^7.4.4",
32
31
  "snatch-http": "^0.0.1",
32
+ "tailwind-merge": "^3.6.0",
33
33
  "tailwind-variants": "^1.0.0",
34
34
  "ts-helper-kit": "^0.0.6"
35
35
  },