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

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