es-grid-template 0.0.7 → 0.0.8

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.
@@ -15,7 +15,7 @@ const numberOperator = exports.numberOperator = [{
15
15
  label: 'Greater than',
16
16
  key: '>'
17
17
  }, {
18
- value: 'greaterthan',
18
+ value: 'greaterthanorequal',
19
19
  label: 'Greater Than or Equal',
20
20
  key: '>='
21
21
  }, {
@@ -1,5 +1,5 @@
1
1
  import dayjs from "dayjs";
2
- import type { EditType, IColumnType, TypeFilter } from "ui-rc";
2
+ import type { EditType, IColumnType, TypeFilter } from "rc-master-ui";
3
3
  import type { ColumnType } from "../type";
4
4
  export declare const sumDataByField: (data: any[], field: string) => any;
5
5
  export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
@@ -16,3 +16,4 @@ export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[
16
16
  export declare const updateColumns: (columns: any[], includes: string[]) => any[];
17
17
  export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, col: ColumnType<any>) => string;
18
18
  export declare const getTypeFilter: (col: ColumnType<any>) => TypeFilter;
19
+ export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getDatepickerFormat = exports.getAllVisibleKeys = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.checkThousandSeparator = exports.checkDecimalSeparator = void 0;
8
8
  exports.getHiddenParentKeys = getHiddenParentKeys;
9
- exports.updateColumns = exports.sumDataByField = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = void 0;
9
+ exports.updateColumns = exports.updateArrayByKey = exports.sumDataByField = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = void 0;
10
10
  var _dayjs = _interopRequireDefault(require("dayjs"));
11
11
  const sumDataByField = (data, field) => {
12
12
  if (data && data.length > 0) {
@@ -146,6 +146,9 @@ const updateColumns = (columns, includes) => {
146
146
  ...column
147
147
  };
148
148
  let hasVisibleChild = false;
149
+ if (!column.key && !column.dataIndex) {
150
+ return column;
151
+ }
149
152
  if (newColumn.children) {
150
153
  newColumn.children = updateColumns(newColumn.children, includes);
151
154
  hasVisibleChild = newColumn.children.some(child => !child.hidden);
@@ -186,10 +189,10 @@ const getDatepickerFormat = (type, col) => {
186
189
  };
187
190
  exports.getDatepickerFormat = getDatepickerFormat;
188
191
  const getTypeFilter = col => {
189
- if (col.typeFilter) {
192
+ if (col?.typeFilter) {
190
193
  return col.typeFilter;
191
194
  }
192
- const type = col.type ?? '';
195
+ const type = col?.type ?? 'Text';
193
196
  switch (type) {
194
197
  case "number":
195
198
  return 'Number';
@@ -203,7 +206,7 @@ const getTypeFilter = col => {
203
206
  return 'Checkbox';
204
207
 
205
208
  // case "week": return ''
206
- // case "month": return col.format?.monthFormat ? col.format?.monthFormat : 'MM/YYYY'
209
+ // case "month": return 'Month'
207
210
  // case "quarter": return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY'
208
211
  // case "year": return col.format?.yearFormat ? col.format?.yearFormat : 'YYYY'
209
212
  // case "time": return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm'
@@ -212,4 +215,22 @@ const getTypeFilter = col => {
212
215
  return 'Text';
213
216
  }
214
217
  };
215
- exports.getTypeFilter = getTypeFilter;
218
+ exports.getTypeFilter = getTypeFilter;
219
+ const updateArrayByKey = (arr, element, key) => {
220
+ if (arr) {
221
+ return arr.map(item => {
222
+ if (item[key] === element[key]) {
223
+ return {
224
+ ...item,
225
+ ...element
226
+ };
227
+ } else if (item.children && item.children.length > 0) {
228
+ item.children = updateArrayByKey(item.children, element, key);
229
+ }
230
+ return item;
231
+ });
232
+ } else {
233
+ return [];
234
+ }
235
+ };
236
+ exports.updateArrayByKey = updateArrayByKey;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import GridTable from './GridTable';
2
- export default GridTable;
1
+ import InternalTable from './InternalTable';
2
+ export default InternalTable;
package/lib/index.js CHANGED
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _GridTable = _interopRequireDefault(require("./GridTable"));
9
- var _default = exports.default = _GridTable.default;
8
+ var _InternalTable = _interopRequireDefault(require("./InternalTable"));
9
+ var _default = exports.default = _InternalTable.default;
package/lib/styles.scss CHANGED
@@ -1,30 +1,296 @@
1
- $prefix : 'ui-rc'!default;
1
+ $prefix: 'ui-rc' !default;
2
+ $primary: #eb4619 !default;
3
+ $rowHoverBg: #FBDED6 !default;
4
+ $rowSelectedBg: #FEF2EF !default;
5
+ $tableBorderColor: #e0e0e0 !default;
6
+ //$rowSelectedHoverBg: 'ui-rc' !default;
7
+
8
+
2
9
  .popup-context-menu {
3
10
  min-width: 200px;
4
11
  }
5
12
 
6
- .ui-rc-table-wrapper{
7
- &.table-none-column-select {
8
- .#{$prefix}-table-cell {
9
- &.#{$prefix}-table-selection-column {
10
- padding: 0!important;
11
- overflow: hidden !important;
12
- border-inline-end: 0 !important;
13
- //flex: 0 0 0 !important;
14
- //width: 0 !important;
13
+ .react-resizable {
14
+ position: relative;
15
+ background-clip: padding-box;
16
+ }
17
+
18
+ .react-resizable-handle {
19
+ position: absolute;
20
+ right: -5px;
21
+ bottom: 0;
22
+ z-index: 1;
23
+ width: 10px;
24
+ height: 100%;
25
+ cursor: col-resize;
26
+ //transform: translateY(-50%);
27
+ }
28
+
29
+ // -------------- Table -------------
30
+ .#{$prefix}-table-wrapper {
31
+ &.table-none-column-select {
32
+ .#{$prefix}-table-cell {
33
+ &.#{$prefix}-table-selection-column {
34
+ padding: 0 !important;
35
+ overflow: hidden !important;
36
+ border-inline-end: 0 !important;
37
+ //flex: 0 0 0 !important;
38
+ //width: 0 !important;
39
+ }
40
+ }
41
+ }
42
+
43
+ .#{$prefix}-table-tbody {
44
+ .#{$prefix}-table-row {
45
+ &.#{$prefix}-table-row-selected {
46
+ >.#{$prefix}-table-cell {
47
+ background: #FEF2EF;
48
+ }
49
+ }
50
+ >.#{$prefix}-table-cell {
51
+ &.#{$prefix}-table-cell-row-hover {
52
+ background: #FBDED6;
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ .#{$prefix}-table-tbody-virtual {
59
+ .#{$prefix}-table-cell {
60
+ border-bottom: 1px solid $tableBorderColor;
61
+ }
62
+ }
63
+
64
+ .#{$prefix}-table-bordered {
65
+
66
+ .#{$prefix}-table-tbody-virtual {
67
+ .#{$prefix}-table-cell {
68
+ border-inline-end: 1px solid $tableBorderColor;
69
+ }
70
+ }
71
+
72
+ }
73
+
74
+
75
+ .#{$prefix}-table {
76
+ &.#{$prefix}-table-bordered {
77
+ > .#{$prefix}-table-container {
78
+
79
+ > .#{$prefix}-table-content,
80
+ > .#{$prefix}-table-header,
81
+ > .#{$prefix}-table-body,
82
+ > .#{$prefix}-table-summary {
83
+ > table {
84
+ > thead {
85
+ > tr:not(:last-child) {
86
+ > th {
87
+ border-bottom: 1px solid $tableBorderColor;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ border-inline-start: 1px solid $tableBorderColor;
95
+ border-top: 1px solid $tableBorderColor;
96
+
97
+
98
+ > .#{$prefix}-table-content,
99
+ > .#{$prefix}-table-header,
100
+ > .#{$prefix}-table-body,
101
+ > .#{$prefix}-table-summary {
102
+ > table {
103
+ > thead,
104
+ > tbody,
105
+ > tfoot {
106
+ > tr {
107
+ > th,
108
+ > td {
109
+ border-inline-end: 1px solid $tableBorderColor;
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ }
117
+
118
+ >.#{$prefix}-table-title {
119
+ border: 1px solid $tableBorderColor;
120
+ border-bottom: 0;
121
+ }
122
+ }
123
+ }
124
+
125
+
126
+ .#{$prefix}-table-thead >tr>th,
127
+ .#{$prefix}-table-thead >tr>td {
128
+ background-color: #ffffff;
129
+ }
130
+
131
+ .#{$prefix}-table-thead {
132
+ > tr {
133
+ > th,
134
+ > td {
135
+ border-bottom: 1px solid $tableBorderColor;
136
+ }
137
+ }
138
+ }
139
+
140
+ .#{$prefix}-table-summary {
141
+ .#{$prefix}-table-cell {
142
+ background-color: #fafafa;
143
+ }
144
+
145
+ > tr > td {
146
+ border-bottom: 1px solid $tableBorderColor;
147
+ }
148
+ }
149
+
150
+ .#{$prefix}-table-bordered .#{$prefix}-table-tbody-virtual .#{$prefix}-table-cell.#{$prefix}-table-cell-fix-right-first:before {
151
+ border-inline-start: 1px solid $tableBorderColor;
152
+ }
153
+
154
+ .#{$prefix}-table.#{$prefix}-table-bordered {
155
+ > .#{$prefix}-table-container {
156
+ > .#{$prefix}-table-header > table > thead > tr,
157
+ > .#{$prefix}-table-summary > table > tfoot > tr {
158
+ > .#{$prefix}-table-cell-fix-right-first::before {
159
+ border-inline-start: 1px solid $tableBorderColor;
160
+ content: "";
161
+ position: absolute;
162
+ inset-block: 0;
163
+ inset-inline-start: -1px;
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+
170
+ .#{$prefix}-table.#{$prefix}-table-bordered {
171
+ > .#{$prefix}-table-container {
172
+ > .#{$prefix}-table-header > table > thead > tr,
173
+ > .#{$prefix}-table-summary > table > tfoot > tr {
174
+ > .#{$prefix}-table-cell-fix-right-first::after {
175
+ border-inline-end: 0;
176
+ }
177
+ }
15
178
  }
