@mkt-loitd/react-table-grid-custom 1.2.2 → 1.2.5
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.css +0 -97
- package/dist/index.d.mts +18 -152
- package/dist/index.d.ts +18 -152
- package/dist/index.js +71 -243
- package/dist/index.mjs +76 -243
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -55,100 +55,3 @@ div[aria-sort] > span {
|
|
|
55
55
|
position: sticky !important;
|
|
56
56
|
right: 0 !important;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
/* src/component/ui/ContextMenu/ContextMenu.css */
|
|
60
|
-
.shadow-menu {
|
|
61
|
-
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
|
|
62
|
-
animation: open 0.3s;
|
|
63
|
-
transform-origin: top left;
|
|
64
|
-
}
|
|
65
|
-
.shadow-submenu {
|
|
66
|
-
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
|
|
67
|
-
}
|
|
68
|
-
@keyframes open {
|
|
69
|
-
from {
|
|
70
|
-
transform: scale(0);
|
|
71
|
-
}
|
|
72
|
-
to {
|
|
73
|
-
transform: scale(1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* node_modules/tippy.js/dist/tippy.css */
|
|
78
|
-
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
79
|
-
opacity: 0;
|
|
80
|
-
}
|
|
81
|
-
[data-tippy-root] {
|
|
82
|
-
max-width: calc(100vw - 10px);
|
|
83
|
-
}
|
|
84
|
-
.tippy-box {
|
|
85
|
-
position: relative;
|
|
86
|
-
background-color: #333;
|
|
87
|
-
color: #fff;
|
|
88
|
-
border-radius: 4px;
|
|
89
|
-
font-size: 14px;
|
|
90
|
-
line-height: 1.4;
|
|
91
|
-
white-space: normal;
|
|
92
|
-
outline: 0;
|
|
93
|
-
transition-property:
|
|
94
|
-
transform,
|
|
95
|
-
visibility,
|
|
96
|
-
opacity;
|
|
97
|
-
}
|
|
98
|
-
.tippy-box[data-placement^=top] > .tippy-arrow {
|
|
99
|
-
bottom: 0;
|
|
100
|
-
}
|
|
101
|
-
.tippy-box[data-placement^=top] > .tippy-arrow:before {
|
|
102
|
-
bottom: -7px;
|
|
103
|
-
left: 0;
|
|
104
|
-
border-width: 8px 8px 0;
|
|
105
|
-
border-top-color: initial;
|
|
106
|
-
transform-origin: center top;
|
|
107
|
-
}
|
|
108
|
-
.tippy-box[data-placement^=bottom] > .tippy-arrow {
|
|
109
|
-
top: 0;
|
|
110
|
-
}
|
|
111
|
-
.tippy-box[data-placement^=bottom] > .tippy-arrow:before {
|
|
112
|
-
top: -7px;
|
|
113
|
-
left: 0;
|
|
114
|
-
border-width: 0 8px 8px;
|
|
115
|
-
border-bottom-color: initial;
|
|
116
|
-
transform-origin: center bottom;
|
|
117
|
-
}
|
|
118
|
-
.tippy-box[data-placement^=left] > .tippy-arrow {
|
|
119
|
-
right: 0;
|
|
120
|
-
}
|
|
121
|
-
.tippy-box[data-placement^=left] > .tippy-arrow:before {
|
|
122
|
-
border-width: 8px 0 8px 8px;
|
|
123
|
-
border-left-color: initial;
|
|
124
|
-
right: -7px;
|
|
125
|
-
transform-origin: center left;
|
|
126
|
-
}
|
|
127
|
-
.tippy-box[data-placement^=right] > .tippy-arrow {
|
|
128
|
-
left: 0;
|
|
129
|
-
}
|
|
130
|
-
.tippy-box[data-placement^=right] > .tippy-arrow:before {
|
|
131
|
-
left: -7px;
|
|
132
|
-
border-width: 8px 8px 8px 0;
|
|
133
|
-
border-right-color: initial;
|
|
134
|
-
transform-origin: center right;
|
|
135
|
-
}
|
|
136
|
-
.tippy-box[data-inertia][data-state=visible] {
|
|
137
|
-
transition-timing-function: cubic-bezier(.54, 1.5, .38, 1.11);
|
|
138
|
-
}
|
|
139
|
-
.tippy-arrow {
|
|
140
|
-
width: 16px;
|
|
141
|
-
height: 16px;
|
|
142
|
-
color: #333;
|
|
143
|
-
}
|
|
144
|
-
.tippy-arrow:before {
|
|
145
|
-
content: "";
|
|
146
|
-
position: absolute;
|
|
147
|
-
border-color: transparent;
|
|
148
|
-
border-style: solid;
|
|
149
|
-
}
|
|
150
|
-
.tippy-content {
|
|
151
|
-
position: relative;
|
|
152
|
-
padding: 5px 9px;
|
|
153
|
-
z-index: 1;
|
|
154
|
-
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Dispatch, SetStateAction, Key, ReactNode, JSX } from 'react';
|
|
1
|
+
import { Dispatch, SetStateAction, Key, ReactNode, JSX, MutableRefObject } from 'react';
|
|
3
2
|
import { ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
|
|
4
3
|
export { Column, ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
|
|
5
4
|
import { PaginationRootProps } from '@mantine/core';
|
|
6
|
-
import { TFunction } from 'i18next';
|
|
7
|
-
import { UseMutateFunction } from '@tanstack/react-query';
|
|
8
5
|
|
|
9
6
|
type TColumnsTable<T = unknown, SR = unknown> = readonly ColumnOrColumnGroup<NoInfer<T>, NoInfer<SR>>[];
|
|
10
7
|
interface IPaginationParams$1 {
|
|
@@ -14,7 +11,7 @@ interface IPaginationParams$1 {
|
|
|
14
11
|
interface IObjectDynamic {
|
|
15
12
|
[key: string]: any;
|
|
16
13
|
}
|
|
17
|
-
interface ISetConfigPagination
|
|
14
|
+
interface ISetConfigPagination extends IPaginationParams$1, IObjectDynamic {
|
|
18
15
|
}
|
|
19
16
|
interface useShowHideColumnParameter<T, SR = unknown> {
|
|
20
17
|
nameLocal?: string;
|
|
@@ -32,6 +29,9 @@ interface useShowHideColumnReturn<T, SR> {
|
|
|
32
29
|
handleFindLocation: (filterColumns: TColumnsTable<T, SR>, locationColumns?: string[]) => TColumnsTable<T, SR>;
|
|
33
30
|
handleChangeLocation?: (arr: string[]) => void;
|
|
34
31
|
}
|
|
32
|
+
interface ICalculatorTotalPage extends IPaginationParams$1 {
|
|
33
|
+
total?: number;
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
declare const useShowHideColumn: <T, SR = unknown>({ nameLocal, columns, ignoreColumns }: useShowHideColumnParameter<T, SR>) => useShowHideColumnReturn<T, SR>;
|
|
37
37
|
|
|
@@ -49,7 +49,7 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
|
|
|
49
49
|
data?: T[];
|
|
50
50
|
/** Nếu hàm onChange nên dùng useCallback */
|
|
51
51
|
onChange?: Pick<PaginationRootProps, 'onChange'>['onChange'];
|
|
52
|
-
setConfigPagination?: Dispatch<SetStateAction<ISetConfigPagination
|
|
52
|
+
setConfigPagination?: Dispatch<SetStateAction<ISetConfigPagination>>;
|
|
53
53
|
/** Nếu hàm rowKeyGetter nên dùng useCallback*/
|
|
54
54
|
rowKeyGetter?: string | Maybe<(row: NoInfer<T>) => K>;
|
|
55
55
|
hiddenPaginationText?: boolean;
|
|
@@ -58,162 +58,28 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
|
|
|
58
58
|
listPageSize?: string[];
|
|
59
59
|
fetching?: boolean;
|
|
60
60
|
TableLogo?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type ReactTableGridCustomComponent = <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => JSX.Element;
|
|
64
|
-
declare const ReactTableGridCustom: ReactTableGridCustomComponent;
|
|
65
|
-
|
|
66
|
-
interface ContextMenuProps {
|
|
67
|
-
selector: string;
|
|
68
|
-
children?: ReactNode;
|
|
69
|
-
zIndex?: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface IMainResponse<T = any> {
|
|
73
|
-
success?: boolean;
|
|
74
|
-
status?: 'success' | 'error' | 'warning';
|
|
75
|
-
data?: T;
|
|
76
|
-
payload?: {
|
|
77
|
-
data?: T;
|
|
78
|
-
[key: string]: any;
|
|
79
|
-
};
|
|
80
|
-
message?: {
|
|
81
|
-
key: string;
|
|
82
|
-
[key: string]: any;
|
|
83
|
-
};
|
|
84
|
-
error?: any;
|
|
85
|
-
}
|
|
86
|
-
interface IFieldUpdateAndCheck<T = any, F = any, V = any> {
|
|
87
|
-
id?: string | number;
|
|
88
|
-
field?: F;
|
|
89
|
-
value?: V;
|
|
90
|
-
data?: T;
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}
|
|
93
|
-
interface Account {
|
|
94
|
-
id?: string | number;
|
|
95
|
-
username?: string;
|
|
96
|
-
password?: string;
|
|
97
|
-
email?: string;
|
|
98
|
-
status?: string;
|
|
99
|
-
[key: string]: any;
|
|
100
|
-
}
|
|
101
|
-
interface Post {
|
|
102
|
-
id?: string | number;
|
|
103
|
-
title?: string;
|
|
104
|
-
content?: string;
|
|
105
|
-
createdAt?: number;
|
|
106
|
-
[key: string]: any;
|
|
107
|
-
}
|
|
108
|
-
interface AppSettings {
|
|
109
|
-
[key: string]: any;
|
|
110
|
-
}
|
|
111
|
-
interface ISetConfigPagination {
|
|
112
|
-
page?: number;
|
|
113
|
-
limit?: number;
|
|
114
|
-
total?: number;
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
}
|
|
117
|
-
type ITaskName = string;
|
|
118
|
-
|
|
119
|
-
interface IActionUiUtilBy {
|
|
120
|
-
action?: string;
|
|
121
|
-
[key: string]: any;
|
|
122
|
-
}
|
|
123
|
-
interface IPayloadStartAction {
|
|
124
|
-
action?: string;
|
|
125
|
-
[key: string]: any;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
interface Proxy {
|
|
129
|
-
id?: string;
|
|
130
|
-
host?: string;
|
|
131
|
-
port?: number;
|
|
132
|
-
username?: string;
|
|
133
|
-
password?: string;
|
|
134
|
-
protocol?: string;
|
|
135
|
-
provider?: string;
|
|
136
61
|
[key: string]: any;
|
|
137
62
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
interface IPayloadService {
|
|
143
|
-
updateByClipboard?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, string[], keyof Account>, unknown>;
|
|
144
|
-
removeFieldBy?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Array<keyof Account>, string[]>, unknown>;
|
|
145
|
-
copyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, string, string[]>, unknown>;
|
|
146
|
-
actionBy?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, IActionUiUtilBy, string[]>, unknown>;
|
|
147
|
-
updateAccountByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Partial<Account>, string[]>, unknown>;
|
|
148
|
-
deleteProxy?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadRemoveProxy, unknown>;
|
|
149
|
-
removePostByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Post, undefined, string[]>, unknown>;
|
|
150
|
-
startAction?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadStartAction, unknown>;
|
|
151
|
-
updateSettings?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<AppSettings, object, boolean>, unknown>;
|
|
152
|
-
useCopyProxyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Proxy, string, string[]>[], unknown>;
|
|
153
|
-
exportLinkSuccess?: UseMutateFunction<IMainResponse<boolean>, Error, ITaskName, unknown>;
|
|
154
|
-
setAction?: Dispatch<SetStateAction<ITaskName>>;
|
|
63
|
+
interface refTablePaginationClient extends Required<IPaginationParams> {
|
|
64
|
+
setConfigSearch: Dispatch<SetStateAction<ISetConfigPagination>>;
|
|
65
|
+
resetPagition: (conditional?: boolean) => void;
|
|
155
66
|
}
|
|
156
67
|
|
|
157
|
-
type
|
|
158
|
-
|
|
159
|
-
interface IExpandValue extends IPayloadService {
|
|
160
|
-
t?: TFunction<any, any> | undefined | any;
|
|
161
|
-
setConfigSearch?: IDispatchState<ISetConfigPagination>;
|
|
162
|
-
setSelectedRecords?: Dispatch<ReadonlySet<string>>;
|
|
163
|
-
setIsShowEdit?: Dispatch<SetStateAction<boolean>>;
|
|
164
|
-
setIsOpenEditContent?: Dispatch<SetStateAction<boolean>>;
|
|
165
|
-
setIsCopy?: Dispatch<SetStateAction<boolean>>;
|
|
166
|
-
setIsChangeCate?: Dispatch<SetStateAction<boolean>>;
|
|
167
|
-
setIsBackup?: Dispatch<SetStateAction<boolean>>;
|
|
168
|
-
}
|
|
169
|
-
type configContextMenuType = {
|
|
170
|
-
Icon: (prop?: any) => ReactNode;
|
|
171
|
-
action: string;
|
|
172
|
-
onClick?: (value: string[], expandValue: IExpandValue) => void;
|
|
173
|
-
children?: configContextMenuType[];
|
|
174
|
-
};
|
|
175
|
-
interface RenderContextMenuProps {
|
|
176
|
-
renderData?: configContextMenuType[];
|
|
177
|
-
valueClickItem?: any;
|
|
178
|
-
expandValue?: IExpandValue;
|
|
179
|
-
classWapper?: boolean;
|
|
180
|
-
}
|
|
68
|
+
type ReactTableGridCustomComponent = <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => JSX.Element;
|
|
69
|
+
declare const ReactTableGridCustom: ReactTableGridCustomComponent;
|
|
181
70
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
renderContext?: RenderContextMenuProps;
|
|
188
|
-
clsTablecustom?: string;
|
|
71
|
+
type ReactTableGridCustomPaginationClientComponent = <T, SR = unknown, K extends Key = Key>(props: ReactTableGridCustomPaginationClientProps<T, SR, K>) => JSX.Element;
|
|
72
|
+
interface ReactTableGridCustomPaginationClientProps<T = unknown, SR = unknown, K extends Key = Key> extends IReactTableGridCustom<T, SR, K> {
|
|
73
|
+
initPage?: number;
|
|
74
|
+
initPageSize?: number;
|
|
75
|
+
refTable?: MutableRefObject<refTablePaginationClient | undefined>;
|
|
189
76
|
}
|
|
190
|
-
declare const
|
|
77
|
+
declare const ReactTableGridCustomPaginationClient: ReactTableGridCustomPaginationClientComponent;
|
|
191
78
|
|
|
192
79
|
interface IPaginationParams {
|
|
193
80
|
pageSize?: number;
|
|
194
81
|
page?: number;
|
|
195
82
|
}
|
|
196
83
|
type Maybe<T> = T | undefined | null;
|
|
197
|
-
interface ICalculatorTotalPage extends IPaginationParams {
|
|
198
|
-
total?: number;
|
|
199
|
-
}
|
|
200
|
-
interface ISTTParams extends IPaginationParams {
|
|
201
|
-
}
|
|
202
|
-
interface UseShowHideColumnParameter<T, SR = unknown> {
|
|
203
|
-
nameLocal?: string;
|
|
204
|
-
/** nếu đầu vào là columns: Functions() thì nên dùng useMemo thì sẽ tối ưu hơn */
|
|
205
|
-
columns: TColumnsTable<T, SR>;
|
|
206
|
-
ignoreColumns?: string[];
|
|
207
|
-
}
|
|
208
|
-
interface UseShowHideColumnReturn<T, SR> {
|
|
209
|
-
hiddenColumns: string[];
|
|
210
|
-
setHiddenColumns: Dispatch<SetStateAction<string[]>>;
|
|
211
|
-
columnsTable: TColumnsTable<T, SR>;
|
|
212
|
-
changeHiddenColumn: (key: string | string[]) => void;
|
|
213
|
-
newShowhideColumns: TColumnsTable<T, SR>;
|
|
214
|
-
locationColumns: string[];
|
|
215
|
-
handleFindLocation: (filterColumns: TColumnsTable<T, SR>, locationColumns?: string[]) => TColumnsTable<T, SR>;
|
|
216
|
-
handleChangeLocation?: (arr: string[]) => void;
|
|
217
|
-
}
|
|
218
84
|
|
|
219
|
-
export { type
|
|
85
|
+
export { type IPaginationParams, type IReactTableGridCustom, type Maybe, ReactTableGridCustom, ReactTableGridCustomPaginationClient, type TColumnsTable, useShowHideColumn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Dispatch, SetStateAction, Key, ReactNode, JSX } from 'react';
|
|
1
|
+
import { Dispatch, SetStateAction, Key, ReactNode, JSX, MutableRefObject } from 'react';
|
|
3
2
|
import { ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
|
|
4
3
|
export { Column, ColumnOrColumnGroup, DataGridProps } from 'react-data-grid';
|
|
5
4
|
import { PaginationRootProps } from '@mantine/core';
|
|
6
|
-
import { TFunction } from 'i18next';
|
|
7
|
-
import { UseMutateFunction } from '@tanstack/react-query';
|
|
8
5
|
|
|
9
6
|
type TColumnsTable<T = unknown, SR = unknown> = readonly ColumnOrColumnGroup<NoInfer<T>, NoInfer<SR>>[];
|
|
10
7
|
interface IPaginationParams$1 {
|
|
@@ -14,7 +11,7 @@ interface IPaginationParams$1 {
|
|
|
14
11
|
interface IObjectDynamic {
|
|
15
12
|
[key: string]: any;
|
|
16
13
|
}
|
|
17
|
-
interface ISetConfigPagination
|
|
14
|
+
interface ISetConfigPagination extends IPaginationParams$1, IObjectDynamic {
|
|
18
15
|
}
|
|
19
16
|
interface useShowHideColumnParameter<T, SR = unknown> {
|
|
20
17
|
nameLocal?: string;
|
|
@@ -32,6 +29,9 @@ interface useShowHideColumnReturn<T, SR> {
|
|
|
32
29
|
handleFindLocation: (filterColumns: TColumnsTable<T, SR>, locationColumns?: string[]) => TColumnsTable<T, SR>;
|
|
33
30
|
handleChangeLocation?: (arr: string[]) => void;
|
|
34
31
|
}
|
|
32
|
+
interface ICalculatorTotalPage extends IPaginationParams$1 {
|
|
33
|
+
total?: number;
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
declare const useShowHideColumn: <T, SR = unknown>({ nameLocal, columns, ignoreColumns }: useShowHideColumnParameter<T, SR>) => useShowHideColumnReturn<T, SR>;
|
|
37
37
|
|
|
@@ -49,7 +49,7 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
|
|
|
49
49
|
data?: T[];
|
|
50
50
|
/** Nếu hàm onChange nên dùng useCallback */
|
|
51
51
|
onChange?: Pick<PaginationRootProps, 'onChange'>['onChange'];
|
|
52
|
-
setConfigPagination?: Dispatch<SetStateAction<ISetConfigPagination
|
|
52
|
+
setConfigPagination?: Dispatch<SetStateAction<ISetConfigPagination>>;
|
|
53
53
|
/** Nếu hàm rowKeyGetter nên dùng useCallback*/
|
|
54
54
|
rowKeyGetter?: string | Maybe<(row: NoInfer<T>) => K>;
|
|
55
55
|
hiddenPaginationText?: boolean;
|
|
@@ -58,162 +58,28 @@ interface IReactTableGridCustom<T = unknown, SR = unknown, K extends Key = Key>
|
|
|
58
58
|
listPageSize?: string[];
|
|
59
59
|
fetching?: boolean;
|
|
60
60
|
TableLogo?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type ReactTableGridCustomComponent = <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => JSX.Element;
|
|
64
|
-
declare const ReactTableGridCustom: ReactTableGridCustomComponent;
|
|
65
|
-
|
|
66
|
-
interface ContextMenuProps {
|
|
67
|
-
selector: string;
|
|
68
|
-
children?: ReactNode;
|
|
69
|
-
zIndex?: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface IMainResponse<T = any> {
|
|
73
|
-
success?: boolean;
|
|
74
|
-
status?: 'success' | 'error' | 'warning';
|
|
75
|
-
data?: T;
|
|
76
|
-
payload?: {
|
|
77
|
-
data?: T;
|
|
78
|
-
[key: string]: any;
|
|
79
|
-
};
|
|
80
|
-
message?: {
|
|
81
|
-
key: string;
|
|
82
|
-
[key: string]: any;
|
|
83
|
-
};
|
|
84
|
-
error?: any;
|
|
85
|
-
}
|
|
86
|
-
interface IFieldUpdateAndCheck<T = any, F = any, V = any> {
|
|
87
|
-
id?: string | number;
|
|
88
|
-
field?: F;
|
|
89
|
-
value?: V;
|
|
90
|
-
data?: T;
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}
|
|
93
|
-
interface Account {
|
|
94
|
-
id?: string | number;
|
|
95
|
-
username?: string;
|
|
96
|
-
password?: string;
|
|
97
|
-
email?: string;
|
|
98
|
-
status?: string;
|
|
99
|
-
[key: string]: any;
|
|
100
|
-
}
|
|
101
|
-
interface Post {
|
|
102
|
-
id?: string | number;
|
|
103
|
-
title?: string;
|
|
104
|
-
content?: string;
|
|
105
|
-
createdAt?: number;
|
|
106
|
-
[key: string]: any;
|
|
107
|
-
}
|
|
108
|
-
interface AppSettings {
|
|
109
|
-
[key: string]: any;
|
|
110
|
-
}
|
|
111
|
-
interface ISetConfigPagination {
|
|
112
|
-
page?: number;
|
|
113
|
-
limit?: number;
|
|
114
|
-
total?: number;
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
}
|
|
117
|
-
type ITaskName = string;
|
|
118
|
-
|
|
119
|
-
interface IActionUiUtilBy {
|
|
120
|
-
action?: string;
|
|
121
|
-
[key: string]: any;
|
|
122
|
-
}
|
|
123
|
-
interface IPayloadStartAction {
|
|
124
|
-
action?: string;
|
|
125
|
-
[key: string]: any;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
interface Proxy {
|
|
129
|
-
id?: string;
|
|
130
|
-
host?: string;
|
|
131
|
-
port?: number;
|
|
132
|
-
username?: string;
|
|
133
|
-
password?: string;
|
|
134
|
-
protocol?: string;
|
|
135
|
-
provider?: string;
|
|
136
61
|
[key: string]: any;
|
|
137
62
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
interface IPayloadService {
|
|
143
|
-
updateByClipboard?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, string[], keyof Account>, unknown>;
|
|
144
|
-
removeFieldBy?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Array<keyof Account>, string[]>, unknown>;
|
|
145
|
-
copyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, string, string[]>, unknown>;
|
|
146
|
-
actionBy?: UseMutateFunction<IMainResponse<string[]>, Error, IFieldUpdateAndCheck<Account, IActionUiUtilBy, string[]>, unknown>;
|
|
147
|
-
updateAccountByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Account, Partial<Account>, string[]>, unknown>;
|
|
148
|
-
deleteProxy?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadRemoveProxy, unknown>;
|
|
149
|
-
removePostByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Post, undefined, string[]>, unknown>;
|
|
150
|
-
startAction?: UseMutateFunction<IMainResponse<boolean>, Error, IPayloadStartAction, unknown>;
|
|
151
|
-
updateSettings?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<AppSettings, object, boolean>, unknown>;
|
|
152
|
-
useCopyProxyByField?: UseMutateFunction<IMainResponse<boolean>, Error, IFieldUpdateAndCheck<Proxy, string, string[]>[], unknown>;
|
|
153
|
-
exportLinkSuccess?: UseMutateFunction<IMainResponse<boolean>, Error, ITaskName, unknown>;
|
|
154
|
-
setAction?: Dispatch<SetStateAction<ITaskName>>;
|
|
63
|
+
interface refTablePaginationClient extends Required<IPaginationParams> {
|
|
64
|
+
setConfigSearch: Dispatch<SetStateAction<ISetConfigPagination>>;
|
|
65
|
+
resetPagition: (conditional?: boolean) => void;
|
|
155
66
|
}
|
|
156
67
|
|
|
157
|
-
type
|
|
158
|
-
|
|
159
|
-
interface IExpandValue extends IPayloadService {
|
|
160
|
-
t?: TFunction<any, any> | undefined | any;
|
|
161
|
-
setConfigSearch?: IDispatchState<ISetConfigPagination>;
|
|
162
|
-
setSelectedRecords?: Dispatch<ReadonlySet<string>>;
|
|
163
|
-
setIsShowEdit?: Dispatch<SetStateAction<boolean>>;
|
|
164
|
-
setIsOpenEditContent?: Dispatch<SetStateAction<boolean>>;
|
|
165
|
-
setIsCopy?: Dispatch<SetStateAction<boolean>>;
|
|
166
|
-
setIsChangeCate?: Dispatch<SetStateAction<boolean>>;
|
|
167
|
-
setIsBackup?: Dispatch<SetStateAction<boolean>>;
|
|
168
|
-
}
|
|
169
|
-
type configContextMenuType = {
|
|
170
|
-
Icon: (prop?: any) => ReactNode;
|
|
171
|
-
action: string;
|
|
172
|
-
onClick?: (value: string[], expandValue: IExpandValue) => void;
|
|
173
|
-
children?: configContextMenuType[];
|
|
174
|
-
};
|
|
175
|
-
interface RenderContextMenuProps {
|
|
176
|
-
renderData?: configContextMenuType[];
|
|
177
|
-
valueClickItem?: any;
|
|
178
|
-
expandValue?: IExpandValue;
|
|
179
|
-
classWapper?: boolean;
|
|
180
|
-
}
|
|
68
|
+
type ReactTableGridCustomComponent = <T, SR = unknown, K extends Key = Key>(props: IReactTableGridCustom<T, SR, K>) => JSX.Element;
|
|
69
|
+
declare const ReactTableGridCustom: ReactTableGridCustomComponent;
|
|
181
70
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
renderContext?: RenderContextMenuProps;
|
|
188
|
-
clsTablecustom?: string;
|
|
71
|
+
type ReactTableGridCustomPaginationClientComponent = <T, SR = unknown, K extends Key = Key>(props: ReactTableGridCustomPaginationClientProps<T, SR, K>) => JSX.Element;
|
|
72
|
+
interface ReactTableGridCustomPaginationClientProps<T = unknown, SR = unknown, K extends Key = Key> extends IReactTableGridCustom<T, SR, K> {
|
|
73
|
+
initPage?: number;
|
|
74
|
+
initPageSize?: number;
|
|
75
|
+
refTable?: MutableRefObject<refTablePaginationClient | undefined>;
|
|
189
76
|
}
|
|
190
|
-
declare const
|
|
77
|
+
declare const ReactTableGridCustomPaginationClient: ReactTableGridCustomPaginationClientComponent;
|
|
191
78
|
|
|
192
79
|
interface IPaginationParams {
|
|
193
80
|
pageSize?: number;
|
|
194
81
|
page?: number;
|
|
195
82
|
}
|
|
196
83
|
type Maybe<T> = T | undefined | null;
|
|
197
|
-
interface ICalculatorTotalPage extends IPaginationParams {
|
|
198
|
-
total?: number;
|
|
199
|
-
}
|
|
200
|
-
interface ISTTParams extends IPaginationParams {
|
|
201
|
-
}
|
|
202
|
-
interface UseShowHideColumnParameter<T, SR = unknown> {
|
|
203
|
-
nameLocal?: string;
|
|
204
|
-
/** nếu đầu vào là columns: Functions() thì nên dùng useMemo thì sẽ tối ưu hơn */
|
|
205
|
-
columns: TColumnsTable<T, SR>;
|
|
206
|
-
ignoreColumns?: string[];
|
|
207
|
-
}
|
|
208
|
-
interface UseShowHideColumnReturn<T, SR> {
|
|
209
|
-
hiddenColumns: string[];
|
|
210
|
-
setHiddenColumns: Dispatch<SetStateAction<string[]>>;
|
|
211
|
-
columnsTable: TColumnsTable<T, SR>;
|
|
212
|
-
changeHiddenColumn: (key: string | string[]) => void;
|
|
213
|
-
newShowhideColumns: TColumnsTable<T, SR>;
|
|
214
|
-
locationColumns: string[];
|
|
215
|
-
handleFindLocation: (filterColumns: TColumnsTable<T, SR>, locationColumns?: string[]) => TColumnsTable<T, SR>;
|
|
216
|
-
handleChangeLocation?: (arr: string[]) => void;
|
|
217
|
-
}
|
|
218
84
|
|
|
219
|
-
export { type
|
|
85
|
+
export { type IPaginationParams, type IReactTableGridCustom, type Maybe, ReactTableGridCustom, ReactTableGridCustomPaginationClient, type TColumnsTable, useShowHideColumn };
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ReactTableGridCustom: () => ReactTableGridCustom,
|
|
34
|
-
|
|
34
|
+
ReactTableGridCustomPaginationClient: () => ReactTableGridCustomPaginationClient,
|
|
35
35
|
useShowHideColumn: () => useShowHideColumn
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -445,263 +445,91 @@ var ReactTableGridCustom = (0, import_react3.memo)(
|
|
|
445
445
|
ReactTableGridCustomInner
|
|
446
446
|
);
|
|
447
447
|
|
|
448
|
-
// src/component/ui/Table/
|
|
449
|
-
var
|
|
448
|
+
// src/component/ui/Table/ReactTableGridCustomPaginationClient.tsx
|
|
449
|
+
var import_react5 = require("react");
|
|
450
450
|
|
|
451
|
-
// src/
|
|
451
|
+
// src/hooks/useDataPagingClient.ts
|
|
452
452
|
var import_react4 = require("react");
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const contextMenuElem = menuRef.current;
|
|
459
|
-
const elementParent = document.querySelector(selector);
|
|
460
|
-
if (contextMenuElem && contextMenuElem.classList.contains("shadow-menu")) {
|
|
461
|
-
contextMenuElem.classList.remove("shadow-menu");
|
|
462
|
-
contextMenuElem.style.opacity = "0";
|
|
463
|
-
contextMenuElem.style.visibility = "hidden";
|
|
464
|
-
}
|
|
465
|
-
if (elementParent) {
|
|
466
|
-
elementParent.style.removeProperty("overflow");
|
|
453
|
+
var useDataPagingClient = ({ data = [], page, pageSize }) => {
|
|
454
|
+
const newData = (0, import_react4.useMemo)(() => {
|
|
455
|
+
if (page && pageSize) {
|
|
456
|
+
const startIndex = (page - 1) * pageSize;
|
|
457
|
+
return data.slice(startIndex, startIndex + pageSize);
|
|
467
458
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (elementParent) {
|
|
472
|
-
const clickMenu = (e) => {
|
|
473
|
-
const contextMenuElem = menuRef.current;
|
|
474
|
-
if (contextMenuElem) {
|
|
475
|
-
contextMenuElem.style.opacity = "1";
|
|
476
|
-
contextMenuElem.style.visibility = "visible";
|
|
477
|
-
const { width: widthContextMenu, height: heightContextMenu } = contextMenuElem.getBoundingClientRect();
|
|
478
|
-
elementParent.style.overflow = "hidden";
|
|
479
|
-
const maxWidth = window.innerWidth;
|
|
480
|
-
const maxHeight = window.innerHeight;
|
|
481
|
-
const remainingLeft = maxWidth - e.clientX;
|
|
482
|
-
const isLeft = remainingLeft >= widthContextMenu;
|
|
483
|
-
const showTop = heightContextMenu + e.clientY <= maxHeight;
|
|
484
|
-
const showBottom = e.clientY - heightContextMenu >= 0;
|
|
485
|
-
const isCenter = !(showTop || showBottom);
|
|
486
|
-
isCenter;
|
|
487
|
-
const styleOrigin = {
|
|
488
|
-
x: "left",
|
|
489
|
-
y: "top"
|
|
490
|
-
};
|
|
491
|
-
if (isLeft) {
|
|
492
|
-
contextMenuElem.style.left = `${e.clientX}px`;
|
|
493
|
-
styleOrigin.x = "left";
|
|
494
|
-
} else {
|
|
495
|
-
contextMenuElem.style.left = `${e.clientX - widthContextMenu}px`;
|
|
496
|
-
styleOrigin.x = "right";
|
|
497
|
-
}
|
|
498
|
-
if (showTop) {
|
|
499
|
-
contextMenuElem.style.top = `${e.clientY}px`;
|
|
500
|
-
styleOrigin.y = "top";
|
|
501
|
-
} else if (showBottom) {
|
|
502
|
-
contextMenuElem.style.top = `${e.clientY - heightContextMenu}px`;
|
|
503
|
-
styleOrigin.y = "bottom";
|
|
504
|
-
} else {
|
|
505
|
-
const HalfHeight = heightContextMenu / 2;
|
|
506
|
-
const calculatorTop = HalfHeight + e.clientY;
|
|
507
|
-
const showTopCenter = calculatorTop <= maxHeight;
|
|
508
|
-
const calculatorBottom = e.clientY - HalfHeight;
|
|
509
|
-
const showBottom2 = calculatorBottom >= 0;
|
|
510
|
-
let topNew = calculatorBottom;
|
|
511
|
-
if (!showBottom2 && showTopCenter) {
|
|
512
|
-
topNew = topNew - calculatorBottom;
|
|
513
|
-
} else if (!showTopCenter && showBottom2) {
|
|
514
|
-
const ts = calculatorTop - maxHeight;
|
|
515
|
-
topNew = topNew - ts;
|
|
516
|
-
}
|
|
517
|
-
contextMenuElem.style.top = `${topNew}px`;
|
|
518
|
-
styleOrigin.y = "center";
|
|
519
|
-
}
|
|
520
|
-
contextMenuElem.style.transformOrigin = `${styleOrigin.y} ${styleOrigin.x}`;
|
|
521
|
-
if (!contextMenuElem.classList.contains("shadow-menu")) {
|
|
522
|
-
contextMenuElem.classList.add("shadow-menu");
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
elementParent.addEventListener("contextmenu", clickMenu);
|
|
527
|
-
window.addEventListener("click", closeMenu);
|
|
528
|
-
return () => {
|
|
529
|
-
elementParent.removeEventListener("contextmenu", clickMenu);
|
|
530
|
-
window.removeEventListener("click", closeMenu);
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
return () => {
|
|
534
|
-
};
|
|
535
|
-
}, []);
|
|
536
|
-
return (0, import_react_dom.createPortal)(
|
|
537
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
538
|
-
"div",
|
|
539
|
-
{
|
|
540
|
-
className: "fixed z-40 w-fit",
|
|
541
|
-
ref: menuRef,
|
|
542
|
-
style: { opacity: 0, visibility: "hidden", zIndex },
|
|
543
|
-
children
|
|
544
|
-
}
|
|
545
|
-
),
|
|
546
|
-
document.body
|
|
547
|
-
);
|
|
459
|
+
return data;
|
|
460
|
+
}, [data, page, pageSize]);
|
|
461
|
+
return newData;
|
|
548
462
|
};
|
|
549
|
-
var
|
|
550
|
-
|
|
551
|
-
// src/component/ui/ContextMenu/RenderContextMenu.tsx
|
|
552
|
-
var import_react7 = require("react");
|
|
463
|
+
var useDataPagingClient_default = useDataPagingClient;
|
|
553
464
|
|
|
554
|
-
// src/component/ui/
|
|
555
|
-
var
|
|
556
|
-
var
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
show,
|
|
563
|
-
isArrow
|
|
465
|
+
// src/component/ui/Table/ReactTableGridCustomPaginationClient.tsx
|
|
466
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
467
|
+
var ReactTableGridCustomPaginationClientInner = ({
|
|
468
|
+
data,
|
|
469
|
+
initPage = 1,
|
|
470
|
+
initPageSize = 200,
|
|
471
|
+
refTable,
|
|
472
|
+
...spread
|
|
564
473
|
}) => {
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
var
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
{
|
|
595
|
-
theme: "drop-down",
|
|
596
|
-
className: "!bg-transparent !text-inherit !border-r-0 [&>*]:!p-0",
|
|
597
|
-
appendTo: document.body,
|
|
598
|
-
arrow: false,
|
|
599
|
-
placement: "auto",
|
|
600
|
-
interactive: true,
|
|
601
|
-
allowHTML: true,
|
|
602
|
-
content: children,
|
|
603
|
-
...rest,
|
|
604
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
605
|
-
"div",
|
|
606
|
-
{
|
|
607
|
-
id: `div-${id}`,
|
|
608
|
-
onClick: () => {
|
|
609
|
-
var _a;
|
|
610
|
-
(_a = instanceRef == null ? void 0 : instanceRef.current) == null ? void 0 : _a.show();
|
|
611
|
-
},
|
|
612
|
-
children: button
|
|
474
|
+
const [configSearch, setConfigSearch] = (0, import_react5.useState)({
|
|
475
|
+
page: initPage,
|
|
476
|
+
pageSize: initPageSize
|
|
477
|
+
});
|
|
478
|
+
const newDataAccount = useDataPagingClient_default({
|
|
479
|
+
data,
|
|
480
|
+
page: configSearch == null ? void 0 : configSearch.page,
|
|
481
|
+
pageSize: configSearch == null ? void 0 : configSearch.pageSize
|
|
482
|
+
});
|
|
483
|
+
const resetPage = (0, import_react5.useCallback)(() => {
|
|
484
|
+
setConfigSearch((prev) => ({
|
|
485
|
+
...prev,
|
|
486
|
+
page: 1
|
|
487
|
+
}));
|
|
488
|
+
}, []);
|
|
489
|
+
(0, import_react5.useImperativeHandle)(
|
|
490
|
+
refTable,
|
|
491
|
+
() => {
|
|
492
|
+
var _a, _b;
|
|
493
|
+
return {
|
|
494
|
+
setConfigSearch,
|
|
495
|
+
page: (_a = configSearch == null ? void 0 : configSearch.page) != null ? _a : initPage,
|
|
496
|
+
pageSize: (_b = configSearch == null ? void 0 : configSearch.pageSize) != null ? _b : initPageSize,
|
|
497
|
+
resetPagition: (conditional = true) => {
|
|
498
|
+
if (conditional && (configSearch == null ? void 0 : configSearch.page) !== 1) {
|
|
499
|
+
resetPage();
|
|
500
|
+
} else {
|
|
501
|
+
resetPage();
|
|
502
|
+
}
|
|
613
503
|
}
|
|
614
|
-
|
|
615
|
-
}
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
[
|
|
507
|
+
setConfigSearch,
|
|
508
|
+
configSearch == null ? void 0 : configSearch.page,
|
|
509
|
+
configSearch == null ? void 0 : configSearch.pageSize,
|
|
510
|
+
initPage,
|
|
511
|
+
initPageSize,
|
|
512
|
+
resetPage
|
|
513
|
+
]
|
|
616
514
|
);
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
// src/component/ui/ContextMenu/RenderContextMenu.tsx
|
|
621
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
622
|
-
var RenderContextMenu = ({
|
|
623
|
-
renderData,
|
|
624
|
-
valueClickItem,
|
|
625
|
-
expandValue = {}
|
|
626
|
-
}) => {
|
|
627
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "bg-white shadow-submenu p-1 min-w-[250px] border", children: renderData == null ? void 0 : renderData.map((menuAction, index) => {
|
|
628
|
-
const [isShow, setIsShow] = (0, import_react7.useState)(false);
|
|
629
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react7.Fragment, { children: [
|
|
630
|
-
!(menuAction == null ? void 0 : menuAction.children) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
631
|
-
ContextMenuItem_default,
|
|
632
|
-
{
|
|
633
|
-
currentValue: menuAction,
|
|
634
|
-
expandValue,
|
|
635
|
-
valueClickItem
|
|
636
|
-
}
|
|
637
|
-
),
|
|
638
|
-
(menuAction == null ? void 0 : menuAction.children) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
639
|
-
DropdownContextChild_default,
|
|
640
|
-
{
|
|
641
|
-
appendTo: "parent",
|
|
642
|
-
placement: "right",
|
|
643
|
-
offset: [0, 5],
|
|
644
|
-
onShow: () => setIsShow(true),
|
|
645
|
-
onHide: () => setIsShow(false),
|
|
646
|
-
button: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
647
|
-
ContextMenuItem_default,
|
|
648
|
-
{
|
|
649
|
-
currentValue: menuAction,
|
|
650
|
-
expandValue,
|
|
651
|
-
valueClickItem,
|
|
652
|
-
show: isShow,
|
|
653
|
-
isArrow: true
|
|
654
|
-
}
|
|
655
|
-
),
|
|
656
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "dropdown-context-child absolute -top-[20px] -left-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
657
|
-
RenderContextMenu,
|
|
658
|
-
{
|
|
659
|
-
renderData: menuAction == null ? void 0 : menuAction.children,
|
|
660
|
-
expandValue,
|
|
661
|
-
valueClickItem
|
|
662
|
-
}
|
|
663
|
-
) })
|
|
664
|
-
}
|
|
665
|
-
)
|
|
666
|
-
] }, index);
|
|
667
|
-
}) });
|
|
668
|
-
};
|
|
669
|
-
var RenderContextMenu_default = RenderContextMenu;
|
|
670
|
-
|
|
671
|
-
// src/component/ui/Table/TableStyleContextWapper.tsx
|
|
672
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
673
|
-
var TableStyleContextMenuWapper = ({
|
|
674
|
-
children,
|
|
675
|
-
contextMenuProps,
|
|
676
|
-
clsTablecustom,
|
|
677
|
-
renderContext
|
|
678
|
-
}) => {
|
|
679
|
-
const idWapper = (0, import_react8.useId)();
|
|
680
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
681
|
-
"div",
|
|
515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
516
|
+
ReactTableGridCustom,
|
|
682
517
|
{
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
selector: `[id="wapper_menu_context-${idWapper}"] .rdg`,
|
|
690
|
-
...contextMenuProps,
|
|
691
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderContextMenu_default, { ...renderContext })
|
|
692
|
-
}
|
|
693
|
-
),
|
|
694
|
-
children
|
|
695
|
-
]
|
|
518
|
+
data: newDataAccount,
|
|
519
|
+
total: (data == null ? void 0 : data.length) || 0,
|
|
520
|
+
page: configSearch == null ? void 0 : configSearch.page,
|
|
521
|
+
pageSize: configSearch == null ? void 0 : configSearch.pageSize,
|
|
522
|
+
setConfigPagination: setConfigSearch,
|
|
523
|
+
...spread
|
|
696
524
|
}
|
|
697
525
|
);
|
|
698
526
|
};
|
|
699
|
-
var
|
|
700
|
-
|
|
527
|
+
var ReactTableGridCustomPaginationClient = (0, import_react5.memo)(
|
|
528
|
+
ReactTableGridCustomPaginationClientInner
|
|
701
529
|
);
|
|
702
530
|
// Annotate the CommonJS export names for ESM import in node:
|
|
703
531
|
0 && (module.exports = {
|
|
704
532
|
ReactTableGridCustom,
|
|
705
|
-
|
|
533
|
+
ReactTableGridCustomPaginationClient,
|
|
706
534
|
useShowHideColumn
|
|
707
535
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -417,262 +417,95 @@ var ReactTableGridCustom = memo(
|
|
|
417
417
|
ReactTableGridCustomInner
|
|
418
418
|
);
|
|
419
419
|
|
|
420
|
-
// src/component/ui/Table/
|
|
421
|
-
import {
|
|
420
|
+
// src/component/ui/Table/ReactTableGridCustomPaginationClient.tsx
|
|
421
|
+
import {
|
|
422
|
+
memo as memo2,
|
|
423
|
+
useCallback as useCallback3,
|
|
424
|
+
useImperativeHandle,
|
|
425
|
+
useState as useState3
|
|
426
|
+
} from "react";
|
|
422
427
|
|
|
423
|
-
// src/
|
|
424
|
-
import {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const contextMenuElem = menuRef.current;
|
|
431
|
-
const elementParent = document.querySelector(selector);
|
|
432
|
-
if (contextMenuElem && contextMenuElem.classList.contains("shadow-menu")) {
|
|
433
|
-
contextMenuElem.classList.remove("shadow-menu");
|
|
434
|
-
contextMenuElem.style.opacity = "0";
|
|
435
|
-
contextMenuElem.style.visibility = "hidden";
|
|
436
|
-
}
|
|
437
|
-
if (elementParent) {
|
|
438
|
-
elementParent.style.removeProperty("overflow");
|
|
428
|
+
// src/hooks/useDataPagingClient.ts
|
|
429
|
+
import { useMemo as useMemo4 } from "react";
|
|
430
|
+
var useDataPagingClient = ({ data = [], page, pageSize }) => {
|
|
431
|
+
const newData = useMemo4(() => {
|
|
432
|
+
if (page && pageSize) {
|
|
433
|
+
const startIndex = (page - 1) * pageSize;
|
|
434
|
+
return data.slice(startIndex, startIndex + pageSize);
|
|
439
435
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (elementParent) {
|
|
444
|
-
const clickMenu = (e) => {
|
|
445
|
-
const contextMenuElem = menuRef.current;
|
|
446
|
-
if (contextMenuElem) {
|
|
447
|
-
contextMenuElem.style.opacity = "1";
|
|
448
|
-
contextMenuElem.style.visibility = "visible";
|
|
449
|
-
const { width: widthContextMenu, height: heightContextMenu } = contextMenuElem.getBoundingClientRect();
|
|
450
|
-
elementParent.style.overflow = "hidden";
|
|
451
|
-
const maxWidth = window.innerWidth;
|
|
452
|
-
const maxHeight = window.innerHeight;
|
|
453
|
-
const remainingLeft = maxWidth - e.clientX;
|
|
454
|
-
const isLeft = remainingLeft >= widthContextMenu;
|
|
455
|
-
const showTop = heightContextMenu + e.clientY <= maxHeight;
|
|
456
|
-
const showBottom = e.clientY - heightContextMenu >= 0;
|
|
457
|
-
const isCenter = !(showTop || showBottom);
|
|
458
|
-
isCenter;
|
|
459
|
-
const styleOrigin = {
|
|
460
|
-
x: "left",
|
|
461
|
-
y: "top"
|
|
462
|
-
};
|
|
463
|
-
if (isLeft) {
|
|
464
|
-
contextMenuElem.style.left = `${e.clientX}px`;
|
|
465
|
-
styleOrigin.x = "left";
|
|
466
|
-
} else {
|
|
467
|
-
contextMenuElem.style.left = `${e.clientX - widthContextMenu}px`;
|
|
468
|
-
styleOrigin.x = "right";
|
|
469
|
-
}
|
|
470
|
-
if (showTop) {
|
|
471
|
-
contextMenuElem.style.top = `${e.clientY}px`;
|
|
472
|
-
styleOrigin.y = "top";
|
|
473
|
-
} else if (showBottom) {
|
|
474
|
-
contextMenuElem.style.top = `${e.clientY - heightContextMenu}px`;
|
|
475
|
-
styleOrigin.y = "bottom";
|
|
476
|
-
} else {
|
|
477
|
-
const HalfHeight = heightContextMenu / 2;
|
|
478
|
-
const calculatorTop = HalfHeight + e.clientY;
|
|
479
|
-
const showTopCenter = calculatorTop <= maxHeight;
|
|
480
|
-
const calculatorBottom = e.clientY - HalfHeight;
|
|
481
|
-
const showBottom2 = calculatorBottom >= 0;
|
|
482
|
-
let topNew = calculatorBottom;
|
|
483
|
-
if (!showBottom2 && showTopCenter) {
|
|
484
|
-
topNew = topNew - calculatorBottom;
|
|
485
|
-
} else if (!showTopCenter && showBottom2) {
|
|
486
|
-
const ts = calculatorTop - maxHeight;
|
|
487
|
-
topNew = topNew - ts;
|
|
488
|
-
}
|
|
489
|
-
contextMenuElem.style.top = `${topNew}px`;
|
|
490
|
-
styleOrigin.y = "center";
|
|
491
|
-
}
|
|
492
|
-
contextMenuElem.style.transformOrigin = `${styleOrigin.y} ${styleOrigin.x}`;
|
|
493
|
-
if (!contextMenuElem.classList.contains("shadow-menu")) {
|
|
494
|
-
contextMenuElem.classList.add("shadow-menu");
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
elementParent.addEventListener("contextmenu", clickMenu);
|
|
499
|
-
window.addEventListener("click", closeMenu);
|
|
500
|
-
return () => {
|
|
501
|
-
elementParent.removeEventListener("contextmenu", clickMenu);
|
|
502
|
-
window.removeEventListener("click", closeMenu);
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
return () => {
|
|
506
|
-
};
|
|
507
|
-
}, []);
|
|
508
|
-
return createPortal(
|
|
509
|
-
/* @__PURE__ */ jsx4(
|
|
510
|
-
"div",
|
|
511
|
-
{
|
|
512
|
-
className: "fixed z-40 w-fit",
|
|
513
|
-
ref: menuRef,
|
|
514
|
-
style: { opacity: 0, visibility: "hidden", zIndex },
|
|
515
|
-
children
|
|
516
|
-
}
|
|
517
|
-
),
|
|
518
|
-
document.body
|
|
519
|
-
);
|
|
436
|
+
return data;
|
|
437
|
+
}, [data, page, pageSize]);
|
|
438
|
+
return newData;
|
|
520
439
|
};
|
|
521
|
-
var
|
|
522
|
-
|
|
523
|
-
// src/component/ui/ContextMenu/RenderContextMenu.tsx
|
|
524
|
-
import { Fragment as Fragment2, useState as useState3 } from "react";
|
|
440
|
+
var useDataPagingClient_default = useDataPagingClient;
|
|
525
441
|
|
|
526
|
-
// src/component/ui/
|
|
527
|
-
import {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
show,
|
|
535
|
-
isArrow
|
|
442
|
+
// src/component/ui/Table/ReactTableGridCustomPaginationClient.tsx
|
|
443
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
444
|
+
var ReactTableGridCustomPaginationClientInner = ({
|
|
445
|
+
data,
|
|
446
|
+
initPage = 1,
|
|
447
|
+
initPageSize = 200,
|
|
448
|
+
refTable,
|
|
449
|
+
...spread
|
|
536
450
|
}) => {
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
var
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
{
|
|
567
|
-
theme: "drop-down",
|
|
568
|
-
className: "!bg-transparent !text-inherit !border-r-0 [&>*]:!p-0",
|
|
569
|
-
appendTo: document.body,
|
|
570
|
-
arrow: false,
|
|
571
|
-
placement: "auto",
|
|
572
|
-
interactive: true,
|
|
573
|
-
allowHTML: true,
|
|
574
|
-
content: children,
|
|
575
|
-
...rest,
|
|
576
|
-
children: /* @__PURE__ */ jsx6(
|
|
577
|
-
"div",
|
|
578
|
-
{
|
|
579
|
-
id: `div-${id}`,
|
|
580
|
-
onClick: () => {
|
|
581
|
-
var _a;
|
|
582
|
-
(_a = instanceRef == null ? void 0 : instanceRef.current) == null ? void 0 : _a.show();
|
|
583
|
-
},
|
|
584
|
-
children: button
|
|
451
|
+
const [configSearch, setConfigSearch] = useState3({
|
|
452
|
+
page: initPage,
|
|
453
|
+
pageSize: initPageSize
|
|
454
|
+
});
|
|
455
|
+
const newDataAccount = useDataPagingClient_default({
|
|
456
|
+
data,
|
|
457
|
+
page: configSearch == null ? void 0 : configSearch.page,
|
|
458
|
+
pageSize: configSearch == null ? void 0 : configSearch.pageSize
|
|
459
|
+
});
|
|
460
|
+
const resetPage = useCallback3(() => {
|
|
461
|
+
setConfigSearch((prev) => ({
|
|
462
|
+
...prev,
|
|
463
|
+
page: 1
|
|
464
|
+
}));
|
|
465
|
+
}, []);
|
|
466
|
+
useImperativeHandle(
|
|
467
|
+
refTable,
|
|
468
|
+
() => {
|
|
469
|
+
var _a, _b;
|
|
470
|
+
return {
|
|
471
|
+
setConfigSearch,
|
|
472
|
+
page: (_a = configSearch == null ? void 0 : configSearch.page) != null ? _a : initPage,
|
|
473
|
+
pageSize: (_b = configSearch == null ? void 0 : configSearch.pageSize) != null ? _b : initPageSize,
|
|
474
|
+
resetPagition: (conditional = true) => {
|
|
475
|
+
if (conditional && (configSearch == null ? void 0 : configSearch.page) !== 1) {
|
|
476
|
+
resetPage();
|
|
477
|
+
} else {
|
|
478
|
+
resetPage();
|
|
479
|
+
}
|
|
585
480
|
}
|
|
586
|
-
|
|
587
|
-
}
|
|
481
|
+
};
|
|
482
|
+
},
|
|
483
|
+
[
|
|
484
|
+
setConfigSearch,
|
|
485
|
+
configSearch == null ? void 0 : configSearch.page,
|
|
486
|
+
configSearch == null ? void 0 : configSearch.pageSize,
|
|
487
|
+
initPage,
|
|
488
|
+
initPageSize,
|
|
489
|
+
resetPage
|
|
490
|
+
]
|
|
588
491
|
);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
// src/component/ui/ContextMenu/RenderContextMenu.tsx
|
|
593
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
594
|
-
var RenderContextMenu = ({
|
|
595
|
-
renderData,
|
|
596
|
-
valueClickItem,
|
|
597
|
-
expandValue = {}
|
|
598
|
-
}) => {
|
|
599
|
-
return /* @__PURE__ */ jsx7("div", { className: "bg-white shadow-submenu p-1 min-w-[250px] border", children: renderData == null ? void 0 : renderData.map((menuAction, index) => {
|
|
600
|
-
const [isShow, setIsShow] = useState3(false);
|
|
601
|
-
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
602
|
-
!(menuAction == null ? void 0 : menuAction.children) && /* @__PURE__ */ jsx7(
|
|
603
|
-
ContextMenuItem_default,
|
|
604
|
-
{
|
|
605
|
-
currentValue: menuAction,
|
|
606
|
-
expandValue,
|
|
607
|
-
valueClickItem
|
|
608
|
-
}
|
|
609
|
-
),
|
|
610
|
-
(menuAction == null ? void 0 : menuAction.children) && /* @__PURE__ */ jsx7(
|
|
611
|
-
DropdownContextChild_default,
|
|
612
|
-
{
|
|
613
|
-
appendTo: "parent",
|
|
614
|
-
placement: "right",
|
|
615
|
-
offset: [0, 5],
|
|
616
|
-
onShow: () => setIsShow(true),
|
|
617
|
-
onHide: () => setIsShow(false),
|
|
618
|
-
button: /* @__PURE__ */ jsx7(
|
|
619
|
-
ContextMenuItem_default,
|
|
620
|
-
{
|
|
621
|
-
currentValue: menuAction,
|
|
622
|
-
expandValue,
|
|
623
|
-
valueClickItem,
|
|
624
|
-
show: isShow,
|
|
625
|
-
isArrow: true
|
|
626
|
-
}
|
|
627
|
-
),
|
|
628
|
-
children: /* @__PURE__ */ jsx7("div", { className: "dropdown-context-child absolute -top-[20px] -left-1", children: /* @__PURE__ */ jsx7(
|
|
629
|
-
RenderContextMenu,
|
|
630
|
-
{
|
|
631
|
-
renderData: menuAction == null ? void 0 : menuAction.children,
|
|
632
|
-
expandValue,
|
|
633
|
-
valueClickItem
|
|
634
|
-
}
|
|
635
|
-
) })
|
|
636
|
-
}
|
|
637
|
-
)
|
|
638
|
-
] }, index);
|
|
639
|
-
}) });
|
|
640
|
-
};
|
|
641
|
-
var RenderContextMenu_default = RenderContextMenu;
|
|
642
|
-
|
|
643
|
-
// src/component/ui/Table/TableStyleContextWapper.tsx
|
|
644
|
-
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
645
|
-
var TableStyleContextMenuWapper = ({
|
|
646
|
-
children,
|
|
647
|
-
contextMenuProps,
|
|
648
|
-
clsTablecustom,
|
|
649
|
-
renderContext
|
|
650
|
-
}) => {
|
|
651
|
-
const idWapper = useId2();
|
|
652
|
-
return /* @__PURE__ */ jsxs5(
|
|
653
|
-
"div",
|
|
492
|
+
return /* @__PURE__ */ jsx4(
|
|
493
|
+
ReactTableGridCustom,
|
|
654
494
|
{
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
selector: `[id="wapper_menu_context-${idWapper}"] .rdg`,
|
|
662
|
-
...contextMenuProps,
|
|
663
|
-
children: /* @__PURE__ */ jsx8(RenderContextMenu_default, { ...renderContext })
|
|
664
|
-
}
|
|
665
|
-
),
|
|
666
|
-
children
|
|
667
|
-
]
|
|
495
|
+
data: newDataAccount,
|
|
496
|
+
total: (data == null ? void 0 : data.length) || 0,
|
|
497
|
+
page: configSearch == null ? void 0 : configSearch.page,
|
|
498
|
+
pageSize: configSearch == null ? void 0 : configSearch.pageSize,
|
|
499
|
+
setConfigPagination: setConfigSearch,
|
|
500
|
+
...spread
|
|
668
501
|
}
|
|
669
502
|
);
|
|
670
503
|
};
|
|
671
|
-
var
|
|
672
|
-
|
|
504
|
+
var ReactTableGridCustomPaginationClient = memo2(
|
|
505
|
+
ReactTableGridCustomPaginationClientInner
|
|
673
506
|
);
|
|
674
507
|
export {
|
|
675
508
|
ReactTableGridCustom,
|
|
676
|
-
|
|
509
|
+
ReactTableGridCustomPaginationClient,
|
|
677
510
|
useShowHideColumn
|
|
678
511
|
};
|