es-grid-template 1.2.9 → 1.3.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 CHANGED
@@ -42,6 +42,12 @@
42
42
  .ui-rc-table-wrapper .ui-rc-table-bordered .ui-rc-table-tbody-virtual .ui-rc-table-cell {
43
43
  border-inline-end: 1px solid #e0e0e0;
44
44
  }
45
+ .ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell {
46
+ line-height: 22px;
47
+ }
48
+ .ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell .ui-rc-table-cell-content {
49
+ line-height: 22px;
50
+ }
45
51
  .ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-row.ui-rc-table-row-selected > .ui-rc-table-cell {
46
52
  background: #FEF2EF;
47
53
  }
@@ -102,6 +108,9 @@
102
108
  border-bottom: 1px solid #e0e0e0;
103
109
  font-weight: 500;
104
110
  }
111
+ .ui-rc-table-wrapper .ui-rc-table-thead .ui-rc-table-cell .ui-rc-table-cell-content {
112
+ line-height: 22px;
113
+ }
105
114
  .ui-rc-table-wrapper .ui-rc-table-summary .ui-rc-table-cell {
106
115
  background-color: #fafafa;
107
116
  height: 39px;
@@ -176,6 +185,9 @@
176
185
  inset-inline-start: -1px;
177
186
  }
178
187
 
188
+ .ui-rc-table-wrapper .ui-rc-table.ui-rc-table-small .ui-rc-table-thead > tr > th.ui-rc-table-selection-column {
189
+ padding: 0;
190
+ }
179
191
  .ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable {
180
192
  overflow: unset;
181
193
  display: flex;
@@ -276,6 +288,9 @@
276
288
  .ui-rc-table-wrapper.grid-editable .ui-rc_cell-content.selected {
277
289
  background-color: #E6EFFD;
278
290
  }
291
+ .ui-rc-table-wrapper.grid-editable .ui-rc_cell-content.disable {
292
+ background-color: #f0f0f0;
293
+ }
279
294
  .ui-rc-table-wrapper.grid-editable .ui-rc_cell-content--index.focus {
280
295
  background-color: #CEDBEF;
281
296
  }
@@ -471,6 +486,7 @@
471
486
  transition: 0.3s;
472
487
  white-space: nowrap;
473
488
  overflow: hidden;
489
+ line-height: 22px;
474
490
  }
475
491
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-cell.cell-editing:focus-visible {
476
492
  outline: none;
package/assets/index.scss CHANGED
@@ -133,6 +133,21 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
133
133
 
134
134
  .#{$prefix}-table-tbody {
135
135
 
136
+
137
+ .#{$prefix}-table-cell {
138
+ line-height: 22px;
139
+
140
+ .ui-rc-table-cell-content {
141
+ line-height: 22px;
142
+ }
143
+
144
+ &.#{$prefix}-table-cell-fix-left-last {
145
+ .#{$prefix}-table-cell-content {
146
+ }
147
+ }
148
+
149
+ }
150
+
136
151
  .#{$prefix}-table-row {
137
152
 
138
153
  &.#{$prefix}-table-row-selected {
@@ -205,11 +220,17 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
205
220
  border-bottom: 1px solid $tableBorderColor;
206
221
  //background: #fff;
207
222
  font-weight: 500;
223
+ //line-height: 23px;
224
+ //height: 40px;
208
225
  }
209
226
  }
210
227
 
211
228
  .#{$prefix}-table-cell {
212
229
 
230
+ .ui-rc-table-cell-content {
231
+ line-height: 22px;
232
+ }
233
+
213
234
  &.#{$prefix}-table-cell-fix-left-last {
214
235
  .#{$prefix}-table-cell-content {
215
236
  //overflow: visible;
@@ -336,10 +357,18 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
336
357
  .#{$prefix}-table-wrapper {
337
358
 
338
359
  .#{$prefix}-table.#{$prefix}-table-small {
339
- .#{$prefix}-table-selection-column{
340
- //padding: 8px 8px;
341
- //padding: 6px 8px;
360
+ .ui-rc-table-thead {
361
+ >tr >th.#{$prefix}-table-selection-column{
362
+ //padding-block: 7px;
363
+ padding: 0;
364
+ //padding: 6px 8px;
365
+ }
342
366
  }