16
179
  }
180
+
181
+ .#{$prefix}-table-ping-left {
182
+ .#{$prefix}-table-cell-fix-left-first::after,
183
+ .#{$prefix}-table-cell-fix-left-last::after {
184
+ box-shadow: inset 10px 0 8px -8px rgba(5, 5, 5, 0.2);
185
+ }
186
+ }
187
+
188
+ .#{$prefix}-table-ping-right {
189
+ .#{$prefix}-table-cell-fix-right-first::after,
190
+ .#{$prefix}-table-cell-fix-right-last::after {
191
+ box-shadow: inset -10px 0 8px -8px rgba(5, 5, 5, 0.2);
192
+ }
193
+ }
194
+
195
+ .#{$prefix}-spin-nested-loading >div>.#{$prefix}-spin {
196
+ max-height: 100%;
197
+ }
198
+
199
+
200
+ }
201
+
202
+ // -------------- Checkbox ----------
203
+
204
+ .#{$prefix}-checkbox-indeterminate {
205
+ &:hover {
206
+ .#{$prefix}-checkbox-inner {
207
+ border-color: $primary !important; ;
208
+ }
209
+ }
210
+ .#{$prefix}-checkbox-inner {
211
+ &:after {
212
+ background-color: $primary;
213
+ }
214
+ }
215
+ }
216
+
217
+ .#{$prefix}-checkbox {
218
+ &.#{$prefix}-checkbox-checked {
219
+ &:hover {
220
+ .#{$prefix}-checkbox-inner {
221
+ background-color: $primary;
222
+ border-color: $primary;
223
+ }
224
+ }
225
+ .#{$prefix}-checkbox-inner {
226
+ background-color: $primary;
227
+ border-color: $primary;
228
+ }
229
+ }
230
+ }
231
+
232
+ .#{$prefix}-checkbox:not(.#{$prefix}-checkbox-disabled):hover {
233
+ .#{$prefix}-checkbox-inner {
234
+ border-color: $primary;
235
+ }
17
236
  }
