@universal-ember/table 3.0.2 → 3.0.3
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/declarations/-private/-type-tests/plugin-properties.test.d.ts +2 -0
- package/declarations/-private/-type-tests/plugin-properties.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/plugin-with.test.d.ts +2 -0
- package/declarations/-private/-type-tests/plugin-with.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/plugins-accessors.test.d.ts +2 -0
- package/declarations/-private/-type-tests/plugins-accessors.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/plugins-signature-from.test.d.ts +2 -0
- package/declarations/-private/-type-tests/plugins-signature-from.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/plugins-signature-utils.test.d.ts +2 -0
- package/declarations/-private/-type-tests/plugins-signature-utils.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/table-api.test.d.ts +2 -0
- package/declarations/-private/-type-tests/table-api.test.d.ts.map +1 -0
- package/declarations/-private/-type-tests/table-config.test.d.ts +2 -0
- package/declarations/-private/-type-tests/table-config.test.d.ts.map +1 -0
- package/declarations/-private/column.d.ts +18 -0
- package/declarations/-private/column.d.ts.map +1 -0
- package/declarations/-private/ember-compat.d.ts +8 -0
- package/declarations/-private/ember-compat.d.ts.map +1 -0
- package/declarations/-private/interfaces/column.d.ts +63 -0
- package/declarations/-private/interfaces/column.d.ts.map +1 -0
- package/declarations/-private/interfaces/index.d.ts +8 -0
- package/declarations/-private/interfaces/index.d.ts.map +1 -0
- package/declarations/-private/interfaces/modifier.d.ts +7 -0
- package/declarations/-private/interfaces/modifier.d.ts.map +1 -0
- package/declarations/-private/interfaces/pagination.d.ts +17 -0
- package/declarations/-private/interfaces/pagination.d.ts.map +1 -0
- package/declarations/-private/interfaces/plugins.d.ts +315 -0
- package/declarations/-private/interfaces/plugins.d.ts.map +1 -0
- package/declarations/-private/interfaces/preferences.d.ts +74 -0
- package/declarations/-private/interfaces/preferences.d.ts.map +1 -0
- package/declarations/-private/interfaces/selection.d.ts +36 -0
- package/declarations/-private/interfaces/selection.d.ts.map +1 -0
- package/declarations/-private/interfaces/table.d.ts +109 -0
- package/declarations/-private/interfaces/table.d.ts.map +1 -0
- package/declarations/-private/js-helper.d.ts +39 -0
- package/declarations/-private/js-helper.d.ts.map +1 -0
- package/declarations/-private/preferences.d.ts +45 -0
- package/declarations/-private/preferences.d.ts.map +1 -0
- package/declarations/-private/private-types.d.ts +6 -0
- package/declarations/-private/private-types.d.ts.map +1 -0
- package/declarations/-private/row.d.ts +12 -0
- package/declarations/-private/row.d.ts.map +1 -0
- package/declarations/-private/table.d.ts +136 -0
- package/declarations/-private/table.d.ts.map +1 -0
- package/declarations/-private/utils.d.ts +3 -0
- package/declarations/-private/utils.d.ts.map +1 -0
- package/declarations/index.d.ts +14 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/plugins/-private/base.d.ts +281 -0
- package/declarations/plugins/-private/base.d.ts.map +1 -0
- package/declarations/plugins/-private/utils.d.ts +22 -0
- package/declarations/plugins/-private/utils.d.ts.map +1 -0
- package/declarations/plugins/column-reordering/helpers.d.ts +33 -0
- package/declarations/plugins/column-reordering/helpers.d.ts.map +1 -0
- package/declarations/plugins/column-reordering/index.d.ts +5 -0
- package/declarations/plugins/column-reordering/index.d.ts.map +1 -0
- package/declarations/plugins/column-reordering/plugin.d.ts +148 -0
- package/declarations/plugins/column-reordering/plugin.d.ts.map +1 -0
- package/declarations/plugins/column-reordering/utils.d.ts +8 -0
- package/declarations/plugins/column-reordering/utils.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/handle.d.ts +128 -0
- package/declarations/plugins/column-resizing/handle.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/helpers.d.ts +35 -0
- package/declarations/plugins/column-resizing/helpers.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/index.d.ts +6 -0
- package/declarations/plugins/column-resizing/index.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/plugin.d.ts +160 -0
- package/declarations/plugins/column-resizing/plugin.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/resize-observer.d.ts +14 -0
- package/declarations/plugins/column-resizing/resize-observer.d.ts.map +1 -0
- package/declarations/plugins/column-resizing/utils.d.ts +22 -0
- package/declarations/plugins/column-resizing/utils.d.ts.map +1 -0
- package/declarations/plugins/column-visibility/helpers.d.ts +18 -0
- package/declarations/plugins/column-visibility/helpers.d.ts.map +1 -0
- package/declarations/plugins/column-visibility/index.d.ts +5 -0
- package/declarations/plugins/column-visibility/index.d.ts.map +1 -0
- package/declarations/plugins/column-visibility/plugin.d.ts +64 -0
- package/declarations/plugins/column-visibility/plugin.d.ts.map +1 -0
- package/declarations/plugins/data-sorting/helpers.d.ts +38 -0
- package/declarations/plugins/data-sorting/helpers.d.ts.map +1 -0
- package/declarations/plugins/data-sorting/index.d.ts +7 -0
- package/declarations/plugins/data-sorting/index.d.ts.map +1 -0
- package/declarations/plugins/data-sorting/plugin.d.ts +102 -0
- package/declarations/plugins/data-sorting/plugin.d.ts.map +1 -0
- package/declarations/plugins/data-sorting/types.d.ts +23 -0
- package/declarations/plugins/data-sorting/types.d.ts.map +1 -0
- package/declarations/plugins/index.d.ts +6 -0
- package/declarations/plugins/index.d.ts.map +1 -0
- package/declarations/plugins/metadata/helpers.d.ts +4 -0
- package/declarations/plugins/metadata/helpers.d.ts.map +1 -0
- package/declarations/plugins/metadata/index.d.ts +5 -0
- package/declarations/plugins/metadata/index.d.ts.map +1 -0
- package/declarations/plugins/metadata/plugin.d.ts +25 -0
- package/declarations/plugins/metadata/plugin.d.ts.map +1 -0
- package/declarations/plugins/row-selection/helpers.d.ts +6 -0
- package/declarations/plugins/row-selection/helpers.d.ts.map +1 -0
- package/declarations/plugins/row-selection/index.d.ts +5 -0
- package/declarations/plugins/row-selection/index.d.ts.map +1 -0
- package/declarations/plugins/row-selection/plugin.d.ts +80 -0
- package/declarations/plugins/row-selection/plugin.d.ts.map +1 -0
- package/declarations/plugins/sticky-columns/helpers.d.ts +17 -0
- package/declarations/plugins/sticky-columns/helpers.d.ts.map +1 -0
- package/declarations/plugins/sticky-columns/index.d.ts +5 -0
- package/declarations/plugins/sticky-columns/index.d.ts.map +1 -0
- package/declarations/plugins/sticky-columns/plugin.d.ts +70 -0
- package/declarations/plugins/sticky-columns/plugin.d.ts.map +1 -0
- package/declarations/test-support/index.d.ts +15 -0
- package/declarations/test-support/index.d.ts.map +1 -0
- package/declarations/utils.d.ts +26 -0
- package/declarations/utils.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { Table } from '../../-private/table.ts';
|
|
2
|
+
import type { ColumnReordering } from '../column-reordering';
|
|
3
|
+
import type { ColumnVisibility } from '../column-visibility';
|
|
4
|
+
import type { Class, Constructor } from '../../-private/private-types.ts';
|
|
5
|
+
import type { Column, Row } from '../../index.ts';
|
|
6
|
+
import type { ColumnMetaFor, ColumnOptionsFor, OptionsFor, Plugin, RowMetaFor, TableMetaFor } from '../../-private/interfaces';
|
|
7
|
+
type InstanceOf<T> = T extends Class<infer Instance> ? Instance : T;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*
|
|
11
|
+
* list of interfaces by feature name that consumers may provide alternative
|
|
12
|
+
* implementation for
|
|
13
|
+
*/
|
|
14
|
+
export interface TableFeatures extends Record<string, unknown | undefined> {
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
18
|
+
* interface for the table meta of a "column visibility plugin"
|
|
19
|
+
*/
|
|
20
|
+
columnVisibility: InstanceOf<ColumnVisibility['meta']['table']>;
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*
|
|
24
|
+
* interface for the table meta of a "column order plugin"
|
|
25
|
+
*/
|
|
26
|
+
columnOrder: InstanceOf<ColumnReordering['meta']['table']>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
*
|
|
31
|
+
* list of interfaces by feature name that consumers may provide alternative
|
|
32
|
+
* implementation for
|
|
33
|
+
*/
|
|
34
|
+
export interface ColumnFeatures extends Record<string, unknown | undefined> {
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*
|
|
38
|
+
* interface for the column meta of a "column visibility plugin"
|
|
39
|
+
*/
|
|
40
|
+
columnVisibility: InstanceOf<ColumnVisibility['meta']['column']>;
|
|
41
|
+
/**
|
|
42
|
+
* @public
|
|
43
|
+
*
|
|
44
|
+
* interface for the column meta of a "column order plugin"
|
|
45
|
+
*/
|
|
46
|
+
columnOrder: InstanceOf<ColumnReordering['meta']['column']>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @private utility type
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export type SignatureFrom<Klass extends BasePlugin<any>> = Klass extends BasePlugin<infer Signature> ? Signature : never;
|
|
53
|
+
declare const __Signature__: unique symbol;
|
|
54
|
+
/**
|
|
55
|
+
* @public
|
|
56
|
+
*
|
|
57
|
+
* If your table plugin is a class, you may extend from BasePlugin, which provides
|
|
58
|
+
* small utility methods and properties for getting the metadata for your plugin
|
|
59
|
+
* for the table and each column
|
|
60
|
+
*
|
|
61
|
+
* One instance of a plugin exists per table
|
|
62
|
+
*/
|
|
63
|
+
export declare abstract class BasePlugin<Signature = unknown> implements Plugin<Signature> {
|
|
64
|
+
protected table: Table;
|
|
65
|
+
constructor(table: Table);
|
|
66
|
+
/**
|
|
67
|
+
* @private (secret)
|
|
68
|
+
*
|
|
69
|
+
* Because classes are kind of like interfaces,
|
|
70
|
+
* we need "something" to help TS know what a Resource is.
|
|
71
|
+
*
|
|
72
|
+
* This isn't a real API, but does help with type inference
|
|
73
|
+
* with the SignatureFrom utility above
|
|
74
|
+
*/
|
|
75
|
+
[__Signature__]: Signature;
|
|
76
|
+
/**
|
|
77
|
+
* Helper for specifying plugins on `headlessTable` with the plugin-level options
|
|
78
|
+
*/
|
|
79
|
+
static with<T extends BasePlugin<any>>(this: Constructor<T>, configFn: () => OptionsFor<SignatureFrom<T>>): [Constructor<T>, () => OptionsFor<SignatureFrom<T>>];
|
|
80
|
+
/**
|
|
81
|
+
* Helper for specifying column-level configurations for a plugin on `headlessTable`'s
|
|
82
|
+
* columns option
|
|
83
|
+
*/
|
|
84
|
+
static forColumn<T extends BasePlugin<any>>(this: Constructor<T>, configFn: () => ColumnOptionsFor<SignatureFrom<T>>): [Constructor<T>, () => ColumnOptionsFor<SignatureFrom<T>>];
|
|
85
|
+
meta?: {
|
|
86
|
+
column?: Constructor<ColumnMetaFor<Signature>>;
|
|
87
|
+
table?: Constructor<TableMetaFor<Signature>>;
|
|
88
|
+
row?: Constructor<RowMetaFor<Signature>>;
|
|
89
|
+
};
|
|
90
|
+
abstract name: string;
|
|
91
|
+
static features?: string[];
|
|
92
|
+
static requires?: string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @public
|
|
96
|
+
*
|
|
97
|
+
* returns boolean if the passed table has an instance of the configured passed plugin class.
|
|
98
|
+
* This can be used to help guard against accessing public-specific APIs if those plugins
|
|
99
|
+
* are not configured for a particular table instance
|
|
100
|
+
*/
|
|
101
|
+
export declare function hasPlugin<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): boolean;
|
|
102
|
+
export declare const preferences: {
|
|
103
|
+
/**
|
|
104
|
+
* @public
|
|
105
|
+
*
|
|
106
|
+
* returns an object for getting and setting preferences data
|
|
107
|
+
* based on the column (scoped to key)
|
|
108
|
+
*
|
|
109
|
+
* Only the provided plugin will have access to these preferences
|
|
110
|
+
* (though, if other plugins can guess how the underlying plugin access
|
|
111
|
+
* works, they can access this data, too. No security guaranteed)
|
|
112
|
+
*/
|
|
113
|
+
forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>): {
|
|
114
|
+
/**
|
|
115
|
+
* delete an entry on the underlying `Map` used for this column-plugin pair
|
|
116
|
+
*/
|
|
117
|
+
delete(key: string): void | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* get an entry on the underlying `Map` used for this column-plugin pair
|
|
120
|
+
*/
|
|
121
|
+
get(key: string): unknown;
|
|
122
|
+
/**
|
|
123
|
+
* set an entry on the underlying `Map` used for this column-plugin pair
|
|
124
|
+
*/
|
|
125
|
+
set(key: string, value: unknown): void;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @public
|
|
129
|
+
*
|
|
130
|
+
* returns an object for bulk updating preferences data
|
|
131
|
+
* for all columns (scoped to key and table)
|
|
132
|
+
*/
|
|
133
|
+
forAllColumns<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): {
|
|
134
|
+
/**
|
|
135
|
+
* delete an entry on every column in the underlying column `Map` for this table-plugin pair
|
|
136
|
+
*/
|
|
137
|
+
delete(key: string): void | undefined;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* @public
|
|
141
|
+
*
|
|
142
|
+
* returns an object for getting and setting preferences data
|
|
143
|
+
* based on the table (scoped to the key: "table")
|
|
144
|
+
*
|
|
145
|
+
* Only the provided plugin will have access to these preferences
|
|
146
|
+
* (though, if other plugins can guess how the underlying plugin access
|
|
147
|
+
* works, they can access this data, too. No security guaranteed)
|
|
148
|
+
*/
|
|
149
|
+
forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): {
|
|
150
|
+
/**
|
|
151
|
+
* delete an entry on the underlying `Map` used for this table-plugin pair
|
|
152
|
+
*/
|
|
153
|
+
delete(key: string): void | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* get an entry on the underlying `Map` used for this table-plugin pair
|
|
156
|
+
*/
|
|
157
|
+
get(key: string): unknown;
|
|
158
|
+
/**
|
|
159
|
+
* set an entry on the underlying `Map` used for this table-plugin pair
|
|
160
|
+
*/
|
|
161
|
+
set(key: string, value: unknown): void | undefined;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* if a `requester` is not provided,
|
|
166
|
+
* Get the columns for the table, considering any and all plugins that could modify columns.
|
|
167
|
+
*
|
|
168
|
+
* If you are an end-consumer of @universal-ember/table, this is the function to use.
|
|
169
|
+
* If you are a plugin-author, you'll want to pass your plugin class as the second parameter.
|
|
170
|
+
*
|
|
171
|
+
* For a given plugin, `requester`, determine what columns should be returned.
|
|
172
|
+
* Since multiple plugins could be used in a table, there is an implicit hierarchy of
|
|
173
|
+
* column modifications that can occur from each of those plugins.
|
|
174
|
+
*
|
|
175
|
+
* If a plugin defines other plugins as either *requirements* or *optional requirements*,
|
|
176
|
+
* and that upstream plugin defines a `columns` property, then those columns will be returned here.
|
|
177
|
+
*
|
|
178
|
+
* This works recursively up the plugin tree up until a plugin has no requirements, and then
|
|
179
|
+
* all columns from the table are returned.
|
|
180
|
+
*/
|
|
181
|
+
declare function columnsFor<DataType = any>(table: Table<DataType>, requester?: Plugin<any>): Column<DataType>[];
|
|
182
|
+
export declare const columns: {
|
|
183
|
+
for: typeof columnsFor;
|
|
184
|
+
/**
|
|
185
|
+
* for a given current or reference column, return the column that
|
|
186
|
+
* is immediately next, or to the right of that column.
|
|
187
|
+
*
|
|
188
|
+
* If a plugin class is provided, the hierarchy of column list modifications
|
|
189
|
+
* will be respected.
|
|
190
|
+
*/
|
|
191
|
+
next: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>) => Column<Data> | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* for a given current or reference column, return the column that
|
|
194
|
+
* is immediately previous, or to the left of that column.
|
|
195
|
+
*
|
|
196
|
+
* If a plugin class is provided, the hierarchy of column list modifications
|
|
197
|
+
* will be respected.
|
|
198
|
+
*/
|
|
199
|
+
previous: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>) => Column<Data> | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* for a given current or reference column, return the columns that
|
|
202
|
+
* should appear before, or to the left of that column.
|
|
203
|
+
*
|
|
204
|
+
* if a plugin class is provided, the hierarchy of column list modifications
|
|
205
|
+
* will be respected.
|
|
206
|
+
*/
|
|
207
|
+
before: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>) => Column<Data>[];
|
|
208
|
+
/**
|
|
209
|
+
* for a given current or reference column, return the columns that
|
|
210
|
+
* should appear after, or to the right of that column.
|
|
211
|
+
*
|
|
212
|
+
* if a plugin class is provided, the hierarchy of column list modifications
|
|
213
|
+
* will be respected.
|
|
214
|
+
*/
|
|
215
|
+
after: <Data = unknown>(current: Column<Data>, requester?: Plugin<any>) => Column<Data>[];
|
|
216
|
+
};
|
|
217
|
+
export declare const meta: {
|
|
218
|
+
/**
|
|
219
|
+
* @public
|
|
220
|
+
*
|
|
221
|
+
* For a given column and plugin, return the meta / state bucket for the
|
|
222
|
+
* plugin<->column instance pair.
|
|
223
|
+
*
|
|
224
|
+
* Note that this requires the column instance to exist on the table.
|
|
225
|
+
*/
|
|
226
|
+
forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>): ColumnMetaFor<SignatureFrom<P>>;
|
|
227
|
+
/**
|
|
228
|
+
* @public
|
|
229
|
+
*
|
|
230
|
+
* For a given row and plugin, return the meta / state bucket for the
|
|
231
|
+
* plugin<->row instance pair.
|
|
232
|
+
*
|
|
233
|
+
* Note that this requires the row instance to exist on the table.
|
|
234
|
+
*/
|
|
235
|
+
forRow<P extends BasePlugin<any>, Data = unknown>(row: Row<Data>, klass: Class<P>): RowMetaFor<SignatureFrom<P>>;
|
|
236
|
+
/**
|
|
237
|
+
* @public
|
|
238
|
+
*
|
|
239
|
+
* For a given table and plugin, return the meta / state bucket for the
|
|
240
|
+
* plugin<->table instance pair.
|
|
241
|
+
*/
|
|
242
|
+
forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): TableMetaFor<SignatureFrom<P>>;
|
|
243
|
+
/**
|
|
244
|
+
* Instead of finding meta based on column or table instances,
|
|
245
|
+
* you can search for meta based on feature strings, such as `columnWidth`
|
|
246
|
+
*/
|
|
247
|
+
withFeature: {
|
|
248
|
+
/**
|
|
249
|
+
* @public
|
|
250
|
+
*
|
|
251
|
+
* for a given column and feature name, return the "ColumnMeta" for that feature.
|
|
252
|
+
* This is useful when plugins may depend on one another but may not necessarily care which
|
|
253
|
+
* plugin is providing what behavior.
|
|
254
|
+
*
|
|
255
|
+
* For example, multiple column-focused plugins may care about width or visibility
|
|
256
|
+
*/
|
|
257
|
+
forColumn<FeatureName extends string, Data = unknown>(column: Column<Data>, featureName: FeatureName): ColumnFeatures[FeatureName];
|
|
258
|
+
/**
|
|
259
|
+
* @public
|
|
260
|
+
*
|
|
261
|
+
* for a given table and feature name, return the "TableMeta" for that feature.
|
|
262
|
+
* This is useful when plugins may depend on one another but may not necessarily care
|
|
263
|
+
* which plugin is providing that behavior.
|
|
264
|
+
*
|
|
265
|
+
* For example, multiple column-focused plugins may care about width or visibility.
|
|
266
|
+
*/
|
|
267
|
+
forTable<FeatureName extends string, Data = unknown>(table: Table<Data>, featureName: FeatureName): TableFeatures[FeatureName];
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
export declare const options: {
|
|
271
|
+
/**
|
|
272
|
+
* @public
|
|
273
|
+
*
|
|
274
|
+
* For a given table and plugin, return the options, if any were given from the user
|
|
275
|
+
* during construction of the table.
|
|
276
|
+
*/
|
|
277
|
+
forTable<P extends BasePlugin<any>, Data = unknown>(table: Table<Data>, klass: Class<P>): Partial<OptionsFor<SignatureFrom<P>>>;
|
|
278
|
+
forColumn<P extends BasePlugin<any>, Data = unknown>(column: Column<Data>, klass: Class<P>): Partial<ColumnOptionsFor<SignatureFrom<P>>>;
|
|
279
|
+
};
|
|
280
|
+
export {};
|
|
281
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/plugins/-private/base.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM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,KAAK,CAAC,IAAI,CAAC,eACL,WAAW,GACvB,aAAa,CAAC,WAAW,CAAC;;CAehC,CAAC;AAuCF,eAAO,MAAM,OAAO;IAClB;;;;;OAKG;aACM,CAAC,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,mBAC/B,KAAK,CAAC,IAAI,CAAC,SACX,KAAK,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;cAa9B,CAAC,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,oBAC/B,MAAM,CAAC,IAAI,CAAC,SACb,KAAK,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CAY/C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Constructor } from '../../-private/private-types';
|
|
2
|
+
import type { Plugin } from '../../plugins';
|
|
3
|
+
type PluginOption = Constructor<Plugin<any>> | [Constructor<Plugin<any>>, () => any];
|
|
4
|
+
type ExpandedPluginOption = [Constructor<Plugin<any>>, () => any];
|
|
5
|
+
export type Plugins = PluginOption[];
|
|
6
|
+
export declare function normalizePluginsConfig(plugins?: Plugins): ExpandedPluginOption[];
|
|
7
|
+
export declare function verifyPlugins(plugins: ExpandedPluginOption[]): void;
|
|
8
|
+
type AssignableStyles = Omit<CSSStyleDeclaration, 'length' | 'parentRule'>;
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*
|
|
12
|
+
* Utility that helps safely apply styles to an element
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyStyles(element: HTMLElement | SVGElement, styles: Partial<AssignableStyles>): void;
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
18
|
+
* Utility that helps safely remove styles from an element
|
|
19
|
+
*/
|
|
20
|
+
export declare function removeStyles(element: HTMLElement | SVGElement, styles: Array<keyof AssignableStyles>): void;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/plugins/-private/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,YAAY,GACb,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GACxB,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;AAE1C,KAAK,oBAAoB,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;AAElE,MAAM,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;AAErC,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,OAAO,GAChB,oBAAoB,EAAE,CA8BxB;AAsCD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,EAAE,QA6B5D;AAED,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,YAAY,CAAC,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,GAAG,UAAU,EACjC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,QAWlC;AAiBD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,WAAW,GAAG,UAAU,EACjC,MAAM,EAAE,KAAK,CAAC,MAAM,gBAAgB,CAAC,QAMtC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ColumnOrder } from './plugin.ts';
|
|
2
|
+
import type { Column, Table } from '../../index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Move the column one position to the left.
|
|
5
|
+
* If the column is first, nothing will happen.
|
|
6
|
+
*/
|
|
7
|
+
export declare const moveLeft: (column: Column) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Move the column one position to the right.
|
|
10
|
+
* If the column is last, nothing will happen.
|
|
11
|
+
*/
|
|
12
|
+
export declare const moveRight: (column: Column) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Override all column positions at once.
|
|
15
|
+
*/
|
|
16
|
+
export declare const setColumnOrder: (table: Table, order: ColumnOrder) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Ask if the column cannot move to the left
|
|
19
|
+
*/
|
|
20
|
+
export declare const cannotMoveLeft: (column: Column) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Ask if the column cannot move to the right
|
|
23
|
+
*/
|
|
24
|
+
export declare const cannotMoveRight: (column: Column) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Ask if the column can move to the left
|
|
27
|
+
*/
|
|
28
|
+
export declare const canMoveLeft: (column: Column) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Ask if the column can move to the right
|
|
31
|
+
*/
|
|
32
|
+
export declare const canMoveRight: (column: Column) => boolean;
|
|
33
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,SACc,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,SACc,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,EAAE,OAAO,WAAW,SAE9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,YACY,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,YACY,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,YACe,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,YACe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,gBAAgB,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { TrackedMap } from 'tracked-built-ins';
|
|
2
|
+
import { BasePlugin } from '../-private/base.ts';
|
|
3
|
+
import type { PluginPreferences } from '../../plugins/index.ts';
|
|
4
|
+
import type { Column, Table } from '../../index.ts';
|
|
5
|
+
interface ColumnReorderingPreferences extends PluginPreferences {
|
|
6
|
+
table: {
|
|
7
|
+
order?: Record<string, number>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare module '@universal-ember/table/plugins' {
|
|
11
|
+
interface Registry {
|
|
12
|
+
ColumnReordering?: ColumnReorderingPreferences;
|
|
13
|
+
'column-reordering'?: ColumnReorderingPreferences;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export interface Signature {
|
|
17
|
+
Meta: {
|
|
18
|
+
Column: ColumnMeta;
|
|
19
|
+
Table: TableMeta;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare class ColumnReordering extends BasePlugin<Signature> {
|
|
23
|
+
name: string;
|
|
24
|
+
static features: string[];
|
|
25
|
+
meta: {
|
|
26
|
+
readonly column: typeof ColumnMeta;
|
|
27
|
+
readonly table: typeof TableMeta;
|
|
28
|
+
};
|
|
29
|
+
reset(): void;
|
|
30
|
+
get columns(): Column<unknown>[];
|
|
31
|
+
}
|
|
32
|
+
export declare class ColumnMeta {
|
|
33
|
+
#private;
|
|
34
|
+
private column;
|
|
35
|
+
constructor(column: Column);
|
|
36
|
+
get position(): number;
|
|
37
|
+
set position(value: number);
|
|
38
|
+
get canMoveLeft(): boolean;
|
|
39
|
+
get canMoveRight(): boolean;
|
|
40
|
+
get cannotMoveLeft(): boolean;
|
|
41
|
+
get cannotMoveRight(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Move the column one spot to the left
|
|
44
|
+
*/
|
|
45
|
+
moveLeft: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Move the column one spot to the right
|
|
48
|
+
*/
|
|
49
|
+
moveRight: () => void;
|
|
50
|
+
}
|
|
51
|
+
export declare class TableMeta {
|
|
52
|
+
private table;
|
|
53
|
+
constructor(table: Table);
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
*
|
|
57
|
+
* We want to maintain the instance of this ColumnOrder class because
|
|
58
|
+
* we allow the consumer of the table to swap out columns at any time.
|
|
59
|
+
* When they do this, we want to maintain the order of the table, best we can.
|
|
60
|
+
* This is also why the order of the columns is maintained via column key
|
|
61
|
+
*/
|
|
62
|
+
columnOrder: ColumnOrder;
|
|
63
|
+
/**
|
|
64
|
+
* Get the curret order/position of a column
|
|
65
|
+
*/
|
|
66
|
+
getPosition(column: Column): number;
|
|
67
|
+
/**
|
|
68
|
+
* Swap the column with the column at `newPosition`
|
|
69
|
+
*/
|
|
70
|
+
setPosition(column: Column, newPosition: number): false | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Using a `ColumnOrder` instance, set the order of all columns
|
|
73
|
+
*/
|
|
74
|
+
setOrder: (order: ColumnOrder) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Revert to default config, delete preferences,
|
|
77
|
+
* and clear the columnOrder
|
|
78
|
+
*/
|
|
79
|
+
reset(): void;
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
save(map: Map<string, number>): void;
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private read;
|
|
88
|
+
get columns(): Column<unknown>[];
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
* This isn't our data to expose, but it is useful to alias
|
|
92
|
+
*/
|
|
93
|
+
private get availableColumns();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @private
|
|
97
|
+
* Used for keeping track of and updating column order
|
|
98
|
+
*/
|
|
99
|
+
export declare class ColumnOrder {
|
|
100
|
+
private args;
|
|
101
|
+
/**
|
|
102
|
+
* This map will be empty until we re-order something.
|
|
103
|
+
*/
|
|
104
|
+
map: TrackedMap<string, number>;
|
|
105
|
+
constructor(args: {
|
|
106
|
+
columns: () => Column[];
|
|
107
|
+
save?: (order: Map<string, number>) => void;
|
|
108
|
+
existingOrder?: Map<string, number>;
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* To account for columnVisibilty, we need to:
|
|
112
|
+
* - get the list of visible columns
|
|
113
|
+
* - get the column order (which preserves the order of hidden columns)
|
|
114
|
+
* - skip over non-visible columns when determining the previous "index"
|
|
115
|
+
* - set the position to whatever that is.
|
|
116
|
+
*/
|
|
117
|
+
moveLeft(key: string): void;
|
|
118
|
+
setAll: (map: Map<string, number>) => void;
|
|
119
|
+
/**
|
|
120
|
+
* To account for columnVisibilty, we need to:
|
|
121
|
+
* - get the list of visible columns
|
|
122
|
+
* - get the column order (which preserves the order of hidden columns)
|
|
123
|
+
* - skip over non-visible columns when determining the next "index"
|
|
124
|
+
* - set the position to whatever that is.
|
|
125
|
+
*/
|
|
126
|
+
moveRight(key: string): void;
|
|
127
|
+
/**
|
|
128
|
+
* Performs a swap of the column's position with the column at position
|
|
129
|
+
*/
|
|
130
|
+
swapWith(key: string, position: number): false | undefined;
|
|
131
|
+
get(key: string): number;
|
|
132
|
+
/**
|
|
133
|
+
* The same as this.map, but with all the columns' information
|
|
134
|
+
*/
|
|
135
|
+
get orderedMap(): ReadonlyMap<string, number>;
|
|
136
|
+
get orderedColumns(): Column[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @private
|
|
140
|
+
*
|
|
141
|
+
* Utility for helping determine the percieved order of a set of columns
|
|
142
|
+
* given the original (default) ordering, and then user-configurations
|
|
143
|
+
*/
|
|
144
|
+
export declare function orderOf(columns: {
|
|
145
|
+
key: string;
|
|
146
|
+
}[], currentOrder: Map<string, number>): Map<string, number>;
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,UAAU,EAAiB,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEpD,UAAU,2BAA4B,SAAQ,iBAAiB;IAC7D,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;CACH;AAED,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,UAAU,QAAQ;QAChB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;QAC/C,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;KACnD;CACF;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ,MAAM,EAAE,UAAU,CAAC;QACnB,KAAK,EAAE,SAAS,CAAC;KAClB,CAAC;CACH;AA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C,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC;IAOH;;;;;;OAMG;IAEH,QAAQ,CAAC,GAAG,EAAE,MAAM;IAyBpB,MAAM,GAAI,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAQhC;IAEF;;;;;;OAMG;IAEH,SAAS,CAAC,GAAG,EAAE,MAAM;IAyBrB;;OAEG;IAEH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IA6EtC,GAAG,CAAC,GAAG,EAAE,MAAM;IAYf;;OAEG;IACH,IACI,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAE5C;IAED,IACI,cAAc,IAAI,MAAM,EAAE,CAiC7B;CACF;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,EAC1B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8CrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Column } from '../../index.ts';
|
|
2
|
+
type ColumnOrder = {
|
|
3
|
+
key: string;
|
|
4
|
+
position: number | undefined;
|
|
5
|
+
}[];
|
|
6
|
+
export declare function reorderColumns(columns: Column[], orderedColumns: ColumnOrder | undefined): Column<unknown>[];
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,KAAK,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,CAAC;AAEnE,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,cAAc,EAAE,WAAW,GAAG,SAAS,qBAsCxC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
import type { ColumnMeta } from './plugin.ts';
|
|
3
|
+
import type { Column } from '../../-private/column.ts';
|
|
4
|
+
/**
|
|
5
|
+
* - why are mouse events used instead of drag events?
|
|
6
|
+
* - why not use the "draggable" attribute?
|
|
7
|
+
*
|
|
8
|
+
* It seems drag events are more for files and/or moving images around on a page
|
|
9
|
+
* dragging an image, for example, has a ghost of that image until it is dropped.
|
|
10
|
+
* The same thing happens with text.
|
|
11
|
+
* This prevents us from having total control of the styling of how dragging works.
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
declare class ResizeHandle extends Modifier<{
|
|
17
|
+
Args: {
|
|
18
|
+
Positional: [Column];
|
|
19
|
+
};
|
|
20
|
+
}> {
|
|
21
|
+
dragHandle: HTMLElement;
|
|
22
|
+
column: Column;
|
|
23
|
+
meta: ColumnMeta;
|
|
24
|
+
pointerStartX: number;
|
|
25
|
+
pointerStartY: number;
|
|
26
|
+
pointerX: number;
|
|
27
|
+
pointerY: number;
|
|
28
|
+
dragFrame: number;
|
|
29
|
+
keyDistance: number;
|
|
30
|
+
keyFrame: number;
|
|
31
|
+
lastKey: number;
|
|
32
|
+
token?: unknown;
|
|
33
|
+
isSetup: boolean;
|
|
34
|
+
modify(element: Element, [column]: [Column]): void;
|
|
35
|
+
setup: () => void;
|
|
36
|
+
setPosition: (event: Event) => void;
|
|
37
|
+
setStartPosition: (event: Event) => void;
|
|
38
|
+
/**
|
|
39
|
+
* queueUpdate takes an optional function argument that is called
|
|
40
|
+
* in the requestAnimationFrame callback _after_ the resize function.
|
|
41
|
+
*
|
|
42
|
+
* We can use this to ensure that preferences are only ever saved after
|
|
43
|
+
* we have completed column resizing.
|
|
44
|
+
*
|
|
45
|
+
* Because the requestAnimationFrame 'hides' these function calls from the
|
|
46
|
+
* the ember test waiter, we also ensure that we track them by also cancelling
|
|
47
|
+
* the waiter in the requestAnimationFrame callback.
|
|
48
|
+
*/
|
|
49
|
+
queueUpdate: (callback?: () => void) => void;
|
|
50
|
+
dragEndHandler: () => void;
|
|
51
|
+
dragMove: (event: Event) => void;
|
|
52
|
+
dragStartHandler: (event: Event) => void;
|
|
53
|
+
keyHandler: (event: KeyboardEvent) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Modifier to attach to the column resize handles.
|
|
57
|
+
* This provides both keyboard and mouse support for resizing columns.
|
|
58
|
+
* (provided the resize handle element is focusable -- so consider using
|
|
59
|
+
* a button for the resize element)
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```js
|
|
63
|
+
* import Component from '@glimmer/component';
|
|
64
|
+
* import { meta } from '@universal-ember/table/plugins';
|
|
65
|
+
* import { resizeHandle, ColumnResizing } from '@universal-ember/table/plugins/column-resizing';
|
|
66
|
+
*
|
|
67
|
+
* export default class TableHead extends Component {
|
|
68
|
+
* /* ✂️ *\/
|
|
69
|
+
*
|
|
70
|
+
* <template>
|
|
71
|
+
* <thead>
|
|
72
|
+
* <tr>
|
|
73
|
+
* {{#each this.columns as |column|}}
|
|
74
|
+
* <th>
|
|
75
|
+
* <span>{{column.name}}</span>
|
|
76
|
+
* <button {{resizeHandle column}}></button>
|
|
77
|
+
* </th>
|
|
78
|
+
* {{/each}}
|
|
79
|
+
* </tr>
|
|
80
|
+
* </thead>
|
|
81
|
+
* </template>
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* Width and isResizing state is maintained on the "meta"
|
|
86
|
+
* class so that the users may choose per-column stylings for
|
|
87
|
+
* isResizing and dragging behaviors.
|
|
88
|
+
*
|
|
89
|
+
* For example, while dragging, the user may add a class based on the
|
|
90
|
+
* isDragging property.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* import Component from '@glimmer/component';
|
|
95
|
+
* import { meta } from '@universal-ember/table/plugins';
|
|
96
|
+
* import { resizeHandle, ColumnResizing } from '@universal-ember/table/plugins/column-resizing';
|
|
97
|
+
*
|
|
98
|
+
* export default class TableHead extends Component {
|
|
99
|
+
* /* ✂️ *\/
|
|
100
|
+
*
|
|
101
|
+
* isDragging = (column) => {
|
|
102
|
+
* return meta.forColumn(column, ColumnResizing).isDragging;
|
|
103
|
+
* }
|
|
104
|
+
*
|
|
105
|
+
* <template>
|
|
106
|
+
* <thead>
|
|
107
|
+
* <tr>
|
|
108
|
+
* {{#each this.columns as |column|}}
|
|
109
|
+
* <th class="header {{if (this.isDragging column) 'blue'}}">
|
|
110
|
+
* <span>{{column.name}}</span>
|
|
111
|
+
* <button {{resizeHandle column}}></button>
|
|
112
|
+
* </th>
|
|
113
|
+
* {{/each}}
|
|
114
|
+
* </tr>
|
|
115
|
+
* </thead>
|
|
116
|
+
* </template>
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
*
|
|
121
|
+
* @note
|
|
122
|
+
* The logic here is copied from the drag slider in
|
|
123
|
+
* https://limber.glimdown.com/
|
|
124
|
+
* See: "resize-handle" on Limber's GitHub
|
|
125
|
+
*/
|
|
126
|
+
export declare const resizeHandle: typeof ResizeHandle;
|
|
127
|
+
export {};
|
|
128
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-resizing/handle.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAKtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;;;;;;;;;;GAWG;AAEH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