@vaadin/vaadin-grid 22.0.0-alpha6 → 22.0.0-beta1

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.
Files changed (84) hide show
  1. package/package.json +24 -34
  2. package/src/vaadin-grid-column-group.d.ts +14 -57
  3. package/src/vaadin-grid-column-group.js +4 -311
  4. package/src/vaadin-grid-column.d.ts +14 -142
  5. package/src/vaadin-grid-column.js +4 -759
  6. package/src/vaadin-grid-filter-column.d.ts +14 -30
  7. package/src/vaadin-grid-filter-column.js +4 -111
  8. package/src/vaadin-grid-filter.d.ts +11 -60
  9. package/src/vaadin-grid-filter.js +4 -116
  10. package/src/vaadin-grid-selection-column.d.ts +12 -75
  11. package/src/vaadin-grid-selection-column.js +4 -276
  12. package/src/vaadin-grid-sort-column.d.ts +12 -56
  13. package/src/vaadin-grid-sort-column.js +4 -109
  14. package/src/vaadin-grid-sorter.d.ts +11 -82
  15. package/src/vaadin-grid-sorter.js +4 -221
  16. package/src/vaadin-grid-tree-column.d.ts +14 -31
  17. package/src/vaadin-grid-tree-column.js +4 -110
  18. package/src/vaadin-grid-tree-toggle.d.ts +11 -91
  19. package/src/vaadin-grid-tree-toggle.js +4 -196
  20. package/src/vaadin-grid.d.ts +10 -422
  21. package/src/vaadin-grid.js +4 -1026
  22. package/theme/lumo/vaadin-grid-column-group.js +1 -1
  23. package/theme/lumo/vaadin-grid-column.js +1 -1
  24. package/theme/lumo/vaadin-grid-filter-column.js +1 -2
  25. package/theme/lumo/vaadin-grid-filter.js +1 -2
  26. package/theme/lumo/vaadin-grid-selection-column.js +1 -2
  27. package/theme/lumo/vaadin-grid-sort-column.js +1 -2
  28. package/theme/lumo/vaadin-grid-sorter.js +1 -2
  29. package/theme/lumo/vaadin-grid-tree-column.js +1 -2
  30. package/theme/lumo/vaadin-grid-tree-toggle.js +1 -2
  31. package/theme/lumo/vaadin-grid.js +1 -9
  32. package/theme/material/vaadin-grid-column-group.js +1 -1
  33. package/theme/material/vaadin-grid-column.js +1 -1
  34. package/theme/material/vaadin-grid-filter-column.js +1 -2
  35. package/theme/material/vaadin-grid-filter.js +1 -2
  36. package/theme/material/vaadin-grid-selection-column.js +1 -2
  37. package/theme/material/vaadin-grid-sort-column.js +1 -2
  38. package/theme/material/vaadin-grid-sorter.js +1 -2
  39. package/theme/material/vaadin-grid-tree-column.js +1 -2
  40. package/theme/material/vaadin-grid-tree-toggle.js +1 -2
  41. package/theme/material/vaadin-grid.js +1 -2
  42. package/vaadin-grid.d.ts +0 -1
  43. package/src/array-data-provider.js +0 -145
  44. package/src/interfaces.d.ts +0 -78
  45. package/src/vaadin-grid-a11y-mixin.d.ts +0 -27
  46. package/src/vaadin-grid-a11y-mixin.js +0 -158
  47. package/src/vaadin-grid-active-item-mixin.d.ts +0 -28
  48. package/src/vaadin-grid-active-item-mixin.js +0 -117
  49. package/src/vaadin-grid-array-data-provider-mixin.d.ts +0 -20
  50. package/src/vaadin-grid-array-data-provider-mixin.js +0 -75
  51. package/src/vaadin-grid-column-reordering-mixin.d.ts +0 -47
  52. package/src/vaadin-grid-column-reordering-mixin.js +0 -387
  53. package/src/vaadin-grid-column-resizing-mixin.d.ts +0 -11
  54. package/src/vaadin-grid-column-resizing-mixin.js +0 -111
  55. package/src/vaadin-grid-data-provider-mixin.d.ts +0 -126
  56. package/src/vaadin-grid-data-provider-mixin.js +0 -520
  57. package/src/vaadin-grid-drag-and-drop-mixin.d.ts +0 -73
  58. package/src/vaadin-grid-drag-and-drop-mixin.js +0 -435
  59. package/src/vaadin-grid-dynamic-columns-mixin.d.ts +0 -27
  60. package/src/vaadin-grid-dynamic-columns-mixin.js +0 -180
  61. package/src/vaadin-grid-event-context-mixin.d.ts +0 -33
  62. package/src/vaadin-grid-event-context-mixin.js +0 -57
  63. package/src/vaadin-grid-filter-mixin.d.ts +0 -13
  64. package/src/vaadin-grid-filter-mixin.js +0 -76
  65. package/src/vaadin-grid-helpers.js +0 -23
  66. package/src/vaadin-grid-keyboard-navigation-mixin.d.ts +0 -31
  67. package/src/vaadin-grid-keyboard-navigation-mixin.js +0 -891
  68. package/src/vaadin-grid-row-details-mixin.d.ts +0 -54
  69. package/src/vaadin-grid-row-details-mixin.js +0 -200
  70. package/src/vaadin-grid-scroll-mixin.d.ts +0 -22
  71. package/src/vaadin-grid-scroll-mixin.js +0 -202
  72. package/src/vaadin-grid-selection-mixin.d.ts +0 -39
  73. package/src/vaadin-grid-selection-mixin.js +0 -93
  74. package/src/vaadin-grid-sort-mixin.d.ts +0 -21
  75. package/src/vaadin-grid-sort-mixin.js +0 -139
  76. package/src/vaadin-grid-styles.js +0 -297
  77. package/src/vaadin-grid-styling-mixin.d.ts +0 -37
  78. package/src/vaadin-grid-styling-mixin.js +0 -71
  79. package/theme/lumo/vaadin-grid-sorter-styles.js +0 -54
  80. package/theme/lumo/vaadin-grid-styles.js +0 -380
  81. package/theme/lumo/vaadin-grid-tree-toggle-styles.js +0 -112
  82. package/theme/material/vaadin-grid-sorter-styles.js +0 -72
  83. package/theme/material/vaadin-grid-styles.js +0 -252
  84. package/theme/material/vaadin-grid-tree-toggle-styles.js +0 -42
