@triniwiz/nativescript-masonkit 1.0.0-alpha.27 → 1.0.0-alpha.28

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