@triptyk/ember-yeti-table 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +9 -115
  3. package/declarations/components/yeti-table/body.d.ts +32 -0
  4. package/declarations/components/yeti-table/body.d.ts.map +1 -0
  5. package/declarations/components/yeti-table/header.d.ts +33 -0
  6. package/declarations/components/yeti-table/header.d.ts.map +1 -0
  7. package/declarations/components/yeti-table/pagination.d.ts +40 -0
  8. package/declarations/components/yeti-table/pagination.d.ts.map +1 -0
  9. package/declarations/components/yeti-table/table.d.ts +21 -0
  10. package/declarations/components/yeti-table/table.d.ts.map +1 -0
  11. package/declarations/components/yeti-table/tbody/row/cell.d.ts +44 -0
  12. package/declarations/components/yeti-table/tbody/row/cell.d.ts.map +1 -0
  13. package/declarations/components/yeti-table/tbody/row.d.ts +37 -0
  14. package/declarations/components/yeti-table/tbody/row.d.ts.map +1 -0
  15. package/declarations/components/yeti-table/tbody.d.ts +29 -0
  16. package/declarations/components/yeti-table/tbody.d.ts.map +1 -0
  17. package/declarations/components/yeti-table/tfoot/row/cell.d.ts +40 -0
  18. package/declarations/components/yeti-table/tfoot/row/cell.d.ts.map +1 -0
  19. package/declarations/components/yeti-table/tfoot/row.d.ts +37 -0
  20. package/declarations/components/yeti-table/tfoot/row.d.ts.map +1 -0
  21. package/declarations/components/yeti-table/tfoot.d.ts +27 -0
  22. package/declarations/components/yeti-table/tfoot.d.ts.map +1 -0
  23. package/declarations/components/yeti-table/thead/row/cell.d.ts +54 -0
  24. package/declarations/components/yeti-table/thead/row/cell.d.ts.map +1 -0
  25. package/declarations/components/yeti-table/thead/row/column.d.ts +69 -0
  26. package/declarations/components/yeti-table/thead/row/column.d.ts.map +1 -0
  27. package/declarations/components/yeti-table/thead/row.d.ts +55 -0
  28. package/declarations/components/yeti-table/thead/row.d.ts.map +1 -0
  29. package/declarations/components/yeti-table/thead.d.ts +34 -0
  30. package/declarations/components/yeti-table/thead.d.ts.map +1 -0
  31. package/declarations/components/yeti-table.d.ts +107 -0
  32. package/declarations/components/yeti-table.d.ts.map +1 -0
  33. package/declarations/index.d.ts +1 -0
  34. package/declarations/index.d.ts.map +1 -0
  35. package/declarations/template-registry.d.ts +1 -0
  36. package/declarations/template-registry.d.ts.map +1 -0
  37. package/declarations/themes/default-theme.d.ts +3 -27
  38. package/declarations/themes/default-theme.d.ts.map +1 -1
  39. package/declarations/types.d.ts +82 -0
  40. package/declarations/types.d.ts.map +1 -0
  41. package/declarations/utils/create-regex.d.ts +1 -1
  42. package/declarations/utils/create-regex.d.ts.map +1 -1
  43. package/declarations/utils/filtering-utils.d.ts +2 -4
  44. package/declarations/utils/filtering-utils.d.ts.map +1 -1
  45. package/declarations/utils/sorting-utils.d.ts +6 -15
  46. package/declarations/utils/sorting-utils.d.ts.map +1 -1
  47. package/dist/components/yeti-table/body.js +19 -14
  48. package/dist/components/yeti-table/body.js.map +1 -1
  49. package/dist/components/yeti-table/header.js +10 -10
  50. package/dist/components/yeti-table/header.js.map +1 -1
  51. package/dist/components/yeti-table/pagination.js +14 -44
  52. package/dist/components/yeti-table/pagination.js.map +1 -1
  53. package/dist/components/yeti-table/table.js +1 -23
  54. package/dist/components/yeti-table/table.js.map +1 -1
  55. package/dist/components/yeti-table/tbody/row/cell.js +12 -12
  56. package/dist/components/yeti-table/tbody/row/cell.js.map +1 -1
  57. package/dist/components/yeti-table/tbody/row.js +15 -21
  58. package/dist/components/yeti-table/tbody/row.js.map +1 -1
  59. package/dist/components/yeti-table/tbody.js +1 -0
  60. package/dist/components/yeti-table/tbody.js.map +1 -1
  61. package/dist/components/yeti-table/tfoot/row/cell.js +9 -9
  62. package/dist/components/yeti-table/tfoot/row/cell.js.map +1 -1
  63. package/dist/components/yeti-table/tfoot/row.js +11 -11
  64. package/dist/components/yeti-table/tfoot/row.js.map +1 -1
  65. package/dist/components/yeti-table/tfoot.js +1 -0
  66. package/dist/components/yeti-table/tfoot.js.map +1 -1
  67. package/dist/components/yeti-table/thead/row/cell.js +11 -8
  68. package/dist/components/yeti-table/thead/row/cell.js.map +1 -1
  69. package/dist/components/yeti-table/thead/row/column.js +27 -128
  70. package/dist/components/yeti-table/thead/row/column.js.map +1 -1
  71. package/dist/components/yeti-table/thead/row.js +15 -15
  72. package/dist/components/yeti-table/thead/row.js.map +1 -1
  73. package/dist/components/yeti-table/thead.js +3 -22
  74. package/dist/components/yeti-table/thead.js.map +1 -1
  75. package/dist/components/yeti-table.js +99 -303
  76. package/dist/components/yeti-table.js.map +1 -1
  77. package/dist/index.js +2 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/template-registry.js +2 -0
  80. package/dist/template-registry.js.map +1 -0
  81. package/dist/themes/default-theme.js +3 -2
  82. package/dist/themes/default-theme.js.map +1 -1
  83. package/dist/types.js +2 -0
  84. package/dist/types.js.map +1 -0
  85. package/dist/utils/create-regex.js +6 -6
  86. package/dist/utils/create-regex.js.map +1 -1
  87. package/dist/utils/filtering-utils.js +20 -8
  88. package/dist/utils/filtering-utils.js.map +1 -1
  89. package/dist/utils/sorting-utils.js +13 -18
  90. package/dist/utils/sorting-utils.js.map +1 -1
  91. package/package.json +37 -16
  92. package/src/components/yeti-table/{body.gjs → body.gts} +49 -45
  93. package/src/components/yeti-table/header.gts +67 -0
  94. package/src/components/yeti-table/pagination.gts +118 -0
  95. package/src/components/yeti-table/table.gts +27 -0
  96. package/src/components/yeti-table/tbody/row/{cell.gjs → cell.gts} +38 -19
  97. package/src/components/yeti-table/tbody/row.gts +76 -0
  98. package/src/components/yeti-table/tbody.gts +53 -0
  99. package/src/components/yeti-table/tfoot/row/cell.gts +64 -0
  100. package/src/components/yeti-table/tfoot/row.gts +59 -0
  101. package/src/components/yeti-table/tfoot.gts +41 -0
  102. package/src/components/yeti-table/thead/row/{cell.gjs → cell.gts} +36 -13
  103. package/src/components/yeti-table/thead/row/column.gts +177 -0
  104. package/src/components/yeti-table/thead/row.gts +105 -0
  105. package/src/components/yeti-table/thead.gts +65 -0
  106. package/src/components/yeti-table.gts +629 -0
  107. package/src/template-registry.ts +10 -0
  108. package/src/themes/{default-theme.js → default-theme.ts} +5 -1
  109. package/src/types.ts +94 -0
  110. package/src/utils/{create-regex.js → create-regex.ts} +10 -10
  111. package/src/utils/filtering-utils.ts +91 -0
  112. package/src/utils/{sorting-utils.js → sorting-utils.ts} +35 -26
  113. package/dist/_app_/themes/default-theme.js +0 -1
  114. package/dist/_app_/utils/create-regex.js +0 -1
  115. package/dist/_app_/utils/filtering-utils.js +0 -1
  116. package/dist/_app_/utils/sorting-utils.js +0 -1
  117. package/src/components/yeti-table/header.gjs +0 -54
  118. package/src/components/yeti-table/pagination.gjs +0 -155
  119. package/src/components/yeti-table/table.gjs +0 -34
  120. package/src/components/yeti-table/tbody/row.gjs +0 -89
  121. package/src/components/yeti-table/tbody.gjs +0 -55
  122. package/src/components/yeti-table/tfoot/row/cell.gjs +0 -45
  123. package/src/components/yeti-table/tfoot/row.gjs +0 -44
  124. package/src/components/yeti-table/tfoot.gjs +0 -33
  125. package/src/components/yeti-table/thead/row/column.gjs +0 -260
  126. package/src/components/yeti-table/thead/row.gjs +0 -71
  127. package/src/components/yeti-table/thead.gjs +0 -45
  128. package/src/components/yeti-table.gjs +0 -780
  129. package/src/utils/filtering-utils.js +0 -75
  130. /package/src/{.gitkeep → index.ts} +0 -0
