@genesislcap/expression-builder 14.253.0 → 14.255.0
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/custom-elements.json +155 -4
- package/dist/dts/main/expression-group/expression-group.d.ts.map +1 -1
- package/dist/dts/main/expression-group/expression-group.template.d.ts.map +1 -1
- package/dist/dts/main/expression-rule/expression-rule.d.ts +1 -0
- package/dist/dts/main/expression-rule/expression-rule.d.ts.map +1 -1
- package/dist/dts/main/expression-rule/expression-rule.helpers.d.ts +14 -1
- package/dist/dts/main/expression-rule/expression-rule.helpers.d.ts.map +1 -1
- package/dist/dts/main/expression-rule/expression-rule.styles.d.ts.map +1 -1
- package/dist/dts/main/rule-operator/rule-operator.template.d.ts.map +1 -1
- package/dist/dts/types/public.types.d.ts +4 -0
- package/dist/dts/types/public.types.d.ts.map +1 -1
- package/dist/esm/main/expression-group/expression-group.js +0 -10
- package/dist/esm/main/expression-group/expression-group.template.js +9 -0
- package/dist/esm/main/expression-rule/expression-rule.helpers.js +84 -0
- package/dist/esm/main/expression-rule/expression-rule.js +14 -53
- package/dist/esm/main/expression-rule/expression-rule.styles.js +4 -0
- package/dist/esm/main/expression-rule/expression-rule.template.js +2 -2
- package/dist/esm/main/rule-operator/rule-operator.template.js +2 -0
- package/dist/expression-builder.d.ts +4 -0
- package/docs/api-report.md +2 -0
- package/package.json +2 -2
|
@@ -971,7 +971,7 @@
|
|
|
971
971
|
{
|
|
972
972
|
"kind": "variable",
|
|
973
973
|
"name": "template",
|
|
974
|
-
"default": "html<ExpressionGroup>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n const maybeRadioBlock = context.styles?.customElements?.radio;\n const { radioTag, radioGroupTag } = maybeRadioBlock\n ? { radioTag: maybeRadioBlock.input, radioGroupTag: maybeRadioBlock.group }\n : { radioTag: 'input', radioGroupTag: 'div' };\n\n return html<ExpressionGroup>`\n <div class=\"rules-group-container\">\n <div class=\"rules-group-header\">\n <div class=\"btn-group float-end group-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-success\"\n data-add=\"rule\"\n @click=\"${(x, c) => x.dispatchAddRule(c.event)}\"\n >\n Add Rule\n </${buttonTag}>\n ${when(\n (x) => x.allowNestedGroup,\n html<ExpressionGroup>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-success\"\n data-add=\"group\"\n @click=\"${(x, c) => x.dispatchAddGroup(c.event)}\"\n >\n Add Group\n </${buttonTag}>\n `,\n )}\n ${when(\n (x) => typeof x.index === 'number',\n html<ExpressionGroup>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"group\"\n @click=\"${(x, c) => x.dispatchDeleteGroup(c.event)}\"\n >\n Delete Group\n </${buttonTag}>\n `,\n )}\n <div class=\"btn-group group-conditions\">\n ${whenElse(\n (_) => radioTag !== 'input',\n html<ExpressionGroup>`\n <${radioGroupTag}\n class=\"radio-group-container\"\n name=\"combinator\"\n @change=\"${(x, c) => x.handleCombinatorChange(c.event)}\"\n value=\"${(x) => x.model?.combinator?.type}\"\n >\n ${repeat(\n (x) => x.config.combinators,\n html<Combinator, ExpressionGroup>`\n <${radioTag}\n value=\"${(x) => x.type}\"\n ?checked=${(x, c) => c.parent.model?.combinator?.type === x.type}\n >\n ${(x) => x.label ?? x.type}\n </${radioTag}>\n `,\n )}\n </${radioGroupTag}>\n `,\n html<ExpressionGroup>`\n <div class=\"radio-group-container\">\n ${repeat(\n (x) => x.config.combinators,\n html<Combinator, ExpressionGroup>`\n <label class=\"btn btn-sm btn-primary\">\n <input\n type=\"radio\"\n name=\"combinator\"\n value=\"${(x) => x.type}\"\n @change=\"${(_, c) => c.parent.handleCombinatorChange(c.event)}\"\n ?checked=${(x, c) => c.parent.model?.combinator?.type === x.type}\n />\n ${(x) => x.label ?? x.type}\n </label>\n `,\n )}\n </div>\n `,\n )}\n </div>\n </div>\n <div class=\"rules-group-body\">\n <div class=\"rules-list\">\n ${repeat(\n (x) => x.model?.children ?? [],\n html<ModelRule | ModelGroup, ExpressionBuilder>`\n ${whenElse(\n (x) => 'children' in x,\n html<ModelGroup>`\n <expression-group\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :model=${(x) => x}\n :index=${(_, c) => c.index}\n ></expression-group>\n `,\n html<ModelRule>`\n <expression-rule\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :model=${(x) => x}\n :index=${(_, c) => c.index}\n ></expression-rule>\n `,\n )}\n `,\n { recycle: false, positioning: true },\n )}\n </div>\n </div>\n </div>\n </div>\n `;\n }}\n`"
|
|
974
|
+
"default": "html<ExpressionGroup>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n const maybeRadioBlock = context.styles?.customElements?.radio;\n const { radioTag, radioGroupTag } = maybeRadioBlock\n ? { radioTag: maybeRadioBlock.input, radioGroupTag: maybeRadioBlock.group }\n : { radioTag: 'input', radioGroupTag: 'div' };\n\n const ruleTooltip = `Add a new condition with field (e.g. CURRENCY), operator (e.g. EQUALS), and value (e.g. GBP) that will be combined with other conditions in this group using the selected logic (e.g. ${context.config.combinators[0].type})`;\n\n const groupTooltip = `Add a new nested sub-group to create more complex expressions, joined by combinatorial logic (e.g. ${context.config.combinators[0].type})`;\n\n return html<ExpressionGroup>`\n <div class=\"rules-group-container\">\n <div class=\"rules-group-header\">\n <div class=\"btn-group float-end group-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-success\"\n data-add=\"rule\"\n @click=\"${(x, c) => x.dispatchAddRule(c.event)}\"\n title=${(_) => ruleTooltip}\n >\n Add Rule\n </${buttonTag}>\n ${when(\n (x) => x.allowNestedGroup,\n html<ExpressionGroup>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-success\"\n data-add=\"group\"\n @click=\"${(x, c) => x.dispatchAddGroup(c.event)}\"\n title=\"${(_) => groupTooltip}\"\n >\n Add Group\n </${buttonTag}>\n `,\n )}\n ${when(\n (x) => typeof x.index === 'number',\n html<ExpressionGroup>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"group\"\n @click=\"${(x, c) => x.dispatchDeleteGroup(c.event)}\"\n >\n Delete Group\n </${buttonTag}>\n `,\n )}\n <div class=\"btn-group group-conditions\">\n ${whenElse(\n (_) => radioTag !== 'input',\n html<ExpressionGroup>`\n <${radioGroupTag}\n class=\"radio-group-container\"\n name=\"combinator\"\n @change=\"${(x, c) => x.handleCombinatorChange(c.event)}\"\n value=\"${(x) => x.model?.combinator?.type}\"\n >\n ${repeat(\n (x) => x.config.combinators,\n html<Combinator, ExpressionGroup>`\n <${radioTag}\n value=\"${(x) => x.type}\"\n ?checked=${(x, c) => c.parent.model?.combinator?.type === x.type}\n >\n ${(x) => x.label ?? x.type}\n </${radioTag}>\n `,\n )}\n </${radioGroupTag}>\n `,\n html<ExpressionGroup>`\n <div class=\"radio-group-container\">\n ${repeat(\n (x) => x.config.combinators,\n html<Combinator, ExpressionGroup>`\n <label class=\"btn btn-sm btn-primary\">\n <input\n type=\"radio\"\n name=\"combinator\"\n value=\"${(x) => x.type}\"\n @change=\"${(_, c) => c.parent.handleCombinatorChange(c.event)}\"\n ?checked=${(x, c) => c.parent.model?.combinator?.type === x.type}\n />\n ${(x) => x.label ?? x.type}\n </label>\n `,\n )}\n </div>\n `,\n )}\n </div>\n </div>\n <div class=\"rules-group-body\">\n <div class=\"rules-list\">\n ${repeat(\n (x) => x.model?.children ?? [],\n html<ModelRule | ModelGroup, ExpressionBuilder>`\n ${whenElse(\n (x) => 'children' in x,\n html<ModelGroup>`\n <expression-group\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :model=${(x) => x}\n :index=${(_, c) => c.index}\n ></expression-group>\n `,\n html<ModelRule>`\n <expression-rule\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :model=${(x) => x}\n :index=${(_, c) => c.index}\n ></expression-rule>\n `,\n )}\n ${when(\n (_, loopCtx) => !loopCtx.isLast,\n html<ModelRule | ModelGroup, ExpressionBuilder>`\n <p class=\"group-combinator-link\">\n ${(_, innerCtx) => innerCtx.parent.model.combinator.type}\n </p>\n `,\n )}\n `,\n { recycle: false, positioning: true },\n )}\n </div>\n </div>\n </div>\n </div>\n `;\n }}\n`"
|
|
975
975
|
}
|
|
976
976
|
],
|
|
977
977
|
"exports": [
|
|
@@ -1166,6 +1166,18 @@
|
|
|
1166
1166
|
}
|
|
1167
1167
|
]
|
|
1168
1168
|
},
|
|
1169
|
+
{
|
|
1170
|
+
"kind": "function",
|
|
1171
|
+
"name": "getValue",
|
|
1172
|
+
"parameters": [
|
|
1173
|
+
{
|
|
1174
|
+
"name": "m",
|
|
1175
|
+
"type": {
|
|
1176
|
+
"text": "ModelRule"
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
]
|
|
1180
|
+
},
|
|
1169
1181
|
{
|
|
1170
1182
|
"kind": "function",
|
|
1171
1183
|
"name": "fieldDefault",
|
|
@@ -1177,6 +1189,88 @@
|
|
|
1177
1189
|
}
|
|
1178
1190
|
}
|
|
1179
1191
|
]
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
"kind": "function",
|
|
1195
|
+
"name": "operatorChangedUpdatedModel",
|
|
1196
|
+
"return": {
|
|
1197
|
+
"type": {
|
|
1198
|
+
"text": "Rule"
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1201
|
+
"parameters": [
|
|
1202
|
+
{
|
|
1203
|
+
"name": "newOperator",
|
|
1204
|
+
"type": {
|
|
1205
|
+
"text": "Operator"
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
"name": "model",
|
|
1210
|
+
"type": {
|
|
1211
|
+
"text": "ModelRule"
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
]
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
"kind": "function",
|
|
1218
|
+
"name": "valueChangedUpdateModel",
|
|
1219
|
+
"return": {
|
|
1220
|
+
"type": {
|
|
1221
|
+
"text": "Rule"
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
"parameters": [
|
|
1225
|
+
{
|
|
1226
|
+
"name": "model",
|
|
1227
|
+
"type": {
|
|
1228
|
+
"text": "ModelRule"
|
|
1229
|
+
}
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
"name": "value",
|
|
1233
|
+
"type": {
|
|
1234
|
+
"text": "any"
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
"name": "argIndex",
|
|
1239
|
+
"type": {
|
|
1240
|
+
"text": "number"
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
]
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
"kind": "function",
|
|
1247
|
+
"name": "isValueInvalid",
|
|
1248
|
+
"parameters": [
|
|
1249
|
+
{
|
|
1250
|
+
"name": "x",
|
|
1251
|
+
"type": {
|
|
1252
|
+
"text": "any"
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
],
|
|
1256
|
+
"description": "Test a value considered to be allowed for validation reasons\nA boolean cast to falsy is considered invalid, except special case\nthat we allow `0` because that's a valid numeric comparison.\nThis will consider blank strings invalid, to test against that explicitly the user\nshould define an operator such as `is_blank`\nThis shouldn't be used on a boolean value"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
"kind": "function",
|
|
1260
|
+
"name": "isPartialRuleError",
|
|
1261
|
+
"return": {
|
|
1262
|
+
"type": {
|
|
1263
|
+
"text": "boolean"
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
"parameters": [
|
|
1267
|
+
{
|
|
1268
|
+
"name": "model",
|
|
1269
|
+
"type": {
|
|
1270
|
+
"text": "ModelRule"
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
]
|
|
1180
1274
|
}
|
|
1181
1275
|
],
|
|
1182
1276
|
"exports": [
|
|
@@ -1188,6 +1282,14 @@
|
|
|
1188
1282
|
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1189
1283
|
}
|
|
1190
1284
|
},
|
|
1285
|
+
{
|
|
1286
|
+
"kind": "js",
|
|
1287
|
+
"name": "getValue",
|
|
1288
|
+
"declaration": {
|
|
1289
|
+
"name": "getValue",
|
|
1290
|
+
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1291
|
+
}
|
|
1292
|
+
},
|
|
1191
1293
|
{
|
|
1192
1294
|
"kind": "js",
|
|
1193
1295
|
"name": "fieldDefault",
|
|
@@ -1195,6 +1297,38 @@
|
|
|
1195
1297
|
"name": "fieldDefault",
|
|
1196
1298
|
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1197
1299
|
}
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
"kind": "js",
|
|
1303
|
+
"name": "operatorChangedUpdatedModel",
|
|
1304
|
+
"declaration": {
|
|
1305
|
+
"name": "operatorChangedUpdatedModel",
|
|
1306
|
+
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
"kind": "js",
|
|
1311
|
+
"name": "valueChangedUpdateModel",
|
|
1312
|
+
"declaration": {
|
|
1313
|
+
"name": "valueChangedUpdateModel",
|
|
1314
|
+
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
"kind": "js",
|
|
1319
|
+
"name": "isValueInvalid",
|
|
1320
|
+
"declaration": {
|
|
1321
|
+
"name": "isValueInvalid",
|
|
1322
|
+
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
"kind": "js",
|
|
1327
|
+
"name": "isPartialRuleError",
|
|
1328
|
+
"declaration": {
|
|
1329
|
+
"name": "isPartialRuleError",
|
|
1330
|
+
"module": "src/main/expression-rule/expression-rule.helpers.ts"
|
|
1331
|
+
}
|
|
1198
1332
|
}
|
|
1199
1333
|
]
|
|
1200
1334
|
},
|
|
@@ -1205,7 +1339,7 @@
|
|
|
1205
1339
|
{
|
|
1206
1340
|
"kind": "variable",
|
|
1207
1341
|
"name": "styles",
|
|
1208
|
-
"default": "css`\n .rule-container {\n border: 1px solid #eee;\n margin-bottom: 5px;\n padding: 5px;\n display: grid;\n grid-template-columns: auto 1fr;\n }\n\n .margin {\n margin-left: calc(var(--design-unit) * 1px);\n margin-right: calc(var(--design-unit) * 1px);\n }\n\n .rule-header {\n margin-bottom: 5px;\n display: flex;\n justify-content: flex-end;\n }\n\n .rule-actions {\n display: inline-block;\n }\n\n .rule-content {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n }\n\n .rule-field-container,\n .rule-operator-container,\n .rule-value-container {\n display: inline-block;\n margin: 0 5px 0 0;\n vertical-align: middle;\n }\n\n .rule-value-container {\n border-left: var(--rule-value-separator);\n padding-left: 5px;\n }\n\n .rule-value-container label {\n margin-bottom: 0;\n font-weight: normal;\n }\n\n .rule-value-container label.block {\n display: block;\n }\n\n expression-rule-value {\n display: flex;\n }\n`"
|
|
1342
|
+
"default": "css`\n .rule-container {\n border: 1px solid #eee;\n margin-bottom: 5px;\n padding: 5px;\n display: grid;\n grid-template-columns: auto 1fr;\n }\n\n .rule-container.error {\n border-color: red;\n }\n\n .margin {\n margin-left: calc(var(--design-unit) * 1px);\n margin-right: calc(var(--design-unit) * 1px);\n }\n\n .rule-header {\n margin-bottom: 5px;\n display: flex;\n justify-content: flex-end;\n }\n\n .rule-actions {\n display: inline-block;\n }\n\n .rule-content {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n }\n\n .rule-field-container,\n .rule-operator-container,\n .rule-value-container {\n display: inline-block;\n margin: 0 5px 0 0;\n vertical-align: middle;\n }\n\n .rule-value-container {\n border-left: var(--rule-value-separator);\n padding-left: 5px;\n }\n\n .rule-value-container label {\n margin-bottom: 0;\n font-weight: normal;\n }\n\n .rule-value-container label.block {\n display: block;\n }\n\n expression-rule-value {\n display: flex;\n }\n`"
|
|
1209
1343
|
}
|
|
1210
1344
|
],
|
|
1211
1345
|
"exports": [
|
|
@@ -1226,7 +1360,7 @@
|
|
|
1226
1360
|
{
|
|
1227
1361
|
"kind": "variable",
|
|
1228
1362
|
"name": "template",
|
|
1229
|
-
"default": "html<ExpressionRule>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n\n return html<ExpressionRule>`\n <div class=\"rule-container\">\n <div class=\"rule-content\">\n <expression-rule-field\nclass=\"margin\"\n :fields=${(x) => x.config.fields}\n :field=${(x) => x.model?.field}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @field-selected=${(x, c) =>\n x.handleFieldSelected(c.event as CustomEvent<EventsDetailMap[Events.FieldSelected]>)}\n ></expression-rule-field>\n <expression-rule-operator\nclass=\"margin\"\n :operators=${(x) => x.config.operators}\n :field=${(x) => x.model.field}\n :operator=${(x) => x.model?.operator}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @operator-selected=${(x, c) =>\n x.handleOperatorSelected(\n c.event as CustomEvent<EventsDetailMap[Events.OperatorSelected]>,\n )}\n ></expression-rule-operator>\n ${repeat(\n (x) => x.operandIterator,\n html<true, ExpressionRule>`\n <expression-rule-value\n class=\"margin\"\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :field=${(_, c) => c.parent.model.field}\n :value=${(_, c) => c.parent.operandValue(c.index)}\n value-index=${(_, c) => c.index}\n ?variadic=${(_, c) => c.parent.model?.operator?.nbInputs === 'many'}\n @value-updated=${(_, c) =>\n c.parent.handleValueChanged(\n c.event as CustomEvent<EventsDetailMap[Events.ValueUpdated]>,\n )}\n @remove-variadic-operand=${(_, c) =>\n c.parent.handleRemoveVarArg(\n c.event as CustomEvent<EventsDetailMap[Events.RemoveVarArg]>,\n )}\n ></expression-rule-value>\n `,\n { positioning: true, recycle: false },\n )}\n ${when(\n (x) => x.model?.operator?.nbInputs === 'many',\n html<ExpressionRule>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-accept\"\n @click=\"${(x) => x.dispatchAddVarArg()}\"\n >\n +\n </${buttonTag}>\n `,\n )}\n </div>\n\n <div class=\"rule-header\">\n <div class=\"btn-group rule-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"rule\"\n @click=\"${(x, c) => x.dispatchDeleteRule(c.event)}\"\n >\n Delete Rule\n </${buttonTag}>\n </div>\n </div>\n </div>\n `;\n }}\n`"
|
|
1363
|
+
"default": "html<ExpressionRule>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n\n return html<ExpressionRule>`\n <div class=\"rule-container ${(x) => classNames(['error', x.error])}\">\n <div class=\"rule-content\">\n <expression-rule-field\nclass=\"margin\"\n :fields=${(x) => x.config.fields}\n :field=${(x) => x.model?.field}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @field-selected=${(x, c) =>\n x.handleFieldSelected(c.event as CustomEvent<EventsDetailMap[Events.FieldSelected]>)}\n ></expression-rule-field>\n <expression-rule-operator\nclass=\"margin\"\n :operators=${(x) => x.config.operators}\n :field=${(x) => x.model.field}\n :operator=${(x) => x.model?.operator}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @operator-selected=${(x, c) =>\n x.handleOperatorSelected(\n c.event as CustomEvent<EventsDetailMap[Events.OperatorSelected]>,\n )}\n ></expression-rule-operator>\n ${repeat(\n (x) => x.operandIterator,\n html<true, ExpressionRule>`\n <expression-rule-value\n class=\"margin\"\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :field=${(_, c) => c.parent.model.field}\n :value=${(_, c) => c.parent.operandValue(c.index)}\n value-index=${(_, c) => c.index}\n ?variadic=${(_, c) => c.parent.model?.operator?.nbInputs === 'many'}\n @value-updated=${(_, c) =>\n c.parent.handleValueChanged(\n c.event as CustomEvent<EventsDetailMap[Events.ValueUpdated]>,\n )}\n @remove-variadic-operand=${(_, c) =>\n c.parent.handleRemoveVarArg(\n c.event as CustomEvent<EventsDetailMap[Events.RemoveVarArg]>,\n )}\n ></expression-rule-value>\n `,\n { positioning: true, recycle: false },\n )}\n ${when(\n (x) => x.model?.operator?.nbInputs === 'many',\n html<ExpressionRule>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-accept\"\n @click=\"${(x) => x.dispatchAddVarArg()}\"\n >\n +\n </${buttonTag}>\n `,\n )}\n </div>\n\n <div class=\"rule-header\">\n <div class=\"btn-group rule-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"rule\"\n @click=\"${(x, c) => x.dispatchDeleteRule(c.event)}\"\n >\n Delete Rule\n </${buttonTag}>\n </div>\n </div>\n </div>\n `;\n }}\n`"
|
|
1230
1364
|
}
|
|
1231
1365
|
],
|
|
1232
1366
|
"exports": [
|
|
@@ -1277,6 +1411,14 @@
|
|
|
1277
1411
|
"text": "number"
|
|
1278
1412
|
}
|
|
1279
1413
|
},
|
|
1414
|
+
{
|
|
1415
|
+
"kind": "field",
|
|
1416
|
+
"name": "error",
|
|
1417
|
+
"type": {
|
|
1418
|
+
"text": "boolean"
|
|
1419
|
+
},
|
|
1420
|
+
"default": "false"
|
|
1421
|
+
},
|
|
1280
1422
|
{
|
|
1281
1423
|
"kind": "method",
|
|
1282
1424
|
"name": "variadicRule",
|
|
@@ -1388,6 +1530,15 @@
|
|
|
1388
1530
|
}
|
|
1389
1531
|
}
|
|
1390
1532
|
],
|
|
1533
|
+
"attributes": [
|
|
1534
|
+
{
|
|
1535
|
+
"type": {
|
|
1536
|
+
"text": "boolean"
|
|
1537
|
+
},
|
|
1538
|
+
"default": "false",
|
|
1539
|
+
"fieldName": "error"
|
|
1540
|
+
}
|
|
1541
|
+
],
|
|
1391
1542
|
"superclass": {
|
|
1392
1543
|
"name": "GenesisElement",
|
|
1393
1544
|
"package": "@genesislcap/web-core"
|
|
@@ -1536,7 +1687,7 @@
|
|
|
1536
1687
|
{
|
|
1537
1688
|
"kind": "variable",
|
|
1538
1689
|
"name": "template",
|
|
1539
|
-
"default": "html<RuleOperator>`\n ${(context) => {\n const selectTag = context.styles?.customElements?.select || 'select';\n const optionTag = context.styles?.customElements?.option || 'option';\n const optgroupTag = 'optgroup'; // Not supporting custom optgroup for now\n\n return html<RuleOperator>`\n <${selectTag}\n class=\"form-select\"\n @change=${(x, c) => x.handleOperatorChange(c.event)}\n value=${(x) => x.operator?.type}\n >\n <${optionTag} value=\"\">Select an operator</${optionTag}>\n ${repeat(\n (x) => x.groupedOperators,\n html<{ optgroup: string | null; xs: Operator[] } | Operator, RuleOperator>`\n ${(groupOrOperator) => {\n if ('xs' in groupOrOperator) {\n return html<{ optgroup: string | null; xs: Operator[] }, RuleOperator>`\n <${optgroupTag} label=\"${groupOrOperator.optgroup}\">\n ${repeat(\n (x) => x.xs,\n html<Operator>`\n <${optionTag}\n value=\"${(x) => x.type}\"\n ?selected=${(x, c) => x.type === c.parentContext.parent.operator?.type}\n >\n ${(x) => x.type}\n </${optionTag}>\n `,\n )}\n </${optgroupTag}>\n `;\n } else {\n return html<Operator, RuleOperator>`\n <${optionTag}\n value=\"${(x) => x.type}\"\n ?selected=${(x, c) => c.parent.operator?.type === x.type}\n >\n ${(x) => x.type}\n </${optionTag}>\n `;\n }\n }}\n `,\n )}\n </${selectTag}>\n `;\n }}\n`"
|
|
1690
|
+
"default": "html<RuleOperator>`\n ${(context) => {\n const selectTag = context.styles?.customElements?.select || 'select';\n const optionTag = context.styles?.customElements?.option || 'option';\n const optgroupTag = 'optgroup'; // Not supporting custom optgroup for now\n\n return html<RuleOperator>`\n <${selectTag}\n class=\"form-select\"\n @change=${(x, c) => x.handleOperatorChange(c.event)}\n value=${(x) => x.operator?.type}\n >\n <${optionTag} value=\"\">Select an operator</${optionTag}>\n ${repeat(\n (x) => x.groupedOperators,\n html<{ optgroup: string | null; xs: Operator[] } | Operator, RuleOperator>`\n ${(groupOrOperator) => {\n if ('xs' in groupOrOperator) {\n return html<{ optgroup: string | null; xs: Operator[] }, RuleOperator>`\n <${optgroupTag} label=\"${groupOrOperator.optgroup}\">\n ${repeat(\n (x) => x.xs,\n html<Operator>`\n <${optionTag}\n value=\"${(x) => x.type}\"\n ?selected=${(x, c) => x.type === c.parentContext.parent.operator?.type}\n title=${(x) => x.tooltip}\n >\n ${(x) => x.type}\n </${optionTag}>\n `,\n )}\n </${optgroupTag}>\n `;\n } else {\n return html<Operator, RuleOperator>`\n <${optionTag}\n value=\"${(x) => x.type}\"\n ?selected=${(x, c) => c.parent.operator?.type === x.type}\n title=${(x) => x.tooltip}\n >\n ${(x) => x.type}\n </${optionTag}>\n `;\n }\n }}\n `,\n )}\n </${selectTag}>\n `;\n }}\n`"
|
|
1540
1691
|
}
|
|
1541
1692
|
],
|
|
1542
1693
|
"exports": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-group.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-group/expression-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrE,qBAQa,eAAgB,SAAQ,cAAc;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IAE1B,iBAAiB,IAAI,IAAI;IAKzB,IACI,gBAAgB,IAAI,OAAO,CAI9B;
|
|
1
|
+
{"version":3,"file":"expression-group.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-group/expression-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrE,qBAQa,eAAgB,SAAQ,cAAc;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IAE1B,iBAAiB,IAAI,IAAI;IAKzB,IACI,gBAAgB,IAAI,OAAO,CAI9B;IAED,eAAe,CAAC,KAAK,EAAE,KAAK;IAQ5B,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAY7B,mBAAmB,CAAC,KAAK,EAAE,KAAK;IAQhC,sBAAsB,CAAC,KAAK,EAAE,KAAK;IAQnC,4BAA4B,CAAC,KAAK,EAAE,KAAK;IAazC,OAAO,CAAC,gBAAgB;IAcxB,wBAAwB,CAAC,UAAU,EAAE,UAAU;CAWhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-group.template.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-group/expression-group.template.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"expression-group.template.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-group/expression-group.template.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,QAAQ,sEA0IpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-rule.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"expression-rule.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAQ,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAiBpD,qBAQa,cAAe,SAAQ,cAAc;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IAEC,KAAK,UAAS;IAEzC,iBAAiB,IAAI,IAAI;IAQzB,YAAY,CACV,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,SAAS,GAAG;QAAE,QAAQ,EAAE,gBAAgB,CAAC;QAAC,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE;IAIpE;;;OAGG;IACH,IACI,eAAe,IAAI,IAAI,EAAE,CAM5B;IAED,YAAY,CAAC,KAAK,EAAE,MAAM;IAc1B,iBAAiB,IAAI,IAAI;IAgBzB,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI;IAiBlF,kBAAkB,CAAC,KAAK,EAAE,KAAK;IAQ/B,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAqB7E,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAY3E,sBAAsB,CAAC,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;CAsBpF"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { Field } from '../../types';
|
|
1
|
+
import { Field, ModelRule, Operator, Rule } from '../../types';
|
|
2
2
|
export declare const defaultVal: (f: Field) => any;
|
|
3
|
+
export declare const getValue: (m: ModelRule) => (index: number) => any;
|
|
3
4
|
export declare const fieldDefault: (f: Field) => string | false | 0;
|
|
5
|
+
export declare const operatorChangedUpdatedModel: (newOperator: Operator, model: ModelRule) => Rule;
|
|
6
|
+
export declare const valueChangedUpdateModel: (model: ModelRule, value: any, argIndex: number) => Rule;
|
|
7
|
+
/**
|
|
8
|
+
* Test a value considered to be allowed for validation reasons
|
|
9
|
+
* A boolean cast to falsy is considered invalid, except special case
|
|
10
|
+
* that we allow `0` because that's a valid numeric comparison.
|
|
11
|
+
* This will consider blank strings invalid, to test against that explicitly the user
|
|
12
|
+
* should define an operator such as `is_blank`
|
|
13
|
+
* This shouldn't be used on a boolean value
|
|
14
|
+
*/
|
|
15
|
+
export declare const isValueInvalid: (x: any) => boolean;
|
|
16
|
+
export declare const isPartialRuleError: (model: ModelRule) => boolean;
|
|
4
17
|
//# sourceMappingURL=expression-rule.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-rule.helpers.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"expression-rule.helpers.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EAIL,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,UAAU,MAAO,KAAK,QAC8B,CAAC;AAElE,eAAO,MAAM,QAAQ,MAAO,SAAS,aAAa,MAAM,QAKvD,CAAC;AAEF,eAAO,MAAM,YAAY,MAAO,KAAK,uBAqBpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,gBAAiB,QAAQ,SAAS,SAAS,KAAG,IA4BrF,CAAC;AAEF,eAAO,MAAM,uBAAuB,UAAW,SAAS,SAAS,GAAG,YAAY,MAAM,KAAG,IAqBxF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,MAAO,GAAG,YAAkB,CAAC;AAExD,eAAO,MAAM,kBAAkB,UAAW,SAAS,KAAG,OASrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-rule.styles.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"expression-rule.styles.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,iDA2DlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-operator.template.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-operator/rule-operator.template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"rule-operator.template.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-operator/rule-operator.template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,QAAQ,mEAmDpB,CAAC"}
|
|
@@ -52,12 +52,16 @@ export type Config = {
|
|
|
52
52
|
model?: Group;
|
|
53
53
|
/** If set and more than 0, is a 1-indexed config for the nesting of groups */
|
|
54
54
|
maxNesting?: number;
|
|
55
|
+
/** If set a rule will highlight in an error colour when it's not complete
|
|
56
|
+
* (doesn't have a field + operator + (maybe value) selected) */
|
|
57
|
+
partialRuleValidationWarning?: boolean;
|
|
55
58
|
};
|
|
56
59
|
/** @alpha **/
|
|
57
60
|
export type _Operator = {
|
|
58
61
|
applyTo: FieldTypes['type'][];
|
|
59
62
|
optgroup?: string | null;
|
|
60
63
|
type: string;
|
|
64
|
+
tooltip?: string;
|
|
61
65
|
};
|
|
62
66
|
/** @alpha **/
|
|
63
67
|
export type UniraryOperator = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.types.d.ts","sourceRoot":"","sources":["../../../src/types/public.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,MAAM,cAAc,GAAG;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;oFACgF;IAChF,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,YAAY,GAAG;IACzB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,MAAM,GAAG;IACnB,4CAA4C;IAC5C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mCAAmC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC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AAC;IACvB,QAAQ,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;CAC5B,CAAC"}
|
|
@@ -17,16 +17,6 @@ let ExpressionGroup = class ExpressionGroup extends GenesisElement {
|
|
|
17
17
|
return true;
|
|
18
18
|
return this.config.maxNesting > this.model.level;
|
|
19
19
|
}
|
|
20
|
-
// configChanged(_, newConfig: Config) {
|
|
21
|
-
// if (!this.combinator) {
|
|
22
|
-
// this.combinator = newConfig.combinators[0];
|
|
23
|
-
// }
|
|
24
|
-
// }
|
|
25
|
-
//
|
|
26
|
-
// modelChanged(_, newModel: ModelGroup) {
|
|
27
|
-
// if (!newModel) return;
|
|
28
|
-
// this.combinator = newModel.combinator;
|
|
29
|
-
// }
|
|
30
20
|
dispatchAddRule(event) {
|
|
31
21
|
event.stopPropagation();
|
|
32
22
|
const detail = {
|
|
@@ -7,6 +7,8 @@ export const template = html `
|
|
|
7
7
|
const { radioTag, radioGroupTag } = maybeRadioBlock
|
|
8
8
|
? { radioTag: maybeRadioBlock.input, radioGroupTag: maybeRadioBlock.group }
|
|
9
9
|
: { radioTag: 'input', radioGroupTag: 'div' };
|
|
10
|
+
const ruleTooltip = `Add a new condition with field (e.g. CURRENCY), operator (e.g. EQUALS), and value (e.g. GBP) that will be combined with other conditions in this group using the selected logic (e.g. ${context.config.combinators[0].type})`;
|
|
11
|
+
const groupTooltip = `Add a new nested sub-group to create more complex expressions, joined by combinatorial logic (e.g. ${context.config.combinators[0].type})`;
|
|
10
12
|
return html `
|
|
11
13
|
<div class="rules-group-container">
|
|
12
14
|
<div class="rules-group-header">
|
|
@@ -16,6 +18,7 @@ export const template = html `
|
|
|
16
18
|
class="btn btn-sm btn-success"
|
|
17
19
|
data-add="rule"
|
|
18
20
|
@click="${(x, c) => x.dispatchAddRule(c.event)}"
|
|
21
|
+
title=${(_) => ruleTooltip}
|
|
19
22
|
>
|
|
20
23
|
Add Rule
|
|
21
24
|
</${buttonTag}>
|
|
@@ -25,6 +28,7 @@ export const template = html `
|
|
|
25
28
|
class="btn btn-sm btn-success"
|
|
26
29
|
data-add="group"
|
|
27
30
|
@click="${(x, c) => x.dispatchAddGroup(c.event)}"
|
|
31
|
+
title="${(_) => groupTooltip}"
|
|
28
32
|
>
|
|
29
33
|
Add Group
|
|
30
34
|
</${buttonTag}>
|
|
@@ -92,6 +96,11 @@ export const template = html `
|
|
|
92
96
|
:index=${(_, c) => c.index}
|
|
93
97
|
></expression-rule>
|
|
94
98
|
`)}
|
|
99
|
+
${when((_, loopCtx) => !loopCtx.isLast, html `
|
|
100
|
+
<p class="group-combinator-link">
|
|
101
|
+
${(_, innerCtx) => innerCtx.parent.model.combinator.type}
|
|
102
|
+
</p>
|
|
103
|
+
`)}
|
|
95
104
|
`, { recycle: false, positioning: true })}
|
|
96
105
|
</div>
|
|
97
106
|
</div>
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { formatDateString, formatDateTimeString } from '../../utils';
|
|
2
2
|
export const defaultVal = (f) => f.defaultValue !== undefined ? f.defaultValue : fieldDefault(f);
|
|
3
|
+
export const getValue = (m) => (index) => {
|
|
4
|
+
if (!('value' in m) || !m.value || !m.operator)
|
|
5
|
+
return null;
|
|
6
|
+
const value = m.operator.nbInputs === 1 ? [m.value] : m.value;
|
|
7
|
+
if (index >= value.length)
|
|
8
|
+
return null;
|
|
9
|
+
return value[index];
|
|
10
|
+
};
|
|
3
11
|
export const fieldDefault = (f) => {
|
|
4
12
|
switch (f.type) {
|
|
5
13
|
case 'string':
|
|
@@ -23,3 +31,79 @@ export const fieldDefault = (f) => {
|
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
};
|
|
34
|
+
export const operatorChangedUpdatedModel = (newOperator, model) => {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const tryPrevVal = getValue(model);
|
|
37
|
+
switch (newOperator.nbInputs) {
|
|
38
|
+
case 0:
|
|
39
|
+
return {
|
|
40
|
+
field: model.field,
|
|
41
|
+
operator: newOperator,
|
|
42
|
+
};
|
|
43
|
+
case 1:
|
|
44
|
+
return {
|
|
45
|
+
field: model.field,
|
|
46
|
+
operator: newOperator,
|
|
47
|
+
value: (_a = tryPrevVal(0)) !== null && _a !== void 0 ? _a : defaultVal(model.field),
|
|
48
|
+
};
|
|
49
|
+
case 2:
|
|
50
|
+
return {
|
|
51
|
+
field: model.field,
|
|
52
|
+
operator: newOperator,
|
|
53
|
+
value: [(_b = tryPrevVal(0)) !== null && _b !== void 0 ? _b : defaultVal(model.field), (_c = tryPrevVal(1)) !== null && _c !== void 0 ? _c : defaultVal(model.field)],
|
|
54
|
+
};
|
|
55
|
+
case 'many':
|
|
56
|
+
return {
|
|
57
|
+
field: model.field,
|
|
58
|
+
operator: newOperator,
|
|
59
|
+
// Variadic operators always start with 1 operand
|
|
60
|
+
value: [(_d = tryPrevVal(0)) !== null && _d !== void 0 ? _d : defaultVal(model.field)],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export const valueChangedUpdateModel = (model, value, argIndex) => {
|
|
65
|
+
switch (model.operator.nbInputs) {
|
|
66
|
+
case 0:
|
|
67
|
+
throw new Error('Cannot set the value for a UniraryOperator');
|
|
68
|
+
case 1:
|
|
69
|
+
return {
|
|
70
|
+
field: model.field,
|
|
71
|
+
operator: model.operator,
|
|
72
|
+
value,
|
|
73
|
+
};
|
|
74
|
+
case 2:
|
|
75
|
+
case 'many': {
|
|
76
|
+
if (!('value' in model) || !Array.isArray(model.value))
|
|
77
|
+
throw new Error('Invalid value shape for rule');
|
|
78
|
+
return {
|
|
79
|
+
field: model.field,
|
|
80
|
+
operator: model.operator,
|
|
81
|
+
value: model.value.map((v, i) => (i === argIndex ? value : v)),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Test a value considered to be allowed for validation reasons
|
|
88
|
+
* A boolean cast to falsy is considered invalid, except special case
|
|
89
|
+
* that we allow `0` because that's a valid numeric comparison.
|
|
90
|
+
* This will consider blank strings invalid, to test against that explicitly the user
|
|
91
|
+
* should define an operator such as `is_blank`
|
|
92
|
+
* This shouldn't be used on a boolean value
|
|
93
|
+
*/
|
|
94
|
+
export const isValueInvalid = (x) => !x && x !== 0;
|
|
95
|
+
export const isPartialRuleError = (model) => {
|
|
96
|
+
if (!model.field || !model.operator)
|
|
97
|
+
return true;
|
|
98
|
+
if (model.operator.nbInputs === 0)
|
|
99
|
+
return false;
|
|
100
|
+
if (!('value' in model))
|
|
101
|
+
throw new Error('No value set as required for operator');
|
|
102
|
+
// Checking against either false or true boolean is valid
|
|
103
|
+
if (model.field.type === 'boolean')
|
|
104
|
+
return false;
|
|
105
|
+
const value = Array.isArray(model.value) ? model.value : [model.value];
|
|
106
|
+
if (value.some(isValueInvalid))
|
|
107
|
+
return true;
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { customElement, GenesisElement, observable, volatile } from '@genesislcap/web-core';
|
|
2
|
+
import { attr, customElement, GenesisElement, observable, volatile } from '@genesislcap/web-core';
|
|
3
3
|
import { applyCustomStyles } from '../../utils/misc';
|
|
4
4
|
import { Events } from '../events';
|
|
5
5
|
import { RuleField } from '../rule-field/rule-field';
|
|
6
6
|
import { RuleOperator } from '../rule-operator/rule-operator';
|
|
7
7
|
import { RuleValue } from '../rule-value/rule-value';
|
|
8
|
-
import { defaultVal } from './expression-rule.helpers';
|
|
8
|
+
import { operatorChangedUpdatedModel, defaultVal, valueChangedUpdateModel, isPartialRuleError, } from './expression-rule.helpers';
|
|
9
9
|
import { styles } from './expression-rule.styles';
|
|
10
10
|
import { template } from './expression-rule.template';
|
|
11
11
|
RuleOperator;
|
|
12
12
|
RuleField;
|
|
13
13
|
RuleValue;
|
|
14
14
|
let ExpressionRule = class ExpressionRule extends GenesisElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.error = false;
|
|
18
|
+
}
|
|
15
19
|
connectedCallback() {
|
|
16
20
|
super.connectedCallback();
|
|
17
21
|
applyCustomStyles(this, this.styles, 'rule');
|
|
22
|
+
if (this.config.partialRuleValidationWarning) {
|
|
23
|
+
this.error = isPartialRuleError(this.model);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
variadicRule(model) {
|
|
20
27
|
return model.operator.nbInputs === 'many' && 'value' in model && Array.isArray(model.value);
|
|
@@ -100,31 +107,9 @@ let ExpressionRule = class ExpressionRule extends GenesisElement {
|
|
|
100
107
|
handleValueChanged(event) {
|
|
101
108
|
event.stopPropagation();
|
|
102
109
|
const { value, index } = event.detail;
|
|
103
|
-
const buildUpdatedModel = (operator) => {
|
|
104
|
-
switch (operator.nbInputs) {
|
|
105
|
-
case 0:
|
|
106
|
-
throw new Error('Cannot set the value for a UniraryOperator');
|
|
107
|
-
case 1:
|
|
108
|
-
return {
|
|
109
|
-
field: this.model.field,
|
|
110
|
-
operator: operator,
|
|
111
|
-
value,
|
|
112
|
-
};
|
|
113
|
-
case 2:
|
|
114
|
-
case 'many': {
|
|
115
|
-
if (!('value' in this.model) || !Array.isArray(this.model.value))
|
|
116
|
-
throw new Error('Invalid value shape for rule');
|
|
117
|
-
return {
|
|
118
|
-
field: this.model.field,
|
|
119
|
-
operator: operator,
|
|
120
|
-
value: this.model.value.map((v, i) => (i === index ? value : v)),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
110
|
const detail = {
|
|
126
111
|
ruleId: this.model.ruleId,
|
|
127
|
-
newData:
|
|
112
|
+
newData: valueChangedUpdateModel(this.model, value, index),
|
|
128
113
|
};
|
|
129
114
|
this.dispatchEvent(new CustomEvent(Events.UpdateRule, { detail, bubbles: true, composed: true }));
|
|
130
115
|
}
|
|
@@ -138,37 +123,10 @@ let ExpressionRule = class ExpressionRule extends GenesisElement {
|
|
|
138
123
|
if (!newOperator) {
|
|
139
124
|
throw new Error(`Unable to find operator of type ${operatorType}`);
|
|
140
125
|
}
|
|
141
|
-
const buildUpdatedModel = (operator) => {
|
|
142
|
-
switch (operator.nbInputs) {
|
|
143
|
-
case 0:
|
|
144
|
-
return {
|
|
145
|
-
field: this.model.field,
|
|
146
|
-
operator: operator,
|
|
147
|
-
};
|
|
148
|
-
case 1:
|
|
149
|
-
return {
|
|
150
|
-
field: this.model.field,
|
|
151
|
-
operator: operator,
|
|
152
|
-
value: defaultVal(this.model.field),
|
|
153
|
-
};
|
|
154
|
-
case 2:
|
|
155
|
-
return {
|
|
156
|
-
field: this.model.field,
|
|
157
|
-
operator: operator,
|
|
158
|
-
value: [defaultVal(this.model.field), defaultVal(this.model.field)],
|
|
159
|
-
};
|
|
160
|
-
case 'many':
|
|
161
|
-
return {
|
|
162
|
-
field: this.model.field,
|
|
163
|
-
operator: operator,
|
|
164
|
-
value: [defaultVal(this.model.field)],
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
126
|
this.dispatchEvent(new CustomEvent(Events.UpdateRule, {
|
|
169
127
|
detail: {
|
|
170
128
|
ruleId: this.model.ruleId,
|
|
171
|
-
newData:
|
|
129
|
+
newData: operatorChangedUpdatedModel(newOperator, this.model),
|
|
172
130
|
},
|
|
173
131
|
bubbles: true,
|
|
174
132
|
composed: true,
|
|
@@ -187,6 +145,9 @@ __decorate([
|
|
|
187
145
|
__decorate([
|
|
188
146
|
observable
|
|
189
147
|
], ExpressionRule.prototype, "index", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
attr({ mode: 'boolean' })
|
|
150
|
+
], ExpressionRule.prototype, "error", void 0);
|
|
190
151
|
__decorate([
|
|
191
152
|
volatile
|
|
192
153
|
], ExpressionRule.prototype, "operandIterator", null);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { html, repeat, when } from '@genesislcap/web-core';
|
|
1
|
+
import { classNames, html, repeat, when } from '@genesislcap/web-core';
|
|
2
2
|
export const template = html `
|
|
3
3
|
${(context) => {
|
|
4
4
|
var _a, _b;
|
|
5
5
|
const buttonTag = ((_b = (_a = context.styles) === null || _a === void 0 ? void 0 : _a.customElements) === null || _b === void 0 ? void 0 : _b.button) || 'button';
|
|
6
6
|
return html `
|
|
7
|
-
<div class="rule-container">
|
|
7
|
+
<div class="rule-container ${(x) => classNames(['error', x.error])}">
|
|
8
8
|
<div class="rule-content">
|
|
9
9
|
<expression-rule-field
|
|
10
10
|
class="margin"
|
|
@@ -21,6 +21,7 @@ export const template = html `
|
|
|
21
21
|
<${optionTag}
|
|
22
22
|
value="${(x) => x.type}"
|
|
23
23
|
?selected=${(x, c) => { var _a; return x.type === ((_a = c.parentContext.parent.operator) === null || _a === void 0 ? void 0 : _a.type); }}
|
|
24
|
+
title=${(x) => x.tooltip}
|
|
24
25
|
>
|
|
25
26
|
${(x) => x.type}
|
|
26
27
|
</${optionTag}>
|
|
@@ -33,6 +34,7 @@ export const template = html `
|
|
|
33
34
|
<${optionTag}
|
|
34
35
|
value="${(x) => x.type}"
|
|
35
36
|
?selected=${(x, c) => { var _a; return ((_a = c.parent.operator) === null || _a === void 0 ? void 0 : _a.type) === x.type; }}
|
|
37
|
+
title=${(x) => x.tooltip}
|
|
36
38
|
>
|
|
37
39
|
${(x) => x.type}
|
|
38
40
|
</${optionTag}>
|
|
@@ -50,6 +50,9 @@ declare type Config_2 = {
|
|
|
50
50
|
model?: Group;
|
|
51
51
|
/** If set and more than 0, is a 1-indexed config for the nesting of groups */
|
|
52
52
|
maxNesting?: number;
|
|
53
|
+
/** If set a rule will highlight in an error colour when it's not complete
|
|
54
|
+
* (doesn't have a field + operator + (maybe value) selected) */
|
|
55
|
+
partialRuleValidationWarning?: boolean;
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
/** @alpha **/
|
|
@@ -232,6 +235,7 @@ declare type _Operator = {
|
|
|
232
235
|
applyTo: FieldTypes['type'][];
|
|
233
236
|
optgroup?: string | null;
|
|
234
237
|
type: string;
|
|
238
|
+
tooltip?: string;
|
|
235
239
|
};
|
|
236
240
|
|
|
237
241
|
/** @alpha **/
|
package/docs/api-report.md
CHANGED
|
@@ -54,6 +54,7 @@ type Config_2 = {
|
|
|
54
54
|
combinators: Combinator[];
|
|
55
55
|
model?: Group;
|
|
56
56
|
maxNesting?: number;
|
|
57
|
+
partialRuleValidationWarning?: boolean;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
// @alpha (undocumented)
|
|
@@ -167,6 +168,7 @@ type _Operator = {
|
|
|
167
168
|
applyTo: FieldTypes['type'][];
|
|
168
169
|
optgroup?: string | null;
|
|
169
170
|
type: string;
|
|
171
|
+
tooltip?: string;
|
|
170
172
|
};
|
|
171
173
|
|
|
172
174
|
// @alpha (undocumented)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/expression-builder",
|
|
3
3
|
"description": "Genesis Foundation Expression Builder",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.255.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/expression-builder.d.ts",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
64
|
"customElements": "dist/custom-elements.json",
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0138f4ab8d5257e8ffcc6f744c5524a8beb6e11c"
|
|
66
66
|
}
|