@akylas/nativescript 8.2.1 → 8.2.4-alpha.2

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 (158) hide show
  1. package/accessibility/index.ios.js +1 -1
  2. package/accessibility/index.ios.js.map +1 -1
  3. package/application/application-common.d.ts +4 -0
  4. package/application/application-common.js +8 -0
  5. package/application/application-common.js.map +1 -1
  6. package/application/index.android.d.ts +2 -2
  7. package/application/index.android.js +10 -3
  8. package/application/index.android.js.map +1 -1
  9. package/application/index.ios.js +5 -0
  10. package/application/index.ios.js.map +1 -1
  11. package/config/config.interface.d.ts +1 -1
  12. package/core-types/index.d.ts +1 -0
  13. package/core-types/index.js.map +1 -1
  14. package/css/LICENSE +9 -0
  15. package/css/Readme.md +278 -0
  16. package/css-value/LICENSE +9 -0
  17. package/css-value/Readme.md +45 -0
  18. package/css-value/UPGRADING.md +26 -0
  19. package/fetch/LICENSE +20 -0
  20. package/fetch/README.md +1 -0
  21. package/file-system/file-system-access.android.d.ts +1 -0
  22. package/file-system/file-system-access.android.js +1 -0
  23. package/file-system/file-system-access.android.js.map +1 -1
  24. package/file-system/file-system-access.ios.d.ts +2 -0
  25. package/file-system/file-system-access.ios.js +3 -0
  26. package/file-system/file-system-access.ios.js.map +1 -1
  27. package/file-system/index.js +17 -7
  28. package/file-system/index.js.map +1 -1
  29. package/index.d.ts +2 -1
  30. package/index.js +2 -1
  31. package/index.js.map +1 -1
  32. package/js-libs/easysax/LICENSE +20 -0
  33. package/js-libs/easysax/README.md +46 -0
  34. package/js-libs/esprima/LICENSE.BSD +19 -0
  35. package/js-libs/esprima/README.md +24 -0
  36. package/js-libs/polymer-expressions/LICENSE +27 -0
  37. package/js-libs/polymer-expressions/README.md +0 -0
  38. package/package.json +5 -13
  39. package/platforms/README.md +1 -0
  40. package/platforms/android/widgets-release.aar +0 -0
  41. package/ui/action-bar/index.ios.js +7 -6
  42. package/ui/action-bar/index.ios.js.map +1 -1
  43. package/ui/animation/animation-common.d.ts +7 -4
  44. package/ui/animation/animation-common.js +55 -117
  45. package/ui/animation/animation-common.js.map +1 -1
  46. package/ui/animation/animation-interfaces.d.ts +3 -2
  47. package/ui/animation/index.android.d.ts +15 -14
  48. package/ui/animation/index.android.js +99 -22
  49. package/ui/animation/index.android.js.map +1 -1
  50. package/ui/animation/index.ios.d.ts +33 -16
  51. package/ui/animation/index.ios.js +256 -202
  52. package/ui/animation/index.ios.js.map +1 -1
  53. package/ui/animation/keyframe-animation.d.ts +0 -1
  54. package/ui/animation/keyframe-animation.js +51 -51
  55. package/ui/animation/keyframe-animation.js.map +1 -1
  56. package/ui/builder/xml2ui.js +1 -1
  57. package/ui/builder/xml2ui.js.map +1 -1
  58. package/ui/button/index.ios.js +1 -1
  59. package/ui/button/index.ios.js.map +1 -1
  60. package/ui/core/properties/index.d.ts +34 -6
  61. package/ui/core/properties/index.js +429 -643
  62. package/ui/core/properties/index.js.map +1 -1
  63. package/ui/core/view/index.android.d.ts +1 -0
  64. package/ui/core/view/index.android.js +5 -2
  65. package/ui/core/view/index.android.js.map +1 -1
  66. package/ui/core/view/index.d.ts +5 -0
  67. package/ui/core/view/index.ios.d.ts +4 -2
  68. package/ui/core/view/index.ios.js +28 -10
  69. package/ui/core/view/index.ios.js.map +1 -1
  70. package/ui/core/view/view-common.d.ts +2 -0
  71. package/ui/core/view/view-common.js +16 -5
  72. package/ui/core/view/view-common.js.map +1 -1
  73. package/ui/core/view/view-helper/index.ios.js +2 -2
  74. package/ui/core/view-base/index.js +4 -5
  75. package/ui/core/view-base/index.js.map +1 -1
  76. package/ui/editable-text-base/editable-text-base-common.js +2 -1
  77. package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
  78. package/ui/editable-text-base/index.android.d.ts +0 -1
  79. package/ui/editable-text-base/index.android.js +15 -14
  80. package/ui/editable-text-base/index.android.js.map +1 -1
  81. package/ui/frame/frame-common.d.ts +1 -1
  82. package/ui/frame/frame-common.js +15 -15
  83. package/ui/frame/frame-common.js.map +1 -1
  84. package/ui/frame/index.android.js +5 -2
  85. package/ui/frame/index.android.js.map +1 -1
  86. package/ui/gestures/index.android.js +1 -1
  87. package/ui/gestures/index.android.js.map +1 -1
  88. package/ui/gestures/touch-manager.js +2 -1
  89. package/ui/gestures/touch-manager.js.map +1 -1
  90. package/ui/html-view/html-view-common.js +2 -1
  91. package/ui/html-view/html-view-common.js.map +1 -1
  92. package/ui/image/image-common.js +2 -2
  93. package/ui/image/image-common.js.map +1 -1
  94. package/ui/label/index.ios.js +1 -1
  95. package/ui/label/index.ios.js.map +1 -1
  96. package/ui/layouts/root-layout/index.d.ts +5 -4
  97. package/ui/layouts/root-layout/root-layout-common.d.ts +5 -2
  98. package/ui/layouts/root-layout/root-layout-common.js +145 -168
  99. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  100. package/ui/list-view/list-view-common.js +2 -2
  101. package/ui/list-view/list-view-common.js.map +1 -1
  102. package/ui/page/page-common.js +2 -1
  103. package/ui/page/page-common.js.map +1 -1
  104. package/ui/proxy-view-container/index.d.ts +2 -0
  105. package/ui/proxy-view-container/index.js +28 -0
  106. package/ui/proxy-view-container/index.js.map +1 -1
  107. package/ui/search-bar/search-bar-common.js +3 -2
  108. package/ui/search-bar/search-bar-common.js.map +1 -1
  109. package/ui/segmented-bar/segmented-bar-common.js +2 -1
  110. package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
  111. package/ui/styling/background.android.js +2 -0
  112. package/ui/styling/background.android.js.map +1 -1
  113. package/ui/styling/background.ios.js +21 -5
  114. package/ui/styling/background.ios.js.map +1 -1
  115. package/ui/styling/css-animation-parser.js +3 -2
  116. package/ui/styling/css-animation-parser.js.map +1 -1
  117. package/ui/styling/style/index.d.ts +1 -0
  118. package/ui/styling/style/index.js.map +1 -1
  119. package/ui/styling/style-properties.d.ts +1 -0
  120. package/ui/styling/style-properties.js +58 -70
  121. package/ui/styling/style-properties.js.map +1 -1
  122. package/ui/styling/style-scope.js +4 -10
  123. package/ui/styling/style-scope.js.map +1 -1
  124. package/ui/switch/switch-common.js +2 -1
  125. package/ui/switch/switch-common.js.map +1 -1
  126. package/ui/tab-view/index.ios.d.ts +1 -0
  127. package/ui/tab-view/index.ios.js +54 -24
  128. package/ui/tab-view/index.ios.js.map +1 -1
  129. package/ui/tab-view/tab-view-common.js +5 -4
  130. package/ui/tab-view/tab-view-common.js.map +1 -1
  131. package/ui/text-base/index.android.js +10 -1
  132. package/ui/text-base/index.android.js.map +1 -1
  133. package/ui/text-base/index.d.ts +5 -0
  134. package/ui/text-base/index.ios.d.ts +2 -0
  135. package/ui/text-base/index.ios.js +144 -6
  136. package/ui/text-base/index.ios.js.map +1 -1
  137. package/ui/text-base/text-base-common.d.ts +3 -0
  138. package/ui/text-base/text-base-common.js +12 -0
  139. package/ui/text-base/text-base-common.js.map +1 -1
  140. package/ui/text-view/index.android.js +1 -11
  141. package/ui/text-view/index.android.js.map +1 -1
  142. package/ui/text-view/index.ios.js +1 -13
  143. package/ui/text-view/index.ios.js.map +1 -1
  144. package/ui/text-view/text-view-common.d.ts +0 -2
  145. package/ui/text-view/text-view-common.js +0 -6
  146. package/ui/text-view/text-view-common.js.map +1 -1
  147. package/utils/index.d.ts +6 -0
  148. package/utils/mainthread-helper.android.d.ts +1 -0
  149. package/utils/mainthread-helper.android.js +7 -0
  150. package/utils/mainthread-helper.android.js.map +1 -1
  151. package/utils/mainthread-helper.d.ts +6 -0
  152. package/utils/mainthread-helper.ios.d.ts +1 -0
  153. package/utils/mainthread-helper.ios.js +12 -0
  154. package/utils/mainthread-helper.ios.js.map +1 -1
  155. package/utils/utils-common.d.ts +1 -0
  156. package/utils/utils-common.js +24 -3
  157. package/utils/utils-common.js.map +1 -1
  158. package/platforms/android/nativescript.aar +0 -0
