@pnkx-lib/ui 1.9.208 → 1.9.210
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/es/ui/index.js +247 -61
- package/package.json +1 -1
- package/types/components/ui/BulkActions/BulkAction.d.ts +1 -2
- package/types/components/ui/BulkActions/index.d.ts +2 -2
- package/types/components/ui/Table/HeadingTable/components/GroupHeadingButton.d.ts +2 -2
- package/types/components/ui/Table/index.d.ts +1 -2
package/es/ui/index.js
CHANGED
|
@@ -5028,6 +5028,171 @@ const BulkActions = ({
|
|
|
5028
5028
|
] });
|
|
5029
5029
|
};
|
|
5030
5030
|
|
|
5031
|
+
const useTableHeightWrapper = (options = {}) => {
|
|
5032
|
+
const {
|
|
5033
|
+
tableContainerId = "table_content",
|
|
5034
|
+
extraOffset = 24,
|
|
5035
|
+
// Layout padding bottom mặc định
|
|
5036
|
+
minHeight = 200
|
|
5037
|
+
} = options;
|
|
5038
|
+
const [tableHeight, setTableHeight] = useState(minHeight);
|
|
5039
|
+
const calculateTableHeight = useCallback(() => {
|
|
5040
|
+
try {
|
|
5041
|
+
const viewportHeight = window.innerHeight;
|
|
5042
|
+
const layoutWrapper = document.getElementById("layout-wrapper-table");
|
|
5043
|
+
if (!layoutWrapper) {
|
|
5044
|
+
console.error("Layout wrapper table container not found");
|
|
5045
|
+
setTableHeight(minHeight);
|
|
5046
|
+
return;
|
|
5047
|
+
}
|
|
5048
|
+
const wrapperRect = layoutWrapper.getBoundingClientRect();
|
|
5049
|
+
const availableHeight = viewportHeight - wrapperRect.top;
|
|
5050
|
+
const tableContainer = document.getElementById(tableContainerId);
|
|
5051
|
+
if (!tableContainer) {
|
|
5052
|
+
console.error(`Table container "${tableContainerId}" not found`);
|
|
5053
|
+
setTableHeight(minHeight);
|
|
5054
|
+
return;
|
|
5055
|
+
}
|
|
5056
|
+
const directChildren = Array.from(layoutWrapper.children);
|
|
5057
|
+
let otherElementsHeight = 0;
|
|
5058
|
+
directChildren.forEach((child, index) => {
|
|
5059
|
+
const rect = child.getBoundingClientRect();
|
|
5060
|
+
const styles = window.getComputedStyle(child);
|
|
5061
|
+
const marginTop = parseInt(styles.marginTop, 10) || 0;
|
|
5062
|
+
const marginBottom = parseInt(styles.marginBottom, 10) || 0;
|
|
5063
|
+
const totalHeight = rect.height + marginTop + marginBottom;
|
|
5064
|
+
const isTableContent = child.id === tableContainerId;
|
|
5065
|
+
const isBulkActionTable = child.id === "bulkaction_table";
|
|
5066
|
+
if (!isTableContent && !isBulkActionTable) {
|
|
5067
|
+
otherElementsHeight += totalHeight;
|
|
5068
|
+
} else if (isBulkActionTable) {
|
|
5069
|
+
console.log(` -> Ignoring bulkaction_table (id: ${child.id})`);
|
|
5070
|
+
}
|
|
5071
|
+
});
|
|
5072
|
+
const wrapperStyles = window.getComputedStyle(layoutWrapper);
|
|
5073
|
+
const wrapperPaddingTop = parseInt(wrapperStyles.paddingTop, 10) || 0;
|
|
5074
|
+
const wrapperPaddingBottom = parseInt(wrapperStyles.paddingBottom, 10) || 0;
|
|
5075
|
+
console.log("5. Wrapper padding:", {
|
|
5076
|
+
top: wrapperPaddingTop,
|
|
5077
|
+
bottom: wrapperPaddingBottom
|
|
5078
|
+
});
|
|
5079
|
+
const tableStyles = window.getComputedStyle(tableContainer);
|
|
5080
|
+
const tablePaddingTop = parseInt(tableStyles.paddingTop, 10) || 0;
|
|
5081
|
+
const tablePaddingBottom = parseInt(tableStyles.paddingBottom, 10) || 0;
|
|
5082
|
+
console.log("6. Table container padding:", {
|
|
5083
|
+
top: tablePaddingTop,
|
|
5084
|
+
bottom: tablePaddingBottom
|
|
5085
|
+
});
|
|
5086
|
+
const tableHeader = tableContainer.querySelector(".ant-table-header");
|
|
5087
|
+
const headerHeight = tableHeader ? tableHeader.getBoundingClientRect().height : 0;
|
|
5088
|
+
console.log("7. Table header height:", headerHeight);
|
|
5089
|
+
let paginationHeight = 0;
|
|
5090
|
+
const paginationSelectors = [
|
|
5091
|
+
".ant-pagination",
|
|
5092
|
+
".ant-table-pagination",
|
|
5093
|
+
".ant-pagination-mini"
|
|
5094
|
+
];
|
|
5095
|
+
for (const selector of paginationSelectors) {
|
|
5096
|
+
const pagination = tableContainer.querySelector(selector);
|
|
5097
|
+
if (pagination) {
|
|
5098
|
+
const paginationRect = pagination.getBoundingClientRect();
|
|
5099
|
+
const paginationStyles = window.getComputedStyle(pagination);
|
|
5100
|
+
const paginationMarginTop = parseInt(paginationStyles.marginTop, 10) || 0;
|
|
5101
|
+
const paginationMarginBottom = parseInt(paginationStyles.marginBottom, 10) || 0;
|
|
5102
|
+
paginationHeight = paginationRect.height + paginationMarginTop + paginationMarginBottom;
|
|
5103
|
+
console.log(`8. Found pagination with ${selector}:`, {
|
|
5104
|
+
height: paginationRect.height,
|
|
5105
|
+
marginTop: paginationMarginTop,
|
|
5106
|
+
marginBottom: paginationMarginBottom,
|
|
5107
|
+
totalHeight: paginationHeight
|
|
5108
|
+
});
|
|
5109
|
+
break;
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
if (paginationHeight === 0) {
|
|
5113
|
+
console.log("8. No pagination found, assuming 44px");
|
|
5114
|
+
paginationHeight = 44;
|
|
5115
|
+
}
|
|
5116
|
+
const bulkActionHeight = 0;
|
|
5117
|
+
console.log("9. Bulk action detection temporarily disabled for testing");
|
|
5118
|
+
if (bulkActionHeight > 0) ; else {
|
|
5119
|
+
console.log(
|
|
5120
|
+
"9. No bulk action found, not visible, or is fixed positioned"
|
|
5121
|
+
);
|
|
5122
|
+
}
|
|
5123
|
+
const tableBodyHeight = availableHeight - otherElementsHeight - tablePaddingTop - tablePaddingBottom - headerHeight - paginationHeight - bulkActionHeight - extraOffset;
|
|
5124
|
+
console.log("10. Calculation breakdown:", {
|
|
5125
|
+
availableHeight,
|
|
5126
|
+
otherElementsHeight,
|
|
5127
|
+
wrapperPaddingTop: `${wrapperPaddingTop} (not used in calculation)`,
|
|
5128
|
+
wrapperPaddingBottom: `${wrapperPaddingBottom} (not used in calculation)`,
|
|
5129
|
+
tablePaddingTop,
|
|
5130
|
+
tablePaddingBottom,
|
|
5131
|
+
headerHeight,
|
|
5132
|
+
paginationHeight,
|
|
5133
|
+
bulkActionHeight,
|
|
5134
|
+
extraOffset,
|
|
5135
|
+
calculatedTableBodyHeight: tableBodyHeight
|
|
5136
|
+
});
|
|
5137
|
+
const finalHeight = Math.max(tableBodyHeight, minHeight);
|
|
5138
|
+
console.log("11. Final height:", finalHeight);
|
|
5139
|
+
console.log("=== END WRAPPER ===");
|
|
5140
|
+
setTableHeight(finalHeight);
|
|
5141
|
+
} catch (error) {
|
|
5142
|
+
console.error("Error calculating table height:", error);
|
|
5143
|
+
setTableHeight(minHeight);
|
|
5144
|
+
}
|
|
5145
|
+
}, [tableContainerId, extraOffset, minHeight]);
|
|
5146
|
+
useEffect(() => {
|
|
5147
|
+
const timer = setTimeout(() => {
|
|
5148
|
+
calculateTableHeight();
|
|
5149
|
+
}, 300);
|
|
5150
|
+
const handleResize = () => {
|
|
5151
|
+
console.log("Window resized, recalculating...");
|
|
5152
|
+
calculateTableHeight();
|
|
5153
|
+
};
|
|
5154
|
+
window.addEventListener("resize", handleResize);
|
|
5155
|
+
const observer = new MutationObserver((mutations) => {
|
|
5156
|
+
let shouldRecalculate = false;
|
|
5157
|
+
mutations.forEach((mutation) => {
|
|
5158
|
+
if (mutation.type === "childList") {
|
|
5159
|
+
shouldRecalculate = true;
|
|
5160
|
+
}
|
|
5161
|
+
});
|
|
5162
|
+
if (shouldRecalculate) {
|
|
5163
|
+
setTimeout(calculateTableHeight, 100);
|
|
5164
|
+
}
|
|
5165
|
+
});
|
|
5166
|
+
const layoutWrapper = document.getElementById("layout-wrapper-table");
|
|
5167
|
+
const tableContainer = document.getElementById(tableContainerId);
|
|
5168
|
+
if (layoutWrapper) {
|
|
5169
|
+
observer.observe(layoutWrapper, {
|
|
5170
|
+
childList: true,
|
|
5171
|
+
subtree: true,
|
|
5172
|
+
attributes: true,
|
|
5173
|
+
attributeFilter: ["style", "class"]
|
|
5174
|
+
});
|
|
5175
|
+
}
|
|
5176
|
+
if (tableContainer && tableContainer !== layoutWrapper) {
|
|
5177
|
+
observer.observe(tableContainer, {
|
|
5178
|
+
childList: true,
|
|
5179
|
+
subtree: true,
|
|
5180
|
+
attributes: true,
|
|
5181
|
+
attributeFilter: ["style", "class"]
|
|
5182
|
+
});
|
|
5183
|
+
}
|
|
5184
|
+
return () => {
|
|
5185
|
+
clearTimeout(timer);
|
|
5186
|
+
window.removeEventListener("resize", handleResize);
|
|
5187
|
+
observer.disconnect();
|
|
5188
|
+
};
|
|
5189
|
+
}, [calculateTableHeight, tableContainerId]);
|
|
5190
|
+
return {
|
|
5191
|
+
tableHeight,
|
|
5192
|
+
recalculate: calculateTableHeight
|
|
5193
|
+
};
|
|
5194
|
+
};
|
|
5195
|
+
|
|
5031
5196
|
const Table = ({
|
|
5032
5197
|
dataSource = [],
|
|
5033
5198
|
columns,
|
|
@@ -5116,71 +5281,92 @@ const Table = ({
|
|
|
5116
5281
|
}
|
|
5117
5282
|
onRowClick2?.(record);
|
|
5118
5283
|
};
|
|
5284
|
+
const { tableHeight } = useTableHeightWrapper({
|
|
5285
|
+
tableContainerId: "table_content",
|
|
5286
|
+
// ID của table container
|
|
5287
|
+
minHeight: 200
|
|
5288
|
+
// chiều cao tối thiểu
|
|
5289
|
+
});
|
|
5119
5290
|
//! Render
|
|
5120
|
-
return /* @__PURE__ */ jsxs(
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5291
|
+
return /* @__PURE__ */ jsxs(
|
|
5292
|
+
"div",
|
|
5293
|
+
{
|
|
5294
|
+
id: "layout-wrapper-table",
|
|
5295
|
+
className: twMerge(showSetting ? "relative" : ""),
|
|
5296
|
+
children: [
|
|
5297
|
+
/* @__PURE__ */ jsx(
|
|
5298
|
+
HeadingTable,
|
|
5299
|
+
{
|
|
5300
|
+
rightHeadingContent,
|
|
5301
|
+
renderHeadingSearch,
|
|
5302
|
+
setOpenStting,
|
|
5303
|
+
showSetting,
|
|
5304
|
+
menu,
|
|
5305
|
+
groupHeadingButtonItems,
|
|
5306
|
+
setFilters,
|
|
5307
|
+
filters,
|
|
5308
|
+
noBreadcum
|
|
5309
|
+
}
|
|
5310
|
+
),
|
|
5311
|
+
/* @__PURE__ */ jsx(
|
|
5312
|
+
"div",
|
|
5313
|
+
{
|
|
5314
|
+
id: "table_content",
|
|
5315
|
+
className: "bg-[#FFFFFF] p-6 rounded-bl-lg rounded-br-lg",
|
|
5316
|
+
children: /* @__PURE__ */ jsx(
|
|
5317
|
+
Table$1,
|
|
5318
|
+
{
|
|
5319
|
+
rowKey,
|
|
5320
|
+
dataSource: data,
|
|
5321
|
+
columns: columnsWithIndex,
|
|
5322
|
+
pagination: !isEmpty(data) ? paginationConfig : false,
|
|
5323
|
+
loading,
|
|
5324
|
+
rowSelection: rowsSelected ? rowSelection : void 0,
|
|
5325
|
+
onChange: handleTableChange,
|
|
5326
|
+
onRow: (record) => ({
|
|
5327
|
+
onClick: handleOnClickRow(record, onRowClick)
|
|
5328
|
+
}),
|
|
5329
|
+
locale: {
|
|
5330
|
+
emptyText: /* @__PURE__ */ jsx(EmptyTable, {})
|
|
5331
|
+
},
|
|
5332
|
+
rowClassName: (_, index) => `table-row-${index % 2 === 0 ? "even" : "odd"}`,
|
|
5333
|
+
scroll: { y: tableHeight },
|
|
5334
|
+
size,
|
|
5335
|
+
...rest
|
|
5336
|
+
}
|
|
5337
|
+
)
|
|
5338
|
+
}
|
|
5339
|
+
),
|
|
5340
|
+
/* @__PURE__ */ jsx(
|
|
5341
|
+
SettingTable,
|
|
5142
5342
|
{
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5343
|
+
open: openSetting,
|
|
5344
|
+
setOpen: setOpenStting,
|
|
5345
|
+
title: titleSettingTableModal,
|
|
5346
|
+
showSetting,
|
|
5347
|
+
defaultSettingColumnItems: columns,
|
|
5348
|
+
setDefaultSettingColumnItems: setColumns
|
|
5349
|
+
}
|
|
5350
|
+
),
|
|
5351
|
+
rowsSelected && !isEmpty(rowsSelected) && /* @__PURE__ */ jsx(
|
|
5352
|
+
"div",
|
|
5353
|
+
{
|
|
5354
|
+
id: "bulkaction_table",
|
|
5355
|
+
className: "fixed bottom-1/100 left-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
5356
|
+
children: /* @__PURE__ */ jsx(
|
|
5357
|
+
BulkActions,
|
|
5358
|
+
{
|
|
5359
|
+
type: TypeBulkActions.BULKACTION,
|
|
5360
|
+
quantity: rowsSelected?.length,
|
|
5361
|
+
status,
|
|
5362
|
+
...bulkActionHandlers
|
|
5363
|
+
}
|
|
5364
|
+
)
|
|
5159
5365
|
}
|
|
5160
5366
|
)
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
SettingTable,
|
|
5165
|
-
{
|
|
5166
|
-
open: openSetting,
|
|
5167
|
-
setOpen: setOpenStting,
|
|
5168
|
-
title: titleSettingTableModal,
|
|
5169
|
-
showSetting,
|
|
5170
|
-
defaultSettingColumnItems: columns,
|
|
5171
|
-
setDefaultSettingColumnItems: setColumns
|
|
5172
|
-
}
|
|
5173
|
-
),
|
|
5174
|
-
rowsSelected && !isEmpty(rowsSelected) && /* @__PURE__ */ jsx("div", { className: "fixed bottom-1/100 left-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsx(
|
|
5175
|
-
BulkActions,
|
|
5176
|
-
{
|
|
5177
|
-
type: TypeBulkActions.BULKACTION,
|
|
5178
|
-
quantity: rowsSelected?.length,
|
|
5179
|
-
status,
|
|
5180
|
-
...bulkActionHandlers
|
|
5181
|
-
}
|
|
5182
|
-
) })
|
|
5183
|
-
] });
|
|
5367
|
+
]
|
|
5368
|
+
}
|
|
5369
|
+
);
|
|
5184
5370
|
};
|
|
5185
5371
|
const EmptyTable = () => {
|
|
5186
5372
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center text-center", children: [
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ConfirmModalProps } from '../ConfirmModal';
|
|
2
2
|
import { TListIcon } from '.';
|
|
3
|
-
import { TypeStatusTable } from '../../../constants';
|
|
4
3
|
export interface BulkActionProps {
|
|
5
4
|
quantity?: number;
|
|
6
5
|
listIcon?: TListIcon[];
|
|
7
|
-
status?:
|
|
6
|
+
status?: unknown;
|
|
8
7
|
setNotifyContent: React.Dispatch<React.SetStateAction<ConfirmModalProps>>;
|
|
9
8
|
toggle: () => void;
|
|
10
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConfirmModalProps } from '../ConfirmModal';
|
|
2
2
|
import { BulkActionHandlers } from '@pnkx-lib/core';
|
|
3
|
-
import { TypeBulkActions
|
|
3
|
+
import { TypeBulkActions } from '../../../constants';
|
|
4
4
|
import { CATEGORY_LIST_ENUM } from '../CategoryStatus';
|
|
5
5
|
interface IBulkActionsProps extends Partial<BulkActionHandlers> {
|
|
6
6
|
quantity?: number;
|
|
7
|
-
status?:
|
|
7
|
+
status?: unknown;
|
|
8
8
|
type?: TypeBulkActions;
|
|
9
9
|
}
|
|
10
10
|
export type TListIcon = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InitialFiltersSearch } from '@pnkx-lib/core';
|
|
2
|
-
import { TFilters
|
|
2
|
+
import { TFilters } from '../../..';
|
|
3
3
|
export interface GroupHeadingButtonItem {
|
|
4
4
|
label: string;
|
|
5
5
|
quantity: number;
|
|
6
|
-
status:
|
|
6
|
+
status: unknown;
|
|
7
7
|
}
|
|
8
8
|
export interface GroupHeadingButtonProps {
|
|
9
9
|
groupHeadingButtonItems?: GroupHeadingButtonItem[];
|
|
@@ -5,7 +5,6 @@ import { SorterResult } from 'antd/es/table/interface';
|
|
|
5
5
|
import { BulkActionHandlers, InitialFiltersSearch } from '@pnkx-lib/core';
|
|
6
6
|
import { MenuType } from '../Sidebar';
|
|
7
7
|
import { GroupHeadingButtonItem } from './HeadingTable/components/GroupHeadingButton';
|
|
8
|
-
import { TypeStatusTable } from '../../../constants';
|
|
9
8
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
10
9
|
interface RowCommon {
|
|
11
10
|
[x: string]: any;
|
|
@@ -14,7 +13,7 @@ type ColumnTypes<T> = Exclude<TableProps<T>["columns"], undefined>;
|
|
|
14
13
|
export type TableColumnsTypeEditable<T> = (ColumnTypes<T>[number] & {})[];
|
|
15
14
|
export type TableColumnsType<T> = TableColumnsTypeAntd<T> & TableColumnsTypeEditable<T>;
|
|
16
15
|
export type TFilters = {
|
|
17
|
-
status?:
|
|
16
|
+
status?: any;
|
|
18
17
|
};
|
|
19
18
|
export interface TableCommonProps<T> extends Omit<TableProps<T>, "columns"> {
|
|
20
19
|
dataSource?: T[];
|