@mezzanine-ui/core 0.12.9 → 0.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/core",
3
- "version": "0.12.9",
3
+ "version": "0.13.1",
4
4
  "description": "Core for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@mezzanine-ui/icons": "^0.12.9",
40
- "@mezzanine-ui/system": "^0.12.9",
39
+ "@mezzanine-ui/icons": "^0.13.1",
40
+ "@mezzanine-ui/system": "^0.13.1",
41
41
  "lodash": "^4.17.21",
42
42
  "tslib": "^2.4.1"
43
43
  }
@@ -1,5 +1,8 @@
1
+ /* stylelint-disable color-function-notation */
2
+ /* stylelint-disable alpha-value-notation */
1
3
  @use '~@mezzanine-ui/system/palette';
2
4
  @use '~@mezzanine-ui/system/typography';
5
+ @use '~@mezzanine-ui/system/transition';
3
6
  @use './table' as *;
4
7
 
5
8
  $table-header-height: 40px !default;
@@ -16,7 +19,7 @@ $table-refresh-vertical-padding: 8px !default;
16
19
  height: auto;
17
20
  min-height: $min-height;
18
21
  display: flex;
19
- align-items: center;
22
+ align-items: stretch;
20
23
  justify-content: flex-start;
21
24
  border-bottom: 1px solid palette.color(border);
22
25
  }
@@ -54,17 +57,95 @@ $table-refresh-vertical-padding: 8px !default;
54
57
  font-size: typography.px-to-rem($size);
55
58
  }
56
59
 
57
- .#{$prefix} {
60
+ @mixin with-scroll-box-shadow($colorName) {
61
+ &--fixed {
62
+ &:first-child {
63
+ position: sticky;
64
+ z-index: 2;
65
+ left: 0;
66
+ }
67
+
68
+ &::before {
69
+ content: '';
70
+ position: absolute;
71
+ left: 0;
72
+ top: 0;
73
+ width: 100%;
74
+ height: 100%;
75
+ z-index: -1;
76
+ background-color: palette.color(#{$colorName});
77
+ }
78
+
79
+ &::after {
80
+ position: absolute;
81
+ top: 0;
82
+ right: 0;
83
+ bottom: -1px;
84
+ width: 10px;
85
+ transform: translateX(100%);
86
+ transition: transition.standard(box-shadow);
87
+ content: '';
88
+ pointer-events: none;
89
+ }
90
+
91
+ &--stuck {
92
+ &::after {
93
+ box-shadow: inset 8px 0 8px -8px rgba(0, 0, 0, 0.25);
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ .#{$loading-prefix} {
100
+ z-index: 4;
101
+ }
102
+
103
+ .#{$container-prefix} {
104
+ width: 100%;
105
+ max-height: var(--table-scroll-y, 'unset');
58
106
  position: relative;
107
+ overflow: auto;
108
+ scrollbar-width: thin; /* firefox specific (firefox 只能先用原生的) */
109
+
110
+ &::-webkit-scrollbar {
111
+ height: 8px;
112
+ width: 0;
113
+
114
+ /* smartphones, touchscreens */
115
+ @media (hover: none) and (pointer: coarse) {
116
+ display: none;
117
+ height: 0;
118
+ }
119
+ }
120
+
121
+ &::-webkit-scrollbar-thumb {
122
+ border-radius: 6px;
123
+ background: #6a6a6a;
124
+ }
125
+
126
+ &::-webkit-scrollbar-track {
127
+ background: #f2f2f2;
128
+ }
129
+ }
130
+
131
+ .#{$prefix} {
59
132
  width: 100%;
60
- height: 100%;
61
- display: flex;
62
- flex-flow: column;
63
- align-items: flex-start;
64
- justify-content: flex-start;
133
+ min-width: var(--table-scroll-x, '100%');
134
+ table-layout: fixed;
135
+ border-collapse: collapse;
136
+ border-spacing: 0;
65
137
  box-sizing: border-box;
66
138
 
67
139
  @include text_color;
140
+ @include body_bg();
141
+ }
142
+
143
+ .#{$header-fixed-prefix} {
144
+ width: 100%;
145
+ min-width: var(--table-scroll-x, '100%');
146
+ position: sticky;
147
+ z-index: 3;
148
+ top: 0;
68
149
  }
69
150
 
70
151
  .#{$header-prefix} {
@@ -75,33 +156,52 @@ $table-refresh-vertical-padding: 8px !default;
75
156
 
76
157
  &__cellWrapper {
77
158
  @include flexible;
159
+
160
+ background-color: palette.color(divider);
161
+
162
+ @include with-scroll-box-shadow(divider);
78
163
  }
79
164
  }
