@vonage/vivid 3.5.0 → 3.7.0
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/README.md +31 -14
- package/banner/index.js +2 -0
- package/breadcrumb/index.js +1 -1
- package/breadcrumb-item/index.js +1 -1
- package/button/index.js +2 -0
- package/calendar/index.js +1 -1
- package/calendar-event/index.js +1 -1
- package/card/index.js +2 -2
- package/checkbox/index.js +1 -1
- package/combobox/index.js +6 -4
- package/custom-elements.json +302 -0
- package/data-grid/index.js +1 -1
- package/dialog/index.js +4 -2
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/fab/index.js +1 -1
- package/header/index.js +2 -2
- package/index.js +26 -26
- package/layout/index.js +1 -1
- package/lib/accordion-item/accordion-item.d.ts +3 -0
- package/lib/action-group/action-group.d.ts +2 -0
- package/lib/button/button.d.ts +1 -0
- package/lib/button/button.template.d.ts +1 -1
- package/lib/select/select.d.ts +2 -3
- package/listbox/index.js +2 -2
- package/menu/index.js +6 -4
- package/menu-item/index.js +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +1 -1
- package/nav-item/index.js +1 -1
- package/note/index.js +1 -1
- package/number-field/index.js +4 -2
- package/option/index.js +1 -1
- package/package.json +1 -1
- package/popup/index.js +4 -2
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/select/index.js +5 -3
- package/shared/definition.js +1 -1
- package/shared/definition10.js +69 -91
- package/shared/definition11.js +91 -40
- package/shared/definition12.js +31 -755
- package/shared/definition13.js +754 -93
- package/shared/definition14.js +100 -103
- package/shared/definition15.js +106 -24
- package/shared/definition16.js +24 -164
- package/shared/definition17.js +108 -663
- package/shared/definition18.js +667 -1533
- package/shared/definition19.js +1545 -223
- package/shared/definition2.js +8 -7
- package/shared/definition20.js +183 -964
- package/shared/definition21.js +1037 -222
- package/shared/definition22.js +226 -67
- package/shared/definition23.js +68 -77
- package/shared/definition24.js +76 -47
- package/shared/definition25.js +46 -32
- package/shared/definition26.js +35 -49
- package/shared/definition27.js +48 -344
- package/shared/definition28.js +273 -282
- package/shared/definition29.js +356 -14
- package/shared/definition30.js +13 -67
- package/shared/definition31.js +65 -21
- package/shared/definition32.js +21 -39
- package/shared/definition33.js +31 -432
- package/shared/definition34.js +432 -76
- package/shared/definition35.js +76 -59
- package/shared/definition36.js +3 -3
- package/shared/definition37.js +1 -1
- package/shared/definition38.js +7 -6
- package/shared/definition39.js +1 -1
- package/shared/definition4.js +1 -1
- package/shared/definition41.js +1 -1
- package/shared/definition42.js +1 -1
- package/shared/definition44.js +1 -1
- package/shared/definition45.js +1 -1
- package/shared/definition47.js +2 -2
- package/shared/definition48.js +1 -1
- package/shared/definition5.js +10 -3
- package/shared/definition6.js +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.js +1 -1
- package/shared/definition9.js +14 -4
- package/shared/form-elements.js +1 -1
- package/shared/icon.js +1 -1
- package/shared/listbox.js +1 -1
- package/shared/patterns/form-elements/form-elements.d.ts +2 -2
- package/shared/text-field.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/tooltip/index.js +4 -2
package/shared/definition21.js
CHANGED
|
@@ -1,237 +1,1052 @@
|
|
|
1
|
-
import { F as FoundationElement,
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { F as FoundationElement, _ as __decorate, a as attr, o as observable, W as DOM, h as html, b as __metadata, r as registerFactory } from './index.js';
|
|
2
|
+
import { k as keyEnd, a as keyHome, h as keyArrowRight, i as keyArrowLeft, j as keyPageDown, l as keyPageUp, b as keyArrowDown, c as keyArrowUp, f as keyEscape, m as keyFunction2, d as keyEnter } from './key-codes.js';
|
|
3
|
+
import { R as RepeatDirective } from './repeat.js';
|
|
4
|
+
import { e as elements, s as slotted } from './slotted.js';
|
|
5
|
+
import { c as children } from './children.js';
|
|
6
|
+
import { f as focusTemplateFactory } from './focus2.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This set of exported strings reference https://developer.mozilla.org/en-US/docs/Web/Events
|
|
10
|
+
* and should include all non-deprecated and non-experimental Standard events
|
|
11
|
+
*/
|
|
12
|
+
const eventFocus = "focus";
|
|
13
|
+
const eventFocusIn = "focusin";
|
|
14
|
+
const eventFocusOut = "focusout";
|
|
15
|
+
const eventKeyDown = "keydown";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Enumerates the data grid auto generated header options
|
|
19
|
+
* default option generates a non-sticky header row
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
const GenerateHeaderOptions = {
|
|
24
|
+
none: "none",
|
|
25
|
+
default: "default",
|
|
26
|
+
sticky: "sticky",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Enumerates possible data grid cell types.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
const DataGridCellTypes = {
|
|
34
|
+
default: "default",
|
|
35
|
+
columnHeader: "columnheader",
|
|
36
|
+
rowHeader: "rowheader",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Enumerates possible data grid row types
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
const DataGridRowTypes = {
|
|
44
|
+
default: "default",
|
|
45
|
+
header: "header",
|
|
46
|
+
stickyHeader: "sticky-header",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A Data Grid Row Custom HTML Element.
|
|
51
|
+
*
|
|
52
|
+
* @fires row-focused - Fires a custom 'row-focused' event when focus is on an element (usually a cell or its contents) in the row
|
|
53
|
+
* @slot - The default slot for custom cell elements
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
class DataGridRow$1 extends FoundationElement {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
/**
|
|
60
|
+
* The type of row
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @remarks
|
|
64
|
+
* HTML Attribute: row-type
|
|
65
|
+
*/
|
|
66
|
+
this.rowType = DataGridRowTypes.default;
|
|
67
|
+
/**
|
|
68
|
+
* The base data for this row
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
this.rowData = null;
|
|
73
|
+
/**
|
|
74
|
+
* The column definitions of the row
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
this.columnDefinitions = null;
|
|
79
|
+
/**
|
|
80
|
+
* Whether focus is on/in a cell within this row.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
this.isActiveRow = false;
|
|
85
|
+
this.cellsRepeatBehavior = null;
|
|
86
|
+
this.cellsPlaceholder = null;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
this.focusColumnIndex = 0;
|
|
91
|
+
this.refocusOnLoad = false;
|
|
92
|
+
this.updateRowStyle = () => {
|
|
93
|
+
this.style.gridTemplateColumns = this.gridTemplateColumns;
|
|
94
|
+
};
|
|
61
95
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
gridTemplateColumnsChanged() {
|
|
97
|
+
if (this.$fastController.isConnected) {
|
|
98
|
+
this.updateRowStyle();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
rowTypeChanged() {
|
|
102
|
+
if (this.$fastController.isConnected) {
|
|
103
|
+
this.updateItemTemplate();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
rowDataChanged() {
|
|
107
|
+
if (this.rowData !== null && this.isActiveRow) {
|
|
108
|
+
this.refocusOnLoad = true;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
cellItemTemplateChanged() {
|
|
113
|
+
this.updateItemTemplate();
|
|
114
|
+
}
|
|
115
|
+
headerCellItemTemplateChanged() {
|
|
116
|
+
this.updateItemTemplate();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
connectedCallback() {
|
|
122
|
+
super.connectedCallback();
|
|
123
|
+
// note that row elements can be reused with a different data object
|
|
124
|
+
// as the parent grid's repeat behavior reacts to changes in the data set.
|
|
125
|
+
if (this.cellsRepeatBehavior === null) {
|
|
126
|
+
this.cellsPlaceholder = document.createComment("");
|
|
127
|
+
this.appendChild(this.cellsPlaceholder);
|
|
128
|
+
this.updateItemTemplate();
|
|
129
|
+
this.cellsRepeatBehavior = new RepeatDirective(x => x.columnDefinitions, x => x.activeCellItemTemplate, { positioning: true }).createBehavior(this.cellsPlaceholder);
|
|
130
|
+
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
131
|
+
this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
|
|
132
|
+
}
|
|
133
|
+
this.addEventListener("cell-focused", this.handleCellFocus);
|
|
134
|
+
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
135
|
+
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
136
|
+
this.updateRowStyle();
|
|
137
|
+
if (this.refocusOnLoad) {
|
|
138
|
+
// if focus was on the row when data changed try to refocus on same cell
|
|
139
|
+
this.refocusOnLoad = false;
|
|
140
|
+
if (this.cellElements.length > this.focusColumnIndex) {
|
|
141
|
+
this.cellElements[this.focusColumnIndex].focus();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
disconnectedCallback() {
|
|
149
|
+
super.disconnectedCallback();
|
|
150
|
+
this.removeEventListener("cell-focused", this.handleCellFocus);
|
|
151
|
+
this.removeEventListener(eventFocusOut, this.handleFocusout);
|
|
152
|
+
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
153
|
+
}
|
|
154
|
+
handleFocusout(e) {
|
|
155
|
+
if (!this.contains(e.target)) {
|
|
156
|
+
this.isActiveRow = false;
|
|
157
|
+
this.focusColumnIndex = 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
handleCellFocus(e) {
|
|
161
|
+
this.isActiveRow = true;
|
|
162
|
+
this.focusColumnIndex = this.cellElements.indexOf(e.target);
|
|
163
|
+
this.$emit("row-focused", this);
|
|
164
|
+
}
|
|
165
|
+
handleKeydown(e) {
|
|
166
|
+
if (e.defaultPrevented) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
let newFocusColumnIndex = 0;
|
|
170
|
+
switch (e.key) {
|
|
171
|
+
case keyArrowLeft:
|
|
172
|
+
// focus left one cell
|
|
173
|
+
newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
|
|
174
|
+
this.cellElements[newFocusColumnIndex].focus();
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
break;
|
|
177
|
+
case keyArrowRight:
|
|
178
|
+
// focus right one cell
|
|
179
|
+
newFocusColumnIndex = Math.min(this.cellElements.length - 1, this.focusColumnIndex + 1);
|
|
180
|
+
this.cellElements[newFocusColumnIndex].focus();
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
break;
|
|
183
|
+
case keyHome:
|
|
184
|
+
if (!e.ctrlKey) {
|
|
185
|
+
this.cellElements[0].focus();
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
}
|
|
188
|
+
break;
|
|
189
|
+
case keyEnd:
|
|
190
|
+
if (!e.ctrlKey) {
|
|
191
|
+
// focus last cell of the row
|
|
192
|
+
this.cellElements[this.cellElements.length - 1].focus();
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
updateItemTemplate() {
|
|
199
|
+
this.activeCellItemTemplate =
|
|
200
|
+
this.rowType === DataGridRowTypes.default &&
|
|
201
|
+
this.cellItemTemplate !== undefined
|
|
202
|
+
? this.cellItemTemplate
|
|
203
|
+
: this.rowType === DataGridRowTypes.default &&
|
|
204
|
+
this.cellItemTemplate === undefined
|
|
205
|
+
? this.defaultCellItemTemplate
|
|
206
|
+
: this.headerCellItemTemplate !== undefined
|
|
207
|
+
? this.headerCellItemTemplate
|
|
208
|
+
: this.defaultHeaderCellItemTemplate;
|
|
68
209
|
}
|
|
69
|
-
}
|
|
70
|
-
close() {
|
|
71
|
-
if (__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).open) {
|
|
72
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).close();
|
|
73
|
-
this.$emit('close', this.returnValue, {
|
|
74
|
-
bubbles: false
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
this.open = false;
|
|
78
|
-
__classPrivateFieldGet(this, _Dialog_instances, "m", _Dialog_handleModal).call(this, false);
|
|
79
|
-
}
|
|
80
|
-
show() {
|
|
81
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).show();
|
|
82
|
-
this.open = true;
|
|
83
|
-
}
|
|
84
|
-
showModal() {
|
|
85
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).showModal();
|
|
86
|
-
this.open = true;
|
|
87
|
-
__classPrivateFieldGet(this, _Dialog_instances, "m", _Dialog_handleModal).call(this, true);
|
|
88
|
-
}
|
|
89
|
-
connectedCallback() {
|
|
90
|
-
super.connectedCallback();
|
|
91
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).addEventListener('click', __classPrivateFieldGet(this, _Dialog_handleScrimClick, "f"));
|
|
92
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).addEventListener('submit', __classPrivateFieldGet(this, _Dialog_handleInternalFormSubmit, "f"));
|
|
93
|
-
}
|
|
94
|
-
disconnectedCallback() {
|
|
95
|
-
super.disconnectedCallback();
|
|
96
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).removeEventListener('click', __classPrivateFieldGet(this, _Dialog_handleScrimClick, "f"));
|
|
97
|
-
__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).removeEventListener('submit', __classPrivateFieldGet(this, _Dialog_handleInternalFormSubmit, "f"));
|
|
98
|
-
}
|
|
99
210
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
211
|
+
__decorate([
|
|
212
|
+
attr({ attribute: "grid-template-columns" })
|
|
213
|
+
], DataGridRow$1.prototype, "gridTemplateColumns", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
attr({ attribute: "row-type" })
|
|
216
|
+
], DataGridRow$1.prototype, "rowType", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
observable
|
|
219
|
+
], DataGridRow$1.prototype, "rowData", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
observable
|
|
222
|
+
], DataGridRow$1.prototype, "columnDefinitions", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
observable
|
|
225
|
+
], DataGridRow$1.prototype, "cellItemTemplate", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
observable
|
|
228
|
+
], DataGridRow$1.prototype, "headerCellItemTemplate", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
observable
|
|
231
|
+
], DataGridRow$1.prototype, "rowIndex", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
observable
|
|
234
|
+
], DataGridRow$1.prototype, "isActiveRow", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
observable
|
|
237
|
+
], DataGridRow$1.prototype, "activeCellItemTemplate", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
observable
|
|
240
|
+
], DataGridRow$1.prototype, "defaultCellItemTemplate", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
observable
|
|
243
|
+
], DataGridRow$1.prototype, "defaultHeaderCellItemTemplate", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
observable
|
|
246
|
+
], DataGridRow$1.prototype, "cellElements", void 0);
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A Data Grid Custom HTML Element.
|
|
250
|
+
*
|
|
251
|
+
* @slot - The default slot for custom row elements
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
class DataGrid$1 extends FoundationElement {
|
|
255
|
+
constructor() {
|
|
256
|
+
super();
|
|
257
|
+
/**
|
|
258
|
+
* When true the component will not add itself to the tab queue.
|
|
259
|
+
* Default is false.
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
* @remarks
|
|
263
|
+
* HTML Attribute: no-tabbing
|
|
264
|
+
*/
|
|
265
|
+
this.noTabbing = false;
|
|
266
|
+
/**
|
|
267
|
+
* Whether the grid should automatically generate a header row and its type
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
* @remarks
|
|
271
|
+
* HTML Attribute: generate-header
|
|
272
|
+
*/
|
|
273
|
+
this.generateHeader = GenerateHeaderOptions.default;
|
|
274
|
+
/**
|
|
275
|
+
* The data being displayed in the grid
|
|
276
|
+
*
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
this.rowsData = [];
|
|
280
|
+
/**
|
|
281
|
+
* The column definitions of the grid
|
|
282
|
+
*
|
|
283
|
+
* @public
|
|
284
|
+
*/
|
|
285
|
+
this.columnDefinitions = null;
|
|
286
|
+
/**
|
|
287
|
+
* The index of the row that will receive focus the next time the
|
|
288
|
+
* grid is focused. This value changes as focus moves to different
|
|
289
|
+
* rows within the grid. Changing this value when focus is already
|
|
290
|
+
* within the grid moves focus to the specified row.
|
|
291
|
+
*
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
this.focusRowIndex = 0;
|
|
295
|
+
/**
|
|
296
|
+
* The index of the column that will receive focus the next time the
|
|
297
|
+
* grid is focused. This value changes as focus moves to different rows
|
|
298
|
+
* within the grid. Changing this value when focus is already within
|
|
299
|
+
* the grid moves focus to the specified column.
|
|
300
|
+
*
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
this.focusColumnIndex = 0;
|
|
304
|
+
this.rowsPlaceholder = null;
|
|
305
|
+
this.generatedHeader = null;
|
|
306
|
+
this.isUpdatingFocus = false;
|
|
307
|
+
this.pendingFocusUpdate = false;
|
|
308
|
+
this.rowindexUpdateQueued = false;
|
|
309
|
+
this.columnDefinitionsStale = true;
|
|
310
|
+
this.generatedGridTemplateColumns = "";
|
|
311
|
+
this.focusOnCell = (rowIndex, columnIndex, scrollIntoView) => {
|
|
312
|
+
if (this.rowElements.length === 0) {
|
|
313
|
+
this.focusRowIndex = 0;
|
|
314
|
+
this.focusColumnIndex = 0;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const focusRowIndex = Math.max(0, Math.min(this.rowElements.length - 1, rowIndex));
|
|
318
|
+
const focusRow = this.rowElements[focusRowIndex];
|
|
319
|
+
const cells = focusRow.querySelectorAll('[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"]');
|
|
320
|
+
const focusColumnIndex = Math.max(0, Math.min(cells.length - 1, columnIndex));
|
|
321
|
+
const focusTarget = cells[focusColumnIndex];
|
|
322
|
+
if (scrollIntoView &&
|
|
323
|
+
this.scrollHeight !== this.clientHeight &&
|
|
324
|
+
((focusRowIndex < this.focusRowIndex && this.scrollTop > 0) ||
|
|
325
|
+
(focusRowIndex > this.focusRowIndex &&
|
|
326
|
+
this.scrollTop < this.scrollHeight - this.clientHeight))) {
|
|
327
|
+
focusTarget.scrollIntoView({ block: "center", inline: "center" });
|
|
328
|
+
}
|
|
329
|
+
focusTarget.focus();
|
|
330
|
+
};
|
|
331
|
+
this.onChildListChange = (mutations,
|
|
332
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
333
|
+
observer) => {
|
|
334
|
+
if (mutations && mutations.length) {
|
|
335
|
+
mutations.forEach((mutation) => {
|
|
336
|
+
mutation.addedNodes.forEach((newNode) => {
|
|
337
|
+
if (newNode.nodeType === 1 &&
|
|
338
|
+
newNode.getAttribute("role") === "row") {
|
|
339
|
+
newNode.columnDefinitions = this.columnDefinitions;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
this.queueRowIndexUpdate();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
this.queueRowIndexUpdate = () => {
|
|
347
|
+
if (!this.rowindexUpdateQueued) {
|
|
348
|
+
this.rowindexUpdateQueued = true;
|
|
349
|
+
DOM.queueUpdate(this.updateRowIndexes);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
this.updateRowIndexes = () => {
|
|
353
|
+
let newGridTemplateColumns = this.gridTemplateColumns;
|
|
354
|
+
if (newGridTemplateColumns === undefined) {
|
|
355
|
+
// try to generate columns based on manual rows
|
|
356
|
+
if (this.generatedGridTemplateColumns === "" && this.rowElements.length > 0) {
|
|
357
|
+
const firstRow = this.rowElements[0];
|
|
358
|
+
this.generatedGridTemplateColumns = new Array(firstRow.cellElements.length)
|
|
359
|
+
.fill("1fr")
|
|
360
|
+
.join(" ");
|
|
361
|
+
}
|
|
362
|
+
newGridTemplateColumns = this.generatedGridTemplateColumns;
|
|
363
|
+
}
|
|
364
|
+
this.rowElements.forEach((element, index) => {
|
|
365
|
+
const thisRow = element;
|
|
366
|
+
thisRow.rowIndex = index;
|
|
367
|
+
thisRow.gridTemplateColumns = newGridTemplateColumns;
|
|
368
|
+
if (this.columnDefinitionsStale) {
|
|
369
|
+
thisRow.columnDefinitions = this.columnDefinitions;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
this.rowindexUpdateQueued = false;
|
|
373
|
+
this.columnDefinitionsStale = false;
|
|
374
|
+
};
|
|
108
375
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
376
|
+
/**
|
|
377
|
+
* generates a gridTemplateColumns based on columndata array
|
|
378
|
+
*/
|
|
379
|
+
static generateTemplateColumns(columnDefinitions) {
|
|
380
|
+
let templateColumns = "";
|
|
381
|
+
columnDefinitions.forEach((column) => {
|
|
382
|
+
templateColumns = `${templateColumns}${templateColumns === "" ? "" : " "}${"1fr"}`;
|
|
383
|
+
});
|
|
384
|
+
return templateColumns;
|
|
385
|
+
}
|
|
386
|
+
noTabbingChanged() {
|
|
387
|
+
if (this.$fastController.isConnected) {
|
|
388
|
+
if (this.noTabbing) {
|
|
389
|
+
this.setAttribute("tabIndex", "-1");
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
this.setAttribute("tabIndex", this.contains(document.activeElement) ||
|
|
393
|
+
this === document.activeElement
|
|
394
|
+
? "-1"
|
|
395
|
+
: "0");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
generateHeaderChanged() {
|
|
400
|
+
if (this.$fastController.isConnected) {
|
|
401
|
+
this.toggleGeneratedHeader();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
gridTemplateColumnsChanged() {
|
|
405
|
+
if (this.$fastController.isConnected) {
|
|
406
|
+
this.updateRowIndexes();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
rowsDataChanged() {
|
|
410
|
+
if (this.columnDefinitions === null && this.rowsData.length > 0) {
|
|
411
|
+
this.columnDefinitions = DataGrid$1.generateColumns(this.rowsData[0]);
|
|
412
|
+
}
|
|
413
|
+
if (this.$fastController.isConnected) {
|
|
414
|
+
this.toggleGeneratedHeader();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
columnDefinitionsChanged() {
|
|
418
|
+
if (this.columnDefinitions === null) {
|
|
419
|
+
this.generatedGridTemplateColumns = "";
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
this.generatedGridTemplateColumns = DataGrid$1.generateTemplateColumns(this.columnDefinitions);
|
|
423
|
+
if (this.$fastController.isConnected) {
|
|
424
|
+
this.columnDefinitionsStale = true;
|
|
425
|
+
this.queueRowIndexUpdate();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
headerCellItemTemplateChanged() {
|
|
429
|
+
if (this.$fastController.isConnected) {
|
|
430
|
+
if (this.generatedHeader !== null) {
|
|
431
|
+
this.generatedHeader.headerCellItemTemplate = this.headerCellItemTemplate;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
focusRowIndexChanged() {
|
|
436
|
+
if (this.$fastController.isConnected) {
|
|
437
|
+
this.queueFocusUpdate();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
focusColumnIndexChanged() {
|
|
441
|
+
if (this.$fastController.isConnected) {
|
|
442
|
+
this.queueFocusUpdate();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @internal
|
|
447
|
+
*/
|
|
448
|
+
connectedCallback() {
|
|
449
|
+
super.connectedCallback();
|
|
450
|
+
if (this.rowItemTemplate === undefined) {
|
|
451
|
+
this.rowItemTemplate = this.defaultRowItemTemplate;
|
|
452
|
+
}
|
|
453
|
+
this.rowsPlaceholder = document.createComment("");
|
|
454
|
+
this.appendChild(this.rowsPlaceholder);
|
|
455
|
+
this.toggleGeneratedHeader();
|
|
456
|
+
this.rowsRepeatBehavior = new RepeatDirective(x => x.rowsData, x => x.rowItemTemplate, { positioning: true }).createBehavior(this.rowsPlaceholder);
|
|
457
|
+
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
458
|
+
this.$fastController.addBehaviors([this.rowsRepeatBehavior]);
|
|
459
|
+
this.addEventListener("row-focused", this.handleRowFocus);
|
|
460
|
+
this.addEventListener(eventFocus, this.handleFocus);
|
|
461
|
+
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
462
|
+
this.addEventListener(eventFocusOut, this.handleFocusOut);
|
|
463
|
+
this.observer = new MutationObserver(this.onChildListChange);
|
|
464
|
+
// only observe if nodes are added or removed
|
|
465
|
+
this.observer.observe(this, { childList: true });
|
|
466
|
+
if (this.noTabbing) {
|
|
467
|
+
this.setAttribute("tabindex", "-1");
|
|
468
|
+
}
|
|
469
|
+
DOM.queueUpdate(this.queueRowIndexUpdate);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* @internal
|
|
473
|
+
*/
|
|
474
|
+
disconnectedCallback() {
|
|
475
|
+
super.disconnectedCallback();
|
|
476
|
+
this.removeEventListener("row-focused", this.handleRowFocus);
|
|
477
|
+
this.removeEventListener(eventFocus, this.handleFocus);
|
|
478
|
+
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
479
|
+
this.removeEventListener(eventFocusOut, this.handleFocusOut);
|
|
480
|
+
// disconnect observer
|
|
481
|
+
this.observer.disconnect();
|
|
482
|
+
this.rowsPlaceholder = null;
|
|
483
|
+
this.generatedHeader = null;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @internal
|
|
487
|
+
*/
|
|
488
|
+
handleRowFocus(e) {
|
|
489
|
+
this.isUpdatingFocus = true;
|
|
490
|
+
const focusRow = e.target;
|
|
491
|
+
this.focusRowIndex = this.rowElements.indexOf(focusRow);
|
|
492
|
+
this.focusColumnIndex = focusRow.focusColumnIndex;
|
|
493
|
+
this.setAttribute("tabIndex", "-1");
|
|
494
|
+
this.isUpdatingFocus = false;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* @internal
|
|
498
|
+
*/
|
|
499
|
+
handleFocus(e) {
|
|
500
|
+
this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* @internal
|
|
504
|
+
*/
|
|
505
|
+
handleFocusOut(e) {
|
|
506
|
+
if (e.relatedTarget === null || !this.contains(e.relatedTarget)) {
|
|
507
|
+
this.setAttribute("tabIndex", this.noTabbing ? "-1" : "0");
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* @internal
|
|
512
|
+
*/
|
|
513
|
+
handleKeydown(e) {
|
|
514
|
+
if (e.defaultPrevented) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
let newFocusRowIndex;
|
|
518
|
+
const maxIndex = this.rowElements.length - 1;
|
|
519
|
+
const currentGridBottom = this.offsetHeight + this.scrollTop;
|
|
520
|
+
const lastRow = this.rowElements[maxIndex];
|
|
521
|
+
switch (e.key) {
|
|
522
|
+
case keyArrowUp:
|
|
523
|
+
e.preventDefault();
|
|
524
|
+
// focus up one row
|
|
525
|
+
this.focusOnCell(this.focusRowIndex - 1, this.focusColumnIndex, true);
|
|
526
|
+
break;
|
|
527
|
+
case keyArrowDown:
|
|
528
|
+
e.preventDefault();
|
|
529
|
+
// focus down one row
|
|
530
|
+
this.focusOnCell(this.focusRowIndex + 1, this.focusColumnIndex, true);
|
|
531
|
+
break;
|
|
532
|
+
case keyPageUp:
|
|
533
|
+
e.preventDefault();
|
|
534
|
+
if (this.rowElements.length === 0) {
|
|
535
|
+
this.focusOnCell(0, 0, false);
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
if (this.focusRowIndex === 0) {
|
|
539
|
+
this.focusOnCell(0, this.focusColumnIndex, false);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
newFocusRowIndex = this.focusRowIndex - 1;
|
|
543
|
+
for (newFocusRowIndex; newFocusRowIndex >= 0; newFocusRowIndex--) {
|
|
544
|
+
const thisRow = this.rowElements[newFocusRowIndex];
|
|
545
|
+
if (thisRow.offsetTop < this.scrollTop) {
|
|
546
|
+
this.scrollTop =
|
|
547
|
+
thisRow.offsetTop + thisRow.clientHeight - this.clientHeight;
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
|
|
552
|
+
break;
|
|
553
|
+
case keyPageDown:
|
|
554
|
+
e.preventDefault();
|
|
555
|
+
if (this.rowElements.length === 0) {
|
|
556
|
+
this.focusOnCell(0, 0, false);
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
// focus down one "page"
|
|
560
|
+
if (this.focusRowIndex >= maxIndex ||
|
|
561
|
+
lastRow.offsetTop + lastRow.offsetHeight <= currentGridBottom) {
|
|
562
|
+
this.focusOnCell(maxIndex, this.focusColumnIndex, false);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
newFocusRowIndex = this.focusRowIndex + 1;
|
|
566
|
+
for (newFocusRowIndex; newFocusRowIndex <= maxIndex; newFocusRowIndex++) {
|
|
567
|
+
const thisRow = this.rowElements[newFocusRowIndex];
|
|
568
|
+
if (thisRow.offsetTop + thisRow.offsetHeight > currentGridBottom) {
|
|
569
|
+
let stickyHeaderOffset = 0;
|
|
570
|
+
if (this.generateHeader === GenerateHeaderOptions.sticky &&
|
|
571
|
+
this.generatedHeader !== null) {
|
|
572
|
+
stickyHeaderOffset = this.generatedHeader.clientHeight;
|
|
573
|
+
}
|
|
574
|
+
this.scrollTop = thisRow.offsetTop - stickyHeaderOffset;
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
|
|
579
|
+
break;
|
|
580
|
+
case keyHome:
|
|
581
|
+
if (e.ctrlKey) {
|
|
582
|
+
e.preventDefault();
|
|
583
|
+
// focus first cell of first row
|
|
584
|
+
this.focusOnCell(0, 0, true);
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
case keyEnd:
|
|
588
|
+
if (e.ctrlKey && this.columnDefinitions !== null) {
|
|
589
|
+
e.preventDefault();
|
|
590
|
+
// focus last cell of last row
|
|
591
|
+
this.focusOnCell(this.rowElements.length - 1, this.columnDefinitions.length - 1, true);
|
|
592
|
+
}
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
queueFocusUpdate() {
|
|
597
|
+
if (this.isUpdatingFocus &&
|
|
598
|
+
(this.contains(document.activeElement) || this === document.activeElement)) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (this.pendingFocusUpdate === false) {
|
|
602
|
+
this.pendingFocusUpdate = true;
|
|
603
|
+
DOM.queueUpdate(() => this.updateFocus());
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
updateFocus() {
|
|
607
|
+
this.pendingFocusUpdate = false;
|
|
608
|
+
this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
|
|
609
|
+
}
|
|
610
|
+
toggleGeneratedHeader() {
|
|
611
|
+
if (this.generatedHeader !== null) {
|
|
612
|
+
this.removeChild(this.generatedHeader);
|
|
613
|
+
this.generatedHeader = null;
|
|
614
|
+
}
|
|
615
|
+
if (this.generateHeader !== GenerateHeaderOptions.none &&
|
|
616
|
+
this.rowsData.length > 0) {
|
|
617
|
+
const generatedHeaderElement = document.createElement(this.rowElementTag);
|
|
618
|
+
this.generatedHeader = generatedHeaderElement;
|
|
619
|
+
this.generatedHeader.columnDefinitions = this.columnDefinitions;
|
|
620
|
+
this.generatedHeader.gridTemplateColumns = this.gridTemplateColumns;
|
|
621
|
+
this.generatedHeader.rowType =
|
|
622
|
+
this.generateHeader === GenerateHeaderOptions.sticky
|
|
623
|
+
? DataGridRowTypes.stickyHeader
|
|
624
|
+
: DataGridRowTypes.header;
|
|
625
|
+
if (this.firstChild !== null || this.rowsPlaceholder !== null) {
|
|
626
|
+
this.insertBefore(generatedHeaderElement, this.firstChild !== null ? this.firstChild : this.rowsPlaceholder);
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* generates a basic column definition by examining sample row data
|
|
634
|
+
*/
|
|
635
|
+
DataGrid$1.generateColumns = (row) => {
|
|
636
|
+
return Object.getOwnPropertyNames(row).map((property, index) => {
|
|
637
|
+
return {
|
|
638
|
+
columnDataKey: property,
|
|
639
|
+
gridColumn: `${index}`,
|
|
640
|
+
};
|
|
641
|
+
});
|
|
115
642
|
};
|
|
116
|
-
__decorate([
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
__decorate([
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
__decorate([
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
643
|
+
__decorate([
|
|
644
|
+
attr({ attribute: "no-tabbing", mode: "boolean" })
|
|
645
|
+
], DataGrid$1.prototype, "noTabbing", void 0);
|
|
646
|
+
__decorate([
|
|
647
|
+
attr({ attribute: "generate-header" })
|
|
648
|
+
], DataGrid$1.prototype, "generateHeader", void 0);
|
|
649
|
+
__decorate([
|
|
650
|
+
attr({ attribute: "grid-template-columns" })
|
|
651
|
+
], DataGrid$1.prototype, "gridTemplateColumns", void 0);
|
|
652
|
+
__decorate([
|
|
653
|
+
observable
|
|
654
|
+
], DataGrid$1.prototype, "rowsData", void 0);
|
|
655
|
+
__decorate([
|
|
656
|
+
observable
|
|
657
|
+
], DataGrid$1.prototype, "columnDefinitions", void 0);
|
|
658
|
+
__decorate([
|
|
659
|
+
observable
|
|
660
|
+
], DataGrid$1.prototype, "rowItemTemplate", void 0);
|
|
661
|
+
__decorate([
|
|
662
|
+
observable
|
|
663
|
+
], DataGrid$1.prototype, "cellItemTemplate", void 0);
|
|
664
|
+
__decorate([
|
|
665
|
+
observable
|
|
666
|
+
], DataGrid$1.prototype, "headerCellItemTemplate", void 0);
|
|
667
|
+
__decorate([
|
|
668
|
+
observable
|
|
669
|
+
], DataGrid$1.prototype, "focusRowIndex", void 0);
|
|
670
|
+
__decorate([
|
|
671
|
+
observable
|
|
672
|
+
], DataGrid$1.prototype, "focusColumnIndex", void 0);
|
|
673
|
+
__decorate([
|
|
674
|
+
observable
|
|
675
|
+
], DataGrid$1.prototype, "defaultRowItemTemplate", void 0);
|
|
676
|
+
__decorate([
|
|
677
|
+
observable
|
|
678
|
+
], DataGrid$1.prototype, "rowElementTag", void 0);
|
|
679
|
+
__decorate([
|
|
680
|
+
observable
|
|
681
|
+
], DataGrid$1.prototype, "rowElements", void 0);
|
|
140
682
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
683
|
+
const defaultCellContentsTemplate = html `
|
|
684
|
+
<template>
|
|
685
|
+
${x => x.rowData === null ||
|
|
686
|
+
x.columnDefinition === null ||
|
|
687
|
+
x.columnDefinition.columnDataKey === null
|
|
688
|
+
? null
|
|
689
|
+
: x.rowData[x.columnDefinition.columnDataKey]}
|
|
690
|
+
</template>
|
|
691
|
+
`;
|
|
692
|
+
const defaultHeaderCellContentsTemplate = html `
|
|
693
|
+
<template>
|
|
694
|
+
${x => x.columnDefinition === null
|
|
695
|
+
? null
|
|
696
|
+
: x.columnDefinition.title === undefined
|
|
697
|
+
? x.columnDefinition.columnDataKey
|
|
698
|
+
: x.columnDefinition.title}
|
|
699
|
+
</template>
|
|
700
|
+
`;
|
|
701
|
+
/**
|
|
702
|
+
* A Data Grid Cell Custom HTML Element.
|
|
703
|
+
*
|
|
704
|
+
* @fires cell-focused - Fires a custom 'cell-focused' event when focus is on the cell or its contents
|
|
705
|
+
* @slot - The default slot for cell contents. The "cell contents template" renders here.
|
|
706
|
+
* @public
|
|
707
|
+
*/
|
|
708
|
+
class DataGridCell$1 extends FoundationElement {
|
|
709
|
+
constructor() {
|
|
710
|
+
super(...arguments);
|
|
711
|
+
/**
|
|
712
|
+
* The type of cell
|
|
713
|
+
*
|
|
714
|
+
* @public
|
|
715
|
+
* @remarks
|
|
716
|
+
* HTML Attribute: cell-type
|
|
717
|
+
*/
|
|
718
|
+
this.cellType = DataGridCellTypes.default;
|
|
719
|
+
/**
|
|
720
|
+
* The base data for the parent row
|
|
721
|
+
*
|
|
722
|
+
* @public
|
|
723
|
+
*/
|
|
724
|
+
this.rowData = null;
|
|
725
|
+
/**
|
|
726
|
+
* The base data for the column
|
|
727
|
+
*
|
|
728
|
+
* @public
|
|
729
|
+
*/
|
|
730
|
+
this.columnDefinition = null;
|
|
731
|
+
this.isActiveCell = false;
|
|
732
|
+
this.customCellView = null;
|
|
733
|
+
this.updateCellStyle = () => {
|
|
734
|
+
this.style.gridColumn = this.gridColumn;
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
cellTypeChanged() {
|
|
738
|
+
if (this.$fastController.isConnected) {
|
|
739
|
+
this.updateCellView();
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
gridColumnChanged() {
|
|
743
|
+
if (this.$fastController.isConnected) {
|
|
744
|
+
this.updateCellStyle();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
columnDefinitionChanged(oldValue, newValue) {
|
|
748
|
+
if (this.$fastController.isConnected) {
|
|
749
|
+
this.updateCellView();
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* @internal
|
|
754
|
+
*/
|
|
755
|
+
connectedCallback() {
|
|
756
|
+
var _a;
|
|
757
|
+
super.connectedCallback();
|
|
758
|
+
this.addEventListener(eventFocusIn, this.handleFocusin);
|
|
759
|
+
this.addEventListener(eventFocusOut, this.handleFocusout);
|
|
760
|
+
this.addEventListener(eventKeyDown, this.handleKeydown);
|
|
761
|
+
this.style.gridColumn = `${((_a = this.columnDefinition) === null || _a === void 0 ? void 0 : _a.gridColumn) === undefined
|
|
762
|
+
? 0
|
|
763
|
+
: this.columnDefinition.gridColumn}`;
|
|
764
|
+
this.updateCellView();
|
|
765
|
+
this.updateCellStyle();
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* @internal
|
|
769
|
+
*/
|
|
770
|
+
disconnectedCallback() {
|
|
771
|
+
super.disconnectedCallback();
|
|
772
|
+
this.removeEventListener(eventFocusIn, this.handleFocusin);
|
|
773
|
+
this.removeEventListener(eventFocusOut, this.handleFocusout);
|
|
774
|
+
this.removeEventListener(eventKeyDown, this.handleKeydown);
|
|
775
|
+
this.disconnectCellView();
|
|
776
|
+
}
|
|
777
|
+
handleFocusin(e) {
|
|
778
|
+
if (this.isActiveCell) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
this.isActiveCell = true;
|
|
782
|
+
switch (this.cellType) {
|
|
783
|
+
case DataGridCellTypes.columnHeader:
|
|
784
|
+
if (this.columnDefinition !== null &&
|
|
785
|
+
this.columnDefinition.headerCellInternalFocusQueue !== true &&
|
|
786
|
+
typeof this.columnDefinition.headerCellFocusTargetCallback ===
|
|
787
|
+
"function") {
|
|
788
|
+
// move focus to the focus target
|
|
789
|
+
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
790
|
+
if (focusTarget !== null) {
|
|
791
|
+
focusTarget.focus();
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
break;
|
|
795
|
+
default:
|
|
796
|
+
if (this.columnDefinition !== null &&
|
|
797
|
+
this.columnDefinition.cellInternalFocusQueue !== true &&
|
|
798
|
+
typeof this.columnDefinition.cellFocusTargetCallback === "function") {
|
|
799
|
+
// move focus to the focus target
|
|
800
|
+
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
801
|
+
if (focusTarget !== null) {
|
|
802
|
+
focusTarget.focus();
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
this.$emit("cell-focused", this);
|
|
808
|
+
}
|
|
809
|
+
handleFocusout(e) {
|
|
810
|
+
if (this !== document.activeElement && !this.contains(document.activeElement)) {
|
|
811
|
+
this.isActiveCell = false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
handleKeydown(e) {
|
|
815
|
+
if (e.defaultPrevented ||
|
|
816
|
+
this.columnDefinition === null ||
|
|
817
|
+
(this.cellType === DataGridCellTypes.default &&
|
|
818
|
+
this.columnDefinition.cellInternalFocusQueue !== true) ||
|
|
819
|
+
(this.cellType === DataGridCellTypes.columnHeader &&
|
|
820
|
+
this.columnDefinition.headerCellInternalFocusQueue !== true)) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
switch (e.key) {
|
|
824
|
+
case keyEnter:
|
|
825
|
+
case keyFunction2:
|
|
826
|
+
if (this.contains(document.activeElement) &&
|
|
827
|
+
document.activeElement !== this) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
switch (this.cellType) {
|
|
831
|
+
case DataGridCellTypes.columnHeader:
|
|
832
|
+
if (this.columnDefinition.headerCellFocusTargetCallback !==
|
|
833
|
+
undefined) {
|
|
834
|
+
const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
|
|
835
|
+
if (focusTarget !== null) {
|
|
836
|
+
focusTarget.focus();
|
|
837
|
+
}
|
|
838
|
+
e.preventDefault();
|
|
839
|
+
}
|
|
840
|
+
break;
|
|
841
|
+
default:
|
|
842
|
+
if (this.columnDefinition.cellFocusTargetCallback !== undefined) {
|
|
843
|
+
const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
|
|
844
|
+
if (focusTarget !== null) {
|
|
845
|
+
focusTarget.focus();
|
|
846
|
+
}
|
|
847
|
+
e.preventDefault();
|
|
848
|
+
}
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
break;
|
|
852
|
+
case keyEscape:
|
|
853
|
+
if (this.contains(document.activeElement) &&
|
|
854
|
+
document.activeElement !== this) {
|
|
855
|
+
this.focus();
|
|
856
|
+
e.preventDefault();
|
|
857
|
+
}
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
updateCellView() {
|
|
862
|
+
this.disconnectCellView();
|
|
863
|
+
if (this.columnDefinition === null) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
switch (this.cellType) {
|
|
867
|
+
case DataGridCellTypes.columnHeader:
|
|
868
|
+
if (this.columnDefinition.headerCellTemplate !== undefined) {
|
|
869
|
+
this.customCellView = this.columnDefinition.headerCellTemplate.render(this, this);
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
this.customCellView = defaultHeaderCellContentsTemplate.render(this, this);
|
|
873
|
+
}
|
|
874
|
+
break;
|
|
875
|
+
case undefined:
|
|
876
|
+
case DataGridCellTypes.rowHeader:
|
|
877
|
+
case DataGridCellTypes.default:
|
|
878
|
+
if (this.columnDefinition.cellTemplate !== undefined) {
|
|
879
|
+
this.customCellView = this.columnDefinition.cellTemplate.render(this, this);
|
|
880
|
+
}
|
|
881
|
+
else {
|
|
882
|
+
this.customCellView = defaultCellContentsTemplate.render(this, this);
|
|
883
|
+
}
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
disconnectCellView() {
|
|
888
|
+
if (this.customCellView !== null) {
|
|
889
|
+
this.customCellView.dispose();
|
|
890
|
+
this.customCellView = null;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
156
893
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
894
|
+
__decorate([
|
|
895
|
+
attr({ attribute: "cell-type" })
|
|
896
|
+
], DataGridCell$1.prototype, "cellType", void 0);
|
|
897
|
+
__decorate([
|
|
898
|
+
attr({ attribute: "grid-column" })
|
|
899
|
+
], DataGridCell$1.prototype, "gridColumn", void 0);
|
|
900
|
+
__decorate([
|
|
901
|
+
observable
|
|
902
|
+
], DataGridCell$1.prototype, "rowData", void 0);
|
|
903
|
+
__decorate([
|
|
904
|
+
observable
|
|
905
|
+
], DataGridCell$1.prototype, "columnDefinition", void 0);
|
|
906
|
+
|
|
907
|
+
var css_248z$2 = ":host {\n position: relative;\n display: block;\n}\n\n:host([generate-header=sticky]) {\n max-height: var(--data-grid-max-height, 200px);\n overflow-y: auto;\n}";
|
|
908
|
+
|
|
909
|
+
var css_248z$1 = "/**\n * Do not edit directly\n * Generated on Mon, 03 Apr 2023 14:02:24 GMT\n */\n:host {\n display: grid;\n width: 100%;\n box-sizing: border-box;\n color: var(--vvd-color-canvas-text);\n}\n\n:host([row-type=sticky-header]) {\n position: sticky;\n z-index: 999;\n top: 0;\n background: var(--vvd-color-canvas);\n}";
|
|
910
|
+
|
|
911
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 03 Apr 2023 14:02:24 GMT\n */\n:host {\n position: relative;\n display: flex;\n overflow: hidden;\n box-sizing: border-box;\n align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid var(--vvd-color-neutral-100);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) + 8));\n color: var(--vvd-color-canvas-text);\n font: var(--vvd-typography-base);\n outline: none;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n:host([cell-type=columnheader]) {\n border-color: currentColor;\n font: var(--vvd-typography-base-bold);\n}\n\n.focus-indicator {\n --focus-stroke-gap-color: transparent;\n pointer-events: none;\n}\n#focus-wrapper:not(.active) > .focus-indicator {\n display: none;\n}";
|
|
912
|
+
|
|
913
|
+
class DataGrid extends DataGrid$1 {}
|
|
914
|
+
__decorate([attr({
|
|
915
|
+
attribute: 'selection-mode'
|
|
916
|
+
}), __metadata("design:type", String)], DataGrid.prototype, "selectionMode", void 0);
|
|
917
|
+
|
|
918
|
+
class DataGridRow extends DataGridRow$1 {}
|
|
919
|
+
|
|
920
|
+
let _2$1 = t => t,
|
|
921
|
+
_t$2,
|
|
922
|
+
_t2$1;
|
|
923
|
+
function createRowItemTemplate(context) {
|
|
924
|
+
const rowTag = context.tagFor(DataGridRow);
|
|
925
|
+
return html(_t$2 || (_t$2 = _2$1`
|
|
926
|
+
<${0}
|
|
927
|
+
:rowData="${0}"
|
|
928
|
+
:cellItemTemplate="${0}"
|
|
929
|
+
:headerCellItemTemplate="${0}"
|
|
930
|
+
></${0}>
|
|
931
|
+
`), rowTag, x => x, (_, c) => c.parent.cellItemTemplate, (_, c) => c.parent.headerCellItemTemplate, rowTag);
|
|
163
932
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
933
|
+
const DataGridTemplate = context => {
|
|
934
|
+
const rowItemTemplate = createRowItemTemplate(context);
|
|
935
|
+
const rowTag = context.tagFor(DataGridRow);
|
|
936
|
+
return html(_t2$1 || (_t2$1 = _2$1`
|
|
937
|
+
<template
|
|
938
|
+
role="grid"
|
|
939
|
+
tabindex="0"
|
|
940
|
+
:rowElementTag="${0}"
|
|
941
|
+
:defaultRowItemTemplate="${0}"
|
|
942
|
+
${0}
|
|
943
|
+
>
|
|
944
|
+
<slot></slot>
|
|
945
|
+
</template>
|
|
946
|
+
`), () => rowTag, rowItemTemplate, children({
|
|
947
|
+
property: 'rowElements',
|
|
948
|
+
filter: elements('[role=row]')
|
|
949
|
+
}));
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
class DataGridCell extends DataGridCell$1 {
|
|
953
|
+
handleFocusin(e) {
|
|
954
|
+
super.handleFocusin(e);
|
|
955
|
+
this.shadowRoot.getElementById('focus-wrapper').classList.add('active');
|
|
956
|
+
}
|
|
957
|
+
handleFocusout(e) {
|
|
958
|
+
super.handleFocusout(e);
|
|
959
|
+
this.shadowRoot.getElementById('focus-wrapper').classList.remove('active');
|
|
960
|
+
}
|
|
170
961
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
962
|
+
|
|
963
|
+
let _2 = t => t,
|
|
964
|
+
_t$1,
|
|
965
|
+
_t2,
|
|
966
|
+
_t3;
|
|
967
|
+
function createCellItemTemplate(context) {
|
|
968
|
+
const cellTag = context.tagFor(DataGridCell);
|
|
969
|
+
return html(_t$1 || (_t$1 = _2`
|
|
970
|
+
<${0}
|
|
971
|
+
cell-type="${0}"
|
|
972
|
+
grid-column="${0}"
|
|
973
|
+
:rowData="${0}"
|
|
974
|
+
:columnDefinition="${0}"
|
|
975
|
+
></${0}>
|
|
976
|
+
`), cellTag, x => x.isRowHeader ? 'rowheader' : undefined, (_, c) => c.index + 1, (_, c) => c.parent.rowData, x => x, cellTag);
|
|
181
977
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
978
|
+
function createHeaderCellItemTemplate(context) {
|
|
979
|
+
const cellTag = context.tagFor(DataGridCell);
|
|
980
|
+
return html(_t2 || (_t2 = _2`
|
|
981
|
+
<${0}
|
|
982
|
+
cell-type="columnheader"
|
|
983
|
+
grid-column="${0}"
|
|
984
|
+
:columnDefinition="${0}"
|
|
985
|
+
></${0}>
|
|
986
|
+
`), cellTag, (_, c) => c.index + 1, x => x, cellTag);
|
|
187
987
|
}
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
988
|
+
const DataGridRowTemplate = context => {
|
|
989
|
+
const cellItemTemplate = createCellItemTemplate(context);
|
|
990
|
+
const headerCellItemTemplate = createHeaderCellItemTemplate(context);
|
|
991
|
+
return html(_t3 || (_t3 = _2`
|
|
992
|
+
<template
|
|
993
|
+
role="row"
|
|
994
|
+
class="${0}"
|
|
995
|
+
:defaultCellItemTemplate="${0}"
|
|
996
|
+
:defaultHeaderCellItemTemplate="${0}"
|
|
997
|
+
${0}
|
|
998
|
+
>
|
|
999
|
+
<slot ${0}></slot>
|
|
1000
|
+
</template>
|
|
1001
|
+
`), x => x.rowType !== 'default' ? x.rowType : '', cellItemTemplate, headerCellItemTemplate, children({
|
|
1002
|
+
property: 'cellElements',
|
|
1003
|
+
filter: elements('[role="cell"],[role="gridcell"],[role="columnheader"],[role="rowheader"]')
|
|
1004
|
+
}), slotted('slottedCellElements'));
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
const DataGridCellRole = {
|
|
1008
|
+
columnheader: 'columnheader',
|
|
1009
|
+
rowheader: 'rowheader',
|
|
1010
|
+
default: 'gridcell'
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
let _ = t => t,
|
|
1014
|
+
_t;
|
|
1015
|
+
function DataGridCellTemplate(context) {
|
|
1016
|
+
const focusTemplate = focusTemplateFactory(context);
|
|
1017
|
+
return html(_t || (_t = _`
|
|
1018
|
+
<template
|
|
1019
|
+
tabindex="-1"
|
|
1020
|
+
role="${0}"
|
|
1021
|
+
>
|
|
1022
|
+
<div id="focus-wrapper">
|
|
1023
|
+
<slot></slot>
|
|
1024
|
+
${0}
|
|
216
1025
|
</div>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
</${0}>`), elevationTag, getClasses, (x, c) => handleEscapeKey(x, c.event), x => x.returnValue, x => x.ariaLabelledBy, x => x.ariaLabel, x => x.ariaDescribedBy, x => x.subtitle ? 'border' : '', when(x => x.icon, icon(iconTag)), when(x => x.headline, headline()), when(x => x.subtitle, subtitle()), renderDismissButton(buttonTag), x => {
|
|
221
|
-
var _a;
|
|
222
|
-
return ((_a = x.bodySlottedContent) === null || _a === void 0 ? void 0 : _a.length) ? '' : 'hide';
|
|
223
|
-
}, x => x.fullWidthBody ? 'full-width' : '', slotted('bodySlottedContent'), x => {
|
|
1026
|
+
|
|
1027
|
+
</template>
|
|
1028
|
+
`), x => {
|
|
224
1029
|
var _a;
|
|
225
|
-
return (
|
|
226
|
-
},
|
|
227
|
-
}
|
|
1030
|
+
return (_a = DataGridCellRole[x.cellType]) !== null && _a !== void 0 ? _a : DataGridCellRole.default;
|
|
1031
|
+
}, () => focusTemplate);
|
|
1032
|
+
}
|
|
228
1033
|
|
|
229
|
-
const
|
|
230
|
-
baseName: '
|
|
231
|
-
template:
|
|
232
|
-
styles:
|
|
233
|
-
});
|
|
234
|
-
const
|
|
235
|
-
|
|
1034
|
+
const dataGrid = DataGrid.compose({
|
|
1035
|
+
baseName: 'data-grid',
|
|
1036
|
+
template: DataGridTemplate,
|
|
1037
|
+
styles: css_248z$2
|
|
1038
|
+
})();
|
|
1039
|
+
const dataGridRow = DataGridRow.compose({
|
|
1040
|
+
baseName: 'data-grid-row',
|
|
1041
|
+
template: DataGridRowTemplate,
|
|
1042
|
+
styles: css_248z$1
|
|
1043
|
+
})();
|
|
1044
|
+
const dataGridCell = DataGridCell.compose({
|
|
1045
|
+
baseName: 'data-grid-cell',
|
|
1046
|
+
template: DataGridCellTemplate,
|
|
1047
|
+
styles: css_248z
|
|
1048
|
+
})();
|
|
1049
|
+
const dataGridElements = [dataGridCell, dataGridRow, dataGrid];
|
|
1050
|
+
const registerDataGrid = registerFactory(dataGridElements);
|
|
236
1051
|
|
|
237
|
-
export {
|
|
1052
|
+
export { dataGridRow as a, dataGridCell as b, dataGridElements as c, dataGrid as d, registerDataGrid as r };
|