es-grid-template 1.9.49 → 1.9.51
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/ali-table/Grid.js +14 -8
- package/es/ali-table/InternalTable.js +29 -0
- package/es/ali-table/base-table/styles.d.ts +5 -1
- package/es/ali-table/base-table/styles.js +13 -4
- package/es/ali-table/base-table/table.js +1 -1
- package/es/ali-table/utils/selected.js +0 -1
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/TableContainerEdit.js +12 -5
- package/es/table-component/body/EditableCell.d.ts +3 -0
- package/es/table-component/body/EditableCell.js +122 -36
- package/es/table-component/body/TableBodyCellEdit.js +70 -9
- package/es/table-component/hook/useColumns.js +2 -2
- package/es/table-component/hook/utils.d.ts +3 -0
- package/es/table-component/hook/utils.js +32 -1
- package/es/table-component/style.scss +6 -0
- package/lib/ali-table/Grid.js +14 -8
- package/lib/ali-table/InternalTable.js +29 -0
- package/lib/ali-table/base-table/styles.d.ts +5 -1
- package/lib/ali-table/base-table/styles.js +13 -4
- package/lib/ali-table/base-table/table.js +1 -1
- package/lib/ali-table/utils/selected.js +0 -1
- package/lib/table-component/TableContainerEdit.js +12 -5
- package/lib/table-component/body/EditableCell.d.ts +3 -0
- package/lib/table-component/body/EditableCell.js +122 -36
- package/lib/table-component/body/TableBodyCellEdit.js +69 -8
- package/lib/table-component/hook/useColumns.js +2 -2
- package/lib/table-component/hook/utils.d.ts +3 -0
- package/lib/table-component/hook/utils.js +37 -4
- package/lib/table-component/style.scss +6 -0
- package/package.json +1 -1
|
@@ -38,9 +38,9 @@ export const renderValueCell = (column, value, record, rowIndex, colIndex, forma
|
|
|
38
38
|
case 'date':
|
|
39
39
|
return value ? dayjs(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
40
40
|
case 'time':
|
|
41
|
-
const timeFormat = format?.timeFormat
|
|
41
|
+
const timeFormat = format?.timeFormat;
|
|
42
42
|
const abc = convertToDate(value, timeFormat);
|
|
43
|
-
const timeValue = value ? dayjs(abc).format(timeFormat) : '';
|
|
43
|
+
const timeValue = value ? dayjs(abc).format(timeFormat ?? 'HH:mm') : '';
|
|
44
44
|
return timeValue ?? '';
|
|
45
45
|
case 'year':
|
|
46
46
|
const year = value ? moment(value).format('yyyy') : '';
|
|
@@ -81,6 +81,7 @@ export declare function sortData(data: any[], sorter: Sorter[]): any[];
|
|
|
81
81
|
export declare function filterDataByColumns(data: any[], queries: FilterItem[] | undefined, sorter: Sorter[] | undefined, keysFilter: string[] | undefined, ignoreAccents?: boolean): any[];
|
|
82
82
|
export declare const getAllRowKey: (data: any[]) => any[];
|
|
83
83
|
export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
|
|
84
|
+
export declare const getNextEditableColumn: (columns: any[], currentIndex: number, rowData: any) => any;
|
|
84
85
|
export declare const checkFieldKey: (key: string | undefined) => string;
|
|
85
86
|
export declare const convertArrayWithIndent: (inputArray: any[], parentIndent?: number) => any[];
|
|
86
87
|
export declare const convertLabelToTitle: (data: any[]) => any[];
|
|
@@ -167,3 +168,5 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
|
|
|
167
168
|
export declare function sumFields(columns: ColumnTable[], data: any[], childrenKey?: string): any;
|
|
168
169
|
export declare function sumNumberFields(columns: ColumnTable[], data: any[], childrenKey?: string): any;
|
|
169
170
|
export declare const getTreeDepth: (rows: any[]) => number;
|
|
171
|
+
export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
|
|
172
|
+
export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
|
|
@@ -177,6 +177,9 @@ export function getDateValueType(value) {
|
|
|
177
177
|
}
|
|
178
178
|
const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
179
179
|
const timeRegex = /^\d{2}:\d{2}(:\d{2})?$/;
|
|
180
|
+
|
|
181
|
+
// const timeRegex = /^(?:[01]\d|2[0-3])\s*:\s*[0-5]\d(?:\s*:\s*[0-5]\d)?$/;
|
|
182
|
+
|
|
180
183
|
if (datetimeRegex.test(value)) {
|
|
181
184
|
return 'datetime';
|
|
182
185
|
}
|
|
@@ -191,7 +194,7 @@ export const convertToDate = (value, format) => {
|
|
|
191
194
|
}
|
|
192
195
|
const valueType = getDateValueType(value);
|
|
193
196
|
if (valueType === 'time') {
|
|
194
|
-
const date = dayjs(value, format, true);
|
|
197
|
+
const date = dayjs(value, format ?? ['HH:mm:ss', 'HH:mm'], true);
|
|
195
198
|
return date.isValid() ? moment(date.toDate()).format() : '';
|
|
196
199
|
}
|
|
197
200
|
if (valueType === 'datetime') {
|
|
@@ -1230,6 +1233,14 @@ export const isEditable = (column, rowData) => {
|
|
|
1230
1233
|
}
|
|
1231
1234
|
return column?.editEnable;
|
|
1232
1235
|
};
|
|
1236
|
+
export const getNextEditableColumn = (columns, currentIndex, rowData) => {
|
|
1237
|
+
for (let i = currentIndex + 1; i < columns.length; i++) {
|
|
1238
|
+
if (isEditable(columns[i].columnDef.meta, rowData)) {
|
|
1239
|
+
return columns[i];
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
return undefined;
|
|
1243
|
+
};
|
|
1233
1244
|
export const checkFieldKey = key => {
|
|
1234
1245
|
if (key) {
|
|
1235
1246
|
return key;
|
|
@@ -2718,4 +2729,24 @@ export function sumNumberFields(columns, data, childrenKey = 'children') {
|
|
|
2718
2729
|
export const getTreeDepth = rows => {
|
|
2719
2730
|
if (!rows?.length) return 0;
|
|
2720
2731
|
return 1 + Math.max(0, ...rows.map(r => getTreeDepth(r.children)));
|
|
2732
|
+
};
|
|
2733
|
+
const TOKEN_MAP = {
|
|
2734
|
+
YYYY: 'year',
|
|
2735
|
+
MM: 'month',
|
|
2736
|
+
DD: 'day',
|
|
2737
|
+
HH: 'hour',
|
|
2738
|
+
mm: 'minute',
|
|
2739
|
+
ss: 'second'
|
|
2740
|
+
};
|
|
2741
|
+
export const isDateChanged = (oldDate, newDate, format) => {
|
|
2742
|
+
const prev = dayjs(oldDate, format, true);
|
|
2743
|
+
const next = dayjs(newDate, format, true);
|
|
2744
|
+
const tokens = ['YYYY', 'MM', 'DD', 'HH', 'mm', 'ss'];
|
|
2745
|
+
for (const token of tokens) {
|
|
2746
|
+
if (!format.includes(token)) continue;
|
|
2747
|
+
if (!prev.isSame(next, TOKEN_MAP[token])) {
|
|
2748
|
+
return token;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return null;
|
|
2721
2752
|
};
|
|
@@ -1195,4 +1195,10 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
|
|
|
1195
1195
|
.ui-rc-toolbar-bottom_border-bottom {
|
|
1196
1196
|
border-bottom-color: $tableBorderColorDark;
|
|
1197
1197
|
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
.ui-rc-checkbox {
|
|
1201
|
+
&:has(input:focus) span {
|
|
1202
|
+
border-color: red;
|
|
1203
|
+
}
|
|
1198
1204
|
}
|
package/lib/ali-table/Grid.js
CHANGED
|
@@ -25,7 +25,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
25
25
|
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; }
|
|
26
26
|
// import type { TableProps } from "../table-component"
|
|
27
27
|
|
|
28
|
-
// const Grid = (props: GridProps) => {
|
|
29
28
|
const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
30
29
|
const {
|
|
31
30
|
id,
|
|
@@ -66,7 +65,8 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
66
65
|
loading,
|
|
67
66
|
useVirtual,
|
|
68
67
|
useOuterBorder = true,
|
|
69
|
-
showHeader = true
|
|
68
|
+
showHeader = true,
|
|
69
|
+
gridLines
|
|
70
70
|
} = props;
|
|
71
71
|
const {
|
|
72
72
|
cssVariables
|
|
@@ -169,7 +169,11 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
169
169
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styles2.StyleTableContainer, {
|
|
170
170
|
className: (0, _classnames.default)(`${prefix}-grid`, {
|
|
171
171
|
[tableClassNames]: !!tableClassNames,
|
|
172
|
-
[`${prefix}-grid-theme-dark`]: theme?.theme === 'dark'
|
|
172
|
+
[`${prefix}-grid-theme-dark`]: theme?.theme === 'dark',
|
|
173
|
+
[`${prefix}-grid-line-horizontal`]: gridLines === 'Horizontal',
|
|
174
|
+
[`${prefix}-grid-line-vertical`]: gridLines === 'Vertical',
|
|
175
|
+
[`${prefix}-grid-line-none`]: gridLines === 'None',
|
|
176
|
+
[`use-outer-border`]: useOuterBorder
|
|
173
177
|
}),
|
|
174
178
|
style: {
|
|
175
179
|
maxHeight: height ?? 700,
|
|
@@ -178,8 +182,8 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
178
182
|
flexDirection: 'column',
|
|
179
183
|
...artTableWrapperProps.style
|
|
180
184
|
}
|
|
181
|
-
}, (showToolbar !== false || fullScreen !== false || title) && /*#__PURE__*/_react.default.createElement("div", {
|
|
182
|
-
className: (0, _classnames.default)(`${prefix}-grid-top
|
|
185
|
+
}, (showToolbar !== false || fullScreen !== false || title || topToolbaritems.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
|
|
186
|
+
className: (0, _classnames.default)(`${prefix}-grid-top`, {})
|
|
183
187
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
184
188
|
style: {
|
|
185
189
|
display: 'flex',
|
|
@@ -254,7 +258,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
254
258
|
|
|
255
259
|
// estimatedRowHeight={50}
|
|
256
260
|
,
|
|
257
|
-
useOuterBorder:
|
|
261
|
+
useOuterBorder: false
|
|
258
262
|
// style={{ height: 700, overflow: 'auto' }}
|
|
259
263
|
,
|
|
260
264
|
style: minHeight ? {
|
|
@@ -303,7 +307,9 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
303
307
|
},
|
|
304
308
|
theme: theme,
|
|
305
309
|
footerDataSource: footerDataSource
|
|
306
|
-
})), bottom
|
|
310
|
+
})), (bottom || pagination && !infiniteScroll) && /*#__PURE__*/_react.default.createElement("div", {
|
|
311
|
+
className: (0, _classnames.default)(`${prefix}-grid-bottom`, {})
|
|
312
|
+
}, bottom, pagination && !infiniteScroll && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
307
313
|
pageSizeOptions: _hooks.pageSizeOptions,
|
|
308
314
|
rootClassName: 'pagination-template',
|
|
309
315
|
showSizeChanger: true,
|
|
@@ -330,7 +336,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
330
336
|
}
|
|
331
337
|
},
|
|
332
338
|
responsive: true
|
|
333
|
-
}))), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
339
|
+
})))), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
334
340
|
id: `${id}-tooltip-content`,
|
|
335
341
|
style: {
|
|
336
342
|
zIndex: 1999,
|
|
@@ -243,6 +243,35 @@ const InternalTable = props => {
|
|
|
243
243
|
// colorLink: '#eb4619',
|
|
244
244
|
},
|
|
245
245
|
components: {
|
|
246
|
+
// Input: {
|
|
247
|
+
// activeBorderColor: '#1677ff',
|
|
248
|
+
// hoverBorderColor: '#1677ff',
|
|
249
|
+
// },
|
|
250
|
+
// Button: {
|
|
251
|
+
// colorLink: '#eb4619',
|
|
252
|
+
// colorLinkHover: '#eb4619'
|
|
253
|
+
// },
|
|
254
|
+
TableSelect: {
|
|
255
|
+
// activeBorderColor: '#1677ff',
|
|
256
|
+
// hoverBorderColor: '#1677ff',
|
|
257
|
+
zIndexPopup: 1158
|
|
258
|
+
},
|
|
259
|
+
Select: {
|
|
260
|
+
// activeBorderColor: '#1677ff',
|
|
261
|
+
// hoverBorderColor: '#1677ff',
|
|
262
|
+
zIndexPopup: 1158
|
|
263
|
+
// colorPrimary: '#eb4619',
|
|
264
|
+
// colorBgBase: 'red'
|
|
265
|
+
},
|
|
266
|
+
DatePicker: {
|
|
267
|
+
// colorPrimary: '#eb4619',
|
|
268
|
+
// activeBorderColor: '#1677ff',
|
|
269
|
+
// hoverBorderColor: '#1677ff',
|
|
270
|
+
zIndexPopup: 1158
|
|
271
|
+
},
|
|
272
|
+
// Pagination: {
|
|
273
|
+
// fontSize: 12
|
|
274
|
+
// },
|
|
246
275
|
Dropdown: {
|
|
247
276
|
zIndexPopup: 1158
|
|
248
277
|
},
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
export declare const LOCK_SHADOW_PADDING = 20;
|
|
3
3
|
export declare const Classes: {
|
|
4
4
|
/** Outer wrapper div for BaseTable component */
|
|
5
|
-
readonly
|
|
5
|
+
readonly tableWrapper: "ui-rc-grid-table-wrapper";
|
|
6
6
|
readonly tableThemeDark: "ui-rc-grid-theme-dark";
|
|
7
7
|
readonly artTable: "ui-rc-grid-table";
|
|
8
|
+
readonly tableTop: "ui-rc-grid-top";
|
|
9
|
+
readonly gridHorizontal: "ui-rc-grid-line-horizontal";
|
|
10
|
+
readonly gridVertical: "ui-rc-grid-line-vertical";
|
|
11
|
+
readonly gridNone: "ui-rc-grid-line-none";
|
|
8
12
|
readonly tableHeader: "ui-rc-grid-table-header";
|
|
9
13
|
readonly tableBody: "ui-rc-grid-table-body";
|
|
10
14
|
readonly tableFooter: "ui-rc-grid-table-footer";
|
|
@@ -11,9 +11,18 @@ const LOCK_SHADOW_PADDING = exports.LOCK_SHADOW_PADDING = 20;
|
|
|
11
11
|
const prefix = 'ui-rc-grid-';
|
|
12
12
|
const Classes = exports.Classes = {
|
|
13
13
|
/** Outer wrapper div for BaseTable component */
|
|
14
|
-
|
|
14
|
+
tableWrapper: `${prefix}table-wrapper`,
|
|
15
15
|
tableThemeDark: `${prefix}theme-dark`,
|
|
16
16
|
artTable: `${prefix}table`,
|
|
17
|
+
tableTop: `${prefix}top`,
|
|
18
|
+
// toolbar_top + title
|
|
19
|
+
gridHorizontal: `${prefix}line-horizontal`,
|
|
20
|
+
// line-horizontal
|
|
21
|
+
gridVertical: `${prefix}line-vertical`,
|
|
22
|
+
// line-vertical
|
|
23
|
+
gridNone: `${prefix}line-none`,
|
|
24
|
+
// line-vertical
|
|
25
|
+
|
|
17
26
|
tableHeader: `${prefix}table-header`,
|
|
18
27
|
tableBody: `${prefix}table-body`,
|
|
19
28
|
tableFooter: `${prefix}table-footer`,
|
|
@@ -53,11 +62,11 @@ const Z = {
|
|
|
53
62
|
scrollItem: 30,
|
|
54
63
|
loadingIndicator: 40
|
|
55
64
|
};
|
|
56
|
-
const outerBorderStyleMixin = (0, _styledComponents.css)(["border-top:var(--cell-border-horizontal);border-right:var(--cell-border-vertical);border-bottom:var(--cell-border-horizontal);border-left:var(--cell-border-vertical);td.first,th.first{border-left:none;}td.last,th.last{border-right:none;}thead tr.first th,tbody tr.first td{border-top:none;}
|
|
65
|
+
const outerBorderStyleMixin = (0, _styledComponents.css)(["border-top:var(--cell-border-horizontal);border-right:var(--cell-border-vertical);border-bottom:var(--cell-border-horizontal);border-left:var(--cell-border-vertical);.", "{border-left:0;border-right:0;border-top:0;}td.first,th.first{border-left:none;}td.last,th.last{border-right:none;}thead tr.first th,tbody tr.first td{border-top:none;}.has-footer tfoot tr.last td{}.has-footer tbody tr.last td{&.lock-left,&.lock-right{border-bottom-width:0;border-top-width:0;box-shadow:0 -1px 0 0 var(--border-color),0 0px 0 0 var(--border-color),-1px 0 0 0 var(--border-color);}}.has-footer tfoot tr td{background:var(--footer-bgcolor);&.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}&.", "{width:100%;white-space:normal;word-break:break-word;}&.", "{text-align:center;}&.", "{text-align:right;}}:not(.has-footer) tbody tr.last td{}&:has(.", ") thead tr.first th{border-top:var(--cell-border-vertical);}&.", "{&:has(.", ") thead tr.first th{border-top:0;}}"], Classes.tableWrapper, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableTop, Classes.gridNone, Classes.tableTop);
|
|
57
66
|
const StyledArtTableWrapper = exports.StyledArtTableWrapper = _styledComponents.default.div.withConfig({
|
|
58
67
|
displayName: "StyledArtTableWrapper",
|
|
59
68
|
componentId: "es-grid-template__sc-ipj1ht-0"
|
|
60
|
-
})(["
|
|
69
|
+
})(["box-sizing:border-box;*{box-sizing:border-box;}cursor:default;color:var(--color);font-size:var(--font-size);line-height:var(--line-height);position:relative;overflow-anchor:none;&::-webkit-scrollbar{width:8px;height:8px;}&::-webkit-scrollbar-track{background:var(--bgcolor);}&::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.4);border-radius:8px;}&::-webkit-scrollbar-thumb:hover{background:#555;}&.dark{&::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.3);}&::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,0.5);}}&.", "{border:var(--cell-border-vertical);&.has-footer{.", "{td{}}}}&.use-outer-border{}.no-scrollbar{scrollbar-width:none;::-webkit-scrollbar{display:none;}}.", "{overflow-x:auto;overflow-y:hidden;background:var(--header-bgcolor);.ui-rc-table-column-title{flex:1;min-width:0;text-align:start;}.", "{font-weight:500;.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}.", "{width:100%;white-space:normal;word-break:break-word;}.", "{text-align:center;}.", "{text-align:right;}}}.", "{.", "{&.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;.expansion-cell{.expansion-content{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}}&.", "{width:100%;white-space:normal;word-break:break-word;}&.", "{text-align:center;}&.", "{text-align:right;}}.", "{background:var(--footer-bgcolor);}}.", ",.", "{overflow-x:auto;overflow-y:hidden;}&.sticky-header .", "{position:sticky;top:0;z-index:", ";}&.sticky-footer .", "{position:sticky;bottom:0;z-index:", ";}.", "{tr{td{&.lock-left,&.lock-right{border-bottom-width:0;box-shadow:0 -1px 0 0 var(--border-color),0 0px 0 0 var(--border-color),-1px 0 0 0 var(--border-color);}}td.first{&.lock-left{border-bottom-width:1px;}}}}table{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0;display:table;margin:0;padding:0;}tr:not(.no-hover):hover > td{background:var(--hover-bgcolor);color:var(--hover-color);}tr:not(.no-highlight).highlight > td{}th{font-weight:normal;text-align:left;padding:var(--cell-padding);height:var(--header-row-height);color:var(--header-color);background:var(--header-bgcolor);border:none;border-right:var(--header-cell-border-vertical);border-bottom:var(--header-cell-border-horizontal);}tr.first th{}th.first{}td{padding:var(--cell-padding);background:var(--bgcolor);height:var(--row-height);border:none;border-right:var(--cell-border-vertical);border-bottom:var(--cell-border-horizontal);}td.first{}tr.first td{border-top:var(--cell-border-horizontal);}&.has-header tbody tr.first td{border-top:none;}&.has-footer tbody tr.last td{border-bottom:none;}&.has-footer tfoot tr > td{background:var(--footer-bgcolor);color:var(--footer-color);}&.has-footer tfoot tr:not(.no-hover):hover > td{background:var(--footer-bgcolor);}.lock-left,.lock-right{z-index:", ";}.resize-handle{width:6px;height:100%;position:absolute;top:0;right:0;cursor:col-resize;background-color:transparent;border-right:2px solid transparent;}.", "{position:absolute;top:0;bottom:0;z-index:", ";pointer-events:none;overflow:hidden;.", "{height:100%;}.", "{margin-right:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-right:var(--cell-border-vertical);}}.", "{margin-left:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-left:var(--cell-border-vertical);}}}.", "{pointer-events:none;color:#99a3b3;font-size:12px;text-align:center;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);.empty-image{width:50px;height:50px;}.empty-tips{margin-top:16px;line-height:1.5;}}.", "{overflow:auto;position:sticky;bottom:0;z-index:", ";margin-top:-17px;}.ui-rc-grid-loading-wrapper{}.ui-rc-grid-table{}.art-loading-content-wrapper{display:flex;height:100%;}.", "{height:1px;visibility:hidden;}.", "{position:relative;height:100%;.", "{position:absolute;inset:0;pointer-events:none;}.", "{position:sticky;z-index:", ";transform:translateY(-50%);}}"], Classes.tableWrapper, Classes.tableFooter, Classes.tableHeader, Classes.tableHeaderCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableBody, Classes.tableCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableFooter, Classes.tableBody, Classes.tableFooter, Classes.tableHeader, Z.header, Classes.tableFooter, Z.footer, Classes.tableBody, Z.lock, Classes.lockShadowMask, Z.lockShadow, Classes.lockShadow, Classes.leftLockShadow, LOCK_SHADOW_PADDING, Classes.rightLockShadow, LOCK_SHADOW_PADDING, Classes.emptyWrapper, Classes.stickyScroll, Z.scrollItem, Classes.stickyScrollItem, Classes.loadingWrapper, Classes.loadingIndicatorWrapper, Classes.loadingIndicator, Z.loadingIndicator);
|
|
61
70
|
|
|
62
71
|
// type StyleTableContainerProps = {
|
|
63
72
|
|
|
@@ -66,4 +75,4 @@ const StyledArtTableWrapper = exports.StyledArtTableWrapper = _styledComponents.
|
|
|
66
75
|
const StyleTableContainer = exports.StyleTableContainer = _styledComponents.default.div.withConfig({
|
|
67
76
|
displayName: "StyleTableContainer",
|
|
68
77
|
componentId: "es-grid-template__sc-ipj1ht-1"
|
|
69
|
-
})(["--color:#333;--bgcolor:white;--header-bgcolor:#ffffff;--header-hover-bgcolor:#ddd;--header-highlight-bgcolor:#e4e8ed;--cell-padding:7px 8px;--font-size:13px;--line-height:1.28571;--border-color:#dfe3e8;--cell-border:1px solid var(--border-color);--cell-border-horizontal:var(--cell-border);--cell-border-vertical:var(--cell-border);--header-cell-border:1px solid var(--border-color);--header-cell-border-horizontal:var(--header-cell-border);--header-cell-border-vertical:var(--header-cell-border);--footer-bgcolor:#fafafa;&.", "{--bgcolor:#343e59;--footer-bgcolor:#2e3342;--header-bgcolor:#343e59;--hover-bgcolor:#232b43;--header-hover-bgcolor:#606164;--highlight-bgcolor:#eff2f5;--header-highlight-bgcolor:#191a1b;--color:#dadde1;--header-color:#dadde1;--lock-shadow:rgb(37 37 37 / 0.5) 0 0 6px 2px;--border-color:#4f5266;background-color:var(--bgcolor);}&.
|
|
78
|
+
})(["--row-height:38px;--color:#333;--bgcolor:white;--body-hover-bgcolor:#f5f5f5;--body-hover-color:#333;--hover-bgcolor:var(--body-hover-bgcolor,#f5f5f5);--hover-color:var(--body-hover-color);--highlight-bgcolor:#eee;--header-row-height:36px;--header-color:#000000de;--header-bgcolor:#ffffff;--header-hover-bgcolor:#ddd;--header-highlight-bgcolor:#e4e8ed;--cell-padding:7px 8px;--font-size:13px;--line-height:1.28571;--lock-shadow:rgba(152,152,152,0.5) 0 0 6px 2px;--border-color:#dfe3e8;--cell-border:1px solid var(--border-color);--cell-border-horizontal:var(--cell-border);--cell-border-vertical:var(--cell-border);--header-cell-border:1px solid var(--border-color);--header-cell-border-horizontal:var(--header-cell-border);--header-cell-border-vertical:var(--header-cell-border);--footer-bgcolor:#fafafa;&.", "{--bgcolor:#343e59;--footer-bgcolor:#2e3342;--header-bgcolor:#343e59;--hover-bgcolor:#232b43;--header-hover-bgcolor:#606164;--highlight-bgcolor:#eff2f5;--header-highlight-bgcolor:#191a1b;--hover-color:#dadde1;--color:#dadde1;--header-color:#dadde1;--lock-shadow:rgb(37 37 37 / 0.5) 0 0 6px 2px;--border-color:#4f5266;background-color:var(--bgcolor);}&.use-outer-border{", ";}&.", "{.", "{border-left:0;border-right:0;td,th{border-right:0;}td.first,th.first{}td.last,th.last{}thead tr.first th,tbody tr.first td{}&.has-footer tfoot tr.last td{}&.has-footer tbody tr.last td{}&.has-footer tfoot tr td{}&:not(.has-footer) tbody tr.last td{}&:has(.", ") thead tr.first th{}}}&.", "{.", "{border-top:0;td,th{border-bottom:0;}td.lock-left{box-shadow:none;}td.first,th.first{}td.last,th.last{}thead tr.first th,tbody tr.first td{}&.has-footer tfoot tr td{border-bottom:0;border-top:0;}&.has-footer tbody tr.last td{}&.has-footer tfoot tr td{}&:not(.has-footer) tbody tr.last td{}&:has(.", ") thead tr.first th{}}}&.", "{.", "{border:0;td,th{border-right:0;border-bottom:0;}td.lock-left{box-shadow:none;}td.first,th.first{}td.last,th.last{}thead tr.first th,tbody tr.first td{}&.has-footer tfoot tr td{border-bottom:0;border-top:0;}&.has-footer tbody tr.last td{}&.has-footer tfoot tr td{}&:not(.has-footer) tbody tr.last td{}&:has(.", ") thead tr.first th{border-top:0;border:0;}}}.", "{padding:8px;}&.ui-rc-grid .ui-rc-pagination{background-color:var(--bgcolor);color:var(--color);padding:10px;background-color:var(--bgcolor);.ui-rc-pagination-prev{.anticon.anticon-left{color:var(--color);}}.ui-rc-pagination-disabled{.anticon.anticon-left{color:#7d7a7a;}}.ui-rc-pagination-next{.anticon.anticon-right{color:var(--color);}&.ui-rc-pagination-disabled{.anticon.anticon-right{color:#7d7a7a;}}}}&.", "{&.ui-rc-grid{.ui-rc-toolbar-bottom{background-color:var(--footer-bgcolor);color:#ffffff;}}.ui-rc-grid-top-toolbar{border-color:var(--border-color);color:#ffffff;}.ui-rc-toolbar{.ui-rc-toolbar-selection-item{background-color:var(--footer-bgcolor);color:#ffffff;}}}"], Classes.tableThemeDark, outerBorderStyleMixin, Classes.gridHorizontal, Classes.tableWrapper, Classes.tableTop, Classes.gridVertical, Classes.tableWrapper, Classes.tableTop, Classes.gridNone, Classes.tableWrapper, Classes.tableTop, Classes.tableTop, Classes.tableThemeDark);
|
|
@@ -357,7 +357,7 @@ class BaseTable extends _react.default.Component {
|
|
|
357
357
|
footerDataSource,
|
|
358
358
|
components
|
|
359
359
|
} = this.props;
|
|
360
|
-
const artTableWrapperClassName = (0, _classnames.default)(_styles.Classes.
|
|
360
|
+
const artTableWrapperClassName = (0, _classnames.default)(_styles.Classes.tableWrapper, {
|
|
361
361
|
'use-outer-border': useOuterBorder,
|
|
362
362
|
empty: dataSource.length === 0,
|
|
363
363
|
lock: info.hasLockColumn,
|
|
@@ -433,7 +433,6 @@ function isRowChecked(key, selectedKeys, treeIndex, checkedStrategy, isDisabledF
|
|
|
433
433
|
// =========================
|
|
434
434
|
if (checkedStrategy === 'parent') {
|
|
435
435
|
// node disable => chỉ true nếu explicit chọn
|
|
436
|
-
// console.log('isDisabled', isDisabled)
|
|
437
436
|
if (isDisabled) {
|
|
438
437
|
const abc = selectedKeys.has(key);
|
|
439
438
|
return abc;
|
|
@@ -417,11 +417,14 @@ const TableContainerEdit = props => {
|
|
|
417
417
|
}
|
|
418
418
|
} else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
|
|
419
419
|
const isDate = (0, _utils.isDateValue)(cellValue.trim());
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
const
|
|
420
|
+
|
|
421
|
+
// const colFormat = typeof columnOri?.format === 'function' ? columnOri?.format(record) : columnOri?.format
|
|
422
|
+
// const cellFormat = getFormat(colFormat, format)
|
|
423
|
+
// const editType = getEditType(columnOri as any)
|
|
424
|
+
// const dateFormat = getDatepickerFormat(editType, cellFormat)
|
|
425
|
+
// const date = isDate && !isEmpty(cellValue.trim()) ? moment(cellValue.trim(), dateFormat, true).format() : null
|
|
426
|
+
|
|
427
|
+
const date = isDate && !(0, _utils.isEmpty)(cellValue.trim()) ? (0, _moment.default)(cellValue.trim()).format() : null;
|
|
425
428
|
newData[targetRow] = {
|
|
426
429
|
...newData[targetRow],
|
|
427
430
|
[columnKey]: date
|
|
@@ -601,6 +604,8 @@ const TableContainerEdit = props => {
|
|
|
601
604
|
handlePasted(rowsPasted);
|
|
602
605
|
}
|
|
603
606
|
}, [handlePasted, onCellPaste?.maxRowsPaste, startCell]);
|
|
607
|
+
|
|
608
|
+
// Copy
|
|
604
609
|
_react.default.useEffect(() => {
|
|
605
610
|
const handleKeyDown = e => {
|
|
606
611
|
if (e.ctrlKey && e.key === 'c' && startCell && endCell && !editingKey) {
|
|
@@ -611,6 +616,8 @@ const TableContainerEdit = props => {
|
|
|
611
616
|
document.addEventListener('keydown', handleKeyDown);
|
|
612
617
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
613
618
|
}, [startCell, endCell, table, copySelectionToClipboard, editingKey]);
|
|
619
|
+
|
|
620
|
+
// Paste
|
|
614
621
|
_react.default.useEffect(() => {
|
|
615
622
|
const handlePaste = e => {
|
|
616
623
|
if (startCell && !editingKey) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { EditType } from "rc-master-ui";
|
|
3
3
|
import type { ColumnTable, IFormat } from "../../grid-component/type";
|
|
4
|
+
import type { Column } from "@tanstack/react-table";
|
|
4
5
|
interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
|
|
5
6
|
t?: any;
|
|
6
7
|
dataIndex: string;
|
|
@@ -11,6 +12,8 @@ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement>
|
|
|
11
12
|
indexRow: number;
|
|
12
13
|
indexCol: number;
|
|
13
14
|
cellEditing?: any;
|
|
15
|
+
visibleColumns?: Column<DataType>[];
|
|
16
|
+
handleNextCell?: () => void;
|
|
14
17
|
}
|
|
15
18
|
declare const EditableCell: <T>(props: EditableCellProps<T>) => JSX.Element;
|
|
16
19
|
export default EditableCell;
|
|
@@ -51,7 +51,9 @@ const EditableCell = props => {
|
|
|
51
51
|
// children,
|
|
52
52
|
column,
|
|
53
53
|
indexRow,
|
|
54
|
-
indexCol
|
|
54
|
+
indexCol,
|
|
55
|
+
// visibleColumns,
|
|
56
|
+
handleNextCell
|
|
55
57
|
// cellEditing,
|
|
56
58
|
// ...restProps
|
|
57
59
|
} = props;
|
|
@@ -69,8 +71,7 @@ const EditableCell = props => {
|
|
|
69
71
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
70
72
|
const datePickerRef = _react.default.useRef(null);
|
|
71
73
|
const dateTimePickerRef = _react.default.useRef(null);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
const timePickerRef = _react.default.useRef(null);
|
|
74
75
|
const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
|
|
75
76
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
76
77
|
const inputNode = (value, onChange) => {
|
|
@@ -107,7 +108,24 @@ const EditableCell = props => {
|
|
|
107
108
|
const options = validateOption ? validateOption(record, column.field) : selectOptions ?? [];
|
|
108
109
|
const optionsTree = validateOption ? (0, _utils.convertArrayWithIndent)(validateOption(record, column.field)) : selectOptions ? (0, _utils.convertArrayWithIndent)(selectOptions) : [];
|
|
109
110
|
|
|
110
|
-
// const
|
|
111
|
+
// const focusToken = (token: FormatToken, fmt: string) => {
|
|
112
|
+
// const input: HTMLInputElement | null =
|
|
113
|
+
// timePickerRef.current?.nativeElement?.querySelector('input') ??
|
|
114
|
+
// timePickerRef.current?.input;
|
|
115
|
+
|
|
116
|
+
// if (!input) return;
|
|
117
|
+
|
|
118
|
+
// const start = fmt.indexOf(token);
|
|
119
|
+
// if (start === -1) return;
|
|
120
|
+
|
|
121
|
+
// input.focus();
|
|
122
|
+
|
|
123
|
+
// input.setSelectionRange(start, start + token.length - 1);
|
|
124
|
+
|
|
125
|
+
// requestAnimationFrame(() => {
|
|
126
|
+
// input.setSelectionRange(start, start + token.length);
|
|
127
|
+
// });
|
|
128
|
+
// };
|
|
111
129
|
|
|
112
130
|
switch (editType) {
|
|
113
131
|
case 'date':
|
|
@@ -332,6 +350,7 @@ const EditableCell = props => {
|
|
|
332
350
|
const maxTime = maxTimeValue ? (0, _dayjs.default)(maxTimeValue, timeFormat) : undefined;
|
|
333
351
|
const minTime = minTimeValue ? (0, _dayjs.default)(minTimeValue, timeFormat) : undefined;
|
|
334
352
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TimePicker, {
|
|
353
|
+
ref: timePickerRef,
|
|
335
354
|
format: {
|
|
336
355
|
format: timeFormat,
|
|
337
356
|
type: 'mask'
|
|
@@ -352,8 +371,79 @@ const EditableCell = props => {
|
|
|
352
371
|
"data-tooltip-content": message,
|
|
353
372
|
"data-tooltip-id": `${id}-tooltip-error`,
|
|
354
373
|
autoFocus: column.field === startCell?.colId,
|
|
355
|
-
defaultOpen: column.field === startCell?.colId
|
|
356
|
-
|
|
374
|
+
defaultOpen: column.field === startCell?.colId
|
|
375
|
+
|
|
376
|
+
// onChange={(newDate, dateString) => {
|
|
377
|
+
|
|
378
|
+
// if (typeTime === 'time') {
|
|
379
|
+
|
|
380
|
+
// onChange(dateString)
|
|
381
|
+
|
|
382
|
+
// } else {
|
|
383
|
+
|
|
384
|
+
// // const datetime = dayjs(dateString as string, timeFormat, true);
|
|
385
|
+
|
|
386
|
+
// const newVal = newDate ? moment(newDate.toDate()).format() : undefined
|
|
387
|
+
|
|
388
|
+
// // const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : ''
|
|
389
|
+
// onChange(newVal)
|
|
390
|
+
|
|
391
|
+
// }
|
|
392
|
+
|
|
393
|
+
// setTimeout(() => {
|
|
394
|
+
// // @ts-ignore
|
|
395
|
+
// dateTimePickerRef.current?.focus()
|
|
396
|
+
// }, 0)
|
|
397
|
+
|
|
398
|
+
// }}
|
|
399
|
+
|
|
400
|
+
// onBlur={() => {
|
|
401
|
+
// const formState = getValues()
|
|
402
|
+
// const itemState = getValues(dataIndex)
|
|
403
|
+
// // @ts-ignore
|
|
404
|
+
// const prevState = record[dataIndex]
|
|
405
|
+
// const newState = itemState
|
|
406
|
+
|
|
407
|
+
// let newValue = newState
|
|
408
|
+
|
|
409
|
+
// if (typeTime === 'time') {
|
|
410
|
+
|
|
411
|
+
// newValue = newState
|
|
412
|
+
|
|
413
|
+
// } else {
|
|
414
|
+
|
|
415
|
+
// const datetime = dayjs(newState as string, timeFormat, true);
|
|
416
|
+
|
|
417
|
+
// const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : undefined
|
|
418
|
+
// onChange(newVal)
|
|
419
|
+
|
|
420
|
+
// newValue = newVal
|
|
421
|
+
|
|
422
|
+
// }
|
|
423
|
+
|
|
424
|
+
// if (prevState !== newState) {
|
|
425
|
+
// handleCellChange?.({
|
|
426
|
+
// key: key as any,
|
|
427
|
+
// field: column.field ?? column.field as any,
|
|
428
|
+
// record: formState,
|
|
429
|
+
// prevState,
|
|
430
|
+
// newState: newValue,
|
|
431
|
+
// option: newValue,
|
|
432
|
+
// indexCol,
|
|
433
|
+
// indexRow,
|
|
434
|
+
// type: 'blur'
|
|
435
|
+
// })
|
|
436
|
+
// }
|
|
437
|
+
// }}
|
|
438
|
+
|
|
439
|
+
// needConfirm={false}
|
|
440
|
+
,
|
|
441
|
+
|
|
442
|
+
onCalendarChange: (newDate, dateString) => {
|
|
443
|
+
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
444
|
+
|
|
445
|
+
// onChange(newDateValue)
|
|
446
|
+
|
|
357
447
|
if (typeTime === 'time') {
|
|
358
448
|
onChange(dateString);
|
|
359
449
|
} else {
|
|
@@ -366,38 +456,34 @@ const EditableCell = props => {
|
|
|
366
456
|
}
|
|
367
457
|
setTimeout(() => {
|
|
368
458
|
// @ts-ignore
|
|
369
|
-
|
|
370
|
-
}
|
|
459
|
+
timePickerRef.current?.focus();
|
|
460
|
+
});
|
|
371
461
|
},
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
462
|
+
onOpenChange: open => {
|
|
463
|
+
if (!open) {
|
|
464
|
+
const formState = getValues();
|
|
465
|
+
const itemState = getValues(dataIndex);
|
|
466
|
+
// @ts-ignore
|
|
467
|
+
const prevState = record[dataIndex];
|
|
468
|
+
const newState = itemState;
|
|
469
|
+
if (prevState !== newState) {
|
|
470
|
+
handleCellChange?.({
|
|
471
|
+
key: key,
|
|
472
|
+
field: column.field ?? column.field,
|
|
473
|
+
record: formState,
|
|
474
|
+
prevState,
|
|
475
|
+
newState,
|
|
476
|
+
option: newState,
|
|
477
|
+
indexCol,
|
|
478
|
+
indexRow,
|
|
479
|
+
type: 'blur'
|
|
480
|
+
});
|
|
481
|
+
}
|
|
387
482
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
field: column.field ?? column.field,
|
|
393
|
-
record: formState,
|
|
394
|
-
prevState,
|
|
395
|
-
newState: newValue,
|
|
396
|
-
option: newValue,
|
|
397
|
-
indexCol,
|
|
398
|
-
indexRow,
|
|
399
|
-
type: 'blur'
|
|
400
|
-
});
|
|
483
|
+
},
|
|
484
|
+
onKeyDown: e => {
|
|
485
|
+
if (e?.code === "Tab") {
|
|
486
|
+
handleNextCell?.();
|
|
401
487
|
}
|
|
402
488
|
}
|
|
403
489
|
});
|