@triniwiz/nativescript-masonkit 1.0.0-alpha.34 → 1.0.0-alpha.35

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.
Files changed (53) hide show
  1. package/common.d.ts +140 -0
  2. package/common.js +1728 -0
  3. package/common.js.map +1 -0
  4. package/img/index.android.d.ts +10 -0
  5. package/img/index.android.js +40 -0
  6. package/img/index.android.js.map +1 -0
  7. package/img/index.ios.d.ts +13 -0
  8. package/img/index.ios.js +102 -0
  9. package/img/index.ios.js.map +1 -0
  10. package/index.android.d.ts +5 -0
  11. package/index.android.js +6 -0
  12. package/index.android.js.map +1 -0
  13. package/index.ios.d.ts +5 -0
  14. package/index.ios.js +6 -0
  15. package/index.ios.js.map +1 -0
  16. package/package.json +1 -1
  17. package/platforms/android/masonkit-release.aar +0 -0
  18. package/scroll/index.android.d.ts +12 -0
  19. package/scroll/index.android.js +50 -0
  20. package/scroll/index.android.js.map +1 -0
  21. package/scroll/index.ios.d.ts +14 -0
  22. package/scroll/index.ios.js +120 -0
  23. package/scroll/index.ios.js.map +1 -0
  24. package/style.d.ts +222 -0
  25. package/style.js +2521 -0
  26. package/style.js.map +1 -0
  27. package/text/index.android.d.ts +30 -0
  28. package/text/index.android.js +124 -0
  29. package/text/index.android.js.map +1 -0
  30. package/text/index.ios.d.ts +38 -0
  31. package/text/index.ios.js +252 -0
  32. package/text/index.ios.js.map +1 -0
  33. package/tree/index.android.d.ts +27 -0
  34. package/tree/index.android.js +74 -0
  35. package/tree/index.android.js.map +1 -0
  36. package/tree/index.ios.d.ts +28 -0
  37. package/tree/index.ios.js +73 -0
  38. package/tree/index.ios.js.map +1 -0
  39. package/utils/index.android.d.ts +187 -0
  40. package/utils/index.android.js +515 -0
  41. package/utils/index.android.js.map +1 -0
  42. package/utils/index.ios.d.ts +198 -0
  43. package/utils/index.ios.js +710 -0
  44. package/utils/index.ios.js.map +1 -0
  45. package/view/index.android.d.ts +12 -0
  46. package/view/index.android.js +50 -0
  47. package/view/index.android.js.map +1 -0
  48. package/view/index.ios.d.ts +16 -0
  49. package/view/index.ios.js +123 -0
  50. package/view/index.ios.js.map +1 -0
  51. package/web.d.ts +55 -0
  52. package/web.js +189 -0
  53. package/web.js.map +1 -0