@@ -1,55 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- /**
4
- Renders a `<tbody>` element and yields the row component and data. You must iterate each row
5
- ```hbs
6
- <table.tbody as |body data|>
7
- {{#each data as |person index|}}
8
- <body.row as |row|>
9
- <row.cell>
10
- {{person.firstName}} #{{index}}
11
- </row.cell>
12
- <row.cell>
13
- {{person.lastName}}
14
- </row.cell>
15
- <row.cell>
16
- {{person.points}}
17
- </row.cell>
18
- </body.row>
19
- {{/each}}
20
- </table.tbody>
21
- ```
22
- Remember that you must perform the {{#each}} to iterate over the `@data` array.
23
-
24
- This component does not provide a blockless variation
25
-
26
- @class TBody
27
- @yield {object} body
28
- @yield {Component} body.row - the row component
29
- @yield {Array} data
30
- */
31
- import { hash } from '@ember/helper';
32
- import TBodyRow from './tbody/row.gjs';
33
-
34
- // eslint-disable-next-line ember/no-empty-glimmer-component-classes
35
- export default class TBody extends Component {
36
- <template>
37
- <tbody class={{@theme.tbody}} ...attributes>
38
- {{yield
39
- (hash
40
- row=(component
41
- TBodyRow theme=@theme onClick=@onRowClick columns=@columns
42
- )
43
- )
44
- @data
45
- }}
46
- </tbody>
47
- </template>
48
- /**
49
- * Adds a click action to each row, called with the clicked row's data as an argument.
50
- * Can be used with both the blockless and block invocations.
51
- *
52
- * @argument onRowClick
53
- * @type Function
54
- */
55
- }
@@ -1,45 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
-
4
- /**
5
- Renders a `<td>` element and yields for the developer to supply content.
6
-
7
- ```hbs
8
- <table.tfoot as |foot|>
9
- <foot.row as |row|>
10
- <row.cell>
11
- Footer content
12
- </row.cell>
13
- </foot.row>
14
- </table.tfoot>
15
- ```
16
- @class TFootCell
17
- */
18
-
19
- export default class TFootCell extends Component {
20
- <template>
21
- {{#if this.column.visible}}
22
- <td class="{{@class}} {{@theme.tfootCell}}" ...attributes>
23
- {{yield}}
24
- </td>
25
- {{/if}}
26
- </template>
27
-
28
- @tracked
29
- index;
30
-
31
- get column() {
32
- return this.args.columns[this.index];
33
- }
34
-
35
- constructor() {
36
- super(...arguments);
37
-
38
- this.index = this.args.parent?.registerCell(this);
39
- }
40
-
41
- willDestroy() {
42
- super.willDestroy(...arguments);
43
- this.args.parent?.unregisterCell(this);
44
- }
45
- }
@@ -1,44 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- /**
4
- Renders a `<tr>` element and yields cell component.
5
- ```hbs
6
- <table.tfoot as |foot|>
7
- <foot.row as |row|>
8
- <row.cell>
9
- Footer content
10
- </row.cell>
11
- </foot.row>
12
- </table.tfoot>
13
- ```
14
-
15
- @class TFootRow
16
- @yield {object} row
17
- @yield {Component} row.cell
18
- */
19
-
20
- import { hash } from '@ember/helper';
21
- import Cell from './row/cell.gjs';
22
-
23
- export default class TFootRow extends Component {
24
- <template>
25
- <tr class="{{@class}} {{@theme.tfootRow}} {{@theme.row}}" ...attributes>
26
- {{yield
27
- (hash cell=(component Cell theme=@theme parent=this columns=@columns))
28
- }}
29
- </tr>
30
- </template>
31
- cells = [];
32
-
33
- registerCell(cell) {
34
- let index = this.cells.length;
35
- this.cells.push(cell);
36
- return index;
37
- }
38
-
39
- unregisterCell(cell) {
40
- let cells = this.cells;
41
- let index = cells.indexOf(cell);
42
- cells.splice(index, 1);
43
- }
44
- }
@@ -1,33 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- /**
4
- Renders a `<tfoot>` element and yields the row component.
5
- ```hbs
6
- <table.tfoot as |foot|>
7
- <foot.row as |row|>
8
- <row.cell>
9
- Footer content
10
- </row.cell>
11
- </foot.row>
12
- </table.tfoot>
13
- ```
14
-
15
- @class TTFoot
16
- @yield {object} footer
17
- @yield {Component} footer.row
18
- */
19
- import { hash } from '@ember/helper';
20
- import TFootRow from './tfoot/row.gjs';
21
-
22
- // eslint-disable-next-line ember/no-empty-glimmer-component-classes
23
- export default class TFoot extends Component {
24
- <template>
25
- <tfoot class={{@theme.tfoot}} ...attributes>
26
- {{yield
27
- (hash
28
- row=(component TFootRow columns=@columns theme=@theme parent=@parent)
29
- )
30
- }}
31
- </tfoot>
32
- </template>
33
- }
@@ -1,260 +0,0 @@
1
- import { isArray } from '@ember/array';
2
- import { assert } from '@ember/debug';
3
-
4
- import Component from '@glimmer/component';
5
- import { modifier } from 'ember-modifier';
6
- import { localCopy } from 'tracked-toolbox';
7
-
8
- /**
9
- An important component yielded from the header or head.row component that is used to define
10
- a column of the table.
11
-
12
- ```hbs
13
- <table.header as |header|>
14
- <header.column @prop="firstName" as |column|>
15
- First name
16
- {{if column.isAscSorted "(sorted asc)"}}
17
- {{if column.isDescSorted "(sorted desc)"}}
18
- </header.column>
19
- </table.header>
20
- ```
21
-
22
- ```hbs
23
- <table.thead as |head|>
24
- <head.row as |row|>
25
- <row.column @prop="firstName" as |column|>
26
- First name
27
- {{if column.isAscSorted "(sorted asc)"}}
28
- {{if column.isDescSorted "(sorted desc)"}}
29
- </row.column>
30
- </head.row>
31
- </table.thead>
32
- ```
33
-
34
- @class Column
35
- @yield {object} column
36
- @yield {boolean} column.isSorted - `true` if column is sorted ascending or descending
37
- @yield {boolean} column.isAscSorted - `true` if column is sorted ascending
38
- @yield {boolean} column.isDescSorted - `true` if column is sorted descending
39
- */
40
- import { on } from '@ember/modifier';
41
- import { fn, hash } from '@ember/helper';
42
-
43
- export default class Column extends Component {
44
- <template>
45
- {{! template-lint-disable no-invalid-interactive }}
46
- {{#if this.visible}}
47
- <th
48
- role={{if this.sortable "button"}}
49
- class="{{@class}}
50
- {{@theme.theadCell}}
51
- {{if this.sortable @theme.sorting.columnSortable}}
52
- {{if this.isSorted @theme.sorting.columnSorted}}
53
- {{if this.isAscSorted @theme.sorting.columnSortedAsc}}
54
- {{if this.isDescSorted @theme.sorting.columnSortedDesc}}"
55
- {{on "click" (if this.sortable (fn @onClick this) this.noop)}}
56
- {{this.updateName}}
57
- ...attributes
58
- >
59
- {{yield
60
- (hash
61
- isSorted=this.isSorted
62
- isAscSorted=this.isAscSorted
63
- isDescSorted=this.isDescSorted
64
- )
65
- }}
66
- </th>
67
- {{/if}}
68
- </template>
69
- /**
70
- * An important argument that Yeti Table uses to tie this column to a certain property on
71
- * each row object of the original `@data` (or `@loadFunction`) that was passed in.
72
- *
73
- * This is the argument that Yeti Table uses to filter and sort the data.
74
- *
75
- * This argument also allows Yeti Table to keep itself up to date when the original
76
- * data changes. NOTE: If this property is a nested property (one that contains periods),
77
- * the table will not update when this property changes. This is due to `@each` only supporting
78
- * one level of properties.
79
- *
80
- * If you don't need sorting, filtering or automatic table unrolling (using the blockless
81
- * body component), then this property is optional.
82
- *
83
- * @argument prop
84
- * @type {String}
85
- */
86
- get prop() {
87
- return this.args.prop;
88
- }
89
-
90
- /**
91
- * Set to `false` to hide the entire column across all rows. Keep in mind that this property
92
- * won't just hide the column using css. The DOM for the column will be removed. Defaults to `true`.
93
- *
94
- * @argument visible
95
- * @type {Boolean}
96
- */
97
- @localCopy('args.visible', true)
98
- visible;
99
-
100
- /**
101
- * Used to turn off sorting clicking on this column (clicks won't toggle sorting anymore).
102
- * Useful on avatar columns, for example, where a sorting order doesn't really make sense.
103
- * Defaults to the `<YetiTable>` `@sortable` argument (which in turn defaults to `true`).
104
- *
105
- * @argument sortable
106
- * @type Boolean
107
- */
108
- @localCopy('args.sortable', true)
109
- sortable;
110
-
111
- /**
112
- * Optionally use an `asc` or `desc` string on this argument to turn on ascending or descending sorting
113
- * on this column. Useful to turn on default sortings on the table.
114
-
115
- * @argument sort
116
- * @type {String}
117
- */
118
- @localCopy('args.sort')
119
- sort;
120
-
121
- /**
122
- * Use `@sortSequence` to customize the sequence in which the sorting order will cycle when
123
- * clicking on this column header. You can either pass in a comma-separated string or an array
124
- * of strings. Accepted values are `'asc'`, `'desc'` and `'unsorted'`. The default value is `['asc', 'desc']`
125
- * or whatever the global table sortSequence value is.
126
- *
127
- * @argument sortSequence
128
- * @type Array
129
- */
130
-
131
- /**
132
- * Used to turn off filtering for this column. When `false`, Yeti Table won't look for
133
- * values on this column. Defaults to `true`.
134
- *
135
- * @argument filterable
136
- * @type {Boolean}
137
- */
138
- @localCopy('args.filterable', true)
139
- filterable;
140
-
141
- /**
142
- * The column filter. If passed in, Yeti Table will search this column for rows that contain this
143
- * string and show those rows.
144
- *
145
- * The column definitions `@filter` argument is subtractive, meaning that it will filter out rows
146
- * from the subset that passes the general `@filter`.
147
- *
148
- * @argument filter
149
- * @type {String}
150
- */
151
- get filter() {
152
- return this.args.filter;
153
- }
154
-
155
- /**
156
- * An optional function to customize the filtering logic *on this column*. This function should return true
157
- * or false to either include or exclude the row on the resulting set. If this function depends
158
- * on a value, pass that value as the `@filterUsing` argument.
159
- *
160
- * This function will be called with two arguments:
161
- * - `value` - the current data cell to use for filtering
162
- * - `filterUsing` - the value you passed in as `@filterUsing`
163
- *
164
- * @argument filterFunction
165
- * @type {Function}
166
- */
167
- get filterFunction() {
168
- return this.args.filterFunction;
169
- }
170
-
171
- /**
172
- * If you `@filterFunction` function depends on a different value (other that `@filter`)
173
- * to show, pass it in this argument. Yeti Table uses this argument to know when to recalculate
174
- * the fitlered rows.
175
- *
176
- * @argument filterUsing
177
- * @type {String}
178
- */
179
- get filterUsing() {
180
- return this.args.filterUsing;
181
- }
182
-
183
- /**
184
- * Used to add a class to all the cells in this column.
185
- *
186
- * @argument columnClass
187
- * @type {String}
188
- */
189
- get columnClass() {
190
- return this.args.columnClass;
191
- }
192
-
193
- /**
194
- * This property is a human-readable representation of the name of the column.
195
- * It defaults to the trimmed `textContent` of the `<th>` element, but can be overridden
196
- * by using a `@name="your custom name"` argument.
197
- *
198
- * @argument name
199
- * @type {String}
200
- */
201
- @localCopy('args.name')
202
- name;
203
-
204
- /**
205
- * An optional function to be invoked whenever this column is clicked
206
- *
207
- * This function will be called with two arguments:
208
- * - `column` - the column that was clicked
209
- *
210
- * @argument onClick
211
- * @type {Function}
212
- */
213
-
214
- get isAscSorted() {
215
- return this.sort === 'asc';
216
- }
217
-
218
- get isDescSorted() {
219
- return this.sort === 'desc';
220
- }
221
-
222
- get isSorted() {
223
- return this.isAscSorted || this.isDescSorted;
224
- }
225
-
226
- get normalizedSortSequence() {
227
- let sortSequence = this.args.sortSequence;
228
- assert(
229
- '@sortSequence must be either a comma-separated string or an array. Got `${sortSequence}.`',
230
- isArray(sortSequence) || typeof sortSequence === 'string',
231
- );
232
-
233
- if (isArray(sortSequence)) {
234
- return sortSequence;
235
- } else if (typeof sortSequence === 'string') {
236
- return sortSequence.split(',').map((s) => s.trim());
237
- } else {
238
- return [];
239
- }
240
- }
241
-
242
- constructor() {
243
- super(...arguments);
244
-
245
- this.args.parent?.registerColumn(this);
246
- }
247
-
248
- willDestroy() {
249
- super.willDestroy(...arguments);
250
- this.args.parent?.unregisterColumn(this);
251
- }
252
-
253
- updateName = modifier((element) => {
254
- if (!this.args.name) {
255
- this.name = element.textContent.trim();
256
- }
257
- });
258
-
259
- noop = () => {};
260
- }
@@ -1,71 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- /**
4
- Renders a `<tr>` element and yields the column and cell component.
5
- ```hbs
6
- <table.thead as |head|>
7
- <head.row as |row|>
8
- <row.column @prop="firstName" as |column|>
9
- First name
10
- {{if column.isAscSorted "(sorted asc)"}}
11
- {{if column.isDescSorted "(sorted desc)"}}
12
- </row.column>
13
- </head.row>
14
- </table.thead>
15
- ```
16
-
17
- @class THeadRow
18
- @yield {Component} column
19
- @yield {Component} cell
20
- */
21
-
22
- import Column from './row/column.gjs';
23
- import Cell from './row/cell.gjs';
24
- import { hash } from '@ember/helper';
25
-
26
- export default class THeadRow extends Component {
27
- <template>
28
- <tr class="{{@trClass}} {{@theme.theadRow}} {{@theme.row}}" ...attributes>
29
- {{yield
30
- (hash
31
- column=(component
32
- Column
33
- sortable=@sortable
34
- sortSequence=@sortSequence
35
- onClick=@onColumnClick
36
- theme=@theme
37
- parent=@parent
38
- )
39
- cell=(component Cell theme=@theme parent=this)
40
- )
41
- }}
42
- </tr>
43
- </template>
44
-
45
- cells = [];
46
-
47
- registerCell(cell) {
48
- let column;
49
-
50
- if (cell.prop) {
51
- column = this.args.columns.findBy('prop', cell.prop);
52
- cell.column = column;
53
- } else {
54
- let index = this.cells.length;
55
- column = this.args.columns[index];
56
-
57
- return column;
58
- }
59
-
60
- this.cells.push(cell);
61
-
62
- return column;
63
- }
64
-
65
- unregisterCell(cell) {
66
- let cells = this.cells;
67
- let index = cells.indexOf(cell);
68
-
69
- cells.splice(index, 1);
70
- }
71
- }
@@ -1,45 +0,0 @@
1
- /**
2
- Renders a `<thead>` element and yields the row component.
3
-
4
- ```hbs
5
- <table.thead as |head|>
6
- <head.row as |row|>
7
- <row.column @prop="firstName" as |column|>
8
- First name
9
- {{if column.isAscSorted "(sorted asc)"}}
10
- {{if column.isDescSorted "(sorted desc)"}}
11
- </row.column>
12
- </head.row>
13
- </table.thead>
14
- ```
15
-
16
- @class THead
17
- @yield {object} head
18
- @yield {Component} head.row
19
- */
20
- import { hash } from '@ember/helper';
21
- import THead from './thead/row.gjs';
22
-
23
- <template>
24
- <thead class={{@theme.thead}} ...attributes>
25
- {{yield
26
- (hash
27
- row=(component
28
- THead
29
- sortable=@sortable
30
- sortSequence=@sortSequence
31
- onColumnClick=@onColumnClick
32
- columns=@columns
33
- theme=@theme
34
- parent=@parent
35
- )
36
- )
37
- }}
38
- </thead>
39
- </template>
40
- /**
41
- * Adds a click action to the thead, called with the clicked column as an argument.
42
- *
43
- * @argument onColumnClick - action that is called when the column header is clicked
44
- * @type Function
45
- */