@jiaozhiye/qm-design-react 1.11.0 → 1.11.2

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.
@@ -1,9 +1,6 @@
1
+ import type { IColumn } from '../../../table/src/table/types';
1
2
  declare const _default: {
2
- selectionColumnDefine: {
3
- title: string;
4
- dataIndex: string;
5
- width: number;
6
- };
3
+ selectionColumnDefine: IColumn;
7
4
  indentWidth: number;
8
5
  };
9
6
  export default _default;
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { IRowKey } from '../../../table/src/table/types';
3
3
  import type { ScrollbarRef } from '../../../scrollbar';
4
+ import type { Summary } from '../utils';
4
5
  export type IGridLayoutContext = {
5
6
  scrollbarRef: React.RefObject<ScrollbarRef>;
6
7
  indentDepth: number;
7
8
  selectionKeys: IRowKey[];
8
- countMethod: Record<string, any>;
9
+ countMethod: Record<string, string>;
10
+ summationData: Summary;
9
11
  };
10
12
  type IProps = {
11
13
  scrollbar: React.RefObject<ScrollbarRef>;
@@ -15,6 +17,7 @@ export declare const GridLayoutProvider: React.FC<IProps>;
15
17
  export declare const useGridLayoutContext: () => (IGridLayoutContext & {
16
18
  setContext: (data: Partial<IGridLayoutContext>) => void;
17
19
  setSelectionKeys: (rowKeys: IRowKey[]) => void;
18
- setCountMethod: (value: IGridLayoutContext[`countMethod`]) => void;
20
+ setCountMethod: (value: Record<string, string | undefined>) => void;
21
+ setSummationData: (value: Summary) => void;
19
22
  }) | undefined;
20
23
  export {};
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import type { IColumn } from '../../../table/src/table/types';
3
3
  type IProps = {
4
4
  column: IColumn;
5
+ keyPath: string;
6
+ type: 'total' | 'subtotal';
5
7
  };
6
8
  declare const CountPanel: React.FC<IProps>;
7
9
  export default CountPanel;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  type IProps = {
3
- labelKey: string;
3
+ dataKey: string;
4
+ dataKeyPath: string;
4
5
  depth: number;
5
6
  className?: string;
6
7
  style?: React.CSSProperties;
@@ -1,2 +1,29 @@
1
- import type { IRecord, IOrderBy } from '../../../table/src/table/types';
1
+ import type { IRecord, IOrderBy, IColumn } from '../../../table/src/table/types';
2
2
  export declare const groupMultiData: (records: IRecord[], groupKeys: Record<string, IOrderBy>[] | undefined, fn: (row: IRecord, key: string) => string | number) => any;
3
+ export type Subtotal = {
4
+ [key: string]: number;
5
+ };
6
+ export type GroupSummary = {
7
+ subtotal: Subtotal;
8
+ };
9
+ export type Summary = {
10
+ [key: string]: GroupSummary | Subtotal;
11
+ };
12
+ export type FieldCalculations = Record<string, (dataList: number[]) => number>;
13
+ /**
14
+ * 递归计算分组数据
15
+ * @param {Object} group - 当前分组数据
16
+ * @returns {Object} - 计算后的结果
17
+ */
18
+ export declare const calculateSummary: (groupData: Record<string, any> | Record<string, any>[], fieldCalculations: Record<string, (data: number[]) => number>) => Summary;
19
+ export declare const calculations: {
20
+ sum: (arr: number[]) => number;
21
+ avg: (arr: number[]) => number;
22
+ max: (arr: number[]) => number | undefined;
23
+ min: (arr: number[]) => number | undefined;
24
+ count: (arr: number[]) => number;
25
+ unique: (arr: number[]) => number;
26
+ empty: (arr: number[]) => number;
27
+ notEmpty: (arr: number[]) => number;
28
+ };
29
+ export declare const getStickyLeft: (flattenColumns: IColumn[], fieldName: string) => number;
@@ -1,234 +1,239 @@
1
- /*
2
- * @Author: 焦质晔
3
- * @Date: 2022-03-16 19:05:30
4
- * @Last Modified by: 焦质晔
5
- * @Last Modified time: 2024-11-29 13:20:19
6
- */
7
- @import '../../style/common';
8
-
9
- .@{prefix-pivot-grid}__layout {
10
- .reset-container();
11
- height: 100%;
12
- .header,
13
- .footer {
14
- overflow: hidden;
15
- background-color: #fff;
16
- border: 1px solid @--border-color-secondary;
17
- border-radius: @pivot-border-radius;
18
- .table {
19
- table-layout: fixed;
20
- display: contents;
21
- thead th,
22
- tfoot td {
23
- text-align: left;
24
- font-weight: normal;
25
- border-right: 1px solid @--border-color-secondary;
26
- position: relative;
27
- &.selection-column {
28
- text-align: center;
29
- justify-content: center;
30
- border-right-color: transparent;
31
- }
32
- }
33
- }
34
- }
35
- .header {
36
- position: sticky;
37
- top: 0;
38
- z-index: 1;
39
- .resize-bar {
40
- position: absolute;
41
- top: 0;
42
- bottom: 0;
43
- right: -3px;
44
- width: 6px;
45
- z-index: 2;
46
- cursor: col-resize;
47
- }
48
- }
49
- .body {
50
- min-height: fit-content;
51
- .group-card {
52
- margin: 15px 0;
53
- border: 1px solid @--border-color-secondary;
54
- border-radius: @pivot-border-radius;
55
- background-color: #fff;
56
- &.inner {
57
- margin: 0 12px 12px;
58
- }
59
- &:has(.inner) > .label-row > .label-cell {
60
- border-bottom: 0;
61
- }
62
- .label-row {
63
- display: flex;
64
- align-items: center;
65
- .label-cell {
66
- align-self: stretch;
67
- display: inline-flex;
68
- align-items: center;
69
- border-bottom: 1px solid @--border-color-secondary;
70
- &.expandable-column {
71
- justify-content: center;
72
- .button-icon {
73
- & > .anticon {
74
- transition: transform 0.3s ease;
75
- }
76
- &.expand > .anticon {
77
- transform: rotate(90deg);
78
- }
79
- }
80
- }
81
- }
82
- }
83
- .grid-list {
84
- margin: 0;
85
- border: 0;
86
- border-radius: 0;
87
- background: transparent;
88
- }
89
- }
90
- .grid-list {
91
- margin: 15px 0;
92
- border: 1px solid @--border-color-secondary;
93
- border-radius: @pivot-border-radius;
94
- background-color: #fff;
95
- .table-row {
96
- display: flex;
97
- align-items: center;
98
- &:hover {
99
- background-color: @--background-color-light;
100
- .table-cell {
101
- .order {
102
- display: none;
103
- }
104
- .checkbox {
105
- display: inline-flex;
106
- }
107
- }
108
- }
109
- &.row--selection {
110
- background-color: @--primary-1;
111
- .table-cell {
112
- .order {
113
- display: none;
114
- }
115
- .checkbox {
116
- display: inline-flex;
117
- }
118
- }
119
- }
120
- .table-cell {
121
- align-self: stretch; // 子元素高度和父元素一致
122
- display: inline-flex;
123
- align-items: center;
124
- border-right: 1px solid @--border-color-secondary;
125
- border-bottom: 1px solid @--border-color-secondary;
126
- &:last-child {
127
- border-right: 0;
128
- }
129
- &.selection-column {
130
- justify-content: center;
131
- border-right-color: transparent;
132
- }
133
- .order {
134
- display: inline-block;
135
- }
136
- .checkbox {
137
- display: none;
138
- }
139
- }
140
- &:last-child {
141
- .table-cell {
142
- border-bottom: 0;
143
- }
144
- }
145
- }
146
- }
147
- }
148
- .footer {
149
- position: sticky;
150
- bottom: 0;
151
- z-index: 1;
152
- }
153
- .header,
154
- .body,
155
- .footer {
156
- .table-cell {
157
- &.col--center {
158
- text-align: center !important;
159
- justify-content: center;
160
- }
161
- &.col--right {
162
- text-align: right !important;
163
- justify-content: flex-end;
164
- }
165
- .cell {
166
- .text-overflow-cut();
167
- padding: 0 @--padding-sm;
168
- }
169
- &:hover {
170
- .count-select {
171
- visibility: visible;
172
- }
173
- }
174
- }
175
- .count-select {
176
- .text-overflow-cut();
177
- display: inline-flex;
178
- align-items: center;
179
- justify-content: flex-end;
180
- height: 100%;
181
- width: 100%;
182
- padding: 0 @--padding-sm;
183
- color: @--text-color-placeholder;
184
- cursor: pointer;
185
- visibility: hidden;
186
- &:hover,
187
- &.ant-dropdown-open {
188
- visibility: visible;
189
- background-color: @--background-color-light;
190
- }
191
- &.show {
192
- visibility: visible;
193
- }
194
- .icon {
195
- margin-left: 4px;
196
- }
197
- }
198
- }
199
- .resize-line {
200
- position: absolute;
201
- left: -2px;
202
- top: 0;
203
- width: 2px;
204
- height: 100%;
205
- background-color: @--primary-color;
206
- cursor: col-resize;
207
- z-index: 2;
208
- }
209
- // size
210
- &.small {
211
- .header .table th,
212
- .footer .table td,
213
- .body .grid-list > li,
214
- .body .group-card > li {
215
- height: 26px;
216
- }
217
- }
218
- &.middle {
219
- .header .table th,
220
- .footer .table td,
221
- .body .grid-list > li,
222
- .body .group-card > li {
223
- height: 34px;
224
- }
225
- }
226
- &.large {
227
- .header .table th,
228
- .footer .table td,
229
- .body .grid-list > li,
230
- .body .group-card > li {
231
- height: 42px;
232
- }
233
- }
234
- }
1
+ /*
2
+ * @Author: 焦质晔
3
+ * @Date: 2022-03-16 19:05:30
4
+ * @Last Modified by: 焦质晔
5
+ * @Last Modified time: 2024-12-02 20:51:13
6
+ */
7
+ @import '../../style/common';
8
+
9
+ .@{prefix-pivot-grid}__layout {
10
+ .reset-container();
11
+ height: 100%;
12
+ .header,
13
+ .footer {
14
+ border: 1px solid @--border-color-secondary;
15
+ .table {
16
+ table-layout: fixed;
17
+ display: contents;
18
+ thead th,
19
+ tfoot td {
20
+ text-align: left;
21
+ font-weight: normal;
22
+ border-right: 1px solid @--border-color-secondary;
23
+ position: relative;
24
+ &.selection-column {
25
+ text-align: center;
26
+ justify-content: center;
27
+ border-right-color: transparent;
28
+ }
29
+ }
30
+ }
31
+ }
32
+ .header {
33
+ position: sticky;
34
+ top: 0;
35
+ z-index: 2;
36
+ .resize-bar {
37
+ position: absolute;
38
+ top: 0;
39
+ bottom: 0;
40
+ right: -3px;
41
+ width: 6px;
42
+ z-index: 2;
43
+ cursor: col-resize;
44
+ }
45
+ }
46
+ .body {
47
+ min-height: fit-content;
48
+ .group-card {
49
+ margin: 15px 0;
50
+ background-color: #fff;
51
+ border: 1px solid @--border-color-secondary;
52
+ &.inner {
53
+ margin: 0 12px 12px;
54
+ }
55
+ &:has(.inner) > .label-row > .label-cell {
56
+ border-bottom: 0;
57
+ }
58
+ .label-row {
59
+ display: flex;
60
+ align-items: center;
61
+ .label-cell {
62
+ align-self: stretch;
63
+ display: inline-flex;
64
+ align-items: center;
65
+ background-color: #fff;
66
+ border-bottom: 1px solid @--border-color-secondary;
67
+ &.expandable-column {
68
+ justify-content: center;
69
+ .button-icon {
70
+ & > .anticon {
71
+ transition: transform 0.3s ease;
72
+ }
73
+ &.expand > .anticon {
74
+ transform: rotate(90deg);
75
+ }
76
+ }
77
+ }
78
+ &.col--fix-left {
79
+ position: sticky;
80
+ z-index: 1;
81
+ }
82
+ .title {
83
+ flex-shrink: 0;
84
+ margin-right: 20px;
85
+ }
86
+ }
87
+ }
88
+ .grid-list {
89
+ margin: 0;
90
+ border: 0;
91
+ background: transparent;
92
+ }
93
+ }
94
+ .grid-list {
95
+ margin: 15px 0;
96
+ border: 1px solid @--border-color-secondary;
97
+ .table-row {
98
+ display: flex;
99
+ align-items: center;
100
+ &:hover {
101
+ .table-cell {
102
+ background-color: @--background-color-light;
103
+ .order {
104
+ display: none;
105
+ }
106
+ .checkbox {
107
+ display: inline-flex;
108
+ }
109
+ }
110
+ }
111
+ &.row--selection {
112
+ background-color: @--primary-1;
113
+ .table-cell {
114
+ .order {
115
+ display: none;
116
+ }
117
+ .checkbox {
118
+ display: inline-flex;
119
+ }
120
+ }
121
+ }
122
+ .table-cell {
123
+ align-self: stretch; // 子元素高度和父元素一致
124
+ display: inline-flex;
125
+ align-items: center;
126
+ border-bottom: 1px solid @--border-color-secondary;
127
+ }
128
+ }
129
+ }
130
+ }
131
+ .footer {
132
+ position: sticky;
133
+ bottom: 0;
134
+ z-index: 2;
135
+ }
136
+ .header,
137
+ .body,
138
+ .footer {
139
+ .table-cell {
140
+ background-color: #fff;
141
+ border-right: 1px solid @--border-color-secondary;
142
+ &:last-child {
143
+ border-right: 0;
144
+ }
145
+ &.selection-column {
146
+ justify-content: center;
147
+ border-right-color: transparent;
148
+ }
149
+ .order {
150
+ display: inline-block;
151
+ }
152
+ .checkbox {
153
+ display: none;
154
+ }
155
+ &.col--center {
156
+ text-align: center !important;
157
+ justify-content: center;
158
+ }
159
+ &.col--right {
160
+ text-align: right !important;
161
+ justify-content: flex-end;
162
+ }
163
+ &.col--fix-left {
164
+ position: sticky;
165
+ z-index: 1;
166
+ }
167
+ .cell {
168
+ .text-overflow-cut();
169
+ padding: 0 @--padding-sm;
170
+ }
171
+ }
172
+ .label-cell,
173
+ .table-cell {
174
+ &:hover {
175
+ .count-select {
176
+ visibility: visible;
177
+ }
178
+ }
179
+ }
180
+ .count-select {
181
+ .text-overflow-cut();
182
+ display: inline-flex;
183
+ align-items: center;
184
+ justify-content: flex-end;
185
+ height: 100%;
186
+ width: 100%;
187
+ padding: 0 @--padding-sm;
188
+ color: @--text-color-placeholder;
189
+ cursor: pointer;
190
+ visibility: hidden;
191
+ &:hover,
192
+ &.ant-dropdown-open {
193
+ visibility: visible;
194
+ background-color: @--background-color-light;
195
+ }
196
+ &.show {
197
+ visibility: visible;
198
+ }
199
+ .icon {
200
+ margin-left: 4px;
201
+ }
202
+ }
203
+ }
204
+ .resize-line {
205
+ position: absolute;
206
+ left: -2px;
207
+ top: 0;
208
+ width: 2px;
209
+ height: 100%;
210
+ background-color: @--primary-color;
211
+ cursor: col-resize;
212
+ z-index: 2;
213
+ }
214
+ // size
215
+ &.small {
216
+ .header .table th,
217
+ .footer .table td,
218
+ .body .grid-list > li,
219
+ .body .group-card > li {
220
+ height: 26px;
221
+ }
222
+ }
223
+ &.middle {
224
+ .header .table th,
225
+ .footer .table td,
226
+ .body .grid-list > li,
227
+ .body .group-card > li {
228
+ height: 34px;
229
+ }
230
+ }
231
+ &.large {
232
+ .header .table th,
233
+ .footer .table td,
234
+ .body .grid-list > li,
235
+ .body .group-card > li {
236
+ height: 42px;
237
+ }
238
+ }
239
+ }
@@ -1,9 +1,7 @@
1
- /*
2
- * @Author: 焦质晔
3
- * @Date: 2020-02-28 21:58:58
4
- * @Last Modified by: 焦质晔
5
- * @Last Modified time: 2024-11-28 20:04:56
6
- */
7
- @prefix-pivot-grid: ~'@{qm-prefix}-pivot-grid';
8
-
9
- @pivot-border-radius: 6px;
1
+ /*
2
+ * @Author: 焦质晔
3
+ * @Date: 2020-02-28 21:58:58
4
+ * @Last Modified by: 焦质晔
5
+ * @Last Modified time: 2024-11-28 20:04:56
6
+ */
7
+ @prefix-pivot-grid: ~'@{qm-prefix}-pivot-grid';