react-table-edit 1.4.19 → 1.4.20

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.
@@ -22,4 +22,4 @@ type VirtualTableProps = {
22
22
  changeOrder?: (data: IFOrderTable[]) => void;
23
23
  };
24
24
  declare const VirtualTable: React.FC<VirtualTableProps>;
25
- export default VirtualTable;
25
+ export { VirtualTable };
package/dist/index.d.ts CHANGED
@@ -713,4 +713,27 @@ type IFProps = {
713
713
  };
714
714
  declare const Wizard: React.ForwardRefExoticComponent<IFProps & React.RefAttributes<unknown>>;
715
715
 
716
- export { ExportExcelComponent, FindNodeByPath, type FromItemsField, type IColumnTable, type IColumnVirtualizedTable, type IColumnsVirtualizedAgg, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFFilterTable, type IFOrderTable, type IFPageSize, type IFPropsDetail, type IFSettingFilterColumn, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, ImportExcelComponent, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
716
+ type VirtualTableProps = {
717
+ idTable: string;
718
+ dataSource: any[];
719
+ rowHeight?: number;
720
+ height?: number;
721
+ columns: IColumnVirtualizedTable[];
722
+ selectEnable?: boolean;
723
+ isMutil?: boolean;
724
+ isLoading?: boolean;
725
+ formatSetting?: IFTableEditFormat;
726
+ allowFilter?: boolean;
727
+ allowOrder?: boolean;
728
+ pagingSetting?: IFTableEditPaging;
729
+ toolbarSetting?: IFTableEditToolbar;
730
+ searchSetting?: IFTableEditSearchSetting;
731
+ columnsAggregate?: IColumnsVirtualizedAgg[];
732
+ setColumns?: (columns: IColumnVirtualizedTable[]) => void;
733
+ commandClick?: (data: any) => void;
734
+ changeFilter?: (data: IFFilterTable[]) => void;
735
+ changeOrder?: (data: IFOrderTable[]) => void;
736
+ };
737
+ declare const VirtualTable: React__default.FC<VirtualTableProps>;
738
+
739
+ export { ExportExcelComponent, FindNodeByPath, type FromItemsField, type IColumnTable, type IColumnVirtualizedTable, type IColumnsVirtualizedAgg, type ICommandItem, type IFColumnSelectTable, type IFColumnSelectTableTree, type IFCurrentPage, type IFCurrentPageConfig, type IFFilterTable, type IFOrderTable, type IFPageSize, type IFPropsDetail, type IFSettingFilterColumn, type IFTableEditButton, type IFTableEditFormat, type IFTableEditPaging, type IFTableEditSearchSetting, type IFTableEditToolbar, type IFTableSelectFormat, type IFTableTreeSelectFormat, type IFToolbarOptions, type IHeaderColumnTable, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, ImportExcelComponent, InputStyleComponent, SelectTable, SelectTableTree, TabsMenuComponent, VirtualTable, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
package/dist/index.js CHANGED
@@ -41807,7 +41807,7 @@ function styleInject(css, ref) {
41807
41807
  var css_248z$1 = ".react-resizable {\n position: relative;\n}\n.react-resizable-handle {\n position: absolute;\n width: 20px;\n height: 20px;\n background-repeat: no-repeat;\n background-origin: content-box;\n box-sizing: border-box;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+');\n background-position: bottom right;\n padding: 0 3px 3px 0;\n}\n.react-resizable-handle-sw {\n bottom: 0;\n left: 0;\n cursor: sw-resize;\n transform: rotate(90deg);\n}\n.react-resizable-handle-se {\n bottom: 0;\n right: 0;\n cursor: se-resize;\n}\n.react-resizable-handle-nw {\n top: 0;\n left: 0;\n cursor: nw-resize;\n transform: rotate(180deg);\n}\n.react-resizable-handle-ne {\n top: 0;\n right: 0;\n cursor: ne-resize;\n transform: rotate(270deg);\n}\n.react-resizable-handle-w,\n.react-resizable-handle-e {\n top: 50%;\n margin-top: -10px;\n cursor: ew-resize;\n}\n.react-resizable-handle-w {\n left: 0;\n transform: rotate(135deg);\n}\n.react-resizable-handle-e {\n right: 0;\n transform: rotate(315deg);\n}\n.react-resizable-handle-n,\n.react-resizable-handle-s {\n left: 50%;\n margin-left: -10px;\n cursor: ns-resize;\n}\n.react-resizable-handle-n {\n top: 0;\n transform: rotate(225deg);\n}\n.react-resizable-handle-s {\n bottom: 0;\n transform: rotate(45deg);\n}";
41808
41808
  styleInject(css_248z$1);
41809
41809
 
41810
- const HeaderTableCol = (props) => {
41810
+ const HeaderTableCol$1 = (props) => {
41811
41811
  const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent, objWidthFixLeft, objWidthFixRight, totalCount, selectedRows, column, setColumn, fisrtObjWidthFixRight, lastObjWidthFixLeft, isMulti } = props;
41812
41812
  const { t } = reactI18next.useTranslation();
41813
41813
  const handleResize = (e, { size }) => {
@@ -43507,7 +43507,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
43507
43507
  }, [searchTerm, searchSetting?.searchTerm]);
43508
43508
  return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "react-table-edit", children: [jsxRuntime.jsxs("div", { className: 'r-grid', ref: gridRef, children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsx("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : 'auto'}`, minHeight: `${minHeight ? `${minHeight}px` : ''}`, maxHeight: `${maxHeight ? `${maxHeight}px` : '400px'}` }, children: jsxRuntime.jsxs("table", { style: { width: '100%' }, children: [jsxRuntime.jsx("thead", { className: 'r-gridheader', children: headerColumns.map((element, indexParent) => {
43509
43509
  return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
43510
- return (jsxRuntime.jsx(HeaderTableCol, { col: col, dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, column: contentColumns, setColumn: setContentColumns, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
43510
+ return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, column: contentColumns, setColumn: setContentColumns, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
43511
43511
  }) }, `header-${-indexParent}`));
43512
43512
  }) }), jsxRuntime.jsx("tbody", { className: 'r-gridcontent', children: renderData() }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsxRuntime.jsx("tr", { className: 'r-row', children: contentColumns.map((col, index) => {
43513
43513
  return (renderFooterCol(col, index));
@@ -65406,6 +65406,323 @@ const ImportExcelComponent = (props) => {
65406
65406
  ] }) }));
65407
65407
  };
