@triniwiz/nativescript-masonkit 1.0.0-alpha.24 → 1.0.0-alpha.26

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