@genesislcap/expression-builder 14.253.0 → 14.254.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 +471 -320
- 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
|
@@ -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;I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,EAAE,GAAG,CAAC,CAAC;CACnB,GACD;IACE,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,GAAG,EAAE,CAAC;CACd,CACJ,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,UAAU,CAAC;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.254.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": "de0da7f3f592bd417917da9dc7b163e57984ea7c"
|
|
66
66
|
}
|