367
+ //.#{$prefix}-table-selection-column{
368
+ // padding-block: 7px;
369
+ // padding: 0;
370
+ // //padding: 6px 8px;
371
+ //}
343
372
  }
344
373
 
345
374
  &.grid-editable {
@@ -594,6 +623,10 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
594
623
  background-color: $cell-selected-bg;
595
624
  }
596
625
 
626
+ .ui-rc_cell-content.disable {
627
+ background-color: #f0f0f0;
628
+ }
629
+
597
630
  .ui-rc_cell-content--index {
598
631
  &.focus {
599
632
  background-color: $cell-index-focus-bg;
@@ -678,6 +711,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
678
711
  transition: 0.3s;
679
712
  white-space: nowrap;
680
713
  overflow: hidden;
714
+ line-height: 22px;
681
715
  }
682
716
  }
683
717
  }
@@ -33,7 +33,7 @@ export const ColumnsGroup = props => {
33
33
  return rsCol.map(it => ({
34
34
  ...it,
35
35
  value: it.field,
36
- label: t ? t(it.columnGroupText ?? it.headerText ?? it.title) : it.columnGroupText ?? it.headerText ?? it.title
36
+ label: t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText
37
37
  }));
38
38
  }, [rsCol, t]);
39
39
 
@@ -136,7 +136,7 @@ export const ColumnsGroup = props => {
136
136
  ,
137
137
  labelRender: labelProps => {
138
138
  const it = columns.find(col => col.field === labelProps.value);
139
- return t ? t(it.columnGroupText ?? it.headerText ?? it.title) : it.columnGroupText ?? it.headerText ?? it.title;
139
+ return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
140
140
  }
141
141
  // hideSelectedOptions
142
142
  })), /*#__PURE__*/React.createElement("div", {
@@ -165,7 +165,7 @@ export const ColumnsGroup = props => {
165
165
  ,
166
166
  labelRender: labelProps => {
167
167
  const it = columns.find(col => col.field === labelProps.value);
168
- return t ? t(it.columnGroupText ?? it.headerText ?? it.title) : it.columnGroupText ?? it.headerText ?? it.title;
168
+ return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
169
169
  }
170
170
  })), /*#__PURE__*/React.createElement("div", {
171
171
  className: 'mb-1',
@@ -192,7 +192,7 @@ export const ColumnsGroup = props => {
192
192
  ,
193
193
  labelRender: labelProps => {
194
194
  const it = columns.find(col => col.field === labelProps.value);
195
- return t ? t(it.columnGroupText ?? it.headerText ?? it.title) : it.columnGroupText ?? it.headerText ?? it.title;
195
+ return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
196
196
  }
197
197
  }))), /*#__PURE__*/React.createElement(BoxAction, {
198
198
  className: 'px-1'
@@ -104,6 +104,7 @@ const ConvertColumnTable = props => {
104
104
  locale,
105
105
  t,
106
106
  buddhistLocale,
107
+ dataSource,
107
108
  dataSourceFilter: propDataSourceFilter,
108
109
  format,
109
110
  sortMultiple,
@@ -125,7 +125,7 @@ const EditableCell = props => {
125
125
  });
126
126
  }
127
127
  },
128
- placeholder: column.placeholder,
128
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
129
129
  disabled: isDisable(column, record) ?? false,
130
130
  maxDate: maxDate,
131
131
  minDate: minDate
@@ -165,7 +165,7 @@ const EditableCell = props => {
165
165
  },
166
166
  showTime: true,
167
167
  value: date,
168
- placeholder: column.placeholder,
168
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
169
169
  disabled: isDisable(column, record) ?? false,
170
170
  maxDate: maxDate,
171
171
  minDate: minDate,
@@ -216,7 +216,7 @@ const EditableCell = props => {
216
216
  height: '100%'
217
217
  },
218
218
  picker: editType,
219
- placeholder: column.placeholder,
219
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
220
220
  disabled: isDisable(column, record) ?? false,
221
221
  maxDate: maxDateValue1,
222
222
  minDate: minDateValue1,
@@ -233,7 +233,7 @@ const EditableCell = props => {
233
233
  height: '100%'
234
234
  },