@@ -3,766 +3,11 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { PolymerElement } from '@polymer/polymer/polymer-element.js';
7
- import { DirMixin } from '@vaadin/vaadin-element-mixin/vaadin-dir-mixin.js';
8
- import { processTemplates } from '@vaadin/vaadin-element-mixin/templates.js';
9
- import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js';
10
- import { animationFrame } from '@polymer/polymer/lib/utils/async.js';
6
+ import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
11
7
 
12
8
  /**
13
- * @polymerMixin
9
+ * @deprecated Import `GridColumn` from `@vaadin/grid/vaadin-grid-column` instead.
14
10
  */
15
- export const ColumnBaseMixin = (superClass) =>
16
- class ColumnBaseMixin extends superClass {
17
- static get properties() {
18
- return {
19
- /**
20
- * When set to true, the column is user-resizable.
21
- * @default false
22
- */
23
- resizable: {
24
- type: Boolean,
25
- value: function () {
26
- if (this.localName === 'vaadin-grid-column-group') {
27
- return;
28
- }
11
+ export const GridColumnElement = GridColumn;
29
12
 
30
- const parent = this.parentNode;
31
- if (parent && parent.localName === 'vaadin-grid-column-group') {
32
- return parent.resizable || false;
33
- } else {
34
- return false;
35
- }
36
- }
37
- },
38
-
39
- /**
40
- * When true, the column is frozen. When a column inside of a column group is frozen,
41
- * all of the sibling columns inside the group will get frozen also.
42
- * @type {boolean}
43
- */
44
- frozen: {
45
- type: Boolean,
46
- value: false
47
- },
48
-
49
- /**
50
- * When set to true, the cells for this column are hidden.
51
- */
52
- hidden: {
53
- type: Boolean,
54
- value: false
55
- },
56
-
57
- /**
58
- * Text content to display in the header cell of the column.
59
- */
60
- header: {
61
- type: String
62
- },
63
-
64
- /**
65
- * Aligns the columns cell content horizontally.
66
- * Supported values: "start", "center" and "end".
67
- * @attr {start|center|end} text-align
68
- * @type {GridColumnTextAlign | null | undefined}
69
- */
70
- textAlign: {
71
- type: String
72
- },
73
-
74
- /**
75
- * @type {boolean}
76
- * @protected
77
- */
78
- _lastFrozen: {
79
- type: Boolean,
80
- value: false
81
- },
82
-
83
- /** @protected */
84
- _order: Number,
85
-
86
- /** @private */
87
- _reorderStatus: Boolean,
88
-
89
- /**
90
- * @type {Array<!HTMLElement>}
91
- * @protected
92
- */
93
- _emptyCells: Array,
94
-
95
- /** @private */
96
- _headerCell: Object,
97
-
98
- /** @private */
99
- _footerCell: Object,
100
-
101
- /** @protected */
102
- _grid: Object,
103
-
104
- /**
105
- * By default, the Polymer doesn't invoke the observer
106
- * during initialization if all of its dependencies are `undefined`.
107
- * This internal property can be used to force initial invocation of an observer
108
- * even the other dependencies of the observer are `undefined`.
109
- *
110
- * @private
111
- */
112
- __initialized: {
113
- type: Boolean,
114
- value: true
115
- },
116
-
117
- /**
118
- * Custom function for rendering the header content.
119
- * Receives two arguments:
120
- *
121
- * - `root` The header cell content DOM element. Append your content to it.
122
- * - `column` The `<vaadin-grid-column>` element.
123
- *
124
- * @type {GridHeaderFooterRenderer | null | undefined}
125
- */
126
- headerRenderer: Function,
127
-
128
- /**
129
- * Represents the final header renderer computed on the set of observable arguments.
130
- * It is supposed to be used internally when rendering the header cell content.
131
- *
132
- * @protected
133
- * @type {GridHeaderFooterRenderer | undefined}
134
- */
135
- _headerRenderer: {
136
- type: Function,
137
- computed: '_computeHeaderRenderer(headerRenderer, header, __initialized)'
138
- },
139
-
140
- /**
141
- * Custom function for rendering the footer content.
142
- * Receives two arguments:
143
- *
144
- * - `root` The footer cell content DOM element. Append your content to it.
145
- * - `column` The `<vaadin-grid-column>` element.
146
- *
147
- * @type {GridHeaderFooterRenderer | null | undefined}
148
- */
149
- footerRenderer: Function,
150
-
151
- /**
152
- * Represents the final footer renderer computed on the set of observable arguments.
153
- * It is supposed to be used internally when rendering the footer cell content.
154
- *
155
- * @protected
156
- * @type {GridHeaderFooterRenderer | undefined}
157
- */
158
- _footerRenderer: {
159
- type: Function,
160
- computed: '_computeFooterRenderer(footerRenderer, __initialized)'
161
- },
162
-
163
- /**
164
- * An internal property that is mainly used by `vaadin-template-renderer`
165
- * to identify grid column elements.
166
- *
167
- * @private
168
- */
169
- __gridColumnElement: {
170
- type: Boolean,
171
- value: true
172
- }
173
- };
174
- }
175
-
176
- static get observers() {
177
- return [
178
- '_widthChanged(width, _headerCell, _footerCell, _cells.*)',
179
- '_frozenChanged(frozen, _headerCell, _footerCell, _cells.*)',
180
- '_flexGrowChanged(flexGrow, _headerCell, _footerCell, _cells.*)',
181
- '_textAlignChanged(textAlign, _cells.*, _headerCell, _footerCell)',
182
- '_orderChanged(_order, _headerCell, _footerCell, _cells.*)',
183
- '_lastFrozenChanged(_lastFrozen)',
184
- '_onRendererOrBindingChanged(_renderer, _cells, _cells.*, path)',
185
- '_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header)',
186
- '_onFooterRendererOrBindingChanged(_footerRenderer, _footerCell)',
187
- '_resizableChanged(resizable, _headerCell)',
188
- '_reorderStatusChanged(_reorderStatus, _headerCell, _footerCell, _cells.*)',
189
- '_hiddenChanged(hidden, _headerCell, _footerCell, _cells.*)'
190
- ];
191
- }
192
-
193
- /** @protected */
194
- connectedCallback() {
195
- super.connectedCallback();
196
-
197
- // Adds the column cells to the grid after the column is attached
198
- requestAnimationFrame(() => {
199
- // Skip if the column has been detached
200
- if (!this._grid) return;
201
-
202
- this._allCells.forEach((cell) => {
203
- if (!cell._content.parentNode) {
204
- this._grid.appendChild(cell._content);
205
- }
206
- });
207
- });
208
- }
209
-
210
- /** @protected */
211
- disconnectedCallback() {
212
- super.disconnectedCallback();
213
-
214
- // Removes the column cells from the grid after the column is detached
215
- requestAnimationFrame(() => {
216
- // Skip if the column has been attached again
217
- if (this._grid) return;
218
-
219
- this._allCells.forEach((cell) => {
220
- if (cell._content.parentNode) {
221
- cell._content.parentNode.removeChild(cell._content);
222
- }
223
- });
224
- });
225
-
226
- this._gridValue = undefined;
227
- }
228
-
229
- /** @protected */
230
- ready() {
231
- super.ready();
232
-
233
- processTemplates(this);
234
- }
235
-
236
- /**
237
- * @return {!GridElement | undefined}
238
- * @protected
239
- */
240
- _findHostGrid() {
241
- // eslint-disable-next-line @typescript-eslint/no-this-alias
242
- let el = this;
243
- // Custom elements extending grid must have a specific localName
244
- while (el && !/^vaadin.*grid(-pro)?$/.test(el.localName)) {
245
- el = el.assignedSlot ? el.assignedSlot.parentNode : el.parentNode;
246
- }
247
- return el || undefined;
248
- }
249
-
250
- /**
251
- * @return {!GridElement | undefined}
252
- * @protected
253
- */
254
- get _grid() {
255
- if (!this._gridValue) {
256
- this._gridValue = this._findHostGrid();
257
- }
258
- return this._gridValue;
259
- }
260
-
261
- /**
262
- * @return {!Array<!HTMLElement>}
263
- * @protected
264
- */
265
- get _allCells() {
266
- return []
267
- .concat(this._cells || [])
268
- .concat(this._emptyCells || [])
269
- .concat(this._headerCell)
270
- .concat(this._footerCell)
271
- .filter((cell) => cell);
272
- }
273
-
274
- /** @protected */
275
- _renderHeaderAndFooter() {
276
- this._renderHeaderCellContent(this._headerRenderer, this._headerCell);
277
- this._renderFooterCellContent(this._footerRenderer, this._footerCell);
278
- }
279
-
280
- /** @private */
281
- _flexGrowChanged(flexGrow) {
282
- if (this.parentElement && this.parentElement._columnPropChanged) {
283
- this.parentElement._columnPropChanged('flexGrow');
284
- }
285
-
286
- this._allCells.forEach((cell) => (cell.style.flexGrow = flexGrow));
287
- }
288
-
289
- /** @private */
290
- _orderChanged(order) {
291
- this._allCells.forEach((cell) => (cell.style.order = order));
292
- }
293
-
294
- /** @private */
295
- _widthChanged(width) {
296
- if (this.parentElement && this.parentElement._columnPropChanged) {
297
- this.parentElement._columnPropChanged('width');
298
- }
299
-
300
- this._allCells.forEach((cell) => (cell.style.width = width));
301
-
302
- // Force a reflow to workaround browser issues causing double scrollbars to grid
303
- // https://github.com/vaadin/vaadin-grid/issues/1586
304
- if (this._grid && this._grid.__forceReflow) {
305
- this._grid.__forceReflow();
306
- }
307
- }
308
-
309
- /** @private */
310
- _frozenChanged(frozen) {
311
- if (this.parentElement && this.parentElement._columnPropChanged) {
312
- this.parentElement._columnPropChanged('frozen', frozen);
313
- }
314
-
315
- this._allCells.forEach((cell) => this._toggleAttribute('frozen', frozen, cell));
316
-
317
- this._grid && this._grid._frozenCellsChanged && this._grid._frozenCellsChanged();
318
- }
319
-
320
- /** @private */
321
- _lastFrozenChanged(lastFrozen) {
322
- this._allCells.forEach((cell) => this._toggleAttribute('last-frozen', lastFrozen, cell));
323
-
324
- if (this.parentElement && this.parentElement._columnPropChanged) {
325
- this.parentElement._lastFrozen = lastFrozen;
326
- }
327
- }
328
-
329
- /**
330
- * @param {string} path
331
- * @return {string}
332
- * @protected
333
- */
334
- _generateHeader(path) {
335
- return path
336
- .substr(path.lastIndexOf('.') + 1)
337
- .replace(/([A-Z])/g, '-$1')
338
- .toLowerCase()
339
- .replace(/-/g, ' ')
340
- .replace(/^./, (match) => match.toUpperCase());
341
- }
342
-
343
- /**
344
- * @param {string} name
345
- * @param {boolean} bool
346
- * @param {!Element} node
347
- * @protected
348
- */
349
- _toggleAttribute(name, bool, node) {
350
- if (node.hasAttribute(name) === !bool) {
351
- if (bool) {
352
- node.setAttribute(name, '');
353
- } else {
354
- node.removeAttribute(name);
355
- }
356
- }
357
- }
358
-
359
- /** @private */
360
- _reorderStatusChanged(reorderStatus) {
361
- this._allCells.forEach((cell) => cell.setAttribute('reorder-status', reorderStatus));
362
- }
363
-
364
- /** @private */
365
- _resizableChanged(resizable, headerCell) {
366
- if (resizable === undefined || headerCell === undefined) {
367
- return;
368
- }
369
-
370
- if (headerCell) {
371
- [headerCell].concat(this._emptyCells).forEach((cell) => {
372
- if (cell) {
373
- const existingHandle = cell.querySelector('[part~="resize-handle"]');
374
- if (existingHandle) {
375
- cell.removeChild(existingHandle);
376
- }
377
-
378
- if (resizable) {
379
- const handle = document.createElement('div');
380
- handle.setAttribute('part', 'resize-handle');
381
- cell.appendChild(handle);
382
- }
383
- }
384
- });
385
- }
386
- }
387
-
388
- /** @private */
389
- _textAlignChanged(textAlign) {
390
- if (textAlign === undefined) {
391
- return;
392
- }
393
- if (['start', 'end', 'center'].indexOf(textAlign) === -1) {
394
- console.warn('textAlign can only be set as "start", "end" or "center"');
395
- return;
396
- }
397
-
398
- let textAlignFallback;
399
- if (getComputedStyle(this._grid).direction === 'ltr') {
400
- if (textAlign === 'start') {
401
- textAlignFallback = 'left';
402
- } else if (textAlign === 'end') {
403
- textAlignFallback = 'right';
404
- }
405
- } else {
406
- if (textAlign === 'start') {
407
- textAlignFallback = 'right';
408
- } else if (textAlign === 'end') {
409
- textAlignFallback = 'left';
410
- }
411
- }
412
-
413
- this._allCells.forEach((cell) => {
414
- cell._content.style.textAlign = textAlign;
415
- if (getComputedStyle(cell._content).textAlign !== textAlign) {
416
- cell._content.style.textAlign = textAlignFallback;
417
- }
418
- });
419
- }
420
-
421
- /** @private */
422
- _hiddenChanged(hidden) {
423
- if (this.parentElement && this.parentElement._columnPropChanged) {
424
- this.parentElement._columnPropChanged('hidden', hidden);
425
- }
426
-
427
- if (!!hidden !== !!this._previousHidden && this._grid) {
428
- if (hidden === true) {
429
- this._allCells.forEach((cell) => {
430
- if (cell._content.parentNode) {
431
- cell._content.parentNode.removeChild(cell._content);
432
- }
433
- });
434
- }
435
- this._grid._debouncerHiddenChanged = Debouncer.debounce(
436
- this._grid._debouncerHiddenChanged,
437
- animationFrame,
438
- () => {
439
- if (this._grid && this._grid._renderColumnTree) {
440
- this._grid._renderColumnTree(this._grid._columnTree);
441
- }
442
- }
443
- );
444
-
445
- this._grid._updateLastFrozen && this._grid._updateLastFrozen();
446
- this._grid.notifyResize && this._grid.notifyResize();
447
- this._grid._resetKeyboardNavigation && this._grid._resetKeyboardNavigation();
448
- }
449
- this._previousHidden = hidden;
450
- }
451
-
452
- /** @protected */
453
- _runRenderer(renderer, cell, model) {
454
- const args = [cell._content, this];
455
- if (model && model.item) {
456
- args.push(model);
457
- }
458
-
459
- renderer.apply(this, args);
460
- }
461
-
462
- /**
463
- * Renders the content to the given cells using a renderer.
464
- *
465
- * @private
466
- */
467
- __renderCellsContent(renderer, cells) {
468
- // Skip if the column is hidden or not attached to a grid.
469
- if (this.hidden || !this._grid) {
470
- return;
471
- }
472
-
473
- cells.forEach((cell) => {
474
- const model = this._grid.__getRowModel(cell.parentElement);
475
-
476
- if (!renderer) return;
477
-
478
- if (cell._renderer !== renderer) {
479
- this._clearCellContent(cell);
480
- }
481
-
482
- cell._renderer = renderer;
483
-
484
- if (model.item || renderer === this._headerRenderer || renderer === this._footerRenderer) {
485
- this._runRenderer(renderer, cell, model);
486
- }
487
- });
488
- }
489
-
490
- /**
491
- * Clears the content of a cell.
492
- *
493
- * @protected
494
- */
495
- _clearCellContent(cell) {
496
- cell._content.innerHTML = '';
497
- // Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
498
- // When clearing the rendered content, this part needs to be manually disposed of.
499
- // Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
500
- delete cell._content._$litPart$;
501
- }
502
-
503
- /**
504
- * Renders the header cell content using a renderer,
505
- * and then updates the visibility of the parent row depending on
506
- * whether all its children cells are empty or not.
507
- *
508
- * @protected
509
- */
510
- _renderHeaderCellContent(headerRenderer, headerCell) {
511
- if (!headerCell || !headerRenderer) {
512
- return;
513
- }
514
-
515
- this.__renderCellsContent(headerRenderer, [headerCell]);
516
- this._grid.__updateHeaderFooterRowVisibility(headerCell.parentElement);
517
- }
518
-
519
- /** @protected */
520
- _onHeaderRendererOrBindingChanged(headerRenderer, headerCell, ..._bindings) {
521
- this._renderHeaderCellContent(headerRenderer, headerCell);
522
- }
523
-
524
- /**
525
- * Renders the content of body cells using a renderer.
526
- *
527
- * @protected
528
- */
529
- _renderBodyCellsContent(renderer, cells) {
530
- if (!cells || !renderer) {
531
- return;
532
- }
533
-
534
- this.__renderCellsContent(renderer, cells);
535
- }
536
-
537
- /** @protected */
538
- _onRendererOrBindingChanged(renderer, cells, ..._bindings) {
539
- this._renderBodyCellsContent(renderer, cells);
540
- }
541
-
542
- /**
543
- * Renders the footer cell content using a renderer
544
- * and then updates the visibility of the parent row depending on
545
- * whether all its children cells are empty or not.
546
- *
547
- * @protected
548
- */
549
- _renderFooterCellContent(footerRenderer, footerCell) {
550
- if (!footerCell || !footerRenderer) {
551
- return;
552
- }
553
-
554
- this.__renderCellsContent(footerRenderer, [footerCell]);
555
- this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
556
- }
557
-
558
- /** @protected */
559
- _onFooterRendererOrBindingChanged(footerRenderer, footerCell) {
560
- this._renderFooterCellContent(footerRenderer, footerCell);
561
- }
562
-
563
- /** @private */
564
- __setTextContent(node, textContent) {
565
- node.textContent !== textContent && (node.textContent = textContent);
566
- }
567
-
568
- /**
569
- * Renders the text header to the header cell.
570
- *
571
- * @private
572
- */
573
- __textHeaderRenderer() {
574
- this.__setTextContent(this._headerCell._content, this.header);
575
- }
576
-
577
- /**
578
- * Computes the property name based on the path and renders it to the header cell.
579
- * If the path is not defined, then nothing is rendered.
580
- *
581
- * @protected
582
- */
583
- _defaultHeaderRenderer() {
584
- if (!this.path) return;
585
-
586
- this.__setTextContent(this._headerCell._content, this._generateHeader(this.path));
587
- }
588
-
589
- /**
590
- * Computes the item property value based on the path and renders it to the body cell.
591
- * If the path is not defined, then nothing is rendered.
592
- *
593
- * @protected
594
- */
595
- _defaultRenderer(root, _owner, { item }) {
596
- if (!this.path) return;
597
-
598
- this.__setTextContent(root, this.get(this.path, item));
599
- }
600
-
601
- /**
602
- * By default, nothing is rendered to the footer cell.
603
- *
604
- * @protected
605
- */
606
- _defaultFooterRenderer() {}
607
-
608
- /**
609
- * Computes the final header renderer for the `_headerRenderer` computed property.
610
- * All the arguments are observable by the Polymer, it re-calls the method
611
- * once an argument is changed to update the property value.
612
- *
613
- * @protected
614
- * @return {GridHeaderFooterRenderer | undefined}
615
- */
616
- _computeHeaderRenderer(headerRenderer, header) {
617
- if (headerRenderer) {
618
- return headerRenderer;
619
- }
620
-
621
- if (header !== undefined && header !== null) {
622
- return this.__textHeaderRenderer;
623
- }
624
-
625
- return this._defaultHeaderRenderer;
626
- }
627
-
628
- /**
629
- * Computes the final renderer for the `_renderer` property.
630
- * All the arguments are observable by the Polymer, it re-calls the method
631
- * once an argument is changed to update the property value.
632
- *
633
- * @protected
634
- * @return {GridBodyRenderer | undefined}
635
- */
636
- _computeRenderer(renderer) {
637
- if (renderer) {
638
- return renderer;
639
- }
640
-
641
- return this._defaultRenderer;
642
- }
643
-
644
- /**
645
- * Computes the final footer renderer for the `_footerRenderer` property.
646
- * All the arguments are observable by the Polymer, it re-calls the method
647
- * once an argument is changed to update the property value.
648
- *
649
- * @protected
650
- * @return {GridHeaderFooterRenderer | undefined}
651
- */
652
- _computeFooterRenderer(footerRenderer) {
653
- if (footerRenderer) {
654
- return footerRenderer;
655
- }
656
-
657
- return this._defaultFooterRenderer;
658
- }
659
- };
660
-
661
- /**
662
- * A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`
663
- * should look like.
664
- *
665
- * See [`<vaadin-grid>`](#/elements/vaadin-grid) documentation for instructions on how
666
- * to configure the `<vaadin-grid-column>`.
667
- *
668
- * @extends HTMLElement
669
- * @mixes ColumnBaseMixin
670
- */
671
- class GridColumnElement extends ColumnBaseMixin(DirMixin(PolymerElement)) {
672
- static get is() {
673
- return 'vaadin-grid-column';
674
- }
675
-
676
- static get properties() {
677
- return {
678
- /**
679
- * Width of the cells for this column.
680
- */
681
- width: {
682
- type: String,
683
- value: '100px'
684
- },
685
-
686
- /**
687
- * Flex grow ratio for the cell widths. When set to 0, cell width is fixed.
688
- * @attr {number} flex-grow
689
- * @type {number}
690
- */
691
- flexGrow: {
692
- type: Number,
693
- value: 1
694
- },
695
-
696
- /**
697
- * Custom function for rendering the cell content.
698
- * Receives three arguments:
699
- *
700
- * - `root` The cell content DOM element. Append your content to it.
701
- * - `column` The `<vaadin-grid-column>` element.
702
- * - `model` The object with the properties related with
703
- * the rendered item, contains:
704
- * - `model.index` The index of the item.
705
- * - `model.item` The item.
706
- * - `model.expanded` Sublevel toggle state.
707
- * - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
708
- * - `model.selected` Selected state.
709
- * - `model.detailsOpened` Details opened state.
710
- *
711
- * @type {GridBodyRenderer | null | undefined}
712
- */
713
- renderer: Function,
714
-
715
- /**
716
- * Represents the final renderer computed on the set of observable arguments.
717
- * It is supposed to be used internally when rendering the content of a body cell.
718
- *
719
- * @protected
720
- * @type {GridBodyRenderer | undefined}
721
- */
722
- _renderer: {
723
- type: Function,
724
- computed: '_computeRenderer(renderer, __initialized)'
725
- },
726
-
727
- /**
728
- * Path to an item sub-property whose value gets displayed in the column body cells.
729
- * The property name is also shown in the column header if an explicit header or renderer isn't defined.
730
- */
731
- path: {
732
- type: String
733
- },
734
-
735
- /**
736
- * Automatically sets the width of the column based on the column contents when this is set to `true`.
737
- *
738
- * For performance reasons the column width is calculated automatically only once when the grid items
739
- * are rendered for the first time and the calculation only considers the rows which are currently
740
- * rendered in DOM (a bit more than what is currently visible). If the grid is scrolled, or the cell
741
- * content changes, the column width might not match the contents anymore.
742
- *
743
- * Hidden columns are ignored in the calculation and their widths are not automatically updated when
744
- * you show a column that was initially hidden.
745
- *
746
- * You can manually trigger the auto sizing behavior again by calling `grid.recalculateColumnWidths()`.
747
- *
748
- * The column width may still grow larger when `flexGrow` is not 0.
749
- * @attr {boolean} auto-width
750
- * @type {boolean}
751
- */
752
- autoWidth: {
753
- type: Boolean,
754
- value: false
755
- },
756
-
757
- /**
758
- * @type {Array<!HTMLElement>}
759
- * @protected
760
- */
761
- _cells: Array
762
- };
763
- }
764
- }
765
-
766
- customElements.define(GridColumnElement.is, GridColumnElement);
767
-
768
- export { GridColumnElement };
13
+ export * from '@vaadin/grid/src/vaadin-grid-column.js';