slint-ui 1.9.0-nightly.2024092723 → 1.9.0-nightly.2024100103
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/Cargo.toml +5 -4
- package/{index.d.ts → dist/index.d.ts} +147 -309
- package/{index.js → dist/index.js} +167 -384
- package/dist/models.d.ts +169 -0
- package/dist/models.js +235 -0
- package/package.json +10 -10
- package/tsconfig.json +2 -1
- package/{index.ts → typescript/index.ts} +166 -431
- package/typescript/models.ts +278 -0
- /package/{src → rust}/interpreter/component_compiler.rs +0 -0
- /package/{src → rust}/interpreter/component_definition.rs +0 -0
- /package/{src → rust}/interpreter/component_instance.rs +0 -0
- /package/{src → rust}/interpreter/diagnostic.rs +0 -0
- /package/{src → rust}/interpreter/value.rs +0 -0
- /package/{src → rust}/interpreter/window.rs +0 -0
- /package/{src → rust}/interpreter.rs +0 -0
- /package/{src → rust}/lib.rs +0 -0
- /package/{src → rust}/types/brush.rs +0 -0
- /package/{src → rust}/types/image_data.rs +0 -0
- /package/{src → rust}/types/model.rs +0 -0
- /package/{src → rust}/types/point.rs +0 -0
- /package/{src → rust}/types/size.rs +0 -0
- /package/{src → rust}/types.rs +0 -0
package/Cargo.toml
CHANGED
|
@@ -18,6 +18,7 @@ build = "build.rs"
|
|
|
18
18
|
|
|
19
19
|
[lib]
|
|
20
20
|
crate-type = ["cdylib"]
|
|
21
|
+
path = "rust/lib.rs"
|
|
21
22
|
|
|
22
23
|
[features]
|
|
23
24
|
default = ["backend-winit", "renderer-femtovg", "renderer-software", "backend-qt", "accessibility"]
|
|
@@ -40,10 +41,10 @@ accessibility = ["slint-interpreter/accessibility"]
|
|
|
40
41
|
[dependencies]
|
|
41
42
|
napi = { version = "2.14.0", default-features = false, features = ["napi8"] }
|
|
42
43
|
napi-derive = "2.14.0"
|
|
43
|
-
i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
44
|
-
i-slint-core = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
45
|
-
i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "
|
|
46
|
-
slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "
|
|
44
|
+
i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "f041075e76b61b95df3cff8c430776cb032e20fb", version = "=1.9.0", default-features = false }
|
|
45
|
+
i-slint-core = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "f041075e76b61b95df3cff8c430776cb032e20fb", version = "=1.9.0", default-features = false }
|
|
46
|
+
i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "f041075e76b61b95df3cff8c430776cb032e20fb", version = "=1.9.0", default-features = false }
|
|
47
|
+
slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "f041075e76b61b95df3cff8c430776cb032e20fb", version = "=1.9.0"}
|
|
47
48
|
spin_on = { version = "0.1" }
|
|
48
49
|
css-color-parser2 = { version = "1.0.1" }
|
|
49
50
|
itertools = { version = "0.13" }
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import * as napi from "
|
|
2
|
-
export { Diagnostic, DiagnosticLevel, RgbaColor, Brush, } from "
|
|
1
|
+
import * as napi from "../rust-module.cjs";
|
|
2
|
+
export { Diagnostic, DiagnosticLevel, RgbaColor, Brush, } from "../rust-module.cjs";
|
|
3
|
+
import { Model } from "./models";
|
|
4
|
+
export { Model };
|
|
5
|
+
export { ArrayModel } from "./models";
|
|
3
6
|
/**
|
|
4
7
|
* Represents a two-dimensional point.
|
|
5
8
|
*/
|
|
@@ -85,313 +88,6 @@ export interface ImageData {
|
|
|
85
88
|
*/
|
|
86
89
|
get height(): number;
|
|
87
90
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Model<T> is the interface for feeding dynamic data into
|
|
90
|
-
* `.slint` views.
|
|
91
|
-
*
|
|
92
|
-
* A model is organized like a table with rows of data. The
|
|
93
|
-
* fields of the data type T behave like columns.
|
|
94
|
-
*
|
|
95
|
-
* @template T the type of the model's items.
|
|
96
|
-
*
|
|
97
|
-
* ### Example
|
|
98
|
-
* As an example let's see the implementation of {@link ArrayModel}
|
|
99
|
-
*
|
|
100
|
-
* ```js
|
|
101
|
-
* export class ArrayModel<T> extends Model<T> {
|
|
102
|
-
* private a: Array<T>
|
|
103
|
-
*
|
|
104
|
-
* constructor(arr: Array<T>) {
|
|
105
|
-
* super();
|
|
106
|
-
* this.a = arr;
|
|
107
|
-
* }
|
|
108
|
-
*
|
|
109
|
-
* rowCount() {
|
|
110
|
-
* return this.a.length;
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* rowData(row: number) {
|
|
114
|
-
* return this.a[row];
|
|
115
|
-
* }
|
|
116
|
-
*
|
|
117
|
-
* setRowData(row: number, data: T) {
|
|
118
|
-
* this.a[row] = data;
|
|
119
|
-
* this.notifyRowDataChanged(row);
|
|
120
|
-
* }
|
|
121
|
-
*
|
|
122
|
-
* push(...values: T[]) {
|
|
123
|
-
* let size = this.a.length;
|
|
124
|
-
* Array.prototype.push.apply(this.a, values);
|
|
125
|
-
* this.notifyRowAdded(size, arguments.length);
|
|
126
|
-
* }
|
|
127
|
-
*
|
|
128
|
-
* remove(index: number, size: number) {
|
|
129
|
-
* let r = this.a.splice(index, size);
|
|
130
|
-
* this.notifyRowRemoved(index, size);
|
|
131
|
-
* }
|
|
132
|
-
*
|
|
133
|
-
* get length(): number {
|
|
134
|
-
* return this.a.length;
|
|
135
|
-
* }
|
|
136
|
-
*
|
|
137
|
-
* values(): IterableIterator<T> {
|
|
138
|
-
* return this.a.values();
|
|
139
|
-
* }
|
|
140
|
-
*
|
|
141
|
-
* entries(): IterableIterator<[number, T]> {
|
|
142
|
-
* return this.a.entries()
|
|
143
|
-
* }
|
|
144
|
-
*}
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export declare abstract class Model<T> implements Iterable<T> {
|
|
148
|
-
/**
|
|
149
|
-
* @hidden
|
|
150
|
-
*/
|
|
151
|
-
modelNotify: napi.ExternalObject<napi.SharedModelNotify>;
|
|
152
|
-
constructor();
|
|
153
|
-
/**
|
|
154
|
-
* Implementations of this function must return the current number of rows.
|
|
155
|
-
*/
|
|
156
|
-
abstract rowCount(): number;
|
|
157
|
-
/**
|
|
158
|
-
* Implementations of this function must return the data at the specified row.
|
|
159
|
-
* @param row index in range 0..(rowCount() - 1).
|
|
160
|
-
* @returns undefined if row is out of range otherwise the data.
|
|
161
|
-
*/
|
|
162
|
-
abstract rowData(row: number): T | undefined;
|
|
163
|
-
/**
|
|
164
|
-
* Implementations of this function must store the provided data parameter
|
|
165
|
-
* in the model at the specified row.
|
|
166
|
-
* @param _row index in range 0..(rowCount() - 1).
|
|
167
|
-
* @param _data new data item to store on the given row index
|
|
168
|
-
*/
|
|
169
|
-
setRowData(_row: number, _data: T): void;
|
|
170
|
-
[Symbol.iterator](): Iterator<T>;
|
|
171
|
-
/**
|
|
172
|
-
* Notifies the view that the data of the current row is changed.
|
|
173
|
-
* @param row index of the changed row.
|
|
174
|
-
*/
|
|
175
|
-
protected notifyRowDataChanged(row: number): void;
|
|
176
|
-
/**
|
|
177
|
-
* Notifies the view that multiple rows are added to the model.
|
|
178
|
-
* @param row index of the first added row.
|
|
179
|
-
* @param count the number of added items.
|
|
180
|
-
*/
|
|
181
|
-
protected notifyRowAdded(row: number, count: number): void;
|
|
182
|
-
/**
|
|
183
|
-
* Notifies the view that multiple rows are removed to the model.
|
|
184
|
-
* @param row index of the first removed row.
|
|
185
|
-
* @param count the number of removed items.
|
|
186
|
-
*/
|
|
187
|
-
protected notifyRowRemoved(row: number, count: number): void;
|
|
188
|
-
/**
|
|
189
|
-
* Notifies the view that the complete data must be reload.
|
|
190
|
-
*/
|
|
191
|
-
protected notifyReset(): void;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* ArrayModel wraps a JavaScript array for use in `.slint` views. The underlying
|
|
195
|
-
* array can be modified with the [[ArrayModel.push]] and [[ArrayModel.remove]] methods.
|
|
196
|
-
*/
|
|
197
|
-
export declare class ArrayModel<T> extends Model<T> {
|
|
198
|
-
#private;
|
|
199
|
-
/**
|
|
200
|
-
* Creates a new ArrayModel.
|
|
201
|
-
*
|
|
202
|
-
* @param arr
|
|
203
|
-
*/
|
|
204
|
-
constructor(arr: Array<T>);
|
|
205
|
-
/**
|
|
206
|
-
* Returns the number of entries in the array model.
|
|
207
|
-
*/
|
|
208
|
-
get length(): number;
|
|
209
|
-
/**
|
|
210
|
-
* Returns the number of entries in the array model.
|
|
211
|
-
*/
|
|
212
|
-
rowCount(): number;
|
|
213
|
-
/**
|
|
214
|
-
* Returns the data at the specified row.
|
|
215
|
-
* @param row index in range 0..(rowCount() - 1).
|
|
216
|
-
* @returns undefined if row is out of range otherwise the data.
|
|
217
|
-
*/
|
|
218
|
-
rowData(row: number): T;
|
|
219
|
-
/**
|
|
220
|
-
* Stores the given data on the given row index and notifies run-time about the changed row.
|
|
221
|
-
* @param row index in range 0..(rowCount() - 1).
|
|
222
|
-
* @param data new data item to store on the given row index
|
|
223
|
-
*/
|
|
224
|
-
setRowData(row: number, data: T): void;
|
|
225
|
-
/**
|
|
226
|
-
* Pushes new values to the array that's backing the model and notifies
|
|
227
|
-
* the run-time about the added rows.
|
|
228
|
-
* @param values list of values that will be pushed to the array.
|
|
229
|
-
*/
|
|
230
|
-
push(...values: T[]): void;
|
|
231
|
-
/**
|
|
232
|
-
* Removes the last element from the array and returns it.
|
|
233
|
-
*
|
|
234
|
-
* @returns The removed element or undefined if the array is empty.
|
|
235
|
-
*/
|
|
236
|
-
pop(): T | undefined;
|
|
237
|
-
/**
|
|
238
|
-
* Removes the specified number of element from the array that's backing
|
|
239
|
-
* the model, starting at the specified index.
|
|
240
|
-
* @param index index of first row to remove.
|
|
241
|
-
* @param size number of rows to remove.
|
|
242
|
-
*/
|
|
243
|
-
remove(index: number, size: number): void;
|
|
244
|
-
/**
|
|
245
|
-
* Returns an iterable of values in the array.
|
|
246
|
-
*/
|
|
247
|
-
values(): IterableIterator<T>;
|
|
248
|
-
/**
|
|
249
|
-
* Returns an iterable of key, value pairs for every entry in the array.
|
|
250
|
-
*/
|
|
251
|
-
entries(): IterableIterator<[number, T]>;
|
|
252
|
-
}
|
|
253
|
-
export declare namespace private_api {
|
|
254
|
-
/**
|
|
255
|
-
* Provides rows that are generated by a map function based on the rows of another Model.
|
|
256
|
-
*
|
|
257
|
-
* @template T item type of source model that is mapped to U.
|
|
258
|
-
* @template U the type of the mapped items
|
|
259
|
-
*
|
|
260
|
-
* ## Example
|
|
261
|
-
*
|
|
262
|
-
* Here we have a {@link ArrayModel} holding rows of a custom interface `Name` and a {@link MapModel} that maps the name rows
|
|
263
|
-
* to single string rows.
|
|
264
|
-
*
|
|
265
|
-
* ```ts
|
|
266
|
-
* import { Model, ArrayModel, MapModel } from "./index";
|
|
267
|
-
*
|
|
268
|
-
* interface Name {
|
|
269
|
-
* first: string;
|
|
270
|
-
* last: string;
|
|
271
|
-
* }
|
|
272
|
-
*
|
|
273
|
-
* const model = new ArrayModel<Name>([
|
|
274
|
-
* {
|
|
275
|
-
* first: "Hans",
|
|
276
|
-
* last: "Emil",
|
|
277
|
-
* },
|
|
278
|
-
* {
|
|
279
|
-
* first: "Max",
|
|
280
|
-
* last: "Mustermann",
|
|
281
|
-
* },
|
|
282
|
-
* {
|
|
283
|
-
* first: "Roman",
|
|
284
|
-
* last: "Tisch",
|
|
285
|
-
* },
|
|
286
|
-
* ]);
|
|
287
|
-
*
|
|
288
|
-
* const mappedModel = new MapModel(
|
|
289
|
-
* model,
|
|
290
|
-
* (data) => {
|
|
291
|
-
* return data.last + ", " + data.first;
|
|
292
|
-
* }
|
|
293
|
-
* );
|
|
294
|
-
*
|
|
295
|
-
* // prints "Emil, Hans"
|
|
296
|
-
* console.log(mappedModel.rowData(0));
|
|
297
|
-
*
|
|
298
|
-
* // prints "Mustermann, Max"
|
|
299
|
-
* console.log(mappedModel.rowData(1));
|
|
300
|
-
*
|
|
301
|
-
* // prints "Tisch, Roman"
|
|
302
|
-
* console.log(mappedModel.rowData(2));
|
|
303
|
-
*
|
|
304
|
-
* // Alternatively you can use the shortcut {@link MapModel.map}.
|
|
305
|
-
*
|
|
306
|
-
* const model = new ArrayModel<Name>([
|
|
307
|
-
* {
|
|
308
|
-
* first: "Hans",
|
|
309
|
-
* last: "Emil",
|
|
310
|
-
* },
|
|
311
|
-
* {
|
|
312
|
-
* first: "Max",
|
|
313
|
-
* last: "Mustermann",
|
|
314
|
-
* },
|
|
315
|
-
* {
|
|
316
|
-
* first: "Roman",
|
|
317
|
-
* last: "Tisch",
|
|
318
|
-
* },
|
|
319
|
-
* ]);
|
|
320
|
-
*
|
|
321
|
-
* const mappedModel = model.map(
|
|
322
|
-
* (data) => {
|
|
323
|
-
* return data.last + ", " + data.first;
|
|
324
|
-
* }
|
|
325
|
-
* );
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* // prints "Emil, Hans"
|
|
329
|
-
* console.log(mappedModel.rowData(0));
|
|
330
|
-
*
|
|
331
|
-
* // prints "Mustermann, Max"
|
|
332
|
-
* console.log(mappedModel.rowData(1));
|
|
333
|
-
*
|
|
334
|
-
* // prints "Tisch, Roman"
|
|
335
|
-
* console.log(mappedModel.rowData(2));
|
|
336
|
-
*
|
|
337
|
-
* // You can modifying the underlying {@link ArrayModel}:
|
|
338
|
-
*
|
|
339
|
-
* const model = new ArrayModel<Name>([
|
|
340
|
-
* {
|
|
341
|
-
* first: "Hans",
|
|
342
|
-
* last: "Emil",
|
|
343
|
-
* },
|
|
344
|
-
* {
|
|
345
|
-
* first: "Max",
|
|
346
|
-
* last: "Mustermann",
|
|
347
|
-
* },
|
|
348
|
-
* {
|
|
349
|
-
* first: "Roman",
|
|
350
|
-
* last: "Tisch",
|
|
351
|
-
* },
|
|
352
|
-
* ]);
|
|
353
|
-
*
|
|
354
|
-
* const mappedModel = model.map(
|
|
355
|
-
* (data) => {
|
|
356
|
-
* return data.last + ", " + data.first;
|
|
357
|
-
* }
|
|
358
|
-
* );
|
|
359
|
-
*
|
|
360
|
-
* model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
|
|
361
|
-
*
|
|
362
|
-
* // prints "Emil, Hans"
|
|
363
|
-
* console.log(mappedModel.rowData(0));
|
|
364
|
-
*
|
|
365
|
-
* // prints "Musterfrau, Minnie"
|
|
366
|
-
* console.log(mappedModel.rowData(1));
|
|
367
|
-
*
|
|
368
|
-
* // prints "Tisch, Roman"
|
|
369
|
-
* console.log(mappedModel.rowData(2));
|
|
370
|
-
* ```
|
|
371
|
-
*/
|
|
372
|
-
class MapModel<T, U> extends Model<U> {
|
|
373
|
-
#private;
|
|
374
|
-
readonly sourceModel: Model<T>;
|
|
375
|
-
/**
|
|
376
|
-
* Constructs the MapModel with a source model and map functions.
|
|
377
|
-
* @template T item type of source model that is mapped to U.
|
|
378
|
-
* @template U the type of the mapped items.
|
|
379
|
-
* @param sourceModel the wrapped model.
|
|
380
|
-
* @param mapFunction maps the data from T to U.
|
|
381
|
-
*/
|
|
382
|
-
constructor(sourceModel: Model<T>, mapFunction: (data: T) => U);
|
|
383
|
-
/**
|
|
384
|
-
* Returns the number of entries in the model.
|
|
385
|
-
*/
|
|
386
|
-
rowCount(): number;
|
|
387
|
-
/**
|
|
388
|
-
* Returns the data at the specified row.
|
|
389
|
-
* @param row index in range 0..(rowCount() - 1).
|
|
390
|
-
* @returns undefined if row is out of range otherwise the data.
|
|
391
|
-
*/
|
|
392
|
-
rowData(row: number): U | undefined;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
91
|
/**
|
|
396
92
|
* This interface describes the public API of a Slint component that is common to all instances. Use this to
|
|
397
93
|
* show() the window on the screen, access the window and subsequent window properties, or start the
|
|
@@ -566,6 +262,148 @@ export declare function runEventLoop(args?: Function | {
|
|
|
566
262
|
from run_event_loop() will resolve in a later tick of the nodejs event loop.
|
|
567
263
|
*/
|
|
568
264
|
export declare function quitEventLoop(): void;
|
|
265
|
+
export declare namespace private_api {
|
|
266
|
+
/**
|
|
267
|
+
* Provides rows that are generated by a map function based on the rows of another Model.
|
|
268
|
+
*
|
|
269
|
+
* @template T item type of source model that is mapped to U.
|
|
270
|
+
* @template U the type of the mapped items
|
|
271
|
+
*
|
|
272
|
+
* ## Example
|
|
273
|
+
*
|
|
274
|
+
* Here we have a {@link ArrayModel} holding rows of a custom interface `Name` and a {@link MapModel} that maps the name rows
|
|
275
|
+
* to single string rows.
|
|
276
|
+
*
|
|
277
|
+
* ```ts
|
|
278
|
+
* import { Model, ArrayModel, MapModel } from "./index";
|
|
279
|
+
*
|
|
280
|
+
* interface Name {
|
|
281
|
+
* first: string;
|
|
282
|
+
* last: string;
|
|
283
|
+
* }
|
|
284
|
+
*
|
|
285
|
+
* const model = new ArrayModel<Name>([
|
|
286
|
+
* {
|
|
287
|
+
* first: "Hans",
|
|
288
|
+
* last: "Emil",
|
|
289
|
+
* },
|
|
290
|
+
* {
|
|
291
|
+
* first: "Max",
|
|
292
|
+
* last: "Mustermann",
|
|
293
|
+
* },
|
|
294
|
+
* {
|
|
295
|
+
* first: "Roman",
|
|
296
|
+
* last: "Tisch",
|
|
297
|
+
* },
|
|
298
|
+
* ]);
|
|
299
|
+
*
|
|
300
|
+
* const mappedModel = new MapModel(
|
|
301
|
+
* model,
|
|
302
|
+
* (data) => {
|
|
303
|
+
* return data.last + ", " + data.first;
|
|
304
|
+
* }
|
|
305
|
+
* );
|
|
306
|
+
*
|
|
307
|
+
* // prints "Emil, Hans"
|
|
308
|
+
* console.log(mappedModel.rowData(0));
|
|
309
|
+
*
|
|
310
|
+
* // prints "Mustermann, Max"
|
|
311
|
+
* console.log(mappedModel.rowData(1));
|
|
312
|
+
*
|
|
313
|
+
* // prints "Tisch, Roman"
|
|
314
|
+
* console.log(mappedModel.rowData(2));
|
|
315
|
+
*
|
|
316
|
+
* // Alternatively you can use the shortcut {@link MapModel.map}.
|
|
317
|
+
*
|
|
318
|
+
* const model = new ArrayModel<Name>([
|
|
319
|
+
* {
|
|
320
|
+
* first: "Hans",
|
|
321
|
+
* last: "Emil",
|
|
322
|
+
* },
|
|
323
|
+
* {
|
|
324
|
+
* first: "Max",
|
|
325
|
+
* last: "Mustermann",
|
|
326
|
+
* },
|
|
327
|
+
* {
|
|
328
|
+
* first: "Roman",
|
|
329
|
+
* last: "Tisch",
|
|
330
|
+
* },
|
|
331
|
+
* ]);
|
|
332
|
+
*
|
|
333
|
+
* const mappedModel = model.map(
|
|
334
|
+
* (data) => {
|
|
335
|
+
* return data.last + ", " + data.first;
|
|
336
|
+
* }
|
|
337
|
+
* );
|
|
338
|
+
*
|
|
339
|
+
*
|
|
340
|
+
* // prints "Emil, Hans"
|
|
341
|
+
* console.log(mappedModel.rowData(0));
|
|
342
|
+
*
|
|
343
|
+
* // prints "Mustermann, Max"
|
|
344
|
+
* console.log(mappedModel.rowData(1));
|
|
345
|
+
*
|
|
346
|
+
* // prints "Tisch, Roman"
|
|
347
|
+
* console.log(mappedModel.rowData(2));
|
|
348
|
+
*
|
|
349
|
+
* // You can modifying the underlying {@link ArrayModel}:
|
|
350
|
+
*
|
|
351
|
+
* const model = new ArrayModel<Name>([
|
|
352
|
+
* {
|
|
353
|
+
* first: "Hans",
|
|
354
|
+
* last: "Emil",
|
|
355
|
+
* },
|
|
356
|
+
* {
|
|
357
|
+
* first: "Max",
|
|
358
|
+
* last: "Mustermann",
|
|
359
|
+
* },
|
|
360
|
+
* {
|
|
361
|
+
* first: "Roman",
|
|
362
|
+
* last: "Tisch",
|
|
363
|
+
* },
|
|
364
|
+
* ]);
|
|
365
|
+
*
|
|
366
|
+
* const mappedModel = model.map(
|
|
367
|
+
* (data) => {
|
|
368
|
+
* return data.last + ", " + data.first;
|
|
369
|
+
* }
|
|
370
|
+
* );
|
|
371
|
+
*
|
|
372
|
+
* model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
|
|
373
|
+
*
|
|
374
|
+
* // prints "Emil, Hans"
|
|
375
|
+
* console.log(mappedModel.rowData(0));
|
|
376
|
+
*
|
|
377
|
+
* // prints "Musterfrau, Minnie"
|
|
378
|
+
* console.log(mappedModel.rowData(1));
|
|
379
|
+
*
|
|
380
|
+
* // prints "Tisch, Roman"
|
|
381
|
+
* console.log(mappedModel.rowData(2));
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
class MapModel<T, U> extends Model<U> {
|
|
385
|
+
#private;
|
|
386
|
+
readonly sourceModel: Model<T>;
|
|
387
|
+
/**
|
|
388
|
+
* Constructs the MapModel with a source model and map functions.
|
|
389
|
+
* @template T item type of source model that is mapped to U.
|
|
390
|
+
* @template U the type of the mapped items.
|
|
391
|
+
* @param sourceModel the wrapped model.
|
|
392
|
+
* @param mapFunction maps the data from T to U.
|
|
393
|
+
*/
|
|
394
|
+
constructor(sourceModel: Model<T>, mapFunction: (data: T) => U);
|
|
395
|
+
/**
|
|
396
|
+
* Returns the number of entries in the model.
|
|
397
|
+
*/
|
|
398
|
+
rowCount(): number;
|
|
399
|
+
/**
|
|
400
|
+
* Returns the data at the specified row.
|
|
401
|
+
* @param row index in range 0..(rowCount() - 1).
|
|
402
|
+
* @returns undefined if row is out of range otherwise the data.
|
|
403
|
+
*/
|
|
404
|
+
rowData(row: number): U | undefined;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
569
407
|
/**
|
|
570
408
|
* @hidden
|
|
571
409
|
*/
|