es-grid-template 1.2.0 → 1.2.1
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/assets/index.css +679 -0
- package/assets/index.scss +1006 -0
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +63 -28
- package/es/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +223 -0
- package/es/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/es/grid-component/ColumnsGroup/index.js +1 -0
- package/es/grid-component/ConvertColumnTable.d.ts +7 -0
- package/es/grid-component/ConvertColumnTable.js +143 -0
- package/es/grid-component/EditableCell.js +1 -1
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +148 -248
- package/es/grid-component/TableGrid.d.ts +4 -1
- package/es/grid-component/TableGrid.js +29 -58
- package/es/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/es/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/es/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/es/grid-component/hooks/content/HeaderContent.js +80 -0
- package/es/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/es/grid-component/hooks/content/TooltipContent.js +74 -0
- package/es/grid-component/hooks/useColumns.d.ts +16 -0
- package/es/grid-component/hooks/useColumns.js +272 -0
- package/es/grid-component/hooks/utils.d.ts +46 -1
- package/es/grid-component/hooks/utils.js +740 -2
- package/es/grid-component/index.js +3 -1
- package/es/grid-component/styles.scss +304 -64
- package/es/grid-component/table/Grid.d.ts +2 -0
- package/es/grid-component/table/Grid.js +1 -5
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +690 -281
- package/es/grid-component/table/Group.d.ts +13 -0
- package/es/grid-component/table/Group.js +154 -0
- package/es/grid-component/type.d.ts +38 -1
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +62 -27
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +234 -0
- package/lib/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/grid-component/ColumnsGroup/index.js +16 -0
- package/lib/grid-component/ConvertColumnTable.d.ts +7 -0
- package/lib/grid-component/ConvertColumnTable.js +152 -0
- package/lib/grid-component/EditableCell.js +1 -1
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +142 -248
- package/lib/grid-component/TableGrid.d.ts +4 -1
- package/lib/grid-component/TableGrid.js +23 -56
- package/lib/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/lib/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +87 -0
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/lib/grid-component/hooks/content/TooltipContent.js +81 -0
- package/lib/grid-component/hooks/useColumns.d.ts +16 -0
- package/lib/grid-component/hooks/useColumns.js +283 -0
- package/lib/grid-component/hooks/utils.d.ts +46 -1
- package/lib/grid-component/hooks/utils.js +763 -5
- package/lib/grid-component/index.js +2 -1
- package/lib/grid-component/styles.scss +304 -64
- package/lib/grid-component/table/Grid.d.ts +2 -0
- package/lib/grid-component/table/Grid.js +1 -5
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +689 -280
- package/lib/grid-component/table/Group.d.ts +13 -0
- package/lib/grid-component/table/Group.js +163 -0
- package/lib/grid-component/type.d.ts +38 -1
- package/package.json +106 -105
|
@@ -16,7 +16,7 @@ var _ContextMenu = _interopRequireDefault(require("./ContextMenu"));
|
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
17
|
var _hooks = require("./hooks");
|
|
18
18
|
var _antd = require("antd");
|
|
19
|
-
var
|
|
19
|
+
var _columns = require("./hooks/columns");
|
|
20
20
|
var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
21
21
|
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
22
22
|
var _ColumnsChoose = require("./ColumnsChoose");
|
|
@@ -98,7 +98,6 @@ const TableGrid = props => {
|
|
|
98
98
|
locale,
|
|
99
99
|
expandable,
|
|
100
100
|
rowHoverable,
|
|
101
|
-
// mergedData,
|
|
102
101
|
title,
|
|
103
102
|
format,
|
|
104
103
|
virtual = true,
|
|
@@ -123,10 +122,16 @@ const TableGrid = props => {
|
|
|
123
122
|
dataSourceFilter: propDataSourceFilter,
|
|
124
123
|
loading,
|
|
125
124
|
triggerChangeColumns,
|
|
125
|
+
triggerGroupColumns,
|
|
126
126
|
summary,
|
|
127
127
|
showToolbar,
|
|
128
128
|
onSorter,
|
|
129
129
|
bottomToolbar,
|
|
130
|
+
groupSetting,
|
|
131
|
+
groupAble,
|
|
132
|
+
getRowKey,
|
|
133
|
+
groupColumns,
|
|
134
|
+
groupToolbar,
|
|
130
135
|
...rest
|
|
131
136
|
} = props;
|
|
132
137
|
const {
|
|
@@ -141,16 +146,10 @@ const TableGrid = props => {
|
|
|
141
146
|
selectedRowKeys,
|
|
142
147
|
defaultSelectedRowKeys
|
|
143
148
|
} = selectionSettings || {};
|
|
144
|
-
const clickRef =
|
|
145
|
-
const menuRef =
|
|
149
|
+
const clickRef = _react.default.useRef(null);
|
|
150
|
+
const menuRef = _react.default.useRef(null);
|
|
146
151
|
const viewportWidth = window.innerWidth;
|
|
147
152
|
const viewportHeight = window.innerHeight;
|
|
148
|
-
|
|
149
|
-
// const defaultSelected = useMemo(() => {
|
|
150
|
-
// return defaultSelectedRowKeys ?? []
|
|
151
|
-
//
|
|
152
|
-
// }, [defaultSelectedRowKeys])
|
|
153
|
-
|
|
154
153
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
155
154
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
156
155
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -188,7 +187,7 @@ const TableGrid = props => {
|
|
|
188
187
|
}
|
|
189
188
|
return propContextMenuItems;
|
|
190
189
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
191
|
-
|
|
190
|
+
_react.default.useLayoutEffect(() => {
|
|
192
191
|
setMenuVisible(false);
|
|
193
192
|
}, []);
|
|
194
193
|
const onContextMenu = data => event => {
|
|
@@ -325,10 +324,9 @@ const TableGrid = props => {
|
|
|
325
324
|
},
|
|
326
325
|
loading: {
|
|
327
326
|
spinning: columns && columns.length === 0 || loading === true,
|
|
328
|
-
// spinning: loading === true,
|
|
329
327
|
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
330
328
|
},
|
|
331
|
-
dataSource: dataSource
|
|
329
|
+
dataSource: columns && columns.length > 0 && loading !== true ? dataSource : []
|
|
332
330
|
// className={styles.customTable}
|
|
333
331
|
,
|
|
334
332
|
className: (0, _classnames.default)(className, {
|
|
@@ -346,7 +344,6 @@ const TableGrid = props => {
|
|
|
346
344
|
onRow: (data, index) => {
|
|
347
345
|
return {
|
|
348
346
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
349
|
-
// onClick: handleRowClick,
|
|
350
347
|
onClick: handleRowClick(),
|
|
351
348
|
onContextMenu: onContextMenu(data)
|
|
352
349
|
};
|
|
@@ -377,7 +374,7 @@ const TableGrid = props => {
|
|
|
377
374
|
}
|
|
378
375
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
379
376
|
fixed: true
|
|
380
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0,
|
|
377
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)([_rcMasterUi.Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
381
378
|
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
382
379
|
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
383
380
|
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
@@ -401,7 +398,7 @@ const TableGrid = props => {
|
|
|
401
398
|
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
402
399
|
})));
|
|
403
400
|
},
|
|
404
|
-
pagination: pagination && pagination.onChange ? false : {
|
|
401
|
+
pagination: !pagination || pagination && pagination.onChange ? false : {
|
|
405
402
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
406
403
|
...pagination
|
|
407
404
|
},
|
|
@@ -416,11 +413,11 @@ const TableGrid = props => {
|
|
|
416
413
|
justifyContent: 'space-between',
|
|
417
414
|
alignItems: 'center'
|
|
418
415
|
}
|
|
419
|
-
}, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
416
|
+
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
420
417
|
// @ts-ignore
|
|
421
418
|
, {
|
|
422
419
|
style: {
|
|
423
|
-
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px` : `calc(100% - 25px`
|
|
420
|
+
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px - ${groupAble ? 50 : 0}px` : `calc(100% - 25px - ${groupAble ? 50 : 0}px`
|
|
424
421
|
},
|
|
425
422
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
426
423
|
mode: 'scroll'
|
|
@@ -441,53 +438,23 @@ const TableGrid = props => {
|
|
|
441
438
|
}, pagination)), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
442
439
|
columns: columns,
|
|
443
440
|
t: t,
|
|
441
|
+
columnsGroup: groupColumns,
|
|
444
442
|
triggerChangeColumns: triggerChangeColumns
|
|
445
443
|
}))));
|
|
446
444
|
},
|
|
447
445
|
expandable: {
|
|
448
|
-
|
|
449
|
-
defaultExpandAllRows: true,
|
|
450
|
-
indentSize: 25,
|
|
451
|
-
...expandable,
|
|
452
|
-
expandIcon: args => {
|
|
453
|
-
const {
|
|
454
|
-
record,
|
|
455
|
-
expanded,
|
|
456
|
-
onExpand
|
|
457
|
-
} = args;
|
|
458
|
-
|
|
459
|
-
// @ts-ignore
|
|
460
|
-
if (record?.children?.length > 0 || record?.isChildren) {
|
|
461
|
-
return expanded ? /*#__PURE__*/_react.default.createElement("button", {
|
|
462
|
-
onClick: e => {
|
|
463
|
-
e.preventDefault();
|
|
464
|
-
e.stopPropagation();
|
|
465
|
-
onExpand(record, e);
|
|
466
|
-
},
|
|
467
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
468
|
-
}) : /*#__PURE__*/_react.default.createElement("button", {
|
|
469
|
-
onClick: e => {
|
|
470
|
-
e.preventDefault();
|
|
471
|
-
e.stopPropagation();
|
|
472
|
-
onExpand(record, e);
|
|
473
|
-
},
|
|
474
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
475
|
-
});
|
|
476
|
-
} else {
|
|
477
|
-
return /*#__PURE__*/_react.default.createElement("button", {
|
|
478
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
}
|
|
446
|
+
...expandable
|
|
482
447
|
}
|
|
483
|
-
})),
|
|
448
|
+
})), /*#__PURE__*/_react.default.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
484
449
|
// style={{padding: '0.75rem 1rem'}}
|
|
485
450
|
, (0, _extends2.default)({
|
|
486
451
|
rootClassName: 'pagination-template',
|
|
487
452
|
showSizeChanger: true,
|
|
488
453
|
responsive: true,
|
|
489
|
-
size: 'small'
|
|
490
|
-
|
|
491
|
-
|
|
454
|
+
size: 'small'
|
|
455
|
+
// @ts-ignore
|
|
456
|
+
,
|
|
457
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
458
|
+
}, pagination)), bottomToolbar?.()));
|
|
492
459
|
};
|
|
493
460
|
var _default = exports.default = TableGrid;
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
4
4
|
import type { ColumnsTable } from "../../type";
|
|
5
5
|
export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
6
|
-
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType
|
|
6
|
+
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType>): ColumnsTable<RecordType>;
|
|
7
7
|
export declare const getValueCell: <T>(column: ColumnType<T>, value: any, format?: IFormat) => any;
|
|
8
|
-
export declare const renderContent:
|
|
8
|
+
export declare const renderContent: (column: any, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
|
|
9
9
|
export declare const renderFilter: <RecordType>(column: ColumnType<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any) => React.JSX.Element;
|
|
@@ -17,8 +17,6 @@ var _CheckboxFilter = _interopRequireDefault(require("../../CheckboxFilter"));
|
|
|
17
17
|
var _useSelection = require("rc-master-ui/es/table/hooks/useSelection");
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
-
// import * as React from 'react'
|
|
21
|
-
|
|
22
20
|
const {
|
|
23
21
|
RangePicker
|
|
24
22
|
} = _rcMasterUi.DatePicker;
|
|
@@ -45,15 +43,16 @@ function flatColumns(columns, parentKey = 'key') {
|
|
|
45
43
|
}];
|
|
46
44
|
}, []);
|
|
47
45
|
}
|
|
48
|
-
function flatColumns2(columns
|
|
46
|
+
function flatColumns2(columns
|
|
47
|
+
// parentKey = 'key'
|
|
48
|
+
) {
|
|
49
49
|
// @ts-ignore
|
|
50
|
-
return columns.reduce((list, column
|
|
51
|
-
const {
|
|
52
|
-
fixed
|
|
53
|
-
} = column;
|
|
50
|
+
return columns.reduce((list, column) => {
|
|
51
|
+
// const { fixed } = column
|
|
54
52
|
// Convert `fixed='true'` to `fixed='left'` instead
|
|
55
|
-
const parsedFixed = fixed === true ? 'left' : fixed
|
|
56
|
-
const mergedKey = `${parentKey}-${index}
|
|
53
|
+
// const parsedFixed = fixed === true ? 'left' : fixed
|
|
54
|
+
// const mergedKey = `${parentKey}-${index}`
|
|
55
|
+
|
|
57
56
|
const subColumns = column.children;
|
|
58
57
|
if (column === _useSelection.SELECTION_COLUMN) {
|
|
59
58
|
return [...list, {
|
|
@@ -61,15 +60,15 @@ function flatColumns2(columns, parentKey = 'key') {
|
|
|
61
60
|
}];
|
|
62
61
|
}
|
|
63
62
|
if (subColumns && subColumns.length > 0) {
|
|
64
|
-
return [...list, ...flatColumns(subColumns
|
|
65
|
-
fixed: parsedFixed,
|
|
63
|
+
return [...list, ...flatColumns(subColumns).map(subColum => ({
|
|
64
|
+
// fixed: parsedFixed,
|
|
66
65
|
...subColum
|
|
67
66
|
}))];
|
|
68
67
|
}
|
|
69
68
|
return [...list, {
|
|
70
|
-
key: mergedKey,
|
|
71
|
-
...column
|
|
72
|
-
fixed: parsedFixed
|
|
69
|
+
// key: mergedKey,
|
|
70
|
+
...column
|
|
71
|
+
// fixed: parsedFixed
|
|
73
72
|
}];
|
|
74
73
|
}, []);
|
|
75
74
|
}
|
|
@@ -138,8 +137,13 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
138
137
|
const type = (0, _utils.getTypeFilter)(column);
|
|
139
138
|
const dateFormat = (0, _utils.getDatepickerFormat)(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
140
139
|
const dateRangeFormat = (0, _utils.getDatepickerFormat)(column?.type, column) ?? 'DD/MM/YYYY';
|
|
141
|
-
const find = dataSourceFilter?.find(it => it.key === column?.
|
|
140
|
+
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
142
141
|
const options = find ? find.data : [];
|
|
142
|
+
|
|
143
|
+
// console.log('dataSourceFilter', dataSourceFilter)
|
|
144
|
+
// console.log('options', options)
|
|
145
|
+
// console.log('column', column)
|
|
146
|
+
|
|
143
147
|
switch (type) {
|
|
144
148
|
case 'Number':
|
|
145
149
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -374,7 +378,7 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
374
378
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select
|
|
375
379
|
// options={translateOption(numberOperator, t)}
|
|
376
380
|
, {
|
|
377
|
-
options: options,
|
|
381
|
+
options: find ? options : column.source ?? [],
|
|
378
382
|
style: {
|
|
379
383
|
width: '100%',
|
|
380
384
|
marginBottom: 8
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ColumnTable } from "../../type";
|
|
3
|
+
type Props = {
|
|
4
|
+
t?: any;
|
|
5
|
+
content?: string;
|
|
6
|
+
column?: ColumnTable;
|
|
7
|
+
template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
8
|
+
tooltip?: string | number | React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
9
|
+
};
|
|
10
|
+
declare const HeaderContent: (props: Props) => React.JSX.Element;
|
|
11
|
+
export default HeaderContent;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _react2 = require("@floating-ui/react");
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _utils = require("../utils");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
17
|
+
displayName: "TooltipStyle",
|
|
18
|
+
componentId: "es-grid-template__sc-ibhq66-0"
|
|
19
|
+
})(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
|
|
20
|
+
const HeaderContent = props => {
|
|
21
|
+
const {
|
|
22
|
+
t
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
headerTooltip,
|
|
26
|
+
headerText,
|
|
27
|
+
columnGroupText,
|
|
28
|
+
headerTemplate,
|
|
29
|
+
title
|
|
30
|
+
} = props.column ?? {};
|
|
31
|
+
const text = _react.default.useMemo(() => {
|
|
32
|
+
return columnGroupText ?? headerText ?? title;
|
|
33
|
+
}, [columnGroupText, headerText, title]);
|
|
34
|
+
const tooltip = _react.default.useMemo(() => {
|
|
35
|
+
return headerTooltip ?? columnGroupText ?? headerText ?? title;
|
|
36
|
+
}, [columnGroupText, headerText, headerTooltip, title]);
|
|
37
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
38
|
+
const {
|
|
39
|
+
refs,
|
|
40
|
+
floatingStyles,
|
|
41
|
+
context
|
|
42
|
+
} = (0, _react2.useFloating)({
|
|
43
|
+
open: isOpen,
|
|
44
|
+
onOpenChange: setIsOpen,
|
|
45
|
+
placement: "top",
|
|
46
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
47
|
+
middleware: [(0, _react2.offset)(5), (0, _react2.flip)({
|
|
48
|
+
fallbackAxisSideDirection: "start"
|
|
49
|
+
}), (0, _react2.shift)()]
|
|
50
|
+
});
|
|
51
|
+
const hover = (0, _react2.useHover)(context, {
|
|
52
|
+
move: false
|
|
53
|
+
});
|
|
54
|
+
const focus = (0, _react2.useFocus)(context);
|
|
55
|
+
const dismiss = (0, _react2.useDismiss)(context);
|
|
56
|
+
const role = (0, _react2.useRole)(context, {
|
|
57
|
+
role: "tooltip"
|
|
58
|
+
});
|
|
59
|
+
const {
|
|
60
|
+
getReferenceProps,
|
|
61
|
+
getFloatingProps
|
|
62
|
+
} = (0, _react2.useInteractions)([hover, focus, dismiss, role]);
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
64
|
+
ref: refs.setReference
|
|
65
|
+
}, getReferenceProps(), {
|
|
66
|
+
tabIndex: -1,
|
|
67
|
+
style: {
|
|
68
|
+
flex: 1,
|
|
69
|
+
overflow: 'hidden',
|
|
70
|
+
textOverflow: 'ellipsis',
|
|
71
|
+
wordBreak: 'keep-all'
|
|
72
|
+
}
|
|
73
|
+
// style={{flex: 1}}
|
|
74
|
+
,
|
|
75
|
+
className: (0, _classnames.default)('', {})
|
|
76
|
+
}), headerTemplate ? (0, _utils.getTemplate)(headerTemplate) : t ? t(text) : text), isOpen && (headerTooltip !== false || headerTemplate || headerTooltip || columnGroupText || headerText || title) && /*#__PURE__*/_react.default.createElement(_react2.FloatingPortal, {
|
|
77
|
+
root: document.body
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(TooltipStyle, (0, _extends2.default)({
|
|
79
|
+
className: "Tooltip",
|
|
80
|
+
ref: refs.setFloating,
|
|
81
|
+
style: {
|
|
82
|
+
...floatingStyles,
|
|
83
|
+
zIndex: 1999
|
|
84
|
+
}
|
|
85
|
+
}, getFloatingProps()), headerTooltip && typeof headerTooltip === 'function' ? headerTooltip() : t ? t(tooltip) : tooltip)));
|
|
86
|
+
};
|
|
87
|
+
var _default = exports.default = HeaderContent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
t?: any;
|
|
4
|
+
content?: any;
|
|
5
|
+
value?: any;
|
|
6
|
+
record?: any;
|
|
7
|
+
rowIndex?: any;
|
|
8
|
+
template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
9
|
+
tooltip?: ReactNode | ReactElement | ((value: any, record: any, index: number) => ReactNode | ReactElement);
|
|
10
|
+
showTooltip?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const TooltipContent: (props: Props) => React.JSX.Element;
|
|
13
|
+
export default TooltipContent;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _react2 = require("@floating-ui/react");
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _useIsOverflow = require("../useIsOverflow");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
// import {getTemplate} from "../utils";
|
|
17
|
+
|
|
18
|
+
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
19
|
+
displayName: "TooltipStyle",
|
|
20
|
+
componentId: "es-grid-template__sc-7yfbzv-0"
|
|
21
|
+
})(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
|
|
22
|
+
const TooltipContent = props => {
|
|
23
|
+
const {
|
|
24
|
+
content,
|
|
25
|
+
tooltip,
|
|
26
|
+
value,
|
|
27
|
+
record,
|
|
28
|
+
rowIndex,
|
|
29
|
+
showTooltip
|
|
30
|
+
} = props;
|
|
31
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
32
|
+
const {
|
|
33
|
+
refs,
|
|
34
|
+
floatingStyles,
|
|
35
|
+
context
|
|
36
|
+
} = (0, _react2.useFloating)({
|
|
37
|
+
open: isOpen,
|
|
38
|
+
onOpenChange: setIsOpen,
|
|
39
|
+
placement: "top",
|
|
40
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
41
|
+
middleware: [(0, _react2.offset)(5), (0, _react2.flip)({
|
|
42
|
+
fallbackAxisSideDirection: "start"
|
|
43
|
+
}), (0, _react2.shift)()]
|
|
44
|
+
});
|
|
45
|
+
const isOverflow = (0, _useIsOverflow.useIsOverflow)(refs.reference);
|
|
46
|
+
const hover = (0, _react2.useHover)(context, {
|
|
47
|
+
move: false
|
|
48
|
+
});
|
|
49
|
+
const focus = (0, _react2.useFocus)(context);
|
|
50
|
+
const dismiss = (0, _react2.useDismiss)(context);
|
|
51
|
+
const role = (0, _react2.useRole)(context, {
|
|
52
|
+
role: "tooltip"
|
|
53
|
+
});
|
|
54
|
+
const {
|
|
55
|
+
getReferenceProps,
|
|
56
|
+
getFloatingProps
|
|
57
|
+
} = (0, _react2.useInteractions)([hover, focus, dismiss, role]);
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
59
|
+
ref: refs.setReference
|
|
60
|
+
}, getReferenceProps(), {
|
|
61
|
+
style: {
|
|
62
|
+
flex: 1,
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
textOverflow: 'ellipsis',
|
|
65
|
+
wordBreak: 'keep-all'
|
|
66
|
+
},
|
|
67
|
+
className: (0, _classnames.default)('', {})
|
|
68
|
+
}), content()), isOpen && showTooltip !== false && isOverflow &&
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
// {true && (
|
|
71
|
+
_react.default.createElement(_react2.FloatingPortal, {
|
|
72
|
+
root: document.body
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(TooltipStyle, (0, _extends2.default)({
|
|
74
|
+
className: "Tooltip",
|
|
75
|
+
ref: refs.setFloating,
|
|
76
|
+
style: {
|
|
77
|
+
...floatingStyles
|
|
78
|
+
}
|
|
79
|
+
}, getFloatingProps()), tooltip && typeof tooltip === 'function' ? tooltip(value, record, rowIndex) : tooltip ?? content())));
|
|
80
|
+
};
|
|
81
|
+
var _default = exports.default = TooltipContent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnyObject, IGroupSetting } from "../type";
|
|
2
|
+
export declare const SELECTION_COLUMN: {};
|
|
3
|
+
interface UseColumnsConfig {
|
|
4
|
+
t?: any;
|
|
5
|
+
buddhistLocale?: any;
|
|
6
|
+
dataSourceFilter?: any;
|
|
7
|
+
locale?: any;
|
|
8
|
+
format?: any;
|
|
9
|
+
handleResize?: any;
|
|
10
|
+
sortMultiple?: boolean;
|
|
11
|
+
groupAble?: boolean;
|
|
12
|
+
groupSetting?: IGroupSetting;
|
|
13
|
+
groupColumns?: string[];
|
|
14
|
+
}
|
|
15
|
+
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig) => readonly [any];
|
|
16
|
+
export default useColumns;
|