@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
package/dist/cb-rule.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { i, _ as __decorate, I as IndividualComponent, a as i$1, b } from './IndividualComponent-Bdwyrvd6.js';
|
|
2
|
+
import { e } from './query-CHb9Ft_d.js';
|
|
3
|
+
import { g as getActiveRule, c as claimDropTarget, C as CbGroupBase, s as setActiveRule } from './cb-group-base-DsX_2aFl.js';
|
|
4
|
+
import './base-Cl6v8-BZ.js';
|
|
5
|
+
import './property-B49QQ8pS.js';
|
|
6
|
+
import './state-DkTK9EGF.js';
|
|
7
|
+
import './class-map-DG7CA1et.js';
|
|
8
|
+
import './directive-ZPhl09Yt.js';
|
|
9
|
+
import './style-map-BQD5Et1D.js';
|
|
10
|
+
|
|
11
|
+
var css_248z = i`* {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
-webkit-tap-highlight-color: transparent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.screen-reader-only {
|
|
17
|
+
display: none !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[hidden] {
|
|
21
|
+
display: none !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
container-type: inline-size;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host([dragging]) {
|
|
30
|
+
opacity: 0.4;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rule {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
border: 1px solid var(--color-outline-variant);
|
|
37
|
+
border-radius: var(--shape-corner-medium);
|
|
38
|
+
background: var(--color-surface);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.handle {
|
|
42
|
+
position: relative;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
flex: none;
|
|
47
|
+
width: 2rem;
|
|
48
|
+
border-inline-end: 1px solid var(--color-outline-variant);
|
|
49
|
+
color: var(--color-on-surface-variant);
|
|
50
|
+
cursor: grab;
|
|
51
|
+
outline: none;
|
|
52
|
+
}
|
|
53
|
+
.handle:active {
|
|
54
|
+
cursor: grabbing;
|
|
55
|
+
}
|
|
56
|
+
.handle wc-icon {
|
|
57
|
+
--icon-size: 1.25rem;
|
|
58
|
+
}
|
|
59
|
+
.handle wc-focus-ring {
|
|
60
|
+
--focus-ring-container-shape-start-start: var(--shape-corner-medium);
|
|
61
|
+
--focus-ring-container-shape-end-start: var(--shape-corner-medium);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.content {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
align-items: center;
|
|
68
|
+
flex: 1;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
gap: var(--spacing-100) var(--spacing-150);
|
|
71
|
+
padding: var(--spacing-100) var(--spacing-150);
|
|
72
|
+
--field-height: var(--cb-rule-field-height, 2.5rem);
|
|
73
|
+
}
|
|
74
|
+
.content ::slotted(*) {
|
|
75
|
+
flex: 1 1 8rem;
|
|
76
|
+
min-width: 0;
|
|
77
|
+
}
|
|
78
|
+
.content ::slotted(:last-child) {
|
|
79
|
+
flex-grow: 1.5;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.remove {
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
flex: none;
|
|
86
|
+
padding-inline: var(--spacing-050);
|
|
87
|
+
border-inline-start: 1px solid var(--color-outline-variant);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@container (max-width: 22rem) {
|
|
91
|
+
.handle {
|
|
92
|
+
width: 1.5rem;
|
|
93
|
+
}
|
|
94
|
+
.content {
|
|
95
|
+
padding: var(--spacing-100);
|
|
96
|
+
}
|
|
97
|
+
.remove {
|
|
98
|
+
padding-inline: 0;
|
|
99
|
+
}
|
|
100
|
+
}`;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @label CB Rule
|
|
104
|
+
* @tag wc-cb-rule
|
|
105
|
+
* @rawTag cb-rule
|
|
106
|
+
* @summary One condition row in a condition builder: a drag handle, the slotted field, operator and value controls, and a remove button.
|
|
107
|
+
* @overview
|
|
108
|
+
* <p>Drag the handle to reorder the rule, or to move it into another group. With the handle focused, ArrowUp and ArrowDown move the rule within its group.</p>
|
|
109
|
+
* @tags condition-builder
|
|
110
|
+
*
|
|
111
|
+
* @cssprop --cb-rule-field-height - Height of the slotted fields (wc-select, wc-input…). Defaults to `2.5rem`.
|
|
112
|
+
*
|
|
113
|
+
* @fires {CustomEvent<{rule: CbRule, group: HTMLElement | null}>} rule-remove - Dispatched when the remove button is clicked. Cancelable: unless prevented, the rule removes itself.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```html
|
|
117
|
+
* <wc-cb-rule>
|
|
118
|
+
* <wc-select placeholder="Field"></wc-select>
|
|
119
|
+
* <wc-select placeholder="Operator"></wc-select>
|
|
120
|
+
* <wc-input placeholder="Value"></wc-input>
|
|
121
|
+
* </wc-cb-rule>
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
let CbRule = class CbRule extends i$1 {
|
|
125
|
+
// ── Private methods ───────────────────────────────────────────────────────
|
|
126
|
+
_onDragStart(event) {
|
|
127
|
+
const { dataTransfer } = event;
|
|
128
|
+
if (dataTransfer) {
|
|
129
|
+
dataTransfer.effectAllowed = 'move';
|
|
130
|
+
// Firefox only starts a drag that carries data.
|
|
131
|
+
dataTransfer.setData('text/plain', '');
|
|
132
|
+
const rect = this.getBoundingClientRect();
|
|
133
|
+
dataTransfer.setDragImage(this, event.clientX - rect.left, event.clientY - rect.top);
|
|
134
|
+
}
|
|
135
|
+
setActiveRule(this);
|
|
136
|
+
// Dim the row after the browser has captured the drag image.
|
|
137
|
+
requestAnimationFrame(() => this.toggleAttribute('dragging', getActiveRule() === this));
|
|
138
|
+
}
|
|
139
|
+
_onDragEnd() {
|
|
140
|
+
setActiveRule(null);
|
|
141
|
+
claimDropTarget(null);
|
|
142
|
+
this.toggleAttribute('dragging', false);
|
|
143
|
+
}
|
|
144
|
+
_onHandleKeyDown(event) {
|
|
145
|
+
const offsets = { ArrowUp: -1, ArrowDown: 1 };
|
|
146
|
+
const offset = offsets[event.key];
|
|
147
|
+
const group = this.parentElement;
|
|
148
|
+
if (!offset || !(group instanceof CbGroupBase))
|
|
149
|
+
return;
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
const index = group.items.indexOf(this) + offset;
|
|
152
|
+
if (index >= 0 && group.moveRule(this, index)) {
|
|
153
|
+
this._handleEl?.focus();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_onRemoveClick() {
|
|
157
|
+
const event = new CustomEvent('rule-remove', {
|
|
158
|
+
detail: { rule: this, group: this.parentElement },
|
|
159
|
+
bubbles: true,
|
|
160
|
+
composed: true,
|
|
161
|
+
cancelable: true,
|
|
162
|
+
});
|
|
163
|
+
if (this.dispatchEvent(event))
|
|
164
|
+
this.remove();
|
|
165
|
+
}
|
|
166
|
+
// ── Render ────────────────────────────────────────────────────────────────
|
|
167
|
+
render() {
|
|
168
|
+
return b `
|
|
169
|
+
<div class="rule">
|
|
170
|
+
<div
|
|
171
|
+
class="handle"
|
|
172
|
+
role="button"
|
|
173
|
+
tabindex="0"
|
|
174
|
+
draggable="true"
|
|
175
|
+
aria-label="Reorder condition"
|
|
176
|
+
title="Drag to reorder"
|
|
177
|
+
@dragstart=${this._onDragStart}
|
|
178
|
+
@dragend=${this._onDragEnd}
|
|
179
|
+
@keydown=${this._onHandleKeyDown}
|
|
180
|
+
>
|
|
181
|
+
<wc-focus-ring></wc-focus-ring>
|
|
182
|
+
<wc-icon name="drag_indicator" aria-hidden="true"></wc-icon>
|
|
183
|
+
</div>
|
|
184
|
+
<div class="content">
|
|
185
|
+
<slot></slot>
|
|
186
|
+
</div>
|
|
187
|
+
<div class="remove">
|
|
188
|
+
<wc-icon-button
|
|
189
|
+
variant="text"
|
|
190
|
+
color="on-surface"
|
|
191
|
+
size="sm"
|
|
192
|
+
aria-label="Remove condition"
|
|
193
|
+
@click=${this._onRemoveClick}
|
|
194
|
+
>
|
|
195
|
+
<wc-icon name="delete"></wc-icon>
|
|
196
|
+
</wc-icon-button>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
// ── Static ────────────────────────────────────────────────────────────────
|
|
203
|
+
CbRule.styles = [css_248z];
|
|
204
|
+
__decorate([
|
|
205
|
+
e('.handle')
|
|
206
|
+
], CbRule.prototype, "_handleEl", void 0);
|
|
207
|
+
CbRule = __decorate([
|
|
208
|
+
IndividualComponent
|
|
209
|
+
], CbRule);
|
|
210
|
+
|
|
211
|
+
export { CbRule };
|
|
212
|
+
//# sourceMappingURL=cb-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cb-rule.js","sources":["../../src/condition-builder/cb-rule.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { query } from 'lit/decorators.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { claimDropTarget, getActiveRule, setActiveRule } from './cb-drag.js';\nimport { CbGroupBase } from './cb-group-base.js';\nimport type { CbRuleRemoveDetail } from './cb-types.js';\nimport styles from './cb-rule.scss';\n\n/**\n * @label CB Rule\n * @tag wc-cb-rule\n * @rawTag cb-rule\n * @summary One condition row in a condition builder: a drag handle, the slotted field, operator and value controls, and a remove button.\n * @overview\n * <p>Drag the handle to reorder the rule, or to move it into another group. With the handle focused, ArrowUp and ArrowDown move the rule within its group.</p>\n * @tags condition-builder\n *\n * @cssprop --cb-rule-field-height - Height of the slotted fields (wc-select, wc-input…). Defaults to `2.5rem`.\n *\n * @fires {CustomEvent<{rule: CbRule, group: HTMLElement | null}>} rule-remove - Dispatched when the remove button is clicked. Cancelable: unless prevented, the rule removes itself.\n *\n * @example\n * ```html\n * <wc-cb-rule>\n * <wc-select placeholder=\"Field\"></wc-select>\n * <wc-select placeholder=\"Operator\"></wc-select>\n * <wc-input placeholder=\"Value\"></wc-input>\n * </wc-cb-rule>\n * ```\n */\n@IndividualComponent\nexport class CbRule extends LitElement {\n // ── Static ────────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Queries ───────────────────────────────────────────────────────────────\n\n @query('.handle')\n private readonly _handleEl?: HTMLElement;\n\n // ── Private methods ───────────────────────────────────────────────────────\n\n private _onDragStart(event: DragEvent) {\n const { dataTransfer } = event;\n if (dataTransfer) {\n dataTransfer.effectAllowed = 'move';\n // Firefox only starts a drag that carries data.\n dataTransfer.setData('text/plain', '');\n const rect = this.getBoundingClientRect();\n dataTransfer.setDragImage(\n this,\n event.clientX - rect.left,\n event.clientY - rect.top,\n );\n }\n setActiveRule(this);\n // Dim the row after the browser has captured the drag image.\n requestAnimationFrame(() =>\n this.toggleAttribute('dragging', getActiveRule() === this),\n );\n }\n\n private _onDragEnd() {\n setActiveRule(null);\n claimDropTarget(null);\n this.toggleAttribute('dragging', false);\n }\n\n private _onHandleKeyDown(event: KeyboardEvent) {\n const offsets: Record<string, number> = { ArrowUp: -1, ArrowDown: 1 };\n const offset = offsets[event.key];\n const group = this.parentElement;\n if (!offset || !(group instanceof CbGroupBase)) return;\n\n event.preventDefault();\n const index = group.items.indexOf(this) + offset;\n if (index >= 0 && group.moveRule(this, index)) {\n this._handleEl?.focus();\n }\n }\n\n private _onRemoveClick() {\n const event = new CustomEvent<CbRuleRemoveDetail>('rule-remove', {\n detail: { rule: this, group: this.parentElement },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (this.dispatchEvent(event)) this.remove();\n }\n\n // ── Render ────────────────────────────────────────────────────────────────\n\n render() {\n return html`\n <div class=\"rule\">\n <div\n class=\"handle\"\n role=\"button\"\n tabindex=\"0\"\n draggable=\"true\"\n aria-label=\"Reorder condition\"\n title=\"Drag to reorder\"\n @dragstart=${this._onDragStart}\n @dragend=${this._onDragEnd}\n @keydown=${this._onHandleKeyDown}\n >\n <wc-focus-ring></wc-focus-ring>\n <wc-icon name=\"drag_indicator\" aria-hidden=\"true\"></wc-icon>\n </div>\n <div class=\"content\">\n <slot></slot>\n </div>\n <div class=\"remove\">\n <wc-icon-button\n variant=\"text\"\n color=\"on-surface\"\n size=\"sm\"\n aria-label=\"Remove condition\"\n @click=${this._onRemoveClick}\n >\n <wc-icon name=\"delete\"></wc-icon>\n </wc-icon-button>\n </div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","styles","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQA,GAAU,CAAA;;AAY5B,IAAA,YAAY,CAAC,KAAgB,EAAA;AACnC,QAAA,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK;QAC9B,IAAI,YAAY,EAAE;AAChB,YAAA,YAAY,CAAC,aAAa,GAAG,MAAM;;AAEnC,YAAA,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACtC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,EAAE;YACzC,YAAY,CAAC,YAAY,CACvB,IAAI,EACJ,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,EACzB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CACzB;QACH;QACA,aAAa,CAAC,IAAI,CAAC;;AAEnB,QAAA,qBAAqB,CAAC,MACpB,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC,CAC3D;IACH;IAEQ,UAAU,GAAA;QAChB,aAAa,CAAC,IAAI,CAAC;QACnB,eAAe,CAAC,IAAI,CAAC;AACrB,QAAA,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC;IACzC;AAEQ,IAAA,gBAAgB,CAAC,KAAoB,EAAA;AAC3C,QAAA,MAAM,OAAO,GAA2B,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;QACrE,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;AACjC,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa;QAChC,IAAI,CAAC,MAAM,IAAI,EAAE,KAAK,YAAY,WAAW,CAAC;YAAE;QAEhD,KAAK,CAAC,cAAc,EAAE;AACtB,QAAA,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM;AAChD,QAAA,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;AAC7C,YAAA,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE;QACzB;IACF;IAEQ,cAAc,GAAA;AACpB,QAAA,MAAM,KAAK,GAAG,IAAI,WAAW,CAAqB,aAAa,EAAE;YAC/D,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE;AACjD,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,UAAU,EAAE,IAAI;AACjB,SAAA,CAAC;AACF,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,MAAM,EAAE;IAC9C;;IAIA,MAAM,GAAA;AACJ,QAAA,OAAOC,CAAI,CAAA;;;;;;;;;AASQ,qBAAA,EAAA,IAAI,CAAC,YAAY;AACnB,mBAAA,EAAA,IAAI,CAAC,UAAU;AACf,mBAAA,EAAA,IAAI,CAAC,gBAAgB;;;;;;;;;;;;;;AAcrB,mBAAA,EAAA,IAAI,CAAC,cAAc;;;;;;KAMnC;IACH;;AA/FA;AAEO,MAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAKP,UAAA,CAAA;IADhBC,CAAK,CAAC,SAAS;AACyB,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAR9B,MAAM,GAAA,UAAA,CAAA;IADlB;AACY,CAAA,EAAA,MAAM,CAiGlB;;;;"}
|
|
@@ -1,60 +1,115 @@
|
|
|
1
|
-
import { i, _ as __decorate, I as IndividualComponent,
|
|
1
|
+
import { i, _ as __decorate, I as IndividualComponent, b } from './IndividualComponent-Bdwyrvd6.js';
|
|
2
|
+
import { C as CbGroupBase } from './cb-group-base-DsX_2aFl.js';
|
|
3
|
+
import { c as css_248z$1 } from './cb-group-base-D9gv7SDY.js';
|
|
4
|
+
import './property-B49QQ8pS.js';
|
|
5
|
+
import './state-DkTK9EGF.js';
|
|
6
|
+
import './query-CHb9Ft_d.js';
|
|
7
|
+
import './base-Cl6v8-BZ.js';
|
|
8
|
+
import './class-map-DG7CA1et.js';
|
|
9
|
+
import './directive-ZPhl09Yt.js';
|
|
10
|
+
import './style-map-BQD5Et1D.js';
|
|
2
11
|
|
|
3
|
-
var css_248z = i
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
[hidden] {
|
|
13
|
-
display: none !important;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
:host {
|
|
17
|
-
display: block;
|
|
12
|
+
var css_248z = i`.footer {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
gap: var(--spacing-100);
|
|
18
|
+
padding-top: var(--spacing-200);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
.
|
|
21
|
+
.actions,
|
|
22
|
+
.actions-end {
|
|
21
23
|
display: flex;
|
|
22
|
-
flex-
|
|
23
|
-
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--spacing-100);
|
|
24
27
|
}`;
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* @label Condition Builder
|
|
28
31
|
* @tag wc-condition-builder
|
|
29
32
|
* @rawTag condition-builder
|
|
30
|
-
* @summary A
|
|
33
|
+
* @summary A query builder for composing filter conditions from rules and nested groups joined by And/Or.
|
|
34
|
+
* @overview
|
|
35
|
+
* <p>The condition builder is the root group of a query. It holds rules (<code>wc-cb-rule</code>) and bordered nested groups (<code>wc-cb-group</code>), each joined by a bracket with an And/Or pill.</p>
|
|
36
|
+
* <ul>
|
|
37
|
+
* <li>Click the pill to switch a group between And and Or.</li>
|
|
38
|
+
* <li>Drag a rule by its handle to reorder it or move it between groups.</li>
|
|
39
|
+
* <li>Removing, moving and switching are built in; adding rules and groups is up to you, since only you know what a new rule contains. Listen for <code>add-rule</code> and <code>add-group</code>.</li>
|
|
40
|
+
* </ul>
|
|
31
41
|
* @tags condition-builder
|
|
32
42
|
*
|
|
43
|
+
* @fires {CustomEvent<{operator: 'and' | 'or'}>} operator-change - Dispatched when the user picks a different operator, on this or a nested group.
|
|
44
|
+
* @fires {CustomEvent<{rule: CbRule, from: HTMLElement | null, to: HTMLElement, index: number}>} rule-move - Dispatched before a rule is moved. Cancelable: unless prevented, the target group moves the rule.
|
|
45
|
+
* @fires {CustomEvent<{rule: CbRule, group: HTMLElement | null}>} rule-remove - Dispatched when a rule's remove button is clicked. Cancelable: unless prevented, the rule removes itself.
|
|
46
|
+
* @fires {CustomEvent<{group: HTMLElement}>} add-rule - Dispatched when "Add rule" (or a nested group's "Add condition") is clicked.
|
|
47
|
+
* @fires {CustomEvent<{group: HTMLElement}>} add-group - Dispatched when "Add inner group" is clicked.
|
|
48
|
+
*
|
|
49
|
+
* @slot - Rules (`wc-cb-rule`) and groups (`wc-cb-group`).
|
|
50
|
+
* @slot actions - Replaces the default "Add rule" and "Add inner group" buttons.
|
|
51
|
+
* @slot actions-end - Actions aligned to the end of the footer, such as a "Run query" button.
|
|
52
|
+
*
|
|
33
53
|
* @example
|
|
34
54
|
* ```html
|
|
35
|
-
* <wc-condition-builder>
|
|
36
|
-
* <wc-cb-
|
|
37
|
-
* <wc-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
55
|
+
* <wc-condition-builder operator="and">
|
|
56
|
+
* <wc-cb-rule>
|
|
57
|
+
* <wc-input placeholder="Value"></wc-input>
|
|
58
|
+
* </wc-cb-rule>
|
|
59
|
+
* <wc-cb-group operator="or">
|
|
60
|
+
* <wc-cb-rule>
|
|
61
|
+
* <wc-input placeholder="Value"></wc-input>
|
|
62
|
+
* </wc-cb-rule>
|
|
63
|
+
* <wc-cb-rule>
|
|
64
|
+
* <wc-input placeholder="Value"></wc-input>
|
|
65
|
+
* </wc-cb-rule>
|
|
66
|
+
* </wc-cb-group>
|
|
67
|
+
* <wc-button slot="actions-end">Run query</wc-button>
|
|
45
68
|
* </wc-condition-builder>
|
|
46
69
|
* ```
|
|
47
70
|
*/
|
|
48
|
-
let ConditionBuilder = class ConditionBuilder extends
|
|
49
|
-
|
|
71
|
+
let ConditionBuilder = class ConditionBuilder extends CbGroupBase {
|
|
72
|
+
// ── Private methods ───────────────────────────────────────────────────────
|
|
73
|
+
_dispatchAdd(type) {
|
|
74
|
+
this.dispatchEvent(new CustomEvent(type, {
|
|
75
|
+
detail: { group: this },
|
|
76
|
+
bubbles: true,
|
|
77
|
+
composed: true,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
// ── Render helpers ────────────────────────────────────────────────────────
|
|
81
|
+
renderFooter() {
|
|
50
82
|
return b `
|
|
51
|
-
<div class="
|
|
52
|
-
<
|
|
83
|
+
<div class="footer">
|
|
84
|
+
<div class="actions">
|
|
85
|
+
<slot name="actions">
|
|
86
|
+
<wc-button
|
|
87
|
+
variant="outlined"
|
|
88
|
+
size="sm"
|
|
89
|
+
@click=${() => this._dispatchAdd('add-rule')}
|
|
90
|
+
>
|
|
91
|
+
<wc-icon slot="icon" name="add_circle"></wc-icon>
|
|
92
|
+
Add rule
|
|
93
|
+
</wc-button>
|
|
94
|
+
<wc-button
|
|
95
|
+
variant="text"
|
|
96
|
+
size="sm"
|
|
97
|
+
@click=${() => this._dispatchAdd('add-group')}
|
|
98
|
+
>
|
|
99
|
+
<wc-icon slot="icon" name="create_new_folder"></wc-icon>
|
|
100
|
+
Add inner group
|
|
101
|
+
</wc-button>
|
|
102
|
+
</slot>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="actions-end">
|
|
105
|
+
<slot name="actions-end"></slot>
|
|
106
|
+
</div>
|
|
53
107
|
</div>
|
|
54
108
|
`;
|
|
55
109
|
}
|
|
56
110
|
};
|
|
57
|
-
|
|
111
|
+
// ── Static ────────────────────────────────────────────────────────────────
|
|
112
|
+
ConditionBuilder.styles = [css_248z$1, css_248z];
|
|
58
113
|
ConditionBuilder = __decorate([
|
|
59
114
|
IndividualComponent
|
|
60
115
|
], ConditionBuilder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-builder.js","sources":["../../src/condition-builder/condition-builder.ts"],"sourcesContent":["import { html
|
|
1
|
+
{"version":3,"file":"condition-builder.js","sources":["../../src/condition-builder/condition-builder.ts"],"sourcesContent":["import { html } from 'lit';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { CbGroupBase } from './cb-group-base.js';\nimport baseStyles from './cb-group-base.scss';\nimport styles from './condition-builder.scss';\n\n/**\n * @label Condition Builder\n * @tag wc-condition-builder\n * @rawTag condition-builder\n * @summary A query builder for composing filter conditions from rules and nested groups joined by And/Or.\n * @overview\n * <p>The condition builder is the root group of a query. It holds rules (<code>wc-cb-rule</code>) and bordered nested groups (<code>wc-cb-group</code>), each joined by a bracket with an And/Or pill.</p>\n * <ul>\n * <li>Click the pill to switch a group between And and Or.</li>\n * <li>Drag a rule by its handle to reorder it or move it between groups.</li>\n * <li>Removing, moving and switching are built in; adding rules and groups is up to you, since only you know what a new rule contains. Listen for <code>add-rule</code> and <code>add-group</code>.</li>\n * </ul>\n * @tags condition-builder\n *\n * @fires {CustomEvent<{operator: 'and' | 'or'}>} operator-change - Dispatched when the user picks a different operator, on this or a nested group.\n * @fires {CustomEvent<{rule: CbRule, from: HTMLElement | null, to: HTMLElement, index: number}>} rule-move - Dispatched before a rule is moved. Cancelable: unless prevented, the target group moves the rule.\n * @fires {CustomEvent<{rule: CbRule, group: HTMLElement | null}>} rule-remove - Dispatched when a rule's remove button is clicked. Cancelable: unless prevented, the rule removes itself.\n * @fires {CustomEvent<{group: HTMLElement}>} add-rule - Dispatched when \"Add rule\" (or a nested group's \"Add condition\") is clicked.\n * @fires {CustomEvent<{group: HTMLElement}>} add-group - Dispatched when \"Add inner group\" is clicked.\n *\n * @slot - Rules (`wc-cb-rule`) and groups (`wc-cb-group`).\n * @slot actions - Replaces the default \"Add rule\" and \"Add inner group\" buttons.\n * @slot actions-end - Actions aligned to the end of the footer, such as a \"Run query\" button.\n *\n * @example\n * ```html\n * <wc-condition-builder operator=\"and\">\n * <wc-cb-rule>\n * <wc-input placeholder=\"Value\"></wc-input>\n * </wc-cb-rule>\n * <wc-cb-group operator=\"or\">\n * <wc-cb-rule>\n * <wc-input placeholder=\"Value\"></wc-input>\n * </wc-cb-rule>\n * <wc-cb-rule>\n * <wc-input placeholder=\"Value\"></wc-input>\n * </wc-cb-rule>\n * </wc-cb-group>\n * <wc-button slot=\"actions-end\">Run query</wc-button>\n * </wc-condition-builder>\n * ```\n */\n@IndividualComponent\nexport class ConditionBuilder extends CbGroupBase {\n // ── Static ────────────────────────────────────────────────────────────────\n\n static styles = [baseStyles, styles];\n\n // ── Private methods ───────────────────────────────────────────────────────\n\n private _dispatchAdd(type: 'add-rule' | 'add-group') {\n this.dispatchEvent(\n new CustomEvent<{ group: HTMLElement }>(type, {\n detail: { group: this },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // ── Render helpers ────────────────────────────────────────────────────────\n\n protected override renderFooter() {\n return html`\n <div class=\"footer\">\n <div class=\"actions\">\n <slot name=\"actions\">\n <wc-button\n variant=\"outlined\"\n size=\"sm\"\n @click=${() => this._dispatchAdd('add-rule')}\n >\n <wc-icon slot=\"icon\" name=\"add_circle\"></wc-icon>\n Add rule\n </wc-button>\n <wc-button\n variant=\"text\"\n size=\"sm\"\n @click=${() => this._dispatchAdd('add-group')}\n >\n <wc-icon slot=\"icon\" name=\"create_new_folder\"></wc-icon>\n Add inner group\n </wc-button>\n </slot>\n </div>\n <div class=\"actions-end\">\n <slot name=\"actions-end\"></slot>\n </div>\n </div>\n `;\n }\n}\n"],"names":["html","baseStyles","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,WAAW,CAAA;;AAOvC,IAAA,YAAY,CAAC,IAA8B,EAAA;AACjD,QAAA,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAyB,IAAI,EAAE;AAC5C,YAAA,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;AACvB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA,CAAC,CACH;IACH;;IAImB,YAAY,GAAA;AAC7B,QAAA,OAAOA,CAAI,CAAA;;;;;;;AAOQ,qBAAA,EAAA,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;;;;;;;;AAQnC,qBAAA,EAAA,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;;;;;;;;;;;KAWtD;IACH;;AA9CA;AAEO,gBAAA,CAAA,MAAM,GAAG,CAACC,UAAU,EAAEC,QAAM,CAAC;AAHzB,gBAAgB,GAAA,UAAA,CAAA;IAD5B;AACY,CAAA,EAAA,gBAAgB,CAgD5B;;;;"}
|