@vaadin/grid 24.2.0-dev.f254716fe → 24.3.0-alpha2

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