237
+
238
+ .#{$prefix}-checkbox-wrapper:not(.#{$prefix}-checkbox-wrapper-disabled):hover {
239
+ .#{$prefix}-checkbox-inner {
240
+ border-color: $primary;
241
+ }
242
+ .#{$prefix}-checkbox-checked:not(.#{$prefix}-checkbox-disabled) {
243
+ .#{$prefix}-checkbox-inner {
244
+ background-color: $primary;
245
+ }
246
+ }
18
247
  }
19
248
 
20
- //
21
- //.ui-rc-table-wrapper {
22
- // &.table-none-column-select {
23
- // .ui-rc-table-cell {
24
- // &.ui-rc-table-selection-column {
25
- // padding: 0!important;
26
- // overflow: hidden !important;
27
- // }
28
- // }
29
- // }
30
- //}
249
+ // ------------ Tree ---------------
250
+
251
+ .#{$prefix}-tree {
252
+ .#{$prefix}-tree-checkbox-checked {
253
+ .#{$prefix}-tree-checkbox-inner {
254
+ background-color: $primary;
255
+ border-color: $primary;
256
+ }
257
+ }
258
+
259
+ .#{$prefix}-tree-checkbox-wrapper-checked:not(.#{$prefix}-tree-checkbox-wrapper-disabled):hover,
260
+ .#{$prefix}-tree-checkbox-checked:not(.#{$prefix}-tree-checkbox-disabled):hover {
261
+ .#{$prefix}-tree-checkbox-inner {
262
+ background-color: $primary;
263
+ }
264
+ }
265
+
266
+ .#{$prefix}-tree-checkbox-wrapper:not(.#{$prefix}-tree-checkbox-wrapper-disabled):hover,
267
+ .#{$prefix}-tree-checkbox:not(.#{$prefix}-tree-checkbox-disabled):hover {
268
+ .#{$prefix}-tree-checkbox-inner {
269
+ border-color: $primary;
270
+ }
271
+ }
272
+ }
273
+
274
+
275
+
276
+
277
+ .#{$prefix}-pagination {
278
+ &::before {
279
+ content: "";
280
+ position: absolute;
281
+ border-left: 1px solid $tableBorderColor;
282
+ height: 55px;
283
+ bottom: 0;
284
+ left: 0;
285
+ }
286
+ &::after {
287
+ content: "";
288
+ position: absolute;
289
+ border-left: 1px solid $tableBorderColor;
290
+ height: 55px;
291
+ bottom: 0;
292
+ visibility: visible;
293
+ right: 0;
294
+ }
295
+ border-bottom: 1px solid $tableBorderColor;
296
+ }
package/lib/type.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { TableProps, TableColumnType as RcColumnType } from "ui-rc";
2
1
  import type { Key, ReactElement, ReactNode } from "react";
