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

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