@bouku/core 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { type Row, type Action } from "./row";
1
+ import { type Row, type TableAction } from "./row";
2
2
  type ColumnOptions = {
3
3
  label?: string;
4
4
  pad?: number;
@@ -9,7 +9,7 @@ type Props<T extends Row> = {
9
9
  title?: string;
10
10
  config: Partial<Record<keyof T, boolean | ColumnOptions>>;
11
11
  items: T[];
12
- actions?: Action<T>[];
12
+ actions?: TableAction<T>[];
13
13
  };
14
14
  export default function Table<T extends Row>({ style, title, config: initConfig, items, actions }: Props<T>): import("react").JSX.Element;
15
15
  export {};
@@ -4,17 +4,19 @@ type ColumnOptions = {
4
4
  pad?: number;
5
5
  link?: string;
6
6
  };
7
- export type Action<T> = {
8
- variant?: "accent" | "surface" | "error";
9
- icon?: React.ReactNode;
7
+ export type TableAction<T> = {
10
8
  style?: string;
9
+ variant?: "accent" | "surface" | "error";
10
+ label?: string;
11
+ icon: React.ReactNode;
11
12
  handler: (row: T) => void;
13
+ next?: () => void;
12
14
  };
13
15
  interface Props<T> {
14
16
  config: Record<string, ColumnOptions>;
15
17
  data: T;
16
18
  count: number;
17
- actions?: Action<T>[];
19
+ actions?: TableAction<T>[];
18
20
  }
19
21
  export type Row = Record<string, CellValue>;
20
22
  export type CellValue = string | number | boolean | object | null;
@@ -20,7 +20,11 @@ function TableRow({ config, data, actions, count }) {
20
20
  const variantStyles = action.variant === "error" ? "bg-error/10 text-error hover:bg-error/20" :
21
21
  action.variant === "accent" ? "bg-accent/10 text-accent hover:bg-accent/20" :
22
22
  "bg-surface-light text-primary hover:bg-surface-light/80";
23
- return ((0, jsx_runtime_1.jsx)(_1.Button, { size: "xs", variant: "surface", style: action.style, icon: action.icon, action: () => action.handler(data) }, actionIdx));
23
+ const onClick = async () => {
24
+ await action.handler(data);
25
+ action.next?.();
26
+ };
27
+ return ((0, jsx_runtime_1.jsx)(_1.Button, { size: "xs", variant: "surface", style: action.style, icon: action.icon, action: onClick }, actionIdx));
24
28
  }) }) }, i));
25
29
  }
26
30
  const rawValue = data[key];
@@ -31,8 +31,3 @@ export interface NavItem {
31
31
  label: string;
32
32
  href: string;
33
33
  }
34
- export type TableActions<T> = {
35
- label?: string;
36
- icon: ReactNode;
37
- handler: (row: T) => void;
38
- }[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouku/core",
4
- "version": "0.2.7",
4
+ "version": "0.2.9",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",