3
2
  import type React from "react";
4
3
  import type { IOperator } from "./hooks";
5
- import type { FilterOperator, TableRowSelection } from "ui-rc/dist/table/interface";
6
- import type { ToolbarItem } from "ui-rc/dist/toolbar";
7
- import type { ItemType } from "ui-rc/dist/menu/interface";
4
+ import type { TypeFilter, TableProps, TableColumnType as RcColumnType } from "rc-master-ui";
5
+ import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/interface";
6
+ import type { ToolbarItem } from "rc-master-ui/es/toolbar";
7
+ import type { ItemType } from "rc-master-ui/es/menu/interface";
8
8
  export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
9
9
  export type AnyObject = Record<PropertyKey, any>;
10
10
  export interface ColumnGroupType<RecordType = AnyObject> extends Omit<ColumnType<RecordType>, 'dataIndex'> {
@@ -20,9 +20,12 @@ export type ColumnType<RecordType> = RcColumnType<RecordType> & {
20
20
  operator?: FilterOperator;
21
21
  placeholder?: string;
22
22
  showInColumnChoose?: boolean;
23
+ typeFilter?: TypeFilter;
24
+ children?: ColumnsType<RecordType>;
25
+ headerText?: string;
23
26
  };
24
27
  export type ColumnsType<RecordType = AnyObject> = (ColumnGroupType<RecordType> | ColumnType<RecordType>)[];
25
- export interface GridTableProps<RecordType> extends Omit<TableProps<RecordType>, 'columns' | 'rowSelection'> {
28
+ export interface GridTableProps<RecordType> extends Omit<TableProps<RecordType>, 'columns' | 'rowSelection' | 'loading'> {
26
29
  columns?: ColumnsType<RecordType>;
27
30
  format?: IFormat;
28
31
  t?: any;
@@ -49,7 +52,16 @@ export interface GridTableProps<RecordType> extends Omit<TableProps<RecordType>,
49
52
  rowData: RecordType;
50
53
  selected: RecordType | RecordType[];
51
54
  }) => void;
55
+ dataSourceFilter?: SourceFilter[];
56
+ onFilterClick?: (column: ColumnType<RecordType>, callback: (key: string, data: any) => void) => void;
57
+ loading?: boolean;
58
+ allowResizing?: boolean;
52
59
  }
