@mkt-loitd/react-table-grid-custom 1.3.10 → 1.4.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/index.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { Dispatch, SetStateAction, Key, ReactNode, FC } from 'react';
1
+ import { Dispatch, SetStateAction, Key, FC, ReactNode } from 'react';
2
2
  import { ColumnOrColumnGroup, SortColumn } from 'react-data-grid';
3
3
  export { Column, ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { UseMutateFunction } from '@tanstack/react-query';
6
5
 
7
6
  type TColumnsTable<T = unknown, SR = unknown> = readonly ColumnOrColumnGroup<NoInfer<T>, NoInfer<SR>>[];
8
7
  interface useShowHideColumnParameter<T, SR = unknown> {
@@ -25,26 +24,19 @@ interface useShowHideColumnReturn<T, SR> {
25
24
  declare const useShowHideColumn: <T, SR = unknown>({ nameLocal, columns, ignoreColumns }: useShowHideColumnParameter<T, SR>) => useShowHideColumnReturn<T, SR>;
26
25
 
27
26
  interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key> {
28
- /** Data */
27
+ classNameWapperTable?: string;
28
+ hiddenSTT?: boolean;
29
29
  data: readonly T[];
30
30
  columns: readonly ColumnOrColumnGroup<T, SR>[];
31
- /** Pagination display */
31
+ rowKeyGetter?: keyof T | ((row: T) => K);
32
32
  page?: number;
33
33
  pageSize?: number;
34
- hiddenSTT?: boolean;
35
- /** Selection */
36
34
  enableSelectRow?: boolean;
37
35
  selectedRows?: ReadonlySet<K>;
38
36
  onSelectedRowsChange?: (rows: ReadonlySet<K>) => void;
39
- /** Sorting */
40
37
  sortColumns?: readonly SortColumn[];
41
38
  onSortColumnsChange?: (sortColumns: readonly SortColumn[]) => void;
42
- /** Row key */
43
- rowKeyGetter?: keyof T | ((row: T) => K);
44
- /** UI */
45
- classNameWapperTable?: string;
46
39
  fetching?: boolean;
47
- /** Events */
48
40
  onRowClick?: (row: T, rowIdx: number) => void;
49
41
  onRowDoubleClick?: (row: T, rowIdx: number) => void;
50
42
  }
@@ -52,127 +44,8 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
52
44
  declare const ReactTableGridCustomInner: <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => react_jsx_runtime.JSX.Element;
53
45
  declare const ReactTableGridCustom: typeof ReactTableGridCustomInner;
54
46
 
55
- interface ContextMenuProps {
56
- selector: string;
57
- children?: ReactNode;
58
- zIndex?: number;
59
- }
60
-
61
- interface IMainResponse<T = any> {
62
- success?: boolean;
63
- status?: 'success' | 'error' | 'warning';
64
- data?: T;
65
- payload?: {
66
- data?: T;
67
- [key: string]: any;
68
- };
69
- message?: {
70
- key: string;
71
- [key: string]: any;
72
- };
73
- error?: any;
74
- }
75
- interface IFieldUpdateAndCheck<T = any, F = any, V = any> {
76
- id?: string | number;
77
- field?: F;
78
- value?: V;
79
- data?: T;
80
- [key: string]: any;
81
- }
82
- interface Account {
83
- id?: string | number;
84
- username?: string;
85
- password?: string;
86
- email?: string;
87
- status?: string;
88
- [key: string]: any;
89
- }
90
- interface Post {
91
- id?: string | number;
92
- title?: string;
93
- content?: string;
94
- createdAt?: number;
95
- [key: string]: any;
96
- }
97
- interface AppSettings {
98
- [key: string]: any;
99
- }
100
- interface ISetConfigPagination {
101
- page?: number;
102
- limit?: number;
103
- total?: number;
104
- [key: string]: any;
105
- }
106
- type ITaskName = string;
107
-
108
- interface IActionUiUtilBy {
109
- action?: string;
110
- [key: string]: any;
111
- }
112
- interface IPayloadStartAction {
113
- action?: string;
114
- [key: string]: any;
115
- }
116
-
117
- interface Proxy {
118
- id?: string;
119
- host?: string;
120
- port?: number;
121
- username?: string;
122
- password?: string;
123
- protocol?: string;
124
- provider?: string;
125
- [key: string]: any;
126
- }
127
-
128
- interface IPayloadRemoveProxy {
129
- ids: string[];
130
- }
131
- interface IPayloadService {
132
- updateByClipboard?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, string[], keyof Account>, unknown>;
133
- removeFieldBy?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Array<keyof Account>, string[]>, unknown>;
134
- copyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, string, string[]>, unknown>;
135
- actionBy?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, IActionUiUtilBy, string[]>, unknown>;
136
- updateAccountByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Partial<Account>, string[]>, unknown>;
137
- deleteProxy?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadRemoveProxy, unknown>;
138
- removePostByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Post, undefined, string[]>, unknown>;
139
- startAction?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadStartAction, unknown>;
140
- updateSettings?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<AppSettings, object, boolean>, unknown>;
141
- useCopyProxyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Proxy, string, string[]>[], unknown>;
142
- exportLinkSuccess?: UseMutateFunction<IMainResponse<boolean>, Error, ITaskName, unknown>;
143
- setAction?: Dispatch<SetStateAction<ITaskName>>;
144
- }
145
-
146
- type IDispatchState<T> = Dispatch<SetStateAction<T>>;
147
-
148
- interface IExpandValue extends IPayloadService {
149
- t?: any;
150
- setConfigSearch?: IDispatchState<ISetConfigPagination>;
151
- setSelectedRecords?: Dispatch<ReadonlySet<string>>;
152
- setIsShowEdit?: Dispatch<SetStateAction<boolean>>;
153
- setIsOpenEditContent?: Dispatch<SetStateAction<boolean>>;
154
- setIsCopy?: Dispatch<SetStateAction<boolean>>;
155
- setIsChangeCate?: Dispatch<SetStateAction<boolean>>;
156
- setIsBackup?: Dispatch<SetStateAction<boolean>>;
157
- }
158
- type configContextMenuType = {
159
- Icon: (prop?: any) => ReactNode;
160
- action: string;
161
- onClick?: (value: string[], expandValue: IExpandValue) => void;
162
- children?: configContextMenuType[];
163
- };
164
- interface RenderContextMenuProps {
165
- renderData?: configContextMenuType[];
166
- valueClickItem?: any;
167
- expandValue?: IExpandValue;
168
- }
169
-
170
47
  interface TableStyleWapperProps {
171
48
  children?: ReactNode;
172
- contextMenuProps?: Omit<ContextMenuProps, 'selector' | 'children'> & {
173
- selector?: string;
174
- };
175
- renderContext?: RenderContextMenuProps;
176
49
  clsTablecustom?: string;
177
50
  idWapper?: string;
178
51
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { Dispatch, SetStateAction, Key, ReactNode, FC } from 'react';
1
+ import { Dispatch, SetStateAction, Key, FC, ReactNode } from 'react';
2
2
  import { ColumnOrColumnGroup, SortColumn } from 'react-data-grid';
3
3
  export { Column, ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { UseMutateFunction } from '@tanstack/react-query';
6
5
 
7
6
  type TColumnsTable<T = unknown, SR = unknown> = readonly ColumnOrColumnGroup<NoInfer<T>, NoInfer<SR>>[];
8
7
  interface useShowHideColumnParameter<T, SR = unknown> {
@@ -25,26 +24,19 @@ interface useShowHideColumnReturn<T, SR> {
25
24
  declare const useShowHideColumn: <T, SR = unknown>({ nameLocal, columns, ignoreColumns }: useShowHideColumnParameter<T, SR>) => useShowHideColumnReturn<T, SR>;
26
25
 
27
26
  interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key> {
28
- /** Data */
27
+ classNameWapperTable?: string;
28
+ hiddenSTT?: boolean;
29
29
  data: readonly T[];
30
30
  columns: readonly ColumnOrColumnGroup<T, SR>[];
31
- /** Pagination display */
31
+ rowKeyGetter?: keyof T | ((row: T) => K);
32
32
  page?: number;
33
33
  pageSize?: number;
34
- hiddenSTT?: boolean;
35
- /** Selection */
36
34
  enableSelectRow?: boolean;
37
35
  selectedRows?: ReadonlySet<K>;
38
36
  onSelectedRowsChange?: (rows: ReadonlySet<K>) => void;
39
- /** Sorting */
40
37
  sortColumns?: readonly SortColumn[];
41
38
  onSortColumnsChange?: (sortColumns: readonly SortColumn[]) => void;
42
- /** Row key */
43
- rowKeyGetter?: keyof T | ((row: T) => K);
44
- /** UI */
45
- classNameWapperTable?: string;
46
39
  fetching?: boolean;
47
- /** Events */
48
40
  onRowClick?: (row: T, rowIdx: number) => void;
49
41
  onRowDoubleClick?: (row: T, rowIdx: number) => void;
50
42
  }
@@ -52,127 +44,8 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
52
44
  declare const ReactTableGridCustomInner: <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => react_jsx_runtime.JSX.Element;
53
45
  declare const ReactTableGridCustom: typeof ReactTableGridCustomInner;
54
46
 
55
- interface ContextMenuProps {
56
- selector: string;
57
- children?: ReactNode;
58
- zIndex?: number;
59
- }
60
-
61
- interface IMainResponse<T = any> {
62
- success?: boolean;
63
- status?: 'success' | 'error' | 'warning';
64
- data?: T;
65
- payload?: {
66
- data?: T;
67
- [key: string]: any;
68
- };
69
- message?: {
70
- key: string;
71
- [key: string]: any;
72
- };
73
- error?: any;
74
- }
75
- interface IFieldUpdateAndCheck<T = any, F = any, V = any> {
76
- id?: string | number;
77
- field?: F;
78
- value?: V;
79
- data?: T;
80
- [key: string]: any;
81
- }
82
- interface Account {
83
- id?: string | number;
84
- username?: string;
85
- password?: string;
86
- email?: string;
87
- status?: string;
88
- [key: string]: any;
89
- }
90
- interface Post {
91
- id?: string | number;
92
- title?: string;
93
- content?: string;
94
- createdAt?: number;
95
- [key: string]: any;
96
- }
97
- interface AppSettings {
98
- [key: string]: any;
99
- }
100
- interface ISetConfigPagination {
101
- page?: number;
102
- limit?: number;
103
- total?: number;
104
- [key: string]: any;
105
- }
106
- type ITaskName = string;
107
-
108
- interface IActionUiUtilBy {
109
- action?: string;
110
- [key: string]: any;
111
- }
112
- interface IPayloadStartAction {
113
- action?: string;
114
- [key: string]: any;
115
- }
116
-
117
- interface Proxy {
118
- id?: string;
119
- host?: string;
120
- port?: number;
121
- username?: string;
122
- password?: string;
123
- protocol?: string;
124
- provider?: string;
125
- [key: string]: any;
126
- }
127
-
128
- interface IPayloadRemoveProxy {
129
- ids: string[];
130
- }
131
- interface IPayloadService {
132
- updateByClipboard?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, string[], keyof Account>, unknown>;
133
- removeFieldBy?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Array<keyof Account>, string[]>, unknown>;
134
- copyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, string, string[]>, unknown>;
135
- actionBy?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, IActionUiUtilBy, string[]>, unknown>;
136
- updateAccountByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Partial<Account>, string[]>, unknown>;
137
- deleteProxy?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadRemoveProxy, unknown>;
138
- removePostByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Post, undefined, string[]>, unknown>;
139
- startAction?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadStartAction, unknown>;
140
- updateSettings?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<AppSettings, object, boolean>, unknown>;
141
- useCopyProxyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Proxy, string, string[]>[], unknown>;
142
- exportLinkSuccess?: UseMutateFunction<IMainResponse<boolean>, Error, ITaskName, unknown>;
143
- setAction?: Dispatch<SetStateAction<ITaskName>>;
144
- }
145
-
146
- type IDispatchState<T> = Dispatch<SetStateAction<T>>;
147
-
148
- interface IExpandValue extends IPayloadService {
149
- t?: any;
150
- setConfigSearch?: IDispatchState<ISetConfigPagination>;
151
- setSelectedRecords?: Dispatch<ReadonlySet<string>>;
152
- setIsShowEdit?: Dispatch<SetStateAction<boolean>>;
153
- setIsOpenEditContent?: Dispatch<SetStateAction<boolean>>;
154
- setIsCopy?: Dispatch<SetStateAction<boolean>>;
155
- setIsChangeCate?: Dispatch<SetStateAction<boolean>>;
156
- setIsBackup?: Dispatch<SetStateAction<boolean>>;
157
- }
158
- type configContextMenuType = {
159
- Icon: (prop?: any) => ReactNode;
160
- action: string;
161
- onClick?: (value: string[], expandValue: IExpandValue) => void;
162
- children?: configContextMenuType[];
163
- };
164
- interface RenderContextMenuProps {
165
- renderData?: configContextMenuType[];
166
- valueClickItem?: any;
167
- expandValue?: IExpandValue;
168
- }
169
-
170
47
  interface TableStyleWapperProps {
171
48
  children?: ReactNode;
172
- contextMenuProps?: Omit<ContextMenuProps, 'selector' | 'children'> & {
173
- selector?: string;
174
- };
175
- renderContext?: RenderContextMenuProps;
176
49
  clsTablecustom?: string;
177
50
  idWapper?: string;
178
51
  }
package/dist/index.js CHANGED
@@ -251,13 +251,13 @@ var ReactTableGridCustomInner = (props) => {
251
251
  } = props;
252
252
  const isSelectRow = enableSelectRow && selectedRows !== void 0;
253
253
  const newColumns = (0, import_react2.useMemo)(() => {
254
- let cols = [...columns];
254
+ const cols = [...columns];
255
255
  if (isSelectRow) {
256
256
  cols.unshift(import_react_data_grid.SelectColumn);
257
257
  }
258
258
  if (!hiddenSTT) {
259
259
  cols.unshift({
260
- key: "index",
260
+ key: "__index__",
261
261
  name: "STT",
262
262
  width: 80,
263
263
  renderCell: ({ rowIdx }) => STT({ page, pageSize }, rowIdx)
@@ -278,7 +278,7 @@ var ReactTableGridCustomInner = (props) => {
278
278
  "div",
279
279
  {
280
280
  className: cn(
281
- "wapper_table flex flex-col h-full min-h-0",
281
+ "wapper_table flex flex-col h-full min-h-0 relative",
282
282
  classNameWapperTable
283
283
  ),
284
284
  children: [
@@ -296,7 +296,7 @@ var ReactTableGridCustomInner = (props) => {
296
296
  onCellDoubleClick: ({ row, rowIdx }) => onRowDoubleClick == null ? void 0 : onRowDoubleClick(row, rowIdx)
297
297
  }
298
298
  ),
299
- fetching && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingIcon, { isSpin: true }) })
299
+ fetching && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-white/60 z-10", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingIcon, { isSpin: true }) })
300
300
  ]
301
301
  }
302
302
  );
@@ -311,9 +311,9 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
311
311
  var isClient = typeof window !== "undefined";
312
312
  var TableStyleContextWapper = ({
313
313
  children,
314
- contextMenuProps,
314
+ // contextMenuProps,
315
315
  clsTablecustom,
316
- renderContext,
316
+ // renderContext,
317
317
  idWapper: externalId
318
318
  }) => {
319
319
  if (!isClient) {
package/dist/index.mjs CHANGED
@@ -220,13 +220,13 @@ var ReactTableGridCustomInner = (props) => {
220
220
  } = props;
221
221
  const isSelectRow = enableSelectRow && selectedRows !== void 0;
222
222
  const newColumns = useMemo2(() => {
223
- let cols = [...columns];
223
+ const cols = [...columns];
224
224
  if (isSelectRow) {
225
225
  cols.unshift(SelectColumn);
226
226
  }
227
227
  if (!hiddenSTT) {
228
228
  cols.unshift({
229
- key: "index",
229
+ key: "__index__",
230
230
  name: "STT",
231
231
  width: 80,
232
232
  renderCell: ({ rowIdx }) => STT({ page, pageSize }, rowIdx)
@@ -247,7 +247,7 @@ var ReactTableGridCustomInner = (props) => {
247
247
  "div",
248
248
  {
249
249
  className: cn(
250
- "wapper_table flex flex-col h-full min-h-0",
250
+ "wapper_table flex flex-col h-full min-h-0 relative",
251
251
  classNameWapperTable
252
252
  ),
253
253
  children: [
@@ -265,7 +265,7 @@ var ReactTableGridCustomInner = (props) => {
265
265
  onCellDoubleClick: ({ row, rowIdx }) => onRowDoubleClick == null ? void 0 : onRowDoubleClick(row, rowIdx)
266
266
  }
267
267
  ),
268
- fetching && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx2(LoadingIcon, { isSpin: true }) })
268
+ fetching && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 flex items-center justify-center bg-white/60 z-10", children: /* @__PURE__ */ jsx2(LoadingIcon, { isSpin: true }) })
269
269
  ]
270
270
  }
271
271
  );
@@ -280,9 +280,9 @@ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
280
280
  var isClient = typeof window !== "undefined";
281
281
  var TableStyleContextWapper = ({
282
282
  children,
283
- contextMenuProps,
283
+ // contextMenuProps,
284
284
  clsTablecustom,
285
- renderContext,
285
+ // renderContext,
286
286
  idWapper: externalId
287
287
  }) => {
288
288
  if (!isClient) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkt-loitd/react-table-grid-custom",
3
- "version": "1.3.10",
3
+ "version": "1.4.2",
4
4
  "description": "React Table Grid Custom component",
5
5
  "license": "ISC",
6
6
  "private": false,