bruce-models 1.8.3 → 1.8.5
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 +72 -0
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +72 -0
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/calculator/calculator.js +72 -0
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/types/calculator/calculator.d.ts +3 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -2045,6 +2045,7 @@
|
|
|
2045
2045
|
/**
|
|
2046
2046
|
* Calculates the value of arbitrary field options.
|
|
2047
2047
|
* The context calling this should validate results and parse stuff if needed.
|
|
2048
|
+
* @deprecated use specific calls: eg GetColor or GetNumber.
|
|
2048
2049
|
* @param fields
|
|
2049
2050
|
* @param entity
|
|
2050
2051
|
* @param tags
|
|
@@ -2149,6 +2150,77 @@
|
|
|
2149
2150
|
return null;
|
|
2150
2151
|
}
|
|
2151
2152
|
Calculator.GetColor = GetColor;
|
|
2153
|
+
function GetNumber(fields, entity, tags) {
|
|
2154
|
+
if (!tags) {
|
|
2155
|
+
tags = [];
|
|
2156
|
+
}
|
|
2157
|
+
if (!entity) {
|
|
2158
|
+
entity = {};
|
|
2159
|
+
}
|
|
2160
|
+
for (let i = 0; i < fields.length; i++) {
|
|
2161
|
+
const field = fields[i];
|
|
2162
|
+
let value;
|
|
2163
|
+
switch (field.type) {
|
|
2164
|
+
case EValueType.Gradient:
|
|
2165
|
+
value = Number(GetGradientValue(field.value, entity));
|
|
2166
|
+
break;
|
|
2167
|
+
case EValueType.Color:
|
|
2168
|
+
case EValueType.Input:
|
|
2169
|
+
value = Number(GetInputValue(field.value, entity));
|
|
2170
|
+
break;
|
|
2171
|
+
case EValueType.Mapping:
|
|
2172
|
+
value = Number(GetMappingValue(field.value, entity));
|
|
2173
|
+
break;
|
|
2174
|
+
}
|
|
2175
|
+
if (value || value == 0) {
|
|
2176
|
+
return value;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
return null;
|
|
2180
|
+
}
|
|
2181
|
+
Calculator.GetNumber = GetNumber;
|
|
2182
|
+
function GetString(fields, entity, tags) {
|
|
2183
|
+
if (!tags) {
|
|
2184
|
+
tags = [];
|
|
2185
|
+
}
|
|
2186
|
+
if (!entity) {
|
|
2187
|
+
entity = {};
|
|
2188
|
+
}
|
|
2189
|
+
for (let i = 0; i < fields.length; i++) {
|
|
2190
|
+
const field = fields[i];
|
|
2191
|
+
let value;
|
|
2192
|
+
switch (field.type) {
|
|
2193
|
+
case EValueType.Gradient:
|
|
2194
|
+
value = String(GetGradientValue(field.value, entity));
|
|
2195
|
+
break;
|
|
2196
|
+
case EValueType.Color:
|
|
2197
|
+
case EValueType.Input:
|
|
2198
|
+
value = String(GetInputValue(field.value, entity));
|
|
2199
|
+
break;
|
|
2200
|
+
case EValueType.Mapping:
|
|
2201
|
+
value = String(GetMappingValue(field.value, entity));
|
|
2202
|
+
break;
|
|
2203
|
+
case EValueType.RandomColor:
|
|
2204
|
+
var color = exports.Color.RandomColor();
|
|
2205
|
+
value = `rgba(${color.red},${color.green},${color.blue},${color.alpha})`;
|
|
2206
|
+
break;
|
|
2207
|
+
case EValueType.TagColor:
|
|
2208
|
+
for (let i = 0; i < tags.length; i++) {
|
|
2209
|
+
const tag = tags[i];
|
|
2210
|
+
if (tag.Color) {
|
|
2211
|
+
value = tag.Color;
|
|
2212
|
+
break;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
break;
|
|
2216
|
+
}
|
|
2217
|
+
if (value) {
|
|
2218
|
+
return value;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
return null;
|
|
2222
|
+
}
|
|
2223
|
+
Calculator.GetString = GetString;
|
|
2152
2224
|
function GetMappingValue(value, entity) {
|
|
2153
2225
|
const attrPath = parseLegacyPath(value.field);
|
|
2154
2226
|
let eValue = exports.Entity.GetValue({
|