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

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