@triniwiz/nativescript-masonkit 1.0.0-alpha.23 → 1.0.0-alpha.25

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