80
165
 
81
166
  .#{$body-prefix} {
82
167
  position: relative;
83
168
  width: 100%;
84
- flex: 1 0 0;
85
- overflow: auto;
86
- scrollbar-width: none; /* Firefox specific */
87
-
88
- &::-webkit-scrollbar {
89
- display: none;
90
- -webkit-overflow-scrolling: touch;
91
- }
169
+ min-width: var(--table-scroll-x, '100%');
92
170
 
93
171
  &__row {
94
172
  @include row(52px);
95
173
  @include body_content;
96
174
  @include body_bg;
97
175
 
176
+ position: relative;
177
+
98
178
  &:hover,
99
179
  &--highlight {
100
- @include action_highlight_bg;
180
+ .#{$body-prefix} {
181
+ &__row {
182
+ &__cellWrapper {
183
+ @include action_highlight_bg;
184
+
185
+ &--fixed {
186
+ @include body_bg;
187
+
188
+ &::before {
189
+ @include action_highlight_bg;
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ &--drag {
198
+ filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.25));
101
199
  }
102
200
 
103
201
  &__cellWrapper {
104
202
  @include flexible;
203
+ @include body_bg;
204
+ @include with-scroll-box-shadow(surface);
105
205
  }
106
206
 
107
207
  &__expandedTableWrapper {
@@ -119,12 +219,15 @@ $table-refresh-vertical-padding: 8px !default;
119
219
 
120
220
  &__empty {
121
221
  @include body_bg;
222
+
223
+ min-height: calc(var(--table-scroll-y, '130px') - 12px - #{$table-header-height});
122
224
  }
123
225
 
124
226
  &__fetchMore {
125
227
  @include row(auto);
126
228
  @include body_bg;
127
229
 
230
+ justify-content: center;
128
231
  padding: $table-fetch-more-vertical-padding 0;
129
232
  border-bottom: none;
130
233
  }
package/table/_table.scss CHANGED
@@ -1,6 +1,9 @@
1
1
  @use '~@mezzanine-ui/system/size';
2
2
 
3
+ $loading-prefix: mzn-table-loading;
4
+ $container-prefix: mzn-table-scroll-area;
3
5
  $prefix: mzn-table;
6
+ $header-fixed-prefix: mzn-table__header-fixed;
4
7
  $header-prefix: mzn-table__header;
5
8
  $body-prefix: mzn-table__body;
6
9
  $cell-prefix: mzn-table__cell;
package/table/index.js CHANGED
@@ -1 +1 @@
1
- export { getCellStyle, getColumnStyle, tableBodyPrefix, tableCellPrefix, tableClasses, tableHeaderPrefix, tablePrefix } from './table.js';
1
+ export { getCellStyle, getColumnStyle, tableBodyPrefix, tableCellPrefix, tableClasses, tableHeaderFixedPrefix, tableHeaderPrefix, tableLoadingPrefix, tablePrefix, tableScrollContainerPrefix } from './table.js';
package/table/table.d.ts CHANGED
@@ -1,17 +1,28 @@
1
+ export declare const tableScrollContainerPrefix = "mzn-table-scroll-area";
2
+ export declare const tableLoadingPrefix = "mzn-table-loading";
1
3
  export declare const tablePrefix = "mzn-table";
4
+ export declare const tableHeaderFixedPrefix: string;
2
5
  export declare const tableHeaderPrefix: string;
3
6
  export declare const tableBodyPrefix: string;
4
7
  export declare const tableCellPrefix: string;
5
8
  export declare const tableClasses: {
9
+ readonly loading: "mzn-table-loading";
10
+ readonly scrollContainer: "mzn-table-scroll-area";
6
11
  readonly host: "mzn-table";
12
+ readonly headerFixed: string;
7
13
  readonly header: string;
8
14
  readonly headerCellWrapper: `${string}__cellWrapper`;
15
+ readonly headerCellWrapperFixed: `${string}__cellWrapper--fixed`;
16
+ readonly headerCellWrapperFixedStuck: `${string}__cellWrapper--fixed--stuck`;
9
17
  readonly body: string;
10
18
  readonly bodyEmpty: `${string}__empty`;
11
19
  readonly bodyFetchMore: `${string}__fetchMore`;
12
20
  readonly bodyRow: `${string}__row`;
21
+ readonly bodyRowDragging: `${string}__row--drag`;
13
22
  readonly bodyRowHighlight: `${string}__row--highlight`;
14
23
  readonly bodyRowCellWrapper: `${string}__row__cellWrapper`;
24
+ readonly bodyRowCellWrapperFixed: `${string}__row__cellWrapper--fixed`;
25
+ readonly bodyRowCellWrapperFixedStuck: `${string}__row__cellWrapper--fixed--stuck`;
15
26
  readonly bodyRowExpandedTableWrapper: `${string}__row__expandedTableWrapper`;
16
27
  readonly bodyRowExpandedTable: `${string}__row__expandedTable`;
17
28
  readonly bodyRowExpandedTableRow: `${string}__row__expandedTableRow`;
@@ -71,6 +82,11 @@ export interface TableRowSelection {
71
82
  onChange?(keys: string[]): void;
72
83
  actions?: TableRowAction[];
73
84
  }
85
+ /** === Feature draggable */
86
+ export interface TableDraggable {
87
+ enabled: boolean;
88
+ onDragEnd?: (nextDataSource: any[]) => void;
89
+ }
74
90
  /** === Feature Expandable */
75
91
  export type ExpandRowBySources = {
76
92
  dataSource: TableDataSource[];
@@ -122,6 +138,13 @@ export interface TableComponents {
122
138
  cell?: any;
123
139
  };
124
140
  }
141
+ /** === Feature scrolling */
142
+ export interface TableScrolling {
143
+ x?: number;
144
+ y?: number;
145
+ /** Only available when horizontal scrolling is enabled */
146
+ fixedFirstColumn?: boolean;
147
+ }
125
148
  /** styling */
126
149
  export declare function getColumnStyle(column: TableColumn<TableRecord<unknown>>): {};
127
150
  export declare function getCellStyle(column: TableColumn<TableRecord<unknown>>): {};
package/table/table.js CHANGED
@@ -1,17 +1,28 @@
1
+ const tableScrollContainerPrefix = 'mzn-table-scroll-area';
2
+ const tableLoadingPrefix = 'mzn-table-loading';
1
3
  const tablePrefix = 'mzn-table';
4
+ const tableHeaderFixedPrefix = `${tablePrefix}__header-fixed`;
2
5
  const tableHeaderPrefix = `${tablePrefix}__header`;
3
6
  const tableBodyPrefix = `${tablePrefix}__body`;
4
7
  const tableCellPrefix = `${tablePrefix}__cell`;
5
8
  const tableClasses = {
9
+ loading: tableLoadingPrefix,
10
+ scrollContainer: tableScrollContainerPrefix,
6
11
  host: tablePrefix,
12
+ headerFixed: tableHeaderFixedPrefix,
7
13
  header: tableHeaderPrefix,
8
14
  headerCellWrapper: `${tableHeaderPrefix}__cellWrapper`,
15
+ headerCellWrapperFixed: `${tableHeaderPrefix}__cellWrapper--fixed`,
16
+ headerCellWrapperFixedStuck: `${tableHeaderPrefix}__cellWrapper--fixed--stuck`,
9
17
  body: tableBodyPrefix,
10
18
  bodyEmpty: `${tableBodyPrefix}__empty`,
11
19
  bodyFetchMore: `${tableBodyPrefix}__fetchMore`,
12
20
  bodyRow: `${tableBodyPrefix}__row`,
21
+ bodyRowDragging: `${tableBodyPrefix}__row--drag`,
13
22
  bodyRowHighlight: `${tableBodyPrefix}__row--highlight`,
14
23
  bodyRowCellWrapper: `${tableBodyPrefix}__row__cellWrapper`,
24
+ bodyRowCellWrapperFixed: `${tableBodyPrefix}__row__cellWrapper--fixed`,
25
+ bodyRowCellWrapperFixedStuck: `${tableBodyPrefix}__row__cellWrapper--fixed--stuck`,
15
26
  bodyRowExpandedTableWrapper: `${tableBodyPrefix}__row__expandedTableWrapper`,
16
27
  bodyRowExpandedTable: `${tableBodyPrefix}__row__expandedTable`,
17
28
  bodyRowExpandedTableRow: `${tableBodyPrefix}__row__expandedTableRow`,
@@ -54,4 +65,4 @@ function getCellStyle(column) {
54
65
  return style;
55
66
  }
56
67
 
57
- export { getCellStyle, getColumnStyle, tableBodyPrefix, tableCellPrefix, tableClasses, tableHeaderPrefix, tablePrefix };
68
+ export { getCellStyle, getColumnStyle, tableBodyPrefix, tableCellPrefix, tableClasses, tableHeaderFixedPrefix, tableHeaderPrefix, tableLoadingPrefix, tablePrefix, tableScrollContainerPrefix };