react-table-edit 0.4.6 → 0.4.8
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +145 -70
- package/dist/index.mjs +163 -89
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
3
3
|
import { TFunction } from 'react-i18next';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
type ITextAlign = 'center' | 'left' | 'right';
|
|
6
7
|
type IEditType = 'text' | 'numeric' | 'asyncSelect' | 'datetime' | 'selectMulti' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'color';
|
|
@@ -184,4 +185,14 @@ declare const objSymbolThousand: any;
|
|
|
184
185
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean) => string;
|
|
185
186
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
type IFDataProps = {
|
|
189
|
+
buttonWidth?: number;
|
|
190
|
+
tabParent?: boolean;
|
|
191
|
+
tabChild?: boolean;
|
|
192
|
+
resourceCodeParent?: string;
|
|
193
|
+
resourceCode: string;
|
|
194
|
+
resources: any[];
|
|
195
|
+
};
|
|
196
|
+
declare const TabsMenuComponent: ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode }: IFDataProps) => react_jsx_runtime.JSX.Element;
|
|
197
|
+
|
|
198
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFToolbarOptions, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TabsMenuComponent, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, objSymbolDecimal, objSymbolThousand, roundNumber, useOnClickOutside };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
3
3
|
import { TFunction } from 'react-i18next';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
type ITextAlign = 'center' | 'left' | 'right';
|
|
6
7
|
type IEditType = 'text' | 'numeric' | 'asyncSelect' | 'datetime' | 'selectMulti' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'color';
|
|
@@ -184,4 +185,14 @@ declare const objSymbolThousand: any;
|
|
|
184
185
|
declare const formartNumberic: (str: string | number, decimalSeparator: string, thousandSeparator: string, fraction?: number, isDone?: boolean) => string;
|
|
185
186
|
declare const roundNumber: (num: number, fraction: number) => number;
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
type IFDataProps = {
|
|
189
|
+
buttonWidth?: number;
|
|
190
|
+
tabParent?: boolean;
|
|
191
|
+
tabChild?: boolean;
|
|
192
|
+
resourceCodeParent?: string;
|
|
193
|
+
resourceCode: string;
|
|
194
|
+
resources: any[];
|
|
195
|
+
};
|
|
196
|
+
declare const TabsMenuComponent: ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode }: IFDataProps) => react_jsx_runtime.JSX.Element;
|
|
197
|
+
|
|
198
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditButton, type IFTableEditPaging, type IFTableEditProps, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFToolbarOptions, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TabsMenuComponent, TableEdit as default, formartNumberic, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, objSymbolDecimal, objSymbolThousand, roundNumber, useOnClickOutside };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// index.ts
|
|
31
31
|
var Table_edit_exports = {};
|
|
32
32
|
__export(Table_edit_exports, {
|
|
33
|
+
TabsMenuComponent: () => TabsMenuComponent,
|
|
33
34
|
default: () => Table_edit_default,
|
|
34
35
|
formartNumberic: () => formartNumberic,
|
|
35
36
|
generateUUID: () => generateUUID,
|
|
@@ -72,6 +73,11 @@ var ReactInput = (props) => {
|
|
|
72
73
|
setValue("");
|
|
73
74
|
setSearchTerm("");
|
|
74
75
|
};
|
|
76
|
+
(0, import_react.useEffect)(() => {
|
|
77
|
+
if (!props.value) {
|
|
78
|
+
setValue("");
|
|
79
|
+
}
|
|
80
|
+
}, [props.value]);
|
|
75
81
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
76
82
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
83
|
import_reactstrap.Input,
|
|
@@ -1535,7 +1541,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
1535
1541
|
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
1536
1542
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
1537
1543
|
(0, import_react12.useEffect)(() => {
|
|
1538
|
-
if (pagingClient && pagingSetting.setCurrentPage &&
|
|
1544
|
+
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
1539
1545
|
pagingSetting.setCurrentPage(1);
|
|
1540
1546
|
}
|
|
1541
1547
|
}, [dataSource]);
|
|
@@ -2163,6 +2169,18 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2163
2169
|
}, 100);
|
|
2164
2170
|
}
|
|
2165
2171
|
};
|
|
2172
|
+
const focusNewElement = (idElement, onLoad = false) => {
|
|
2173
|
+
setTimeout(() => {
|
|
2174
|
+
const element = document.getElementById(idElement);
|
|
2175
|
+
if (element) {
|
|
2176
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2177
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
2178
|
+
} else {
|
|
2179
|
+
element.focus();
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}, onLoad ? 100 : 0);
|
|
2183
|
+
};
|
|
2166
2184
|
const checkKeyDown = (e, row, col, indexRow, indexCol) => {
|
|
2167
2185
|
if (e.code === "ArrowRight") {
|
|
2168
2186
|
let newIndexCol = -1;
|
|
@@ -2173,14 +2191,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2173
2191
|
}
|
|
2174
2192
|
}
|
|
2175
2193
|
if (newIndexCol > -1) {
|
|
2176
|
-
|
|
2177
|
-
if (element) {
|
|
2178
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2179
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2180
|
-
} else {
|
|
2181
|
-
element.focus();
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2194
|
+
focusNewElement(`${idTable}-col${newIndexCol}-row${indexRow}`);
|
|
2184
2195
|
e.preventDefault();
|
|
2185
2196
|
return e.code;
|
|
2186
2197
|
}
|
|
@@ -2193,14 +2204,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2193
2204
|
}
|
|
2194
2205
|
}
|
|
2195
2206
|
if (newIndexCol > -1) {
|
|
2196
|
-
|
|
2197
|
-
if (element) {
|
|
2198
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2199
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2200
|
-
} else {
|
|
2201
|
-
element.focus();
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2207
|
+
focusNewElement(`${idTable}-col${newIndexCol}-row${indexRow}`);
|
|
2204
2208
|
e.preventDefault();
|
|
2205
2209
|
return e.code;
|
|
2206
2210
|
}
|
|
@@ -2212,16 +2216,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2212
2216
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) - 1);
|
|
2213
2217
|
}
|
|
2214
2218
|
setIndexFocus(indexRow - 2);
|
|
2215
|
-
|
|
2216
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow - 1}`);
|
|
2217
|
-
if (element2) {
|
|
2218
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2219
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2220
|
-
} else {
|
|
2221
|
-
element2.focus();
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
}, 100);
|
|
2219
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow - 1}`, true);
|
|
2225
2220
|
e.preventDefault();
|
|
2226
2221
|
return e.code;
|
|
2227
2222
|
}
|
|
@@ -2234,16 +2229,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2234
2229
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2235
2230
|
}
|
|
2236
2231
|
setIndexFocus(indexRow);
|
|
2237
|
-
|
|
2238
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2239
|
-
if (element2) {
|
|
2240
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2241
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2242
|
-
} else {
|
|
2243
|
-
element2.focus();
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
}, 100);
|
|
2232
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2247
2233
|
e.preventDefault();
|
|
2248
2234
|
return e.code;
|
|
2249
2235
|
}
|
|
@@ -2256,16 +2242,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2256
2242
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2257
2243
|
}
|
|
2258
2244
|
setIndexFocus(indexRow);
|
|
2259
|
-
|
|
2260
|
-
const element = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2261
|
-
if (element) {
|
|
2262
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2263
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2264
|
-
} else {
|
|
2265
|
-
element.focus();
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
}, 100);
|
|
2245
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2269
2246
|
}
|
|
2270
2247
|
e.preventDefault();
|
|
2271
2248
|
return e.code;
|
|
@@ -2279,16 +2256,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2279
2256
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2280
2257
|
}
|
|
2281
2258
|
setIndexFocus(indexRow);
|
|
2282
|
-
|
|
2283
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2284
|
-
if (element2) {
|
|
2285
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2286
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2287
|
-
} else {
|
|
2288
|
-
element2.focus();
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
}, 100);
|
|
2259
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2292
2260
|
}
|
|
2293
2261
|
e.preventDefault();
|
|
2294
2262
|
return e.code;
|
|
@@ -2329,22 +2297,13 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2329
2297
|
});
|
|
2330
2298
|
const handleAdd = () => {
|
|
2331
2299
|
changeDataSource(dataSource, true);
|
|
2300
|
+
const lengthData = dataSource.length - 1;
|
|
2332
2301
|
if (pagingSetting?.setCurrentPage) {
|
|
2333
|
-
pagingSetting?.setCurrentPage(Math.floor(
|
|
2302
|
+
pagingSetting?.setCurrentPage(Math.floor(lengthData / (pagingSetting?.pageSize ?? 0)) + 1);
|
|
2334
2303
|
}
|
|
2335
2304
|
if (tableElement) {
|
|
2336
|
-
setIndexFocus(
|
|
2337
|
-
|
|
2338
|
-
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
2339
|
-
const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${totalCount + 1}`);
|
|
2340
|
-
if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("select-100__control--menu-is-open").length > 0 || element.getElementsByClassName("select-200__control--menu-is-open").length > 0 || element.getElementsByClassName("select-300__control--menu-is-open").length > 0 || element.getElementsByClassName("select-400__control--menu-is-open").length > 0 || element.getElementsByClassName("select-500__control--menu-is-open").length > 0)) {
|
|
2341
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2342
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2343
|
-
} else {
|
|
2344
|
-
element.focus();
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
}, 100);
|
|
2305
|
+
setIndexFocus(lengthData);
|
|
2306
|
+
focusNewElement(`${idTable}-col${columnFistEdit}-row${lengthData + 1}`, true);
|
|
2348
2307
|
}
|
|
2349
2308
|
};
|
|
2350
2309
|
const handleDuplicate = (data, index) => {
|
|
@@ -2427,6 +2386,14 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2427
2386
|
};
|
|
2428
2387
|
const changeDataSource = (data, haveNew = false) => {
|
|
2429
2388
|
if (!editDisable && !addDisable && setDataSource) {
|
|
2389
|
+
if (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm) {
|
|
2390
|
+
console.log("\xE1dads");
|
|
2391
|
+
if (searchSetting?.setSearchTerm) {
|
|
2392
|
+
searchSetting?.setSearchTerm("");
|
|
2393
|
+
} else {
|
|
2394
|
+
setSearchTerm("");
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2430
2397
|
if (haveNew) {
|
|
2431
2398
|
data.push(defaultValue ? { ...defaultValue, [fieldKey]: generateUUID() } : {});
|
|
2432
2399
|
setDataSource([...data]);
|
|
@@ -2936,6 +2903,11 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2936
2903
|
}
|
|
2937
2904
|
});
|
|
2938
2905
|
};
|
|
2906
|
+
(0, import_react12.useEffect)(() => {
|
|
2907
|
+
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
2908
|
+
pagingSetting?.setCurrentPage(1);
|
|
2909
|
+
}
|
|
2910
|
+
}, [searchTerm, searchSetting?.searchTerm]);
|
|
2939
2911
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react12.Fragment, { children: [
|
|
2940
2912
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "react-table-edit", children: [
|
|
2941
2913
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "r-grid", ref: gridRef, children: [
|
|
@@ -2989,11 +2961,114 @@ var import_react13 = require("react");
|
|
|
2989
2961
|
var import_react_router_dom = require("react-router-dom");
|
|
2990
2962
|
var import_reactstrap9 = require("reactstrap");
|
|
2991
2963
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2964
|
+
var TabsMenuComponent = ({
|
|
2965
|
+
buttonWidth,
|
|
2966
|
+
tabParent,
|
|
2967
|
+
tabChild,
|
|
2968
|
+
resourceCodeParent,
|
|
2969
|
+
resources,
|
|
2970
|
+
resourceCode
|
|
2971
|
+
}) => {
|
|
2972
|
+
const [dataMenu, setDataMenu] = (0, import_react13.useState)([]);
|
|
2973
|
+
const [openMenu, setOpenMenu] = (0, import_react13.useState)(false);
|
|
2974
|
+
const [url, setUrl] = (0, import_react13.useState)("");
|
|
2975
|
+
const [contentWidth, setContentWidth] = (0, import_react13.useState)(0);
|
|
2976
|
+
const [componentWidth, setComponentWidth] = (0, import_react13.useState)(0);
|
|
2977
|
+
const [scrollPosition, setScrollPosition] = (0, import_react13.useState)(0);
|
|
2978
|
+
const handleWindowResize = () => {
|
|
2979
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2980
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2981
|
+
if (tabEle && tabContent) {
|
|
2982
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2983
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
(0, import_react13.useEffect)(() => {
|
|
2987
|
+
setUrl(window.location.pathname);
|
|
2988
|
+
window.addEventListener("resize", handleWindowResize);
|
|
2989
|
+
setTimeout(() => {
|
|
2990
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2991
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2992
|
+
if (tabEle && tabContent) {
|
|
2993
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2994
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2995
|
+
}
|
|
2996
|
+
}, 100);
|
|
2997
|
+
return () => {
|
|
2998
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
2999
|
+
};
|
|
3000
|
+
}, []);
|
|
3001
|
+
(0, import_react13.useEffect)(() => {
|
|
3002
|
+
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
3003
|
+
if (item) {
|
|
3004
|
+
if (resourceCodeParent) {
|
|
3005
|
+
const data = item.children?.find((x) => x.code === resourceCode);
|
|
3006
|
+
if (data) {
|
|
3007
|
+
setDataMenu([...data.children]);
|
|
3008
|
+
}
|
|
3009
|
+
} else {
|
|
3010
|
+
setDataMenu([...item.children]);
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
}, [resources]);
|
|
3014
|
+
const toggleMenu = () => {
|
|
3015
|
+
setOpenMenu(!openMenu);
|
|
3016
|
+
};
|
|
3017
|
+
const handleScroll = (scrollAmount) => {
|
|
3018
|
+
let newScrollPosition = scrollPosition + scrollAmount;
|
|
3019
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3020
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
3021
|
+
if (tabEle && tabContent && tabContent?.offsetWidth - tabEle?.offsetWidth - newScrollPosition > -200) {
|
|
3022
|
+
if (newScrollPosition < 0) {
|
|
3023
|
+
newScrollPosition = 0;
|
|
3024
|
+
}
|
|
3025
|
+
setScrollPosition(newScrollPosition);
|
|
3026
|
+
tabEle.scrollLeft = newScrollPosition;
|
|
3027
|
+
}
|
|
3028
|
+
};
|
|
3029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_classnames11.default)("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
3030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3031
|
+
"div",
|
|
3032
|
+
{
|
|
3033
|
+
onClick: () => handleScroll(-200),
|
|
3034
|
+
className: (0, import_classnames11.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3035
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_becoxy_icons5.ChevronLeft, {})
|
|
3036
|
+
}
|
|
3037
|
+
),
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3039
|
+
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_reactstrap9.UncontrolledDropdown, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
3041
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownToggle, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: item.name }) }),
|
|
3042
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownMenu, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownItem, { style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%", padding: "0.5rem 0.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_router_dom.Link, { to: x.url, style: { display: "block", width: "100%" }, children: x.name }) }, x.code)) })
|
|
3043
|
+
] }, item.code);
|
|
3044
|
+
} else {
|
|
3045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3046
|
+
import_react_router_dom.Link,
|
|
3047
|
+
{
|
|
3048
|
+
to: item.url,
|
|
3049
|
+
className: (0, import_classnames11.default)("tab-custom-item", { active: item.url === url || tabParent && url?.split("/").length > 3 && item.url.startsWith(url.substring(0, url.lastIndexOf("/"))) }),
|
|
3050
|
+
children: item.name
|
|
3051
|
+
},
|
|
3052
|
+
item.code
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
}) }) }),
|
|
3056
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3057
|
+
"div",
|
|
3058
|
+
{
|
|
3059
|
+
onClick: () => handleScroll(200),
|
|
3060
|
+
className: (0, import_classnames11.default)("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3061
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_becoxy_icons5.ChevronRight, {})
|
|
3062
|
+
}
|
|
3063
|
+
)
|
|
3064
|
+
] }) });
|
|
3065
|
+
};
|
|
2992
3066
|
|
|
2993
3067
|
// index.ts
|
|
2994
3068
|
var Table_edit_default = table_default;
|
|
2995
3069
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2996
3070
|
0 && (module.exports = {
|
|
3071
|
+
TabsMenuComponent,
|
|
2997
3072
|
formartNumberic,
|
|
2998
3073
|
generateUUID,
|
|
2999
3074
|
isNullOrUndefined,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// test-app/src/component/table/index.tsx
|
|
2
|
-
import { Fragment as Fragment12, forwardRef as forwardRef2, useEffect as
|
|
2
|
+
import { Fragment as Fragment12, forwardRef as forwardRef2, useEffect as useEffect6, useImperativeHandle, useRef as useRef2, useState as useState5 } from "react";
|
|
3
3
|
import { Button as Button3, DropdownMenu as DropdownMenu2, DropdownToggle as DropdownToggle2, Input as Input6, UncontrolledDropdown } from "reactstrap";
|
|
4
4
|
import classnames6 from "classnames";
|
|
5
5
|
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
@@ -11,7 +11,7 @@ import { AlertCircle, Info as Info2, Settings } from "becoxy-icons";
|
|
|
11
11
|
// test-app/src/component/react-input/index.tsx
|
|
12
12
|
import { X } from "becoxy-icons";
|
|
13
13
|
import classNames from "classnames";
|
|
14
|
-
import { Fragment, useState } from "react";
|
|
14
|
+
import { Fragment, useEffect, useState } from "react";
|
|
15
15
|
import { Input } from "reactstrap";
|
|
16
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
var ReactInput = (props) => {
|
|
@@ -21,6 +21,11 @@ var ReactInput = (props) => {
|
|
|
21
21
|
setValue("");
|
|
22
22
|
setSearchTerm("");
|
|
23
23
|
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!props.value) {
|
|
26
|
+
setValue("");
|
|
27
|
+
}
|
|
28
|
+
}, [props.value]);
|
|
24
29
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
30
|
/* @__PURE__ */ jsx(
|
|
26
31
|
Input,
|
|
@@ -178,9 +183,9 @@ var messageBoxConfirm2 = async (t, data, data2, message) => {
|
|
|
178
183
|
};
|
|
179
184
|
|
|
180
185
|
// test-app/src/component/utils.ts
|
|
181
|
-
import { useEffect } from "react";
|
|
186
|
+
import { useEffect as useEffect2 } from "react";
|
|
182
187
|
var useOnClickOutside = (ref, handler) => {
|
|
183
|
-
|
|
188
|
+
useEffect2(
|
|
184
189
|
() => {
|
|
185
190
|
const listener = (event) => {
|
|
186
191
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
@@ -293,7 +298,7 @@ import moment from "moment";
|
|
|
293
298
|
import { DropDownTreeComponent } from "@syncfusion/ej2-react-dropdowns";
|
|
294
299
|
|
|
295
300
|
// test-app/src/component/edit-form/index.tsx
|
|
296
|
-
import { forwardRef, useEffect as
|
|
301
|
+
import { forwardRef, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
297
302
|
import {
|
|
298
303
|
DropdownItem,
|
|
299
304
|
DropdownMenu,
|
|
@@ -748,14 +753,14 @@ var EditForm = forwardRef((props, ref) => {
|
|
|
748
753
|
defaultValues,
|
|
749
754
|
resolver: yupResolver(schema)
|
|
750
755
|
});
|
|
751
|
-
|
|
756
|
+
useEffect3(() => {
|
|
752
757
|
if (dropdownOpen) {
|
|
753
758
|
if (onFormOpen && itemsField.length === 0) {
|
|
754
759
|
onFormOpen(rowData, itemsField, setItemsField);
|
|
755
760
|
}
|
|
756
761
|
}
|
|
757
762
|
}, [dropdownOpen]);
|
|
758
|
-
|
|
763
|
+
useEffect3(() => {
|
|
759
764
|
if (dropdownOpen && itemsField.length > 0) {
|
|
760
765
|
itemsField.forEach((ele) => {
|
|
761
766
|
setValue(ele.name, rowData[ele.name] ?? "");
|
|
@@ -1031,7 +1036,7 @@ var EditForm = forwardRef((props, ref) => {
|
|
|
1031
1036
|
var edit_form_default = EditForm;
|
|
1032
1037
|
|
|
1033
1038
|
// test-app/src/component/sidebar-setting-column/index.tsx
|
|
1034
|
-
import { Fragment as Fragment10, useEffect as
|
|
1039
|
+
import { Fragment as Fragment10, useEffect as useEffect5, useState as useState4 } from "react";
|
|
1035
1040
|
import { Button as Button2, Input as Input5 } from "reactstrap";
|
|
1036
1041
|
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1037
1042
|
|
|
@@ -1082,7 +1087,7 @@ var modal_header_default = ModalHeader;
|
|
|
1082
1087
|
// test-app/src/component/sidebar/index.tsx
|
|
1083
1088
|
import { ChevronLeft, ChevronRight } from "becoxy-icons";
|
|
1084
1089
|
import classNames4 from "classnames";
|
|
1085
|
-
import { useEffect as
|
|
1090
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
1086
1091
|
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1087
1092
|
var Sidebar = (props) => {
|
|
1088
1093
|
const {
|
|
@@ -1096,7 +1101,7 @@ var Sidebar = (props) => {
|
|
|
1096
1101
|
} = props;
|
|
1097
1102
|
const [isFullScreen, setIsFullScreen] = useState3(false);
|
|
1098
1103
|
const [flag, setFlag] = useState3(open);
|
|
1099
|
-
|
|
1104
|
+
useEffect4(() => {
|
|
1100
1105
|
if (open !== flag) {
|
|
1101
1106
|
if (open) {
|
|
1102
1107
|
setFlag(open);
|
|
@@ -1191,7 +1196,7 @@ var SidebarSetColumn = (props) => {
|
|
|
1191
1196
|
const { t } = useTranslation7();
|
|
1192
1197
|
const [dataSource, setDataSource] = useState4([]);
|
|
1193
1198
|
const [indexFocus, setIndexFocus] = useState4();
|
|
1194
|
-
|
|
1199
|
+
useEffect5(() => {
|
|
1195
1200
|
if (openSidebar) {
|
|
1196
1201
|
setDataSource(column.map((e) => ({ ...e })));
|
|
1197
1202
|
}
|
|
@@ -1209,7 +1214,7 @@ var SidebarSetColumn = (props) => {
|
|
|
1209
1214
|
return { innerWidth, innerHeight };
|
|
1210
1215
|
};
|
|
1211
1216
|
const [windowSize, setWindowSize] = useState4(getWindowSize());
|
|
1212
|
-
|
|
1217
|
+
useEffect5(() => {
|
|
1213
1218
|
const handleWindowResize = () => {
|
|
1214
1219
|
setWindowSize(getWindowSize());
|
|
1215
1220
|
};
|
|
@@ -1493,12 +1498,12 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1493
1498
|
let totalCount = dataSource.length;
|
|
1494
1499
|
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
1495
1500
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
1496
|
-
|
|
1497
|
-
if (pagingClient && pagingSetting.setCurrentPage &&
|
|
1501
|
+
useEffect6(() => {
|
|
1502
|
+
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
1498
1503
|
pagingSetting.setCurrentPage(1);
|
|
1499
1504
|
}
|
|
1500
1505
|
}, [dataSource]);
|
|
1501
|
-
|
|
1506
|
+
useEffect6(() => {
|
|
1502
1507
|
let indexFirst = -1;
|
|
1503
1508
|
let indexlast = -1;
|
|
1504
1509
|
let letfWidthFix = 0;
|
|
@@ -1531,7 +1536,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1531
1536
|
setColumnFistEdit(indexFirst + 1);
|
|
1532
1537
|
setColumnlastEdit(indexlast + 1);
|
|
1533
1538
|
}, [contentColumns]);
|
|
1534
|
-
|
|
1539
|
+
useEffect6(() => {
|
|
1535
1540
|
const arrHeaderColumns = [];
|
|
1536
1541
|
const arrContentColumns = [];
|
|
1537
1542
|
let headerLevelRow = 0;
|
|
@@ -1548,7 +1553,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1548
1553
|
setHeaderColumns(arrHeaderColumns);
|
|
1549
1554
|
setContentColumns(arrContentColumns);
|
|
1550
1555
|
}, [columns]);
|
|
1551
|
-
|
|
1556
|
+
useEffect6(() => {
|
|
1552
1557
|
const arrHeaderColumns = [];
|
|
1553
1558
|
const arrContentColumns = [];
|
|
1554
1559
|
let headerLevelRow = 0;
|
|
@@ -2122,6 +2127,18 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2122
2127
|
}, 100);
|
|
2123
2128
|
}
|
|
2124
2129
|
};
|
|
2130
|
+
const focusNewElement = (idElement, onLoad = false) => {
|
|
2131
|
+
setTimeout(() => {
|
|
2132
|
+
const element = document.getElementById(idElement);
|
|
2133
|
+
if (element) {
|
|
2134
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2135
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
2136
|
+
} else {
|
|
2137
|
+
element.focus();
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}, onLoad ? 100 : 0);
|
|
2141
|
+
};
|
|
2125
2142
|
const checkKeyDown = (e, row, col, indexRow, indexCol) => {
|
|
2126
2143
|
if (e.code === "ArrowRight") {
|
|
2127
2144
|
let newIndexCol = -1;
|
|
@@ -2132,14 +2149,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2132
2149
|
}
|
|
2133
2150
|
}
|
|
2134
2151
|
if (newIndexCol > -1) {
|
|
2135
|
-
|
|
2136
|
-
if (element) {
|
|
2137
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2138
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2139
|
-
} else {
|
|
2140
|
-
element.focus();
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2152
|
+
focusNewElement(`${idTable}-col${newIndexCol}-row${indexRow}`);
|
|
2143
2153
|
e.preventDefault();
|
|
2144
2154
|
return e.code;
|
|
2145
2155
|
}
|
|
@@ -2152,14 +2162,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2152
2162
|
}
|
|
2153
2163
|
}
|
|
2154
2164
|
if (newIndexCol > -1) {
|
|
2155
|
-
|
|
2156
|
-
if (element) {
|
|
2157
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2158
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2159
|
-
} else {
|
|
2160
|
-
element.focus();
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2165
|
+
focusNewElement(`${idTable}-col${newIndexCol}-row${indexRow}`);
|
|
2163
2166
|
e.preventDefault();
|
|
2164
2167
|
return e.code;
|
|
2165
2168
|
}
|
|
@@ -2171,16 +2174,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2171
2174
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) - 1);
|
|
2172
2175
|
}
|
|
2173
2176
|
setIndexFocus(indexRow - 2);
|
|
2174
|
-
|
|
2175
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow - 1}`);
|
|
2176
|
-
if (element2) {
|
|
2177
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2178
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2179
|
-
} else {
|
|
2180
|
-
element2.focus();
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
}, 100);
|
|
2177
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow - 1}`, true);
|
|
2184
2178
|
e.preventDefault();
|
|
2185
2179
|
return e.code;
|
|
2186
2180
|
}
|
|
@@ -2193,16 +2187,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2193
2187
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2194
2188
|
}
|
|
2195
2189
|
setIndexFocus(indexRow);
|
|
2196
|
-
|
|
2197
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2198
|
-
if (element2) {
|
|
2199
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2200
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2201
|
-
} else {
|
|
2202
|
-
element2.focus();
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
}, 100);
|
|
2190
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2206
2191
|
e.preventDefault();
|
|
2207
2192
|
return e.code;
|
|
2208
2193
|
}
|
|
@@ -2215,16 +2200,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2215
2200
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2216
2201
|
}
|
|
2217
2202
|
setIndexFocus(indexRow);
|
|
2218
|
-
|
|
2219
|
-
const element = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2220
|
-
if (element) {
|
|
2221
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2222
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2223
|
-
} else {
|
|
2224
|
-
element.focus();
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
}, 100);
|
|
2203
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2228
2204
|
}
|
|
2229
2205
|
e.preventDefault();
|
|
2230
2206
|
return e.code;
|
|
@@ -2238,16 +2214,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2238
2214
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
2239
2215
|
}
|
|
2240
2216
|
setIndexFocus(indexRow);
|
|
2241
|
-
|
|
2242
|
-
const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
|
|
2243
|
-
if (element2) {
|
|
2244
|
-
if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
|
|
2245
|
-
element2.getElementsByTagName("input")[0]?.focus();
|
|
2246
|
-
} else {
|
|
2247
|
-
element2.focus();
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
}, 100);
|
|
2217
|
+
focusNewElement(`${idTable}-col${indexCol}-row${indexRow + 1}`, true);
|
|
2251
2218
|
}
|
|
2252
2219
|
e.preventDefault();
|
|
2253
2220
|
return e.code;
|
|
@@ -2288,22 +2255,13 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2288
2255
|
});
|
|
2289
2256
|
const handleAdd = () => {
|
|
2290
2257
|
changeDataSource(dataSource, true);
|
|
2258
|
+
const lengthData = dataSource.length - 1;
|
|
2291
2259
|
if (pagingSetting?.setCurrentPage) {
|
|
2292
|
-
pagingSetting?.setCurrentPage(Math.floor(
|
|
2260
|
+
pagingSetting?.setCurrentPage(Math.floor(lengthData / (pagingSetting?.pageSize ?? 0)) + 1);
|
|
2293
2261
|
}
|
|
2294
2262
|
if (tableElement) {
|
|
2295
|
-
setIndexFocus(
|
|
2296
|
-
|
|
2297
|
-
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
2298
|
-
const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${totalCount + 1}`);
|
|
2299
|
-
if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("select-100__control--menu-is-open").length > 0 || element.getElementsByClassName("select-200__control--menu-is-open").length > 0 || element.getElementsByClassName("select-300__control--menu-is-open").length > 0 || element.getElementsByClassName("select-400__control--menu-is-open").length > 0 || element.getElementsByClassName("select-500__control--menu-is-open").length > 0)) {
|
|
2300
|
-
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
2301
|
-
element.getElementsByTagName("input")[0]?.focus();
|
|
2302
|
-
} else {
|
|
2303
|
-
element.focus();
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
}, 100);
|
|
2263
|
+
setIndexFocus(lengthData);
|
|
2264
|
+
focusNewElement(`${idTable}-col${columnFistEdit}-row${lengthData + 1}`, true);
|
|
2307
2265
|
}
|
|
2308
2266
|
};
|
|
2309
2267
|
const handleDuplicate = (data, index) => {
|
|
@@ -2386,6 +2344,14 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2386
2344
|
};
|
|
2387
2345
|
const changeDataSource = (data, haveNew = false) => {
|
|
2388
2346
|
if (!editDisable && !addDisable && setDataSource) {
|
|
2347
|
+
if (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm) {
|
|
2348
|
+
console.log("\xE1dads");
|
|
2349
|
+
if (searchSetting?.setSearchTerm) {
|
|
2350
|
+
searchSetting?.setSearchTerm("");
|
|
2351
|
+
} else {
|
|
2352
|
+
setSearchTerm("");
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2389
2355
|
if (haveNew) {
|
|
2390
2356
|
data.push(defaultValue ? { ...defaultValue, [fieldKey]: generateUUID() } : {});
|
|
2391
2357
|
setDataSource([...data]);
|
|
@@ -2394,7 +2360,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2394
2360
|
}
|
|
2395
2361
|
}
|
|
2396
2362
|
};
|
|
2397
|
-
|
|
2363
|
+
useEffect6(() => {
|
|
2398
2364
|
setIndexFocus(-1);
|
|
2399
2365
|
if (setSelectedItem) {
|
|
2400
2366
|
if (isMulti) {
|
|
@@ -2421,7 +2387,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2421
2387
|
}
|
|
2422
2388
|
}
|
|
2423
2389
|
}, [selectedRows]);
|
|
2424
|
-
|
|
2390
|
+
useEffect6(() => {
|
|
2425
2391
|
if (!isMulti) {
|
|
2426
2392
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
2427
2393
|
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
@@ -2895,6 +2861,11 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2895
2861
|
}
|
|
2896
2862
|
});
|
|
2897
2863
|
};
|
|
2864
|
+
useEffect6(() => {
|
|
2865
|
+
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
2866
|
+
pagingSetting?.setCurrentPage(1);
|
|
2867
|
+
}
|
|
2868
|
+
}, [searchTerm, searchSetting?.searchTerm]);
|
|
2898
2869
|
return /* @__PURE__ */ jsxs11(Fragment12, { children: [
|
|
2899
2870
|
/* @__PURE__ */ jsxs11("div", { className: "react-table-edit", children: [
|
|
2900
2871
|
/* @__PURE__ */ jsxs11("div", { className: "r-grid", ref: gridRef, children: [
|
|
@@ -2944,14 +2915,117 @@ var table_default = TableEdit;
|
|
|
2944
2915
|
// test-app/src/component/tab-menu/index.tsx
|
|
2945
2916
|
import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2 } from "becoxy-icons";
|
|
2946
2917
|
import classNames5 from "classnames";
|
|
2947
|
-
import { Fragment as Fragment14, useEffect as
|
|
2918
|
+
import { Fragment as Fragment14, useEffect as useEffect7, useState as useState6 } from "react";
|
|
2948
2919
|
import { Link } from "react-router-dom";
|
|
2949
2920
|
import { DropdownItem as DropdownItem2, DropdownMenu as DropdownMenu3, DropdownToggle as DropdownToggle3, UncontrolledDropdown as UncontrolledDropdown2 } from "reactstrap";
|
|
2950
2921
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2922
|
+
var TabsMenuComponent = ({
|
|
2923
|
+
buttonWidth,
|
|
2924
|
+
tabParent,
|
|
2925
|
+
tabChild,
|
|
2926
|
+
resourceCodeParent,
|
|
2927
|
+
resources,
|
|
2928
|
+
resourceCode
|
|
2929
|
+
}) => {
|
|
2930
|
+
const [dataMenu, setDataMenu] = useState6([]);
|
|
2931
|
+
const [openMenu, setOpenMenu] = useState6(false);
|
|
2932
|
+
const [url, setUrl] = useState6("");
|
|
2933
|
+
const [contentWidth, setContentWidth] = useState6(0);
|
|
2934
|
+
const [componentWidth, setComponentWidth] = useState6(0);
|
|
2935
|
+
const [scrollPosition, setScrollPosition] = useState6(0);
|
|
2936
|
+
const handleWindowResize = () => {
|
|
2937
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2938
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2939
|
+
if (tabEle && tabContent) {
|
|
2940
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2941
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
useEffect7(() => {
|
|
2945
|
+
setUrl(window.location.pathname);
|
|
2946
|
+
window.addEventListener("resize", handleWindowResize);
|
|
2947
|
+
setTimeout(() => {
|
|
2948
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2949
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2950
|
+
if (tabEle && tabContent) {
|
|
2951
|
+
setComponentWidth(tabEle?.offsetWidth ?? 0);
|
|
2952
|
+
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
2953
|
+
}
|
|
2954
|
+
}, 100);
|
|
2955
|
+
return () => {
|
|
2956
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
2957
|
+
};
|
|
2958
|
+
}, []);
|
|
2959
|
+
useEffect7(() => {
|
|
2960
|
+
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
2961
|
+
if (item) {
|
|
2962
|
+
if (resourceCodeParent) {
|
|
2963
|
+
const data = item.children?.find((x) => x.code === resourceCode);
|
|
2964
|
+
if (data) {
|
|
2965
|
+
setDataMenu([...data.children]);
|
|
2966
|
+
}
|
|
2967
|
+
} else {
|
|
2968
|
+
setDataMenu([...item.children]);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
}, [resources]);
|
|
2972
|
+
const toggleMenu = () => {
|
|
2973
|
+
setOpenMenu(!openMenu);
|
|
2974
|
+
};
|
|
2975
|
+
const handleScroll = (scrollAmount) => {
|
|
2976
|
+
let newScrollPosition = scrollPosition + scrollAmount;
|
|
2977
|
+
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
2978
|
+
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
2979
|
+
if (tabEle && tabContent && tabContent?.offsetWidth - tabEle?.offsetWidth - newScrollPosition > -200) {
|
|
2980
|
+
if (newScrollPosition < 0) {
|
|
2981
|
+
newScrollPosition = 0;
|
|
2982
|
+
}
|
|
2983
|
+
setScrollPosition(newScrollPosition);
|
|
2984
|
+
tabEle.scrollLeft = newScrollPosition;
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
return /* @__PURE__ */ jsx13(Fragment14, { children: /* @__PURE__ */ jsxs12("div", { className: classNames5("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
2988
|
+
/* @__PURE__ */ jsx13(
|
|
2989
|
+
"div",
|
|
2990
|
+
{
|
|
2991
|
+
onClick: () => handleScroll(-200),
|
|
2992
|
+
className: classNames5("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
2993
|
+
children: /* @__PURE__ */ jsx13(ChevronLeft2, {})
|
|
2994
|
+
}
|
|
2995
|
+
),
|
|
2996
|
+
/* @__PURE__ */ jsx13("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ jsx13("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
2997
|
+
if (item?.resAttributes?.IS_MENU === "1") {
|
|
2998
|
+
return /* @__PURE__ */ jsxs12(UncontrolledDropdown2, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
2999
|
+
/* @__PURE__ */ jsx13(DropdownToggle3, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ jsx13("div", { children: item.name }) }),
|
|
3000
|
+
/* @__PURE__ */ jsx13(DropdownMenu3, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ jsx13(DropdownItem2, { style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%", padding: "0.5rem 0.5rem" }, children: /* @__PURE__ */ jsx13(Link, { to: x.url, style: { display: "block", width: "100%" }, children: x.name }) }, x.code)) })
|
|
3001
|
+
] }, item.code);
|
|
3002
|
+
} else {
|
|
3003
|
+
return /* @__PURE__ */ jsx13(
|
|
3004
|
+
Link,
|
|
3005
|
+
{
|
|
3006
|
+
to: item.url,
|
|
3007
|
+
className: classNames5("tab-custom-item", { active: item.url === url || tabParent && url?.split("/").length > 3 && item.url.startsWith(url.substring(0, url.lastIndexOf("/"))) }),
|
|
3008
|
+
children: item.name
|
|
3009
|
+
},
|
|
3010
|
+
item.code
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
}) }) }),
|
|
3014
|
+
/* @__PURE__ */ jsx13(
|
|
3015
|
+
"div",
|
|
3016
|
+
{
|
|
3017
|
+
onClick: () => handleScroll(200),
|
|
3018
|
+
className: classNames5("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3019
|
+
children: /* @__PURE__ */ jsx13(ChevronRight2, {})
|
|
3020
|
+
}
|
|
3021
|
+
)
|
|
3022
|
+
] }) });
|
|
3023
|
+
};
|
|
2951
3024
|
|
|
2952
3025
|
// index.ts
|
|
2953
3026
|
var Table_edit_default = table_default;
|
|
2954
3027
|
export {
|
|
3028
|
+
TabsMenuComponent,
|
|
2955
3029
|
Table_edit_default as default,
|
|
2956
3030
|
formartNumberic,
|
|
2957
3031
|
generateUUID,
|