bruce-models 7.1.19 → 7.1.20
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/dist/bruce-models.es5.js +137 -107
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +137 -107
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/calculator/calculator.js +136 -106
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/calculator/calculator.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -5188,136 +5188,166 @@
|
|
|
5188
5188
|
if (type == "number" && field.type == EValueType.Color) {
|
|
5189
5189
|
field.type = EValueType.Input;
|
|
5190
5190
|
}
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
value = assertColor(value);
|
|
5198
|
-
if (value && type == "string") {
|
|
5199
|
-
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5191
|
+
// Custom resolution.
|
|
5192
|
+
if (field.value instanceof Function) {
|
|
5193
|
+
value = field.value(data, tags);
|
|
5194
|
+
if (type == "number") {
|
|
5195
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5196
|
+
value = Number(value);
|
|
5200
5197
|
}
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
if (type === "number") {
|
|
5204
|
-
break;
|
|
5198
|
+
else if (typeof value != "number") {
|
|
5199
|
+
value = null;
|
|
5205
5200
|
}
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
if (value
|
|
5209
|
-
value =
|
|
5201
|
+
}
|
|
5202
|
+
else if (type == "string") {
|
|
5203
|
+
if (typeof value == "number") {
|
|
5204
|
+
value = String(value);
|
|
5210
5205
|
}
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5206
|
+
else if (typeof value == "object") {
|
|
5207
|
+
if (isColor(value)) {
|
|
5208
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5209
|
+
}
|
|
5210
|
+
else {
|
|
5211
|
+
value = null;
|
|
5212
|
+
}
|
|
5215
5213
|
}
|
|
5216
|
-
|
|
5214
|
+
}
|
|
5215
|
+
else if (type == "color") {
|
|
5217
5216
|
value = assertColor(value);
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
else {
|
|
5220
|
+
switch (field.type) {
|
|
5221
|
+
case EValueType.Color:
|
|
5222
|
+
if (type === "number") {
|
|
5223
|
+
break;
|
|
5224
|
+
}
|
|
5225
|
+
value = field.value;
|
|
5226
|
+
value = assertColor(value);
|
|
5227
|
+
if (value && type == "string") {
|
|
5228
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5229
|
+
}
|
|
5224
5230
|
break;
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
if (tag.Color) {
|
|
5229
|
-
value = exports.Color.ColorFromStr(tag.Color);
|
|
5230
|
-
value = assertColor(value);
|
|
5231
|
-
if (value) {
|
|
5232
|
-
break;
|
|
5233
|
-
}
|
|
5231
|
+
case EValueType.Gradient:
|
|
5232
|
+
if (type === "number") {
|
|
5233
|
+
break;
|
|
5234
5234
|
}
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
if (type == "
|
|
5248
|
-
|
|
5249
|
-
value = Number(value);
|
|
5250
|
-
}
|
|
5251
|
-
else if (typeof value != "number") {
|
|
5252
|
-
value = null;
|
|
5253
|
-
}
|
|
5235
|
+
value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
|
|
5236
|
+
value = assertColor(value);
|
|
5237
|
+
if (value && type == "string") {
|
|
5238
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5239
|
+
}
|
|
5240
|
+
break;
|
|
5241
|
+
case EValueType.RandomColor:
|
|
5242
|
+
if (type === "number") {
|
|
5243
|
+
break;
|
|
5244
|
+
}
|
|
5245
|
+
value = exports.Color.RandomColor();
|
|
5246
|
+
value = assertColor(value);
|
|
5247
|
+
if (value && type == "string") {
|
|
5248
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5254
5249
|
}
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5250
|
+
break;
|
|
5251
|
+
case EValueType.TagColor:
|
|
5252
|
+
if (type === "number") {
|
|
5253
|
+
break;
|
|
5254
|
+
}
|
|
5255
|
+
for (let i = 0; i < tags.length; i++) {
|
|
5256
|
+
const tag = tags[i];
|
|
5257
|
+
if (tag.Color) {
|
|
5258
|
+
value = exports.Color.ColorFromStr(tag.Color);
|
|
5259
|
+
value = assertColor(value);
|
|
5260
|
+
if (value) {
|
|
5261
|
+
break;
|
|
5262
|
+
}
|
|
5258
5263
|
}
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5264
|
+
}
|
|
5265
|
+
if (value && type == "string") {
|
|
5266
|
+
const cColor = value;
|
|
5267
|
+
value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
|
|
5268
|
+
}
|
|
5269
|
+
break;
|
|
5270
|
+
// Input can be an arbitrary value.
|
|
5271
|
+
// Eg: Result is a colour, a number, a string.
|
|
5272
|
+
// This means we first calculate the value, then validate it in the context of the desired type.
|
|
5273
|
+
case EValueType.Input:
|
|
5274
|
+
value = GetInputValue(field.value, data);
|
|
5275
|
+
if (value != null) {
|
|
5276
|
+
if (type == "number") {
|
|
5277
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5278
|
+
value = Number(value);
|
|
5262
5279
|
}
|
|
5263
|
-
else {
|
|
5280
|
+
else if (typeof value != "number") {
|
|
5264
5281
|
value = null;
|
|
5265
5282
|
}
|
|
5266
5283
|
}
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
if (type == "number") {
|
|
5280
|
-
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5281
|
-
value = Number(value);
|
|
5284
|
+
else if (type == "string") {
|
|
5285
|
+
if (typeof value == "number") {
|
|
5286
|
+
value = String(value);
|
|
5287
|
+
}
|
|
5288
|
+
else if (typeof value == "object") {
|
|
5289
|
+
if (isColor(value)) {
|
|
5290
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5291
|
+
}
|
|
5292
|
+
else {
|
|
5293
|
+
value = null;
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5282
5296
|
}
|
|
5283
|
-
else if (
|
|
5284
|
-
value =
|
|
5297
|
+
else if (type == "color") {
|
|
5298
|
+
value = assertColor(value);
|
|
5285
5299
|
}
|
|
5286
5300
|
}
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5301
|
+
break;
|
|
5302
|
+
// Mapping can be an arbitrary value.
|
|
5303
|
+
// Eg: mapping a value to a Client File ID, or a colour, or a number.
|
|
5304
|
+
// This means we first calculate the value, then validate it in the context of the desired type.
|
|
5305
|
+
case EValueType.Mapping:
|
|
5306
|
+
value = GetMappingValue(field.value, data);
|
|
5307
|
+
if (value != null) {
|
|
5308
|
+
if (type == "number") {
|
|
5309
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5310
|
+
value = Number(value);
|
|
5294
5311
|
}
|
|
5295
|
-
else {
|
|
5312
|
+
else if (typeof value != "number") {
|
|
5296
5313
|
value = null;
|
|
5297
5314
|
}
|
|
5298
5315
|
}
|
|
5316
|
+
else if (type == "string") {
|
|
5317
|
+
if (typeof value == "number") {
|
|
5318
|
+
value = String(value);
|
|
5319
|
+
}
|
|
5320
|
+
else if (typeof value == "object") {
|
|
5321
|
+
if (isColor(value)) {
|
|
5322
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5323
|
+
}
|
|
5324
|
+
else {
|
|
5325
|
+
value = null;
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
else if (type == "color") {
|
|
5330
|
+
value = assertColor(typeof value === "number" ? String(value) : value);
|
|
5331
|
+
}
|
|
5299
5332
|
}
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5333
|
+
break;
|
|
5334
|
+
}
|
|
5335
|
+
// Extra layer of validation.
|
|
5336
|
+
// This is a backup in case some branch above failed to convert into the right type.
|
|
5337
|
+
if (type == "number") {
|
|
5338
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
5339
|
+
value = null;
|
|
5303
5340
|
}
|
|
5304
|
-
break;
|
|
5305
|
-
}
|
|
5306
|
-
// Extra layer of validation.
|
|
5307
|
-
// This is a backup in case some branch above failed to convert into the right type.
|
|
5308
|
-
if (type == "number") {
|
|
5309
|
-
if (typeof value !== "number" || isNaN(value)) {
|
|
5310
|
-
value = null;
|
|
5311
5341
|
}
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5342
|
+
else if (type == "color") {
|
|
5343
|
+
if (typeof value !== "object" || !value) {
|
|
5344
|
+
value = null;
|
|
5345
|
+
}
|
|
5316
5346
|
}
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5347
|
+
else if (type == "string") {
|
|
5348
|
+
if (typeof value !== "string" || !value) {
|
|
5349
|
+
value = null;
|
|
5350
|
+
}
|
|
5321
5351
|
}
|
|
5322
5352
|
}
|
|
5323
5353
|
if (value != null) {
|
|
@@ -17140,7 +17170,7 @@
|
|
|
17140
17170
|
})(exports.ChangeSet || (exports.ChangeSet = {}));
|
|
17141
17171
|
|
|
17142
17172
|
// This is updated with the package.json version on build.
|
|
17143
|
-
const VERSION = "7.1.
|
|
17173
|
+
const VERSION = "7.1.20";
|
|
17144
17174
|
|
|
17145
17175
|
exports.VERSION = VERSION;
|
|
17146
17176
|
exports.AbstractApi = AbstractApi;
|