@triniwiz/nativescript-masonkit 1.0.0-beta.6 → 1.0.0-beta.60

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 (117) hide show
  1. package/br/index.android.d.ts +10 -0
  2. package/br/index.android.js +31 -0
  3. package/br/index.android.js.map +1 -0
  4. package/br/index.ios.d.ts +11 -0
  5. package/br/index.ios.js +30 -0
  6. package/br/index.ios.js.map +1 -0
  7. package/button/index.android.d.ts +4 -2
  8. package/button/index.android.js +9 -4
  9. package/button/index.android.js.map +1 -1
  10. package/button/index.ios.d.ts +4 -5
  11. package/button/index.ios.js +9 -66
  12. package/button/index.ios.js.map +1 -1
  13. package/common.d.ts +135 -70
  14. package/common.js +775 -1337
  15. package/common.js.map +1 -1
  16. package/img/index.android.d.ts +5 -4
  17. package/img/index.android.js +18 -6
  18. package/img/index.android.js.map +1 -1
  19. package/img/index.ios.d.ts +3 -2
  20. package/img/index.ios.js +23 -19
  21. package/img/index.ios.js.map +1 -1
  22. package/index.android.d.ts +4 -1
  23. package/index.android.js +4 -1
  24. package/index.android.js.map +1 -1
  25. package/index.d.ts +21 -1
  26. package/index.ios.d.ts +4 -1
  27. package/index.ios.js +4 -1
  28. package/index.ios.js.map +1 -1
  29. package/input/common.d.ts +20 -0
  30. package/input/common.js +64 -0
  31. package/input/common.js.map +1 -0
  32. package/input/index.android.d.ts +20 -0
  33. package/input/index.android.js +118 -0
  34. package/input/index.android.js.map +1 -0
  35. package/input/index.ios.d.ts +23 -0
  36. package/input/index.ios.js +163 -0
  37. package/input/index.ios.js.map +1 -0
  38. package/package.json +3 -2
  39. package/platforms/android/masonkit-release.aar +0 -0
  40. package/platforms/ios/Mason.xcframework/Info.plist +5 -5
  41. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +281 -51
  42. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/mason_native.h +70 -42
  43. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Info.plist +0 -0
  44. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  45. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  46. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +39728 -27944
  47. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +876 -247
  48. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  49. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +876 -247
  50. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  51. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7413 -4294
  52. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +562 -102
  53. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/mason_native.h +70 -42
  54. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Info.plist +0 -0
  55. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  56. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  57. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  58. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +34845 -23061
  59. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +975 -346
  60. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  61. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +975 -346
  62. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +34845 -23061
  63. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +975 -346
  64. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  65. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +975 -346
  66. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +29 -29
  67. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  68. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7408 -4287
  69. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +7103 -4165
  70. package/properties.d.ts +49 -0
  71. package/properties.js +1147 -0
  72. package/properties.js.map +1 -0
  73. package/scroll/index.android.d.ts +3 -2
  74. package/scroll/index.android.js +16 -4
  75. package/scroll/index.android.js.map +1 -1
  76. package/scroll/index.ios.d.ts +3 -2
  77. package/scroll/index.ios.js +18 -5
  78. package/scroll/index.ios.js.map +1 -1
  79. package/style.d.ts +9 -5
  80. package/style.js +622 -367
  81. package/style.js.map +1 -1
  82. package/symbols.d.ts +10 -0
  83. package/symbols.js +11 -0
  84. package/symbols.js.map +1 -0
  85. package/text/index.android.d.ts +11 -5
  86. package/text/index.android.js +72 -103
  87. package/text/index.android.js.map +1 -1
  88. package/text/index.ios.d.ts +12 -10
  89. package/text/index.ios.js +69 -168
  90. package/text/index.ios.js.map +1 -1
  91. package/text-node/index.android.d.ts +13 -0
  92. package/text-node/index.android.js +35 -0
  93. package/text-node/index.android.js.map +1 -0
  94. package/text-node/index.ios.d.ts +13 -0
  95. package/text-node/index.ios.js +35 -0
  96. package/text-node/index.ios.js.map +1 -0
  97. package/tree/index.android.d.ts +10 -2
  98. package/tree/index.android.js +62 -1
  99. package/tree/index.android.js.map +1 -1
  100. package/tree/index.ios.d.ts +4 -1
  101. package/tree/index.ios.js +36 -1
  102. package/tree/index.ios.js.map +1 -1
  103. package/utils/index.android.d.ts +2 -1
  104. package/utils/index.android.js +1 -1
  105. package/utils/index.android.js.map +1 -1
  106. package/utils/index.ios.d.ts +2 -1
  107. package/utils/index.ios.js +1 -1
  108. package/utils/index.ios.js.map +1 -1
  109. package/view/index.android.d.ts +3 -2
  110. package/view/index.android.js +18 -4
  111. package/view/index.android.js.map +1 -1
  112. package/view/index.ios.d.ts +3 -2
  113. package/view/index.ios.js +18 -5
  114. package/view/index.ios.js.map +1 -1
  115. package/web.d.ts +6 -0
  116. package/web.js +22 -0
  117. package/web.js.map +1 -1