235
235
  picker: editType,
236
- placeholder: column.placeholder,
236
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
237
237
  disabled: isDisable(column, record) ?? false,
238
238
  maxDate: maxWeekValue,
239
239
  minDate: minWeekValue,
@@ -253,6 +253,7 @@ const EditableCell = props => {
253
253
  format: timeFormat,
254
254
  type: 'mask'
255
255
  },
256
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
256
257
  maxDate: maxTime,
257
258
  minDate: minTime,
258
259
  disabled: isDisable(column, record) ?? false,
@@ -326,7 +327,7 @@ const EditableCell = props => {
326
327
  defaultOpen: column.field === cellEditing?.column.field
327
328
  // autoFocus={true}
328
329
  ,
329
- placeholder: t ? t('Select') : 'Select',
330
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
330
331
  allowClear: column.isClearable ?? false,
331
332
  maxTagCount: 'responsive',
332
333
  rowKey: keySelect,
@@ -406,7 +407,7 @@ const EditableCell = props => {
406
407
  width: '100%',
407
408
  height: '100%'
408
409
  },
409
- placeholder: t ? t('Select') : 'Select',
410
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
410
411
  allowClear: column.isClearable ?? false,
411
412
  maxTagCount: 'responsive',
412
413
  popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
@@ -460,7 +461,7 @@ const EditableCell = props => {
460
461
  width: '100%',
461
462
  height: '100%'
462
463
  },
463
- placeholder: t ? t('Select') : 'Select',
464
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
464
465
  allowClear: column.isClearable ?? false,
465
466
  maxTagCount: 'responsive',
466
467
  popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
@@ -530,7 +531,7 @@ const EditableCell = props => {
530
531
  overflow: 'auto'
531
532
  },
532
533
  treeData: newTreeData,
533
- placeholder: t ? t('Select') : 'Select',
534
+ placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
534
535
  treeDefaultExpandAll: true,
535
536
  defaultOpen: column.field === cellEditing?.column.field
536
537
  // autoFocus={true}
@@ -744,6 +745,7 @@ const EditableCell = props => {
744
745
  customInput: Input
745
746
  // valueIsNumericString={true}
746
747
  ,
748
+ placeholder: t ? t(column.placeholder ?? 'Enter') : column.placeholder ?? 'Enter',
747
749
  autoComplete: 'off',
748
750
  className: classNames('be-cell-editing rounded-0 input-element', {
749
751
  'is-invalid': isInvalid,
@@ -787,6 +789,7 @@ const EditableCell = props => {
787
789
  ,
788
790
  disabled: isDisable(column, record) ?? false,
789
791
  className: classNames('be-cell-editing rounded-0 input-element'),
792
+ placeholder: t ? t(column.placeholder ?? 'Enter') : column.placeholder ?? 'Enter',
790
793
  value: !isNullOrUndefined(value) ? value : '',
791
794
  onBlur: () => {
792
795
  const formState = getValues();
@@ -127,9 +127,20 @@ const InternalTable = props => {
127
127
  const newColumns = updateArrayByKey(columns, newColumn, 'field');
128
128
  setColumns(newColumns);
129
129
  };
130
+
131
+ // ============================ RowKey ============================
132
+ const getRowKey = React.useMemo(() => {
133
+ if (typeof rowKey === 'function') {
134
+ return rowKey;
135
+ }
136
+ // @ts-ignore
137
+ return record => record?.[rowKey];
138
+ }, [rowKey]);
130
139
  const [transformSelectionColumns] = useColumns({
131
140
  locale,
132
141
  t,
142
+ rowKey,
143
+ dataSource: mergerdData,
133
144
  buddhistLocale,
134
145
  dataSourceFilter: propDataSourceFilter,
135
146
  format,
@@ -143,15 +154,6 @@ const InternalTable = props => {
143
154
  return transformSelectionColumns(columns);
144
155
  }, [columns, transformSelectionColumns]);
145
156
 
146
- // ============================ RowKey ============================
147
- const getRowKey = React.useMemo(() => {
148
- if (typeof rowKey === 'function') {
149
- return rowKey;
150
- }
151
- // @ts-ignore
152
- return record => record?.[rowKey];
153
- }, [rowKey]);
154
-
155
157
  // const triggerChangeColumns = (newColumns: ColumnsTable<RecordType>) => {
156
158
  const triggerChangeColumns = (newColumns, type) => {
157
159
  setColumns(newColumns);
@@ -331,10 +333,12 @@ const InternalTable = props => {
331
333
  const handlePasteCallback = callbackData => {
332
334
  const newDataUpdate = updateData(dataSource, callbackData, rowKey);
333
335
  triggerChangeData(newDataUpdate);
334
- onCellPaste?.dataChange?.(newDataUpdate);
336
+
337
+ // onCellPaste?.dataChange?.(newDataUpdate)
335
338
  };
336
339
  if (onCellPaste && onCellPaste.onPasted) {
337
340
  if (onCellPaste.onPasted.length > 1) {
341
+ // có callback
338
342
  onCellPaste.onPasted({
339
343
  pasteData: pastedRows,
340
344
  type: 'onPaste',
@@ -342,6 +346,7 @@ const InternalTable = props => {
342
346
  pastedColumns: pastedColumnsArray
343
347
  }, handlePasteCallback);
344
348
  } else {
349
+ // không có callback
345
350
  onCellPaste.onPasted({
346
351
  pasteData: pastedRows,
347
352
  type: 'onPaste',
@@ -349,8 +354,11 @@ const InternalTable = props => {
349
354
  pastedColumns: pastedColumnsArray
350
355
  }, handlePasteCallback);
351
356
  triggerChangeData(newData);
352
- onCellPaste.dataChange?.(newData);
357
+
358
+ // onCellPaste.dataChange?.(newData)
353
359
  }
360
+ } else {
361
+ triggerChangeData(newData);
354
362
  }
355
363
  };
356
364
  const TableComponent = groupAble ? Group : editAble ? GridEdit : Grid;
@@ -10,6 +10,7 @@ import classNames from "classnames";
10
10
  import { checkDecimalSeparator, checkThousandSeparator,
11
11
  // convertFlatColumn,
12
12
  isEmpty,
13
+ // newGuid,
13
14
  // removeColumns,
14
15
  sumDataByField
15
16
  // updateArrayByKey
@@ -305,6 +306,7 @@ const TableGrid = props => {
305
306
  }), /*#__PURE__*/React.createElement(Table, _extends({
306
307
  ref: tableRef
307
308
  }, rest, {
309
+ // id={newGuid()}
308
310
  locale: {
309
311
  ...locale,
310
312
  emptyText: showEmptyText !== false ? /*#__PURE__*/React.createElement(Empty, {
@@ -1,7 +1,8 @@
1
1
  import type { AnyObject, IGroupSetting } from "../type";
2
2
  export declare const SELECTION_COLUMN: {};
3
- interface UseColumnsConfig {
3
+ interface UseColumnsConfig<RecordType> {
4
4
  t?: any;
5
+ dataSource: RecordType[];
5
6
  buddhistLocale?: any;
6
7
  dataSourceFilter?: any;
7
8
  locale?: any;
@@ -11,6 +12,7 @@ interface UseColumnsConfig {
11
12
  groupAble?: boolean;
12
13
  groupSetting?: IGroupSetting;
13
14
  groupColumns?: string[];
15
+ rowKey?: any;
14
16
  }
15
- declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig) => readonly [any];
17
+ declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
16
18
  export default useColumns;
@@ -4,7 +4,7 @@ import { Fragment, useCallback } from 'react';
4
4
  // import Command from "../Command";
5
5
  import { Button, Space } from "antd";
6
6
  import { Select } from "rc-master-ui";
7
- import { getTypeFilter } from "./utils";
7
+ import { findItemPath, getTypeFilter } from "./utils";
8
8
  import { booleanOperator, numberOperator, stringOperator, translateOption } from "./constant";
9
9
  import { flatColumns2, renderContent, renderFilter } from "./columns";
10
10
  import { SearchOutlined } from "@ant-design/icons";
@@ -39,7 +39,9 @@ const useColumns = config => {
39
39
  handleResize,
40
40
  groupAble,
41
41
  groupColumns,
42
- groupSetting
42
+ groupSetting,
43
+ dataSource,
44
+ rowKey
43
45
  } = config;
44
46
 
45
47
  // ====================== Selections ======================
@@ -138,8 +140,8 @@ const useColumns = config => {
138
140
  const transformColumns = useCallback(columns => {
139
141
  // >>>>>>>>>>> Support selection
140
142
  const cloneColumns = [...columns];
141
- const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && !groupColumns?.includes(col.field) && col.hidden !== true);
142
- const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && !groupColumns?.includes(col.field) && col.hidden !== true);
143
+ const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
144
+ const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
143
145
 
144
146
  // ===================== Render =====================
145
147
 
@@ -181,7 +183,10 @@ const useColumns = config => {
181
183
  onCell: () => ({
182
184
  className: 'cell-number'
183
185
  }),
184
- render: (_, __, rowIndex) => rowIndex + 1
186
+ render: (val, record) => {
187
+ // return rowIndex + 1
188
+ return findItemPath(dataSource, record, rowKey);
189
+ }
185
190
  };
186
191
  }
187
192
  if (col.key === 'command') {
@@ -71,3 +71,4 @@ export declare const checkChild: (inputArray: any[]) => boolean;
71
71
  export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
72
72
  export declare const isArraysEqual: (arr1: any[], arr2: any[]) => boolean;
73
73
  export declare const editAbleColumns: <T>(columns: ColumnsTable<T>) => ColumnTable<T>[];
74
+ export declare const findItemPath: (tree: any[], targetItem: any, rowKey: any) => any;
@@ -787,4 +787,25 @@ export const isArraysEqual = (arr1, arr2) => {
787
787
  };
788
788
  export const editAbleColumns = columns => {
789
789
  return columns.filter(col => col.field !== '#' && col.field !== 'index' && col.field !== 'command' && col.visible !== false);
790
+ };
791
+ export const findItemPath = (tree, targetItem, rowKey) => {
792
+ let result = null;
793
+ function dfs(nodes, path = []) {
794
+ for (let i = 0; i < nodes.length; i++) {
795
+ const currentPath = [...path, i + 1];
796
+ const node = nodes[i];
797
+ if (node?.[rowKey] === targetItem?.[rowKey]) {
798
+ result = currentPath.join('.');
799
+ return true;
800
+ }
801
+ if (node?.children) {
802
+ if (dfs(node.children, currentPath)) {
803
+ return true;
804
+ }
805
+ }
806
+ }
807
+ return false;
808
+ }
809
+ dfs(tree);
810
+ return result;
790
811
  };
@@ -133,6 +133,21 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
133
133
 
134
134
  .#{$prefix}-table-tbody {
135
135
 
136
+
137
+ .#{$prefix}-table-cell {
138
+ line-height: 22px;
139
+
140
+ .ui-rc-table-cell-content {
141
+ line-height: 22px;
142
+ }
143
+
144
+ &.#{$prefix}-table-cell-fix-left-last {
145
+ .#{$prefix}-table-cell-content {
146
+ }
147
+ }
148
+
149
+ }
150
+
136
151
  .#{$prefix}-table-row {
137
152
 
138
153
  &.#{$prefix}-table-row-selected {
@@ -212,6 +227,10 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
212
227
 
213
228
  .#{$prefix}-table-cell {
214
229
 
230
+ .ui-rc-table-cell-content {
231
+ line-height: 22px;
232
+ }
233
+
215
234
  &.#{$prefix}-table-cell-fix-left-last {
216
235
  .#{$prefix}-table-cell-content {
217
236
  //overflow: visible;
@@ -604,6 +623,10 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
604
623
  background-color: $cell-selected-bg;
605
624
  }
606
625
 
626
+ .ui-rc_cell-content.disable {
627
+ background-color: #f0f0f0;
628
+ }
629
+
607
630
  .ui-rc_cell-content--index {
608
631
  &.focus {
609
632
  background-color: $cell-index-focus-bg;
@@ -688,6 +711,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
688
711
  transition: 0.3s;
689
712
  white-space: nowrap;
690
713
  overflow: hidden;
714
+ line-height: 22px;
691
715
  }
692
716
  }
693
717
  }