@triniwiz/nativescript-masonkit 1.0.0-alpha.34 → 1.0.0-alpha.35
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.
- package/common.d.ts +140 -0
- package/common.js +1728 -0
- package/common.js.map +1 -0
- package/img/index.android.d.ts +10 -0
- package/img/index.android.js +40 -0
- package/img/index.android.js.map +1 -0
- package/img/index.ios.d.ts +13 -0
- package/img/index.ios.js +102 -0
- package/img/index.ios.js.map +1 -0
- package/index.android.d.ts +5 -0
- package/index.android.js +6 -0
- package/index.android.js.map +1 -0
- package/index.ios.d.ts +5 -0
- package/index.ios.js +6 -0
- package/index.ios.js.map +1 -0
- package/package.json +1 -1
- package/platforms/android/masonkit-release.aar +0 -0
- package/scroll/index.android.d.ts +12 -0
- package/scroll/index.android.js +50 -0
- package/scroll/index.android.js.map +1 -0
- package/scroll/index.ios.d.ts +14 -0
- package/scroll/index.ios.js +120 -0
- package/scroll/index.ios.js.map +1 -0
- package/style.d.ts +222 -0
- package/style.js +2521 -0
- package/style.js.map +1 -0
- package/text/index.android.d.ts +30 -0
- package/text/index.android.js +124 -0
- package/text/index.android.js.map +1 -0
- package/text/index.ios.d.ts +38 -0
- package/text/index.ios.js +252 -0
- package/text/index.ios.js.map +1 -0
- package/tree/index.android.d.ts +27 -0
- package/tree/index.android.js +74 -0
- package/tree/index.android.js.map +1 -0
- package/tree/index.ios.d.ts +28 -0
- package/tree/index.ios.js +73 -0
- package/tree/index.ios.js.map +1 -0
- package/utils/index.android.d.ts +187 -0
- package/utils/index.android.js +515 -0
- package/utils/index.android.js.map +1 -0
- package/utils/index.ios.d.ts +198 -0
- package/utils/index.ios.js +710 -0
- package/utils/index.ios.js.map +1 -0
- package/view/index.android.d.ts +12 -0
- package/view/index.android.js +50 -0
- package/view/index.android.js.map +1 -0
- package/view/index.ios.d.ts +16 -0
- package/view/index.ios.js +123 -0
- package/view/index.ios.js.map +1 -0
- package/web.d.ts +55 -0
- package/web.js +189 -0
- package/web.js.map +1 -0
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
import { Length, Utils } from '@nativescript/core';
|
|
2
|
+
import { isMasonView_, style_ } from '../common';
|
|
3
|
+
import { parseUnit } from '@nativescript/core/css/parser';
|
|
4
|
+
// if (__ANDROID__) {
|
|
5
|
+
// try {
|
|
6
|
+
// java.lang.System.loadLibrary('masonnative');
|
|
7
|
+
// __non_webpack_require__('system_lib://libmasonnativev8.so');
|
|
8
|
+
// UseV8Module = true;
|
|
9
|
+
// } catch (error) {
|
|
10
|
+
// console.warn('Failed to enable on FastAPI');
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
13
|
+
// if (__APPLE__) {
|
|
14
|
+
// NSCMason.alwaysEnable = true;
|
|
15
|
+
// if (!UseV8Module) {
|
|
16
|
+
// try {
|
|
17
|
+
// const installer = MasonV8Module.new();
|
|
18
|
+
// installer.install();
|
|
19
|
+
// UseV8Module = true;
|
|
20
|
+
// } catch (error) {
|
|
21
|
+
// console.warn('Failed to enable on FastAPI');
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
let sharedMason = null;
|
|
26
|
+
function getNode(instance) {
|
|
27
|
+
const nativeView = instance?.ios;
|
|
28
|
+
if (instance[isMasonView_]) {
|
|
29
|
+
return nativeView.node;
|
|
30
|
+
}
|
|
31
|
+
if (!sharedMason) {
|
|
32
|
+
sharedMason = NSCMason.shared;
|
|
33
|
+
}
|
|
34
|
+
return sharedMason.nodeForView(nativeView, true);
|
|
35
|
+
}
|
|
36
|
+
function getStyle(instance) {
|
|
37
|
+
const nativeView = instance?.ios;
|
|
38
|
+
if (instance[isMasonView_]) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return nativeView.node.style;
|
|
41
|
+
}
|
|
42
|
+
if (!sharedMason) {
|
|
43
|
+
sharedMason = NSCMason.shared;
|
|
44
|
+
}
|
|
45
|
+
return sharedMason.nodeForView(nativeView, true).style;
|
|
46
|
+
}
|
|
47
|
+
export function _forceStyleUpdate(instance) {
|
|
48
|
+
if (!instance._hasNativeView) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// if (__ANDROID__) {
|
|
52
|
+
// const nodeOrView = getMasonInstance(instance) as org.nativescript.mason.masonkit.TextView;
|
|
53
|
+
// nodeOrView.getStyle().updateNodeAndStyle();
|
|
54
|
+
// }
|
|
55
|
+
// if (__APPLE__) {
|
|
56
|
+
// (instance.ios as MasonUIView).node.style.updateNativeStyle();
|
|
57
|
+
// }
|
|
58
|
+
}
|
|
59
|
+
export function _markDirty(instance) {
|
|
60
|
+
if (!instance._hasNativeView) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
getNode(instance).markDirty();
|
|
64
|
+
}
|
|
65
|
+
export function _isDirty(instance) {
|
|
66
|
+
if (!instance._hasNativeView) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return getNode(instance).isDirty;
|
|
70
|
+
}
|
|
71
|
+
export function _intoType(type) {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'auto':
|
|
74
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
75
|
+
case 'points':
|
|
76
|
+
return 1 /* MasonDimensionCompatType.Points */;
|
|
77
|
+
case 'percent':
|
|
78
|
+
return 2 /* MasonDimensionCompatType.Percent */;
|
|
79
|
+
default:
|
|
80
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function _parseDimension(dim) {
|
|
84
|
+
const type = dim.type;
|
|
85
|
+
const value = dim.value;
|
|
86
|
+
switch (type) {
|
|
87
|
+
case 0 /* MasonDimensionCompatType.Auto */:
|
|
88
|
+
return 'auto';
|
|
89
|
+
case 1 /* MasonDimensionCompatType.Points */:
|
|
90
|
+
return { value: value, unit: 'px' };
|
|
91
|
+
case 2 /* MasonDimensionCompatType.Percent */:
|
|
92
|
+
return { value: value, unit: '%' };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function parseLength(length, parent = 0) {
|
|
96
|
+
switch (length.unit) {
|
|
97
|
+
case '%':
|
|
98
|
+
return length.value * parent;
|
|
99
|
+
case 'dip':
|
|
100
|
+
return Utils.layout.toDevicePixels(length.value);
|
|
101
|
+
case 'px':
|
|
102
|
+
return length.value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function _parseLengthPercentage(dim) {
|
|
106
|
+
const type = dim.type;
|
|
107
|
+
const value = dim.value;
|
|
108
|
+
switch (type) {
|
|
109
|
+
case 0 /* MasonLengthPercentageCompatType.Points */:
|
|
110
|
+
return { value: value, unit: 'px' };
|
|
111
|
+
case 1 /* MasonLengthPercentageCompatType.Percent */:
|
|
112
|
+
return { value: value, unit: '%' };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export function _parseLengthPercentageAuto(dim) {
|
|
116
|
+
const type = dim.type;
|
|
117
|
+
const value = dim.value;
|
|
118
|
+
switch (type) {
|
|
119
|
+
case 0 /* MasonLengthPercentageAutoCompatType.Auto */:
|
|
120
|
+
return 'auto';
|
|
121
|
+
case 1 /* MasonLengthPercentageAutoCompatType.Points */:
|
|
122
|
+
return { value: value, unit: 'px' };
|
|
123
|
+
case 2 /* MasonLengthPercentageAutoCompatType.Percent */:
|
|
124
|
+
return { value: value, unit: '%' };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function _toMasonDimension(value) {
|
|
128
|
+
if (value === undefined || value === null) {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
if (value === 'auto') {
|
|
132
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
|
|
133
|
+
}
|
|
134
|
+
let typeOf = typeof value;
|
|
135
|
+
if (typeOf === 'number') {
|
|
136
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
137
|
+
}
|
|
138
|
+
if (typeOf === 'string') {
|
|
139
|
+
value = parseUnit(value).value;
|
|
140
|
+
typeOf = 'object';
|
|
141
|
+
}
|
|
142
|
+
if (typeOf === 'object') {
|
|
143
|
+
switch (value?.unit) {
|
|
144
|
+
case '%':
|
|
145
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonDimensionCompatType.Percent */ };
|
|
146
|
+
case 'px':
|
|
147
|
+
return { value: value.value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
148
|
+
case 'dip':
|
|
149
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { value: value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
153
|
+
}
|
|
154
|
+
export function _intoMasonDimension(value) {
|
|
155
|
+
if (value === undefined || value === null) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (value === 'auto') {
|
|
159
|
+
return MasonDimensionCompat.Auto;
|
|
160
|
+
}
|
|
161
|
+
const typeOf = typeof value;
|
|
162
|
+
if (typeOf === 'object') {
|
|
163
|
+
switch (value?.unit) {
|
|
164
|
+
case '%':
|
|
165
|
+
return MasonDimensionCompat.alloc().initWithPercent(value.value);
|
|
166
|
+
case 'px':
|
|
167
|
+
return MasonDimensionCompat.alloc().initWithPoints(value.value);
|
|
168
|
+
case 'dip':
|
|
169
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value.value));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (typeOf === 'number') {
|
|
173
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
|
|
174
|
+
}
|
|
175
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
|
|
176
|
+
}
|
|
177
|
+
export function _toLengthPercentageAuto(value) {
|
|
178
|
+
if (value === undefined || value === null) {
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
if (value === 'auto') {
|
|
182
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonLengthPercentageAutoCompatType.Auto */ };
|
|
183
|
+
}
|
|
184
|
+
const typeOf = typeof value;
|
|
185
|
+
if (typeOf === 'object') {
|
|
186
|
+
switch (value?.unit) {
|
|
187
|
+
case '%':
|
|
188
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonLengthPercentageAutoCompatType.Percent */ };
|
|
189
|
+
case 'px':
|
|
190
|
+
return { value: value.value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
191
|
+
case 'dip':
|
|
192
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (typeOf === 'number') {
|
|
196
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
197
|
+
}
|
|
198
|
+
return { value: value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
199
|
+
}
|
|
200
|
+
export function _toLengthPercentage(value) {
|
|
201
|
+
if (value === undefined || value === null) {
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
if (typeof value === 'string') {
|
|
205
|
+
const parsed = Length.parse(value);
|
|
206
|
+
if (parsed) {
|
|
207
|
+
value = parsed;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const typeOf = typeof value;
|
|
211
|
+
if (typeOf === 'object') {
|
|
212
|
+
switch (value?.unit) {
|
|
213
|
+
case '%':
|
|
214
|
+
return { value: value.value, type: 'percent', native_type: 1 /* MasonLengthPercentageCompatType.Percent */ };
|
|
215
|
+
case 'px':
|
|
216
|
+
return { value: value.value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
217
|
+
case 'dip':
|
|
218
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (typeOf === 'number') {
|
|
222
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
223
|
+
}
|
|
224
|
+
return { value: value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
225
|
+
}
|
|
226
|
+
function syncStyle(instance) {
|
|
227
|
+
// noop
|
|
228
|
+
}
|
|
229
|
+
export function _getAspectRatio(instance) {
|
|
230
|
+
if (!instance._hasNativeView) {
|
|
231
|
+
return instance.style.aspectRatio;
|
|
232
|
+
}
|
|
233
|
+
const ratio = instance._styleHelper.aspectRatio;
|
|
234
|
+
return Number.isNaN(ratio) ? null : ratio;
|
|
235
|
+
}
|
|
236
|
+
export function _parseGridLine(value) {
|
|
237
|
+
let parsedValue = undefined;
|
|
238
|
+
let parsedType = undefined;
|
|
239
|
+
if (value === 'auto' || value === undefined) {
|
|
240
|
+
parsedValue = 0;
|
|
241
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
242
|
+
}
|
|
243
|
+
if (typeof value === 'string') {
|
|
244
|
+
if (value.startsWith('span')) {
|
|
245
|
+
parsedValue = Number(value.replace('span', '').trim());
|
|
246
|
+
parsedType = 2 /* GridPlacementCompatType.Span */;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
parsedValue = Number(value.trim());
|
|
250
|
+
if (parsedValue < 1) {
|
|
251
|
+
parsedValue = 0;
|
|
252
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
parsedType = 1 /* GridPlacementCompatType.Line */;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (typeof value === 'number') {
|
|
260
|
+
parsedValue = value;
|
|
261
|
+
if (parsedValue < 1) {
|
|
262
|
+
parsedValue = 0;
|
|
263
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
parsedType = 1 /* GridPlacementCompatType.Line */;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return { value: Number.isNaN(parsedValue) ? undefined : parsedValue, type: parsedType };
|
|
270
|
+
}
|
|
271
|
+
export function _setGridColumnStart(value, instance, initial = false) {
|
|
272
|
+
if (!instance._hasNativeView) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const val = _parseGridLine(value);
|
|
276
|
+
if (val.value === undefined || val.type === undefined) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
switch (val.type) {
|
|
280
|
+
case 0 /* GridPlacementCompatType.Auto */:
|
|
281
|
+
instance.ios.gridColumnStartCompat = GridPlacementCompat.Auto;
|
|
282
|
+
break;
|
|
283
|
+
case 1 /* GridPlacementCompatType.Line */:
|
|
284
|
+
instance.ios.gridColumnStartCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
285
|
+
break;
|
|
286
|
+
case 2 /* GridPlacementCompatType.Span */:
|
|
287
|
+
instance.ios.gridColumnStartCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
export function _setGridColumnEnd(value, instance, initial = false) {
|
|
292
|
+
if (!instance._hasNativeView) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const val = _parseGridLine(value);
|
|
296
|
+
if (val.value === undefined || val.type === undefined) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
switch (val.type) {
|
|
300
|
+
case 0 /* GridPlacementCompatType.Auto */:
|
|
301
|
+
instance.ios.gridColumnEndCompat = GridPlacementCompat.Auto;
|
|
302
|
+
break;
|
|
303
|
+
case 1 /* GridPlacementCompatType.Line */:
|
|
304
|
+
instance.ios.gridColumnEndCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
305
|
+
break;
|
|
306
|
+
case 2 /* GridPlacementCompatType.Span */:
|
|
307
|
+
instance.ios.gridColumnEndCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
export function _setGridRowStart(value, instance, initial = false) {
|
|
312
|
+
if (!instance._hasNativeView) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const val = _parseGridLine(value);
|
|
316
|
+
if (val.value === undefined || val.type === undefined) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
switch (val.type) {
|
|
320
|
+
case 0 /* GridPlacementCompatType.Auto */:
|
|
321
|
+
instance.ios.gridRowStartCompat = GridPlacementCompat.Auto;
|
|
322
|
+
break;
|
|
323
|
+
case 1 /* GridPlacementCompatType.Line */:
|
|
324
|
+
instance.ios.gridRowStartCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
325
|
+
break;
|
|
326
|
+
case 2 /* GridPlacementCompatType.Span */:
|
|
327
|
+
instance.ios.gridRowStartCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export function _setGridRowEnd(value, instance, initial = false) {
|
|
332
|
+
if (!instance._hasNativeView) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const val = _parseGridLine(value);
|
|
336
|
+
if (val.value === undefined || val.type === undefined) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
switch (val.type) {
|
|
340
|
+
case 0 /* GridPlacementCompatType.Auto */:
|
|
341
|
+
instance.ios.gridRowEndCompat = GridPlacementCompat.Auto;
|
|
342
|
+
break;
|
|
343
|
+
case 1 /* GridPlacementCompatType.Line */:
|
|
344
|
+
instance.ios.gridRowEndCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
345
|
+
break;
|
|
346
|
+
case 2 /* GridPlacementCompatType.Span */:
|
|
347
|
+
instance.ios.gridRowEndCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
export function _setRowGap(value, instance, initial = false) {
|
|
352
|
+
if (!instance._hasNativeView) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
instance._styleHelper.rowGap = value;
|
|
356
|
+
}
|
|
357
|
+
export function _getRowGap(instance) {
|
|
358
|
+
if (!instance._hasNativeView) {
|
|
359
|
+
return instance.style.rowGap;
|
|
360
|
+
}
|
|
361
|
+
return instance._styleHelper.rowGap;
|
|
362
|
+
}
|
|
363
|
+
export function _setColumnGap(value, instance, initial = false) {
|
|
364
|
+
if (!instance._hasNativeView) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
instance._styleHelper.columnGap = value;
|
|
368
|
+
}
|
|
369
|
+
export function _getColumnGap(instance) {
|
|
370
|
+
if (!instance._hasNativeView) {
|
|
371
|
+
return instance.style.gap;
|
|
372
|
+
}
|
|
373
|
+
return instance._styleHelper.columnGap;
|
|
374
|
+
}
|
|
375
|
+
const Auto = 'auto';
|
|
376
|
+
const None = 'none';
|
|
377
|
+
const MinContent = 'min-content';
|
|
378
|
+
const MaxContent = 'max-content';
|
|
379
|
+
export function _parseMinMaxValue(value) {
|
|
380
|
+
if (typeof value === 'string') {
|
|
381
|
+
if (value === Auto || value === None) {
|
|
382
|
+
return {
|
|
383
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
384
|
+
min_value: 0,
|
|
385
|
+
max_type: 0 /* MaxSizingType.Auto */,
|
|
386
|
+
max_value: 0,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
else if (value === MinContent) {
|
|
390
|
+
return {
|
|
391
|
+
min_type: 1 /* MinSizingType.MinContent */,
|
|
392
|
+
min_value: 0,
|
|
393
|
+
max_type: 1 /* MaxSizingType.MinContent */,
|
|
394
|
+
max_value: 0,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
else if (value === MaxContent) {
|
|
398
|
+
return {
|
|
399
|
+
min_type: 2 /* MinSizingType.MaxContent */,
|
|
400
|
+
min_value: 0,
|
|
401
|
+
max_type: 2 /* MaxSizingType.MaxContent */,
|
|
402
|
+
max_value: 0,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
else if (value.indexOf('fr') > -1) {
|
|
406
|
+
const flex = parseInt(value.replace('fr', '').trim());
|
|
407
|
+
return {
|
|
408
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
409
|
+
min_value: 0,
|
|
410
|
+
max_type: 5 /* MaxSizingType.Fraction */,
|
|
411
|
+
max_value: flex,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
else if (value.startsWith('minmax')) {
|
|
415
|
+
// todo
|
|
416
|
+
const minMax = parseInt(value.replace('minmax(', '').replace(')', '').trim());
|
|
417
|
+
}
|
|
418
|
+
else if (value.startsWith('fit-content')) {
|
|
419
|
+
const fitContent = value.replace('fit-content(', '').replace(')', '').trim();
|
|
420
|
+
if (fitContent.indexOf('px') > -1) {
|
|
421
|
+
const px = parseInt(fitContent.replace('px', ''));
|
|
422
|
+
return {
|
|
423
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
424
|
+
min_value: px,
|
|
425
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
426
|
+
max_value: px,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (fitContent.indexOf('px') > -1) {
|
|
430
|
+
const dip = Utils.layout.toDevicePixels(parseInt(fitContent.replace('dip', '')));
|
|
431
|
+
return {
|
|
432
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
433
|
+
min_value: dip,
|
|
434
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
435
|
+
max_value: dip,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
if (fitContent.indexOf('%') > -1) {
|
|
439
|
+
const percent = parseFloat(fitContent.replace('%', ''));
|
|
440
|
+
return {
|
|
441
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
442
|
+
min_value: percent,
|
|
443
|
+
max_type: 7 /* MaxSizingType.FitContentPercent */,
|
|
444
|
+
max_value: percent,
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
else if (value.indexOf('px') > -1) {
|
|
449
|
+
const px = parseInt(value.replace('px', ''));
|
|
450
|
+
return {
|
|
451
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
452
|
+
min_value: px,
|
|
453
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
454
|
+
max_value: px,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
else if (value.indexOf('dip') > -1) {
|
|
458
|
+
const dip = Utils.layout.toDevicePixels(parseInt(value.replace('dip', '')));
|
|
459
|
+
return {
|
|
460
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
461
|
+
min_value: dip,
|
|
462
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
463
|
+
max_value: dip,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
else if (value.indexOf('%') > -1) {
|
|
467
|
+
const percent = parseFloat(value.replace('%', ''));
|
|
468
|
+
return {
|
|
469
|
+
min_type: 4 /* MinSizingType.Percent */,
|
|
470
|
+
min_value: percent,
|
|
471
|
+
max_type: 4 /* MaxSizingType.Percent */,
|
|
472
|
+
max_value: percent,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
const dip = Utils.layout.toDevicePixels(Number(value));
|
|
477
|
+
return {
|
|
478
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
479
|
+
min_value: dip,
|
|
480
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
481
|
+
max_value: dip,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (typeof value === 'number') {
|
|
486
|
+
const dip = Utils.layout.toDevicePixels(value);
|
|
487
|
+
return {
|
|
488
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
489
|
+
min_value: dip,
|
|
490
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
491
|
+
max_value: dip,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
const grid_templates_regex = /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g;
|
|
497
|
+
export function _parseGridTemplates(value) {
|
|
498
|
+
const array = [];
|
|
499
|
+
if (typeof value === 'string') {
|
|
500
|
+
const values = Array.from(value.matchAll(grid_templates_regex), (m) => m[0]);
|
|
501
|
+
values.forEach((item) => {
|
|
502
|
+
if (item.startsWith('repeat(')) {
|
|
503
|
+
const repeatValue = item.replace('repeat(', '').replace(')', '');
|
|
504
|
+
const trackEnd = repeatValue.indexOf(',');
|
|
505
|
+
const repetition = repeatValue.substring(0, trackEnd);
|
|
506
|
+
const tracks = repeatValue
|
|
507
|
+
.substring(trackEnd + 1)
|
|
508
|
+
.split(' ')
|
|
509
|
+
.filter((a) => {
|
|
510
|
+
return a.length || a.trim() === ',';
|
|
511
|
+
});
|
|
512
|
+
let isValid = true;
|
|
513
|
+
let repeating_type = 0;
|
|
514
|
+
let repeat_count = 0;
|
|
515
|
+
switch (repetition) {
|
|
516
|
+
case 'repeat-fill':
|
|
517
|
+
repeating_type = 0 /* TSCGridTrackRepetition.AutoFill */;
|
|
518
|
+
break;
|
|
519
|
+
case 'repeat-fit':
|
|
520
|
+
repeating_type = 1 /* TSCGridTrackRepetition.AutoFit */;
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
{
|
|
524
|
+
const number = parseInt(repetition);
|
|
525
|
+
repeating_type = 2 /* TSCGridTrackRepetition.Count */;
|
|
526
|
+
isValid = !Number.isNaN(number);
|
|
527
|
+
if (isValid) {
|
|
528
|
+
repeat_count = number;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
if (isValid) {
|
|
534
|
+
const tracks_array = [];
|
|
535
|
+
tracks.forEach((track) => {
|
|
536
|
+
const minMax = _parseMinMaxValue(track.trim());
|
|
537
|
+
tracks_array.push(minMax);
|
|
538
|
+
});
|
|
539
|
+
array.push({
|
|
540
|
+
is_repeating: true,
|
|
541
|
+
repeating_type,
|
|
542
|
+
repeating_count: repeat_count,
|
|
543
|
+
value: tracks_array,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
const value = _parseMinMaxValue(item);
|
|
549
|
+
array.push({
|
|
550
|
+
is_repeating: false,
|
|
551
|
+
repeating_type: 0,
|
|
552
|
+
value,
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
return array;
|
|
558
|
+
}
|
|
559
|
+
export function _setGridTemplateRows(value, instance, initial = false) {
|
|
560
|
+
if (!instance[isMasonView_]) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const length = value.length;
|
|
564
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
565
|
+
for (let i = 0; i < length; i++) {
|
|
566
|
+
const item = value[i];
|
|
567
|
+
if (item.is_repeating) {
|
|
568
|
+
const repeating = item.value;
|
|
569
|
+
const repeatingLength = repeating.length;
|
|
570
|
+
const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
|
|
571
|
+
let gridTrackRepetition = null;
|
|
572
|
+
switch (item.repeating_type) {
|
|
573
|
+
case 0 /* TSCGridTrackRepetition.AutoFill */:
|
|
574
|
+
gridTrackRepetition = MasonGridTrackRepetition.AutoFill;
|
|
575
|
+
break;
|
|
576
|
+
case 1 /* TSCGridTrackRepetition.AutoFit */:
|
|
577
|
+
gridTrackRepetition = MasonGridTrackRepetition.AutoFit;
|
|
578
|
+
break;
|
|
579
|
+
case 2 /* TSCGridTrackRepetition.Count */:
|
|
580
|
+
gridTrackRepetition = MasonGridTrackRepetition.Count(item.repeating_count);
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
if (gridTrackRepetition === null) {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
for (let j = 0; j < repeatingLength; j++) {
|
|
587
|
+
const repeat = repeating[j];
|
|
588
|
+
tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
|
|
589
|
+
}
|
|
590
|
+
const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
|
|
591
|
+
array.addObject(repeat);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
const single = item.value;
|
|
595
|
+
const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
|
|
596
|
+
array.addObject(trackSizingFunction);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
instance.ios.gridTemplateRows = array;
|
|
600
|
+
}
|
|
601
|
+
export function _setGridTemplateColumns(value, instance, initial = false) {
|
|
602
|
+
if (!instance[isMasonView_]) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
const length = value.length;
|
|
606
|
+
const array = NSMutableArray.new();
|
|
607
|
+
for (let i = 0; i < length; i++) {
|
|
608
|
+
const item = value[i];
|
|
609
|
+
if (item.is_repeating) {
|
|
610
|
+
const repeating = item.value;
|
|
611
|
+
const repeatingLength = repeating.length;
|
|
612
|
+
const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
|
|
613
|
+
let gridTrackRepetition = null;
|
|
614
|
+
switch (item.repeating_type) {
|
|
615
|
+
case 0 /* TSCGridTrackRepetition.AutoFill */:
|
|
616
|
+
gridTrackRepetition = 0 /* TSCGridTrackRepetition.AutoFill */;
|
|
617
|
+
break;
|
|
618
|
+
case 1 /* TSCGridTrackRepetition.AutoFit */:
|
|
619
|
+
gridTrackRepetition = 1 /* TSCGridTrackRepetition.AutoFit */;
|
|
620
|
+
break;
|
|
621
|
+
case 2 /* TSCGridTrackRepetition.Count */:
|
|
622
|
+
gridTrackRepetition = MasonGridTrackRepetition.Count(item.repeating_count);
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
if (gridTrackRepetition === null) {
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
for (let j = 0; j < repeatingLength; j++) {
|
|
629
|
+
const repeat = repeating[j];
|
|
630
|
+
tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
|
|
631
|
+
}
|
|
632
|
+
const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
|
|
633
|
+
array.addObject(repeat);
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
const single = item.value;
|
|
637
|
+
const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
|
|
638
|
+
array.addObject(trackSizingFunction);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
instance.ios.gridTemplateColumns = array;
|
|
642
|
+
}
|
|
643
|
+
export function _parseGridAutoRowsColumns(value) {
|
|
644
|
+
const array = [];
|
|
645
|
+
if (typeof value === 'string') {
|
|
646
|
+
const values = value.split(' ');
|
|
647
|
+
values.forEach((item) => {
|
|
648
|
+
const value = _parseMinMaxValue(item);
|
|
649
|
+
array.push({
|
|
650
|
+
is_repeating: false,
|
|
651
|
+
repeating_type: 0,
|
|
652
|
+
value,
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return array;
|
|
657
|
+
}
|
|
658
|
+
export function _setGridAutoFlow(value, instance) {
|
|
659
|
+
if (!instance[isMasonView_]) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
instance.ios.gridAutoFlow = value;
|
|
663
|
+
}
|
|
664
|
+
export function _getGridAutoFlow(instance) {
|
|
665
|
+
if (!instance[isMasonView_]) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
return this._styleHelper.gridAutoFlow;
|
|
669
|
+
}
|
|
670
|
+
export function _setGridAutoRows(value, instance, initial = false) {
|
|
671
|
+
if (!instance[isMasonView_]) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
675
|
+
const length = value.length;
|
|
676
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
677
|
+
for (let i = 0; i < length; i++) {
|
|
678
|
+
const item = value[i];
|
|
679
|
+
const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
680
|
+
array.addObject(minMax);
|
|
681
|
+
}
|
|
682
|
+
instance.ios.gridAutoRows = array;
|
|
683
|
+
}
|
|
684
|
+
export function _setGridAutoColumns(value, instance, initial = false) {
|
|
685
|
+
if (!instance[isMasonView_]) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
689
|
+
const length = value.length;
|
|
690
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
691
|
+
for (let i = 0; i < length; i++) {
|
|
692
|
+
const item = values[i];
|
|
693
|
+
const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
694
|
+
array.addObject(minMax);
|
|
695
|
+
}
|
|
696
|
+
instance.ios.gridAutoColumns = array;
|
|
697
|
+
}
|
|
698
|
+
export function _getGridTemplateRows(instance) {
|
|
699
|
+
if (!instance[isMasonView_]) {
|
|
700
|
+
return '';
|
|
701
|
+
}
|
|
702
|
+
return ''; //instance.ios.style.gridTemplateRowsCSS;
|
|
703
|
+
}
|
|
704
|
+
export function _getGridTemplateColumns(instance) {
|
|
705
|
+
if (!instance[isMasonView_]) {
|
|
706
|
+
return '';
|
|
707
|
+
}
|
|
708
|
+
return ''; //instance.ios.style.gridTemplateColumnsCSS;
|
|
709
|
+
}
|
|
710
|
+
//# sourceMappingURL=index.ios.js.map
|