@redvars/peacock 3.11.0 → 3.12.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/cb-divider.js +7 -6
- package/dist/cb-divider.js.map +1 -1
- package/dist/cb-group-base-D9gv7SDY.js +114 -0
- package/dist/cb-group-base-D9gv7SDY.js.map +1 -0
- package/dist/cb-group-base-DsX_2aFl.js +325 -0
- package/dist/cb-group-base-DsX_2aFl.js.map +1 -0
- package/dist/cb-group.js +96 -0
- package/dist/cb-group.js.map +1 -0
- package/dist/cb-rule.js +212 -0
- package/dist/cb-rule.js.map +1 -0
- package/dist/condition-builder.js +90 -35
- package/dist/condition-builder.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +176 -96
- package/dist/custom-elements.json +1412 -225
- package/dist/field.js +2 -0
- package/dist/field.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/loader.js +6 -13
- package/dist/loader.js.map +1 -1
- package/dist/src/condition-builder/cb-divider.d.ts +3 -1
- package/dist/src/condition-builder/cb-drag.d.ts +10 -0
- package/dist/src/condition-builder/cb-group-base.d.ts +59 -0
- package/dist/src/condition-builder/cb-group.d.ts +34 -0
- package/dist/src/condition-builder/cb-rule.d.ts +32 -0
- package/dist/src/condition-builder/cb-types.d.ts +13 -0
- package/dist/src/condition-builder/condition-builder.d.ts +35 -14
- package/dist/src/condition-builder/index.d.ts +3 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/test/condition-builder.test.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +2 -2
- package/src/condition-builder/cb-divider.scss +4 -5
- package/src/condition-builder/cb-divider.ts +3 -1
- package/src/condition-builder/cb-drag.ts +35 -0
- package/src/condition-builder/cb-group-base.scss +97 -0
- package/src/condition-builder/cb-group-base.ts +335 -0
- package/src/condition-builder/cb-group.scss +21 -0
- package/src/condition-builder/cb-group.ts +72 -0
- package/src/condition-builder/cb-rule.scss +90 -0
- package/src/condition-builder/cb-rule.ts +129 -0
- package/src/condition-builder/cb-types.ts +16 -0
- package/src/condition-builder/condition-builder.scss +12 -9
- package/src/condition-builder/condition-builder.ts +77 -17
- package/src/condition-builder/index.ts +7 -3
- package/src/field/field.scss +3 -0
- package/src/index.ts +7 -3
- package/src/loader.ts +6 -13
- package/dist/cb-compound-expression.js +0 -133
- package/dist/cb-compound-expression.js.map +0 -1
- package/dist/cb-expression.js +0 -78
- package/dist/cb-expression.js.map +0 -1
- package/dist/cb-predicate.js +0 -141
- package/dist/cb-predicate.js.map +0 -1
- package/dist/src/condition-builder/cb-compound-expression.d.ts +0 -30
- package/dist/src/condition-builder/cb-expression.d.ts +0 -30
- package/dist/src/condition-builder/cb-predicate.d.ts +0 -29
- package/src/condition-builder/cb-compound-expression.scss +0 -41
- package/src/condition-builder/cb-compound-expression.ts +0 -79
- package/src/condition-builder/cb-expression.scss +0 -13
- package/src/condition-builder/cb-expression.ts +0 -48
- package/src/condition-builder/cb-predicate.scss +0 -35
- package/src/condition-builder/cb-predicate.ts +0 -101
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cb-expression.js","sources":["../../src/condition-builder/cb-expression.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './cb-expression.scss';\n\n/**\n * @label CB Expression\n * @tag wc-cb-expression\n * @rawTag cb-expression\n * @summary An expression row within a condition builder, containing an operator select and a slot for value inputs.\n * @tags condition-builder\n *\n * @example\n * ```html\n * <wc-cb-expression>\n * <wc-input placeholder=\"Enter value\"></wc-input>\n * </wc-cb-expression>\n * ```\n */\n@IndividualComponent\nexport class CbExpression extends LitElement {\n static styles = [styles];\n\n /**\n * The list of operator options to display in the operator select.\n * Each item should have at least `label` and `value` properties.\n */\n @property({ type: Array })\n operators: { label: string; value: string; icon?: string }[] = [];\n\n /** The currently selected operator value. */\n @property({ type: String, attribute: 'operator-value' })\n operatorValue = '';\n\n render() {\n return html`\n <div class=\"expression\">\n <wc-select\n inline\n .value=${this.operatorValue}\n placeholder=\"Select Operator\"\n .options=${this.operators}\n ></wc-select>\n <slot></slot>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;;;;;;;;AAaG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQA,GAAU,CAAA;AAArC,IAAA,WAAA,GAAA;;AAGL;;;AAGG;QAEH,IAAA,CAAA,SAAS,GAAsD,EAAE;;QAIjE,IAAA,CAAA,aAAa,GAAG,EAAE;IAepB;IAbE,MAAM,GAAA;AACJ,QAAA,OAAOC,CAAI,CAAA;;;;AAII,iBAAA,EAAA,IAAI,CAAC,aAAa;;AAEhB,mBAAA,EAAA,IAAI,CAAC,SAAS;;;;KAI9B;IACH;;AAzBO,YAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAOxB,UAAA,CAAA;AADC,IAAAC,CAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;AACyC,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAIlE,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE;AACpC,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,eAAA,EAAA,MAAA,CAAA;AAZR,YAAY,GAAA,UAAA,CAAA;IADxB;AACY,CAAA,EAAA,YAAY,CA2BxB;;;;"}
|
package/dist/cb-predicate.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './IndividualComponent-Bdwyrvd6.js';
|
|
2
|
-
import { n } from './property-B49QQ8pS.js';
|
|
3
|
-
import { e } from './class-map-DG7CA1et.js';
|
|
4
|
-
import './directive-ZPhl09Yt.js';
|
|
5
|
-
|
|
6
|
-
var css_248z = i`* {
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
-webkit-tap-highlight-color: transparent;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.screen-reader-only {
|
|
12
|
-
display: none !important;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
[hidden] {
|
|
16
|
-
display: none !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:host {
|
|
20
|
-
display: block;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.predicate:not(.vertical) .predicate-body {
|
|
24
|
-
padding-top: var(--spacing-200);
|
|
25
|
-
}
|
|
26
|
-
.predicate:not(.vertical) .predicate-condition-operator {
|
|
27
|
-
padding: var(--spacing-200) var(--spacing-400) 0 var(--spacing-400);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.predicate.vertical {
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: stretch;
|
|
33
|
-
}
|
|
34
|
-
.predicate.vertical .predicate-condition-operator {
|
|
35
|
-
padding: var(--spacing-400) 0 var(--spacing-200) 0;
|
|
36
|
-
padding-inline-end: var(--spacing-200);
|
|
37
|
-
}
|
|
38
|
-
.predicate.vertical .predicate-body {
|
|
39
|
-
flex: 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.slot-end {
|
|
43
|
-
display: block;
|
|
44
|
-
}`;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @label CB Predicate
|
|
48
|
-
* @tag wc-cb-predicate
|
|
49
|
-
* @rawTag cb-predicate
|
|
50
|
-
* @summary A predicate container in a condition builder that can display conditions in horizontal or vertical layout with an optional logical operator divider.
|
|
51
|
-
* @tags condition-builder
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```html
|
|
55
|
-
* <wc-cb-predicate condition-operator="and" vertical>
|
|
56
|
-
* <wc-cb-compound-expression field-label="Age">
|
|
57
|
-
* <wc-cb-expression></wc-cb-expression>
|
|
58
|
-
* </wc-cb-compound-expression>
|
|
59
|
-
* </wc-cb-predicate>
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
let CbPredicate = class CbPredicate extends i$1 {
|
|
63
|
-
constructor() {
|
|
64
|
-
super(...arguments);
|
|
65
|
-
/** Whether to render the predicate in vertical layout. */
|
|
66
|
-
this.vertical = false;
|
|
67
|
-
}
|
|
68
|
-
updated() {
|
|
69
|
-
if (this.vertical) {
|
|
70
|
-
this.__adjustSlotEndPadding();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
__adjustSlotEndPadding() {
|
|
74
|
-
const slotEnd = this.renderRoot.querySelector('.slot-end');
|
|
75
|
-
const operatorElm = this.renderRoot.querySelector('.predicate-condition-operator');
|
|
76
|
-
if (slotEnd && operatorElm) {
|
|
77
|
-
slotEnd.style.paddingInlineStart =
|
|
78
|
-
operatorElm.getBoundingClientRect().width + 'px';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
__renderHorizontalOperator() {
|
|
82
|
-
if (!this.conditionOperator)
|
|
83
|
-
return A;
|
|
84
|
-
return b `
|
|
85
|
-
<wc-cb-divider vertical class="predicate-condition-operator">
|
|
86
|
-
<wc-tag color="yellow" size="sm">${this.conditionOperator}</wc-tag>
|
|
87
|
-
</wc-cb-divider>
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
__renderVerticalOperator() {
|
|
91
|
-
if (!this.conditionOperator)
|
|
92
|
-
return A;
|
|
93
|
-
return b `
|
|
94
|
-
<div class="predicate-condition-operator">
|
|
95
|
-
<wc-cb-divider connect-start connect-end>
|
|
96
|
-
<wc-tag color="green" size="sm">${this.conditionOperator}</wc-tag>
|
|
97
|
-
</wc-cb-divider>
|
|
98
|
-
</div>
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
render() {
|
|
102
|
-
const classes = {
|
|
103
|
-
predicate: true,
|
|
104
|
-
vertical: this.vertical,
|
|
105
|
-
};
|
|
106
|
-
if (this.vertical) {
|
|
107
|
-
return b `
|
|
108
|
-
<div class=${e(classes)}>
|
|
109
|
-
${this.__renderVerticalOperator()}
|
|
110
|
-
<div class="predicate-body">
|
|
111
|
-
<slot></slot>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
<div class="slot-end">
|
|
115
|
-
<slot name="end"></slot>
|
|
116
|
-
</div>
|
|
117
|
-
`;
|
|
118
|
-
}
|
|
119
|
-
return b `
|
|
120
|
-
<div class=${e(classes)}>
|
|
121
|
-
<div class="predicate-body">
|
|
122
|
-
<slot></slot>
|
|
123
|
-
</div>
|
|
124
|
-
${this.__renderHorizontalOperator()}
|
|
125
|
-
</div>
|
|
126
|
-
`;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
CbPredicate.styles = [css_248z];
|
|
130
|
-
__decorate([
|
|
131
|
-
n({ type: String, attribute: 'condition-operator', reflect: true })
|
|
132
|
-
], CbPredicate.prototype, "conditionOperator", void 0);
|
|
133
|
-
__decorate([
|
|
134
|
-
n({ type: Boolean, reflect: true })
|
|
135
|
-
], CbPredicate.prototype, "vertical", void 0);
|
|
136
|
-
CbPredicate = __decorate([
|
|
137
|
-
IndividualComponent
|
|
138
|
-
], CbPredicate);
|
|
139
|
-
|
|
140
|
-
export { CbPredicate };
|
|
141
|
-
//# sourceMappingURL=cb-predicate.js.map
|
package/dist/cb-predicate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cb-predicate.js","sources":["../../src/condition-builder/cb-predicate.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './cb-predicate.scss';\n\n/**\n * @label CB Predicate\n * @tag wc-cb-predicate\n * @rawTag cb-predicate\n * @summary A predicate container in a condition builder that can display conditions in horizontal or vertical layout with an optional logical operator divider.\n * @tags condition-builder\n *\n * @example\n * ```html\n * <wc-cb-predicate condition-operator=\"and\" vertical>\n * <wc-cb-compound-expression field-label=\"Age\">\n * <wc-cb-expression></wc-cb-expression>\n * </wc-cb-compound-expression>\n * </wc-cb-predicate>\n * ```\n */\n@IndividualComponent\nexport class CbPredicate extends LitElement {\n static styles = [styles];\n\n /** The logical operator shown between predicates ('and' or 'or'). */\n @property({ type: String, attribute: 'condition-operator', reflect: true })\n conditionOperator?: 'and' | 'or';\n\n /** Whether to render the predicate in vertical layout. */\n @property({ type: Boolean, reflect: true })\n vertical = false;\n\n override updated() {\n if (this.vertical) {\n this.__adjustSlotEndPadding();\n }\n }\n\n private __adjustSlotEndPadding() {\n const slotEnd = this.renderRoot.querySelector<HTMLElement>('.slot-end');\n const operatorElm = this.renderRoot.querySelector<HTMLElement>(\n '.predicate-condition-operator',\n );\n if (slotEnd && operatorElm) {\n slotEnd.style.paddingInlineStart =\n operatorElm.getBoundingClientRect().width + 'px';\n }\n }\n\n private __renderHorizontalOperator() {\n if (!this.conditionOperator) return nothing;\n return html`\n <wc-cb-divider vertical class=\"predicate-condition-operator\">\n <wc-tag color=\"yellow\" size=\"sm\">${this.conditionOperator}</wc-tag>\n </wc-cb-divider>\n `;\n }\n\n private __renderVerticalOperator() {\n if (!this.conditionOperator) return nothing;\n return html`\n <div class=\"predicate-condition-operator\">\n <wc-cb-divider connect-start connect-end>\n <wc-tag color=\"green\" size=\"sm\">${this.conditionOperator}</wc-tag>\n </wc-cb-divider>\n </div>\n `;\n }\n\n render() {\n const classes = {\n predicate: true,\n vertical: this.vertical,\n };\n\n if (this.vertical) {\n return html`\n <div class=${classMap(classes)}>\n ${this.__renderVerticalOperator()}\n <div class=\"predicate-body\">\n <slot></slot>\n </div>\n </div>\n <div class=\"slot-end\">\n <slot name=\"end\"></slot>\n </div>\n `;\n }\n\n return html`\n <div class=${classMap(classes)}>\n <div class=\"predicate-body\">\n <slot></slot>\n </div>\n ${this.__renderHorizontalOperator()}\n </div>\n `;\n }\n}\n"],"names":["LitElement","nothing","html","classMap","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;AAeG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQA,GAAU,CAAA;AAApC,IAAA,WAAA,GAAA;;;QASL,IAAA,CAAA,QAAQ,GAAG,KAAK;IAoElB;IAlEW,OAAO,GAAA;AACd,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,sBAAsB,EAAE;QAC/B;IACF;IAEQ,sBAAsB,GAAA;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAc,WAAW,CAAC;QACvE,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAC/C,+BAA+B,CAChC;AACD,QAAA,IAAI,OAAO,IAAI,WAAW,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,kBAAkB;AAC9B,gBAAA,WAAW,CAAC,qBAAqB,EAAE,CAAC,KAAK,GAAG,IAAI;QACpD;IACF;IAEQ,0BAA0B,GAAA;QAChC,IAAI,CAAC,IAAI,CAAC,iBAAiB;AAAE,YAAA,OAAOC,CAAO;AAC3C,QAAA,OAAOC,CAAI,CAAA;;AAE4B,yCAAA,EAAA,IAAI,CAAC,iBAAiB,CAAA;;KAE5D;IACH;IAEQ,wBAAwB,GAAA;QAC9B,IAAI,CAAC,IAAI,CAAC,iBAAiB;AAAE,YAAA,OAAOD,CAAO;AAC3C,QAAA,OAAOC,CAAI,CAAA;;;AAG6B,0CAAA,EAAA,IAAI,CAAC,iBAAiB,CAAA;;;KAG7D;IACH;IAEA,MAAM,GAAA;AACJ,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB;AAED,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAA,OAAOA,CAAI,CAAA;qBACIC,CAAQ,CAAC,OAAO,CAAC,CAAA;YAC1B,IAAI,CAAC,wBAAwB,EAAE;;;;;;;;OAQpC;QACH;AAEA,QAAA,OAAOD,CAAI,CAAA;mBACIC,CAAQ,CAAC,OAAO,CAAC,CAAA;;;;UAI1B,IAAI,CAAC,0BAA0B,EAAE;;KAEtC;IACH;;AA3EO,WAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAIxB,UAAA,CAAA;AADC,IAAAC,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,IAAI,EAAE;AACzC,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,MAAA,CAAA;AAIjC,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AATN,WAAW,GAAA,UAAA,CAAA;IADvB;AACY,CAAA,EAAA,WAAW,CA6EvB;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* @label CB Compound Expression
|
|
4
|
-
* @tag wc-cb-compound-expression
|
|
5
|
-
* @rawTag cb-compound-expression
|
|
6
|
-
* @summary A compound expression group in a condition builder that displays a field label, an optional condition operator divider, and slots for child expressions.
|
|
7
|
-
* @tags condition-builder
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```html
|
|
11
|
-
* <wc-cb-compound-expression field-label="Age" condition-operator="or">
|
|
12
|
-
* <wc-cb-expression>
|
|
13
|
-
* <wc-input placeholder="Enter value"></wc-input>
|
|
14
|
-
* </wc-cb-expression>
|
|
15
|
-
* </wc-cb-compound-expression>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class CbCompoundExpression extends LitElement {
|
|
19
|
-
static styles: import("lit").CSSResultGroup[];
|
|
20
|
-
/** The logical operator joining conditions in this group ('and' or 'or'). */
|
|
21
|
-
conditionOperator?: 'and' | 'or';
|
|
22
|
-
/** The field name for the compound expression. */
|
|
23
|
-
fieldName: string;
|
|
24
|
-
/** The display label for the field. */
|
|
25
|
-
fieldLabel: string;
|
|
26
|
-
updated(): void;
|
|
27
|
-
private __adjustSlotEndPadding;
|
|
28
|
-
private __renderOperatorDivider;
|
|
29
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
30
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* @label CB Expression
|
|
4
|
-
* @tag wc-cb-expression
|
|
5
|
-
* @rawTag cb-expression
|
|
6
|
-
* @summary An expression row within a condition builder, containing an operator select and a slot for value inputs.
|
|
7
|
-
* @tags condition-builder
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```html
|
|
11
|
-
* <wc-cb-expression>
|
|
12
|
-
* <wc-input placeholder="Enter value"></wc-input>
|
|
13
|
-
* </wc-cb-expression>
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare class CbExpression extends LitElement {
|
|
17
|
-
static styles: import("lit").CSSResultGroup[];
|
|
18
|
-
/**
|
|
19
|
-
* The list of operator options to display in the operator select.
|
|
20
|
-
* Each item should have at least `label` and `value` properties.
|
|
21
|
-
*/
|
|
22
|
-
operators: {
|
|
23
|
-
label: string;
|
|
24
|
-
value: string;
|
|
25
|
-
icon?: string;
|
|
26
|
-
}[];
|
|
27
|
-
/** The currently selected operator value. */
|
|
28
|
-
operatorValue: string;
|
|
29
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* @label CB Predicate
|
|
4
|
-
* @tag wc-cb-predicate
|
|
5
|
-
* @rawTag cb-predicate
|
|
6
|
-
* @summary A predicate container in a condition builder that can display conditions in horizontal or vertical layout with an optional logical operator divider.
|
|
7
|
-
* @tags condition-builder
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```html
|
|
11
|
-
* <wc-cb-predicate condition-operator="and" vertical>
|
|
12
|
-
* <wc-cb-compound-expression field-label="Age">
|
|
13
|
-
* <wc-cb-expression></wc-cb-expression>
|
|
14
|
-
* </wc-cb-compound-expression>
|
|
15
|
-
* </wc-cb-predicate>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class CbPredicate extends LitElement {
|
|
19
|
-
static styles: import("lit").CSSResultGroup[];
|
|
20
|
-
/** The logical operator shown between predicates ('and' or 'or'). */
|
|
21
|
-
conditionOperator?: 'and' | 'or';
|
|
22
|
-
/** Whether to render the predicate in vertical layout. */
|
|
23
|
-
vertical: boolean;
|
|
24
|
-
updated(): void;
|
|
25
|
-
private __adjustSlotEndPadding;
|
|
26
|
-
private __renderHorizontalOperator;
|
|
27
|
-
private __renderVerticalOperator;
|
|
28
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
29
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
@use '../../scss/mixin';
|
|
2
|
-
|
|
3
|
-
@include mixin.base-styles;
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
display: block;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.compound-expression {
|
|
10
|
-
display: flex;
|
|
11
|
-
padding-top: var(--spacing-200);
|
|
12
|
-
|
|
13
|
-
.field-name-container {
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
padding-top: var(--spacing-100);
|
|
17
|
-
padding-right: var(--spacing-200);
|
|
18
|
-
|
|
19
|
-
.field-label {
|
|
20
|
-
@include mixin.get-typography-not-important(label-medium);
|
|
21
|
-
color: var(--color-on-surface-variant);
|
|
22
|
-
text-align: center;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.field-compound-type {
|
|
26
|
-
flex: 1;
|
|
27
|
-
padding-bottom: var(--spacing-250);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.conditions {
|
|
32
|
-
flex: 1;
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
gap: 1rem;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.slot-end {
|
|
40
|
-
display: block;
|
|
41
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { html, LitElement, nothing } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import IndividualComponent from '@/IndividualComponent.js';
|
|
4
|
-
import styles from './cb-compound-expression.scss';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @label CB Compound Expression
|
|
8
|
-
* @tag wc-cb-compound-expression
|
|
9
|
-
* @rawTag cb-compound-expression
|
|
10
|
-
* @summary A compound expression group in a condition builder that displays a field label, an optional condition operator divider, and slots for child expressions.
|
|
11
|
-
* @tags condition-builder
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```html
|
|
15
|
-
* <wc-cb-compound-expression field-label="Age" condition-operator="or">
|
|
16
|
-
* <wc-cb-expression>
|
|
17
|
-
* <wc-input placeholder="Enter value"></wc-input>
|
|
18
|
-
* </wc-cb-expression>
|
|
19
|
-
* </wc-cb-compound-expression>
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
@IndividualComponent
|
|
23
|
-
export class CbCompoundExpression extends LitElement {
|
|
24
|
-
static styles = [styles];
|
|
25
|
-
|
|
26
|
-
/** The logical operator joining conditions in this group ('and' or 'or'). */
|
|
27
|
-
@property({ type: String, attribute: 'condition-operator', reflect: true })
|
|
28
|
-
conditionOperator?: 'and' | 'or';
|
|
29
|
-
|
|
30
|
-
/** The field name for the compound expression. */
|
|
31
|
-
@property({ type: String, attribute: 'field-name' })
|
|
32
|
-
fieldName = '';
|
|
33
|
-
|
|
34
|
-
/** The display label for the field. */
|
|
35
|
-
@property({ type: String, attribute: 'field-label' })
|
|
36
|
-
fieldLabel = '';
|
|
37
|
-
|
|
38
|
-
override updated() {
|
|
39
|
-
this.__adjustSlotEndPadding();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private __adjustSlotEndPadding() {
|
|
43
|
-
const slotEnd = this.renderRoot.querySelector<HTMLElement>('.slot-end');
|
|
44
|
-
const fieldNameContainer =
|
|
45
|
-
this.renderRoot.querySelector<HTMLElement>('.field-name-container');
|
|
46
|
-
if (slotEnd && fieldNameContainer) {
|
|
47
|
-
slotEnd.style.paddingInlineStart =
|
|
48
|
-
fieldNameContainer.getBoundingClientRect().width + 'px';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private __renderOperatorDivider() {
|
|
53
|
-
if (!this.conditionOperator) return nothing;
|
|
54
|
-
return html`
|
|
55
|
-
<wc-cb-divider connect-end>
|
|
56
|
-
<wc-tag color="yellow" size="sm">${this.conditionOperator}</wc-tag>
|
|
57
|
-
</wc-cb-divider>
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
render() {
|
|
62
|
-
return html`
|
|
63
|
-
<div class="compound-expression" field-name=${this.fieldName}>
|
|
64
|
-
<div class="field-name-container">
|
|
65
|
-
<span class="field-label">${this.fieldLabel}</span>
|
|
66
|
-
<div class="field-compound-type">
|
|
67
|
-
${this.__renderOperatorDivider()}
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
<div class="conditions">
|
|
71
|
-
<slot></slot>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
<div class="slot-end">
|
|
75
|
-
<slot name="end"></slot>
|
|
76
|
-
</div>
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { html, LitElement } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import IndividualComponent from '@/IndividualComponent.js';
|
|
4
|
-
import styles from './cb-expression.scss';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @label CB Expression
|
|
8
|
-
* @tag wc-cb-expression
|
|
9
|
-
* @rawTag cb-expression
|
|
10
|
-
* @summary An expression row within a condition builder, containing an operator select and a slot for value inputs.
|
|
11
|
-
* @tags condition-builder
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```html
|
|
15
|
-
* <wc-cb-expression>
|
|
16
|
-
* <wc-input placeholder="Enter value"></wc-input>
|
|
17
|
-
* </wc-cb-expression>
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
@IndividualComponent
|
|
21
|
-
export class CbExpression extends LitElement {
|
|
22
|
-
static styles = [styles];
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The list of operator options to display in the operator select.
|
|
26
|
-
* Each item should have at least `label` and `value` properties.
|
|
27
|
-
*/
|
|
28
|
-
@property({ type: Array })
|
|
29
|
-
operators: { label: string; value: string; icon?: string }[] = [];
|
|
30
|
-
|
|
31
|
-
/** The currently selected operator value. */
|
|
32
|
-
@property({ type: String, attribute: 'operator-value' })
|
|
33
|
-
operatorValue = '';
|
|
34
|
-
|
|
35
|
-
render() {
|
|
36
|
-
return html`
|
|
37
|
-
<div class="expression">
|
|
38
|
-
<wc-select
|
|
39
|
-
inline
|
|
40
|
-
.value=${this.operatorValue}
|
|
41
|
-
placeholder="Select Operator"
|
|
42
|
-
.options=${this.operators}
|
|
43
|
-
></wc-select>
|
|
44
|
-
<slot></slot>
|
|
45
|
-
</div>
|
|
46
|
-
`;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
@use '../../scss/mixin';
|
|
2
|
-
|
|
3
|
-
@include mixin.base-styles;
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
display: block;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.predicate:not(.vertical) {
|
|
10
|
-
.predicate-body {
|
|
11
|
-
padding-top: var(--spacing-200);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.predicate-condition-operator {
|
|
15
|
-
padding: var(--spacing-200) var(--spacing-400) 0 var(--spacing-400);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.predicate.vertical {
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: stretch;
|
|
22
|
-
|
|
23
|
-
.predicate-condition-operator {
|
|
24
|
-
padding: var(--spacing-400) 0 var(--spacing-200) 0;
|
|
25
|
-
padding-inline-end: var(--spacing-200);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.predicate-body {
|
|
29
|
-
flex: 1;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.slot-end {
|
|
34
|
-
display: block;
|
|
35
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { html, LitElement, nothing } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
-
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
-
import styles from './cb-predicate.scss';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @label CB Predicate
|
|
9
|
-
* @tag wc-cb-predicate
|
|
10
|
-
* @rawTag cb-predicate
|
|
11
|
-
* @summary A predicate container in a condition builder that can display conditions in horizontal or vertical layout with an optional logical operator divider.
|
|
12
|
-
* @tags condition-builder
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```html
|
|
16
|
-
* <wc-cb-predicate condition-operator="and" vertical>
|
|
17
|
-
* <wc-cb-compound-expression field-label="Age">
|
|
18
|
-
* <wc-cb-expression></wc-cb-expression>
|
|
19
|
-
* </wc-cb-compound-expression>
|
|
20
|
-
* </wc-cb-predicate>
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
@IndividualComponent
|
|
24
|
-
export class CbPredicate extends LitElement {
|
|
25
|
-
static styles = [styles];
|
|
26
|
-
|
|
27
|
-
/** The logical operator shown between predicates ('and' or 'or'). */
|
|
28
|
-
@property({ type: String, attribute: 'condition-operator', reflect: true })
|
|
29
|
-
conditionOperator?: 'and' | 'or';
|
|
30
|
-
|
|
31
|
-
/** Whether to render the predicate in vertical layout. */
|
|
32
|
-
@property({ type: Boolean, reflect: true })
|
|
33
|
-
vertical = false;
|
|
34
|
-
|
|
35
|
-
override updated() {
|
|
36
|
-
if (this.vertical) {
|
|
37
|
-
this.__adjustSlotEndPadding();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private __adjustSlotEndPadding() {
|
|
42
|
-
const slotEnd = this.renderRoot.querySelector<HTMLElement>('.slot-end');
|
|
43
|
-
const operatorElm = this.renderRoot.querySelector<HTMLElement>(
|
|
44
|
-
'.predicate-condition-operator',
|
|
45
|
-
);
|
|
46
|
-
if (slotEnd && operatorElm) {
|
|
47
|
-
slotEnd.style.paddingInlineStart =
|
|
48
|
-
operatorElm.getBoundingClientRect().width + 'px';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private __renderHorizontalOperator() {
|
|
53
|
-
if (!this.conditionOperator) return nothing;
|
|
54
|
-
return html`
|
|
55
|
-
<wc-cb-divider vertical class="predicate-condition-operator">
|
|
56
|
-
<wc-tag color="yellow" size="sm">${this.conditionOperator}</wc-tag>
|
|
57
|
-
</wc-cb-divider>
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private __renderVerticalOperator() {
|
|
62
|
-
if (!this.conditionOperator) return nothing;
|
|
63
|
-
return html`
|
|
64
|
-
<div class="predicate-condition-operator">
|
|
65
|
-
<wc-cb-divider connect-start connect-end>
|
|
66
|
-
<wc-tag color="green" size="sm">${this.conditionOperator}</wc-tag>
|
|
67
|
-
</wc-cb-divider>
|
|
68
|
-
</div>
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
render() {
|
|
73
|
-
const classes = {
|
|
74
|
-
predicate: true,
|
|
75
|
-
vertical: this.vertical,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
if (this.vertical) {
|
|
79
|
-
return html`
|
|
80
|
-
<div class=${classMap(classes)}>
|
|
81
|
-
${this.__renderVerticalOperator()}
|
|
82
|
-
<div class="predicate-body">
|
|
83
|
-
<slot></slot>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
<div class="slot-end">
|
|
87
|
-
<slot name="end"></slot>
|
|
88
|
-
</div>
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return html`
|
|
93
|
-
<div class=${classMap(classes)}>
|
|
94
|
-
<div class="predicate-body">
|
|
95
|
-
<slot></slot>
|
|
96
|
-
</div>
|
|
97
|
-
${this.__renderHorizontalOperator()}
|
|
98
|
-
</div>
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
}
|