@uniformdev/canvas 19.173.1-alpha.17 → 19.173.2-alpha.210
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/index.d.mts +3031 -2823
- package/dist/index.d.ts +3031 -2823
- package/dist/index.esm.js +242 -121
- package/dist/index.js +247 -120
- package/dist/index.mjs +242 -121
- package/package.json +6 -5
package/dist/index.js
CHANGED
@@ -281,6 +281,7 @@ __export(src_exports, {
|
|
281
281
|
ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
|
282
282
|
ApiClientError: () => import_api15.ApiClientError,
|
283
283
|
BatchEntry: () => BatchEntry,
|
284
|
+
BlockFormatError: () => BlockFormatError,
|
284
285
|
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
285
286
|
CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
|
286
287
|
CANVAS_EDITOR_STATE: () => CANVAS_EDITOR_STATE,
|
@@ -300,6 +301,7 @@ __export(src_exports, {
|
|
300
301
|
CANVAS_TEST_VARIANT_PARAM: () => CANVAS_TEST_VARIANT_PARAM,
|
301
302
|
CANVAS_VIZ_CONTROL_PARAM: () => CANVAS_VIZ_CONTROL_PARAM,
|
302
303
|
CANVAS_VIZ_DI_RULE: () => CANVAS_VIZ_DI_RULE,
|
304
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE: () => CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
303
305
|
CANVAS_VIZ_LOCALE_RULE: () => CANVAS_VIZ_LOCALE_RULE,
|
304
306
|
CANVAS_VIZ_QUIRKS_RULE: () => CANVAS_VIZ_QUIRKS_RULE,
|
305
307
|
CanvasClient: () => CanvasClient,
|
@@ -345,6 +347,7 @@ __export(src_exports, {
|
|
345
347
|
createBatchEnhancer: () => createBatchEnhancer,
|
346
348
|
createCanvasChannel: () => createCanvasChannel,
|
347
349
|
createDynamicInputVisibilityRule: () => createDynamicInputVisibilityRule,
|
350
|
+
createDynamicTokenVisibilityRule: () => createDynamicTokenVisibilityRule,
|
348
351
|
createEventBus: () => createEventBus,
|
349
352
|
createLimitPolicy: () => createLimitPolicy,
|
350
353
|
createLocaleVisibilityRule: () => createLocaleVisibilityRule,
|
@@ -352,6 +355,7 @@ __export(src_exports, {
|
|
352
355
|
createUniformApiEnhancer: () => createUniformApiEnhancer,
|
353
356
|
createVariableReference: () => createVariableReference,
|
354
357
|
enhance: () => enhance,
|
358
|
+
evaluateNodeVisibilityParameter: () => evaluateNodeVisibilityParameter,
|
355
359
|
evaluatePropertyCriteria: () => evaluatePropertyCriteria,
|
356
360
|
evaluateVisibilityCriteriaGroup: () => evaluateVisibilityCriteriaGroup,
|
357
361
|
evaluateWalkTreeNodeVisibility: () => evaluateWalkTreeNodeVisibility,
|
@@ -371,6 +375,7 @@ __export(src_exports, {
|
|
371
375
|
getParameterAttributes: () => getParameterAttributes,
|
372
376
|
getPropertiesValue: () => getPropertiesValue,
|
373
377
|
getPropertyValue: () => getPropertyValue,
|
378
|
+
hasReferencedVariables: () => hasReferencedVariables,
|
374
379
|
isAddComponentMessage: () => isAddComponentMessage,
|
375
380
|
isAllowedReferrer: () => isAllowedReferrer,
|
376
381
|
isAssetParamValue: () => isAssetParamValue,
|
@@ -380,6 +385,7 @@ __export(src_exports, {
|
|
380
385
|
isContextStorageUpdatedMessage: () => isContextStorageUpdatedMessage,
|
381
386
|
isDismissPlaceholderMessage: () => isDismissPlaceholderMessage,
|
382
387
|
isEntryData: () => isEntryData,
|
388
|
+
isLinkParamValue: () => isLinkParamValue,
|
383
389
|
isMovingComponentMessage: () => isMovingComponentMessage,
|
384
390
|
isNestedNodeType: () => isNestedNodeType,
|
385
391
|
isOpenParameterEditorMessage: () => isOpenParameterEditorMessage,
|
@@ -612,14 +618,17 @@ var nullLimitPolicy = async (func) => await func();
|
|
612
618
|
// src/utils/rewriteFilters.ts
|
613
619
|
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
614
620
|
function rewriteFilters(filters) {
|
615
|
-
return Object.entries(filters != null ? filters : {}).reduce(
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
621
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
622
|
+
(acc, [key, value]) => {
|
623
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
624
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
625
|
+
return {
|
626
|
+
...acc,
|
627
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
628
|
+
};
|
629
|
+
},
|
630
|
+
{}
|
631
|
+
);
|
623
632
|
}
|
624
633
|
|
625
634
|
// src/CanvasClient.ts
|
@@ -1130,6 +1139,9 @@ function isAssetParamValueItem(item) {
|
|
1130
1139
|
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
1131
1140
|
);
|
1132
1141
|
}
|
1142
|
+
function isLinkParamValue(value) {
|
1143
|
+
return typeof value === "object" && value !== null && "type" in value && "path" in value;
|
1144
|
+
}
|
1133
1145
|
|
1134
1146
|
// src/utils/properties.ts
|
1135
1147
|
function getPropertiesValue(entity) {
|
@@ -1181,6 +1193,86 @@ function flattenSingleNodeValues(data, options = {}) {
|
|
1181
1193
|
) : properties;
|
1182
1194
|
}
|
1183
1195
|
|
1196
|
+
// src/utils/variables/parseVariableExpression.ts
|
1197
|
+
var escapeCharacter = "\\";
|
1198
|
+
var variablePrefix = "${";
|
1199
|
+
var variableSuffix = "}";
|
1200
|
+
function parseVariableExpression(serialized, onToken) {
|
1201
|
+
let bufferStartIndex = 0;
|
1202
|
+
let bufferEndIndex = 0;
|
1203
|
+
let tokenCount = 0;
|
1204
|
+
const handleToken = (token, type) => {
|
1205
|
+
tokenCount++;
|
1206
|
+
return onToken == null ? void 0 : onToken(token, type);
|
1207
|
+
};
|
1208
|
+
let state = "text";
|
1209
|
+
for (let index = 0; index < serialized.length; index++) {
|
1210
|
+
const char = serialized[index];
|
1211
|
+
if (bufferStartIndex > bufferEndIndex) {
|
1212
|
+
bufferEndIndex = bufferStartIndex;
|
1213
|
+
}
|
1214
|
+
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
1215
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1216
|
+
bufferEndIndex -= escapeCharacter.length;
|
1217
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1218
|
+
return tokenCount;
|
1219
|
+
}
|
1220
|
+
bufferStartIndex = index;
|
1221
|
+
bufferEndIndex = index + 1;
|
1222
|
+
continue;
|
1223
|
+
}
|
1224
|
+
state = "variable";
|
1225
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1226
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
1227
|
+
return tokenCount;
|
1228
|
+
}
|
1229
|
+
bufferStartIndex = bufferEndIndex;
|
1230
|
+
}
|
1231
|
+
index += variablePrefix.length - 1;
|
1232
|
+
bufferStartIndex += variablePrefix.length;
|
1233
|
+
continue;
|
1234
|
+
}
|
1235
|
+
if (char === variableSuffix && state === "variable") {
|
1236
|
+
if (serialized[index - 1] === escapeCharacter) {
|
1237
|
+
bufferEndIndex++;
|
1238
|
+
continue;
|
1239
|
+
}
|
1240
|
+
state = "text";
|
1241
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1242
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
1243
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
1244
|
+
return tokenCount;
|
1245
|
+
}
|
1246
|
+
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
1247
|
+
}
|
1248
|
+
continue;
|
1249
|
+
}
|
1250
|
+
bufferEndIndex++;
|
1251
|
+
}
|
1252
|
+
if (bufferEndIndex > bufferStartIndex) {
|
1253
|
+
if (state === "variable") {
|
1254
|
+
state = "text";
|
1255
|
+
bufferStartIndex -= variablePrefix.length;
|
1256
|
+
}
|
1257
|
+
handleToken(serialized.substring(bufferStartIndex), state);
|
1258
|
+
}
|
1259
|
+
return tokenCount;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
// src/utils/variables/hasReferencedVariables.ts
|
1263
|
+
function hasReferencedVariables(value) {
|
1264
|
+
if (value === void 0) {
|
1265
|
+
return 0;
|
1266
|
+
}
|
1267
|
+
let variableTokenCount = 0;
|
1268
|
+
parseVariableExpression(value, (_, tokenType) => {
|
1269
|
+
if (tokenType === "variable") {
|
1270
|
+
variableTokenCount++;
|
1271
|
+
}
|
1272
|
+
});
|
1273
|
+
return variableTokenCount;
|
1274
|
+
}
|
1275
|
+
|
1184
1276
|
// src/enhancement/walkNodeTree.ts
|
1185
1277
|
function walkNodeTree(node, visitor, options) {
|
1186
1278
|
var _a, _b;
|
@@ -1404,7 +1496,25 @@ function walkNodeTree(node, visitor, options) {
|
|
1404
1496
|
const propertyEntries = Object.entries(properties);
|
1405
1497
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1406
1498
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1407
|
-
if (!isNestedNodeType(propObject.type))
|
1499
|
+
if (!isNestedNodeType(propObject.type)) {
|
1500
|
+
continue;
|
1501
|
+
}
|
1502
|
+
if (typeof propObject.value === "string" && hasReferencedVariables(propObject.value) > 0) {
|
1503
|
+
continue;
|
1504
|
+
}
|
1505
|
+
if (!Array.isArray(propObject.value)) {
|
1506
|
+
const error = new BlockFormatError(
|
1507
|
+
`${getComponentPath(currentQueueEntry.ancestorsAndSelf)}`,
|
1508
|
+
propKey,
|
1509
|
+
propObject.value
|
1510
|
+
);
|
1511
|
+
if (options == null ? void 0 : options.throwForInvalidBlockValues) {
|
1512
|
+
throw error;
|
1513
|
+
} else {
|
1514
|
+
console.warn(`Skipped invalid block value: ${error.message}}`);
|
1515
|
+
continue;
|
1516
|
+
}
|
1517
|
+
}
|
1408
1518
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1409
1519
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1410
1520
|
const enqueueingBlock = blocks[blockIndex];
|
@@ -1440,6 +1550,17 @@ function getBlockValue(component, parameterName) {
|
|
1440
1550
|
}
|
1441
1551
|
return [];
|
1442
1552
|
}
|
1553
|
+
var BlockFormatError = class _BlockFormatError extends Error {
|
1554
|
+
constructor(componentPath, propertyId, blockValue) {
|
1555
|
+
super(
|
1556
|
+
`${componentPath} has an invalid block property value on ${propertyId}. Block values must be arrays of blocks (BlockValue type), but received ${blockValue === null ? "null" : typeof blockValue}`
|
1557
|
+
);
|
1558
|
+
this.componentPath = componentPath;
|
1559
|
+
this.propertyId = propertyId;
|
1560
|
+
this.blockValue = blockValue;
|
1561
|
+
Object.setPrototypeOf(this, _BlockFormatError.prototype);
|
1562
|
+
}
|
1563
|
+
};
|
1443
1564
|
|
1444
1565
|
// src/enhancement/enhance.ts
|
1445
1566
|
async function enhance({
|
@@ -1768,12 +1889,18 @@ function evaluateVisibilityCriteriaGroup(options) {
|
|
1768
1889
|
return hasIndeterminateClauses ? null : !earlyExitResult;
|
1769
1890
|
}
|
1770
1891
|
function evaluateCriterion(clause, rootOptions) {
|
1892
|
+
var _a;
|
1771
1893
|
if ("clauses" in clause) {
|
1772
1894
|
return evaluateVisibilityCriteriaGroup({
|
1773
1895
|
...rootOptions,
|
1774
1896
|
criteriaGroup: clause
|
1775
1897
|
});
|
1776
1898
|
}
|
1899
|
+
const lhs = (_a = clause.source) != null ? _a : clause.rule;
|
1900
|
+
const rhs = Array.isArray(clause.value) ? clause.value : clause.value !== void 0 ? [clause.value] : void 0;
|
1901
|
+
if (hasReferencedVariables(lhs) > 0 || (rhs == null ? void 0 : rhs.some((rhv) => hasReferencedVariables(rhv) > 0))) {
|
1902
|
+
return null;
|
1903
|
+
}
|
1777
1904
|
const rule = rootOptions.rules[clause.rule];
|
1778
1905
|
if (rule) {
|
1779
1906
|
return rule(clause);
|
@@ -1781,6 +1908,24 @@ function evaluateCriterion(clause, rootOptions) {
|
|
1781
1908
|
return null;
|
1782
1909
|
}
|
1783
1910
|
|
1911
|
+
// src/enhancement/visibility/evaluateNodeVisibilityParameter.ts
|
1912
|
+
function evaluateNodeVisibilityParameter({
|
1913
|
+
parameter,
|
1914
|
+
...evaluateGroupOptions
|
1915
|
+
}) {
|
1916
|
+
if (parameter == null ? void 0 : parameter.explicitlyHidden) {
|
1917
|
+
return false;
|
1918
|
+
}
|
1919
|
+
if (!(parameter == null ? void 0 : parameter.criteria)) {
|
1920
|
+
return true;
|
1921
|
+
}
|
1922
|
+
const result = evaluateVisibilityCriteriaGroup({
|
1923
|
+
...evaluateGroupOptions,
|
1924
|
+
criteriaGroup: parameter.criteria
|
1925
|
+
});
|
1926
|
+
return result;
|
1927
|
+
}
|
1928
|
+
|
1784
1929
|
// src/enhancement/visibility/evaluatePropertyCriteria.ts
|
1785
1930
|
function evaluatePropertyCriteria({
|
1786
1931
|
baseValue,
|
@@ -1845,17 +1990,11 @@ function evaluateNodeVisibility({
|
|
1845
1990
|
var _a;
|
1846
1991
|
const properties = getPropertiesValue(node);
|
1847
1992
|
const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
|
1848
|
-
|
1849
|
-
return false;
|
1850
|
-
}
|
1851
|
-
if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
|
1852
|
-
return true;
|
1853
|
-
}
|
1854
|
-
const result = evaluateVisibilityCriteriaGroup({
|
1993
|
+
const result = evaluateNodeVisibilityParameter({
|
1855
1994
|
...evaluateGroupOptions,
|
1856
|
-
|
1995
|
+
parameter: vizCriteria
|
1857
1996
|
});
|
1858
|
-
if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1997
|
+
if ((vizCriteria == null ? void 0 : vizCriteria.criteria) && vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
|
1859
1998
|
properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
|
1860
1999
|
}
|
1861
2000
|
return result;
|
@@ -1897,7 +2036,7 @@ function evaluateWalkTreePropertyCriteria({
|
|
1897
2036
|
...Object.keys((_b = property.localesConditions) != null ? _b : {})
|
1898
2037
|
];
|
1899
2038
|
localesDefined.forEach((locale) => {
|
1900
|
-
var _a2, _b2, _c2, _d, _e, _f
|
2039
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
1901
2040
|
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1902
2041
|
baseValue: (_a2 = property.locales) == null ? void 0 : _a2[locale],
|
1903
2042
|
conditionalValues: (_b2 = property.localesConditions) == null ? void 0 : _b2[locale],
|
@@ -1905,25 +2044,25 @@ function evaluateWalkTreePropertyCriteria({
|
|
1905
2044
|
simplifyCriteria: true,
|
1906
2045
|
keepIndeterminate
|
1907
2046
|
});
|
1908
|
-
if (currentValue === null) {
|
2047
|
+
if (currentValue === null || currentValue === void 0) {
|
1909
2048
|
(_c2 = property.locales) == null ? true : delete _c2[locale];
|
1910
|
-
if (!Object.keys((_d = property.locales) != null ? _d : {}).length) {
|
1911
|
-
delete properties[propertyName];
|
1912
|
-
}
|
1913
2049
|
} else {
|
1914
|
-
(
|
2050
|
+
(_d = property.locales) != null ? _d : property.locales = {};
|
1915
2051
|
property.locales[locale] = currentValue;
|
1916
2052
|
}
|
1917
2053
|
if (!(remainingConditionalValues == null ? void 0 : remainingConditionalValues.length)) {
|
1918
|
-
(
|
2054
|
+
(_e = property.localesConditions) == null ? true : delete _e[locale];
|
1919
2055
|
} else {
|
1920
|
-
(
|
2056
|
+
(_f = property.localesConditions) != null ? _f : property.localesConditions = {};
|
1921
2057
|
property.localesConditions[locale] = remainingConditionalValues;
|
1922
2058
|
}
|
1923
2059
|
});
|
1924
2060
|
if (!Object.keys((_c = property.localesConditions) != null ? _c : {}).length) {
|
1925
2061
|
delete property.localesConditions;
|
1926
2062
|
}
|
2063
|
+
if (!property.locales && !property.localesConditions) {
|
2064
|
+
delete properties[propertyName];
|
2065
|
+
}
|
1927
2066
|
} else {
|
1928
2067
|
const { currentValue, remainingConditionalValues } = evaluatePropertyCriteria({
|
1929
2068
|
baseValue: property.value,
|
@@ -1935,9 +2074,17 @@ function evaluateWalkTreePropertyCriteria({
|
|
1935
2074
|
if (currentValue === null) {
|
1936
2075
|
delete properties[propertyName];
|
1937
2076
|
} else {
|
1938
|
-
|
2077
|
+
if (currentValue !== void 0) {
|
2078
|
+
property.value = currentValue;
|
2079
|
+
} else {
|
2080
|
+
delete property.value;
|
2081
|
+
}
|
2082
|
+
}
|
2083
|
+
if (remainingConditionalValues === void 0) {
|
2084
|
+
delete property.conditions;
|
2085
|
+
} else {
|
2086
|
+
property.conditions = remainingConditionalValues;
|
1939
2087
|
}
|
1940
|
-
property.conditions = remainingConditionalValues;
|
1941
2088
|
}
|
1942
2089
|
});
|
1943
2090
|
}
|
@@ -2019,6 +2166,32 @@ function createDynamicInputVisibilityRule(dynamicInputs) {
|
|
2019
2166
|
};
|
2020
2167
|
}
|
2021
2168
|
|
2169
|
+
// src/enhancement/visibility/rules/createDynamicTokenVisibilityRule.ts
|
2170
|
+
var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
|
2171
|
+
"is",
|
2172
|
+
"!is",
|
2173
|
+
"has",
|
2174
|
+
"!has",
|
2175
|
+
"startswith",
|
2176
|
+
"!startswith",
|
2177
|
+
"endswith",
|
2178
|
+
"!endswith",
|
2179
|
+
"empty",
|
2180
|
+
"!empty"
|
2181
|
+
]);
|
2182
|
+
var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
|
2183
|
+
function createDynamicTokenVisibilityRule() {
|
2184
|
+
return {
|
2185
|
+
[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
|
2186
|
+
var _a;
|
2187
|
+
if (hasReferencedVariables(criterion.source)) {
|
2188
|
+
return null;
|
2189
|
+
}
|
2190
|
+
return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
|
2191
|
+
}
|
2192
|
+
};
|
2193
|
+
}
|
2194
|
+
|
2022
2195
|
// src/enhancement/visibility/rules/createLocaleVisibilityRule.ts
|
2023
2196
|
var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
|
2024
2197
|
var CANVAS_VIZ_LOCALE_RULE = "$locale";
|
@@ -2081,7 +2254,7 @@ function localize(options) {
|
|
2081
2254
|
const { type, node, actions } = context;
|
2082
2255
|
if (type !== "component") {
|
2083
2256
|
if (isUsingModernOptions) {
|
2084
|
-
localizeProperties(node
|
2257
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2085
2258
|
}
|
2086
2259
|
return;
|
2087
2260
|
}
|
@@ -2094,11 +2267,6 @@ function localize(options) {
|
|
2094
2267
|
if (!result) {
|
2095
2268
|
return;
|
2096
2269
|
}
|
2097
|
-
evaluateWalkTreePropertyCriteria({
|
2098
|
-
node: context.node,
|
2099
|
-
rules: vizControlLocaleRule,
|
2100
|
-
keepIndeterminate: true
|
2101
|
-
});
|
2102
2270
|
}
|
2103
2271
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
2104
2272
|
const locales = extractLocales({ component: node });
|
@@ -2111,7 +2279,7 @@ function localize(options) {
|
|
2111
2279
|
replaceComponent.forEach((component) => {
|
2112
2280
|
removeLocaleProperty(component);
|
2113
2281
|
if (isUsingModernOptions) {
|
2114
|
-
localizeProperties(
|
2282
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
2115
2283
|
}
|
2116
2284
|
});
|
2117
2285
|
const [first, ...rest] = replaceComponent;
|
@@ -2123,7 +2291,7 @@ function localize(options) {
|
|
2123
2291
|
actions.remove();
|
2124
2292
|
}
|
2125
2293
|
} else if (isUsingModernOptions) {
|
2126
|
-
localizeProperties(
|
2294
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2127
2295
|
}
|
2128
2296
|
});
|
2129
2297
|
}
|
@@ -2142,36 +2310,51 @@ function removeLocaleProperty(component) {
|
|
2142
2310
|
}
|
2143
2311
|
}
|
2144
2312
|
}
|
2145
|
-
function localizeProperties(
|
2313
|
+
function localizeProperties(node, locale, rules) {
|
2314
|
+
const properties = getPropertiesValue(node);
|
2146
2315
|
if (!properties) {
|
2147
2316
|
return void 0;
|
2148
2317
|
}
|
2149
|
-
Object.entries(properties).forEach(([
|
2150
|
-
var _a;
|
2318
|
+
Object.entries(properties).forEach(([propertyId, propertyValue]) => {
|
2319
|
+
var _a, _b;
|
2151
2320
|
if (!locale) {
|
2152
|
-
delete
|
2321
|
+
delete propertyValue.locales;
|
2322
|
+
delete propertyValue.localesConditions;
|
2153
2323
|
}
|
2154
|
-
const currentLocaleValue = locale ? (_a =
|
2324
|
+
const currentLocaleValue = locale ? (_a = propertyValue.locales) == null ? void 0 : _a[locale] : void 0;
|
2155
2325
|
if (currentLocaleValue !== void 0) {
|
2156
|
-
|
2326
|
+
propertyValue.value = currentLocaleValue;
|
2327
|
+
}
|
2328
|
+
const currentLocaleConditionalValues = locale ? (_b = propertyValue.localesConditions) == null ? void 0 : _b[locale] : void 0;
|
2329
|
+
if (currentLocaleConditionalValues !== void 0) {
|
2330
|
+
propertyValue.conditions = currentLocaleConditionalValues;
|
2157
2331
|
}
|
2158
|
-
delete
|
2159
|
-
|
2160
|
-
|
2332
|
+
delete propertyValue.locales;
|
2333
|
+
delete propertyValue.localesConditions;
|
2334
|
+
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
2335
|
+
delete properties[propertyId];
|
2161
2336
|
}
|
2162
2337
|
});
|
2338
|
+
evaluateWalkTreePropertyCriteria({
|
2339
|
+
node,
|
2340
|
+
rules,
|
2341
|
+
keepIndeterminate: true
|
2342
|
+
});
|
2163
2343
|
}
|
2164
2344
|
|
2165
2345
|
// src/enhancement/UniqueBatchEntries.ts
|
2166
2346
|
var UniqueBatchEntries = class {
|
2167
2347
|
constructor(entries, uniqueKeySelector) {
|
2168
|
-
this.groups = entries.reduce(
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2348
|
+
this.groups = entries.reduce(
|
2349
|
+
(acc, task) => {
|
2350
|
+
var _a;
|
2351
|
+
const key = uniqueKeySelector(task.args);
|
2352
|
+
acc[key] = (_a = acc[key]) != null ? _a : [];
|
2353
|
+
acc[key].push(task);
|
2354
|
+
return acc;
|
2355
|
+
},
|
2356
|
+
{}
|
2357
|
+
);
|
2175
2358
|
}
|
2176
2359
|
/** Resolves all entries in a group key with the same result value. */
|
2177
2360
|
resolveKey(key, result) {
|
@@ -3019,7 +3202,7 @@ var isComponentPlaceholderId = (id) => {
|
|
3019
3202
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
3020
3203
|
};
|
3021
3204
|
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
3022
|
-
if (
|
3205
|
+
if (sdkVersion === 1) {
|
3023
3206
|
return PLACEHOLDER_ID;
|
3024
3207
|
}
|
3025
3208
|
let idParts = [PLACEHOLDER_ID, randomId];
|
@@ -3045,72 +3228,6 @@ var parseComponentPlaceholderId = (id) => {
|
|
3045
3228
|
return result;
|
3046
3229
|
};
|
3047
3230
|
|
3048
|
-
// src/utils/variables/parseVariableExpression.ts
|
3049
|
-
var escapeCharacter = "\\";
|
3050
|
-
var variablePrefix = "${";
|
3051
|
-
var variableSuffix = "}";
|
3052
|
-
function parseVariableExpression(serialized, onToken) {
|
3053
|
-
let bufferStartIndex = 0;
|
3054
|
-
let bufferEndIndex = 0;
|
3055
|
-
let tokenCount = 0;
|
3056
|
-
const handleToken = (token, type) => {
|
3057
|
-
tokenCount++;
|
3058
|
-
return onToken == null ? void 0 : onToken(token, type);
|
3059
|
-
};
|
3060
|
-
let state = "text";
|
3061
|
-
for (let index = 0; index < serialized.length; index++) {
|
3062
|
-
const char = serialized[index];
|
3063
|
-
if (bufferStartIndex > bufferEndIndex) {
|
3064
|
-
bufferEndIndex = bufferStartIndex;
|
3065
|
-
}
|
3066
|
-
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
3067
|
-
if (serialized[index - 1] === escapeCharacter) {
|
3068
|
-
bufferEndIndex -= escapeCharacter.length;
|
3069
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
3070
|
-
return tokenCount;
|
3071
|
-
}
|
3072
|
-
bufferStartIndex = index;
|
3073
|
-
bufferEndIndex = index + 1;
|
3074
|
-
continue;
|
3075
|
-
}
|
3076
|
-
state = "variable";
|
3077
|
-
if (bufferEndIndex > bufferStartIndex) {
|
3078
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
3079
|
-
return tokenCount;
|
3080
|
-
}
|
3081
|
-
bufferStartIndex = bufferEndIndex;
|
3082
|
-
}
|
3083
|
-
index += variablePrefix.length - 1;
|
3084
|
-
bufferStartIndex += variablePrefix.length;
|
3085
|
-
continue;
|
3086
|
-
}
|
3087
|
-
if (char === variableSuffix && state === "variable") {
|
3088
|
-
if (serialized[index - 1] === escapeCharacter) {
|
3089
|
-
bufferEndIndex++;
|
3090
|
-
continue;
|
3091
|
-
}
|
3092
|
-
state = "text";
|
3093
|
-
if (bufferEndIndex > bufferStartIndex) {
|
3094
|
-
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
3095
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
3096
|
-
return tokenCount;
|
3097
|
-
}
|
3098
|
-
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
3099
|
-
}
|
3100
|
-
continue;
|
3101
|
-
}
|
3102
|
-
bufferEndIndex++;
|
3103
|
-
}
|
3104
|
-
if (bufferEndIndex > bufferStartIndex) {
|
3105
|
-
if (state === "variable") {
|
3106
|
-
state = "text";
|
3107
|
-
bufferStartIndex -= variablePrefix.length;
|
3108
|
-
}
|
3109
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
3110
|
-
}
|
3111
|
-
return tokenCount;
|
3112
|
-
}
|
3113
|
-
|
3114
3231
|
// src/utils/variables/bindVariables.ts
|
3115
3232
|
function bindVariables({
|
3116
3233
|
variables,
|
@@ -3176,7 +3293,11 @@ function bindVariablesToObjectRecursive({
|
|
3176
3293
|
if (richTextNodeResult !== void 0) {
|
3177
3294
|
return richTextNodeResult;
|
3178
3295
|
}
|
3179
|
-
const
|
3296
|
+
const produceToUse = !(0, import_immer.isDraft)(value) ? import_immer.produce : (produceValue, producer) => {
|
3297
|
+
producer(produceValue);
|
3298
|
+
return produceValue;
|
3299
|
+
};
|
3300
|
+
const result = produceToUse(value, (draft) => {
|
3180
3301
|
Object.entries(draft).forEach(([property, oldValue]) => {
|
3181
3302
|
const currentObjectPath = recursivePath ? `${recursivePath}.${property}` : property;
|
3182
3303
|
if (typeof oldValue === "string") {
|
@@ -3283,6 +3404,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3283
3404
|
ATTRIBUTE_PLACEHOLDER,
|
3284
3405
|
ApiClientError,
|
3285
3406
|
BatchEntry,
|
3407
|
+
BlockFormatError,
|
3286
3408
|
CANVAS_BLOCK_PARAM_TYPE,
|
3287
3409
|
CANVAS_DRAFT_STATE,
|
3288
3410
|
CANVAS_EDITOR_STATE,
|
@@ -3302,6 +3424,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3302
3424
|
CANVAS_TEST_VARIANT_PARAM,
|
3303
3425
|
CANVAS_VIZ_CONTROL_PARAM,
|
3304
3426
|
CANVAS_VIZ_DI_RULE,
|
3427
|
+
CANVAS_VIZ_DYNAMIC_TOKEN_RULE,
|
3305
3428
|
CANVAS_VIZ_LOCALE_RULE,
|
3306
3429
|
CANVAS_VIZ_QUIRKS_RULE,
|
3307
3430
|
CanvasClient,
|
@@ -3347,6 +3470,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3347
3470
|
createBatchEnhancer,
|
3348
3471
|
createCanvasChannel,
|
3349
3472
|
createDynamicInputVisibilityRule,
|
3473
|
+
createDynamicTokenVisibilityRule,
|
3350
3474
|
createEventBus,
|
3351
3475
|
createLimitPolicy,
|
3352
3476
|
createLocaleVisibilityRule,
|
@@ -3354,6 +3478,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3354
3478
|
createUniformApiEnhancer,
|
3355
3479
|
createVariableReference,
|
3356
3480
|
enhance,
|
3481
|
+
evaluateNodeVisibilityParameter,
|
3357
3482
|
evaluatePropertyCriteria,
|
3358
3483
|
evaluateVisibilityCriteriaGroup,
|
3359
3484
|
evaluateWalkTreeNodeVisibility,
|
@@ -3373,6 +3498,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3373
3498
|
getParameterAttributes,
|
3374
3499
|
getPropertiesValue,
|
3375
3500
|
getPropertyValue,
|
3501
|
+
hasReferencedVariables,
|
3376
3502
|
isAddComponentMessage,
|
3377
3503
|
isAllowedReferrer,
|
3378
3504
|
isAssetParamValue,
|
@@ -3382,6 +3508,7 @@ var CanvasClientError = import_api15.ApiClientError;
|
|
3382
3508
|
isContextStorageUpdatedMessage,
|
3383
3509
|
isDismissPlaceholderMessage,
|
3384
3510
|
isEntryData,
|
3511
|
+
isLinkParamValue,
|
3385
3512
|
isMovingComponentMessage,
|
3386
3513
|
isNestedNodeType,
|
3387
3514
|
isOpenParameterEditorMessage,
|