@triniwiz/nativescript-masonkit 1.0.0-beta.6 → 1.0.0-beta.61
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/DOCS.md +884 -0
- package/br/index.android.d.ts +10 -0
- package/br/index.android.js +31 -0
- package/br/index.android.js.map +1 -0
- package/br/index.ios.d.ts +11 -0
- package/br/index.ios.js +30 -0
- package/br/index.ios.js.map +1 -0
- package/button/index.android.d.ts +4 -2
- package/button/index.android.js +9 -4
- package/button/index.android.js.map +1 -1
- package/button/index.ios.d.ts +4 -5
- package/button/index.ios.js +9 -66
- package/button/index.ios.js.map +1 -1
- package/common.d.ts +135 -70
- package/common.js +775 -1337
- package/common.js.map +1 -1
- package/img/index.android.d.ts +5 -4
- package/img/index.android.js +18 -6
- package/img/index.android.js.map +1 -1
- package/img/index.ios.d.ts +3 -2
- package/img/index.ios.js +23 -19
- package/img/index.ios.js.map +1 -1
- package/index.android.d.ts +4 -1
- package/index.android.js +4 -1
- package/index.android.js.map +1 -1
- package/index.d.ts +21 -1
- package/index.ios.d.ts +4 -1
- package/index.ios.js +4 -1
- package/index.ios.js.map +1 -1
- package/input/common.d.ts +20 -0
- package/input/common.js +64 -0
- package/input/common.js.map +1 -0
- package/input/index.android.d.ts +20 -0
- package/input/index.android.js +118 -0
- package/input/index.android.js.map +1 -0
- package/input/index.ios.d.ts +23 -0
- package/input/index.ios.js +163 -0
- package/input/index.ios.js.map +1 -0
- package/package.json +3 -2
- package/platforms/android/masonkit-release.aar +0 -0
- package/platforms/ios/Mason.xcframework/Info.plist +5 -5
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +281 -51
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/mason_native.h +70 -42
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Info.plist +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +39728 -27944
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +876 -247
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +876 -247
- package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7413 -4294
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +562 -102
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/mason_native.h +70 -42
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Info.plist +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +34845 -23061
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +975 -346
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +975 -346
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +34845 -23061
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +975 -346
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +975 -346
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +29 -29
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/aarch64/Mason.yml +7408 -4287
- package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/Relocations/x86_64/Mason.yml +7103 -4165
- package/properties.d.ts +49 -0
- package/properties.js +1147 -0
- package/properties.js.map +1 -0
- package/scroll/index.android.d.ts +3 -2
- package/scroll/index.android.js +16 -4
- package/scroll/index.android.js.map +1 -1
- package/scroll/index.ios.d.ts +3 -2
- package/scroll/index.ios.js +18 -5
- package/scroll/index.ios.js.map +1 -1
- package/style.d.ts +9 -5
- package/style.js +622 -367
- package/style.js.map +1 -1
- package/symbols.d.ts +10 -0
- package/symbols.js +11 -0
- package/symbols.js.map +1 -0
- package/text/index.android.d.ts +11 -5
- package/text/index.android.js +72 -103
- package/text/index.android.js.map +1 -1
- package/text/index.ios.d.ts +12 -10
- package/text/index.ios.js +69 -168
- package/text/index.ios.js.map +1 -1
- package/text-node/index.android.d.ts +13 -0
- package/text-node/index.android.js +35 -0
- package/text-node/index.android.js.map +1 -0
- package/text-node/index.ios.d.ts +13 -0
- package/text-node/index.ios.js +35 -0
- package/text-node/index.ios.js.map +1 -0
- package/tree/index.android.d.ts +10 -2
- package/tree/index.android.js +62 -1
- package/tree/index.android.js.map +1 -1
- package/tree/index.ios.d.ts +4 -1
- package/tree/index.ios.js +36 -1
- package/tree/index.ios.js.map +1 -1
- package/utils/index.android.d.ts +2 -1
- package/utils/index.android.js +1 -1
- package/utils/index.android.js.map +1 -1
- package/utils/index.ios.d.ts +2 -1
- package/utils/index.ios.js +1 -1
- package/utils/index.ios.js.map +1 -1
- package/view/index.android.d.ts +3 -2
- package/view/index.android.js +18 -4
- package/view/index.android.js.map +1 -1
- package/view/index.ios.d.ts +3 -2
- package/view/index.ios.js +18 -5
- package/view/index.ios.js.map +1 -1
- package/web.d.ts +6 -0
- package/web.js +22 -0
- package/web.js.map +1 -1
package/properties.js
ADDED
|
@@ -0,0 +1,1147 @@
|
|
|
1
|
+
import { CssProperty, Style, ShorthandProperty, Length as CoreLength, fontSizeProperty, textAlignmentProperty, PercentLength as CorePercentLength, Trace, CoreTypes, unsetValue, verticalAlignmentProperty, textShadowProperty, Font } from '@nativescript/core';
|
|
2
|
+
import { isMasonChild_, isMasonView_ } from './symbols';
|
|
3
|
+
import { alignItemsProperty, alignSelfProperty, flexDirectionProperty, flexGrowProperty, flexShrinkProperty, flexWrapProperty, justifyContentProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
|
|
4
|
+
function getViewStyle(view) {
|
|
5
|
+
const ret = (__ANDROID__ ? view.get() : view.deref());
|
|
6
|
+
return ret._styleHelper;
|
|
7
|
+
}
|
|
8
|
+
function isMasonViewOrChild(style) {
|
|
9
|
+
if (style && style.viewRef) {
|
|
10
|
+
const view = __ANDROID__ ? style.viewRef.get() : style.viewRef.deref();
|
|
11
|
+
return view && (view[isMasonView_] || view[isMasonChild_]);
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
export const displayProperty = new CssProperty({
|
|
16
|
+
name: 'display',
|
|
17
|
+
cssName: 'display',
|
|
18
|
+
defaultValue: 'block',
|
|
19
|
+
valueChanged: (target, oldValue, newValue) => {
|
|
20
|
+
const view = getViewStyle(target.viewRef);
|
|
21
|
+
if (view && newValue) {
|
|
22
|
+
view.display = newValue;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
valueConverter: function (value) {
|
|
26
|
+
if (typeof value === 'number') {
|
|
27
|
+
switch (value) {
|
|
28
|
+
case 0:
|
|
29
|
+
return 'none';
|
|
30
|
+
case 1:
|
|
31
|
+
return 'flex';
|
|
32
|
+
case 2:
|
|
33
|
+
return 'grid';
|
|
34
|
+
case 3:
|
|
35
|
+
return 'block';
|
|
36
|
+
case 4:
|
|
37
|
+
return 'inline';
|
|
38
|
+
case 5:
|
|
39
|
+
return 'inline-block';
|
|
40
|
+
case 6:
|
|
41
|
+
return 'inline-flex';
|
|
42
|
+
case 7:
|
|
43
|
+
return 'inline-grid';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
switch (value) {
|
|
47
|
+
case 'none':
|
|
48
|
+
case 'flex':
|
|
49
|
+
case 'grid':
|
|
50
|
+
case 'block':
|
|
51
|
+
case 'inline':
|
|
52
|
+
case 'inline-block':
|
|
53
|
+
case 'inline-flex':
|
|
54
|
+
case 'inline-grid':
|
|
55
|
+
return value;
|
|
56
|
+
default:
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const filterProperty = new CssProperty({
|
|
62
|
+
name: 'filter',
|
|
63
|
+
cssName: 'filter',
|
|
64
|
+
});
|
|
65
|
+
export const borderProperty = new CssProperty({
|
|
66
|
+
name: 'border',
|
|
67
|
+
cssName: 'border',
|
|
68
|
+
});
|
|
69
|
+
export const backgroundProperty = new CssProperty({
|
|
70
|
+
name: 'background',
|
|
71
|
+
cssName: 'background',
|
|
72
|
+
});
|
|
73
|
+
function overflowConverter(value) {
|
|
74
|
+
if (typeof value === 'number') {
|
|
75
|
+
switch (value) {
|
|
76
|
+
case 0:
|
|
77
|
+
return 'visible';
|
|
78
|
+
case 1:
|
|
79
|
+
return 'clip';
|
|
80
|
+
case 2:
|
|
81
|
+
return 'hidden';
|
|
82
|
+
case 3:
|
|
83
|
+
return 'scroll';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
switch (value) {
|
|
87
|
+
case 'visible':
|
|
88
|
+
case 'hidden':
|
|
89
|
+
case 'clip':
|
|
90
|
+
case 'scroll':
|
|
91
|
+
return value;
|
|
92
|
+
default:
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
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
|
+
target.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
|
+
target.overflowY = oldValue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
export const paddingProperty = new CssProperty({
|
|
166
|
+
name: 'padding',
|
|
167
|
+
cssName: 'padding',
|
|
168
|
+
});
|
|
169
|
+
paddingProperty.register(Style);
|
|
170
|
+
export const marginProperty = new CssProperty({
|
|
171
|
+
name: 'margin',
|
|
172
|
+
cssName: 'margin',
|
|
173
|
+
});
|
|
174
|
+
export const scrollBarWidthProperty = new CssProperty({
|
|
175
|
+
name: 'scrollBarWidth',
|
|
176
|
+
cssName: 'scrollbar-width',
|
|
177
|
+
defaultValue: 0,
|
|
178
|
+
valueConverter: parseFloat,
|
|
179
|
+
});
|
|
180
|
+
flexDirectionProperty.overrideHandlers({
|
|
181
|
+
name: 'flexDirection',
|
|
182
|
+
cssName: 'flex-direction',
|
|
183
|
+
valueChanged(target, oldValue, newValue) {
|
|
184
|
+
const view = getViewStyle(target.viewRef);
|
|
185
|
+
if (view) {
|
|
186
|
+
if (newValue) {
|
|
187
|
+
view.flexDirection = newValue;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// Revert to old value if newValue is invalid
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
target.flexDirection = oldValue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
flexWrapProperty.overrideHandlers({
|
|
198
|
+
name: 'flexWrap',
|
|
199
|
+
cssName: 'flex-wrap',
|
|
200
|
+
valueChanged(target, oldValue, newValue) {
|
|
201
|
+
const view = getViewStyle(target.viewRef);
|
|
202
|
+
if (view) {
|
|
203
|
+
if (newValue) {
|
|
204
|
+
view.flexWrap = newValue;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// Revert to old value if newValue is invalid
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
target.flexWrap = oldValue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
flexGrowProperty.overrideHandlers({
|
|
215
|
+
name: 'flexGrow',
|
|
216
|
+
cssName: 'flex-grow',
|
|
217
|
+
valueChanged(target, oldValue, newValue) {
|
|
218
|
+
const view = getViewStyle(target.viewRef);
|
|
219
|
+
if (view) {
|
|
220
|
+
if (newValue) {
|
|
221
|
+
view.flexGrow = newValue;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
// Revert to old value if newValue is invalid
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
target.flexGrow = oldValue;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
fontSizeProperty.overrideHandlers({
|
|
232
|
+
name: 'fontSize',
|
|
233
|
+
cssName: 'font-size',
|
|
234
|
+
valueConverter: function (value) {
|
|
235
|
+
if (isMasonViewOrChild(this)) {
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
return parseFloat(value);
|
|
239
|
+
},
|
|
240
|
+
valueChanged(target, oldValue, newValue) {
|
|
241
|
+
const view = getViewStyle(target.viewRef);
|
|
242
|
+
if (view) {
|
|
243
|
+
if (newValue) {
|
|
244
|
+
if (typeof newValue === 'string') {
|
|
245
|
+
// @ts-ignore
|
|
246
|
+
if (newValue.indexOf('%') !== -1) {
|
|
247
|
+
view.fontSize = {
|
|
248
|
+
value: parseFloat(newValue) / 100,
|
|
249
|
+
unit: '%',
|
|
250
|
+
};
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
}
|
|
253
|
+
else if (newValue.indexOf('dip') !== -1) {
|
|
254
|
+
view.fontSize = parseFloat(newValue);
|
|
255
|
+
// @ts-ignore
|
|
256
|
+
}
|
|
257
|
+
else if (newValue.indexOf('px') !== -1) {
|
|
258
|
+
view.fontSize = {
|
|
259
|
+
value: parseFloat(newValue),
|
|
260
|
+
unit: 'px',
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
view.fontSize = parseFloat(newValue);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
view.fontSize = newValue;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// Revert to old value if newValue is invalid
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
target.fontSize = oldValue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// fallback to core behavior
|
|
279
|
+
const currentFont = target.fontInternal || Font.default;
|
|
280
|
+
if (currentFont.fontSize !== newValue) {
|
|
281
|
+
const newFont = currentFont.withFontSize(newValue);
|
|
282
|
+
target.fontInternal = Font.equals(Font.default, newFont) ? unsetValue : newFont;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
export const rowGapProperty = new CssProperty({
|
|
288
|
+
name: 'rowGap',
|
|
289
|
+
cssName: 'row-gap',
|
|
290
|
+
defaultValue: 0,
|
|
291
|
+
valueConverter(value) {
|
|
292
|
+
const parsed = CoreLength.parse(value);
|
|
293
|
+
if (typeof parsed === 'string') {
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
return parsed;
|
|
297
|
+
},
|
|
298
|
+
valueChanged(target, oldValue, newValue) {
|
|
299
|
+
const view = getViewStyle(target.viewRef);
|
|
300
|
+
if (view) {
|
|
301
|
+
view.rowGap = newValue;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
export const columnGapProperty = new CssProperty({
|
|
306
|
+
name: 'columnGap',
|
|
307
|
+
cssName: 'column-gap',
|
|
308
|
+
defaultValue: 0,
|
|
309
|
+
valueConverter(value) {
|
|
310
|
+
const parsed = CoreLength.parse(value);
|
|
311
|
+
if (typeof parsed === 'string') {
|
|
312
|
+
return 0;
|
|
313
|
+
}
|
|
314
|
+
return parsed;
|
|
315
|
+
},
|
|
316
|
+
valueChanged(target, oldValue, newValue) {
|
|
317
|
+
const view = getViewStyle(target.viewRef);
|
|
318
|
+
if (view) {
|
|
319
|
+
view.columnGap = newValue;
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
export const gridGapProperty = new ShorthandProperty({
|
|
324
|
+
name: 'gridGap',
|
|
325
|
+
cssName: 'grid-gap',
|
|
326
|
+
getter: function () {
|
|
327
|
+
if (this.rowGap === this.columnGap) {
|
|
328
|
+
return this.rowGap;
|
|
329
|
+
}
|
|
330
|
+
return `${this.rowGap} ${this.columnGap}`;
|
|
331
|
+
},
|
|
332
|
+
converter(gap) {
|
|
333
|
+
const properties = [];
|
|
334
|
+
let value = gap;
|
|
335
|
+
if (typeof value === 'number') {
|
|
336
|
+
value = `${value}`;
|
|
337
|
+
}
|
|
338
|
+
if (typeof value === 'string') {
|
|
339
|
+
const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
|
|
340
|
+
const length = values.length;
|
|
341
|
+
if (length === 0) {
|
|
342
|
+
return properties;
|
|
343
|
+
}
|
|
344
|
+
if (length === 1) {
|
|
345
|
+
const row = values[0];
|
|
346
|
+
properties.push([rowGapProperty, row]);
|
|
347
|
+
properties.push([columnGapProperty, row]);
|
|
348
|
+
}
|
|
349
|
+
if (length > 1) {
|
|
350
|
+
const row = values[0];
|
|
351
|
+
const column = values[1];
|
|
352
|
+
properties.push([rowGapProperty, row]);
|
|
353
|
+
properties.push([columnGapProperty, column]);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return properties;
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
export const gapProperty = new ShorthandProperty({
|
|
360
|
+
name: 'gap',
|
|
361
|
+
cssName: 'gap',
|
|
362
|
+
getter: function () {
|
|
363
|
+
if (this.rowGap === this.columnGap) {
|
|
364
|
+
return this.rowGap;
|
|
365
|
+
}
|
|
366
|
+
return `${this.rowGap} ${this.columnGap}`;
|
|
367
|
+
},
|
|
368
|
+
converter(gap) {
|
|
369
|
+
const properties = [];
|
|
370
|
+
let value = gap;
|
|
371
|
+
if (typeof value === 'number') {
|
|
372
|
+
value = `${value}`;
|
|
373
|
+
}
|
|
374
|
+
if (typeof value === 'string') {
|
|
375
|
+
const values = value.split(/\s+/).filter((item) => item.trim().length !== 0);
|
|
376
|
+
const length = values.length;
|
|
377
|
+
if (length === 0) {
|
|
378
|
+
return properties;
|
|
379
|
+
}
|
|
380
|
+
if (length === 1) {
|
|
381
|
+
const row = values[0];
|
|
382
|
+
properties.push([rowGapProperty, row]);
|
|
383
|
+
properties.push([columnGapProperty, row]);
|
|
384
|
+
}
|
|
385
|
+
if (length > 1) {
|
|
386
|
+
const row = values[0];
|
|
387
|
+
const column = values[1];
|
|
388
|
+
properties.push([rowGapProperty, row]);
|
|
389
|
+
properties.push([columnGapProperty, column]);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return properties;
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
export const gridRowGapProperty = new ShorthandProperty({
|
|
396
|
+
name: 'gridRowGap',
|
|
397
|
+
cssName: 'grid-row-gap',
|
|
398
|
+
getter: function () {
|
|
399
|
+
return this.rowGap;
|
|
400
|
+
},
|
|
401
|
+
converter(value) {
|
|
402
|
+
return [[rowGapProperty, value]];
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
export const gridColumnGapProperty = new ShorthandProperty({
|
|
406
|
+
name: 'gridColumnGap',
|
|
407
|
+
cssName: 'grid-column-gap',
|
|
408
|
+
getter: function () {
|
|
409
|
+
return this.columnGap;
|
|
410
|
+
},
|
|
411
|
+
converter(value) {
|
|
412
|
+
return [[columnGapProperty, value]];
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
textAlignmentProperty.overrideHandlers({
|
|
416
|
+
name: 'textAlignment',
|
|
417
|
+
cssName: 'text-align',
|
|
418
|
+
valueChanged(target, oldValue, newValue) {
|
|
419
|
+
const view = getViewStyle(target.viewRef);
|
|
420
|
+
if (view) {
|
|
421
|
+
if (newValue) {
|
|
422
|
+
view.textAlignment = newValue;
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// Revert to old value if newValue is invalid
|
|
426
|
+
// @ts-ignore
|
|
427
|
+
target.textAlignment = oldValue;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
function masonLengthParse(value) {
|
|
433
|
+
try {
|
|
434
|
+
return CoreLength.parse(value);
|
|
435
|
+
}
|
|
436
|
+
catch (e) {
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function masonLengthPercentParse(value) {
|
|
441
|
+
try {
|
|
442
|
+
return CorePercentLength.parse(value);
|
|
443
|
+
}
|
|
444
|
+
catch (e) {
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
export const maxWidthProperty = new CssProperty({
|
|
449
|
+
name: 'maxWidth',
|
|
450
|
+
cssName: 'max-width',
|
|
451
|
+
defaultValue: 'auto',
|
|
452
|
+
// @ts-ignore
|
|
453
|
+
equalityComparer: CoreLength.equals,
|
|
454
|
+
valueConverter: masonLengthParse,
|
|
455
|
+
valueChanged: (target, oldValue, newValue) => {
|
|
456
|
+
const view = getViewStyle(target.viewRef);
|
|
457
|
+
if (view) {
|
|
458
|
+
view.maxWidth = newValue;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
export const maxHeightProperty = new CssProperty({
|
|
466
|
+
name: 'maxHeight',
|
|
467
|
+
cssName: 'max-height',
|
|
468
|
+
defaultValue: 'auto',
|
|
469
|
+
// @ts-ignore
|
|
470
|
+
equalityComparer: CoreLength.equals,
|
|
471
|
+
valueConverter: masonLengthParse,
|
|
472
|
+
valueChanged(target, oldValue, newValue) {
|
|
473
|
+
const view = getViewStyle(target.viewRef);
|
|
474
|
+
if (view) {
|
|
475
|
+
view.maxHeight = newValue;
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
export const insetProperty = new ShorthandProperty({
|
|
480
|
+
name: 'inset',
|
|
481
|
+
cssName: 'inset',
|
|
482
|
+
getter: function () {
|
|
483
|
+
if (this.top === this.right && this.top === this.bottom && this.top === this.left) {
|
|
484
|
+
if (typeof this.top === 'string') {
|
|
485
|
+
if (this.top === 'auto') {
|
|
486
|
+
return this.top;
|
|
487
|
+
}
|
|
488
|
+
const value = CorePercentLength.parse(this.top);
|
|
489
|
+
if (Number.isNaN(value)) {
|
|
490
|
+
return this.top;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
return CorePercentLength.convertToString(value);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (CorePercentLength.equals(this.top, this.right) && CorePercentLength.equals(this.top, this.bottom) && CorePercentLength.equals(this.top, this.left)) {
|
|
498
|
+
return this.top;
|
|
499
|
+
}
|
|
500
|
+
return `${CorePercentLength.convertToString(this.paddingTop)} ${CorePercentLength.convertToString(this.paddingRight)} ${CorePercentLength.convertToString(this.paddingBottom)} ${CorePercentLength.convertToString(this.paddingLeft)}`;
|
|
501
|
+
},
|
|
502
|
+
converter: convertToInsets,
|
|
503
|
+
});
|
|
504
|
+
function parseShorthandPositioning(value) {
|
|
505
|
+
const arr = value.split(/[ ,]+/);
|
|
506
|
+
let top;
|
|
507
|
+
let right;
|
|
508
|
+
let bottom;
|
|
509
|
+
let left;
|
|
510
|
+
if (arr.length === 1) {
|
|
511
|
+
top = arr[0];
|
|
512
|
+
right = arr[0];
|
|
513
|
+
bottom = arr[0];
|
|
514
|
+
left = arr[0];
|
|
515
|
+
}
|
|
516
|
+
else if (arr.length === 2) {
|
|
517
|
+
top = arr[0];
|
|
518
|
+
bottom = arr[0];
|
|
519
|
+
right = arr[1];
|
|
520
|
+
left = arr[1];
|
|
521
|
+
}
|
|
522
|
+
else if (arr.length === 3) {
|
|
523
|
+
top = arr[0];
|
|
524
|
+
right = arr[1];
|
|
525
|
+
left = arr[1];
|
|
526
|
+
bottom = arr[2];
|
|
527
|
+
}
|
|
528
|
+
else if (arr.length === 4) {
|
|
529
|
+
top = arr[0];
|
|
530
|
+
right = arr[1];
|
|
531
|
+
bottom = arr[2];
|
|
532
|
+
left = arr[3];
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
throw new Error('Expected 1, 2, 3 or 4 parameters. Actual: ' + value);
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
top: top,
|
|
539
|
+
right: right,
|
|
540
|
+
bottom: bottom,
|
|
541
|
+
left: left,
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
function convertToInsets(value) {
|
|
545
|
+
if (typeof value === 'string' && value !== 'auto') {
|
|
546
|
+
const thickness = parseShorthandPositioning(value);
|
|
547
|
+
return [
|
|
548
|
+
[topProperty, masonLengthPercentParse(thickness.top)],
|
|
549
|
+
[rightProperty, masonLengthPercentParse(thickness.right)],
|
|
550
|
+
[bottomProperty, masonLengthPercentParse(thickness.bottom)],
|
|
551
|
+
[leftProperty, masonLengthPercentParse(thickness.left)],
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
return [
|
|
556
|
+
[topProperty, value],
|
|
557
|
+
[rightProperty, value],
|
|
558
|
+
[bottomProperty, value],
|
|
559
|
+
[leftProperty, value],
|
|
560
|
+
];
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
export const leftProperty = new CssProperty({
|
|
564
|
+
name: 'left',
|
|
565
|
+
cssName: 'left',
|
|
566
|
+
defaultValue: 'auto',
|
|
567
|
+
// @ts-ignore
|
|
568
|
+
equalityComparer: CorePercentLength.equals,
|
|
569
|
+
valueConverter: masonLengthPercentParse,
|
|
570
|
+
valueChanged(target, oldValue, newValue) {
|
|
571
|
+
const view = getViewStyle(target.viewRef);
|
|
572
|
+
if (view) {
|
|
573
|
+
view.left = newValue;
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
export const rightProperty = new CssProperty({
|
|
578
|
+
name: 'right',
|
|
579
|
+
cssName: 'right',
|
|
580
|
+
defaultValue: 'auto',
|
|
581
|
+
// @ts-ignore
|
|
582
|
+
equalityComparer: CorePercentLength.equals,
|
|
583
|
+
valueConverter: masonLengthPercentParse,
|
|
584
|
+
valueChanged(target, oldValue, newValue) {
|
|
585
|
+
const view = getViewStyle(target.viewRef);
|
|
586
|
+
if (view) {
|
|
587
|
+
view.right = newValue;
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
export const topProperty = new CssProperty({
|
|
592
|
+
name: 'top',
|
|
593
|
+
cssName: 'top',
|
|
594
|
+
defaultValue: 'auto',
|
|
595
|
+
// @ts-ignore
|
|
596
|
+
equalityComparer: CorePercentLength.equals,
|
|
597
|
+
valueConverter: masonLengthPercentParse,
|
|
598
|
+
valueChanged(target, oldValue, newValue) {
|
|
599
|
+
const view = getViewStyle(target.viewRef);
|
|
600
|
+
if (view) {
|
|
601
|
+
view.top = newValue;
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
export const bottomProperty = new CssProperty({
|
|
606
|
+
name: 'bottom',
|
|
607
|
+
cssName: 'bottom',
|
|
608
|
+
defaultValue: 'auto',
|
|
609
|
+
// @ts-ignore
|
|
610
|
+
equalityComparer: CorePercentLength.equals,
|
|
611
|
+
valueConverter: masonLengthPercentParse,
|
|
612
|
+
valueChanged(target, oldValue, newValue) {
|
|
613
|
+
const view = getViewStyle(target.viewRef);
|
|
614
|
+
if (view) {
|
|
615
|
+
view.bottom = newValue;
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
export const positionProperty = new CssProperty({
|
|
620
|
+
name: 'position',
|
|
621
|
+
cssName: 'position',
|
|
622
|
+
defaultValue: 'relative',
|
|
623
|
+
valueChanged(target, oldValue, newValue) {
|
|
624
|
+
const view = getViewStyle(target.viewRef);
|
|
625
|
+
if (view) {
|
|
626
|
+
view.position = newValue;
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
});
|
|
630
|
+
export const boxSizingProperty = new CssProperty({
|
|
631
|
+
name: 'boxSizing',
|
|
632
|
+
cssName: 'box-sizing',
|
|
633
|
+
defaultValue: 'border-box',
|
|
634
|
+
valueChanged(target, oldValue, newValue) {
|
|
635
|
+
const view = getViewStyle(target.viewRef);
|
|
636
|
+
if (view) {
|
|
637
|
+
if (newValue) {
|
|
638
|
+
view.boxSizing = newValue;
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
// Revert to old value if newValue is invalid
|
|
642
|
+
target.boxSizing = oldValue;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
valueConverter(value) {
|
|
647
|
+
switch (value) {
|
|
648
|
+
case 'content-box':
|
|
649
|
+
case 'border-box':
|
|
650
|
+
return value;
|
|
651
|
+
default:
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
});
|
|
656
|
+
export const borderRadiusProperty = new CssProperty({
|
|
657
|
+
name: 'borderRadius',
|
|
658
|
+
cssName: 'border-radius',
|
|
659
|
+
});
|
|
660
|
+
alignItemsProperty.overrideHandlers({
|
|
661
|
+
name: 'alignItems',
|
|
662
|
+
cssName: 'align-items',
|
|
663
|
+
valueChanged(target, oldValue, newValue) {
|
|
664
|
+
const view = getViewStyle(target.viewRef);
|
|
665
|
+
if (view) {
|
|
666
|
+
if (newValue) {
|
|
667
|
+
view.alignItems = newValue;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
// Revert to old value if newValue is invalid
|
|
671
|
+
// @ts-ignore
|
|
672
|
+
target.alignItems = oldValue;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
});
|
|
677
|
+
alignSelfProperty.overrideHandlers({
|
|
678
|
+
name: 'alignSelf',
|
|
679
|
+
cssName: 'align-self',
|
|
680
|
+
valueChanged(target, oldValue, newValue) {
|
|
681
|
+
const view = getViewStyle(target.viewRef);
|
|
682
|
+
if (view) {
|
|
683
|
+
if (newValue) {
|
|
684
|
+
view.alignSelf = newValue;
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
// Revert to old value if newValue is invalid
|
|
688
|
+
// @ts-ignore
|
|
689
|
+
target.alignSelf = oldValue;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
});
|
|
694
|
+
export const alignContentProperty = new CssProperty({
|
|
695
|
+
name: 'alignContent',
|
|
696
|
+
cssName: 'align-content',
|
|
697
|
+
defaultValue: 'normal',
|
|
698
|
+
valueChanged(target, oldValue, newValue) {
|
|
699
|
+
const view = getViewStyle(target.viewRef);
|
|
700
|
+
if (view) {
|
|
701
|
+
if (newValue) {
|
|
702
|
+
view.alignContent = newValue;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
// Revert to old value if newValue is invalid
|
|
706
|
+
// @ts-ignore
|
|
707
|
+
target.alignContent = oldValue;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
});
|
|
712
|
+
export const justifyItemsProperty = new CssProperty({
|
|
713
|
+
name: 'justifyItems',
|
|
714
|
+
cssName: 'justify-items',
|
|
715
|
+
defaultValue: 'normal',
|
|
716
|
+
valueChanged(target, oldValue, newValue) {
|
|
717
|
+
const view = getViewStyle(target.viewRef);
|
|
718
|
+
if (view) {
|
|
719
|
+
if (newValue) {
|
|
720
|
+
view.justifyItems = newValue;
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
// Revert to old value if newValue is invalid
|
|
724
|
+
// @ts-ignore
|
|
725
|
+
target.justifyItems = oldValue;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
export const justifySelfProperty = new CssProperty({
|
|
731
|
+
name: 'justifySelf',
|
|
732
|
+
cssName: 'justify-self',
|
|
733
|
+
defaultValue: 'normal',
|
|
734
|
+
valueChanged(target, oldValue, newValue) {
|
|
735
|
+
const view = getViewStyle(target.viewRef);
|
|
736
|
+
if (view) {
|
|
737
|
+
if (newValue) {
|
|
738
|
+
view.justifySelf = newValue;
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
// Revert to old value if newValue is invalid
|
|
742
|
+
// @ts-ignore
|
|
743
|
+
target.justifySelf = oldValue;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
});
|
|
748
|
+
justifyContentProperty.overrideHandlers({
|
|
749
|
+
name: 'justifyContent',
|
|
750
|
+
cssName: 'justify-content',
|
|
751
|
+
valueChanged(target, oldValue, newValue) {
|
|
752
|
+
const view = getViewStyle(target.viewRef);
|
|
753
|
+
if (view) {
|
|
754
|
+
if (newValue) {
|
|
755
|
+
view.justifyContent = newValue;
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
// Revert to old value if newValue is invalid
|
|
759
|
+
// @ts-ignore
|
|
760
|
+
target.justifyContent = oldValue;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
export const flexBasisProperty = new CssProperty({
|
|
766
|
+
name: 'flexBasis',
|
|
767
|
+
cssName: 'flex-basis',
|
|
768
|
+
defaultValue: 'auto',
|
|
769
|
+
equalityComparer: CoreLength.equals,
|
|
770
|
+
valueConverter: masonLengthParse,
|
|
771
|
+
valueChanged(target, oldValue, newValue) {
|
|
772
|
+
const view = getViewStyle(target.viewRef);
|
|
773
|
+
if (view) {
|
|
774
|
+
view.flexBasis = newValue;
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
});
|
|
778
|
+
export const aspectRatioProperty = new CssProperty({
|
|
779
|
+
name: 'aspectRatio',
|
|
780
|
+
cssName: 'aspect-ratio',
|
|
781
|
+
defaultValue: Number.NaN,
|
|
782
|
+
valueChanged(target, oldValue, newValue) {
|
|
783
|
+
const view = getViewStyle(target.viewRef);
|
|
784
|
+
if (view) {
|
|
785
|
+
view.aspectRatio = newValue;
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
export const gridAutoRowsProperty = new CssProperty({
|
|
790
|
+
name: 'gridAutoRows',
|
|
791
|
+
cssName: 'grid-auto-rows',
|
|
792
|
+
defaultValue: '',
|
|
793
|
+
valueChanged(target, oldValue, newValue) {
|
|
794
|
+
const view = getViewStyle(target.viewRef);
|
|
795
|
+
if (view) {
|
|
796
|
+
view.gridAutoRows = newValue;
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
});
|
|
800
|
+
export const gridAutoColumnsProperty = new CssProperty({
|
|
801
|
+
name: 'gridAutoColumns',
|
|
802
|
+
cssName: 'grid-auto-columns',
|
|
803
|
+
defaultValue: '',
|
|
804
|
+
valueChanged(target, oldValue, newValue) {
|
|
805
|
+
const view = getViewStyle(target.viewRef);
|
|
806
|
+
if (view) {
|
|
807
|
+
view.gridAutoColumns = newValue;
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
export const gridAutoFlowProperty = new CssProperty({
|
|
812
|
+
name: 'gridAutoFlow',
|
|
813
|
+
cssName: 'grid-auto-flow',
|
|
814
|
+
defaultValue: 'row',
|
|
815
|
+
valueChanged(target, oldValue, newValue) {
|
|
816
|
+
const view = getViewStyle(target.viewRef);
|
|
817
|
+
if (view) {
|
|
818
|
+
view.gridAutoFlow = newValue;
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
});
|
|
822
|
+
export const gridAreaProperty = new CssProperty({
|
|
823
|
+
name: 'gridArea',
|
|
824
|
+
cssName: 'grid-area',
|
|
825
|
+
defaultValue: '',
|
|
826
|
+
valueChanged(target, oldValue, newValue) {
|
|
827
|
+
const view = getViewStyle(target.viewRef);
|
|
828
|
+
if (view) {
|
|
829
|
+
view.gridArea = newValue;
|
|
830
|
+
}
|
|
831
|
+
},
|
|
832
|
+
});
|
|
833
|
+
export const gridColumnStartProperty = new CssProperty({
|
|
834
|
+
name: 'gridColumnStart',
|
|
835
|
+
cssName: 'grid-column-start',
|
|
836
|
+
defaultValue: 'auto',
|
|
837
|
+
valueChanged(target, oldValue, newValue) {
|
|
838
|
+
const view = getViewStyle(target.viewRef);
|
|
839
|
+
if (view) {
|
|
840
|
+
view.gridColumnStart = newValue;
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
});
|
|
844
|
+
export const gridColumnEndProperty = new CssProperty({
|
|
845
|
+
name: 'gridColumnEnd',
|
|
846
|
+
cssName: 'grid-column-end',
|
|
847
|
+
defaultValue: 'auto',
|
|
848
|
+
valueChanged(target, oldValue, newValue) {
|
|
849
|
+
const view = getViewStyle(target.viewRef);
|
|
850
|
+
if (view) {
|
|
851
|
+
view.gridColumnEnd = newValue;
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
});
|
|
855
|
+
export const gridColumnProperty = new CssProperty({
|
|
856
|
+
name: 'gridColumn',
|
|
857
|
+
cssName: 'grid-column',
|
|
858
|
+
defaultValue: '',
|
|
859
|
+
valueChanged(target, oldValue, newValue) {
|
|
860
|
+
const view = getViewStyle(target.viewRef);
|
|
861
|
+
if (view) {
|
|
862
|
+
view.gridColumn = newValue;
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
});
|
|
866
|
+
export const gridRowStartProperty = new CssProperty({
|
|
867
|
+
name: 'gridRowStart',
|
|
868
|
+
cssName: 'grid-row-start',
|
|
869
|
+
defaultValue: 'auto',
|
|
870
|
+
valueChanged(target, oldValue, newValue) {
|
|
871
|
+
const view = getViewStyle(target.viewRef);
|
|
872
|
+
if (view) {
|
|
873
|
+
view.gridRowStart = newValue;
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
});
|
|
877
|
+
export const gridRowEndProperty = new CssProperty({
|
|
878
|
+
name: 'gridRowEnd',
|
|
879
|
+
cssName: 'grid-row-end',
|
|
880
|
+
defaultValue: 'auto',
|
|
881
|
+
valueChanged(target, oldValue, newValue) {
|
|
882
|
+
const view = getViewStyle(target.viewRef);
|
|
883
|
+
if (view) {
|
|
884
|
+
view.gridRowEnd = newValue;
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
export const gridRowProperty = new CssProperty({
|
|
889
|
+
name: 'gridRow',
|
|
890
|
+
cssName: 'grid-row',
|
|
891
|
+
defaultValue: '',
|
|
892
|
+
valueChanged(target, oldValue, newValue) {
|
|
893
|
+
const view = getViewStyle(target.viewRef);
|
|
894
|
+
if (view) {
|
|
895
|
+
view.gridRow = newValue;
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
});
|
|
899
|
+
export const gridTemplateAreasProperty = new CssProperty({
|
|
900
|
+
name: 'gridTemplateAreas',
|
|
901
|
+
cssName: 'grid-template-areas',
|
|
902
|
+
defaultValue: null,
|
|
903
|
+
valueChanged(target, oldValue, newValue) {
|
|
904
|
+
const view = getViewStyle(target.viewRef);
|
|
905
|
+
if (view) {
|
|
906
|
+
view.gridTemplateAreas = newValue;
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
});
|
|
910
|
+
export const gridTemplateRowsProperty = new CssProperty({
|
|
911
|
+
name: 'gridTemplateRows',
|
|
912
|
+
cssName: 'grid-template-rows',
|
|
913
|
+
defaultValue: null,
|
|
914
|
+
valueChanged(target, oldValue, newValue) {
|
|
915
|
+
const view = getViewStyle(target.viewRef);
|
|
916
|
+
if (view) {
|
|
917
|
+
view.gridTemplateRows = newValue;
|
|
918
|
+
}
|
|
919
|
+
},
|
|
920
|
+
});
|
|
921
|
+
export const gridTemplateColumnsProperty = new CssProperty({
|
|
922
|
+
name: 'gridTemplateColumns',
|
|
923
|
+
cssName: 'grid-template-columns',
|
|
924
|
+
defaultValue: null,
|
|
925
|
+
valueChanged(target, oldValue, newValue) {
|
|
926
|
+
const view = getViewStyle(target.viewRef);
|
|
927
|
+
if (view) {
|
|
928
|
+
view.gridTemplateColumns = newValue;
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
});
|
|
932
|
+
// @ts-ignore
|
|
933
|
+
export const textWrapProperty = new CssProperty({
|
|
934
|
+
name: 'textWrap',
|
|
935
|
+
affectsLayout: true,
|
|
936
|
+
defaultValue: 'wrap',
|
|
937
|
+
valueChanged(target, oldValue, newValue) {
|
|
938
|
+
const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
|
|
939
|
+
if (view) {
|
|
940
|
+
view.textWrap = newValue;
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
// flex-flow: <flex-direction> || <flex-wrap>
|
|
945
|
+
const flexFlowProperty = new ShorthandProperty({
|
|
946
|
+
name: 'flexFlow',
|
|
947
|
+
cssName: 'flex-flow',
|
|
948
|
+
getter: function () {
|
|
949
|
+
return `${this.flexDirection} ${this.flexWrap}`;
|
|
950
|
+
},
|
|
951
|
+
converter: function (value) {
|
|
952
|
+
const properties = [];
|
|
953
|
+
if (value === unsetValue) {
|
|
954
|
+
properties.push([flexDirectionProperty, value]);
|
|
955
|
+
properties.push([flexWrapProperty, value]);
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
const trimmed = value && value.trim();
|
|
959
|
+
if (trimmed) {
|
|
960
|
+
const values = trimmed.split(/\s+/);
|
|
961
|
+
if (values.length >= 1) {
|
|
962
|
+
properties.push([flexDirectionProperty, values[0]]);
|
|
963
|
+
}
|
|
964
|
+
if (value.length >= 2) {
|
|
965
|
+
properties.push([flexWrapProperty, values[1]]);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return properties;
|
|
970
|
+
},
|
|
971
|
+
});
|
|
972
|
+
// flex: inital | auto | none | <flex-grow> <flex-shrink> || <flex-basis>
|
|
973
|
+
const flexProperty = new ShorthandProperty({
|
|
974
|
+
name: 'flex',
|
|
975
|
+
cssName: 'flex',
|
|
976
|
+
getter: function () {
|
|
977
|
+
return `${this.flexGrow} ${this.flexShrink} ${this.flexBasis}`;
|
|
978
|
+
},
|
|
979
|
+
converter: function (value) {
|
|
980
|
+
const properties = [];
|
|
981
|
+
if (value === unsetValue) {
|
|
982
|
+
properties.push([flexGrowProperty, value]);
|
|
983
|
+
properties.push([flexShrinkProperty, value]);
|
|
984
|
+
}
|
|
985
|
+
else if (typeof value === 'number') {
|
|
986
|
+
properties.push([flexGrowProperty, value]);
|
|
987
|
+
properties.push([flexShrinkProperty, 1]);
|
|
988
|
+
properties.push([flexBasisProperty, 'auto']);
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
const trimmed = value && value.trim();
|
|
992
|
+
if (trimmed) {
|
|
993
|
+
const values = trimmed.split(/\s+/);
|
|
994
|
+
if (values.length === 1) {
|
|
995
|
+
switch (values[0]) {
|
|
996
|
+
case 'inital':
|
|
997
|
+
properties.push([flexGrowProperty, 0]);
|
|
998
|
+
properties.push([flexShrinkProperty, 1]);
|
|
999
|
+
properties.push([flexBasisProperty, 'auto']);
|
|
1000
|
+
break;
|
|
1001
|
+
case 'auto':
|
|
1002
|
+
properties.push([flexGrowProperty, 1]);
|
|
1003
|
+
properties.push([flexShrinkProperty, 1]);
|
|
1004
|
+
properties.push([flexBasisProperty, 'auto']);
|
|
1005
|
+
break;
|
|
1006
|
+
case 'none':
|
|
1007
|
+
properties.push([flexGrowProperty, 0]);
|
|
1008
|
+
properties.push([flexShrinkProperty, 0]);
|
|
1009
|
+
properties.push([flexBasisProperty, 'auto']);
|
|
1010
|
+
break;
|
|
1011
|
+
default:
|
|
1012
|
+
properties.push([flexGrowProperty, values[0]]);
|
|
1013
|
+
properties.push([flexShrinkProperty, 1]);
|
|
1014
|
+
properties.push([flexBasisProperty, 'auto']);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (values.length >= 2) {
|
|
1018
|
+
properties.push([flexGrowProperty, values[0]]);
|
|
1019
|
+
properties.push([flexShrinkProperty, values[1]]);
|
|
1020
|
+
}
|
|
1021
|
+
if (value.length >= 3) {
|
|
1022
|
+
properties.push({ property: flexBasisProperty, value: values[2] });
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return properties;
|
|
1027
|
+
},
|
|
1028
|
+
});
|
|
1029
|
+
export const textOverFlowProperty = new CssProperty({
|
|
1030
|
+
name: 'textOverflow',
|
|
1031
|
+
cssName: 'text-overflow',
|
|
1032
|
+
defaultValue: 'clip',
|
|
1033
|
+
valueChanged(target, oldValue, newValue) {
|
|
1034
|
+
const view = target?.viewRef ? getViewStyle(target.viewRef) : target.view;
|
|
1035
|
+
if (view) {
|
|
1036
|
+
view.textOverflow = newValue;
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
});
|
|
1040
|
+
export const verticalAlignProperty = new CssProperty({
|
|
1041
|
+
name: 'verticalAlign',
|
|
1042
|
+
cssName: 'vertical-align',
|
|
1043
|
+
defaultValue: 'baseline',
|
|
1044
|
+
valueChanged: (target, oldValue, newValue) => {
|
|
1045
|
+
const view = getViewStyle(target.viewRef);
|
|
1046
|
+
if (view) {
|
|
1047
|
+
if (newValue) {
|
|
1048
|
+
view.verticalAlign = newValue;
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
// Revert to old value if newValue is invalid
|
|
1052
|
+
target.verticalAlign = oldValue;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
});
|
|
1057
|
+
verticalAlignmentProperty.overrideHandlers({
|
|
1058
|
+
name: 'verticalAlignment',
|
|
1059
|
+
cssName: 'vertical-align',
|
|
1060
|
+
valueConverter: function (value) {
|
|
1061
|
+
if (isMasonViewOrChild(this)) {
|
|
1062
|
+
return value;
|
|
1063
|
+
}
|
|
1064
|
+
return CoreTypes.VerticalAlignmentText.parse(value);
|
|
1065
|
+
},
|
|
1066
|
+
valueChanged(target, oldValue, newValue) {
|
|
1067
|
+
const view = getViewStyle(target.viewRef);
|
|
1068
|
+
if (view) {
|
|
1069
|
+
if (newValue) {
|
|
1070
|
+
// @ts-ignore
|
|
1071
|
+
view.verticalAlign = newValue;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
// Revert to old value if newValue is invalid
|
|
1075
|
+
// @ts-ignore
|
|
1076
|
+
target.verticalAlign = oldValue;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
});
|
|
1081
|
+
textShadowProperty.overrideHandlers({
|
|
1082
|
+
name: 'textShadow',
|
|
1083
|
+
cssName: 'text-shadow',
|
|
1084
|
+
valueConverter: function (value) {
|
|
1085
|
+
return value;
|
|
1086
|
+
},
|
|
1087
|
+
valueChanged(target, oldValue, newValue) {
|
|
1088
|
+
const view = getViewStyle(target.viewRef);
|
|
1089
|
+
if (view) {
|
|
1090
|
+
view.textShadow = newValue;
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
// Revert to old value if newValue is invalid
|
|
1094
|
+
// @ts-ignore
|
|
1095
|
+
target.textShadow = oldValue;
|
|
1096
|
+
}
|
|
1097
|
+
},
|
|
1098
|
+
});
|
|
1099
|
+
verticalAlignProperty.register(Style);
|
|
1100
|
+
textOverFlowProperty.register(Style);
|
|
1101
|
+
flexProperty.register(Style);
|
|
1102
|
+
flexFlowProperty.register(Style);
|
|
1103
|
+
textWrapProperty.register(Style);
|
|
1104
|
+
gridTemplateColumnsProperty.register(Style);
|
|
1105
|
+
gridTemplateRowsProperty.register(Style);
|
|
1106
|
+
alignContentProperty.register(Style);
|
|
1107
|
+
justifySelfProperty.register(Style);
|
|
1108
|
+
justifyItemsProperty.register(Style);
|
|
1109
|
+
gridTemplateAreasProperty.register(Style);
|
|
1110
|
+
gridRowProperty.register(Style);
|
|
1111
|
+
gridRowStartProperty.register(Style);
|
|
1112
|
+
gridRowEndProperty.register(Style);
|
|
1113
|
+
gridColumnProperty.register(Style);
|
|
1114
|
+
gridColumnEndProperty.register(Style);
|
|
1115
|
+
gridColumnStartProperty.register(Style);
|
|
1116
|
+
gridAreaProperty.register(Style);
|
|
1117
|
+
gridAutoFlowProperty.register(Style);
|
|
1118
|
+
gridAutoRowsProperty.register(Style);
|
|
1119
|
+
gridAutoColumnsProperty.register(Style);
|
|
1120
|
+
aspectRatioProperty.register(Style);
|
|
1121
|
+
flexBasisProperty.register(Style);
|
|
1122
|
+
borderRadiusProperty.register(Style);
|
|
1123
|
+
boxSizingProperty.register(Style);
|
|
1124
|
+
positionProperty.register(Style);
|
|
1125
|
+
insetProperty.register(Style);
|
|
1126
|
+
leftProperty.register(Style);
|
|
1127
|
+
rightProperty.register(Style);
|
|
1128
|
+
topProperty.register(Style);
|
|
1129
|
+
bottomProperty.register(Style);
|
|
1130
|
+
maxWidthProperty.register(Style);
|
|
1131
|
+
maxHeightProperty.register(Style);
|
|
1132
|
+
gridRowGapProperty.register(Style);
|
|
1133
|
+
gridColumnGapProperty.register(Style);
|
|
1134
|
+
gridGapProperty.register(Style);
|
|
1135
|
+
gapProperty.register(Style);
|
|
1136
|
+
rowGapProperty.register(Style);
|
|
1137
|
+
columnGapProperty.register(Style);
|
|
1138
|
+
scrollBarWidthProperty.register(Style);
|
|
1139
|
+
marginProperty.register(Style);
|
|
1140
|
+
overflowProperty.register(Style);
|
|
1141
|
+
overflowXProperty.register(Style);
|
|
1142
|
+
overflowYProperty.register(Style);
|
|
1143
|
+
backgroundProperty.register(Style);
|
|
1144
|
+
borderProperty.register(Style);
|
|
1145
|
+
filterProperty.register(Style);
|
|
1146
|
+
displayProperty.register(Style);
|
|
1147
|
+
//# sourceMappingURL=properties.js.map
|