@@ -11,19 +11,6 @@ const symbolPropertyMap = {};
11
11
  const cssSymbolPropertyMap = {};
12
12
  const inheritableProperties = new Array();
13
13
  const inheritableCssProperties = new Array();
14
- function print(map) {
15
- const symbols = Object.getOwnPropertySymbols(map);
16
- for (const symbol of symbols) {
17
- const prop = map[symbol];
18
- if (!prop.registered) {
19
- console.log(`Property ${prop.name} not Registered!!!!!`);
20
- }
21
- }
22
- }
23
- export function _printUnregisteredProperties() {
24
- print(symbolPropertyMap);
25
- print(cssSymbolPropertyMap);
26
- }
27
14
  export function _getProperties() {
28
15
  return getPropertiesFromMap(symbolPropertyMap);
29
16
  }
@@ -94,155 +81,186 @@ function getPropertiesFromMap(map) {
94
81
  Object.getOwnPropertySymbols(map).forEach((symbol) => props.push(map[symbol]));
95
82
  return props;
96
83
  }
97
- export class Property {
98
- constructor(options) {
99
- this.enumerable = true;
100
- this.configurable = true;
101
- const propertyName = options.name;
102
- this.name = propertyName;
103
- const key = Symbol(propertyName + ':propertyKey');
104
- this.key = key;
105
- const getDefault = Symbol(propertyName + ':getDefault');
106
- this.getDefault = getDefault;
107
- const setNative = Symbol(propertyName + ':setNative');
108
- this.setNative = setNative;
109
- const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
110
- this.defaultValueKey = defaultValueKey;
111
- const defaultValue = options.defaultValue;
112
- this.defaultValue = defaultValue;
113
- const eventName = propertyName + 'Change';
114
- let equalityComparer = options.equalityComparer;
115
- let affectsLayout = options.affectsLayout;
116
- let valueChanged = options.valueChanged;
117
- let valueConverter = options.valueConverter;
118
- this.overrideHandlers = function (options) {
119
- if (typeof options.equalityComparer !== 'undefined') {
120
- equalityComparer = options.equalityComparer;
121
- }
122
- if (typeof options.affectsLayout !== 'undefined') {
123
- affectsLayout = options.affectsLayout;
84
+ function overrideHandlers(property) {
85
+ return function (options) {
86
+ if (property instanceof CssAnimationProperty || property instanceof CssProperty || property instanceof ShorthandProperty) {
87
+ Object.keys(options).forEach((key) => {
88
+ if (key === 'cssName') {
89
+ if (options[key] !== undefined) {
90
+ //@ts-ignore ignore readonly
91
+ property.cssName = 'css:' + options[key];
92
+ //@ts-ignore ignore readonly
93
+ property.cssLocalName = options[key];
94
+ }
95
+ }
96
+ else if (options[key] !== undefined) {
97
+ property[key] = options[key];
98
+ }
99
+ });
100
+ }
101
+ else {
102
+ Object.keys(options).forEach((key) => {
103
+ if (options[key] !== undefined) {
104
+ property[key] = options[key];
105
+ }
106
+ });
107
+ }
108
+ };
109
+ }
110
+ function getPropertySetter(property) {
111
+ return function (boxedValue) {
112
+ const reset = boxedValue === unsetValue;
113
+ let value;
114
+ let wrapped;
115
+ const key = property.key;
116
+ const defaultValue = property.defaultValue;
117
+ if (reset) {
118
+ value = property.defaultValue;
119
+ if (property instanceof CoercibleProperty) {
120
+ delete this[property.coerceKey];
124
121
  }
125
- if (typeof options.valueChanged !== 'undefined') {
126
- valueChanged = options.valueChanged;
122
+ }
123
+ else {
124
+ wrapped = boxedValue && boxedValue.wrapped;
125
+ value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
126
+ if (property.valueConverter && typeof value === 'string') {
127
+ value = property.valueConverter(value);
127
128
  }
128
- if (typeof options.valueConverter !== 'undefined') {
129
- valueConverter = options.valueConverter;
129
+ if (property instanceof CoercibleProperty) {
130
+ this[property.coerceKey] = value;
131
+ value = property.coerceValue(this, value);
130
132
  }
131
- };
132
- const property = this;
133
- this.set = function (boxedValue) {
134
- const reset = boxedValue === unsetValue;
135
- let value;
136
- let wrapped;
133
+ }
134
+ const oldValue = key in this ? this[key] : defaultValue;
135
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
136
+ if (wrapped || changed) {
137
+ const defaultValueKey = property.defaultValueKey;
138
+ const setNative = property.setNative;
139
+ const valueChanged = property.valueChanged;
140
+ const getDefault = property.getDefault;
141
+ const eventName = property.eventName;
142
+ const propertyName = property.name;
137
143
  if (reset) {
138
- value = defaultValue;
139
- }
140
- else {
141
- wrapped = boxedValue && boxedValue.wrapped;
142
- value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
143
- if (valueConverter && typeof value === 'string') {
144
- value = valueConverter(value);
145
- }
146
- }
147
- const oldValue = key in this ? this[key] : defaultValue;
148
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
149
- if (wrapped || changed) {
150
- if (affectsLayout) {
151
- this.requestLayout();
144
+ delete this[key];
145
+ if (valueChanged) {
146
+ valueChanged(this, oldValue, value);
152
147
  }
153
- if (reset) {
154
- delete this[key];
155
- if (valueChanged) {
156
- valueChanged(this, oldValue, value);
157
- }
158
- if (this[setNative]) {
159
- if (this._suspendNativeUpdatesCount) {
160
- if (this._suspendedUpdates) {
161
- this._suspendedUpdates[propertyName] = property;
162
- }
163
- }
164
- else {
165
- if (defaultValueKey in this) {
166
- this[setNative](this[defaultValueKey]);
167
- delete this[defaultValueKey];
168
- }
169
- else {
170
- this[setNative](defaultValue);
171
- }
148
+ if (this[setNative]) {
149
+ if (this._suspendNativeUpdatesCount) {
150
+ if (this._suspendedUpdates) {
151
+ this._suspendedUpdates[propertyName] = property;
172
152
  }
173
153
  }
174
- }
175
- else {
176
- this[key] = value;
177
- if (valueChanged) {
178
- valueChanged(this, oldValue, value);
179
- }
180
- if (this[setNative]) {
181
- if (this._suspendNativeUpdatesCount) {
182
- if (this._suspendedUpdates) {
183
- this._suspendedUpdates[propertyName] = property;
184
- }
154
+ else {
155
+ if (defaultValueKey in this) {
156
+ this[setNative](this[defaultValueKey]);
157
+ delete this[defaultValueKey];
185
158
  }
186
159
  else {
187
- if (!(defaultValueKey in this)) {
188
- this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
189
- }
190
- this[setNative](value);
160
+ this[setNative](defaultValue);
191
161
  }
192
162
  }
193
163
  }
194
- if (this.hasListeners(eventName)) {
195
- this.notify({
196
- object: this,
197
- eventName,
198
- propertyName,
199
- value,
200
- oldValue,
201
- });
164
+ }
165
+ else {
166
+ this[key] = value;
167
+ if (valueChanged) {
168
+ valueChanged(this, oldValue, value);
202
169
  }
203
- if (this.domNode) {
204
- if (reset) {
205
- this.domNode.attributeRemoved(propertyName);
170
+ if (this[setNative]) {
171
+ if (this._suspendNativeUpdatesCount) {
172
+ if (this._suspendedUpdates) {
173
+ this._suspendedUpdates[propertyName] = property;
174
+ }
206
175
  }
207
176
  else {
208
- this.domNode.attributeModified(propertyName, value);
177
+ if (!(defaultValueKey in this)) {
178
+ this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
179
+ }
180
+ this[setNative](value);
209
181
  }
210
182
  }
211
183
  }
212
- };
213
- this.get = function () {
214
- return key in this ? this[key] : defaultValue;
215
- };
216
- this.nativeValueChange = function (owner, value) {
217
- const oldValue = key in owner ? owner[key] : defaultValue;
218
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
219
- if (changed) {
220
- owner[key] = value;
221
- if (valueChanged) {
222
- valueChanged(owner, oldValue, value);
223
- }
224
- if (owner.nativeViewProtected && !(defaultValueKey in owner)) {
225
- owner[defaultValueKey] = owner[getDefault] ? owner[getDefault]() : defaultValue;
226
- }
227
- if (owner.hasListeners(eventName)) {
228
- owner.notify({
229
- object: owner,
230
- eventName,
231
- propertyName,
232
- value,
233
- oldValue,
234
- });
235
- }
236
- if (affectsLayout) {
237
- owner.requestLayout();
184
+ if (this.hasListeners(eventName)) {
185
+ this.notify({
186
+ object: this,
187
+ eventName,
188
+ propertyName,
189
+ value,
190
+ oldValue,
191
+ });
192
+ }
193
+ if (property.affectsLayout) {
194
+ this.requestLayout();
195
+ }
196
+ if (this.domNode) {
197
+ if (reset) {
198
+ this.domNode.attributeRemoved(propertyName);
238
199
  }
239
- if (owner.domNode) {
240
- owner.domNode.attributeModified(propertyName, value);
200
+ else {
201
+ this.domNode.attributeModified(propertyName, value);
241
202
  }
242
203
  }
204
+ }
205
+ };
206
+ }
207
+ export class Property {
208
+ constructor(options) {
209
+ this.enumerable = true;
210
+ this.configurable = true;
211
+ this.overrideHandlers = overrideHandlers(this);
212
+ this.overrideHandlers(options);
213
+ const propertyName = this.name;
214
+ const key = Symbol(propertyName + ':propertyKey');
215
+ this.key = key;
216
+ const getDefault = Symbol(propertyName + ':getDefault');
217
+ this.getDefault = getDefault;
218
+ const setNative = Symbol(propertyName + ':setNative');
219
+ this.setNative = setNative;
220
+ const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
221
+ this.defaultValueKey = defaultValueKey;
222
+ this.eventName = propertyName + 'Change';
223
+ const property = this;
224
+ this.set = getPropertySetter(this);
225
+ this.get = function () {
226
+ return key in this ? this[key] : property.defaultValue;
243
227
  };
244
228
  symbolPropertyMap[key] = this;
245
229
  }
230
+ nativeValueChange(owner, value) {
231
+ const key = this.key;
232
+ const defaultValue = this.defaultValue;
233
+ const oldValue = key in owner ? owner[key] : defaultValue;
234
+ const changed = this.equalityComparer ? !this.equalityComparer(oldValue, value) : oldValue !== value;
235
+ if (changed) {
236
+ const defaultValueKey = this.defaultValueKey;
237
+ const getDefault = this.getDefault;
238
+ const eventName = this.eventName;
239
+ const propertyName = this.name;
240
+ owner[key] = value;
241
+ if (this.valueChanged) {
242
+ this.valueChanged(owner, oldValue, value);
243
+ }
244
+ if (owner.nativeViewProtected && !(defaultValueKey in owner)) {
245
+ owner[defaultValueKey] = owner[getDefault] ? owner[getDefault]() : defaultValue;
246
+ }
247
+ if (owner.hasListeners(eventName)) {
248
+ owner.notify({
249
+ object: owner,
250
+ eventName,
251
+ propertyName,
252
+ value,
253
+ oldValue,
254
+ });
255
+ }
256
+ if (this.affectsLayout) {
257
+ owner.requestLayout();
258
+ }
259
+ if (owner.domNode) {
260
+ owner.domNode.attributeModified(propertyName, value);
261
+ }
262
+ }
263
+ }
246
264
  register(cls) {
247
265
  if (this.registered) {
248
266
  throw new Error(`Property ${this.name} already registered.`);
@@ -258,136 +276,22 @@ Property.prototype.isStyleProperty = false;
258
276
  export class CoercibleProperty extends Property {
259
277
  constructor(options) {
260
278
  super(options);
261
- const propertyName = options.name;
262
- const key = this.key;
263
- const getDefault = this.getDefault;
264
- const setNative = this.setNative;
265
- const defaultValueKey = this.defaultValueKey;
266
- const defaultValue = this.defaultValue;
267
- const coerceKey = Symbol(propertyName + ':coerceKey');
268
- const eventName = propertyName + 'Change';
269
- let affectsLayout = options.affectsLayout;
270
- let equalityComparer = options.equalityComparer;
271
- let valueChanged = options.valueChanged;
272
- let valueConverter = options.valueConverter;
273
- let coerceCallback = options.coerceValue;
274
- const property = this;
275
- this.overrideHandlers = function (options) {
276
- if (typeof options.equalityComparer !== 'undefined') {
277
- equalityComparer = options.equalityComparer;
278
- }
279
- if (typeof options.affectsLayout !== 'undefined') {
280
- affectsLayout = options.affectsLayout;
281
- }
282
- if (typeof options.valueChanged !== 'undefined') {
283
- valueChanged = options.valueChanged;
284
- }
285
- if (typeof options.valueConverter !== 'undefined') {
286
- valueConverter = options.valueConverter;
287
- }
288
- if (typeof options.coerceValue !== 'undefined') {
289
- coerceCallback = options.coerceValue;
290
- }
291
- };
292
- this.coerce = function (target) {
293
- const originalValue = coerceKey in target ? target[coerceKey] : defaultValue;
294
- // need that to make coercing but also fire change events
295
- target[propertyName] = originalValue;
296
- };
297
- this.set = function (boxedValue) {
298
- const reset = boxedValue === unsetValue;
299
- let value;
300
- let wrapped;
301
- if (reset) {
302
- value = defaultValue;
303
- delete this[coerceKey];
304
- }
305
- else {
306
- wrapped = boxedValue && boxedValue.wrapped;
307
- value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
308
- if (valueConverter && typeof value === 'string') {
309
- value = valueConverter(value);
310
- }
311
- this[coerceKey] = value;
312
- value = coerceCallback(this, value);
313
- }
314
- const oldValue = key in this ? this[key] : defaultValue;
315
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
316
- if (wrapped || changed) {
317
- if (reset) {
318
- delete this[key];
319
- if (valueChanged) {
320
- valueChanged(this, oldValue, value);
321
- }
322
- if (this[setNative]) {
323
- if (this._suspendNativeUpdatesCount) {
324
- if (this._suspendedUpdates) {
325
- this._suspendedUpdates[propertyName] = property;
326
- }
327
- }
328
- else {
329
- if (defaultValueKey in this) {
330
- this[setNative](this[defaultValueKey]);
331
- delete this[defaultValueKey];
332
- }
333
- else {
334
- this[setNative](defaultValue);
335
- }
336
- }
337
- }
338
- }
339
- else {
340
- this[key] = value;
341
- if (valueChanged) {
342
- valueChanged(this, oldValue, value);
343
- }
344
- if (this[setNative]) {
345
- if (this._suspendNativeUpdatesCount) {
346
- if (this._suspendedUpdates) {
347
- this._suspendedUpdates[propertyName] = property;
348
- }
349
- }
350
- else {
351
- if (!(defaultValueKey in this)) {
352
- this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
353
- }
354
- this[setNative](value);
355
- }
356
- }
357
- }
358
- if (this.hasListeners(eventName)) {
359
- this.notify({
360
- object: this,
361
- eventName,
362
- propertyName,
363
- value,
364
- oldValue,
365
- });
366
- }
367
- if (affectsLayout) {
368
- this.requestLayout();
369
- }
370
- if (this.domNode) {
371
- if (reset) {
372
- this.domNode.attributeRemoved(propertyName);
373
- }
374
- else {
375
- this.domNode.attributeModified(propertyName, value);
376
- }
377
- }
378
- }
379
- };
279
+ this.coerceKey = Symbol(this.name + ':coerceKey');
280
+ }
281
+ coerce(target) {
282
+ const originalValue = this.coerceKey in target ? target[this.coerceKey] : this.defaultValue;
283
+ // need that to make coercing but also fire change events
284
+ target[this.name] = originalValue;
380
285
  }
381
286
  }
382
287
  export class InheritedProperty extends Property {
383
288
  constructor(options) {
384
289
  super(options);
385
- const name = options.name;
386
290
  const key = this.key;
387
- const defaultValue = options.defaultValue;
388
- const sourceKey = Symbol(name + ':valueSourceKey');
291
+ const sourceKey = Symbol(this.name + ':valueSourceKey');
389
292
  this.sourceKey = sourceKey;
390
293
  const setBase = this.set;
294
+ const property = this;
391
295
  const setFunc = (valueSource) => function (value) {
392
296
  const that = this;
393
297
  let unboxedValue;
@@ -397,11 +301,11 @@ export class InheritedProperty extends Property {
397
301
  const parent = that.parent;
398
302
  // If we have parent and it has non-default value we use as our inherited value.
399
303
  if (parent && parent[sourceKey] !== 0 /* Default */) {
400
- unboxedValue = parent[name];
304
+ unboxedValue = parent[property.name];
401
305
  newValueSource = 1 /* Inherited */;
402
306
  }
403
307
  else {
404
- unboxedValue = defaultValue;
308
+ unboxedValue = property.defaultValue;
405
309
  newValueSource = 0 /* Default */;
406
310
  }
407
311
  }
@@ -439,212 +343,129 @@ export class InheritedProperty extends Property {
439
343
  inheritableProperties.push(this);
440
344
  }
441
345
  }
442
- export class CssProperty {
443
- constructor(options) {
444
- const propertyName = options.name;
445
- this.name = propertyName;
446
- cssPropertyNames.push(options.cssName);
447
- this.cssName = `css:${options.cssName}`;
448
- this.cssLocalName = options.cssName;
449
- const key = Symbol(propertyName + ':propertyKey');
450
- this.key = key;
451
- const sourceKey = Symbol(propertyName + ':valueSourceKey');
452
- this.sourceKey = sourceKey;
453
- const getDefault = Symbol(propertyName + ':getDefault');
454
- this.getDefault = getDefault;
455
- const setNative = Symbol(propertyName + ':setNative');
456
- this.setNative = setNative;
457
- const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
458
- this.defaultValueKey = defaultValueKey;
459
- const defaultValue = options.defaultValue;
460
- this.defaultValue = defaultValue;
461
- const eventName = propertyName + 'Change';
462
- let affectsLayout = options.affectsLayout;
463
- let equalityComparer = options.equalityComparer;
464
- let valueChanged = options.valueChanged;
465
- let valueConverter = options.valueConverter;
466
- this.overrideHandlers = function (options) {
467
- if (typeof options.equalityComparer !== 'undefined') {
468
- equalityComparer = options.equalityComparer;
469
- }
470
- if (typeof options.affectsLayout !== 'undefined') {
471
- affectsLayout = options.affectsLayout;
472
- }
473
- if (typeof options.valueChanged !== 'undefined') {
474
- valueChanged = options.valueChanged;
475
- }
476
- if (typeof options.valueConverter !== 'undefined') {
477
- valueConverter = options.valueConverter;
478
- }
479
- };
480
- const property = this;
481
- function setLocalValue(newValue) {
482
- const view = this.viewRef.get();
483
- if (!view) {
484
- Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
485
- return;
486
- }
487
- const reset = newValue === unsetValue || newValue === '';
488
- let value;
489
- if (reset) {
490
- value = defaultValue;
491
- delete this[sourceKey];
492
- }
493
- else {
494
- this[sourceKey] = 3 /* Local */;
495
- value = valueConverter && typeof newValue === 'string' ? valueConverter(newValue) : newValue;
496
- }
497
- const oldValue = key in this ? this[key] : defaultValue;
498
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
499
- if (changed) {
500
- if (reset) {
501
- delete this[key];
502
- if (valueChanged) {
503
- valueChanged(this, oldValue, value);
504
- }
505
- if (view[setNative]) {
506
- if (view._suspendNativeUpdatesCount) {
507
- if (view._suspendedUpdates) {
508
- view._suspendedUpdates[propertyName] = property;
509
- }
510
- }
511
- else {
512
- if (defaultValueKey in this) {
513
- view[setNative](this[defaultValueKey]);
514
- delete this[defaultValueKey];
515
- }
516
- else {
517
- view[setNative](defaultValue);
518
- }
519
- }
520
- }
521
- }
522
- else {
523
- this[key] = value;
524
- if (valueChanged) {
525
- valueChanged(this, oldValue, value);
526
- }
527
- if (view[setNative]) {
528
- if (view._suspendNativeUpdatesCount) {
529
- if (view._suspendedUpdates) {
530
- view._suspendedUpdates[propertyName] = property;
531
- }
532
- }
533
- else {
534
- if (!(defaultValueKey in this)) {
535
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
536
- }
537
- view[setNative](value);
538
- }
539
- }
540
- }
541
- if (this.hasListeners(eventName)) {
542
- this.notify({
543
- object: this,
544
- eventName,
545
- propertyName,
546
- value,
547
- oldValue,
548
- });
549
- }
550
- if (affectsLayout) {
551
- view.requestLayout();
552
- }
553
- }
346
+ function setCssFunc(property, valueSource) {
347
+ return function (newValue) {
348
+ const view = this.viewRef.get();
349
+ if (!view) {
350
+ Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
351
+ return;
554
352
  }
555
- function setCssValue(newValue) {
556
- const view = this.viewRef.get();
557
- if (!view) {
558
- Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
559
- return;
560
- }
353
+ const sourceKey = property.sourceKey;
354
+ if (valueSource === 2 /* Css */) {
561
355
  const currentValueSource = this[sourceKey] || 0 /* Default */;
562
356
  // We have localValueSource - NOOP.
563
357
  if (currentValueSource === 3 /* Local */) {
564
358
  return;
565
359
  }
566
- const reset = newValue === unsetValue || newValue === '';
567
- let value;
360
+ }
361
+ const defaultValue = property.defaultValue;
362
+ const key = property.key;
363
+ const reset = newValue === unsetValue || newValue === '';
364
+ let value;
365
+ if (reset) {
366
+ value = defaultValue;
367
+ delete this[sourceKey];
368
+ }
369
+ else {
370
+ this[sourceKey] = valueSource;
371
+ value = property.valueConverter && typeof newValue === 'string' ? property.valueConverter(newValue) : newValue;
372
+ }
373
+ const oldValue = key in this ? this[key] : defaultValue;
374
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
375
+ if (changed) {
376
+ const setNative = property.setNative;
377
+ const defaultValueKey = property.defaultValueKey;
378
+ const propertyName = property.name;
379
+ const valueChanged = property.valueChanged;
380
+ const eventName = property.eventName;
568
381
  if (reset) {
569
- value = defaultValue;
570
- delete this[sourceKey];
571
- }
572
- else {
573
- value = valueConverter && typeof newValue === 'string' ? valueConverter(newValue) : newValue;
574
- this[sourceKey] = 2 /* Css */;
575
- }
576
- const oldValue = key in this ? this[key] : defaultValue;
577
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
578
- if (changed) {
579
- if (reset) {
580
- delete this[key];
581
- if (valueChanged) {
582
- valueChanged(this, oldValue, value);
382
+ delete this[key];
383
+ if (valueChanged) {
384
+ valueChanged(this, oldValue, value);
385
+ }
386
+ if (view[setNative]) {
387
+ if (view._suspendNativeUpdatesCount) {
388
+ if (view._suspendedUpdates) {
389
+ view._suspendedUpdates[propertyName] = property;
390
+ }
583
391
  }
584
- if (view[setNative]) {
585
- if (view._suspendNativeUpdatesCount) {
586
- if (view._suspendedUpdates) {
587
- view._suspendedUpdates[propertyName] = property;
588
- }
392
+ else {
393
+ if (defaultValueKey in this) {
394
+ view[setNative](this[defaultValueKey]);
395
+ delete this[defaultValueKey];
589
396
  }
590
397
  else {
591
- if (defaultValueKey in this) {
592
- view[setNative](this[defaultValueKey]);
593
- delete this[defaultValueKey];
594
- }
595
- else {
596
- view[setNative](defaultValue);
597
- }
398
+ view[setNative](defaultValue);
598
399
  }
599
400
  }
600
401
  }
601
- else {
602
- this[key] = value;
603
- if (valueChanged) {
604
- valueChanged(this, oldValue, value);
605
- }
606
- if (view[setNative]) {
607
- if (view._suspendNativeUpdatesCount) {
608
- if (view._suspendedUpdates) {
609
- view._suspendedUpdates[propertyName] = property;
610
- }
402
+ }
403
+ else {
404
+ this[key] = value;
405
+ if (valueChanged) {
406
+ valueChanged(this, oldValue, value);
407
+ }
408
+ if (view[setNative]) {
409
+ if (view._suspendNativeUpdatesCount) {
410
+ if (view._suspendedUpdates) {
411
+ view._suspendedUpdates[propertyName] = property;
611
412
  }
612
- else {
613
- if (!(defaultValueKey in this)) {
614
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
615
- }
616
- view[setNative](value);
413
+ }
414
+ else {
415
+ if (!(defaultValueKey in this)) {
416
+ const getDefault = property.getDefault;
417
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
617
418
  }
419
+ view[setNative](value);
618
420
  }
619
421
  }
620
- if (this.hasListeners(eventName)) {
621
- this.notify({
622
- object: this,
623
- eventName,
624
- propertyName,
625
- value,
626
- oldValue,
627
- });
628
- }
629
- if (affectsLayout) {
630
- view.requestLayout();
631
- }
422
+ }
423
+ if (this.hasListeners(eventName)) {
424
+ this.notify({
425
+ object: this,
426
+ eventName,
427
+ propertyName,
428
+ value,
429
+ oldValue,
430
+ });
431
+ }
432
+ if (property.affectsLayout) {
433
+ view.requestLayout();
632
434
  }
633
435
  }
436
+ };
437
+ }
438
+ export class CssProperty {
439
+ constructor(options) {
440
+ this.overrideHandlers = overrideHandlers(this);
441
+ this.overrideHandlers(options);
442
+ const propertyName = this.name;
443
+ const key = Symbol(propertyName + ':propertyKey');
444
+ this.key = key;
445
+ const sourceKey = Symbol(propertyName + ':valueSourceKey');
446
+ this.sourceKey = sourceKey;
447
+ const getDefault = Symbol(propertyName + ':getDefault');
448
+ this.getDefault = getDefault;
449
+ const setNative = Symbol(propertyName + ':setNative');
450
+ this.setNative = setNative;
451
+ const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
452
+ this.defaultValueKey = defaultValueKey;
453
+ this.eventName = propertyName + 'Change';
454
+ const property = this;
634
455
  function get() {
635
- return key in this ? this[key] : defaultValue;
456
+ return key in this ? this[key] : property.defaultValue;
636
457
  }
637
458
  this.cssValueDescriptor = {
638
459
  enumerable: true,
639
460
  configurable: true,
640
461
  get: get,
641
- set: setCssValue,
462
+ set: setCssFunc(this, 2 /* Css */),
642
463
  };
643
464
  this.localValueDescriptor = {
644
465
  enumerable: true,
645
466
  configurable: true,
646
467
  get: get,
647
- set: setLocalValue,
468
+ set: setCssFunc(this, 3 /* Local */),
648
469
  };
649
470
  cssSymbolPropertyMap[key] = this;
650
471
  }
@@ -652,6 +473,8 @@ export class CssProperty {
652
473
  if (this.registered) {
653
474
  throw new Error(`Property ${this.name} already registered.`);
654
475
  }
476
+ // we add it so that overrideHandlers might work
477
+ cssPropertyNames.push(this.cssLocalName);
655
478
  this.registered = true;
656
479
  Object.defineProperty(cls.prototype, this.name, this.localValueDescriptor);
657
480
  Object.defineProperty(cls.prototype, this.cssName, this.cssValueDescriptor);
@@ -666,25 +489,19 @@ export class CssProperty {
666
489
  CssProperty.prototype.isStyleProperty = true;
667
490
  export class CssAnimationProperty {
668
491
  constructor(options) {
669
- const propertyName = options.name;
670
- this.name = propertyName;
671
- cssPropertyNames.push(options.cssName);
492
+ this.overrideHandlers = overrideHandlers(this);
493
+ this.overrideHandlers(options);
494
+ const propertyName = this.name;
672
495
  CssAnimationProperty.properties[propertyName] = this;
673
- if (options.cssName && options.cssName !== propertyName) {
674
- CssAnimationProperty.properties[options.cssName] = this;
496
+ if (this.cssLocalName && this.cssLocalName !== propertyName) {
497
+ CssAnimationProperty.properties[this.cssLocalName] = this;
675
498
  }
676
- this._valueConverter = options.valueConverter;
677
- const cssLocalName = options.cssName || propertyName;
678
- this.cssLocalName = cssLocalName;
679
- const cssName = 'css:' + cssLocalName;
680
- this.cssName = cssName;
681
499
  const keyframeName = 'keyframe:' + propertyName;
682
500
  this.keyframe = keyframeName;
683
501
  const defaultName = 'default:' + propertyName;
684
502
  const defaultValueKey = Symbol(defaultName);
685
503
  this.defaultValueKey = defaultValueKey;
686
- this.defaultValue = options.defaultValue;
687
- const cssValue = Symbol(cssName);
504
+ const cssValue = Symbol(this.cssName);
688
505
  const styleValue = Symbol(`local:${propertyName}`);
689
506
  const keyframeValue = Symbol(keyframeName);
690
507
  const computedValue = Symbol('computed-value:' + propertyName);
@@ -694,7 +511,7 @@ export class CssAnimationProperty {
694
511
  this.getDefault = Symbol(propertyName + ':getDefault');
695
512
  const getDefault = this.getDefault;
696
513
  const setNative = (this.setNative = Symbol(propertyName + ':setNative'));
697
- const eventName = propertyName + 'Change';
514
+ this.eventName = propertyName + 'Change';
698
515
  const property = this;
699
516
  function descriptor(symbol, propertySource, enumerable, configurable, getsComputed) {
700
517
  return {
@@ -736,8 +553,8 @@ export class CssAnimationProperty {
736
553
  }
737
554
  }
738
555
  else {
739
- if (options.valueConverter && typeof boxedValue === 'string') {
740
- boxedValue = options.valueConverter(boxedValue);
556
+ if (property.valueConverter && typeof boxedValue === 'string') {
557
+ boxedValue = property.valueConverter(boxedValue);
741
558
  }
742
559
  this[symbol] = boxedValue;
743
560
  if (this[computedSource] <= propertySource) {
@@ -748,9 +565,9 @@ export class CssAnimationProperty {
748
565
  const value = this[computedValue];
749
566
  const source = this[computedSource];
750
567
  const isSet = source !== 0 /* Default */;
751
- const computedValueChanged = oldValue !== value && (!options.equalityComparer || !options.equalityComparer(oldValue, value));
752
- if (computedValueChanged && options.valueChanged) {
753
- options.valueChanged(this, oldValue, value);
568
+ const computedValueChanged = oldValue !== value && (!property.equalityComparer || !property.equalityComparer(oldValue, value));
569
+ if (computedValueChanged && property.valueChanged) {
570
+ property.valueChanged(this, oldValue, value);
754
571
  }
755
572
  if (view[setNative] && (computedValueChanged || isSet !== wasSet)) {
756
573
  if (view._suspendNativeUpdatesCount) {
@@ -761,7 +578,7 @@ export class CssAnimationProperty {
761
578
  else {
762
579
  if (isSet) {
763
580
  if (!wasSet && !(defaultValueKey in this)) {
764
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : options.defaultValue;
581
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : property.defaultValue;
765
582
  }
766
583
  view[setNative](value);
767
584
  }
@@ -770,11 +587,12 @@ export class CssAnimationProperty {
770
587
  view[setNative](this[defaultValueKey]);
771
588
  }
772
589
  else {
773
- view[setNative](options.defaultValue);
590
+ view[setNative](property.defaultValue);
774
591
  }
775
592
  }
776
593
  }
777
594
  }
595
+ const eventName = property.eventName;
778
596
  if (computedValueChanged && this.hasListeners(eventName)) {
779
597
  this.notify({
780
598
  object: this,
@@ -784,6 +602,9 @@ export class CssAnimationProperty {
784
602
  oldValue,
785
603
  });
786
604
  }
605
+ if (property.affectsLayout) {
606
+ view.requestLayout();
607
+ }
787
608
  },
788
609
  };
789
610
  }
@@ -794,16 +615,18 @@ export class CssAnimationProperty {
794
615
  symbolPropertyMap[computedValue] = this;
795
616
  cssSymbolPropertyMap[computedValue] = this;
796
617
  this.register = (cls) => {
797
- cls.prototype[computedValue] = options.defaultValue;
618
+ // we add it so that overrideHandlers might work
619
+ cssPropertyNames.push(this.cssLocalName);
620
+ cls.prototype[computedValue] = this.defaultValue;
798
621
  cls.prototype[computedSource] = 0 /* Default */;
799
622
  cls.prototype[cssValue] = unsetValue;
800
623
  cls.prototype[styleValue] = unsetValue;
801
624
  cls.prototype[keyframeValue] = unsetValue;
802
625
  Object.defineProperty(cls.prototype, defaultName, defaultPropertyDescriptor);
803
- Object.defineProperty(cls.prototype, cssName, cssPropertyDescriptor);
626
+ Object.defineProperty(cls.prototype, this.cssName, cssPropertyDescriptor);
804
627
  Object.defineProperty(cls.prototype, propertyName, stylePropertyDescriptor);
805
- if (options.cssName && options.cssName !== options.name) {
806
- Object.defineProperty(cls.prototype, options.cssName, stylePropertyDescriptor);
628
+ if (this.cssLocalName && this.cssLocalName !== this.name) {
629
+ Object.defineProperty(cls.prototype, this.cssLocalName, stylePropertyDescriptor);
807
630
  }
808
631
  Object.defineProperty(cls.prototype, keyframeName, keyframePropertyDescriptor);
809
632
  };
@@ -832,200 +655,180 @@ export class CssAnimationProperty {
832
655
  }
833
656
  CssAnimationProperty.properties = {};
834
657
  CssAnimationProperty.prototype.isStyleProperty = true;
835
- export class InheritedCssProperty extends CssProperty {
836
- constructor(options) {
837
- super(options);
838
- const propertyName = options.name;
839
- const key = this.key;
840
- const sourceKey = this.sourceKey;
841
- const getDefault = this.getDefault;
842
- const setNative = this.setNative;
843
- const defaultValueKey = this.defaultValueKey;
844
- const eventName = propertyName + 'Change';
845
- let defaultValue = options.defaultValue;
846
- let affectsLayout = options.affectsLayout;
847
- let equalityComparer = options.equalityComparer;
848
- let valueChanged = options.valueChanged;
849
- let valueConverter = options.valueConverter;
850
- const property = this;
851
- this.overrideHandlers = function (options) {
852
- if (typeof options.equalityComparer !== 'undefined') {
853
- equalityComparer = options.equalityComparer;
854
- }
855
- if (typeof options.affectsLayout !== 'undefined') {
856
- affectsLayout = options.affectsLayout;
857
- }
858
- if (typeof options.valueChanged !== 'undefined') {
859
- valueChanged = options.valueChanged;
860
- }
861
- if (typeof options.valueConverter !== 'undefined') {
862
- valueConverter = options.valueConverter;
658
+ function setCssInheritedFunc(property, valueSource) {
659
+ return function (boxedValue) {
660
+ const view = this.viewRef.get();
661
+ if (!view) {
662
+ Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
663
+ return;
664
+ }
665
+ const key = property.key;
666
+ const defaultValue = property.defaultValue;
667
+ const sourceKey = property.sourceKey;
668
+ const propertyName = property.name;
669
+ const reset = boxedValue === unsetValue || boxedValue === '';
670
+ const currentValueSource = this[sourceKey] || 0 /* Default */;
671
+ if (reset) {
672
+ // If we want to reset cssValue and we have localValue - return;
673
+ if (valueSource === 2 /* Css */ && currentValueSource === 3 /* Local */) {
674
+ return;
863
675
  }
864
- };
865
- const setFunc = (valueSource) => function (boxedValue) {
866
- const view = this.viewRef.get();
867
- if (!view) {
868
- Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
676
+ }
677
+ else {
678
+ if (currentValueSource > valueSource) {
869
679
  return;
870
680
  }
871
- const reset = boxedValue === unsetValue || boxedValue === '';
872
- const currentValueSource = this[sourceKey] || 0 /* Default */;
873
- if (reset) {
874
- // If we want to reset cssValue and we have localValue - return;
875
- if (valueSource === 2 /* Css */ && currentValueSource === 3 /* Local */) {
876
- return;
877
- }
681
+ }
682
+ const oldValue = key in this ? this[key] : defaultValue;
683
+ let value;
684
+ let unsetNativeValue = false;
685
+ if (reset) {
686
+ // If unsetValue - we want to reset this property.
687
+ const parent = view.parent;
688
+ const style = parent ? parent.style : null;
689
+ // If we have parent and it has non-default value we use as our inherited value.
690
+ if (style && style[sourceKey] > 0 /* Default */) {
691
+ value = style[propertyName];
692
+ this[sourceKey] = 1 /* Inherited */;
693
+ this[key] = value;
878
694
  }
879
695
  else {
880
- if (currentValueSource > valueSource) {
881
- return;
882
- }
696
+ value = defaultValue;
697
+ delete this[sourceKey];
698
+ delete this[key];
699
+ unsetNativeValue = true;
883
700
  }
884
- const oldValue = key in this ? this[key] : defaultValue;
885
- let value;
886
- let unsetNativeValue = false;
887
- if (reset) {
888
- // If unsetValue - we want to reset this property.
889
- const parent = view.parent;
890
- const style = parent ? parent.style : null;
891
- // If we have parent and it has non-default value we use as our inherited value.
892
- if (style && style[sourceKey] > 0 /* Default */) {
893
- value = style[propertyName];
894
- this[sourceKey] = 1 /* Inherited */;
895
- this[key] = value;
896
- }
897
- else {
898
- value = defaultValue;
899
- delete this[sourceKey];
900
- delete this[key];
901
- unsetNativeValue = true;
902
- }
701
+ }
702
+ else {
703
+ this[sourceKey] = valueSource;
704
+ if (property.valueConverter && typeof boxedValue === 'string') {
705
+ value = property.valueConverter(boxedValue);
903
706
  }
904
707
  else {
905
- this[sourceKey] = valueSource;
906
- if (valueConverter && typeof boxedValue === 'string') {
907
- value = valueConverter(boxedValue);
908
- }
909
- else {
910
- value = boxedValue;
911
- }
912
- this[key] = value;
708
+ value = boxedValue;
913
709
  }
914
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
915
- if (changed) {
916
- if (valueChanged) {
917
- valueChanged(this, oldValue, value);
918
- }
919
- if (view[setNative]) {
920
- if (view._suspendNativeUpdatesCount) {
921
- if (view._suspendedUpdates) {
922
- view._suspendedUpdates[propertyName] = property;
923
- }
710
+ this[key] = value;
711
+ }
712
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
713
+ if (changed) {
714
+ const setNative = property.setNative;
715
+ const defaultValueKey = property.defaultValueKey;
716
+ const eventName = property.eventName;
717
+ const getDefault = property.getDefault;
718
+ if (property.valueChanged) {
719
+ property.valueChanged(this, oldValue, value);
720
+ }
721
+ if (view[setNative]) {
722
+ if (view._suspendNativeUpdatesCount) {
723
+ if (view._suspendedUpdates) {
724
+ view._suspendedUpdates[propertyName] = property;
924
725
  }
925
- else {
926
- if (unsetNativeValue) {
927
- if (defaultValueKey in this) {
928
- view[setNative](this[defaultValueKey]);
929
- delete this[defaultValueKey];
930
- }
931
- else {
932
- view[setNative](defaultValue);
933
- }
726
+ }
727
+ else {
728
+ if (unsetNativeValue) {
729
+ if (defaultValueKey in this) {
730
+ view[setNative](this[defaultValueKey]);
731
+ delete this[defaultValueKey];
934
732
  }
935
733
  else {
936
- if (!(defaultValueKey in this)) {
937
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
938
- }
939
- view[setNative](value);
940
- }
941
- }
942
- }
943
- if (this.hasListeners(eventName)) {
944
- this.notify({
945
- object: this,
946
- eventName,
947
- propertyName,
948
- value,
949
- oldValue,
950
- });
951
- }
952
- if (affectsLayout) {
953
- view.requestLayout();
954
- }
955
- view.eachChild((child) => {
956
- const childStyle = child.style;
957
- const childValueSource = childStyle[sourceKey] || 0 /* Default */;
958
- if (reset) {
959
- if (childValueSource === 1 /* Inherited */) {
960
- setDefaultFunc.call(childStyle, unsetValue);
734
+ view[setNative](defaultValue);
961
735
  }
962
736
  }
963
737
  else {
964
- if (childValueSource <= 1 /* Inherited */) {
965
- setInheritedFunc.call(childStyle, value);
738
+ if (!(defaultValueKey in this)) {
739
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
966
740
  }
741
+ view[setNative](value);
967
742
  }
968
- return true;
743
+ }
744
+ }
745
+ if (this.hasListeners(eventName)) {
746
+ this.notify({
747
+ object: this,
748
+ eventName,
749
+ propertyName,
750
+ value,
751
+ oldValue,
969
752
  });
970
753
  }
971
- };
972
- const setDefaultFunc = setFunc(0 /* Default */);
973
- const setInheritedFunc = setFunc(1 /* Inherited */);
974
- this.setInheritedValue = setInheritedFunc;
975
- this.cssValueDescriptor.set = setFunc(2 /* Css */);
976
- this.localValueDescriptor.set = setFunc(3 /* Local */);
754
+ if (property.affectsLayout) {
755
+ view.requestLayout();
756
+ }
757
+ view.eachChild((child) => {
758
+ const childStyle = child.style;
759
+ const childValueSource = childStyle[sourceKey] || 0 /* Default */;
760
+ if (reset) {
761
+ if (childValueSource === 1 /* Inherited */) {
762
+ property.setDefaultValue.call(childStyle, unsetValue);
763
+ }
764
+ }
765
+ else {
766
+ if (childValueSource <= 1 /* Inherited */) {
767
+ property.setInheritedValue.call(childStyle, value);
768
+ }
769
+ }
770
+ return true;
771
+ });
772
+ }
773
+ };
774
+ }
775
+ export class InheritedCssProperty extends CssProperty {
776
+ constructor(options) {
777
+ super(options);
778
+ const propertyName = options.name;
779
+ InheritedCssProperty.properties[propertyName] = this;
780
+ this.setDefaultValue = setCssInheritedFunc(this, 0 /* Default */);
781
+ this.setInheritedValue = setCssInheritedFunc(this, 1 /* Inherited */);
782
+ this.cssValueDescriptor.set = setCssInheritedFunc(this, 2 /* Css */);
783
+ this.localValueDescriptor.set = setCssInheritedFunc(this, 3 /* Local */);
977
784
  inheritableCssProperties.push(this);
978
785
  }
979
786
  }
787
+ InheritedCssProperty.properties = {};
788
+ function setShorthandFunc(property, valueSource) {
789
+ return function (newValue) {
790
+ const view = this.viewRef.get();
791
+ if (!view) {
792
+ Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
793
+ return;
794
+ }
795
+ view._batchUpdate(() => {
796
+ for (const [p, v] of property.converter(newValue)) {
797
+ if (valueSource === 2 /* Css */) {
798
+ this[p.cssName] = v;
799
+ }
800
+ else {
801
+ this[p.name] = v;
802
+ }
803
+ }
804
+ });
805
+ };
806
+ }
980
807
  export class ShorthandProperty {
981
808
  constructor(options) {
982
- this.name = options.name;
809
+ this.overrideHandlers = overrideHandlers(this);
810
+ this.overrideHandlers(options);
983
811
  const key = Symbol(this.name + ':propertyKey');
812
+ ShorthandProperty.properties[this.name] = this;
984
813
  this.key = key;
985
- this.cssName = `css:${options.cssName}`;
986
- this.cssLocalName = `${options.cssName}`;
987
- const converter = options.converter;
988
- function setLocalValue(value) {
989
- const view = this.viewRef.get();
990
- if (!view) {
991
- Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
992
- return;
993
- }
994
- view._batchUpdate(() => {
995
- for (const [p, v] of converter(value)) {
996
- this[p.name] = v;
997
- }
998
- });
999
- }
1000
- function setCssValue(value) {
1001
- const view = this.viewRef.get();
1002
- if (!view) {
1003
- Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
1004
- return;
1005
- }
1006
- view._batchUpdate(() => {
1007
- for (const [p, v] of converter(value)) {
1008
- this[p.cssName] = v;
1009
- }
1010
- });
1011
- }
1012
814
  this.cssValueDescriptor = {
1013
815
  enumerable: true,
1014
816
  configurable: true,
1015
817
  get: options.getter,
1016
- set: setCssValue,
818
+ set: setShorthandFunc(this, 2 /* Css */),
1017
819
  };
1018
820
  this.localValueDescriptor = {
1019
821
  enumerable: true,
1020
822
  configurable: true,
1021
823
  get: options.getter,
1022
- set: setLocalValue,
824
+ set: setShorthandFunc(this, 3 /* Local */),
1023
825
  };
826
+ const property = this;
1024
827
  this.propertyBagDescriptor = {
1025
828
  enumerable: false,
1026
829
  configurable: true,
1027
830
  set(value) {
1028
- converter(value).forEach(([property, value]) => {
831
+ property.converter(value).forEach(([property, value]) => {
1029
832
  this[property.cssLocalName] = value;
1030
833
  });
1031
834
  },
@@ -1045,9 +848,10 @@ export class ShorthandProperty {
1045
848
  Object.defineProperty(cls.prototype.PropertyBag, this.cssLocalName, this.propertyBagDescriptor);
1046
849
  }
1047
850
  }
1048
- function inheritablePropertyValuesOn(view) {
851
+ ShorthandProperty.properties = {};
852
+ function inheritablePropertyValuesOn(view, properties) {
1049
853
  const array = new Array();
1050
- for (const prop of inheritableProperties) {
854
+ for (const prop of properties) {
1051
855
  const sourceKey = prop.sourceKey;
1052
856
  const valueSource = view[sourceKey] || 0 /* Default */;
1053
857
  if (valueSource !== 0 /* Default */) {
@@ -1058,19 +862,6 @@ function inheritablePropertyValuesOn(view) {
1058
862
  }
1059
863
  return array;
1060
864
  }
1061
- function inheritableCssPropertyValuesOn(style) {
1062
- const array = new Array();
1063
- for (const prop of inheritableCssProperties) {
1064
- const sourceKey = prop.sourceKey;
1065
- const valueSource = style[sourceKey] || 0 /* Default */;
1066
- if (valueSource !== 0 /* Default */) {
1067
- // use prop.name as it will return value or default value.
1068
- // prop.key will return undefined if property is set the same value as default one.
1069
- array.push({ property: prop, value: style[prop.name] });
1070
- }
1071
- }
1072
- return array;
1073
- }
1074
865
  export const initNativeView = profile('"properties".initNativeView', function initNativeView(view) {
1075
866
  const wasSuspended = view.suspendRequestLayout;
1076
867
  view.suspendRequestLayout = true;
@@ -1224,8 +1015,14 @@ export function resetCSSProperties(style) {
1224
1015
  }
1225
1016
  }
1226
1017
  }
1018
+ export function propagateInheritableCssProperties(style, child) {
1019
+ return _propagateInheritableProperties(style, child, inheritableCssProperties);
1020
+ }
1227
1021
  export function propagateInheritableProperties(view, child) {
1228
- const inheritablePropertyValues = inheritablePropertyValuesOn(view);
1022
+ return _propagateInheritableProperties(view, child, inheritableProperties);
1023
+ }
1024
+ function _propagateInheritableProperties(view, child, properties) {
1025
+ const inheritablePropertyValues = inheritablePropertyValuesOn(view, properties);
1229
1026
  for (const pair of inheritablePropertyValues) {
1230
1027
  const prop = pair.property;
1231
1028
  const sourceKey = prop.sourceKey;
@@ -1235,17 +1032,6 @@ export function propagateInheritableProperties(view, child) {
1235
1032
  }
1236
1033
  }
1237
1034
  }
1238
- export function propagateInheritableCssProperties(parentStyle, childStyle) {
1239
- const inheritableCssPropertyValues = inheritableCssPropertyValuesOn(parentStyle);
1240
- for (const pair of inheritableCssPropertyValues) {
1241
- const prop = pair.property;
1242
- const sourceKey = prop.sourceKey;
1243
- const currentValueSource = childStyle[sourceKey] || 0 /* Default */;
1244
- if (currentValueSource <= 1 /* Inherited */) {
1245
- prop.setInheritedValue.call(childStyle, pair.value, 1 /* Inherited */);
1246
- }
1247
- }
1248
- }
1249
1035
  export function makeValidator(...values) {
1250
1036
  const set = new Set(values);
1251
1037
  return (value) => set.has(value);