60
+ export type SourceFilter = {
61
+ key: string;
62
+ data: any[];
63
+ loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
64
+ };
53
65
  export type RowSelection<RecordType> = Omit<TableRowSelection<RecordType>, 'type' | 'columnWidth' | 'hideSelectAll' | 'defaultSelectedRowKeys'>;
54
66
  export type SelectionSettings = {
55
67
  mode?: 'checkbox' | 'radio';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",
@@ -24,13 +24,14 @@
24
24
  "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
25
25
  "now-build": "npm run docs:build",
26
26
  "prepare": "dumi setup",
27
- "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
27
+ "prepublishOnly": "npm run compile",
28
28
  "postpublish": "npm run docs:build && npm run docs:deploy",
29
29
  "start": "dumi dev",
30
30
  "test": "rc-test"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.11.2",
34
+ "@faker-js/faker": "^9.5.0",
34
35
  "@rc-component/father-plugin": "^2.0.1",
35
36
  "@rc-component/trigger": "^2.0.0",
36
37
  "@rc-component/util": "^1.0.1",
@@ -38,13 +39,14 @@
38
39
  "@types/styled-components": "^5.1.34",
39
40
  "antd": "^5.24.1",
40
41
  "antd-style": "^3.7.1",
42
+ "becoxy-icons": "^1.9.9",
41
43
  "classnames": "^2.3.1",
42
44
  "dayjs": "^1.11.13",
43
45
  "moment": "^2.30.1",
46
+ "rc-master-ui": "^1.1.0",
44
47
  "react-numeric-component": "^1.0.7",
45
48
  "react-resizable": "^3.0.5",
46
- "styled-components": "^6.1.15",
47
- "ui-rc": "^0.1.5"
49
+ "styled-components": "^6.1.15"
48
50
  },
49
51
  "devDependencies": {
50
52
  "@babel/cli": "^7.26.4",