ember-headless-table 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/dist/-private/-type-tests/plugin-properties.test.js +4 -8
- package/dist/-private/-type-tests/plugin-properties.test.js.map +1 -1
- package/dist/-private/-type-tests/plugin-with.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-accessors.test.js +12 -11
- package/dist/-private/-type-tests/plugins-accessors.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-signature-from.test.js +7 -6
- package/dist/-private/-type-tests/plugins-signature-from.test.js.map +1 -1
- package/dist/-private/-type-tests/plugins-signature-utils.test.js.map +1 -1
- package/dist/-private/-type-tests/table-api.test.js +3 -2
- package/dist/-private/-type-tests/table-api.test.js.map +1 -1
- package/dist/-private/-type-tests/table-config.test.js +9 -11
- package/dist/-private/-type-tests/table-config.test.js.map +1 -1
- package/dist/-private/column.d.ts +1 -1
- package/dist/-private/column.js +7 -15
- package/dist/-private/column.js.map +1 -1
- package/dist/-private/js-helper.d.ts +1 -1
- package/dist/-private/js-helper.js +2 -3
- package/dist/-private/js-helper.js.map +1 -1
- package/dist/-private/preferences.js +7 -39
- package/dist/-private/preferences.js.map +1 -1
- package/dist/-private/row.d.ts +1 -1
- package/dist/-private/row.js +4 -15
- package/dist/-private/row.js.map +1 -1
- package/dist/-private/table.js +4 -4
- package/dist/-private/utils.js +0 -2
- package/dist/-private/utils.js.map +1 -1
- package/dist/{applyDecoratedDescriptor-e0489e2f.js → applyDecoratedDescriptor-6b986a67.js} +1 -6
- package/dist/applyDecoratedDescriptor-6b986a67.js.map +1 -0
- package/dist/{classPrivateFieldGet-af59a8ea.js → classPrivateFieldGet-b4d7d334.js} +1 -3
- package/dist/{classPrivateFieldGet-af59a8ea.js.map → classPrivateFieldGet-b4d7d334.js.map} +1 -1
- package/dist/{defineProperty-a0196711.js → defineProperty-35ce617b.js} +1 -2
- package/dist/defineProperty-35ce617b.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugins/-private/base.d.ts +1 -1
- package/dist/plugins/-private/base.js +18 -59
- package/dist/plugins/-private/base.js.map +1 -1
- package/dist/plugins/-private/utils.js +5 -20
- package/dist/plugins/-private/utils.js.map +1 -1
- package/dist/plugins/column-reordering/helpers.d.ts +9 -4
- package/dist/plugins/column-reordering/helpers.js +13 -6
- package/dist/plugins/column-reordering/helpers.js.map +1 -1
- package/dist/plugins/column-reordering/index.js +1 -1
- package/dist/plugins/column-reordering/plugin.d.ts +57 -11
- package/dist/plugins/column-reordering/plugin.js +109 -130
- package/dist/plugins/column-reordering/plugin.js.map +1 -1
- package/dist/plugins/column-reordering/utils.js +0 -7
- package/dist/plugins/column-reordering/utils.js.map +1 -1
- package/dist/plugins/column-resizing/handle.js +4 -33
- package/dist/plugins/column-resizing/handle.js.map +1 -1
- package/dist/plugins/column-resizing/helpers.js +2 -2
- package/dist/plugins/column-resizing/helpers.js.map +1 -1
- package/dist/plugins/column-resizing/plugin.js +15 -64
- package/dist/plugins/column-resizing/plugin.js.map +1 -1
- package/dist/plugins/column-resizing/resize-observer.js +1 -3
- package/dist/plugins/column-resizing/resize-observer.js.map +1 -1
- package/dist/plugins/column-resizing/utils.js +0 -2
- package/dist/plugins/column-resizing/utils.js.map +1 -1
- package/dist/plugins/column-visibility/helpers.js +3 -3
- package/dist/plugins/column-visibility/helpers.js.map +1 -1
- package/dist/plugins/column-visibility/plugin.js +6 -26
- package/dist/plugins/column-visibility/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/helpers.js +7 -7
- package/dist/plugins/data-sorting/helpers.js.map +1 -1
- package/dist/plugins/data-sorting/plugin.js +2 -32
- package/dist/plugins/data-sorting/plugin.js.map +1 -1
- package/dist/plugins/data-sorting/types.js +0 -3
- package/dist/plugins/data-sorting/types.js.map +1 -1
- package/dist/plugins/metadata/helpers.d.ts +4 -0
- package/dist/plugins/metadata/helpers.js +12 -0
- package/dist/plugins/metadata/helpers.js.map +1 -0
- package/dist/plugins/metadata/index.d.ts +3 -0
- package/dist/plugins/metadata/index.js +3 -0
- package/dist/plugins/metadata/index.js.map +1 -0
- package/dist/plugins/metadata/plugin.d.ts +24 -0
- package/dist/plugins/metadata/plugin.js +25 -0
- package/dist/plugins/metadata/plugin.js.map +1 -0
- package/dist/plugins/row-selection/helpers.js.map +1 -1
- package/dist/plugins/row-selection/plugin.js +5 -42
- package/dist/plugins/row-selection/plugin.js.map +1 -1
- package/dist/plugins/sticky-columns/helpers.d.ts +14 -1
- package/dist/plugins/sticky-columns/helpers.js +40 -1
- package/dist/plugins/sticky-columns/helpers.js.map +1 -1
- package/dist/plugins/sticky-columns/index.js +1 -1
- package/dist/plugins/sticky-columns/plugin.d.ts +17 -1
- package/dist/plugins/sticky-columns/plugin.js +41 -43
- package/dist/plugins/sticky-columns/plugin.js.map +1 -1
- package/dist/{table-8e46554b.d.ts → table-0cbd2720.d.ts} +9 -7
- package/dist/{table-8e46554b.js → table-0cbd2720.js} +34 -36
- package/dist/table-0cbd2720.js.map +1 -0
- package/dist/test-support/index.js +2 -6
- package/dist/test-support/index.js.map +1 -1
- package/dist/utils.js +2 -5
- package/dist/utils.js.map +1 -1
- package/package.json +20 -33
- package/dist/applyDecoratedDescriptor-e0489e2f.js.map +0 -1
- package/dist/defineProperty-a0196711.js.map +0 -1
- package/dist/table-8e46554b.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style"],"mappings":"
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/sticky-columns/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base';\nimport { StickyColumns } from './plugin';\n\nimport type { Column } from '[public-types]';\n\nexport const isSticky = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, StickyColumns).isSticky;\n\nexport const styleFor = <DataType = unknown>(\n column: Column<DataType>\n): Partial<CSSStyleDeclaration> => meta.forColumn(column, StickyColumns).style;\n\n/**\n * In this plugin, buth header and cells have the same styles,\n * if applicable.\n *\n * Until this RFC https://github.com/emberjs/rfcs/pull/883\n * is merged and implemented, we can't performantly\n * use modifiers for apply styles.\n *\n * In the mean time, we'll need to append style strings, which is more work\n * for consumers, but is a reasonable trade-off for now.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>\n): ReturnType<typeof htmlSafe> => {\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n let result = '';\n\n if (columnMeta.isSticky) {\n for (let [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n }\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'zIndex':\n return 'z-index';\n default:\n return key;\n }\n};\n"],"names":["isSticky","column","meta","forColumn","StickyColumns","styleFor","style","styleStringFor","columnMeta","result","key","value","Object","entries","toStyle","htmlSafe"],"mappings":";;;;AAOaA,MAAAA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACJ,SAAQ;AAEnCK,MAAAA,QAAQ,GACnBJ,MAAwB,IACSC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAACE,MAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBN,MAAwB,IACQ;EAChC,IAAIO,UAAU,GAAGN,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,aAAa,CAAC,CAAA;EAEtD,IAAIK,MAAM,GAAG,EAAE,CAAA;EAEf,IAAID,UAAU,CAACR,QAAQ,EAAE;AACvB,IAAA,KAAK,IAAI,CAACU,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACF,KAAK,CAAC,EAAE;MACzDG,MAAM,IAAK,GAAEK,OAAO,CAACJ,GAAG,CAAE,CAAA,CAAA,EAAGC,KAAM,CAAE,CAAA,CAAA,CAAA;AACvC,KAAA;IAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM,CAAA;AACvB,GAAA;EAEA,OAAOM,QAAQ,CAACN,MAAM,CAAC,CAAA;AACzB,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,OAAO,GAAIJ,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA;AACE,MAAA,OAAOA,GAAG,CAAA;AAAC,GAAA;AAEjB,CAAC;;;;"}
|
@@ -13,6 +13,15 @@ interface ColumnOptions {
|
|
13
13
|
interface Signature {
|
14
14
|
Options: {
|
15
15
|
Column: ColumnOptions;
|
16
|
+
Plugin: {
|
17
|
+
/**
|
18
|
+
* Opts this plugin out of engaging in the modifier system
|
19
|
+
* and instead requires setting a `style` attribute on
|
20
|
+
* th / td tags for getting the "position: sticky" behovior
|
21
|
+
* on columns.
|
22
|
+
*/
|
23
|
+
workaroundForModifierTimingUpdateRFC883?: boolean;
|
24
|
+
};
|
16
25
|
};
|
17
26
|
Meta: {
|
18
27
|
Table: TableMeta;
|
@@ -33,7 +42,14 @@ declare class StickyColumns extends BasePlugin<Signature> {
|
|
33
42
|
table: typeof TableMeta;
|
34
43
|
column: typeof ColumnMeta;
|
35
44
|
};
|
36
|
-
|
45
|
+
conditionallyRemoveStyles: (element: HTMLElement) => void;
|
46
|
+
headerCellModifier: (element: HTMLElement, { column, table }: ColumnApi) => void;
|
47
|
+
/**
|
48
|
+
* Not yet supported. Pending Ember RFC #883
|
49
|
+
*
|
50
|
+
* TODO: switch ColumnApi to "RowApi", add the row's data
|
51
|
+
*/
|
52
|
+
cellModifier: (element: HTMLElement, { column, table }: ColumnApi) => void;
|
37
53
|
}
|
38
54
|
/**
|
39
55
|
* @private
|
@@ -1,131 +1,129 @@
|
|
1
|
-
import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-
|
2
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
1
|
+
import { _ as _applyDecoratedDescriptor } from '../../applyDecoratedDescriptor-6b986a67.js';
|
2
|
+
import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
|
3
3
|
import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
|
4
4
|
import '@glimmer/tracking';
|
5
5
|
import { assert } from '@ember/debug';
|
6
|
-
import { BasePlugin,
|
6
|
+
import { BasePlugin, options, meta, columns } from '../-private/base.js';
|
7
7
|
import { applyStyles } from '../-private/utils.js';
|
8
8
|
|
9
9
|
var _class;
|
10
10
|
let cached = macroCondition(dependencySatisfies('ember-source', '>= 4.1.0-alpha.0')) ? importSync('@glimmer/tracking').cached : importSync('ember-cached-decorator-polyfill').cached;
|
11
|
+
const DEFAULT_Z_INDEX = '8';
|
11
12
|
class StickyColumns extends BasePlugin {
|
12
13
|
constructor(...args) {
|
13
14
|
super(...args);
|
14
|
-
|
15
15
|
_defineProperty(this, "name", 'sticky-columns');
|
16
|
-
|
17
16
|
_defineProperty(this, "meta", {
|
18
17
|
table: TableMeta,
|
19
18
|
column: ColumnMeta
|
20
19
|
});
|
21
|
-
|
20
|
+
_defineProperty(this, "conditionallyRemoveStyles", element => {
|
21
|
+
if (element.style.getPropertyValue('position') === 'sticky') {
|
22
|
+
element.style.removeProperty('position');
|
23
|
+
}
|
24
|
+
if (element.style.getPropertyValue('left')) {
|
25
|
+
element.style.left = '';
|
26
|
+
}
|
27
|
+
if (element.style.getPropertyValue('right')) {
|
28
|
+
element.style.right = '';
|
29
|
+
}
|
30
|
+
if (element.style.zIndex === DEFAULT_Z_INDEX) {
|
31
|
+
element.style.zIndex = '';
|
32
|
+
}
|
33
|
+
});
|
22
34
|
_defineProperty(this, "headerCellModifier", (element, {
|
23
|
-
column
|
35
|
+
column,
|
36
|
+
table
|
24
37
|
}) => {
|
38
|
+
if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {
|
39
|
+
return;
|
40
|
+
}
|
25
41
|
let columnMeta = meta.forColumn(column, StickyColumns);
|
26
|
-
|
27
42
|
if (columnMeta.isSticky) {
|
28
43
|
applyStyles(element, columnMeta.style);
|
29
44
|
} else {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
this.conditionallyRemoveStyles(element);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
_defineProperty(this, "cellModifier", (element, {
|
49
|
+
column,
|
50
|
+
table
|
51
|
+
}) => {
|
52
|
+
if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
let columnMeta = meta.forColumn(column, StickyColumns);
|
56
|
+
if (columnMeta.isSticky) {
|
57
|
+
applyStyles(element, columnMeta.style);
|
58
|
+
} else {
|
59
|
+
this.conditionallyRemoveStyles(element);
|
45
60
|
}
|
46
61
|
});
|
47
62
|
}
|
48
|
-
|
49
63
|
}
|
64
|
+
|
50
65
|
/**
|
51
66
|
* @private
|
52
67
|
*
|
53
68
|
* Contains state and behaviors for the sticiness
|
54
69
|
*/
|
55
|
-
|
56
70
|
_defineProperty(StickyColumns, "requires", ['columnWidth']);
|
57
|
-
|
58
71
|
let ColumnMeta = (_class = class ColumnMeta {
|
59
72
|
constructor(column) {
|
60
73
|
this.column = column;
|
61
74
|
}
|
62
|
-
|
63
75
|
get isSticky() {
|
64
76
|
return this.position !== 'none';
|
65
77
|
}
|
66
|
-
|
67
78
|
get position() {
|
68
79
|
let sticky = options.forColumn(this.column, StickyColumns)?.sticky;
|
69
80
|
assert(`Invalid sticky value, ${sticky}. Valid values: 'left', 'right', false`, sticky === 'left' || sticky === 'right' || sticky === false || sticky === undefined);
|
70
81
|
return sticky || 'none';
|
71
82
|
}
|
72
|
-
|
73
83
|
get offset() {
|
74
84
|
if (!this.isSticky) {
|
75
85
|
return;
|
76
86
|
}
|
77
|
-
|
78
87
|
if (this.position === 'left') {
|
79
88
|
let leftColumns = columns.before(this.column);
|
80
89
|
let left = leftColumns.reduce((acc, column) => {
|
81
90
|
let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');
|
82
|
-
|
83
91
|
if (hasWidth(columnMeta)) {
|
84
92
|
return acc + (columnMeta.width ?? 0);
|
85
93
|
}
|
86
|
-
|
87
94
|
return acc;
|
88
95
|
}, 0);
|
89
96
|
return `${left}px`;
|
90
97
|
}
|
91
|
-
|
92
98
|
if (this.position === 'right') {
|
93
99
|
let rightColumns = columns.after(this.column);
|
94
100
|
let right = rightColumns.reduce((acc, column) => {
|
95
101
|
let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');
|
96
|
-
|
97
102
|
if (hasWidth(columnMeta)) {
|
98
103
|
return acc + (columnMeta.width ?? 0);
|
99
104
|
}
|
100
|
-
|
101
105
|
return acc;
|
102
106
|
}, 0);
|
103
107
|
return `${right}px`;
|
104
108
|
}
|
105
|
-
|
106
109
|
return;
|
107
110
|
}
|
108
|
-
|
109
111
|
get style() {
|
110
112
|
if (this.isSticky) {
|
111
113
|
return {
|
112
114
|
position: 'sticky',
|
113
115
|
[this.position]: this.offset,
|
114
|
-
zIndex:
|
116
|
+
zIndex: DEFAULT_Z_INDEX
|
115
117
|
};
|
116
118
|
}
|
117
|
-
|
118
119
|
return {};
|
119
120
|
}
|
120
|
-
|
121
121
|
}, (_applyDecoratedDescriptor(_class.prototype, "offset", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "offset"), _class.prototype)), _class);
|
122
|
-
|
123
122
|
function hasWidth(obj) {
|
124
123
|
return typeof obj === 'object' && obj && 'width' in obj;
|
125
124
|
}
|
126
|
-
/* This Plugin does not need table state */
|
127
|
-
|
128
125
|
|
126
|
+
/* This Plugin does not need table state */
|
129
127
|
class TableMeta {}
|
130
128
|
|
131
129
|
export { ColumnMeta, StickyColumns, TableMeta };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/sticky-columns/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base';\nimport { applyStyles } from '../-private/utils';\n\nimport type { ColumnApi } from '[public-plugin-types]';\nimport type { Column } from '[public-types]';\n\ninterface ColumnOptions {\n /**\n * Whether or not to enable stickiness on the column\n * (default is false)\n *\n * valid values: 'left', 'right', false\n */\n sticky?: boolean | string;\n}\n\nexport interface Signature {\n Options: {\n Column: ColumnOptions;\n };\n Meta: {\n Table: TableMeta;\n Column: ColumnMeta;\n };\n}\n\nexport class StickyColumns extends BasePlugin<Signature> {\n name = 'sticky-columns';\n\n /**\n * This plugin requires that the resizing plugin be present, because the resizing plugin is\n * what manages the base width of the columns.\n *\n * Other width-management plugins can be used instead of ColumnResizing, but they must declare\n * that they manage the width of the columns.\n */\n static requires = ['columnWidth'];\n\n meta = {\n table: TableMeta,\n column: ColumnMeta,\n };\n\n
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/sticky-columns/plugin.ts"],"sourcesContent":["import { cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base';\nimport { applyStyles } from '../-private/utils';\n\nimport type { ColumnApi } from '[public-plugin-types]';\nimport type { Column } from '[public-types]';\n\nconst DEFAULT_Z_INDEX = '8';\n\ninterface ColumnOptions {\n /**\n * Whether or not to enable stickiness on the column\n * (default is false)\n *\n * valid values: 'left', 'right', false\n */\n sticky?: boolean | string;\n}\n\nexport interface Signature {\n Options: {\n Column: ColumnOptions;\n Plugin: {\n /**\n * Opts this plugin out of engaging in the modifier system\n * and instead requires setting a `style` attribute on\n * th / td tags for getting the \"position: sticky\" behovior\n * on columns.\n */\n workaroundForModifierTimingUpdateRFC883?: boolean;\n };\n };\n Meta: {\n Table: TableMeta;\n Column: ColumnMeta;\n };\n}\n\nexport class StickyColumns extends BasePlugin<Signature> {\n name = 'sticky-columns';\n\n /**\n * This plugin requires that the resizing plugin be present, because the resizing plugin is\n * what manages the base width of the columns.\n *\n * Other width-management plugins can be used instead of ColumnResizing, but they must declare\n * that they manage the width of the columns.\n */\n static requires = ['columnWidth'];\n\n meta = {\n table: TableMeta,\n column: ColumnMeta,\n };\n\n conditionallyRemoveStyles = (element: HTMLElement) => {\n if (element.style.getPropertyValue('position') === 'sticky') {\n element.style.removeProperty('position');\n }\n\n if (element.style.getPropertyValue('left')) {\n element.style.left = '';\n }\n\n if (element.style.getPropertyValue('right')) {\n element.style.right = '';\n }\n\n if (element.style.zIndex === DEFAULT_Z_INDEX) {\n element.style.zIndex = '';\n }\n };\n\n headerCellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n\n /**\n * Not yet supported. Pending Ember RFC #883\n *\n * TODO: switch ColumnApi to \"RowApi\", add the row's data\n */\n cellModifier = (element: HTMLElement, { column, table }: ColumnApi) => {\n if (options.forTable(table, StickyColumns).workaroundForModifierTimingUpdateRFC883) {\n return;\n }\n\n let columnMeta = meta.forColumn(column, StickyColumns);\n\n if (columnMeta.isSticky) {\n applyStyles(element, columnMeta.style);\n } else {\n this.conditionallyRemoveStyles(element);\n }\n };\n}\n\n/**\n * @private\n *\n * Contains state and behaviors for the sticiness\n */\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n get isSticky() {\n return this.position !== 'none';\n }\n\n get position(): 'left' | 'right' | 'none' {\n let sticky = options.forColumn(this.column, StickyColumns)?.sticky;\n\n assert(\n `Invalid sticky value, ${sticky}. Valid values: 'left', 'right', false`,\n sticky === 'left' || sticky === 'right' || sticky === false || sticky === undefined\n );\n\n return sticky || 'none';\n }\n\n @cached\n get offset() {\n if (!this.isSticky) {\n return;\n }\n\n if (this.position === 'left') {\n let leftColumns = columns.before(this.column);\n let left = leftColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${left}px`;\n }\n\n if (this.position === 'right') {\n let rightColumns = columns.after(this.column);\n let right = rightColumns.reduce((acc, column) => {\n let columnMeta = meta.withFeature.forColumn(column, 'columnWidth');\n\n if (hasWidth(columnMeta)) {\n return acc + (columnMeta.width ?? 0);\n }\n\n return acc;\n }, 0);\n\n return `${right}px`;\n }\n\n return;\n }\n\n get style(): Partial<Pick<CSSStyleDeclaration, 'position' | 'left' | 'right' | 'zIndex'>> {\n if (this.isSticky) {\n return {\n position: 'sticky',\n [this.position]: this.offset,\n zIndex: DEFAULT_Z_INDEX,\n };\n }\n\n return {};\n }\n}\n\nfunction hasWidth(obj: any): obj is { width?: number } {\n return typeof obj === 'object' && obj && 'width' in obj;\n}\n\n/* This Plugin does not need table state */\nexport class TableMeta {}\n"],"names":["DEFAULT_Z_INDEX","StickyColumns","BasePlugin","table","TableMeta","column","ColumnMeta","element","style","getPropertyValue","removeProperty","left","right","zIndex","options","forTable","workaroundForModifierTimingUpdateRFC883","columnMeta","meta","forColumn","isSticky","applyStyles","conditionallyRemoveStyles","constructor","position","sticky","assert","undefined","offset","leftColumns","columns","before","reduce","acc","withFeature","hasWidth","width","rightColumns","after","cached","obj"],"mappings":";;;;;;;;;AAA2C,IAAA,MAAA,GAAA,cAAA,CAAA,mBAAA,CAAA,cAAA,EAAA,kBAAA,CAAA,CAAA,GAAA,UAAA,CAAA,mBAAA,CAAA,CAAA,MAAA,GAAA,UAAA,CAAA,iCAAA,CAAA,CAAA,MAAA,CAAA;AAS3C,MAAMA,eAAe,GAAG,GAAG,CAAA;AA+BpB,MAAMC,aAAa,SAASC,UAAU,CAAY;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAChD,gBAAgB,CAAA,CAAA;IAAA,eAWhB,CAAA,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,KAAK,EAAEC,SAAS;AAChBC,MAAAA,MAAM,EAAEC,UAAAA;KACT,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,2BAAA,EAE4BC,OAAoB,IAAK;MACpD,IAAIA,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE;AAC3DF,QAAAA,OAAO,CAACC,KAAK,CAACE,cAAc,CAAC,UAAU,CAAC,CAAA;AAC1C,OAAA;MAEA,IAAIH,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,MAAM,CAAC,EAAE;AAC1CF,QAAAA,OAAO,CAACC,KAAK,CAACG,IAAI,GAAG,EAAE,CAAA;AACzB,OAAA;MAEA,IAAIJ,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,OAAO,CAAC,EAAE;AAC3CF,QAAAA,OAAO,CAACC,KAAK,CAACI,KAAK,GAAG,EAAE,CAAA;AA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A,GAAA,MAAA,EAAA;AAoDT,SAASJ,QAAQ,CAACK,GAAQ,EAA6B;EACrD,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,IAAI,OAAO,IAAIA,GAAG,CAAA;AACzD,CAAA;;AAEA;AACO,MAAMpC,SAAS,CAAC;;;;"}
|
@@ -25,25 +25,27 @@ declare class Table<DataType = unknown> extends Resource<Signature<DataType>> {
|
|
25
25
|
[TABLE_KEY]: string;
|
26
26
|
/**
|
27
27
|
* @private
|
28
|
+
*
|
29
|
+
* Unused for now, may be used in the future.
|
30
|
+
* This data is collected along with the scrollContainerWidth, (which is currently in use)
|
28
31
|
*/
|
29
32
|
scrollContainerHeight?: number;
|
30
33
|
/**
|
31
34
|
* @private
|
35
|
+
*
|
36
|
+
* Used to help determine how much space we can give to columns.
|
37
|
+
* As we generate widths for columns, the columns' widths must
|
38
|
+
* add up to about this number.
|
32
39
|
*/
|
33
40
|
scrollContainerWidth?: number;
|
34
41
|
/**
|
35
42
|
* @private
|
43
|
+
*
|
44
|
+
* Lazy way to delay consuming arguments until they are needed.
|
36
45
|
*/
|
37
46
|
args: {
|
38
47
|
named: Signature<DataType>['Named'];
|
39
48
|
};
|
40
|
-
/**
|
41
|
-
* @private
|
42
|
-
*/
|
43
|
-
defaultColumnConfig: {
|
44
|
-
isVisible: boolean;
|
45
|
-
minWidth: number;
|
46
|
-
};
|
47
49
|
/**
|
48
50
|
* @private
|
49
51
|
*/
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { _ as _defineProperty } from './defineProperty-
|
2
|
-
import { _ as _applyDecoratedDescriptor } from './applyDecoratedDescriptor-
|
3
|
-
import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
|
1
|
+
import { _ as _defineProperty } from './defineProperty-35ce617b.js';
|
2
|
+
import { _ as _applyDecoratedDescriptor } from './applyDecoratedDescriptor-6b986a67.js';
|
4
3
|
import { tracked } from '@glimmer/tracking';
|
5
4
|
import { getOwner, setOwner } from '@ember/application';
|
6
5
|
import { assert } from '@ember/debug';
|
7
6
|
import { action } from '@ember/object';
|
8
7
|
import { guidFor } from '@ember/object/internals';
|
8
|
+
import { macroCondition, dependencySatisfies, importSync, isDevelopingApp } from '@embroider/macros';
|
9
9
|
import { modifier } from 'ember-modifier';
|
10
10
|
import { Resource } from 'ember-resources/core';
|
11
11
|
import { map } from 'ember-resources/util/map';
|
@@ -31,7 +31,6 @@ const DEFAULT_COLUMN_CONFIG = {
|
|
31
31
|
isVisible: true,
|
32
32
|
minWidth: 128
|
33
33
|
};
|
34
|
-
|
35
34
|
/**
|
36
35
|
* Because the table is our entry-point object to all the table behaviors,
|
37
36
|
* we need a stable way to know which table we have.
|
@@ -42,28 +41,18 @@ const DEFAULT_COLUMN_CONFIG = {
|
|
42
41
|
* ember-resources.
|
43
42
|
*/
|
44
43
|
const TABLE_KEY = Symbol('__TABLE_KEY__');
|
45
|
-
|
46
44
|
const attachContainer = (element, table) => {
|
47
45
|
assert('Must be installed on an HTMLElement', element instanceof HTMLElement);
|
48
46
|
table.scrollContainerElement = element;
|
49
47
|
};
|
50
|
-
|
51
48
|
let Table = (_class = class Table extends Resource {
|
52
49
|
constructor(...args) {
|
53
50
|
super(...args);
|
54
|
-
|
55
51
|
_defineProperty(this, TABLE_KEY, guidFor(this));
|
56
|
-
|
57
52
|
_initializerDefineProperty(this, "scrollContainerHeight", _descriptor, this);
|
58
|
-
|
59
53
|
_initializerDefineProperty(this, "scrollContainerWidth", _descriptor2, this);
|
60
|
-
|
61
54
|
_initializerDefineProperty(this, "args", _descriptor3, this);
|
62
|
-
|
63
|
-
_defineProperty(this, "defaultColumnConfig", DEFAULT_COLUMN_CONFIG);
|
64
|
-
|
65
55
|
_defineProperty(this, "scrollContainerElement", void 0);
|
66
|
-
|
67
56
|
_defineProperty(this, "modifiers", {
|
68
57
|
container: modifier(element => {
|
69
58
|
let modifiers = this.plugins.map(plugin => plugin.containerModifier);
|
@@ -102,7 +91,6 @@ let Table = (_class = class Table extends Resource {
|
|
102
91
|
eager: false
|
103
92
|
})
|
104
93
|
});
|
105
|
-
|
106
94
|
_defineProperty(this, "rows", map(this, {
|
107
95
|
data: () => {
|
108
96
|
let dataFn = this.args.named?.data;
|
@@ -111,43 +99,60 @@ let Table = (_class = class Table extends Resource {
|
|
111
99
|
},
|
112
100
|
map: datum => new Row(this, datum)
|
113
101
|
}));
|
114
|
-
|
115
102
|
_defineProperty(this, "columns", map(this, {
|
116
103
|
data: () => {
|
117
104
|
let configFn = this.args.named?.columns;
|
118
105
|
if (!configFn) return [];
|
119
|
-
|
106
|
+
let result = configFn() ?? [];
|
107
|
+
if (macroCondition(isDevelopingApp())) {
|
108
|
+
/**
|
109
|
+
* Assertions for a column config to be valid:
|
110
|
+
* - every key must be unique
|
111
|
+
*/
|
112
|
+
let keys = new Set();
|
113
|
+
let allKeys = result.map(columnConfig => columnConfig.key);
|
114
|
+
result.forEach(columnConfig => {
|
115
|
+
if (keys.has(columnConfig.key)) {
|
116
|
+
throw new Error(`Every column key in the table's column config must be unique. ` + `Found duplicate entry: ${columnConfig.key}. ` + `All keys used: ${allKeys}`);
|
117
|
+
}
|
118
|
+
keys.add(columnConfig.key);
|
119
|
+
});
|
120
|
+
}
|
121
|
+
return result;
|
120
122
|
},
|
121
123
|
map: config => {
|
122
|
-
return new Column(this, {
|
124
|
+
return new Column(this, {
|
125
|
+
...DEFAULT_COLUMN_CONFIG,
|
123
126
|
...config
|
124
127
|
});
|
125
128
|
}
|
126
129
|
}));
|
127
130
|
}
|
128
|
-
|
129
131
|
/**
|
130
132
|
* @private
|
131
133
|
*/
|
132
134
|
modify(_, named) {
|
133
135
|
this.args = {
|
134
136
|
named
|
135
|
-
};
|
137
|
+
};
|
136
138
|
|
139
|
+
// only set the preferences once
|
137
140
|
if (!this.preferences) {
|
138
141
|
let {
|
139
142
|
key = guidFor(this),
|
140
143
|
adapter
|
141
|
-
} = named?.preferences ?? {};
|
144
|
+
} = named?.preferences ?? {};
|
145
|
+
|
146
|
+
// TODO: when no key is present,
|
142
147
|
// use "local-storage" preferences.
|
143
148
|
// it does not make sense to use a guid in a user's preferences
|
144
|
-
|
145
149
|
this.preferences = new TablePreferences(key, adapter);
|
146
150
|
} else {
|
147
151
|
// subsequent updates to args
|
148
152
|
this.resetScrollContainer();
|
149
153
|
}
|
150
154
|
}
|
155
|
+
|
151
156
|
/**
|
152
157
|
* Collection of utility modifiers that are the result of composing modifiers
|
153
158
|
* from plugins.
|
@@ -158,7 +163,6 @@ let Table = (_class = class Table extends Resource {
|
|
158
163
|
* These are all no-use, no-cost utilities
|
159
164
|
*/
|
160
165
|
|
161
|
-
|
162
166
|
/**
|
163
167
|
* @private
|
164
168
|
*
|
@@ -172,27 +176,26 @@ let Table = (_class = class Table extends Resource {
|
|
172
176
|
return plugins.map(tuple => {
|
173
177
|
// We don't need the options here
|
174
178
|
let [PluginClass] = tuple;
|
175
|
-
|
176
179
|
if (typeof PluginClass === 'function') {
|
177
180
|
let plugin = new PluginClass(this);
|
178
181
|
let owner = getOwner(this);
|
179
182
|
assert(`The Table does not have an owner. cannot create a plugin without an owner`, owner);
|
180
183
|
setOwner(plugin, owner);
|
181
184
|
return plugin;
|
182
|
-
}
|
183
|
-
// TODO: add test coverage around using classless plugins
|
184
|
-
|
185
|
+
}
|
185
186
|
|
187
|
+
// This is a plugin object, rather than a class
|
188
|
+
// TODO: add test coverage around using classless plugins
|
186
189
|
return PluginClass;
|
187
190
|
});
|
188
191
|
}
|
192
|
+
|
189
193
|
/**
|
190
194
|
* Get the active plugin instance for the given plugin class
|
191
195
|
*/
|
192
|
-
|
193
|
-
|
194
196
|
pluginOf(klass) {
|
195
197
|
let result = this.plugins.find(plugin => plugin instanceof klass);
|
198
|
+
|
196
199
|
/**
|
197
200
|
* This is an unsafe cast, because Instance could be unrelated to any of the types
|
198
201
|
* that matches Plugin[]
|
@@ -202,20 +205,17 @@ let Table = (_class = class Table extends Resource {
|
|
202
205
|
* effectively narrow for what we want (combined with TS being clunky around
|
203
206
|
* comparing Instance and Class types).
|
204
207
|
*/
|
205
|
-
|
206
208
|
return result;
|
207
209
|
}
|
210
|
+
|
208
211
|
/**
|
209
212
|
* @private
|
210
213
|
*
|
211
214
|
* used by other private APIs
|
212
215
|
*/
|
213
|
-
|
214
|
-
|
215
216
|
get config() {
|
216
217
|
return this.args.named;
|
217
218
|
}
|
218
|
-
|
219
219
|
/**
|
220
220
|
* @private
|
221
221
|
*/
|
@@ -223,11 +223,9 @@ let Table = (_class = class Table extends Resource {
|
|
223
223
|
if (!this.scrollContainerElement) return;
|
224
224
|
this.scrollContainerElement.scrollTop = 0;
|
225
225
|
}
|
226
|
-
|
227
226
|
resetToDefaults() {
|
228
227
|
this.plugins.forEach(plugin => plugin.reset?.());
|
229
228
|
}
|
230
|
-
|
231
229
|
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "scrollContainerHeight", [tracked], {
|
232
230
|
configurable: true,
|
233
231
|
enumerable: true,
|
@@ -246,4 +244,4 @@ let Table = (_class = class Table extends Resource {
|
|
246
244
|
}), _applyDecoratedDescriptor(_class.prototype, "plugins", [cached], Object.getOwnPropertyDescriptor(_class.prototype, "plugins"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetScrollContainer", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetScrollContainer"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetToDefaults", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetToDefaults"), _class.prototype)), _class);
|
247
245
|
|
248
246
|
export { TABLE_KEY as T, _initializerDefineProperty as _, Table as a };
|
249
|
-
//# sourceMappingURL=table-
|
247
|
+
//# sourceMappingURL=table-0cbd2720.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table-0cbd2720.js","sources":["../../node_modules/.pnpm/@babel+runtime@7.20.1/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../src/-private/table.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","import { cached, tracked } from '@glimmer/tracking';\nimport { getOwner, setOwner } from '@ember/application';\nimport { assert } from '@ember/debug';\nimport { action } from '@ember/object';\nimport { guidFor } from '@ember/object/internals';\n\nimport { isDevelopingApp, macroCondition } from '@embroider/macros';\nimport { modifier } from 'ember-modifier';\nimport { Resource } from 'ember-resources/core';\nimport { map } from 'ember-resources/util/map';\n\nimport { normalizePluginsConfig, verifyPlugins } from '../plugins/-private/utils';\nimport { Column } from './column';\nimport { TablePreferences } from './preferences';\nimport { Row } from './row';\nimport { composeFunctionModifiers } from './utils';\n\nimport type { BasePlugin, Plugin } from '../plugins';\nimport type { Class } from '[private-types]';\nimport type { Destructor, TableConfig } from '#interfaces';\n\nconst DEFAULT_COLUMN_CONFIG = {\n isVisible: true,\n minWidth: 128,\n};\n\ninterface Signature<DataType> {\n Named: TableConfig<DataType>;\n}\n\n/**\n * Because the table is our entry-point object to all the table behaviors,\n * we need a stable way to know which table we have.\n * Normally, this could be done with referential integrity / identity.\n * However, due to how resources are implemented, if the consumer opts to\n * not use the `@use` decorator, then proxies get involved.\n * The proxies don't maintain instanceof checks, which may be a bug in\n * ember-resources.\n */\nexport const TABLE_KEY = Symbol('__TABLE_KEY__');\n\nconst attachContainer = (element: Element, table: Table) => {\n assert('Must be installed on an HTMLElement', element instanceof HTMLElement);\n\n table.scrollContainerElement = element;\n};\n\nexport class Table<DataType = unknown> extends Resource<Signature<DataType>> {\n /**\n * @private\n */\n [TABLE_KEY] = guidFor(this);\n\n /**\n * @private\n *\n * Unused for now, may be used in the future.\n * This data is collected along with the scrollContainerWidth, (which is currently in use)\n */\n @tracked scrollContainerHeight?: number;\n\n /**\n * @private\n *\n * Used to help determine how much space we can give to columns.\n * As we generate widths for columns, the columns' widths must\n * add up to about this number.\n */\n @tracked scrollContainerWidth?: number;\n\n /**\n * @private\n *\n * Lazy way to delay consuming arguments until they are needed.\n */\n @tracked declare args: { named: Signature<DataType>['Named'] };\n\n /**\n * @private\n */\n scrollContainerElement?: HTMLElement;\n\n /**\n * Interact with, save, modify, etc the preferences for the table,\n * plugins, columns, etc\n */\n declare preferences: TablePreferences;\n\n /**\n * @private\n */\n modify(_: [] | undefined, named: Signature<DataType>['Named']) {\n this.args = { named };\n\n // only set the preferences once\n if (!this.preferences) {\n let { key = guidFor(this), adapter } = named?.preferences ?? {};\n\n // TODO: when no key is present,\n // use \"local-storage\" preferences.\n // it does not make sense to use a guid in a user's preferences\n this.preferences = new TablePreferences(key, adapter);\n } else {\n // subsequent updates to args\n this.resetScrollContainer();\n }\n }\n\n /**\n * Collection of utility modifiers that are the result of composing modifiers\n * from plugins.\n *\n * Using this is optional, and you can \"just\" use modifiers from specific plugins\n * in specific places if you wish -- but these exists as a \"convenience\".\n *\n * These are all no-use, no-cost utilities\n */\n modifiers = {\n container: modifier(\n (element: HTMLElement): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.containerModifier);\n let composed = composeFunctionModifiers([attachContainer, ...modifiers]);\n\n return composed(element, this);\n },\n { eager: false }\n ),\n\n // resize: ResizeModifier,\n // TODO: switch to composing real modifiers once \"curry\" and \"compose\"\n // RFCs are accepted and implemented\n //\n // Atm the moment, if _any_ header modifier's tracked data changes,\n // all the functions for all of the plugins run again.\n //\n // With curried+composed modifiers, only the plugin's headerModifier\n // that has tracked changes would run, leaving the other modifiers alone\n columnHeader: modifier(\n (element: HTMLElement, [column]: [Column<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.headerCellModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { column, table: this });\n },\n { eager: false }\n ),\n\n row: modifier(\n (element: HTMLElement, [row]: [Row<DataType>]): Destructor => {\n let modifiers = this.plugins.map((plugin) => plugin.rowModifier);\n let composed = composeFunctionModifiers(modifiers);\n\n return composed(element, { row, table: this });\n },\n { eager: false }\n ),\n };\n\n /**\n * @private\n *\n * For all configured plugins, instantiates each one.\n * If the plugins argument changes to the Table (either directly or through\n * headlessTable, all state is lost and re-created)\n */\n @cached\n get plugins(): Plugin[] {\n let plugins = normalizePluginsConfig(this.args.named?.plugins);\n\n verifyPlugins(plugins);\n\n return plugins.map((tuple) => {\n // We don't need the options here\n let [PluginClass] = tuple;\n\n if (typeof PluginClass === 'function') {\n let plugin = new PluginClass(this);\n\n let owner = getOwner(this);\n\n assert(`The Table does not have an owner. cannot create a plugin without an owner`, owner);\n setOwner(plugin, owner);\n\n return plugin;\n }\n\n // This is a plugin object, rather than a class\n // TODO: add test coverage around using classless plugins\n return PluginClass;\n });\n }\n\n /**\n * Get the active plugin instance for the given plugin class\n */\n pluginOf<Instance extends BasePlugin<any>>(klass: Class<Instance>): Instance | undefined {\n let result = this.plugins.find((plugin) => plugin instanceof klass);\n\n /**\n * This is an unsafe cast, because Instance could be unrelated to any of the types\n * that matches Plugin[]\n *\n * For example, `table.pluginOf(MyCustomPlugin)`, where MyCustomPlugin isn't in the\n * `plugins` list. This partially a problem with how Array.prototype.find doesn't\n * effectively narrow for what we want (combined with TS being clunky around\n * comparing Instance and Class types).\n */\n return result as unknown as Instance | undefined;\n }\n\n /**\n * @private\n *\n * used by other private APIs\n */\n get config() {\n return this.args.named;\n }\n\n rows = map(this, {\n data: () => {\n let dataFn = this.args.named?.data;\n\n if (!dataFn) return [];\n\n return dataFn() ?? [];\n },\n map: (datum) => new Row(this, datum),\n });\n\n columns = map(this, {\n data: () => {\n let configFn = this.args.named?.columns;\n\n if (!configFn) return [];\n\n let result = configFn() ?? [];\n\n if (macroCondition(isDevelopingApp())) {\n /**\n * Assertions for a column config to be valid:\n * - every key must be unique\n */\n let keys = new Set();\n let allKeys = result.map((columnConfig) => columnConfig.key);\n\n result.forEach((columnConfig) => {\n if (keys.has(columnConfig.key)) {\n throw new Error(\n `Every column key in the table's column config must be unique. ` +\n `Found duplicate entry: ${columnConfig.key}. ` +\n `All keys used: ${allKeys}`\n );\n }\n\n keys.add(columnConfig.key);\n });\n }\n\n return result;\n },\n map: (config) => {\n return new Column<DataType>(this, { ...DEFAULT_COLUMN_CONFIG, ...config });\n },\n });\n\n /**\n * @private\n */\n @action\n resetScrollContainer() {\n if (!this.scrollContainerElement) return;\n\n this.scrollContainerElement.scrollTop = 0;\n }\n\n @action\n resetToDefaults() {\n this.plugins.forEach((plugin) => plugin.reset?.());\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","DEFAULT_COLUMN_CONFIG","isVisible","minWidth","TABLE_KEY","Symbol","attachContainer","element","table","assert","HTMLElement","scrollContainerElement","Table","Resource","guidFor","container","modifier","modifiers","plugins","map","plugin","containerModifier","composed","composeFunctionModifiers","eager","columnHeader","column","headerCellModifier","row","rowModifier","data","dataFn","args","named","datum","Row","configFn","columns","result","macroCondition","isDevelopingApp","keys","Set","allKeys","columnConfig","key","forEach","has","Error","add","config","Column","modify","_","preferences","adapter","TablePreferences","resetScrollContainer","normalizePluginsConfig","verifyPlugins","tuple","PluginClass","owner","getOwner","setOwner","pluginOf","klass","find","scrollTop","resetToDefaults","reset","tracked","cached","action"],"mappings":";;;;;;;;;;;;;;;;;AAAe,SAASA,0BAA0B,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA,MAAM,CAACC,cAAc,CAACL,MAAM,EAAEC,QAAQ,EAAE;IACtCK,UAAU,EAAEJ,UAAU,CAACI,UAAU;IACjCC,YAAY,EAAEL,UAAU,CAACK,YAAY;IACrCC,QAAQ,EAAEN,UAAU,CAACM,QAAQ;AAC7BC,IAAAA,KAAK,EAAEP,UAAU,CAACQ,WAAW,GAAGR,UAAU,CAACQ,WAAW,CAACC,IAAI,CAACR,OAAO,CAAC,GAAG,KAAK,CAAA;AAC9E,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ectors) {
|
|
6
6
|
assert(`Can't use the dragLeft/dragRight/resize helpers without a \`resizeHandle\` selector`, selectors.resizeHandle);
|
7
7
|
let element = parent.querySelector(selectors.resizeHandle);
|
8
8
|
assert(`Can't resize without a handle`, element);
|
9
|
+
|
9
10
|
/**
|
10
11
|
* Start the click in exactly the middle of the element.
|
11
12
|
* "startX" is the horizontal middle of "element"
|
12
13
|
*/
|
13
|
-
|
14
14
|
let rect = element.getBoundingClientRect();
|
15
15
|
let startX = (rect.right + rect.left) / 2;
|
16
16
|
let targetX = startX + delta;
|
@@ -27,33 +27,29 @@ function createHelpers(selectors) {
|
|
27
27
|
button: 0
|
28
28
|
});
|
29
29
|
await settled();
|
30
|
+
|
30
31
|
/**
|
31
32
|
* This has been super finnicky... :(
|
32
33
|
*/
|
33
|
-
|
34
34
|
await new Promise(resolve => setTimeout(resolve, 100));
|
35
35
|
await requestAnimationFrameSettled();
|
36
36
|
}
|
37
|
-
|
38
37
|
function horizontalScrollElement() {
|
39
38
|
assert(`Can't use scrollRight/swipeLeft helpers without a \`scrollContainer\` selector`, selectors.scrollContainer);
|
40
39
|
let element = find(selectors.scrollContainer);
|
41
40
|
assert(`scroll container not found`, element instanceof HTMLElement);
|
42
41
|
return element;
|
43
42
|
}
|
44
|
-
|
45
43
|
async function scrollRight(distance) {
|
46
44
|
let element = horizontalScrollElement();
|
47
45
|
element.scrollLeft += distance;
|
48
46
|
await requestAnimationFrameSettled();
|
49
47
|
}
|
50
|
-
|
51
48
|
async function scrollLeft(distance) {
|
52
49
|
let element = horizontalScrollElement();
|
53
50
|
element.scrollLeft -= distance;
|
54
51
|
await requestAnimationFrameSettled();
|
55
52
|
}
|
56
|
-
|
57
53
|
return {
|
58
54
|
dragLeft: (column, amount) => resize(column, -amount),
|
59
55
|
dragRight: (column, amount) => resize(column, amount),
|