@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.
- package/LICENSE.md +1 -1
- package/README.md +9 -115
- package/declarations/components/yeti-table/body.d.ts +32 -0
- package/declarations/components/yeti-table/body.d.ts.map +1 -0
- package/declarations/components/yeti-table/header.d.ts +33 -0
- package/declarations/components/yeti-table/header.d.ts.map +1 -0
- package/declarations/components/yeti-table/pagination.d.ts +40 -0
- package/declarations/components/yeti-table/pagination.d.ts.map +1 -0
- package/declarations/components/yeti-table/table.d.ts +21 -0
- package/declarations/components/yeti-table/table.d.ts.map +1 -0
- package/declarations/components/yeti-table/tbody/row/cell.d.ts +44 -0
- package/declarations/components/yeti-table/tbody/row/cell.d.ts.map +1 -0
- package/declarations/components/yeti-table/tbody/row.d.ts +37 -0
- package/declarations/components/yeti-table/tbody/row.d.ts.map +1 -0
- package/declarations/components/yeti-table/tbody.d.ts +29 -0
- package/declarations/components/yeti-table/tbody.d.ts.map +1 -0
- package/declarations/components/yeti-table/tfoot/row/cell.d.ts +40 -0
- package/declarations/components/yeti-table/tfoot/row/cell.d.ts.map +1 -0
- package/declarations/components/yeti-table/tfoot/row.d.ts +37 -0
- package/declarations/components/yeti-table/tfoot/row.d.ts.map +1 -0
- package/declarations/components/yeti-table/tfoot.d.ts +27 -0
- package/declarations/components/yeti-table/tfoot.d.ts.map +1 -0
- package/declarations/components/yeti-table/thead/row/cell.d.ts +54 -0
- package/declarations/components/yeti-table/thead/row/cell.d.ts.map +1 -0
- package/declarations/components/yeti-table/thead/row/column.d.ts +69 -0
- package/declarations/components/yeti-table/thead/row/column.d.ts.map +1 -0
- package/declarations/components/yeti-table/thead/row.d.ts +55 -0
- package/declarations/components/yeti-table/thead/row.d.ts.map +1 -0
- package/declarations/components/yeti-table/thead.d.ts +34 -0
- package/declarations/components/yeti-table/thead.d.ts.map +1 -0
- package/declarations/components/yeti-table.d.ts +107 -0
- package/declarations/components/yeti-table.d.ts.map +1 -0
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/template-registry.d.ts +1 -0
- package/declarations/template-registry.d.ts.map +1 -0
- package/declarations/themes/default-theme.d.ts +3 -27
- package/declarations/themes/default-theme.d.ts.map +1 -1
- package/declarations/types.d.ts +82 -0
- package/declarations/types.d.ts.map +1 -0
- package/declarations/utils/create-regex.d.ts +1 -1
- package/declarations/utils/create-regex.d.ts.map +1 -1
- package/declarations/utils/filtering-utils.d.ts +2 -4
- package/declarations/utils/filtering-utils.d.ts.map +1 -1
- package/declarations/utils/sorting-utils.d.ts +6 -15
- package/declarations/utils/sorting-utils.d.ts.map +1 -1
- package/dist/components/yeti-table/body.js +19 -14
- package/dist/components/yeti-table/body.js.map +1 -1
- package/dist/components/yeti-table/header.js +10 -10
- package/dist/components/yeti-table/header.js.map +1 -1
- package/dist/components/yeti-table/pagination.js +14 -44
- package/dist/components/yeti-table/pagination.js.map +1 -1
- package/dist/components/yeti-table/table.js +1 -23
- package/dist/components/yeti-table/table.js.map +1 -1
- package/dist/components/yeti-table/tbody/row/cell.js +12 -12
- package/dist/components/yeti-table/tbody/row/cell.js.map +1 -1
- package/dist/components/yeti-table/tbody/row.js +15 -21
- package/dist/components/yeti-table/tbody/row.js.map +1 -1
- package/dist/components/yeti-table/tbody.js +1 -0
- package/dist/components/yeti-table/tbody.js.map +1 -1
- package/dist/components/yeti-table/tfoot/row/cell.js +9 -9
- package/dist/components/yeti-table/tfoot/row/cell.js.map +1 -1
- package/dist/components/yeti-table/tfoot/row.js +11 -11
- package/dist/components/yeti-table/tfoot/row.js.map +1 -1
- package/dist/components/yeti-table/tfoot.js +1 -0
- package/dist/components/yeti-table/tfoot.js.map +1 -1
- package/dist/components/yeti-table/thead/row/cell.js +11 -8
- package/dist/components/yeti-table/thead/row/cell.js.map +1 -1
- package/dist/components/yeti-table/thead/row/column.js +27 -128
- package/dist/components/yeti-table/thead/row/column.js.map +1 -1
- package/dist/components/yeti-table/thead/row.js +15 -15
- package/dist/components/yeti-table/thead/row.js.map +1 -1
- package/dist/components/yeti-table/thead.js +3 -22
- package/dist/components/yeti-table/thead.js.map +1 -1
- package/dist/components/yeti-table.js +99 -303
- package/dist/components/yeti-table.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/template-registry.js +2 -0
- package/dist/template-registry.js.map +1 -0
- package/dist/themes/default-theme.js +3 -2
- package/dist/themes/default-theme.js.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/create-regex.js +6 -6
- package/dist/utils/create-regex.js.map +1 -1
- package/dist/utils/filtering-utils.js +20 -8
- package/dist/utils/filtering-utils.js.map +1 -1
- package/dist/utils/sorting-utils.js +13 -18
- package/dist/utils/sorting-utils.js.map +1 -1
- package/package.json +37 -16
- package/src/components/yeti-table/{body.gjs → body.gts} +49 -45
- package/src/components/yeti-table/header.gts +67 -0
- package/src/components/yeti-table/pagination.gts +118 -0
- package/src/components/yeti-table/table.gts +27 -0
- package/src/components/yeti-table/tbody/row/{cell.gjs → cell.gts} +38 -19
- package/src/components/yeti-table/tbody/row.gts +76 -0
- package/src/components/yeti-table/tbody.gts +53 -0
- package/src/components/yeti-table/tfoot/row/cell.gts +64 -0
- package/src/components/yeti-table/tfoot/row.gts +59 -0
- package/src/components/yeti-table/tfoot.gts +41 -0
- package/src/components/yeti-table/thead/row/{cell.gjs → cell.gts} +36 -13
- package/src/components/yeti-table/thead/row/column.gts +177 -0
- package/src/components/yeti-table/thead/row.gts +105 -0
- package/src/components/yeti-table/thead.gts +65 -0
- package/src/components/yeti-table.gts +629 -0
- package/src/template-registry.ts +10 -0
- package/src/themes/{default-theme.js → default-theme.ts} +5 -1
- package/src/types.ts +94 -0
- package/src/utils/{create-regex.js → create-regex.ts} +10 -10
- package/src/utils/filtering-utils.ts +91 -0
- package/src/utils/{sorting-utils.js → sorting-utils.ts} +35 -26
- package/dist/_app_/themes/default-theme.js +0 -1
- package/dist/_app_/utils/create-regex.js +0 -1
- package/dist/_app_/utils/filtering-utils.js +0 -1
- package/dist/_app_/utils/sorting-utils.js +0 -1
- package/src/components/yeti-table/header.gjs +0 -54
- package/src/components/yeti-table/pagination.gjs +0 -155
- package/src/components/yeti-table/table.gjs +0 -34
- package/src/components/yeti-table/tbody/row.gjs +0 -89
- package/src/components/yeti-table/tbody.gjs +0 -55
- package/src/components/yeti-table/tfoot/row/cell.gjs +0 -45
- package/src/components/yeti-table/tfoot/row.gjs +0 -44
- package/src/components/yeti-table/tfoot.gjs +0 -33
- package/src/components/yeti-table/thead/row/column.gjs +0 -260
- package/src/components/yeti-table/thead/row.gjs +0 -71
- package/src/components/yeti-table/thead.gjs +0 -45
- package/src/components/yeti-table.gjs +0 -780
- package/src/utils/filtering-utils.js +0 -75
- /package/src/{.gitkeep → index.ts} +0 -0
|
@@ -1,52 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
3
|
import Component from '@glimmer/component';
|
|
4
4
|
import { modifier } from 'ember-modifier';
|
|
5
5
|
import { localCopy } from 'tracked-toolbox';
|
|
6
6
|
import { on } from '@ember/modifier';
|
|
7
|
-
import { hash
|
|
7
|
+
import { hash } from '@ember/helper';
|
|
8
8
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
9
9
|
import { setComponentTemplate } from '@ember/component';
|
|
10
|
-
import { g, i } from 'decorator-transforms/runtime-esm';
|
|
10
|
+
import { g, i, n } from 'decorator-transforms/runtime-esm';
|
|
11
11
|
|
|
12
12
|
class Column extends Component {
|
|
13
|
-
static {
|
|
14
|
-
setComponentTemplate(precompileTemplate("{{!-- template-lint-disable no-invalid-interactive --}}\n{{#if this.visible}}\n <th role={{if this.sortable \"button\"}} class=\"{{@class}}\n {{@theme.theadCell}}\n {{if this.sortable @theme.sorting.columnSortable}}\n {{if this.isSorted @theme.sorting.columnSorted}}\n {{if this.isAscSorted @theme.sorting.columnSortedAsc}}\n {{if this.isDescSorted @theme.sorting.columnSortedDesc}}\" {{on \"click\" (if this.sortable (fn @onClick this) this.noop)}} {{this.updateName}} ...attributes>\n {{yield (hash isSorted=this.isSorted isAscSorted=this.isAscSorted isDescSorted=this.isDescSorted)}}\n </th>\n{{/if}}", {
|
|
15
|
-
strictMode: true,
|
|
16
|
-
scope: () => ({
|
|
17
|
-
on,
|
|
18
|
-
fn,
|
|
19
|
-
hash
|
|
20
|
-
})
|
|
21
|
-
}), this);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* An important argument that Yeti Table uses to tie this column to a certain property on
|
|
25
|
-
* each row object of the original `@data` (or `@loadFunction`) that was passed in.
|
|
26
|
-
*
|
|
27
|
-
* This is the argument that Yeti Table uses to filter and sort the data.
|
|
28
|
-
*
|
|
29
|
-
* This argument also allows Yeti Table to keep itself up to date when the original
|
|
30
|
-
* data changes. NOTE: If this property is a nested property (one that contains periods),
|
|
31
|
-
* the table will not update when this property changes. This is due to `@each` only supporting
|
|
32
|
-
* one level of properties.
|
|
33
|
-
*
|
|
34
|
-
* If you don't need sorting, filtering or automatic table unrolling (using the blockless
|
|
35
|
-
* body component), then this property is optional.
|
|
36
|
-
*
|
|
37
|
-
* @argument prop
|
|
38
|
-
* @type {String}
|
|
39
|
-
*/
|
|
40
13
|
get prop() {
|
|
41
14
|
return this.args.prop;
|
|
42
15
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Set to `false` to hide the entire column across all rows. Keep in mind that this property
|
|
45
|
-
* won't just hide the column using css. The DOM for the column will be removed. Defaults to `true`.
|
|
46
|
-
*
|
|
47
|
-
* @argument visible
|
|
48
|
-
* @type {Boolean}
|
|
49
|
-
*/
|
|
50
16
|
static {
|
|
51
17
|
g(this.prototype, "visible", [localCopy('args.visible', true)]);
|
|
52
18
|
}
|
|
@@ -55,113 +21,30 @@ class Column extends Component {
|
|
|
55
21
|
g(this.prototype, "sortable", [localCopy('args.sortable', true)]);
|
|
56
22
|
}
|
|
57
23
|
#sortable = (i(this, "sortable"), void 0);
|
|
58
|
-
/**
|
|
59
|
-
* Used to turn off sorting clicking on this column (clicks won't toggle sorting anymore).
|
|
60
|
-
* Useful on avatar columns, for example, where a sorting order doesn't really make sense.
|
|
61
|
-
* Defaults to the `<YetiTable>` `@sortable` argument (which in turn defaults to `true`).
|
|
62
|
-
*
|
|
63
|
-
* @argument sortable
|
|
64
|
-
* @type Boolean
|
|
65
|
-
*/
|
|
66
24
|
static {
|
|
67
25
|
g(this.prototype, "sort", [localCopy('args.sort')]);
|
|
68
26
|
}
|
|
69
27
|
#sort = (i(this, "sort"), void 0);
|
|
70
|
-
/**
|
|
71
|
-
* Optionally use an `asc` or `desc` string on this argument to turn on ascending or descending sorting
|
|
72
|
-
* on this column. Useful to turn on default sortings on the table.
|
|
73
|
-
* @argument sort
|
|
74
|
-
* @type {String}
|
|
75
|
-
*/
|
|
76
28
|
static {
|
|
77
29
|
g(this.prototype, "filterable", [localCopy('args.filterable', true)]);
|
|
78
30
|
}
|
|
79
31
|
#filterable = (i(this, "filterable"), void 0);
|
|
80
|
-
/**
|
|
81
|
-
* Use `@sortSequence` to customize the sequence in which the sorting order will cycle when
|
|
82
|
-
* clicking on this column header. You can either pass in a comma-separated string or an array
|
|
83
|
-
* of strings. Accepted values are `'asc'`, `'desc'` and `'unsorted'`. The default value is `['asc', 'desc']`
|
|
84
|
-
* or whatever the global table sortSequence value is.
|
|
85
|
-
*
|
|
86
|
-
* @argument sortSequence
|
|
87
|
-
* @type Array
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* Used to turn off filtering for this column. When `false`, Yeti Table won't look for
|
|
91
|
-
* values on this column. Defaults to `true`.
|
|
92
|
-
*
|
|
93
|
-
* @argument filterable
|
|
94
|
-
* @type {Boolean}
|
|
95
|
-
*/
|
|
96
|
-
/**
|
|
97
|
-
* The column filter. If passed in, Yeti Table will search this column for rows that contain this
|
|
98
|
-
* string and show those rows.
|
|
99
|
-
*
|
|
100
|
-
* The column definitions `@filter` argument is subtractive, meaning that it will filter out rows
|
|
101
|
-
* from the subset that passes the general `@filter`.
|
|
102
|
-
*
|
|
103
|
-
* @argument filter
|
|
104
|
-
* @type {String}
|
|
105
|
-
*/
|
|
106
32
|
get filter() {
|
|
107
33
|
return this.args.filter;
|
|
108
34
|
}
|
|
109
|
-
/**
|
|
110
|
-
* An optional function to customize the filtering logic *on this column*. This function should return true
|
|
111
|
-
* or false to either include or exclude the row on the resulting set. If this function depends
|
|
112
|
-
* on a value, pass that value as the `@filterUsing` argument.
|
|
113
|
-
*
|
|
114
|
-
* This function will be called with two arguments:
|
|
115
|
-
* - `value` - the current data cell to use for filtering
|
|
116
|
-
* - `filterUsing` - the value you passed in as `@filterUsing`
|
|
117
|
-
*
|
|
118
|
-
* @argument filterFunction
|
|
119
|
-
* @type {Function}
|
|
120
|
-
*/
|
|
121
35
|
get filterFunction() {
|
|
122
36
|
return this.args.filterFunction;
|
|
123
37
|
}
|
|
124
|
-
/**
|
|
125
|
-
* If you `@filterFunction` function depends on a different value (other that `@filter`)
|
|
126
|
-
* to show, pass it in this argument. Yeti Table uses this argument to know when to recalculate
|
|
127
|
-
* the fitlered rows.
|
|
128
|
-
*
|
|
129
|
-
* @argument filterUsing
|
|
130
|
-
* @type {String}
|
|
131
|
-
*/
|
|
132
38
|
get filterUsing() {
|
|
133
39
|
return this.args.filterUsing;
|
|
134
40
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Used to add a class to all the cells in this column.
|
|
137
|
-
*
|
|
138
|
-
* @argument columnClass
|
|
139
|
-
* @type {String}
|
|
140
|
-
*/
|
|
141
41
|
get columnClass() {
|
|
142
42
|
return this.args.columnClass;
|
|
143
43
|
}
|
|
144
|
-
/**
|
|
145
|
-
* This property is a human-readable representation of the name of the column.
|
|
146
|
-
* It defaults to the trimmed `textContent` of the `<th>` element, but can be overridden
|
|
147
|
-
* by using a `@name="your custom name"` argument.
|
|
148
|
-
*
|
|
149
|
-
* @argument name
|
|
150
|
-
* @type {String}
|
|
151
|
-
*/
|
|
152
44
|
static {
|
|
153
45
|
g(this.prototype, "name", [localCopy('args.name')]);
|
|
154
46
|
}
|
|
155
47
|
#name = (i(this, "name"), void 0);
|
|
156
|
-
/**
|
|
157
|
-
* An optional function to be invoked whenever this column is clicked
|
|
158
|
-
*
|
|
159
|
-
* This function will be called with two arguments:
|
|
160
|
-
* - `column` - the column that was clicked
|
|
161
|
-
*
|
|
162
|
-
* @argument onClick
|
|
163
|
-
* @type {Function}
|
|
164
|
-
*/
|
|
165
48
|
get isAscSorted() {
|
|
166
49
|
return this.sort === 'asc';
|
|
167
50
|
}
|
|
@@ -172,9 +55,9 @@ class Column extends Component {
|
|
|
172
55
|
return this.isAscSorted || this.isDescSorted;
|
|
173
56
|
}
|
|
174
57
|
get normalizedSortSequence() {
|
|
175
|
-
|
|
176
|
-
assert('@sortSequence must be either a comma-separated string or an array. Got `${sortSequence}.`', isArray(sortSequence) || typeof sortSequence === 'string');
|
|
177
|
-
if (isArray(sortSequence)) {
|
|
58
|
+
const sortSequence = this.args.sortSequence;
|
|
59
|
+
assert('@sortSequence must be either a comma-separated string or an array. Got `${sortSequence}.`', Array.isArray(sortSequence) || typeof sortSequence === 'string');
|
|
60
|
+
if (Array.isArray(sortSequence)) {
|
|
178
61
|
return sortSequence;
|
|
179
62
|
} else if (typeof sortSequence === 'string') {
|
|
180
63
|
return sortSequence.split(',').map(s => s.trim());
|
|
@@ -182,20 +65,36 @@ class Column extends Component {
|
|
|
182
65
|
return [];
|
|
183
66
|
}
|
|
184
67
|
}
|
|
185
|
-
constructor() {
|
|
186
|
-
super(
|
|
68
|
+
constructor(owner, args) {
|
|
69
|
+
super(owner, args);
|
|
187
70
|
this.args.parent?.registerColumn(this);
|
|
188
71
|
}
|
|
189
72
|
willDestroy() {
|
|
190
|
-
super.willDestroy(
|
|
73
|
+
super.willDestroy();
|
|
191
74
|
this.args.parent?.unregisterColumn(this);
|
|
192
75
|
}
|
|
193
76
|
updateName = modifier(element => {
|
|
194
77
|
if (!this.args.name) {
|
|
195
|
-
this.name = element.textContent
|
|
78
|
+
this.name = element.textContent?.trim();
|
|
196
79
|
}
|
|
197
80
|
});
|
|
198
|
-
|
|
81
|
+
handleClick(e) {
|
|
82
|
+
if (this.sortable && this.args.onClick) {
|
|
83
|
+
this.args.onClick(this, e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static {
|
|
87
|
+
n(this.prototype, "handleClick", [action]);
|
|
88
|
+
}
|
|
89
|
+
static {
|
|
90
|
+
setComponentTemplate(precompileTemplate("{{!-- template-lint-disable no-invalid-interactive --}}\n{{#if this.visible}}\n <th role={{if this.sortable \"button\"}} class=\"{{@class}}\n {{@theme.theadCell}}\n {{if this.sortable @theme.sorting.columnSortable}}\n {{if this.isSorted @theme.sorting.columnSorted}}\n {{if this.isAscSorted @theme.sorting.columnSortedAsc}}\n {{if this.isDescSorted @theme.sorting.columnSortedDesc}}\" {{on \"click\" this.handleClick}} {{this.updateName}} ...attributes>\n {{yield (hash isSorted=this.isSorted isAscSorted=this.isAscSorted isDescSorted=this.isDescSorted)}}\n </th>\n{{/if}}", {
|
|
91
|
+
strictMode: true,
|
|
92
|
+
scope: () => ({
|
|
93
|
+
on,
|
|
94
|
+
hash
|
|
95
|
+
})
|
|
96
|
+
}), this);
|
|
97
|
+
}
|
|
199
98
|
}
|
|
200
99
|
|
|
201
100
|
export { Column as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../../../../src/components/yeti-table/thead/row/column.gjs"],"sourcesContent":["import { isArray } from '@ember/array';\nimport { assert } from '@ember/debug';\n\nimport Component from '@glimmer/component';\nimport { modifier } from 'ember-modifier';\nimport { localCopy } from 'tracked-toolbox';\n\n/**\n An important component yielded from the header or head.row component that is used to define\n a column of the table.\n\n ```hbs\n <table.header as |header|>\n <header.column @prop=\"firstName\" as |column|>\n First name\n {{if column.isAscSorted \"(sorted asc)\"}}\n {{if column.isDescSorted \"(sorted desc)\"}}\n </header.column>\n </table.header>\n ```\n\n ```hbs\n <table.thead as |head|>\n <head.row as |row|>\n <row.column @prop=\"firstName\" as |column|>\n First name\n {{if column.isAscSorted \"(sorted asc)\"}}\n {{if column.isDescSorted \"(sorted desc)\"}}\n </row.column>\n </head.row>\n </table.thead>\n ```\n\n @class Column\n @yield {object} column\n @yield {boolean} column.isSorted - `true` if column is sorted ascending or descending\n @yield {boolean} column.isAscSorted - `true` if column is sorted ascending\n @yield {boolean} column.isDescSorted - `true` if column is sorted descending\n*/\nimport { on } from '@ember/modifier';\nimport { fn, hash } from '@ember/helper';\n\nexport default class Column extends Component {\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{#if this.visible}}\n <th\n role={{if this.sortable \"button\"}}\n class=\"{{@class}}\n {{@theme.theadCell}}\n {{if this.sortable @theme.sorting.columnSortable}}\n {{if this.isSorted @theme.sorting.columnSorted}}\n {{if this.isAscSorted @theme.sorting.columnSortedAsc}}\n {{if this.isDescSorted @theme.sorting.columnSortedDesc}}\"\n {{on \"click\" (if this.sortable (fn @onClick this) this.noop)}}\n {{this.updateName}}\n ...attributes\n >\n {{yield\n (hash\n isSorted=this.isSorted\n isAscSorted=this.isAscSorted\n isDescSorted=this.isDescSorted\n )\n }}\n </th>\n {{/if}}\n </template>\n /**\n * An important argument that Yeti Table uses to tie this column to a certain property on\n * each row object of the original `@data` (or `@loadFunction`) that was passed in.\n *\n * This is the argument that Yeti Table uses to filter and sort the data.\n *\n * This argument also allows Yeti Table to keep itself up to date when the original\n * data changes. NOTE: If this property is a nested property (one that contains periods),\n * the table will not update when this property changes. This is due to `@each` only supporting\n * one level of properties.\n *\n * If you don't need sorting, filtering or automatic table unrolling (using the blockless\n * body component), then this property is optional.\n *\n * @argument prop\n * @type {String}\n */\n get prop() {\n return this.args.prop;\n }\n\n /**\n * Set to `false` to hide the entire column across all rows. Keep in mind that this property\n * won't just hide the column using css. The DOM for the column will be removed. Defaults to `true`.\n *\n * @argument visible\n * @type {Boolean}\n */\n @localCopy('args.visible', true)\n visible;\n\n /**\n * Used to turn off sorting clicking on this column (clicks won't toggle sorting anymore).\n * Useful on avatar columns, for example, where a sorting order doesn't really make sense.\n * Defaults to the `<YetiTable>` `@sortable` argument (which in turn defaults to `true`).\n *\n * @argument sortable\n * @type Boolean\n */\n @localCopy('args.sortable', true)\n sortable;\n\n /**\n * Optionally use an `asc` or `desc` string on this argument to turn on ascending or descending sorting\n * on this column. Useful to turn on default sortings on the table.\n\n * @argument sort\n * @type {String}\n */\n @localCopy('args.sort')\n sort;\n\n /**\n * Use `@sortSequence` to customize the sequence in which the sorting order will cycle when\n * clicking on this column header. You can either pass in a comma-separated string or an array\n * of strings. Accepted values are `'asc'`, `'desc'` and `'unsorted'`. The default value is `['asc', 'desc']`\n * or whatever the global table sortSequence value is.\n *\n * @argument sortSequence\n * @type Array\n */\n\n /**\n * Used to turn off filtering for this column. When `false`, Yeti Table won't look for\n * values on this column. Defaults to `true`.\n *\n * @argument filterable\n * @type {Boolean}\n */\n @localCopy('args.filterable', true)\n filterable;\n\n /**\n * The column filter. If passed in, Yeti Table will search this column for rows that contain this\n * string and show those rows.\n *\n * The column definitions `@filter` argument is subtractive, meaning that it will filter out rows\n * from the subset that passes the general `@filter`.\n *\n * @argument filter\n * @type {String}\n */\n get filter() {\n return this.args.filter;\n }\n\n /**\n * An optional function to customize the filtering logic *on this column*. This function should return true\n * or false to either include or exclude the row on the resulting set. If this function depends\n * on a value, pass that value as the `@filterUsing` argument.\n *\n * This function will be called with two arguments:\n * - `value` - the current data cell to use for filtering\n * - `filterUsing` - the value you passed in as `@filterUsing`\n *\n * @argument filterFunction\n * @type {Function}\n */\n get filterFunction() {\n return this.args.filterFunction;\n }\n\n /**\n * If you `@filterFunction` function depends on a different value (other that `@filter`)\n * to show, pass it in this argument. Yeti Table uses this argument to know when to recalculate\n * the fitlered rows.\n *\n * @argument filterUsing\n * @type {String}\n */\n get filterUsing() {\n return this.args.filterUsing;\n }\n\n /**\n * Used to add a class to all the cells in this column.\n *\n * @argument columnClass\n * @type {String}\n */\n get columnClass() {\n return this.args.columnClass;\n }\n\n /**\n * This property is a human-readable representation of the name of the column.\n * It defaults to the trimmed `textContent` of the `<th>` element, but can be overridden\n * by using a `@name=\"your custom name\"` argument.\n *\n * @argument name\n * @type {String}\n */\n @localCopy('args.name')\n name;\n\n /**\n * An optional function to be invoked whenever this column is clicked\n *\n * This function will be called with two arguments:\n * - `column` - the column that was clicked\n *\n * @argument onClick\n * @type {Function}\n */\n\n get isAscSorted() {\n return this.sort === 'asc';\n }\n\n get isDescSorted() {\n return this.sort === 'desc';\n }\n\n get isSorted() {\n return this.isAscSorted || this.isDescSorted;\n }\n\n get normalizedSortSequence() {\n let sortSequence = this.args.sortSequence;\n assert(\n '@sortSequence must be either a comma-separated string or an array. Got `${sortSequence}.`',\n isArray(sortSequence) || typeof sortSequence === 'string',\n );\n\n if (isArray(sortSequence)) {\n return sortSequence;\n } else if (typeof sortSequence === 'string') {\n return sortSequence.split(',').map((s) => s.trim());\n } else {\n return [];\n }\n }\n\n constructor() {\n super(...arguments);\n\n this.args.parent?.registerColumn(this);\n }\n\n willDestroy() {\n super.willDestroy(...arguments);\n this.args.parent?.unregisterColumn(this);\n }\n\n updateName = modifier((element) => {\n if (!this.args.name) {\n this.name = element.textContent.trim();\n }\n });\n\n noop = () => {};\n}\n"],"names":["Column","Component","setComponentTemplate","precompileTemplate","strictMode","scope","on","fn","hash","prop","args","g","prototype","localCopy","i","filter","filterFunction","filterUsing","columnClass","isAscSorted","sort","isDescSorted","isSorted","normalizedSortSequence","sortSequence","assert","isArray","split","map","s","trim","constructor","arguments","parent","registerColumn","willDestroy","unregisterColumn","updateName","modifier","element","name","textContent","noop"],"mappings":";;;;;;;;;;;AA0Ce,MAAMA,MAAA,SAAeC,SAAA,CAAA;AAClC,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,2nBAA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AA,CAAA;AAClD,IAAA,CAAA,MAAO;AACL,MAAA,OAAO,EAAE;AACX,IAAA;AACF,EAAA;AAEAC,EAAAA,WAAAA,GAAc;IACZ,KAAK,CAAA,GAAIC,SAAA,CAAA;IAET,IAAI,CAACtB,IAAI,CAACuB,MAAM,EAAEC,eAAe,IAAI,CAAA;AACvC,EAAA;AAEAC,EAAAA,WAAAA,GAAc;AACZ,IAAA,KAAK,CAACA,WAAA,CAAA,GAAeH,SAAA,CAAA;IACrB,IAAI,CAACtB,IAAI,CAACuB,MAAM,EAAEG,iBAAiB,IAAI,CAAA;AACzC,EAAA;AAEAC,EAAAA,UAAA,GAAaC,SAAUC,OAAA,IAAA;AACrB,IAAA,IAAI,CAAC,IAAI,CAAC7B,IAAI,CAAC8B,IAAI,EAAE;MACnB,IAAI,CAACA,IAAI,GAAGD,OAAA,CAAQE,WAAW,CAACX,IAAI,EAAA;AACtC,IAAA;AACF,EAAA,CAAA,CAAA;AAEAY,EAAAA,IAAA,GAAOA,OAAO,CAAA;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"column.js","sources":["../../../../../src/components/yeti-table/thead/row/column.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport { assert } from '@ember/debug';\n\nimport Component from '@glimmer/component';\nimport { modifier } from 'ember-modifier';\nimport { localCopy } from 'tracked-toolbox';\nimport type Owner from '@ember/owner';\n\nimport { on } from '@ember/modifier';\nimport { hash } from '@ember/helper';\n\nimport type {\n ColumnDefinition,\n FilterFunction,\n SortDirection,\n Theme,\n} from '../../../../types.ts';\n\n/**\n An important component yielded from the header or head.row component that is used to define\n a column of the table.\n\n @class Column\n*/\n\nexport interface ColumnParent {\n registerColumn(column: Column): void;\n unregisterColumn(column: Column): void;\n}\n\nexport interface ColumnSignature {\n Element: HTMLTableCellElement;\n Args: {\n class?: string;\n theme?: Theme;\n prop?: string;\n visible?: boolean;\n sortable?: boolean;\n sort?: SortDirection | null;\n sortSequence?: SortDirection[] | string;\n filterable?: boolean;\n filter?: string;\n filterFunction?: FilterFunction;\n filterUsing?: unknown;\n columnClass?: string;\n name?: string;\n onClick?: (column: Column, e: MouseEvent) => void;\n parent?: ColumnParent;\n };\n Blocks: {\n default: [\n {\n isSorted: boolean;\n isAscSorted: boolean;\n isDescSorted: boolean;\n },\n ];\n };\n}\n\nexport default class Column\n extends Component<ColumnSignature>\n implements ColumnDefinition\n{\n get prop(): string | undefined {\n return this.args.prop;\n }\n\n @localCopy('args.visible', true)\n visible!: boolean;\n\n @localCopy('args.sortable', true)\n sortable!: boolean;\n\n @localCopy('args.sort')\n sort: SortDirection | null | undefined;\n\n @localCopy('args.filterable', true)\n filterable!: boolean;\n\n get filter(): string | undefined {\n return this.args.filter;\n }\n\n get filterFunction(): FilterFunction | undefined {\n return this.args.filterFunction;\n }\n\n get filterUsing(): unknown {\n return this.args.filterUsing;\n }\n\n get columnClass(): string | undefined {\n return this.args.columnClass;\n }\n\n @localCopy('args.name')\n name: string | undefined;\n\n get isAscSorted(): boolean {\n return this.sort === 'asc';\n }\n\n get isDescSorted(): boolean {\n return this.sort === 'desc';\n }\n\n get isSorted(): boolean {\n return this.isAscSorted || this.isDescSorted;\n }\n\n get normalizedSortSequence(): string[] {\n const sortSequence = this.args.sortSequence;\n assert(\n '@sortSequence must be either a comma-separated string or an array. Got `${sortSequence}.`',\n Array.isArray(sortSequence) || typeof sortSequence === 'string',\n );\n\n if (Array.isArray(sortSequence)) {\n return sortSequence;\n } else if (typeof sortSequence === 'string') {\n return sortSequence.split(',').map((s: string) => s.trim());\n } else {\n return [];\n }\n }\n\n constructor(owner: Owner, args: ColumnSignature['Args']) {\n super(owner, args);\n\n this.args.parent?.registerColumn(this);\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.args.parent?.unregisterColumn(this);\n }\n\n updateName = modifier((element: Element) => {\n if (!this.args.name) {\n this.name = element.textContent?.trim();\n }\n });\n\n @action\n handleClick(e: MouseEvent): void {\n if (this.sortable && this.args.onClick) {\n this.args.onClick(this, e);\n }\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{#if this.visible}}\n <th\n role={{if this.sortable \"button\"}}\n class=\"{{@class}}\n {{@theme.theadCell}}\n {{if this.sortable @theme.sorting.columnSortable}}\n {{if this.isSorted @theme.sorting.columnSorted}}\n {{if this.isAscSorted @theme.sorting.columnSortedAsc}}\n {{if this.isDescSorted @theme.sorting.columnSortedDesc}}\"\n {{on \"click\" this.handleClick}}\n {{this.updateName}}\n ...attributes\n >\n {{yield\n (hash\n isSorted=this.isSorted\n isAscSorted=this.isAscSorted\n isDescSorted=this.isDescSorted\n )\n }}\n </th>\n {{/if}}\n </template>\n}\n"],"names":["Column","Component","prop","args","g","prototype","localCopy","i","filter","filterFunction","filterUsing","columnClass","isAscSorted","sort","isDescSorted","isSorted","normalizedSortSequence","sortSequence","assert","Array","isArray","split","map","s","trim","constructor","owner","parent","registerColumn","willDestroy","unregisterColumn","updateName","modifier","element","name","textContent","handleClick","e","sortable","onClick","n","action","setComponentTemplate","precompileTemplate","strictMode","scope","on","hash"],"mappings":";;;;;;;;;;;AA4De,MAAMA,MAAA,SACXC,SAAA,CACG;EAEX,IAAIC,IAAAA,GAA2B;AAC7B,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,IAAI;AACvB,EAAA;AAAA,EAAA;IAAAE,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAECC,UAAU,cAAA,EAAgB,IAAA,CAAA,CAAA,CAAA;AAAA;EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CAG1BC,UAAU,eAAA,EAAiB,IAAA,CAAA,CAAA,CAAA;AAAA;EAAA,SAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAA,MAAA;AAAA,EAAA;AAAAH,IAAAA,CAAA,MAAAC,SAAA,EAAA,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,IAAA,CAAAnC,SAAA,EAAA,aAAA,EAAA,CALCoC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,4lBAAA,EAwBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import { hash } from '@ember/helper';
|
|
2
3
|
import Column from './row/column.js';
|
|
3
4
|
import THeadCell from './row/cell.js';
|
|
4
|
-
import { hash } from '@ember/helper';
|
|
5
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
7
|
|
|
8
8
|
class THeadRow extends Component {
|
|
9
|
-
static {
|
|
10
|
-
setComponentTemplate(precompileTemplate("<tr class=\"{{@trClass}} {{@theme.theadRow}} {{@theme.row}}\" ...attributes>\n {{yield (hash column=(component Column sortable=@sortable sortSequence=@sortSequence onClick=@onColumnClick theme=@theme parent=@parent) cell=(component Cell theme=@theme parent=this))}}\n</tr>", {
|
|
11
|
-
strictMode: true,
|
|
12
|
-
scope: () => ({
|
|
13
|
-
hash,
|
|
14
|
-
Column,
|
|
15
|
-
Cell: THeadCell
|
|
16
|
-
})
|
|
17
|
-
}), this);
|
|
18
|
-
}
|
|
19
9
|
cells = [];
|
|
20
10
|
registerCell(cell) {
|
|
21
11
|
let column;
|
|
22
12
|
if (cell.prop) {
|
|
23
|
-
column = this.args.columns.
|
|
13
|
+
column = this.args.columns.find(c => c.prop === cell.prop);
|
|
24
14
|
cell.column = column;
|
|
25
15
|
} else {
|
|
26
|
-
|
|
16
|
+
const index = this.cells.length;
|
|
27
17
|
column = this.args.columns[index];
|
|
28
18
|
return column;
|
|
29
19
|
}
|
|
@@ -31,10 +21,20 @@ class THeadRow extends Component {
|
|
|
31
21
|
return column;
|
|
32
22
|
}
|
|
33
23
|
unregisterCell(cell) {
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
const cells = this.cells;
|
|
25
|
+
const index = cells.indexOf(cell);
|
|
36
26
|
cells.splice(index, 1);
|
|
37
27
|
}
|
|
28
|
+
static {
|
|
29
|
+
setComponentTemplate(precompileTemplate("<tr class=\"{{@trClass}} {{@theme.theadRow}} {{@theme.row}}\" ...attributes>\n {{yield (hash column=(component Column sortable=@sortable sortSequence=@sortSequence onClick=@onColumnClick theme=@theme parent=@parent) cell=(component Cell theme=@theme parent=this))}}\n</tr>", {
|
|
30
|
+
strictMode: true,
|
|
31
|
+
scope: () => ({
|
|
32
|
+
hash,
|
|
33
|
+
Column,
|
|
34
|
+
Cell: THeadCell
|
|
35
|
+
})
|
|
36
|
+
}), this);
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export { THeadRow as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sources":["../../../../src/components/yeti-table/thead/row.
|
|
1
|
+
{"version":3,"file":"row.js","sources":["../../../../src/components/yeti-table/thead/row.gts"],"sourcesContent":["import Component from '@glimmer/component';\n\nimport { hash } from '@ember/helper';\n\nimport type { WithBoundArgs } from '@glint/template';\n\nimport Column from './row/column.gts';\nimport type { ColumnParent } from './row/column.gts';\nimport Cell from './row/cell.gts';\nimport type { ColumnDefinition, SortDirection, Theme } from '../../../types.ts';\n\n/**\n Renders a `<tr>` element and yields the column and cell component.\n ```hbs\n <table.thead as |head|>\n <head.row as |row|>\n <row.column @prop=\"firstName\" as |column|>\n First name\n {{if column.isAscSorted \"(sorted asc)\"}}\n {{if column.isDescSorted \"(sorted desc)\"}}\n </row.column>\n </head.row>\n </table.thead>\n ```\n\n @class THeadRow\n @yield {Component} column\n @yield {Component} cell\n*/\n\ninterface THeadCellLike {\n prop?: string;\n column?: ColumnDefinition;\n}\n\nexport interface THeadRowSignature {\n Element: HTMLTableRowElement;\n Args: {\n trClass?: string;\n theme?: Theme;\n sortable?: boolean;\n sortSequence?: SortDirection[] | string;\n onColumnClick?: (column: Column, e: MouseEvent) => void;\n columns: ColumnDefinition[];\n parent?: ColumnParent;\n };\n Blocks: {\n default: [\n {\n column: WithBoundArgs<\n typeof Column,\n 'sortable' | 'sortSequence' | 'onClick' | 'theme' | 'parent'\n >;\n cell: WithBoundArgs<typeof Cell, 'theme' | 'parent'>;\n },\n ];\n };\n}\n\nexport default class THeadRow extends Component<THeadRowSignature> {\n cells: THeadCellLike[] = [];\n\n registerCell(cell: THeadCellLike): ColumnDefinition | undefined {\n let column: ColumnDefinition | undefined;\n\n if (cell.prop) {\n column = this.args.columns.find((c) => c.prop === cell.prop);\n cell.column = column;\n } else {\n const index = this.cells.length;\n column = this.args.columns[index];\n\n return column;\n }\n\n this.cells.push(cell);\n\n return column;\n }\n\n unregisterCell(cell: THeadCellLike): void {\n const cells = this.cells;\n const index = cells.indexOf(cell);\n\n cells.splice(index, 1);\n }\n\n <template>\n <tr class=\"{{@trClass}} {{@theme.theadRow}} {{@theme.row}}\" ...attributes>\n {{yield\n (hash\n column=(component\n Column\n sortable=@sortable\n sortSequence=@sortSequence\n onClick=@onColumnClick\n theme=@theme\n parent=@parent\n )\n cell=(component Cell theme=@theme parent=this)\n )\n }}\n </tr>\n </template>\n}\n"],"names":["THeadRow","Component","cells","registerCell","cell","column","prop","args","columns","find","c","index","length","push","unregisterCell","indexOf","splice","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Column","Cell"],"mappings":";;;;;;;AA2De,MAAMA,iBAAiBC,SAAA,CAAU;AAC9CC,EAAAA,KAAA,GAAyB,EAAE;EAE3BC,YAAAA,CAAaC,IAAmB,EAAgC;AAC9D,IAAA,IAAIC,MAAoC;IAExC,IAAID,IAAA,CAAKE,IAAI,EAAE;AACbD,MAAAA,MAAA,GAAS,IAAI,CAACE,IAAI,CAACC,OAAO,CAACC,IAAI,CAAEC,CAAA,IAAMA,CAAA,CAAEJ,IAAI,KAAKF,KAAKE,IAAI,CAAA;MAC3DF,IAAA,CAAKC,MAAM,GAAGA,MAAA;AAChB,IAAA,CAAA,MAAO;AACL,MAAA,MAAMM,KAAA,GAAQ,IAAI,CAACT,KAAK,CAACU,MAAM;MAC/BP,MAAA,GAAS,IAAI,CAACE,IAAI,CAACC,OAAO,CAACG,KAAA,CAAM;AAEjC,MAAA,OAAON,MAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACH,KAAK,CAACW,IAAI,CAACT,IAAA,CAAA;AAEhB,IAAA,OAAOC,MAAA;AACT,EAAA;EAEAS,cAAAA,CAAeV,IAAmB,EAAQ;AACxC,IAAA,MAAMF,KAAA,GAAQ,IAAI,CAACA,KAAK;AACxB,IAAA,MAAMS,KAAA,GAAQT,KAAA,CAAMa,OAAO,CAACX,IAAA,CAAA;AAE5BF,IAAAA,KAAA,CAAMc,MAAM,CAACL,KAAA,EAAO,CAAA,CAAA;AACtB,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,mRAAA,EAgBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,MAAA;AAAAC,cAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -4,32 +4,13 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
4
4
|
import { setComponentTemplate } from '@ember/component';
|
|
5
5
|
import templateOnly from '@ember/component/template-only';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Renders a `<thead>` element and yields the row component.
|
|
9
|
-
|
|
10
|
-
```hbs
|
|
11
|
-
<table.thead as |head|>
|
|
12
|
-
<head.row as |row|>
|
|
13
|
-
<row.column @prop="firstName" as |column|>
|
|
14
|
-
First name
|
|
15
|
-
{{if column.isAscSorted "(sorted asc)"}}
|
|
16
|
-
{{if column.isDescSorted "(sorted desc)"}}
|
|
17
|
-
</row.column>
|
|
18
|
-
</head.row>
|
|
19
|
-
</table.thead>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
@class THead
|
|
23
|
-
@yield {object} head
|
|
24
|
-
@yield {Component} head.row
|
|
25
|
-
*/
|
|
26
|
-
var THead = setComponentTemplate(precompileTemplate("<thead class={{@theme.thead}} ...attributes>\n {{yield (hash row=(component THead sortable=@sortable sortSequence=@sortSequence onColumnClick=@onColumnClick columns=@columns theme=@theme parent=@parent))}}\n</thead>", {
|
|
7
|
+
const THeadComponent = setComponentTemplate(precompileTemplate("<thead class={{@theme.thead}} ...attributes>\n {{yield (hash row=(component THeadRow sortable=@sortable sortSequence=@sortSequence onColumnClick=@onColumnClick columns=@columns theme=@theme parent=@parent))}}\n</thead>", {
|
|
27
8
|
strictMode: true,
|
|
28
9
|
scope: () => ({
|
|
29
10
|
hash,
|
|
30
|
-
|
|
11
|
+
THeadRow
|
|
31
12
|
})
|
|
32
13
|
}), templateOnly());
|
|
33
14
|
|
|
34
|
-
export {
|
|
15
|
+
export { THeadComponent as default };
|
|
35
16
|
//# sourceMappingURL=thead.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thead.js","sources":["../../../src/components/yeti-table/thead.
|
|
1
|
+
{"version":3,"file":"thead.js","sources":["../../../src/components/yeti-table/thead.gts"],"sourcesContent":["import type { TemplateOnlyComponent } from '@ember/component/template-only';\n\nimport { hash } from '@ember/helper';\n\nimport type { WithBoundArgs } from '@glint/template';\n\nimport THeadRow from './thead/row.gts';\nimport type Column from './thead/row/column.gts';\nimport type { ColumnParent } from './thead/row/column.gts';\nimport type { ColumnDefinition, SortDirection, Theme } from '../../types.ts';\n\n/**\n Renders a `<thead>` element and yields the row component.\n\n @class THead\n @yield {object} head\n @yield {Component} head.row\n*/\n\nexport interface THeadSignature {\n Element: HTMLTableSectionElement;\n Args: {\n theme?: Theme;\n sortable?: boolean;\n sortSequence?: SortDirection[] | string;\n onColumnClick?: (column: Column, e: MouseEvent) => void;\n columns: ColumnDefinition[];\n parent?: ColumnParent;\n };\n Blocks: {\n default: [\n {\n row: WithBoundArgs<\n typeof THeadRow,\n | 'sortable'\n | 'sortSequence'\n | 'onColumnClick'\n | 'columns'\n | 'theme'\n | 'parent'\n >;\n },\n ];\n };\n}\n\nconst THeadComponent: TemplateOnlyComponent<THeadSignature> = <template>\n <thead class={{@theme.thead}} ...attributes>\n {{yield\n (hash\n row=(component\n THeadRow\n sortable=@sortable\n sortSequence=@sortSequence\n onColumnClick=@onColumnClick\n columns=@columns\n theme=@theme\n parent=@parent\n )\n )\n }}\n </thead>\n</template>;\n\nexport default THeadComponent;\n"],"names":["THeadComponent","setComponentTemplate","precompileTemplate","strictMode","scope","hash","THeadRow","templateOnly"],"mappings":";;;;;;AA8CA,MAAMA,cAAsC,GAAAC,oBAAA,CAAkBC,kBAAA,CAAA,6NAAA,EAgB9D;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|