package/common.js ADDED
@@ -0,0 +1,1728 @@
1
+ var _a, _b, _c;
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
4
+ import { CssProperty, CustomLayoutView, Length as NSLength, ShorthandProperty, Style, View as NSView, getViewById, unsetValue, Property, widthProperty, heightProperty, CoreTypes, Trace, Length as CoreLength, PercentLength as CorePercentLength, marginLeftProperty, marginRightProperty, marginTopProperty, marginBottomProperty, minWidthProperty, minHeightProperty, fontSizeProperty, fontWeightProperty, fontStyleProperty, colorProperty, Color, lineHeightProperty, letterSpacingProperty, textAlignmentProperty } from '@nativescript/core';
5
+ import { flexDirectionProperty, flexGrowProperty, flexWrapProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
6
+ import { _forceStyleUpdate } from './utils';
7
+ export const native_ = Symbol('[[native]]');
8
+ export const style_ = Symbol('[[style]]');
9
+ export const isTextChild_ = Symbol('[[isTextChild]]');
10
+ export const isText_ = Symbol('[[isText]]');
11
+ export const isMasonView_ = Symbol('[[isMasonView]]');
12
+ export const text_ = Symbol('[[text]]');
13
+ function getViewStyle(view) {
14
+ const ret = (__ANDROID__ ? view.get() : view.deref());
15
+ return ret._styleHelper;
16
+ }
17
+ var FrameWork;
18
+ (function (FrameWork) {
19
+ FrameWork[FrameWork["Core"] = 0] = "Core";
20
+ FrameWork[FrameWork["Angular"] = 1] = "Angular";
21
+ FrameWork[FrameWork["Vue"] = 2] = "Vue";
22
+ FrameWork[FrameWork["React"] = 3] = "React";
23
+ FrameWork[FrameWork["Svelte"] = 4] = "Svelte";
24
+ FrameWork[FrameWork["Solid"] = 5] = "Solid";
25
+ })(FrameWork || (FrameWork = {}));
26
+ let frameWork = FrameWork.Core;
27
+ try {
28
+ global.VUE3_ELEMENT_REF = require('nativescript-vue').ELEMENT_REF;
29
+ frameWork = FrameWork.Vue;
30
+ }
31
+ catch (e) { }
32
+ export const scrollBarWidthProperty = new CssProperty({
33
+ name: 'scrollBarWidth',
34
+ cssName: 'scroll-bar-width',
35
+ defaultValue: 0,
36
+ valueConverter: parseFloat,
37
+ });
38
+ function overflowConverter(value) {
39
+ if (typeof value === 'number') {
40
+ switch (value) {
41
+ case 0:
42
+ return 'visible';
43
+ case 1:
44
+ return 'clip';
45
+ case 2:
46
+ return 'hidden';
47
+ case 3:
48
+ return 'scroll';
49
+ }
50
+ }
51
+ switch (value) {
52
+ case 'visible':
53
+ case 'hidden':
54
+ case 'clip':
55
+ case 'scroll':
56
+ return value;
57
+ default:
58
+ return undefined;
59
+ }
60
+ }
61
+ function masonLengthParse(value) {
62
+ try {
63
+ return CoreLength.parse(value);
64
+ }
65
+ catch (e) {
66
+ return undefined;
67
+ }
68
+ }
69
+ function masonLengthPercentParse(value) {
70
+ try {
71
+ return CorePercentLength.parse(value);
72
+ }
73
+ catch (e) {
74
+ return undefined;
75
+ }
76
+ }
77
+ const overFlow = /^\s*(visible|hidden|clip|scroll|auto)(?:\s+(visible|hidden|clip|scroll|auto))?\s*$/;
78
+ export const overflowProperty = new ShorthandProperty({
79
+ name: 'overflow',
80
+ cssName: 'overflow',
81
+ getter: function () {
82
+ if (this.overflowX === this.overflowY) {
83
+ return this.overflowX;
84
+ }
85
+ return `${this.overflowX} ${this.overflowY}`;
86
+ },
87
+ converter(value) {
88
+ const properties = [];
89
+ if (typeof value === 'string') {
90
+ const values = value.match(overFlow);
91
+ const length = values?.length ?? 0;
92
+ if (length === 0) {
93
+ return properties;
94
+ }
95
+ if (length === 1) {
96
+ const xy = values[0];
97
+ properties.push([overflowXProperty, xy]);
98
+ properties.push([overflowYProperty, xy]);
99
+ }
100
+ if (length > 1) {
101
+ const x = values[0];
102
+ const y = values[1];
103
+ properties.push([overflowXProperty, x]);
104
+ properties.push([overflowYProperty, y]);
105
+ }
106
+ }
107
+ return properties;
108
+ },
109
+ });
110
+ export const overflowXProperty = new CssProperty({
111
+ name: 'overflowX',
112
+ cssName: 'overflow-x',
113
+ defaultValue: 'visible',
114
+ valueConverter: overflowConverter,
115
+ valueChanged: (target, oldValue, newValue) => {
116
+ const view = getViewStyle(target.viewRef);
117
+ if (view) {
118
+ if (newValue) {
119
+ view.overflowX = newValue;
120
+ }
121
+ else {
122
+ // Revert to old value if newValue is invalid
123
+ view.view.style.overflowX = oldValue;
124
+ }
125
+ }
126
+ },
127
+ });
128
+ export const overflowYProperty = new CssProperty({
129
+ name: 'overflowY',
130
+ cssName: 'overflow-y',
131
+ defaultValue: 'visible',
132
+ valueConverter: overflowConverter,
133
+ valueChanged(target, oldValue, newValue) {
134
+ const view = getViewStyle(target.viewRef);
135
+ if (view) {
136
+ if (newValue) {
137
+ view.overflowY = newValue;
138
+ }
139
+ else {
140
+ // Revert to old value if newValue is invalid
141
+ view.view.style.overflowY = oldValue;
142
+ }
143
+ }
144
+ },
145
+ });
146
+ const paddingProperty = new ShorthandProperty({
147
+ name: 'padding',
148
+ cssName: 'padding',
149
+ getter: function () {
150
+ if (CoreLength.equals(this.paddingTop, this.paddingRight) && CoreLength.equals(this.paddingTop, this.paddingBottom) && CoreLength.equals(this.paddingTop, this.paddingLeft)) {
151
+ return this.paddingTop;
152
+ }
153
+ return `${CoreLength.convertToString(this.paddingTop)} ${CoreLength.convertToString(this.paddingRight)} ${CoreLength.convertToString(this.paddingBottom)} ${CoreLength.convertToString(this.paddingLeft)}`;
154
+ },
155
+ converter: convertToPaddings,
156
+ });
157
+ export const paddingLeftProperty = new CssProperty({
158
+ name: 'paddingLeft',
159
+ cssName: 'padding-left',
160
+ defaultValue: CoreTypes.zeroLength,
161
+ affectsLayout: global.isIOS,
162
+ equalityComparer: CoreLength.equals,
163
+ valueChanged: (target, oldValue, newValue) => {
164
+ const view = getViewStyle(target.viewRef);
165
+ if (view) {
166
+ view.paddingLeft = CoreLength.toDevicePixels(newValue, 0);
167
+ }
168
+ else {
169
+ Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
170
+ }
171
+ },
172
+ valueConverter: masonLengthParse,
173
+ });
174
+ export const paddingRightProperty = new CssProperty({
175
+ name: 'paddingRight',
176
+ cssName: 'padding-right',
177
+ defaultValue: CoreTypes.zeroLength,
178
+ affectsLayout: global.isIOS,
179
+ equalityComparer: CoreLength.equals,
180
+ valueChanged: (target, oldValue, newValue) => {
181
+ const view = getViewStyle(target.viewRef);
182
+ if (view) {
183
+ view.paddingRight = CoreLength.toDevicePixels(newValue, 0);
184
+ }
185
+ else {
186
+ Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
187
+ }
188
+ },
189
+ valueConverter: masonLengthParse,
190
+ });
191
+ export const paddingTopProperty = new CssProperty({
192
+ name: 'paddingTop',
193
+ cssName: 'padding-top',
194
+ defaultValue: CoreTypes.zeroLength,
195
+ affectsLayout: global.isIOS,
196
+ equalityComparer: CoreLength.equals,
197
+ valueChanged: (target, oldValue, newValue) => {
198
+ const view = getViewStyle(target.viewRef);
199
+ if (view) {
200
+ view.paddingTop = CoreLength.toDevicePixels(newValue, 0);
201
+ }
202
+ else {
203
+ Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
204
+ }
205
+ },
206
+ valueConverter: masonLengthParse,
207
+ });
208
+ export const paddingBottomProperty = new CssProperty({
209
+ name: 'paddingBottom',
210
+ cssName: 'padding-bottom',
211
+ defaultValue: CoreTypes.zeroLength,
212
+ affectsLayout: global.isIOS,
213
+ equalityComparer: CoreLength.equals,
214
+ valueChanged: (target, oldValue, newValue) => {
215
+ const view = getViewStyle(target.viewRef);
216
+ if (view) {
217
+ view.paddingBottom = CoreLength.toDevicePixels(newValue, 0);
218
+ }
219
+ else {
220
+ Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
221
+ }
222
+ },
223
+ valueConverter: masonLengthParse,
224
+ });
225
+ export const rowGapProperty = new CssProperty({
226
+ name: 'rowGap',
227
+ cssName: 'row-gap',
228
+ defaultValue: 0,
229
+ valueConverter(value) {
230
+ const parsed = CoreLength.parse(value);
231
+ if (typeof parsed === 'string') {
232
+ return 0;
233
+ }
234
+ return parsed;
235
+ },
236
+ valueChanged(target, oldValue, newValue) {
237
+ const view = getViewStyle(target.viewRef);
238
+ if (view) {
239
+ view.rowGap = newValue;
240
+ }
241
+ },
242
+ });
243
+ export const columnGapProperty = new CssProperty({
244
+ name: 'columnGap',
245
+ cssName: 'column-gap',
246
+ defaultValue: 0,
247
+ valueConverter(value) {
248
+ const parsed = CoreLength.parse(value);
249
+ if (typeof parsed === 'string') {
250
+ return 0;
251
+ }
252
+ return parsed;
253
+ },
254
+ valueChanged(target, oldValue, newValue) {
255
+ const view = getViewStyle(target.viewRef);
256
+ if (view) {
257
+ view.columnGap = newValue;
258
+ }
259
+ },
260
+ });
261
+ export const gridGapProperty = new ShorthandProperty({
262
+ name: 'gridGap',
263
+ cssName: 'grid-gap',
264
+ getter: function () {
265
+ if (this.rowGap === this.columnGap) {
266
+ return this.rowGap;
267
+ }
268
+ return `${this.rowGap} ${this.columnGap}`;
269
+ },
270
+ converter(gap) {
271
+ const properties = [];
272
+ let value = gap;
273
+ if (typeof value === 'number') {
274
+ value = `${value}`;
275
+ }
276
+ if (typeof value === 'string') {
277
+ const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
278
+ const length = values.length;
279
+ if (length === 0) {
280
+ return properties;
281
+ }
282
+ if (length === 1) {
283
+ const row = values[0];
284
+ properties.push([rowGapProperty, row]);
285
+ properties.push([columnGapProperty, row]);
286
+ }
287
+ if (length > 1) {
288
+ const row = values[0];
289
+ const column = values[1];
290
+ properties.push([rowGapProperty, row]);
291
+ properties.push([columnGapProperty, column]);
292
+ }
293
+ }
294
+ return properties;
295
+ },
296
+ });
297
+ export const gapProperty = new ShorthandProperty({
298
+ name: 'gap',
299
+ cssName: 'gap',
300
+ getter: function () {
301
+ if (this.rowGap === this.columnGap) {
302
+ return this.rowGap;
303
+ }
304
+ return `${this.rowGap} ${this.columnGap}`;
305
+ },
306
+ converter(gap) {
307
+ const properties = [];
308
+ let value = gap;
309
+ if (typeof value === 'number') {
310
+ value = `${value}`;
311
+ }
312
+ if (typeof value === 'string') {
313
+ const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
314
+ const length = values.length;
315
+ if (length === 0) {
316
+ return properties;
317
+ }
318
+ if (length === 1) {
319
+ const row = values[0];
320
+ properties.push([rowGapProperty, row]);
321
+ properties.push([columnGapProperty, row]);
322
+ }
323
+ if (length > 1) {
324
+ const row = values[0];
325
+ const column = values[1];
326
+ properties.push([rowGapProperty, row]);
327
+ properties.push([columnGapProperty, column]);
328
+ }
329
+ }
330
+ return properties;
331
+ },
332
+ });
333
+ // export const flexGrowProperty = new CssProperty<Style, number>({
334
+ // name: 'flexGrow',
335
+ // cssName: 'flex-grow',
336
+ // defaultValue: 0,
337
+ // valueConverter: parseFloat,
338
+ // });
339
+ export const flexShrinkProperty = new CssProperty({
340
+ name: 'flexShrink',
341
+ cssName: 'flex-shrink',
342
+ defaultValue: 1,
343
+ valueConverter: parseFloat,
344
+ });
345
+ export const displayProperty = new CssProperty({
346
+ name: 'display',
347
+ cssName: 'display',
348
+ defaultValue: 'block',
349
+ valueChanged: (target, oldValue, newValue) => {
350
+ const view = getViewStyle(target.viewRef);
351
+ if (view && newValue) {
352
+ view.display = newValue;
353
+ }
354
+ else {
355
+ // Revert to old value if newValue is invalid
356
+ view.view.style.display = oldValue;
357
+ }
358
+ },
359
+ valueConverter: function (value) {
360
+ if (typeof value === 'number') {
361
+ switch (value) {
362
+ case 0:
363
+ return 'none';
364
+ case 1:
365
+ return 'flex';
366
+ case 2:
367
+ return 'grid';
368
+ case 3:
369
+ return 'block';
370
+ case 4:
371
+ return 'inline';
372
+ case 5:
373
+ return 'inline-block';
374
+ case 6:
375
+ return 'inline-flex';
376
+ case 7:
377
+ return 'inline-grid';
378
+ }
379
+ }
380
+ switch (value) {
381
+ case 'none':
382
+ case 'flex':
383
+ case 'grid':
384
+ case 'block':
385
+ case 'inline':
386
+ case 'inline-block':
387
+ case 'inline-flex':
388
+ case 'inline-grid':
389
+ return value;
390
+ default:
391
+ return undefined;
392
+ }
393
+ },
394
+ });
395
+ export const maxWidthProperty = new CssProperty({
396
+ name: 'maxWidth',
397
+ cssName: 'max-width',
398
+ defaultValue: 'auto',
399
+ // @ts-ignore
400
+ equalityComparer: NSLength.equals,
401
+ valueConverter: masonLengthParse,
402
+ valueChanged: (target, oldValue, newValue) => {
403
+ const view = getViewStyle(target.viewRef);
404
+ if (view) {
405
+ view.maxWidth = newValue;
406
+ }
407
+ else {
408
+ Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
409
+ }
410
+ },
411
+ });
412
+ export const maxHeightProperty = new CssProperty({
413
+ name: 'maxHeight',
414
+ cssName: 'max-height',
415
+ defaultValue: 'auto',
416
+ // @ts-ignore
417
+ equalityComparer: NSLength.equals,
418
+ valueConverter: masonLengthParse,
419
+ valueChanged(target, oldValue, newValue) {
420
+ const view = getViewStyle(target.viewRef);
421
+ if (view) {
422
+ view.maxHeight = newValue;
423
+ }
424
+ },
425
+ });
426
+ export const positionProperty = new CssProperty({
427
+ name: 'position',
428
+ cssName: 'position',
429
+ defaultValue: 'relative',
430
+ valueChanged(target, oldValue, newValue) {
431
+ const view = getViewStyle(target.viewRef);
432
+ if (view) {
433
+ view.position = newValue;
434
+ }
435
+ },
436
+ });
437
+ // export const flexDirectionProperty = new CssProperty<Style, FlexDirection>({
438
+ // name: 'flexDirection',
439
+ // cssName: 'flex-direction',
440
+ // });
441
+ // export const flexWrapProperty = new CssProperty<Style, FlexWrap>({
442
+ // name: 'flexWrap',
443
+ // cssName: 'flex-wrap',
444
+ // defaultValue: 'no-wrap',
445
+ // });
446
+ const insetProperty = new ShorthandProperty({
447
+ name: 'inset',
448
+ cssName: 'inset',
449
+ getter: function () {
450
+ if (this.top === this.right && this.top === this.bottom && this.top === this.left) {
451
+ if (typeof this.top === 'string') {
452
+ if (this.top === 'auto') {
453
+ return this.top;
454
+ }
455
+ const value = CorePercentLength.parse(this.top);
456
+ if (Number.isNaN(value)) {
457
+ return this.top;
458
+ }
459
+ else {
460
+ return CorePercentLength.convertToString(value);
461
+ }
462
+ }
463
+ }
464
+ if (CorePercentLength.equals(this.top, this.right) && CorePercentLength.equals(this.top, this.bottom) && CorePercentLength.equals(this.top, this.left)) {
465
+ return this.top;
466
+ }
467
+ return `${CorePercentLength.convertToString(this.paddingTop)} ${CorePercentLength.convertToString(this.paddingRight)} ${CorePercentLength.convertToString(this.paddingBottom)} ${CorePercentLength.convertToString(this.paddingLeft)}`;
468
+ },
469
+ converter: convertToInsets,
470
+ });
471
+ function convertToInsets(value) {
472
+ if (typeof value === 'string' && value !== 'auto') {
473
+ const thickness = parseShorthandPositioning(value);
474
+ return [
475
+ [topProperty, masonLengthPercentParse(thickness.top)],
476
+ [rightProperty, masonLengthPercentParse(thickness.right)],
477
+ [bottomProperty, masonLengthPercentParse(thickness.bottom)],
478
+ [leftProperty, masonLengthPercentParse(thickness.left)],
479
+ ];
480
+ }
481
+ else {
482
+ return [
483
+ [topProperty, value],
484
+ [rightProperty, value],
485
+ [bottomProperty, value],
486
+ [leftProperty, value],
487
+ ];
488
+ }
489
+ }
490
+ export const leftProperty = new CssProperty({
491
+ name: 'left',
492
+ cssName: 'left',
493
+ defaultValue: 'auto',
494
+ // @ts-ignore
495
+ equalityComparer: NSLength.equals,
496
+ valueConverter: masonLengthParse,
497
+ valueChanged(target, oldValue, newValue) {
498
+ const view = getViewStyle(target.viewRef);
499
+ if (view) {
500
+ view.left = newValue;
501
+ }
502
+ },
503
+ });
504
+ export const rightProperty = new CssProperty({
505
+ name: 'right',
506
+ cssName: 'right',
507
+ defaultValue: 'auto',
508
+ // @ts-ignore
509
+ equalityComparer: NSLength.equals,
510
+ valueConverter: masonLengthParse,
511
+ valueChanged(target, oldValue, newValue) {
512
+ const view = getViewStyle(target.viewRef);
513
+ if (view) {
514
+ view.right = newValue;
515
+ }
516
+ },
517
+ });
518
+ export const topProperty = new CssProperty({
519
+ name: 'top',
520
+ cssName: 'top',
521
+ defaultValue: 'auto',
522
+ // @ts-ignore
523
+ equalityComparer: NSLength.equals,
524
+ valueConverter: masonLengthParse,
525
+ valueChanged(target, oldValue, newValue) {
526
+ const view = getViewStyle(target.viewRef);
527
+ if (view) {
528
+ view.top = newValue;
529
+ }
530
+ },
531
+ });
532
+ export const bottomProperty = new CssProperty({
533
+ name: 'bottom',
534
+ cssName: 'bottom',
535
+ defaultValue: 'auto',
536
+ // @ts-ignore
537
+ equalityComparer: NSLength.equals,
538
+ valueConverter: masonLengthParse,
539
+ valueChanged(target, oldValue, newValue) {
540
+ const view = getViewStyle(target.viewRef);
541
+ if (view) {
542
+ view.bottom = newValue;
543
+ }
544
+ },
545
+ });
546
+ export const flexBasisProperty = new CssProperty({
547
+ name: 'flexBasis',
548
+ cssName: 'flex-basis',
549
+ defaultValue: 'auto',
550
+ equalityComparer: NSLength.equals,
551
+ valueConverter: masonLengthParse,
552
+ valueChanged(target, oldValue, newValue) {
553
+ const view = getViewStyle(target.viewRef);
554
+ if (view) {
555
+ view.flexBasis = newValue;
556
+ }
557
+ },
558
+ });
559
+ export const gridRowGapProperty = new ShorthandProperty({
560
+ name: 'gridRowGap',
561
+ cssName: 'grid-row-gap',
562
+ getter: function () {
563
+ return this.rowGap;
564
+ },
565
+ converter(value) {
566
+ return [[rowGapProperty, value]];
567
+ },
568
+ });
569
+ export const gridColumnGapProperty = new ShorthandProperty({
570
+ name: 'gridColumnGap',
571
+ cssName: 'grid-column-gap',
572
+ getter: function () {
573
+ return this.columnGap;
574
+ },
575
+ converter(value) {
576
+ return [[columnGapProperty, value]];
577
+ },
578
+ });
579
+ export const aspectRatioProperty = new CssProperty({
580
+ name: 'aspectRatio',
581
+ cssName: 'aspect-ratio',
582
+ defaultValue: Number.NaN,
583
+ valueChanged(target, oldValue, newValue) {
584
+ const view = getViewStyle(target.viewRef);
585
+ if (view) {
586
+ view.aspectRatio = newValue;
587
+ }
588
+ },
589
+ });
590
+ export const alignItemsProperty = new CssProperty({
591
+ name: 'alignItems',
592
+ cssName: 'align-items',
593
+ defaultValue: 'normal',
594
+ valueChanged(target, oldValue, newValue) {
595
+ const view = getViewStyle(target.viewRef);
596
+ if (view) {
597
+ view.alignItems = newValue;
598
+ }
599
+ },
600
+ });
601
+ export const alignSelfProperty = new CssProperty({
602
+ name: 'alignSelf',
603
+ cssName: 'align-self',
604
+ defaultValue: 'normal',
605
+ valueChanged(target, oldValue, newValue) {
606
+ const view = getViewStyle(target.viewRef);
607
+ if (view) {
608
+ view.alignSelf = newValue;
609
+ }
610
+ },
611
+ });
612
+ export const alignContentProperty = new CssProperty({
613
+ name: 'alignContent',
614
+ cssName: 'align-content',
615
+ defaultValue: 'normal',
616
+ valueChanged(target, oldValue, newValue) {
617
+ const view = getViewStyle(target.viewRef);
618
+ if (view) {
619
+ view.alignContent = newValue;
620
+ }
621
+ },
622
+ });
623
+ export const justifyItemsProperty = new CssProperty({
624
+ name: 'justifyItems',
625
+ cssName: 'justify-items',
626
+ defaultValue: 'normal',
627
+ valueChanged(target, oldValue, newValue) {
628
+ const view = getViewStyle(target.viewRef);
629
+ if (view) {
630
+ view.justifyItems = newValue;
631
+ }
632
+ },
633
+ });
634
+ export const justifySelfProperty = new CssProperty({
635
+ name: 'justifySelf',
636
+ cssName: 'justify-self',
637
+ defaultValue: 'normal',
638
+ valueChanged(target, oldValue, newValue) {
639
+ const view = getViewStyle(target.viewRef);
640
+ if (view) {
641
+ view.justifySelf = newValue;
642
+ }
643
+ },
644
+ });
645
+ export const justifyContentProperty = new CssProperty({
646
+ name: 'justifyContent',
647
+ cssName: 'justify-content',
648
+ defaultValue: 'normal',
649
+ valueChanged(target, oldValue, newValue) {
650
+ const view = getViewStyle(target.viewRef);
651
+ if (view) {
652
+ view.justifyContent = newValue;
653
+ }
654
+ },
655
+ });
656
+ export const gridAutoRowsProperty = new CssProperty({
657
+ name: 'gridAutoRows',
658
+ cssName: 'grid-auto-rows',
659
+ defaultValue: '',
660
+ valueChanged(target, oldValue, newValue) {
661
+ const view = getViewStyle(target.viewRef);
662
+ if (view) {
663
+ view.gridAutoRows = newValue;
664
+ }
665
+ },
666
+ });
667
+ export const gridAutoColumnsProperty = new CssProperty({
668
+ name: 'gridAutoColumns',
669
+ cssName: 'grid-auto-columns',
670
+ defaultValue: '',
671
+ valueChanged(target, oldValue, newValue) {
672
+ const view = getViewStyle(target.viewRef);
673
+ if (view) {
674
+ view.gridAutoColumns = newValue;
675
+ }
676
+ },
677
+ });
678
+ export const gridAutoFlowProperty = new CssProperty({
679
+ name: 'gridAutoFlow',
680
+ cssName: 'grid-auto-flow',
681
+ defaultValue: 'row',
682
+ valueChanged(target, oldValue, newValue) {
683
+ const view = getViewStyle(target.viewRef);
684
+ if (view) {
685
+ view.gridAutoFlow = newValue;
686
+ }
687
+ },
688
+ });
689
+ export const gridAreaProperty = new CssProperty({
690
+ name: 'gridArea',
691
+ cssName: 'grid-area',
692
+ defaultValue: '',
693
+ valueChanged(target, oldValue, newValue) {
694
+ const view = getViewStyle(target.viewRef);
695
+ if (view) {
696
+ view.gridArea = newValue;
697
+ }
698
+ },
699
+ });
700
+ export const gridColumnStartProperty = new CssProperty({
701
+ name: 'gridColumnStart',
702
+ cssName: 'grid-column-start',
703
+ defaultValue: 'auto',
704
+ valueChanged(target, oldValue, newValue) {
705
+ const view = getViewStyle(target.viewRef);
706
+ if (view) {
707
+ view.gridColumnStart = newValue;
708
+ }
709
+ },
710
+ });
711
+ export const gridColumnEndProperty = new CssProperty({
712
+ name: 'gridColumnEnd',
713
+ cssName: 'grid-column-end',
714
+ defaultValue: 'auto',
715
+ valueChanged(target, oldValue, newValue) {
716
+ const view = getViewStyle(target.viewRef);
717
+ if (view) {
718
+ view.gridColumnEnd = newValue;
719
+ }
720
+ },
721
+ });
722
+ export const gridColumnProperty = new CssProperty({
723
+ name: 'gridColumn',
724
+ cssName: 'grid-column',
725
+ defaultValue: '',
726
+ valueChanged(target, oldValue, newValue) {
727
+ const view = getViewStyle(target.viewRef);
728
+ if (view) {
729
+ view.gridColumn = newValue;
730
+ }
731
+ },
732
+ });
733
+ export const gridRowStartProperty = new CssProperty({
734
+ name: 'gridRowStart',
735
+ cssName: 'grid-row-start',
736
+ defaultValue: 'auto',
737
+ valueChanged(target, oldValue, newValue) {
738
+ const view = getViewStyle(target.viewRef);
739
+ if (view) {
740
+ view.gridRowStart = newValue;
741
+ }
742
+ },
743
+ });
744
+ export const gridRowEndProperty = new CssProperty({
745
+ name: 'gridRowEnd',
746
+ cssName: 'grid-row-end',
747
+ defaultValue: 'auto',
748
+ valueChanged(target, oldValue, newValue) {
749
+ const view = getViewStyle(target.viewRef);
750
+ if (view) {
751
+ view.gridRowEnd = newValue;
752
+ }
753
+ },
754
+ });
755
+ export const gridRowProperty = new CssProperty({
756
+ name: 'gridRow',
757
+ cssName: 'grid-row',
758
+ defaultValue: '',
759
+ valueChanged(target, oldValue, newValue) {
760
+ const view = getViewStyle(target.viewRef);
761
+ if (view) {
762
+ view.gridRow = newValue;
763
+ }
764
+ },
765
+ });
766
+ export const gridTemplateAreasProperty = new CssProperty({
767
+ name: 'gridTemplateAreas',
768
+ cssName: 'grid-template-areas',
769
+ defaultValue: null,
770
+ valueChanged(target, oldValue, newValue) {
771
+ const view = getViewStyle(target.viewRef);
772
+ if (view) {
773
+ view.gridTemplateAreas = newValue;
774
+ }
775
+ },
776
+ });
777
+ export const gridTemplateRowsProperty = new CssProperty({
778
+ name: 'gridTemplateRows',
779
+ cssName: 'grid-template-rows',
780
+ defaultValue: null,
781
+ valueChanged(target, oldValue, newValue) {
782
+ const view = getViewStyle(target.viewRef);
783
+ if (view) {
784
+ view.gridTemplateRows = newValue;
785
+ }
786
+ },
787
+ });
788
+ export const gridTemplateColumnsProperty = new CssProperty({
789
+ name: 'gridTemplateColumns',
790
+ cssName: 'grid-template-columns',
791
+ defaultValue: null,
792
+ valueChanged(target, oldValue, newValue) {
793
+ const view = getViewStyle(target.viewRef);
794
+ if (view) {
795
+ view.gridTemplateColumns = newValue;
796
+ }
797
+ },
798
+ });
799
+ // flex-flow: <flex-direction> || <flex-wrap>
800
+ const flexFlowProperty = new ShorthandProperty({
801
+ name: 'flexFlow',
802
+ cssName: 'flex-flow',
803
+ getter: function () {
804
+ return `${this.flexDirection} ${this.flexWrap}`;
805
+ },
806
+ converter: function (value) {
807
+ const properties = [];
808
+ if (value === unsetValue) {
809
+ properties.push([flexDirectionProperty, value]);
810
+ properties.push([flexWrapProperty, value]);
811
+ }
812
+ else {
813
+ const trimmed = value && value.trim();
814
+ if (trimmed) {
815
+ const values = trimmed.split(/\s+/);
816
+ if (values.length >= 1) {
817
+ properties.push([flexDirectionProperty, values[0]]);
818
+ }
819
+ if (value.length >= 2) {
820
+ properties.push([flexWrapProperty, values[1]]);
821
+ }
822
+ }
823
+ }
824
+ return properties;
825
+ },
826
+ });
827
+ // flex: inital | auto | none | <flex-grow> <flex-shrink> || <flex-basis>
828
+ const flexProperty = new ShorthandProperty({
829
+ name: 'flex',
830
+ cssName: 'flex',
831
+ getter: function () {
832
+ return `${this.flexGrow} ${this.flexShrink} ${this.flexBasis}`;
833
+ },
834
+ converter: function (value) {
835
+ const properties = [];
836
+ if (value === unsetValue) {
837
+ properties.push([flexGrowProperty, value]);
838
+ properties.push([flexShrinkProperty, value]);
839
+ }
840
+ else if (typeof value === 'number') {
841
+ properties.push([flexGrowProperty, value]);
842
+ properties.push([flexShrinkProperty, 1]);
843
+ properties.push([flexBasisProperty, 'auto']);
844
+ }
845
+ else {
846
+ const trimmed = value && value.trim();
847
+ if (trimmed) {
848
+ const values = trimmed.split(/\s+/);
849
+ if (values.length === 1) {
850
+ switch (values[0]) {
851
+ case 'inital':
852
+ properties.push([flexGrowProperty, 0]);
853
+ properties.push([flexShrinkProperty, 1]);
854
+ properties.push([flexBasisProperty, 'auto']);
855
+ break;
856
+ case 'auto':
857
+ properties.push([flexGrowProperty, 1]);
858
+ properties.push([flexShrinkProperty, 1]);
859
+ properties.push([flexBasisProperty, 'auto']);
860
+ break;
861
+ case 'none':
862
+ properties.push([flexGrowProperty, 0]);
863
+ properties.push([flexShrinkProperty, 0]);
864
+ properties.push([flexBasisProperty, 'auto']);
865
+ break;
866
+ default:
867
+ properties.push([flexGrowProperty, values[0]]);
868
+ properties.push([flexShrinkProperty, 1]);
869
+ properties.push([flexBasisProperty, 'auto']);
870
+ }
871
+ }
872
+ if (values.length >= 2) {
873
+ properties.push([flexGrowProperty, values[0]]);
874
+ properties.push([flexShrinkProperty, values[1]]);
875
+ }
876
+ if (value.length >= 3) {
877
+ properties.push({ property: flexBasisProperty, value: values[2] });
878
+ }
879
+ }
880
+ }
881
+ return properties;
882
+ },
883
+ });
884
+ // @ts-ignore
885
+ export const textWrapProperty = new CssProperty({
886
+ name: 'textWrap',
887
+ affectsLayout: true,
888
+ defaultValue: 'nowrap',
889
+ valueChanged(target, oldValue, newValue) {
890
+ const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
891
+ if (view) {
892
+ view.textWrap = newValue;
893
+ }
894
+ },
895
+ });
896
+ // @ts-ignore
897
+ export const textOverFlowProperty = new CssProperty({
898
+ name: 'textOverflow',
899
+ defaultValue: 'text-overflow',
900
+ valueChanged(target, oldValue, newValue) {
901
+ const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
902
+ if (view) {
903
+ view.textOverflow = newValue;
904
+ }
905
+ },
906
+ });
907
+ export const textContentProperty = new Property({
908
+ name: 'textContent',
909
+ affectsLayout: true,
910
+ defaultValue: '',
911
+ });
912
+ export const boxSizingProperty = new CssProperty({
913
+ name: 'boxSizing',
914
+ cssName: 'box-sizing',
915
+ defaultValue: 'border-box',
916
+ valueChanged(target, oldValue, newValue) {
917
+ const view = getViewStyle(target.viewRef);
918
+ if (view) {
919
+ if (newValue) {
920
+ view.boxSizing = newValue;
921
+ }
922
+ else {
923
+ // Revert to old value if newValue is invalid
924
+ view.view.style.boxSizing = oldValue;
925
+ }
926
+ }
927
+ },
928
+ valueConverter(value) {
929
+ switch (value) {
930
+ case 'content-box':
931
+ case 'border-box':
932
+ return value;
933
+ default:
934
+ return undefined;
935
+ }
936
+ },
937
+ });
938
+ export class ViewBase extends CustomLayoutView {
939
+ constructor() {
940
+ super();
941
+ this._children = [];
942
+ this[_a] = false;
943
+ this[_b] = false;
944
+ this[_c] = false;
945
+ }
946
+ forceStyleUpdate() {
947
+ _forceStyleUpdate(this);
948
+ }
949
+ get _viewChildren() {
950
+ return this._children.filter((child) => child instanceof NSView);
951
+ }
952
+ eachLayoutChild(callback) {
953
+ let lastChild = null;
954
+ this.eachChildView((cv) => {
955
+ cv._eachLayoutView((lv) => {
956
+ if (lastChild && !lastChild.isCollapsed) {
957
+ callback(lastChild, false);
958
+ }
959
+ lastChild = lv;
960
+ });
961
+ return true;
962
+ });
963
+ if (lastChild && !lastChild.isCollapsed) {
964
+ callback(lastChild, true);
965
+ }
966
+ }
967
+ eachChild(callback) {
968
+ for (const child of this._viewChildren) {
969
+ callback(child);
970
+ }
971
+ }
972
+ eachChildView(callback) {
973
+ for (const view of this._viewChildren) {
974
+ callback(view);
975
+ }
976
+ }
977
+ _addChildFromBuilder(name, value) {
978
+ this.addChild(value);
979
+ }
980
+ getChildrenCount() {
981
+ return this._viewChildren.length;
982
+ }
983
+ get _childrenCount() {
984
+ return this._viewChildren.length;
985
+ }
986
+ getChildAt(index) {
987
+ return this._viewChildren[index];
988
+ }
989
+ getChildIndex(child) {
990
+ return this._viewChildren.indexOf(child);
991
+ }
992
+ getChildById(id) {
993
+ return getViewById(this, id);
994
+ }
995
+ addChild(child) {
996
+ if (child instanceof NSView) {
997
+ this._children.push(child);
998
+ if (this[isText_]) {
999
+ child[isTextChild_] = true;
1000
+ }
1001
+ this._addView(child);
1002
+ }
1003
+ else {
1004
+ if (text_ in child) {
1005
+ //@ts-ignore
1006
+ if (this._view) {
1007
+ if (__ANDROID__) {
1008
+ //@ts-ignore
1009
+ this._view.addChildAt(child[text_] || '', this._children.length);
1010
+ }
1011
+ if (__APPLE__) {
1012
+ //@ts-ignore
1013
+ this._view.mason_addChildAtText(child[text_] || '', this._children.length);
1014
+ }
1015
+ }
1016
+ this._children.push(child);
1017
+ }
1018
+ }
1019
+ }
1020
+ insertChild(child, atIndex) {
1021
+ if (child instanceof NSView) {
1022
+ this._children.splice(atIndex, 0, child);
1023
+ if (this[isText_]) {
1024
+ child[isTextChild_] = true;
1025
+ }
1026
+ this._addView(child, atIndex);
1027
+ }
1028
+ }
1029
+ replaceChild(child, atIndex) {
1030
+ if (child instanceof NSView) {
1031
+ this._children[atIndex] = child;
1032
+ if (this[isText_]) {
1033
+ child[isTextChild_] = true;
1034
+ }
1035
+ this._addView(child, atIndex);
1036
+ }
1037
+ else {
1038
+ if (text_ in child) {
1039
+ //@ts-ignore
1040
+ if (this._view) {
1041
+ if (__ANDROID__) {
1042
+ //@ts-ignore
1043
+ this._view.replaceChildAt(child[text_] || '', atIndex);
1044
+ }
1045
+ if (__APPLE__) {
1046
+ //@ts-ignore
1047
+ this._view.mason_replaceChildAtText(child[text_] || '', atIndex);
1048
+ }
1049
+ }
1050
+ if (this._children.length >= atIndex) {
1051
+ this._children[atIndex] = { text: child[text_] || '' };
1052
+ }
1053
+ else {
1054
+ this._children.push({ text: child[text_] || '' });
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+ removeChild(child) {
1060
+ const index = this._children.indexOf(child);
1061
+ if (index > -1) {
1062
+ this._children.splice(index, 1);
1063
+ this._removeView(child);
1064
+ }
1065
+ }
1066
+ removeChildren() {
1067
+ if (this._viewChildren.length === 0) {
1068
+ return;
1069
+ }
1070
+ for (const child of this._viewChildren) {
1071
+ // @ts-ignore
1072
+ child._isMasonChild = false;
1073
+ if (child instanceof NSView) {
1074
+ this._removeView(child);
1075
+ }
1076
+ }
1077
+ this._children.splice(0);
1078
+ }
1079
+ set text(value) {
1080
+ if (frameWork === FrameWork.Vue && global.VUE3_ELEMENT_REF) {
1081
+ const view_ref = this[global.VUE3_ELEMENT_REF];
1082
+ if (Array.isArray(view_ref.childNodes)) {
1083
+ if (view_ref.childNodes.length === 0) {
1084
+ this.addChild({ [text_]: value });
1085
+ return;
1086
+ }
1087
+ if (view_ref.childNodes.length === 1) {
1088
+ const node = view_ref.childNodes[0];
1089
+ if (node && node.nodeType === 'text') {
1090
+ this.addChild({ [text_]: node.text });
1091
+ }
1092
+ return;
1093
+ }
1094
+ view_ref.childNodes.forEach((node, index) => {
1095
+ if (node.nodeType === 'text') {
1096
+ // nativeView.replaceChildAt(node.text, index);
1097
+ this.replaceChild({ [text_]: node.text }, index);
1098
+ }
1099
+ });
1100
+ }
1101
+ return;
1102
+ }
1103
+ if ('firstChild' in this) {
1104
+ function getTextNodes(root) {
1105
+ const result = [];
1106
+ let node = root.firstChild;
1107
+ while (node) {
1108
+ result.push(node);
1109
+ node = node.nextSibling;
1110
+ }
1111
+ return result;
1112
+ }
1113
+ const nodes = getTextNodes(this);
1114
+ for (const [index, node] of nodes.entries()) {
1115
+ if (node.nodeType === 'text' || node.nodeName === 'TextNode' || node.constructor.name === 'TextNode') {
1116
+ const existing = this._children[index];
1117
+ if (existing && Object.is(existing['node'], node)) {
1118
+ // todo direct set text
1119
+ this.replaceChild({ [text_]: node.text, node }, index);
1120
+ continue;
1121
+ }
1122
+ this.replaceChild({ [text_]: node.text, node }, index);
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+ [(_a = isMasonView_, _b = isTextChild_, _c = isText_, lineHeightProperty.setNative)](value) {
1128
+ // @ts-ignore
1129
+ const style = this._styleHelper;
1130
+ if (style) {
1131
+ // @ts-ignore
1132
+ style.lineHeight = value;
1133
+ }
1134
+ }
1135
+ [letterSpacingProperty.setNative](value) {
1136
+ // @ts-ignore
1137
+ const style = this._styleHelper;
1138
+ if (style) {
1139
+ // @ts-ignore
1140
+ style.letterSpacing = value;
1141
+ }
1142
+ }
1143
+ [textAlignmentProperty.setNative](value) {
1144
+ // @ts-ignore
1145
+ const style = this._styleHelper;
1146
+ if (style) {
1147
+ // @ts-ignore
1148
+ style.textAlignment = value;
1149
+ }
1150
+ }
1151
+ get boxSizing() {
1152
+ return this.style.boxSizing;
1153
+ }
1154
+ set boxSizing(value) {
1155
+ this.style.boxSizing = value;
1156
+ }
1157
+ get display() {
1158
+ return this.style.display;
1159
+ }
1160
+ set display(value) {
1161
+ this.style.display = value;
1162
+ }
1163
+ get overflowX() {
1164
+ return this.style.overflowX;
1165
+ }
1166
+ set overflowX(value) {
1167
+ this.style.overflowX = value;
1168
+ }
1169
+ get overflowY() {
1170
+ return this.style.overflowY;
1171
+ }
1172
+ set overflowY(value) {
1173
+ this.style.overflowY = value;
1174
+ }
1175
+ get scrollBarWidth() {
1176
+ return this.style.scrollBarWidth;
1177
+ }
1178
+ set scrollBarWidth(value) {
1179
+ this.style.scrollBarWidth = value;
1180
+ }
1181
+ get position() {
1182
+ return this.style.position;
1183
+ }
1184
+ set position(value) {
1185
+ // @ts-ignore
1186
+ const style = this._styleHelper;
1187
+ if (style) {
1188
+ // @ts-ignore
1189
+ style.position = value;
1190
+ }
1191
+ }
1192
+ [colorProperty.setNative](value) {
1193
+ if (value instanceof Color) {
1194
+ // @ts-ignore
1195
+ const style = this._styleHelper;
1196
+ if (style) {
1197
+ // @ts-ignore
1198
+ style.color = value.argb;
1199
+ }
1200
+ }
1201
+ }
1202
+ [flexWrapProperty.setNative](value) {
1203
+ // @ts-ignore
1204
+ const style = this._styleHelper;
1205
+ if (style) {
1206
+ style.flexWrap = value;
1207
+ }
1208
+ }
1209
+ [flexDirectionProperty.setNative](value) {
1210
+ // @ts-ignore
1211
+ const style = this._styleHelper;
1212
+ if (style) {
1213
+ style.flexDirection = value;
1214
+ }
1215
+ }
1216
+ [flexGrowProperty.setNative](value) {
1217
+ // @ts-ignore
1218
+ const style = this._styleHelper;
1219
+ if (style) {
1220
+ style.flexGrow = value;
1221
+ }
1222
+ }
1223
+ [flexShrinkProperty.setNative](value) {
1224
+ // @ts-ignore
1225
+ const style = this._styleHelper;
1226
+ if (style) {
1227
+ style.flexShrink = value;
1228
+ }
1229
+ }
1230
+ [flexBasisProperty.setNative](value) {
1231
+ // @ts-ignore
1232
+ const style = this._styleHelper;
1233
+ if (style) {
1234
+ style.flexBasis = value;
1235
+ }
1236
+ }
1237
+ [alignItemsProperty.setNative](value) {
1238
+ // @ts-ignore
1239
+ const style = this._styleHelper;
1240
+ if (style) {
1241
+ style.alignItems = value;
1242
+ }
1243
+ }
1244
+ [alignSelfProperty.setNative](value) {
1245
+ // @ts-ignore
1246
+ const style = this._styleHelper;
1247
+ if (style) {
1248
+ style.alignSelf = value;
1249
+ }
1250
+ }
1251
+ [alignContentProperty.setNative](value) {
1252
+ // @ts-ignore
1253
+ const style = this._styleHelper;
1254
+ if (style) {
1255
+ style.alignContent = value;
1256
+ }
1257
+ }
1258
+ [justifyItemsProperty.setNative](value) {
1259
+ // @ts-ignore
1260
+ const style = this._styleHelper;
1261
+ if (style) {
1262
+ style.justifyItems = value;
1263
+ }
1264
+ }
1265
+ [justifySelfProperty.setNative](value) {
1266
+ // @ts-ignore
1267
+ const style = this._styleHelper;
1268
+ if (style) {
1269
+ style.justifySelf = value;
1270
+ }
1271
+ }
1272
+ [justifyContentProperty.setNative](value) {
1273
+ // @ts-ignore
1274
+ const style = this._styleHelper;
1275
+ if (style) {
1276
+ style.justifyContent = value;
1277
+ }
1278
+ }
1279
+ [leftProperty.setNative](value) {
1280
+ // @ts-ignore
1281
+ const style = this._styleHelper;
1282
+ if (style) {
1283
+ style.left = value;
1284
+ }
1285
+ }
1286
+ [rightProperty.setNative](value) {
1287
+ // @ts-ignore
1288
+ const style = this._styleHelper;
1289
+ if (style) {
1290
+ style.right = value;
1291
+ }
1292
+ }
1293
+ [bottomProperty.setNative](value) {
1294
+ // @ts-ignore
1295
+ const style = this._styleHelper;
1296
+ if (style) {
1297
+ style.bottom = value;
1298
+ }
1299
+ }
1300
+ [topProperty.setNative](value) {
1301
+ // @ts-ignore
1302
+ const style = this._styleHelper;
1303
+ if (style) {
1304
+ style.top = value;
1305
+ }
1306
+ }
1307
+ [minWidthProperty.setNative](value) {
1308
+ // @ts-ignore
1309
+ const style = this._styleHelper;
1310
+ if (style) {
1311
+ style.minWidth = value;
1312
+ }
1313
+ }
1314
+ [minHeightProperty.setNative](value) {
1315
+ // @ts-ignore
1316
+ const style = this._styleHelper;
1317
+ if (style) {
1318
+ style.minHeight = value;
1319
+ }
1320
+ }
1321
+ [heightProperty.setNative](value) {
1322
+ // @ts-ignore
1323
+ const style = this._styleHelper;
1324
+ if (style) {
1325
+ style.height = value;
1326
+ }
1327
+ }
1328
+ [widthProperty.setNative](value) {
1329
+ // @ts-ignore
1330
+ const style = this._styleHelper;
1331
+ if (style) {
1332
+ style.width = value;
1333
+ }
1334
+ }
1335
+ set maxWidth(value) {
1336
+ this.style.maxWidth = value;
1337
+ }
1338
+ get maxWidth() {
1339
+ return this.style.maxWidth;
1340
+ }
1341
+ set maxHeight(value) {
1342
+ this.style.maxHeight = value;
1343
+ }
1344
+ get maxHeight() {
1345
+ return this.style.maxHeight;
1346
+ }
1347
+ [marginLeftProperty.setNative](value) {
1348
+ // @ts-ignore
1349
+ const style = this._styleHelper;
1350
+ if (style) {
1351
+ style.marginLeft = value;
1352
+ }
1353
+ }
1354
+ [marginRightProperty.setNative](value) {
1355
+ // @ts-ignore
1356
+ const style = this._styleHelper;
1357
+ if (style) {
1358
+ style.marginRight = value;
1359
+ }
1360
+ }
1361
+ [marginBottomProperty.setNative](value) {
1362
+ // @ts-ignore
1363
+ const style = this._styleHelper;
1364
+ if (style) {
1365
+ style.marginBottom = value;
1366
+ }
1367
+ }
1368
+ [marginTopProperty.setNative](value) {
1369
+ // @ts-ignore
1370
+ const style = this._styleHelper;
1371
+ if (style) {
1372
+ style.marginTop = value;
1373
+ }
1374
+ }
1375
+ [paddingLeftProperty.setNative](value) {
1376
+ // @ts-ignore
1377
+ const style = this._styleHelper;
1378
+ if (style) {
1379
+ style.paddingLeft = value;
1380
+ }
1381
+ }
1382
+ [paddingRightProperty.setNative](value) {
1383
+ // @ts-ignore
1384
+ const style = this._styleHelper;
1385
+ if (style) {
1386
+ style.paddingRight = value;
1387
+ }
1388
+ }
1389
+ [paddingTopProperty.setNative](value) {
1390
+ // @ts-ignore
1391
+ const style = this._styleHelper;
1392
+ if (style) {
1393
+ style.paddingTop = value;
1394
+ }
1395
+ }
1396
+ [paddingBottomProperty.setNative](value) {
1397
+ // @ts-ignore
1398
+ const style = this._styleHelper;
1399
+ if (style) {
1400
+ style.paddingBottom = value;
1401
+ }
1402
+ }
1403
+ set rowGap(value) {
1404
+ this.style.rowGap = value;
1405
+ }
1406
+ get rowGap() {
1407
+ return this.style.rowGap;
1408
+ }
1409
+ set columnGap(value) {
1410
+ this.style.columnGap = value;
1411
+ }
1412
+ get columnGap() {
1413
+ return this.style.columnGap;
1414
+ }
1415
+ set gridColumnStart(value) {
1416
+ this.style.gridColumnStart = value;
1417
+ }
1418
+ get gridColumnStart() {
1419
+ return this.style.gridColumnStart;
1420
+ }
1421
+ set gridColumnEnd(value) {
1422
+ this.style.gridColumnEnd = value;
1423
+ }
1424
+ get gridColumnEnd() {
1425
+ return this.style.gridColumnEnd;
1426
+ }
1427
+ set gridRowStart(value) {
1428
+ this.style.gridRowStart = value;
1429
+ }
1430
+ get gridRowStart() {
1431
+ return this.style.gridRowStart;
1432
+ }
1433
+ set gridRowEnd(value) {
1434
+ this.style.gridRowEnd = value;
1435
+ }
1436
+ get gridRowEnd() {
1437
+ return this.style.gridRowEnd;
1438
+ }
1439
+ set gridTemplateRows(value) {
1440
+ this.style.gridTemplateRows = value;
1441
+ }
1442
+ get gridTemplateRows() {
1443
+ return this.style.gridTemplateRows;
1444
+ }
1445
+ set gridTemplateColumns(value) {
1446
+ this.style.gridTemplateColumns = value;
1447
+ }
1448
+ get gridTemplateColumns() {
1449
+ return this.style.gridTemplateColumns;
1450
+ }
1451
+ set gridAutoColumns(value) {
1452
+ this.style.gridAutoColumns = value;
1453
+ }
1454
+ get gridAutoColumns() {
1455
+ return this.style.gridAutoColumns;
1456
+ }
1457
+ set gridAutoRows(value) {
1458
+ this.style.gridAutoRows = value;
1459
+ }
1460
+ get gridAutoRows() {
1461
+ return this.style.gridAutoRows;
1462
+ }
1463
+ // @ts-ignore
1464
+ [fontSizeProperty.setNative](value) {
1465
+ // @ts-ignore
1466
+ if (this._styleHelper) {
1467
+ //@ts-ignore
1468
+ this._styleHelper.fontSize = value;
1469
+ }
1470
+ }
1471
+ [fontWeightProperty.setNative](value) {
1472
+ // @ts-ignore
1473
+ if (this._styleHelper) {
1474
+ //@ts-ignore
1475
+ this._styleHelper.fontWeight = value;
1476
+ }
1477
+ }
1478
+ [fontStyleProperty.setNative](value) {
1479
+ // @ts-ignore
1480
+ if (this._styleHelper) {
1481
+ //@ts-ignore
1482
+ this._styleHelper.fontStyle = value;
1483
+ }
1484
+ }
1485
+ }
1486
+ export class TextBase extends ViewBase {
1487
+ }
1488
+ textContentProperty.register(TextBase);
1489
+ textWrapProperty.register(Style);
1490
+ textOverFlowProperty.register(Style);
1491
+ // @ts-ignore
1492
+ export const srcProperty = new Property({
1493
+ name: 'src',
1494
+ defaultValue: '',
1495
+ });
1496
+ export class ImageBase extends ViewBase {
1497
+ }
1498
+ srcProperty.register(ImageBase);
1499
+ /**
1500
+ * Props are already defined in core flexbox layout,
1501
+ * overriding them breaks the core flexbox layout.
1502
+ */
1503
+ // flexDirectionProperty.register(Style);
1504
+ // flexWrapProperty.register(Style);
1505
+ // flexGrowProperty.register(Style);
1506
+ flexShrinkProperty.register(Style);
1507
+ // revert valueConverter if causing issues with core components
1508
+ fontSizeProperty.overrideHandlers({
1509
+ name: 'fontSize',
1510
+ cssName: 'font-size',
1511
+ valueConverter: function (value) {
1512
+ return value;
1513
+ },
1514
+ valueChanged(target, oldValue, newValue) {
1515
+ const view = getViewStyle(target.viewRef);
1516
+ if (view) {
1517
+ if (newValue) {
1518
+ if (typeof newValue === 'string') {
1519
+ // @ts-ignore
1520
+ if (newValue.indexOf('%') !== -1) {
1521
+ view.fontSize = {
1522
+ value: parseFloat(newValue) / 100,
1523
+ unit: '%',
1524
+ };
1525
+ // @ts-ignore
1526
+ }
1527
+ else if (newValue.indexOf('dip') !== -1) {
1528
+ view.fontSize = parseFloat(newValue);
1529
+ // @ts-ignore
1530
+ }
1531
+ else if (newValue.indexOf('px') !== -1) {
1532
+ view.fontSize = {
1533
+ value: parseFloat(newValue),
1534
+ unit: 'px',
1535
+ };
1536
+ }
1537
+ else {
1538
+ view.fontSize = parseFloat(newValue);
1539
+ }
1540
+ }
1541
+ else {
1542
+ view.fontSize = newValue;
1543
+ }
1544
+ }
1545
+ else {
1546
+ // Revert to old value if newValue is invalid
1547
+ // @ts-ignore
1548
+ view.view.style.fontSize = oldValue;
1549
+ }
1550
+ }
1551
+ },
1552
+ });
1553
+ paddingLeftProperty.overrideHandlers({
1554
+ name: 'paddingLeft',
1555
+ cssName: 'padding-left',
1556
+ valueChanged(target, oldValue, newValue) {
1557
+ const view = getViewStyle(target.viewRef);
1558
+ if (view) {
1559
+ if (newValue) {
1560
+ view.paddingLeft = newValue;
1561
+ }
1562
+ else {
1563
+ // Revert to old value if newValue is invalid
1564
+ // @ts-ignore
1565
+ view.view.style.paddingLeft = oldValue;
1566
+ }
1567
+ }
1568
+ },
1569
+ });
1570
+ paddingTopProperty.overrideHandlers({
1571
+ name: 'paddingTop',
1572
+ cssName: 'padding-top',
1573
+ valueChanged(target, oldValue, newValue) {
1574
+ const view = getViewStyle(target.viewRef);
1575
+ if (view) {
1576
+ if (newValue) {
1577
+ view.paddingTop = newValue;
1578
+ }
1579
+ else {
1580
+ // Revert to old value if newValue is invalid
1581
+ // @ts-ignore
1582
+ view.view.style.paddingTop = oldValue;
1583
+ }
1584
+ }
1585
+ },
1586
+ });
1587
+ paddingRightProperty.overrideHandlers({
1588
+ name: 'paddingRight',
1589
+ cssName: 'padding-right',
1590
+ valueChanged(target, oldValue, newValue) {
1591
+ const view = getViewStyle(target.viewRef);
1592
+ if (view) {
1593
+ if (newValue) {
1594
+ view.paddingRight = newValue;
1595
+ }
1596
+ else {
1597
+ // Revert to old value if newValue is invalid
1598
+ // @ts-ignore
1599
+ view.view.style.paddingRight = oldValue;
1600
+ }
1601
+ }
1602
+ },
1603
+ });
1604
+ paddingBottomProperty.overrideHandlers({
1605
+ name: 'paddingBottom',
1606
+ cssName: 'padding-bottom',
1607
+ valueChanged(target, oldValue, newValue) {
1608
+ const view = getViewStyle(target.viewRef);
1609
+ if (view) {
1610
+ if (newValue) {
1611
+ view.paddingBottom = newValue;
1612
+ }
1613
+ else {
1614
+ // Revert to old value if newValue is invalid
1615
+ // @ts-ignore
1616
+ view.view.style.paddingBottom = oldValue;
1617
+ }
1618
+ }
1619
+ },
1620
+ });
1621
+ insetProperty.register(Style);
1622
+ boxSizingProperty.register(Style);
1623
+ alignItemsProperty.register(Style);
1624
+ alignSelfProperty.register(Style);
1625
+ justifyContentProperty.register(Style);
1626
+ displayProperty.register(Style);
1627
+ maxWidthProperty.register(Style);
1628
+ maxHeightProperty.register(Style);
1629
+ positionProperty.register(Style);
1630
+ leftProperty.register(Style);
1631
+ rightProperty.register(Style);
1632
+ topProperty.register(Style);
1633
+ bottomProperty.register(Style);
1634
+ flexBasisProperty.register(Style);
1635
+ rowGapProperty.register(Style);
1636
+ columnGapProperty.register(Style);
1637
+ gridRowGapProperty.register(Style);
1638
+ gridColumnGapProperty.register(Style);
1639
+ gapProperty.register(Style);
1640
+ gridGapProperty.register(Style);
1641
+ aspectRatioProperty.register(Style);
1642
+ alignContentProperty.register(Style);
1643
+ justifyItemsProperty.register(Style);
1644
+ justifySelfProperty.register(Style);
1645
+ gridAutoRowsProperty.register(Style);
1646
+ gridAutoColumnsProperty.register(Style);
1647
+ gridAutoFlowProperty.register(Style);
1648
+ gridAreaProperty.register(Style);
1649
+ gridColumnProperty.register(Style);
1650
+ gridColumnStartProperty.register(Style);
1651
+ gridColumnEndProperty.register(Style);
1652
+ gridRowProperty.register(Style);
1653
+ gridRowStartProperty.register(Style);
1654
+ gridRowEndProperty.register(Style);
1655
+ gridTemplateRowsProperty.register(Style);
1656
+ gridTemplateColumnsProperty.register(Style);
1657
+ gridTemplateAreasProperty.register(Style);
1658
+ overflowProperty.register(Style);
1659
+ overflowXProperty.register(Style);
1660
+ overflowYProperty.register(Style);
1661
+ scrollBarWidthProperty.register(Style);
1662
+ flexFlowProperty.register(Style);
1663
+ flexProperty.register(Style);
1664
+ function parseShorthandPositioning(value) {
1665
+ const arr = value.split(/[ ,]+/);
1666
+ let top;
1667
+ let right;
1668
+ let bottom;
1669
+ let left;
1670
+ if (arr.length === 1) {
1671
+ top = arr[0];
1672
+ right = arr[0];
1673
+ bottom = arr[0];
1674
+ left = arr[0];
1675
+ }
1676
+ else if (arr.length === 2) {
1677
+ top = arr[0];
1678
+ bottom = arr[0];
1679
+ right = arr[1];
1680
+ left = arr[1];
1681
+ }
1682
+ else if (arr.length === 3) {
1683
+ top = arr[0];
1684
+ right = arr[1];
1685
+ left = arr[1];
1686
+ bottom = arr[2];
1687
+ }
1688
+ else if (arr.length === 4) {
1689
+ top = arr[0];
1690
+ right = arr[1];
1691
+ bottom = arr[2];
1692
+ left = arr[3];
1693
+ }
1694
+ else {
1695
+ throw new Error('Expected 1, 2, 3 or 4 parameters. Actual: ' + value);
1696
+ }
1697
+ return {
1698
+ top: top,
1699
+ right: right,
1700
+ bottom: bottom,
1701
+ left: left,
1702
+ };
1703
+ }
1704
+ function convertToPaddings(value) {
1705
+ if (typeof value === 'string' && value !== 'auto') {
1706
+ const thickness = parseShorthandPositioning(value);
1707
+ return [
1708
+ [paddingTopProperty, CoreLength.parse(thickness.top)],
1709
+ [paddingRightProperty, CoreLength.parse(thickness.right)],
1710
+ [paddingBottomProperty, CoreLength.parse(thickness.bottom)],
1711
+ [paddingLeftProperty, CoreLength.parse(thickness.left)],
1712
+ ];
1713
+ }
1714
+ else {
1715
+ return [
1716
+ [paddingTopProperty, value],
1717
+ [paddingRightProperty, value],
1718
+ [paddingBottomProperty, value],
1719
+ [paddingLeftProperty, value],
1720
+ ];
1721
+ }
1722
+ }
1723
+ paddingProperty.register(Style);
1724
+ paddingLeftProperty.register(Style);
1725
+ paddingRightProperty.register(Style);
1726
+ paddingTopProperty.register(Style);
1727
+ paddingBottomProperty.register(Style);
1728
+ //# sourceMappingURL=common.js.map