package/common.js CHANGED
@@ -1,1027 +1,160 @@
1
1
  var _a, _b, _c;
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  /* eslint-disable @typescript-eslint/ban-ts-comment */
4
- import { CssProperty, CustomLayoutView, Length as NSLength, ShorthandProperty, Style, View as NSView, getViewById, unsetValue, Property, widthProperty, heightProperty, CoreTypes, Trace, Length as CoreLength, PercentLength as CorePercentLength, marginLeftProperty, marginRightProperty, marginTopProperty, marginBottomProperty, minWidthProperty, minHeightProperty, fontSizeProperty, fontWeightProperty, fontStyleProperty, colorProperty, Color, lineHeightProperty, letterSpacingProperty, textAlignmentProperty, borderLeftWidthProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, verticalAlignmentProperty, backgroundColorProperty, textShadowProperty, } from '@nativescript/core';
5
- import { flexDirectionProperty, flexGrowProperty, flexWrapProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
4
+ import { CustomLayoutView, View as NSView, getViewById, Property, widthProperty, heightProperty, Length as CoreLength, PercentLength as CorePercentLength, marginLeftProperty, marginRightProperty, marginTopProperty, marginBottomProperty, minWidthProperty, minHeightProperty, fontSizeProperty, fontWeightProperty, fontStyleProperty, colorProperty, Color, lineHeightProperty, letterSpacingProperty, textAlignmentProperty, borderLeftWidthProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, backgroundColorProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, paddingBottomProperty, zIndexProperty } from '@nativescript/core';
5
+ import { alignItemsProperty, alignSelfProperty, flexDirectionProperty, flexGrowProperty, flexShrinkProperty, flexWrapProperty, justifyContentProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
6
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
- export const isPlaceholder_ = Symbol('[[isPlaceholder]]');
7
+ import { alignContentProperty, aspectRatioProperty, backgroundProperty, borderProperty, borderRadiusProperty, bottomProperty, boxSizingProperty, columnGapProperty, displayProperty, filterProperty, flexBasisProperty, gridAreaProperty, gridAutoColumnsProperty, gridAutoFlowProperty, gridAutoRowsProperty, gridColumnEndProperty, gridColumnProperty, gridColumnStartProperty, gridRowEndProperty, gridRowProperty, gridRowStartProperty, gridTemplateAreasProperty, gridTemplateColumnsProperty, gridTemplateRowsProperty, justifyItemsProperty, justifySelfProperty, leftProperty, marginProperty, maxHeightProperty, maxWidthProperty, overflowXProperty, overflowYProperty, paddingProperty, positionProperty, rightProperty, rowGapProperty, scrollBarWidthProperty, textOverFlowProperty, textWrapProperty, topProperty, verticalAlignProperty, } from './properties';
8
+ import { isMasonView_, isTextChild_, isText_, isPlaceholder_, text_, native_, textNode_, textNodeIndex_ } from './symbols';
9
+ import { Tree } from './tree';
10
+ import { TextNode } from './text-node';
14
11
  function getViewStyle(view) {
15
12
  const ret = (__ANDROID__ ? view.get() : view.deref());
16
13
  return ret._styleHelper;
17
14
  }
18
- var FrameWork;
19
- (function (FrameWork) {
20
- FrameWork[FrameWork["Core"] = 0] = "Core";
21
- FrameWork[FrameWork["Angular"] = 1] = "Angular";
22
- FrameWork[FrameWork["Vue"] = 2] = "Vue";
23
- FrameWork[FrameWork["React"] = 3] = "React";
24
- FrameWork[FrameWork["Svelte"] = 4] = "Svelte";
25
- FrameWork[FrameWork["Solid"] = 5] = "Solid";
26
- })(FrameWork || (FrameWork = {}));
27
- let frameWork = FrameWork.Core;
15
+ let frameWork = 0 /* FrameWork.Core */;
28
16
  try {
29
17
  global.VUE3_ELEMENT_REF = require('nativescript-vue').ELEMENT_REF;
30
- frameWork = FrameWork.Vue;
18
+ frameWork = 2 /* FrameWork.Vue */;
19
+ }
20
+ catch (e) { }
21
+ try {
22
+ const helper = require('react-nativescript/dist/nativescript-vue-next/runtime/runtimeHelpers.js');
23
+ global.REACT_ELEMENT_REF = helper.ELEMENT_REF;
24
+ frameWork = 3 /* FrameWork.React */;
31
25
  }
32
26
  catch (e) { }
33
27
  if (global.__ngRegisteredViews || typeof Zone !== 'undefined') {
34
- frameWork = FrameWork.Angular;
28
+ frameWork = 1 /* FrameWork.Angular */;
35
29
  }
36
- export const scrollBarWidthProperty = new CssProperty({
37
- name: 'scrollBarWidth',
38
- cssName: 'scrollbar-width',
39
- defaultValue: 0,
40
- valueConverter: parseFloat,
30
+ // @ts-ignore
31
+ export const textContentProperty = new Property({
32
+ name: 'textContent',
33
+ affectsLayout: true,
34
+ defaultValue: '',
41
35
  });
42
- function overflowConverter(value) {
43
- if (typeof value === 'number') {
44
- switch (value) {
45
- case 0:
46
- return 'visible';
47
- case 1:
48
- return 'clip';
49
- case 2:
50
- return 'hidden';
51
- case 3:
52
- return 'scroll';
53
- }
54
- }
55
- switch (value) {
56
- case 'visible':
57
- case 'hidden':
58
- case 'clip':
59
- case 'scroll':
60
- return value;
61
- default:
62
- return undefined;
63
- }
64
- }
65
- function masonLengthParse(value) {
66
- try {
67
- return CoreLength.parse(value);
68
- }
69
- catch (e) {
70
- return undefined;
71
- }
72
- }
73
- function masonLengthPercentParse(value) {
74
- try {
75
- return CorePercentLength.parse(value);
76
- }
77
- catch (e) {
78
- return undefined;
36
+ export class ViewBase extends CustomLayoutView {
37
+ constructor() {
38
+ super();
39
+ this._children = [];
40
+ this[_a] = false;
41
+ this[_b] = false;
42
+ this[_c] = false;
43
+ this._pendingEventsRegistration = [];
79
44
  }
80
- }
81
- const filterProperty = new CssProperty({
82
- name: 'filter',
83
- cssName: 'filter',
84
- });
85
- filterProperty.register(Style);
86
- const borderProperty = new CssProperty({
87
- name: 'border',
88
- cssName: 'border',
89
- });
90
- borderProperty.register(Style);
91
- const backgroundProperty = new CssProperty({
92
- name: 'background',
93
- cssName: 'background',
94
- });
95
- backgroundProperty.register(Style);
96
- const overFlow = /^\s*(visible|hidden|clip|scroll|auto)(?:\s+(visible|hidden|clip|scroll|auto))?\s*$/;
97
- export const overflowProperty = new ShorthandProperty({
98
- name: 'overflow',
99
- cssName: 'overflow',
100
- getter: function () {
101
- if (this.overflowX === this.overflowY) {
102
- return this.overflowX;
103
- }
104
- return `${this.overflowX} ${this.overflowY}`;
105
- },
106
- converter(value) {
107
- const properties = [];
108
- if (typeof value === 'string') {
109
- const values = value.match(overFlow);
110
- const length = values?.length ?? 0;
111
- if (length === 0) {
112
- return properties;
113
- }
114
- if (length === 1) {
115
- const xy = values[0];
116
- properties.push([overflowXProperty, xy]);
117
- properties.push([overflowYProperty, xy]);
118
- }
119
- if (length > 1) {
120
- const x = values[0];
121
- const y = values[1];
122
- properties.push([overflowXProperty, x]);
123
- properties.push([overflowYProperty, y]);
124
- }
125
- }
126
- return properties;
127
- },
128
- });
129
- export const overflowXProperty = new CssProperty({
130
- name: 'overflowX',
131
- cssName: 'overflow-x',
132
- defaultValue: 'visible',
133
- valueConverter: overflowConverter,
134
- valueChanged: (target, oldValue, newValue) => {
135
- const view = getViewStyle(target.viewRef);
136
- if (view) {
137
- if (newValue) {
138
- view.overflowX = newValue;
139
- }
140
- else {
141
- // Revert to old value if newValue is invalid
142
- view.view.style.overflowX = oldValue;
143
- }
144
- }
145
- },
146
- });
147
- export const overflowYProperty = new CssProperty({
148
- name: 'overflowY',
149
- cssName: 'overflow-y',
150
- defaultValue: 'visible',
151
- valueConverter: overflowConverter,
152
- valueChanged(target, oldValue, newValue) {
153
- const view = getViewStyle(target.viewRef);
154
- if (view) {
155
- if (newValue) {
156
- view.overflowY = newValue;
157
- }
158
- else {
159
- // Revert to old value if newValue is invalid
160
- view.view.style.overflowY = oldValue;
161
- }
162
- }
163
- },
164
- });
165
- const paddingProperty = new CssProperty({
166
- name: 'padding',
167
- cssName: 'padding',
168
- });
169
- paddingProperty.register(Style);
170
- const marginProperty = new CssProperty({
171
- name: 'margin',
172
- cssName: 'margin',
173
- });
174
- marginProperty.register(Style);
175
- export const paddingLeftProperty = new CssProperty({
176
- name: 'paddingLeft',
177
- cssName: 'padding-left',
178
- defaultValue: CoreTypes.zeroLength,
179
- affectsLayout: global.isIOS,
180
- equalityComparer: CoreLength.equals,
181
- valueChanged: (target, oldValue, newValue) => {
182
- const view = getViewStyle(target.viewRef);
183
- if (view) {
184
- view.paddingLeft = CoreLength.toDevicePixels(newValue, 0);
185
- }
186
- else {
187
- Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
188
- }
189
- },
190
- valueConverter: masonLengthParse,
191
- });
192
- export const paddingRightProperty = new CssProperty({
193
- name: 'paddingRight',
194
- cssName: 'padding-right',
195
- defaultValue: CoreTypes.zeroLength,
196
- affectsLayout: global.isIOS,
197
- equalityComparer: CoreLength.equals,
198
- valueChanged: (target, oldValue, newValue) => {
199
- const view = getViewStyle(target.viewRef);
200
- if (view) {
201
- view.paddingRight = CoreLength.toDevicePixels(newValue, 0);
202
- }
203
- else {
204
- Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
205
- }
206
- },
207
- valueConverter: masonLengthParse,
208
- });
209
- export const paddingTopProperty = new CssProperty({
210
- name: 'paddingTop',
211
- cssName: 'padding-top',
212
- defaultValue: CoreTypes.zeroLength,
213
- affectsLayout: global.isIOS,
214
- equalityComparer: CoreLength.equals,
215
- valueChanged: (target, oldValue, newValue) => {
216
- const view = getViewStyle(target.viewRef);
217
- if (view) {
218
- view.paddingTop = CoreLength.toDevicePixels(newValue, 0);
219
- }
220
- else {
221
- Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
222
- }
223
- },
224
- valueConverter: masonLengthParse,
225
- });
226
- export const paddingBottomProperty = new CssProperty({
227
- name: 'paddingBottom',
228
- cssName: 'padding-bottom',
229
- defaultValue: CoreTypes.zeroLength,
230
- affectsLayout: global.isIOS,
231
- equalityComparer: CoreLength.equals,
232
- valueChanged: (target, oldValue, newValue) => {
233
- const view = getViewStyle(target.viewRef);
234
- if (view) {
235
- view.paddingBottom = CoreLength.toDevicePixels(newValue, 0);
236
- }
237
- else {
238
- Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
239
- }
240
- },
241
- valueConverter: masonLengthParse,
242
- });
243
- export const rowGapProperty = new CssProperty({
244
- name: 'rowGap',
245
- cssName: 'row-gap',
246
- defaultValue: 0,
247
- valueConverter(value) {
248
- const parsed = CoreLength.parse(value);
249
- if (typeof parsed === 'string') {
250
- return 0;
251
- }
252
- return parsed;
253
- },
254
- valueChanged(target, oldValue, newValue) {
255
- const view = getViewStyle(target.viewRef);
256
- if (view) {
257
- view.rowGap = newValue;
258
- }
259
- },
260
- });
261
- export const columnGapProperty = new CssProperty({
262
- name: 'columnGap',
263
- cssName: 'column-gap',
264
- defaultValue: 0,
265
- valueConverter(value) {
266
- const parsed = CoreLength.parse(value);
267
- if (typeof parsed === 'string') {
268
- return 0;
269
- }
270
- return parsed;
271
- },
272
- valueChanged(target, oldValue, newValue) {
273
- const view = getViewStyle(target.viewRef);
274
- if (view) {
275
- view.columnGap = newValue;
276
- }
277
- },
278
- });
279
- export const gridGapProperty = new ShorthandProperty({
280
- name: 'gridGap',
281
- cssName: 'grid-gap',
282
- getter: function () {
283
- if (this.rowGap === this.columnGap) {
284
- return this.rowGap;
285
- }
286
- return `${this.rowGap} ${this.columnGap}`;
287
- },
288
- converter(gap) {
289
- const properties = [];
290
- let value = gap;
291
- if (typeof value === 'number') {
292
- value = `${value}`;
293
- }
294
- if (typeof value === 'string') {
295
- const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
296
- const length = values.length;
297
- if (length === 0) {
298
- return properties;
299
- }
300
- if (length === 1) {
301
- const row = values[0];
302
- properties.push([rowGapProperty, row]);
303
- properties.push([columnGapProperty, row]);
304
- }
305
- if (length > 1) {
306
- const row = values[0];
307
- const column = values[1];
308
- properties.push([rowGapProperty, row]);
309
- properties.push([columnGapProperty, column]);
310
- }
311
- }
312
- return properties;
313
- },
314
- });
315
- export const gapProperty = new ShorthandProperty({
316
- name: 'gap',
317
- cssName: 'gap',
318
- getter: function () {
319
- if (this.rowGap === this.columnGap) {
320
- return this.rowGap;
321
- }
322
- return `${this.rowGap} ${this.columnGap}`;
323
- },
324
- converter(gap) {
325
- const properties = [];
326
- let value = gap;
327
- if (typeof value === 'number') {
328
- value = `${value}`;
329
- }
330
- if (typeof value === 'string') {
331
- const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
332
- const length = values.length;
333
- if (length === 0) {
334
- return properties;
335
- }
336
- if (length === 1) {
337
- const row = values[0];
338
- properties.push([rowGapProperty, row]);
339
- properties.push([columnGapProperty, row]);
340
- }
341
- if (length > 1) {
342
- const row = values[0];
343
- const column = values[1];
344
- properties.push([rowGapProperty, row]);
345
- properties.push([columnGapProperty, column]);
346
- }
347
- }
348
- return properties;
349
- },
350
- });
351
- // export const flexGrowProperty = new CssProperty<Style, number>({
352
- // name: 'flexGrow',
353
- // cssName: 'flex-grow',
354
- // defaultValue: 0,
355
- // valueConverter: parseFloat,
356
- // });
357
- export const flexShrinkProperty = new CssProperty({
358
- name: 'flexShrink',
359
- cssName: 'flex-shrink',
360
- defaultValue: 1,
361
- valueConverter: parseFloat,
362
- });
363
- export const displayProperty = new CssProperty({
364
- name: 'display',
365
- cssName: 'display',
366
- defaultValue: 'block',
367
- valueChanged: (target, oldValue, newValue) => {
368
- const view = getViewStyle(target.viewRef);
369
- if (view && newValue) {
370
- view.display = newValue;
371
- }
372
- else {
373
- // Revert to old value if newValue is invalid
374
- view.view.style.display = oldValue;
45
+ _registerNativeEvent(arg, callback, thisArg) {
46
+ if (!this[native_]) {
47
+ this._pendingEventsRegistration.push({ arg, callback, thisArg });
48
+ return;
375
49
  }
376
- },
377
- valueConverter: function (value) {
378
- if (typeof value === 'number') {
379
- switch (value) {
380
- case 0:
381
- return 'none';
382
- case 1:
383
- return 'flex';
384
- case 2:
385
- return 'grid';
386
- case 3:
387
- return 'block';
388
- case 4:
389
- return 'inline';
390
- case 5:
391
- return 'inline-block';
392
- case 6:
393
- return 'inline-flex';
394
- case 7:
395
- return 'inline-grid';
50
+ //@ts-ignore
51
+ if (this._view) {
52
+ if (__ANDROID__) {
53
+ const ref = new WeakRef(this);
54
+ const cb = new kotlin.jvm.functions.Function1({
55
+ invoke(event) {
56
+ const owner = ref.get();
57
+ if (owner) {
58
+ let ret;
59
+ if (arg === 'input') {
60
+ ret = new InputEvent();
61
+ }
62
+ else {
63
+ ret = new Event();
64
+ }
65
+ ret[native_] = event;
66
+ ret._target = owner;
67
+ callback.call(thisArg || owner, ret);
68
+ }
69
+ },
70
+ });
71
+ //@ts-ignore
72
+ const id = this._view.addEventListener(arg, cb);
73
+ callback['mason:event:id'] = id;
396
74
  }
397
- }
398
- switch (value) {
399
- case 'none':
400
- case 'flex':
401
- case 'grid':
402
- case 'block':
403
- case 'inline':
404
- case 'inline-block':
405
- case 'inline-flex':
406
- case 'inline-grid':
407
- return value;
408
- default:
409
- return undefined;
410
- }
411
- },
412
- });
413
- export const maxWidthProperty = new CssProperty({
414
- name: 'maxWidth',
415
- cssName: 'max-width',
416
- defaultValue: 'auto',
417
- // @ts-ignore
418
- equalityComparer: NSLength.equals,
419
- valueConverter: masonLengthParse,
420
- valueChanged: (target, oldValue, newValue) => {
421
- const view = getViewStyle(target.viewRef);
422
- if (view) {
423
- view.maxWidth = newValue;
424
- }
425
- else {
426
- Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
427
- }
428
- },
429
- });
430
- export const maxHeightProperty = new CssProperty({
431
- name: 'maxHeight',
432
- cssName: 'max-height',
433
- defaultValue: 'auto',
434
- // @ts-ignore
435
- equalityComparer: NSLength.equals,
436
- valueConverter: masonLengthParse,
437
- valueChanged(target, oldValue, newValue) {
438
- const view = getViewStyle(target.viewRef);
439
- if (view) {
440
- view.maxHeight = newValue;
441
- }
442
- },
443
- });
444
- export const positionProperty = new CssProperty({
445
- name: 'position',
446
- cssName: 'position',
447
- defaultValue: 'relative',
448
- valueChanged(target, oldValue, newValue) {
449
- const view = getViewStyle(target.viewRef);
450
- if (view) {
451
- view.position = newValue;
452
- }
453
- },
454
- });
455
- // export const flexDirectionProperty = new CssProperty<Style, FlexDirection>({
456
- // name: 'flexDirection',
457
- // cssName: 'flex-direction',
458
- // });
459
- // export const flexWrapProperty = new CssProperty<Style, FlexWrap>({
460
- // name: 'flexWrap',
461
- // cssName: 'flex-wrap',
462
- // defaultValue: 'no-wrap',
463
- // });
464
- const insetProperty = new ShorthandProperty({
465
- name: 'inset',
466
- cssName: 'inset',
467
- getter: function () {
468
- if (this.top === this.right && this.top === this.bottom && this.top === this.left) {
469
- if (typeof this.top === 'string') {
470
- if (this.top === 'auto') {
471
- return this.top;
472
- }
473
- const value = CorePercentLength.parse(this.top);
474
- if (Number.isNaN(value)) {
475
- return this.top;
476
- }
477
- else {
478
- return CorePercentLength.convertToString(value);
479
- }
75
+ if (__APPLE__) {
76
+ //@ts-ignore
77
+ const id = this._view.mason_addEventListener(arg, (event) => {
78
+ let ret;
79
+ if (arg === 'input') {
80
+ ret = new InputEvent();
81
+ }
82
+ else {
83
+ ret = new Event();
84
+ }
85
+ ret[native_] = event;
86
+ ret._target = this;
87
+ callback.call(thisArg || this, ret);
88
+ });
89
+ callback['mason:event:id'] = id;
480
90
  }
481
91
  }
482
- if (CorePercentLength.equals(this.top, this.right) && CorePercentLength.equals(this.top, this.bottom) && CorePercentLength.equals(this.top, this.left)) {
483
- return this.top;
484
- }
485
- return `${CorePercentLength.convertToString(this.paddingTop)} ${CorePercentLength.convertToString(this.paddingRight)} ${CorePercentLength.convertToString(this.paddingBottom)} ${CorePercentLength.convertToString(this.paddingLeft)}`;
486
- },
487
- converter: convertToInsets,
488
- });
489
- function convertToInsets(value) {
490
- if (typeof value === 'string' && value !== 'auto') {
491
- const thickness = parseShorthandPositioning(value);
492
- return [
493
- [topProperty, masonLengthPercentParse(thickness.top)],
494
- [rightProperty, masonLengthPercentParse(thickness.right)],
495
- [bottomProperty, masonLengthPercentParse(thickness.bottom)],
496
- [leftProperty, masonLengthPercentParse(thickness.left)],
497
- ];
498
- }
499
- else {
500
- return [
501
- [topProperty, value],
502
- [rightProperty, value],
503
- [bottomProperty, value],
504
- [leftProperty, value],
505
- ];
506
92
  }
507
- }
508
- export const leftProperty = new CssProperty({
509
- name: 'left',
510
- cssName: 'left',
511
- defaultValue: 'auto',
512
- // @ts-ignore
513
- equalityComparer: NSLength.equals,
514
- valueConverter: masonLengthParse,
515
- valueChanged(target, oldValue, newValue) {
516
- const view = getViewStyle(target.viewRef);
517
- if (view) {
518
- view.left = newValue;
519
- }
520
- },
521
- });
522
- export const rightProperty = new CssProperty({
523
- name: 'right',
524
- cssName: 'right',
525
- defaultValue: 'auto',
526
- // @ts-ignore
527
- equalityComparer: NSLength.equals,
528
- valueConverter: masonLengthParse,
529
- valueChanged(target, oldValue, newValue) {
530
- const view = getViewStyle(target.viewRef);
531
- if (view) {
532
- view.right = newValue;
533
- }
534
- },
535
- });
536
- export const topProperty = new CssProperty({
537
- name: 'top',
538
- cssName: 'top',
539
- defaultValue: 'auto',
540
- // @ts-ignore
541
- equalityComparer: NSLength.equals,
542
- valueConverter: masonLengthParse,
543
- valueChanged(target, oldValue, newValue) {
544
- const view = getViewStyle(target.viewRef);
545
- if (view) {
546
- view.top = newValue;
547
- }
548
- },
549
- });
550
- export const bottomProperty = new CssProperty({
551
- name: 'bottom',
552
- cssName: 'bottom',
553
- defaultValue: 'auto',
554
- // @ts-ignore
555
- equalityComparer: NSLength.equals,
556
- valueConverter: masonLengthParse,
557
- valueChanged(target, oldValue, newValue) {
558
- const view = getViewStyle(target.viewRef);
559
- if (view) {
560
- view.bottom = newValue;
561
- }
562
- },
563
- });
564
- export const flexBasisProperty = new CssProperty({
565
- name: 'flexBasis',
566
- cssName: 'flex-basis',
567
- defaultValue: 'auto',
568
- equalityComparer: NSLength.equals,
569
- valueConverter: masonLengthParse,
570
- valueChanged(target, oldValue, newValue) {
571
- const view = getViewStyle(target.viewRef);
572
- if (view) {
573
- view.flexBasis = newValue;
574
- }
575
- },
576
- });
577
- export const gridRowGapProperty = new ShorthandProperty({
578
- name: 'gridRowGap',
579
- cssName: 'grid-row-gap',
580
- getter: function () {
581
- return this.rowGap;
582
- },
583
- converter(value) {
584
- return [[rowGapProperty, value]];
585
- },
586
- });
587
- export const gridColumnGapProperty = new ShorthandProperty({
588
- name: 'gridColumnGap',
589
- cssName: 'grid-column-gap',
590
- getter: function () {
591
- return this.columnGap;
592
- },
593
- converter(value) {
594
- return [[columnGapProperty, value]];
595
- },
596
- });
597
- export const aspectRatioProperty = new CssProperty({
598
- name: 'aspectRatio',
599
- cssName: 'aspect-ratio',
600
- defaultValue: Number.NaN,
601
- valueChanged(target, oldValue, newValue) {
602
- const view = getViewStyle(target.viewRef);
603
- if (view) {
604
- view.aspectRatio = newValue;
605
- }
606
- },
607
- });
608
- export const alignItemsProperty = new CssProperty({
609
- name: 'alignItems',
610
- cssName: 'align-items',
611
- defaultValue: 'normal',
612
- valueChanged(target, oldValue, newValue) {
613
- const view = getViewStyle(target.viewRef);
614
- if (view) {
615
- view.alignItems = newValue;
616
- }
617
- },
618
- });
619
- export const alignSelfProperty = new CssProperty({
620
- name: 'alignSelf',
621
- cssName: 'align-self',
622
- defaultValue: 'normal',
623
- valueChanged(target, oldValue, newValue) {
624
- const view = getViewStyle(target.viewRef);
625
- if (view) {
626
- view.alignSelf = newValue;
627
- }
628
- },
629
- });
630
- export const alignContentProperty = new CssProperty({
631
- name: 'alignContent',
632
- cssName: 'align-content',
633
- defaultValue: 'normal',
634
- valueChanged(target, oldValue, newValue) {
635
- const view = getViewStyle(target.viewRef);
636
- if (view) {
637
- view.alignContent = newValue;
638
- }
639
- },
640
- });
641
- export const justifyItemsProperty = new CssProperty({
642
- name: 'justifyItems',
643
- cssName: 'justify-items',
644
- defaultValue: 'normal',
645
- valueChanged(target, oldValue, newValue) {
646
- const view = getViewStyle(target.viewRef);
647
- if (view) {
648
- view.justifyItems = newValue;
649
- }
650
- },
651
- });
652
- export const justifySelfProperty = new CssProperty({
653
- name: 'justifySelf',
654
- cssName: 'justify-self',
655
- defaultValue: 'normal',
656
- valueChanged(target, oldValue, newValue) {
657
- const view = getViewStyle(target.viewRef);
658
- if (view) {
659
- view.justifySelf = newValue;
660
- }
661
- },
662
- });
663
- export const justifyContentProperty = new CssProperty({
664
- name: 'justifyContent',
665
- cssName: 'justify-content',
666
- defaultValue: 'normal',
667
- valueChanged(target, oldValue, newValue) {
668
- const view = getViewStyle(target.viewRef);
669
- if (view) {
670
- view.justifyContent = newValue;
671
- }
672
- },
673
- });
674
- export const gridAutoRowsProperty = new CssProperty({
675
- name: 'gridAutoRows',
676
- cssName: 'grid-auto-rows',
677
- defaultValue: '',
678
- valueChanged(target, oldValue, newValue) {
679
- const view = getViewStyle(target.viewRef);
680
- if (view) {
681
- view.gridAutoRows = newValue;
682
- }
683
- },
684
- });
685
- export const gridAutoColumnsProperty = new CssProperty({
686
- name: 'gridAutoColumns',
687
- cssName: 'grid-auto-columns',
688
- defaultValue: '',
689
- valueChanged(target, oldValue, newValue) {
690
- const view = getViewStyle(target.viewRef);
691
- if (view) {
692
- view.gridAutoColumns = newValue;
693
- }
694
- },
695
- });
696
- export const gridAutoFlowProperty = new CssProperty({
697
- name: 'gridAutoFlow',
698
- cssName: 'grid-auto-flow',
699
- defaultValue: 'row',
700
- valueChanged(target, oldValue, newValue) {
701
- const view = getViewStyle(target.viewRef);
702
- if (view) {
703
- view.gridAutoFlow = newValue;
704
- }
705
- },
706
- });
707
- export const gridAreaProperty = new CssProperty({
708
- name: 'gridArea',
709
- cssName: 'grid-area',
710
- defaultValue: '',
711
- valueChanged(target, oldValue, newValue) {
712
- const view = getViewStyle(target.viewRef);
713
- if (view) {
714
- view.gridArea = newValue;
715
- }
716
- },
717
- });
718
- export const gridColumnStartProperty = new CssProperty({
719
- name: 'gridColumnStart',
720
- cssName: 'grid-column-start',
721
- defaultValue: 'auto',
722
- valueChanged(target, oldValue, newValue) {
723
- const view = getViewStyle(target.viewRef);
724
- if (view) {
725
- view.gridColumnStart = newValue;
726
- }
727
- },
728
- });
729
- export const gridColumnEndProperty = new CssProperty({
730
- name: 'gridColumnEnd',
731
- cssName: 'grid-column-end',
732
- defaultValue: 'auto',
733
- valueChanged(target, oldValue, newValue) {
734
- const view = getViewStyle(target.viewRef);
735
- if (view) {
736
- view.gridColumnEnd = newValue;
737
- }
738
- },
739
- });
740
- export const gridColumnProperty = new CssProperty({
741
- name: 'gridColumn',
742
- cssName: 'grid-column',
743
- defaultValue: '',
744
- valueChanged(target, oldValue, newValue) {
745
- const view = getViewStyle(target.viewRef);
746
- if (view) {
747
- view.gridColumn = newValue;
748
- }
749
- },
750
- });
751
- export const gridRowStartProperty = new CssProperty({
752
- name: 'gridRowStart',
753
- cssName: 'grid-row-start',
754
- defaultValue: 'auto',
755
- valueChanged(target, oldValue, newValue) {
756
- const view = getViewStyle(target.viewRef);
757
- if (view) {
758
- view.gridRowStart = newValue;
759
- }
760
- },
761
- });
762
- export const gridRowEndProperty = new CssProperty({
763
- name: 'gridRowEnd',
764
- cssName: 'grid-row-end',
765
- defaultValue: 'auto',
766
- valueChanged(target, oldValue, newValue) {
767
- const view = getViewStyle(target.viewRef);
768
- if (view) {
769
- view.gridRowEnd = newValue;
770
- }
771
- },
772
- });
773
- export const gridRowProperty = new CssProperty({
774
- name: 'gridRow',
775
- cssName: 'grid-row',
776
- defaultValue: '',
777
- valueChanged(target, oldValue, newValue) {
778
- const view = getViewStyle(target.viewRef);
779
- if (view) {
780
- view.gridRow = newValue;
781
- }
782
- },
783
- });
784
- export const gridTemplateAreasProperty = new CssProperty({
785
- name: 'gridTemplateAreas',
786
- cssName: 'grid-template-areas',
787
- defaultValue: null,
788
- valueChanged(target, oldValue, newValue) {
789
- const view = getViewStyle(target.viewRef);
790
- if (view) {
791
- view.gridTemplateAreas = newValue;
792
- }
793
- },
794
- });
795
- export const gridTemplateRowsProperty = new CssProperty({
796
- name: 'gridTemplateRows',
797
- cssName: 'grid-template-rows',
798
- defaultValue: null,
799
- valueChanged(target, oldValue, newValue) {
800
- const view = getViewStyle(target.viewRef);
801
- if (view) {
802
- view.gridTemplateRows = newValue;
803
- }
804
- },
805
- });
806
- export const gridTemplateColumnsProperty = new CssProperty({
807
- name: 'gridTemplateColumns',
808
- cssName: 'grid-template-columns',
809
- defaultValue: null,
810
- valueChanged(target, oldValue, newValue) {
811
- const view = getViewStyle(target.viewRef);
812
- if (view) {
813
- view.gridTemplateColumns = newValue;
814
- }
815
- },
816
- });
817
- // flex-flow: <flex-direction> || <flex-wrap>
818
- const flexFlowProperty = new ShorthandProperty({
819
- name: 'flexFlow',
820
- cssName: 'flex-flow',
821
- getter: function () {
822
- return `${this.flexDirection} ${this.flexWrap}`;
823
- },
824
- converter: function (value) {
825
- const properties = [];
826
- if (value === unsetValue) {
827
- properties.push([flexDirectionProperty, value]);
828
- properties.push([flexWrapProperty, value]);
93
+ _unregisterNativeEvent(arg, callback, thisArg) {
94
+ const id = callback['mason:event:id'];
95
+ if (!this[native_]) {
96
+ this._pendingEventsRegistration = this._pendingEventsRegistration.filter((registration) => {
97
+ return !(registration.arg === arg && registration.callback === callback && registration.thisArg === thisArg);
98
+ });
99
+ return;
829
100
  }
830
- else {
831
- const trimmed = value && value.trim();
832
- if (trimmed) {
833
- const values = trimmed.split(/\s+/);
834
- if (values.length >= 1) {
835
- properties.push([flexDirectionProperty, values[0]]);
836
- }
837
- if (value.length >= 2) {
838
- properties.push([flexWrapProperty, values[1]]);
101
+ //@ts-ignore
102
+ if (this._view) {
103
+ if (__ANDROID__) {
104
+ if (!id) {
105
+ //@ts-ignore
106
+ const removed = this._view.removeEventListener(arg, id);
107
+ callback['mason:event:id'] = undefined;
839
108
  }
840
109
  }
841
- }
842
- return properties;
843
- },
844
- });
845
- // flex: inital | auto | none | <flex-grow> <flex-shrink> || <flex-basis>
846
- const flexProperty = new ShorthandProperty({
847
- name: 'flex',
848
- cssName: 'flex',
849
- getter: function () {
850
- return `${this.flexGrow} ${this.flexShrink} ${this.flexBasis}`;
851
- },
852
- converter: function (value) {
853
- const properties = [];
854
- if (value === unsetValue) {
855
- properties.push([flexGrowProperty, value]);
856
- properties.push([flexShrinkProperty, value]);
857
- }
858
- else if (typeof value === 'number') {
859
- properties.push([flexGrowProperty, value]);
860
- properties.push([flexShrinkProperty, 1]);
861
- properties.push([flexBasisProperty, 'auto']);
862
- }
863
- else {
864
- const trimmed = value && value.trim();
865
- if (trimmed) {
866
- const values = trimmed.split(/\s+/);
867
- if (values.length === 1) {
868
- switch (values[0]) {
869
- case 'inital':
870
- properties.push([flexGrowProperty, 0]);
871
- properties.push([flexShrinkProperty, 1]);
872
- properties.push([flexBasisProperty, 'auto']);
873
- break;
874
- case 'auto':
875
- properties.push([flexGrowProperty, 1]);
876
- properties.push([flexShrinkProperty, 1]);
877
- properties.push([flexBasisProperty, 'auto']);
878
- break;
879
- case 'none':
880
- properties.push([flexGrowProperty, 0]);
881
- properties.push([flexShrinkProperty, 0]);
882
- properties.push([flexBasisProperty, 'auto']);
883
- break;
884
- default:
885
- properties.push([flexGrowProperty, values[0]]);
886
- properties.push([flexShrinkProperty, 1]);
887
- properties.push([flexBasisProperty, 'auto']);
888
- }
889
- }
890
- if (values.length >= 2) {
891
- properties.push([flexGrowProperty, values[0]]);
892
- properties.push([flexShrinkProperty, values[1]]);
893
- }
894
- if (value.length >= 3) {
895
- properties.push({ property: flexBasisProperty, value: values[2] });
110
+ if (__APPLE__) {
111
+ if (!id) {
112
+ //@ts-ignore
113
+ const removed = this._view.mason_removeEventListenerId(arg, id);
114
+ callback['mason:event:id'] = undefined;
896
115
  }
897
116
  }
898
117
  }
899
- return properties;
900
- },
901
- });
902
- // @ts-ignore
903
- export const textWrapProperty = new CssProperty({
904
- name: 'textWrap',
905
- affectsLayout: true,
906
- defaultValue: 'nowrap',
907
- valueChanged(target, oldValue, newValue) {
908
- const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
909
- if (view) {
910
- view.textWrap = newValue;
911
- }
912
- },
913
- });
914
- // @ts-ignore
915
- export const textOverFlowProperty = new CssProperty({
916
- name: 'textOverflow',
917
- defaultValue: 'text-overflow',
918
- valueChanged(target, oldValue, newValue) {
919
- const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
920
- if (view) {
921
- view.textOverflow = newValue;
922
- }
923
- },
924
- });
925
- export const textContentProperty = new Property({
926
- name: 'textContent',
927
- affectsLayout: true,
928
- defaultValue: '',
929
- });
930
- export const boxSizingProperty = new CssProperty({
931
- name: 'boxSizing',
932
- cssName: 'box-sizing',
933
- defaultValue: 'border-box',
934
- valueChanged(target, oldValue, newValue) {
935
- const view = getViewStyle(target.viewRef);
936
- if (view) {
937
- if (newValue) {
938
- view.boxSizing = newValue;
939
- }
940
- else {
941
- // Revert to old value if newValue is invalid
942
- view.view.style.boxSizing = oldValue;
118
+ }
119
+ initNativeView() {
120
+ super.initNativeView();
121
+ if (this._pendingEventsRegistration.length > 0) {
122
+ const pending = this._pendingEventsRegistration.splice(0);
123
+ for (const registration of pending) {
124
+ this._registerNativeEvent(registration.arg, registration.callback, registration.thisArg);
943
125
  }
944
126
  }
945
- },
946
- valueConverter(value) {
947
- switch (value) {
948
- case 'content-box':
949
- case 'border-box':
950
- return value;
951
- default:
952
- return undefined;
127
+ }
128
+ addEventListener(arg, callback, thisArg) {
129
+ if (typeof thisArg === 'boolean') {
130
+ thisArg = {
131
+ capture: thisArg,
132
+ };
953
133
  }
954
- },
955
- });
956
- const borderRadiusProperty = new CssProperty({
957
- name: 'borderRadius',
958
- cssName: 'border-radius',
959
- });
960
- borderRadiusProperty.register(Style);
961
- export const verticalAlignProperty = new CssProperty({
962
- name: 'verticalAlign',
963
- cssName: 'vertical-align',
964
- defaultValue: 'baseline',
965
- valueChanged: (target, oldValue, newValue) => {
966
- const view = getViewStyle(target.viewRef);
967
- if (view) {
968
- if (newValue) {
969
- view.verticalAlign = newValue;
970
- }
971
- else {
972
- // Revert to old value if newValue is invalid
973
- view.view.style.verticalAlign = oldValue;
974
- }
134
+ super.addEventListener(arg, callback, thisArg);
135
+ if (typeof arg !== 'string') {
136
+ return;
975
137
  }
976
- },
977
- });
978
- verticalAlignProperty.register(Style);
979
- verticalAlignmentProperty.overrideHandlers({
980
- name: 'verticalAlignment',
981
- cssName: 'vertical-align',
982
- valueConverter: function (value) {
983
- return value;
984
- },
985
- valueChanged(target, oldValue, newValue) {
986
- const view = getViewStyle(target.viewRef);
987
- if (view) {
988
- if (newValue) {
989
- // @ts-ignore
990
- view.verticalAlign = newValue;
991
- }
992
- else {
993
- // Revert to old value if newValue is invalid
994
- // @ts-ignore
995
- view.view.style.verticalAlign = oldValue;
996
- }
138
+ switch (arg) {
139
+ case 'input':
140
+ case 'change':
141
+ this._registerNativeEvent(arg, callback, thisArg);
142
+ break;
997
143
  }
998
- },
999
- });
1000
- textShadowProperty.overrideHandlers({
1001
- name: 'textShadow',
1002
- cssName: 'text-shadow',
1003
- valueConverter: function (value) {
1004
- return value;
1005
- },
1006
- valueChanged(target, oldValue, newValue) {
1007
- const view = getViewStyle(target.viewRef);
1008
- if (view) {
1009
- view.textShadow = newValue;
144
+ }
145
+ removeEventListener(arg, callback, thisArg) {
146
+ if (typeof thisArg === 'boolean') {
147
+ thisArg = {
148
+ capture: thisArg,
149
+ };
1010
150
  }
1011
- else {
1012
- // Revert to old value if newValue is invalid
1013
- // @ts-ignore
1014
- view.view.style.verticalAlign = oldValue;
151
+ super.removeEventListener(arg, callback, thisArg);
152
+ switch (arg) {
153
+ case 'input':
154
+ case 'change':
155
+ this._unregisterNativeEvent(arg, callback, thisArg);
156
+ break;
1015
157
  }
1016
- },
1017
- });
1018
- export class ViewBase extends CustomLayoutView {
1019
- constructor() {
1020
- super();
1021
- this._children = [];
1022
- this[_a] = false;
1023
- this[_b] = false;
1024
- this[_c] = false;
1025
158
  }
1026
159
  forceStyleUpdate() {
1027
160
  _forceStyleUpdate(this);
@@ -1078,11 +211,11 @@ export class ViewBase extends CustomLayoutView {
1078
211
  if (child && child[isPlaceholder_] && child._view) {
1079
212
  if (__ANDROID__) {
1080
213
  //@ts-ignore
1081
- this._view.addChildAt(child._view, this._children.length);
214
+ this._view.append(child._view);
1082
215
  }
1083
216
  if (__APPLE__) {
1084
217
  //@ts-ignore
1085
- this._view.mason_addChildAtNode(child._view, this._children.length);
218
+ this._view.mason_append(child._view);
1086
219
  }
1087
220
  if (this[isText_]) {
1088
221
  child[isTextChild_] = true;
@@ -1112,6 +245,20 @@ export class ViewBase extends CustomLayoutView {
1112
245
  }
1113
246
  this._children.push(child);
1114
247
  }
248
+ else if (child instanceof TextNode) {
249
+ //@ts-ignore
250
+ if (this._view) {
251
+ if (__ANDROID__) {
252
+ //@ts-ignore
253
+ this._view.addChildAt(child[native_], this._children.length);
254
+ }
255
+ if (__APPLE__) {
256
+ //@ts-ignore
257
+ this._view.mason_addChildAtNode(child[native_], this._children.length);
258
+ }
259
+ }
260
+ this._children.push(child);
261
+ }
1115
262
  }
1116
263
  }
1117
264
  insertChild(child, atIndex) {
@@ -1201,25 +348,175 @@ export class ViewBase extends CustomLayoutView {
1201
348
  }
1202
349
  this._children.splice(0);
1203
350
  }
351
+ [(_a = isMasonView_, _b = isTextChild_, _c = isText_, zIndexProperty.setNative)](value) {
352
+ // @ts-ignore
353
+ const style = this._styleHelper;
354
+ if (style) {
355
+ // @ts-ignore
356
+ style.zIndex = value;
357
+ }
358
+ }
359
+ set verticalAlign(value) {
360
+ this.style.verticalAlign = value;
361
+ }
362
+ get verticalAlign() {
363
+ return this.style.verticalAlign;
364
+ }
365
+ [verticalAlignProperty.setNative](value) {
366
+ // @ts-ignore
367
+ const style = this._styleHelper;
368
+ if (style) {
369
+ // @ts-ignore
370
+ style.verticalAlign = value;
371
+ }
372
+ }
373
+ set flex(value) {
374
+ this.style.flex = value;
375
+ }
376
+ get flex() {
377
+ return this.style.flex;
378
+ }
379
+ set textWrap(value) {
380
+ this.style.textWrap = value;
381
+ }
382
+ get textWrap() {
383
+ return this.style.textWrap;
384
+ }
385
+ [textWrapProperty.setNative](value) {
386
+ // @ts-ignore
387
+ const style = this._styleHelper;
388
+ if (style) {
389
+ // @ts-ignore
390
+ style.textWrap = value;
391
+ }
392
+ }
393
+ set aspectRatio(value) {
394
+ this.style.aspectRatio = value;
395
+ }
396
+ get aspectRatio() {
397
+ return this.style.aspectRatio;
398
+ }
399
+ [aspectRatioProperty.setNative](value) {
400
+ // @ts-ignore
401
+ const style = this._styleHelper;
402
+ if (style) {
403
+ // @ts-ignore
404
+ style.aspectRatio = value;
405
+ }
406
+ }
407
+ _updateTextNode(node, operation = null) {
408
+ let textNode;
409
+ if (__ANDROID__) {
410
+ if (node[textNode_]) {
411
+ node[textNode_].setData(node.text ?? '');
412
+ textNode = node[textNode_];
413
+ }
414
+ else {
415
+ textNode = new org.nativescript.mason.masonkit.TextNode(Tree.instance.native, node.text ?? '');
416
+ node[textNode_] = textNode;
417
+ }
418
+ if (operation) {
419
+ switch (operation.type) {
420
+ case 'add':
421
+ //@ts-ignore
422
+ this._view.addChildAt(textNode, this._children.length);
423
+ //@ts-ignore
424
+ this._children.push({ [text_]: node.text, [textNode_]: textNode, [textNodeIndex_]: this._children.length });
425
+ break;
426
+ case 'replace':
427
+ //@ts-ignore
428
+ this._view.replaceChildAt(textNode, operation.index);
429
+ if (this._children.length >= operation.index) {
430
+ //@ts-ignore
431
+ this._children[operation.index] = { text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index };
432
+ }
433
+ else {
434
+ //@ts-ignore
435
+ this._children.push({ text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index });
436
+ }
437
+ break;
438
+ case 'insert':
439
+ //@ts-ignore
440
+ this._view.addChildAt(textNode, operation.index);
441
+ if (this._children.length >= operation.index) {
442
+ //@ts-ignore
443
+ this._children[operation.index] = { text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index };
444
+ }
445
+ else {
446
+ //@ts-ignore
447
+ this._children.push({ text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index });
448
+ }
449
+ break;
450
+ }
451
+ }
452
+ }
453
+ if (__APPLE__) {
454
+ if (node[textNode_]) {
455
+ node[textNode_].data = node.text;
456
+ textNode = node[textNode_];
457
+ if (operation && 'index' in operation && node[textNodeIndex_] === operation.index) {
458
+ return;
459
+ }
460
+ }
461
+ else {
462
+ textNode = MasonTextNode.alloc().initWithMasonDataAttributes(Tree.instance.native, node.text, null);
463
+ node[textNode_] = textNode;
464
+ node[textNodeIndex_] = operation?.index ?? this._children.length;
465
+ }
466
+ if (operation) {
467
+ switch (operation.type) {
468
+ case 'add':
469
+ //@ts-ignore
470
+ this._view.mason_addChildAtNode(textNode, this._children.length);
471
+ //@ts-ignore
472
+ this._children.push({ [text_]: node.text, [textNode_]: textNode, [textNodeIndex_]: this._children.length });
473
+ break;
474
+ case 'replace':
475
+ //@ts-ignore
476
+ this._view.mason_replaceChildAtNode(textNode, operation.index);
477
+ if (this._children.length >= operation.index) {
478
+ //@ts-ignore
479
+ this._children[operation.index] = { text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index };
480
+ }
481
+ else {
482
+ //@ts-ignore
483
+ this._children.push({ text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index });
484
+ }
485
+ break;
486
+ case 'insert':
487
+ //@ts-ignore
488
+ this._view.mason_addChildAtNode(textNode, operation.index);
489
+ if (this._children.length >= operation.index) {
490
+ //@ts-ignore
491
+ this._children[operation.index] = { text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index };
492
+ }
493
+ else {
494
+ //@ts-ignore
495
+ this._children.push({ text: node.text, [textNode_]: textNode, [textNodeIndex_]: operation.index });
496
+ }
497
+ break;
498
+ }
499
+ }
500
+ }
501
+ }
1204
502
  set text(value) {
1205
- if (frameWork === FrameWork.Vue && global.VUE3_ELEMENT_REF) {
1206
- const view_ref = this[global.VUE3_ELEMENT_REF];
503
+ if ((frameWork === 2 /* FrameWork.Vue */ && global.VUE3_ELEMENT_REF) || (frameWork === 3 /* FrameWork.React */ && global.REACT_ELEMENT_REF)) {
504
+ const view_ref = this[global.VUE3_ELEMENT_REF] ?? this[global.REACT_ELEMENT_REF];
1207
505
  if (Array.isArray(view_ref.childNodes)) {
1208
506
  if (view_ref.childNodes.length === 0) {
1209
- this.addChild({ [text_]: value });
507
+ this.replaceChild({ [text_]: value }, 0);
1210
508
  return;
1211
509
  }
1212
510
  if (view_ref.childNodes.length === 1) {
1213
511
  const node = view_ref.childNodes[0];
1214
512
  if (node && node.nodeType === 'text') {
1215
- this.addChild({ [text_]: node.text });
513
+ this._updateTextNode(node, { type: 'add' });
1216
514
  }
1217
515
  return;
1218
516
  }
1219
517
  view_ref.childNodes.forEach((node, index) => {
1220
518
  if (node.nodeType === 'text') {
1221
- // nativeView.replaceChildAt(node.text, index);
1222
- this.replaceChild({ [text_]: node.text }, index);
519
+ this._updateTextNode(node, { type: 'replace', index, isBreak: node.nodeName === 'br' });
1223
520
  }
1224
521
  });
1225
522
  }
@@ -1241,18 +538,29 @@ export class ViewBase extends CustomLayoutView {
1241
538
  const existing = this._children[index];
1242
539
  if (existing && Object.is(existing['node'], node)) {
1243
540
  // todo direct set text
1244
- this.replaceChild({ [text_]: node.text, node }, index);
541
+ this._updateTextNode(node, { type: 'replace', index });
1245
542
  continue;
1246
543
  }
1247
- this.replaceChild({ [text_]: node.text, node }, index);
544
+ this._updateTextNode(node, { type: 'replace', index });
1248
545
  }
1249
546
  else if (node.nodeName === 'br') {
1250
- this.replaceChild(node, index);
547
+ this._updateTextNode(node, { type: 'replace', index, isBreak: true });
1251
548
  }
1252
549
  }
550
+ return;
1253
551
  }
552
+ if ('textContent' in this) {
553
+ // @ts-ignore
554
+ this.textContent = value;
555
+ }
556
+ }
557
+ get filter() {
558
+ return this.style.filter;
559
+ }
560
+ set filter(value) {
561
+ this.style.filter = value;
1254
562
  }
1255
- [(_a = isMasonView_, _b = isTextChild_, _c = isText_, filterProperty.setNative)](value) {
563
+ [filterProperty.setNative](value) {
1256
564
  // @ts-ignore
1257
565
  const style = this._styleHelper;
1258
566
  if (style) {
@@ -1260,6 +568,13 @@ export class ViewBase extends CustomLayoutView {
1260
568
  style.filter = value;
1261
569
  }
1262
570
  }
571
+ // @ts-ignore
572
+ set borderRadius(value) {
573
+ this.style.borderRadius = value;
574
+ }
575
+ get borderRadius() {
576
+ return this.style.borderRadius;
577
+ }
1263
578
  [borderRadiusProperty.setNative](value) {
1264
579
  // @ts-ignore
1265
580
  const style = this._styleHelper;
@@ -1268,6 +583,12 @@ export class ViewBase extends CustomLayoutView {
1268
583
  style.borderRadius = value;
1269
584
  }
1270
585
  }
586
+ set border(value) {
587
+ this.style.border = value;
588
+ }
589
+ get border() {
590
+ return this.style.border;
591
+ }
1271
592
  [borderProperty.setNative](value) {
1272
593
  // @ts-ignore
1273
594
  const style = this._styleHelper;
@@ -1276,6 +597,13 @@ export class ViewBase extends CustomLayoutView {
1276
597
  style.border = value;
1277
598
  }
1278
599
  }
600
+ // @ts-ignore
601
+ set background(value) {
602
+ this.style.background = value;
603
+ }
604
+ get background() {
605
+ return this.style.background;
606
+ }
1279
607
  [backgroundProperty.setNative](value) {
1280
608
  // @ts-ignore
1281
609
  const style = this._styleHelper;
@@ -1373,34 +701,83 @@ export class ViewBase extends CustomLayoutView {
1373
701
  set boxSizing(value) {
1374
702
  this.style.boxSizing = value;
1375
703
  }
704
+ [boxSizingProperty.setNative](value) {
705
+ // @ts-ignore
706
+ const style = this._styleHelper;
707
+ if (style) {
708
+ // @ts-ignore
709
+ style.boxSizing = value;
710
+ }
711
+ }
1376
712
  get display() {
1377
713
  return this.style.display;
1378
714
  }
1379
715
  set display(value) {
1380
716
  this.style.display = value;
1381
717
  }
718
+ [displayProperty.setNative](value) {
719
+ // @ts-ignore
720
+ const style = this._styleHelper;
721
+ if (style) {
722
+ // @ts-ignore
723
+ style.display = value;
724
+ }
725
+ }
726
+ get overflow() {
727
+ return this.style.overflow;
728
+ }
729
+ set overflow(value) {
730
+ this.style.overflow = value;
731
+ }
1382
732
  get overflowX() {
1383
733
  return this.style.overflowX;
1384
734
  }
1385
735
  set overflowX(value) {
1386
736
  this.style.overflowX = value;
1387
737
  }
738
+ [overflowXProperty.setNative](value) {
739
+ // @ts-ignore
740
+ const style = this._styleHelper;
741
+ if (style) {
742
+ // @ts-ignore
743
+ style.overflowX = value;
744
+ }
745
+ }
1388
746
  get overflowY() {
1389
747
  return this.style.overflowY;
1390
748
  }
1391
749
  set overflowY(value) {
1392
750
  this.style.overflowY = value;
1393
751
  }
752
+ [overflowYProperty.setNative](value) {
753
+ // @ts-ignore
754
+ const style = this._styleHelper;
755
+ if (style) {
756
+ // @ts-ignore
757
+ style.overflowY = value;
758
+ }
759
+ }
1394
760
  get scrollBarWidth() {
1395
761
  return this.style.scrollBarWidth;
1396
762
  }
1397
763
  set scrollBarWidth(value) {
1398
764
  this.style.scrollBarWidth = value;
1399
765
  }
766
+ [scrollBarWidthProperty.setNative](value) {
767
+ // @ts-ignore
768
+ const style = this._styleHelper;
769
+ if (style) {
770
+ // @ts-ignore
771
+ style.scrollBarWidth = value;
772
+ }
773
+ }
1400
774
  get position() {
1401
775
  return this.style.position;
1402
776
  }
1403
777
  set position(value) {
778
+ this.style.position = value;
779
+ }
780
+ [positionProperty.setNative](value) {
1404
781
  // @ts-ignore
1405
782
  const style = this._styleHelper;
1406
783
  if (style) {
@@ -1467,6 +844,12 @@ export class ViewBase extends CustomLayoutView {
1467
844
  style.alignSelf = value;
1468
845
  }
1469
846
  }
847
+ get alignContent() {
848
+ return this.style.alignContent;
849
+ }
850
+ set alignContent(value) {
851
+ this.style.alignContent = value;
852
+ }
1470
853
  [alignContentProperty.setNative](value) {
1471
854
  // @ts-ignore
1472
855
  const style = this._styleHelper;
@@ -1474,6 +857,12 @@ export class ViewBase extends CustomLayoutView {
1474
857
  style.alignContent = value;
1475
858
  }
1476
859
  }
860
+ get justifyItems() {
861
+ return this.style.justifyItems;
862
+ }
863
+ set justifyItems(value) {
864
+ this.style.justifyItems = value;
865
+ }
1477
866
  [justifyItemsProperty.setNative](value) {
1478
867
  // @ts-ignore
1479
868
  const style = this._styleHelper;
@@ -1481,6 +870,12 @@ export class ViewBase extends CustomLayoutView {
1481
870
  style.justifyItems = value;
1482
871
  }
1483
872
  }
873
+ get justifySelf() {
874
+ return this.style.justifySelf;
875
+ }
876
+ set justifySelf(value) {
877
+ this.style.justifySelf = value;
878
+ }
1484
879
  [justifySelfProperty.setNative](value) {
1485
880
  // @ts-ignore
1486
881
  const style = this._styleHelper;
@@ -1502,6 +897,12 @@ export class ViewBase extends CustomLayoutView {
1502
897
  style.left = value;
1503
898
  }
1504
899
  }
900
+ get right() {
901
+ return this.style.right;
902
+ }
903
+ set right(value) {
904
+ this.style.right = value;
905
+ }
1505
906
  [rightProperty.setNative](value) {
1506
907
  // @ts-ignore
1507
908
  const style = this._styleHelper;
@@ -1509,6 +910,12 @@ export class ViewBase extends CustomLayoutView {
1509
910
  style.right = value;
1510
911
  }
1511
912
  }
913
+ get bottom() {
914
+ return this.style.bottom;
915
+ }
916
+ set bottom(value) {
917
+ this.style.bottom = value;
918
+ }
1512
919
  [bottomProperty.setNative](value) {
1513
920
  // @ts-ignore
1514
921
  const style = this._styleHelper;
@@ -1563,6 +970,20 @@ export class ViewBase extends CustomLayoutView {
1563
970
  get maxHeight() {
1564
971
  return this.style.maxHeight;
1565
972
  }
973
+ [maxWidthProperty.setNative](value) {
974
+ // @ts-ignore
975
+ const style = this._styleHelper;
976
+ if (style) {
977
+ style.maxWidth = value;
978
+ }
979
+ }
980
+ [maxHeightProperty.setNative](value) {
981
+ // @ts-ignore
982
+ const style = this._styleHelper;
983
+ if (style) {
984
+ style.maxHeight = value;
985
+ }
986
+ }
1566
987
  _redrawNativeBackground(value) { }
1567
988
  [marginProperty.setNative](value) {
1568
989
  // @ts-ignore
@@ -1606,6 +1027,12 @@ export class ViewBase extends CustomLayoutView {
1606
1027
  style.marginTop = value;
1607
1028
  }
1608
1029
  }
1030
+ get padding() {
1031
+ return this.style.padding;
1032
+ }
1033
+ set padding(value) {
1034
+ this.style.padding = value;
1035
+ }
1609
1036
  [paddingProperty.setNative](value) {
1610
1037
  // @ts-ignore
1611
1038
  const style = this._styleHelper;
@@ -1645,67 +1072,228 @@ export class ViewBase extends CustomLayoutView {
1645
1072
  style.paddingBottom = value;
1646
1073
  }
1647
1074
  }
1075
+ set gap(value) {
1076
+ this.style.gap = value;
1077
+ }
1078
+ get gap() {
1079
+ return this.style.gap;
1080
+ }
1081
+ set gridGap(value) {
1082
+ this.style.gridGap = value;
1083
+ }
1084
+ get gridGap() {
1085
+ return this.style.gridGap;
1086
+ }
1648
1087
  set rowGap(value) {
1649
1088
  this.style.rowGap = value;
1650
1089
  }
1651
1090
  get rowGap() {
1652
1091
  return this.style.rowGap;
1653
1092
  }
1093
+ [rowGapProperty.setNative](value) {
1094
+ // @ts-ignore
1095
+ const style = this._styleHelper;
1096
+ if (style) {
1097
+ // @ts-ignore
1098
+ style.rowGap = value;
1099
+ }
1100
+ }
1654
1101
  set columnGap(value) {
1655
1102
  this.style.columnGap = value;
1656
1103
  }
1657
1104
  get columnGap() {
1658
1105
  return this.style.columnGap;
1659
1106
  }
1107
+ [columnGapProperty.setNative](value) {
1108
+ // @ts-ignore
1109
+ const style = this._styleHelper;
1110
+ if (style) {
1111
+ // @ts-ignore
1112
+ style.columnGap = value;
1113
+ }
1114
+ }
1660
1115
  set gridColumnStart(value) {
1661
1116
  this.style.gridColumnStart = value;
1662
1117
  }
1663
1118
  get gridColumnStart() {
1664
1119
  return this.style.gridColumnStart;
1665
1120
  }
1121
+ [gridColumnStartProperty.setNative](value) {
1122
+ // @ts-ignore
1123
+ const style = this._styleHelper;
1124
+ if (style) {
1125
+ // @ts-ignore
1126
+ style.gridColumnStart = value;
1127
+ }
1128
+ }
1666
1129
  set gridColumnEnd(value) {
1667
1130
  this.style.gridColumnEnd = value;
1668
1131
  }
1669
1132
  get gridColumnEnd() {
1670
1133
  return this.style.gridColumnEnd;
1671
1134
  }
1135
+ [gridColumnEndProperty.setNative](value) {
1136
+ // @ts-ignore
1137
+ const style = this._styleHelper;
1138
+ if (style) {
1139
+ // @ts-ignore
1140
+ style.gridColumnEnd = value;
1141
+ }
1142
+ }
1143
+ get gridColumn() {
1144
+ return this.style.gridColumn;
1145
+ }
1146
+ set gridColumn(value) {
1147
+ this.style.gridColumn = value;
1148
+ }
1149
+ [gridColumnProperty.setNative](value) {
1150
+ // @ts-ignore
1151
+ const style = this._styleHelper;
1152
+ if (style) {
1153
+ // @ts-ignore
1154
+ style.gridColumn = value;
1155
+ }
1156
+ }
1672
1157
  set gridRowStart(value) {
1673
1158
  this.style.gridRowStart = value;
1674
1159
  }
1675
1160
  get gridRowStart() {
1676
1161
  return this.style.gridRowStart;
1677
1162
  }
1163
+ [gridRowStartProperty.setNative](value) {
1164
+ // @ts-ignore
1165
+ const style = this._styleHelper;
1166
+ if (style) {
1167
+ // @ts-ignore
1168
+ style.gridRowStart = value;
1169
+ }
1170
+ }
1678
1171
  set gridRowEnd(value) {
1679
1172
  this.style.gridRowEnd = value;
1680
1173
  }
1681
1174
  get gridRowEnd() {
1682
1175
  return this.style.gridRowEnd;
1683
1176
  }
1177
+ [gridRowEndProperty.setNative](value) {
1178
+ // @ts-ignore
1179
+ const style = this._styleHelper;
1180
+ if (style) {
1181
+ // @ts-ignore
1182
+ style.gridRowEnd = value;
1183
+ }
1184
+ }
1185
+ get gridRow() {
1186
+ return this.style.gridRow;
1187
+ }
1188
+ set gridRow(value) {
1189
+ this.style.gridRow = value;
1190
+ }
1191
+ [gridRowProperty.setNative](value) {
1192
+ // @ts-ignore
1193
+ const style = this._styleHelper;
1194
+ if (style) {
1195
+ // @ts-ignore
1196
+ style.gridRow = value;
1197
+ }
1198
+ }
1684
1199
  set gridTemplateRows(value) {
1685
1200
  this.style.gridTemplateRows = value;
1686
1201
  }
1687
1202
  get gridTemplateRows() {
1688
1203
  return this.style.gridTemplateRows;
1689
1204
  }
1205
+ [gridTemplateRowsProperty.setNative](value) {
1206
+ // @ts-ignore
1207
+ const style = this._styleHelper;
1208
+ if (style) {
1209
+ // @ts-ignore
1210
+ style.gridTemplateRows = value;
1211
+ }
1212
+ }
1690
1213
  set gridTemplateColumns(value) {
1691
1214
  this.style.gridTemplateColumns = value;
1692
1215
  }
1693
1216
  get gridTemplateColumns() {
1694
1217
  return this.style.gridTemplateColumns;
1695
1218
  }
1219
+ [gridTemplateColumnsProperty.setNative](value) {
1220
+ // @ts-ignore
1221
+ const style = this._styleHelper;
1222
+ if (style) {
1223
+ // @ts-ignore
1224
+ style.gridTemplateColumns = value;
1225
+ }
1226
+ }
1696
1227
  set gridAutoColumns(value) {
1697
1228
  this.style.gridAutoColumns = value;
1698
1229
  }
1699
1230
  get gridAutoColumns() {
1700
1231
  return this.style.gridAutoColumns;
1701
1232
  }
1233
+ [gridAutoColumnsProperty.setNative](value) {
1234
+ // @ts-ignore
1235
+ const style = this._styleHelper;
1236
+ if (style) {
1237
+ // @ts-ignore
1238
+ style.gridAutoColumns = value;
1239
+ }
1240
+ }
1702
1241
  set gridAutoRows(value) {
1703
1242
  this.style.gridAutoRows = value;
1704
1243
  }
1705
1244
  get gridAutoRows() {
1706
1245
  return this.style.gridAutoRows;
1707
1246
  }
1708
- // @ts-ignore
1247
+ [gridAutoRowsProperty.setNative](value) {
1248
+ // @ts-ignore
1249
+ const style = this._styleHelper;
1250
+ if (style) {
1251
+ // @ts-ignore
1252
+ style.gridAutoRows = value;
1253
+ }
1254
+ }
1255
+ set gridAutoFlow(value) {
1256
+ this.style.gridAutoFlow = value;
1257
+ }
1258
+ get gridAutoFlow() {
1259
+ return this.style.gridAutoFlow;
1260
+ }
1261
+ [gridAutoFlowProperty.setNative](value) {
1262
+ // @ts-ignore
1263
+ const style = this._styleHelper;
1264
+ if (style) {
1265
+ // @ts-ignore
1266
+ style.gridAutoFlow = value;
1267
+ }
1268
+ }
1269
+ set gridArea(value) {
1270
+ this.style.gridArea = value;
1271
+ }
1272
+ get gridArea() {
1273
+ return this.style.gridArea;
1274
+ }
1275
+ [gridAreaProperty.setNative](value) {
1276
+ // @ts-ignore
1277
+ const style = this._styleHelper;
1278
+ if (style) {
1279
+ // @ts-ignore
1280
+ style.gridArea = value;
1281
+ }
1282
+ }
1283
+ set gridTemplateAreas(value) {
1284
+ this.style.gridTemplateAreas = value;
1285
+ }
1286
+ get gridTemplateAreas() {
1287
+ return this.style.gridTemplateAreas;
1288
+ }
1289
+ [gridTemplateAreasProperty.setNative](value) {
1290
+ // @ts-ignore
1291
+ const style = this._styleHelper;
1292
+ if (style) {
1293
+ // @ts-ignore
1294
+ style.gridTemplateAreas = value;
1295
+ }
1296
+ }
1709
1297
  [fontSizeProperty.setNative](value) {
1710
1298
  // @ts-ignore
1711
1299
  if (this._styleHelper) {
@@ -1727,12 +1315,57 @@ export class ViewBase extends CustomLayoutView {
1727
1315
  this._styleHelper.fontStyle = value;
1728
1316
  }
1729
1317
  }
1318
+ set flexFlowProperty(value) {
1319
+ this.style.flexFlow = value;
1320
+ }
1321
+ get flexFlowProperty() {
1322
+ return this.style.flexFlow;
1323
+ }
1324
+ set inset(value) {
1325
+ this.style.inset = value;
1326
+ }
1327
+ get inset() {
1328
+ return this.style.inset;
1329
+ }
1330
+ set textOverFlow(value) {
1331
+ this.style.textOverFlow = value;
1332
+ }
1333
+ get textOverFlow() {
1334
+ return this.style.textOverFlow;
1335
+ }
1336
+ [textOverFlowProperty.setNative](value) {
1337
+ // @ts-ignore
1338
+ const style = this._styleHelper;
1339
+ if (style) {
1340
+ // @ts-ignore
1341
+ style.textOverFlow = value;
1342
+ }
1343
+ }
1730
1344
  }
1731
1345
  export class TextBase extends ViewBase {
1346
+ [textWrapProperty.setNative](value) {
1347
+ // @ts-ignore
1348
+ const style = this._styleHelper;
1349
+ if (style) {
1350
+ switch (value) {
1351
+ case 'false':
1352
+ case false:
1353
+ case 'nowrap':
1354
+ style.textWrap = 1 /* MasonTextWrap.NoWrap */;
1355
+ break;
1356
+ case true:
1357
+ case 'true':
1358
+ case 'wrap':
1359
+ style.textWrap = 0 /* MasonTextWrap.Wrap */;
1360
+ break;
1361
+ case 'balance':
1362
+ style.textWrap = 2 /* MasonTextWrap.Balance */;
1363
+ break;
1364
+ }
1365
+ }
1366
+ }
1732
1367
  }
1733
- textContentProperty.register(TextBase);
1734
- textWrapProperty.register(Style);
1735
- textOverFlowProperty.register(Style);
1368
+ textContentProperty.register(ViewBase);
1736
1369
  export class ButtonBase extends TextBase {
1737
1370
  }
1738
1371
  // @ts-ignore
@@ -1743,351 +1376,156 @@ export const srcProperty = new Property({
1743
1376
  export class ImageBase extends ViewBase {
1744
1377
  }
1745
1378
  srcProperty.register(ImageBase);
1746
- /**
1747
- * Props are already defined in core flexbox layout,
1748
- * overriding them breaks the core flexbox layout.
1749
- */
1750
- // flexDirectionProperty.register(Style);
1751
- // flexWrapProperty.register(Style);
1752
- // flexGrowProperty.register(Style);
1753
- flexShrinkProperty.register(Style);
1754
- // revert valueConverter if causing issues with core components
1755
- fontSizeProperty.overrideHandlers({
1756
- name: 'fontSize',
1757
- cssName: 'font-size',
1758
- valueConverter: function (value) {
1759
- return value;
1760
- },
1761
- valueChanged(target, oldValue, newValue) {
1762
- const view = getViewStyle(target.viewRef);
1763
- if (view) {
1764
- if (newValue) {
1765
- if (typeof newValue === 'string') {
1766
- // @ts-ignore
1767
- if (newValue.indexOf('%') !== -1) {
1768
- view.fontSize = {
1769
- value: parseFloat(newValue) / 100,
1770
- unit: '%',
1771
- };
1772
- // @ts-ignore
1773
- }
1774
- else if (newValue.indexOf('dip') !== -1) {
1775
- view.fontSize = parseFloat(newValue);
1776
- // @ts-ignore
1777
- }
1778
- else if (newValue.indexOf('px') !== -1) {
1779
- view.fontSize = {
1780
- value: parseFloat(newValue),
1781
- unit: 'px',
1782
- };
1783
- }
1784
- else {
1785
- view.fontSize = parseFloat(newValue);
1786
- }
1787
- }
1788
- else {
1789
- view.fontSize = newValue;
1790
- }
1791
- }
1792
- else {
1793
- // Revert to old value if newValue is invalid
1794
- // @ts-ignore
1795
- view.view.style.fontSize = oldValue;
1796
- }
1379
+ export class Event {
1380
+ get bubbles() {
1381
+ if (__ANDROID__) {
1382
+ return this[native_]?.getBubbles();
1797
1383
  }
1798
- },
1799
- });
1800
- marginLeftProperty.overrideHandlers({
1801
- name: 'marginLeft',
1802
- cssName: 'margin-left',
1803
- valueChanged(target, oldValue, newValue) {
1804
- const view = getViewStyle(target.viewRef);
1805
- if (view) {
1806
- if (newValue) {
1807
- view.marginLeft = newValue;
1808
- }
1809
- else {
1810
- // Revert to old value if newValue is invalid
1811
- // @ts-ignore
1812
- view.view.style.marginLeft = oldValue;
1813
- }
1384
+ if (__APPLE__) {
1385
+ return this[native_]?.bubbles;
1814
1386
  }
1815
- },
1816
- });
1817
- marginTopProperty.overrideHandlers({
1818
- name: 'marginTop',
1819
- cssName: 'margin-top',
1820
- valueChanged(target, oldValue, newValue) {
1821
- const view = getViewStyle(target.viewRef);
1822
- if (view) {
1823
- if (newValue) {
1824
- view.marginTop = newValue;
1825
- }
1826
- else {
1827
- // Revert to old value if newValue is invalid
1828
- // @ts-ignore
1829
- view.view.style.marginTop = oldValue;
1830
- }
1387
+ return false;
1388
+ }
1389
+ get cancelable() {
1390
+ if (__ANDROID__) {
1391
+ return this[native_]?.getCancelable();
1831
1392
  }
1832
- },
1833
- });
1834
- marginRightProperty.overrideHandlers({
1835
- name: 'marginRight',
1836
- cssName: 'margin-right',
1837
- valueChanged(target, oldValue, newValue) {
1838
- const view = getViewStyle(target.viewRef);
1839
- if (view) {
1840
- if (newValue) {
1841
- view.marginRight = newValue;
1842
- }
1843
- else {
1844
- // Revert to old value if newValue is invalid
1845
- // @ts-ignore
1846
- view.view.style.marginRight = oldValue;
1847
- }
1393
+ if (__APPLE__) {
1394
+ return this[native_]?.cancelable;
1848
1395
  }
1849
- },
1850
- });
1851
- marginBottomProperty.overrideHandlers({
1852
- name: 'marginBottom',
1853
- cssName: 'margin-bottom',
1854
- valueChanged(target, oldValue, newValue) {
1855
- const view = getViewStyle(target.viewRef);
1856
- if (view) {
1857
- if (newValue) {
1858
- view.marginBottom = newValue;
1859
- }
1860
- else {
1861
- // Revert to old value if newValue is invalid
1862
- // @ts-ignore
1863
- view.view.style.marginBottom = oldValue;
1864
- }
1396
+ return false;
1397
+ }
1398
+ get isComposing() {
1399
+ if (__ANDROID__) {
1400
+ return this[native_]?.getIsComposing();
1865
1401
  }
1866
- },
1867
- });
1868
- paddingLeftProperty.overrideHandlers({
1869
- name: 'paddingLeft',
1870
- cssName: 'padding-left',
1871
- valueChanged(target, oldValue, newValue) {
1872
- const view = getViewStyle(target.viewRef);
1873
- if (view) {
1874
- if (newValue) {
1875
- view.paddingLeft = newValue;
1876
- }
1877
- else {
1878
- // Revert to old value if newValue is invalid
1879
- // @ts-ignore
1880
- view.view.style.paddingLeft = oldValue;
1881
- }
1402
+ if (__APPLE__) {
1403
+ return this[native_]?.isComposing;
1882
1404
  }
1883
- },
1884
- });
1885
- paddingTopProperty.overrideHandlers({
1886
- name: 'paddingTop',
1887
- cssName: 'padding-top',
1888
- valueChanged(target, oldValue, newValue) {
1889
- const view = getViewStyle(target.viewRef);
1890
- if (view) {
1891
- if (newValue) {
1892
- view.paddingTop = newValue;
1893
- }
1894
- else {
1895
- // Revert to old value if newValue is invalid
1896
- // @ts-ignore
1897
- view.view.style.paddingTop = oldValue;
1898
- }
1405
+ return false;
1406
+ }
1407
+ get timeStamp() {
1408
+ if (__ANDROID__) {
1409
+ return this[native_]?.getTimeStamp();
1899
1410
  }
1900
- },
1901
- });
1902
- paddingRightProperty.overrideHandlers({
1903
- name: 'paddingRight',
1904
- cssName: 'padding-right',
1905
- valueChanged(target, oldValue, newValue) {
1906
- const view = getViewStyle(target.viewRef);
1907
- if (view) {
1908
- if (newValue) {
1909
- view.paddingRight = newValue;
1910
- }
1911
- else {
1912
- // Revert to old value if newValue is invalid
1913
- // @ts-ignore
1914
- view.view.style.paddingRight = oldValue;
1915
- }
1411
+ if (__APPLE__) {
1412
+ return this[native_]?.timeStamp;
1916
1413
  }
1917
- },
1918
- });
1919
- paddingBottomProperty.overrideHandlers({
1920
- name: 'paddingBottom',
1921
- cssName: 'padding-bottom',
1922
- valueChanged(target, oldValue, newValue) {
1923
- const view = getViewStyle(target.viewRef);
1924
- if (view) {
1925
- if (newValue) {
1926
- view.paddingBottom = newValue;
1927
- }
1928
- else {
1929
- // Revert to old value if newValue is invalid
1930
- // @ts-ignore
1931
- view.view.style.paddingBottom = oldValue;
1932
- }
1414
+ return false;
1415
+ }
1416
+ get defaultPrevented() {
1417
+ if (__ANDROID__) {
1418
+ return this[native_]?.getDefaultPrevented();
1933
1419
  }
1934
- },
1935
- });
1936
- flexDirectionProperty.overrideHandlers({
1937
- name: 'flexDirection',
1938
- cssName: 'flex-direction',
1939
- valueChanged(target, oldValue, newValue) {
1940
- const view = getViewStyle(target.viewRef);
1941
- if (view) {
1942
- if (newValue) {
1943
- view.flexDirection = newValue;
1944
- }
1945
- else {
1946
- // Revert to old value if newValue is invalid
1947
- // @ts-ignore
1948
- view.view.style.flexDirection = oldValue;
1949
- }
1420
+ if (__APPLE__) {
1421
+ return this[native_]?.defaultPrevented;
1950
1422
  }
1951
- },
1952
- });
1953
- flexWrapProperty.overrideHandlers({
1954
- name: 'flexWrap',
1955
- cssName: 'flex-wrap',
1956
- valueChanged(target, oldValue, newValue) {
1957
- const view = getViewStyle(target.viewRef);
1958
- if (view) {
1959
- if (newValue) {
1960
- view.flexWrap = newValue;
1961
- }
1962
- else {
1963
- // Revert to old value if newValue is invalid
1964
- // @ts-ignore
1965
- view.view.style.flexWrap = oldValue;
1966
- }
1423
+ return false;
1424
+ }
1425
+ get propagationStopped() {
1426
+ if (__ANDROID__) {
1427
+ return this[native_]?.getPropagationStopped();
1967
1428
  }
1968
- },
1969
- });
1970
- flexGrowProperty.overrideHandlers({
1971
- name: 'flexGrow',
1972
- cssName: 'flex-grow',
1973
- valueChanged(target, oldValue, newValue) {
1974
- const view = getViewStyle(target.viewRef);
1975
- if (view) {
1976
- if (newValue) {
1977
- view.flexGrow = newValue;
1429
+ if (__APPLE__) {
1430
+ return this[native_]?.propagationStopped;
1431
+ }
1432
+ return false;
1433
+ }
1434
+ get immediatePropagationStopped() {
1435
+ if (__ANDROID__) {
1436
+ return this[native_]?.getImmediatePropagationStopped();
1437
+ }
1438
+ if (__APPLE__) {
1439
+ return this[native_]?.immediatePropagationStopped;
1440
+ }
1441
+ return false;
1442
+ }
1443
+ get currentTarget() {
1444
+ if (__ANDROID__) {
1445
+ return this[native_]?.getCurrentTarget();
1446
+ }
1447
+ if (__APPLE__) {
1448
+ return this[native_]?.currentTarget;
1449
+ }
1450
+ return false;
1451
+ }
1452
+ stopImmediatePropagation() {
1453
+ if (__ANDROID__) {
1454
+ return this[native_]?.stopImmediatePropagation();
1455
+ }
1456
+ if (__APPLE__) {
1457
+ return this[native_]?.stopImmediatePropagation();
1458
+ }
1459
+ }
1460
+ stopPropagation() {
1461
+ if (__ANDROID__) {
1462
+ return this[native_]?.stopPropagation();
1463
+ }
1464
+ if (__APPLE__) {
1465
+ return this[native_]?.stopPropagation();
1466
+ }
1467
+ }
1468
+ preventDefault() {
1469
+ if (__ANDROID__) {
1470
+ return this[native_]?.preventDefault();
1471
+ }
1472
+ if (__APPLE__) {
1473
+ return this[native_]?.preventDefault();
1474
+ }
1475
+ }
1476
+ get type() {
1477
+ if (__ANDROID__) {
1478
+ return this[native_]?.getType();
1479
+ }
1480
+ return this[native_]?.type;
1481
+ }
1482
+ get target() {
1483
+ return this['_target'];
1484
+ }
1485
+ }
1486
+ export class InputEvent extends Event {
1487
+ get data() {
1488
+ if (__ANDROID__) {
1489
+ if (this[native_] instanceof org.nativescript.mason.masonkit.events.FileInputEvent) {
1490
+ const data = this[native_]?.getRawData();
1491
+ if (!data) {
1492
+ return null;
1493
+ }
1494
+ const ret = [];
1495
+ const size = data.size();
1496
+ for (let i = 0; i < size; i++) {
1497
+ ret.push(data.get(i).toString());
1498
+ }
1499
+ return ret;
1978
1500
  }
1979
- else {
1980
- // Revert to old value if newValue is invalid
1981
- // @ts-ignore
1982
- view.view.style.flexGrow = oldValue;
1501
+ return this[native_]?.getData();
1502
+ }
1503
+ if (__APPLE__) {
1504
+ if (this[native_] instanceof MasonFileInputEvent) {
1505
+ const data = this[native_]?.rawData;
1506
+ if (!data) {
1507
+ return null;
1508
+ }
1509
+ const ret = [];
1510
+ const size = data.count;
1511
+ for (let i = 0; i < size; i++) {
1512
+ const item = data.objectAtIndex(i);
1513
+ ret.push(item.absoluteString);
1514
+ }
1515
+ return ret;
1983
1516
  }
1517
+ return this[native_]?.data;
1984
1518
  }
1985
- },
1986
- });
1987
- insetProperty.register(Style);
1988
- boxSizingProperty.register(Style);
1989
- alignItemsProperty.register(Style);
1990
- alignSelfProperty.register(Style);
1991
- justifyContentProperty.register(Style);
1992
- displayProperty.register(Style);
1993
- maxWidthProperty.register(Style);
1994
- maxHeightProperty.register(Style);
1995
- positionProperty.register(Style);
1996
- leftProperty.register(Style);
1997
- rightProperty.register(Style);
1998
- topProperty.register(Style);
1999
- bottomProperty.register(Style);
2000
- flexBasisProperty.register(Style);
2001
- rowGapProperty.register(Style);
2002
- columnGapProperty.register(Style);
2003
- gridRowGapProperty.register(Style);
2004
- gridColumnGapProperty.register(Style);
2005
- gapProperty.register(Style);
2006
- gridGapProperty.register(Style);
2007
- aspectRatioProperty.register(Style);
2008
- alignContentProperty.register(Style);
2009
- justifyItemsProperty.register(Style);
2010
- justifySelfProperty.register(Style);
2011
- gridAutoRowsProperty.register(Style);
2012
- gridAutoColumnsProperty.register(Style);
2013
- gridAutoFlowProperty.register(Style);
2014
- gridAreaProperty.register(Style);
2015
- gridColumnProperty.register(Style);
2016
- gridColumnStartProperty.register(Style);
2017
- gridColumnEndProperty.register(Style);
2018
- gridRowProperty.register(Style);
2019
- gridRowStartProperty.register(Style);
2020
- gridRowEndProperty.register(Style);
2021
- gridTemplateRowsProperty.register(Style);
2022
- gridTemplateColumnsProperty.register(Style);
2023
- gridTemplateAreasProperty.register(Style);
2024
- overflowProperty.register(Style);
2025
- overflowXProperty.register(Style);
2026
- overflowYProperty.register(Style);
2027
- scrollBarWidthProperty.register(Style);
2028
- flexFlowProperty.register(Style);
2029
- flexProperty.register(Style);
2030
- function parseShorthandPositioning(value) {
2031
- const arr = value.split(/[ ,]+/);
2032
- let top;
2033
- let right;
2034
- let bottom;
2035
- let left;
2036
- if (arr.length === 1) {
2037
- top = arr[0];
2038
- right = arr[0];
2039
- bottom = arr[0];
2040
- left = arr[0];
2041
- }
2042
- else if (arr.length === 2) {
2043
- top = arr[0];
2044
- bottom = arr[0];
2045
- right = arr[1];
2046
- left = arr[1];
2047
- }
2048
- else if (arr.length === 3) {
2049
- top = arr[0];
2050
- right = arr[1];
2051
- left = arr[1];
2052
- bottom = arr[2];
2053
- }
2054
- else if (arr.length === 4) {
2055
- top = arr[0];
2056
- right = arr[1];
2057
- bottom = arr[2];
2058
- left = arr[3];
2059
- }
2060
- else {
2061
- throw new Error('Expected 1, 2, 3 or 4 parameters. Actual: ' + value);
2062
- }
2063
- return {
2064
- top: top,
2065
- right: right,
2066
- bottom: bottom,
2067
- left: left,
2068
- };
2069
- }
2070
- function convertToPaddings(value) {
2071
- if (typeof value === 'string' && value !== 'auto') {
2072
- const thickness = parseShorthandPositioning(value);
2073
- return [
2074
- [paddingTopProperty, CoreLength.parse(thickness.top)],
2075
- [paddingRightProperty, CoreLength.parse(thickness.right)],
2076
- [paddingBottomProperty, CoreLength.parse(thickness.bottom)],
2077
- [paddingLeftProperty, CoreLength.parse(thickness.left)],
2078
- ];
2079
- }
2080
- else {
2081
- return [
2082
- [paddingTopProperty, value],
2083
- [paddingRightProperty, value],
2084
- [paddingBottomProperty, value],
2085
- [paddingLeftProperty, value],
2086
- ];
1519
+ return false;
1520
+ }
1521
+ get inputType() {
1522
+ if (__ANDROID__) {
1523
+ return this[native_]?.getInputType();
1524
+ }
1525
+ if (__APPLE__) {
1526
+ return this[native_]?.inputType;
1527
+ }
1528
+ return false;
2087
1529
  }
2088
1530
  }
2089
- paddingLeftProperty.register(Style);
2090
- paddingRightProperty.register(Style);
2091
- paddingTopProperty.register(Style);
2092
- paddingBottomProperty.register(Style);
2093
1531
  //# sourceMappingURL=common.js.map