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
package/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
1
|
+
import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
|
2
2
|
import { expectTypeOf } from 'expect-type';
|
3
3
|
import { BasePlugin } from '../../plugins/-private/base.js';
|
4
4
|
import '@ember/debug';
|
@@ -6,25 +6,21 @@ import '@ember/debug';
|
|
6
6
|
class A extends BasePlugin {
|
7
7
|
constructor(...args) {
|
8
8
|
super(...args);
|
9
|
-
|
10
9
|
_defineProperty(this, "name", 'a plugin');
|
11
10
|
}
|
12
|
-
|
13
11
|
}
|
14
|
-
|
15
12
|
let x = 0;
|
16
|
-
let a = new A(x);
|
13
|
+
let a = new A(x);
|
14
|
+
|
15
|
+
///////////////////////////////////////////////////
|
17
16
|
// Meta instantiation
|
18
17
|
///////////////////////////////////////////////////
|
19
|
-
|
20
18
|
if (a.meta?.table) {
|
21
19
|
expectTypeOf(new a.meta.table()).toEqualTypeOf();
|
22
20
|
}
|
23
|
-
|
24
21
|
if (a.meta?.column) {
|
25
22
|
expectTypeOf(new a.meta.column()).toEqualTypeOf();
|
26
23
|
}
|
27
|
-
|
28
24
|
if (a.meta?.row) {
|
29
25
|
expectTypeOf(new a.meta.row()).toEqualTypeOf();
|
30
26
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin-properties.test.js","sources":["../../../src/-private/-type-tests/plugin-properties.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins';\n\nimport type { Table } from '[public-types]';\n\nclass TableMeta {\n a = 'a';\n}\nclass ColumnMeta {\n b = 'b';\n}\nclass RowMeta {\n c = 'c';\n}\nclass A extends BasePlugin<{ Meta: { Table: TableMeta; Column: ColumnMeta; Row: RowMeta } }> {\n name = 'a plugin';\n}\n\nlet x = 0 as unknown as Table;\nlet a = new A(x);\n\n///////////////////////////////////////////////////\n// Meta instantiation\n///////////////////////////////////////////////////\nif (a.meta?.table) {\n expectTypeOf(new a.meta.table()).toEqualTypeOf<TableMeta>();\n}\n\nif (a.meta?.column) {\n expectTypeOf(new a.meta.column()).toEqualTypeOf<ColumnMeta>();\n}\n\nif (a.meta?.row) {\n expectTypeOf(new a.meta.row()).toEqualTypeOf<RowMeta>();\n}\n"],"names":["A","BasePlugin","x","a","meta","table","expectTypeOf","toEqualTypeOf","column","row"],"mappings":";;;;;AAeA,MAAMA,
|
1
|
+
{"version":3,"file":"plugin-properties.test.js","sources":["../../../src/-private/-type-tests/plugin-properties.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins';\n\nimport type { Table } from '[public-types]';\n\nclass TableMeta {\n a = 'a';\n}\nclass ColumnMeta {\n b = 'b';\n}\nclass RowMeta {\n c = 'c';\n}\nclass A extends BasePlugin<{ Meta: { Table: TableMeta; Column: ColumnMeta; Row: RowMeta } }> {\n name = 'a plugin';\n}\n\nlet x = 0 as unknown as Table;\nlet a = new A(x);\n\n///////////////////////////////////////////////////\n// Meta instantiation\n///////////////////////////////////////////////////\nif (a.meta?.table) {\n expectTypeOf(new a.meta.table()).toEqualTypeOf<TableMeta>();\n}\n\nif (a.meta?.column) {\n expectTypeOf(new a.meta.column()).toEqualTypeOf<ColumnMeta>();\n}\n\nif (a.meta?.row) {\n expectTypeOf(new a.meta.row()).toEqualTypeOf<RowMeta>();\n}\n"],"names":["A","BasePlugin","x","a","meta","table","expectTypeOf","toEqualTypeOf","column","row"],"mappings":";;;;;AAeA,MAAMA,CAAC,SAASC,UAAU,CAAmE;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EACpF,UAAU,CAAA,CAAA;AAAA,GAAA;AACnB,CAAA;AAEA,IAAIC,CAAC,GAAG,CAAqB,CAAA;AAC7B,IAAIC,CAAC,GAAG,IAAIH,CAAC,CAACE,CAAC,CAAC,CAAA;;AAEhB;AACA;AACA;AACA,IAAIC,CAAC,CAACC,IAAI,EAAEC,KAAK,EAAE;EACjBC,YAAY,CAAC,IAAIH,CAAC,CAACC,IAAI,CAACC,KAAK,EAAE,CAAC,CAACE,aAAa,EAAa,CAAA;AAC7D,CAAA;AAEA,IAAIJ,CAAC,CAACC,IAAI,EAAEI,MAAM,EAAE;EAClBF,YAAY,CAAC,IAAIH,CAAC,CAACC,IAAI,CAACI,MAAM,EAAE,CAAC,CAACD,aAAa,EAAc,CAAA;AAC/D,CAAA;AAEA,IAAIJ,CAAC,CAACC,IAAI,EAAEK,GAAG,EAAE;EACfH,YAAY,CAAC,IAAIH,CAAC,CAACC,IAAI,CAACK,GAAG,EAAE,CAAC,CAACF,aAAa,EAAW,CAAA;AACzD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin-with.test.js","sources":["../../../src/-private/-type-tests/plugin-with.test.ts"],"sourcesContent":["import { DataSorting } from '../../plugins/data-sorting';\nimport { RowSelection } from '../../plugins/row-selection';\n\nimport type { SortItem } from '../../plugins/data-sorting';\n\nRowSelection.with(() => {\n let simpleOptions = {\n selection: new Set<number>(),\n onSelect: (item: number) => console.debug(item),\n onDeselect: (item: number) => console.debug(item),\n };\n\n return simpleOptions;\n});\n\nDataSorting.with(() => {\n let simpleOptions = {\n onSort: (sorts: SortItem<number>[]) => console.debug(sorts),\n sorts: [] as unknown as SortItem<number>[],\n };\n\n return simpleOptions;\n});\n"],"names":["RowSelection","with","simpleOptions","selection","Set","onSelect","item","console","debug","onDeselect","DataSorting","onSort","sorts"],"mappings":";;;;;AAKAA,YAAY,CAACC,
|
1
|
+
{"version":3,"file":"plugin-with.test.js","sources":["../../../src/-private/-type-tests/plugin-with.test.ts"],"sourcesContent":["import { DataSorting } from '../../plugins/data-sorting';\nimport { RowSelection } from '../../plugins/row-selection';\n\nimport type { SortItem } from '../../plugins/data-sorting';\n\nRowSelection.with(() => {\n let simpleOptions = {\n selection: new Set<number>(),\n onSelect: (item: number) => console.debug(item),\n onDeselect: (item: number) => console.debug(item),\n };\n\n return simpleOptions;\n});\n\nDataSorting.with(() => {\n let simpleOptions = {\n onSort: (sorts: SortItem<number>[]) => console.debug(sorts),\n sorts: [] as unknown as SortItem<number>[],\n };\n\n return simpleOptions;\n});\n"],"names":["RowSelection","with","simpleOptions","selection","Set","onSelect","item","console","debug","onDeselect","DataSorting","onSort","sorts"],"mappings":";;;;;AAKAA,YAAY,CAACC,IAAI,CAAC,MAAM;AACtB,EAAA,IAAIC,aAAa,GAAG;IAClBC,SAAS,EAAE,IAAIC,GAAG,EAAU;IAC5BC,QAAQ,EAAGC,IAAY,IAAKC,OAAO,CAACC,KAAK,CAACF,IAAI,CAAC;AAC/CG,IAAAA,UAAU,EAAGH,IAAY,IAAKC,OAAO,CAACC,KAAK,CAACF,IAAI,CAAA;GACjD,CAAA;AAED,EAAA,OAAOJ,aAAa,CAAA;AACtB,CAAC,CAAC,CAAA;AAEFQ,OAAW,CAACT,IAAI,CAAC,MAAM;AACrB,EAAA,IAAIC,aAAa,GAAG;IAClBS,MAAM,EAAGC,KAAyB,IAAKL,OAAO,CAACC,KAAK,CAACI,KAAK,CAAC;AAC3DA,IAAAA,KAAK,EAAE,EAAA;GACR,CAAA;AAED,EAAA,OAAOV,aAAa,CAAA;AACtB,CAAC,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
1
|
+
import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
|
2
2
|
import { options, meta, preferences, BasePlugin } from '../../plugins/-private/base.js';
|
3
3
|
import '@ember/debug';
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
@@ -7,30 +7,31 @@ import '../../plugins/data-sorting/types.js';
|
|
7
7
|
|
8
8
|
// This value is irrelevant for the tests it's used in
|
9
9
|
const x = 0;
|
10
|
-
const y = 0;
|
11
|
-
|
10
|
+
const y = 0;
|
12
11
|
class SimplePlugin extends BasePlugin {
|
13
12
|
constructor(...args) {
|
14
13
|
super(...args);
|
15
|
-
|
16
14
|
_defineProperty(this, "name", 'my-test-plugin');
|
17
15
|
}
|
16
|
+
}
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
// Options
|
22
19
|
expectTypeOf(options.forTable(x, SimplePlugin)).toEqualTypeOf();
|
23
|
-
expectTypeOf(options.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
20
|
+
expectTypeOf(options.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
24
21
|
|
22
|
+
// Meta
|
25
23
|
expectTypeOf(meta.forTable(x, SimplePlugin)).toEqualTypeOf();
|
26
|
-
expectTypeOf(meta.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
24
|
+
expectTypeOf(meta.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
25
|
+
|
26
|
+
// Preferences
|
27
27
|
|
28
28
|
expectTypeOf(preferences.forTable(x, SimplePlugin)).toEqualTypeOf();
|
29
|
-
expectTypeOf(preferences.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
29
|
+
expectTypeOf(preferences.forColumn(y, SimplePlugin)).toEqualTypeOf();
|
30
30
|
// Options
|
31
31
|
expectTypeOf(options.forTable(x, Sorting)).toEqualTypeOf();
|
32
|
-
expectTypeOf(options.forColumn(y, Sorting)).toEqualTypeOf();
|
32
|
+
expectTypeOf(options.forColumn(y, Sorting)).toEqualTypeOf();
|
33
33
|
|
34
|
+
// Meta
|
34
35
|
expectTypeOf(meta.forTable(x, Sorting)).toEqualTypeOf();
|
35
36
|
expectTypeOf(meta.forColumn(y, Sorting)).toEqualTypeOf();
|
36
37
|
//# sourceMappingURL=plugins-accessors.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugins-accessors.test.js","sources":["../../../src/-private/-type-tests/plugins-accessors.test.ts"],"sourcesContent":["import { BasePlugin, meta, options, preferences } from 'ember-headless-table/plugins';\nimport { expectTypeOf } from 'expect-type';\n\nimport type { Column, Table } from '[public-types]';\n\n// This value is irrelevant for the tests it's used in\nconst x = 0 as unknown as Table<unknown>;\nconst y = 0 as unknown as Column<unknown>;\n\n//////////////////////////////////////////////\n// A SimplePlugin\n//////////////////////////////////////////////\nclass ATableMeta {\n isEnabled = true;\n}\nclass AColumnMeta {\n isPinned = 1;\n}\nclass ARowMeta {\n isARow = true;\n}\ninterface AOptions {\n enabled?: boolean;\n}\ninterface AColumnOptions {\n isPinned?: boolean;\n}\n\ninterface SignatureA {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nclass SimplePlugin<Signature = SignatureA> extends BasePlugin<Signature> {\n name = 'my-test-plugin';\n}\n\n// Options\nexpectTypeOf(options.forTable(x, SimplePlugin)).toEqualTypeOf<AOptions>();\nexpectTypeOf(options.forColumn(y, SimplePlugin)).toEqualTypeOf<AColumnOptions>();\n\n// Meta\nexpectTypeOf(meta.forTable(x, SimplePlugin)).toEqualTypeOf<ATableMeta>();\nexpectTypeOf(meta.forColumn(y, SimplePlugin)).toEqualTypeOf<AColumnMeta>();\n\n// Preferences\ninterface MapLite {\n get(key: string): unknown;\n set(key: string, value: unknown): void | undefined;\n delete(key: string): void | undefined;\n}\nexpectTypeOf(preferences.forTable(x, SimplePlugin)).toEqualTypeOf<MapLite>();\nexpectTypeOf(preferences.forColumn(y, SimplePlugin)).toEqualTypeOf<MapLite>();\n\n//////////////////////////////////////////////\n// A Real plugin\n//////////////////////////////////////////////\n\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Signature as DataSortingSignature } from '../../plugins/data-sorting';\n\n// Options\nexpectTypeOf(options.forTable(x, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Options']['Plugin']\n>();\nexpectTypeOf(options.forColumn(y, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Options']['Column']\n>();\n\n// Meta\nexpectTypeOf(meta.forTable(x, DataSorting)).toEqualTypeOf<DataSortingSignature['Meta']['Table']>();\nexpectTypeOf(meta.forColumn(y, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Meta']['Column']\n>();\n"],"names":["x","y","SimplePlugin","BasePlugin","expectTypeOf","options","forTable","toEqualTypeOf","forColumn","meta","preferences","DataSorting"],"mappings":";;;;;;;AAKA;AACA,MAAMA,CAAC,GAAG,
|
1
|
+
{"version":3,"file":"plugins-accessors.test.js","sources":["../../../src/-private/-type-tests/plugins-accessors.test.ts"],"sourcesContent":["import { BasePlugin, meta, options, preferences } from 'ember-headless-table/plugins';\nimport { expectTypeOf } from 'expect-type';\n\nimport type { Column, Table } from '[public-types]';\n\n// This value is irrelevant for the tests it's used in\nconst x = 0 as unknown as Table<unknown>;\nconst y = 0 as unknown as Column<unknown>;\n\n//////////////////////////////////////////////\n// A SimplePlugin\n//////////////////////////////////////////////\nclass ATableMeta {\n isEnabled = true;\n}\nclass AColumnMeta {\n isPinned = 1;\n}\nclass ARowMeta {\n isARow = true;\n}\ninterface AOptions {\n enabled?: boolean;\n}\ninterface AColumnOptions {\n isPinned?: boolean;\n}\n\ninterface SignatureA {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nclass SimplePlugin<Signature = SignatureA> extends BasePlugin<Signature> {\n name = 'my-test-plugin';\n}\n\n// Options\nexpectTypeOf(options.forTable(x, SimplePlugin)).toEqualTypeOf<AOptions>();\nexpectTypeOf(options.forColumn(y, SimplePlugin)).toEqualTypeOf<AColumnOptions>();\n\n// Meta\nexpectTypeOf(meta.forTable(x, SimplePlugin)).toEqualTypeOf<ATableMeta>();\nexpectTypeOf(meta.forColumn(y, SimplePlugin)).toEqualTypeOf<AColumnMeta>();\n\n// Preferences\ninterface MapLite {\n get(key: string): unknown;\n set(key: string, value: unknown): void | undefined;\n delete(key: string): void | undefined;\n}\nexpectTypeOf(preferences.forTable(x, SimplePlugin)).toEqualTypeOf<MapLite>();\nexpectTypeOf(preferences.forColumn(y, SimplePlugin)).toEqualTypeOf<MapLite>();\n\n//////////////////////////////////////////////\n// A Real plugin\n//////////////////////////////////////////////\n\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Signature as DataSortingSignature } from '../../plugins/data-sorting';\n\n// Options\nexpectTypeOf(options.forTable(x, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Options']['Plugin']\n>();\nexpectTypeOf(options.forColumn(y, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Options']['Column']\n>();\n\n// Meta\nexpectTypeOf(meta.forTable(x, DataSorting)).toEqualTypeOf<DataSortingSignature['Meta']['Table']>();\nexpectTypeOf(meta.forColumn(y, DataSorting)).toEqualTypeOf<\n DataSortingSignature['Meta']['Column']\n>();\n"],"names":["x","y","SimplePlugin","BasePlugin","expectTypeOf","options","forTable","toEqualTypeOf","forColumn","meta","preferences","DataSorting"],"mappings":";;;;;;;AAKA;AACA,MAAMA,CAAC,GAAG,CAA8B,CAAA;AACxC,MAAMC,CAAC,GAAG,CAA+B,CAAA;AAiCzC,MAAMC,YAAY,SAAiCC,UAAU,CAAY;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAChE,gBAAgB,CAAA,CAAA;AAAA,GAAA;AACzB,CAAA;;AAEA;AACAC,YAAY,CAACC,OAAO,CAACC,QAAQ,CAACN,CAAC,EAAEE,YAAY,CAAC,CAAC,CAACK,aAAa,EAAY,CAAA;AACzEH,YAAY,CAACC,OAAO,CAACG,SAAS,CAACP,CAAC,EAAEC,YAAY,CAAC,CAAC,CAACK,aAAa,EAAkB,CAAA;;AAEhF;AACAH,YAAY,CAACK,IAAI,CAACH,QAAQ,CAACN,CAAC,EAAEE,YAAY,CAAC,CAAC,CAACK,aAAa,EAAc,CAAA;AACxEH,YAAY,CAACK,IAAI,CAACD,SAAS,CAACP,CAAC,EAAEC,YAAY,CAAC,CAAC,CAACK,aAAa,EAAe,CAAA;;AAE1E;;AAMAH,YAAY,CAACM,WAAW,CAACJ,QAAQ,CAACN,CAAC,EAAEE,YAAY,CAAC,CAAC,CAACK,aAAa,EAAW,CAAA;AAC5EH,YAAY,CAACM,WAAW,CAACF,SAAS,CAACP,CAAC,EAAEC,YAAY,CAAC,CAAC,CAACK,aAAa,EAAW,CAAA;AAU7E;AACAH,YAAY,CAACC,OAAO,CAACC,QAAQ,CAACN,CAAC,EAAEW,OAAW,CAAC,CAAC,CAACJ,aAAa,EAEzD,CAAA;AACHH,YAAY,CAACC,OAAO,CAACG,SAAS,CAACP,CAAC,EAAEU,OAAW,CAAC,CAAC,CAACJ,aAAa,EAE1D,CAAA;;AAEH;AACAH,YAAY,CAACK,IAAI,CAACH,QAAQ,CAACN,CAAC,EAAEW,OAAW,CAAC,CAAC,CAACJ,aAAa,EAAyC,CAAA;AAClGH,YAAY,CAACK,IAAI,CAACD,SAAS,CAACP,CAAC,EAAEU,OAAW,CAAC,CAAC,CAACJ,aAAa,EAEvD"}
|
@@ -2,13 +2,14 @@ import { expectTypeOf } from 'expect-type';
|
|
2
2
|
import '../../plugins/-private/base.js';
|
3
3
|
import '@ember/debug';
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
expectTypeOf().toEqualTypeOf(); // Tests that we can get the generic type off of a sub-type of BasePlugin
|
8
|
-
|
9
|
-
expectTypeOf().toEqualTypeOf(); // Tests that we can get the generic off of a sub-type passed to BasePlugin
|
5
|
+
// Test the tests
|
6
|
+
expectTypeOf().toEqualTypeOf();
|
10
7
|
|
11
|
-
|
8
|
+
// Tests that we can pluck the generic off of BasePlugin
|
9
|
+
expectTypeOf().toEqualTypeOf();
|
12
10
|
|
11
|
+
// Tests that we can get the generic type off of a sub-type of BasePlugin
|
12
|
+
expectTypeOf().toEqualTypeOf();
|
13
|
+
expectTypeOf().toEqualTypeOf();
|
13
14
|
expectTypeOf().toEqualTypeOf();
|
14
15
|
//# sourceMappingURL=plugins-signature-from.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugins-signature-from.test.js","sources":["../../../src/-private/-type-tests/plugins-signature-from.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins';\n\nimport type { SignatureFrom } from '../../plugins/-private/base';\n\nclass ATableMeta {\n a = 1;\n}\nclass AColumnMeta {\n ac = 1;\n}\nclass ARowMeta {\n ar = 1;\n}\nclass AOptions {\n ao = 1;\n}\nclass AColumnOptions {\n aco = 1;\n}\n\ninterface SignatureA {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nclass PluginA<Signature = SignatureA> extends BasePlugin<Signature> {\n name = 'my-test-plugin';\n}\n\n// Test the tests\nexpectTypeOf<SignatureA>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can pluck the generic off of BasePlugin\nexpectTypeOf<SignatureFrom<BasePlugin<SignatureA>>>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can get the generic type off of a sub-type of BasePlugin\nexpectTypeOf<SignatureFrom<PluginA>>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can get the generic off of a sub-type passed to BasePlugin\nclass PluginC extends BasePlugin<SignatureA> {\n name = 'plugin-c';\n}\nexpectTypeOf<SignatureFrom<PluginC>>().toEqualTypeOf<SignatureA>();\n\n///////////////////////////////////////////\n\nclass PluginB extends BasePlugin<{ Meta: { Table: ATableMeta } }> {\n name = 'plugin-b';\n}\n\nexpectTypeOf<SignatureFrom<PluginB>>().toEqualTypeOf<{\n Meta: {\n Table: ATableMeta;\n };\n}>();\n"],"names":["expectTypeOf","toEqualTypeOf"],"mappings":";;;;
|
1
|
+
{"version":3,"file":"plugins-signature-from.test.js","sources":["../../../src/-private/-type-tests/plugins-signature-from.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins';\n\nimport type { SignatureFrom } from '../../plugins/-private/base';\n\nclass ATableMeta {\n a = 1;\n}\nclass AColumnMeta {\n ac = 1;\n}\nclass ARowMeta {\n ar = 1;\n}\nclass AOptions {\n ao = 1;\n}\nclass AColumnOptions {\n aco = 1;\n}\n\ninterface SignatureA {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nclass PluginA<Signature = SignatureA> extends BasePlugin<Signature> {\n name = 'my-test-plugin';\n}\n\n// Test the tests\nexpectTypeOf<SignatureA>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can pluck the generic off of BasePlugin\nexpectTypeOf<SignatureFrom<BasePlugin<SignatureA>>>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can get the generic type off of a sub-type of BasePlugin\nexpectTypeOf<SignatureFrom<PluginA>>().toEqualTypeOf<SignatureA>();\n\n// Tests that we can get the generic off of a sub-type passed to BasePlugin\nclass PluginC extends BasePlugin<SignatureA> {\n name = 'plugin-c';\n}\nexpectTypeOf<SignatureFrom<PluginC>>().toEqualTypeOf<SignatureA>();\n\n///////////////////////////////////////////\n\nclass PluginB extends BasePlugin<{ Meta: { Table: ATableMeta } }> {\n name = 'plugin-b';\n}\n\nexpectTypeOf<SignatureFrom<PluginB>>().toEqualTypeOf<{\n Meta: {\n Table: ATableMeta;\n };\n}>();\n"],"names":["expectTypeOf","toEqualTypeOf"],"mappings":";;;;AAsCA;AACAA,YAAY,EAAc,CAACC,aAAa,EAAc,CAAA;;AAEtD;AACAD,YAAY,EAAyC,CAACC,aAAa,EAAc,CAAA;;AAEjF;AACAD,YAAY,EAA0B,CAACC,aAAa,EAAc,CAAA;AAMlED,YAAY,EAA0B,CAACC,aAAa,EAAc,CAAA;AAQlED,YAAY,EAA0B,CAACC,aAAa,EAIhD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugins-signature-utils.test.js","sources":["../../../src/-private/-type-tests/plugins-signature-utils.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n EmptyObject,\n OptionsFor,\n PluginSignature,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces/plugins';\n\nclass ATableMeta {\n a = 1;\n}\nclass AColumnMeta {\n ac = 1;\n}\nclass ARowMeta {\n ar = 1;\n}\ninterface AOptions {\n ao: number;\n}\ninterface AColumnOptions {\n aco: number;\n}\n\ninterface FullExtendedSignature extends PluginSignature {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<FullExtendedSignature>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<FullExtendedSignature>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<FullExtendedSignature>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<FullExtendedSignature>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<FullExtendedSignature>>().toEqualTypeOf<ARowMeta>();\n\ninterface FullFreeformSignature {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<FullFreeformSignature>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<FullFreeformSignature>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<FullFreeformSignature>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<FullFreeformSignature>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<FullFreeformSignature>>().toEqualTypeOf<ARowMeta>();\n\ninterface WithoutOptions {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<WithoutOptions>>().toEqualTypeOf<EmptyObject>();\nexpectTypeOf<OptionsFor<WithoutOptions>>().toEqualTypeOf<EmptyObject>();\nexpectTypeOf<TableMetaFor<WithoutOptions>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<WithoutOptions>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<WithoutOptions>>().toEqualTypeOf<ARowMeta>();\n\ninterface WithoutMeta {\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<WithoutMeta>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<WithoutMeta>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\nexpectTypeOf<ColumnMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n ColumnOptionsFor<{ Options: { Column: AColumnOptions } }>\n>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<ColumnOptionsFor<{ Options: { Plugin: AOptions } }>>().toEqualTypeOf<EmptyObject>();\n\nexpectTypeOf<OptionsFor<{ Options: { Plugin: AOptions } }>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<OptionsFor<{ Options: { Column: AColumnOptions } }>>().toEqualTypeOf<EmptyObject>();\n\nexpectTypeOf<\n TableMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<TableMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<never>();\nexpectTypeOf<TableMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n ColumnMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<never>();\nexpectTypeOf<ColumnMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<ColumnMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n RowMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<ARowMeta>();\n"],"names":["expectTypeOf","toEqualTypeOf"],"mappings":";;AAwCAA,YAAY,
|
1
|
+
{"version":3,"file":"plugins-signature-utils.test.js","sources":["../../../src/-private/-type-tests/plugins-signature-utils.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport type {\n ColumnMetaFor,\n ColumnOptionsFor,\n EmptyObject,\n OptionsFor,\n PluginSignature,\n RowMetaFor,\n TableMetaFor,\n} from '#interfaces/plugins';\n\nclass ATableMeta {\n a = 1;\n}\nclass AColumnMeta {\n ac = 1;\n}\nclass ARowMeta {\n ar = 1;\n}\ninterface AOptions {\n ao: number;\n}\ninterface AColumnOptions {\n aco: number;\n}\n\ninterface FullExtendedSignature extends PluginSignature {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<FullExtendedSignature>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<FullExtendedSignature>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<FullExtendedSignature>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<FullExtendedSignature>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<FullExtendedSignature>>().toEqualTypeOf<ARowMeta>();\n\ninterface FullFreeformSignature {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<FullFreeformSignature>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<FullFreeformSignature>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<FullFreeformSignature>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<FullFreeformSignature>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<FullFreeformSignature>>().toEqualTypeOf<ARowMeta>();\n\ninterface WithoutOptions {\n Meta: {\n Table: ATableMeta;\n Column: AColumnMeta;\n Row: ARowMeta;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<WithoutOptions>>().toEqualTypeOf<EmptyObject>();\nexpectTypeOf<OptionsFor<WithoutOptions>>().toEqualTypeOf<EmptyObject>();\nexpectTypeOf<TableMetaFor<WithoutOptions>>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<ColumnMetaFor<WithoutOptions>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<RowMetaFor<WithoutOptions>>().toEqualTypeOf<ARowMeta>();\n\ninterface WithoutMeta {\n Options: {\n Plugin: AOptions;\n Column: AColumnOptions;\n };\n}\n\nexpectTypeOf<ColumnOptionsFor<WithoutMeta>>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<OptionsFor<WithoutMeta>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<TableMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\nexpectTypeOf<ColumnMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<WithoutMeta>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n ColumnOptionsFor<{ Options: { Column: AColumnOptions } }>\n>().toEqualTypeOf<AColumnOptions>();\nexpectTypeOf<ColumnOptionsFor<{ Options: { Plugin: AOptions } }>>().toEqualTypeOf<EmptyObject>();\n\nexpectTypeOf<OptionsFor<{ Options: { Plugin: AOptions } }>>().toEqualTypeOf<AOptions>();\nexpectTypeOf<OptionsFor<{ Options: { Column: AColumnOptions } }>>().toEqualTypeOf<EmptyObject>();\n\nexpectTypeOf<\n TableMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<ATableMeta>();\nexpectTypeOf<TableMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<never>();\nexpectTypeOf<TableMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n ColumnMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<never>();\nexpectTypeOf<ColumnMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<AColumnMeta>();\nexpectTypeOf<ColumnMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<never>();\n\nexpectTypeOf<\n RowMetaFor<{\n Meta: {\n Table: ATableMeta;\n };\n }>\n>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<{ Meta: { Column: AColumnMeta } }>>().toEqualTypeOf<never>();\nexpectTypeOf<RowMetaFor<{ Meta: { Row: ARowMeta } }>>().toEqualTypeOf<ARowMeta>();\n"],"names":["expectTypeOf","toEqualTypeOf"],"mappings":";;AAwCAA,YAAY,EAA2C,CAACC,aAAa,EAAkB,CAAA;AACvFD,YAAY,EAAqC,CAACC,aAAa,EAAY,CAAA;AAC3ED,YAAY,EAAuC,CAACC,aAAa,EAAc,CAAA;AAC/ED,YAAY,EAAwC,CAACC,aAAa,EAAe,CAAA;AACjFD,YAAY,EAAqC,CAACC,aAAa,EAAY,CAAA;AAc3ED,YAAY,EAA2C,CAACC,aAAa,EAAkB,CAAA;AACvFD,YAAY,EAAqC,CAACC,aAAa,EAAY,CAAA;AAC3ED,YAAY,EAAuC,CAACC,aAAa,EAAc,CAAA;AAC/ED,YAAY,EAAwC,CAACC,aAAa,EAAe,CAAA;AACjFD,YAAY,EAAqC,CAACC,aAAa,EAAY,CAAA;AAU3ED,YAAY,EAAoC,CAACC,aAAa,EAAe,CAAA;AAC7ED,YAAY,EAA8B,CAACC,aAAa,EAAe,CAAA;AACvED,YAAY,EAAgC,CAACC,aAAa,EAAc,CAAA;AACxED,YAAY,EAAiC,CAACC,aAAa,EAAe,CAAA;AAC1ED,YAAY,EAA8B,CAACC,aAAa,EAAY,CAAA;AASpED,YAAY,EAAiC,CAACC,aAAa,EAAkB,CAAA;AAC7ED,YAAY,EAA2B,CAACC,aAAa,EAAY,CAAA;AACjED,YAAY,EAA6B,CAACC,aAAa,EAAS,CAAA;AAChED,YAAY,EAA8B,CAACC,aAAa,EAAS,CAAA;AACjED,YAAY,EAA2B,CAACC,aAAa,EAAS,CAAA;AAE9DD,YAAY,EAET,CAACC,aAAa,EAAkB,CAAA;AACnCD,YAAY,EAAuD,CAACC,aAAa,EAAe,CAAA;AAEhGD,YAAY,EAAiD,CAACC,aAAa,EAAY,CAAA;AACvFD,YAAY,EAAuD,CAACC,aAAa,EAAe,CAAA;AAEhGD,YAAY,EAMT,CAACC,aAAa,EAAc,CAAA;AAC/BD,YAAY,EAAmD,CAACC,aAAa,EAAS,CAAA;AACtFD,YAAY,EAA6C,CAACC,aAAa,EAAS,CAAA;AAEhFD,YAAY,EAMT,CAACC,aAAa,EAAS,CAAA;AAC1BD,YAAY,EAAoD,CAACC,aAAa,EAAe,CAAA;AAC7FD,YAAY,EAA8C,CAACC,aAAa,EAAS,CAAA;AAEjFD,YAAY,EAMT,CAACC,aAAa,EAAS,CAAA;AAC1BD,YAAY,EAAiD,CAACC,aAAa,EAAS,CAAA;AACpFD,YAAY,EAA2C,CAACC,aAAa,EAAY"}
|
@@ -7,9 +7,10 @@ import { Sorting } from '../../plugins/data-sorting/plugin.js';
|
|
7
7
|
import '../../plugins/data-sorting/types.js';
|
8
8
|
|
9
9
|
// We're testing types, not behaviors
|
10
|
-
const x = 0;
|
11
|
-
// <Table>#pluginOf
|
10
|
+
const x = 0;
|
12
11
|
|
12
|
+
//////////////////////////////
|
13
|
+
// <Table>#pluginOf
|
13
14
|
expectTypeOf(x.pluginOf(Sorting)).toEqualTypeOf();
|
14
15
|
expectTypeOf(x.pluginOf(ColumnReordering)).toEqualTypeOf();
|
15
16
|
expectTypeOf(x.pluginOf(ColumnResizing)).toEqualTypeOf();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table-api.test.js","sources":["../../../src/-private/-type-tests/table-api.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Table } from '[public-types]';\n\n// We're testing types, not behaviors\nconst x = 0 as unknown as Table<{ x: number }>;\n\n//////////////////////////////\n// <Table>#pluginOf\nexpectTypeOf(x.pluginOf(DataSorting)).toEqualTypeOf<DataSorting | undefined>();\nexpectTypeOf(x.pluginOf(ColumnReordering)).toEqualTypeOf<ColumnReordering | undefined>();\nexpectTypeOf(x.pluginOf(ColumnResizing)).toEqualTypeOf<ColumnResizing | undefined>();\n"],"names":["x","expectTypeOf","pluginOf","DataSorting","toEqualTypeOf","ColumnReordering","ColumnResizing"],"mappings":";;;;;;;;AAQA;AACA,MAAMA,CAAC,GAAG,
|
1
|
+
{"version":3,"file":"table-api.test.js","sources":["../../../src/-private/-type-tests/table-api.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { DataSorting } from '../../plugins/data-sorting';\n\nimport type { Table } from '[public-types]';\n\n// We're testing types, not behaviors\nconst x = 0 as unknown as Table<{ x: number }>;\n\n//////////////////////////////\n// <Table>#pluginOf\nexpectTypeOf(x.pluginOf(DataSorting)).toEqualTypeOf<DataSorting | undefined>();\nexpectTypeOf(x.pluginOf(ColumnReordering)).toEqualTypeOf<ColumnReordering | undefined>();\nexpectTypeOf(x.pluginOf(ColumnResizing)).toEqualTypeOf<ColumnResizing | undefined>();\n"],"names":["x","expectTypeOf","pluginOf","DataSorting","toEqualTypeOf","ColumnReordering","ColumnResizing"],"mappings":";;;;;;;;AAQA;AACA,MAAMA,CAAC,GAAG,CAAoC,CAAA;;AAE9C;AACA;AACAC,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACC,OAAW,CAAC,CAAC,CAACC,aAAa,EAA2B,CAAA;AAC9EH,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACG,gBAAgB,CAAC,CAAC,CAACD,aAAa,EAAgC,CAAA;AACxFH,YAAY,CAACD,CAAC,CAACE,QAAQ,CAACI,cAAc,CAAC,CAAC,CAACF,aAAa,EAA8B"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _defineProperty } from '../../defineProperty-
|
1
|
+
import { _ as _defineProperty } from '../../defineProperty-35ce617b.js';
|
2
2
|
import { expectTypeOf } from 'expect-type';
|
3
3
|
import { BasePlugin } from '../../plugins/-private/base.js';
|
4
4
|
import { ColumnReordering } from '../../plugins/column-reordering/plugin.js';
|
@@ -7,6 +7,7 @@ import { ColumnResizing } from '../../plugins/column-resizing/plugin.js';
|
|
7
7
|
import { ColumnVisibility } from '../../plugins/column-visibility/plugin.js';
|
8
8
|
import { Sorting } from '../../plugins/data-sorting/plugin.js';
|
9
9
|
import '../../plugins/data-sorting/types.js';
|
10
|
+
import '@ember/template';
|
10
11
|
import { StickyColumns } from '../../plugins/sticky-columns/plugin.js';
|
11
12
|
|
12
13
|
/////////////////////////////////////////////
|
@@ -18,37 +19,34 @@ expectTypeOf().toMatchTypeOf();
|
|
18
19
|
expectTypeOf().toMatchTypeOf();
|
19
20
|
expectTypeOf().toMatchTypeOf();
|
20
21
|
expectTypeOf().toMatchTypeOf();
|
21
|
-
|
22
22
|
class LocalPlugin extends BasePlugin {
|
23
23
|
constructor(...args) {
|
24
24
|
super(...args);
|
25
|
-
|
26
25
|
_defineProperty(this, "name", 'local-plugin');
|
27
26
|
}
|
28
|
-
|
29
27
|
}
|
28
|
+
expectTypeOf([LocalPlugin]).toMatchTypeOf();
|
30
29
|
|
31
|
-
|
30
|
+
/////////////////////////////////////////////
|
32
31
|
// Making sure all plugins are subclassed appropriately
|
33
|
-
|
34
32
|
expectTypeOf(LocalPlugin).toMatchTypeOf();
|
35
33
|
expectTypeOf(ColumnReordering).toMatchTypeOf();
|
36
34
|
expectTypeOf(LocalPlugin).toMatchTypeOf();
|
37
|
-
expectTypeOf(ColumnReordering).toMatchTypeOf();
|
35
|
+
expectTypeOf(ColumnReordering).toMatchTypeOf();
|
38
36
|
|
37
|
+
// Actual plugins match the actual table config
|
39
38
|
expectTypeOf([Sorting]).toMatchTypeOf();
|
40
39
|
expectTypeOf([ColumnReordering]).toMatchTypeOf();
|
41
40
|
expectTypeOf([ColumnResizing]).toMatchTypeOf();
|
42
41
|
expectTypeOf([ColumnVisibility]).toMatchTypeOf();
|
43
|
-
expectTypeOf([StickyColumns]).toMatchTypeOf();
|
44
|
-
// The various ways to define plugins
|
42
|
+
expectTypeOf([StickyColumns]).toMatchTypeOf();
|
45
43
|
|
44
|
+
/////////////////////////////////////////////
|
45
|
+
// The various ways to define plugins
|
46
46
|
expectTypeOf([Sorting, ColumnReordering]).toMatchTypeOf();
|
47
|
-
|
48
47
|
const onSort = _sorts => {
|
49
48
|
/* intentionally empty */
|
50
49
|
};
|
51
|
-
|
52
50
|
const sorts = [];
|
53
51
|
expectTypeOf([Sorting.with(() => ({}))]).toMatchTypeOf();
|
54
52
|
expectTypeOf([Sorting.with(() => ({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table-config.test.js","sources":["../../../src/-private/-type-tests/table-config.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins/-private/base';\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { ColumnVisibility } from '../../plugins/column-visibility';\nimport { DataSorting } from '../../plugins/data-sorting';\nimport { StickyColumns } from '../../plugins/sticky-columns';\n\nimport type { Plugins } from '../../plugins/-private/utils';\nimport type { SortItem } from '../../plugins/data-sorting';\nimport type { Plugin } from '[public-plugin-types]';\nimport type { TableConfig } from '[public-types]';\nimport type { Constructor } from '#private-types';\n\ntype TablePluginConfig = NonNullable<TableConfig<unknown>['plugins']>;\n\n/////////////////////////////////////////////\n// Sanity checks\nexpectTypeOf<Plugins>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<Plugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>, Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<BasePlugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<BasePlugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<\n [Constructor<BasePlugin>, Constructor<BasePlugin>]\n>().toMatchTypeOf<TablePluginConfig>();\n\nclass SomeClass {\n foo = 'bar';\n}\nclass LocalPlugin extends BasePlugin<{ Meta: { Table: SomeClass } }> {\n name = 'local-plugin';\n}\n\nexpectTypeOf([LocalPlugin]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// Making sure all plugins are subclassed appropriately\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<Plugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<Plugin<any>>>();\n\n// Actual plugins match the actual table config\nexpectTypeOf([DataSorting]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnResizing]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnVisibility]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([StickyColumns]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// The various ways to define plugins\nexpectTypeOf([DataSorting, ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\n\nconst onSort = (_sorts: SortItem<number>[]) => {\n /* intentionally empty */\n};\nconst sorts: SortItem<number>[] = [];\n\nexpectTypeOf([DataSorting.with(() => ({}))]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([DataSorting.with(() => ({ onSort, sorts }))]).toMatchTypeOf<TablePluginConfig>();\n"],"names":["expectTypeOf","toMatchTypeOf","LocalPlugin","BasePlugin","ColumnReordering","DataSorting","ColumnResizing","ColumnVisibility","StickyColumns","onSort","_sorts","sorts","with"],"mappings":"
|
1
|
+
{"version":3,"file":"table-config.test.js","sources":["../../../src/-private/-type-tests/table-config.test.ts"],"sourcesContent":["import { expectTypeOf } from 'expect-type';\n\nimport { BasePlugin } from '../../plugins/-private/base';\nimport { ColumnReordering } from '../../plugins/column-reordering';\nimport { ColumnResizing } from '../../plugins/column-resizing';\nimport { ColumnVisibility } from '../../plugins/column-visibility';\nimport { DataSorting } from '../../plugins/data-sorting';\nimport { StickyColumns } from '../../plugins/sticky-columns';\n\nimport type { Plugins } from '../../plugins/-private/utils';\nimport type { SortItem } from '../../plugins/data-sorting';\nimport type { Plugin } from '[public-plugin-types]';\nimport type { TableConfig } from '[public-types]';\nimport type { Constructor } from '#private-types';\n\ntype TablePluginConfig = NonNullable<TableConfig<unknown>['plugins']>;\n\n/////////////////////////////////////////////\n// Sanity checks\nexpectTypeOf<Plugins>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<Plugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<Plugin>, Constructor<Plugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<Constructor<BasePlugin>[]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<[Constructor<BasePlugin>]>().toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf<\n [Constructor<BasePlugin>, Constructor<BasePlugin>]\n>().toMatchTypeOf<TablePluginConfig>();\n\nclass SomeClass {\n foo = 'bar';\n}\nclass LocalPlugin extends BasePlugin<{ Meta: { Table: SomeClass } }> {\n name = 'local-plugin';\n}\n\nexpectTypeOf([LocalPlugin]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// Making sure all plugins are subclassed appropriately\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<BasePlugin<any>>>();\nexpectTypeOf(LocalPlugin).toMatchTypeOf<Constructor<Plugin<any>>>();\nexpectTypeOf(ColumnReordering).toMatchTypeOf<Constructor<Plugin<any>>>();\n\n// Actual plugins match the actual table config\nexpectTypeOf([DataSorting]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnResizing]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([ColumnVisibility]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([StickyColumns]).toMatchTypeOf<TablePluginConfig>();\n\n/////////////////////////////////////////////\n// The various ways to define plugins\nexpectTypeOf([DataSorting, ColumnReordering]).toMatchTypeOf<TablePluginConfig>();\n\nconst onSort = (_sorts: SortItem<number>[]) => {\n /* intentionally empty */\n};\nconst sorts: SortItem<number>[] = [];\n\nexpectTypeOf([DataSorting.with(() => ({}))]).toMatchTypeOf<TablePluginConfig>();\nexpectTypeOf([DataSorting.with(() => ({ onSort, sorts }))]).toMatchTypeOf<TablePluginConfig>();\n"],"names":["expectTypeOf","toMatchTypeOf","LocalPlugin","BasePlugin","ColumnReordering","DataSorting","ColumnResizing","ColumnVisibility","StickyColumns","onSort","_sorts","sorts","with"],"mappings":";;;;;;;;;;;;AAiBA;AACA;AACAA,YAAY,EAAW,CAACC,aAAa,EAAqB,CAAA;AAC1DD,YAAY,EAAyB,CAACC,aAAa,EAAqB,CAAA;AACxED,YAAY,EAAyB,CAACC,aAAa,EAAqB,CAAA;AACxED,YAAY,EAA8C,CAACC,aAAa,EAAqB,CAAA;AAC7FD,YAAY,EAA6B,CAACC,aAAa,EAAqB,CAAA;AAC5ED,YAAY,EAA6B,CAACC,aAAa,EAAqB,CAAA;AAC5ED,YAAY,EAET,CAACC,aAAa,EAAqB,CAAA;AAKtC,MAAMC,WAAW,SAASC,UAAU,CAAiC;AAAA,EAAA,WAAA,CAAA,GAAA,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,MAAA,EAC5D,cAAc,CAAA,CAAA;AAAA,GAAA;AACvB,CAAA;AAEAH,YAAY,CAAC,CAACE,WAAW,CAAC,CAAC,CAACD,aAAa,EAAqB,CAAA;;AAE9D;AACA;AACAD,YAAY,CAACE,WAAW,CAAC,CAACD,aAAa,EAAgC,CAAA;AACvED,YAAY,CAACI,gBAAgB,CAAC,CAACH,aAAa,EAAgC,CAAA;AAC5ED,YAAY,CAACE,WAAW,CAAC,CAACD,aAAa,EAA4B,CAAA;AACnED,YAAY,CAACI,gBAAgB,CAAC,CAACH,aAAa,EAA4B,CAAA;;AAExE;AACAD,YAAY,CAAC,CAACK,OAAW,CAAC,CAAC,CAACJ,aAAa,EAAqB,CAAA;AAC9DD,YAAY,CAAC,CAACI,gBAAgB,CAAC,CAAC,CAACH,aAAa,EAAqB,CAAA;AACnED,YAAY,CAAC,CAACM,cAAc,CAAC,CAAC,CAACL,aAAa,EAAqB,CAAA;AACjED,YAAY,CAAC,CAACO,gBAAgB,CAAC,CAAC,CAACN,aAAa,EAAqB,CAAA;AACnED,YAAY,CAAC,CAACQ,aAAa,CAAC,CAAC,CAACP,aAAa,EAAqB,CAAA;;AAEhE;AACA;AACAD,YAAY,CAAC,CAACK,OAAW,EAAED,gBAAgB,CAAC,CAAC,CAACH,aAAa,EAAqB,CAAA;AAEhF,MAAMQ,MAAM,GAAIC,MAA0B,IAAK;AAC7C;AAAA,CACD,CAAA;AACD,MAAMC,KAAyB,GAAG,EAAE,CAAA;AAEpCX,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAACX,aAAa,EAAqB,CAAA;AAC/ED,YAAY,CAAC,CAACK,OAAW,CAACO,IAAI,CAAC,OAAO;EAAEH,MAAM;AAAEE,EAAAA,KAAAA;AAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAACV,aAAa,EAAqB"}
|
package/dist/-private/column.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as _applyDecoratedDescriptor } from '../applyDecoratedDescriptor-
|
1
|
+
import { _ as _applyDecoratedDescriptor } from '../applyDecoratedDescriptor-6b986a67.js';
|
2
2
|
import { action, get } from '@ember/object';
|
3
3
|
import { isEmpty } from '@ember/utils';
|
4
4
|
|
@@ -12,58 +12,50 @@ let Column = (_class = class Column {
|
|
12
12
|
get Cell() {
|
13
13
|
return this.config.Cell;
|
14
14
|
}
|
15
|
-
|
16
15
|
get key() {
|
17
16
|
return this.config.key;
|
18
17
|
}
|
19
|
-
|
20
18
|
get name() {
|
21
19
|
return this.config.name;
|
22
20
|
}
|
23
|
-
|
24
21
|
constructor(table, config) {
|
25
22
|
this.table = table;
|
26
23
|
this.config = config;
|
27
24
|
}
|
28
|
-
|
29
25
|
getValueForRow(row) {
|
30
26
|
if (this.config.value) {
|
31
27
|
return this.config.value({
|
32
28
|
column: this,
|
33
29
|
row
|
34
30
|
});
|
35
|
-
}
|
36
|
-
// even though the real implementation does
|
37
|
-
|
31
|
+
}
|
38
32
|
|
33
|
+
// Cast here, because ember get's types do not support nested keys
|
34
|
+
// even though the real implementation does
|
39
35
|
let value = get(row.data, this.config.key);
|
40
|
-
|
41
36
|
if (isEmpty(value)) {
|
42
37
|
return this.getDefaultValue(row);
|
43
38
|
}
|
39
|
+
|
44
40
|
/**
|
45
41
|
* UNSAFE: casting to ContentValue is incorrect, because we have not
|
46
42
|
* properly constrained the type of value, (isEmpty doesn't narrow types either)
|
47
43
|
*/
|
48
|
-
|
49
|
-
|
50
44
|
return value;
|
51
45
|
}
|
52
|
-
|
53
46
|
getDefaultValue(row) {
|
54
47
|
return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];
|
55
48
|
}
|
56
|
-
|
57
49
|
getOptionsForRow(row) {
|
58
50
|
let defaults = DEFAULT_OPTIONS;
|
59
|
-
return {
|
51
|
+
return {
|
52
|
+
...defaults,
|
60
53
|
...this.config.options?.({
|
61
54
|
column: this,
|
62
55
|
row
|
63
56
|
})
|
64
57
|
};
|
65
58
|
}
|
66
|
-
|
67
59
|
}, (_applyDecoratedDescriptor(_class.prototype, "getValueForRow", [action], Object.getOwnPropertyDescriptor(_class.prototype, "getValueForRow"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getOptionsForRow", [action], Object.getOwnPropertyDescriptor(_class.prototype, "getOptionsForRow"), _class.prototype)), _class);
|
68
60
|
|
69
61
|
export { Column };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../src/-private/column.ts"],"sourcesContent":["import { action, get } from '@ember/object';\nimport { isEmpty } from '@ember/utils';\n\nimport type { Row } from './row';\nimport type { Table } from './table';\nimport type { ContentValue } from '@glint/template';\nimport type { ColumnConfig } from '#interfaces';\n\nconst DEFAULT_VALUE = '--';\nconst DEFAULT_VALUE_KEY = 'defaultValue';\nconst DEFAULT_OPTIONS = {\n [DEFAULT_VALUE_KEY]: DEFAULT_VALUE,\n};\n\nexport class Column<T = unknown> {\n get Cell() {\n return this.config.Cell;\n }\n\n get key() {\n return this.config.key;\n }\n\n get name() {\n return this.config.name;\n }\n\n constructor(public table: Table<T>, public config: ColumnConfig<T>) {}\n\n @action\n getValueForRow(row: Row<T>): ContentValue {\n if (this.config.value) {\n return this.config.value({ column: this, row });\n }\n\n // Cast here, because ember get's types do not support nested keys\n // even though the real implementation does\n let value = get(row.data, this.config.key as keyof typeof row.data);\n\n if (isEmpty(value)) {\n return this.getDefaultValue(row);\n }\n\n /**\n * UNSAFE: casting to ContentValue is incorrect, because we have not\n * properly constrained the type of value, (isEmpty doesn't narrow types either)\n */\n return value as ContentValue;\n }\n\n private getDefaultValue(row: Row<T>) {\n return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];\n }\n\n @action\n getOptionsForRow(row: Row<T>) {\n let defaults = DEFAULT_OPTIONS;\n\n return {\n ...defaults,\n ...this.config.options?.({ column: this, row }),\n };\n }\n}\n"],"names":["DEFAULT_VALUE","DEFAULT_VALUE_KEY","DEFAULT_OPTIONS","Column","Cell","config","key","name","constructor","table","getValueForRow","row","value","column","get","data","isEmpty","getDefaultValue","getOptionsForRow","defaults","options","action"],"mappings":";;;;;AAQA,MAAMA,aAAa,GAAG,
|
1
|
+
{"version":3,"file":"column.js","sources":["../../src/-private/column.ts"],"sourcesContent":["import { action, get } from '@ember/object';\nimport { isEmpty } from '@ember/utils';\n\nimport type { Row } from './row';\nimport type { Table } from './table';\nimport type { ContentValue } from '@glint/template';\nimport type { ColumnConfig } from '#interfaces';\n\nconst DEFAULT_VALUE = '--';\nconst DEFAULT_VALUE_KEY = 'defaultValue';\nconst DEFAULT_OPTIONS = {\n [DEFAULT_VALUE_KEY]: DEFAULT_VALUE,\n};\n\nexport class Column<T = unknown> {\n get Cell() {\n return this.config.Cell;\n }\n\n get key() {\n return this.config.key;\n }\n\n get name() {\n return this.config.name;\n }\n\n constructor(public table: Table<T>, public config: ColumnConfig<T>) {}\n\n @action\n getValueForRow(row: Row<T>): ContentValue {\n if (this.config.value) {\n return this.config.value({ column: this, row });\n }\n\n // Cast here, because ember get's types do not support nested keys\n // even though the real implementation does\n let value = get(row.data, this.config.key as keyof typeof row.data);\n\n if (isEmpty(value)) {\n return this.getDefaultValue(row);\n }\n\n /**\n * UNSAFE: casting to ContentValue is incorrect, because we have not\n * properly constrained the type of value, (isEmpty doesn't narrow types either)\n */\n return value as ContentValue;\n }\n\n private getDefaultValue(row: Row<T>) {\n return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];\n }\n\n @action\n getOptionsForRow(row: Row<T>) {\n let defaults = DEFAULT_OPTIONS;\n\n return {\n ...defaults,\n ...this.config.options?.({ column: this, row }),\n };\n }\n}\n"],"names":["DEFAULT_VALUE","DEFAULT_VALUE_KEY","DEFAULT_OPTIONS","Column","Cell","config","key","name","constructor","table","getValueForRow","row","value","column","get","data","isEmpty","getDefaultValue","getOptionsForRow","defaults","options","action"],"mappings":";;;;;AAQA,MAAMA,aAAa,GAAG,IAAI,CAAA;AAC1B,MAAMC,iBAAiB,GAAG,cAAc,CAAA;AACxC,MAAMC,eAAe,GAAG;AACtB,EAAA,CAACD,iBAAiB,GAAGD,aAAAA;AACvB,CAAC,CAAA;AAED,IAAaG,MAAM,IAAA,MAAA,GAAZ,MAAMA,MAAM,CAAc;AAC/B,EAAA,IAAIC,IAAI,GAAG;AACT,IAAA,OAAO,IAAI,CAACC,MAAM,CAACD,IAAI,CAAA;AACzB,GAAA;AAEA,EAAA,IAAIE,GAAG,GAAG;AACR,IAAA,OAAO,IAAI,CAACD,MAAM,CAACC,GAAG,CAAA;AACxB,GAAA;AAEA,EAAA,IAAIC,IAAI,GAAG;AACT,IAAA,OAAO,IAAI,CAACF,MAAM,CAACE,IAAI,CAAA;AACzB,GAAA;AAEAC,EAAAA,WAAW,CAAQC,KAAe,EAASJ,MAAuB,EAAE;IAAA,IAAjDI,CAAAA,KAAe,GAAfA,KAAe,CAAA;IAAA,IAASJ,CAAAA,MAAuB,GAAvBA,MAAuB,CAAA;AAAG,GAAA;EAGrEK,cAAc,CAACC,GAAW,EAAgB;AACxC,IAAA,IAAI,IAAI,CAACN,MAAM,CAACO,KAAK,EAAE;AACrB,MAAA,OAAO,IAAI,CAACP,MAAM,CAACO,KAAK,CAAC;AAAEC,QAAAA,MAAM,EAAE,IAAI;AAAEF,QAAAA,GAAAA;AAAI,OAAC,CAAC,CAAA;AACjD,KAAA;;AAEA;AACA;AACA,IAAA,IAAIC,KAAK,GAAGE,GAAG,CAACH,GAAG,CAACI,IAAI,EAAE,IAAI,CAACV,MAAM,CAACC,GAAG,CAA0B,CAAA;AAEnE,IAAA,IAAIU,OAAO,CAACJ,KAAK,CAAC,EAAE;AAClB,MAAA,OAAO,IAAI,CAACK,eAAe,CAACN,GAAG,CAAC,CAAA;AAClC,KAAA;;AAEA;AACJ;AACA;AACA;AACI,IAAA,OAAOC,KAAK,CAAA;AACd,GAAA;EAEQK,eAAe,CAACN,GAAW,EAAE;IACnC,OAAO,IAAI,CAACO,gBAAgB,CAACP,GAAG,CAAC,CAACV,iBAAiB,CAAC,CAAA;AACtD,GAAA;EAGAiB,gBAAgB,CAACP,GAAW,EAAE;IAC5B,IAAIQ,QAAQ,GAAGjB,eAAe,CAAA;IAE9B,OAAO;AACL,MAAA,GAAGiB,QAAQ;AACX,MAAA,GAAG,IAAI,CAACd,MAAM,CAACe,OAAO,GAAG;AAAEP,QAAAA,MAAM,EAAE,IAAI;AAAEF,QAAAA,GAAAA;OAAK,CAAA;KAC/C,CAAA;AACH,GAAA;AACF,CAAC,GAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,CAlCEU,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,EAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,CAyBNA,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,kBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA;;;;"}
|
@@ -1,17 +1,16 @@
|
|
1
|
-
import { a as Table } from '../table-
|
1
|
+
import { a as Table } from '../table-0cbd2720.js';
|
2
2
|
|
3
3
|
function headlessTable(...args) {
|
4
4
|
if (args.length === 2) {
|
5
5
|
let [destroyable, options] = args;
|
6
|
+
|
6
7
|
/**
|
7
8
|
* If any "root level" config changes, we need to throw-away everything.
|
8
9
|
* otherwise individual-property reactivity can be managed on a per-property
|
9
10
|
* "thunk"-basis
|
10
11
|
*/
|
11
|
-
|
12
12
|
return Table.from(destroyable, () => options);
|
13
13
|
}
|
14
|
-
|
15
14
|
let [options] = args;
|
16
15
|
return Table.from(() => options);
|
17
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"js-helper.js","sources":["../../src/-private/js-helper.ts"],"sourcesContent":["import { Table } from './table';\n\nimport type { TableConfig } from '#interfaces';\n\ntype Args<T> = [destroyable: object, options: TableConfig<T>] | [options: TableConfig<T>];\n\n/**\n * Represents a UI-less version of a table\n *\n * _For use for building tables in ui frameworks_.\n *\n * @example\n * ```js\n * import { use } from 'ember-resources';\n * import { headlessTable } '@crowdstrike/ember-headless-table';\n *\n * class MyImplementation {\n * @use table = headlessTable({\n * // your config here\n * })\n * }\n * ```\n */\nexport function headlessTable<T = unknown>(options: TableConfig<T>): Table<T>;\n\n/**\n * Represents a UI-less version of a table\n *\n * _For use for building tables in ui frameworks_.\n *\n * @example\n * ```js\n * import { headlessTable } '@crowdstrike/ember-headless-table';\n *\n * class MyImplementation {\n * table = headlessTable(this, {\n * // your config here\n * })\n * }\n * ```\n *\n */\nexport function headlessTable<T = unknown>(destroyable: object, options: TableConfig<T>): Table<T>;\n\nexport function headlessTable<T = unknown>(...args: Args<T>): Table<T> {\n if (args.length === 2) {\n let [destroyable, options] = args;\n\n /**\n * If any \"root level\" config changes, we need to throw-away everything.\n * otherwise individual-property reactivity can be managed on a per-property\n * \"thunk\"-basis\n */\n return Table.from<Table<T>>(destroyable, () => options);\n }\n\n let [options] = args;\n\n return Table.from<Table<T>>(() => options);\n}\n"],"names":["headlessTable","args","length","destroyable","options","Table","from"],"mappings":";;AA4CO,SAASA,
|
1
|
+
{"version":3,"file":"js-helper.js","sources":["../../src/-private/js-helper.ts"],"sourcesContent":["import { Table } from './table';\n\nimport type { TableConfig } from '#interfaces';\n\ntype Args<T> = [destroyable: object, options: TableConfig<T>] | [options: TableConfig<T>];\n\n/**\n * Represents a UI-less version of a table\n *\n * _For use for building tables in ui frameworks_.\n *\n * @example\n * ```js\n * import { use } from 'ember-resources';\n * import { headlessTable } '@crowdstrike/ember-headless-table';\n *\n * class MyImplementation {\n * @use table = headlessTable({\n * // your config here\n * })\n * }\n * ```\n */\nexport function headlessTable<T = unknown>(options: TableConfig<T>): Table<T>;\n\n/**\n * Represents a UI-less version of a table\n *\n * _For use for building tables in ui frameworks_.\n *\n * @example\n * ```js\n * import { headlessTable } '@crowdstrike/ember-headless-table';\n *\n * class MyImplementation {\n * table = headlessTable(this, {\n * // your config here\n * })\n * }\n * ```\n *\n */\nexport function headlessTable<T = unknown>(destroyable: object, options: TableConfig<T>): Table<T>;\n\nexport function headlessTable<T = unknown>(...args: Args<T>): Table<T> {\n if (args.length === 2) {\n let [destroyable, options] = args;\n\n /**\n * If any \"root level\" config changes, we need to throw-away everything.\n * otherwise individual-property reactivity can be managed on a per-property\n * \"thunk\"-basis\n */\n return Table.from<Table<T>>(destroyable, () => options);\n }\n\n let [options] = args;\n\n return Table.from<Table<T>>(() => options);\n}\n"],"names":["headlessTable","args","length","destroyable","options","Table","from"],"mappings":";;AA4CO,SAASA,aAAa,CAAc,GAAGC,IAAa,EAAY;AACrE,EAAA,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,IAAI,CAACC,WAAW,EAAEC,OAAO,CAAC,GAAGH,IAAI,CAAA;;AAEjC;AACJ;AACA;AACA;AACA;IACI,OAAOI,KAAK,CAACC,IAAI,CAAWH,WAAW,EAAE,MAAMC,OAAO,CAAC,CAAA;AACzD,GAAA;AAEA,EAAA,IAAI,CAACA,OAAO,CAAC,GAAGH,IAAI,CAAA;AAEpB,EAAA,OAAOI,KAAK,CAACC,IAAI,CAAW,MAAMF,OAAO,CAAC,CAAA;AAC5C;;;;"}
|