65408
65408
 
65409
+ const HeaderTableCol = (props) => {
65410
+ const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent, objWidthFixLeft, objWidthFixRight, totalCount, selectedRows, columns, setColumns, orderBy, changeFilter, filterBy, changeOrder, allowFilter, allowOrder, container, fisrtObjWidthFixRight, lastObjWidthFixLeft, formatSetting, isMulti } = props;
65411
+ const { t } = reactI18next.useTranslation();
65412
+ const order = orderBy.find((item) => item.key === col.field);
65413
+ const [openFilter, setOpenFilter] = React$5.useState(false);
65414
+ const filter = filterBy.find((item) => item.key === col.field);
65415
+ const handleResize = (e, { size }) => {
65416
+ // Update the column width here
65417
+ // You might need to update the state or call a callback to update the width
65418
+ if (size.width > 50) {
65419
+ const newColumns = [...columns];
65420
+ newColumns[indexCol].width = size.width;
65421
+ if ((columns[indexCol]?.maxWidth ?? 0) < size.width) {
65422
+ newColumns[indexCol].maxWidth = size.width;
65423
+ }
65424
+ if ((columns[indexCol]?.minWidth ?? 0) > size.width) {
65425
+ newColumns[indexCol].minWidth = size.width;
65426
+ }
65427
+ if (setColumns) {
65428
+ setColumns(newColumns);
65429
+ }
65430
+ }
65431
+ };
65432
+ return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx(Resizable, { className: "r-resize", width: typeof col.width === 'number' ? col.width : Number((col.width ?? "").replaceAll(new RegExp(`[^0-9]`, "g"), '')), height: 0, onResize: handleResize, draggableOpts: { enableUserSelectHack: false }, children: jsxRuntime.jsx("th", { rowSpan: col.rowspan !== 1 ? col.rowspan : 1, colSpan: col.columns?.filter(x => x.visible !== false)?.length ?? 1, className: classNames$1(`r-headercell fix-${col.fixedType}`, { 'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'cell-fixed': col.fixedType }), style: {
65433
+ top: `${indexParent * 42}px`,
65434
+ left: col.fixedType === 'left' ? objWidthFixLeft[indexCol ?? 0] : undefined,
65435
+ right: col.fixedType === 'right' ? objWidthFixRight[indexCol ?? 0] : undefined
65436
+ }, children: jsxRuntime.jsxs("div", { style: { justifyContent: 'space-between' }, onClick: () => {
65437
+ if (order) {
65438
+ if (order.direction === 'asc') {
65439
+ order.direction = 'desc';
65440
+ changeOrder(orderBy);
65441
+ }
65442
+ else {
65443
+ changeOrder(orderBy.filter((x) => x.key !== col.field));
65444
+ }
65445
+ }
65446
+ else {
65447
+ orderBy.push({ direction: 'asc', key: col.field });
65448
+ changeOrder(orderBy);
65449
+ }
65450
+ }, className: classNames$1('r-headercell-div', { 'cursor-pointer': allowOrder }), children: [col.type === 'checkbox' && (jsxRuntime.jsx(Input$1, { checked: !!(totalCount > 0 && selectedRows?.length >= totalCount), type: "checkbox", className: classNames$1('cursor-pointer', { 'd-none': !isMulti }), style: { textAlign: col.textAlign ?? 'left', marginTop: 6 }, onChange: (e) => {
65451
+ if (selectEnable) {
65452
+ if (e.target.checked) {
65453
+ setSelectedRows(dataSource.map((item) => { return item; }));
65454
+ }
65455
+ else {
65456
+ setSelectedRows([]);
65457
+ }
65458
+ }
65459
+ } })), col.type !== 'checkbox' && jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: 'header-content d-flex', style: { justifyContent: col.textAlign ?? 'left', flex: 1 }, children: t(col.headerText ?? '') }), col.type !== '#' && col.type !== 'command' && jsxRuntime.jsxs("div", { className: 'd-flex', children: [allowOrder && order?.direction === 'asc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_6)", children: jsxRuntime.jsx("path", { d: "M8.70711 0.292893C8.31658 -0.0976311 7.68342 -0.0976311 7.29289 0.292893L0.928932 6.65685C0.538408 7.04738 0.538408 7.68054 0.928932 8.07107C1.31946 8.46159 1.95262 8.46159 2.34315 8.07107L8 2.41421L13.6569 8.07107C14.0474 8.46159 14.6805 8.46159 15.0711 8.07107C15.4616 7.68054 15.4616 7.04738 15.0711 6.65685L8.70711 0.292893ZM8 18H9L9 1H8H7L7 18H8Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_6", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowOrder && order?.direction === 'desc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_2)", children: jsxRuntime.jsx("path", { d: "M7.29289 17.7071C7.68342 18.0976 8.31658 18.0976 8.70711 17.7071L15.0711 11.3431C15.4616 10.9526 15.4616 10.3195 15.0711 9.92893C14.6805 9.53841 14.0474 9.53841 13.6569 9.92893L8 15.5858L2.34315 9.92893C1.95262 9.53841 1.31946 9.53841 0.928932 9.92893C0.538408 10.3195 0.538408 10.9526 0.928932 11.3431L7.29289 17.7071ZM8 0L7 0L7 17H8H9L9 0L8 0Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_2", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowFilter && jsxRuntime.jsxs(Dropdown$1, { isOpen: openFilter, toggle: (e) => {
65460
+ setOpenFilter(!openFilter);
65461
+ e.stopPropagation();
65462
+ }, onClick: (e) => {
65463
+ e.stopPropagation();
65464
+ }, children: [jsxRuntime.jsx(DropdownToggle$1, { tag: 'div', className: 'p-0 r-filter', children: jsxRuntime.jsxs("svg", { className: classNames$1('ms-25', { 'active': filter }), width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "stroke-width": "1.5", "font-size": "12", children: [jsxRuntime.jsx("path", { d: "M14.7 11.998v10.506c.052.4-.08.826-.381 1.106a1.306 1.306 0 0 1-.925.39 1.289 1.289 0 0 1-.926-.39l-2.637-2.68a1.323 1.323 0 0 1-.38-1.106v-7.826h-.04L1.85 2.16A1.348 1.348 0 0 1 2.076.293C2.325.107 2.6 0 2.888 0h18.373c.289 0 .564.107.814.293a1.348 1.348 0 0 1 .223 1.866L14.738 12H14.7Z", fill: "currentColor" }), " "] }) }), jsxRuntime.jsx(DropdownMenu$1, { container: container, className: 'formula-dropdown icon-dropdown p-0', style: {
65465
+ borderRadius: 8,
65466
+ zIndex: 1056
65467
+ }, children: jsxRuntime.jsx(DropdownItem$1, { className: 'p-1', style: { borderRadius: '6px' }, tag: 'div', header: true, children: jsxRuntime.jsx(RenderFilterElement, { setOpenFilter: setOpenFilter, filter: filter, filterBy: filterBy, formatSetting: formatSetting, changeFilter: changeFilter, column: col }) }) })] })] })] })] }) }) })) }, `header-${indexCol}`));
65468
+ };
65469
+ const RenderFilterElement = ({ filter, formatSetting, filterBy, setOpenFilter, changeFilter, column }) => {
65470
+ const { t } = reactI18next.useTranslation();
65471
+ const [operator, setOperator] = React$5.useState(filter?.ope ?? 'contains');
65472
+ const [valueFilter, setValueFilter] = React$5.useState(filter?.value ?? '');
65473
+ const RenderStringFilter = () => {
65474
+ const options = [
65475
+ { label: 'Bắt đầu bởi', value: 'startswith' },
65476
+ { label: 'Kết thúc bởi', value: 'endswith' },
65477
+ { label: 'Chứa', value: 'contains' },
65478
+ { label: 'Bằng', value: 'equal' },
65479
+ { label: 'Không bằng', value: 'notequal' }
65480
+ ];
65481
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(SelectTable, { value: options.find((x) => x.value === (operator)), options: options, onChange: (val) => {
65482
+ setOperator(val.value);
65483
+ }, placeholder: 'Select' }), jsxRuntime.jsx(Input$1, { className: 'my-1', value: valueFilter, onChange: (val) => {
65484
+ setValueFilter(val.target.value);
65485
+ } })] }));
65486
+ };
65487
+ const RenderNumberFilter = () => {
65488
+ const options = [
65489
+ { label: 'Lớn hơn', value: 'greaterthan' },
65490
+ { label: 'Lớn hơn hoặc bằng', value: 'greaterthanorequal' },
65491
+ { label: 'Bằng', value: 'equal' },
65492
+ { label: 'Bé hơn', value: 'lessthan' },
65493
+ { label: 'Bé hơn hoặc bằng', value: 'lessthanorequal' }
65494
+ ];
65495
+ const numericFormatProps = {
65496
+ value: !isNullOrUndefined$1(valueFilter) ? valueFilter.toString() : '',
65497
+ thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
65498
+ decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
65499
+ allowNegative: column.numericSettings?.allowNegative ?? false,
65500
+ decimalScale: column.numericSettings?.fraction ?? 0
65501
+ };
65502
+ let floatValue = parseFloat(valueFilter ?? '0');
65503
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(SelectTable, { value: options.find((x) => x.value === (operator)), options: options, onChange: (val) => {
65504
+ setOperator(val.value);
65505
+ }, placeholder: 'Select' }), jsxRuntime.jsx(Input$1, { className: 'my-1', value: valueFilter, onChange: (val) => {
65506
+ setValueFilter(val.target.value);
65507
+ } }), jsxRuntime.jsx(NumericFormat, { style: { textAlign: column.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(valueFilter, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', column.numericSettings?.fraction), className: classNames$1('form-control my-1 input-numeric'), onValueChange: (values) => {
65508
+ floatValue = values?.floatValue;
65509
+ }, onFocus: (e) => {
65510
+ e.target.setSelectionRange(0, e.target.innerText.length - 1);
65511
+ }, onBlur: () => {
65512
+ if (floatValue !== valueFilter) {
65513
+ setValueFilter(!isNaN(floatValue) ? floatValue : 0);
65514
+ }
65515
+ } })] }));
65516
+ };
65517
+ const RenderSelectFilter = () => {
65518
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(SelectTable, { value: column.settingFilter?.options.find((x) => x.value === (operator)), options: column.settingFilter?.options ?? [], isClearable: true, onChange: (val) => {
65519
+ setOperator(val.value);
65520
+ }, placeholder: 'Select' }) }));
65521
+ };
65522
+ return (jsxRuntime.jsxs("div", { className: 'r-filter-popup', children: [((!column.settingFilter?.filterType && column.type === 'numeric') || column.settingFilter?.filterType === 'numeric') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderNumberFilter(), " "] }) : (column.settingFilter?.filterType === 'select' ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxRuntime.jsxs("div", { className: 'd-flex justify-content-end', children: [jsxRuntime.jsx(Button$1, { outline: true, color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50', onClick: () => {
65523
+ if (filter) {
65524
+ filter.ope = operator;
65525
+ filter.value = valueFilter;
65526
+ }
65527
+ else {
65528
+ filterBy.push({ key: column.field, ope: operator, value: valueFilter });
65529
+ }
65530
+ changeFilter([...filterBy]);
65531
+ setOpenFilter(false);
65532
+ }, children: t('Filter') }), jsxRuntime.jsx(Button$1, { className: 'py-25 px-50', outline: true, style: { borderRadius: 3 }, onClick: () => {
65533
+ if (filterBy) {
65534
+ changeFilter(filterBy.filter((x) => x.key !== column.field));
65535
+ }
65536
+ setOpenFilter(false);
65537
+ }, children: t('Clear') })] })] }));
65538
+ };
65539
+
65540
+ const RenderContentCol = (props) => {
65541
+ const { col, indexCol, indexRow, isSelected, row, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, selectEnable, setSelectedRows, handleCommandClick, fieldKey, isMulti } = props;
65542
+ const RenderElement = () => {
65543
+ if (col.type === 'command') {
65544
+ return jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row }) });
65545
+ }
65546
+ else if (col.type === '#') {
65547
+ jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 });
65548
+ }
65549
+ else if (col.type === 'checkbox') {
65550
+ return (jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
65551
+ if (selectEnable) {
65552
+ const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
65553
+ if (index > -1) {
65554
+ if (isMulti) {
65555
+ selectedRows?.splice(index, 1);
65556
+ setSelectedRows([...selectedRows]);
65557
+ }
65558
+ else {
65559
+ setSelectedRows([]);
65560
+ }
65561
+ }
65562
+ else {
65563
+ if (isMulti) {
65564
+ setSelectedRows([...selectedRows, row]);
65565
+ }
65566
+ else {
65567
+ setSelectedRows([row]);
65568
+ }
65569
+ }
65570
+ e.stopPropagation();
65571
+ }
65572
+ }, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }));
65573
+ }
65574
+ else {
65575
+ let value = row[col.field];
65576
+ if (col.type === 'numeric') {
65577
+ value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
65578
+ }
65579
+ else if (col.type === 'date') {
65580
+ value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
65581
+ }
65582
+ else if (col.type === 'datetime') {
65583
+ value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
65584
+ }
65585
+ return (jsxRuntime.jsx("div", { className: classNames$1('r-rowcell-div'), children: jsxRuntime.jsxs("div", { className: classNames$1('r-rowcell-content'), style: {
65586
+ textAlign: col.textAlign ? col.textAlign : 'left'
65587
+ }, children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) }), col.haveToolTip && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }) }));
65588
+ }
65589
+ };
65590
+ return (col.visible !== false && jsxRuntime.jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': isSelected }), style: {
65591
+ left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
65592
+ right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined
65593
+ }, onClick: (e) => {
65594
+ if (e.target.nodeName === 'DIV' || e.target.nodeName === 'TD') {
65595
+ if (selectEnable) {
65596
+ const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
65597
+ if (index > -1) {
65598
+ if (isMulti) {
65599
+ selectedRows?.splice(index, 1);
65600
+ setSelectedRows([...selectedRows]);
65601
+ }
65602
+ else {
65603
+ setSelectedRows([]);
65604
+ }
65605
+ }
65606
+ else {
65607
+ if (isMulti) {
65608
+ setSelectedRows([...selectedRows, row]);
65609
+ }
65610
+ else {
65611
+ setSelectedRows([row]);
65612
+ }
65613
+ }
65614
+ }
65615
+ e.stopPropagation();
65616
+ }
65617
+ }, children: RenderElement() }, `col-${indexRow}-${indexCol}`));
65618
+ };
65619
+
65620
+ const RenderColGroup = ({ contentColumns }) => (jsxRuntime.jsx("colgroup", { children: contentColumns.map((col, index) => (jsxRuntime.jsx("col", { style: {
65621
+ width: typeof col.width === 'number' ? `${col.width}px` : col.width || undefined,
65622
+ minWidth: typeof col.minWidth === 'number' ? `${col.minWidth}px` : col.minWidth || undefined,
65623
+ maxWidth: typeof col.maxWidth === 'number' ? `${col.maxWidth}px` : col.maxWidth || undefined
65624
+ } }, index))) }));
65625
+
65626
+ const SkeletonRow = ({ columns, rowHeight }) => (jsxRuntime.jsx("tr", { style: { height: rowHeight }, className: "animate-pulse", children: Array.from({ length: columns }).map((_, colIndex) => (jsxRuntime.jsx("td", { style: { padding: '8px' }, children: jsxRuntime.jsx("div", { style: { height: 12, background: '#e0e0e0', borderRadius: 4 } }) }, colIndex))) }));
65627
+
65628
+ const VirtualTable = ({ idTable, dataSource, rowHeight = 28, height = 400, columns, isMutil, isLoading, selectEnable, formatSetting, commandClick, allowFilter, allowOrder, setColumns, pagingSetting, changeFilter, changeOrder, searchSetting, columnsAggregate, toolbarSetting }) => {
65629
+ const gridRef = React$5.useRef(null);
65630
+ const [startIndex, setStartIndex] = React$5.useState(0);
65631
+ const [selectedRows, setSelectedRows] = React$5.useState([]);
65632
+ const [orderBy, setOrderBy] = React$5.useState([]);
65633
+ const [filterBy, setFilterBy] = React$5.useState([]);
65634
+ const [searchTerm, setSearchTerm] = React$5.useState('');
65635
+ const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
65636
+ const visibleRowCount = Math.ceil(height / rowHeight) + 5;
65637
+ const countLoading = 10;
65638
+ const { t } = reactI18next.useTranslation();
65639
+ const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = React$5.useMemo(() => calculateTableStructure(columns), [columns]);
65640
+ const handleScroll = () => {
65641
+ if (gridRef.current) {
65642
+ const scrollTop = gridRef.current.scrollTop;
65643
+ const newStartIndex = Math.floor(scrollTop / rowHeight);
65644
+ if (newStartIndex !== startIndex) {
65645
+ setStartIndex(newStartIndex);
65646
+ }
65647
+ }
65648
+ };
65649
+ const visibleData = dataSource.slice(startIndex, Math.min(startIndex + visibleRowCount, dataSource.length));
65650
+ const handleCommandClick = (id, rowData, index) => {
65651
+ if (commandClick) {
65652
+ commandClick({ id, rowData, index });
65653
+ }
65654
+ };
65655
+ const handleKeyPress = (e) => {
65656
+ if ((e.code === 'Enter' || e.code === 'NumpadEnter')) {
65657
+ if (searchSetting?.setSearchTerm) {
65658
+ searchSetting?.setSearchTerm(e.target.value);
65659
+ }
65660
+ else {
65661
+ setSearchTerm(e.target.value);
65662
+ }
65663
+ e.stopPropagation();
65664
+ e.preventDefault();
65665
+ }
65666
+ };
65667
+ const searchTemplate = () => {
65668
+ return (jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
65669
+ };
65670
+ const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: 'left' }] : [];
65671
+ let toolbarTopOption = [];
65672
+ if (toolbarSetting?.toolbarOptions) {
65673
+ toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
65674
+ }
65675
+ else {
65676
+ toolbarTopOption = [...defaultToolbarOption];
65677
+ }
65678
+ const onChangePage = (args) => {
65679
+ if (pagingSetting?.setCurrentPage) {
65680
+ if (args.currentPage === args.oldPage) {
65681
+ return;
65682
+ }
65683
+ pagingSetting.setCurrentPage(args.currentPage);
65684
+ }
65685
+ };
65686
+ const onChangePageSize = (args) => {
65687
+ if (pagingSetting?.allowPaging) {
65688
+ if (pagingSetting?.pageSize !== args.pageSize) {
65689
+ if (pagingSetting?.setPageSize) {
65690
+ pagingSetting.setPageSize(args.pageSize);
65691
+ }
65692
+ if (pagingSetting?.setCurrentPage) {
65693
+ pagingSetting.setCurrentPage(1);
65694
+ }
65695
+ }
65696
+ }
65697
+ };
65698
+ return (jsxRuntime.jsxs("div", { className: "react-table-edit", children: [jsxRuntime.jsxs("div", { className: 'r-grid', children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsx("div", { ref: gridRef, className: "r-gridtable", onScroll: handleScroll, style: { height: `${height ? `${height}px` : 'auto'}` }, children: jsxRuntime.jsxs("table", { style: { width: '100%' }, children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: flatVisble }), jsxRuntime.jsx("thead", { className: 'r-gridheader', children: headerColumns.map((rowColumn, indexParent) => (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((column, indexColumn) => (jsxRuntime.jsx(HeaderTableCol, { col: column, dataSource: dataSource, indexCol: indexColumn, indexParent: indexParent, isMulti: isMutil ?? false, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, columns: contentColumns, setColumns: setColumns, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, orderBy: orderBy, allowFilter: allowFilter, allowOrder: allowOrder, filterBy: filterBy, changeFilter: (val) => {
65699
+ setFilterBy([...val]);
65700
+ if (changeFilter) {
65701
+ changeFilter(val);
65702
+ }
65703
+ }, changeOrder: (val) => {
65704
+ setOrderBy([...val]);
65705
+ if (changeOrder) {
65706
+ changeOrder(val);
65707
+ }
65708
+ }, container: gridRef, totalCount: dataSource.length }, `header-${indexParent}-${indexColumn}`))) }, indexParent))) }), (((dataSource.length ?? 0) === 0) && !isLoading) && jsxRuntime.jsxs("div", { className: "r-no-data", children: [jsxRuntime.jsx("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsxs("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [jsxRuntime.jsx("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }), jsxRuntime.jsxs("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [jsxRuntime.jsx("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" }), jsxRuntime.jsx("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" })] })] }) }), t('No data available.')] }), isLoading && jsxRuntime.jsxs("div", { className: "r-no-data", children: [jsxRuntime.jsx(Spinner$1, { className: "me-1", children: " " }), t('Loading...')] }), jsxRuntime.jsxs("tbody", { className: 'r-gridcontent', children: [jsxRuntime.jsx("tr", { style: { height: (startIndex < countLoading ? startIndex : startIndex - countLoading) * rowHeight }, children: jsxRuntime.jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) }), startIndex > countLoading && Array.from({ length: countLoading }).map((_, index) => (jsxRuntime.jsx(SkeletonRow, { columns: flatVisble.length, rowHeight: rowHeight }, `top-${index}`))), visibleData.map((row, index) => {
65709
+ const indexRow = index + startIndex;
65710
+ const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
65711
+ return (jsxRuntime.jsx("tr", { className: classNames$1('r-row'), children: contentColumns.map((column, indexCol) => (jsxRuntime.jsx(RenderContentCol, { idTable: idTable, col: column, fieldKey: 'field', objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, isMulti: isMutil ?? false, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, formatSetting: formatSetting, handleCommandClick: handleCommandClick, indexCol: indexCol, indexRow: indexRow, isSelected: isSelected, row: row }, indexCol))) }, `row-${indexRow}`));
65712
+ }), jsxRuntime.jsx("tr", { style: { height: (dataSource.length - (startIndex + visibleData.length)) * rowHeight }, children: jsxRuntime.jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) })] }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: (columnsAggregate?.length ?? 0) > 0 ? jsxRuntime.jsx("tr", { className: 'r-row', children: contentColumns.map((col, indexCol) => {
65713
+ const item = columnsAggregate?.find((x) => x.field === col.field);
65714
+ let sumValue = item?.value;
65715
+ if (!item && col.haveSum === true && col.type === "numeric") {
65716
+ sumValue = dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0);
65717
+ }
65718
+ return col.visible !== false && jsxRuntime.jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
65719
+ left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
65720
+ right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
65721
+ textAlign: col.textAlign ? col.textAlign : 'left'
65722
+ }, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [(item || (col.haveSum === true && col.type === "numeric")) && col.type === "numeric" && (Number(sumValue) >= 0) && jsxRuntime.jsx(jsxRuntime.Fragment, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) }), (item || (col.haveSum === true && col.type === "numeric")) && col.type === "numeric" && (Number(sumValue) < 0) && jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false)}${formatSetting?.suffixNegative ?? ''}`] })] }) }, `summarycell-${indexCol}`);
65723
+ }) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) })] }), pagingSetting?.allowPaging ? jsxRuntime.jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: (pagingSetting?.totalItem ?? 0), onChangePageSize: onChangePageSize }) : jsxRuntime.jsx(jsxRuntime.Fragment, {})] }));
65724
+ };
65725
+
65409
65726
  exports.ExportExcelComponent = ExportExcelComponent;
65410
65727
  exports.FindNodeByPath = FindNodeByPath;
65411
65728
  exports.ImportExcelComponent = ImportExcelComponent;
@@ -65413,6 +65730,7 @@ exports.InputStyleComponent = InputStyleComponent;
65413
65730
  exports.SelectTable = SelectTable;
65414
65731
  exports.SelectTableTree = SelectTableTree;
65415
65732
  exports.TabsMenuComponent = TabsMenuComponent;
65733
+ exports.VirtualTable = VirtualTable;
65416
65734
  exports.Wizard = Wizard;
65417
65735
  exports.calculateTableStructure = calculateTableStructure;
65418
65736
  exports.checkDecimalSeparator = checkDecimalSeparator;