@teamnovu/nuxt-statamic-formbuilder 1.4.0 → 1.4.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.
package/dist/module.json
CHANGED
|
@@ -105,6 +105,32 @@ function resolveField(field, formValues) {
|
|
|
105
105
|
}
|
|
106
106
|
return dataGet(formValues, field);
|
|
107
107
|
}
|
|
108
|
+
function normalizeScalar(value) {
|
|
109
|
+
if (typeof value !== "string") return value;
|
|
110
|
+
const trimmed = value.trim();
|
|
111
|
+
return trimmed === "" ? null : trimmed;
|
|
112
|
+
}
|
|
113
|
+
function compareScalarAgainstArray(lhs, rhs, op) {
|
|
114
|
+
const rhsValue = normalizeScalar(rhs);
|
|
115
|
+
const comparePair = (left, right) => {
|
|
116
|
+
switch (op) {
|
|
117
|
+
// eslint-disable-next-line eqeqeq
|
|
118
|
+
case "==":
|
|
119
|
+
return normalizeScalar(left) == right;
|
|
120
|
+
// eslint-disable-next-line eqeqeq
|
|
121
|
+
case "!=":
|
|
122
|
+
return normalizeScalar(left) != right;
|
|
123
|
+
case "===":
|
|
124
|
+
return normalizeScalar(left) === right;
|
|
125
|
+
case "!==":
|
|
126
|
+
return normalizeScalar(left) !== right;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
if (op === "==" || op === "===") {
|
|
130
|
+
return lhs.some((value) => comparePair(value, rhsValue));
|
|
131
|
+
}
|
|
132
|
+
return lhs.every((value) => comparePair(value, rhsValue));
|
|
133
|
+
}
|
|
108
134
|
function testCondition(condition, formValues) {
|
|
109
135
|
const op = normalizeOperator(condition.operator);
|
|
110
136
|
const rawLhs = resolveField(condition.field, formValues);
|
|
@@ -164,13 +190,20 @@ function testCondition(condition, formValues) {
|
|
|
164
190
|
return lhsNum <= rhsNum;
|
|
165
191
|
}
|
|
166
192
|
}
|
|
167
|
-
if (rawLhs
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
193
|
+
if (Array.isArray(rawLhs)) {
|
|
194
|
+
switch (op) {
|
|
195
|
+
case "==":
|
|
196
|
+
case "!=":
|
|
197
|
+
case "===":
|
|
198
|
+
case "!==":
|
|
199
|
+
return compareScalarAgainstArray(rawLhs, rhs, op);
|
|
200
|
+
default:
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
172
203
|
}
|
|
173
|
-
if (typeof
|
|
204
|
+
if (rawLhs !== null && typeof rawLhs === "object") return false;
|
|
205
|
+
const lhs = normalizeScalar(rawLhs);
|
|
206
|
+
rhs = normalizeScalar(rhs);
|
|
174
207
|
switch (op) {
|
|
175
208
|
// Loose equality intentional — mirrors the original eval() behaviour,
|
|
176
209
|
// e.g. null == "null" should be false but null == null should be true.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnovu/nuxt-statamic-formbuilder",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Headless Nuxt form builder with Statamic submit adapter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/teamnovu/nuxt-statamic-formbuilder#readme",
|