@genesislcap/expression-builder 14.260.0 → 14.260.1-RPT-0.1
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 +24 -1
- package/dist/dts/main/expression-builder.d.ts +2 -0
- package/dist/dts/main/expression-builder.d.ts.map +1 -1
- package/dist/dts/main/expression-builder.template.d.ts.map +1 -1
- package/dist/esm/main/expression-builder.js +31 -10
- package/dist/esm/main/expression-builder.template.js +8 -6
- package/dist/expression-builder.d.ts +2 -0
- package/package.json +2 -2
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
{
|
|
425
425
|
"kind": "variable",
|
|
426
426
|
"name": "template",
|
|
427
|
-
"default": "html<ExpressionBuilder>`\n <div class=\"query-builder\">\n <expression-group\n
|
|
427
|
+
"default": "html<ExpressionBuilder>`\n <div class=\"query-builder\">\n ${when(\n (x) => x.model !== null,\n html<ExpressionBuilder>`\n <expression-group\n :model=${(x) => x.model}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n ></expression-group>\n `,\n )}\n </div>\n`"
|
|
428
428
|
}
|
|
429
429
|
],
|
|
430
430
|
"exports": [
|
|
@@ -500,6 +500,29 @@
|
|
|
500
500
|
}
|
|
501
501
|
]
|
|
502
502
|
},
|
|
503
|
+
{
|
|
504
|
+
"kind": "method",
|
|
505
|
+
"name": "isValidConfig",
|
|
506
|
+
"privacy": "private",
|
|
507
|
+
"return": {
|
|
508
|
+
"type": {
|
|
509
|
+
"text": "boolean"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
"parameters": [
|
|
513
|
+
{
|
|
514
|
+
"name": "config",
|
|
515
|
+
"type": {
|
|
516
|
+
"text": "Config"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"kind": "method",
|
|
523
|
+
"name": "initBaseModel",
|
|
524
|
+
"privacy": "private"
|
|
525
|
+
},
|
|
503
526
|
{
|
|
504
527
|
"kind": "field",
|
|
505
528
|
"name": "handleAddGroup",
|
|
@@ -35,6 +35,8 @@ export declare class ExpressionBuilder extends GenesisElement implements Metadat
|
|
|
35
35
|
getRuleId(): string;
|
|
36
36
|
connectedCallback(): void;
|
|
37
37
|
disconnectedCallback(): void;
|
|
38
|
+
private isValidConfig;
|
|
39
|
+
private initBaseModel;
|
|
38
40
|
private handleAddGroup;
|
|
39
41
|
private _handleAddGroup;
|
|
40
42
|
private handleAddRule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-builder.d.ts","sourceRoot":"","sources":["../../../src/main/expression-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAa,MAAM,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAqB,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAkB7F,cAAc;AACd,qBAKa,iBAAkB,SAAQ,cAAe,YAAW,gBAAgB;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,GAAG,IAAI,CAAQ;IAE5C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAK;IAEvB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB,CAAS;IAElC,gBAAgB;IAChB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"expression-builder.d.ts","sourceRoot":"","sources":["../../../src/main/expression-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAa,MAAM,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAqB,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAkB7F,cAAc;AACd,qBAKa,iBAAkB,SAAQ,cAAe,YAAW,gBAAgB;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,GAAG,IAAI,CAAQ;IAE5C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAK;IAEvB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB,CAAS;IAElC,gBAAgB;IAChB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAiB1C,gBAAgB;IAChB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU;IAM5C;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK;IAa1C,gBAAgB;IAChB,SAAS,IAAI,MAAM;IAInB,gBAAgB;IAChB,UAAU;IAKV,gBAAgB;IAChB,SAAS;IAOT,iBAAiB;IAsBjB,oBAAoB,IAAI,IAAI;IAU5B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,cAAc,CAAmC;IACzD,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,iBAAiB,CAAsC;IAC/D,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,qBAAqB,CAA0C;IACvE,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,oBAAoB,CAAyC;IACrE,OAAO,CAAC,qBAAqB;CAI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-builder.template.d.ts","sourceRoot":"","sources":["../../../src/main/expression-builder.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK9D,cAAc;AACd,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"expression-builder.template.d.ts","sourceRoot":"","sources":["../../../src/main/expression-builder.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK9D,cAAc;AACd,eAAO,MAAM,QAAQ,wEAapB,CAAC"}
|
|
@@ -32,6 +32,9 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
32
32
|
}
|
|
33
33
|
/** @internal */
|
|
34
34
|
configChanged(_, newConfig) {
|
|
35
|
+
if (!this.isValidConfig(newConfig)) {
|
|
36
|
+
throw new Error("Invalid config passed to ExpressionBuilder. Verify you've defined operators, fields, and combinators.");
|
|
37
|
+
}
|
|
35
38
|
if (newConfig.model) {
|
|
36
39
|
this.ruleCount = 0;
|
|
37
40
|
this.groupCount = 0;
|
|
@@ -39,6 +42,9 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
39
42
|
this.model = groupToModelGroup(newConfig.model, this);
|
|
40
43
|
this.userUpdatingModel = false;
|
|
41
44
|
}
|
|
45
|
+
else if (this.model === null) {
|
|
46
|
+
this.initBaseModel();
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
/** @internal */
|
|
44
50
|
modelChanged(_, newModel) {
|
|
@@ -80,24 +86,23 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
80
86
|
// Behaviour
|
|
81
87
|
connectedCallback() {
|
|
82
88
|
super.connectedCallback();
|
|
83
|
-
if (!this.config || !this.config.combinators || !this.config.operators || !this.config.fields) {
|
|
84
|
-
throw new Error("Invalid config passed to ExpressionBuilder. Verify you've defined operators, fields, and combinators.");
|
|
85
|
-
}
|
|
86
89
|
this.addEventListener(Events.AddGroup, this.handleAddGroup);
|
|
87
90
|
this.addEventListener(Events.DelGroup, this.handleDeleteGroup);
|
|
88
91
|
this.addEventListener(Events.AddRule, this.handleAddRule);
|
|
89
92
|
this.addEventListener(Events.DelRule, this.handleDeleteRule);
|
|
90
93
|
this.addEventListener(Events.UpdateGroup, this.handleUpdateGroupData);
|
|
91
94
|
this.addEventListener(Events.UpdateRule, this.handleUpdateRuleData);
|
|
95
|
+
// When using other frameworks such as React we cannot guarantee that it sets the property on the component
|
|
96
|
+
// by the time connectedCallback is called, so we need to allow for lazy setting of the config
|
|
97
|
+
if (!this.isValidConfig(this.config)) {
|
|
98
|
+
this.config = null;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// If the property contains a model then let that be used, via configChanged
|
|
92
102
|
if (this.config.model)
|
|
93
103
|
return;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
level: 1,
|
|
97
|
-
groupId: ROOT_GROUP,
|
|
98
|
-
config: this.config,
|
|
99
|
-
combinator: this.config.combinators[0],
|
|
100
|
-
};
|
|
104
|
+
// Else, set a blank model
|
|
105
|
+
this.initBaseModel();
|
|
101
106
|
}
|
|
102
107
|
disconnectedCallback() {
|
|
103
108
|
super.disconnectedCallback();
|
|
@@ -108,6 +113,22 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
108
113
|
this.removeEventListener(Events.UpdateGroup, this.handleUpdateGroupData);
|
|
109
114
|
this.removeEventListener(Events.UpdateRule, this.handleUpdateRuleData);
|
|
110
115
|
}
|
|
116
|
+
isValidConfig(config) {
|
|
117
|
+
var _a, _b, _c;
|
|
118
|
+
return Boolean(config && ((_a = config.combinators) === null || _a === void 0 ? void 0 : _a.length) && ((_b = config.operators) === null || _b === void 0 ? void 0 : _b.length) && ((_c = config.fields) === null || _c === void 0 ? void 0 : _c.length));
|
|
119
|
+
}
|
|
120
|
+
initBaseModel() {
|
|
121
|
+
if (!this.isValidConfig(this.config)) {
|
|
122
|
+
throw new Error("Invalid config set on ExpressionBuilder. Verify you've defined operators, fields, and combinators.");
|
|
123
|
+
}
|
|
124
|
+
this.model = {
|
|
125
|
+
children: [],
|
|
126
|
+
level: 1,
|
|
127
|
+
groupId: ROOT_GROUP,
|
|
128
|
+
config: this.config,
|
|
129
|
+
combinator: this.config.combinators[0],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
111
132
|
_handleAddGroup(event) {
|
|
112
133
|
const { parentGroupId, newGroup: _newGroup } = event.detail;
|
|
113
134
|
const newGroup = {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { html } from '@genesislcap/web-core';
|
|
1
|
+
import { html, when } from '@genesislcap/web-core';
|
|
2
2
|
import { ExpressionGroup } from './expression-group/expression-group';
|
|
3
3
|
ExpressionGroup;
|
|
4
4
|
/** @alpha **/
|
|
5
5
|
export const template = html `
|
|
6
6
|
<div class="query-builder">
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
${when((x) => x.model !== null, html `
|
|
8
|
+
<expression-group
|
|
9
|
+
:model=${(x) => x.model}
|
|
10
|
+
:config=${(x) => x.config}
|
|
11
|
+
:styles=${(x) => x.styles}
|
|
12
|
+
></expression-group>
|
|
13
|
+
`)}
|
|
12
14
|
</div>
|
|
13
15
|
`;
|
|
@@ -145,6 +145,8 @@ export declare class ExpressionBuilder extends GenesisElement implements Metadat
|
|
|
145
145
|
getRuleId(): string;
|
|
146
146
|
connectedCallback(): void;
|
|
147
147
|
disconnectedCallback(): void;
|
|
148
|
+
private isValidConfig;
|
|
149
|
+
private initBaseModel;
|
|
148
150
|
private handleAddGroup;
|
|
149
151
|
private _handleAddGroup;
|
|
150
152
|
private handleAddRule;
|
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.260.0",
|
|
4
|
+
"version": "14.260.1-RPT-0.1",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/expression-builder.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"customElements": "dist/custom-elements.json",
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "037b17c8615a0c30d39df49782ffed1090303e85"
|
|
63
63
|
}
|