@openmrs/esm-form-engine-lib 4.1.1-pre.2341 → 4.1.1-pre.2355
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/repeat/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAoD7F;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/repeat/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAoD7F;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAajG;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,WAM7E"}
|
|
@@ -45,15 +45,16 @@ export function cloneRepeatField(srcField, value, idSuffix) {
|
|
|
45
45
|
return clonedField;
|
|
46
46
|
}
|
|
47
47
|
export function updateFieldIdInExpression(expression, index, questionIds) {
|
|
48
|
-
|
|
48
|
+
const uniqueQuestionIds = [
|
|
49
49
|
...new Set(questionIds)
|
|
50
50
|
];
|
|
51
|
-
uniqueQuestionIds.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if (!uniqueQuestionIds.length) {
|
|
52
|
+
return expression;
|
|
53
|
+
}
|
|
54
|
+
// Sort by length desc so longer ids are tried before their shorter prefixes (e.g. `status_code` before `status`).
|
|
55
|
+
// Word boundaries keep the match from landing inside a longer identifier; regex metachars in ids are escaped.
|
|
56
|
+
const pattern = uniqueQuestionIds.slice().sort((a, b)=>b.length - a.length).map((id)=>id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
|
|
57
|
+
return expression.replace(new RegExp(`\\b(?:${pattern})\\b`, 'g'), (match)=>`${match}_${index}`);
|
|
57
58
|
}
|
|
58
59
|
export function disableRepeatAddButton(limit, counter) {
|
|
59
60
|
const repeatLimit = Number(limit);
|
package/package.json
CHANGED
|
@@ -59,13 +59,18 @@ export function cloneRepeatField(srcField: FormField, value: OpenmrsResource, id
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function updateFieldIdInExpression(expression: string, index: number, questionIds: string[]) {
|
|
62
|
-
|
|
63
|
-
uniqueQuestionIds.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const uniqueQuestionIds = [...new Set(questionIds)];
|
|
63
|
+
if (!uniqueQuestionIds.length) {
|
|
64
|
+
return expression;
|
|
65
|
+
}
|
|
66
|
+
// Sort by length desc so longer ids are tried before their shorter prefixes (e.g. `status_code` before `status`).
|
|
67
|
+
// Word boundaries keep the match from landing inside a longer identifier; regex metachars in ids are escaped.
|
|
68
|
+
const pattern = uniqueQuestionIds
|
|
69
|
+
.slice()
|
|
70
|
+
.sort((a, b) => b.length - a.length)
|
|
71
|
+
.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
72
|
+
.join('|');
|
|
73
|
+
return expression.replace(new RegExp(`\\b(?:${pattern})\\b`, 'g'), (match) => `${match}_${index}`);
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
export function disableRepeatAddButton(limit: string | number, counter: number) {
|