kmod-cli 1.7.7 → 1.7.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.
@@ -8,7 +8,6 @@ import {
8
8
  useState,
9
9
  } from 'react';
10
10
 
11
- // Nếu bạn cần alias cho ITable type, dùng:
12
11
  import type { Table as ITable } from '@tanstack/react-table';
13
12
  import {
14
13
  Cell,
@@ -53,83 +52,159 @@ export type TableClassNames = {
53
52
  header?: TableHeaderClassNames;
54
53
  body?: TableBodyClassNames;
55
54
  };
55
+
56
+ // table
57
+ export type HandleClickTableProps<TData> = {
58
+ e: React.MouseEvent<HTMLTableElement>;
59
+ table: ITable<TData>;
60
+ }
61
+ export type HandleClickTableFnc<TData> = ({
62
+ e,
63
+ table,
64
+ }: HandleClickTableProps<TData>) => void;
65
+
66
+ // header
67
+ export type HandleClickTableHeaderProps<TData> = {
68
+ e: React.MouseEvent<HTMLTableSectionElement>;
69
+ table: ITable<TData>;
70
+ }
71
+ export type HandleClickTableHeaderFnc<TData> = ({
72
+ e,
73
+ table,
74
+ }: HandleClickTableHeaderProps<TData>) => void;
75
+
76
+ // row header
77
+ export type HandleClickTableRowHeaderProps<TData> = {
78
+ e: React.MouseEvent<HTMLTableRowElement>;
79
+ row: HeaderGroup<TData>;
80
+ table: ITable<TData>;
81
+ }
82
+ export type HandleClickTableRowHeaderFnc<TData> = ({
83
+ e,
84
+ table,
85
+ row,
86
+ }: HandleClickTableRowHeaderProps<TData>) => void;
87
+
88
+ // body
89
+ export type HandleClickTableBodyProps<TData> = {
90
+ e: React.MouseEvent<HTMLTableSectionElement>;
91
+ table: ITable<TData>;
92
+ }
93
+ export type HandleClickTableBodyFnc<TData> = ({
94
+ e,
95
+ table,
96
+ }: HandleClickTableBodyProps<TData>) => void;
97
+
98
+ // row body
99
+ export type HandleClickTableRowBodyProps<TData> = {
100
+ e: React.MouseEvent<HTMLTableRowElement>;
101
+ row: Row<TData>;
102
+ table: ITable<TData>;
103
+ }
104
+ export type HandleClickTableRowBodyFnc<TData> = ({
105
+ e,
106
+ table,
107
+ row,
108
+ }: HandleClickTableRowBodyProps<TData>) => void;
109
+
110
+ // head cell
111
+ export type HandleClickTableHeadProps<TData> = {
112
+ e: React.MouseEvent<HTMLTableCellElement>;
113
+ cell: Header<TData, unknown>;
114
+ table: ITable<TData>;
115
+ }
116
+ export type HandleClickTableHeadFnc<TData> = ({
117
+ e,
118
+ table,
119
+ cell,
120
+ }: HandleClickTableHeadProps<TData>) => void;
121
+
122
+ // body cell
123
+ export type HandleClickTableCellProps<TData, TValue> = {
124
+ e: React.MouseEvent<HTMLTableCellElement>;
125
+ cell: Cell<TData, TValue>;
126
+ row: Row<TData>;
127
+ table: ITable<TData>;
128
+ }
129
+ export type HandleClickTableCellFnc<TData, TValue> = ({
130
+ e,
131
+ table,
132
+ cell,
133
+ row
134
+ }: HandleClickTableCellProps<TData, TValue>) => void;
135
+
136
+ // ============================================================== Table Props ==============================================================
137
+ /**
138
+ * @prop e - event click
139
+ * @prop table - table instance
140
+ * @example `handleClick: ({ e, table }) => {...}`
141
+ */
56
142
  export type TableHeaderProps<TData> =
57
143
  HTMLAttributes<HTMLTableSectionElement> & {
58
- handleClick?: ({
59
- e,
60
- table,
61
- }: {
62
- e: React.MouseEvent<HTMLTableSectionElement>;
63
- table: ITable<TData>;
64
- }) => void;
144
+ handleClick?: HandleClickTableHeaderFnc<TData>;
65
145
  };
146
+
147
+ /**
148
+ * @prop e - event click
149
+ * @prop table - table instance
150
+ * @example `handleClick: ({ e, table }) => {...}`
151
+ */
66
152
  export type TableBodyProps<TData> = HTMLAttributes<HTMLTableSectionElement> & {
67
- handleClick?: ({
68
- e,
69
- table,
70
- }: {
71
- e: React.MouseEvent<HTMLTableSectionElement>;
72
- table: ITable<TData>;
73
- }) => void;
153
+ handleClick?: HandleClickTableBodyFnc<TData>;
74
154
  };
155
+
156
+ /**
157
+ * @prop e - event click
158
+ * @prop table - table instance
159
+ * @prop cell - cell instance
160
+ * @example `handleClick: ({ e, table, cell }) => {...}`
161
+ */
75
162
  export type TableHeadProps<TData> = HTMLAttributes<HTMLTableCellElement> & {
76
163
  classNameCondition?: | (({cell, table}: {cell?: Header<TData, unknown>; table?: ITable<TData>}) => string) | string;
77
- handleClick?: ({
78
- e,
79
- table,
80
- cell,
81
- }: {
82
- e: React.MouseEvent<HTMLTableCellElement>;
83
- cell: Header<TData, unknown>;
84
- table: ITable<TData>;
85
- }) => void;
164
+ handleClick?: HandleClickTableHeadFnc<TData>;
86
165
  };
166
+
167
+ /**
168
+ * @prop e - event click
169
+ * @prop table - table instance
170
+ * @prop cell - cell instance
171
+ * @prop row - row instance
172
+ * @example `handleClick: ({ e, table, cell, row }) => {...}`
173
+ */
87
174
  export type TableCellProps<TData, TValue> =
88
175
  HTMLAttributes<HTMLTableCellElement> & {
89
176
  classNameCondition?: | (({cell, table}: {cell?: Cell<TData, unknown>; table?: ITable<TData>}) => string) | string;
90
- handleClick?: ({
91
- e,
92
- table,
93
- cell,
94
- row
95
- }: {
96
- e: React.MouseEvent<HTMLTableCellElement>;
97
- cell: Cell<TData, TValue>;
98
- row: Row<TData>;
99
- table: ITable<TData>;
100
- }) => void;
177
+ handleClick?: HandleClickTableCellFnc<TData, TValue>;
101
178
  };
179
+
180
+ /**
181
+ * @prop e - event click
182
+ * @prop table - table instance
183
+ * @prop row - row instance
184
+ * @example `handleClick: ({ e, table, row }) => {...}`
185
+ */
102
186
  export type TableRowHeadProps<TData> = HTMLAttributes<HTMLTableRowElement> & {
103
- handleClick?: ({
104
- e,
105
- table,
106
- row,
107
- }: {
108
- e: React.MouseEvent<HTMLTableRowElement>;
109
- row: HeaderGroup<TData>;
110
- table: ITable<TData>;
111
- }) => void;
187
+ handleClick?: HandleClickTableRowHeaderFnc<TData>;
112
188
  };
189
+
190
+ /**
191
+ * @prop e - event click
192
+ * @prop table - table instance
193
+ * @prop row - row instance
194
+ * @example `handleClick: ({ e, table, row }) => {...}`
195
+ */
113
196
  export type TableRowBodyProps<TData> = HTMLAttributes<HTMLTableRowElement> & {
114
197
  classNameCondition?: | (({row, table}: {row?: Row<TData>; table?: ITable<TData>}) => string) | string;
115
- handleClick?: ({
116
- e,
117
- table,
118
- row,
119
- }: {
120
- e: React.MouseEvent<HTMLTableRowElement>;
121
- row: Row<TData>;
122
- table: ITable<TData>;
123
- }) => void;
198
+ handleClick?: HandleClickTableRowBodyFnc<TData>;
124
199
  };
200
+
201
+ /**
202
+ * @prop e - event click
203
+ * @prop table - table instance
204
+ * @example `handleClick: ({ e, table }) => {...}`
205
+ */
125
206
  export type TableProps<TData> = HTMLAttributes<HTMLTableElement> & {
126
- handleClick?: ({
127
- e,
128
- table,
129
- }: {
130
- e: React.MouseEvent<HTMLTableElement>;
131
- table: ITable<TData>;
132
- }) => void;
207
+ handleClick?: HandleClickTableFnc<TData>;
133
208
  };
134
209
 
135
210
  export type UseTableProps<TData, TValue> = {
@@ -142,23 +217,30 @@ export type UseTableProps<TData, TValue> = {
142
217
  cellHeadProps?: TableHeadProps<TData>;
143
218
  };
144
219
 
220
+ export type SurfixProps<TData, TValue> = {
221
+ header: Header<TData, TValue | unknown>;
222
+ showSortIconHeader: boolean;
223
+ }
224
+ export type ToolbarProps<TData> = {
225
+ table: ITable<TData>;
226
+ fns: DataTableToolbarFns<TData>;
227
+ }
228
+ export type PaginationProps<TData, TValue> = {
229
+ table: ITable<TData>;
230
+ fns: DataTablePaginationFns<TData>;
231
+ }
232
+
145
233
  export type DataTableProps<TData, TValue> = {
146
234
  columns: ColumnDef<TData, TValue>[];
147
235
  data: TData[];
148
236
  toolbarTable?: ({
149
237
  table,
150
238
  fns,
151
- }: {
152
- table: ITable<TData>;
153
- fns: DataTableToolbarFns<TData>;
154
- }) => ReactNode | ReactNode[];
239
+ }: ToolbarProps<TData>) => ReactNode | ReactNode[];
155
240
  paginationTable?: ({
156
241
  table,
157
242
  fns,
158
- }: {
159
- table: ITable<TData>;
160
- fns: DataTablePaginationFns<TData>;
161
- }) => ReactNode | ReactNode[];
243
+ }: PaginationProps<TData, TValue>) => ReactNode | ReactNode[];
162
244
  isLoading?: boolean;
163
245
  classNames?: TableClassNames;
164
246
  alternate?: "even" | "odd";
@@ -168,10 +250,7 @@ export type DataTableProps<TData, TValue> = {
168
250
  surfix?: ({
169
251
  header,
170
252
  showSortIconHeader,
171
- }: {
172
- header: Header<TData, TValue | unknown>;
173
- showSortIconHeader: boolean;
174
- }) => ReactNode | ReactNode[];
253
+ }: SurfixProps<TData, TValue>) => ReactNode | ReactNode[];
175
254
  enableSort?: boolean;
176
255
  useTableProps?: UseTableProps<TData, TValue>;
177
256
  initialState?: InitialTableState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kmod-cli",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Stack components utilities fast setup in projects",
5
5
  "author": "kumo_d",
6
6
  "license": "MIT",