@triniwiz/nativescript-masonkit 1.0.0-alpha.21 → 1.0.0-alpha.22

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/helpers.js DELETED
@@ -1,1315 +0,0 @@
1
- // declare const __non_webpack_require__;
2
- import { Length, Utils } from '@nativescript/core';
3
- import { style_ } from './common';
4
- import { parseUnit } from '@nativescript/core/css/parser';
5
- // if (__ANDROID__) {
6
- // try {
7
- // java.lang.System.loadLibrary('masonnative');
8
- // __non_webpack_require__('system_lib://libmasonnativev8.so');
9
- // UseV8Module = true;
10
- // } catch (error) {
11
- // console.warn('Failed to enable on FastAPI');
12
- // }
13
- // }
14
- // if (__APPLE__) {
15
- // NSCMason.alwaysEnable = true;
16
- // if (!UseV8Module) {
17
- // try {
18
- // const installer = MasonV8Module.new();
19
- // installer.install();
20
- // UseV8Module = true;
21
- // } catch (error) {
22
- // console.warn('Failed to enable on FastAPI');
23
- // }
24
- // }
25
- // }
26
- function getMasonInstance(instance) {
27
- const nativeView = instance?.android;
28
- if (instance._isMasonChild) {
29
- return org.nativescript.mason.masonkit.Mason.getShared().nodeForView(nativeView);
30
- }
31
- return nativeView.getNode();
32
- }
33
- function getStyleInstance(instance) {
34
- const nativeView = instance?.android;
35
- if (instance._isMasonChild) {
36
- return org.nativescript.mason.masonkit.Mason.getShared()
37
- .nodeForView(nativeView)
38
- .getStyle();
39
- }
40
- return nativeView.getStyle();
41
- }
42
- function getNode(instance) {
43
- const nativeView = instance?.ios;
44
- if (instance._isMasonChild) {
45
- return NSCMason.shared.nodeForView(nativeView, true);
46
- }
47
- return nativeView.node;
48
- }
49
- function getStyle(instance) {
50
- const nativeView = instance?.ios;
51
- if (instance._isMasonChild) {
52
- return NSCMason.shared.nodeForView(nativeView, true).style;
53
- }
54
- return nativeView.style;
55
- }
56
- export function _forceStyleUpdate(instance) {
57
- if (!instance._hasNativeView) {
58
- return;
59
- }
60
- // if (__ANDROID__) {
61
- // const nodeOrView = getMasonInstance(instance) as org.nativescript.mason.masonkit.TextView;
62
- // nodeOrView.getStyle().updateNodeAndStyle();
63
- // }
64
- // if (__APPLE__) {
65
- // (instance.ios as MasonUIView).node.style.updateNativeStyle();
66
- // }
67
- }
68
- export function _markDirty(instance) {
69
- if (!instance._hasNativeView) {
70
- return;
71
- }
72
- if (__ANDROID__) {
73
- const nodeOrView = getMasonInstance(instance);
74
- nodeOrView.dirty();
75
- }
76
- if (__APPLE__) {
77
- getNode(instance).markDirty();
78
- }
79
- }
80
- export function _isDirty(instance) {
81
- if (!instance._hasNativeView) {
82
- return;
83
- }
84
- if (__ANDROID__) {
85
- const nodeOrView = getMasonInstance(instance);
86
- return nodeOrView.isDirty();
87
- }
88
- if (__APPLE__) {
89
- return getNode(instance).isDirty;
90
- }
91
- return false;
92
- }
93
- export function _intoType(type) {
94
- switch (type) {
95
- case 'auto':
96
- return 0 /* MasonDimensionCompatType.Auto */;
97
- case 'points':
98
- return 1 /* MasonDimensionCompatType.Points */;
99
- case 'percent':
100
- return 2 /* MasonDimensionCompatType.Percent */;
101
- default:
102
- return 0 /* MasonDimensionCompatType.Auto */;
103
- }
104
- }
105
- export function _parseDimension(dim) {
106
- if (__APPLE__) {
107
- const type = dim.type;
108
- const value = dim.value;
109
- switch (type) {
110
- case 0 /* MasonDimensionCompatType.Auto */:
111
- return 'auto';
112
- case 1 /* MasonDimensionCompatType.Points */:
113
- return { value: value, unit: 'px' };
114
- case 2 /* MasonDimensionCompatType.Percent */:
115
- return { value: value, unit: '%' };
116
- }
117
- }
118
- const name = dim.getClass().getName();
119
- switch (name) {
120
- case 'org.nativescript.mason.masonkit.Dimension$Points':
121
- return { value: dim.getPoints(), unit: 'px' };
122
- case 'org.nativescript.mason.masonkit.Dimension$Percent':
123
- return { value: dim.getPercentage(), unit: '%' };
124
- case 'org.nativescript.mason.masonkit.Dimension$Auto':
125
- return 'auto';
126
- }
127
- }
128
- export function _parseLengthPercentage(dim) {
129
- if (__APPLE__) {
130
- const type = dim.type;
131
- const value = dim.value;
132
- switch (type) {
133
- case 0 /* MasonLengthPercentageCompatType.Points */:
134
- return { value: value, unit: 'px' };
135
- case 1 /* MasonLengthPercentageCompatType.Percent */:
136
- return { value: value, unit: '%' };
137
- }
138
- }
139
- const name = dim.getClass().getName();
140
- switch (name) {
141
- case 'org.nativescript.mason.masonkit.LengthPercentage$Points':
142
- return { value: dim.getPoints(), unit: 'px' };
143
- case 'org.nativescript.mason.masonkit.LengthPercentage$Percent':
144
- return { value: dim.getPercentage(), unit: '%' };
145
- case 'org.nativescript.mason.masonkit.LengthPercentage$Auto':
146
- return 'auto';
147
- }
148
- }
149
- export function _parseLengthPercentageAuto(dim) {
150
- if (__APPLE__) {
151
- const type = dim.type;
152
- const value = dim.value;
153
- switch (type) {
154
- case 0 /* MasonLengthPercentageAutoCompatType.Auto */:
155
- return 'auto';
156
- case 1 /* MasonLengthPercentageAutoCompatType.Points */:
157
- return { value: value, unit: 'px' };
158
- case 2 /* MasonLengthPercentageAutoCompatType.Percent */:
159
- return { value: value, unit: '%' };
160
- }
161
- }
162
- const name = dim.getClass().getName();
163
- switch (name) {
164
- case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Points':
165
- return { value: dim.getPoints(), unit: 'px' };
166
- case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Percent':
167
- return { value: dim.getPercentage(), unit: '%' };
168
- case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Auto':
169
- return 'auto';
170
- }
171
- }
172
- export function _toMasonDimension(value) {
173
- if (value === undefined || value === null) {
174
- return value;
175
- }
176
- if (value === 'auto') {
177
- return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
178
- }
179
- let typeOf = typeof value;
180
- if (typeOf === 'number') {
181
- return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
182
- }
183
- if (typeOf === 'string') {
184
- value = parseUnit(value).value;
185
- typeOf = 'object';
186
- }
187
- if (typeOf === 'object') {
188
- switch (value?.unit) {
189
- case '%':
190
- return { value: value.value, type: 'percent', native_type: 2 /* MasonDimensionCompatType.Percent */ };
191
- case 'px':
192
- return { value: value.value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
193
- case 'dip':
194
- return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
195
- }
196
- }
197
- return { value: value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
198
- }
199
- export function _intoMasonDimension(value) {
200
- if (value === undefined || value === null) {
201
- return null;
202
- }
203
- if (__APPLE__) {
204
- if (value === 'auto') {
205
- return MasonDimensionCompat.Auto;
206
- }
207
- const typeOf = typeof value;
208
- if (typeOf === 'object') {
209
- switch (value?.unit) {
210
- case '%':
211
- return MasonDimensionCompat.alloc().initWithPercent(value.value);
212
- case 'px':
213
- return MasonDimensionCompat.alloc().initWithPoints(value.value);
214
- case 'dip':
215
- return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value.value));
216
- }
217
- }
218
- if (typeOf === 'number') {
219
- return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
220
- }
221
- return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
222
- }
223
- if (__ANDROID__) {
224
- if (value === 'auto') {
225
- return org.nativescript.mason.masonkit.Dimension.Auto;
226
- }
227
- const typeOf = typeof value;
228
- if (typeOf === 'object') {
229
- switch (value?.unit) {
230
- case '%':
231
- return new org.nativescript.mason.masonkit.Dimension.Percent(value.value);
232
- case 'px':
233
- return new org.nativescript.mason.masonkit.Dimension.Points(value.value);
234
- case 'dip':
235
- return new org.nativescript.mason.masonkit.Dimension.Points(Utils.layout.toDevicePixels(value.value));
236
- }
237
- }
238
- if (typeOf === 'number') {
239
- return new org.nativescript.mason.masonkit.Dimension.Points(Utils.layout.toDevicePixels(value));
240
- }
241
- return new org.nativescript.mason.masonkit.Dimension.Points(Utils.layout.toDevicePixels(value));
242
- }
243
- return null;
244
- }
245
- export function _toLengthPercentageAuto(value) {
246
- if (value === undefined || value === null) {
247
- return value;
248
- }
249
- if (value === 'auto') {
250
- return { value: 0, type: 'auto', native_type: 0 /* MasonLengthPercentageAutoCompatType.Auto */ };
251
- }
252
- const typeOf = typeof value;
253
- if (typeOf === 'object') {
254
- switch (value?.unit) {
255
- case '%':
256
- return { value: value.value, type: 'percent', native_type: 2 /* MasonLengthPercentageAutoCompatType.Percent */ };
257
- case 'px':
258
- return { value: value.value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
259
- case 'dip':
260
- return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
261
- }
262
- }
263
- if (typeOf === 'number') {
264
- return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
265
- }
266
- return { value: value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
267
- }
268
- export function _toLengthPercentage(value) {
269
- if (value === undefined || value === null) {
270
- return value;
271
- }
272
- if (typeof value === 'string') {
273
- const parsed = Length.parse(value);
274
- if (parsed) {
275
- value = parsed;
276
- }
277
- }
278
- const typeOf = typeof value;
279
- if (typeOf === 'object') {
280
- switch (value?.unit) {
281
- case '%':
282
- return { value: value.value, type: 'percent', native_type: 1 /* MasonLengthPercentageCompatType.Percent */ };
283
- case 'px':
284
- return { value: value.value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
285
- case 'dip':
286
- return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
287
- }
288
- }
289
- if (typeOf === 'number') {
290
- return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
291
- }
292
- return { value: value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
293
- }
294
- function syncStyle(instance) {
295
- // noop
296
- }
297
- export function _setDisplay(value, instance, initial = false) {
298
- if (initial && value === 'block') {
299
- return;
300
- }
301
- if (instance._hasNativeView) {
302
- instance._styleHelper.display = value;
303
- syncStyle(instance);
304
- }
305
- }
306
- export function _getDisplay(instance) {
307
- return instance._styleHelper.display;
308
- }
309
- export function _setMinWidth(value, instance, initial = false) {
310
- if (!instance._hasNativeView) {
311
- return;
312
- }
313
- instance._styleHelper.minWidth = value;
314
- syncStyle(instance);
315
- }
316
- export function _getMinWidth(instance) {
317
- if (!instance._hasNativeView) {
318
- return instance.style.minWidth;
319
- }
320
- return instance._styleHelper.minWidth;
321
- }
322
- export function _setMinHeight(value, instance, initial = false) {
323
- if (!instance._hasNativeView) {
324
- return;
325
- }
326
- instance._styleHelper.minHeight = value;
327
- syncStyle(instance);
328
- }
329
- export function _getMinHeight(instance) {
330
- if (!instance._hasNativeView) {
331
- return instance.style.minHeight;
332
- }
333
- return instance._styleHelper.minHeight;
334
- }
335
- export function _setWidth(value, instance, initial = false) {
336
- if (!instance._hasNativeView) {
337
- return;
338
- }
339
- if (instance._styleHelper) {
340
- instance._styleHelper.width = value;
341
- }
342
- syncStyle(instance);
343
- }
344
- export function _getWidth(instance) {
345
- if (!instance._hasNativeView) {
346
- return instance.style.width;
347
- }
348
- return instance._styleHelper.width;
349
- }
350
- export function _setHeight(value, instance, initial = false) {
351
- if (!instance._hasNativeView) {
352
- return;
353
- }
354
- instance._styleHelper.height = value;
355
- }
356
- export function _getHeight(instance) {
357
- if (!instance._hasNativeView) {
358
- return instance.style.height;
359
- }
360
- return instance._styleHelper.height;
361
- }
362
- export function _setMaxWidth(value, instance, initial = false) {
363
- if (!instance._hasNativeView) {
364
- return;
365
- }
366
- instance._styleHelper.maxWidth = value;
367
- syncStyle(instance);
368
- }
369
- export function _getMaxWidth(instance) {
370
- if (!instance._hasNativeView) {
371
- return instance.style.maxWidth;
372
- }
373
- return instance._styleHelper.maxWidth;
374
- }
375
- export function _setMaxHeight(value, instance, initial = false) {
376
- if (!instance._hasNativeView) {
377
- return;
378
- }
379
- instance._styleHelper.maxHeight = value;
380
- syncStyle(instance);
381
- }
382
- export function _getMaxHeight(instance) {
383
- if (!instance._hasNativeView) {
384
- return instance.style.maxHeight;
385
- }
386
- return instance._styleHelper.maxHeight;
387
- }
388
- export function _setFlexDirection(value, instance, initial = false) {
389
- if (initial && value === 'row') {
390
- return;
391
- }
392
- if (instance._hasNativeView) {
393
- instance._styleHelper.flexDirection = value;
394
- }
395
- }
396
- export function _getFlexDirection(instance) {
397
- return instance._styleHelper.flexDirection;
398
- }
399
- export function _getPosition(instance) {
400
- return instance._styleHelper.position;
401
- }
402
- export function _setPosition(value, instance, initial = false) {
403
- if (initial && value === 'relative') {
404
- return;
405
- }
406
- if (instance._hasNativeView) {
407
- instance._styleHelper.position = value;
408
- }
409
- }
410
- export function _setFlexWrap(value, instance, initial = false) {
411
- if (initial && value === 'no-wrap') {
412
- return;
413
- }
414
- if (instance._hasNativeView) {
415
- instance._styleHelper.flexWrap = value;
416
- }
417
- }
418
- export function _getFlexWrap(instance) {
419
- if (instance._hasNativeView) {
420
- return instance._styleHelper.flexWrap;
421
- }
422
- return instance.style.flexWrap;
423
- }
424
- export function _setAlignItems(value, instance, initial = false) {
425
- if (initial && value === 'normal') {
426
- return;
427
- }
428
- if (instance._hasNativeView) {
429
- instance._styleHelper.alignItems = value;
430
- }
431
- }
432
- export function _getAlignItems(instance) {
433
- if (instance._hasNativeView) {
434
- return instance._styleHelper.alignItems;
435
- }
436
- return instance.style.alignItems;
437
- }
438
- export function _setAlignSelf(value, instance, initial = false) {
439
- if (initial && value === 'normal') {
440
- return;
441
- }
442
- if (instance._hasNativeView) {
443
- instance._styleHelper.alignSelf = value;
444
- }
445
- }
446
- export function _getAlignSelf(instance) {
447
- if (instance._hasNativeView) {
448
- return instance._styleHelper.alignSelf;
449
- }
450
- return instance.style.alignSelf;
451
- }
452
- export function _setAlignContent(value, instance, initial = false) {
453
- if (initial && value === 'normal') {
454
- return;
455
- }
456
- if (instance._hasNativeView) {
457
- if (instance._styleHelper) {
458
- instance._styleHelper.alignContent = value;
459
- }
460
- }
461
- }
462
- export function _getAlignContent(instance) {
463
- if (instance._hasNativeView) {
464
- return instance._styleHelper.alignContent;
465
- }
466
- return instance.style.alignContent;
467
- }
468
- export function _setJustifyItems(value, instance, initial = false) {
469
- if (initial && value === 'normal') {
470
- return;
471
- }
472
- if (instance._hasNativeView) {
473
- instance._styleHelper.justifyItems = value;
474
- }
475
- }
476
- export function _getJustifyItems(instance) {
477
- if (instance._hasNativeView) {
478
- return instance._styleHelper.justifyItems;
479
- }
480
- return instance.style.justifyItems;
481
- }
482
- export function _setJustifySelf(value, instance, initial = false) {
483
- if (initial && value === 'normal') {
484
- return;
485
- }
486
- if (instance._hasNativeView) {
487
- instance._styleHelper.justifySelf = value;
488
- }
489
- }
490
- export function _getJustifySelf(instance) {
491
- if (instance._hasNativeView) {
492
- return instance._styleHelper.justifySelf;
493
- }
494
- return instance.style.justifySelf;
495
- }
496
- export function _setJustifyContent(value, instance, initial = false) {
497
- if (initial && value === 'normal') {
498
- return;
499
- }
500
- if (!value)
501
- value = 'normal';
502
- if (instance._hasNativeView) {
503
- if (instance._styleHelper) {
504
- instance._styleHelper.justifyContent = value;
505
- }
506
- }
507
- }
508
- export function _getJustifyContent(instance) {
509
- if (instance._hasNativeView) {
510
- return instance._styleHelper.justifyContent;
511
- }
512
- return instance.style.justifyContent;
513
- }
514
- export function _setLeft(value, instance, initial = false) {
515
- if (!instance._hasNativeView) {
516
- return;
517
- }
518
- instance._styleHelper.left = value;
519
- }
520
- export function _setRight(value, instance, initial = false) {
521
- if (!instance._hasNativeView) {
522
- return;
523
- }
524
- instance._styleHelper.right = value;
525
- }
526
- export function _setTop(value, instance, initial = false) {
527
- if (!instance._hasNativeView) {
528
- return;
529
- }
530
- instance._styleHelper.top = value;
531
- }
532
- export function _setBottom(value, instance, initial = false) {
533
- if (!instance._hasNativeView) {
534
- return;
535
- }
536
- instance._styleHelper.bottom = value;
537
- }
538
- export function _setMarginLeft(value, instance, initial = false) {
539
- if (!instance._hasNativeView) {
540
- return;
541
- }
542
- instance._styleHelper.marginLeft = value;
543
- }
544
- export function _setMarginRight(value, instance, initial = false) {
545
- if (!instance._hasNativeView) {
546
- return;
547
- }
548
- instance._styleHelper.marginRight = value;
549
- }
550
- export function _setMarginTop(value, instance, initial = false) {
551
- if (!instance._hasNativeView) {
552
- return;
553
- }
554
- instance._styleHelper.marginTop = value;
555
- }
556
- export function _setMarginBottom(value, instance, initial = false) {
557
- if (!instance._hasNativeView) {
558
- return;
559
- }
560
- instance._styleHelper.marginBottom = value;
561
- }
562
- export function _setPaddingLeft(value, instance, initial = false) {
563
- if (!instance._hasNativeView) {
564
- return;
565
- }
566
- instance._styleHelper.paddingLeft = value;
567
- }
568
- export function _setPaddingRight(value, instance, initial = false) {
569
- if (!instance._hasNativeView) {
570
- return;
571
- }
572
- instance._styleHelper.paddingRight = value;
573
- }
574
- export function _setPaddingTop(value, instance, initial = false) {
575
- if (!instance._hasNativeView) {
576
- return;
577
- }
578
- instance._styleHelper.paddingTop = value;
579
- }
580
- export function _setPaddingBottom(value, instance, initial = false) {
581
- if (!instance._hasNativeView) {
582
- return;
583
- }
584
- instance._styleHelper.paddingBottom = value;
585
- }
586
- export function _setBorderLeft(value, instance, initial = false) {
587
- if (!instance._hasNativeView) {
588
- return;
589
- }
590
- }
591
- export function _setBorderRight(value, instance, initial = false) {
592
- if (!instance._hasNativeView) {
593
- return;
594
- }
595
- }
596
- export function _setBorderTop(value, instance, initial = false) {
597
- if (!instance._hasNativeView) {
598
- return;
599
- }
600
- }
601
- export function _setBorderBottom(value, instance, initial = false) {
602
- if (!instance._hasNativeView) {
603
- return;
604
- }
605
- }
606
- export function _setFlexBasis(value, instance, initial = false) {
607
- if (!instance._hasNativeView) {
608
- return;
609
- }
610
- instance._styleHelper.flexBasis = value;
611
- }
612
- export function _getFlexBasis(instance) {
613
- if (!instance._hasNativeView) {
614
- return instance.style.flexBasis;
615
- }
616
- return instance._styleHelper.flexBasis;
617
- }
618
- export function _setGap(value, instance, initial = false) {
619
- if (!instance._hasNativeView) {
620
- return;
621
- }
622
- }
623
- export function _getGap(instance) {
624
- if (!instance._hasNativeView) {
625
- return instance.style.gap;
626
- }
627
- return {
628
- row: this._styleHelper.rowGap,
629
- column: this._styleHelper.columnGap,
630
- };
631
- }
632
- export function _setOverflow(value, instance) {
633
- if (!instance._hasNativeView) {
634
- return;
635
- }
636
- instance._styleHelper.overflow = value;
637
- }
638
- export function _getOverflow(instance) {
639
- if (!instance._hasNativeView) {
640
- return instance.style.flexGrow;
641
- }
642
- return instance._styleHelper.overflow;
643
- }
644
- export function _setOverflowX(value, instance) {
645
- if (!instance._hasNativeView) {
646
- return;
647
- }
648
- instance._styleHelper.overflowX = value;
649
- }
650
- export function _getOverflowX(instance) {
651
- if (!instance._hasNativeView) {
652
- return instance.style.overflowX;
653
- }
654
- return instance._styleHelper.overflowX;
655
- }
656
- export function _setOverflowY(value, instance, initial = false) {
657
- if (!instance._hasNativeView) {
658
- return;
659
- }
660
- instance._styleHelper.overflowY = value;
661
- }
662
- export function _getOverflowY(instance) {
663
- if (!instance._hasNativeView) {
664
- return instance.style.overflowY;
665
- }
666
- return instance._styleHelper.overflowY;
667
- }
668
- export function _setScrollbarWidth(value, instance, initial = false) {
669
- if (!instance._hasNativeView) {
670
- return;
671
- }
672
- instance._styleHelper.scrollBarWidth = value;
673
- }
674
- export function getScrollbarWidth(instance) {
675
- if (!instance._hasNativeView) {
676
- return instance.style.scrollBarWidth;
677
- }
678
- return instance._styleHelper.scrollBarWidth;
679
- }
680
- export function _setFlexGrow(value, instance, initial = false) {
681
- if (!instance._hasNativeView) {
682
- return;
683
- }
684
- instance._styleHelper.flexGrow = value;
685
- }
686
- export function _getFlexGrow(instance) {
687
- if (!instance._hasNativeView) {
688
- return instance.style.flexGrow;
689
- }
690
- return instance._styleHelper.flexGrow;
691
- }
692
- export function _setFlexShrink(value, instance, initial = false) {
693
- if (!instance._hasNativeView) {
694
- return;
695
- }
696
- instance._styleHelper.flexShrink = value;
697
- }
698
- export function _getFlexShrink(instance) {
699
- if (!instance._hasNativeView) {
700
- return instance.style.flexShrink;
701
- }
702
- return instance._styleHelper.flexShrink;
703
- }
704
- export function _setAspectRatio(value, instance, initial = false) {
705
- if (!instance._hasNativeView) {
706
- return;
707
- }
708
- instance._styleHelper.aspectRatio = value ? value : Number.NaN;
709
- }
710
- export function _getAspectRatio(instance) {
711
- if (!instance._hasNativeView) {
712
- return instance.style.aspectRatio;
713
- }
714
- const ratio = instance._styleHelper.aspectRatio;
715
- return Number.isNaN(ratio) ? null : ratio;
716
- }
717
- function _parseGridLine(value) {
718
- let parsedValue = undefined;
719
- let parsedType = undefined;
720
- let nativeValue = undefined;
721
- if (value === 'auto' || value === undefined) {
722
- parsedValue = 0;
723
- parsedType = 0 /* GridPlacementCompatType.Auto */;
724
- }
725
- if (typeof value === 'string') {
726
- if (value.startsWith('span')) {
727
- parsedValue = Number(value.replace('span', '').trim());
728
- parsedType = 2 /* GridPlacementCompatType.Span */;
729
- }
730
- else {
731
- parsedValue = Number(value.trim());
732
- if (parsedValue < 1) {
733
- parsedValue = 0;
734
- parsedType = 0 /* GridPlacementCompatType.Auto */;
735
- }
736
- else {
737
- parsedType = 1 /* GridPlacementCompatType.Line */;
738
- }
739
- }
740
- }
741
- if (typeof value === 'number') {
742
- parsedValue = value;
743
- if (parsedValue < 1) {
744
- parsedValue = 0;
745
- parsedType = 0 /* GridPlacementCompatType.Auto */;
746
- }
747
- else {
748
- parsedType = 1 /* GridPlacementCompatType.Line */;
749
- }
750
- }
751
- if (parsedType === 0) {
752
- if (__ANDROID__) {
753
- parsedType = org.nativescript.mason.masonkit.GridPlacement.Auto;
754
- nativeValue = org.nativescript.mason.masonkit.GridPlacement.Auto.INSTANCE;
755
- }
756
- if (__APPLE__) {
757
- parsedType = 0 /* GridPlacementCompatType.Auto */;
758
- nativeValue = GridPlacementCompat.Auto;
759
- }
760
- }
761
- else if (parsedType === 1) {
762
- const isValid = !Number.isNaN(parsedValue);
763
- if (__ANDROID__) {
764
- parsedType = org.nativescript.mason.masonkit.GridPlacement.Line;
765
- if (isValid) {
766
- nativeValue = new org.nativescript.mason.masonkit.GridPlacement.Line(parsedValue);
767
- }
768
- }
769
- if (__APPLE__) {
770
- parsedType = 1 /* GridPlacementCompatType.Line */;
771
- if (isValid) {
772
- nativeValue = GridPlacementCompat.alloc().initWithLine(parsedValue);
773
- }
774
- }
775
- }
776
- else {
777
- const isValid = !Number.isNaN(parsedValue);
778
- if (__ANDROID__) {
779
- parsedType = org.nativescript.mason.masonkit.GridPlacement.Span;
780
- if (isValid) {
781
- nativeValue = new org.nativescript.mason.masonkit.GridPlacement.Span(parsedValue);
782
- }
783
- }
784
- if (__APPLE__) {
785
- parsedType = 2 /* GridPlacementCompatType.Span */;
786
- if (isValid) {
787
- nativeValue = GridPlacementCompat.alloc().initWithSpan(parsedValue);
788
- }
789
- }
790
- }
791
- return { value: Number.isNaN(parsedValue) ? undefined : parsedValue, type: parsedType, native_value: nativeValue };
792
- }
793
- export function _setGridColumnStart(value, instance, initial = false) {
794
- if (!instance._hasNativeView) {
795
- return;
796
- }
797
- const val = _parseGridLine(value);
798
- if (val.value === undefined || val.type === undefined) {
799
- return;
800
- }
801
- if (__ANDROID__) {
802
- const nodeOrView = getMasonInstance(instance);
803
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridColumnStart(nodeOrView, val.native_value);
804
- }
805
- if (__APPLE__) {
806
- instance.ios.gridColumnStartCompat = val.native_value;
807
- }
808
- }
809
- export function _setGridColumnEnd(value, instance, initial = false) {
810
- if (!instance._hasNativeView) {
811
- return;
812
- }
813
- const val = _parseGridLine(value);
814
- if (val.value === undefined || val.type === undefined) {
815
- return;
816
- }
817
- if (__ANDROID__) {
818
- const nodeOrView = getMasonInstance(instance);
819
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridColumnEnd(nodeOrView, val.native_value);
820
- }
821
- if (__APPLE__) {
822
- instance.ios.gridColumnEndCompat = val.native_value;
823
- }
824
- }
825
- export function _setGridRowStart(value, instance, initial = false) {
826
- if (!instance._hasNativeView) {
827
- return;
828
- }
829
- const val = _parseGridLine(value);
830
- if (val.value === undefined || val.type === undefined) {
831
- return;
832
- }
833
- if (__ANDROID__) {
834
- const nodeOrView = getMasonInstance(instance);
835
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridRowStart(nodeOrView, val.native_value);
836
- }
837
- if (__APPLE__) {
838
- instance.ios.gridRowStartCompat = val.native_value;
839
- }
840
- }
841
- export function _setGridRowEnd(value, instance, initial = false) {
842
- if (!instance._hasNativeView) {
843
- return;
844
- }
845
- const val = _parseGridLine(value);
846
- if (val.value === undefined || val.type === undefined) {
847
- return;
848
- }
849
- if (__ANDROID__) {
850
- const nodeOrView = getMasonInstance(instance);
851
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridRowEnd(nodeOrView, val.native_value);
852
- }
853
- if (__APPLE__) {
854
- instance.ios.gridRowEndCompat = val.native_value;
855
- }
856
- }
857
- export function _setRowGap(value, instance, initial = false) {
858
- if (!instance._hasNativeView) {
859
- return;
860
- }
861
- instance._styleHelper.rowGap = value;
862
- }
863
- export function _getRowGap(instance) {
864
- if (!instance._hasNativeView) {
865
- return instance.style.rowGap;
866
- }
867
- return instance._styleHelper.rowGap;
868
- }
869
- export function _setColumnGap(value, instance, initial = false) {
870
- if (!instance._hasNativeView) {
871
- return;
872
- }
873
- instance._styleHelper.columnGap = value;
874
- }
875
- export function _getColumnGap(instance) {
876
- if (!instance._hasNativeView) {
877
- return instance.style.gap;
878
- }
879
- return instance._styleHelper.columnGap;
880
- }
881
- const Auto = 'auto';
882
- const None = 'none';
883
- const MinContent = 'min-content';
884
- const MaxContent = 'max-content';
885
- export function _parseMinMaxValue(value) {
886
- if (typeof value === 'string') {
887
- if (value === Auto || value === None) {
888
- return {
889
- min_type: 0 /* MinSizingType.Auto */,
890
- min_value: 0,
891
- max_type: 0 /* MaxSizingType.Auto */,
892
- max_value: 0,
893
- };
894
- }
895
- else if (value === MinContent) {
896
- return {
897
- min_type: 1 /* MinSizingType.MinContent */,
898
- min_value: 0,
899
- max_type: 1 /* MaxSizingType.MinContent */,
900
- max_value: 0,
901
- };
902
- }
903
- else if (value === MaxContent) {
904
- return {
905
- min_type: 2 /* MinSizingType.MaxContent */,
906
- min_value: 0,
907
- max_type: 2 /* MaxSizingType.MaxContent */,
908
- max_value: 0,
909
- };
910
- }
911
- else if (value.indexOf('fr') > -1) {
912
- const flex = parseInt(value.replace('fr', '').trim());
913
- return {
914
- min_type: 0 /* MinSizingType.Auto */,
915
- min_value: 0,
916
- max_type: 5 /* MaxSizingType.Fraction */,
917
- max_value: flex,
918
- };
919
- }
920
- else if (value.startsWith('minmax')) {
921
- // todo
922
- const minMax = parseInt(value.replace('minmax(', '').replace(')', '').trim());
923
- }
924
- else if (value.startsWith('fit-content')) {
925
- const fitContent = value.replace('fit-content(', '').replace(')', '').trim();
926
- if (fitContent.indexOf('px') > -1) {
927
- const px = parseInt(fitContent.replace('px', ''));
928
- return {
929
- min_type: 0 /* MinSizingType.Auto */,
930
- min_value: px,
931
- max_type: 6 /* MaxSizingType.FitContent */,
932
- max_value: px,
933
- };
934
- }
935
- if (fitContent.indexOf('px') > -1) {
936
- const dip = Utils.layout.toDevicePixels(parseInt(fitContent.replace('dip', '')));
937
- return {
938
- min_type: 0 /* MinSizingType.Auto */,
939
- min_value: dip,
940
- max_type: 6 /* MaxSizingType.FitContent */,
941
- max_value: dip,
942
- };
943
- }
944
- if (fitContent.indexOf('%') > -1) {
945
- const percent = parseFloat(fitContent.replace('%', ''));
946
- return {
947
- min_type: 0 /* MinSizingType.Auto */,
948
- min_value: percent,
949
- max_type: 7 /* MaxSizingType.FitContentPercent */,
950
- max_value: percent,
951
- };
952
- }
953
- }
954
- else if (value.indexOf('px') > -1) {
955
- const px = parseInt(value.replace('px', ''));
956
- return {
957
- min_type: 3 /* MinSizingType.Points */,
958
- min_value: px,
959
- max_type: 3 /* MaxSizingType.Points */,
960
- max_value: px,
961
- };
962
- }
963
- else if (value.indexOf('dip') > -1) {
964
- const dip = Utils.layout.toDevicePixels(parseInt(value.replace('dip', '')));
965
- return {
966
- min_type: 3 /* MinSizingType.Points */,
967
- min_value: dip,
968
- max_type: 3 /* MaxSizingType.Points */,
969
- max_value: dip,
970
- };
971
- }
972
- else if (value.indexOf('%') > -1) {
973
- const percent = parseFloat(value.replace('%', ''));
974
- return {
975
- min_type: 4 /* MinSizingType.Percent */,
976
- min_value: percent,
977
- max_type: 4 /* MaxSizingType.Percent */,
978
- max_value: percent,
979
- };
980
- }
981
- else {
982
- const dip = Utils.layout.toDevicePixels(Number(value));
983
- return {
984
- min_type: 3 /* MinSizingType.Points */,
985
- min_value: dip,
986
- max_type: 3 /* MaxSizingType.Points */,
987
- max_value: dip,
988
- };
989
- }
990
- }
991
- if (typeof value === 'number') {
992
- const dip = Utils.layout.toDevicePixels(value);
993
- return {
994
- min_type: 3 /* MinSizingType.Points */,
995
- min_value: dip,
996
- max_type: 3 /* MaxSizingType.Points */,
997
- max_value: dip,
998
- };
999
- }
1000
- return undefined;
1001
- }
1002
- const grid_templates_regex = /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g;
1003
- export function _parseGridTemplates(value) {
1004
- const array = [];
1005
- if (typeof value === 'string') {
1006
- const values = Array.from(value.matchAll(grid_templates_regex), (m) => m[0]);
1007
- values.forEach((item) => {
1008
- if (item.startsWith('repeat(')) {
1009
- const repeatValue = item.replace('repeat(', '').replace(')', '');
1010
- const trackEnd = repeatValue.indexOf(',');
1011
- const repetition = repeatValue.substring(0, trackEnd);
1012
- const tracks = repeatValue
1013
- .substring(trackEnd + 1)
1014
- .split(' ')
1015
- .filter((a) => {
1016
- return a.length || a.trim() === ',';
1017
- });
1018
- let isValid = true;
1019
- let repeating_type = 0;
1020
- let repeat_count = 0;
1021
- switch (repetition) {
1022
- case 'repeat-fill':
1023
- repeating_type = 0 /* TSCGridTrackRepetition.AutoFill */;
1024
- break;
1025
- case 'repeat-fit':
1026
- repeating_type = 1 /* TSCGridTrackRepetition.AutoFit */;
1027
- break;
1028
- default:
1029
- {
1030
- const number = parseInt(repetition);
1031
- repeating_type = 2 /* TSCGridTrackRepetition.Count */;
1032
- isValid = !Number.isNaN(number);
1033
- if (isValid) {
1034
- repeat_count = number;
1035
- }
1036
- }
1037
- break;
1038
- }
1039
- if (isValid) {
1040
- const tracks_array = [];
1041
- tracks.forEach((track) => {
1042
- const minMax = _parseMinMaxValue(track.trim());
1043
- tracks_array.push(minMax);
1044
- });
1045
- array.push({
1046
- is_repeating: true,
1047
- repeating_type,
1048
- repeating_count: repeat_count,
1049
- value: tracks_array,
1050
- });
1051
- }
1052
- }
1053
- else {
1054
- const value = _parseMinMaxValue(item);
1055
- array.push({
1056
- is_repeating: false,
1057
- repeating_type: 0,
1058
- value,
1059
- });
1060
- }
1061
- });
1062
- }
1063
- return array;
1064
- }
1065
- export function _setGridTemplateRows(value, instance, initial = false) {
1066
- if (!instance._hasNativeView) {
1067
- return;
1068
- }
1069
- if (__ANDROID__) {
1070
- const array = Array.create('org.nativescript.mason.masonkit.TrackSizingFunction', value.length);
1071
- const length = value.length;
1072
- for (let i = 0; i < length; i++) {
1073
- const item = value[i];
1074
- if (item.is_repeating) {
1075
- const repeating = item.value;
1076
- const tracks = Array.create('org.nativescript.mason.masonkit.MinMax', repeating.length);
1077
- let gridTrackRepetition = null;
1078
- switch (item.repeating_type) {
1079
- case 0 /* TSCGridTrackRepetition.AutoFill */:
1080
- gridTrackRepetition = org.nativescript.mason.masonkit.GridTrackRepetition.AutoFill;
1081
- break;
1082
- case 1 /* TSCGridTrackRepetition.AutoFit */:
1083
- gridTrackRepetition = org.nativescript.mason.masonkit.GridTrackRepetition.AutoFit;
1084
- break;
1085
- case 2 /* TSCGridTrackRepetition.Count */:
1086
- gridTrackRepetition = new org.nativescript.mason.masonkit.GridTrackRepetition.Count(item.repeating_count);
1087
- break;
1088
- }
1089
- if (gridTrackRepetition === null) {
1090
- continue;
1091
- }
1092
- const repeatingLength = repeating.length;
1093
- for (let j = 0; j < repeatingLength; j++) {
1094
- const repeat = repeating[j];
1095
- tracks[j] = org.nativescript.mason.masonkit.MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value);
1096
- }
1097
- const repeat = new org.nativescript.mason.masonkit.TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
1098
- array[i] = repeat;
1099
- }
1100
- else {
1101
- const single = item.value;
1102
- const trackSizingFunction = new org.nativescript.mason.masonkit.TrackSizingFunction.Single(org.nativescript.mason.masonkit.MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
1103
- array[i] = trackSizingFunction;
1104
- }
1105
- }
1106
- const nodeOrView = getMasonInstance(instance);
1107
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridTemplateRows(nodeOrView, array);
1108
- }
1109
- if (__APPLE__) {
1110
- const length = value.length;
1111
- const array = NSMutableArray.arrayWithCapacity(length);
1112
- for (let i = 0; i < length; i++) {
1113
- const item = value[i];
1114
- if (item.is_repeating) {
1115
- const repeating = item.value;
1116
- const repeatingLength = repeating.length;
1117
- const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
1118
- let gridTrackRepetition = null;
1119
- switch (item.repeating_type) {
1120
- case 0 /* TSCGridTrackRepetition.AutoFill */:
1121
- gridTrackRepetition = 0 /* TSCGridTrackRepetition.AutoFill */;
1122
- break;
1123
- case 1 /* TSCGridTrackRepetition.AutoFit */:
1124
- gridTrackRepetition = 1 /* TSCGridTrackRepetition.AutoFit */;
1125
- break;
1126
- case 2 /* TSCGridTrackRepetition.Count */:
1127
- gridTrackRepetition = GridTrackRepetition.Count(item.repeating_count);
1128
- break;
1129
- }
1130
- if (gridTrackRepetition === null) {
1131
- continue;
1132
- }
1133
- for (let j = 0; j < repeatingLength; j++) {
1134
- const repeat = repeating[j];
1135
- tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
1136
- }
1137
- const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
1138
- array.addObject(repeat);
1139
- }
1140
- else {
1141
- const single = item.value;
1142
- const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
1143
- array.addObject(trackSizingFunction);
1144
- }
1145
- }
1146
- instance.ios.gridTemplateRows = array;
1147
- }
1148
- }
1149
- export function _setGridTemplateColumns(value, instance, initial = false) {
1150
- if (!instance._hasNativeView) {
1151
- return;
1152
- }
1153
- if (__ANDROID__) {
1154
- const array = Array.create('org.nativescript.mason.masonkit.TrackSizingFunction', value.length);
1155
- const length = value.length;
1156
- for (let i = 0; i < length; i++) {
1157
- const item = value[i];
1158
- if (item.is_repeating) {
1159
- const repeating = item.value;
1160
- const tracks = Array.create('org.nativescript.mason.masonkit.MinMax', repeating.length);
1161
- let gridTrackRepetition = null;
1162
- switch (item.repeating_type) {
1163
- case 0 /* TSCGridTrackRepetition.AutoFill */:
1164
- gridTrackRepetition = org.nativescript.mason.masonkit.GridTrackRepetition.AutoFill.INSTANCE;
1165
- break;
1166
- case 1 /* TSCGridTrackRepetition.AutoFit */:
1167
- gridTrackRepetition = org.nativescript.mason.masonkit.GridTrackRepetition.AutoFit.INSTANCE;
1168
- break;
1169
- case 2 /* TSCGridTrackRepetition.Count */:
1170
- gridTrackRepetition = new org.nativescript.mason.masonkit.GridTrackRepetition.Count(item.repeating_count);
1171
- break;
1172
- }
1173
- if (gridTrackRepetition === null) {
1174
- continue;
1175
- }
1176
- const repeatingLength = repeating.length;
1177
- for (let j = 0; j < repeatingLength; j++) {
1178
- const repeat = repeating[j];
1179
- tracks[j] = org.nativescript.mason.masonkit.MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value);
1180
- }
1181
- const repeat = new org.nativescript.mason.masonkit.TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
1182
- array[i] = repeat;
1183
- }
1184
- else {
1185
- const single = item.value;
1186
- const minMax = single ? org.nativescript.mason.masonkit.MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value) : org.nativescript.mason.masonkit.MinMax.Auto.INSTANCE;
1187
- const trackSizingFunction = new org.nativescript.mason.masonkit.TrackSizingFunction.Single(minMax);
1188
- array[i] = trackSizingFunction;
1189
- }
1190
- }
1191
- const nodeOrView = getMasonInstance(instance);
1192
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridTemplateColumns(nodeOrView, array);
1193
- }
1194
- if (__APPLE__) {
1195
- const length = value.length;
1196
- const array = NSMutableArray.new();
1197
- for (let i = 0; i < length; i++) {
1198
- const item = value[i];
1199
- if (item.is_repeating) {
1200
- const repeating = item.value;
1201
- const repeatingLength = repeating.length;
1202
- const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
1203
- let gridTrackRepetition = null;
1204
- switch (item.repeating_type) {
1205
- case 0 /* TSCGridTrackRepetition.AutoFill */:
1206
- gridTrackRepetition = 0 /* TSCGridTrackRepetition.AutoFill */;
1207
- break;
1208
- case 1 /* TSCGridTrackRepetition.AutoFit */:
1209
- gridTrackRepetition = 1 /* TSCGridTrackRepetition.AutoFit */;
1210
- break;
1211
- case 2 /* TSCGridTrackRepetition.Count */:
1212
- gridTrackRepetition = GridTrackRepetition.Count(item.repeating_count);
1213
- break;
1214
- }
1215
- if (gridTrackRepetition === null) {
1216
- continue;
1217
- }
1218
- for (let j = 0; j < repeatingLength; j++) {
1219
- const repeat = repeating[j];
1220
- tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
1221
- }
1222
- const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
1223
- array.addObject(repeat);
1224
- }
1225
- else {
1226
- const single = item.value;
1227
- const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
1228
- array.addObject(trackSizingFunction);
1229
- }
1230
- }
1231
- instance.ios.gridTemplateColumns = array;
1232
- }
1233
- }
1234
- export function _parseGridAutoRowsColumns(value) {
1235
- const array = [];
1236
- if (typeof value === 'string') {
1237
- const values = value.split(' ');
1238
- values.forEach((item) => {
1239
- const value = _parseMinMaxValue(item);
1240
- array.push({
1241
- is_repeating: false,
1242
- repeating_type: 0,
1243
- value,
1244
- });
1245
- });
1246
- }
1247
- return array;
1248
- }
1249
- export function _setGridAutoFlow(value, instance) {
1250
- if (!instance._hasNativeView) {
1251
- return;
1252
- }
1253
- instance.ios.gridAutoFlow = value;
1254
- }
1255
- export function _getGridAutoFlow(instance) {
1256
- if (!instance._hasNativeView) {
1257
- return;
1258
- }
1259
- return this._styleHelper.gridAutoFlow;
1260
- }
1261
- export function _setGridAutoRows(value, instance, initial = false) {
1262
- if (!instance._hasNativeView) {
1263
- return;
1264
- }
1265
- const values = _parseGridAutoRowsColumns(value);
1266
- if (__ANDROID__) {
1267
- const array = Array.create('org.nativescript.mason.masonkit.MinMax', values.length);
1268
- const length = value.length;
1269
- for (let i = 0; i < length; i++) {
1270
- const item = value[i];
1271
- const minMax = org.nativescript.mason.masonkit.MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
1272
- array[i] = minMax;
1273
- }
1274
- const nodeOrView = getMasonInstance(instance);
1275
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridAutoRows(nodeOrView, array);
1276
- }
1277
- if (__APPLE__) {
1278
- const length = value.length;
1279
- const array = NSMutableArray.arrayWithCapacity(length);
1280
- for (let i = 0; i < length; i++) {
1281
- const item = value[i];
1282
- const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
1283
- array.addObject(minMax);
1284
- }
1285
- instance.ios.gridAutoRows = array;
1286
- }
1287
- }
1288
- export function _setGridAutoColumns(value, instance, initial = false) {
1289
- if (!instance._hasNativeView) {
1290
- return;
1291
- }
1292
- const values = _parseGridAutoRowsColumns(value);
1293
- if (__ANDROID__) {
1294
- const array = Array.create('org.nativescript.mason.masonkit.MinMax', values.length);
1295
- const length = value.length;
1296
- for (let i = 0; i < length; i++) {
1297
- const item = value[i];
1298
- const minMax = org.nativescript.mason.masonkit.MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
1299
- array[i] = minMax;
1300
- }
1301
- const nodeOrView = getMasonInstance(instance);
1302
- org.nativescript.mason.masonkit.NodeHelper.INSTANCE.setGridAutoColumns(nodeOrView, array);
1303
- }
1304
- if (__APPLE__) {
1305
- const length = value.length;
1306
- const array = NSMutableArray.arrayWithCapacity(length);
1307
- for (let i = 0; i < length; i++) {
1308
- const item = value[i];
1309
- const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
1310
- array.addObject(minMax);
1311
- }
1312
- instance.ios.gridAutoColumns = array;
1313
- }
1314
- }
1315
- //# sourceMappingURL=helpers.js.map