react-table-edit 0.9.6 → 0.9.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 +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +852 -245
- package/dist/index.mjs +853 -238
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// test-app/src/component/table/index.tsx
|
|
2
|
-
import { Fragment as
|
|
3
|
-
import { Button as
|
|
4
|
-
import
|
|
5
|
-
import { useTranslation as
|
|
2
|
+
import { Fragment as Fragment19, forwardRef as forwardRef4, useEffect as useEffect9, useImperativeHandle, useRef as useRef4, useState as useState8 } from "react";
|
|
3
|
+
import { Button as Button6, DropdownMenu as DropdownMenu4, DropdownToggle as DropdownToggle4, Input as Input9, UncontrolledDropdown, UncontrolledTooltip as UncontrolledTooltip5 } from "reactstrap";
|
|
4
|
+
import classnames9 from "classnames";
|
|
5
|
+
import { useTranslation as useTranslation12 } from "react-i18next";
|
|
6
6
|
import { AlertCircle, Info as Info2, Settings } from "becoxy-icons";
|
|
7
7
|
|
|
8
8
|
// test-app/src/component/react-input/index.tsx
|
|
@@ -276,7 +276,7 @@ var roundNumber = (num, fraction) => {
|
|
|
276
276
|
};
|
|
277
277
|
|
|
278
278
|
// test-app/src/component/table/index.tsx
|
|
279
|
-
import
|
|
279
|
+
import moment3 from "moment";
|
|
280
280
|
|
|
281
281
|
// test-app/src/component/edit-form/index.tsx
|
|
282
282
|
import { forwardRef as forwardRef2, useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
|
|
@@ -527,7 +527,7 @@ import classnames4 from "classnames";
|
|
|
527
527
|
import { Fragment as Fragment7 } from "react";
|
|
528
528
|
|
|
529
529
|
// test-app/src/component/select-table/index.tsx
|
|
530
|
-
import { forwardRef, Fragment as Fragment5, useEffect as useEffect3, useMemo, useRef, useState as useState2 } from "react";
|
|
530
|
+
import React, { forwardRef, Fragment as Fragment5, useEffect as useEffect3, useMemo, useRef, useState as useState2 } from "react";
|
|
531
531
|
import {
|
|
532
532
|
DropdownItem,
|
|
533
533
|
DropdownMenu,
|
|
@@ -653,19 +653,17 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
653
653
|
const listKeyUse = ["Escape", "Space", "Enter", "Tab", "NumpadEnter", "ArrowDown", "ArrowUp", "F9"];
|
|
654
654
|
const handleOnKeyDown = (e) => {
|
|
655
655
|
let key = "";
|
|
656
|
-
if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code))) {
|
|
656
|
+
if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter" || e.code === "Space") && !(optionsLoad ? optionsLoad : options)[indexFocus] || (e.code === "ArrowDown" || e.code === "ArrowUp") && (optionsLoad?.length ?? 0) === 0 && options.length === 0 || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
|
|
657
657
|
key = onKeyDown(e);
|
|
658
|
-
if (key === "ArrowRight" || key === "ArrowLeft") {
|
|
659
|
-
closeMenu();
|
|
660
|
-
}
|
|
661
658
|
}
|
|
662
659
|
let flag = false;
|
|
663
660
|
if (!key) {
|
|
664
661
|
if (e.code === "F9") {
|
|
665
662
|
handleAdd();
|
|
666
663
|
flag = true;
|
|
667
|
-
} else if (e.code === "
|
|
668
|
-
|
|
664
|
+
} else if (e.code === "Space") {
|
|
665
|
+
const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
|
|
666
|
+
if (dropdownOpen && newItem) {
|
|
669
667
|
if ((optionsLoad ? optionsLoad : options)[indexFocus]) {
|
|
670
668
|
onChange((optionsLoad ? optionsLoad : options)[indexFocus]);
|
|
671
669
|
}
|
|
@@ -674,14 +672,21 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
674
672
|
handleOpenClose();
|
|
675
673
|
flag = true;
|
|
676
674
|
}
|
|
675
|
+
} else if (e.code === "Escape") {
|
|
676
|
+
if (dropdownOpen && isClearable && value && !isDisabled) {
|
|
677
|
+
onChange(void 0);
|
|
678
|
+
handleOpenClose();
|
|
679
|
+
flag = true;
|
|
680
|
+
}
|
|
677
681
|
} else if (e.code === "Enter" || e.code === "Tab" || e.code === "NumpadEnter") {
|
|
678
|
-
|
|
679
|
-
|
|
682
|
+
const newItem = (optionsLoad ? optionsLoad : options)[indexFocus];
|
|
683
|
+
if (dropdownOpen && newItem) {
|
|
684
|
+
onChange(newItem);
|
|
680
685
|
handleOpenClose();
|
|
681
686
|
flag = true;
|
|
682
687
|
}
|
|
683
688
|
} else if (e.code === "ArrowDown") {
|
|
684
|
-
if (dropdownOpen) {
|
|
689
|
+
if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
|
|
685
690
|
let newIndex = 0;
|
|
686
691
|
if (indexFocus >= 0) {
|
|
687
692
|
newIndex = indexFocus + 1;
|
|
@@ -701,7 +706,7 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
701
706
|
flag = true;
|
|
702
707
|
}
|
|
703
708
|
} else if (e.code === "ArrowUp") {
|
|
704
|
-
if (dropdownOpen) {
|
|
709
|
+
if (dropdownOpen && ((optionsLoad?.length ?? 0) > 0 || options.length > 0)) {
|
|
705
710
|
let newIndex = 0;
|
|
706
711
|
if (indexFocus >= 0) {
|
|
707
712
|
newIndex = indexFocus - 1;
|
|
@@ -813,7 +818,7 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
813
818
|
const element = document.getElementById(`select-${id}-${indexRow}-${indexCol}`);
|
|
814
819
|
return element && element.scrollWidth > element.clientWidth;
|
|
815
820
|
};
|
|
816
|
-
const RenderElement = (props2) => {
|
|
821
|
+
const RenderElement = React.memo((props2) => {
|
|
817
822
|
const { indexRow, row, isSelected, level = 0 } = props2;
|
|
818
823
|
return /* @__PURE__ */ jsxs5(
|
|
819
824
|
"tr",
|
|
@@ -832,13 +837,11 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
832
837
|
const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
|
|
833
838
|
if (index > -1) {
|
|
834
839
|
value?.splice(index, 1);
|
|
835
|
-
|
|
836
|
-
onChange(valueArr);
|
|
840
|
+
onChange([...value]);
|
|
837
841
|
} else {
|
|
838
842
|
if (value) {
|
|
839
843
|
value?.push(row[fieldValue ?? "value"]);
|
|
840
|
-
|
|
841
|
-
onChange(valueArr);
|
|
844
|
+
onChange([...value]);
|
|
842
845
|
} else {
|
|
843
846
|
onChange([row[fieldValue ?? "value"]]);
|
|
844
847
|
}
|
|
@@ -885,13 +888,11 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
885
888
|
const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
|
|
886
889
|
if (index > -1) {
|
|
887
890
|
value?.splice(index, 1);
|
|
888
|
-
|
|
889
|
-
onChange(valueArr);
|
|
891
|
+
onChange([...value]);
|
|
890
892
|
} else {
|
|
891
893
|
if (value) {
|
|
892
894
|
value?.push(row[fieldValue ?? "value"]);
|
|
893
|
-
|
|
894
|
-
onChange(valueArr);
|
|
895
|
+
onChange([...value]);
|
|
895
896
|
} else {
|
|
896
897
|
onChange([row[fieldValue ?? "value"]]);
|
|
897
898
|
}
|
|
@@ -921,7 +922,7 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
921
922
|
},
|
|
922
923
|
`row-${indexRow}`
|
|
923
924
|
);
|
|
924
|
-
};
|
|
925
|
+
});
|
|
925
926
|
const RenderTable = (props2) => {
|
|
926
927
|
const {} = props2;
|
|
927
928
|
let countDisplay = 0;
|
|
@@ -943,7 +944,7 @@ var SelectTable = forwardRef((props, ref) => {
|
|
|
943
944
|
if (isSelectedAll) {
|
|
944
945
|
onChange([]);
|
|
945
946
|
} else {
|
|
946
|
-
onChange([...optionsLoad ? optionsLoad : options]);
|
|
947
|
+
onChange([...(optionsLoad ? optionsLoad : options).map((x) => x[fieldValue ?? "value"])]);
|
|
947
948
|
}
|
|
948
949
|
e.stopPropagation();
|
|
949
950
|
}
|
|
@@ -1965,9 +1966,6 @@ var SidebarSetColumn = (props) => {
|
|
|
1965
1966
|
};
|
|
1966
1967
|
var sidebar_setting_column_default = SidebarSetColumn;
|
|
1967
1968
|
|
|
1968
|
-
// test-app/src/component/table/index.tsx
|
|
1969
|
-
import { DropDownTreeComponent } from "@syncfusion/ej2-react-dropdowns";
|
|
1970
|
-
|
|
1971
1969
|
// test-app/src/component/table/paging/index.tsx
|
|
1972
1970
|
import { ChevronRight as ChevronRight2, ChevronLeft as ChevronLeft2, ChevronsLeft, ChevronsRight } from "becoxy-icons";
|
|
1973
1971
|
import classNames5 from "classnames";
|
|
@@ -2199,10 +2197,595 @@ var CommandElement = (props) => {
|
|
|
2199
2197
|
};
|
|
2200
2198
|
var command_default = CommandElement;
|
|
2201
2199
|
|
|
2202
|
-
// test-app/src/component/table/index.tsx
|
|
2200
|
+
// test-app/src/component/select-table-tree/index.tsx
|
|
2201
|
+
import React2, { forwardRef as forwardRef3, Fragment as Fragment17, useEffect as useEffect8, useMemo as useMemo2, useRef as useRef3, useState as useState7 } from "react";
|
|
2202
|
+
import {
|
|
2203
|
+
DropdownItem as DropdownItem3,
|
|
2204
|
+
DropdownMenu as DropdownMenu3,
|
|
2205
|
+
DropdownToggle as DropdownToggle3,
|
|
2206
|
+
Dropdown as Dropdown3,
|
|
2207
|
+
Button as Button5,
|
|
2208
|
+
Input as Input8,
|
|
2209
|
+
UncontrolledTooltip as UncontrolledTooltip4
|
|
2210
|
+
} from "reactstrap";
|
|
2211
|
+
import { useTranslation as useTranslation11 } from "react-i18next";
|
|
2212
|
+
import classnames8 from "classnames";
|
|
2213
|
+
import moment2 from "moment";
|
|
2214
|
+
import { ChevronRight as ChevronRight3, Plus as Plus3 } from "becoxy-icons";
|
|
2203
2215
|
import { Fragment as Fragment18, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2204
|
-
var
|
|
2216
|
+
var defaultMaxHeight2 = 250;
|
|
2217
|
+
var SelectTableTree = forwardRef3((props, ref) => {
|
|
2218
|
+
const {
|
|
2219
|
+
id,
|
|
2220
|
+
menuWidth,
|
|
2221
|
+
width,
|
|
2222
|
+
invalid,
|
|
2223
|
+
onKeyDown,
|
|
2224
|
+
placeholder,
|
|
2225
|
+
textAlign,
|
|
2226
|
+
options,
|
|
2227
|
+
columns,
|
|
2228
|
+
decimalSeparator,
|
|
2229
|
+
thousandSeparator,
|
|
2230
|
+
onChange,
|
|
2231
|
+
value,
|
|
2232
|
+
fieldValue,
|
|
2233
|
+
fieldLabel,
|
|
2234
|
+
fieldChildren,
|
|
2235
|
+
maxHeight,
|
|
2236
|
+
handleAdd,
|
|
2237
|
+
isClearable,
|
|
2238
|
+
component,
|
|
2239
|
+
formatOptionLabel,
|
|
2240
|
+
isMulti,
|
|
2241
|
+
noHeader,
|
|
2242
|
+
isDisabled,
|
|
2243
|
+
showFooter,
|
|
2244
|
+
selectChilds,
|
|
2245
|
+
footerComponent,
|
|
2246
|
+
onPaste
|
|
2247
|
+
} = props;
|
|
2248
|
+
const selectTableRef = useRef3();
|
|
2249
|
+
const selectMenuTableRef = useRef3();
|
|
2250
|
+
const inputRef = useRef3();
|
|
2251
|
+
const [dropdownOpen, setDropdownOpen] = useState7(false);
|
|
2252
|
+
const [isFocus, setIsFocus] = useState7(false);
|
|
2253
|
+
const [searchTerm, setSearchTerm] = useState7("");
|
|
2205
2254
|
const { t } = useTranslation11();
|
|
2255
|
+
const areAllItemsSelected = (value2, options2, fieldValue2) => {
|
|
2256
|
+
const checkAllSelected = (nodes) => {
|
|
2257
|
+
return nodes.every((node) => {
|
|
2258
|
+
const isSelected = value2.includes(node[fieldValue2]);
|
|
2259
|
+
const childrenSelected = node.children ? checkAllSelected(node.children) : true;
|
|
2260
|
+
return isSelected && childrenSelected;
|
|
2261
|
+
});
|
|
2262
|
+
};
|
|
2263
|
+
return checkAllSelected(options2);
|
|
2264
|
+
};
|
|
2265
|
+
const isSelectedAll = useMemo2(() => {
|
|
2266
|
+
return isMulti === true && options.length > 0 && areAllItemsSelected(value, options, fieldValue ?? "value");
|
|
2267
|
+
}, [options, value]);
|
|
2268
|
+
const defaultColumns = noHeader ? [
|
|
2269
|
+
{
|
|
2270
|
+
headerText: "Name",
|
|
2271
|
+
field: fieldLabel ?? "label",
|
|
2272
|
+
width: menuWidth
|
|
2273
|
+
}
|
|
2274
|
+
] : [
|
|
2275
|
+
{
|
|
2276
|
+
field: "key",
|
|
2277
|
+
headerText: "Code",
|
|
2278
|
+
width: 100,
|
|
2279
|
+
maxWidth: 120,
|
|
2280
|
+
minWidth: 80
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
headerText: "Name",
|
|
2284
|
+
field: "label",
|
|
2285
|
+
width: 150,
|
|
2286
|
+
maxWidth: 200,
|
|
2287
|
+
minWidth: 250
|
|
2288
|
+
}
|
|
2289
|
+
];
|
|
2290
|
+
const closeMenu = () => {
|
|
2291
|
+
setDropdownOpen(false);
|
|
2292
|
+
};
|
|
2293
|
+
useEffect8(() => {
|
|
2294
|
+
if (dropdownOpen && value && !isMulti && selectMenuTableRef) {
|
|
2295
|
+
const index = options?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"]);
|
|
2296
|
+
if (index >= 0) {
|
|
2297
|
+
selectMenuTableRef.current.scrollTo({ top: (index - 1) * 30 });
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
}, [dropdownOpen]);
|
|
2301
|
+
useEffect8(() => {
|
|
2302
|
+
if (inputRef && !isDisabled) {
|
|
2303
|
+
inputRef.current.addEventListener("blur", function() {
|
|
2304
|
+
setDropdownOpen(false);
|
|
2305
|
+
setSearchTerm("");
|
|
2306
|
+
setIsFocus(false);
|
|
2307
|
+
});
|
|
2308
|
+
inputRef.current.addEventListener("focus", function() {
|
|
2309
|
+
if (!isFocus) {
|
|
2310
|
+
setIsFocus(true);
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2314
|
+
}, [inputRef]);
|
|
2315
|
+
useEffect8(() => {
|
|
2316
|
+
if (searchTerm && !dropdownOpen) {
|
|
2317
|
+
setDropdownOpen(true);
|
|
2318
|
+
}
|
|
2319
|
+
}, [searchTerm]);
|
|
2320
|
+
const handleOpenClose = () => {
|
|
2321
|
+
setSearchTerm("");
|
|
2322
|
+
if (dropdownOpen) {
|
|
2323
|
+
closeMenu();
|
|
2324
|
+
} else {
|
|
2325
|
+
if (!isDisabled) {
|
|
2326
|
+
setDropdownOpen(true);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
const listKeyUse = ["Escape", "Space", "F9"];
|
|
2331
|
+
const handleOnKeyDown = (e) => {
|
|
2332
|
+
let key = "";
|
|
2333
|
+
if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
|
|
2334
|
+
key = onKeyDown(e);
|
|
2335
|
+
}
|
|
2336
|
+
let flag = false;
|
|
2337
|
+
if (!key) {
|
|
2338
|
+
if (e.code === "F9") {
|
|
2339
|
+
handleAdd();
|
|
2340
|
+
flag = true;
|
|
2341
|
+
} else if (e.code === "Space") {
|
|
2342
|
+
if (!searchTerm) {
|
|
2343
|
+
handleOpenClose();
|
|
2344
|
+
flag = true;
|
|
2345
|
+
}
|
|
2346
|
+
} else if (e.code === "Escape") {
|
|
2347
|
+
if (dropdownOpen && isClearable && value && !isDisabled) {
|
|
2348
|
+
onChange(void 0);
|
|
2349
|
+
handleOpenClose();
|
|
2350
|
+
flag = true;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
if (flag) {
|
|
2355
|
+
e.stopPropagation();
|
|
2356
|
+
e.preventDefault();
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
const renderHeaderCol = (col, indexCol) => {
|
|
2360
|
+
return /* @__PURE__ */ jsx15(Fragment17, { children: col.visible !== false && /* @__PURE__ */ jsx15(
|
|
2361
|
+
"th",
|
|
2362
|
+
{
|
|
2363
|
+
className: classnames8(`r-select-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
|
|
2364
|
+
style: {
|
|
2365
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
2366
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
2367
|
+
maxWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
2368
|
+
top: `${0 * 35}px`
|
|
2369
|
+
},
|
|
2370
|
+
children: /* @__PURE__ */ jsx15(
|
|
2371
|
+
"div",
|
|
2372
|
+
{
|
|
2373
|
+
role: "textbox",
|
|
2374
|
+
title: t(col.headerText ?? ""),
|
|
2375
|
+
style: {
|
|
2376
|
+
height: `${1 * 35}px`,
|
|
2377
|
+
justifyContent: col.textAlign ?? "left"
|
|
2378
|
+
},
|
|
2379
|
+
className: "r-select-headercell-div",
|
|
2380
|
+
children: t(col.headerText ?? "")
|
|
2381
|
+
}
|
|
2382
|
+
)
|
|
2383
|
+
}
|
|
2384
|
+
) }, `header-select-${indexCol}`);
|
|
2385
|
+
};
|
|
2386
|
+
const checkSearch = (keyword, data, columnsSearch) => {
|
|
2387
|
+
if (!keyword || columnsSearch.length === 0) {
|
|
2388
|
+
return true;
|
|
2389
|
+
}
|
|
2390
|
+
for (let index = 0; index < columnsSearch.length; index++) {
|
|
2391
|
+
const key = columnsSearch[index].field.trim();
|
|
2392
|
+
if (data[key] && data[key].toString().trim().toLowerCase().includes(keyword.trim().toLowerCase())) {
|
|
2393
|
+
return true;
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
if (data[fieldChildren ?? "children"]) {
|
|
2397
|
+
return data[fieldChildren ?? "children"].some((child) => checkSearch(keyword, child, columnsSearch));
|
|
2398
|
+
}
|
|
2399
|
+
return false;
|
|
2400
|
+
};
|
|
2401
|
+
const checkOverflow = (indexRow, indexCol) => {
|
|
2402
|
+
const element = document.getElementById(`select-${id}-${indexRow}-${indexCol}`);
|
|
2403
|
+
return element && element.scrollWidth > element.clientWidth;
|
|
2404
|
+
};
|
|
2405
|
+
const getSelectAll = (tree, checkValue = false) => {
|
|
2406
|
+
const selects = [];
|
|
2407
|
+
const traverse = (items) => {
|
|
2408
|
+
items.forEach((item) => {
|
|
2409
|
+
if (item[fieldValue ?? "value"] && !(checkValue && value?.includes(item[fieldValue ?? "value"]))) {
|
|
2410
|
+
selects.push(item[fieldValue ?? "value"]);
|
|
2411
|
+
}
|
|
2412
|
+
if (item[fieldChildren ?? "children"] && item[fieldChildren ?? "children"].length > 0) {
|
|
2413
|
+
traverse(item[fieldChildren ?? "children"]);
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
};
|
|
2417
|
+
traverse(tree);
|
|
2418
|
+
return selects;
|
|
2419
|
+
};
|
|
2420
|
+
const RenderElement = React2.memo((props2) => {
|
|
2421
|
+
const { indexRow, row, isSelected, level = 0 } = props2;
|
|
2422
|
+
const [expanded, setExpanded] = useState7(row.expanded);
|
|
2423
|
+
return /* @__PURE__ */ jsxs14(Fragment18, { children: [
|
|
2424
|
+
/* @__PURE__ */ jsxs14(
|
|
2425
|
+
"tr",
|
|
2426
|
+
{
|
|
2427
|
+
id: `row-select-table-${indexRow}`,
|
|
2428
|
+
className: classnames8("r-select-row", { "fisrt-row": indexRow === 0 && level === 0 }),
|
|
2429
|
+
children: [
|
|
2430
|
+
isMulti && /* @__PURE__ */ jsxs14(
|
|
2431
|
+
"td",
|
|
2432
|
+
{
|
|
2433
|
+
className: classnames8(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
|
|
2434
|
+
style: {
|
|
2435
|
+
textAlign: "center",
|
|
2436
|
+
paddingLeft: level * 15 + (row[fieldChildren ?? "children"].length > 0 ? 0 : 10)
|
|
2437
|
+
},
|
|
2438
|
+
onClick: (e) => {
|
|
2439
|
+
if (isMulti) {
|
|
2440
|
+
const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
|
|
2441
|
+
if (index > -1) {
|
|
2442
|
+
if (!selectChilds) {
|
|
2443
|
+
value?.splice(index, 1);
|
|
2444
|
+
} else {
|
|
2445
|
+
value?.splice(index, 1);
|
|
2446
|
+
getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
|
|
2447
|
+
const index2 = value?.findIndex((y) => y === x);
|
|
2448
|
+
if (index2 > -1) {
|
|
2449
|
+
value?.splice(index2, 1);
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
onChange([...value]);
|
|
2454
|
+
} else {
|
|
2455
|
+
if (value) {
|
|
2456
|
+
if (!selectChilds) {
|
|
2457
|
+
onChange([...value, row[fieldValue ?? "value"]]);
|
|
2458
|
+
} else {
|
|
2459
|
+
onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
|
|
2460
|
+
}
|
|
2461
|
+
} else {
|
|
2462
|
+
onChange([row[fieldValue ?? "value"]]);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
e.stopPropagation();
|
|
2466
|
+
}
|
|
2467
|
+
},
|
|
2468
|
+
children: [
|
|
2469
|
+
row[fieldChildren ?? "children"].length > 0 && /* @__PURE__ */ jsx15(
|
|
2470
|
+
ChevronRight3,
|
|
2471
|
+
{
|
|
2472
|
+
onClick: (e) => {
|
|
2473
|
+
if (expanded) {
|
|
2474
|
+
row.expanded = false;
|
|
2475
|
+
setExpanded(false);
|
|
2476
|
+
} else {
|
|
2477
|
+
row.expanded = true;
|
|
2478
|
+
setExpanded(true);
|
|
2479
|
+
}
|
|
2480
|
+
e.stopPropagation();
|
|
2481
|
+
},
|
|
2482
|
+
fontSize: 18,
|
|
2483
|
+
className: classnames8("me-50 pb-0 r-icon-expand", { "is-open": expanded })
|
|
2484
|
+
}
|
|
2485
|
+
),
|
|
2486
|
+
/* @__PURE__ */ jsx15(
|
|
2487
|
+
Input8,
|
|
2488
|
+
{
|
|
2489
|
+
checked: isSelected,
|
|
2490
|
+
type: "checkbox",
|
|
2491
|
+
className: "cursor-pointer",
|
|
2492
|
+
onChange: () => {
|
|
2493
|
+
},
|
|
2494
|
+
style: { textAlign: "center" }
|
|
2495
|
+
}
|
|
2496
|
+
)
|
|
2497
|
+
]
|
|
2498
|
+
}
|
|
2499
|
+
),
|
|
2500
|
+
(columns ? columns : defaultColumns).map((col, indexCol) => {
|
|
2501
|
+
let valueDisplay = row[col.field];
|
|
2502
|
+
if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
|
|
2503
|
+
valueDisplay = formartNumberic(row[col.field], decimalSeparator ?? ".", thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
|
|
2504
|
+
} else if (col.type === "date") {
|
|
2505
|
+
valueDisplay = valueDisplay ? moment2(valueDisplay).format("DD/MM/yyyy") : "";
|
|
2506
|
+
} else if (col.type === "datetime") {
|
|
2507
|
+
valueDisplay = valueDisplay ? moment2(valueDisplay).format("DD/MM/yyyy HH:mm") : "";
|
|
2508
|
+
}
|
|
2509
|
+
return /* @__PURE__ */ jsxs14(Fragment17, { children: [
|
|
2510
|
+
col.visible !== false && /* @__PURE__ */ jsxs14(
|
|
2511
|
+
"td",
|
|
2512
|
+
{
|
|
2513
|
+
id: `select-${id}-${indexRow}-${indexCol}`,
|
|
2514
|
+
className: classnames8(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
|
|
2515
|
+
style: {
|
|
2516
|
+
paddingLeft: 9 + (indexCol === 0 && !isMulti ? level * 10 + (row[fieldChildren ?? "children"].length > 0 ? 0 : 15) : 0),
|
|
2517
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
2518
|
+
},
|
|
2519
|
+
onClick: (e) => {
|
|
2520
|
+
if (isMulti) {
|
|
2521
|
+
const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
|
|
2522
|
+
if (index > -1) {
|
|
2523
|
+
if (!selectChilds) {
|
|
2524
|
+
value?.splice(index, 1);
|
|
2525
|
+
} else {
|
|
2526
|
+
value?.splice(index, 1);
|
|
2527
|
+
getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
|
|
2528
|
+
const index2 = value?.findIndex((y) => y === x);
|
|
2529
|
+
if (index2 > -1) {
|
|
2530
|
+
value?.splice(index2, 1);
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
onChange([...value]);
|
|
2535
|
+
} else {
|
|
2536
|
+
if (value) {
|
|
2537
|
+
if (!selectChilds) {
|
|
2538
|
+
onChange([...value, row[fieldValue ?? "value"]]);
|
|
2539
|
+
} else {
|
|
2540
|
+
onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
|
|
2541
|
+
}
|
|
2542
|
+
} else {
|
|
2543
|
+
onChange([row[fieldValue ?? "value"]]);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
e.stopPropagation();
|
|
2547
|
+
} else {
|
|
2548
|
+
onChange(row);
|
|
2549
|
+
setSearchTerm("");
|
|
2550
|
+
closeMenu();
|
|
2551
|
+
}
|
|
2552
|
+
e.preventDefault();
|
|
2553
|
+
e.stopPropagation();
|
|
2554
|
+
},
|
|
2555
|
+
children: [
|
|
2556
|
+
!isMulti && indexCol === 0 && row[fieldChildren ?? "children"].length > 0 && /* @__PURE__ */ jsx15(
|
|
2557
|
+
ChevronRight3,
|
|
2558
|
+
{
|
|
2559
|
+
onClick: (e) => {
|
|
2560
|
+
if (expanded) {
|
|
2561
|
+
row.expanded = false;
|
|
2562
|
+
setExpanded(false);
|
|
2563
|
+
} else {
|
|
2564
|
+
row.expanded = true;
|
|
2565
|
+
setExpanded(true);
|
|
2566
|
+
}
|
|
2567
|
+
e.stopPropagation();
|
|
2568
|
+
},
|
|
2569
|
+
fontSize: 18,
|
|
2570
|
+
className: classnames8("me-50 r-icon-expand", { "is-open": expanded })
|
|
2571
|
+
}
|
|
2572
|
+
),
|
|
2573
|
+
col.template ? col.template(row, indexRow) : valueDisplay
|
|
2574
|
+
]
|
|
2575
|
+
},
|
|
2576
|
+
`col-${indexRow}-${indexCol}`
|
|
2577
|
+
),
|
|
2578
|
+
checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx15(UncontrolledTooltip4, { className: "r-tooltip", autohide: false, target: `select-${id}-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : valueDisplay })
|
|
2579
|
+
] }, indexCol);
|
|
2580
|
+
})
|
|
2581
|
+
]
|
|
2582
|
+
},
|
|
2583
|
+
`row-${indexRow}`
|
|
2584
|
+
),
|
|
2585
|
+
row[fieldChildren ?? "children"] && row.expanded && row[fieldChildren ?? "children"].map((child, indexChild) => {
|
|
2586
|
+
if (checkSearch(searchTerm, child, columns ? columns : defaultColumns)) {
|
|
2587
|
+
const isSelectedChild = isMulti ? value?.some((x) => x === child[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === child[fieldValue ?? "value"];
|
|
2588
|
+
return /* @__PURE__ */ jsx15(RenderElement, { isSelected: isSelectedChild, indexRow: indexChild, row: child, level: level + 1 }, `select-table-${indexRow}-${indexChild}`);
|
|
2589
|
+
}
|
|
2590
|
+
})
|
|
2591
|
+
] });
|
|
2592
|
+
});
|
|
2593
|
+
const RenderTable = (props2) => {
|
|
2594
|
+
const {} = props2;
|
|
2595
|
+
let countDisplay = 0;
|
|
2596
|
+
return /* @__PURE__ */ jsxs14(Fragment18, { children: [
|
|
2597
|
+
/* @__PURE__ */ jsxs14("table", { style: { width: "100%" }, children: [
|
|
2598
|
+
!noHeader && /* @__PURE__ */ jsx15("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ jsxs14("tr", { className: "r-select-row", role: "row", children: [
|
|
2599
|
+
isMulti && /* @__PURE__ */ jsx15(
|
|
2600
|
+
"th",
|
|
2601
|
+
{
|
|
2602
|
+
className: classnames8(`r-select-headercell checkbox-column`),
|
|
2603
|
+
style: { width: 40, minWidth: 40, maxWidth: 100, top: `0px` },
|
|
2604
|
+
children: /* @__PURE__ */ jsx15(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
style: { justifyContent: "center" },
|
|
2608
|
+
className: classnames8("r-select-headercell-div"),
|
|
2609
|
+
children: /* @__PURE__ */ jsx15(
|
|
2610
|
+
Input8,
|
|
2611
|
+
{
|
|
2612
|
+
checked: isSelectedAll,
|
|
2613
|
+
type: "checkbox",
|
|
2614
|
+
onClick: (e) => {
|
|
2615
|
+
if (isMulti) {
|
|
2616
|
+
if (isSelectedAll) {
|
|
2617
|
+
onChange([]);
|
|
2618
|
+
} else {
|
|
2619
|
+
onChange(getSelectAll(options));
|
|
2620
|
+
}
|
|
2621
|
+
e.stopPropagation();
|
|
2622
|
+
}
|
|
2623
|
+
},
|
|
2624
|
+
readOnly: true,
|
|
2625
|
+
className: classnames8("cursor-pointer", { "d-none": !isMulti }),
|
|
2626
|
+
style: { textAlign: "center", marginTop: 6 }
|
|
2627
|
+
}
|
|
2628
|
+
)
|
|
2629
|
+
}
|
|
2630
|
+
)
|
|
2631
|
+
}
|
|
2632
|
+
),
|
|
2633
|
+
!noHeader && (columns ? columns : defaultColumns).map((col, index) => {
|
|
2634
|
+
return renderHeaderCol(col, index);
|
|
2635
|
+
})
|
|
2636
|
+
] }) }),
|
|
2637
|
+
options.length > 0 && /* @__PURE__ */ jsx15(Fragment18, { children: /* @__PURE__ */ jsx15("tbody", { className: "r-select-gridcontent", children: options?.map((row, indexRow) => {
|
|
2638
|
+
if (checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
|
|
2639
|
+
const isSelected = isMulti ? value?.some((x) => x === row[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === row[fieldValue ?? "value"];
|
|
2640
|
+
countDisplay++;
|
|
2641
|
+
return /* @__PURE__ */ jsx15(RenderElement, { isSelected, indexRow, row }, `select-table-${indexRow}`);
|
|
2642
|
+
}
|
|
2643
|
+
}) }) })
|
|
2644
|
+
] }),
|
|
2645
|
+
countDisplay === 0 && /* @__PURE__ */ jsxs14("div", { className: "r-no-data", children: [
|
|
2646
|
+
/* @__PURE__ */ jsx15("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxs14("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
|
|
2647
|
+
/* @__PURE__ */ jsx15("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
|
|
2648
|
+
/* @__PURE__ */ jsxs14("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
|
|
2649
|
+
/* @__PURE__ */ jsx15("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
|
|
2650
|
+
/* @__PURE__ */ jsx15("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })
|
|
2651
|
+
] })
|
|
2652
|
+
] }) }),
|
|
2653
|
+
t("No data available.")
|
|
2654
|
+
] })
|
|
2655
|
+
] });
|
|
2656
|
+
};
|
|
2657
|
+
const getSelectedRecords = (tree, value2) => {
|
|
2658
|
+
const records = [];
|
|
2659
|
+
const traverse = (nodes) => {
|
|
2660
|
+
nodes.forEach((node) => {
|
|
2661
|
+
if (value2.includes(node[fieldValue ?? "value"])) {
|
|
2662
|
+
records.push(node);
|
|
2663
|
+
}
|
|
2664
|
+
if (node.children && node.children.length > 0) {
|
|
2665
|
+
traverse(node.children);
|
|
2666
|
+
}
|
|
2667
|
+
});
|
|
2668
|
+
};
|
|
2669
|
+
traverse(tree);
|
|
2670
|
+
return records;
|
|
2671
|
+
};
|
|
2672
|
+
return /* @__PURE__ */ jsx15(
|
|
2673
|
+
"div",
|
|
2674
|
+
{
|
|
2675
|
+
className: classnames8("react-select-table", { "is-invalid": invalid }),
|
|
2676
|
+
ref,
|
|
2677
|
+
id,
|
|
2678
|
+
children: /* @__PURE__ */ jsx15("div", { ref: selectTableRef, children: /* @__PURE__ */ jsxs14(
|
|
2679
|
+
Dropdown3,
|
|
2680
|
+
{
|
|
2681
|
+
isOpen: dropdownOpen,
|
|
2682
|
+
toggle: () => {
|
|
2683
|
+
},
|
|
2684
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2685
|
+
children: [
|
|
2686
|
+
/* @__PURE__ */ jsxs14(
|
|
2687
|
+
DropdownToggle3,
|
|
2688
|
+
{
|
|
2689
|
+
onClick: (e) => {
|
|
2690
|
+
if (!isDisabled) {
|
|
2691
|
+
inputRef?.current.focus();
|
|
2692
|
+
handleOpenClose();
|
|
2693
|
+
}
|
|
2694
|
+
e.preventDefault();
|
|
2695
|
+
},
|
|
2696
|
+
tag: "div",
|
|
2697
|
+
style: { width: width ? width : "100%" },
|
|
2698
|
+
className: classnames8("select-table-control", { "r-select-is-disabled": isDisabled }, { "r-select-is-open": dropdownOpen }, { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
|
|
2699
|
+
children: [
|
|
2700
|
+
/* @__PURE__ */ jsxs14("div", { className: "select-table-container", children: [
|
|
2701
|
+
isMulti ? /* @__PURE__ */ jsx15(Fragment18, { children: /* @__PURE__ */ jsx15("div", { className: classnames8("select-value is-mutil", { "d-none": searchTerm }), children: getSelectedRecords(options, value).map((ele, index) => {
|
|
2702
|
+
return /* @__PURE__ */ jsxs14("span", { children: [
|
|
2703
|
+
index === 0 ? "" : ", ",
|
|
2704
|
+
ele[fieldLabel ?? "label"]
|
|
2705
|
+
] }, index);
|
|
2706
|
+
}) }) }) : /* @__PURE__ */ jsx15(Fragment18, { children: /* @__PURE__ */ jsxs14("div", { className: classnames8("select-value", { "d-none": searchTerm }), children: [
|
|
2707
|
+
value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
|
|
2708
|
+
" "
|
|
2709
|
+
] }) }),
|
|
2710
|
+
!((isMulti ? value?.length > 0 : value) || isDisabled || searchTerm) && /* @__PURE__ */ jsx15("div", { className: classnames8("select-placeholder"), children: placeholder }),
|
|
2711
|
+
/* @__PURE__ */ jsx15("div", { className: "input-container", children: /* @__PURE__ */ jsx15(
|
|
2712
|
+
"input",
|
|
2713
|
+
{
|
|
2714
|
+
style: { textAlign: textAlign ?? "left" },
|
|
2715
|
+
ref: inputRef,
|
|
2716
|
+
className: classnames8("select-input"),
|
|
2717
|
+
readOnly: isDisabled,
|
|
2718
|
+
value: searchTerm,
|
|
2719
|
+
onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
|
|
2720
|
+
onChange: (val) => {
|
|
2721
|
+
setSearchTerm(val.target.value);
|
|
2722
|
+
},
|
|
2723
|
+
onKeyDown: (e) => handleOnKeyDown(e)
|
|
2724
|
+
}
|
|
2725
|
+
) })
|
|
2726
|
+
] }),
|
|
2727
|
+
isClearable && value && !isDisabled && /* @__PURE__ */ jsx15(
|
|
2728
|
+
"div",
|
|
2729
|
+
{
|
|
2730
|
+
className: classnames8("cursor-pointer"),
|
|
2731
|
+
onClick: (e) => {
|
|
2732
|
+
onChange(isMulti ? [] : void 0);
|
|
2733
|
+
e.stopPropagation();
|
|
2734
|
+
},
|
|
2735
|
+
children: /* @__PURE__ */ jsx15("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ jsx15("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
|
|
2736
|
+
}
|
|
2737
|
+
),
|
|
2738
|
+
!isDisabled && /* @__PURE__ */ jsx15("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx15("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx15("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
|
|
2739
|
+
]
|
|
2740
|
+
}
|
|
2741
|
+
),
|
|
2742
|
+
/* @__PURE__ */ jsx15(
|
|
2743
|
+
DropdownMenu3,
|
|
2744
|
+
{
|
|
2745
|
+
container: component,
|
|
2746
|
+
className: "formula-dropdown icon-dropdown p-0",
|
|
2747
|
+
style: {
|
|
2748
|
+
width: "min-content",
|
|
2749
|
+
position: "fixed",
|
|
2750
|
+
borderRadius: 3,
|
|
2751
|
+
zIndex: 9999
|
|
2752
|
+
},
|
|
2753
|
+
children: /* @__PURE__ */ jsx15(DropdownItem3, { className: classnames8("p-0 menu-select-table"), style: { borderRadius: "6px" }, tag: "div", header: true, children: dropdownOpen && /* @__PURE__ */ jsx15(
|
|
2754
|
+
"div",
|
|
2755
|
+
{
|
|
2756
|
+
onMouseDown: (e) => {
|
|
2757
|
+
if (!isDisabled) {
|
|
2758
|
+
inputRef?.current.focus();
|
|
2759
|
+
e.preventDefault();
|
|
2760
|
+
}
|
|
2761
|
+
},
|
|
2762
|
+
children: /* @__PURE__ */ jsxs14("div", { className: "r-select-grid", children: [
|
|
2763
|
+
/* @__PURE__ */ jsx15("div", { className: "r-select-gridtable", ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight2 }, children: /* @__PURE__ */ jsx15(RenderTable, {}) }),
|
|
2764
|
+
/* @__PURE__ */ jsxs14("div", { className: classnames8("r-select-footer", { "d-none": !(showFooter === true || handleAdd || isMulti) }), children: [
|
|
2765
|
+
/* @__PURE__ */ jsxs14(Button5, { outline: true, color: "primary", onClick: handleAdd, className: classnames8("r-btn d-flex align-items-center", { "d-none": !handleAdd }), children: [
|
|
2766
|
+
/* @__PURE__ */ jsx15(Plus3, { className: "me-50", fontSize: 16 }),
|
|
2767
|
+
t("AddNew"),
|
|
2768
|
+
" (F9)"
|
|
2769
|
+
] }),
|
|
2770
|
+
isMulti && /* @__PURE__ */ jsx15("div", { className: "ms-50 text-primary h-100 d-flex align-items-center", onClick: handleAdd, children: t("countSelected", { item: value?.length ?? 0 }) }),
|
|
2771
|
+
footerComponent ? footerComponent() : null
|
|
2772
|
+
] })
|
|
2773
|
+
] })
|
|
2774
|
+
}
|
|
2775
|
+
) })
|
|
2776
|
+
}
|
|
2777
|
+
)
|
|
2778
|
+
]
|
|
2779
|
+
}
|
|
2780
|
+
) })
|
|
2781
|
+
}
|
|
2782
|
+
);
|
|
2783
|
+
});
|
|
2784
|
+
|
|
2785
|
+
// test-app/src/component/table/index.tsx
|
|
2786
|
+
import { Fragment as Fragment20, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2787
|
+
var TableEdit = forwardRef4((props, ref) => {
|
|
2788
|
+
const { t } = useTranslation12();
|
|
2206
2789
|
const {
|
|
2207
2790
|
idTable,
|
|
2208
2791
|
dataSource,
|
|
@@ -2235,31 +2818,30 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2235
2818
|
refeshFocusRow: handleRefeshRow
|
|
2236
2819
|
};
|
|
2237
2820
|
});
|
|
2238
|
-
const [refreshRow, setRefreshRow] =
|
|
2239
|
-
const [indexFocus, setIndexFocus] =
|
|
2240
|
-
const [selectedRows, setSelectedRows] =
|
|
2241
|
-
const [headerColumns, setHeaderColumns] =
|
|
2242
|
-
const [contentColumns, setContentColumns] =
|
|
2243
|
-
const [levelCol, setLevelCol] =
|
|
2244
|
-
const [columnFistEdit, setColumnFistEdit] =
|
|
2245
|
-
const [columnLastEdit, setColumnlastEdit] =
|
|
2246
|
-
const [objWidthFix, setObjWidthFix] =
|
|
2247
|
-
const [
|
|
2248
|
-
const [
|
|
2249
|
-
const
|
|
2250
|
-
const
|
|
2251
|
-
const gridRef = useRef3();
|
|
2821
|
+
const [refreshRow, setRefreshRow] = useState8(false);
|
|
2822
|
+
const [indexFocus, setIndexFocus] = useState8();
|
|
2823
|
+
const [selectedRows, setSelectedRows] = useState8([]);
|
|
2824
|
+
const [headerColumns, setHeaderColumns] = useState8([[]]);
|
|
2825
|
+
const [contentColumns, setContentColumns] = useState8([]);
|
|
2826
|
+
const [levelCol, setLevelCol] = useState8(0);
|
|
2827
|
+
const [columnFistEdit, setColumnFistEdit] = useState8(0);
|
|
2828
|
+
const [columnLastEdit, setColumnlastEdit] = useState8(0);
|
|
2829
|
+
const [objWidthFix, setObjWidthFix] = useState8({});
|
|
2830
|
+
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState8(false);
|
|
2831
|
+
const [searchTerm, setSearchTerm] = useState8("");
|
|
2832
|
+
const tableElement = useRef4(null);
|
|
2833
|
+
const gridRef = useRef4();
|
|
2252
2834
|
let totalCount = dataSource.length;
|
|
2253
2835
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
2254
2836
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
2255
2837
|
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
2256
2838
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
2257
|
-
|
|
2839
|
+
useEffect9(() => {
|
|
2258
2840
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
2259
2841
|
pagingSetting.setCurrentPage(1);
|
|
2260
2842
|
}
|
|
2261
2843
|
}, [dataSource]);
|
|
2262
|
-
|
|
2844
|
+
useEffect9(() => {
|
|
2263
2845
|
let indexFirst = -1;
|
|
2264
2846
|
let indexlast = -1;
|
|
2265
2847
|
let letfWidthFix = 0;
|
|
@@ -2293,7 +2875,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2293
2875
|
setColumnFistEdit(indexFirst + 1);
|
|
2294
2876
|
setColumnlastEdit(indexlast + 1);
|
|
2295
2877
|
}, [contentColumns]);
|
|
2296
|
-
|
|
2878
|
+
useEffect9(() => {
|
|
2297
2879
|
const arrHeaderColumns = [];
|
|
2298
2880
|
const arrContentColumns = [];
|
|
2299
2881
|
let headerLevelRow = 0;
|
|
@@ -2310,7 +2892,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2310
2892
|
setHeaderColumns(arrHeaderColumns);
|
|
2311
2893
|
setContentColumns(arrContentColumns);
|
|
2312
2894
|
}, [columns]);
|
|
2313
|
-
|
|
2895
|
+
useEffect9(() => {
|
|
2314
2896
|
const arrHeaderColumns = [];
|
|
2315
2897
|
const arrContentColumns = [];
|
|
2316
2898
|
let headerLevelRow = 0;
|
|
@@ -2427,7 +3009,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2427
3009
|
}
|
|
2428
3010
|
};
|
|
2429
3011
|
const searchTemplate = () => {
|
|
2430
|
-
return /* @__PURE__ */
|
|
3012
|
+
return /* @__PURE__ */ jsx16(Fragment19, { children: /* @__PURE__ */ jsx16("div", { className: "me-50 r-search", children: /* @__PURE__ */ jsx16(
|
|
2431
3013
|
react_input_default,
|
|
2432
3014
|
{
|
|
2433
3015
|
style: { width: "230px" },
|
|
@@ -2448,12 +3030,12 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2448
3030
|
const renderEdit = (row, col, indexRow, indexCol) => {
|
|
2449
3031
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
2450
3032
|
case "date":
|
|
2451
|
-
return /* @__PURE__ */
|
|
2452
|
-
|
|
3033
|
+
return /* @__PURE__ */ jsx16(
|
|
3034
|
+
Input9,
|
|
2453
3035
|
{
|
|
2454
3036
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2455
3037
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2456
|
-
value: row[col.field] ?
|
|
3038
|
+
value: row[col.field] ? moment3(row[col.field]).format("yyyy-MM-DD") : row[col.field],
|
|
2457
3039
|
onChange: (val) => {
|
|
2458
3040
|
row[col.field] = val.target.value;
|
|
2459
3041
|
if (col.callback) {
|
|
@@ -2461,7 +3043,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2461
3043
|
}
|
|
2462
3044
|
handleDataChange(row, col, indexRow);
|
|
2463
3045
|
},
|
|
2464
|
-
className:
|
|
3046
|
+
className: classnames9("border-0 rounded-0 r-date-input", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2465
3047
|
type: "date",
|
|
2466
3048
|
max: "9999-12-31",
|
|
2467
3049
|
onKeyDown: (e) => {
|
|
@@ -2477,12 +3059,12 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2477
3059
|
}
|
|
2478
3060
|
);
|
|
2479
3061
|
case "datetime":
|
|
2480
|
-
return /* @__PURE__ */
|
|
2481
|
-
|
|
3062
|
+
return /* @__PURE__ */ jsx16(
|
|
3063
|
+
Input9,
|
|
2482
3064
|
{
|
|
2483
3065
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2484
3066
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2485
|
-
value: row[col.field] ?
|
|
3067
|
+
value: row[col.field] ? moment3(row[col.field]).format("yyyy-MM-DD HH:MM") : row[col.field],
|
|
2486
3068
|
onChange: (val) => {
|
|
2487
3069
|
row[col.field] = val.target.value;
|
|
2488
3070
|
if (col.callback) {
|
|
@@ -2490,7 +3072,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2490
3072
|
}
|
|
2491
3073
|
handleDataChange(row, col, indexRow);
|
|
2492
3074
|
},
|
|
2493
|
-
className:
|
|
3075
|
+
className: classnames9("border-0 rounded-0 r-date-input", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2494
3076
|
type: "datetime-local",
|
|
2495
3077
|
max: "9999-12-31T23:59",
|
|
2496
3078
|
onKeyDown: (e) => {
|
|
@@ -2521,7 +3103,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2521
3103
|
valueSelect = col.selectSettings?.defaultValue(row);
|
|
2522
3104
|
}
|
|
2523
3105
|
}
|
|
2524
|
-
return /* @__PURE__ */
|
|
3106
|
+
return /* @__PURE__ */ jsx16(
|
|
2525
3107
|
SelectTable,
|
|
2526
3108
|
{
|
|
2527
3109
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2529,7 +3111,11 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2529
3111
|
options: optionsSelect,
|
|
2530
3112
|
rowData: row,
|
|
2531
3113
|
onChange: (val) => {
|
|
2532
|
-
|
|
3114
|
+
if (isMulti) {
|
|
3115
|
+
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
3116
|
+
} else {
|
|
3117
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
|
|
3118
|
+
}
|
|
2533
3119
|
if (col.callback) {
|
|
2534
3120
|
col.callback(val, indexRow);
|
|
2535
3121
|
}
|
|
@@ -2547,6 +3133,10 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2547
3133
|
handleAdd: col.selectSettings?.handAddNew,
|
|
2548
3134
|
isMulti: col.selectSettings?.isMulti,
|
|
2549
3135
|
noHeader: col.selectSettings?.noHeader,
|
|
3136
|
+
showFooter: col.selectSettings?.showFooter,
|
|
3137
|
+
formatOptionLabel: col.selectSettings?.formatOptionLabel,
|
|
3138
|
+
footerComponent: col.selectSettings?.footerComponent,
|
|
3139
|
+
width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
2550
3140
|
invalid: col.validate && col.validate(row[col.field], row),
|
|
2551
3141
|
maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : void 0,
|
|
2552
3142
|
menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
@@ -2564,68 +3154,95 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2564
3154
|
}
|
|
2565
3155
|
);
|
|
2566
3156
|
case "selectTree":
|
|
2567
|
-
let valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? [row[col.field]] : [];
|
|
2568
3157
|
const findItemInTree = (items, value) => {
|
|
2569
3158
|
for (let index = 0; index < items.length; index++) {
|
|
2570
3159
|
const item = items[index];
|
|
2571
3160
|
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
|
|
2572
3161
|
return { ...item };
|
|
2573
|
-
} else if (item["children"]?.length > 0) {
|
|
2574
|
-
const itemFilter = findItemInTree(item["children"], value);
|
|
3162
|
+
} else if (item[col.selectSettings?.fieldChild ?? "children"]?.length > 0) {
|
|
3163
|
+
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ?? "children"], value);
|
|
2575
3164
|
if (itemFilter) {
|
|
2576
3165
|
return itemFilter;
|
|
2577
3166
|
}
|
|
2578
3167
|
}
|
|
2579
3168
|
}
|
|
2580
3169
|
};
|
|
2581
|
-
|
|
3170
|
+
let valueSelectTree;
|
|
3171
|
+
let optionsSelectTree = [];
|
|
3172
|
+
if (col.selectSettings?.optionsField) {
|
|
3173
|
+
optionsSelectTree = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
3174
|
+
} else {
|
|
3175
|
+
optionsSelectTree = col.selectSettings?.options ? col.selectSettings?.validateOption ? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row)) : col.selectSettings?.options : [];
|
|
3176
|
+
}
|
|
3177
|
+
if (col.selectSettings?.isMulti) {
|
|
3178
|
+
valueSelectTree = row[col.field];
|
|
3179
|
+
} else {
|
|
3180
|
+
valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? findItemInTree(optionsSelectTree, row[col.field]) : "";
|
|
3181
|
+
}
|
|
3182
|
+
return /* @__PURE__ */ jsx16(
|
|
2582
3183
|
"div",
|
|
2583
3184
|
{
|
|
2584
3185
|
onKeyDown: (e) => {
|
|
2585
3186
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
2586
3187
|
}
|
|
2587
3188
|
},
|
|
2588
|
-
children: /* @__PURE__ */
|
|
2589
|
-
|
|
3189
|
+
children: /* @__PURE__ */ jsx16(
|
|
3190
|
+
SelectTableTree,
|
|
2590
3191
|
{
|
|
2591
3192
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2592
|
-
fields: {
|
|
2593
|
-
dataSource: col.selectSettings?.options,
|
|
2594
|
-
value: col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value",
|
|
2595
|
-
text: "label",
|
|
2596
|
-
parentValue: "parentId",
|
|
2597
|
-
child: "children"
|
|
2598
|
-
},
|
|
2599
|
-
className: classnames8("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2600
|
-
allowFiltering: false,
|
|
2601
3193
|
value: valueSelectTree,
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
}
|
|
2613
|
-
handleDataChange(row, col, indexRow);
|
|
3194
|
+
options: optionsSelectTree,
|
|
3195
|
+
rowData: row,
|
|
3196
|
+
onChange: (val) => {
|
|
3197
|
+
if (isMulti) {
|
|
3198
|
+
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
3199
|
+
} else {
|
|
3200
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
|
|
3201
|
+
}
|
|
3202
|
+
if (col.callback) {
|
|
3203
|
+
col.callback(val, indexRow);
|
|
2614
3204
|
}
|
|
3205
|
+
handleDataChange(row, col, indexRow);
|
|
2615
3206
|
},
|
|
2616
|
-
|
|
2617
|
-
|
|
3207
|
+
fieldValue: col.selectSettings?.fieldValue,
|
|
3208
|
+
fieldLabel: col.selectSettings?.fieldLabel,
|
|
3209
|
+
component: tableElement,
|
|
3210
|
+
columns: col.selectSettings?.columns,
|
|
3211
|
+
isClearable: col.selectSettings?.isClearable ?? false,
|
|
3212
|
+
decimalSeparator,
|
|
3213
|
+
thousandSeparator,
|
|
3214
|
+
placeholder: t("Select"),
|
|
3215
|
+
loadOptions: col.selectSettings?.loadOptions,
|
|
3216
|
+
handleAdd: col.selectSettings?.handAddNew,
|
|
3217
|
+
fieldChildren: col.selectSettings?.fieldChild ?? "children",
|
|
3218
|
+
selectChilds: col.selectSettings?.selectChilds,
|
|
3219
|
+
showFooter: col.selectSettings?.showFooter,
|
|
3220
|
+
formatOptionLabel: col.selectSettings?.formatOptionLabel,
|
|
3221
|
+
footerComponent: col.selectSettings?.footerComponent,
|
|
3222
|
+
width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
3223
|
+
isMulti: col.selectSettings?.isMulti,
|
|
3224
|
+
noHeader: col.selectSettings?.noHeader,
|
|
3225
|
+
invalid: col.validate && col.validate(row[col.field], row),
|
|
3226
|
+
maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : void 0,
|
|
3227
|
+
menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : void 0,
|
|
3228
|
+
textAlign: col.textAlign ?? "left",
|
|
3229
|
+
onKeyDown: (e) => {
|
|
3230
|
+
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
3231
|
+
}
|
|
2618
3232
|
},
|
|
2619
|
-
|
|
2620
|
-
|
|
3233
|
+
onPaste: (e) => {
|
|
3234
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable) {
|
|
3235
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
3236
|
+
e.preventDefault();
|
|
3237
|
+
}
|
|
2621
3238
|
}
|
|
2622
3239
|
}
|
|
2623
3240
|
)
|
|
2624
3241
|
}
|
|
2625
3242
|
);
|
|
2626
3243
|
case "checkbox":
|
|
2627
|
-
return /* @__PURE__ */
|
|
2628
|
-
|
|
3244
|
+
return /* @__PURE__ */ jsx16(
|
|
3245
|
+
Input9,
|
|
2629
3246
|
{
|
|
2630
3247
|
checked: row[col.field],
|
|
2631
3248
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2647,13 +3264,13 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2647
3264
|
);
|
|
2648
3265
|
case "numeric":
|
|
2649
3266
|
let valueCurrency = row[col.field];
|
|
2650
|
-
return /* @__PURE__ */
|
|
2651
|
-
|
|
3267
|
+
return /* @__PURE__ */ jsx16(
|
|
3268
|
+
Input9,
|
|
2652
3269
|
{
|
|
2653
3270
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2654
3271
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2655
3272
|
defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
|
|
2656
|
-
className:
|
|
3273
|
+
className: classnames9("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2657
3274
|
onChange: (val) => {
|
|
2658
3275
|
let newVal = "";
|
|
2659
3276
|
const flag = val.target?.value.startsWith("-");
|
|
@@ -2737,8 +3354,8 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2737
3354
|
}
|
|
2738
3355
|
);
|
|
2739
3356
|
case "color":
|
|
2740
|
-
return /* @__PURE__ */
|
|
2741
|
-
|
|
3357
|
+
return /* @__PURE__ */ jsx16("div", { style: { padding: "4px 8px" }, children: /* @__PURE__ */ jsx16(
|
|
3358
|
+
Input9,
|
|
2742
3359
|
{
|
|
2743
3360
|
type: "color",
|
|
2744
3361
|
value: row[col.field],
|
|
@@ -2760,7 +3377,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2760
3377
|
`col-${indexRow}-${indexCol}`
|
|
2761
3378
|
) });
|
|
2762
3379
|
case "form":
|
|
2763
|
-
return /* @__PURE__ */
|
|
3380
|
+
return /* @__PURE__ */ jsx16(
|
|
2764
3381
|
edit_form_default,
|
|
2765
3382
|
{
|
|
2766
3383
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
@@ -2788,13 +3405,13 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2788
3405
|
}
|
|
2789
3406
|
);
|
|
2790
3407
|
default:
|
|
2791
|
-
return /* @__PURE__ */
|
|
2792
|
-
|
|
3408
|
+
return /* @__PURE__ */ jsx16(
|
|
3409
|
+
Input9,
|
|
2793
3410
|
{
|
|
2794
3411
|
id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
|
|
2795
3412
|
style: { textAlign: col.textAlign, height: 29 },
|
|
2796
3413
|
defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
|
|
2797
|
-
className:
|
|
3414
|
+
className: classnames9("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
|
|
2798
3415
|
onBlur: (val) => {
|
|
2799
3416
|
if (row[col.field] != val.target?.value) {
|
|
2800
3417
|
row[col.field] = val.target?.value;
|
|
@@ -2849,9 +3466,9 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2849
3466
|
}
|
|
2850
3467
|
}
|
|
2851
3468
|
if ((tableElement.current?.scrollHeight ?? 0) > 0) {
|
|
2852
|
-
if ((tableElement.current?.scrollTop ?? 0) > (row - 1) * 34) {
|
|
2853
|
-
tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) * 34 });
|
|
2854
|
-
} else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
3469
|
+
if ((tableElement.current?.scrollTop ?? 0) > (row - 1) % (pagingSetting?.pageSize ?? 1) * 34) {
|
|
3470
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: (row - 1) % (pagingSetting?.pageSize ?? 1) * 34 });
|
|
3471
|
+
} else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 < row % (pagingSetting?.pageSize ?? 1) * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
2855
3472
|
tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
|
|
2856
3473
|
}
|
|
2857
3474
|
}
|
|
@@ -2976,11 +3593,9 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
2976
3593
|
}
|
|
2977
3594
|
};
|
|
2978
3595
|
useOnClickOutside(gridRef, () => {
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
}, 50);
|
|
2983
|
-
}
|
|
3596
|
+
setTimeout(() => {
|
|
3597
|
+
setIndexFocus(-1);
|
|
3598
|
+
}, 50);
|
|
2984
3599
|
});
|
|
2985
3600
|
const handleAdd = () => {
|
|
2986
3601
|
const lengthData = dataSource.length;
|
|
@@ -3176,7 +3791,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3176
3791
|
}
|
|
3177
3792
|
}
|
|
3178
3793
|
};
|
|
3179
|
-
|
|
3794
|
+
useEffect9(() => {
|
|
3180
3795
|
setIndexFocus(-1);
|
|
3181
3796
|
if (setSelectedItem) {
|
|
3182
3797
|
if (isMulti) {
|
|
@@ -3203,7 +3818,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3203
3818
|
}
|
|
3204
3819
|
}
|
|
3205
3820
|
}, [selectedRows]);
|
|
3206
|
-
|
|
3821
|
+
useEffect9(() => {
|
|
3207
3822
|
if (!isMulti) {
|
|
3208
3823
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
3209
3824
|
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
@@ -3220,10 +3835,10 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3220
3835
|
}, [selectedItem]);
|
|
3221
3836
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
3222
3837
|
if (col.field === "command") {
|
|
3223
|
-
return col.visible !== false && /* @__PURE__ */
|
|
3838
|
+
return col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3224
3839
|
"td",
|
|
3225
3840
|
{
|
|
3226
|
-
className:
|
|
3841
|
+
className: classnames9(
|
|
3227
3842
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3228
3843
|
{ "cell-fixed": col.fixedType },
|
|
3229
3844
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -3233,15 +3848,15 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3233
3848
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3234
3849
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3235
3850
|
},
|
|
3236
|
-
children: /* @__PURE__ */
|
|
3851
|
+
children: /* @__PURE__ */ jsx16("div", { className: "r-rowcell-div ", children: /* @__PURE__ */ jsx16(command_default, { commandItems: col.commandItems ?? [], handleCommandClick, indexRow, rowData: row, setIndexFocus, indexFocus }) })
|
|
3237
3852
|
},
|
|
3238
3853
|
`col-${indexRow}-${indexCol}`
|
|
3239
3854
|
);
|
|
3240
3855
|
} else if (col.field === "#") {
|
|
3241
|
-
return col.visible !== false && /* @__PURE__ */
|
|
3856
|
+
return col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3242
3857
|
"td",
|
|
3243
3858
|
{
|
|
3244
|
-
className:
|
|
3859
|
+
className: classnames9(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
3245
3860
|
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
3246
3861
|
style: {
|
|
3247
3862
|
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
@@ -3285,15 +3900,15 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3285
3900
|
e.stopPropagation();
|
|
3286
3901
|
}
|
|
3287
3902
|
},
|
|
3288
|
-
children: /* @__PURE__ */
|
|
3903
|
+
children: /* @__PURE__ */ jsx16("div", { className: "r-rowcell-div pt-50", children: indexRow + 1 })
|
|
3289
3904
|
},
|
|
3290
3905
|
`col-${indexRow}-${indexCol}`
|
|
3291
3906
|
);
|
|
3292
3907
|
} else if (col.field === "checkbox") {
|
|
3293
|
-
return /* @__PURE__ */
|
|
3908
|
+
return /* @__PURE__ */ jsx16(
|
|
3294
3909
|
"td",
|
|
3295
3910
|
{
|
|
3296
|
-
className:
|
|
3911
|
+
className: classnames9(
|
|
3297
3912
|
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3298
3913
|
{ "cell-fixed": col.fixedType },
|
|
3299
3914
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -3303,7 +3918,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3303
3918
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3304
3919
|
textAlign: col.textAlign ? col.textAlign : "center"
|
|
3305
3920
|
},
|
|
3306
|
-
children: /* @__PURE__ */
|
|
3921
|
+
children: /* @__PURE__ */ jsx16(
|
|
3307
3922
|
"div",
|
|
3308
3923
|
{
|
|
3309
3924
|
className: "r-rowcell-div cursor-pointer",
|
|
@@ -3327,8 +3942,8 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3327
3942
|
e.stopPropagation();
|
|
3328
3943
|
}
|
|
3329
3944
|
},
|
|
3330
|
-
children: /* @__PURE__ */
|
|
3331
|
-
|
|
3945
|
+
children: /* @__PURE__ */ jsx16(
|
|
3946
|
+
Input9,
|
|
3332
3947
|
{
|
|
3333
3948
|
checked: isSelected,
|
|
3334
3949
|
type: "checkbox",
|
|
@@ -3348,16 +3963,16 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3348
3963
|
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3349
3964
|
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
3350
3965
|
} else if (col.editType === "date") {
|
|
3351
|
-
value = value ?
|
|
3966
|
+
value = value ? moment3(value).format("DD/MM/yyyy") : "";
|
|
3352
3967
|
} else if (col.editType === "datetime") {
|
|
3353
|
-
value = value ?
|
|
3968
|
+
value = value ? moment3(value).format("DD/MM/yyyy HH:mm") : "";
|
|
3354
3969
|
}
|
|
3355
3970
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3356
3971
|
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
3357
|
-
return /* @__PURE__ */
|
|
3972
|
+
return /* @__PURE__ */ jsx16(Fragment19, { children: col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3358
3973
|
"td",
|
|
3359
3974
|
{
|
|
3360
|
-
className:
|
|
3975
|
+
className: classnames9(
|
|
3361
3976
|
`r-rowcell fix-${col.fixedType}`,
|
|
3362
3977
|
{ "cell-fixed": col.fixedType },
|
|
3363
3978
|
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
@@ -3399,25 +4014,25 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3399
4014
|
e.stopPropagation();
|
|
3400
4015
|
}
|
|
3401
4016
|
},
|
|
3402
|
-
children: /* @__PURE__ */
|
|
4017
|
+
children: /* @__PURE__ */ jsx16(
|
|
3403
4018
|
"div",
|
|
3404
4019
|
{
|
|
3405
|
-
className:
|
|
3406
|
-
children: /* @__PURE__ */
|
|
4020
|
+
className: classnames9("r-rowcell-div"),
|
|
4021
|
+
children: /* @__PURE__ */ jsxs15(
|
|
3407
4022
|
"div",
|
|
3408
4023
|
{
|
|
3409
4024
|
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
3410
|
-
className:
|
|
4025
|
+
className: classnames9("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
3411
4026
|
style: {
|
|
3412
4027
|
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
3413
4028
|
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
3414
4029
|
},
|
|
3415
4030
|
children: [
|
|
3416
|
-
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */
|
|
3417
|
-
/* @__PURE__ */
|
|
3418
|
-
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */
|
|
3419
|
-
/* @__PURE__ */
|
|
3420
|
-
|
|
4031
|
+
typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : /* @__PURE__ */ jsx16("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
4032
|
+
/* @__PURE__ */ jsx16("span", { id: `error-${indexRow}-${indexCol}`, className: classnames9("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ jsx16(AlertCircle, { fontSize: 15.5 }) }),
|
|
4033
|
+
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx16(UncontrolledTooltip5, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
4034
|
+
/* @__PURE__ */ jsx16(
|
|
4035
|
+
UncontrolledTooltip5,
|
|
3421
4036
|
{
|
|
3422
4037
|
target: `error-${indexRow}-${indexCol}`,
|
|
3423
4038
|
className: "r-tooltip tooltip-error",
|
|
@@ -3439,10 +4054,10 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3439
4054
|
return element && element.scrollWidth > element.clientWidth;
|
|
3440
4055
|
};
|
|
3441
4056
|
const renderFooterCol = (col, indexCol) => {
|
|
3442
|
-
return /* @__PURE__ */
|
|
4057
|
+
return /* @__PURE__ */ jsx16(Fragment19, { children: col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3443
4058
|
"td",
|
|
3444
4059
|
{
|
|
3445
|
-
className:
|
|
4060
|
+
className: classnames9(
|
|
3446
4061
|
`p-0 px-50 r-footer fix-${col.fixedType}`,
|
|
3447
4062
|
{ "cell-fixed": col.fixedType }
|
|
3448
4063
|
),
|
|
@@ -3451,56 +4066,56 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3451
4066
|
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3452
4067
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3453
4068
|
},
|
|
3454
|
-
children: /* @__PURE__ */
|
|
4069
|
+
children: /* @__PURE__ */ jsx16("div", { className: "r-footer-div", children: col.haveSum === true && col.editType === "numeric" ? formartNumberic(dataSource.reduce(function(accumulator, currentValue) {
|
|
3455
4070
|
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
3456
4071
|
}, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : "" })
|
|
3457
4072
|
}
|
|
3458
4073
|
) }, `summarycell-${indexCol}`);
|
|
3459
4074
|
};
|
|
3460
4075
|
const renderToolbarTop = () => {
|
|
3461
|
-
return /* @__PURE__ */
|
|
3462
|
-
/* @__PURE__ */
|
|
3463
|
-
return item.align === "left" ? /* @__PURE__ */
|
|
4076
|
+
return /* @__PURE__ */ jsx16("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs15("div", { className: "r-toolbar-items", children: [
|
|
4077
|
+
/* @__PURE__ */ jsx16("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
|
|
4078
|
+
return item.align === "left" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
|
|
3464
4079
|
}) }),
|
|
3465
|
-
/* @__PURE__ */
|
|
3466
|
-
return item.align === "center" ? /* @__PURE__ */
|
|
4080
|
+
/* @__PURE__ */ jsx16("div", { className: "r-toolbar-center", children: toolbarTopOption?.map((item, index) => {
|
|
4081
|
+
return item.align === "center" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) : "";
|
|
3467
4082
|
}) }),
|
|
3468
|
-
/* @__PURE__ */
|
|
3469
|
-
return item.align === "right" ? /* @__PURE__ */
|
|
4083
|
+
/* @__PURE__ */ jsx16("div", { className: "r-toolbar-right", children: toolbarTopOption?.map((item, index) => {
|
|
4084
|
+
return item.align === "right" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) : "";
|
|
3470
4085
|
}) })
|
|
3471
4086
|
] }) });
|
|
3472
4087
|
};
|
|
3473
4088
|
const renderToolbarBottom = () => {
|
|
3474
|
-
return /* @__PURE__ */
|
|
3475
|
-
/* @__PURE__ */
|
|
3476
|
-
/* @__PURE__ */
|
|
3477
|
-
(indexFocus ?? -1) > -1 ? /* @__PURE__ */
|
|
3478
|
-
/* @__PURE__ */
|
|
4089
|
+
return /* @__PURE__ */ jsx16("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs15("div", { className: "r-toolbar-items", children: [
|
|
4090
|
+
/* @__PURE__ */ jsxs15("div", { className: "r-toolbar-left", children: [
|
|
4091
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
|
|
4092
|
+
(indexFocus ?? -1) > -1 ? /* @__PURE__ */ jsxs15(Fragment20, { children: [
|
|
4093
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "success", outline: true, onClick: () => {
|
|
3479
4094
|
handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
|
|
3480
4095
|
}, className: "d-flex", children: t("Duplicate") }) }),
|
|
3481
|
-
/* @__PURE__ */
|
|
3482
|
-
/* @__PURE__ */
|
|
3483
|
-
] }) : /* @__PURE__ */
|
|
3484
|
-
/* @__PURE__ */
|
|
4096
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
|
|
4097
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || addDisable || buttonSetting?.insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
|
|
4098
|
+
] }) : /* @__PURE__ */ jsx16(Fragment20, { children: " " }),
|
|
4099
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || buttonSetting?.deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
|
|
3485
4100
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
3486
|
-
return item.align === "left" ? /* @__PURE__ */
|
|
4101
|
+
return item.align === "left" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
|
|
3487
4102
|
})
|
|
3488
4103
|
] }),
|
|
3489
|
-
/* @__PURE__ */
|
|
3490
|
-
return item.align === "center" ? /* @__PURE__ */
|
|
4104
|
+
/* @__PURE__ */ jsx16("div", { className: "r-toolbar-center", children: toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
4105
|
+
return item.align === "center" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : "";
|
|
3491
4106
|
}) }),
|
|
3492
|
-
/* @__PURE__ */
|
|
4107
|
+
/* @__PURE__ */ jsxs15("div", { className: "r-toolbar-right", children: [
|
|
3493
4108
|
toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
3494
|
-
return item.align === "right" ? /* @__PURE__ */
|
|
4109
|
+
return item.align === "right" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
|
|
3495
4110
|
}),
|
|
3496
|
-
/* @__PURE__ */
|
|
3497
|
-
/* @__PURE__ */
|
|
3498
|
-
/* @__PURE__ */
|
|
3499
|
-
/* @__PURE__ */
|
|
3500
|
-
/* @__PURE__ */
|
|
3501
|
-
/* @__PURE__ */
|
|
3502
|
-
/* @__PURE__ */
|
|
3503
|
-
/* @__PURE__ */
|
|
4111
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
|
|
4112
|
+
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsxs15(UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
|
|
4113
|
+
/* @__PURE__ */ jsx16(DropdownToggle4, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx16(Info2, { className: "cursor-pointer" }) }),
|
|
4114
|
+
/* @__PURE__ */ jsx16(DropdownMenu4, { children: /* @__PURE__ */ jsxs15("div", { className: "d-flex flex-column p-50 py-25", children: [
|
|
4115
|
+
/* @__PURE__ */ jsx16("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\xE2n b\u1EA3n" }),
|
|
4116
|
+
/* @__PURE__ */ jsx16("div", { style: { fontSize: 13 }, children: "Ch\u1ECDn \xF4 v\xE0 Ctrl + V \u0111\u1EC3 d\xE1n th\xF4ng tin t\u1EEB excel" }),
|
|
4117
|
+
/* @__PURE__ */ jsx16("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + C \u0111\u1EC3 sao ch\xE9p h\xE0ng" }),
|
|
4118
|
+
/* @__PURE__ */ jsx16("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + V \u0111\u1EC3 d\xE1n h\xE0ng" })
|
|
3504
4119
|
] }) })
|
|
3505
4120
|
] }) })
|
|
3506
4121
|
] })
|
|
@@ -3529,10 +4144,10 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3529
4144
|
const flagDisplay = !pagingClient || totalCount > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && totalCount <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0);
|
|
3530
4145
|
if (flagDisplay) {
|
|
3531
4146
|
countDisplay++;
|
|
3532
|
-
return /* @__PURE__ */
|
|
4147
|
+
return /* @__PURE__ */ jsx16(
|
|
3533
4148
|
"tr",
|
|
3534
4149
|
{
|
|
3535
|
-
className:
|
|
4150
|
+
className: classnames9("r-row", { "fisrt-row": countDisplay === 0 }),
|
|
3536
4151
|
children: contentColumns.map((col, indexCol) => {
|
|
3537
4152
|
return renderContentCol(col, row, indexRow, indexCol, isSelected);
|
|
3538
4153
|
})
|
|
@@ -3543,19 +4158,19 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3543
4158
|
}
|
|
3544
4159
|
});
|
|
3545
4160
|
};
|
|
3546
|
-
|
|
4161
|
+
useEffect9(() => {
|
|
3547
4162
|
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
3548
4163
|
pagingSetting?.setCurrentPage(1);
|
|
3549
4164
|
}
|
|
3550
4165
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
3551
|
-
return /* @__PURE__ */
|
|
3552
|
-
/* @__PURE__ */
|
|
3553
|
-
/* @__PURE__ */
|
|
3554
|
-
toolbarSetting?.showTopToolbar ? /* @__PURE__ */
|
|
3555
|
-
/* @__PURE__ */
|
|
3556
|
-
/* @__PURE__ */
|
|
3557
|
-
return /* @__PURE__ */
|
|
3558
|
-
return /* @__PURE__ */
|
|
4166
|
+
return /* @__PURE__ */ jsxs15(Fragment19, { children: [
|
|
4167
|
+
/* @__PURE__ */ jsxs15("div", { className: "react-table-edit", children: [
|
|
4168
|
+
/* @__PURE__ */ jsxs15("div", { className: "r-grid", ref: gridRef, children: [
|
|
4169
|
+
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ jsx16(Fragment20, { children: renderToolbarTop() }) : /* @__PURE__ */ jsx16(Fragment20, {}),
|
|
4170
|
+
/* @__PURE__ */ jsx16("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ jsxs15("table", { style: { width: "100%" }, children: [
|
|
4171
|
+
/* @__PURE__ */ jsx16("thead", { className: "r-gridheader", children: headerColumns.map((element, indexParent) => {
|
|
4172
|
+
return /* @__PURE__ */ jsx16("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
4173
|
+
return /* @__PURE__ */ jsx16(
|
|
3559
4174
|
header_default,
|
|
3560
4175
|
{
|
|
3561
4176
|
col,
|
|
@@ -3575,14 +4190,14 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3575
4190
|
);
|
|
3576
4191
|
}) }, `header-${-indexParent}`);
|
|
3577
4192
|
}) }),
|
|
3578
|
-
/* @__PURE__ */
|
|
3579
|
-
/* @__PURE__ */
|
|
4193
|
+
/* @__PURE__ */ jsx16("tbody", { className: "r-gridcontent", children: renderData() }),
|
|
4194
|
+
/* @__PURE__ */ jsx16("tfoot", { className: "r-gridfoot", children: haveSum == true ? /* @__PURE__ */ jsx16("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
3580
4195
|
return renderFooterCol(col, index);
|
|
3581
|
-
}) }) : /* @__PURE__ */
|
|
4196
|
+
}) }) : /* @__PURE__ */ jsx16(Fragment20, {}) })
|
|
3582
4197
|
] }) }),
|
|
3583
|
-
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */
|
|
4198
|
+
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ jsx16(Fragment20, { children: renderToolbarBottom() }) : /* @__PURE__ */ jsx16(Fragment20, {})
|
|
3584
4199
|
] }),
|
|
3585
|
-
pagingSetting?.allowPaging ? /* @__PURE__ */
|
|
4200
|
+
pagingSetting?.allowPaging ? /* @__PURE__ */ jsx16(
|
|
3586
4201
|
PagingComponent,
|
|
3587
4202
|
{
|
|
3588
4203
|
onChangePage,
|
|
@@ -3592,9 +4207,9 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3592
4207
|
totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0,
|
|
3593
4208
|
onChangePageSize
|
|
3594
4209
|
}
|
|
3595
|
-
) : /* @__PURE__ */
|
|
4210
|
+
) : /* @__PURE__ */ jsx16(Fragment20, {})
|
|
3596
4211
|
] }),
|
|
3597
|
-
/* @__PURE__ */
|
|
4212
|
+
/* @__PURE__ */ jsx16(
|
|
3598
4213
|
sidebar_setting_column_default,
|
|
3599
4214
|
{
|
|
3600
4215
|
handleSidebar: () => {
|
|
@@ -3610,12 +4225,12 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3610
4225
|
var table_default = TableEdit;
|
|
3611
4226
|
|
|
3612
4227
|
// test-app/src/component/tab-menu/index.tsx
|
|
3613
|
-
import { ChevronLeft as ChevronLeft3, ChevronRight as
|
|
4228
|
+
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight4 } from "becoxy-icons";
|
|
3614
4229
|
import classNames6 from "classnames";
|
|
3615
|
-
import { Fragment as
|
|
4230
|
+
import { Fragment as Fragment21, useEffect as useEffect10, useState as useState9 } from "react";
|
|
3616
4231
|
import { Link, useNavigate } from "react-router-dom";
|
|
3617
|
-
import { DropdownItem as
|
|
3618
|
-
import { jsx as
|
|
4232
|
+
import { DropdownItem as DropdownItem4, DropdownMenu as DropdownMenu5, DropdownToggle as DropdownToggle5, UncontrolledDropdown as UncontrolledDropdown2 } from "reactstrap";
|
|
4233
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3619
4234
|
var TabsMenuComponent = ({
|
|
3620
4235
|
buttonWidth,
|
|
3621
4236
|
tabParent,
|
|
@@ -3627,14 +4242,14 @@ var TabsMenuComponent = ({
|
|
|
3627
4242
|
renderModal
|
|
3628
4243
|
}) => {
|
|
3629
4244
|
const navigate = useNavigate();
|
|
3630
|
-
const [dataMenu, setDataMenu] =
|
|
3631
|
-
const [openMenu, setOpenMenu] =
|
|
3632
|
-
const [url, setUrl] =
|
|
3633
|
-
const [contentWidth, setContentWidth] =
|
|
3634
|
-
const [componentWidth, setComponentWidth] =
|
|
3635
|
-
const [scrollPosition, setScrollPosition] =
|
|
3636
|
-
const [dataItem, setDataItem] =
|
|
3637
|
-
const [openModal, setOpenModal] =
|
|
4245
|
+
const [dataMenu, setDataMenu] = useState9([]);
|
|
4246
|
+
const [openMenu, setOpenMenu] = useState9(false);
|
|
4247
|
+
const [url, setUrl] = useState9("");
|
|
4248
|
+
const [contentWidth, setContentWidth] = useState9(0);
|
|
4249
|
+
const [componentWidth, setComponentWidth] = useState9(0);
|
|
4250
|
+
const [scrollPosition, setScrollPosition] = useState9(0);
|
|
4251
|
+
const [dataItem, setDataItem] = useState9([]);
|
|
4252
|
+
const [openModal, setOpenModal] = useState9({});
|
|
3638
4253
|
const handleWindowResize = () => {
|
|
3639
4254
|
const tabEle = document.getElementById(`tab-component-${resourceCode}`);
|
|
3640
4255
|
const tabContent = document.getElementById(`content-component-${resourceCode}`);
|
|
@@ -3643,7 +4258,7 @@ var TabsMenuComponent = ({
|
|
|
3643
4258
|
setContentWidth(tabContent?.offsetWidth ?? 0);
|
|
3644
4259
|
}
|
|
3645
4260
|
};
|
|
3646
|
-
|
|
4261
|
+
useEffect10(() => {
|
|
3647
4262
|
setUrl(window.location.pathname);
|
|
3648
4263
|
window.addEventListener("resize", handleWindowResize);
|
|
3649
4264
|
setTimeout(() => {
|
|
@@ -3659,7 +4274,7 @@ var TabsMenuComponent = ({
|
|
|
3659
4274
|
window.removeEventListener("resize", handleWindowResize);
|
|
3660
4275
|
};
|
|
3661
4276
|
}, []);
|
|
3662
|
-
|
|
4277
|
+
useEffect10(() => {
|
|
3663
4278
|
const item = resources?.find((x) => x.code === (resourceCodeParent ? resourceCodeParent : resourceCode));
|
|
3664
4279
|
if (item) {
|
|
3665
4280
|
if (resourceCodeParent) {
|
|
@@ -3690,23 +4305,23 @@ var TabsMenuComponent = ({
|
|
|
3690
4305
|
const handleModal = (name) => {
|
|
3691
4306
|
setOpenModal((old) => ({ ...old, [name]: !(openModal[name] ?? false) }));
|
|
3692
4307
|
};
|
|
3693
|
-
return /* @__PURE__ */
|
|
4308
|
+
return /* @__PURE__ */ jsxs16(Fragment21, { children: [
|
|
3694
4309
|
renderModal ? renderModal({ handleModal, windowSize, openModal, setDataItem, dataItem }) : "",
|
|
3695
|
-
/* @__PURE__ */
|
|
3696
|
-
/* @__PURE__ */
|
|
4310
|
+
/* @__PURE__ */ jsxs16("div", { className: classNames6("tab-custom", { "tab-parent": tabParent }, { "tab-child": tabChild }), style: { width: `calc(100% - ${buttonWidth ?? 100}px` }, children: [
|
|
4311
|
+
/* @__PURE__ */ jsx17(
|
|
3697
4312
|
"div",
|
|
3698
4313
|
{
|
|
3699
4314
|
onClick: () => handleScroll(-200),
|
|
3700
4315
|
className: classNames6("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3701
|
-
children: /* @__PURE__ */
|
|
4316
|
+
children: /* @__PURE__ */ jsx17(ChevronLeft3, {})
|
|
3702
4317
|
}
|
|
3703
4318
|
),
|
|
3704
|
-
/* @__PURE__ */
|
|
4319
|
+
/* @__PURE__ */ jsx17("div", { id: `tab-component-${resourceCode}`, className: "tab-component", children: /* @__PURE__ */ jsx17("div", { id: `content-component-${resourceCode}`, children: dataMenu.map((item) => {
|
|
3705
4320
|
if (item?.resAttributes?.IS_MENU === "1") {
|
|
3706
|
-
return /* @__PURE__ */
|
|
3707
|
-
/* @__PURE__ */
|
|
3708
|
-
/* @__PURE__ */
|
|
3709
|
-
|
|
4321
|
+
return /* @__PURE__ */ jsxs16(UncontrolledDropdown2, { className: "tab-custom-item", isOpen: openMenu, toggle: toggleMenu, direction: "down", style: { backgroundColor: openMenu ? "#e0e0e0" : "" }, children: [
|
|
4322
|
+
/* @__PURE__ */ jsx17(DropdownToggle5, { color: "#00000", style: { border: "none", boxShadow: "none", margin: 0, padding: 0 }, className: "background-none", children: /* @__PURE__ */ jsx17("div", { children: item.name }) }),
|
|
4323
|
+
/* @__PURE__ */ jsx17(DropdownMenu5, { container: document.body, end: true, style: { width: 300 }, children: item?.children?.map((x) => /* @__PURE__ */ jsx17(
|
|
4324
|
+
DropdownItem4,
|
|
3710
4325
|
{
|
|
3711
4326
|
style: { borderRadius: "5px", margin: "0 0.5rem", width: "95%" },
|
|
3712
4327
|
onClick: () => {
|
|
@@ -3722,7 +4337,7 @@ var TabsMenuComponent = ({
|
|
|
3722
4337
|
)) })
|
|
3723
4338
|
] }, item.code);
|
|
3724
4339
|
} else {
|
|
3725
|
-
return /* @__PURE__ */
|
|
4340
|
+
return /* @__PURE__ */ jsx17(
|
|
3726
4341
|
Link,
|
|
3727
4342
|
{
|
|
3728
4343
|
to: item.url,
|
|
@@ -3733,12 +4348,12 @@ var TabsMenuComponent = ({
|
|
|
3733
4348
|
);
|
|
3734
4349
|
}
|
|
3735
4350
|
}) }) }),
|
|
3736
|
-
/* @__PURE__ */
|
|
4351
|
+
/* @__PURE__ */ jsx17(
|
|
3737
4352
|
"div",
|
|
3738
4353
|
{
|
|
3739
4354
|
onClick: () => handleScroll(200),
|
|
3740
4355
|
className: classNames6("btn-scroll", { "d-none": componentWidth >= contentWidth - 20 }),
|
|
3741
|
-
children: /* @__PURE__ */
|
|
4356
|
+
children: /* @__PURE__ */ jsx17(ChevronRight4, {})
|
|
3742
4357
|
}
|
|
3743
4358
|
)
|
|
3744
4359
|
] })
|
|
@@ -3747,9 +4362,9 @@ var TabsMenuComponent = ({
|
|
|
3747
4362
|
|
|
3748
4363
|
// test-app/src/component/input-style/index.tsx
|
|
3749
4364
|
import { Bold, Droplet, Italic, Type, Underline } from "becoxy-icons";
|
|
3750
|
-
import { Button as
|
|
3751
|
-
import
|
|
3752
|
-
import { Fragment as
|
|
4365
|
+
import { Button as Button7, Input as Input10 } from "reactstrap";
|
|
4366
|
+
import classnames10 from "classnames";
|
|
4367
|
+
import { Fragment as Fragment22 } from "react";
|
|
3753
4368
|
|
|
3754
4369
|
// test-app/src/component/input-style/fonts.ts
|
|
3755
4370
|
var OptionFont = [
|
|
@@ -4608,7 +5223,7 @@ var OptionFont = [
|
|
|
4608
5223
|
];
|
|
4609
5224
|
|
|
4610
5225
|
// test-app/src/component/input-style/index.tsx
|
|
4611
|
-
import { jsx as
|
|
5226
|
+
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4612
5227
|
var InputStyleComponent = (props) => {
|
|
4613
5228
|
const {
|
|
4614
5229
|
value,
|
|
@@ -4622,8 +5237,8 @@ var InputStyleComponent = (props) => {
|
|
|
4622
5237
|
disabledItalic,
|
|
4623
5238
|
disabledUnderline
|
|
4624
5239
|
} = props;
|
|
4625
|
-
return /* @__PURE__ */
|
|
4626
|
-
/* @__PURE__ */
|
|
5240
|
+
return /* @__PURE__ */ jsx18(Fragment22, { children: /* @__PURE__ */ jsxs17("div", { className: "d-flex align-items-center", children: [
|
|
5241
|
+
/* @__PURE__ */ jsx18(
|
|
4627
5242
|
SelectTable,
|
|
4628
5243
|
{
|
|
4629
5244
|
options: OptionFont,
|
|
@@ -4639,12 +5254,12 @@ var InputStyleComponent = (props) => {
|
|
|
4639
5254
|
field: "label",
|
|
4640
5255
|
headerText: "",
|
|
4641
5256
|
template: (row) => {
|
|
4642
|
-
return /* @__PURE__ */
|
|
5257
|
+
return /* @__PURE__ */ jsx18("div", { style: { fontFamily: row.label }, children: row.label });
|
|
4643
5258
|
}
|
|
4644
5259
|
}
|
|
4645
5260
|
],
|
|
4646
5261
|
formatOptionLabel: (props2) => {
|
|
4647
|
-
return /* @__PURE__ */
|
|
5262
|
+
return /* @__PURE__ */ jsx18("p", { style: {
|
|
4648
5263
|
paddingLeft: 3,
|
|
4649
5264
|
borderRadius: 2,
|
|
4650
5265
|
fontFamily: value.fontFamily,
|
|
@@ -4657,7 +5272,7 @@ var InputStyleComponent = (props) => {
|
|
|
4657
5272
|
}
|
|
4658
5273
|
}
|
|
4659
5274
|
),
|
|
4660
|
-
/* @__PURE__ */
|
|
5275
|
+
/* @__PURE__ */ jsx18("div", { className: classnames10("ms-25", { "d-none": disabledFontSize }), style: { width: 60 }, children: /* @__PURE__ */ jsx18(
|
|
4661
5276
|
SelectTable,
|
|
4662
5277
|
{
|
|
4663
5278
|
options: Array.from({ length: 100 }, (_, i) => ({ value: i + 1, label: i + 1 })),
|
|
@@ -4669,45 +5284,45 @@ var InputStyleComponent = (props) => {
|
|
|
4669
5284
|
}
|
|
4670
5285
|
}
|
|
4671
5286
|
) }),
|
|
4672
|
-
/* @__PURE__ */
|
|
5287
|
+
/* @__PURE__ */ jsx18(
|
|
4673
5288
|
"div",
|
|
4674
5289
|
{
|
|
4675
|
-
className:
|
|
5290
|
+
className: classnames10("btn-input-style", { "active-custom": value.bold }, { "d-none": disabledBold }),
|
|
4676
5291
|
onClick: () => {
|
|
4677
5292
|
if (!disabled) {
|
|
4678
5293
|
onChange({ ...value, bold: !value.bold });
|
|
4679
5294
|
}
|
|
4680
5295
|
},
|
|
4681
|
-
children: /* @__PURE__ */
|
|
5296
|
+
children: /* @__PURE__ */ jsx18(Bold, { fontSize: 18 })
|
|
4682
5297
|
}
|
|
4683
5298
|
),
|
|
4684
|
-
/* @__PURE__ */
|
|
5299
|
+
/* @__PURE__ */ jsx18(
|
|
4685
5300
|
"div",
|
|
4686
5301
|
{
|
|
4687
|
-
className:
|
|
5302
|
+
className: classnames10("btn-input-style", { "active-custom": value.italic }, { "d-none": disabledItalic }),
|
|
4688
5303
|
onClick: () => {
|
|
4689
5304
|
if (!disabled) {
|
|
4690
5305
|
onChange({ ...value, italic: !value.italic });
|
|
4691
5306
|
}
|
|
4692
5307
|
},
|
|
4693
|
-
children: /* @__PURE__ */
|
|
5308
|
+
children: /* @__PURE__ */ jsx18(Italic, { fontSize: 18 })
|
|
4694
5309
|
}
|
|
4695
5310
|
),
|
|
4696
|
-
/* @__PURE__ */
|
|
5311
|
+
/* @__PURE__ */ jsx18(
|
|
4697
5312
|
"div",
|
|
4698
5313
|
{
|
|
4699
|
-
className:
|
|
5314
|
+
className: classnames10("btn-input-style", { "active-custom": value.underline }, { "d-none": disabledUnderline }),
|
|
4700
5315
|
onClick: () => {
|
|
4701
5316
|
if (!disabled) {
|
|
4702
5317
|
onChange({ ...value, underline: !value.underline });
|
|
4703
5318
|
}
|
|
4704
5319
|
},
|
|
4705
|
-
children: /* @__PURE__ */
|
|
5320
|
+
children: /* @__PURE__ */ jsx18(Underline, { fontSize: 18 })
|
|
4706
5321
|
}
|
|
4707
5322
|
),
|
|
4708
|
-
/* @__PURE__ */
|
|
4709
|
-
/* @__PURE__ */
|
|
4710
|
-
/* @__PURE__ */
|
|
5323
|
+
/* @__PURE__ */ jsxs17(Button7, { tag: "label", color: "none", className: classnames10("btn-input-style", { "d-none": disabledColor }), children: [
|
|
5324
|
+
/* @__PURE__ */ jsx18(Type, { stroke: value.color ?? "#000000", fontSize: 18 }),
|
|
5325
|
+
/* @__PURE__ */ jsx18(
|
|
4711
5326
|
"input",
|
|
4712
5327
|
{
|
|
4713
5328
|
type: "color",
|
|
@@ -4721,10 +5336,10 @@ var InputStyleComponent = (props) => {
|
|
|
4721
5336
|
}
|
|
4722
5337
|
)
|
|
4723
5338
|
] }),
|
|
4724
|
-
/* @__PURE__ */
|
|
4725
|
-
/* @__PURE__ */
|
|
4726
|
-
/* @__PURE__ */
|
|
4727
|
-
|
|
5339
|
+
/* @__PURE__ */ jsxs17(Button7, { tag: "label", color: "none", className: classnames10("btn-input-style", { "d-none": disabledBackgroundColor }), children: [
|
|
5340
|
+
/* @__PURE__ */ jsx18(Droplet, { fill: value.backgroundColor ?? "#ffffff", fontSize: 18 }),
|
|
5341
|
+
/* @__PURE__ */ jsx18(
|
|
5342
|
+
Input10,
|
|
4728
5343
|
{
|
|
4729
5344
|
id: "backgroundColor",
|
|
4730
5345
|
type: "color",
|